@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.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/engine/builders/helpers/get-playground-metadata.js +7 -1
  3. package/engine/builders/helpers/get-playground-metadata.js.map +1 -1
  4. package/engine/builders/page/demo-assets.builder.js +2 -0
  5. package/engine/builders/page/demo-assets.builder.js.map +1 -1
  6. package/engine/builders/shared/content.builder.js +2 -0
  7. package/engine/builders/shared/content.builder.js.map +1 -1
  8. package/engine/builders/shared/page-wrapper.builder.js +2 -0
  9. package/engine/builders/shared/page-wrapper.builder.js.map +1 -1
  10. package/generator/bootstrap/bin.js +174 -107
  11. package/generator/bootstrap/cli.js +174 -107
  12. package/generator/bootstrap/index.js +139 -99
  13. package/generator/bootstrap/process-tree.d.ts +5 -4
  14. package/generator/build-metafile.json +647 -240
  15. package/generator/build-provenance.json +6 -4
  16. package/generator/compiler/index.d.ts +20 -0
  17. package/generator/compiler/index.js +2400 -945
  18. package/generator/compiler/plan.d.ts +24 -0
  19. package/generator/content/code-snippet.d.ts +20 -0
  20. package/generator/content/content-compiler.d.ts +5 -1
  21. package/generator/content/format-cache.d.ts +108 -0
  22. package/generator/content/highlight-cache.d.ts +12 -36
  23. package/generator/content/html-pipeline.d.ts +10 -1
  24. package/generator/content/html-pool.d.ts +8 -2
  25. package/generator/content/html-worker.js +630 -39
  26. package/generator/contracts.d.ts +57 -0
  27. package/generator/discovery/index.d.ts +2 -0
  28. package/generator/kernel/flags.d.ts +5 -0
  29. package/generator/outputs/index.d.ts +29 -0
  30. package/generator/semantic/angular.d.ts +21 -1
  31. package/generator/semantic/formatting.d.ts +27 -0
  32. package/generator/semantic/fragments.d.ts +11 -2
  33. package/generator/templates/api/class-declaration.html.nunj +5 -3
  34. package/generator/templates/demo-app.ts.nunj +37 -0
  35. package/generator/templates/demo-routes.ts.nunj +43 -0
  36. package/generator/templates/index.ts.nunj +5 -0
  37. package/generator/templates/page-wrapper.ts.nunj +6 -1
  38. package/generator/templates/page.ts.nunj +13 -2
  39. package/generator/templates/routes.ts.nunj +7 -3
  40. package/generator/templates/symbol/members.html.nunj +6 -4
  41. package/generator/templates/symbol/page.html.nunj +1 -1
  42. package/generator/vite/angular/analog-provenance.json +1 -1
  43. package/generator/vite/angular-composition.d.ts +25 -1
  44. package/generator/vite/application-builder.js +6 -1
  45. package/generator/vite/application.d.ts +14 -0
  46. package/generator/vite/content-updates.d.ts +62 -0
  47. package/generator/vite/demo-application.d.ts +34 -0
  48. package/generator/vite/dev-server-builder.js +6 -1
  49. package/generator/vite/host-updates.d.ts +153 -6
  50. package/generator/vite/index.js +985 -247
  51. package/generator/vite/lifecycle.d.ts +40 -2
  52. package/generator/vite/prerender-entry.js +72 -2
  53. package/generator/vite/prerender-runtime.d.ts +13 -0
  54. package/generator/vite/prerender.d.ts +2 -0
  55. package/helpers/format-cache.d.ts +34 -0
  56. package/helpers/format-cache.js +26 -0
  57. package/helpers/format-cache.js.map +1 -0
  58. package/helpers/format-code.js +9 -2
  59. package/helpers/format-code.js.map +1 -1
  60. package/helpers/playground/get-playground-inputs.js +6 -3
  61. package/helpers/playground/get-playground-inputs.js.map +1 -1
  62. package/helpers/playground/playground-options.d.ts +28 -0
  63. package/helpers/playground/playground-options.js +122 -0
  64. package/helpers/playground/playground-options.js.map +1 -0
  65. package/helpers/playground/written-union-order.d.ts +33 -0
  66. package/helpers/playground/written-union-order.js +106 -0
  67. package/helpers/playground/written-union-order.js.map +1 -0
  68. package/helpers/to-template-string.d.ts +5 -1
  69. package/helpers/to-template-string.js +7 -2
  70. package/helpers/to-template-string.js.map +1 -1
  71. package/interfaces/code-block-options.d.ts +5 -0
  72. package/interfaces/configuration.d.ts +92 -1
  73. package/package.json +6 -5
  74. package/parsers/parse-code-block-params.d.ts +10 -1
  75. package/parsers/parse-code-block-params.js +29 -3
  76. package/parsers/parse-code-block-params.js.map +1 -1
  77. package/schematics/collection.json +1 -1
  78. package/schematics/migrate-to-vite/analyze.js +46 -3
  79. package/schematics/migrate-to-vite/analyze.js.map +1 -1
  80. package/schematics/migrate-to-vite/setup/workspace.d.ts +5 -0
  81. package/schematics/migrate-to-vite/setup/workspace.js +20 -0
  82. package/schematics/migrate-to-vite/setup/workspace.js.map +1 -1
  83. package/schematics/migrate-to-vite/testing/fixtures.d.ts +12 -0
  84. package/schematics/migrate-to-vite/testing/fixtures.js +27 -0
  85. package/schematics/migrate-to-vite/testing/fixtures.js.map +1 -1
  86. package/schematics/vite-setup/index.d.ts +9 -5
  87. package/schematics/vite-setup/index.js +11 -5
  88. package/schematics/vite-setup/index.js.map +1 -1
  89. package/schematics/vite-setup/schema.json +1 -1
  90. package/templates/api/class-declaration.html.nunj +5 -3
  91. package/templates/demo-app.ts.nunj +37 -0
  92. package/templates/demo-routes.ts.nunj +43 -0
  93. package/templates/index.ts.nunj +5 -0
  94. package/templates/page-wrapper.ts.nunj +6 -1
  95. package/templates/page.ts.nunj +13 -2
  96. package/templates/routes.ts.nunj +7 -3
  97. package/templates/symbol/members.html.nunj +6 -4
  98. package/templates/symbol/page.html.nunj +1 -1
