asciidoctor 4.0.0-alpha.2 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/types/abstract_node.d.ts +1 -2
- package/types/attribute_entry.d.ts +8 -0
- package/types/browser/reader.d.ts +1 -1
- package/types/extensions.d.ts +203 -9
- package/types/http_cache.d.ts +59 -0
- package/types/index.d.cts +12 -1
- package/types/index.d.ts +12 -1
- package/types/logging.d.ts +15 -4
- package/types/path_resolver.d.ts +0 -5
- package/types/stylesheets.d.ts +1 -0
- package/types/table.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asciidoctor",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "A JavaScript AsciiDoc processor powered by Asciidoctor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "node --test test/cli.test.js",
|
|
17
|
+
"test:deno": "deno test --allow-env --no-check --allow-read --allow-sys --allow-write --allow-run --allow-net test/cli.test.js",
|
|
17
18
|
"lint": "biome lint bin lib tasks index.js rollup.config.js",
|
|
18
19
|
"format": "biome format --write bin lib tasks index.js rollup.config.js",
|
|
19
20
|
"build:bundle": "rollup -c",
|
|
@@ -53,11 +54,11 @@
|
|
|
53
54
|
},
|
|
54
55
|
"homepage": "https://github.com/asciidoctor/asciidoctor.js",
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@asciidoctor/core": "4.0.0-alpha.
|
|
57
|
+
"@asciidoctor/core": "4.0.0-alpha.4"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@biomejs/biome": "^2.4.13",
|
|
60
|
-
"@rollup/plugin-commonjs": "^
|
|
61
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
61
62
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
62
63
|
"ejs": "^3.1.10",
|
|
63
64
|
"handlebars": "^4.7.8",
|
|
@@ -66,6 +67,6 @@
|
|
|
66
67
|
"pug": "^3.0.3"
|
|
67
68
|
},
|
|
68
69
|
"volta": {
|
|
69
|
-
"node": "24.
|
|
70
|
+
"node": "24.15.0"
|
|
70
71
|
}
|
|
71
72
|
}
|
package/types/abstract_node.d.ts
CHANGED
|
@@ -278,10 +278,9 @@ export abstract class AbstractNode {
|
|
|
278
278
|
* imageUri, the caller must await the returned Promise.
|
|
279
279
|
*
|
|
280
280
|
* @param {string} imageUri - The URI from which to read the image data (http/https/ftp).
|
|
281
|
-
* @param {boolean} [cacheUri=false] - A Boolean to control caching (not yet supported in JS).
|
|
282
281
|
* @returns {Promise<string>} a Promise resolving to a String data URI.
|
|
283
282
|
*/
|
|
284
|
-
generateDataUriFromUri(imageUri: string
|
|
283
|
+
generateDataUriFromUri(imageUri: string): Promise<string>;
|
|
285
284
|
/**
|
|
286
285
|
* Normalize the asset file or directory to a concrete and rinsed path.
|
|
287
286
|
*
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the attribute entries stored for the given block attributes object,
|
|
3
|
+
* or undefined if none have been saved.
|
|
4
|
+
* @param {Object} blockAttributes
|
|
5
|
+
* @returns {AttributeEntry[]|undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function getAttributeEntries(blockAttributes: any): AttributeEntry[] | undefined;
|
|
8
|
+
export const ATTR_ENTRIES_KEY: unique symbol;
|
|
1
9
|
export class AttributeEntry {
|
|
2
10
|
constructor(name: any, value: any, negate?: any);
|
|
3
11
|
name: any;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 1. target starts with file:// → inc_path = relpath = target
|
|
8
8
|
* 2. target is a URI → must descend from baseDir or allow-uri-read; else → link
|
|
9
9
|
* 3. target is an absolute OS path → prepend file:// (or file:///)
|
|
10
|
-
* 4. baseDir == '.' → inc_path = relpath = target (resolved by
|
|
10
|
+
* 4. baseDir == '.' → inc_path = relpath = target (resolved by fetch)
|
|
11
11
|
* 5. baseDir starts with file:// OR baseDir is not a URI → inc_path = baseDir/target; relpath = target
|
|
12
12
|
* 6. baseDir is an absolute URL → inc_path = baseDir/target; relpath = target
|
|
13
13
|
*
|
package/types/extensions.d.ts
CHANGED
|
@@ -224,7 +224,12 @@ export class Processor {
|
|
|
224
224
|
* Extensions.register(function () { this.preprocessor(CommentStripPreprocessor) })
|
|
225
225
|
*/
|
|
226
226
|
export class Preprocessor extends Processor {
|
|
227
|
-
|
|
227
|
+
/**
|
|
228
|
+
* @param {Document} document - The document being parsed.
|
|
229
|
+
* @param {Reader} reader - The reader positioned at the beginning of the source.
|
|
230
|
+
* @returns {Reader|undefined} The same or a substitute Reader, or undefined to use the original.
|
|
231
|
+
*/
|
|
232
|
+
process(document: Document, reader: Reader): Reader | undefined;
|
|
228
233
|
}
|
|
229
234
|
export namespace Preprocessor {
|
|
230
235
|
export { DocumentProcessorDsl as DSL };
|
|
@@ -246,7 +251,11 @@ export namespace Preprocessor {
|
|
|
246
251
|
* Extensions.register(function () { this.treeProcessor(ShoutTreeProcessor) })
|
|
247
252
|
*/
|
|
248
253
|
export class TreeProcessor extends Processor {
|
|
249
|
-
|
|
254
|
+
/**
|
|
255
|
+
* @param {Document} document - The parsed document.
|
|
256
|
+
* @returns {void}
|
|
257
|
+
*/
|
|
258
|
+
process(document: Document): void;
|
|
250
259
|
}
|
|
251
260
|
export namespace TreeProcessor {
|
|
252
261
|
export { DocumentProcessorDsl as DSL };
|
|
@@ -271,7 +280,12 @@ export const Treeprocessor: typeof TreeProcessor;
|
|
|
271
280
|
* Extensions.register(function () { this.postprocessor(FooterPostprocessor) })
|
|
272
281
|
*/
|
|
273
282
|
export class Postprocessor extends Processor {
|
|
274
|
-
|
|
283
|
+
/**
|
|
284
|
+
* @param {Document} document - The converted document.
|
|
285
|
+
* @param {string} output - The converted output string.
|
|
286
|
+
* @returns {string} The (possibly modified) output string.
|
|
287
|
+
*/
|
|
288
|
+
process(document: Document, output: string): string;
|
|
275
289
|
}
|
|
276
290
|
export namespace Postprocessor {
|
|
277
291
|
export { DocumentProcessorDsl as DSL };
|
|
@@ -282,8 +296,20 @@ export namespace Postprocessor {
|
|
|
282
296
|
* Implementations must extend IncludeProcessor.
|
|
283
297
|
*/
|
|
284
298
|
export class IncludeProcessor extends Processor {
|
|
285
|
-
|
|
286
|
-
|
|
299
|
+
/**
|
|
300
|
+
* @param {Document} document - The document being parsed.
|
|
301
|
+
* @param {Reader} reader - The reader for the including document.
|
|
302
|
+
* @param {string} target - The target of the include directive.
|
|
303
|
+
* @param {Record<string, string>} attributes - The parsed include attributes.
|
|
304
|
+
* @returns {void}
|
|
305
|
+
*/
|
|
306
|
+
process(document: Document, reader: Reader, target: string, attributes: Record<string, string>): void;
|
|
307
|
+
/**
|
|
308
|
+
* @param {Document} doc - The document being parsed.
|
|
309
|
+
* @param {string} target - The target of the include directive.
|
|
310
|
+
* @returns {boolean} true if this processor handles the given target.
|
|
311
|
+
*/
|
|
312
|
+
handles(doc: Document, target: string): boolean;
|
|
287
313
|
}
|
|
288
314
|
export namespace IncludeProcessor {
|
|
289
315
|
export { IncludeProcessorDsl as DSL };
|
|
@@ -295,7 +321,11 @@ export namespace IncludeProcessor {
|
|
|
295
321
|
* Implementations must extend DocinfoProcessor.
|
|
296
322
|
*/
|
|
297
323
|
export class DocinfoProcessor extends Processor {
|
|
298
|
-
|
|
324
|
+
/**
|
|
325
|
+
* @param {Document} document - The document being converted.
|
|
326
|
+
* @returns {string} The docinfo content to inject into the document.
|
|
327
|
+
*/
|
|
328
|
+
process(document: Document): string;
|
|
299
329
|
}
|
|
300
330
|
export namespace DocinfoProcessor {
|
|
301
331
|
export { DocinfoProcessorDsl as DSL };
|
|
@@ -331,7 +361,13 @@ export namespace DocinfoProcessor {
|
|
|
331
361
|
export class BlockProcessor extends Processor {
|
|
332
362
|
constructor(name?: any, config?: {});
|
|
333
363
|
name: any;
|
|
334
|
-
|
|
364
|
+
/**
|
|
365
|
+
* @param {AbstractBlock} parent - The enclosing block.
|
|
366
|
+
* @param {Reader} reader - The reader positioned at the block content.
|
|
367
|
+
* @param {Record<string, unknown>} attributes - The parsed block attributes.
|
|
368
|
+
* @returns {Block|void} A block node, or void to let the parser handle it.
|
|
369
|
+
*/
|
|
370
|
+
process(parent: AbstractBlock, reader: Reader, attributes: Record<string, unknown>): Block | void;
|
|
335
371
|
}
|
|
336
372
|
export namespace BlockProcessor {
|
|
337
373
|
export { BlockProcessorDsl as DSL };
|
|
@@ -342,7 +378,13 @@ export namespace BlockProcessor {
|
|
|
342
378
|
export class MacroProcessor extends Processor {
|
|
343
379
|
constructor(name?: any, config?: {});
|
|
344
380
|
name: any;
|
|
345
|
-
|
|
381
|
+
/**
|
|
382
|
+
* @param {AbstractBlock} parent - The enclosing block.
|
|
383
|
+
* @param {string} target - The macro target (text between `name:` and `[`).
|
|
384
|
+
* @param {Record<string, unknown>} attributes - The parsed macro attributes.
|
|
385
|
+
* @returns {Block|Inline|void}
|
|
386
|
+
*/
|
|
387
|
+
process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Block | Inline | void;
|
|
346
388
|
}
|
|
347
389
|
/**
|
|
348
390
|
* BlockMacroProcessors handle block macros with a custom name.
|
|
@@ -370,6 +412,13 @@ export class MacroProcessor extends Processor {
|
|
|
370
412
|
*/
|
|
371
413
|
export class BlockMacroProcessor extends MacroProcessor {
|
|
372
414
|
_name: any;
|
|
415
|
+
/**
|
|
416
|
+
* @param {AbstractBlock} parent - The enclosing block.
|
|
417
|
+
* @param {string} target - The macro target.
|
|
418
|
+
* @param {Record<string, unknown>} attributes - The parsed macro attributes.
|
|
419
|
+
* @returns {Block} A block node created with one of the `createBlock` helpers.
|
|
420
|
+
*/
|
|
421
|
+
process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Block;
|
|
373
422
|
}
|
|
374
423
|
export namespace BlockMacroProcessor {
|
|
375
424
|
export { MacroProcessorDsl as DSL };
|
|
@@ -407,6 +456,13 @@ export class InlineMacroProcessor extends MacroProcessor {
|
|
|
407
456
|
* @returns {RegExp}
|
|
408
457
|
*/
|
|
409
458
|
get regexp(): RegExp;
|
|
459
|
+
/**
|
|
460
|
+
* @param {AbstractBlock} parent - The enclosing block.
|
|
461
|
+
* @param {string} target - The macro target.
|
|
462
|
+
* @param {Record<string, unknown>} attributes - The parsed macro attributes.
|
|
463
|
+
* @returns {Inline} An Inline node created with `this.createInline(...)`.
|
|
464
|
+
*/
|
|
465
|
+
process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Inline;
|
|
410
466
|
resolveRegexp(name: any, format: any): any;
|
|
411
467
|
}
|
|
412
468
|
export namespace InlineMacroProcessor {
|
|
@@ -456,7 +512,7 @@ export class Registry {
|
|
|
456
512
|
* @returns {Registry} this Registry.
|
|
457
513
|
*/
|
|
458
514
|
activate(document: Document): Registry;
|
|
459
|
-
document:
|
|
515
|
+
document: import("./document.js").Document;
|
|
460
516
|
/**
|
|
461
517
|
* Register a Preprocessor with the extension registry.
|
|
462
518
|
*
|
|
@@ -609,6 +665,12 @@ export class Registry {
|
|
|
609
665
|
* @returns {boolean}
|
|
610
666
|
*/
|
|
611
667
|
hasBlocks(): boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Retrieve all BlockProcessor Extension proxy objects.
|
|
670
|
+
*
|
|
671
|
+
* @returns {ProcessorExtension[]}
|
|
672
|
+
*/
|
|
673
|
+
blocks(): ProcessorExtension[];
|
|
612
674
|
/**
|
|
613
675
|
* Check whether a BlockProcessor is registered for the given name and context.
|
|
614
676
|
*
|
|
@@ -639,6 +701,12 @@ export class Registry {
|
|
|
639
701
|
* @returns {boolean}
|
|
640
702
|
*/
|
|
641
703
|
hasBlockMacros(): boolean;
|
|
704
|
+
/**
|
|
705
|
+
* Retrieve all BlockMacroProcessor Extension proxy objects.
|
|
706
|
+
*
|
|
707
|
+
* @returns {ProcessorExtension[]}
|
|
708
|
+
*/
|
|
709
|
+
blockMacros(): ProcessorExtension[];
|
|
642
710
|
/**
|
|
643
711
|
* Check whether a BlockMacroProcessor is registered for the given name.
|
|
644
712
|
*
|
|
@@ -700,6 +768,47 @@ export class Registry {
|
|
|
700
768
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
701
769
|
*/
|
|
702
770
|
prefer(...args: any[]): ProcessorExtension;
|
|
771
|
+
/** @returns {object} the plain Object that maps names to groups for this registry. */
|
|
772
|
+
getGroups(): object;
|
|
773
|
+
/** Alias for {@link preprocessors}. */
|
|
774
|
+
getPreprocessors(): ProcessorExtension[];
|
|
775
|
+
/** Alias for {@link treeProcessors}. */
|
|
776
|
+
getTreeProcessors(): ProcessorExtension[];
|
|
777
|
+
/** Alias for {@link includeProcessors}. */
|
|
778
|
+
getIncludeProcessors(): ProcessorExtension[];
|
|
779
|
+
/** Alias for {@link postprocessors}. */
|
|
780
|
+
getPostprocessors(): ProcessorExtension[];
|
|
781
|
+
/**
|
|
782
|
+
* Alias for {@link docinfoProcessors}.
|
|
783
|
+
*
|
|
784
|
+
* @param {string|null} [location=null]
|
|
785
|
+
*/
|
|
786
|
+
getDocinfoProcessors(location?: string | null): ProcessorExtension[];
|
|
787
|
+
/** Alias for {@link blocks}. */
|
|
788
|
+
getBlocks(): ProcessorExtension[];
|
|
789
|
+
/** Alias for {@link blockMacros}. */
|
|
790
|
+
getBlockMacros(): ProcessorExtension[];
|
|
791
|
+
/** Alias for {@link inlineMacros}. */
|
|
792
|
+
getInlineMacros(): ProcessorExtension[];
|
|
793
|
+
/**
|
|
794
|
+
* Alias for {@link registeredForInlineMacro}.
|
|
795
|
+
*
|
|
796
|
+
* @param {string} name
|
|
797
|
+
*/
|
|
798
|
+
getInlineMacroFor(name: string): false | ProcessorExtension;
|
|
799
|
+
/**
|
|
800
|
+
* Alias for {@link registeredForBlock}.
|
|
801
|
+
*
|
|
802
|
+
* @param {string} name
|
|
803
|
+
* @param {string} context
|
|
804
|
+
*/
|
|
805
|
+
getBlockFor(name: string, context: string): false | ProcessorExtension;
|
|
806
|
+
/**
|
|
807
|
+
* Alias for {@link registeredForBlockMacro}.
|
|
808
|
+
*
|
|
809
|
+
* @param {string} name
|
|
810
|
+
*/
|
|
811
|
+
getBlockMacroFor(name: string): false | ProcessorExtension;
|
|
703
812
|
}
|
|
704
813
|
export namespace Extensions {
|
|
705
814
|
/**
|
|
@@ -708,6 +817,12 @@ export namespace Extensions {
|
|
|
708
817
|
* @returns {object}
|
|
709
818
|
*/
|
|
710
819
|
function groups(): object;
|
|
820
|
+
/**
|
|
821
|
+
* Alias for {@link groups}.
|
|
822
|
+
*
|
|
823
|
+
* @returns {object}
|
|
824
|
+
*/
|
|
825
|
+
function getGroups(): object;
|
|
711
826
|
/**
|
|
712
827
|
* Create a new Registry, optionally pre-populated with a named block.
|
|
713
828
|
*
|
|
@@ -868,6 +983,85 @@ export namespace Extensions {
|
|
|
868
983
|
*/
|
|
869
984
|
function newBlockMacroProcessor(name?: string, functions?: object, ...args: any[]): BlockMacroProcessor;
|
|
870
985
|
}
|
|
986
|
+
export type Document = import("./document.js").Document;
|
|
987
|
+
export type AbstractBlock = import("./abstract_block.js").AbstractBlock;
|
|
988
|
+
/**
|
|
989
|
+
* DSL interface for configuring a {@link Processor} instance.
|
|
990
|
+
* Applied to a processor instance via `Object.assign(instance, DslMixin)`.
|
|
991
|
+
*
|
|
992
|
+
* The `process` property behaves as a setter when called with a single Function
|
|
993
|
+
* argument (stores the process block), or as a passthrough caller otherwise.
|
|
994
|
+
*/
|
|
995
|
+
export type ProcessorDslInterface = {
|
|
996
|
+
/**
|
|
997
|
+
* - Set a config option.
|
|
998
|
+
*/
|
|
999
|
+
option: (key: string, value: unknown) => void;
|
|
1000
|
+
/**
|
|
1001
|
+
* - Register the process function.
|
|
1002
|
+
*/
|
|
1003
|
+
process: (fn: (...args: unknown[]) => unknown) => void;
|
|
1004
|
+
/**
|
|
1005
|
+
* - Returns true if a process function has been registered.
|
|
1006
|
+
*/
|
|
1007
|
+
processBlockGiven: () => boolean;
|
|
1008
|
+
};
|
|
1009
|
+
/**
|
|
1010
|
+
* DSL interface for document processors (Preprocessor, TreeProcessor, Postprocessor, DocinfoProcessor).
|
|
1011
|
+
*/
|
|
1012
|
+
export type DocumentProcessorDslInterface = ProcessorDslInterface & {
|
|
1013
|
+
prefer(): void;
|
|
1014
|
+
prepend(): void;
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* DSL interface for syntax processors (BlockProcessor, BlockMacroProcessor, InlineMacroProcessor).
|
|
1018
|
+
*/
|
|
1019
|
+
export type SyntaxProcessorDslInterface = ProcessorDslInterface & {
|
|
1020
|
+
named(value: string): void;
|
|
1021
|
+
contentModel(value: string): void;
|
|
1022
|
+
parseContentAs(value: string): void;
|
|
1023
|
+
positionalAttributes(...value: string[]): void;
|
|
1024
|
+
namePositionalAttributes(...value: string[]): void;
|
|
1025
|
+
positionalAttrs(...value: string[]): void;
|
|
1026
|
+
defaultAttributes(value: Record<string, string>): void;
|
|
1027
|
+
defaultAttrs(value: Record<string, string>): void;
|
|
1028
|
+
resolveAttributes(...args: unknown[]): void;
|
|
1029
|
+
resolvesAttributes(...args: unknown[]): void;
|
|
1030
|
+
};
|
|
1031
|
+
/**
|
|
1032
|
+
* DSL interface for include processors.
|
|
1033
|
+
*/
|
|
1034
|
+
export type IncludeProcessorDslInterface = DocumentProcessorDslInterface & {
|
|
1035
|
+
handles(fn: (doc: Document, target: string) => boolean): void;
|
|
1036
|
+
};
|
|
1037
|
+
/**
|
|
1038
|
+
* DSL interface for docinfo processors.
|
|
1039
|
+
*/
|
|
1040
|
+
export type DocinfoProcessorDslInterface = DocumentProcessorDslInterface & {
|
|
1041
|
+
atLocation(value: string): void;
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* DSL interface for block processors.
|
|
1045
|
+
*/
|
|
1046
|
+
export type BlockProcessorDslInterface = SyntaxProcessorDslInterface & {
|
|
1047
|
+
contexts(...value: (string | string[])[]): void;
|
|
1048
|
+
onContexts(...value: (string | string[])[]): void;
|
|
1049
|
+
onContext(...value: (string | string[])[]): void;
|
|
1050
|
+
bindTo(...value: (string | string[])[]): void;
|
|
1051
|
+
};
|
|
1052
|
+
/**
|
|
1053
|
+
* DSL interface for macro processors (block and inline macros).
|
|
1054
|
+
*/
|
|
1055
|
+
export type MacroProcessorDslInterface = SyntaxProcessorDslInterface;
|
|
1056
|
+
/**
|
|
1057
|
+
* DSL interface for inline macro processors.
|
|
1058
|
+
*/
|
|
1059
|
+
export type InlineMacroProcessorDslInterface = MacroProcessorDslInterface & {
|
|
1060
|
+
format(value: string): void;
|
|
1061
|
+
matchFormat(value: string): void;
|
|
1062
|
+
usingFormat(value: string): void;
|
|
1063
|
+
match(value: RegExp): void;
|
|
1064
|
+
};
|
|
871
1065
|
import { Section } from './section.js';
|
|
872
1066
|
import { Block } from './block.js';
|
|
873
1067
|
import { List } from './list.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a URI, routing through the HTTP cache when `cache-uri` is set on the document.
|
|
3
|
+
* @param {string} uri
|
|
4
|
+
* @param {object} doc - the current Document instance
|
|
5
|
+
* @returns {Promise<Response>}
|
|
6
|
+
*/
|
|
7
|
+
export function fetchUri(uri: string, doc: object): Promise<Response>;
|
|
8
|
+
/**
|
|
9
|
+
* Base HTTP cache class.
|
|
10
|
+
*
|
|
11
|
+
* The default implementation delegates directly to fetch() with no caching.
|
|
12
|
+
* Subclasses override read() to add caching behaviour.
|
|
13
|
+
*/
|
|
14
|
+
export class HttpCache {
|
|
15
|
+
/**
|
|
16
|
+
* Fetch content from a URI, optionally from a cache.
|
|
17
|
+
* @param {string} uri
|
|
18
|
+
* @returns {Promise<Response>}
|
|
19
|
+
*/
|
|
20
|
+
read(uri: string): Promise<Response>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* In-memory HTTP cache.
|
|
24
|
+
*
|
|
25
|
+
* Stores successful responses as ArrayBuffers keyed by URI. On a cache hit
|
|
26
|
+
* a synthetic Response is reconstructed from the stored data without touching
|
|
27
|
+
* the network. Non-OK responses (4xx, 5xx) are never cached.
|
|
28
|
+
*
|
|
29
|
+
* Safe as an ephemeral per-conversion cache or as a longer-lived process-level
|
|
30
|
+
* cache when registered via HttpCacheManager.setCache().
|
|
31
|
+
*/
|
|
32
|
+
export class MemoryHttpCache extends HttpCache {
|
|
33
|
+
read(uri: any): Promise<any>;
|
|
34
|
+
#private;
|
|
35
|
+
}
|
|
36
|
+
export namespace HttpCacheManager {
|
|
37
|
+
/** @type {HttpCache|null} */
|
|
38
|
+
let _cache: HttpCache | null;
|
|
39
|
+
/**
|
|
40
|
+
* Register a cache to use for all conversions.
|
|
41
|
+
* Pass null to unregister and revert to the ephemeral default.
|
|
42
|
+
* @param {HttpCache|null} cache
|
|
43
|
+
*/
|
|
44
|
+
function setCache(cache: HttpCache | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Return the registered process-level cache, or null if none is registered.
|
|
47
|
+
* @returns {HttpCache|null}
|
|
48
|
+
*/
|
|
49
|
+
function getCache(): HttpCache | null;
|
|
50
|
+
/**
|
|
51
|
+
* Return the cache to use for a specific document conversion.
|
|
52
|
+
*
|
|
53
|
+
* Returns the registered cache if one exists; otherwise creates (or reuses)
|
|
54
|
+
* an ephemeral MemoryHttpCache scoped to the document's lifetime via a WeakMap.
|
|
55
|
+
* @param {object} doc - the current Document instance
|
|
56
|
+
* @returns {HttpCache}
|
|
57
|
+
*/
|
|
58
|
+
function getCacheForDocument(doc: object): HttpCache;
|
|
59
|
+
}
|
package/types/index.d.cts
CHANGED
|
@@ -27,6 +27,14 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
|
|
|
27
27
|
* @returns {Promise<Document>} - the parsed Document
|
|
28
28
|
*/
|
|
29
29
|
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
30
|
+
export type ProcessorDslInterface = import("./extensions.js").ProcessorDslInterface;
|
|
31
|
+
export type DocumentProcessorDslInterface = import("./extensions.js").DocumentProcessorDslInterface;
|
|
32
|
+
export type SyntaxProcessorDslInterface = import("./extensions.js").SyntaxProcessorDslInterface;
|
|
33
|
+
export type IncludeProcessorDslInterface = import("./extensions.js").IncludeProcessorDslInterface;
|
|
34
|
+
export type DocinfoProcessorDslInterface = import("./extensions.js").DocinfoProcessorDslInterface;
|
|
35
|
+
export type BlockProcessorDslInterface = import("./extensions.js").BlockProcessorDslInterface;
|
|
36
|
+
export type MacroProcessorDslInterface = import("./extensions.js").MacroProcessorDslInterface;
|
|
37
|
+
export type InlineMacroProcessorDslInterface = import("./extensions.js").InlineMacroProcessorDslInterface;
|
|
30
38
|
import { Document } from './document.js';
|
|
31
39
|
import { convert } from './convert.js';
|
|
32
40
|
import { convertFile } from './convert.js';
|
|
@@ -48,6 +56,9 @@ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
|
|
|
48
56
|
import { LoggerManager } from './logging.js';
|
|
49
57
|
import { MemoryLogger } from './logging.js';
|
|
50
58
|
import { NullLogger } from './logging.js';
|
|
59
|
+
import { HttpCache } from './http_cache.js';
|
|
60
|
+
import { MemoryHttpCache } from './http_cache.js';
|
|
61
|
+
import { HttpCacheManager } from './http_cache.js';
|
|
51
62
|
import { SafeMode } from './constants.js';
|
|
52
63
|
import { ContentModel } from './constants.js';
|
|
53
64
|
import { Timings } from './timings.js';
|
|
@@ -72,4 +83,4 @@ import { deriveBackendTraits } from './converter.js';
|
|
|
72
83
|
import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
|
|
73
84
|
import Html5Converter from './converter/html5.js';
|
|
74
85
|
import { SyntaxHighlighter } from './syntax_highlighter.js';
|
|
75
|
-
export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
|
|
86
|
+
export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, HttpCache, MemoryHttpCache, HttpCacheManager, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
|
package/types/index.d.ts
CHANGED
|
@@ -26,6 +26,14 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
|
|
|
26
26
|
* @returns {Promise<Document>} - the parsed Document
|
|
27
27
|
*/
|
|
28
28
|
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
29
|
+
export type ProcessorDslInterface = import("./extensions.js").ProcessorDslInterface;
|
|
30
|
+
export type DocumentProcessorDslInterface = import("./extensions.js").DocumentProcessorDslInterface;
|
|
31
|
+
export type SyntaxProcessorDslInterface = import("./extensions.js").SyntaxProcessorDslInterface;
|
|
32
|
+
export type IncludeProcessorDslInterface = import("./extensions.js").IncludeProcessorDslInterface;
|
|
33
|
+
export type DocinfoProcessorDslInterface = import("./extensions.js").DocinfoProcessorDslInterface;
|
|
34
|
+
export type BlockProcessorDslInterface = import("./extensions.js").BlockProcessorDslInterface;
|
|
35
|
+
export type MacroProcessorDslInterface = import("./extensions.js").MacroProcessorDslInterface;
|
|
36
|
+
export type InlineMacroProcessorDslInterface = import("./extensions.js").InlineMacroProcessorDslInterface;
|
|
29
37
|
import { Document } from './document.js';
|
|
30
38
|
import { convert } from './convert.js';
|
|
31
39
|
import { convertFile } from './convert.js';
|
|
@@ -47,6 +55,9 @@ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
|
|
|
47
55
|
import { LoggerManager } from './logging.js';
|
|
48
56
|
import { MemoryLogger } from './logging.js';
|
|
49
57
|
import { NullLogger } from './logging.js';
|
|
58
|
+
import { HttpCache } from './http_cache.js';
|
|
59
|
+
import { MemoryHttpCache } from './http_cache.js';
|
|
60
|
+
import { HttpCacheManager } from './http_cache.js';
|
|
50
61
|
import { SafeMode } from './constants.js';
|
|
51
62
|
import { ContentModel } from './constants.js';
|
|
52
63
|
import { Timings } from './timings.js';
|
|
@@ -71,4 +82,4 @@ import { deriveBackendTraits } from './converter.js';
|
|
|
71
82
|
import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
|
|
72
83
|
import Html5Converter from './converter/html5.js';
|
|
73
84
|
import { SyntaxHighlighter } from './syntax_highlighter.js';
|
|
74
|
-
export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
|
|
85
|
+
export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, HttpCache, MemoryHttpCache, HttpCacheManager, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
|
package/types/logging.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Run fn() within an async-local logger context so that all log calls via
|
|
4
|
+
* `this.logger` (from applyLogging) automatically route to the provided logger
|
|
5
|
+
* for the duration of the async execution chain.
|
|
6
|
+
*
|
|
7
|
+
* Falls back to global mutation in environments without node:async_hooks (e.g. browsers).
|
|
8
|
+
*
|
|
9
|
+
* @param {Logger|MemoryLogger|NullLogger} logger - The logger to activate.
|
|
10
|
+
* @param {() => any} fn - The function to execute within the logger context.
|
|
11
|
+
* @returns {Promise<any>}
|
|
12
|
+
*/
|
|
13
|
+
export function withLogger(logger: Logger | MemoryLogger | NullLogger, fn: () => any): Promise<any>;
|
|
1
14
|
/**
|
|
2
15
|
* Apply the Logging mixin to a class prototype.
|
|
3
16
|
*
|
|
@@ -120,12 +133,10 @@ export class MemoryLogger {
|
|
|
120
133
|
empty(): boolean;
|
|
121
134
|
}
|
|
122
135
|
/** Logger that discards all messages but still tracks the maximum severity. */
|
|
123
|
-
export class NullLogger {
|
|
136
|
+
export class NullLogger extends Logger {
|
|
124
137
|
static create(): NullLogger;
|
|
138
|
+
constructor();
|
|
125
139
|
level: number;
|
|
126
|
-
_maxSeverity: number;
|
|
127
|
-
get maxSeverity(): number;
|
|
128
|
-
getMaxSeverity(): number;
|
|
129
140
|
add(severity: any): boolean;
|
|
130
141
|
log(severity: any): boolean;
|
|
131
142
|
debug(): boolean;
|
package/types/path_resolver.d.ts
CHANGED
|
@@ -54,11 +54,6 @@ export class PathResolver {
|
|
|
54
54
|
* @returns {string} The posixified path.
|
|
55
55
|
*/
|
|
56
56
|
posixify(path: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* @param {string} path
|
|
59
|
-
* @returns {string}
|
|
60
|
-
*/
|
|
61
|
-
posixfy(path: string): string;
|
|
62
57
|
/**
|
|
63
58
|
* Expand the path by resolving parent references (..) and removing self references (.).
|
|
64
59
|
* @param {string} path
|
package/types/stylesheets.d.ts
CHANGED
package/types/table.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ declare class Cell extends AbstractBlock<string | string[]> {
|
|
|
113
113
|
imageUri(targetImage: string, assetDirKey?: string): Promise<string>;
|
|
114
114
|
mediaUri(target: string, assetDirKey?: string): string;
|
|
115
115
|
generateDataUri(targetImage: string, assetDirKey?: string | null): Promise<string>;
|
|
116
|
-
generateDataUriFromUri(imageUri: string
|
|
116
|
+
generateDataUriFromUri(imageUri: string): Promise<string>;
|
|
117
117
|
normalizeAssetPath(assetRef: string, assetName?: string, autocorrect?: boolean): string;
|
|
118
118
|
normalizeSystemPath(target: string, start?: string | null, jail?: string | null, opts?: any): string;
|
|
119
119
|
normalizeWebPath(target: string, start?: string | null, preserveUriTarget?: boolean): string;
|