@ng-doc/builder 22.0.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/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 +174 -107
- package/generator/bootstrap/cli.js +174 -107
- package/generator/bootstrap/index.js +139 -99
- package/generator/bootstrap/process-tree.d.ts +5 -4
- package/generator/build-metafile.json +647 -240
- package/generator/build-provenance.json +6 -4
- package/generator/compiler/index.d.ts +20 -0
- package/generator/compiler/index.js +2400 -945
- 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 +630 -39
- package/generator/contracts.d.ts +57 -0
- package/generator/discovery/index.d.ts +2 -0
- package/generator/kernel/flags.d.ts +5 -0
- package/generator/outputs/index.d.ts +29 -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 +43 -0
- package/generator/templates/index.ts.nunj +5 -0
- package/generator/templates/page-wrapper.ts.nunj +6 -1
- package/generator/templates/page.ts.nunj +13 -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/angular/analog-provenance.json +1 -1
- package/generator/vite/angular-composition.d.ts +25 -1
- package/generator/vite/application-builder.js +6 -1
- package/generator/vite/application.d.ts +14 -0
- package/generator/vite/content-updates.d.ts +62 -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 +153 -6
- package/generator/vite/index.js +985 -247
- package/generator/vite/lifecycle.d.ts +40 -2
- 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/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/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 +92 -1
- package/package.json +6 -5
- 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 +43 -0
- package/templates/index.ts.nunj +5 -0
- package/templates/page-wrapper.ts.nunj +6 -1
- package/templates/page.ts.nunj +13 -2
- package/templates/routes.ts.nunj +7 -3
- package/templates/symbol/members.html.nunj +6 -4
- package/templates/symbol/page.html.nunj +1 -1
|
@@ -26,6 +26,14 @@ export declare class ViteAdapterLifecycle {
|
|
|
26
26
|
* description modules it read. `read` is computed on demand, once per snapshot.
|
|
27
27
|
*/
|
|
28
28
|
private committed?;
|
|
29
|
+
/** Whether a content-only reload updates the open pages in place (`NGDOC_VITE_CONTENT_UPDATE`). */
|
|
30
|
+
private readonly contentUpdates;
|
|
31
|
+
/** The browser clients whose NgDoc client listens for content updates. */
|
|
32
|
+
private readonly contentClients;
|
|
33
|
+
/** The timestamp of the last content update: each one imports the modules anew. */
|
|
34
|
+
private contentStamp;
|
|
35
|
+
/** Records the clients that announce the NgDoc client. */
|
|
36
|
+
private readonly contentClient;
|
|
29
37
|
/**
|
|
30
38
|
* @param progress NgDoc's terminal progress: `interrupt` clears its live line before the adapter
|
|
31
39
|
* logs, and `release` follows each watch result the adapter has logged (or skipped), so the
|
|
@@ -38,6 +46,15 @@ export declare class ViteAdapterLifecycle {
|
|
|
38
46
|
} | undefined);
|
|
39
47
|
attachSession(session: BuildSession): void;
|
|
40
48
|
attachServer(server: ViteDevServer, source: ViteFileEventSource): void;
|
|
49
|
+
/** Stops recording the clients that announce the NgDoc client. */
|
|
50
|
+
private stopContentClients;
|
|
51
|
+
/**
|
|
52
|
+
* Tells the browser about the newest settled publication: a content update when it changed only
|
|
53
|
+
* content (see `contentOnly`), else a full reload.
|
|
54
|
+
* @param changes The generated files that differ from the last announcement, if the reload may
|
|
55
|
+
* be applied in place.
|
|
56
|
+
*/
|
|
57
|
+
private announce;
|
|
41
58
|
attachWatch(watch: WatchHandle): void;
|
|
42
59
|
acceptInitial(result: BuildResult): Extract<BuildResult, {
|
|
43
60
|
status: 'success';
|
|
@@ -59,9 +76,24 @@ export declare class ViteAdapterLifecycle {
|
|
|
59
76
|
*/
|
|
60
77
|
private committedDescriptionModule;
|
|
61
78
|
hostUpdateStarted(file: string, type: 'create' | 'update' | 'delete', read: () => string | Promise<string>): HostUpdateTicket;
|
|
62
|
-
|
|
79
|
+
/**
|
|
80
|
+
* See {@link HostUpdateCoordinator.complete}.
|
|
81
|
+
* @param ticket The hot update's ticket.
|
|
82
|
+
* @param modules Whether its hooks hand Vite any module to update.
|
|
83
|
+
*/
|
|
84
|
+
hostUpdateCompleted(ticket: HostUpdateTicket, modules?: boolean): Promise<void>;
|
|
63
85
|
/** The adapter reloads for this settled hot update itself. */
|
|
64
86
|
hostUpdateAnnounced(read: object): boolean;
|
|
87
|
+
/** See {@link HostUpdateCoordinator.generationPass}. */
|
|
88
|
+
hostGenerationPass(ticket: HostUpdateTicket): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether `file` is a description module (`ng-doc.page.ts`, `ng-doc.category.ts`,
|
|
91
|
+
* `ng-doc.api.ts`) the generator watches: its edit starts a generation that reads it.
|
|
92
|
+
* @param file An absolute path.
|
|
93
|
+
*/
|
|
94
|
+
hostDescriptionModule(file: string): boolean;
|
|
95
|
+
/** Whether `file` is a generated output (see {@link HostUpdateCoordinator.generated}). */
|
|
96
|
+
hostGenerated(file: string): boolean;
|
|
65
97
|
/** See {@link HostUpdateCoordinator.compilerCompanions}. */
|
|
66
98
|
hostUpdateCompanions(ticket: HostUpdateTicket): string[];
|
|
67
99
|
/**
|
|
@@ -92,7 +124,12 @@ export declare class ViteAdapterLifecycle {
|
|
|
92
124
|
initialCompilationInventory(): import("./host-updates.js").InitialCompilationInventory;
|
|
93
125
|
hostUpdateAcknowledged(ticket: HostUpdateTicket, resourceWitness?: boolean, compilerPass?: boolean, recoverBefore?: number): Promise<void>;
|
|
94
126
|
hostUpdateDiagnostic(ticket: HostUpdateTicket, error: Error): void;
|
|
95
|
-
|
|
127
|
+
/**
|
|
128
|
+
* See {@link HostUpdateCoordinator.settle}.
|
|
129
|
+
* @param ticket The hot update's ticket.
|
|
130
|
+
* @param modules Whether its hooks hand Vite any module to update.
|
|
131
|
+
*/
|
|
132
|
+
hostUpdateSettled(ticket: HostUpdateTicket, modules?: boolean): Promise<void>;
|
|
96
133
|
hostUpdateCommitted(ticket: HostUpdateTicket): Promise<void>;
|
|
97
134
|
hostUpdateFailed(error: Error): void;
|
|
98
135
|
observer(configurationOf: (result: BuildResult) => PublishedGeneratorConfiguration | undefined): (event: BuildEvent) => void;
|
|
@@ -111,6 +148,7 @@ export declare class ViteAdapterLifecycle {
|
|
|
111
148
|
private reconcile;
|
|
112
149
|
private fail;
|
|
113
150
|
private report;
|
|
151
|
+
private warn;
|
|
114
152
|
private isCurrent;
|
|
115
153
|
private log;
|
|
116
154
|
private interrupt;
|
|
@@ -301,13 +301,82 @@ async function runPrerender(request, options = {}) {
|
|
|
301
301
|
errors.push({ route: current, message: format(...args) });
|
|
302
302
|
log.apply(console, args);
|
|
303
303
|
};
|
|
304
|
+
const warnings = [];
|
|
304
305
|
try {
|
|
305
|
-
|
|
306
|
+
const report = await renderRoutes();
|
|
307
|
+
if (request.demoServerEntry) report.routes = await renderDemoRoutes(report.routes);
|
|
308
|
+
return { ...report, errors, ...warnings.length ? { warnings } : {} };
|
|
306
309
|
} finally {
|
|
307
310
|
console.error = log;
|
|
308
311
|
restoreWarnings();
|
|
309
312
|
globalThis.fetch = originalFetch;
|
|
310
313
|
}
|
|
314
|
+
async function renderDemoRoutes(rendered) {
|
|
315
|
+
const shellFile2 = path2.join(browserDir, DEMO_SHELL);
|
|
316
|
+
const message = (error) => error instanceof Error ? error.message : String(error);
|
|
317
|
+
let demoDocument;
|
|
318
|
+
let demo;
|
|
319
|
+
let inventory;
|
|
320
|
+
current = `/${DEMO_SHELL}`;
|
|
321
|
+
try {
|
|
322
|
+
demoDocument = await readFile(shellFile2, "utf8");
|
|
323
|
+
demo = serverEntry(
|
|
324
|
+
await importModule(pathToFileURL(path2.resolve(request.demoServerEntry)).href)
|
|
325
|
+
);
|
|
326
|
+
await withTimeout(
|
|
327
|
+
demo.renderApplication(
|
|
328
|
+
async (context) => {
|
|
329
|
+
const application = await demo.bootstrap(context);
|
|
330
|
+
const router = application.injector.get(demo.Router);
|
|
331
|
+
inventory = await enumerateRoutes(Array.isArray(router?.config) ? router.config : [], {
|
|
332
|
+
invoke: (factory) => demo.runInInjectionContext(application.injector, factory)
|
|
333
|
+
});
|
|
334
|
+
return application;
|
|
335
|
+
},
|
|
336
|
+
{ document: demoDocument, url: url("/"), allowedHosts: [HOST] }
|
|
337
|
+
),
|
|
338
|
+
request.routeTimeoutMs,
|
|
339
|
+
current
|
|
340
|
+
);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
warnings.push({
|
|
343
|
+
route: current,
|
|
344
|
+
message: `[NGDOC_PRERENDER_DEMO_APPLICATION] The demo pages were not prerendered: ${message(error)}`
|
|
345
|
+
});
|
|
346
|
+
return rendered;
|
|
347
|
+
}
|
|
348
|
+
const taken = new Set(rendered.map((route) => route.path));
|
|
349
|
+
const result = [...rendered];
|
|
350
|
+
for (const route of inventory.routes) {
|
|
351
|
+
if (route.redirectTo !== void 0 || taken.has(route.path)) continue;
|
|
352
|
+
const file = routeFile(route.path);
|
|
353
|
+
current = route.path;
|
|
354
|
+
let html;
|
|
355
|
+
try {
|
|
356
|
+
html = await withTimeout(
|
|
357
|
+
demo.renderApplication(demo.bootstrap, {
|
|
358
|
+
document: demoDocument,
|
|
359
|
+
url: url(route.path),
|
|
360
|
+
allowedHosts: [HOST]
|
|
361
|
+
}),
|
|
362
|
+
request.routeTimeoutMs,
|
|
363
|
+
route.path
|
|
364
|
+
);
|
|
365
|
+
} catch (error) {
|
|
366
|
+
warnings.push({
|
|
367
|
+
route: route.path,
|
|
368
|
+
message: `[NGDOC_PRERENDER_DEMO_FALLBACK] The demo page did not render on the server, so it renders in the browser only: ${message(error)}`
|
|
369
|
+
});
|
|
370
|
+
html = demoDocument;
|
|
371
|
+
}
|
|
372
|
+
await mkdir(path2.dirname(path2.join(browserDir, file)), { recursive: true });
|
|
373
|
+
await writeFile(path2.join(browserDir, file), html);
|
|
374
|
+
result.push({ ...route, file });
|
|
375
|
+
}
|
|
376
|
+
return result.sort(
|
|
377
|
+
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
378
|
+
);
|
|
379
|
+
}
|
|
311
380
|
async function renderRoutes() {
|
|
312
381
|
const discovered = [];
|
|
313
382
|
const excluded = [];
|
|
@@ -374,13 +443,14 @@ function runPrerenderChild(port, run = runPrerender) {
|
|
|
374
443
|
);
|
|
375
444
|
});
|
|
376
445
|
}
|
|
377
|
-
var SHELL, HOST;
|
|
446
|
+
var SHELL, DEMO_SHELL, HOST;
|
|
378
447
|
var init_prerender_runtime = __esm({
|
|
379
448
|
"libs/builder/generator/vite/prerender-runtime.ts"() {
|
|
380
449
|
"use strict";
|
|
381
450
|
init_mime();
|
|
382
451
|
init_route_inventory();
|
|
383
452
|
SHELL = "index.csr.html";
|
|
453
|
+
DEMO_SHELL = "ng-doc-demo.html";
|
|
384
454
|
HOST = "localhost";
|
|
385
455
|
}
|
|
386
456
|
});
|
|
@@ -11,6 +11,11 @@ export interface PrerenderRequest {
|
|
|
11
11
|
discoverRoutes: boolean;
|
|
12
12
|
/** Fails a route that takes longer to render, in milliseconds. */
|
|
13
13
|
routeTimeoutMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The server bundle of the demo application (`demo-server.mjs`), when the build has demo pages.
|
|
16
|
+
* Its routes are rendered into the demo application's page (`ng-doc-demo.html`).
|
|
17
|
+
*/
|
|
18
|
+
demoServerEntry?: string;
|
|
14
19
|
}
|
|
15
20
|
export interface PrerenderReport {
|
|
16
21
|
/** Every rendered route, in code-unit order, with the file written for it. */
|
|
@@ -26,6 +31,14 @@ export interface PrerenderReport {
|
|
|
26
31
|
route: string;
|
|
27
32
|
message: string;
|
|
28
33
|
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Demo pages that failed to render, which got the demo application's client page instead, and
|
|
36
|
+
* a demo application that could not be prerendered at all. Absent when there are none.
|
|
37
|
+
*/
|
|
38
|
+
warnings?: Array<{
|
|
39
|
+
route: string;
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
29
42
|
}
|
|
30
43
|
export interface PrerenderRuntimeOptions {
|
|
31
44
|
/** Imports the server bundle; tests replace it. */
|
|
@@ -12,6 +12,8 @@ export interface NgDocPrerenderOptions {
|
|
|
12
12
|
discoverRoutes?: boolean;
|
|
13
13
|
/** Fails a route that takes longer to render, in milliseconds (default: no limit). */
|
|
14
14
|
routeTimeoutMs?: number;
|
|
15
|
+
/** The demo application's server bundle (`demo-server.mjs`), when the build has demo pages. */
|
|
16
|
+
demoServerEntry?: string;
|
|
15
17
|
signal?: AbortSignal;
|
|
16
18
|
/** The child process entry; tests replace it. */
|
|
17
19
|
entryUrl?: URL;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Options } from 'prettier';
|
|
2
|
+
/**
|
|
3
|
+
* A cache that `formatCode` consults while it is installed with {@link withFormatCodeCache}. The
|
|
4
|
+
* new engine installs one around its own formatting calls; without one (the legacy engine, the
|
|
5
|
+
* kill switch, the reference path) `formatCode` resolves the configuration and formats every
|
|
6
|
+
* call, as it always did.
|
|
7
|
+
*/
|
|
8
|
+
export interface FormatCodeCache {
|
|
9
|
+
/**
|
|
10
|
+
* The Prettier configuration for `configDirectory`. `resolve` reads it; the cache may call it
|
|
11
|
+
* once and return that value for later calls. An error of `resolve` is thrown to the caller.
|
|
12
|
+
*/
|
|
13
|
+
config(configDirectory: string | undefined, resolve: () => Options | null): Options | null;
|
|
14
|
+
/**
|
|
15
|
+
* The formatted code. `format` formats it; the cache may return a value it stored for the same
|
|
16
|
+
* code, parser and configuration instead. An error of `format` is thrown; the cache may store a
|
|
17
|
+
* Prettier syntax error (deterministic for these inputs) and throw one again on a hit, so
|
|
18
|
+
* `formatCode` returns the code unformatted in both cases.
|
|
19
|
+
*/
|
|
20
|
+
format(input: {
|
|
21
|
+
code: string;
|
|
22
|
+
parser: string;
|
|
23
|
+
config: Options | null;
|
|
24
|
+
}, format: () => string): string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Runs `run` with `cache` installed for every `formatCode` call it makes synchronously, and
|
|
28
|
+
* restores the previous one afterwards.
|
|
29
|
+
* @param cache The cache to install, or undefined for none.
|
|
30
|
+
* @param run The synchronous work that formats.
|
|
31
|
+
*/
|
|
32
|
+
export declare function withFormatCodeCache<T>(cache: FormatCodeCache | undefined, run: () => T): T;
|
|
33
|
+
/** The cache installed by {@link withFormatCodeCache}, if any. */
|
|
34
|
+
export declare function activeFormatCodeCache(): FormatCodeCache | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withFormatCodeCache = withFormatCodeCache;
|
|
4
|
+
exports.activeFormatCodeCache = activeFormatCodeCache;
|
|
5
|
+
let active;
|
|
6
|
+
/**
|
|
7
|
+
* Runs `run` with `cache` installed for every `formatCode` call it makes synchronously, and
|
|
8
|
+
* restores the previous one afterwards.
|
|
9
|
+
* @param cache The cache to install, or undefined for none.
|
|
10
|
+
* @param run The synchronous work that formats.
|
|
11
|
+
*/
|
|
12
|
+
function withFormatCodeCache(cache, run) {
|
|
13
|
+
const previous = active;
|
|
14
|
+
active = cache;
|
|
15
|
+
try {
|
|
16
|
+
return run();
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
active = previous;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** The cache installed by {@link withFormatCodeCache}, if any. */
|
|
23
|
+
function activeFormatCodeCache() {
|
|
24
|
+
return active;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=format-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-cache.js","sourceRoot":"","sources":["../../../../libs/builder/helpers/format-cache.ts"],"names":[],"mappings":";;AAkCA,kDAQC;AAGD,sDAEC;AArBD,IAAI,MAAmC,CAAC;AAExC;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAI,KAAkC,EAAE,GAAY;IACrF,MAAM,QAAQ,GAAG,MAAM,CAAC;IACxB,MAAM,GAAG,KAAK,CAAC;IACf,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,SAAgB,qBAAqB;IACnC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/helpers/format-code.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.formatCode = formatCode;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sync_1 = tslib_1.__importDefault(require("@prettier/sync"));
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
|
+
const format_cache_1 = require("./format-cache");
|
|
7
8
|
/**
|
|
8
9
|
* Format code with Prettier
|
|
9
10
|
* @param code - Code to format
|
|
@@ -14,14 +15,20 @@ function formatCode(code, codeType = 'TypeScript', configDirectory) {
|
|
|
14
15
|
try {
|
|
15
16
|
if (codeType) {
|
|
16
17
|
const parser = getPrettierParserFromCodeType(codeType);
|
|
17
|
-
|
|
18
|
+
// The new engine's cache, when it formats (see `./format-cache`); none in the legacy engine.
|
|
19
|
+
const cache = (0, format_cache_1.activeFormatCodeCache)();
|
|
20
|
+
const resolve = () => sync_1.default.resolveConfig(
|
|
18
21
|
// Prettier searches from a file's parent, so use a synthetic path inside the directory.
|
|
19
22
|
configDirectory ? (0, node_path_1.join)(configDirectory, '__ng_doc_format__.ts') : process.cwd(), { editorconfig: true, useCache: false });
|
|
20
|
-
|
|
23
|
+
const config = cache ? cache.config(configDirectory, resolve) : resolve();
|
|
24
|
+
const format = () => sync_1.default.format(code, {
|
|
21
25
|
...config,
|
|
22
26
|
parser,
|
|
23
27
|
embeddedLanguageFormatting: 'auto',
|
|
24
28
|
}).trim();
|
|
29
|
+
return cache && typeof parser === 'string'
|
|
30
|
+
? cache.format({ code, parser, config }, format)
|
|
31
|
+
: format();
|
|
25
32
|
}
|
|
26
33
|
return code.trim();
|
|
27
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-code.js","sourceRoot":"","sources":["../../../../libs/builder/helpers/format-code.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"format-code.js","sourceRoot":"","sources":["../../../../libs/builder/helpers/format-code.ts"],"names":[],"mappings":";;AAaA,gCAmCC;;AA/CD,kEAA0C;AAC1C,yCAAiC;AAGjC,iDAAuD;AAEvD;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,IAAY,EACZ,WAAiC,YAAY,EAC7C,eAAwB;IAExB,IAAI,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAkC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;YACtF,6FAA6F;YAC7F,MAAM,KAAK,GAAG,IAAA,oCAAqB,GAAE,CAAC;YACtC,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,cAAY,CAAC,aAAa;YACxB,wFAAwF;YACxF,eAAe,CAAC,CAAC,CAAC,IAAA,gBAAI,EAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAC/E,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CACxC,CAAC;YACJ,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAC1E,MAAM,MAAM,GAAG,GAAG,EAAE,CAEhB,cAAY,CAAC,MAAM,CAAC,IAAI,EAAE;gBACxB,GAAG,MAAM;gBACT,MAAM;gBACN,0BAA0B,EAAE,MAAM;aACnC,CACF,CAAC,IAAI,EAAE,CAAC;YAEX,OAAO,KAAK,IAAI,OAAO,MAAM,KAAK,QAAQ;gBACxC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC;gBAChD,CAAC,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,6BAA6B,CAAC,QAAuB;IAC5D,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -10,6 +10,7 @@ const get_input_name_1 = require("../angular/get-input-name");
|
|
|
10
10
|
const get_input_type_1 = require("../angular/get-input-type");
|
|
11
11
|
const get_js_doc_1 = require("../get-js-doc");
|
|
12
12
|
const typescript_1 = require("../typescript");
|
|
13
|
+
const playground_options_1 = require("./playground-options");
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
15
16
|
* @param declaration
|
|
@@ -52,9 +53,11 @@ function propOrParamToPlaygroundProperty(propOrParam, inputName) {
|
|
|
52
53
|
ts_morph_1.Node.isSetAccessorDeclaration(propOrParam)
|
|
53
54
|
? (0, get_js_doc_1.getJsDocDescription)(propOrParam)
|
|
54
55
|
: (0, get_js_doc_1.getJsDocParam)(propOrParam.getParentIfKindOrThrow(ts_morph_1.SyntaxKind.MethodDeclaration), propOrParam.getName()),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// An array of a union of literals gets the members of its item type, as in the new engine.
|
|
57
|
+
options: (0, playground_options_1.playgroundArrayOptions)(propOrParam, inputType) ??
|
|
58
|
+
inputType
|
|
59
|
+
.getUnionTypes()
|
|
60
|
+
.map((type) => type.getText(undefined, ts_morph_1.TypeFormatFlags.NoTruncation | ts_morph_1.TypeFormatFlags.UseSingleQuotesForStringLiteralType)),
|
|
58
61
|
},
|
|
59
62
|
};
|
|
60
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-playground-inputs.js","sourceRoot":"","sources":["../../../../../libs/builder/helpers/playground/get-playground-inputs.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"get-playground-inputs.js","sourceRoot":"","sources":["../../../../../libs/builder/helpers/playground/get-playground-inputs.ts"],"names":[],"mappings":";;AAwBA,oEAUC;AAMD,0DAQC;AA/CD,uCAOkB;AAElB,qFAAqF;AACrF,gGAAgG;AAChG,0EAAqE;AACrE,8DAAyD;AACzD,8DAAyD;AAEzD,8CAAmE;AACnE,8CAA2C;AAC3C,6DAA8D;AAE9D;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,WAA6B;IAE7B,OAAO,IAAA,yCAAkB,EAAC,WAAW,CAAC,CAAC,MAAM,CAC3C,CAAC,UAAqC,EAAE,QAA+B,EAAE,EAAE;QACzE,MAAM,SAAS,GAAW,IAAA,6BAAY,EAAC,QA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,CAAC,EAChE,WAAW,CAAC,OAAO,EAAE,CACtB;YACP,2FAA2F;YAC3F,OAAO,EACL,IAAA,2CAAsB,EAAC,WAAW,EAAE,SAAS,CAAC;gBAC9C,SAAS;qBACN,aAAa,EAAE;qBACf,GAAG,CAAC,CAAC,IAAU,EAAE,EAAE,CAClB,IAAI,CAAC,OAAO,CACV,SAAS,EACT,0BAAe,CAAC,YAAY,GAAG,0BAAe,CAAC,mCAAmC,CACnF,CACF;SACN;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { NgDocPlaygroundOption } from '@ng-doc/core';
|
|
2
|
+
import { Node, Type } from 'ts-morph';
|
|
3
|
+
import { NgDocInputDeclaration } from '../angular/is-input';
|
|
4
|
+
/**
|
|
5
|
+
* An option of a union input. The runtime evaluates the printed text of a member, which works for
|
|
6
|
+
* literals (`'small'`, `1`) but not for an enum member (`Status.Good`): a member of an enum is the
|
|
7
|
+
* member's name, which the playground shows, and the literal value the checker resolved for it,
|
|
8
|
+
* which the playground sets.
|
|
9
|
+
* @param member - A member of the input's union type.
|
|
10
|
+
*/
|
|
11
|
+
export declare function playgroundOption(member: Type): string | NgDocPlaygroundOption;
|
|
12
|
+
/**
|
|
13
|
+
* The options of an array input whose items are a union of literals, such as `NgDocSize[]`,
|
|
14
|
+
* `('a' | 'b')[]`, `Array<'x' | 'y'>` or `Status[]` of an enum, optional or nullable too: the
|
|
15
|
+
* members of the item type, which the playground's multi-select offers. Both engines call it, so
|
|
16
|
+
* their options are the same.
|
|
17
|
+
*
|
|
18
|
+
* The members are listed in the order the item type is written (`writtenOrder`), and the members
|
|
19
|
+
* the syntax does not name (the literals of a `boolean` among them) by their printed text, never
|
|
20
|
+
* in the checker's order, which differs between the engines' programs. `undefined` and `null`
|
|
21
|
+
* items are left out: the multi-select adds values. An array of booleans only, a tuple, an
|
|
22
|
+
* array whose items are not all literals, and an alias of an array type (printed by its name, so
|
|
23
|
+
* the playground can't read it as an array) have no such options.
|
|
24
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
25
|
+
* @param type - The input's type.
|
|
26
|
+
* @returns The options, or `undefined` when the input is not such an array.
|
|
27
|
+
*/
|
|
28
|
+
export declare function playgroundArrayOptions(declaration: NgDocInputDeclaration | Node, type: Type): Array<string | NgDocPlaygroundOption> | undefined;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.playgroundOption = playgroundOption;
|
|
4
|
+
exports.playgroundArrayOptions = playgroundArrayOptions;
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const text_order_1 = require("../text-order");
|
|
7
|
+
const written_union_order_1 = require("./written-union-order");
|
|
8
|
+
/** How option texts are printed: in full, with the single quotes the runtime evaluates. */
|
|
9
|
+
const OPTION_TEXT_FLAGS = ts_morph_1.TypeFormatFlags.NoTruncation | ts_morph_1.TypeFormatFlags.UseSingleQuotesForStringLiteralType;
|
|
10
|
+
/**
|
|
11
|
+
* An option of a union input. The runtime evaluates the printed text of a member, which works for
|
|
12
|
+
* literals (`'small'`, `1`) but not for an enum member (`Status.Good`): a member of an enum is the
|
|
13
|
+
* member's name, which the playground shows, and the literal value the checker resolved for it,
|
|
14
|
+
* which the playground sets.
|
|
15
|
+
* @param member - A member of the input's union type.
|
|
16
|
+
*/
|
|
17
|
+
function playgroundOption(member) {
|
|
18
|
+
if (member.isEnumLiteral()) {
|
|
19
|
+
const value = member.getLiteralValue();
|
|
20
|
+
const name = member.getSymbol()?.getName();
|
|
21
|
+
if (name && (typeof value === 'string' || typeof value === 'number'))
|
|
22
|
+
return { label: name, value };
|
|
23
|
+
}
|
|
24
|
+
return member.getText(undefined, OPTION_TEXT_FLAGS);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The options of an array input whose items are a union of literals, such as `NgDocSize[]`,
|
|
28
|
+
* `('a' | 'b')[]`, `Array<'x' | 'y'>` or `Status[]` of an enum, optional or nullable too: the
|
|
29
|
+
* members of the item type, which the playground's multi-select offers. Both engines call it, so
|
|
30
|
+
* their options are the same.
|
|
31
|
+
*
|
|
32
|
+
* The members are listed in the order the item type is written (`writtenOrder`), and the members
|
|
33
|
+
* the syntax does not name (the literals of a `boolean` among them) by their printed text, never
|
|
34
|
+
* in the checker's order, which differs between the engines' programs. `undefined` and `null`
|
|
35
|
+
* items are left out: the multi-select adds values. An array of booleans only, a tuple, an
|
|
36
|
+
* array whose items are not all literals, and an alias of an array type (printed by its name, so
|
|
37
|
+
* the playground can't read it as an array) have no such options.
|
|
38
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
39
|
+
* @param type - The input's type.
|
|
40
|
+
* @returns The options, or `undefined` when the input is not such an array.
|
|
41
|
+
*/
|
|
42
|
+
function playgroundArrayOptions(declaration, type) {
|
|
43
|
+
const arrays = withoutNullish(type.isUnion() ? type.getUnionTypes() : [type]);
|
|
44
|
+
const array = arrays.length === 1 ? arrays[0] : undefined;
|
|
45
|
+
if (!array || !(array.isArray() || array.isReadonlyArray()) || array.getAliasSymbol()) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const item = array.getTypeArguments()[0];
|
|
49
|
+
const members = item?.isUnion() ? withoutNullish(item.getUnionTypes()) : [];
|
|
50
|
+
if (!members.length ||
|
|
51
|
+
!members.every(isLiteral) ||
|
|
52
|
+
members.every((member) => member.isBooleanLiteral())) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const byText = [...members].sort((a, b) => compareTexts(text(a), text(b)));
|
|
56
|
+
return (0, written_union_order_1.writtenOrder)(itemTypeNode((0, written_union_order_1.writtenTypeNode)(declaration)), byText).map(playgroundOption);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The type node of the items of a written array type: `T` of `T[]`, `readonly T[]`, `Array<T>`
|
|
60
|
+
* and `ReadonlyArray<T>`, alone or in a union with `undefined` or `null`.
|
|
61
|
+
* @param node - The written type of the input.
|
|
62
|
+
*/
|
|
63
|
+
function itemTypeNode(node) {
|
|
64
|
+
if (!node)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (ts_morph_1.Node.isParenthesizedTypeNode(node))
|
|
67
|
+
return itemTypeNode(node.getTypeNode());
|
|
68
|
+
if (ts_morph_1.Node.isUnionTypeNode(node)) {
|
|
69
|
+
const rest = node.getTypeNodes().filter((member) => !isNullish(member));
|
|
70
|
+
return rest.length === 1 ? itemTypeNode(rest[0]) : undefined;
|
|
71
|
+
}
|
|
72
|
+
if (ts_morph_1.Node.isTypeOperatorTypeNode(node) && node.getOperator() === ts_morph_1.SyntaxKind.ReadonlyKeyword)
|
|
73
|
+
return itemTypeNode(node.getTypeNode());
|
|
74
|
+
if (ts_morph_1.Node.isArrayTypeNode(node))
|
|
75
|
+
return node.getElementTypeNode();
|
|
76
|
+
if (ts_morph_1.Node.isTypeReference(node) && /^(?:Readonly)?Array$/.test(node.getTypeName().getText()))
|
|
77
|
+
return node.getTypeArguments()[0];
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Whether a written type is `undefined` or `null`.
|
|
82
|
+
* @param node - A member of a written union.
|
|
83
|
+
*/
|
|
84
|
+
function isNullish(node) {
|
|
85
|
+
return (node.getKind() === ts_morph_1.SyntaxKind.UndefinedKeyword ||
|
|
86
|
+
(ts_morph_1.Node.isLiteralTypeNode(node) && node.getLiteral().getKind() === ts_morph_1.SyntaxKind.NullKeyword));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The types other than `undefined` and `null`.
|
|
90
|
+
* @param types - The members of a union.
|
|
91
|
+
*/
|
|
92
|
+
function withoutNullish(types) {
|
|
93
|
+
return types.filter((type) => !type.isUndefined() && !type.isNull());
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether a type is a literal the playground can set: a string, number or boolean literal, or an
|
|
97
|
+
* enum member.
|
|
98
|
+
* @param type - A member of the item union.
|
|
99
|
+
*/
|
|
100
|
+
function isLiteral(type) {
|
|
101
|
+
return (type.isStringLiteral() ||
|
|
102
|
+
type.isNumberLiteral() ||
|
|
103
|
+
type.isBooleanLiteral() ||
|
|
104
|
+
type.isEnumLiteral());
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The printed text of a member.
|
|
108
|
+
* @param type - A member of the item union.
|
|
109
|
+
*/
|
|
110
|
+
function text(type) {
|
|
111
|
+
return type.getText(undefined, OPTION_TEXT_FLAGS);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Orders texts in NgDoc's fixed text order, and texts the collator finds equal by code units, so
|
|
115
|
+
* the order never depends on the program or the machine.
|
|
116
|
+
* @param a - A text.
|
|
117
|
+
* @param b - Another text.
|
|
118
|
+
*/
|
|
119
|
+
function compareTexts(a, b) {
|
|
120
|
+
return (0, text_order_1.compareText)(a, b) || (a < b ? -1 : a > b ? 1 : 0);
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=playground-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground-options.js","sourceRoot":"","sources":["../../../../../libs/builder/helpers/playground/playground-options.ts"],"names":[],"mappings":";;AAkBA,4CAQC;AAkBD,wDAyBC;AApED,uCAA6E;AAG7E,8CAA4C;AAC5C,+DAAsE;AAEtE,2FAA2F;AAC3F,MAAM,iBAAiB,GACrB,0BAAe,CAAC,YAAY,GAAG,0BAAe,CAAC,mCAAmC,CAAC;AAErF;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,MAAY;IAC3C,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC;QAC3C,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI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DocInputDeclaration } from '../angular/is-input';
|
|
3
|
+
/**
|
|
4
|
+
* The members of `type`'s union in the order the author wrote them.
|
|
5
|
+
*
|
|
6
|
+
* The checker's order is not the author's: without `stableTypeOrdering` it is the creation order
|
|
7
|
+
* of the member types (which depends on what the checker was asked before), with it literals sort
|
|
8
|
+
* by value. A playground lists its options from that union, so the list is read from the syntax: the type node written for the input (its annotation, or the type
|
|
9
|
+
* argument of `input<T>()`, `input.required<T>()` or `model<T>()`), followed through unions,
|
|
10
|
+
* parentheses, non-generic type aliases and enums, to its literal members. Those members take their
|
|
11
|
+
* written order, in the positions they hold in the checker's list; every member the syntax does
|
|
12
|
+
* not name (`undefined` of an optional input, `boolean`'s literals, a generic alias) keeps the
|
|
13
|
+
* checker's position. Without a written node the checker's order is returned.
|
|
14
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
15
|
+
* @param type - The input's type.
|
|
16
|
+
* @param members - The union's members in the order to fall back to (default: the checker's).
|
|
17
|
+
*/
|
|
18
|
+
export declare function writtenUnionOrder(declaration: NgDocInputDeclaration | Node, type: Type, members?: Type[]): Type[];
|
|
19
|
+
/**
|
|
20
|
+
* The members of a union in the order a written type node names them (see
|
|
21
|
+
* {@link writtenUnionOrder}): the members the node names, through unions, parentheses,
|
|
22
|
+
* non-generic type aliases and enums, take their written order in the positions they hold in
|
|
23
|
+
* `members`; the others keep their positions. Without a node, `members` is returned.
|
|
24
|
+
* @param node - The type node the author wrote for the union, if any.
|
|
25
|
+
* @param members - The union's members in the order to fall back to.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writtenOrder(node: TypeNode | undefined, members: Type[]): Type[];
|
|
28
|
+
/**
|
|
29
|
+
* The type node the author wrote for an input or parameter, if any: its annotation, or the type
|
|
30
|
+
* argument of `input<T>()`, `input.required<T>()` or `model<T>()`.
|
|
31
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
32
|
+
*/
|
|
33
|
+
export declare function writtenTypeNode(declaration: NgDocInputDeclaration | Node): TypeNode | undefined;
|