@@ -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/helpers/playground/written-union-order.ts"],"names":[],"mappings":";;AAmBA,8CAMC;AAUD,oCAcC;AAOD,0CAWC;AAnED,uCAAoD;AAEpD,kDAA2E;AAE3E;;;;;;;;;;;;;;GAcG;AACH,SAAgB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
1
  /**
2
+ * Escapes text for the body of a template literal, so the literal evaluates to the text itself.
2
3
  *
3
- * @param content
4
+ * The backslash is escaped first: otherwise `\d` would evaluate to `d`, `\n` to a line break and
5
+ * `\203A` would fail to compile (octal escapes are not allowed in template literals), and the
6
+ * escapes added for `` ` `` and `${` must not be escaped again.
7
+ * @param content - The text to embed.
4
8
  */
5
9
  export declare function toTemplateString(content: string): string;
@@ -2,12 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toTemplateString = toTemplateString;
4
4
  /**
5
+ * Escapes text for the body of a template literal, so the literal evaluates to the text itself.
5
6
  *
6
- * @param content
7
+ * The backslash is escaped first: otherwise `\d` would evaluate to `d`, `\n` to a line break and
8
+ * `\203A` would fail to compile (octal escapes are not allowed in template literals), and the
9
+ * escapes added for `` ` `` and `${` must not be escaped again.
10
+ * @param content - The text to embed.
7
11
  */
