asciidoctor 4.0.0-alpha.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asciidoctor",
3
- "version": "4.0.0-alpha.3",
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",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "homepage": "https://github.com/asciidoctor/asciidoctor.js",
56
56
  "dependencies": {
57
- "@asciidoctor/core": "4.0.0-alpha.3"
57
+ "@asciidoctor/core": "4.0.0-alpha.4"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@biomejs/biome": "^2.4.13",
@@ -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, cacheUri?: boolean): Promise<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
  *
@@ -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
@@ -56,6 +56,9 @@ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
56
56
  import { LoggerManager } from './logging.js';
57
57
  import { MemoryLogger } from './logging.js';
58
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';
59
62
  import { SafeMode } from './constants.js';
60
63
  import { ContentModel } from './constants.js';
61
64
  import { Timings } from './timings.js';
@@ -80,4 +83,4 @@ import { deriveBackendTraits } from './converter.js';
80
83
  import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
81
84
  import Html5Converter from './converter/html5.js';
82
85
  import { SyntaxHighlighter } from './syntax_highlighter.js';
83
- 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
@@ -55,6 +55,9 @@ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
55
55
  import { LoggerManager } from './logging.js';
56
56
  import { MemoryLogger } from './logging.js';
57
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';
58
61
  import { SafeMode } from './constants.js';
59
62
  import { ContentModel } from './constants.js';
60
63
  import { Timings } from './timings.js';
@@ -79,4 +82,4 @@ import { deriveBackendTraits } from './converter.js';
79
82
  import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
80
83
  import Html5Converter from './converter/html5.js';
81
84
  import { SyntaxHighlighter } from './syntax_highlighter.js';
82
- 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 };
@@ -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
@@ -6,5 +6,6 @@ declare class StylesheetsClass {
6
6
  get primaryStylesheetName(): string;
7
7
  primaryStylesheetData(): Promise<string>;
8
8
  embedPrimaryStylesheet(): Promise<string>;
9
+ writePrimaryStylesheet(stylesoutdir: any): Promise<boolean>;
9
10
  }
10
11
  export {};
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, cacheUri?: boolean): Promise<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;