@ng-doc/builder 22.0.0 → 22.1.0
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/engine/builders/helpers/get-playground-metadata.js +7 -1
- package/engine/builders/helpers/get-playground-metadata.js.map +1 -1
- package/engine/builders/page/demo-assets.builder.js +2 -0
- package/engine/builders/page/demo-assets.builder.js.map +1 -1
- package/engine/builders/shared/content.builder.js +2 -0
- package/engine/builders/shared/content.builder.js.map +1 -1
- package/engine/builders/shared/page-wrapper.builder.js +2 -0
- package/engine/builders/shared/page-wrapper.builder.js.map +1 -1
- package/generator/bootstrap/bin.js +27 -3
- package/generator/bootstrap/cli.js +27 -3
- package/generator/bootstrap/index.js +17 -3
- package/generator/build-metafile.json +529 -221
- package/generator/build-provenance.json +6 -4
- package/generator/compiler/index.d.ts +20 -0
- package/generator/compiler/index.js +1875 -625
- package/generator/compiler/plan.d.ts +24 -0
- package/generator/content/code-snippet.d.ts +20 -0
- package/generator/content/content-compiler.d.ts +5 -1
- package/generator/content/format-cache.d.ts +108 -0
- package/generator/content/highlight-cache.d.ts +12 -36
- package/generator/content/html-pipeline.d.ts +10 -1
- package/generator/content/html-pool.d.ts +8 -2
- package/generator/content/html-worker.js +622 -39
- package/generator/contracts.d.ts +39 -0
- package/generator/discovery/index.d.ts +2 -0
- package/generator/kernel/flags.d.ts +2 -0
- package/generator/outputs/index.d.ts +13 -0
- package/generator/semantic/angular.d.ts +21 -1
- package/generator/semantic/formatting.d.ts +27 -0
- package/generator/semantic/fragments.d.ts +11 -2
- package/generator/templates/api/class-declaration.html.nunj +5 -3
- package/generator/templates/demo-app.ts.nunj +37 -0
- package/generator/templates/demo-routes.ts.nunj +23 -0
- package/generator/templates/index.ts.nunj +5 -0
- package/generator/templates/page-wrapper.ts.nunj +6 -1
- package/generator/templates/page.ts.nunj +9 -2
- package/generator/templates/routes.ts.nunj +7 -3
- package/generator/templates/symbol/members.html.nunj +6 -4
- package/generator/templates/symbol/page.html.nunj +1 -1
- package/generator/vite/application-builder.js +6 -1
- package/generator/vite/application.d.ts +14 -0
- package/generator/vite/demo-application.d.ts +34 -0
- package/generator/vite/dev-server-builder.js +6 -1
- package/generator/vite/host-updates.d.ts +69 -2
- package/generator/vite/index.js +490 -130
- package/generator/vite/lifecycle.d.ts +1 -0
- package/generator/vite/prerender-entry.js +72 -2
- package/generator/vite/prerender-runtime.d.ts +13 -0
- package/generator/vite/prerender.d.ts +2 -0
- package/helpers/format-cache.d.ts +34 -0
- package/helpers/format-cache.js +26 -0
- package/helpers/format-cache.js.map +1 -0
- package/helpers/format-code.js +9 -2
- package/helpers/format-code.js.map +1 -1
- package/helpers/to-template-string.d.ts +5 -1
- package/helpers/to-template-string.js +7 -2
- package/helpers/to-template-string.js.map +1 -1
- package/interfaces/code-block-options.d.ts +5 -0
- package/interfaces/configuration.d.ts +84 -1
- package/package.json +5 -4
- package/parsers/parse-code-block-params.d.ts +10 -1
- package/parsers/parse-code-block-params.js +29 -3
- package/parsers/parse-code-block-params.js.map +1 -1
- package/schematics/collection.json +1 -1
- package/schematics/migrate-to-vite/analyze.js +46 -3
- package/schematics/migrate-to-vite/analyze.js.map +1 -1
- package/schematics/migrate-to-vite/setup/workspace.d.ts +5 -0
- package/schematics/migrate-to-vite/setup/workspace.js +20 -0
- package/schematics/migrate-to-vite/setup/workspace.js.map +1 -1
- package/schematics/migrate-to-vite/testing/fixtures.d.ts +12 -0
- package/schematics/migrate-to-vite/testing/fixtures.js +27 -0
- package/schematics/migrate-to-vite/testing/fixtures.js.map +1 -1
- package/schematics/vite-setup/index.d.ts +9 -5
- package/schematics/vite-setup/index.js +11 -5
- package/schematics/vite-setup/index.js.map +1 -1
- package/schematics/vite-setup/schema.json +1 -1
- package/templates/api/class-declaration.html.nunj +5 -3
- package/templates/demo-app.ts.nunj +37 -0
- package/templates/demo-routes.ts.nunj +23 -0
- package/templates/index.ts.nunj +5 -0
- package/templates/page-wrapper.ts.nunj +6 -1
- package/templates/page.ts.nunj +9 -2
- package/templates/routes.ts.nunj +7 -3
- package/templates/symbol/members.html.nunj +6 -4
- package/templates/symbol/page.html.nunj +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JsonArtifactCache } from '../artifacts/index.js';
|
|
2
2
|
import { GeneratorContentCompiler } from '../content/content-compiler.js';
|
|
3
|
+
import { type FormatSession } from '../content/format-cache.js';
|
|
3
4
|
import { type HighlightSession } from '../content/highlight-cache.js';
|
|
4
5
|
import { type RenderBack } from '../content/html-pool.js';
|
|
5
6
|
import type { CompilationRequest, Dependency, Diagnostic, DiscoverySnapshot, PageArtifact, RebuildReason } from '../contracts.js';
|
|
@@ -58,12 +59,24 @@ export interface GenerationPlan extends CompilationServices {
|
|
|
58
59
|
compiler: GeneratorContentCompiler;
|
|
59
60
|
/** The cache of highlighted code blocks, when this generation uses one (`content/highlight-cache`). */
|
|
60
61
|
highlight?: HighlightSession;
|
|
62
|
+
/** The cache of formatted signatures and snippets, when this generation uses one (`content/format-cache`). */
|
|
63
|
+
format?: FormatSession;
|
|
61
64
|
/** Where the content's HTML pipeline runs, when it may run on threads (`content/html-pool`). */
|
|
62
65
|
back?: RenderBack;
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Setup phase: previous artifacts (session snapshot or cache index), reuse switches and the output
|
|
66
69
|
* templates. Its diagnostics are recorded as the `setup` phase.
|
|
70
|
+
* @param services
|
|
71
|
+
* @param input
|
|
72
|
+
* @param input.request
|
|
73
|
+
* @param input.signal
|
|
74
|
+
* @param input.records
|
|
75
|
+
* @param input.refresher
|
|
76
|
+
* @param input.found
|
|
77
|
+
* @param input.programDependencies
|
|
78
|
+
* @param input.scopedSemantic
|
|
79
|
+
* @param input.scratch
|
|
67
80
|
*/
|
|
68
81
|
export declare function planGeneration(services: CompilationServices, input: {
|
|
69
82
|
request: CompilationRequest;
|
|
@@ -82,11 +95,22 @@ export declare function planGeneration(services: CompilationServices, input: {
|
|
|
82
95
|
/**
|
|
83
96
|
* Plan phase, after describe: the current descriptor plan, in which a duplicate descriptor fails
|
|
84
97
|
* the generation. Every descriptor of the plan is rendered.
|
|
98
|
+
* @param plan
|
|
99
|
+
* @param units
|
|
85
100
|
*/
|
|
86
101
|
export declare function planContent(plan: GenerationPlan, units: Unit[]): void;
|
|
87
102
|
/**
|
|
88
103
|
* The artifacts the cache index names, in its order. An entry that cannot be read is left out
|
|
89
104
|
* with its diagnostics; an index of another schema version restores nothing.
|
|
105
|
+
* @param root
|
|
106
|
+
* @param projectId
|
|
107
|
+
* @param diagnostics
|
|
90
108
|
*/
|
|
91
109
|
export declare function restoreIndex(root: string, projectId: string, diagnostics: Diagnostic[]): Promise<PageArtifact[]>;
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param root
|
|
113
|
+
* @param projectId
|
|
114
|
+
* @param artifacts
|
|
115
|
+
*/
|
|
92
116
|
export declare function saveIndex(root: string, projectId: string, artifacts: PageArtifact[]): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The code of a named snippet, or why a file has none. */
|
|
2
|
+
export type SnippetRegion = {
|
|
3
|
+
status: 'found';
|
|
4
|
+
code: string;
|
|
5
|
+
} | {
|
|
6
|
+
status: 'unknown';
|
|
7
|
+
} | {
|
|
8
|
+
status: 'unclosed';
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The region of `text` between the first `snippet#<id>` marker and the next marker with the same
|
|
12
|
+
* id, as a code block's `file="./x.ts"#<id>` shows it: every marker line inside it is removed
|
|
13
|
+
* (nested snippets included, as in demos) and so are `ng-doc-ignore-line` lines, blank lines
|
|
14
|
+
* around it are dropped, and the common indentation is taken off, so a region inside a class
|
|
15
|
+
* reads like top-level code. Lines end with LF whatever the file uses, so the output never
|
|
16
|
+
* depends on the platform that saved the file.
|
|
17
|
+
* @param text - The whole file.
|
|
18
|
+
* @param id - The snippet id.
|
|
19
|
+
*/
|
|
20
|
+
export declare function snippetRegion(text: string, id: string): SnippetRegion;
|
|
@@ -30,13 +30,17 @@ export declare class GeneratorContentCompiler implements ContentCompiler {
|
|
|
30
30
|
private readonly services;
|
|
31
31
|
private readonly highlight?;
|
|
32
32
|
private readonly back?;
|
|
33
|
+
/** The Shiki grammars highlighting loads (`grammarsSwitch`). */
|
|
34
|
+
private readonly grammars;
|
|
33
35
|
/**
|
|
34
36
|
* @param services - What the compiler reads.
|
|
35
37
|
* @param highlight - The generation's cache of highlighted code blocks; without it, every block
|
|
36
38
|
* is highlighted (`./highlight-cache`).
|
|
37
39
|
* @param back - Where the HTML pipeline runs; without it, in this thread, at once.
|
|
38
40
|
*/
|
|
39
|
-
constructor(services: ContentCompilerServices, highlight?: HighlightSession | undefined, back?: ContentBack | undefined
|
|
41
|
+
constructor(services: ContentCompilerServices, highlight?: HighlightSession | undefined, back?: ContentBack | undefined,
|
|
42
|
+
/** The Shiki grammars highlighting loads (`grammarsSwitch`). */
|
|
43
|
+
grammars?: 'used' | 'all');
|
|
40
44
|
/**
|
|
41
45
|
* Whether this call records its footprint. The semantic service's effective recorder state
|
|
42
46
|
* decides when it reports one: a service that records nothing, or whose probe or install failed,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Options } from 'prettier';
|
|
2
|
+
import type { CompilationRequest, GeneratorConfiguration } from '../contracts.js';
|
|
3
|
+
/**
|
|
4
|
+
* The cache of formatted code: API signatures and demo snippets that `formatCode` formats with
|
|
5
|
+
* Prettier (`helpers/format-code.ts`), the main thread's largest cost after highlighting at a
|
|
6
|
+
* cold start. Each call resolved the Prettier configuration again and formatted through
|
|
7
|
+
* `@prettier/sync`'s worker.
|
|
8
|
+
*
|
|
9
|
+
* - **Configuration.** One generation resolves the configuration of a directory once. The files
|
|
10
|
+
* it reads (`.prettierrc*`, `prettier.config.*`, `.editorconfig`, `package.json` in the workspace
|
|
11
|
+
* root and every directory above it) are already program inputs of every page that formats
|
|
12
|
+
* (`trackFormatterConfiguration`), so an edit of one runs a new generation, which resolves
|
|
13
|
+
* again.
|
|
14
|
+
* - **Formatted code.** Formatting is a pure function of the code, the parser, the resolved
|
|
15
|
+
* configuration and the Prettier release, so its result is cached under
|
|
16
|
+
* `digestOf({ context, parser, config, code })`: the context is this cache's format and the
|
|
17
|
+
* resolved versions of `prettier` and `@prettier/sync`, and `config` the resolved configuration
|
|
18
|
+
* with the versions of the plugins it names. A configuration that cannot be identified exactly
|
|
19
|
+
* (a value JSON cannot hold, a plugin given as a path or that does not resolve to a package) is
|
|
20
|
+
* never cached: such code is formatted every time. Code Prettier rejects with a syntax error
|
|
21
|
+
* (signatures such as a bare `constructor(…): T;` always are) is cached as such and throws
|
|
22
|
+
* again, so `formatCode` returns it unformatted as before; any other error stores nothing.
|
|
23
|
+
* - **Storage.** One map per runtime, kept across generations by a long-lived runtime and
|
|
24
|
+
* cleared when it outgrows {@link FORMAT_CACHE_LIMIT}. Development generations with the artifact
|
|
25
|
+
* cache read `<hash(projectId)>.format.json` beside it once per runtime and context, and write it
|
|
26
|
+
* after the cache (best effort, atomic, skipped when unchanged), like the highlight cache.
|
|
27
|
+
* Production, `cache: false` and the reference path never read or write the pack.
|
|
28
|
+
*
|
|
29
|
+
* No dependency or watch input is added: the result depends only on the key, and the
|
|
30
|
+
* configuration's own files are recorded where the program is built.
|
|
31
|
+
*
|
|
32
|
+
* `NGDOC_FORMAT_CACHE=0` (`CompilationOptions.formatCache: false`) formats every call as before;
|
|
33
|
+
* `verify` resolves the configuration and formats every hit again, uses the fresh result and
|
|
34
|
+
* reports `CONTENT_FORMAT_CACHE_MISMATCH` when one differs. The semantic service formats through
|
|
35
|
+
* the session the compiler installs for the generation (`semantic/formatting.ts`).
|
|
36
|
+
*/
|
|
37
|
+
/** The warning of a `verify` hit (or configuration) that differs from the cached one. */
|
|
38
|
+
export declare const FORMAT_CACHE_MISMATCH = "CONTENT_FORMAT_CACHE_MISMATCH";
|
|
39
|
+
/**
|
|
40
|
+
* Above this size (keys and values, in UTF-16 code units) the pack and the map keep only the
|
|
41
|
+
* entries of the current generation.
|
|
42
|
+
*/
|
|
43
|
+
export declare const FORMAT_CACHE_LIMIT: number;
|
|
44
|
+
/**
|
|
45
|
+
* The cache's switch: `off`, `on` or `verify`.
|
|
46
|
+
* @param options
|
|
47
|
+
* @param options.formatCache
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatCacheSwitch(options: {
|
|
50
|
+
formatCache?: boolean | 'verify';
|
|
51
|
+
}): 'off' | 'on' | 'verify';
|
|
52
|
+
/**
|
|
53
|
+
* The cache of one generation, or undefined when code is formatted without it: with the switch
|
|
54
|
+
* off, and on the reference path (`incrementalReuse: false`), which recomputes everything. Only
|
|
55
|
+
* a development generation with the artifact cache on keeps a pack.
|
|
56
|
+
* @param options
|
|
57
|
+
* @param options.projectId
|
|
58
|
+
* @param options.incrementalReuse
|
|
59
|
+
* @param options.formatCache
|
|
60
|
+
* @param request
|
|
61
|
+
* @param configuration
|
|
62
|
+
*/
|
|
63
|
+
export declare function createFormatSession(options: {
|
|
64
|
+
projectId: string;
|
|
65
|
+
incrementalReuse?: boolean;
|
|
66
|
+
formatCache?: boolean | 'verify';
|
|
67
|
+
}, request: Pick<CompilationRequest, 'mode'>, configuration: Pick<GeneratorConfiguration, 'cacheEnabled' | 'cacheRoot'>): FormatSession | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* One generation's use of the cache: its resolved configurations, the keys it used, its pack. It
|
|
70
|
+
* is a `FormatCodeCache` (`helpers/format-cache.ts`), structurally: the published declarations
|
|
71
|
+
* reach this class, and they cannot import from outside the generator.
|
|
72
|
+
*/
|
|
73
|
+
export declare class FormatSession {
|
|
74
|
+
readonly verify: boolean;
|
|
75
|
+
readonly pack: string | undefined;
|
|
76
|
+
readonly context: string;
|
|
77
|
+
/** The keys this generation hit or formatted. */
|
|
78
|
+
private readonly used;
|
|
79
|
+
/** The resolved configuration per directory (`''` for the process's working directory). */
|
|
80
|
+
private readonly configs;
|
|
81
|
+
/** Each resolved configuration's identity in the keys; undefined: not cacheable. */
|
|
82
|
+
private readonly identities;
|
|
83
|
+
private loaded;
|
|
84
|
+
/** An entry was replaced (a `verify` repair): the pack must be written. */
|
|
85
|
+
private replaced;
|
|
86
|
+
private mismatchCount;
|
|
87
|
+
constructor(verify: boolean, pack: string | undefined);
|
|
88
|
+
/** How many `verify` hits and configurations differed from the cached ones. */
|
|
89
|
+
get mismatches(): number;
|
|
90
|
+
config(configDirectory: string | undefined, resolve: () => Options | null): Options | null;
|
|
91
|
+
format(input: {
|
|
92
|
+
code: string;
|
|
93
|
+
parser: string;
|
|
94
|
+
config: Options | null;
|
|
95
|
+
}, format: () => string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Writes the pack after the artifact cache: the entries this generation hit or formatted, plus
|
|
98
|
+
* those the pack held before unless the generation rendered every content (`complete`), or the
|
|
99
|
+
* result would exceed {@link FORMAT_CACHE_LIMIT}. Best effort.
|
|
100
|
+
* @param complete
|
|
101
|
+
*/
|
|
102
|
+
save(complete: boolean): Promise<void>;
|
|
103
|
+
private remember;
|
|
104
|
+
/** Reads the pack once per runtime and context; an unusable pack is not read. */
|
|
105
|
+
private load;
|
|
106
|
+
}
|
|
107
|
+
/** Forgets every entry and pack of this runtime (tests). */
|
|
108
|
+
export declare function resetFormatCache(): void;
|
|
@@ -1,37 +1,4 @@
|
|
|
1
|
-
import type { CompilationRequest, GeneratorConfiguration } from '../contracts.js';
|
|
2
|
-
/**
|
|
3
|
-
* The cache of highlighted code blocks (`processHtml`'s `highlight` option, `@ng-doc/utils`).
|
|
4
|
-
*
|
|
5
|
-
* Highlighting a block is a pure function of its text, language and meta string, the themes, the
|
|
6
|
-
* fixed options of the highlighting plugin and the Shiki release, so its result is cached under a
|
|
7
|
-
* key that covers all of them: `digestOf({ context, block })`, where the context is the format of
|
|
8
|
-
* this cache, the resolved versions of `shiki`, `@shikijs/core` and `@shikijs/rehype`
|
|
9
|
-
* (`runtimePackages`) and the identity of each theme (a bundled theme's name; NgDoc's own theme by
|
|
10
|
-
* the digest of its definition), and the block names the plugin's format and options, the theme
|
|
11
|
-
* names, the language before its fallback, the raw meta string and the text. A Shiki upgrade or a
|
|
12
|
-
* plugin change therefore changes every key, and a stale entry is never hit.
|
|
13
|
-
*
|
|
14
|
-
* Every runtime (each thread) keeps one map of entries, which a long-lived runtime keeps across
|
|
15
|
-
* generations. A development generation with the artifact cache on also reads a pack of entries
|
|
16
|
-
* beside the cache (`<hash(projectId)>.highlight.json`) the first time it highlights, and writes
|
|
17
|
-
* it after the cache (best effort, atomically replaced, skipped when unchanged). Production, the
|
|
18
|
-
* reference path and `cache: false` never read or write the pack: they use the map only.
|
|
19
|
-
*
|
|
20
|
-
* A cached entry can never change output: the plugin uses an entry only when it is a JSON array of
|
|
21
|
-
* HAST elements and highlights the block otherwise, it stores only blocks that were highlighted
|
|
22
|
-
* without an error, and a pack of another version or context, or one that cannot be read or
|
|
23
|
-
* parsed, is not read. No dependency or watch input is added: the result depends only on the key.
|
|
24
|
-
*
|
|
25
|
-
* `NGDOC_HIGHLIGHT_CACHE=0` (`CompilationOptions.highlightCache: false`) highlights every block
|
|
26
|
-
* with the plain `@shikijs/rehype` plugin, which sets its highlighter up again for every document;
|
|
27
|
-
* `verify` highlights every hit again, uses the fresh result and reports
|
|
28
|
-
* `CONTENT_HIGHLIGHT_CACHE_MISMATCH` when it differs.
|
|
29
|
-
*
|
|
30
|
-
* The entries are plain strings, so a render thread (`./html-pool`) is handed them (the journal of
|
|
31
|
-
* this runtime's writes, `highlightJournal`) and returns what it hit and highlighted, which the
|
|
32
|
-
* main thread merges (`HighlightSession.merge`); the key is a function of the block alone. Only the
|
|
33
|
-
* main thread reads and writes the pack.
|
|
34
|
-
*/
|
|
1
|
+
import type { CompilationRequest, GeneratorConfiguration, ShikiLanguage } from '../contracts.js';
|
|
35
2
|
/** The warning of a `verify` hit whose highlighting differs from the cached one. */
|
|
36
3
|
export declare const HIGHLIGHT_CACHE_MISMATCH = "CONTENT_HIGHLIGHT_CACHE_MISMATCH";
|
|
37
4
|
/**
|
|
@@ -46,6 +13,7 @@ export interface HighlightBlock {
|
|
|
46
13
|
readonly light: string;
|
|
47
14
|
readonly dark: string;
|
|
48
15
|
};
|
|
16
|
+
readonly languages?: string;
|
|
49
17
|
readonly lang: string;
|
|
50
18
|
readonly meta: string;
|
|
51
19
|
readonly code: string;
|
|
@@ -70,6 +38,14 @@ export declare function highlightJournal(): {
|
|
|
70
38
|
export declare function highlightCacheSwitch(options: {
|
|
71
39
|
highlightCache?: boolean | 'verify';
|
|
72
40
|
}): 'off' | 'on' | 'verify';
|
|
41
|
+
/**
|
|
42
|
+
* Which Shiki grammars highlighting loads: only those code blocks reach (`used`, the default), or
|
|
43
|
+
* every bundled grammar (`all`: `usedGrammars: false` or `NGDOC_USED_GRAMMARS=0`). The HTML is the
|
|
44
|
+
* same, so neither the cache keys nor any digest depend on it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function grammarsSwitch(options: {
|
|
47
|
+
usedGrammars?: boolean;
|
|
48
|
+
}): 'used' | 'all';
|
|
73
49
|
/**
|
|
74
50
|
* The cache of one generation, or undefined when blocks are highlighted without it: with the
|
|
75
51
|
* switch off, and on the reference path (`incrementalReuse: false`), which recomputes everything.
|
|
@@ -79,7 +55,7 @@ export declare function createHighlightSession(options: {
|
|
|
79
55
|
projectId: string;
|
|
80
56
|
incrementalReuse?: boolean;
|
|
81
57
|
highlightCache?: boolean | 'verify';
|
|
82
|
-
}, request: Pick<CompilationRequest, 'mode'>, configuration: Pick<GeneratorConfiguration, 'cacheEnabled' | 'cacheRoot' | 'themes'>): HighlightSession | undefined;
|
|
58
|
+
}, request: Pick<CompilationRequest, 'mode'>, configuration: Pick<GeneratorConfiguration, 'cacheEnabled' | 'cacheRoot' | 'themes' | 'shikiLangs'>): HighlightSession | undefined;
|
|
83
59
|
/** One generation's use of the cache: what it hit or highlighted, and its pack. */
|
|
84
60
|
export declare class HighlightSession {
|
|
85
61
|
readonly themes: {
|
|
@@ -97,7 +73,7 @@ export declare class HighlightSession {
|
|
|
97
73
|
constructor(themes: {
|
|
98
74
|
readonly light: string;
|
|
99
75
|
readonly dark: string;
|
|
100
|
-
}, verify: boolean, pack: string | undefined);
|
|
76
|
+
}, verify: boolean, pack: string | undefined, langs?: readonly ShikiLanguage[]);
|
|
101
77
|
/** The cache of one `processHtml` call. */
|
|
102
78
|
call(): HighlightCall;
|
|
103
79
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentAnchor, KeywordExport, SearchRecord } from '../contracts.js';
|
|
1
|
+
import type { ContentAnchor, KeywordExport, SearchRecord, ShikiLanguage } from '../contracts.js';
|
|
2
2
|
import type { HighlightBlock } from './highlight-cache.js';
|
|
3
3
|
/**
|
|
4
4
|
* The back half of content compilation: the HTML pipeline of `@ng-doc/utils` (process, post-process,
|
|
@@ -19,6 +19,8 @@ interface HtmlUtilities {
|
|
|
19
19
|
route?: string;
|
|
20
20
|
lightTheme?: string;
|
|
21
21
|
darkTheme?: string;
|
|
22
|
+
langs?: readonly ShikiLanguage[];
|
|
23
|
+
grammars?: 'all' | 'used';
|
|
22
24
|
highlight?: PipelineHighlight;
|
|
23
25
|
}): Promise<{
|
|
24
26
|
content: string;
|
|
@@ -60,6 +62,13 @@ export interface RenderTask {
|
|
|
60
62
|
readonly light: string;
|
|
61
63
|
readonly dark: string;
|
|
62
64
|
};
|
|
65
|
+
/** The configured Shiki languages (`shiki.langs`); absent without any. */
|
|
66
|
+
readonly langs?: readonly ShikiLanguage[];
|
|
67
|
+
/**
|
|
68
|
+
* `all` when highlighting loads every bundled Shiki grammar (the switch is off); absent when it
|
|
69
|
+
* loads only the grammars code blocks reach. The HTML is the same.
|
|
70
|
+
*/
|
|
71
|
+
readonly grammars?: 'all';
|
|
63
72
|
}
|
|
64
73
|
/**
|
|
65
74
|
* What processing one document gave. `mismatches` counts the cached code blocks that `verify`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Worker } from 'node:worker_threads';
|
|
2
|
-
import type { CompilationRequest, KeywordExport } from '../contracts.js';
|
|
2
|
+
import type { CompilationRequest, KeywordExport, ShikiLanguage } from '../contracts.js';
|
|
3
3
|
import type { ContentBack } from './content-compiler.js';
|
|
4
4
|
export { PARALLEL_RENDER_MISMATCH } from './content-compiler.js';
|
|
5
5
|
import { type HighlightSession } from './highlight-cache.js';
|
|
@@ -103,12 +103,18 @@ declare class HtmlThread {
|
|
|
103
103
|
fail(error: Error): void;
|
|
104
104
|
terminate(): Promise<void>;
|
|
105
105
|
}
|
|
106
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* A warm-up: the themes and languages to set the highlighter up for, and whether the cached
|
|
108
|
+
* plugin is used.
|
|
109
|
+
*/
|
|
107
110
|
export interface RenderWarmUp {
|
|
108
111
|
themes: {
|
|
109
112
|
light: string;
|
|
110
113
|
dark: string;
|
|
111
114
|
};
|
|
115
|
+
langs?: readonly ShikiLanguage[];
|
|
116
|
+
/** `all` when highlighting loads every bundled grammar. */
|
|
117
|
+
grammars?: 'all';
|
|
112
118
|
cache: boolean;
|
|
113
119
|
}
|
|
114
120
|
/** Up to `size` render threads, started on demand. */
|