@ng-prism/core 21.12.0-beta.1 → 21.12.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/dist/app/header/prism-header.component.d.ts.map +1 -1
- package/dist/app/header/prism-header.component.js +2 -3
- package/dist/app/panels/a11y/a11y.types.d.ts.map +1 -1
- package/dist/app/provide-prism.d.ts.map +1 -1
- package/dist/app/provide-prism.js +13 -4
- package/dist/app/renderer/prism-renderer.component.d.ts.map +1 -1
- package/dist/app/services/prism-navigation.service.d.ts.map +1 -1
- package/dist/app/services/prism-navigation.service.js +19 -15
- package/dist/builder/a11y/a11y-report-reader.d.ts.map +1 -1
- package/dist/builder/a11y/a11y-report-reader.js +20 -4
- package/dist/builder/manifest/runtime-manifest.generator.d.ts.map +1 -1
- package/dist/builder/manifest/runtime-manifest.generator.js +11 -3
- package/dist/builder/plugin-runner/plugin-runner.d.ts.map +1 -1
- package/dist/decorator/index.d.ts +1 -1
- package/dist/decorator/index.d.ts.map +1 -1
- package/dist/decorator/showcase.decorator.d.ts.map +1 -1
- package/dist/decorator/showcase.types.d.ts.map +1 -1
- package/dist/schematics/ng-add/index.d.ts.map +1 -1
- package/dist/schematics/ng-add/index.js +30 -0
- package/dist/schematics/utils/config-ast.d.ts +17 -0
- package/dist/schematics/utils/config-ast.d.ts.map +1 -0
- package/dist/schematics/utils/config-ast.js +118 -0
- package/dist/schematics/utils/index.d.ts +2 -0
- package/dist/schematics/utils/index.d.ts.map +1 -0
- package/dist/schematics/utils/index.js +1 -0
- package/package.json +11 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prism-header.component.d.ts","sourceRoot":"","sources":["../../../src/app/header/prism-header.component.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;;AAGvE,
|
|
1
|
+
{"version":3,"file":"prism-header.component.d.ts","sourceRoot":"","sources":["../../../src/app/header/prism-header.component.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;;AAGvE,qBA2Na,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8B;IAC5D,SAAS,CAAC,QAAQ,CAAC,aAAa,qBAA8B;IAC9D,SAAS,CAAC,QAAQ,CAAC,YAAY,oBAA6B;IAE5D,SAAS,CAAC,QAAQ,CAAC,YAAY,kGAK7B;IAEF,SAAS,CAAC,QAAQ,CAAC,UAAU,kGAK3B;IAEF,SAAS,CAAC,QAAQ,CAAC,OAAO,gDAKvB;IAEH,SAAS,CAAC,QAAQ,CAAC,KAAK,yCAAmD;IAC3E,SAAS,CAAC,QAAQ,CAAC,QAAQ,gDAAgD;IAE3E,SAAS,CAAC,QAAQ,CAAC,cAAc,gDAO9B;IAGH,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI;IAO7C,SAAS,CAAC,aAAa,IAAI,IAAI;yCA/CpB,oBAAoB;2CAApB,oBAAoB;CAkDhC"}
|
|
@@ -190,8 +190,7 @@ export class PrismHeaderComponent {
|
|
|
190
190
|
<div class="prism-header__actions">
|
|
191
191
|
@for (w of widgetsEnd(); track w.id) {
|
|
192
192
|
<prism-header-widget-host [widget]="w" />
|
|
193
|
-
}
|
|
194
|
-
@if (buildInfoLabel()) {
|
|
193
|
+
} @if (buildInfoLabel()) {
|
|
195
194
|
<span class="prism-header__build-pill">{{ buildInfoLabel() }}</span>
|
|
196
195
|
}
|
|
197
196
|
<button
|
|
@@ -223,4 +222,4 @@ export class PrismHeaderComponent {
|
|
|
223
222
|
type: HostListener,
|
|
224
223
|
args: ['document:keydown', ['$event']]
|
|
225
224
|
}] }); })();
|
|
226
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PrismHeaderComponent, { className: "PrismHeaderComponent", filePath: "app/header/prism-header.component.ts", lineNumber:
|
|
225
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PrismHeaderComponent, { className: "PrismHeaderComponent", filePath: "app/header/prism-header.component.ts", lineNumber: 237 }); })();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.types.d.ts","sourceRoot":"","sources":["../../../../src/app/panels/a11y/a11y.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,+EAA+E;AAC/E,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,KAAK,EAAE,eAAe,GAAG;
|
|
1
|
+
{"version":3,"file":"a11y.types.d.ts","sourceRoot":"","sources":["../../../../src/app/panels/a11y/a11y.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,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O,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACzC,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provide-prism.d.ts","sourceRoot":"","sources":["../../src/app/provide-prism.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provide-prism.d.ts","sourceRoot":"","sources":["../../src/app/provide-prism.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAStE,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACzC;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,MAAM,CAAC,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,oBAAoB,CAuCtB"}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { makeEnvironmentProviders } from '@angular/core';
|
|
1
|
+
import { makeEnvironmentProviders, } from '@angular/core';
|
|
2
2
|
import { provideHighlightOptions } from 'ngx-highlightjs';
|
|
3
3
|
import { componentPage } from '../plugin/page-helpers.js';
|
|
4
4
|
import { BUILTIN_PANELS } from './panels/builtin-panels.js';
|
|
5
5
|
import { PRISM_BUILTIN_PANELS, PRISM_CONFIG, PRISM_MANIFEST, } from './tokens/prism-tokens.js';
|
|
6
6
|
export function providePrism(manifest, config, options) {
|
|
7
7
|
const mergedManifest = options?.componentPages?.length
|
|
8
|
-
? {
|
|
8
|
+
? {
|
|
9
|
+
...manifest,
|
|
10
|
+
pages: [
|
|
11
|
+
...(manifest.pages ?? []),
|
|
12
|
+
...options.componentPages.map((o) => componentPage(o)),
|
|
13
|
+
],
|
|
14
|
+
}
|
|
9
15
|
: manifest;
|
|
10
|
-
//
|
|
16
|
+
// Exposes a thin discovery view of the manifest to external audit tooling.
|
|
11
17
|
// We intentionally only expose className + variant info — no Angular type references.
|
|
12
18
|
if (typeof globalThis !== 'undefined') {
|
|
13
19
|
globalThis['__PRISM_MANIFEST__'] = {
|
|
14
20
|
components: mergedManifest.components.map((c) => ({
|
|
15
21
|
className: c.meta.className,
|
|
16
|
-
variants: c.meta.showcaseConfig.variants?.map((v, i) => ({
|
|
22
|
+
variants: c.meta.showcaseConfig.variants?.map((v, i) => ({
|
|
23
|
+
name: v.name,
|
|
24
|
+
index: i,
|
|
25
|
+
})) ?? [{ name: 'Default', index: 0 }],
|
|
17
26
|
})),
|
|
18
27
|
pages: (mergedManifest.pages ?? []).map((p) => ({ title: p.title })),
|
|
19
28
|
};
|
|
@@ -1 +1 @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CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;IACjE,QAAQ,CAAC,aAAa,+DAAsC;IAC5D,wFAAwF;IACxF,SAAS,CAAC,QAAQ,CAAC,WAAW,gDAQ3B;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa;;MAA6C;IAC7E,SAAS,CAAC,QAAQ,CAAC,eAAe,yFAG/B;;IA0FH,OAAO,CAAC,eAAe;IA6FvB,OAAO,CAAC,OAAO;yCAlOJ,sBAAsB;2CAAtB,sBAAsB;CAgPlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prism-navigation.service.d.ts","sourceRoot":"","sources":["../../../src/app/services/prism-navigation.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;;AAIjE,qBACa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8B;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;IAEhE,QAAQ,CAAC,UAAU,gEAAuC;IAE1D,QAAQ,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"prism-navigation.service.d.ts","sourceRoot":"","sources":["../../../src/app/services/prism-navigation.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;;AAIjE,qBACa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8B;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;IAEhE,QAAQ,CAAC,UAAU,gEAAuC;IAE1D,QAAQ,CAAC,eAAe,0DAQrB;IAEH,QAAQ,CAAC,UAAU,wDAQhB;IAEH,QAAQ,CAAC,YAAY,gEA0DlB;IAEH,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAIpC,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAItC,WAAW,IAAI,IAAI;yCA9FR,sBAAsB;6CAAtB,sBAAsB;CA2GlC"}
|
|
@@ -39,26 +39,30 @@ export class PrismNavigationService {
|
|
|
39
39
|
for (const items of map.values()) {
|
|
40
40
|
items.sort((a, b) => {
|
|
41
41
|
const orderA = a.kind === 'component'
|
|
42
|
-
?
|
|
43
|
-
:
|
|
42
|
+
? a.data.meta.showcaseConfig.componentOrder ?? Infinity
|
|
43
|
+
: a.data.order ?? Infinity;
|
|
44
44
|
const orderB = b.kind === 'component'
|
|
45
|
-
?
|
|
46
|
-
:
|
|
45
|
+
? b.data.meta.showcaseConfig.componentOrder ?? Infinity
|
|
46
|
+
: b.data.order ?? Infinity;
|
|
47
47
|
if (orderA !== orderB)
|
|
48
48
|
return orderA - orderB;
|
|
49
|
-
const labelA = a.kind === 'component'
|
|
50
|
-
|
|
49
|
+
const labelA = a.kind === 'component'
|
|
50
|
+
? a.data.meta.showcaseConfig.title
|
|
51
|
+
: a.data.title;
|
|
52
|
+
const labelB = b.kind === 'component'
|
|
53
|
+
? b.data.meta.showcaseConfig.title
|
|
54
|
+
: b.data.title;
|
|
51
55
|
return labelA.localeCompare(labelB);
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
58
|
const sorted = [...map.entries()].sort(([catA, itemsA], [catB, itemsB]) => {
|
|
55
59
|
const catOrders = itemsA.map((i) => i.kind === 'component'
|
|
56
|
-
?
|
|
57
|
-
:
|
|
60
|
+
? i.data.meta.showcaseConfig.categoryOrder ?? Infinity
|
|
61
|
+
: i.data.categoryOrder ?? Infinity);
|
|
58
62
|
const orderA = Math.min(...catOrders);
|
|
59
63
|
const catOrdersB = itemsB.map((i) => i.kind === 'component'
|
|
60
|
-
?
|
|
61
|
-
:
|
|
64
|
+
? i.data.meta.showcaseConfig.categoryOrder ?? Infinity
|
|
65
|
+
: i.data.categoryOrder ?? Infinity);
|
|
62
66
|
const orderB = Math.min(...catOrdersB);
|
|
63
67
|
if (orderA !== orderB)
|
|
64
68
|
return orderA - orderB;
|
|
@@ -73,16 +77,16 @@ export class PrismNavigationService {
|
|
|
73
77
|
this.activeItem.set({ kind: 'page', data: page });
|
|
74
78
|
}
|
|
75
79
|
selectFirst() {
|
|
76
|
-
const comps = this.searchService.filteredComponents();
|
|
77
|
-
if (comps.length > 0) {
|
|
78
|
-
this.activeItem.set({ kind: 'component', data: comps[0] });
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
80
|
const pages = this.searchService.filteredPages();
|
|
82
81
|
if (pages.length > 0) {
|
|
83
82
|
this.activeItem.set({ kind: 'page', data: pages[0] });
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
85
|
+
const comps = this.searchService.filteredComponents();
|
|
86
|
+
if (comps.length > 0) {
|
|
87
|
+
this.activeItem.set({ kind: 'component', data: comps[0] });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
86
90
|
this.activeItem.set(null);
|
|
87
91
|
}
|
|
88
92
|
static ɵfac = function PrismNavigationService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PrismNavigationService)(); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y-report-reader.d.ts","sourceRoot":"","sources":["../../../src/builder/a11y/a11y-report-reader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACf,MAAM,qCAAqC,CAAC;AAG7C,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAI3D,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAapE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACxC,gBAAgB,GAAG,IAAI,CAQzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,GACrB,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"a11y-report-reader.d.ts","sourceRoot":"","sources":["../../../src/builder/a11y/a11y-report-reader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACf,MAAM,qCAAqC,CAAC;AAG7C,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAI3D,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAapE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACxC,gBAAgB,GAAG,IAAI,CAQzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,GACrB,kBAAkB,EAAE,CAkCtB;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -31,16 +31,32 @@ export function checkA11yThresholds(meta) {
|
|
|
31
31
|
const t = meta.thresholds;
|
|
32
32
|
const total = meta.total;
|
|
33
33
|
if (total.score < t.score) {
|
|
34
|
-
violations.push({
|
|
34
|
+
violations.push({
|
|
35
|
+
metric: 'score',
|
|
36
|
+
actual: total.score,
|
|
37
|
+
threshold: t.score,
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
if (total.critical > t.critical) {
|
|
37
|
-
violations.push({
|
|
41
|
+
violations.push({
|
|
42
|
+
metric: 'critical',
|
|
43
|
+
actual: total.critical,
|
|
44
|
+
threshold: t.critical,
|
|
45
|
+
});
|
|
38
46
|
}
|
|
39
47
|
if (total.serious > t.serious) {
|
|
40
|
-
violations.push({
|
|
48
|
+
violations.push({
|
|
49
|
+
metric: 'serious',
|
|
50
|
+
actual: total.serious,
|
|
51
|
+
threshold: t.serious,
|
|
52
|
+
});
|
|
41
53
|
}
|
|
42
54
|
if (total.moderate > t.moderate) {
|
|
43
|
-
violations.push({
|
|
55
|
+
violations.push({
|
|
56
|
+
metric: 'moderate',
|
|
57
|
+
actual: total.moderate,
|
|
58
|
+
threshold: t.moderate,
|
|
59
|
+
});
|
|
44
60
|
}
|
|
45
61
|
return violations;
|
|
46
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-manifest.generator.d.ts","sourceRoot":"","sources":["../../../src/builder/manifest/runtime-manifest.generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,8BAA8B,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"runtime-manifest.generator.d.ts","sourceRoot":"","sources":["../../../src/builder/manifest/runtime-manifest.generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,8BAA8B,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAiID,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAmFR"}
|
|
@@ -20,7 +20,9 @@ function formatInputDeclaration(input) {
|
|
|
20
20
|
const typeAnnotation = inputTypeAnnotation(input);
|
|
21
21
|
return `input.required<${typeAnnotation}>()`;
|
|
22
22
|
}
|
|
23
|
-
const def = input.defaultValue !== undefined
|
|
23
|
+
const def = input.defaultValue !== undefined
|
|
24
|
+
? JSON.stringify(input.defaultValue)
|
|
25
|
+
: "''";
|
|
24
26
|
const needsAnnotation = input.type === 'union' && input.values;
|
|
25
27
|
if (needsAnnotation) {
|
|
26
28
|
const typeAnnotation = inputTypeAnnotation(input);
|
|
@@ -33,7 +35,10 @@ function directiveSelector(selector) {
|
|
|
33
35
|
return match ? match[1] : selector;
|
|
34
36
|
}
|
|
35
37
|
function isBindableInput(input) {
|
|
36
|
-
if (input.type === 'string' ||
|
|
38
|
+
if (input.type === 'string' ||
|
|
39
|
+
input.type === 'number' ||
|
|
40
|
+
input.type === 'boolean' ||
|
|
41
|
+
input.type === 'union') {
|
|
37
42
|
return true;
|
|
38
43
|
}
|
|
39
44
|
return input.defaultValue !== undefined;
|
|
@@ -160,7 +165,10 @@ export function generateRuntimeManifest(options) {
|
|
|
160
165
|
}
|
|
161
166
|
lines.push(' ],');
|
|
162
167
|
if (pages && pages.length > 0) {
|
|
163
|
-
lines.push(` pages: ${JSON.stringify(pages, null, 2)
|
|
168
|
+
lines.push(` pages: ${JSON.stringify(pages, null, 2)
|
|
169
|
+
.split('\n')
|
|
170
|
+
.map((l, i) => (i === 0 ? l : ' ' + l))
|
|
171
|
+
.join('\n')},`);
|
|
164
172
|
}
|
|
165
173
|
if (meta && Object.keys(meta).length > 0) {
|
|
166
174
|
const metaJson = JSON.stringify(meta, null, 2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-runner.d.ts","sourceRoot":"","sources":["../../../src/builder/plugin-runner/plugin-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin-runner.d.ts","sourceRoot":"","sources":["../../../src/builder/plugin-runner/plugin-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EAEd,MAAM,8BAA8B,CAAC;AA0BtC,wBAAsB,cAAc,CAClC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,aAAa,EAAE,GACvB,OAAO,CAAC,aAAa,CAAC,CAmExB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { ShowcaseConfig, Variant, ComponentStatus, InputsOf } from './showcase.types.js';
|
|
1
|
+
export type { ShowcaseConfig, Variant, ComponentStatus, InputsOf, } from './showcase.types.js';
|
|
2
2
|
export { Showcase } from './showcase.decorator.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AACA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showcase.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"showcase.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,cAAc,CAEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showcase.types.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAOD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,
|
|
1
|
+
{"version":3,"file":"showcase.types.d.ts","sourceRoot":"","sources":["../../src/decorator/showcase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAEvE,MAAM,WA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AC,CAAC;IAC/B;;;;;OAKG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd,6HAA6H;IAC7H,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9B,mPAAmP;IACnP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,0IAA0I;IAC1I,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,qFAAqF;IACrF,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,4BAA4B,CAAC;AAOpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoYtD,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAWvD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chain, SchematicsException, } from '@angular-devkit/schematics';
|
|
2
|
+
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
2
3
|
import { parse as parseJsonc, modify as modifyJsonc, applyEdits as applyJsoncEdits, } from 'jsonc-parser';
|
|
3
4
|
function readWorkspace(tree) {
|
|
4
5
|
const buffer = tree.read('angular.json');
|
|
@@ -242,6 +243,34 @@ function addGitignoreEntry(options) {
|
|
|
242
243
|
return tree;
|
|
243
244
|
};
|
|
244
245
|
}
|
|
246
|
+
const RUNTIME_PEER_DEPS = {
|
|
247
|
+
'highlight.js': '^11.0.0',
|
|
248
|
+
'ngx-highlightjs': '^14.0.0',
|
|
249
|
+
};
|
|
250
|
+
function addRuntimePeerDeps() {
|
|
251
|
+
return (tree, context) => {
|
|
252
|
+
const pkgPath = 'package.json';
|
|
253
|
+
const buffer = tree.read(pkgPath);
|
|
254
|
+
if (!buffer)
|
|
255
|
+
return tree;
|
|
256
|
+
const pkg = JSON.parse(buffer.toString('utf-8'));
|
|
257
|
+
pkg.devDependencies ??= {};
|
|
258
|
+
let changed = false;
|
|
259
|
+
for (const [name, version] of Object.entries(RUNTIME_PEER_DEPS)) {
|
|
260
|
+
const alreadyPresent = pkg.devDependencies[name] || pkg.dependencies?.[name];
|
|
261
|
+
if (!alreadyPresent) {
|
|
262
|
+
pkg.devDependencies[name] = version;
|
|
263
|
+
changed = true;
|
|
264
|
+
context.logger.info(` Added ${name}@${version} to devDependencies`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (changed) {
|
|
268
|
+
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
269
|
+
context.addTask(new NodePackageInstallTask());
|
|
270
|
+
}
|
|
271
|
+
return tree;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
245
274
|
function logSetupSummary(options) {
|
|
246
275
|
return (_tree, context) => {
|
|
247
276
|
const prismProjectName = `${options.project}-prism`;
|
|
@@ -280,6 +309,7 @@ export function ngAdd(options) {
|
|
|
280
309
|
createConfigFile(),
|
|
281
310
|
addStripShowcaseScript(options),
|
|
282
311
|
addGitignoreEntry(options),
|
|
312
|
+
addRuntimePeerDeps(),
|
|
283
313
|
logSetupSummary(options),
|
|
284
314
|
]);
|
|
285
315
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Tree } from '@angular-devkit/schematics';
|
|
2
|
+
export interface AddPluginToConfigOptions {
|
|
3
|
+
/** Named import binding, e.g. 'jsDocPlugin' */
|
|
4
|
+
importName: string;
|
|
5
|
+
/** Module specifier, e.g. '@ng-prism/plugin-jsdoc' */
|
|
6
|
+
importFrom: string;
|
|
7
|
+
/** Factory call to insert into plugins array, e.g. 'jsDocPlugin()' */
|
|
8
|
+
call: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Adds a plugin import + factory call to the user's ng-prism.config.ts.
|
|
12
|
+
* Idempotent: skips if import or call is already present.
|
|
13
|
+
* Throws SchematicsException on unsupported config shapes.
|
|
14
|
+
* Returns true if the file was changed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addPluginToConfig(tree: Tree, configPath: string, options: AddPluginToConfigOptions): boolean;
|
|
17
|
+
//# sourceMappingURL=config-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-ast.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAG5E,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAoGT"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { SchematicsException } from '@angular-devkit/schematics';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
/**
|
|
4
|
+
* Adds a plugin import + factory call to the user's ng-prism.config.ts.
|
|
5
|
+
* Idempotent: skips if import or call is already present.
|
|
6
|
+
* Throws SchematicsException on unsupported config shapes.
|
|
7
|
+
* Returns true if the file was changed.
|
|
8
|
+
*/
|
|
9
|
+
export function addPluginToConfig(tree, configPath, options) {
|
|
10
|
+
const buffer = tree.read(configPath);
|
|
11
|
+
if (!buffer) {
|
|
12
|
+
throw new SchematicsException(`${configPath} not found. Run "ng add @ng-prism/core" first.`);
|
|
13
|
+
}
|
|
14
|
+
const source = buffer.toString('utf-8');
|
|
15
|
+
const sf = ts.createSourceFile(configPath, source, ts.ScriptTarget.Latest,
|
|
16
|
+
/* setParentNodes */ true);
|
|
17
|
+
const imports = sf.statements.filter(ts.isImportDeclaration);
|
|
18
|
+
const defineConfigCall = findDefineConfigCall(sf);
|
|
19
|
+
if (!defineConfigCall) {
|
|
20
|
+
throw new SchematicsException('Unsupported config: defineConfig() call not found at default export.');
|
|
21
|
+
}
|
|
22
|
+
const arg = defineConfigCall.arguments[0];
|
|
23
|
+
if (!arg || !ts.isObjectLiteralExpression(arg)) {
|
|
24
|
+
throw new SchematicsException('Unsupported config: defineConfig argument must be an object literal.');
|
|
25
|
+
}
|
|
26
|
+
const objectLiteral = arg;
|
|
27
|
+
const pluginsProp = findPluginsProperty(objectLiteral);
|
|
28
|
+
if (pluginsProp && !ts.isArrayLiteralExpression(pluginsProp.initializer)) {
|
|
29
|
+
throw new SchematicsException('Unsupported config: plugins must be an array literal.');
|
|
30
|
+
}
|
|
31
|
+
const importAlreadyPresent = imports.some((imp) => importHasNamedBinding(imp, options.importFrom, options.importName));
|
|
32
|
+
const callAlreadyPresent = !!pluginsProp &&
|
|
33
|
+
pluginsProp.initializer.elements.some((el) => ts.isCallExpression(el) &&
|
|
34
|
+
ts.isIdentifier(el.expression) &&
|
|
35
|
+
el.expression.text === options.importName);
|
|
36
|
+
if (importAlreadyPresent && callAlreadyPresent)
|
|
37
|
+
return false;
|
|
38
|
+
const edits = [];
|
|
39
|
+
if (!importAlreadyPresent) {
|
|
40
|
+
const insertPos = imports.length > 0 ? imports[imports.length - 1].end : 0;
|
|
41
|
+
edits.push({
|
|
42
|
+
start: insertPos,
|
|
43
|
+
end: insertPos,
|
|
44
|
+
newText: `\nimport { ${options.importName} } from '${options.importFrom}';`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!callAlreadyPresent) {
|
|
48
|
+
if (!pluginsProp) {
|
|
49
|
+
const insertPos = objectLiteral.getStart(sf) + 1;
|
|
50
|
+
edits.push({
|
|
51
|
+
start: insertPos,
|
|
52
|
+
end: insertPos,
|
|
53
|
+
newText: `\n plugins: [${options.call}],`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const arr = pluginsProp.initializer;
|
|
58
|
+
if (arr.elements.length === 0) {
|
|
59
|
+
edits.push({
|
|
60
|
+
start: arr.getStart(sf),
|
|
61
|
+
end: arr.getEnd(),
|
|
62
|
+
newText: `[${options.call}]`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const lastElement = arr.elements[arr.elements.length - 1];
|
|
67
|
+
const insertPos = lastElement.end;
|
|
68
|
+
edits.push({
|
|
69
|
+
start: insertPos,
|
|
70
|
+
end: insertPos,
|
|
71
|
+
newText: `, ${options.call}`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
edits.sort((a, b) => b.start - a.start);
|
|
77
|
+
let result = source;
|
|
78
|
+
for (const e of edits) {
|
|
79
|
+
result = result.slice(0, e.start) + e.newText + result.slice(e.end);
|
|
80
|
+
}
|
|
81
|
+
tree.overwrite(configPath, result);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function findDefineConfigCall(sf) {
|
|
85
|
+
for (const stmt of sf.statements) {
|
|
86
|
+
if (!ts.isExportAssignment(stmt) || stmt.isExportEquals)
|
|
87
|
+
continue;
|
|
88
|
+
const expr = stmt.expression;
|
|
89
|
+
if (ts.isCallExpression(expr) &&
|
|
90
|
+
ts.isIdentifier(expr.expression) &&
|
|
91
|
+
expr.expression.text === 'defineConfig') {
|
|
92
|
+
return expr;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function findPluginsProperty(obj) {
|
|
98
|
+
for (const prop of obj.properties) {
|
|
99
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
100
|
+
ts.isIdentifier(prop.name) &&
|
|
101
|
+
prop.name.text === 'plugins') {
|
|
102
|
+
return prop;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function importHasNamedBinding(imp, moduleSpecifier, binding) {
|
|
108
|
+
if (!ts.isStringLiteral(imp.moduleSpecifier))
|
|
109
|
+
return false;
|
|
110
|
+
if (imp.moduleSpecifier.text !== moduleSpecifier)
|
|
111
|
+
return false;
|
|
112
|
+
const clause = imp.importClause;
|
|
113
|
+
if (!clause?.namedBindings)
|
|
114
|
+
return false;
|
|
115
|
+
if (!ts.isNamedImports(clause.namedBindings))
|
|
116
|
+
return false;
|
|
117
|
+
return clause.namedBindings.elements.some((el) => el.name.text === binding);
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config-ast.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-prism/core",
|
|
3
|
-
"version": "21.12.0
|
|
3
|
+
"version": "21.12.0",
|
|
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",
|
|
@@ -47,11 +47,18 @@
|
|
|
47
47
|
"types": "./dist/transformer/index.d.ts",
|
|
48
48
|
"import": "./dist/transformer/index.js",
|
|
49
49
|
"default": "./dist/transformer/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./schematics/utils": {
|
|
52
|
+
"types": "./dist/schematics/utils/index.d.ts",
|
|
53
|
+
"import": "./dist/schematics/utils/index.js",
|
|
54
|
+
"default": "./dist/schematics/utils/index.js"
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
"bin": {
|
|
53
|
-
"ng-prism-strip": "./dist/transformer/cli.js"
|
|
54
|
-
|
|
58
|
+
"ng-prism-strip": "./dist/transformer/cli.js"
|
|
59
|
+
},
|
|
60
|
+
"ng-add": {
|
|
61
|
+
"save": "devDependencies"
|
|
55
62
|
},
|
|
56
63
|
"schematics": "./schematics/collection.json",
|
|
57
64
|
"builders": "./builders.json",
|
|
@@ -71,9 +78,7 @@
|
|
|
71
78
|
"@angular-devkit/schematics": ">=21.0.0",
|
|
72
79
|
"typescript": ">=5.5.0",
|
|
73
80
|
"highlight.js": ">=11.0.0",
|
|
74
|
-
"ngx-highlightjs": ">=14.0.0"
|
|
75
|
-
"playwright": ">=1.40.0",
|
|
76
|
-
"axe-core": ">=4.0.0"
|
|
81
|
+
"ngx-highlightjs": ">=14.0.0"
|
|
77
82
|
},
|
|
78
83
|
"peerDependenciesMeta": {
|
|
79
84
|
"@angular-devkit/architect": {
|
|
@@ -81,12 +86,6 @@
|
|
|
81
86
|
},
|
|
82
87
|
"@angular-devkit/schematics": {
|
|
83
88
|
"optional": false
|
|
84
|
-
},
|
|
85
|
-
"playwright": {
|
|
86
|
-
"optional": true
|
|
87
|
-
},
|
|
88
|
-
"axe-core": {
|
|
89
|
-
"optional": true
|
|
90
89
|
}
|
|
91
90
|
},
|
|
92
91
|
"dependencies": {
|