fix
This commit is contained in:
158
book/node_modules/honkit/lib/models/book.d.ts
generated
vendored
Normal file
158
book/node_modules/honkit/lib/models/book.d.ts
generated
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
import Immutable from "immutable";
|
||||
import FS from "./fs";
|
||||
import Config from "./config";
|
||||
import Readme from "./readme";
|
||||
import Summary from "./summary";
|
||||
import Glossary from "./glossary";
|
||||
import Languages from "./languages";
|
||||
import Ignore from "./ignore";
|
||||
declare const Book_base: Immutable.Record.Class;
|
||||
declare class Book extends Book_base {
|
||||
getLogger(): any;
|
||||
getFS(): FS;
|
||||
getIgnore(): Ignore;
|
||||
getConfig(): Config;
|
||||
getReadme(): Readme;
|
||||
getSummary(): Summary;
|
||||
getGlossary(): Glossary;
|
||||
getLanguages(): Languages;
|
||||
getBooks(): any;
|
||||
getLanguage(): any;
|
||||
/**
|
||||
Return FS instance to access the content
|
||||
|
||||
@return {FS}
|
||||
*/
|
||||
getContentFS(): FS;
|
||||
/**
|
||||
Return root of the book
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot(): string;
|
||||
/**
|
||||
Return root for content of the book
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getContentRoot(): string;
|
||||
/**
|
||||
Check if a file is ignore (should not being parsed, etc)
|
||||
|
||||
@param {string} ref
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
isFileIgnored(filename: any): boolean;
|
||||
/**
|
||||
Check if a content file is ignore (should not being parsed, etc)
|
||||
|
||||
@param {string} ref
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
isContentFileIgnored(filename: any): boolean;
|
||||
/**
|
||||
Is this book the parent of language's books
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
isMultilingual(): boolean;
|
||||
/**
|
||||
Return true if book is associated to a language
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
isLanguageBook(): boolean;
|
||||
/**
|
||||
Return a languages book
|
||||
|
||||
@param {string} language
|
||||
@return {Book}
|
||||
*/
|
||||
getLanguageBook(language: any): any;
|
||||
/**
|
||||
Add a new language book
|
||||
|
||||
@param {string} language
|
||||
@param {Book} book
|
||||
@return {Book}
|
||||
*/
|
||||
addLanguageBook(language: any, book: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
Set the summary for this book
|
||||
|
||||
@param {Summary}
|
||||
@return {Book}
|
||||
*/
|
||||
setSummary(summary: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
Set the readme for this book
|
||||
|
||||
@param {Readme}
|
||||
@return {Book}
|
||||
*/
|
||||
setReadme(readme: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
Set the configuration for this book
|
||||
|
||||
@param {Config}
|
||||
@return {Book}
|
||||
*/
|
||||
setConfig(config: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
Set the ignore instance for this book
|
||||
|
||||
@param {Ignore}
|
||||
@return {Book}
|
||||
*/
|
||||
setIgnore(ignore: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
Change log level
|
||||
|
||||
@param {string} level
|
||||
@return {Book}
|
||||
*/
|
||||
setLogLevel(level: any): this;
|
||||
/**
|
||||
Create a book using a filesystem
|
||||
|
||||
@param {FS} fs
|
||||
@return {Book}
|
||||
*/
|
||||
static createForFS(fs: any): Book;
|
||||
/**
|
||||
Infers the default extension for files
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultExt(): any;
|
||||
/**
|
||||
Infer the default path for a Readme.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultReadmePath(absolute: any): string;
|
||||
/**
|
||||
Infer the default path for a Summary.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultSummaryPath(absolute: any): string;
|
||||
/**
|
||||
Infer the default path for a Glossary.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultGlossaryPath(absolute: any): string;
|
||||
/**
|
||||
Create a language book from a parent
|
||||
|
||||
@param {Book} parent
|
||||
@param {string} language
|
||||
@return {Book}
|
||||
*/
|
||||
static createFromParent(parent: any, language: any): Book;
|
||||
}
|
||||
export default Book;
|
||||
//# sourceMappingURL=book.d.ts.map
|
1
book/node_modules/honkit/lib/models/book.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/book.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../src/models/book.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;;AAE9B,cAAM,IAAK,SAAQ,SAwBjB;IACE,SAAS;IAIT,KAAK,IAAI,EAAE;IAIX,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAInB,UAAU,IAAI,OAAO;IAIrB,WAAW,IAAI,QAAQ;IAIvB,YAAY,IAAI,SAAS;IAIzB,QAAQ;IAIR,WAAW;IAIX;;;;OAIG;IACH,YAAY,IAAI,EAAE;IAYlB;;;;OAIG;IACH,OAAO;IAKP;;;;OAIG;IACH,cAAc;IAKd;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,KAAA;IAYtB;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,KAAA;IAW7B;;;;OAIG;IACH,cAAc;IAId;;;;OAIG;IACH,cAAc;IAId;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,KAAA;IAKxB;;;;;;OAMG;IACH,eAAe,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA;IAO9B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,KAAA;IAIlB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,KAAA;IAIhB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,KAAA;IAIhB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,KAAA;IAIhB;;;;;OAKG;IACH,WAAW,CAAC,KAAK,KAAA;IAKjB;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,KAAA;IAMrB;;;OAGG;IACH,aAAa;IAsBb;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,KAAA;IAS7B;;;;;OAKG;IACH,qBAAqB,CAAC,QAAQ,KAAA;IAS9B;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,KAAA;IAS/B;;;;;;OAMG;IAEH,MAAM,CAAC,gBAAgB,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA;CAkB3C;AAED,eAAe,IAAI,CAAC"}
|
312
book/node_modules/honkit/lib/models/book.js
generated
vendored
Normal file
312
book/node_modules/honkit/lib/models/book.js
generated
vendored
Normal file
@ -0,0 +1,312 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const logger_1 = __importDefault(require("../utils/logger"));
|
||||
const fs_1 = __importDefault(require("./fs"));
|
||||
const config_1 = __importDefault(require("./config"));
|
||||
const readme_1 = __importDefault(require("./readme"));
|
||||
const summary_1 = __importDefault(require("./summary"));
|
||||
const glossary_1 = __importDefault(require("./glossary"));
|
||||
const languages_1 = __importDefault(require("./languages"));
|
||||
const ignore_1 = __importDefault(require("./ignore"));
|
||||
class Book extends immutable_1.default.Record({
|
||||
// Logger for outptut message
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 0.
|
||||
logger: (0, logger_1.default)(),
|
||||
// Filesystem binded to the book scope to read files/directories
|
||||
fs: new fs_1.default(),
|
||||
// Ignore files parser
|
||||
ignore: new ignore_1.default(),
|
||||
// Structure files
|
||||
config: new config_1.default(),
|
||||
readme: new readme_1.default(),
|
||||
summary: new summary_1.default(),
|
||||
glossary: new glossary_1.default(),
|
||||
languages: new languages_1.default(),
|
||||
// ID of the language for language books
|
||||
language: String(),
|
||||
// List of children, if multilingual (String -> Book)
|
||||
books: immutable_1.default.OrderedMap()
|
||||
}) {
|
||||
getLogger() {
|
||||
return this.get("logger");
|
||||
}
|
||||
getFS() {
|
||||
return this.get("fs");
|
||||
}
|
||||
getIgnore() {
|
||||
return this.get("ignore");
|
||||
}
|
||||
getConfig() {
|
||||
return this.get("config");
|
||||
}
|
||||
getReadme() {
|
||||
return this.get("readme");
|
||||
}
|
||||
getSummary() {
|
||||
return this.get("summary");
|
||||
}
|
||||
getGlossary() {
|
||||
return this.get("glossary");
|
||||
}
|
||||
getLanguages() {
|
||||
return this.get("languages");
|
||||
}
|
||||
getBooks() {
|
||||
return this.get("books");
|
||||
}
|
||||
getLanguage() {
|
||||
return this.get("language");
|
||||
}
|
||||
/**
|
||||
Return FS instance to access the content
|
||||
|
||||
@return {FS}
|
||||
*/
|
||||
getContentFS() {
|
||||
const fs = this.getFS();
|
||||
const config = this.getConfig();
|
||||
const rootFolder = config.getValue("root");
|
||||
if (rootFolder) {
|
||||
return fs_1.default.reduceScope(fs, rootFolder);
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
/**
|
||||
Return root of the book
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot() {
|
||||
const fs = this.getFS();
|
||||
return fs.getRoot();
|
||||
}
|
||||
/**
|
||||
Return root for content of the book
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getContentRoot() {
|
||||
const fs = this.getContentFS();
|
||||
return fs.getRoot();
|
||||
}
|
||||
/**
|
||||
Check if a file is ignore (should not being parsed, etc)
|
||||
|
||||
@param {string} ref
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
isFileIgnored(filename) {
|
||||
const ignore = this.getIgnore();
|
||||
const language = this.getLanguage();
|
||||
// Ignore is always relative to the root of the main book
|
||||
if (language) {
|
||||
filename = path_1.default.join(language, filename);
|
||||
}
|
||||
return ignore.isFileIgnored(filename);
|
||||
}
|
||||
/**
|
||||
Check if a content file is ignore (should not being parsed, etc)
|
||||
|
||||
@param {string} ref
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
isContentFileIgnored(filename) {
|
||||
const config = this.getConfig();
|
||||
const rootFolder = config.getValue("root");
|
||||
if (rootFolder) {
|
||||
filename = path_1.default.join(rootFolder, filename);
|
||||
}
|
||||
return this.isFileIgnored(filename);
|
||||
}
|
||||
/**
|
||||
Is this book the parent of language's books
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
isMultilingual() {
|
||||
return this.getLanguages().getCount() > 0;
|
||||
}
|
||||
/**
|
||||
Return true if book is associated to a language
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
isLanguageBook() {
|
||||
return Boolean(this.getLanguage());
|
||||
}
|
||||
/**
|
||||
Return a languages book
|
||||
|
||||
@param {string} language
|
||||
@return {Book}
|
||||
*/
|
||||
getLanguageBook(language) {
|
||||
const books = this.getBooks();
|
||||
return books.get(language);
|
||||
}
|
||||
/**
|
||||
Add a new language book
|
||||
|
||||
@param {string} language
|
||||
@param {Book} book
|
||||
@return {Book}
|
||||
*/
|
||||
addLanguageBook(language, book) {
|
||||
let books = this.getBooks();
|
||||
books = books.set(language, book);
|
||||
return this.set("books", books);
|
||||
}
|
||||
/**
|
||||
Set the summary for this book
|
||||
|
||||
@param {Summary}
|
||||
@return {Book}
|
||||
*/
|
||||
setSummary(summary) {
|
||||
return this.set("summary", summary);
|
||||
}
|
||||
/**
|
||||
Set the readme for this book
|
||||
|
||||
@param {Readme}
|
||||
@return {Book}
|
||||
*/
|
||||
setReadme(readme) {
|
||||
return this.set("readme", readme);
|
||||
}
|
||||
/**
|
||||
Set the configuration for this book
|
||||
|
||||
@param {Config}
|
||||
@return {Book}
|
||||
*/
|
||||
setConfig(config) {
|
||||
return this.set("config", config);
|
||||
}
|
||||
/**
|
||||
Set the ignore instance for this book
|
||||
|
||||
@param {Ignore}
|
||||
@return {Book}
|
||||
*/
|
||||
setIgnore(ignore) {
|
||||
return this.set("ignore", ignore);
|
||||
}
|
||||
/**
|
||||
Change log level
|
||||
|
||||
@param {string} level
|
||||
@return {Book}
|
||||
*/
|
||||
setLogLevel(level) {
|
||||
this.getLogger().setLevel(level);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
Create a book using a filesystem
|
||||
|
||||
@param {FS} fs
|
||||
@return {Book}
|
||||
*/
|
||||
static createForFS(fs) {
|
||||
return new Book({
|
||||
fs: fs
|
||||
});
|
||||
}
|
||||
/**
|
||||
Infers the default extension for files
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultExt() {
|
||||
// Inferring sources
|
||||
const clues = [this.getReadme(), this.getSummary(), this.getGlossary()];
|
||||
// List their extensions
|
||||
const exts = clues.map((clue) => {
|
||||
const file = clue.getFile();
|
||||
if (file.exists()) {
|
||||
return file.getParser().getExtensions().first();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
// Adds the general default extension
|
||||
exts.push(".md");
|
||||
// Choose the first non null
|
||||
return exts.find((e) => {
|
||||
return e !== null;
|
||||
});
|
||||
}
|
||||
/**
|
||||
Infer the default path for a Readme.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultReadmePath(absolute) {
|
||||
const defaultPath = `README${this.getDefaultExt()}`;
|
||||
if (absolute) {
|
||||
return path_1.default.join(this.getContentRoot(), defaultPath);
|
||||
}
|
||||
else {
|
||||
return defaultPath;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Infer the default path for a Summary.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultSummaryPath(absolute) {
|
||||
const defaultPath = `SUMMARY${this.getDefaultExt()}`;
|
||||
if (absolute) {
|
||||
return path_1.default.join(this.getContentRoot(), defaultPath);
|
||||
}
|
||||
else {
|
||||
return defaultPath;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Infer the default path for a Glossary.
|
||||
@param {boolean} [absolute=false] False for a path relative to
|
||||
this book's content root
|
||||
@return {string}
|
||||
*/
|
||||
getDefaultGlossaryPath(absolute) {
|
||||
const defaultPath = `GLOSSARY${this.getDefaultExt()}`;
|
||||
if (absolute) {
|
||||
return path_1.default.join(this.getContentRoot(), defaultPath);
|
||||
}
|
||||
else {
|
||||
return defaultPath;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Create a language book from a parent
|
||||
|
||||
@param {Book} parent
|
||||
@param {string} language
|
||||
@return {Book}
|
||||
*/
|
||||
static createFromParent(parent, language) {
|
||||
const ignore = parent.getIgnore();
|
||||
let config = parent.getConfig();
|
||||
// Set language in configuration
|
||||
config = config.setValue("language", language);
|
||||
return new Book({
|
||||
// Inherits config. logegr and list of ignored files
|
||||
logger: parent.getLogger(),
|
||||
config: config,
|
||||
ignore: ignore,
|
||||
language: language,
|
||||
fs: fs_1.default.reduceScope(parent.getContentFS(), language)
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Book;
|
82
book/node_modules/honkit/lib/models/config.d.ts
generated
vendored
Normal file
82
book/node_modules/honkit/lib/models/config.d.ts
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
import Immutable from "immutable";
|
||||
import PluginDependency from "./pluginDependency";
|
||||
declare const Config_base: Immutable.Record.Class;
|
||||
declare class Config extends Config_base {
|
||||
getFile(): any;
|
||||
getValues(): any;
|
||||
/**
|
||||
* Return minimum version of configuration,
|
||||
* Basically it returns the current config minus the default one
|
||||
* @return {Map}
|
||||
*/
|
||||
toReducedVersion(): any;
|
||||
/**
|
||||
* Render config as text
|
||||
* @return {Promise<String>}
|
||||
*/
|
||||
toText(): string;
|
||||
/**
|
||||
* Change the file for the configuration
|
||||
* @param {File} file
|
||||
* @return {Config}
|
||||
*/
|
||||
setFile(file: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
* Return a configuration value by its key path
|
||||
*/
|
||||
getValue(keyPath: string | string[], def?: any): any;
|
||||
/**
|
||||
* Update a configuration value
|
||||
* @return {Config}
|
||||
*/
|
||||
setValue(keyPath: string | string[], value: any): Config;
|
||||
/**
|
||||
* Return a list of plugin dependencies
|
||||
* @return {List<PluginDependency>}
|
||||
*/
|
||||
getPluginDependencies(): Immutable.Iterable<number, PluginDependency>;
|
||||
/**
|
||||
* Return a plugin dependency by its name
|
||||
* @param {string} name
|
||||
* @return {PluginDependency}
|
||||
*/
|
||||
getPluginDependency(name: string): PluginDependency;
|
||||
/**
|
||||
* Update the list of plugins dependencies
|
||||
* @param {List<PluginDependency>}
|
||||
* @return {Config}
|
||||
*/
|
||||
setPluginDependencies(deps: any): Config;
|
||||
/**
|
||||
* Update values for an existing configuration
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
updateValues(values: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
* Update values for an existing configuration
|
||||
* @param {Config} config
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
mergeValues(values: any): Immutable.Map<string, any>;
|
||||
/**
|
||||
* Create a new config for a file
|
||||
* @param {File} file
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
static create(file: any, values: any): Config;
|
||||
/**
|
||||
* Create a new config
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
static createWithValues(values: any): Config;
|
||||
/**
|
||||
* Convert a keyPath to an array of keys
|
||||
*/
|
||||
static keyToKeyPath(keyPath: string | string[]): string[];
|
||||
}
|
||||
export default Config;
|
||||
//# sourceMappingURL=config.d.ts.map
|
1
book/node_modules/honkit/lib/models/config.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/config.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;;AAIlD,cAAM,MAAO,SAAQ,WAMpB;IACG,OAAO;IAIP,SAAS;IAIT;;;;OAIG;IACH,gBAAgB;IAIhB;;;OAGG;IACH,MAAM;IAIN;;;;OAIG;IACH,OAAO,CAAC,IAAI,KAAA;IAIZ;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG;IAW9C;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM;IAWxD;;;OAGG;IACH,qBAAqB;IASrB;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM;IAQhC;;;;OAIG;IACH,qBAAqB,CAAC,IAAI,KAAA;IAM1B;;;;OAIG;IACH,YAAY,CAAC,MAAM,KAAA;IAMnB;;;;;OAKG;IACH,WAAW,CAAC,MAAM,KAAA;IASlB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA;IAO1B;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,KAAA;IAM9B;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;CAMjD;AAED,eAAe,MAAM,CAAC"}
|
152
book/node_modules/honkit/lib/models/config.js
generated
vendored
Normal file
152
book/node_modules/honkit/lib/models/config.js
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const pluginDependency_1 = __importDefault(require("./pluginDependency"));
|
||||
const configDefault_1 = __importDefault(require("../constants/configDefault"));
|
||||
const reducedObject_1 = __importDefault(require("../utils/reducedObject"));
|
||||
class Config extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
values: configDefault_1.default
|
||||
}, "Config") {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getValues() {
|
||||
return this.get("values");
|
||||
}
|
||||
/**
|
||||
* Return minimum version of configuration,
|
||||
* Basically it returns the current config minus the default one
|
||||
* @return {Map}
|
||||
*/
|
||||
toReducedVersion() {
|
||||
return (0, reducedObject_1.default)(configDefault_1.default, this.getValues());
|
||||
}
|
||||
/**
|
||||
* Render config as text
|
||||
* @return {Promise<String>}
|
||||
*/
|
||||
toText() {
|
||||
return JSON.stringify(this.toReducedVersion().toJS(), null, 4);
|
||||
}
|
||||
/**
|
||||
* Change the file for the configuration
|
||||
* @param {File} file
|
||||
* @return {Config}
|
||||
*/
|
||||
setFile(file) {
|
||||
return this.set("file", file);
|
||||
}
|
||||
/**
|
||||
* Return a configuration value by its key path
|
||||
*/
|
||||
getValue(keyPath, def) {
|
||||
const values = this.getValues();
|
||||
keyPath = Config.keyToKeyPath(keyPath);
|
||||
if (!values.hasIn(keyPath)) {
|
||||
return immutable_1.default.fromJS(def);
|
||||
}
|
||||
return values.getIn(keyPath);
|
||||
}
|
||||
/**
|
||||
* Update a configuration value
|
||||
* @return {Config}
|
||||
*/
|
||||
setValue(keyPath, value) {
|
||||
keyPath = Config.keyToKeyPath(keyPath);
|
||||
value = immutable_1.default.fromJS(value);
|
||||
let values = this.getValues();
|
||||
values = values.setIn(keyPath, value);
|
||||
return this.set("values", values);
|
||||
}
|
||||
/**
|
||||
* Return a list of plugin dependencies
|
||||
* @return {List<PluginDependency>}
|
||||
*/
|
||||
getPluginDependencies() {
|
||||
const plugins = this.getValue("plugins");
|
||||
if (typeof plugins === "string") {
|
||||
return pluginDependency_1.default.listFromString(plugins);
|
||||
}
|
||||
else {
|
||||
return pluginDependency_1.default.listFromArray(plugins);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return a plugin dependency by its name
|
||||
* @param {string} name
|
||||
* @return {PluginDependency}
|
||||
*/
|
||||
getPluginDependency(name) {
|
||||
const plugins = this.getPluginDependencies();
|
||||
return plugins.find((dep) => {
|
||||
return dep.getName() === name;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Update the list of plugins dependencies
|
||||
* @param {List<PluginDependency>}
|
||||
* @return {Config}
|
||||
*/
|
||||
setPluginDependencies(deps) {
|
||||
const plugins = pluginDependency_1.default.listToArray(deps);
|
||||
return this.setValue("plugins", plugins);
|
||||
}
|
||||
/**
|
||||
* Update values for an existing configuration
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
updateValues(values) {
|
||||
values = immutable_1.default.fromJS(values);
|
||||
return this.set("values", values);
|
||||
}
|
||||
/**
|
||||
* Update values for an existing configuration
|
||||
* @param {Config} config
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
mergeValues(values) {
|
||||
let currentValues = this.getValues();
|
||||
values = immutable_1.default.fromJS(values);
|
||||
currentValues = currentValues.mergeDeep(values);
|
||||
return this.set("values", currentValues);
|
||||
}
|
||||
/**
|
||||
* Create a new config for a file
|
||||
* @param {File} file
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
static create(file, values) {
|
||||
return new Config({
|
||||
file: file,
|
||||
values: immutable_1.default.fromJS(values)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a new config
|
||||
* @param {Object} values
|
||||
* @returns {Config}
|
||||
*/
|
||||
static createWithValues(values) {
|
||||
return new Config({
|
||||
values: immutable_1.default.fromJS(values)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Convert a keyPath to an array of keys
|
||||
*/
|
||||
static keyToKeyPath(keyPath) {
|
||||
if (typeof keyPath === "string") {
|
||||
return keyPath.split(".");
|
||||
}
|
||||
return keyPath;
|
||||
}
|
||||
}
|
||||
exports.default = Config;
|
53
book/node_modules/honkit/lib/models/file.d.ts
generated
vendored
Normal file
53
book/node_modules/honkit/lib/models/file.d.ts
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import fs from "fs";
|
||||
import Immutable from "immutable";
|
||||
import Parser from "./parser";
|
||||
declare const File_base: Immutable.Record.Class;
|
||||
declare class File extends File_base {
|
||||
getPath(): string;
|
||||
getMTime(): Date;
|
||||
/**
|
||||
Does the file exists / is set
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
exists(): boolean;
|
||||
/**
|
||||
Return type of file ('markdown' or 'asciidoc')
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getType(): string;
|
||||
/**
|
||||
Return extension of this file (lowercased)
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getExtension(): string;
|
||||
/**
|
||||
Return parser for this file
|
||||
|
||||
@return {Parsers}
|
||||
*/
|
||||
getParser(): Parser;
|
||||
/**
|
||||
Return basedirectory of this file
|
||||
@return {string}
|
||||
*/
|
||||
getBaseDirectory(): string;
|
||||
/**
|
||||
Create a file from stats informations
|
||||
|
||||
@param {string} filepath
|
||||
@param {Object|fs.Stats} stat
|
||||
@return {File}
|
||||
*/
|
||||
static createFromStat(filepath: string, stat: fs.Stats): File;
|
||||
/**
|
||||
Create a file with only a path
|
||||
@param {string} filepath
|
||||
@return {File}
|
||||
*/
|
||||
static createWithFilepath(filepath: string): File;
|
||||
}
|
||||
export default File;
|
||||
//# sourceMappingURL=file.d.ts.map
|
1
book/node_modules/honkit/lib/models/file.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/file.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/models/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,MAAM,MAAM,UAAU,CAAC;;AAE9B,cAAM,IAAK,SAAQ,SAMjB;IACE,OAAO,IAAI,MAAM;IAIjB,QAAQ,IAAI,IAAI;IAIhB;;;;OAIG;IAEH,MAAM,IAAI,OAAO;IAIjB;;;;OAIG;IACH,OAAO,IAAI,MAAM;IASjB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB;;;;OAIG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI;IAO7D;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAKpD;AAED,eAAe,IAAI,CAAC"}
|
90
book/node_modules/honkit/lib/models/file.js
generated
vendored
Normal file
90
book/node_modules/honkit/lib/models/file.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const parsers_1 = __importDefault(require("../parsers"));
|
||||
class File extends immutable_1.default.Record({
|
||||
// Path of the file, relative to the FS
|
||||
path: String(),
|
||||
// Time when file data last modified
|
||||
mtime: Date()
|
||||
}) {
|
||||
getPath() {
|
||||
return this.get("path");
|
||||
}
|
||||
getMTime() {
|
||||
return this.get("mtime");
|
||||
}
|
||||
/**
|
||||
Does the file exists / is set
|
||||
|
||||
@return {boolean}
|
||||
*/
|
||||
exists() {
|
||||
return Boolean(this.getPath());
|
||||
}
|
||||
/**
|
||||
Return type of file ('markdown' or 'asciidoc')
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getType() {
|
||||
const parser = this.getParser();
|
||||
if (parser) {
|
||||
return parser.getName();
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Return extension of this file (lowercased)
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getExtension() {
|
||||
return path_1.default.extname(this.getPath()).toLowerCase();
|
||||
}
|
||||
/**
|
||||
Return parser for this file
|
||||
|
||||
@return {Parsers}
|
||||
*/
|
||||
getParser() {
|
||||
return parsers_1.default.getByExt(this.getExtension());
|
||||
}
|
||||
/**
|
||||
Return basedirectory of this file
|
||||
@return {string}
|
||||
*/
|
||||
getBaseDirectory() {
|
||||
return path_1.default.dirname(this.getPath());
|
||||
}
|
||||
/**
|
||||
Create a file from stats informations
|
||||
|
||||
@param {string} filepath
|
||||
@param {Object|fs.Stats} stat
|
||||
@return {File}
|
||||
*/
|
||||
static createFromStat(filepath, stat) {
|
||||
return new File({
|
||||
path: filepath,
|
||||
mtime: stat.mtime
|
||||
});
|
||||
}
|
||||
/**
|
||||
Create a file with only a path
|
||||
@param {string} filepath
|
||||
@return {File}
|
||||
*/
|
||||
static createWithFilepath(filepath) {
|
||||
return new File({
|
||||
path: filepath
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = File;
|
115
book/node_modules/honkit/lib/models/fs.d.ts
generated
vendored
Normal file
115
book/node_modules/honkit/lib/models/fs.d.ts
generated
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
import Promise from "../utils/promise";
|
||||
declare const FS_base: Immutable.Record.Class;
|
||||
declare class FS extends FS_base {
|
||||
/**
|
||||
Return path to the root
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot(): string;
|
||||
/**
|
||||
Verify that a file is in the fs scope
|
||||
|
||||
@param {string} filename
|
||||
@return {boolean}
|
||||
*/
|
||||
isInScope(filename: string): boolean;
|
||||
/**
|
||||
Resolve a file in this FS
|
||||
@return {string}
|
||||
*/
|
||||
resolve(...args: string[]): string;
|
||||
/**
|
||||
Check if a file exists, run a Promise(true) if that's the case, Promise(false) otherwise
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Boolean>}
|
||||
*/
|
||||
exists(filename: string): Promise<boolean>;
|
||||
/**
|
||||
Read a file and returns a promise with the content as a buffer
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Buffer>}
|
||||
*/
|
||||
read(filename: string): Promise<Buffer>;
|
||||
/**
|
||||
Read a file as a string (utf-8)
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
readAsString(filename: string, encoding?: string): Promise<string>;
|
||||
/**
|
||||
Read file as a stream
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Stream>}
|
||||
*/
|
||||
readAsStream(filename: string): any;
|
||||
/**
|
||||
Read stat infos about a file
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<File>}
|
||||
*/
|
||||
statFile(filename: string): Promise<File>;
|
||||
/**
|
||||
List files/directories in a directory.
|
||||
Directories ends with '/'
|
||||
|
||||
@param {string} dirname
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
readDir(dirname: string): any;
|
||||
/**
|
||||
List only files in a diretcory
|
||||
Directories ends with '/'
|
||||
|
||||
@param {string} dirname
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
listFiles(dirname: string): any;
|
||||
/**
|
||||
List all files in a directory
|
||||
|
||||
@param {string} dirName
|
||||
@param {Function(dirName)} filterFn: call it for each file/directory to test if it should stop iterating
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
listAllFiles(dirName: string, filterFn: (arg0: string) => boolean): any;
|
||||
/**
|
||||
Find a file in a folder (case insensitive)
|
||||
Return the found filename
|
||||
|
||||
@param {string} dirname
|
||||
@param {string} filename
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
findFile(dirname: string, filename: string): any;
|
||||
/**
|
||||
Load a JSON file
|
||||
By default, fs only supports JSON
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Object>}
|
||||
*/
|
||||
loadAsObject(filename: string): any;
|
||||
/**
|
||||
Create a FS instance
|
||||
|
||||
@param {Object} def
|
||||
@return {FS}
|
||||
*/
|
||||
static create(def: any): FS;
|
||||
/**
|
||||
Create a new FS instance with a reduced scope
|
||||
|
||||
@param {FS} fs
|
||||
@param {string} scope
|
||||
@return {FS}
|
||||
*/
|
||||
static reduceScope(fs: FS, scope: string): FS;
|
||||
}
|
||||
export default FS;
|
||||
//# sourceMappingURL=fs.d.ts.map
|
1
book/node_modules/honkit/lib/models/fs.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/fs.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/models/fs.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,kBAAkB,CAAC;;AAIvC,cAAM,EAAG,SAAQ,OAUf;IACE;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAOpC;;;OAGG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAelC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW1C;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWvC;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAM1E;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM;IAiB7B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAezC;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM;IAevB;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM;IAMzB;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;IA4BjE;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAQ1C;;;;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM;IAwB7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,KAAA;IAIjB;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE;CAGhD;AAQD,eAAe,EAAE,CAAC"}
|
255
book/node_modules/honkit/lib/models/fs.js
generated
vendored
Normal file
255
book/node_modules/honkit/lib/models/fs.js
generated
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const stream_1 = __importDefault(require("stream"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const promise_1 = __importDefault(require("../utils/promise"));
|
||||
const error_1 = __importDefault(require("../utils/error"));
|
||||
const path_2 = __importDefault(require("../utils/path"));
|
||||
class FS extends immutable_1.default.Record({
|
||||
root: String(),
|
||||
fsExists: Function(),
|
||||
fsReadFile: Function(),
|
||||
fsStatFile: Function(),
|
||||
fsReadDir: Function(),
|
||||
fsLoadObject: null,
|
||||
fsReadAsStream: null
|
||||
}) {
|
||||
/**
|
||||
Return path to the root
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot() {
|
||||
return this.get("root");
|
||||
}
|
||||
/**
|
||||
Verify that a file is in the fs scope
|
||||
|
||||
@param {string} filename
|
||||
@return {boolean}
|
||||
*/
|
||||
isInScope(filename) {
|
||||
const rootPath = this.getRoot();
|
||||
filename = path_1.default.join(rootPath, filename);
|
||||
return path_2.default.isInRoot(rootPath, filename);
|
||||
}
|
||||
/**
|
||||
Resolve a file in this FS
|
||||
@return {string}
|
||||
*/
|
||||
resolve(...args) {
|
||||
const rootPath = this.getRoot();
|
||||
let filename = path_1.default.join.apply(path_1.default, [rootPath].concat(args));
|
||||
filename = path_1.default.normalize(filename);
|
||||
if (!this.isInScope(filename)) {
|
||||
throw error_1.default.FileOutOfScopeError({
|
||||
filename: filename,
|
||||
root: rootPath
|
||||
});
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
/**
|
||||
Check if a file exists, run a Promise(true) if that's the case, Promise(false) otherwise
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Boolean>}
|
||||
*/
|
||||
exists(filename) {
|
||||
const that = this;
|
||||
return (0, promise_1.default)().then(() => {
|
||||
filename = that.resolve(filename);
|
||||
const exists = that.get("fsExists");
|
||||
return exists(filename);
|
||||
});
|
||||
}
|
||||
/**
|
||||
Read a file and returns a promise with the content as a buffer
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Buffer>}
|
||||
*/
|
||||
read(filename) {
|
||||
const that = this;
|
||||
return (0, promise_1.default)().then(() => {
|
||||
filename = that.resolve(filename);
|
||||
const read = that.get("fsReadFile");
|
||||
return read(filename);
|
||||
});
|
||||
}
|
||||
/**
|
||||
Read a file as a string (utf-8)
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
readAsString(filename, encoding = "utf8") {
|
||||
return this.read(filename).then((buf) => {
|
||||
return buf.toString(encoding);
|
||||
});
|
||||
}
|
||||
/**
|
||||
Read file as a stream
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Stream>}
|
||||
*/
|
||||
readAsStream(filename) {
|
||||
const that = this;
|
||||
const filepath = that.resolve(filename);
|
||||
const fsReadAsStream = this.get("fsReadAsStream");
|
||||
if (fsReadAsStream) {
|
||||
return (0, promise_1.default)(fsReadAsStream(filepath));
|
||||
}
|
||||
return this.read(filename).then((buf) => {
|
||||
const bufferStream = new stream_1.default.PassThrough();
|
||||
bufferStream.end(buf);
|
||||
return bufferStream;
|
||||
});
|
||||
}
|
||||
/**
|
||||
Read stat infos about a file
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<File>}
|
||||
*/
|
||||
statFile(filename) {
|
||||
const that = this;
|
||||
return (0, promise_1.default)()
|
||||
.then(() => {
|
||||
const filepath = that.resolve(filename);
|
||||
const stat = that.get("fsStatFile");
|
||||
return stat(filepath);
|
||||
})
|
||||
.then((stat) => {
|
||||
return file_1.default.createFromStat(filename, stat);
|
||||
});
|
||||
}
|
||||
/**
|
||||
List files/directories in a directory.
|
||||
Directories ends with '/'
|
||||
|
||||
@param {string} dirname
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
readDir(dirname) {
|
||||
const that = this;
|
||||
return (0, promise_1.default)()
|
||||
.then(() => {
|
||||
const dirpath = that.resolve(dirname);
|
||||
const readDir = that.get("fsReadDir");
|
||||
return readDir(dirpath);
|
||||
})
|
||||
.then((files) => {
|
||||
return immutable_1.default.List(files);
|
||||
});
|
||||
}
|
||||
/**
|
||||
List only files in a diretcory
|
||||
Directories ends with '/'
|
||||
|
||||
@param {string} dirname
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
listFiles(dirname) {
|
||||
return this.readDir(dirname).then((files) => {
|
||||
return files.filterNot(pathIsFolder);
|
||||
});
|
||||
}
|
||||
/**
|
||||
List all files in a directory
|
||||
|
||||
@param {string} dirName
|
||||
@param {Function(dirName)} filterFn: call it for each file/directory to test if it should stop iterating
|
||||
@return {Promise<List<String>>}
|
||||
*/
|
||||
listAllFiles(dirName, filterFn) {
|
||||
const that = this;
|
||||
dirName = dirName || ".";
|
||||
return this.readDir(dirName).then((files) => {
|
||||
return promise_1.default.reduce(files, (out, file) => {
|
||||
const isDirectory = pathIsFolder(file);
|
||||
const newDirName = path_1.default.join(dirName, file);
|
||||
if (filterFn && filterFn(newDirName) === false) {
|
||||
return out;
|
||||
}
|
||||
if (!isDirectory) {
|
||||
return out.push(newDirName);
|
||||
}
|
||||
return that.listAllFiles(newDirName, filterFn).then((inner) => {
|
||||
return out.concat(inner);
|
||||
});
|
||||
}, immutable_1.default.List());
|
||||
});
|
||||
}
|
||||
/**
|
||||
Find a file in a folder (case insensitive)
|
||||
Return the found filename
|
||||
|
||||
@param {string} dirname
|
||||
@param {string} filename
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
findFile(dirname, filename) {
|
||||
return this.listFiles(dirname).then((files) => {
|
||||
return files.find((file) => {
|
||||
return file.toLowerCase() == filename.toLowerCase();
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
Load a JSON file
|
||||
By default, fs only supports JSON
|
||||
|
||||
@param {string} filename
|
||||
@return {Promise<Object>}
|
||||
*/
|
||||
loadAsObject(filename) {
|
||||
const that = this;
|
||||
const fsLoadObject = this.get("fsLoadObject");
|
||||
return this.exists(filename).then((exists) => {
|
||||
if (!exists) {
|
||||
const err = new Error("Module doesn't exist");
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'code' does not exist on type 'Error'.
|
||||
err.code = "MODULE_NOT_FOUND";
|
||||
throw err;
|
||||
}
|
||||
if (fsLoadObject) {
|
||||
return fsLoadObject(that.resolve(filename));
|
||||
}
|
||||
else {
|
||||
return that.readAsString(filename).then((str) => {
|
||||
return JSON.parse(str);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
Create a FS instance
|
||||
|
||||
@param {Object} def
|
||||
@return {FS}
|
||||
*/
|
||||
static create(def) {
|
||||
return new FS(def);
|
||||
}
|
||||
/**
|
||||
Create a new FS instance with a reduced scope
|
||||
|
||||
@param {FS} fs
|
||||
@param {string} scope
|
||||
@return {FS}
|
||||
*/
|
||||
static reduceScope(fs, scope) {
|
||||
return fs.set("root", path_1.default.join(fs.getRoot(), scope));
|
||||
}
|
||||
}
|
||||
// .readdir return files/folder as a list of string, folder ending with '/'
|
||||
function pathIsFolder(filename) {
|
||||
const lastChar = filename[filename.length - 1];
|
||||
return lastChar == "/" || lastChar == "\\";
|
||||
}
|
||||
exports.default = FS;
|
42
book/node_modules/honkit/lib/models/glossary.d.ts
generated
vendored
Normal file
42
book/node_modules/honkit/lib/models/glossary.d.ts
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
import GlossaryEntry from "./glossaryEntry";
|
||||
declare const Glossary_base: Immutable.Record.Class;
|
||||
declare class Glossary extends Glossary_base {
|
||||
getFile(): any;
|
||||
getEntries(): any;
|
||||
/**
|
||||
Return an entry by its name
|
||||
@param {string} name
|
||||
@return {GlossaryEntry}
|
||||
*/
|
||||
getEntry(name: string): any;
|
||||
/**
|
||||
Render glossary as text
|
||||
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
toText(parser: any): any;
|
||||
/**
|
||||
Add/Replace an entry to a glossary
|
||||
|
||||
@param {Glossary} glossary
|
||||
@param {GlossaryEntry} entry
|
||||
@return {Glossary}
|
||||
*/
|
||||
static addEntry(glossary: Glossary, entry: GlossaryEntry): Glossary;
|
||||
/**
|
||||
Add/Replace an entry to a glossary by name/description
|
||||
*/
|
||||
static addEntryByName(glossary: Glossary, name: string, description: string): Glossary;
|
||||
/**
|
||||
Create a glossary from a list of entries
|
||||
|
||||
@param file
|
||||
@param {Array|List} entries
|
||||
@return {Glossary}
|
||||
*/
|
||||
static createFromEntries(file: File, entries: any[]): Glossary;
|
||||
}
|
||||
export default Glossary;
|
||||
//# sourceMappingURL=glossary.d.ts.map
|
1
book/node_modules/honkit/lib/models/glossary.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/glossary.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/models/glossary.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;;AAG5C,cAAM,QAAS,SAAQ,aAGrB;IACE,OAAO;IAIP,UAAU;IAIV;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM;IAOrB;;;;OAIG;IACH,MAAM,CAAC,MAAM,KAAA;IAcb;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,GAAG,QAAQ;IAQnE;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ;IAQtF;;;;;;OAMG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;CActD;AAED,eAAe,QAAQ,CAAC"}
|
90
book/node_modules/honkit/lib/models/glossary.js
generated
vendored
Normal file
90
book/node_modules/honkit/lib/models/glossary.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const error_1 = __importDefault(require("../utils/error"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const glossaryEntry_1 = __importDefault(require("./glossaryEntry"));
|
||||
const parsers_1 = __importDefault(require("../parsers"));
|
||||
class Glossary extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
entries: immutable_1.default.OrderedMap()
|
||||
}) {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getEntries() {
|
||||
return this.get("entries");
|
||||
}
|
||||
/**
|
||||
Return an entry by its name
|
||||
@param {string} name
|
||||
@return {GlossaryEntry}
|
||||
*/
|
||||
getEntry(name) {
|
||||
const entries = this.getEntries();
|
||||
const id = glossaryEntry_1.default.nameToID(name);
|
||||
return entries.get(id);
|
||||
}
|
||||
/**
|
||||
Render glossary as text
|
||||
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
toText(parser) {
|
||||
const file = this.getFile();
|
||||
const entries = this.getEntries();
|
||||
parser = parser ? parsers_1.default.getByExt(parser) : file.getParser();
|
||||
if (!parser) {
|
||||
throw error_1.default.FileNotParsableError({
|
||||
filename: file.getPath()
|
||||
});
|
||||
}
|
||||
return parser.renderGlossary(entries.toJS());
|
||||
}
|
||||
/**
|
||||
Add/Replace an entry to a glossary
|
||||
|
||||
@param {Glossary} glossary
|
||||
@param {GlossaryEntry} entry
|
||||
@return {Glossary}
|
||||
*/
|
||||
static addEntry(glossary, entry) {
|
||||
const id = entry.getID();
|
||||
let entries = glossary.getEntries();
|
||||
entries = entries.set(id, entry);
|
||||
return glossary.set("entries", entries);
|
||||
}
|
||||
/**
|
||||
Add/Replace an entry to a glossary by name/description
|
||||
*/
|
||||
static addEntryByName(glossary, name, description) {
|
||||
const entry = new glossaryEntry_1.default({
|
||||
name: name,
|
||||
description: description
|
||||
});
|
||||
return Glossary.addEntry(glossary, entry);
|
||||
}
|
||||
/**
|
||||
Create a glossary from a list of entries
|
||||
|
||||
@param file
|
||||
@param {Array|List} entries
|
||||
@return {Glossary}
|
||||
*/
|
||||
static createFromEntries(file, entries) {
|
||||
entries = entries.map((entry) => {
|
||||
if (!(entry instanceof glossaryEntry_1.default)) {
|
||||
entry = new glossaryEntry_1.default(entry);
|
||||
}
|
||||
return [entry.getID(), entry];
|
||||
});
|
||||
return new Glossary({
|
||||
file: file,
|
||||
entries: immutable_1.default.OrderedMap(entries)
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Glossary;
|
16
book/node_modules/honkit/lib/models/glossaryEntry.d.ts
generated
vendored
Normal file
16
book/node_modules/honkit/lib/models/glossaryEntry.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import Immutable from "immutable";
|
||||
declare const GlossaryEntry_base: Immutable.Record.Class;
|
||||
declare class GlossaryEntry extends GlossaryEntry_base {
|
||||
getName(): string;
|
||||
getDescription(): string;
|
||||
/**
|
||||
Get identifier for this entry
|
||||
*/
|
||||
getID(): string;
|
||||
/**
|
||||
Normalize a glossary entry name into a unique id
|
||||
*/
|
||||
static nameToID(name: string): string;
|
||||
}
|
||||
export default GlossaryEntry;
|
||||
//# sourceMappingURL=glossaryEntry.d.ts.map
|
1
book/node_modules/honkit/lib/models/glossaryEntry.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/glossaryEntry.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"glossaryEntry.d.ts","sourceRoot":"","sources":["../../src/models/glossaryEntry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;;AAOlC,cAAM,aAAc,SAAQ,kBAG1B;IACE,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAGxC;AAED,eAAe,aAAa,CAAC"}
|
34
book/node_modules/honkit/lib/models/glossaryEntry.js
generated
vendored
Normal file
34
book/node_modules/honkit/lib/models/glossaryEntry.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const github_slugid_1 = __importDefault(require("github-slugid"));
|
||||
/*
|
||||
A definition represents an entry in the glossary
|
||||
*/
|
||||
class GlossaryEntry extends immutable_1.default.Record({
|
||||
name: String(),
|
||||
description: String()
|
||||
}) {
|
||||
getName() {
|
||||
return this.get("name");
|
||||
}
|
||||
getDescription() {
|
||||
return this.get("description");
|
||||
}
|
||||
/**
|
||||
Get identifier for this entry
|
||||
*/
|
||||
getID() {
|
||||
return GlossaryEntry.nameToID(this.getName());
|
||||
}
|
||||
/**
|
||||
Normalize a glossary entry name into a unique id
|
||||
*/
|
||||
static nameToID(name) {
|
||||
return (0, github_slugid_1.default)(name);
|
||||
}
|
||||
}
|
||||
exports.default = GlossaryEntry;
|
4
book/node_modules/honkit/lib/models/hash.d.ts
generated
vendored
Normal file
4
book/node_modules/honkit/lib/models/hash.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare const hash: (o: any) => any;
|
||||
declare function hashString(string: any): number;
|
||||
export { hashString };
|
||||
//# sourceMappingURL=hash.d.ts.map
|
1
book/node_modules/honkit/lib/models/hash.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/hash.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/models/hash.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,IAAI,iBAgChB,CAAC;AAkCF,iBAAS,UAAU,CAAC,MAAM,KAAA,UAYzB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
191
book/node_modules/honkit/lib/models/hash.js
generated
vendored
Normal file
191
book/node_modules/honkit/lib/models/hash.js
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hash = void 0;
|
||||
exports.hashString = hashString;
|
||||
// v8 has an optimization for storing 31-bit signed numbers.
|
||||
// Values which have either 00 or 11 as the high order bits qualify.
|
||||
// This function drops the highest order bit in a signed number, maintaining
|
||||
// the sign bit.
|
||||
function smi(i32) {
|
||||
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
|
||||
}
|
||||
const defaultValueOf = Object.prototype.valueOf;
|
||||
// If possible, use a WeakMap.
|
||||
const usingWeakMap = typeof WeakMap === "function";
|
||||
let weakMap;
|
||||
if (usingWeakMap) {
|
||||
weakMap = new WeakMap();
|
||||
}
|
||||
let objHashUID = 0;
|
||||
let UID_HASH_KEY = "__immutablehash__";
|
||||
if (typeof Symbol === "function") {
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type 'symbol' is not assignable to type 'string'.
|
||||
UID_HASH_KEY = Symbol(UID_HASH_KEY);
|
||||
}
|
||||
const STRING_HASH_CACHE_MIN_STRLEN = 16;
|
||||
const STRING_HASH_CACHE_MAX_SIZE = 255;
|
||||
let STRING_HASH_CACHE_SIZE = 0;
|
||||
let stringHashCache = {};
|
||||
const hash = function hash(o) {
|
||||
switch (typeof o) {
|
||||
case "boolean":
|
||||
// The hash values for built-in constants are a 1 value for each 5-byte
|
||||
// shift region expect for the first, which encodes the value. This
|
||||
// reduces the odds of a hash collision for these common values.
|
||||
return o ? 0x42108421 : 0x42108420;
|
||||
case "number":
|
||||
return hashNumber(o);
|
||||
case "string":
|
||||
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
|
||||
case "object":
|
||||
case "function":
|
||||
if (o === null) {
|
||||
return 0x42108422;
|
||||
}
|
||||
if (typeof o.hashCode === "function") {
|
||||
// Drop any high bits from accidentally long hash codes.
|
||||
return smi(o.hashCode(o));
|
||||
}
|
||||
if (o.valueOf !== defaultValueOf && typeof o.valueOf === "function") {
|
||||
o = o.valueOf(o);
|
||||
}
|
||||
return hashJSObj(o);
|
||||
case "undefined":
|
||||
return 0x42108423;
|
||||
default:
|
||||
if (typeof o.toString === "function") {
|
||||
return hashString(o.toString());
|
||||
}
|
||||
throw new Error(`Value type ${typeof o} cannot be hashed.`);
|
||||
}
|
||||
};
|
||||
exports.hash = hash;
|
||||
// Compress arbitrarily large numbers into smi hashes.
|
||||
function hashNumber(n) {
|
||||
if (n !== n || n === Infinity) {
|
||||
return 0;
|
||||
}
|
||||
let hash = n | 0;
|
||||
if (hash !== n) {
|
||||
hash ^= n * 0xffffffff;
|
||||
}
|
||||
while (n > 0xffffffff) {
|
||||
n /= 0xffffffff;
|
||||
hash ^= n;
|
||||
}
|
||||
return smi(hash);
|
||||
}
|
||||
function cachedHashString(string) {
|
||||
let hashed = stringHashCache[string];
|
||||
if (hashed === undefined) {
|
||||
hashed = hashString(string);
|
||||
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
|
||||
STRING_HASH_CACHE_SIZE = 0;
|
||||
stringHashCache = {};
|
||||
}
|
||||
STRING_HASH_CACHE_SIZE++;
|
||||
stringHashCache[string] = hashed;
|
||||
}
|
||||
return hashed;
|
||||
}
|
||||
// http://jsperf.com/hashing-strings
|
||||
function hashString(string) {
|
||||
// This is the hash from JVM
|
||||
// The hash code for a string is computed as
|
||||
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
|
||||
// where s[i] is the ith character of the string and n is the length of
|
||||
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
|
||||
// (exclusive) by dropping high bits.
|
||||
let hashed = 0;
|
||||
for (let ii = 0; ii < string.length; ii++) {
|
||||
hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
|
||||
}
|
||||
return smi(hashed);
|
||||
}
|
||||
function hashJSObj(obj) {
|
||||
let hashed;
|
||||
if (usingWeakMap) {
|
||||
hashed = weakMap.get(obj);
|
||||
if (hashed !== undefined) {
|
||||
return hashed;
|
||||
}
|
||||
}
|
||||
hashed = obj[UID_HASH_KEY];
|
||||
if (hashed !== undefined) {
|
||||
return hashed;
|
||||
}
|
||||
if (!canDefineProperty) {
|
||||
hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
|
||||
if (hashed !== undefined) {
|
||||
return hashed;
|
||||
}
|
||||
hashed = getIENodeHash(obj);
|
||||
if (hashed !== undefined) {
|
||||
return hashed;
|
||||
}
|
||||
}
|
||||
hashed = ++objHashUID;
|
||||
if (objHashUID & 0x40000000) {
|
||||
objHashUID = 0;
|
||||
}
|
||||
if (usingWeakMap) {
|
||||
weakMap.set(obj, hashed);
|
||||
}
|
||||
else if (isExtensible !== undefined && isExtensible(obj) === false) {
|
||||
throw new Error("Non-extensible objects are not allowed as keys.");
|
||||
}
|
||||
else if (canDefineProperty) {
|
||||
Object.defineProperty(obj, UID_HASH_KEY, {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: hashed
|
||||
});
|
||||
}
|
||||
else if (obj.propertyIsEnumerable !== undefined &&
|
||||
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
|
||||
// Since we can't define a non-enumerable property on the object
|
||||
// we'll hijack one of the less-used non-enumerable properties to
|
||||
// save our hash on it. Since this is a function it will not show up in
|
||||
// `JSON.stringify` which is what we want.
|
||||
obj.propertyIsEnumerable = function () {
|
||||
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
|
||||
};
|
||||
obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
|
||||
}
|
||||
else if (obj.nodeType !== undefined) {
|
||||
// At this point we couldn't get the IE `uniqueID` to use as a hash
|
||||
// and we couldn't use a non-enumerable property to exploit the
|
||||
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
|
||||
// itself.
|
||||
obj[UID_HASH_KEY] = hashed;
|
||||
}
|
||||
else {
|
||||
throw new Error("Unable to set a non-enumerable property on object.");
|
||||
}
|
||||
return hashed;
|
||||
}
|
||||
// Get references to ES5 object methods.
|
||||
const isExtensible = Object.isExtensible;
|
||||
// True if Object.defineProperty works as expected. IE8 fails this test.
|
||||
const canDefineProperty = (function () {
|
||||
try {
|
||||
Object.defineProperty({}, "@", {});
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
|
||||
// and avoid memory leaks from the IE cloneNode bug.
|
||||
function getIENodeHash(node) {
|
||||
if (node && node.nodeType > 0) {
|
||||
switch (node.nodeType) {
|
||||
case 1: // Element
|
||||
return node.uniqueID;
|
||||
case 9: // Document
|
||||
return node.documentElement && node.documentElement.uniqueID;
|
||||
}
|
||||
}
|
||||
}
|
20
book/node_modules/honkit/lib/models/ignore.d.ts
generated
vendored
Normal file
20
book/node_modules/honkit/lib/models/ignore.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import Immutable from "immutable";
|
||||
declare const Ignore_base: Immutable.Record.Class;
|
||||
declare class Ignore extends Ignore_base {
|
||||
getIgnore(): any;
|
||||
/**
|
||||
Test if a file is ignored by these rules
|
||||
|
||||
@return {boolean}
|
||||
* @param filename
|
||||
*/
|
||||
isFileIgnored(filename: string): boolean;
|
||||
/**
|
||||
Add rules
|
||||
@param {string}
|
||||
@return {Ignore}
|
||||
*/
|
||||
add(rule: string | import("ignore").Ignore): Immutable.Map<string, any>;
|
||||
}
|
||||
export default Ignore;
|
||||
//# sourceMappingURL=ignore.d.ts.map
|
1
book/node_modules/honkit/lib/models/ignore.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/ignore.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/models/ignore.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;;AAMlC,cAAM,MAAO,SAAQ,WAKpB;IACG,SAAS;IAIT;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM;IAK9B;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,QAAQ,EAAE,MAAM;CAS7C;AAED,eAAe,MAAM,CAAC"}
|
40
book/node_modules/honkit/lib/models/ignore.js
generated
vendored
Normal file
40
book/node_modules/honkit/lib/models/ignore.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const ignore_1 = __importDefault(require("ignore"));
|
||||
/*
|
||||
Immutable version of node-ignore
|
||||
*/
|
||||
class Ignore extends immutable_1.default.Record({
|
||||
ignore: (0, ignore_1.default)()
|
||||
}, "Ignore") {
|
||||
getIgnore() {
|
||||
return this.get("ignore");
|
||||
}
|
||||
/**
|
||||
Test if a file is ignored by these rules
|
||||
|
||||
@return {boolean}
|
||||
* @param filename
|
||||
*/
|
||||
isFileIgnored(filename) {
|
||||
const ignore = this.getIgnore();
|
||||
return ignore.filter([filename]).length == 0;
|
||||
}
|
||||
/**
|
||||
Add rules
|
||||
@param {string}
|
||||
@return {Ignore}
|
||||
*/
|
||||
add(rule) {
|
||||
const ignore = this.getIgnore();
|
||||
const newIgnore = (0, ignore_1.default)();
|
||||
newIgnore.add(ignore);
|
||||
newIgnore.add(rule);
|
||||
return this.set("ignore", newIgnore);
|
||||
}
|
||||
}
|
||||
exports.default = Ignore;
|
9
book/node_modules/honkit/lib/models/language.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/models/language.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import Immutable from "immutable";
|
||||
declare const Language_base: Immutable.Record.Class;
|
||||
declare class Language extends Language_base {
|
||||
getTitle(): string;
|
||||
getPath(): string;
|
||||
getID(): string;
|
||||
}
|
||||
export default Language;
|
||||
//# sourceMappingURL=language.d.ts.map
|
1
book/node_modules/honkit/lib/models/language.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/language.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/models/language.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;;AAElC,cAAM,QAAS,SAAQ,aAGrB;IACE,QAAQ,IAAI,MAAM;IAIlB,OAAO,IAAI,MAAM;IAIjB,KAAK,IAAI,MAAM;CAGlB;AAED,eAAe,QAAQ,CAAC"}
|
22
book/node_modules/honkit/lib/models/language.js
generated
vendored
Normal file
22
book/node_modules/honkit/lib/models/language.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
class Language extends immutable_1.default.Record({
|
||||
title: String(),
|
||||
path: String()
|
||||
}) {
|
||||
getTitle() {
|
||||
return this.get("title");
|
||||
}
|
||||
getPath() {
|
||||
return this.get("path");
|
||||
}
|
||||
getID() {
|
||||
return path_1.default.basename(this.getPath());
|
||||
}
|
||||
}
|
||||
exports.default = Language;
|
35
book/node_modules/honkit/lib/models/languages.d.ts
generated
vendored
Normal file
35
book/node_modules/honkit/lib/models/languages.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
import Language from "./language";
|
||||
declare const Languages_base: Immutable.Record.Class;
|
||||
declare class Languages extends Languages_base {
|
||||
getFile(): any;
|
||||
getList(): any;
|
||||
/**
|
||||
Get default languages
|
||||
|
||||
@return {Language}
|
||||
*/
|
||||
getDefaultLanguage(): Language;
|
||||
/**
|
||||
Get a language by its ID
|
||||
|
||||
@param {string} lang
|
||||
@return {Language}
|
||||
*/
|
||||
getLanguage(lang: string): Language;
|
||||
/**
|
||||
Return count of langs
|
||||
|
||||
@return {number}
|
||||
*/
|
||||
getCount(): any;
|
||||
/**
|
||||
Create a languages list from a JS object
|
||||
|
||||
@return {Language}
|
||||
*/
|
||||
static createFromList(file: File, langs: Languages): Languages;
|
||||
}
|
||||
export default Languages;
|
||||
//# sourceMappingURL=languages.d.ts.map
|
1
book/node_modules/honkit/lib/models/languages.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/languages.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/models/languages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;;AAElC,cAAM,SAAU,SAAQ,cAGtB;IACE,OAAO;IAIP,OAAO;IAIP;;;;OAIG;IACH,kBAAkB,IAAI,QAAQ;IAI9B;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAInC;;;;OAIG;IACH,QAAQ;IAIR;;;;OAIG;IAEH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS;CAgBjE;AAED,eAAe,SAAS,CAAC"}
|
64
book/node_modules/honkit/lib/models/languages.js
generated
vendored
Normal file
64
book/node_modules/honkit/lib/models/languages.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const language_1 = __importDefault(require("./language"));
|
||||
class Languages extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
list: immutable_1.default.OrderedMap()
|
||||
}) {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getList() {
|
||||
return this.get("list");
|
||||
}
|
||||
/**
|
||||
Get default languages
|
||||
|
||||
@return {Language}
|
||||
*/
|
||||
getDefaultLanguage() {
|
||||
return this.getList().first();
|
||||
}
|
||||
/**
|
||||
Get a language by its ID
|
||||
|
||||
@param {string} lang
|
||||
@return {Language}
|
||||
*/
|
||||
getLanguage(lang) {
|
||||
return this.getList().get(lang);
|
||||
}
|
||||
/**
|
||||
Return count of langs
|
||||
|
||||
@return {number}
|
||||
*/
|
||||
getCount() {
|
||||
return this.getList().size;
|
||||
}
|
||||
/**
|
||||
Create a languages list from a JS object
|
||||
|
||||
@return {Language}
|
||||
*/
|
||||
static createFromList(file, langs) {
|
||||
let list = immutable_1.default.OrderedMap();
|
||||
langs.forEach((lang) => {
|
||||
lang = new language_1.default({
|
||||
title: lang.title,
|
||||
path: lang.ref
|
||||
});
|
||||
list = list.set(lang.getID(), lang);
|
||||
});
|
||||
return new Languages({
|
||||
file: file,
|
||||
list: list
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Languages;
|
53
book/node_modules/honkit/lib/models/output.d.ts
generated
vendored
Normal file
53
book/node_modules/honkit/lib/models/output.d.ts
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import Immutable from "immutable";
|
||||
import Book from "./book";
|
||||
import Page from "./page";
|
||||
import type GeneratorState from "../output/website/state";
|
||||
type Assets = Immutable.List<string>;
|
||||
type State = GeneratorState;
|
||||
type Options = Immutable.Map<any, any>;
|
||||
declare const Output_base: Immutable.Record.Class;
|
||||
declare class Output extends Output_base {
|
||||
getBook(): Book;
|
||||
getGenerator(): string;
|
||||
getPlugins(): Immutable.OrderedMap<string, Plugin>;
|
||||
getPages(): Immutable.OrderedMap<string, Page>;
|
||||
getOptions(): Options;
|
||||
getAssets(): Assets;
|
||||
getState(): State;
|
||||
/**
|
||||
Return a page byt its file path
|
||||
|
||||
@param {string} filePath
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
getPage(filePath: string): Page | undefined;
|
||||
reloadPage(contentRootDir: string, filePath: string): Immutable.Map<string, any>;
|
||||
/**
|
||||
Get root folder for output
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot(): string;
|
||||
/**
|
||||
Update state of output
|
||||
|
||||
@param {Map} newState
|
||||
@return {Output}
|
||||
*/
|
||||
setState(newState: State): Output;
|
||||
/**
|
||||
Update options
|
||||
|
||||
@param {Map} newOptions
|
||||
@return {Output}
|
||||
*/
|
||||
setOptions(newOptions: Options): Output;
|
||||
/**
|
||||
Return logegr for this output (same as book)
|
||||
|
||||
@return {Logger}
|
||||
*/
|
||||
getLogger(): any;
|
||||
}
|
||||
export default Output;
|
||||
//# sourceMappingURL=output.d.ts.map
|
1
book/node_modules/honkit/lib/models/output.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/output.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/models/output.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAE1D,KAAK,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACrC,KAAK,KAAK,GAAG,cAAc,CAAC;AAC5B,KAAK,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;;AACvC,cAAM,MAAO,SAAQ,WAwBnB;IACE,OAAO,IAAI,IAAI;IAIf,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;IAIlD,QAAQ,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC;IAI9C,UAAU,IAAI,OAAO;IAIrB,SAAS,IAAI,MAAM;IAInB,QAAQ,IAAI,KAAK;IAIjB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAO3C,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAanD;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,MAAM;IAIjC;;;;;OAKG;IACH,UAAU,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM;IAIvC;;;;OAIG;IACH,SAAS;CAGZ;AAED,eAAe,MAAM,CAAC"}
|
109
book/node_modules/honkit/lib/models/output.js
generated
vendored
Normal file
109
book/node_modules/honkit/lib/models/output.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const parsePageFromString_1 = __importDefault(require("../parse/parsePageFromString"));
|
||||
const book_1 = __importDefault(require("./book"));
|
||||
const location_1 = __importDefault(require("../utils/location"));
|
||||
class Output extends immutable_1.default.Record({
|
||||
book: new book_1.default(),
|
||||
// Name of the generator being used
|
||||
generator: String(),
|
||||
// Map of plugins to use (String -> Plugin)
|
||||
plugins: immutable_1.default.OrderedMap(),
|
||||
// Map pages to generation (String -> Page)
|
||||
pages: immutable_1.default.OrderedMap(),
|
||||
// List assets (String)
|
||||
assets: immutable_1.default.List(),
|
||||
// Option for the generation
|
||||
options: immutable_1.default.Map(),
|
||||
// Internal state for the generation
|
||||
state: immutable_1.default.Map(),
|
||||
// incrementalChangeFileSet for incremental building
|
||||
// If it is empty, should build all
|
||||
incrementalChangeFileSet: immutable_1.default.Set()
|
||||
}) {
|
||||
getBook() {
|
||||
return this.get("book");
|
||||
}
|
||||
getGenerator() {
|
||||
return this.get("generator");
|
||||
}
|
||||
getPlugins() {
|
||||
return this.get("plugins");
|
||||
}
|
||||
getPages() {
|
||||
return this.get("pages");
|
||||
}
|
||||
getOptions() {
|
||||
return this.get("options");
|
||||
}
|
||||
getAssets() {
|
||||
return this.get("assets");
|
||||
}
|
||||
getState() {
|
||||
return this.get("state");
|
||||
}
|
||||
/**
|
||||
Return a page byt its file path
|
||||
|
||||
@param {string} filePath
|
||||
@return {Page|undefined}
|
||||
*/
|
||||
getPage(filePath) {
|
||||
filePath = location_1.default.normalize(filePath);
|
||||
const pages = this.getPages();
|
||||
return pages.get(filePath);
|
||||
}
|
||||
reloadPage(contentRootDir, filePath) {
|
||||
const relativePath = location_1.default.normalize(path_1.default.normalize(path_1.default.relative(contentRootDir, filePath)));
|
||||
const pages = this.getPages();
|
||||
const page = pages.get(relativePath);
|
||||
if (!page) {
|
||||
return this;
|
||||
}
|
||||
const newPage = (0, parsePageFromString_1.default)(page, fs_1.default.readFileSync(filePath, "utf-8"));
|
||||
return this.merge({
|
||||
pages: pages.set(relativePath, newPage)
|
||||
});
|
||||
}
|
||||
/**
|
||||
Get root folder for output
|
||||
|
||||
@return {string}
|
||||
*/
|
||||
getRoot() {
|
||||
return this.getOptions().get("root");
|
||||
}
|
||||
/**
|
||||
Update state of output
|
||||
|
||||
@param {Map} newState
|
||||
@return {Output}
|
||||
*/
|
||||
setState(newState) {
|
||||
return this.set("state", newState);
|
||||
}
|
||||
/**
|
||||
Update options
|
||||
|
||||
@param {Map} newOptions
|
||||
@return {Output}
|
||||
*/
|
||||
setOptions(newOptions) {
|
||||
return this.set("options", newOptions);
|
||||
}
|
||||
/**
|
||||
Return logegr for this output (same as book)
|
||||
|
||||
@return {Logger}
|
||||
*/
|
||||
getLogger() {
|
||||
return this.getBook().getLogger();
|
||||
}
|
||||
}
|
||||
exports.default = Output;
|
44
book/node_modules/honkit/lib/models/page.d.ts
generated
vendored
Normal file
44
book/node_modules/honkit/lib/models/page.d.ts
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
declare const Page_base: Immutable.Record.Class;
|
||||
declare class Page extends Page_base {
|
||||
getFile(): File;
|
||||
getAttributes(): any;
|
||||
getContent(): string;
|
||||
getDir(): string;
|
||||
/**
|
||||
* Return page as text
|
||||
* @return {string}
|
||||
*/
|
||||
toText(): string;
|
||||
/**
|
||||
* Return path of the page
|
||||
* @return {string}
|
||||
*/
|
||||
getPath(): string;
|
||||
/**
|
||||
* Create a page for a file
|
||||
* @param {File} file
|
||||
* @return {Page}
|
||||
*/
|
||||
static createForFile(file: File): Page;
|
||||
/**
|
||||
* Load a page for a file
|
||||
* @param {File} file
|
||||
* @param {string} content
|
||||
* @return {Page}
|
||||
*/
|
||||
static loadFile(file: File, content: string): Page;
|
||||
static fromJSON(json: {
|
||||
file: {
|
||||
[key: string]: any;
|
||||
};
|
||||
atributes: Immutable.Iterable.Keyed<unknown, unknown>;
|
||||
content: any;
|
||||
dir: any;
|
||||
}): Page;
|
||||
static toJSON(page: Page): any;
|
||||
hash(): number;
|
||||
}
|
||||
export default Page;
|
||||
//# sourceMappingURL=page.d.ts.map
|
1
book/node_modules/honkit/lib/models/page.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/page.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/models/page.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;;AAG1B,cAAM,IAAK,SAAQ,SAWjB;IACE,OAAO,IAAI,IAAI;IAIf,aAAa;IAIb,UAAU,IAAI,MAAM;IAIpB,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAYhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAOlD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAClB,IAAI,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;QAC7B,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,EAAE,GAAG,CAAC;QACb,GAAG,EAAE,GAAG,CAAC;KACZ;IAYD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI;IAIxB,IAAI;CAGP;AAED,eAAe,IAAI,CAAC"}
|
91
book/node_modules/honkit/lib/models/page.js
generated
vendored
Normal file
91
book/node_modules/honkit/lib/models/page.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const js_yaml_1 = __importDefault(require("js-yaml"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const hash_1 = require("./hash");
|
||||
class Page extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
// Attributes extracted from the YAML header
|
||||
attributes: immutable_1.default.Map(),
|
||||
// Content of the page
|
||||
content: String(),
|
||||
// Direction of the text
|
||||
dir: String("ltr")
|
||||
}) {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getAttributes() {
|
||||
return this.get("attributes");
|
||||
}
|
||||
getContent() {
|
||||
return this.get("content");
|
||||
}
|
||||
getDir() {
|
||||
return this.get("dir");
|
||||
}
|
||||
/**
|
||||
* Return page as text
|
||||
* @return {string}
|
||||
*/
|
||||
toText() {
|
||||
const attrs = this.getAttributes();
|
||||
const content = this.getContent();
|
||||
if (attrs.size === 0) {
|
||||
return content;
|
||||
}
|
||||
const frontMatter = `---\n${js_yaml_1.default.safeDump(attrs.toJS(), { skipInvalid: true })}---\n\n`;
|
||||
return frontMatter + (content || "");
|
||||
}
|
||||
/**
|
||||
* Return path of the page
|
||||
* @return {string}
|
||||
*/
|
||||
getPath() {
|
||||
return this.getFile().getPath();
|
||||
}
|
||||
/**
|
||||
* Create a page for a file
|
||||
* @param {File} file
|
||||
* @return {Page}
|
||||
*/
|
||||
static createForFile(file) {
|
||||
return new Page({
|
||||
file: file
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Load a page for a file
|
||||
* @param {File} file
|
||||
* @param {string} content
|
||||
* @return {Page}
|
||||
*/
|
||||
static loadFile(file, content) {
|
||||
return new Page({
|
||||
file: file,
|
||||
content: content
|
||||
});
|
||||
}
|
||||
static fromJSON(json) {
|
||||
return new Page({
|
||||
file: new file_1.default(json.file),
|
||||
// Attributes extracted from the YAML header
|
||||
attributes: immutable_1.default.Map(json.atributes),
|
||||
// Content of the page
|
||||
content: json.content,
|
||||
// Direction of the text
|
||||
dir: json.dir
|
||||
});
|
||||
}
|
||||
static toJSON(page) {
|
||||
return page.toJS();
|
||||
}
|
||||
hash() {
|
||||
return (0, hash_1.hashString)(JSON.stringify(this.toJS()));
|
||||
}
|
||||
}
|
||||
exports.default = Page;
|
44
book/node_modules/honkit/lib/models/parser.d.ts
generated
vendored
Normal file
44
book/node_modules/honkit/lib/models/parser.d.ts
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
import Immutable from "immutable";
|
||||
export type ParserOptions = {
|
||||
baseDirectory: string;
|
||||
};
|
||||
declare const Parser_base: Immutable.Record.Class;
|
||||
declare class Parser extends Parser_base {
|
||||
getName(): string;
|
||||
getExtensions(): Immutable.List<string>;
|
||||
parseReadme(content: string, options: ParserOptions): any;
|
||||
parseSummary(content: string, options: ParserOptions): any;
|
||||
parseGlossary(content: string, options: ParserOptions): any;
|
||||
preparePage(content: string): any;
|
||||
parsePage(content: string, options: ParserOptions): any;
|
||||
parseInline(content: string, options: ParserOptions): any;
|
||||
parseLanguages(content: string, options: ParserOptions): any;
|
||||
renderLanguages(content: any): any;
|
||||
renderSummary(content: any): any;
|
||||
renderGlossary(content: any): any;
|
||||
/**
|
||||
Test if this parser matches an extension
|
||||
|
||||
@param {string} ext
|
||||
@return {boolean}
|
||||
*/
|
||||
matchExtension(ext: string): boolean;
|
||||
/**
|
||||
Create a new parser using a module (gitbook-markdown, etc)
|
||||
|
||||
@param {string} name
|
||||
@param {Array<String>} extensions
|
||||
@param {Object} module
|
||||
@return {Parsers}
|
||||
*/
|
||||
static create(name: string, extensions: string[] | Immutable.Iterable.Indexed<unknown>, module: {
|
||||
readme: any;
|
||||
langs: any;
|
||||
summary: any;
|
||||
glossary: any;
|
||||
page: any;
|
||||
inline: any;
|
||||
}): Parser;
|
||||
}
|
||||
export default Parser;
|
||||
//# sourceMappingURL=parser.d.ts.map
|
1
book/node_modules/honkit/lib/models/parser.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/parser.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/models/parser.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,MAAM,MAAM,aAAa,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;;AACF,cAAM,MAAO,SAAQ,WAanB;IACE,OAAO,IAAI,MAAM;IAIjB,aAAa,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;IAMvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAMnD,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAMpD,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAMrD,WAAW,CAAC,OAAO,EAAE,MAAM;IAS3B,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAMjD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAMnD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAQtD,eAAe,CAAC,OAAO,EAAE,GAAG;IAM5B,aAAa,CAAC,OAAO,EAAE,GAAG;IAM1B,cAAc,CAAC,OAAO,EAAE,GAAG;IAM3B;;;;;OAKG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM;IAK1B;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAC1D,MAAM,EAAE;QAAE,MAAM,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE;CAa/F;AAED,eAAe,MAAM,CAAC"}
|
102
book/node_modules/honkit/lib/models/parser.js
generated
vendored
Normal file
102
book/node_modules/honkit/lib/models/parser.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const promise_1 = __importDefault(require("../utils/promise"));
|
||||
class Parser extends immutable_1.default.Record({
|
||||
name: String(),
|
||||
// List of extensions that can be processed using this parser
|
||||
extensions: immutable_1.default.List(),
|
||||
// Parsing functions
|
||||
readme: Function(),
|
||||
langs: Function(),
|
||||
summary: Function(),
|
||||
glossary: Function(),
|
||||
page: Function(),
|
||||
inline: Function()
|
||||
}) {
|
||||
getName() {
|
||||
return this.get("name");
|
||||
}
|
||||
getExtensions() {
|
||||
return this.get("extensions");
|
||||
}
|
||||
// PARSE
|
||||
parseReadme(content, options) {
|
||||
const readme = this.get("readme");
|
||||
return (0, promise_1.default)(readme(content, options));
|
||||
}
|
||||
parseSummary(content, options) {
|
||||
const summary = this.get("summary");
|
||||
return (0, promise_1.default)(summary(content));
|
||||
}
|
||||
parseGlossary(content, options) {
|
||||
const glossary = this.get("glossary");
|
||||
return (0, promise_1.default)(glossary(content, options));
|
||||
}
|
||||
preparePage(content) {
|
||||
const page = this.get("page");
|
||||
if (!page.prepare) {
|
||||
return (0, promise_1.default)(content);
|
||||
}
|
||||
return (0, promise_1.default)(page.prepare(content));
|
||||
}
|
||||
parsePage(content, options) {
|
||||
const page = this.get("page");
|
||||
return (0, promise_1.default)(page(content, options));
|
||||
}
|
||||
parseInline(content, options) {
|
||||
const inline = this.get("inline");
|
||||
return (0, promise_1.default)(inline(content, options));
|
||||
}
|
||||
parseLanguages(content, options) {
|
||||
const langs = this.get("langs");
|
||||
return (0, promise_1.default)(langs(content, options));
|
||||
}
|
||||
// TO TEXT
|
||||
renderLanguages(content) {
|
||||
const langs = this.get("langs");
|
||||
return (0, promise_1.default)(langs.toText(content));
|
||||
}
|
||||
renderSummary(content) {
|
||||
const summary = this.get("summary");
|
||||
return (0, promise_1.default)(summary.toText(content));
|
||||
}
|
||||
renderGlossary(content) {
|
||||
const glossary = this.get("glossary");
|
||||
return (0, promise_1.default)(glossary.toText(content));
|
||||
}
|
||||
/**
|
||||
Test if this parser matches an extension
|
||||
|
||||
@param {string} ext
|
||||
@return {boolean}
|
||||
*/
|
||||
matchExtension(ext) {
|
||||
const exts = this.getExtensions();
|
||||
return exts.includes(ext.toLowerCase());
|
||||
}
|
||||
/**
|
||||
Create a new parser using a module (gitbook-markdown, etc)
|
||||
|
||||
@param {string} name
|
||||
@param {Array<String>} extensions
|
||||
@param {Object} module
|
||||
@return {Parsers}
|
||||
*/
|
||||
static create(name, extensions, module) {
|
||||
return new Parser({
|
||||
name: name,
|
||||
extensions: immutable_1.default.List(extensions),
|
||||
readme: module.readme,
|
||||
langs: module.langs,
|
||||
summary: module.summary,
|
||||
glossary: module.glossary,
|
||||
page: module.page,
|
||||
inline: module.inline
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Parser;
|
69
book/node_modules/honkit/lib/models/plugin.d.ts
generated
vendored
Normal file
69
book/node_modules/honkit/lib/models/plugin.d.ts
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
import Immutable from "immutable";
|
||||
import PluginDependency from "./pluginDependency";
|
||||
type Content = Immutable.Map<any, any>;
|
||||
type Package = Immutable.Map<any, any>;
|
||||
declare const Plugin_base: Immutable.Record.Class;
|
||||
declare class Plugin extends Plugin_base {
|
||||
getName(): string;
|
||||
getPath(): string;
|
||||
getVersion(): string;
|
||||
getPackage(): Package;
|
||||
getContent(): Content;
|
||||
getDepth(): number;
|
||||
getParent(): string;
|
||||
/**
|
||||
* Return the ID on NPM for this plugin
|
||||
* return package.json's name
|
||||
* @return {string}
|
||||
*/
|
||||
getNpmID(): string;
|
||||
/**
|
||||
* Check if a plugin is loaded
|
||||
* @return {boolean}
|
||||
*/
|
||||
isLoaded(): boolean;
|
||||
/**
|
||||
* Check if a plugin is a theme given its name
|
||||
* @return {boolean}
|
||||
*/
|
||||
isTheme(): boolean;
|
||||
/**
|
||||
* Return map of hooks
|
||||
*/
|
||||
getHooks(): Immutable.Map<string, Function>;
|
||||
/**
|
||||
* Return infos about resources for a specific type
|
||||
* @param {string} type
|
||||
* @return {Map<String:Mixed>}
|
||||
*/
|
||||
getResources(type: string): any;
|
||||
/**
|
||||
* Return map of filters
|
||||
* @return {Map<String:Function>}
|
||||
*/
|
||||
getFilters(): any;
|
||||
/**
|
||||
* Return map of blocks
|
||||
* @return {Map<String:TemplateBlock>}
|
||||
*/
|
||||
getBlocks(): any;
|
||||
/**
|
||||
* Return a specific hook
|
||||
* @param {string} name
|
||||
* @return {Function|undefined}
|
||||
*/
|
||||
getHook(name: string): Function;
|
||||
/**
|
||||
* Create a plugin from a string
|
||||
* @return {Plugin}
|
||||
* @param s
|
||||
*/
|
||||
static createFromString(s: string): Plugin;
|
||||
/**
|
||||
* Create a plugin from a dependency
|
||||
* @return {Plugin}
|
||||
*/
|
||||
static createFromDep(dep: PluginDependency): Plugin;
|
||||
}
|
||||
export default Plugin;
|
||||
//# sourceMappingURL=plugin.d.ts.map
|
1
book/node_modules/honkit/lib/models/plugin.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/plugin.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/models/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAKlD,KAAK,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,KAAK,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;;AAEvC,cAAM,MAAO,SAAQ,WAuBpB;IACG,OAAO,IAAI,MAAM;IAIjB,OAAO,IAAI,MAAM;IAIjB,UAAU,IAAI,MAAM;IAIpB,UAAU,IAAI,OAAO;IAIrB,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,MAAM;IAIlB,SAAS,IAAI,MAAM;IAInB;;;;OAIG;IAEH,QAAQ,IAAI,MAAM;IAQlB;;;OAGG;IAEH,QAAQ,IAAI,OAAO;IAInB;;;OAGG;IAEH,OAAO,IAAI,OAAO;IAKlB;;OAEG;IACH,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;IAI3C;;;;OAIG;IAEH,YAAY,CAAC,IAAI,EAAE,MAAM;IASzB;;;OAGG;IAEH,UAAU;IAIV;;;OAGG;IAEH,SAAS;IAST;;;;OAIG;IAEH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;;;OAIG;IAEH,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM;IAWjC;;;OAGG;IAEH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,gBAAgB;CAM7C;AAED,eAAe,MAAM,CAAC"}
|
142
book/node_modules/honkit/lib/models/plugin.js
generated
vendored
Normal file
142
book/node_modules/honkit/lib/models/plugin.js
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const templateBlock_1 = __importDefault(require("./templateBlock"));
|
||||
const themePrefix_1 = __importDefault(require("../constants/themePrefix"));
|
||||
const DEFAULT_VERSION = "*";
|
||||
class Plugin extends immutable_1.default.Record({
|
||||
name: String(),
|
||||
// Requirement version (ex: ">1.0.0")
|
||||
version: String(DEFAULT_VERSION),
|
||||
// Path to load this plugin
|
||||
path: String(),
|
||||
// Depth of this plugin in the dependency tree
|
||||
depth: Number(0),
|
||||
// Parent depending on this plugin
|
||||
parent: String(),
|
||||
// Content of the "package.json"
|
||||
package: immutable_1.default.Map(),
|
||||
// Content of the package itself
|
||||
content: immutable_1.default.Map()
|
||||
}, "Plugin") {
|
||||
getName() {
|
||||
return this.get("name");
|
||||
}
|
||||
getPath() {
|
||||
return this.get("path");
|
||||
}
|
||||
getVersion() {
|
||||
return this.get("version");
|
||||
}
|
||||
getPackage() {
|
||||
return this.get("package");
|
||||
}
|
||||
getContent() {
|
||||
return this.get("content");
|
||||
}
|
||||
getDepth() {
|
||||
return this.get("depth");
|
||||
}
|
||||
getParent() {
|
||||
return this.get("parent");
|
||||
}
|
||||
/**
|
||||
* Return the ID on NPM for this plugin
|
||||
* return package.json's name
|
||||
* @return {string}
|
||||
*/
|
||||
getNpmID() {
|
||||
const pkg = this.getPackage().toJS();
|
||||
if ("name" in pkg) {
|
||||
return pkg["name"];
|
||||
}
|
||||
throw new Error(`${this.getName()} plugin's package.json does not have "name" fields.`);
|
||||
}
|
||||
/**
|
||||
* Check if a plugin is loaded
|
||||
* @return {boolean}
|
||||
*/
|
||||
isLoaded() {
|
||||
return Boolean(this.getPackage().size > 0);
|
||||
}
|
||||
/**
|
||||
* Check if a plugin is a theme given its name
|
||||
* @return {boolean}
|
||||
*/
|
||||
isTheme() {
|
||||
const name = this.getName();
|
||||
return name && name.indexOf(themePrefix_1.default) === 0;
|
||||
}
|
||||
/**
|
||||
* Return map of hooks
|
||||
*/
|
||||
getHooks() {
|
||||
return this.getContent().get("hooks") || immutable_1.default.Map();
|
||||
}
|
||||
/**
|
||||
* Return infos about resources for a specific type
|
||||
* @param {string} type
|
||||
* @return {Map<String:Mixed>}
|
||||
*/
|
||||
getResources(type) {
|
||||
if (type != "website" && type != "ebook") {
|
||||
throw new Error(`Invalid assets type ${type}`);
|
||||
}
|
||||
const content = this.getContent();
|
||||
return content.get(type) || (type == "website" ? content.get("book") : null) || immutable_1.default.Map();
|
||||
}
|
||||
/**
|
||||
* Return map of filters
|
||||
* @return {Map<String:Function>}
|
||||
*/
|
||||
getFilters() {
|
||||
return this.getContent().get("filters");
|
||||
}
|
||||
/**
|
||||
* Return map of blocks
|
||||
* @return {Map<String:TemplateBlock>}
|
||||
*/
|
||||
getBlocks() {
|
||||
let blocks = this.getContent().get("blocks");
|
||||
blocks = blocks || immutable_1.default.Map();
|
||||
return blocks.map((block, blockName) => {
|
||||
return templateBlock_1.default.create(blockName, block);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Return a specific hook
|
||||
* @param {string} name
|
||||
* @return {Function|undefined}
|
||||
*/
|
||||
getHook(name) {
|
||||
return this.getHooks().get(name);
|
||||
}
|
||||
/**
|
||||
* Create a plugin from a string
|
||||
* @return {Plugin}
|
||||
* @param s
|
||||
*/
|
||||
static createFromString(s) {
|
||||
const parts = s.split("@");
|
||||
const name = parts[0];
|
||||
const version = parts.slice(1).join("@");
|
||||
return new Plugin({
|
||||
name: name,
|
||||
version: version || DEFAULT_VERSION
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a plugin from a dependency
|
||||
* @return {Plugin}
|
||||
*/
|
||||
static createFromDep(dep) {
|
||||
return new Plugin({
|
||||
name: dep.getName(),
|
||||
version: dep.getVersion()
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Plugin;
|
47
book/node_modules/honkit/lib/models/pluginDependency.d.ts
generated
vendored
Normal file
47
book/node_modules/honkit/lib/models/pluginDependency.d.ts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import Immutable from "immutable";
|
||||
declare const PluginDependency_base: Immutable.Record.Class;
|
||||
declare class PluginDependency extends PluginDependency_base {
|
||||
getName(): any;
|
||||
getVersion(): any;
|
||||
getPath(): any;
|
||||
isEnabled(): any;
|
||||
/**
|
||||
* Toggle this plugin state
|
||||
* @return {PluginDependency}
|
||||
*/
|
||||
toggle(state?: boolean): Immutable.Map<string, any>;
|
||||
/**
|
||||
* Is the plugin using a git dependency
|
||||
* @return {boolean}
|
||||
*/
|
||||
isGitDependency(): boolean;
|
||||
/**
|
||||
* Create a plugin with a name and a plugin
|
||||
* @return {Plugin|undefined}
|
||||
*/
|
||||
static create(name: string, version: string, enabled?: boolean): PluginDependency;
|
||||
/**
|
||||
* Create a plugin from a string
|
||||
* @param {string} s
|
||||
* @return {Plugin|undefined}
|
||||
*/
|
||||
static createFromString(s: any): PluginDependency;
|
||||
/**
|
||||
* Create a PluginDependency from a string
|
||||
* @param {string}
|
||||
* @return {List<PluginDependency>}
|
||||
*/
|
||||
static listFromString(s: any): Immutable.Iterable<number, PluginDependency>;
|
||||
/**
|
||||
* Create a PluginDependency from an array
|
||||
*/
|
||||
static listFromArray(arr: (PluginDependency | string)[]): Immutable.Iterable<number, PluginDependency>;
|
||||
/**
|
||||
* Export plugin dependencies as an array
|
||||
* @param {List<PluginDependency>} list
|
||||
* @return {Array<String>}
|
||||
*/
|
||||
static listToArray(list: any): any;
|
||||
}
|
||||
export default PluginDependency;
|
||||
//# sourceMappingURL=pluginDependency.d.ts.map
|
1
book/node_modules/honkit/lib/models/pluginDependency.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/pluginDependency.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"pluginDependency.d.ts","sourceRoot":"","sources":["../../src/models/pluginDependency.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;;AASlC,cAAM,gBAAiB,SAAQ,qBAc9B;IACG,OAAO;IAIP,UAAU;IAIV,OAAO;IAIP,SAAS;IAIT;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO;IAQtB;;;OAGG;IACH,eAAe;IAIf;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAY9D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,KAAA;IAqDzB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,CAAC,KAAA;IAKvB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,gBAAgB,GAAG,MAAM,CAAC,EAAE;IAiBvD;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,KAAA;CAkB1B;AAED,eAAe,gBAAgB,CAAC"}
|
175
book/node_modules/honkit/lib/models/pluginDependency.js
generated
vendored
Normal file
175
book/node_modules/honkit/lib/models/pluginDependency.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const DEFAULT_VERSION = "*";
|
||||
/*
|
||||
* PluginDependency represents the information about a plugin
|
||||
* stored in config.plugins
|
||||
*/
|
||||
class PluginDependency extends immutable_1.default.Record({
|
||||
name: String(),
|
||||
// Requirement version (ex: ">1.0.0")
|
||||
version: String(DEFAULT_VERSION),
|
||||
// path to package
|
||||
path: String(),
|
||||
// Is this plugin enabled or disabled?
|
||||
enabled: Boolean(true)
|
||||
}, "PluginDependency") {
|
||||
getName() {
|
||||
return this.get("name");
|
||||
}
|
||||
getVersion() {
|
||||
return this.get("version");
|
||||
}
|
||||
getPath() {
|
||||
return this.get("path");
|
||||
}
|
||||
isEnabled() {
|
||||
return this.get("enabled");
|
||||
}
|
||||
/**
|
||||
* Toggle this plugin state
|
||||
* @return {PluginDependency}
|
||||
*/
|
||||
toggle(state) {
|
||||
if (state === undefined) {
|
||||
state = !this.isEnabled();
|
||||
}
|
||||
return this.set("enabled", state);
|
||||
}
|
||||
/**
|
||||
* Is the plugin using a git dependency
|
||||
* @return {boolean}
|
||||
*/
|
||||
isGitDependency() {
|
||||
return !semver_1.default.validRange(this.getVersion());
|
||||
}
|
||||
/**
|
||||
* Create a plugin with a name and a plugin
|
||||
* @return {Plugin|undefined}
|
||||
*/
|
||||
static create(name, version, enabled) {
|
||||
if (is_1.default.undefined(enabled)) {
|
||||
enabled = true;
|
||||
}
|
||||
return new PluginDependency({
|
||||
name: name,
|
||||
version: version || DEFAULT_VERSION,
|
||||
enabled: Boolean(enabled)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a plugin from a string
|
||||
* @param {string} s
|
||||
* @return {Plugin|undefined}
|
||||
*/
|
||||
static createFromString(s) {
|
||||
/*
|
||||
HonKit will support following format
|
||||
pkg
|
||||
@scope/pkg
|
||||
-pkg - Disable package
|
||||
-@scope/pkg - Disable package
|
||||
*/
|
||||
const packagePattern = /^(?<disabled>-)?(?<name>.+)$/;
|
||||
const scopedPackagePattern = /^(?<disabled>-)?(?<name>@[^/]+\/.+)$/;
|
||||
if (packagePattern.test(s) && !s.includes("@")) {
|
||||
const match = s.match(packagePattern);
|
||||
const enabled = !match.groups.disabled;
|
||||
return new PluginDependency({
|
||||
name: match.groups.name,
|
||||
version: DEFAULT_VERSION,
|
||||
enabled: enabled
|
||||
});
|
||||
}
|
||||
else if (scopedPackagePattern.test(s)) {
|
||||
const match = s.match(scopedPackagePattern);
|
||||
const enabled = !match.groups.disabled;
|
||||
return new PluginDependency({
|
||||
name: match.groups.name,
|
||||
version: DEFAULT_VERSION,
|
||||
enabled: enabled
|
||||
});
|
||||
}
|
||||
else {
|
||||
/*
|
||||
Deprecated It is only for backward compatible
|
||||
This is original GitBook logic supports
|
||||
|
||||
pkg@version - backward compatible with GitBook
|
||||
pkg@>=version - backward compatible with GitBook
|
||||
hello@git+ssh://samy@github.com/GitbookIO/plugin-ga.git
|
||||
|
||||
Note: This logic does not support scoped module
|
||||
*/
|
||||
const parts = s.split("@");
|
||||
let name = parts[0];
|
||||
const version = parts.slice(1).join("@");
|
||||
let enabled = true;
|
||||
if (name[0] === "-") {
|
||||
enabled = false;
|
||||
name = name.slice(1);
|
||||
}
|
||||
return new PluginDependency({
|
||||
name: name,
|
||||
version: version || DEFAULT_VERSION,
|
||||
enabled: enabled
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a PluginDependency from a string
|
||||
* @param {string}
|
||||
* @return {List<PluginDependency>}
|
||||
*/
|
||||
static listFromString(s) {
|
||||
const parts = s.split(",");
|
||||
return PluginDependency.listFromArray(parts);
|
||||
}
|
||||
/**
|
||||
* Create a PluginDependency from an array
|
||||
*/
|
||||
static listFromArray(arr) {
|
||||
return immutable_1.default.List(arr)
|
||||
.map((entry) => {
|
||||
if (typeof entry === "string") {
|
||||
return PluginDependency.createFromString(entry);
|
||||
}
|
||||
else {
|
||||
return new PluginDependency({
|
||||
name: entry.get("name"),
|
||||
version: entry.get("version")
|
||||
});
|
||||
}
|
||||
})
|
||||
.filter((dep) => {
|
||||
return Boolean(dep.getName());
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Export plugin dependencies as an array
|
||||
* @param {List<PluginDependency>} list
|
||||
* @return {Array<String>}
|
||||
*/
|
||||
static listToArray(list) {
|
||||
return list
|
||||
.map((dep) => {
|
||||
let result = "";
|
||||
if (!dep.isEnabled()) {
|
||||
result += "-";
|
||||
}
|
||||
result += dep.getName();
|
||||
if (dep.getVersion() !== DEFAULT_VERSION) {
|
||||
result += `@${dep.getVersion()}`;
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.toJS();
|
||||
}
|
||||
}
|
||||
exports.default = PluginDependency;
|
21
book/node_modules/honkit/lib/models/readme.d.ts
generated
vendored
Normal file
21
book/node_modules/honkit/lib/models/readme.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
declare const Readme_base: Immutable.Record.Class;
|
||||
declare class Readme extends Readme_base {
|
||||
getFile(): File;
|
||||
getTitle(): string;
|
||||
getDescription(): string;
|
||||
/**
|
||||
Create a new readme
|
||||
|
||||
@param {File} file
|
||||
@param {Object} def
|
||||
@return {Readme}
|
||||
*/
|
||||
static create(file: File, def: {
|
||||
title?: any;
|
||||
description?: any;
|
||||
}): Readme;
|
||||
}
|
||||
export default Readme;
|
||||
//# sourceMappingURL=readme.d.ts.map
|
1
book/node_modules/honkit/lib/models/readme.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/readme.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/models/readme.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,QAAQ,CAAC;;AAE1B,cAAM,MAAO,SAAQ,WAInB;IACE,OAAO,IAAI,IAAI;IAIf,QAAQ,IAAI,MAAM;IAIlB,cAAc,IAAI,MAAM;IAIxB;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;QAAE,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,WAAW,CAAC,EAAE,GAAG,CAAA;KAAE;CASpE;AAED,eAAe,MAAM,CAAC"}
|
38
book/node_modules/honkit/lib/models/readme.js
generated
vendored
Normal file
38
book/node_modules/honkit/lib/models/readme.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
class Readme extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
title: String(),
|
||||
description: String()
|
||||
}) {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getTitle() {
|
||||
return this.get("title");
|
||||
}
|
||||
getDescription() {
|
||||
return this.get("description");
|
||||
}
|
||||
/**
|
||||
Create a new readme
|
||||
|
||||
@param {File} file
|
||||
@param {Object} def
|
||||
@return {Readme}
|
||||
*/
|
||||
static create(file, def) {
|
||||
def = def || {};
|
||||
return new Readme({
|
||||
file: file,
|
||||
title: def.title || "",
|
||||
description: def.description || ""
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = Readme;
|
83
book/node_modules/honkit/lib/models/summary.d.ts
generated
vendored
Normal file
83
book/node_modules/honkit/lib/models/summary.d.ts
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
import SummaryArticle from "./summaryArticle";
|
||||
type Parts = Immutable.List<any>;
|
||||
declare const Summary_base: Immutable.Record.Class;
|
||||
declare class Summary extends Summary_base {
|
||||
getFile(): File;
|
||||
getParts(): Parts;
|
||||
/**
|
||||
Return a part by its index
|
||||
*/
|
||||
getPart(i: number): any;
|
||||
/**
|
||||
Return an article using an iterator to find it.
|
||||
if "partIter" is set, it can also return a Part.
|
||||
|
||||
@param {Function} iter
|
||||
@param {Function} [partIter]
|
||||
@return {Article|Part}
|
||||
*/
|
||||
getArticle(iter: any, partIter?: any): SummaryArticle | null;
|
||||
/**
|
||||
Return a part/article by its level
|
||||
|
||||
@param {string} level
|
||||
@return {Article|Part}
|
||||
*/
|
||||
getByLevel(level: string): SummaryArticle;
|
||||
/**
|
||||
Return an article by its path
|
||||
|
||||
@param {string} filePath
|
||||
@return {Article}
|
||||
*/
|
||||
getByPath(filePath: string): SummaryArticle;
|
||||
/**
|
||||
Return the first article
|
||||
|
||||
@return {Article}
|
||||
*/
|
||||
getFirstArticle(): SummaryArticle;
|
||||
/**
|
||||
Return next article of an article
|
||||
|
||||
*/
|
||||
getNextArticle(current: SummaryArticle | string): SummaryArticle;
|
||||
/**
|
||||
Return previous article of an article
|
||||
|
||||
@param {Article} current
|
||||
@return {Article}
|
||||
*/
|
||||
getPrevArticle(current: any): any;
|
||||
/**
|
||||
Return the parent article, or parent part of an article
|
||||
|
||||
@param {String|Article} current
|
||||
@return {Article|Part|Null}
|
||||
*/
|
||||
getParent(level: any): SummaryArticle;
|
||||
/**
|
||||
Render summary as text
|
||||
|
||||
@param {string} parseExt Extension of the parser to use
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
toText(parseExt: any): any;
|
||||
/**
|
||||
Return all articles as a list
|
||||
|
||||
@return {List<Article>}
|
||||
*/
|
||||
getArticlesAsList(): Immutable.List<any>;
|
||||
/**
|
||||
Create a new summary for a list of parts
|
||||
|
||||
@param {Lust|Array} parts
|
||||
@return {Summary}
|
||||
*/
|
||||
static createFromParts(file: any, parts: any): Summary;
|
||||
}
|
||||
export default Summary;
|
||||
//# sourceMappingURL=summary.d.ts.map
|
1
book/node_modules/honkit/lib/models/summary.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/summary.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/models/summary.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAG9C,KAAK,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;AAEjC,cAAM,OAAQ,SAAQ,YAMrB;IACG,OAAO,IAAI,IAAI;IAIf,QAAQ,IAAI,KAAK;IAIjB;;OAEG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM;IAKjB;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,KAAA,EAAE,QAAQ,CAAC,KAAA,GAAG,cAAc,GAAG,IAAI;IAWlD;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM;IAQxB;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc;IAQ3C;;;;OAIG;IACH,eAAe;IAMf;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,cAAc;IAgBhE;;;;;OAKG;IACH,cAAc,CAAC,OAAO,KAAA;IAiBtB;;;;;OAKG;IACH,SAAS,CAAC,KAAK,KAAA;IAef;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,KAAA;IAiBf;;;;OAIG;IACH,iBAAiB;IAUjB;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA;CAerC;AAaD,eAAe,OAAO,CAAC"}
|
199
book/node_modules/honkit/lib/models/summary.js
generated
vendored
Normal file
199
book/node_modules/honkit/lib/models/summary.js
generated
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const error_1 = __importDefault(require("../utils/error"));
|
||||
const location_1 = __importDefault(require("../utils/location"));
|
||||
const file_1 = __importDefault(require("./file"));
|
||||
const summaryPart_1 = __importDefault(require("./summaryPart"));
|
||||
const summaryArticle_1 = __importDefault(require("./summaryArticle"));
|
||||
const parsers_1 = __importDefault(require("../parsers"));
|
||||
class Summary extends immutable_1.default.Record({
|
||||
file: new file_1.default(),
|
||||
parts: immutable_1.default.List()
|
||||
}, "Summary") {
|
||||
getFile() {
|
||||
return this.get("file");
|
||||
}
|
||||
getParts() {
|
||||
return this.get("parts");
|
||||
}
|
||||
/**
|
||||
Return a part by its index
|
||||
*/
|
||||
getPart(i) {
|
||||
const parts = this.getParts();
|
||||
return parts.get(i);
|
||||
}
|
||||
/**
|
||||
Return an article using an iterator to find it.
|
||||
if "partIter" is set, it can also return a Part.
|
||||
|
||||
@param {Function} iter
|
||||
@param {Function} [partIter]
|
||||
@return {Article|Part}
|
||||
*/
|
||||
getArticle(iter, partIter) {
|
||||
const parts = this.getParts();
|
||||
return parts.reduce((result, part) => {
|
||||
if (result)
|
||||
return result;
|
||||
if (partIter && partIter(part))
|
||||
return part;
|
||||
return summaryArticle_1.default.findArticle(part, iter);
|
||||
}, null);
|
||||
}
|
||||
/**
|
||||
Return a part/article by its level
|
||||
|
||||
@param {string} level
|
||||
@return {Article|Part}
|
||||
*/
|
||||
getByLevel(level) {
|
||||
function iterByLevel(article) {
|
||||
return article.getLevel() === level;
|
||||
}
|
||||
return this.getArticle(iterByLevel, iterByLevel);
|
||||
}
|
||||
/**
|
||||
Return an article by its path
|
||||
|
||||
@param {string} filePath
|
||||
@return {Article}
|
||||
*/
|
||||
getByPath(filePath) {
|
||||
return this.getArticle((article) => {
|
||||
const articlePath = article.getPath();
|
||||
return articlePath && location_1.default.areIdenticalPaths(articlePath, filePath);
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return the first article
|
||||
|
||||
@return {Article}
|
||||
*/
|
||||
getFirstArticle() {
|
||||
return this.getArticle((article) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return next article of an article
|
||||
|
||||
*/
|
||||
getNextArticle(current) {
|
||||
const level = typeof current === "string" ? current : current.getLevel();
|
||||
let wasPrev = false;
|
||||
return this.getArticle((article) => {
|
||||
if (wasPrev && !article.hasAnchor()) {
|
||||
return true;
|
||||
}
|
||||
if (!wasPrev) {
|
||||
wasPrev = article.getLevel() === level;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return previous article of an article
|
||||
|
||||
@param {Article} current
|
||||
@return {Article}
|
||||
*/
|
||||
getPrevArticle(current) {
|
||||
const level = is_1.default.string(current) ? current : current.getLevel();
|
||||
let prev = undefined;
|
||||
this.getArticle((article) => {
|
||||
if (article.getLevel() == level) {
|
||||
return true;
|
||||
}
|
||||
if (!article.hasAnchor()) {
|
||||
prev = article;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return prev;
|
||||
}
|
||||
/**
|
||||
Return the parent article, or parent part of an article
|
||||
|
||||
@param {String|Article} current
|
||||
@return {Article|Part|Null}
|
||||
*/
|
||||
getParent(level) {
|
||||
// Coerce to level
|
||||
level = is_1.default.string(level) ? level : level.getLevel();
|
||||
// Get parent level
|
||||
const parentLevel = getParentLevel(level);
|
||||
if (!parentLevel) {
|
||||
return null;
|
||||
}
|
||||
// Get parent of the position
|
||||
const parentArticle = this.getByLevel(parentLevel);
|
||||
return parentArticle || null;
|
||||
}
|
||||
/**
|
||||
Render summary as text
|
||||
|
||||
@param {string} parseExt Extension of the parser to use
|
||||
@return {Promise<String>}
|
||||
*/
|
||||
toText(parseExt) {
|
||||
const file = this.getFile();
|
||||
const parts = this.getParts();
|
||||
const parser = parseExt ? parsers_1.default.getByExt(parseExt) : file.getParser();
|
||||
if (!parser) {
|
||||
throw error_1.default.FileNotParsableError({
|
||||
filename: file.getPath()
|
||||
});
|
||||
}
|
||||
return parser.renderSummary({
|
||||
parts: parts.toJS()
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return all articles as a list
|
||||
|
||||
@return {List<Article>}
|
||||
*/
|
||||
getArticlesAsList() {
|
||||
const accu = [];
|
||||
this.getArticle((article) => {
|
||||
accu.push(article);
|
||||
});
|
||||
return immutable_1.default.List(accu);
|
||||
}
|
||||
/**
|
||||
Create a new summary for a list of parts
|
||||
|
||||
@param {Lust|Array} parts
|
||||
@return {Summary}
|
||||
*/
|
||||
static createFromParts(file, parts) {
|
||||
parts = parts.map((part, i) => {
|
||||
if (part instanceof summaryPart_1.default) {
|
||||
return part;
|
||||
}
|
||||
return summaryPart_1.default.create(part, i + 1);
|
||||
});
|
||||
return new Summary({
|
||||
file: file,
|
||||
// @ts-expect-error ts-migrate(2350) FIXME: Only a void function can be called with the 'new' ... Remove this comment to see the full error message
|
||||
parts: new immutable_1.default.List(parts)
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
Returns parent level of a level
|
||||
|
||||
@param {string} level
|
||||
@return {string}
|
||||
*/
|
||||
function getParentLevel(level) {
|
||||
const parts = level.split(".");
|
||||
return parts.slice(0, -1).join(".");
|
||||
}
|
||||
exports.default = Summary;
|
93
book/node_modules/honkit/lib/models/summaryArticle.d.ts
generated
vendored
Normal file
93
book/node_modules/honkit/lib/models/summaryArticle.d.ts
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
import Immutable from "immutable";
|
||||
import File from "./file";
|
||||
import Book from "./book";
|
||||
import Readme from "./readme";
|
||||
type Articles = Immutable.List<SummaryArticle>;
|
||||
declare const SummaryArticle_base: Immutable.Record.Class;
|
||||
declare class SummaryArticle extends SummaryArticle_base {
|
||||
getLevel(): string;
|
||||
getTitle(): string;
|
||||
getRef(): string;
|
||||
getArticles(): Articles;
|
||||
/**
|
||||
* Return how deep the article is.
|
||||
* The README has a depth of 1
|
||||
*
|
||||
* @return {number}
|
||||
*/
|
||||
getDepth(): number;
|
||||
/**
|
||||
* Get path (without anchor) to the pointing file.
|
||||
* It also normalizes the file path.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getPath(): string;
|
||||
/**
|
||||
* Return url if article is external
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getUrl(): string;
|
||||
/**
|
||||
* Get anchor for this article (or undefined)
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getAnchor(): string;
|
||||
/**
|
||||
* Create a new level for a new child article
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
createChildLevel(): string;
|
||||
/**
|
||||
* Is article pointing to a page of an absolute url
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
isPage(): boolean;
|
||||
/**
|
||||
* Check if this article is a file (exatcly)
|
||||
*
|
||||
* @param {File} file
|
||||
* @return {boolean}
|
||||
*/
|
||||
isFile(file: File): boolean;
|
||||
/**
|
||||
* Check if this article is the introduction of the book
|
||||
*
|
||||
* @param {Book|Readme} book
|
||||
* @return {boolean}
|
||||
*/
|
||||
isReadme(book: Book | Readme): boolean;
|
||||
/**
|
||||
* Is article pointing to aan absolute url
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
isExternal(): boolean;
|
||||
/**
|
||||
* Create a SummaryArticle
|
||||
*
|
||||
* @param {Object} def
|
||||
* @return {SummaryArticle}
|
||||
*/
|
||||
static create(def: any, level: any): SummaryArticle;
|
||||
/**
|
||||
* Has anchor for this article
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasAnchor(): boolean;
|
||||
/**
|
||||
* Find an article from a base one
|
||||
*
|
||||
* @param {Article|Part} base
|
||||
* @param {Function(article)} iter
|
||||
* @return {Article}
|
||||
*/
|
||||
static findArticle(base: any, iter: any): SummaryArticle | null;
|
||||
}
|
||||
export default SummaryArticle;
|
||||
//# sourceMappingURL=summaryArticle.d.ts.map
|
1
book/node_modules/honkit/lib/models/summaryArticle.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/summaryArticle.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"summaryArticle.d.ts","sourceRoot":"","sources":["../../src/models/summaryArticle.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAM9B,KAAK,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;;AAE/C,cAAM,cAAe,SAAQ,mBAQ5B;IACG,QAAQ,IAAI,MAAM;IAIlB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAIhB,WAAW,IAAI,QAAQ;IAIvB;;;;;OAKG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;;OAKG;IACH,OAAO,IAAI,MAAM;IAmBjB;;;;OAIG;IACH,MAAM,IAAI,MAAM;IAIhB;;;;OAIG;IACH,SAAS,IAAI,MAAM;IAQnB;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;IAQ1B;;;;OAIG;IACH,MAAM,IAAI,OAAO;IAIjB;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAI3B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAQ5B;;;;OAIG;IACH,UAAU;IAIV;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA;IAgBxB;;;;OAIG;IACH,SAAS,IAAI,OAAO;IAKpB;;;;;;OAMG;IAEH,MAAM,CAAC,WAAW,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,GAAG,cAAc,GAAG,IAAI;CAYxD;AAED,eAAe,cAAc,CAAC"}
|
169
book/node_modules/honkit/lib/models/summaryArticle.js
generated
vendored
Normal file
169
book/node_modules/honkit/lib/models/summaryArticle.js
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const location_1 = __importDefault(require("../utils/location"));
|
||||
class SummaryArticle extends immutable_1.default.Record({
|
||||
level: String(),
|
||||
title: String(),
|
||||
ref: String(),
|
||||
articles: immutable_1.default.List()
|
||||
}, "SummaryArticle") {
|
||||
getLevel() {
|
||||
return this.get("level");
|
||||
}
|
||||
getTitle() {
|
||||
return this.get("title");
|
||||
}
|
||||
getRef() {
|
||||
return this.get("ref");
|
||||
}
|
||||
getArticles() {
|
||||
return this.get("articles");
|
||||
}
|
||||
/**
|
||||
* Return how deep the article is.
|
||||
* The README has a depth of 1
|
||||
*
|
||||
* @return {number}
|
||||
*/
|
||||
getDepth() {
|
||||
return this.getLevel().split(".").length - 1;
|
||||
}
|
||||
/**
|
||||
* Get path (without anchor) to the pointing file.
|
||||
* It also normalizes the file path.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getPath() {
|
||||
if (this.isExternal()) {
|
||||
return undefined;
|
||||
}
|
||||
const ref = this.getRef();
|
||||
if (!ref) {
|
||||
return undefined;
|
||||
}
|
||||
const parts = ref.split("#");
|
||||
const pathname = parts.length > 1 ? parts.slice(0, -1).join("#") : ref;
|
||||
// Normalize path to remove ('./', '/...', etc)
|
||||
return location_1.default.flatten(pathname);
|
||||
}
|
||||
/**
|
||||
* Return url if article is external
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getUrl() {
|
||||
return this.isExternal() ? this.getRef() : undefined;
|
||||
}
|
||||
/**
|
||||
* Get anchor for this article (or undefined)
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getAnchor() {
|
||||
const ref = this.getRef();
|
||||
const parts = ref.split("#");
|
||||
const anchor = parts.length > 1 ? `#${parts[parts.length - 1]}` : undefined;
|
||||
return anchor;
|
||||
}
|
||||
/**
|
||||
* Create a new level for a new child article
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
createChildLevel() {
|
||||
const level = this.getLevel();
|
||||
const subArticles = this.getArticles();
|
||||
const childLevel = `${level}.${subArticles.size + 1}`;
|
||||
return childLevel;
|
||||
}
|
||||
/**
|
||||
* Is article pointing to a page of an absolute url
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
isPage() {
|
||||
return Boolean(!this.isExternal() && this.getRef());
|
||||
}
|
||||
/**
|
||||
* Check if this article is a file (exatcly)
|
||||
*
|
||||
* @param {File} file
|
||||
* @return {boolean}
|
||||
*/
|
||||
isFile(file) {
|
||||
return file.getPath() === this.getPath() && this.getAnchor() === undefined;
|
||||
}
|
||||
/**
|
||||
* Check if this article is the introduction of the book
|
||||
*
|
||||
* @param {Book|Readme} book
|
||||
* @return {boolean}
|
||||
*/
|
||||
isReadme(book) {
|
||||
// @ts-expect-error: union
|
||||
const readme = book.getFile ? book : book.getReadme();
|
||||
const file = readme.getFile();
|
||||
return this.isFile(file);
|
||||
}
|
||||
/**
|
||||
* Is article pointing to aan absolute url
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
isExternal() {
|
||||
return location_1.default.isExternal(this.getRef());
|
||||
}
|
||||
/**
|
||||
* Create a SummaryArticle
|
||||
*
|
||||
* @param {Object} def
|
||||
* @return {SummaryArticle}
|
||||
*/
|
||||
static create(def, level) {
|
||||
const articles = (def.articles || []).map((article, i) => {
|
||||
if (article instanceof SummaryArticle) {
|
||||
return article;
|
||||
}
|
||||
return SummaryArticle.create(article, [level, i + 1].join("."));
|
||||
});
|
||||
return new SummaryArticle({
|
||||
level: level,
|
||||
title: def.title,
|
||||
ref: def.ref || def.path || "",
|
||||
articles: immutable_1.default.List(articles)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Has anchor for this article
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasAnchor() {
|
||||
const ref = this.getRef();
|
||||
return ref.includes("#");
|
||||
}
|
||||
/**
|
||||
* Find an article from a base one
|
||||
*
|
||||
* @param {Article|Part} base
|
||||
* @param {Function(article)} iter
|
||||
* @return {Article}
|
||||
*/
|
||||
static findArticle(base, iter) {
|
||||
const articles = base.getArticles();
|
||||
return articles.reduce((result, article) => {
|
||||
if (result)
|
||||
return result;
|
||||
if (iter(article)) {
|
||||
return article;
|
||||
}
|
||||
return SummaryArticle.findArticle(article, iter);
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
exports.default = SummaryArticle;
|
23
book/node_modules/honkit/lib/models/summaryPart.d.ts
generated
vendored
Normal file
23
book/node_modules/honkit/lib/models/summaryPart.d.ts
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import Immutable from "immutable";
|
||||
type Articles = Immutable.List<any>;
|
||||
declare const SummaryPart_base: Immutable.Record.Class;
|
||||
declare class SummaryPart extends SummaryPart_base {
|
||||
getLevel(): string;
|
||||
getTitle(): string;
|
||||
getArticles(): Articles;
|
||||
/**
|
||||
* Create a new level for a new child article
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
createChildLevel(): string;
|
||||
/**
|
||||
* Create a SummaryPart
|
||||
*
|
||||
* @param {Object} def
|
||||
* @return {SummaryPart}
|
||||
*/
|
||||
static create(def: any, level: any): SummaryPart;
|
||||
}
|
||||
export default SummaryPart;
|
||||
//# sourceMappingURL=summaryPart.d.ts.map
|
1
book/node_modules/honkit/lib/models/summaryPart.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/summaryPart.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"summaryPart.d.ts","sourceRoot":"","sources":["../../src/models/summaryPart.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAOlC,KAAK,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;AAEpC,cAAM,WAAY,SAAQ,gBAIxB;IACE,QAAQ,IAAI,MAAM;IAIlB,QAAQ,IAAI,MAAM;IAIlB,WAAW,IAAI,QAAQ;IAIvB;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;IAQ1B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,GAAG,WAAW;CAezC;AAED,eAAe,WAAW,CAAC"}
|
53
book/node_modules/honkit/lib/models/summaryPart.js
generated
vendored
Normal file
53
book/node_modules/honkit/lib/models/summaryPart.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const summaryArticle_1 = __importDefault(require("./summaryArticle"));
|
||||
class SummaryPart extends immutable_1.default.Record({
|
||||
level: String(),
|
||||
title: String(),
|
||||
articles: immutable_1.default.List()
|
||||
}) {
|
||||
getLevel() {
|
||||
return this.get("level");
|
||||
}
|
||||
getTitle() {
|
||||
return this.get("title");
|
||||
}
|
||||
getArticles() {
|
||||
return this.get("articles");
|
||||
}
|
||||
/**
|
||||
* Create a new level for a new child article
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
createChildLevel() {
|
||||
const level = this.getLevel();
|
||||
const subArticles = this.getArticles();
|
||||
const childLevel = `${level}.${subArticles.size + 1}`;
|
||||
return childLevel;
|
||||
}
|
||||
/**
|
||||
* Create a SummaryPart
|
||||
*
|
||||
* @param {Object} def
|
||||
* @return {SummaryPart}
|
||||
*/
|
||||
static create(def, level) {
|
||||
const articles = (def.articles || []).map((article, i) => {
|
||||
if (article instanceof summaryArticle_1.default) {
|
||||
return article;
|
||||
}
|
||||
return summaryArticle_1.default.create(article, [level, i + 1].join("."));
|
||||
});
|
||||
return new SummaryPart({
|
||||
level: String(level),
|
||||
title: def.title,
|
||||
articles: immutable_1.default.List(articles)
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = SummaryPart;
|
54
book/node_modules/honkit/lib/models/templateBlock.d.ts
generated
vendored
Normal file
54
book/node_modules/honkit/lib/models/templateBlock.d.ts
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import Immutable from "immutable";
|
||||
import TemplateShortcut from "./templateShortcut";
|
||||
import nunjucks from "nunjucks";
|
||||
declare const TemplateBlock_base: Immutable.Record.Class;
|
||||
declare class TemplateBlock extends TemplateBlock_base {
|
||||
getName(): string;
|
||||
getEndTag(): string;
|
||||
getProcess(): Function;
|
||||
getBlocks(): Immutable.List<string>;
|
||||
/**
|
||||
* Return shortcuts associated with this block or undefined
|
||||
* @return {TemplateShortcut|undefined}
|
||||
*/
|
||||
getShortcuts(): TemplateShortcut;
|
||||
/**
|
||||
* Return name for the nunjucks extension
|
||||
* @return {string}
|
||||
*/
|
||||
getExtensionName(): string;
|
||||
/**
|
||||
* Return a nunjucks extension to represents this block
|
||||
* @return {Nunjucks.Extension}
|
||||
*/
|
||||
toNunjucksExt(mainContext: any, blocksOutput: any): nunjucks.Extension;
|
||||
/**
|
||||
* Apply a block to a content
|
||||
* @param {Object} inner
|
||||
* @param {Object} context
|
||||
* @return {Promise<String>|String}
|
||||
*/
|
||||
applyBlock(inner: any, context: any): any;
|
||||
/**
|
||||
* Normalize result from a block process function
|
||||
* @param {Object|String} result
|
||||
* @return {Object}
|
||||
*/
|
||||
normalizeBlockResult(result: any): any;
|
||||
/**
|
||||
* Convert a block result to HTML
|
||||
* @param {Object} result
|
||||
* @param {Object} blocksOutput: stored post processing blocks in this object
|
||||
* @return {string}
|
||||
*/
|
||||
blockResultToHtml(result: any, blocksOutput: any): any;
|
||||
/**
|
||||
* Create a template block from a function or an object
|
||||
* @param {string} blockName
|
||||
* @param {Object} block
|
||||
* @return {TemplateBlock}
|
||||
*/
|
||||
static create(blockName: any, block: any): any;
|
||||
}
|
||||
export default TemplateBlock;
|
||||
//# sourceMappingURL=templateBlock.d.ts.map
|
1
book/node_modules/honkit/lib/models/templateBlock.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/templateBlock.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"templateBlock.d.ts","sourceRoot":"","sources":["../../src/models/templateBlock.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,QAAQ,MAAM,UAAU,CAAC;;AAIhC,cAAM,aAAc,SAAQ,kBAkB3B;IACG,OAAO,IAAI,MAAM;IAIjB,SAAS,IAAI,MAAM;IAInB,UAAU,IAAI,QAAQ;IAItB,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;IAInC;;;OAGG;IACH,YAAY,IAAI,gBAAgB;IAQhC;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;OAGG;IACH,aAAa,CAAC,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,QAAQ,CAAC,SAAS;IA0H5D;;;;;OAKG;IACH,UAAU,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAiBzB;;;;OAIG;IACH,oBAAoB,CAAC,MAAM,KAAA;IAS3B;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,KAAA,EAAE,YAAY,KAAA;IAkBtC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,KAAA,EAAE,KAAK,KAAA;CAYjC;AAYD,eAAe,aAAa,CAAC"}
|
230
book/node_modules/honkit/lib/models/templateBlock.js
generated
vendored
Normal file
230
book/node_modules/honkit/lib/models/templateBlock.js
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const extend_1 = __importDefault(require("extend"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const promise_1 = __importDefault(require("../utils/promise"));
|
||||
const genKey_1 = __importDefault(require("../utils/genKey"));
|
||||
const templateShortcut_1 = __importDefault(require("./templateShortcut"));
|
||||
const NODE_ENDARGS = "%%endargs%%";
|
||||
class TemplateBlock extends immutable_1.default.Record({
|
||||
// Name of block, also the start tag
|
||||
name: String(),
|
||||
// End tag, default to "end<name>"
|
||||
end: String(),
|
||||
// Function to process the block content
|
||||
process: Function(),
|
||||
// List of String, for inner block tags
|
||||
blocks: immutable_1.default.List(),
|
||||
// List of shortcuts to replace with this block
|
||||
shortcuts: immutable_1.default.Map()
|
||||
}, "TemplateBlock") {
|
||||
getName() {
|
||||
return this.get("name");
|
||||
}
|
||||
getEndTag() {
|
||||
return this.get("end") || `end${this.getName()}`;
|
||||
}
|
||||
getProcess() {
|
||||
return this.get("process");
|
||||
}
|
||||
getBlocks() {
|
||||
return this.get("blocks");
|
||||
}
|
||||
/**
|
||||
* Return shortcuts associated with this block or undefined
|
||||
* @return {TemplateShortcut|undefined}
|
||||
*/
|
||||
getShortcuts() {
|
||||
const shortcuts = this.get("shortcuts");
|
||||
if (shortcuts.size === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return templateShortcut_1.default.createForBlock(this, shortcuts);
|
||||
}
|
||||
/**
|
||||
* Return name for the nunjucks extension
|
||||
* @return {string}
|
||||
*/
|
||||
getExtensionName() {
|
||||
return `Block${this.getName()}Extension`;
|
||||
}
|
||||
/**
|
||||
* Return a nunjucks extension to represents this block
|
||||
* @return {Nunjucks.Extension}
|
||||
*/
|
||||
toNunjucksExt(mainContext, blocksOutput) {
|
||||
blocksOutput = blocksOutput || {};
|
||||
const that = this;
|
||||
const name = this.getName();
|
||||
const endTag = this.getEndTag();
|
||||
const blocks = this.getBlocks().toJS();
|
||||
function Ext() {
|
||||
this.tags = [name];
|
||||
this.parse = function (parser, nodes) {
|
||||
let lastBlockName = null;
|
||||
let lastBlockArgs = null;
|
||||
const allBlocks = blocks.concat([endTag]);
|
||||
// Parse first block
|
||||
const tok = parser.nextToken();
|
||||
lastBlockArgs = parser.parseSignature(null, true);
|
||||
parser.advanceAfterBlockEnd(tok.value);
|
||||
const args = new nodes.NodeList();
|
||||
const bodies = [];
|
||||
const blockNamesNode = new nodes.Array(tok.lineno, tok.colno);
|
||||
const blockArgCounts = new nodes.Array(tok.lineno, tok.colno);
|
||||
// Parse while we found "end<block>"
|
||||
do {
|
||||
// Read body
|
||||
const currentBody = parser.parseUntilBlocks.apply(parser, allBlocks);
|
||||
// Handle body with previous block name and args
|
||||
blockNamesNode.addChild(new nodes.Literal(args.lineno, args.colno, lastBlockName));
|
||||
blockArgCounts.addChild(new nodes.Literal(args.lineno, args.colno, lastBlockArgs.children.length));
|
||||
bodies.push(currentBody);
|
||||
// Append arguments of this block as arguments of the run function
|
||||
lastBlockArgs.children.forEach((child) => {
|
||||
args.addChild(child);
|
||||
});
|
||||
// Read new block
|
||||
lastBlockName = parser.nextToken().value;
|
||||
// Parse signature and move to the end of the block
|
||||
if (lastBlockName != endTag) {
|
||||
lastBlockArgs = parser.parseSignature(null, true);
|
||||
}
|
||||
parser.advanceAfterBlockEnd(lastBlockName);
|
||||
} while (lastBlockName != endTag);
|
||||
args.addChild(blockNamesNode);
|
||||
args.addChild(blockArgCounts);
|
||||
args.addChild(new nodes.Literal(args.lineno, args.colno, NODE_ENDARGS));
|
||||
return new nodes.CallExtensionAsync(this, "run", args, bodies);
|
||||
};
|
||||
this.run = function (context) {
|
||||
const fnArgs = Array.prototype.slice.call(arguments, 1);
|
||||
let args;
|
||||
const blocks = [];
|
||||
let bodies = [];
|
||||
// Extract callback
|
||||
const callback = fnArgs.pop();
|
||||
// Detect end of arguments
|
||||
const endArgIndex = fnArgs.indexOf(NODE_ENDARGS);
|
||||
// Extract arguments and bodies
|
||||
args = fnArgs.slice(0, endArgIndex);
|
||||
bodies = fnArgs.slice(endArgIndex + 1);
|
||||
// Extract block counts
|
||||
const blockArgCounts = args.pop();
|
||||
const blockNames = args.pop();
|
||||
// Recreate list of blocks
|
||||
blockNames.forEach((name, i) => {
|
||||
const countArgs = blockArgCounts[i];
|
||||
const blockBody = bodies.shift();
|
||||
const blockArgs = countArgs > 0 ? args.slice(0, countArgs) : [];
|
||||
args = args.slice(countArgs);
|
||||
const blockKwargs = extractKwargs(blockArgs);
|
||||
blocks.push({
|
||||
name: name,
|
||||
body: blockBody(),
|
||||
args: blockArgs,
|
||||
kwargs: blockKwargs
|
||||
});
|
||||
});
|
||||
const mainBlock = blocks.shift();
|
||||
mainBlock.blocks = blocks;
|
||||
(0, promise_1.default)()
|
||||
.then(() => {
|
||||
const ctx = (0, extend_1.default)({
|
||||
ctx: context
|
||||
}, mainContext || {});
|
||||
return that.applyBlock(mainBlock, ctx);
|
||||
})
|
||||
.then((result) => {
|
||||
return that.blockResultToHtml(result, blocksOutput);
|
||||
})
|
||||
.nodeify(callback);
|
||||
};
|
||||
}
|
||||
// @ts-expect-error: nunjucks.Extension
|
||||
return Ext;
|
||||
}
|
||||
/**
|
||||
* Apply a block to a content
|
||||
* @param {Object} inner
|
||||
* @param {Object} context
|
||||
* @return {Promise<String>|String}
|
||||
*/
|
||||
applyBlock(inner, context) {
|
||||
const processFn = this.getProcess();
|
||||
inner = inner || {};
|
||||
inner.args = inner.args || [];
|
||||
inner.kwargs = inner.kwargs || {};
|
||||
inner.blocks = inner.blocks || [];
|
||||
const r = processFn.call(context, inner);
|
||||
if (promise_1.default.isPromiseAlike(r)) {
|
||||
return r.then(this.normalizeBlockResult.bind(this));
|
||||
}
|
||||
else {
|
||||
return this.normalizeBlockResult(r);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Normalize result from a block process function
|
||||
* @param {Object|String} result
|
||||
* @return {Object}
|
||||
*/
|
||||
normalizeBlockResult(result) {
|
||||
if (is_1.default.string(result)) {
|
||||
result = { body: result };
|
||||
}
|
||||
result.name = this.getName();
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Convert a block result to HTML
|
||||
* @param {Object} result
|
||||
* @param {Object} blocksOutput: stored post processing blocks in this object
|
||||
* @return {string}
|
||||
*/
|
||||
blockResultToHtml(result, blocksOutput) {
|
||||
let indexedKey;
|
||||
const toIndex = !result.parse || result.post !== undefined;
|
||||
if (toIndex) {
|
||||
indexedKey = (0, genKey_1.default)();
|
||||
blocksOutput[indexedKey] = result;
|
||||
}
|
||||
// Parsable block, just return it
|
||||
if (result.parse) {
|
||||
return result.body;
|
||||
}
|
||||
// Return it as a position marker
|
||||
return `{{-%${indexedKey}%-}}`;
|
||||
}
|
||||
/**
|
||||
* Create a template block from a function or an object
|
||||
* @param {string} blockName
|
||||
* @param {Object} block
|
||||
* @return {TemplateBlock}
|
||||
*/
|
||||
static create(blockName, block) {
|
||||
if (is_1.default.fn(block)) {
|
||||
// @ts-expect-error ts-migrate(2350) FIXME: Only a void function can be called with the 'new' ... Remove this comment to see the full error message
|
||||
block = new immutable_1.default.Map({
|
||||
process: block
|
||||
});
|
||||
}
|
||||
block = new TemplateBlock(block);
|
||||
block = block.set("name", blockName);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Extract kwargs from an arguments array
|
||||
* @param {Array} args
|
||||
* @return {Object}
|
||||
*/
|
||||
function extractKwargs(args) {
|
||||
const last = args[args.length - 1];
|
||||
return is_1.default.object(last) && last.__keywords ? args.pop() : {};
|
||||
}
|
||||
exports.default = TemplateBlock;
|
35
book/node_modules/honkit/lib/models/templateEngine.d.ts
generated
vendored
Normal file
35
book/node_modules/honkit/lib/models/templateEngine.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import nunjucks from "nunjucks";
|
||||
import Immutable from "immutable";
|
||||
import TemplateBlock from "./templateBlock";
|
||||
import TemplateOutput from "./templateOutput";
|
||||
type Extensions = Immutable.Map<any, any>;
|
||||
declare const TemplateEngine_base: Immutable.Record.Class;
|
||||
declare class TemplateEngine extends TemplateEngine_base {
|
||||
getBlocks(): TemplateBlock;
|
||||
getGlobals(): Immutable.Map<string, any>;
|
||||
getFilters(): any;
|
||||
getShortcuts(): any;
|
||||
getLoader(): nunjucks.FileSystemLoader;
|
||||
getContext(): object;
|
||||
getExtensions(): Extensions;
|
||||
/**
|
||||
Return a block by its name (or undefined)
|
||||
|
||||
@param {string} name
|
||||
@return {TemplateBlock}
|
||||
*/
|
||||
getBlock(name: string): TemplateBlock;
|
||||
/**
|
||||
Return a nunjucks environment from this configuration
|
||||
*/
|
||||
toNunjucks(blocksOutput?: TemplateOutput): nunjucks.Environment;
|
||||
/**
|
||||
Create a template engine
|
||||
|
||||
@param {Object} def
|
||||
@return {TemplateEngine}
|
||||
*/
|
||||
static create(def: any): TemplateEngine;
|
||||
}
|
||||
export default TemplateEngine;
|
||||
//# sourceMappingURL=templateEngine.d.ts.map
|
1
book/node_modules/honkit/lib/models/templateEngine.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/templateEngine.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"templateEngine.d.ts","sourceRoot":"","sources":["../../src/models/templateEngine.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,KAAK,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;;AAE1C,cAAM,cAAe,SAAQ,mBAqB5B;IACG,SAAS,IAAI,aAAa;IAI1B,UAAU,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAIxC,UAAU;IAIV,YAAY;IAIZ,SAAS,IAAI,QAAQ,CAAC,gBAAgB;IAItC,UAAU,IAAI,MAAM;IAIpB,aAAa,IAAI,UAAU;IAI3B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;IAOrC;;OAEG;IACH,UAAU,CAAC,YAAY,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC,WAAW;IAiD/D;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc;CAU1C;AAED,eAAe,cAAc,CAAC"}
|
115
book/node_modules/honkit/lib/models/templateEngine.js
generated
vendored
Normal file
115
book/node_modules/honkit/lib/models/templateEngine.js
generated
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const nunjucks_1 = __importDefault(require("nunjucks"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
class TemplateEngine extends immutable_1.default.Record({
|
||||
// Map of {TemplateBlock}
|
||||
blocks: immutable_1.default.Map(),
|
||||
// Map of Extension
|
||||
extensions: immutable_1.default.Map(),
|
||||
// Map of filters: {string} name -> {Function} fn
|
||||
filters: immutable_1.default.Map(),
|
||||
// Map of globals: {string} name -> {Mixed}
|
||||
globals: immutable_1.default.Map(),
|
||||
// Context for filters / blocks
|
||||
context: Object(),
|
||||
// Nunjucks loader
|
||||
loader: new nunjucks_1.default.FileSystemLoader("views")
|
||||
}, "TemplateEngine") {
|
||||
getBlocks() {
|
||||
return this.get("blocks");
|
||||
}
|
||||
getGlobals() {
|
||||
return this.get("globals");
|
||||
}
|
||||
getFilters() {
|
||||
return this.get("filters");
|
||||
}
|
||||
getShortcuts() {
|
||||
return this.get("shortcuts");
|
||||
}
|
||||
getLoader() {
|
||||
return this.get("loader");
|
||||
}
|
||||
getContext() {
|
||||
return this.get("context");
|
||||
}
|
||||
getExtensions() {
|
||||
return this.get("extensions");
|
||||
}
|
||||
/**
|
||||
Return a block by its name (or undefined)
|
||||
|
||||
@param {string} name
|
||||
@return {TemplateBlock}
|
||||
*/
|
||||
getBlock(name) {
|
||||
const blocks = this.getBlocks();
|
||||
return blocks.find((block) => {
|
||||
return block.getName() === name;
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return a nunjucks environment from this configuration
|
||||
*/
|
||||
toNunjucks(blocksOutput) {
|
||||
const loader = this.getLoader();
|
||||
const blocks = this.getBlocks();
|
||||
const filters = this.getFilters();
|
||||
const globals = this.getGlobals();
|
||||
const extensions = this.getExtensions();
|
||||
const context = this.getContext();
|
||||
const env = new nunjucks_1.default.Environment(loader, {
|
||||
// Escaping is done after by the asciidoc/markdown parser
|
||||
autoescape: false,
|
||||
// Syntax
|
||||
tags: {
|
||||
blockStart: "{%",
|
||||
blockEnd: "%}",
|
||||
variableStart: "{{",
|
||||
variableEnd: "}}",
|
||||
commentStart: "{###",
|
||||
commentEnd: "###}"
|
||||
}
|
||||
});
|
||||
// Add filters
|
||||
filters.forEach((filterFn, filterName) => {
|
||||
env.addFilter(filterName, filterFn.bind(context));
|
||||
});
|
||||
// Add blocks
|
||||
blocks.forEach((block) => {
|
||||
const extName = block.getExtensionName();
|
||||
const Ext = block.toNunjucksExt(context, blocksOutput);
|
||||
env.addExtension(extName, new Ext());
|
||||
});
|
||||
// Add globals
|
||||
globals.forEach((globalValue, globalName) => {
|
||||
env.addGlobal(globalName, globalValue);
|
||||
});
|
||||
// Add other extensions
|
||||
extensions.forEach((ext, extName) => {
|
||||
env.addExtension(extName, ext);
|
||||
});
|
||||
return env;
|
||||
}
|
||||
/**
|
||||
Create a template engine
|
||||
|
||||
@param {Object} def
|
||||
@return {TemplateEngine}
|
||||
*/
|
||||
static create(def) {
|
||||
return new TemplateEngine({
|
||||
blocks: immutable_1.default.List(def.blocks || []),
|
||||
extensions: immutable_1.default.Map(def.extensions || {}),
|
||||
filters: immutable_1.default.Map(def.filters || {}),
|
||||
globals: immutable_1.default.Map(def.globals || {}),
|
||||
context: def.context,
|
||||
loader: def.loader
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = TemplateEngine;
|
18
book/node_modules/honkit/lib/models/templateOutput.d.ts
generated
vendored
Normal file
18
book/node_modules/honkit/lib/models/templateOutput.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import Immutable from "immutable";
|
||||
import TemplateBlock from "./templateBlock";
|
||||
declare const TemplateOutput_base: Immutable.Record.Class;
|
||||
declare class TemplateOutput extends TemplateOutput_base {
|
||||
getContent(): string;
|
||||
getBlocks(): TemplateBlock;
|
||||
/**
|
||||
* Update content of this output
|
||||
*/
|
||||
setContent(content: string): TemplateOutput;
|
||||
/**
|
||||
* Create a TemplateOutput from a text content
|
||||
* and an object containing block definition
|
||||
*/
|
||||
static create(content: string, blocks: object): TemplateOutput;
|
||||
}
|
||||
export default TemplateOutput;
|
||||
//# sourceMappingURL=templateOutput.d.ts.map
|
1
book/node_modules/honkit/lib/models/templateOutput.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/templateOutput.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"templateOutput.d.ts","sourceRoot":"","sources":["../../src/models/templateOutput.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,aAAa,MAAM,iBAAiB,CAAC;;AAE5C,cAAM,cAAe,SAAQ,mBAS5B;IACG,UAAU,IAAI,MAAM;IAIpB,SAAS,IAAI,aAAa;IAI1B;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc;IAI3C;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc;CAMjE;AAED,eAAe,cAAc,CAAC"}
|
36
book/node_modules/honkit/lib/models/templateOutput.js
generated
vendored
Normal file
36
book/node_modules/honkit/lib/models/templateOutput.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
class TemplateOutput extends immutable_1.default.Record({
|
||||
// Text content of the template
|
||||
content: String(),
|
||||
// Map of blocks to replace / post process
|
||||
blocks: immutable_1.default.Map()
|
||||
}, "TemplateOutput") {
|
||||
getContent() {
|
||||
return this.get("content");
|
||||
}
|
||||
getBlocks() {
|
||||
return this.get("blocks");
|
||||
}
|
||||
/**
|
||||
* Update content of this output
|
||||
*/
|
||||
setContent(content) {
|
||||
return this.set("content", content);
|
||||
}
|
||||
/**
|
||||
* Create a TemplateOutput from a text content
|
||||
* and an object containing block definition
|
||||
*/
|
||||
static create(content, blocks) {
|
||||
return new TemplateOutput({
|
||||
content: content,
|
||||
blocks: immutable_1.default.fromJS(blocks)
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = TemplateOutput;
|
28
book/node_modules/honkit/lib/models/templateShortcut.d.ts
generated
vendored
Normal file
28
book/node_modules/honkit/lib/models/templateShortcut.d.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import Immutable from "immutable";
|
||||
import Parser from "./parser";
|
||||
import TemplateBlock from "./templateBlock";
|
||||
declare const TemplateShortcut_base: Immutable.Record.Class;
|
||||
declare class TemplateShortcut extends TemplateShortcut_base {
|
||||
getStart(): string;
|
||||
getEnd(): string;
|
||||
getStartTag(): string;
|
||||
getEndTag(): string;
|
||||
getParsers(): Parser;
|
||||
/**
|
||||
Test if this shortcut accept a parser
|
||||
|
||||
@param {Parsers|String} parser
|
||||
@return {boolean}
|
||||
*/
|
||||
acceptParser(parser: Parser | string): any;
|
||||
/**
|
||||
Create a shortcut for a block
|
||||
|
||||
@param {TemplateBlock} block
|
||||
@param {Map} details
|
||||
@return {TemplateShortcut}
|
||||
*/
|
||||
static createForBlock(block: TemplateBlock, details: Immutable.Map<string, any>): TemplateShortcut;
|
||||
}
|
||||
export default TemplateShortcut;
|
||||
//# sourceMappingURL=templateShortcut.d.ts.map
|
1
book/node_modules/honkit/lib/models/templateShortcut.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/models/templateShortcut.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"templateShortcut.d.ts","sourceRoot":"","sources":["../../src/models/templateShortcut.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,aAAa,MAAM,iBAAiB,CAAC;;AAM5C,cAAM,gBAAiB,SAAQ,qBAY9B;IACG,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAIhB,WAAW,IAAI,MAAM;IAIrB,SAAS,IAAI,MAAM;IAInB,UAAU,IAAI,MAAM;IAIpB;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IASpC;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;CAWrG;AAED,eAAe,gBAAgB,CAAC"}
|
65
book/node_modules/honkit/lib/models/templateShortcut.js
generated
vendored
Normal file
65
book/node_modules/honkit/lib/models/templateShortcut.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
/*
|
||||
A TemplateShortcut is defined in plugin's template blocks
|
||||
to replace content with a templating block using delimiters.
|
||||
*/
|
||||
class TemplateShortcut extends immutable_1.default.Record({
|
||||
// List of parser names accepting this shortcut
|
||||
parsers: immutable_1.default.Map(),
|
||||
start: String(),
|
||||
end: String(),
|
||||
startTag: String(),
|
||||
endTag: String()
|
||||
}, "TemplateShortcut") {
|
||||
getStart() {
|
||||
return this.get("start");
|
||||
}
|
||||
getEnd() {
|
||||
return this.get("end");
|
||||
}
|
||||
getStartTag() {
|
||||
return this.get("startTag");
|
||||
}
|
||||
getEndTag() {
|
||||
return this.get("endTag");
|
||||
}
|
||||
getParsers() {
|
||||
return this.get("parsers");
|
||||
}
|
||||
/**
|
||||
Test if this shortcut accept a parser
|
||||
|
||||
@param {Parsers|String} parser
|
||||
@return {boolean}
|
||||
*/
|
||||
acceptParser(parser) {
|
||||
if (typeof parser !== "string") {
|
||||
parser = parser.getName();
|
||||
}
|
||||
const parserNames = this.get("parsers");
|
||||
return parserNames.includes(parser);
|
||||
}
|
||||
/**
|
||||
Create a shortcut for a block
|
||||
|
||||
@param {TemplateBlock} block
|
||||
@param {Map} details
|
||||
@return {TemplateShortcut}
|
||||
*/
|
||||
static createForBlock(block, details) {
|
||||
details = immutable_1.default.fromJS(details);
|
||||
return new TemplateShortcut({
|
||||
parsers: details.get("parsers"),
|
||||
start: details.get("start"),
|
||||
end: details.get("end"),
|
||||
startTag: block.getName(),
|
||||
endTag: block.getEndTag()
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = TemplateShortcut;
|
Reference in New Issue
Block a user