@ng-prism/core 21.12.0 → 22.0.0-beta.1

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 (86) hide show
  1. package/README.md +10 -13
  2. package/dist/app/canvas/prism-canvas-bg-pill.component.js +1 -1
  3. package/dist/app/canvas/prism-canvas-rulers.component.js +5 -3
  4. package/dist/app/canvas/prism-canvas-toolbar.component.js +1 -1
  5. package/dist/app/canvas/prism-template-popover.component.js +7 -4
  6. package/dist/app/component-head/prism-component-head.component.js +20 -11
  7. package/dist/app/component-head/prism-stat.component.js +9 -5
  8. package/dist/app/component-header/prism-component-header.component.js +1 -1
  9. package/dist/app/controls/boolean-control.component.js +7 -4
  10. package/dist/app/controls/json-control.component.js +19 -10
  11. package/dist/app/controls/number-control.component.js +7 -4
  12. package/dist/app/controls/string-control.component.js +7 -4
  13. package/dist/app/controls/union-control.component.js +9 -5
  14. package/dist/app/directives/prism-resizer.directive.js +8 -4
  15. package/dist/app/header/prism-header-widget-host.component.js +5 -3
  16. package/dist/app/header/prism-header.component.js +13 -7
  17. package/dist/app/icons/prism-icon.component.js +5 -3
  18. package/dist/app/layout-menu/prism-layout-menu.component.js +2 -1
  19. package/dist/app/page-renderer/prism-page-renderer.component.d.ts.map +1 -1
  20. package/dist/app/page-renderer/prism-page-renderer.component.js +13 -16
  21. package/dist/app/panels/a11y/a11y-audit.service.js +8 -4
  22. package/dist/app/panels/a11y/a11y-header-badge.component.js +3 -2
  23. package/dist/app/panels/a11y/a11y-keyboard-overlay.component.js +3 -2
  24. package/dist/app/panels/a11y/a11y-keyboard.component.js +3 -2
  25. package/dist/app/panels/a11y/a11y-overlay-host.component.js +11 -6
  26. package/dist/app/panels/a11y/a11y-panel-state.service.js +2 -1
  27. package/dist/app/panels/a11y/a11y-panel.component.js +7 -4
  28. package/dist/app/panels/a11y/a11y-perspective.service.js +2 -1
  29. package/dist/app/panels/a11y/a11y-score.component.js +7 -4
  30. package/dist/app/panels/a11y/a11y-sr-overlay.component.js +5 -3
  31. package/dist/app/panels/a11y/a11y-sr.component.js +3 -2
  32. package/dist/app/panels/a11y/a11y-tree.component.js +14 -8
  33. package/dist/app/panels/a11y/a11y-violations.component.d.ts +1 -1
  34. package/dist/app/panels/a11y/a11y-violations.component.d.ts.map +1 -1
  35. package/dist/app/panels/a11y/a11y-violations.component.js +9 -11
  36. package/dist/app/panels/controls/prism-controls-panel.component.js +3 -2
  37. package/dist/app/panels/events/prism-events-panel.component.js +3 -2
  38. package/dist/app/panels/events/prism-json-node.component.js +14 -7
  39. package/dist/app/panels/panel-host/prism-panel-host.component.js +15 -8
  40. package/dist/app/renderer/prism-renderer.component.d.ts.map +1 -1
  41. package/dist/app/renderer/prism-renderer.component.js +9 -6
  42. package/dist/app/services/prism-canvas.service.js +8 -4
  43. package/dist/app/services/prism-event-log.service.js +2 -1
  44. package/dist/app/services/prism-layout.service.js +16 -8
  45. package/dist/app/services/prism-manifest.service.js +10 -5
  46. package/dist/app/services/prism-navigation.service.js +8 -4
  47. package/dist/app/services/prism-panel.service.js +6 -3
  48. package/dist/app/services/prism-plugin.service.js +14 -7
  49. package/dist/app/services/prism-renderer.service.js +10 -5
  50. package/dist/app/services/prism-search.service.js +6 -3
  51. package/dist/app/services/prism-theme.service.js +4 -2
  52. package/dist/app/services/prism-variant-bg.service.js +8 -4
  53. package/dist/app/shell/prism-shell.component.js +7 -4
  54. package/dist/app/sidebar/prism-sidebar.component.js +15 -8
  55. package/dist/app/variant-ribbon/prism-variant-ribbon.component.js +7 -4
  56. package/dist/app/view-tab-bar/prism-view-panel-host.component.js +8 -4
  57. package/dist/app/view-tab-bar/prism-view-tab-bar.component.js +2 -1
  58. package/dist/builder/build/index.d.ts.map +1 -1
  59. package/dist/builder/build/index.js +11 -4
  60. package/dist/builder/build/schema.d.ts +1 -0
  61. package/dist/builder/build/schema.d.ts.map +1 -1
  62. package/dist/builder/serve/index.d.ts.map +1 -1
  63. package/dist/builder/serve/index.js +21 -6
  64. package/dist/builder/serve/schema.d.ts +1 -0
  65. package/dist/builder/serve/schema.d.ts.map +1 -1
  66. package/dist/builder/shared/prism-pipeline.d.ts +2 -0
  67. package/dist/builder/shared/prism-pipeline.d.ts.map +1 -1
  68. package/dist/builder/shared/prism-pipeline.js +3 -5
  69. package/dist/builder/shared/resolve-cache-dir.d.ts +8 -0
  70. package/dist/builder/shared/resolve-cache-dir.d.ts.map +1 -0
  71. package/dist/builder/shared/resolve-cache-dir.js +12 -0
  72. package/dist/schematics/migrations/v21-13-manifest-cache/index.d.ts +3 -0
  73. package/dist/schematics/migrations/v21-13-manifest-cache/index.d.ts.map +1 -0
  74. package/dist/schematics/migrations/v21-13-manifest-cache/index.js +136 -0
  75. package/dist/schematics/ng-add/index.d.ts.map +1 -1
  76. package/dist/schematics/ng-add/index.js +36 -45
  77. package/dist/schematics/utils/index.d.ts +1 -0
  78. package/dist/schematics/utils/index.d.ts.map +1 -1
  79. package/dist/schematics/utils/index.js +1 -0
  80. package/dist/schematics/utils/tsconfig-paths.d.ts +8 -0
  81. package/dist/schematics/utils/tsconfig-paths.d.ts.map +1 -0
  82. package/dist/schematics/utils/tsconfig-paths.js +20 -0
  83. package/package.json +9 -6
  84. package/schematics/migrations.json +10 -0
  85. package/src/builder/build/schema.json +4 -0
  86. package/src/builder/serve/schema.json +4 -0