8
12
  function toTemplateString(content) {
9
13
  return (content
10
- ?.replace(/`/g, '\\`')
14
+ ?.replace(/\\/g, '\\\\')
15
+ .replace(/`/g, '\\`')
11
16
  .replace(/\${/g, '\\${')
12
17
  .replace(/{/g, '\\{')
13
18
  .replace(/}/g, '\\}') ?? '');
@@ -1 +1 @@
1
- {"version":3,"file":"to-template-string.js","sourceRoot":"","sources":["../../../../libs/builder/helpers/to-template-string.ts"],"names":[],"mappings":";;AAIA,4CAQC;AAZD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC/C,OAAO,CACN,OAAO;QACN,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAC5B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"to-template-string.js","sourceRoot":"","sources":["../../../../libs/builder/helpers/to-template-string.ts"],"names":[],"mappings":";;AAQA,4CASC;AAjBD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,OAAO,CACL,OAAO;QACL,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAC9B,CAAC;AACJ,CAAC"}
@@ -8,5 +8,10 @@ export interface NgDocCodeBlockParams {
8
8
  icon?: string;
9
9
  fileLineStart?: number;
10
10
  fileLineEnd?: number;
11
+ /**
12
+ * The snippet of `file` to show, from `file="./x.ts"#<id>`: the lines between the two
13
+ * `snippet#<id>` markers. Only the Vite engine reads it.
14
+ */
15
+ snippet?: string;
11
16
  highlightedLines?: number[];
12
17
  }
@@ -1,4 +1,4 @@
1
- import { NgDocHeading, NgDocKeywordsLoader } from '@ng-doc/core';
1
+ import { NgDocDemoProvidersImport, NgDocHeading, NgDocKeywordsLoader } from '@ng-doc/core';
2
2
  import { NgDocGlobalKeyword } from '@ng-doc/core/interfaces/keyword-map';
3
3
  import { NgDocRepoConfig } from './repo-config';
4
4
  /**
@@ -43,6 +43,38 @@ export interface NgDocConfiguration {
43
43
  * The configuration for the guides
44
44
  */
45
45
  guide?: NgDocGuideConfiguration;
46
+ /**
47
+ * The configuration for the API pages. Only the Vite engine reads it.
48
+ */
49
+ api?: NgDocApiConfiguration;
50
+ /**
51
+ * Shows every demo of the `demo` action in an iframe, as `isolated: true` does for one demo
52
+ * (`false` by default). It also builds a demo page for every demo. Only the Vite engine reads it.
53
+ */
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;
61
+ /**
62
+ * The demo pages: one page per demo that loads only Angular and that demo, which isolated demos
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.
65
+ *
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.
69
+ */
70
+ demoApplication?: boolean | NgDocDemoApplicationConfiguration;
71
+ /**
72
+ * Imports the module whose default export lists the providers of the demo pages, for example
73
+ * `() => import('./demo.providers')`. It must be written in `ng-doc.config.ts` as an arrow
74
+ * function that returns one `import()` of a file. NgDoc never calls it while it generates; the
75
+ * demo pages import the module. Only the Vite engine reads it.
76
+ */
77
+ demoProviders?: NgDocDemoProvidersImport;
46
78
  /**
47
79
  * Shiki configuration
48
80
  */
@@ -51,8 +83,43 @@ export interface NgDocConfiguration {
51
83
  light: string;
52
84
  dark: string;
53
85
  };
86
+ /**
87
+ * Shiki language registrations that code blocks can use in addition to the languages bundled
88
+ * with Shiki, such as a grammar imported from a `.tmLanguage.json` file or from
89
+ * `@shikijs/langs`. A registration named like a bundled language replaces it. Only the Vite
90
+ * engine reads it; load the same languages in the browser with `provideNgDocApp`.
91
+ */
92
+ langs?: Array<NgDocShikiLanguage | readonly NgDocShikiLanguage[]>;
54
93
  };
55
94
  }
95
+ /**
96
+ * A Shiki (TextMate) language registration: a grammar and the name that code blocks use for it.
97
+ * It must be plain JSON data, as in a `.tmLanguage.json` file or a module of `@shikijs/langs`.
98
+ */
99
+ export interface NgDocShikiLanguage {
100
+ /** The language name: code blocks that name it (for example ` ```my-lang `) use the grammar. */
101
+ name: string;
102
+ /** The root scope of the grammar, such as `source.my-lang`. */
103
+ scopeName: string;
104
+ /** The name to display for the language. */
105
+ displayName?: string;
106
+ /** Other names that code blocks can use for the language. */
107
+ aliases?: string[];
108
+ /** The languages that the grammar embeds, which must be bundled or registered too. */
109
+ embeddedLangs?: string[];
110
+ /** The languages that the grammar embeds when they are loaded. */
111
+ embeddedLangsLazy?: string[];
112
+ /** The scopes that the grammar injects itself into. */
113
+ injectTo?: string[];
114
+ /** The TextMate rules of the grammar. */
115
+ patterns?: unknown;
116
+ /** The named TextMate rules that `patterns` include. */
117
+ repository?: unknown;
118
+ /** TextMate injections. */
119
+ injections?: unknown;
120
+ /** The selector of an injection grammar. */
121
+ injectionSelector?: string;
122
+ }
56
123
  /**
57
124
  * The configuration for the guide page
58
125
  */
@@ -67,6 +134,30 @@ export interface NgDocGuideConfiguration {
67
134
  */
68
135
  headerTemplate?: string;
69
136
  }
137
+ /**
138
+ * The configuration for the API pages.
139
+ */
140
+ export interface NgDocApiConfiguration {
141
+ /**
142
+ * Whether API pages list the protected members of classes, inherited ones included
143
+ * (`true` by default). With `false`, they list only public members: hidden members get no row,
144
+ * anchor, search record or keyword.
145
+ */
146
+ protectedMembers?: boolean;
147
+ }
148
+ /**
149
+ * The configuration of the demo pages.
150
+ */
151
+ export interface NgDocDemoApplicationConfiguration {
152
+ /**
153
+ * The URL path under which the demo pages are served, relative to the base href
154
+ * (`demo-preview` by default): a demo's page is `<base href><path>/<page route>/<demo name>/`.
155
+ * One or more URL segments of letters, digits, `-`, `_` and `.`; the first character of a
156
+ * segment is a letter or a digit, because some static hosts skip folders that start with `_`
157
+ * or `.`.
158
+ */
159
+ path?: string;
160
+ }
70
161
  /**
71
162
  * The configuration for the global keywords.
72
163
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-doc/builder",
3
- "version": "22.0.0",
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.0.0",
35
- "@ng-doc/utils": "22.0.0",
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",
@@ -56,7 +56,8 @@
56
56
  "parsimmon": "^1.18.1",
57
57
  "@parcel/watcher": "^2.5.0",
58
58
  "@microsoft/tsdoc": "0.15.1",
59
- "@shikijs/rehype": "1.10.3",
59
+ "@shikijs/rehype": "4.5.0",
60
+ "shiki": "4.5.0",
60
61
  "css-what": "6.1.0",
61
62
  "github-slugger": "2.0.0",
62
63
  "hast-util-has-property": "3.0.0",
@@ -121,7 +122,7 @@
121
122
  "ng-doc": "./generator/bootstrap/bin.js"
122
123
  },
123
124
  "engines": {
124
- "node": ">=24.15.0 <25"
125
+ "node": ">=24.15.0 <25 || >=26.0.0 <27"
125
126
  },
126
127
  "author": "Skoropad Aleksandr <alex@skoropad.dev>"
127
128
  }
@@ -1,6 +1,15 @@
1
1
  import type { NgDocCodeBlockParams } from '../interfaces/code-block-options';
2
+ /** Options of {@link parseCodeBlockParams}. */
3
+ export interface NgDocCodeBlockParserOptions {
4
+ /**
5
+ * Whether a fragment after the `file` parameter may name a snippet: `file="./x.ts"#greeting`.
6
+ * Without it, only line ranges are accepted, and any other fragment fails to parse.
7
+ */
8
+ snippets?: boolean;
9
+ }
2
10
  /**
3
11
  * Code block options parser
4
12
  * @param options - Options string to parse
13
+ * @param parserOptions - What the caller supports beyond the original syntax.
5
14
  */
6
- export declare function parseCodeBlockParams(options: string): NgDocCodeBlockParams;
15
+ export declare function parseCodeBlockParams(options: string, parserOptions?: NgDocCodeBlockParserOptions): NgDocCodeBlockParams;
@@ -10,11 +10,31 @@ const helpers_1 = require("./helpers");
10
10
  * whitespace end it, so the parameters that follow are parsed as before.
11
11
  */
12
12
  const CODE_BLOCK_LANGUAGE = /[\p{L}\p{N}+#-]+/u;
13
+ /** The characters of a snippet id, as `// snippet#<id>` markers spell it (`parseSnippet`). */
14
+ const SNIPPET_ID = /[a-zA-Z0-9-]+/;
15
+ /** A fragment that is a line range: `L<n>`, `L<n>-` or `L<n>-L<m>`. */
16
+ const LINE_RANGE = /^L(\d+)(?:(-)(?:L(\d+))?)?$/;
17
+ /**
18
+ * The fragment after a `file` parameter when snippets are on: `#L<n>`, `#L<n>-` and
19
+ * `#L<n>-L<m>` are line ranges (the same ranges as without snippets), any other id names a
20
+ * snippet.
21
+ * @param fragment - The fragment without its `#`.
22
+ */
23
+ function fileFragment(fragment) {
24
+ const range = LINE_RANGE.exec(fragment);
25
+ if (!range)
26
+ return { snippet: fragment };
27
+ const fileLineStart = Number(range[1]) - 1;
28
+ if (!range[2])
29
+ return { fileLineStart, fileLineEnd: fileLineStart + 1 };
30
+ return { fileLineStart, fileLineEnd: range[3] === undefined ? undefined : Number(range[3]) };
31
+ }
13
32
  /**
14
33
  * Code block options parser
15
34
  * @param options - Options string to parse
35
+ * @param parserOptions - What the caller supports beyond the original syntax.
16
36
  */
17
- function parseCodeBlockParams(options) {
37
+ function parseCodeBlockParams(options, parserOptions = {}) {
18
38
  const parser = parsimmon_1.default.createLanguage({
19
39
  language: () => parsimmon_1.default.regexp(CODE_BLOCK_LANGUAGE)
20
40
  .skip(parsimmon_1.default.optWhitespace)
@@ -28,7 +48,9 @@ function parseCodeBlockParams(options) {
28
48
  .then(p['fileLineNumber'])
29
49
  .map((num) => num - 1)
30
50
  .map((fileLineStart) => ({ fileLineStart, fileLineEnd: fileLineStart + 1 })),
31
- lineParams: (p) => p['fileLineRange'].or(p['fileLineStart']).fallback({}),
51
+ lineParams: (p) => (parserOptions.snippets
52
+ ? parsimmon_1.default.string('#').then(parsimmon_1.default.regexp(SNIPPET_ID)).map(fileFragment)
53
+ : p['fileLineRange'].or(p['fileLineStart'])).fallback({}),
32
54
  highlightedLinesRange: () => parsimmon_1.default.seqMap(helpers_1.number.skip(parsimmon_1.default.string('-')), helpers_1.number, (start, end) => [...Array(end + 1).keys()].slice(start - end - 1)),
33
55
  // Main Parsers
34
56
  lineNumbers: () => parsimmon_1.default.string('lineNumbers').map(() => ({ lineNumbers: true })),
@@ -38,7 +60,11 @@ function parseCodeBlockParams(options) {
38
60
  fileName: () => (0, helpers_1.param)('fileName', 'name'),
39
61
  icon: () => (0, helpers_1.param)('icon'),
40
62
  active: () => parsimmon_1.default.string('active').map(() => ({ active: true })),
41
- file: (p) => parsimmon_1.default.seq(p['filePath'], p['lineParams'].map(({ fileLineStart, fileLineEnd }) => ({ fileLineStart, fileLineEnd }))).map(([file, lineParams]) => ({ ...file, ...lineParams })),
63
+ file: (p) => parsimmon_1.default.seq(p['filePath'], p['lineParams'].map(({ fileLineStart, fileLineEnd, snippet }) => ({
64
+ fileLineStart,
65
+ fileLineEnd,
66
+ ...(snippet === undefined ? {} : { snippet }),
67
+ }))).map(([file, lineParams]) => ({ ...file, ...lineParams })),
42
68
  highlightedLines: (p) => p['highlightedLinesRange']
43
69
  .or(helpers_1.number)
44
70
  .sepBy(parsimmon_1.default.string(',').then(parsimmon_1.default.optWhitespace))
@@ -1 +1 @@
1
- {"version":3,"file":"parse-code-block-params.js","sourceRoot":"","sources":["../../../../libs/builder/parsers/parse-code-block-params.ts"],"names":[],"mappings":";;AAgBA,oDAkFC;;AAlGD,kEAA0B;AAG1B,uCAA0C;AAE1C;;;;GAIG;AACH,MAAM,mBAAmB,GAAW,mBAAmB,CAAC;AAExD;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,MAAM,MAAM,GAAG,mBAAC,CAAC,cAAc,CAAC;QAC9B,QAAQ,EAAE,GAAG,EAAE,CACb,mBAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;aAC1B,IAAI,CAAC,mBAAC,CAAC,aAAa,CAAC;aACrB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtC,eAAe;QACf,cAAc,EAAE,GAAG,EAAE,CAAC,mBAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAA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,CAAC,CAAC;IAEnD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,CAAC,GAAyB,EAAE,GAAkC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EACvF,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE3D,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,CAAC,GAAyB,EAAE,GAAkC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EACvF,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,GAAG,CAAC,CAAC;AACtE,CAAC"}
1
+ {"version":3,"file":"parse-code-block-params.js","sourceRoot":"","sources":["../../../../libs/builder/parsers/parse-code-block-params.ts"],"names":[],"mappings":";;AA8CA,oDA6FC;;AA3ID,kEAA0B;AAG1B,uCAA0C;AAE1C;;;;GAIG;AACH,MAAM,mBAAmB,GAAW,mBAAmB,CAAC;AAExD,8FAA8F;AAC9F,MAAM,UAAU,GAAW,eAAe,CAAC;AAE3C,uEAAuE;AACvE,MAAM,UAAU,GAAW,6BAA6B,CAAC;AAWzD;;;;;GAKG;AACH,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,CAAC,CAAC,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;IAED,MAAM,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE3D,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,CAAC,GAAyB,EAAE,GAAkC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EACvF,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,GAAG,CAAC,CAAC;AACtE,CAAC"}
@@ -22,7 +22,7 @@
22
22
  "schema": "./migrate-to-vite/schema.json"
23
23
  },
24
24
  "vite-setup": {
25
- "description": "Sets up the Vite engine for a project on Angular's application builder (run by ng add @ng-doc/add)",
25
+ "description": "Sets up the Vite engine for a project on Angular's application builder or Nx's application executor (run by ng add @ng-doc/add)",
26
26
  "factory": "./vite-setup/index#viteSetup",
27
27
  "schema": "./vite-setup/schema.json",
28
28
  "hidden": true
@@ -106,7 +106,15 @@ const MANUAL = {
106
106
  serviceWorker: 'The Vite engine does not build the Angular service worker.',
107
107
  subresourceIntegrity: 'Use a Vite plugin to add `integrity` attributes.',
108
108
  webWorkerTsConfig: 'Vite bundles workers created with `new Worker(new URL(...))` itself.',
109
+ // Nx's `application` executor runs Angular's builder with these options of its own.
110
+ indexHtmlTransformer: 'Nx transforms index.html with this function; move it to a Vite plugin with a `transformIndexHtml` hook.',
111
+ plugins: 'Nx runs these esbuild plugins and Vite does not; add a Vite plugin that does the same to the Vite configuration.',
109
112
  };
113
+ /**
114
+ * `buildLibsFromSource: false` of Nx's executors: Nx builds the buildable libraries first and
115
+ * resolves them to their output.
116
+ */
117
+ const BUILD_LIBS_FROM_SOURCE = 'is `false`; the Vite engine reads the workspace libraries from source through the tsconfig `paths` and does not build them first.';
110
118
  function isRecord(value) {
111
119
  return typeof value === 'object' && value !== null && !Array.isArray(value);
112
120
  }
@@ -526,11 +534,17 @@ function analyzeProject(tree, project, buildName, serveName, options, builderKey
526
534
  else
527
535
  add('dropped', 'build.outputHashing', 'Vite hashes the output file names by default.');
528
536
  }
529
- else if (option === 'scripts') {
537
+ else if (option === 'scripts' || option === 'plugins') {
530
538
  if (values.some((value) => Array.isArray(value) && value.length))
531
- add('manual', 'build.scripts', MANUAL['scripts']);
539
+ add('manual', `build.${option}`, MANUAL[option]);
540
+ else
541
+ add('dropped', `build.${option}`, 'The list is empty.');
542
+ }
543
+ else if (option === 'buildLibsFromSource') {
544
+ if (values.includes(false))
545
+ add('manual', 'build.buildLibsFromSource', BUILD_LIBS_FROM_SOURCE);
532
546
  else
533
- add('dropped', 'build.scripts', 'The list is empty.');
547
+ add('dropped', 'build.buildLibsFromSource', 'The Vite engine reads the workspace libraries from source through the tsconfig `paths`.');
534
548
  }
535
549
  else if (option === 'serviceWorker') {
536
550
  if (active.length)
@@ -744,6 +758,35 @@ function analyzeServe(project, serveName, buildName, build, add, plainMode) {
744
758
  case 'verbose':
745
759
  add('dropped', subject, 'Vite prebundles dependencies and logs by its own settings.');
746
760
  break;
761
+ // The options Nx's `dev-server` executor adds to Angular's.
762
+ case 'buildLibsFromSource':
763
+ if (value === false)
764
+ add('manual', subject, BUILD_LIBS_FROM_SOURCE);
765
+ else
766
+ add('dropped', subject, 'The Vite engine reads the workspace libraries from source.');
767
+ break;
768
+ case 'watchDependencies':
769
+ add('dropped', subject, 'The Vite engine watches the library sources it reads.');
770
+ break;
771
+ case 'forceEsbuild':
772
+ case 'publicHost':
773
+ add('dropped', subject, 'Nx uses it with webpack-based builds only.');
774
+ break;
775
+ case 'disableHostCheck':
776
+ if (value === true) {
777
+ devServer.allowedHosts = true;
778
+ add('migrated', subject, 'Vite `server.allowedHosts: true`.');
779
+ }
780
+ else
781
+ add('dropped', subject, 'The host check is on.');
782
+ break;
783
+ case 'esbuildMiddleware':
784
+ if (Array.isArray(value) && value.length) {
785
+ add('manual', subject, 'Add these middleware functions with the `configureServer` hook of a Vite plugin.');
786
+ }
787
+ else
788
+ add('dropped', subject, 'The list is empty.');
789
+ break;
747
790
  case 'ngDoc':
748
791
  add('manual', subject, 'The development server uses the NgDoc settings of the build target.');
749
792
  break;