@ng-doc/builder 22.1.0 → 22.2.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/LICENSE +21 -0
- package/generator/bootstrap/bin.js +150 -107
- package/generator/bootstrap/cli.js +150 -107
- package/generator/bootstrap/index.js +125 -99
- package/generator/bootstrap/process-tree.d.ts +5 -4
- package/generator/build-metafile.json +177 -78
- package/generator/build-provenance.json +3 -3
- package/generator/compiler/index.js +689 -484
- package/generator/content/html-worker.js +8 -0
- package/generator/contracts.d.ts +20 -2
- package/generator/kernel/flags.d.ts +3 -0
- package/generator/outputs/index.d.ts +22 -6
- package/generator/templates/demo-routes.ts.nunj +21 -1
- package/generator/templates/page.ts.nunj +5 -1
- package/generator/vite/angular/analog-provenance.json +1 -1
- package/generator/vite/angular-composition.d.ts +25 -1
- package/generator/vite/content-updates.d.ts +62 -0
- package/generator/vite/host-updates.d.ts +85 -5
- package/generator/vite/index.js +621 -243
- package/generator/vite/lifecycle.d.ts +39 -2
- package/helpers/playground/get-playground-inputs.js +6 -3
- package/helpers/playground/get-playground-inputs.js.map +1 -1
- package/helpers/playground/playground-options.d.ts +28 -0
- package/helpers/playground/playground-options.js +122 -0
- package/helpers/playground/playground-options.js.map +1 -0
- package/helpers/playground/written-union-order.d.ts +33 -0
- package/helpers/playground/written-union-order.js +106 -0
- package/helpers/playground/written-union-order.js.map +1 -0
- package/interfaces/configuration.d.ts +11 -3
- package/package.json +4 -4
- package/templates/demo-routes.ts.nunj +21 -1
- package/templates/page.ts.nunj +5 -1
|
@@ -387,6 +387,13 @@ var init_kebab_case = __esm({
|
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
389
|
|
|
390
|
+
// libs/core/helpers/playground-target-slugs.ts
|
|
391
|
+
var init_playground_target_slugs = __esm({
|
|
392
|
+
"libs/core/helpers/playground-target-slugs.ts"() {
|
|
393
|
+
"use strict";
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
390
397
|
// libs/core/helpers/stringify.ts
|
|
391
398
|
var init_stringify = __esm({
|
|
392
399
|
"libs/core/helpers/stringify.ts"() {
|
|
@@ -428,6 +435,7 @@ var init_helpers = __esm({
|
|
|
428
435
|
init_is_same_object();
|
|
429
436
|
init_kebab_case();
|
|
430
437
|
init_object_keys();
|
|
438
|
+
init_playground_target_slugs();
|
|
431
439
|
init_stringify();
|
|
432
440
|
init_uid();
|
|
433
441
|
init_unique();
|
package/generator/contracts.d.ts
CHANGED
|
@@ -178,17 +178,25 @@ export interface GeneratorConfiguration {
|
|
|
178
178
|
*/
|
|
179
179
|
apiProtectedMembers?: false;
|
|
180
180
|
/**
|
|
181
|
-
* The demo pages (`isolatedDemos`, `demoApplication`, `demoProviders`).
|
|
182
|
-
* is set, so every other configuration keeps its digest, and so is every
|
|
181
|
+
* The demo pages (`isolatedDemos`, `isolatedPlaygrounds`, `demoApplication`, `demoProviders`).
|
|
182
|
+
* Absent when none of them is set, so every other configuration keeps its digest, and so is every
|
|
183
|
+
* default field:
|
|
183
184
|
* - `pages`: `all` builds a demo page for every demo, `none` for none; absent, only the guides
|
|
184
185
|
* with an isolated demo get them.
|
|
185
186
|
* - `isolated`: `true` when `isolatedDemos` is: every `demo` action shows an iframe by default.
|
|
187
|
+
* - `playgroundPages`: `all` builds the playground pages of every playground
|
|
188
|
+
* (`isolatedPlaygrounds`, or `demoApplication` set); absent, only the guides with an isolated playground get them, and
|
|
189
|
+
* no guide does when `pages` is `none`.
|
|
190
|
+
* - `isolatedPlaygrounds`: `true` when `isolatedPlaygrounds` is: every playground shows its demos
|
|
191
|
+
* in iframes by default.
|
|
186
192
|
* - `path`: the URL path of the demo pages, absent for `demo-preview`.
|
|
187
193
|
* - `providers`: the module that `demoProviders` imports.
|
|
188
194
|
*/
|
|
189
195
|
demoApplication?: {
|
|
190
196
|
pages?: 'all' | 'none';
|
|
191
197
|
isolated?: true;
|
|
198
|
+
playgroundPages?: 'all';
|
|
199
|
+
isolatedPlaygrounds?: true;
|
|
192
200
|
path?: string;
|
|
193
201
|
providers?: FilePath;
|
|
194
202
|
};
|
|
@@ -358,6 +366,11 @@ export interface PlaygroundDescriptor {
|
|
|
358
366
|
/** Existing NgDocPlaygroundProperties shape with JSON-safe values, aliases and model inputs. */
|
|
359
367
|
properties: Record<string, JsonValue>;
|
|
360
368
|
content: Record<string, string>;
|
|
369
|
+
/**
|
|
370
|
+
* `true` when the playground's configuration in `ng-doc.page.ts` sets `isolated: true`, so its
|
|
371
|
+
* guide gets playground pages. Absent otherwise, so every other guide keeps its semantics.
|
|
372
|
+
*/
|
|
373
|
+
isolated?: true;
|
|
361
374
|
}
|
|
362
375
|
export interface GuideSemantics {
|
|
363
376
|
demos: Record<string, DemoAsset[]>;
|
|
@@ -647,6 +660,11 @@ export interface RouteRecord {
|
|
|
647
660
|
demoModulePath?: string;
|
|
648
661
|
/** The names of the guide's demo pages, in the order of `demos`, with `demoModulePath`. */
|
|
649
662
|
demoNames?: string[];
|
|
663
|
+
/**
|
|
664
|
+
* The guide's playground pages relative to its demo route (`playground/<id>/<target>`), with
|
|
665
|
+
* `demoModulePath`. Only written for a guide that has them.
|
|
666
|
+
*/
|
|
667
|
+
playgroundPages?: string[];
|
|
650
668
|
}
|
|
651
669
|
export interface ApiListRecord {
|
|
652
670
|
apiEntryId: EntryId;
|
|
@@ -29,7 +29,10 @@ export declare const INCREMENTAL_PROGRAM_FLAG = "NGDOC_INCREMENTAL_PROGRAM";
|
|
|
29
29
|
export declare const SHAPE_CLOSURE_FLAG = "NGDOC_SHAPE_CLOSURE";
|
|
30
30
|
export declare const ANGULAR_SHARED_PASS_FLAG = "NGDOC_ANGULAR_SHARED_PASS";
|
|
31
31
|
export declare const ANGULAR_STRUCTURAL_PASS_FLAG = "NGDOC_ANGULAR_STRUCTURAL_PASS";
|
|
32
|
+
export declare const ANGULAR_DESCRIPTION_PASS_FLAG = "NGDOC_ANGULAR_DESCRIPTION_PASS";
|
|
33
|
+
export declare const VITE_CONTENT_UPDATE_FLAG = "NGDOC_VITE_CONTENT_UPDATE";
|
|
32
34
|
export declare const VITE_BUILD_HANDOFF_FLAG = "NGDOC_VITE_BUILD_HANDOFF";
|
|
35
|
+
export declare const VITE_MODULELESS_SETTLE_FLAG = "NGDOC_VITE_MODULELESS_SETTLE";
|
|
33
36
|
export declare const TRACKED_PROGRAM_REUSE_FLAG = "NGDOC_TRACKED_PROGRAM_REUSE";
|
|
34
37
|
export declare const FAST_START_FLAG = "NGDOC_FAST_START";
|
|
35
38
|
export declare const PARALLEL_WRITES_FLAG = "NGDOC_PARALLEL_WRITES";
|
|
@@ -57,20 +57,36 @@ export declare class OutputAssemblerImpl implements OutputAssembler {
|
|
|
57
57
|
aggregate(request: AggregateRequest): AggregateAssembly;
|
|
58
58
|
private guide;
|
|
59
59
|
/**
|
|
60
|
-
* Writes the guide's demo routes module
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* Writes the guide's demo routes module when the guide gets demo or playground pages, and
|
|
61
|
+
* returns its path, the names of the demos that got a page and the playground pages (relative
|
|
62
|
+
* to the guide's demo route), or undefined.
|
|
63
|
+
*
|
|
64
|
+
* - Demo pages: with `pages: 'all'`, by default when its content has a demo with
|
|
65
|
+
* `isolated: true`, and whenever the guide gets playground pages: the page then has a demo
|
|
66
|
+
* route, and the runtime offers every demo of such a page its demo page.
|
|
67
|
+
* - Playground pages (`playground/<id>/<target>`, one per target of every playground of the
|
|
68
|
+
* guide, under the page's providers and its generated playground classes): with
|
|
69
|
+
* `playgroundPages: 'all'`, or by default when a `playground` action of its content or a
|
|
70
|
+
* playground of its configuration has `isolated: true`.
|
|
64
71
|
*/
|
|
65
72
|
private demoRoutes;
|
|
73
|
+
/**
|
|
74
|
+
* The playground pages of a guide, when it gets them (see `demoRoutes`): one per target of each
|
|
75
|
+
* playground, in the order of the guide's playgrounds and of `playgroundTargets`. A playground
|
|
76
|
+
* whose ID is no URL segment gets none, with a warning.
|
|
77
|
+
* @param request - The guide's assembly request.
|
|
78
|
+
* @param slots - The guide's content.
|
|
79
|
+
* @param diagnostics - Receives the warnings.
|
|
80
|
+
*/
|
|
81
|
+
private playgroundRoutes;
|
|
66
82
|
private apiEntry;
|
|
67
83
|
private apiDeclaration;
|
|
68
84
|
private apiLists;
|
|
69
85
|
private addContentSource;
|
|
70
86
|
/**
|
|
71
87
|
* Writes `demo-app.ts`, the routes of the demo application (one lazy route per guide with demo
|
|
72
|
-
* pages, under its categories' providers)
|
|
73
|
-
* pages. Returns whether it did.
|
|
88
|
+
* or playground pages, under its categories' providers), every such page (`NG_DOC_DEMO_PAGES`)
|
|
89
|
+
* and its `demoProviders` import, when a guide has demo pages. Returns whether it did.
|
|
74
90
|
*/
|
|
75
91
|
private demoApplication;
|
|
76
92
|
private renderOutput;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import {Routes} from '@angular/router';
|
|
3
|
+
{%- if demos.length or not playgrounds.length %}
|
|
3
4
|
import {NgDocDemoHostComponent} from '@ng-doc/app/demo-app';
|
|
5
|
+
{%- endif %}
|
|
6
|
+
{%- if playgrounds.length %}
|
|
7
|
+
import {NgDocPlaygroundHostComponent} from '@ng-doc/app/components/playground';
|
|
8
|
+
{%- endif %}
|
|
4
9
|
import entry from '{{ entryImport }}';
|
|
10
|
+
{%- if playgrounds.length %}
|
|
11
|
+
import {PLAYGROUND_PROVIDERS} from '{{ playgroundsImport }}';
|
|
12
|
+
{%- endif %}
|
|
5
13
|
|
|
6
14
|
// The demo pages of one guide: one route per demo, under the page's providers, as the demos have
|
|
7
15
|
// them on the page.
|
|
16
|
+
{%- if playgrounds.length %}
|
|
17
|
+
// Its playground pages: one route per target of each playground, which finds the generated
|
|
18
|
+
// playground classes of the page through PLAYGROUND_PROVIDERS, as the page does.
|
|
19
|
+
{%- endif %}
|
|
8
20
|
const routes: Routes = [{
|
|
9
21
|
path: '',
|
|
10
|
-
providers: [...(entry.providers ?? [])],
|
|
22
|
+
providers: [{% if playgrounds.length %}PLAYGROUND_PROVIDERS, {% endif %}...(entry.providers ?? [])],
|
|
11
23
|
children: [
|
|
12
24
|
{%- for demo in demos %}
|
|
13
25
|
{
|
|
@@ -17,6 +29,14 @@ const routes: Routes = [{
|
|
|
17
29
|
data: {ngDocDemo: entry.demos?.['{{ demo.name }}']},
|
|
18
30
|
},
|
|
19
31
|
{%- endfor %}
|
|
32
|
+
{%- for playground in playgrounds %}
|
|
33
|
+
{
|
|
34
|
+
path: '{{ playground.path }}',
|
|
35
|
+
component: NgDocPlaygroundHostComponent,
|
|
36
|
+
title: `{{ playground.title | toTemplateString }}`,
|
|
37
|
+
data: {ngDocPlayground: {{ playground.data | dump }}},
|
|
38
|
+
},
|
|
39
|
+
{%- endfor %}
|
|
20
40
|
],
|
|
21
41
|
}];
|
|
22
42
|
|
|
@@ -64,12 +64,16 @@ export class PageComponent extends NgDocRootPage {
|
|
|
64
64
|
{%- if demoAssetsPath %}
|
|
65
65
|
readonly demoAssets: NgDocDemoAssets = demoAssets;
|
|
66
66
|
{%- endif %}
|
|
67
|
-
{#- The demo pages of the guide (Vite engine), and whether its demos
|
|
67
|
+
{#- The demo and playground pages of the guide (Vite engine), and whether its demos and
|
|
68
|
+
playgrounds are isolated by default. #}
|
|
68
69
|
{%- if demoRoute %}
|
|
69
70
|
readonly demoRoute: string = '{{ demoRoute | replace("\\", "\\\\") | replace("'", "\\'") | replace("\n", "\\n") }}';
|
|
70
71
|
{%- if isolatedDemos %}
|
|
71
72
|
readonly isolatedDemos: boolean = true;
|
|
72
73
|
{%- endif %}
|
|
74
|
+
{%- if isolatedPlaygrounds %}
|
|
75
|
+
readonly isolatedPlaygrounds: boolean = true;
|
|
76
|
+
{%- endif %}
|
|
73
77
|
{%- endif %}
|
|
74
78
|
|
|
75
79
|
constructor() {
|
|
@@ -10,6 +10,17 @@ import { type HostUpdateTicket, type InitialCompilationInventory } from './host-
|
|
|
10
10
|
* @returns Whether only global style sheets depend on the file.
|
|
11
11
|
*/
|
|
12
12
|
export declare function globalStyleSheet(context: Pick<HmrContext, 'file' | 'modules'>): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether a hot update's hooks hand Vite anything to do once they return: a module to update, or
|
|
15
|
+
* (for an HTML file without modules) the page reload Vite sends itself. Only such a hot update
|
|
16
|
+
* has to wait for the newest publication before it returns; a module-less one settles once it is
|
|
17
|
+
* acknowledged (`HostUpdateCoordinator.settle`).
|
|
18
|
+
* @param file - The hot update's file.
|
|
19
|
+
* @param modules - The modules Vite updates after this hook: what the hook returned, or the
|
|
20
|
+
* context's modules when it returned nothing.
|
|
21
|
+
* @returns Whether Vite updates or reloads anything for the hot update.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handsViteModules(file: string, modules: readonly unknown[]): boolean;
|
|
13
24
|
/**
|
|
14
25
|
* The hooks NgDoc's patched Analog compiler exposes as `api.ngDocHost` (the
|
|
15
26
|
* `generation-claimed-filesystem-*` changes): a claimed add or unlink event invalidates the
|
|
@@ -31,6 +42,15 @@ export interface AngularCompositionBridge {
|
|
|
31
42
|
start(file: string, read: () => string | Promise<string>): HostUpdateTicket;
|
|
32
43
|
/** Other TypeScript outputs to compile in this ready ticket's pass (see compilerCompanions). */
|
|
33
44
|
companions?(ticket: HostUpdateTicket): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Whether the generation of this committed source update still has a generated TypeScript
|
|
47
|
+
* update to compile (see HostUpdateCoordinator.generationPass).
|
|
48
|
+
*/
|
|
49
|
+
generationPass?(ticket: HostUpdateTicket): boolean;
|
|
50
|
+
/** Whether `file` is a description module the generator watches. */
|
|
51
|
+
descriptionModule?(file: string): boolean;
|
|
52
|
+
/** Whether `file` is a generated output. */
|
|
53
|
+
generated?(file: string): boolean;
|
|
34
54
|
/** A mark of the diagnostics recorded so far (see HostUpdateCoordinator.diagnosticMark). */
|
|
35
55
|
diagnosticMark?(): number;
|
|
36
56
|
/**
|
|
@@ -41,7 +61,11 @@ export interface AngularCompositionBridge {
|
|
|
41
61
|
acknowledge(ticket: HostUpdateTicket, resourceWitness: boolean, compilerPass?: boolean, recoverBefore?: number): Promise<void>;
|
|
42
62
|
diagnostic(ticket: HostUpdateTicket, error: Error): void;
|
|
43
63
|
committed(ticket: HostUpdateTicket): Promise<void>;
|
|
44
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Settles the hot update (see HostUpdateCoordinator.settle). `modules` is false when its hooks
|
|
66
|
+
* hand Vite nothing to update ({@link handsViteModules}); omitted, it is true.
|
|
67
|
+
*/
|
|
68
|
+
settle(ticket: HostUpdateTicket, modules?: boolean): Promise<void>;
|
|
45
69
|
fail(error: Error): void;
|
|
46
70
|
}
|
|
47
71
|
export interface AngularComposition {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { HtmlTagDescriptor, ViteDevServer, WebSocketClient } from 'vite';
|
|
2
|
+
import type { AnnouncedChange } from './host-updates.js';
|
|
3
|
+
/** The custom HMR event that carries a content update to the NgDoc client of a page. */
|
|
4
|
+
export declare const CONTENT_UPDATE_EVENT = "ng-doc:content-update";
|
|
5
|
+
/** The custom HMR event a page's NgDoc client sends once it listens for content updates. */
|
|
6
|
+
export declare const CONTENT_CLIENT_EVENT = "ng-doc:content-client";
|
|
7
|
+
/** The version of the content update messages; a client announces the version it reads. */
|
|
8
|
+
export declare const CONTENT_UPDATE_VERSION = 1;
|
|
9
|
+
/** A content update as the server sends it to a client. */
|
|
10
|
+
export interface ContentUpdateMessage {
|
|
11
|
+
readonly version: typeof CONTENT_UPDATE_VERSION;
|
|
12
|
+
/** The URLs to import the changed content modules from, each with a fresh timestamp. */
|
|
13
|
+
readonly modules: readonly string[];
|
|
14
|
+
/** Whether the search index changed. */
|
|
15
|
+
readonly search: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** What a content-only publication changed. */
|
|
18
|
+
export interface ContentChanges {
|
|
19
|
+
/** The changed content modules (`*.content.mjs`), absolute, in path order. */
|
|
20
|
+
readonly modules: readonly string[];
|
|
21
|
+
/** Whether the search index changed. */
|
|
22
|
+
readonly search: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The page's NgDoc development client, a module script Vite serves with a hot context. It imports
|
|
26
|
+
* the changed content modules again and hands their payloads to the NgDoc runtime as a cancelable
|
|
27
|
+
* window event (`@ng-doc/app`'s `ɵNG_DOC_CONTENT_UPDATE_EVENT`, the same name). The runtime
|
|
28
|
+
* cancels it once it applied them; otherwise (no NgDoc runtime on the page, a payload it cannot
|
|
29
|
+
* read) and on any failure the client reloads the page, as it did before. Updates apply one at a
|
|
30
|
+
* time, in the order they arrive.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CONTENT_UPDATE_CLIENT: string;
|
|
33
|
+
/**
|
|
34
|
+
* The tag that adds the NgDoc development client to a page the development server serves.
|
|
35
|
+
* Vite turns an inline module script into a module of its own, with a hot context.
|
|
36
|
+
* @param html The page.
|
|
37
|
+
* @returns The tag, or none when the page carries the client or the switch is off.
|
|
38
|
+
*/
|
|
39
|
+
export declare function contentUpdateClientTags(html: string): HtmlTagDescriptor[];
|
|
40
|
+
/** Whether content updates are on (`NGDOC_VITE_CONTENT_UPDATE`). */
|
|
41
|
+
export declare function contentUpdatesEnabled(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* What a reload announces, when it changes only content: every changed file is an existing
|
|
44
|
+
* content module (`*.content.mjs`) whose bytes changed, the search index or the keyword map
|
|
45
|
+
* (which no page reads). Anything else (a TypeScript module, a created or deleted file, another
|
|
46
|
+
* asset, the API lists) takes a full reload.
|
|
47
|
+
* @param changes The files that differ from the last announcement.
|
|
48
|
+
* @param assetDirectory The asset directory, relative to the output root.
|
|
49
|
+
* @returns The content changes, or `undefined` for a full reload.
|
|
50
|
+
*/
|
|
51
|
+
export declare function contentOnly(changes: readonly AnnouncedChange[] | undefined, assetDirectory: string): ContentChanges | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Sends a content update. Each client that announced its NgDoc client gets the changed content
|
|
54
|
+
* modules it may have loaded (those in the client module graph: a module nobody imported loads
|
|
55
|
+
* afresh anyway); every other client reloads, as before. Without any client the reload is sent
|
|
56
|
+
* as Vite buffers it, so a page that connects later reloads.
|
|
57
|
+
* @param server The development server.
|
|
58
|
+
* @param clients The clients that announced the NgDoc client.
|
|
59
|
+
* @param changes The content changes.
|
|
60
|
+
* @param timestamp A timestamp no earlier update used, so the browser imports new modules.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sendContentUpdate(server: ViteDevServer, clients: WeakSet<WebSocketClient>, changes: ContentChanges, timestamp: number): void;
|
|
@@ -4,6 +4,24 @@ export interface PhysicalState {
|
|
|
4
4
|
digest?: string;
|
|
5
5
|
version: string;
|
|
6
6
|
}
|
|
7
|
+
export interface ManifestFile {
|
|
8
|
+
digest: string;
|
|
9
|
+
role: OutputManifest['files'][number]['role'];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One generated file whose bytes or role differ between the outputs the browser was last told
|
|
13
|
+
* about and the outputs a reload announces now.
|
|
14
|
+
*/
|
|
15
|
+
export interface AnnouncedChange {
|
|
16
|
+
/** Relative to the output root, with forward slashes, as the manifest lists it. */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
/** The absolute path. */
|
|
19
|
+
readonly file: string;
|
|
20
|
+
/** Absent for a created file. */
|
|
21
|
+
readonly before?: Readonly<ManifestFile>;
|
|
22
|
+
/** Absent for a deleted file. */
|
|
23
|
+
readonly after?: Readonly<ManifestFile>;
|
|
24
|
+
}
|
|
7
25
|
export interface HostUpdateTicket {
|
|
8
26
|
readonly ready: Promise<void>;
|
|
9
27
|
readonly token: object;
|
|
@@ -57,6 +75,13 @@ export declare function observePhysicalVersion(file: string): string | undefined
|
|
|
57
75
|
* input is re-observed (`HostUpdateRecovery.rescan`), so the newest edit is published even if
|
|
58
76
|
* its event was lost or its generation failed under the load. A replayed report is matched like
|
|
59
77
|
* any other: one that arrives twice is a repeat, so an edit still reloads once.
|
|
78
|
+
*
|
|
79
|
+
* Churn: under a sustained stream of edits a new generation starts before the previous one is
|
|
80
|
+
* published, again and again. A host update that waits for the current publication follows each
|
|
81
|
+
* newer generation, so it settles only once the stream stops. That is required of one whose hook
|
|
82
|
+
* hands Vite modules: Vite updates them when the hook returns, which must not happen before the
|
|
83
|
+
* newest publication. A module-less one hands Vite nothing, so it settles once it is acknowledged
|
|
84
|
+
* (see {@link settle}; `NGDOC_VITE_MODULELESS_SETTLE=0` makes it wait as well).
|
|
60
85
|
*/
|
|
61
86
|
export declare class HostUpdateCoordinator {
|
|
62
87
|
private readonly notify;
|
|
@@ -86,7 +111,21 @@ export declare class HostUpdateCoordinator {
|
|
|
86
111
|
private burst?;
|
|
87
112
|
/** The start and the hot updates of the current burst-detection window. */
|
|
88
113
|
private window;
|
|
89
|
-
|
|
114
|
+
/** Whether a module-less host update settles without waiting for the current publication. */
|
|
115
|
+
private readonly modulelessSettle;
|
|
116
|
+
/**
|
|
117
|
+
* Whether the pending reload must reload the page whatever its outputs: an Angular source was
|
|
118
|
+
* compiled for it, or it repairs an earlier failure (the browser shows the error overlay).
|
|
119
|
+
*/
|
|
120
|
+
private pendingFull;
|
|
121
|
+
/**
|
|
122
|
+
* @param notify Announces the newest settled publication to the browser. `changes` lists the
|
|
123
|
+
* generated files that differ from the last announcement, when nothing else asks for a full
|
|
124
|
+
* reload; without it, or when the host cannot apply the changes in place, the page reloads.
|
|
125
|
+
* @param fail Reports a host error.
|
|
126
|
+
* @param recovery What the host does after a burst.
|
|
127
|
+
*/
|
|
128
|
+
constructor(notify: (changes?: readonly AnnouncedChange[]) => void, fail: (error: Error) => void, recovery?: HostUpdateRecovery | undefined);
|
|
90
129
|
seed(outputRoot: string, manifest: OutputManifest): void;
|
|
91
130
|
initialCompilationInventory(): InitialCompilationInventory;
|
|
92
131
|
started(generation: number, changes: FileChange[]): void;
|
|
@@ -113,7 +152,8 @@ export declare class HostUpdateCoordinator {
|
|
|
113
152
|
* generated output that a generation claimed. Its host hooks settle only once the newest
|
|
114
153
|
* generation is published and every host obligation is drained, and by then `flush()` has sent
|
|
115
154
|
* that generation's reload (or its outputs equal the last announced ones). A native reload for
|
|
116
|
-
* the same output would be a second one.
|
|
155
|
+
* the same output would be a second one. A module-less one settles earlier (see
|
|
156
|
+
* {@link settle}), but Vite has nothing of it to reload either way.
|
|
117
157
|
*/
|
|
118
158
|
announces(read: object): boolean;
|
|
119
159
|
/**
|
|
@@ -124,6 +164,16 @@ export declare class HostUpdateCoordinator {
|
|
|
124
164
|
* `ticket.ready`, which binds the generation.
|
|
125
165
|
*/
|
|
126
166
|
compilerCompanions(ticket: HostUpdateTicket): string[];
|
|
167
|
+
/**
|
|
168
|
+
* Whether the generation that claimed this TypeScript source update committed and still has a
|
|
169
|
+
* generated TypeScript module update whose Angular pass has not completed: that pass is still to
|
|
170
|
+
* come, and the source can join it (`ngDocCompanionFiles`) instead of taking a pass of its own.
|
|
171
|
+
* False for anything else: a generated output, a source no generation claimed, a generation
|
|
172
|
+
* that failed, was cancelled or rewrote no TypeScript module, or whose passes all completed.
|
|
173
|
+
* Call it after `committed(ticket)`, which waits for the generation's result.
|
|
174
|
+
* @param ticket The source's hot update ticket.
|
|
175
|
+
*/
|
|
176
|
+
generationPass(ticket: HostUpdateTicket): boolean;
|
|
127
177
|
/**
|
|
128
178
|
* Whether `file` is a generated output: a path below the output root of the published
|
|
129
179
|
* generation. Nothing is generated before the first publication or after disposal.
|
|
@@ -136,11 +186,30 @@ export declare class HostUpdateCoordinator {
|
|
|
136
186
|
/** The diagnostics recorded so far; a pass that starts now can repair exactly these. */
|
|
137
187
|
diagnosticMark(): number;
|
|
138
188
|
private recoverDiagnostics;
|
|
139
|
-
/**
|
|
140
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Waits for the current accepted publication and all peer host acknowledgments.
|
|
191
|
+
*
|
|
192
|
+
* A module-less hot update does not wait: once its hooks return, Vite has no module to update
|
|
193
|
+
* and sends nothing, and its acknowledgment has already settled what it obliged (the reload,
|
|
194
|
+
* sent by `flush()` once every obligation is settled, is this coordinator's own). Waiting made
|
|
195
|
+
* it follow every generation that started meanwhile, so under sustained churn it settled only
|
|
196
|
+
* when the churn stopped, and each wait for the host obligations to drain could time out
|
|
197
|
+
* (`NGDOC_VITE_HOST_TIMEOUT`) while every single obligation was completed in time. Nothing
|
|
198
|
+
* else changes: obligations, the reload and what is published are the same, so the switch off
|
|
199
|
+
* (`NGDOC_VITE_MODULELESS_SETTLE=0`) only makes it wait as before.
|
|
200
|
+
* @param ticket The hot update's ticket, after its acknowledgment.
|
|
201
|
+
* @param modules Whether its hooks hand Vite any module to update (or a page reload Vite sends
|
|
202
|
+
* itself, for an HTML file without modules). Only the caller, which sees Vite's context, knows.
|
|
203
|
+
*/
|
|
204
|
+
settle(ticket: HostUpdateTicket, modules?: boolean): Promise<void>;
|
|
141
205
|
/** Waits for the candidate's atomic commit boundary, including a failure that kept last-good. */
|
|
142
206
|
committed(ticket: HostUpdateTicket): Promise<void>;
|
|
143
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Acknowledges a hot update that takes no compiler pass, then settles it.
|
|
209
|
+
* @param ticket The hot update's ticket.
|
|
210
|
+
* @param modules See {@link settle}.
|
|
211
|
+
*/
|
|
212
|
+
complete(ticket: HostUpdateTicket, modules?: boolean): Promise<void>;
|
|
144
213
|
published(result: Extract<BuildResult, {
|
|
145
214
|
status: 'success';
|
|
146
215
|
}>, recovered: boolean): void;
|
|
@@ -179,9 +248,20 @@ export declare class HostUpdateCoordinator {
|
|
|
179
248
|
private hasOutputBlockers;
|
|
180
249
|
private flush;
|
|
181
250
|
private queueCurrentReload;
|
|
251
|
+
/**
|
|
252
|
+
* Settles a module-less hot update without waiting (see {@link settle}).
|
|
253
|
+
* @param token The acknowledged hot update.
|
|
254
|
+
*/
|
|
255
|
+
private settleModuleless;
|
|
182
256
|
private awaitCurrentPublication;
|
|
183
257
|
private awaitWithoutDiagnostic;
|
|
184
258
|
private delta;
|
|
259
|
+
/**
|
|
260
|
+
* The generated files that differ between two manifests, in path order.
|
|
261
|
+
* @param previousManifest The outputs the browser was last told about.
|
|
262
|
+
* @param nextManifest The outputs announced now.
|
|
263
|
+
*/
|
|
264
|
+
private changes;
|
|
185
265
|
private prune;
|
|
186
266
|
private withTimeout;
|
|
187
267
|
/** Counts a hot update towards a burst of file events (see the class description). */
|