@@ -1,6 +1,6 @@
1
1
  import { chain, SchematicsException, } from '@angular-devkit/schematics';
2
2
  import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
- import { parse as parseJsonc, modify as modifyJsonc, applyEdits as applyJsoncEdits, } from 'jsonc-parser';
3
+ import { addTsConfigPath } from '../utils/tsconfig-paths.js';
4
4
  function readWorkspace(tree) {
5
5
  const buffer = tree.read('angular.json');
6
6
  if (!buffer) {
@@ -27,7 +27,7 @@ function addPrismAppProject(options) {
27
27
  "import { provideZonelessChangeDetection } from '@angular/core';",
28
28
  "import { bootstrapApplication } from '@angular/platform-browser';",
29
29
  "import { PrismShellComponent, providePrism } from '@ng-prism/core';",
30
- "import { PRISM_RUNTIME_MANIFEST } from './prism-manifest';",
30
+ `import { PRISM_RUNTIME_MANIFEST } from 'prism-manifest/${prismProjectName}';`,
31
31
  "import config from 'ng-prism.config';",
32
32
  '',
33
33
  'bootstrapApplication(PrismShellComponent, {',
@@ -41,7 +41,7 @@ function addPrismAppProject(options) {
41
41
  : [
42
42
  "import { bootstrapApplication } from '@angular/platform-browser';",
43
43
  "import { PrismShellComponent, providePrism } from '@ng-prism/core';",
44
- "import { PRISM_RUNTIME_MANIFEST } from './prism-manifest';",
44
+ `import { PRISM_RUNTIME_MANIFEST } from 'prism-manifest/${prismProjectName}';`,
45
45
  "import config from 'ng-prism.config';",
46
46
  '',
47
47
  'bootstrapApplication(PrismShellComponent, {',
@@ -77,10 +77,14 @@ function addPrismAppProject(options) {
77
77
  extends: '../../tsconfig.json',
78
78
  compilerOptions: {
79
79
  outDir: '../../out-tsc/app',
80
+ rootDir: '../..',
80
81
  types: [],
81
82
  },
82
83
  files: ['src/main.ts'],
83
- include: ['src/**/*.d.ts'],
84
+ include: [
85
+ 'src/**/*.d.ts',
86
+ `../../.ng-prism/${prismProjectName}/**/*.ts`,
87
+ ],
84
88
  };
85
89
  tree.create(tsconfigAppPath, JSON.stringify(tsconfigApp, null, 2) + '\n');
86
90
  }
@@ -180,32 +184,20 @@ function addBuilderTargets(options) {
180
184
  function addTsConfigPaths(options) {
181
185
  return (tree, _context) => {
182
186
  const tsConfigPath = 'tsconfig.json';
183
- const buffer = tree.read(tsConfigPath);
184
- if (!buffer) {
187
+ if (!tree.read(tsConfigPath))
185
188
  return tree;
186
- }
187
- const sourceText = buffer.toString('utf-8');
188
- const tsConfig = parseJsonc(sourceText);
189
- const existingPaths = tsConfig.compilerOptions?.paths ?? {};
190
189
  const workspace = readWorkspace(tree);
191
190
  const project = workspace.projects[options.project];
192
191
  const sourceRoot = project.sourceRoot ?? `${project.root}/src`;
193
- const formattingOptions = { tabSize: 2, insertSpaces: true };
194
- let nextText = sourceText;
195
- let changed = false;
196
- if (!existingPaths['ng-prism.config']) {
197
- const edits = modifyJsonc(nextText, ['compilerOptions', 'paths', 'ng-prism.config'], ['ng-prism.config.ts'], { formattingOptions });
198
- nextText = applyJsoncEdits(nextText, edits);
199
- changed = true;
200
- }
201
- if (!existingPaths[options.project]) {
202
- const edits = modifyJsonc(nextText, ['compilerOptions', 'paths', options.project], [`${sourceRoot}/public-api.ts`], { formattingOptions });
203
- nextText = applyJsoncEdits(nextText, edits);
204
- changed = true;
205
- }
206
- if (changed) {
207
- tree.overwrite(tsConfigPath, nextText);
208
- }
192
+ addTsConfigPath(tree, tsConfigPath, 'ng-prism.config', [
193
+ './ng-prism.config.ts',
194
+ ]);
195
+ addTsConfigPath(tree, tsConfigPath, options.project, [
196
+ `./${sourceRoot}/public-api.ts`,
197
+ ]);
198
+ addTsConfigPath(tree, tsConfigPath, 'prism-manifest/*', [
199
+ './.ng-prism/*/prism-manifest.ts',
200
+ ]);
209
201
  return tree;
210
202
  };
211
203
  }
@@ -225,24 +217,6 @@ function createConfigFile() {
225
217
  return tree;
226
218
  };
227
219
  }
228
- function addGitignoreEntry(options) {
229
- return (tree) => {
230
- const prismProjectName = `${options.project}-prism`;
231
- const entry = `projects/${prismProjectName}/src/prism-manifest.ts`;
232
- const gitignorePath = '.gitignore';
233
- const buffer = tree.read(gitignorePath);
234
- if (buffer) {
235
- const content = buffer.toString('utf-8');
236
- if (content.includes(entry))
237
- return tree;
238
- tree.overwrite(gitignorePath, content.trimEnd() + '\n' + entry + '\n');
239
- }
240
- else {
241
- tree.create(gitignorePath, entry + '\n');
242
- }
243
- return tree;
244
- };
245
- }
246
220
  const RUNTIME_PEER_DEPS = {
247
221
  'highlight.js': '^11.0.0',
248
222
  'ngx-highlightjs': '^14.0.0',
@@ -284,6 +258,23 @@ function logSetupSummary(options) {
284
258
  context.logger.info('');
285
259
  };
286
260
  }
261
+ function addNgPrismGitignoreEntry() {
262
+ return (tree) => {
263
+ const entry = '.ng-prism/';
264
+ const gitignorePath = '.gitignore';
265
+ const buffer = tree.read(gitignorePath);
266
+ if (buffer) {
267
+ const content = buffer.toString('utf-8');
268
+ if (content.split('\n').some((line) => line.trim() === entry))
269
+ return tree;
270
+ tree.overwrite(gitignorePath, content.trimEnd() + '\n' + entry + '\n');
271
+ }
272
+ else {
273
+ tree.create(gitignorePath, entry + '\n');
274
+ }
275
+ return tree;
276
+ };
277
+ }
287
278
  function addStripShowcaseScript(options) {
288
279
  return (tree) => {
289
280
  const pkgPath = 'package.json';
@@ -306,9 +297,9 @@ export function ngAdd(options) {
306
297
  addPrismAppProject(options),
307
298
  addBuilderTargets(options),
308
299
  addTsConfigPaths(options),
300
+ addNgPrismGitignoreEntry(),
309
301
  createConfigFile(),
310
302
  addStripShowcaseScript(options),
311
- addGitignoreEntry(options),
312
303
  addRuntimePeerDeps(),
313
304
  logSetupSummary(options),
314
305
  ]);
@@ -1,2 +1,3 @@
1
1
  export * from './config-ast.js';
2
+ export { addTsConfigPath } from './tsconfig-paths.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './config-ast.js';
2
+ export { addTsConfigPath } from './tsconfig-paths.js';
@@ -0,0 +1,8 @@
1
+ import type { Tree } from '@angular-devkit/schematics';
2
+ /**
3
+ * Adds `compilerOptions.paths[<key>] = <value>` to a tsconfig.json (JSONC-safe).
4
+ * Idempotent: does not overwrite an existing entry.
5
+ * Returns true when an entry was added, false otherwise (already present or file missing).
6
+ */
7
+ export declare function addTsConfigPath(tree: Tree, tsConfigPath: string, key: string, value: string[]): boolean;
8
+ //# sourceMappingURL=tsconfig-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/tsconfig-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAevD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAkBT"}
@@ -0,0 +1,20 @@
1
+ import { parse as parseJsonc, modify as modifyJsonc, applyEdits as applyJsoncEdits, } from 'jsonc-parser';
2
+ /**
3
+ * Adds `compilerOptions.paths[<key>] = <value>` to a tsconfig.json (JSONC-safe).
4
+ * Idempotent: does not overwrite an existing entry.
5
+ * Returns true when an entry was added, false otherwise (already present or file missing).
6
+ */
7
+ export function addTsConfigPath(tree, tsConfigPath, key, value) {
8
+ const buffer = tree.read(tsConfigPath);
9
+ if (!buffer)
10
+ return false;
11
+ const sourceText = buffer.toString('utf-8');
12
+ const parsed = parseJsonc(sourceText);
13
+ const existing = parsed.compilerOptions?.paths ?? {};
14
+ if (existing[key])
15
+ return false;
16
+ const edits = modifyJsonc(sourceText, ['compilerOptions', 'paths', key], value, { formattingOptions: { tabSize: 2, insertSpaces: true } });
17
+ const nextText = applyJsoncEdits(sourceText, edits);
18
+ tree.overwrite(tsConfigPath, nextText);
19
+ return true;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-prism/core",
3
- "version": "21.12.0",
3
+ "version": "22.0.0-beta.1",
4
4
  "description": "ng-prism — the Angular-native Storybook alternative. Lightweight component showcase with @Showcase decorator, no story files needed.",
5
5
  "keywords": [
6
6
  "ng-prism",
@@ -60,6 +60,9 @@
60
60
  "ng-add": {
61
61
  "save": "devDependencies"
62
62
  },
63
+ "ng-update": {
64
+ "migrations": "./schematics/migrations.json"
65
+ },
63
66
  "schematics": "./schematics/collection.json",
64
67
  "builders": "./builders.json",
65
68
  "files": [
@@ -71,11 +74,11 @@
71
74
  "!**/*.tsbuildinfo"
72
75
  ],
73
76
  "peerDependencies": {
74
- "@angular/core": ">=21.0.0",
75
- "@angular/common": ">=21.0.0",
76
- "@angular-devkit/architect": ">=0.2100.0",
77
- "@angular-devkit/core": ">=21.0.0",
78
- "@angular-devkit/schematics": ">=21.0.0",
77
+ "@angular/core": ">=20.0.0",
78
+ "@angular/common": ">=20.0.0",
79
+ "@angular-devkit/architect": ">=0.2000.0",
80
+ "@angular-devkit/core": ">=20.0.0",
81
+ "@angular-devkit/schematics": ">=20.0.0",
79
82
  "typescript": ">=5.5.0",
80
83
  "highlight.js": ">=11.0.0",
81
84
  "ngx-highlightjs": ">=14.0.0"
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "migration-v22-manifest-cache": {
5
+ "version": "22.0.0-beta.0",
6
+ "description": "Move generated prism-manifest.ts into <workspaceRoot>/.ng-prism/<prismProject>/ and resolve it via a wildcard tsconfig path mapping.",
7
+ "factory": "../dist/schematics/migrations/v21-13-manifest-cache/index#migrate"
8
+ }
9
+ }
10
+ }
@@ -28,6 +28,10 @@
28
28
  "type": "string",
29
29
  "default": "ng-prism.config.ts",
30
30
  "description": "Path to the ng-prism config file"
31
+ },
32
+ "cacheDir": {
33
+ "type": "string",
34
+ "description": "Override directory for the generated prism-manifest.ts. Default: <workspaceRoot>/.ng-prism/<prismProject>/. Relative paths resolve against workspaceRoot."
31
35
  }
32
36
  },
33
37
  "required": ["entryPoint", "prismProject"],
@@ -29,6 +29,10 @@
29
29
  "type": "string",
30
30
  "default": "ng-prism.config.ts",
31
31
  "description": "Path to the ng-prism config file"
32
+ },
33
+ "cacheDir": {
34
+ "type": "string",
35
+ "description": "Override directory for the generated prism-manifest.ts. Default: <workspaceRoot>/.ng-prism/<prismProject>/. Relative paths resolve against workspaceRoot."
32
36
  }
33
37
  },
34
38
  "required": ["entryPoint", "prismProject"],