@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
|
@@ -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;
|
|
@@ -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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,IAAA,0BAAa,EACX,WAAW,CAAC,sBAAsB,CAAC,qBAAU,CAAC,iBAAiB,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,C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33 @@
|
|
|
1
|
+
import { Node, Type, TypeNode } from 'ts-morph';
|
|
2
|
+
import { NgDocInputDeclaration } 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;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writtenUnionOrder = writtenUnionOrder;
|
|
4
|
+
exports.writtenOrder = writtenOrder;
|
|
5
|
+
exports.writtenTypeNode = writtenTypeNode;
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const is_input_1 = require("../angular/is-input");
|
|
8
|
+
/**
|
|
9
|
+
* The members of `type`'s union in the order the author wrote them.
|
|
10
|
+
*
|
|
11
|
+
* The checker's order is not the author's: without `stableTypeOrdering` it is the creation order
|
|
12
|
+
* of the member types (which depends on what the checker was asked before), with it literals sort
|
|
13
|
+
* 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
|
|
14
|
+
* argument of `input<T>()`, `input.required<T>()` or `model<T>()`), followed through unions,
|
|
15
|
+
* parentheses, non-generic type aliases and enums, to its literal members. Those members take their
|
|
16
|
+
* written order, in the positions they hold in the checker's list; every member the syntax does
|
|
17
|
+
* not name (`undefined` of an optional input, `boolean`'s literals, a generic alias) keeps the
|
|
18
|
+
* checker's position. Without a written node the checker's order is returned.
|
|
19
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
20
|
+
* @param type - The input's type.
|
|
21
|
+
* @param members - The union's members in the order to fall back to (default: the checker's).
|
|
22
|
+
*/
|
|
23
|
+
function writtenUnionOrder(declaration, type, members = type.getUnionTypes()) {
|
|
24
|
+
return writtenOrder(writtenTypeNode(declaration), members);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The members of a union in the order a written type node names them (see
|
|
28
|
+
* {@link writtenUnionOrder}): the members the node names, through unions, parentheses,
|
|
29
|
+
* non-generic type aliases and enums, take their written order in the positions they hold in
|
|
30
|
+
* `members`; the others keep their positions. Without a node, `members` is returned.
|
|
31
|
+
* @param node - The type node the author wrote for the union, if any.
|
|
32
|
+
* @param members - The union's members in the order to fall back to.
|
|
33
|
+
*/
|
|
34
|
+
function writtenOrder(node, members) {
|
|
35
|
+
if (!node || members.length < 2)
|
|
36
|
+
return members;
|
|
37
|
+
const written = [];
|
|
38
|
+
collect(node, written, new Set());
|
|
39
|
+
const slots = new Set(members.map((member) => member.compilerType));
|
|
40
|
+
const order = written.filter((member, index) => slots.has(member) && written.indexOf(member) === index);
|
|
41
|
+
const named = new Set(order);
|
|
42
|
+
let next = 0;
|
|
43
|
+
const byCompiler = new Map(members.map((member) => [member.compilerType, member]));
|
|
44
|
+
return members.map((member) => named.has(member.compilerType) ? byCompiler.get(order[next++]) : member);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The type node the author wrote for an input or parameter, if any: its annotation, or the type
|
|
48
|
+
* argument of `input<T>()`, `input.required<T>()` or `model<T>()`.
|
|
49
|
+
* @param declaration - The input property, accessor or pipe parameter.
|
|
50
|
+
*/
|
|
51
|
+
function writtenTypeNode(declaration) {
|
|
52
|
+
if (ts_morph_1.Node.isPropertyDeclaration(declaration) && (0, is_input_1.isInputSignal)(declaration)) {
|
|
53
|
+
const initializer = declaration.getInitializer();
|
|
54
|
+
return ts_morph_1.Node.isCallExpression(initializer) ? initializer.getTypeArguments()[0] : undefined;
|
|
55
|
+
}
|
|
56
|
+
if (ts_morph_1.Node.isSetAccessorDeclaration(declaration))
|
|
57
|
+
return declaration.getParameters()[0]?.getTypeNode();
|
|
58
|
+
if (ts_morph_1.Node.isGetAccessorDeclaration(declaration))
|
|
59
|
+
return declaration.getReturnTypeNode();
|
|
60
|
+
if (ts_morph_1.Node.isPropertyDeclaration(declaration) || ts_morph_1.Node.isParameterDeclaration(declaration))
|
|
61
|
+
return declaration.getTypeNode();
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/** Appends the member types `node` names, in written order. */
|
|
65
|
+
function collect(node, into, seen) {
|
|
66
|
+
if (seen.has(node))
|
|
67
|
+
return;
|
|
68
|
+
seen.add(node);
|
|
69
|
+
if (ts_morph_1.Node.isUnionTypeNode(node)) {
|
|
70
|
+
node.getTypeNodes().forEach((member) => collect(member, into, seen));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (ts_morph_1.Node.isParenthesizedTypeNode(node)) {
|
|
74
|
+
collect(node.getTypeNode(), into, seen);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (ts_morph_1.Node.isTypeReference(node) && !node.getTypeArguments().length) {
|
|
78
|
+
let symbol = node.getTypeName().getSymbol();
|
|
79
|
+
if (symbol?.isAlias())
|
|
80
|
+
symbol = symbol.getAliasedSymbol();
|
|
81
|
+
const declaration = symbol?.getDeclarations()[0];
|
|
82
|
+
if (ts_morph_1.Node.isTypeAliasDeclaration(declaration) && !declaration.getTypeParameters().length) {
|
|
83
|
+
const aliased = declaration.getTypeNode();
|
|
84
|
+
if (aliased) {
|
|
85
|
+
collect(aliased, into, seen);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (ts_morph_1.Node.isEnumDeclaration(declaration)) {
|
|
90
|
+
// A member's declared type is the fresh literal type; a union holds the regular one.
|
|
91
|
+
declaration
|
|
92
|
+
.getMembers()
|
|
93
|
+
.forEach((member) => into.push(regularType(member.getType().compilerType)));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
into.push(node.getType().compilerType);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The regular type of a fresh literal type, which is the one unions hold; other types as they are.
|
|
101
|
+
* @param type - A type.
|
|
102
|
+
*/
|
|
103
|
+
function regularType(type) {
|
|
104
|
+
return type.regularType ?? type;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=written-union-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-union-order.js","sourceRoot":"","sources":["../../../../../libs/builder/help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C;AACzC,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,OAAQ,IAA4C,CAAC,WAAW,IAAI,IAAI,CAAC;AAC3E,CAAC"}
|
|
@@ -52,12 +52,20 @@ export interface NgDocConfiguration {
|
|
|
52
52
|
* (`false` by default). It also builds a demo page for every demo. Only the Vite engine reads it.
|
|
53
53
|
*/
|
|
54
54
|
isolatedDemos?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Renders the demos of every playground in iframes, as `isolated: true` does for one playground
|
|
57
|
+
* (`false` by default). It also builds the playground pages of every playground. Only the Vite
|
|
58
|
+
* engine reads it; the legacy engine renders playgrounds in the page.
|
|
59
|
+
*/
|
|
60
|
+
isolatedPlaygrounds?: boolean;
|
|
55
61
|
/**
|
|
56
62
|
* The demo pages: one page per demo that loads only Angular and that demo, which isolated demos
|
|
57
|
-
* show in an iframe and "Open in new tab" opens
|
|
63
|
+
* show in an iframe and "Open in new tab" opens, and one page per target of each playground,
|
|
64
|
+
* which isolated playgrounds show in iframes. Only the Vite engine builds them.
|
|
58
65
|
*
|
|
59
|
-
* By default only the pages with an isolated demo get them. `true` (or an object)
|
|
60
|
-
* every page with demos;
|
|
66
|
+
* By default only the pages with an isolated demo or playground get them. `true` (or an object)
|
|
67
|
+
* builds the demo pages of every page with demos; playground pages are built only for isolated
|
|
68
|
+
* playgrounds. `false` never builds them, and isolated demos and playgrounds render in the page.
|
|
61
69
|
*/
|
|
62
70
|
demoApplication?: boolean | NgDocDemoApplicationConfiguration;
|
|
63
71
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-doc/builder",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.2.0",
|
|
4
4
|
"description": "Generates an NgDoc documentation site from your Markdown pages and TypeScript code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ng-doc/core": "22.
|
|
35
|
-
"@ng-doc/utils": "22.
|
|
34
|
+
"@ng-doc/core": "22.2.0",
|
|
35
|
+
"@ng-doc/utils": "22.2.0",
|
|
36
36
|
"@angular-devkit/architect": ">=0.2200.0 <0.2300.0",
|
|
37
37
|
"minimatch": "9.0.9",
|
|
38
38
|
"rxjs": "^7.0.0",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"ng-doc": "./generator/bootstrap/bin.js"
|
|
123
123
|
},
|
|
124
124
|
"engines": {
|
|
125
|
-
"node": ">=24.15.0 <25"
|
|
125
|
+
"node": ">=24.15.0 <25 || >=26.0.0 <27"
|
|
126
126
|
},
|
|
127
127
|
"author": "Skoropad Aleksandr <alex@skoropad.dev>"
|
|
128
128
|
}
|
|
@@ -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
|
|
package/templates/page.ts.nunj
CHANGED
|
@@ -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() {
|