@cratis/scene.engine 4.12.0 → 4.14.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/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/NavigationDiagnosticCode.js +19 -0
- package/dist/cjs/navigation/NavigationDiagnosticCode.js.map +1 -0
- package/dist/cjs/navigation/collectOutlets.js +45 -0
- package/dist/cjs/navigation/collectOutlets.js.map +1 -0
- package/dist/cjs/navigation/diagnoseNavigation.js +116 -0
- package/dist/cjs/navigation/diagnoseNavigation.js.map +1 -0
- package/dist/cjs/navigation/findHostingCycles.js +43 -0
- package/dist/cjs/navigation/findHostingCycles.js.map +1 -0
- package/dist/cjs/navigation/navigationEntriesFrom.js +19 -0
- package/dist/cjs/navigation/navigationEntriesFrom.js.map +1 -0
- package/dist/cjs/navigation/navigationRoute.js +25 -0
- package/dist/cjs/navigation/navigationRoute.js.map +1 -0
- package/dist/cjs/packageVersionRange.js +16 -0
- package/dist/cjs/packageVersionRange.js.map +1 -1
- package/dist/cjs/templates/TemplateCatalogKind.js +15 -0
- package/dist/cjs/templates/TemplateCatalogKind.js.map +1 -0
- package/dist/cjs/templates/describeTemplateCatalog.js +89 -0
- package/dist/cjs/templates/describeTemplateCatalog.js.map +1 -0
- package/dist/cjs/templates/templateMetadataRules.js +32 -0
- package/dist/cjs/templates/templateMetadataRules.js.map +1 -0
- package/dist/cjs/templates/validateTemplateMetadata.js +50 -0
- package/dist/cjs/templates/validateTemplateMetadata.js.map +1 -0
- package/dist/cjs/validateNavigationDestinations.js +12 -38
- package/dist/cjs/validateNavigationDestinations.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/NavigationDiagnostic.d.ts +7 -0
- package/dist/esm/navigation/NavigationDiagnostic.d.ts.map +1 -0
- package/dist/esm/navigation/NavigationDiagnostic.js +2 -0
- package/dist/esm/navigation/NavigationDiagnostic.js.map +1 -0
- package/dist/esm/navigation/NavigationDiagnosticCode.d.ts +9 -0
- package/dist/esm/navigation/NavigationDiagnosticCode.d.ts.map +1 -0
- package/dist/esm/navigation/NavigationDiagnosticCode.js +17 -0
- package/dist/esm/navigation/NavigationDiagnosticCode.js.map +1 -0
- package/dist/esm/navigation/NavigationEntry.d.ts +6 -0
- package/dist/esm/navigation/NavigationEntry.d.ts.map +1 -0
- package/dist/esm/navigation/NavigationEntry.js +2 -0
- package/dist/esm/navigation/NavigationEntry.js.map +1 -0
- package/dist/esm/navigation/NavigationGraph.d.ts +10 -0
- package/dist/esm/navigation/NavigationGraph.d.ts.map +1 -0
- package/dist/esm/navigation/NavigationGraph.js +2 -0
- package/dist/esm/navigation/NavigationGraph.js.map +1 -0
- package/dist/esm/navigation/OutletOwner.d.ts +7 -0
- package/dist/esm/navigation/OutletOwner.d.ts.map +1 -0
- package/dist/esm/navigation/OutletOwner.js +2 -0
- package/dist/esm/navigation/OutletOwner.js.map +1 -0
- package/dist/esm/navigation/collectOutlets.d.ts +5 -0
- package/dist/esm/navigation/collectOutlets.d.ts.map +1 -0
- package/dist/esm/navigation/collectOutlets.js +43 -0
- package/dist/esm/navigation/collectOutlets.js.map +1 -0
- package/dist/esm/navigation/diagnoseNavigation.d.ts +5 -0
- package/dist/esm/navigation/diagnoseNavigation.d.ts.map +1 -0
- package/dist/esm/navigation/diagnoseNavigation.js +114 -0
- package/dist/esm/navigation/diagnoseNavigation.js.map +1 -0
- package/dist/esm/navigation/findHostingCycles.d.ts +2 -0
- package/dist/esm/navigation/findHostingCycles.d.ts.map +1 -0
- package/dist/esm/navigation/findHostingCycles.js +41 -0
- package/dist/esm/navigation/findHostingCycles.js.map +1 -0
- package/dist/esm/navigation/index.d.ts +8 -0
- package/dist/esm/navigation/index.d.ts.map +1 -0
- package/dist/esm/navigation/index.js +8 -0
- package/dist/esm/navigation/index.js.map +1 -0
- package/dist/esm/navigation/navigationEntriesFrom.d.ts +4 -0
- package/dist/esm/navigation/navigationEntriesFrom.d.ts.map +1 -0
- package/dist/esm/navigation/navigationEntriesFrom.js +17 -0
- package/dist/esm/navigation/navigationEntriesFrom.js.map +1 -0
- package/dist/esm/navigation/navigationRoute.d.ts +5 -0
- package/dist/esm/navigation/navigationRoute.d.ts.map +1 -0
- package/dist/esm/navigation/navigationRoute.js +22 -0
- package/dist/esm/navigation/navigationRoute.js.map +1 -0
- package/dist/esm/packageVersionRange.d.ts +2 -0
- package/dist/esm/packageVersionRange.d.ts.map +1 -1
- package/dist/esm/packageVersionRange.js +15 -1
- package/dist/esm/packageVersionRange.js.map +1 -1
- package/dist/esm/templates/TemplateCatalogEntry.d.ts +20 -0
- package/dist/esm/templates/TemplateCatalogEntry.d.ts.map +1 -0
- package/dist/esm/templates/TemplateCatalogEntry.js +2 -0
- package/dist/esm/templates/TemplateCatalogEntry.js.map +1 -0
- package/dist/esm/templates/TemplateCatalogKind.d.ts +6 -0
- package/dist/esm/templates/TemplateCatalogKind.d.ts.map +1 -0
- package/dist/esm/templates/TemplateCatalogKind.js +13 -0
- package/dist/esm/templates/TemplateCatalogKind.js.map +1 -0
- package/dist/esm/templates/TemplateSource.d.ts +8 -0
- package/dist/esm/templates/TemplateSource.d.ts.map +1 -0
- package/dist/esm/templates/TemplateSource.js +2 -0
- package/dist/esm/templates/TemplateSource.js.map +1 -0
- package/dist/esm/templates/describeTemplateCatalog.d.ts +4 -0
- package/dist/esm/templates/describeTemplateCatalog.d.ts.map +1 -0
- package/dist/esm/templates/describeTemplateCatalog.js +87 -0
- package/dist/esm/templates/describeTemplateCatalog.js.map +1 -0
- package/dist/esm/templates/index.d.ts +7 -0
- package/dist/esm/templates/index.d.ts.map +1 -0
- package/dist/esm/templates/index.js +7 -0
- package/dist/esm/templates/index.js.map +1 -0
- package/dist/esm/templates/templateMetadataRules.d.ts +3 -0
- package/dist/esm/templates/templateMetadataRules.d.ts.map +1 -0
- package/dist/esm/templates/templateMetadataRules.js +29 -0
- package/dist/esm/templates/templateMetadataRules.js.map +1 -0
- package/dist/esm/templates/validateTemplateMetadata.d.ts +3 -0
- package/dist/esm/templates/validateTemplateMetadata.d.ts.map +1 -0
- package/dist/esm/templates/validateTemplateMetadata.js +48 -0
- package/dist/esm/templates/validateTemplateMetadata.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validateNavigationDestinations.d.ts +5 -5
- package/dist/esm/validateNavigationDestinations.d.ts.map +1 -1
- package/dist/esm/validateNavigationDestinations.js +12 -38
- package/dist/esm/validateNavigationDestinations.js.map +1 -1
- package/index.ts +2 -0
- package/navigation/NavigationDiagnostic.ts +18 -0
- package/navigation/NavigationDiagnosticCode.ts +26 -0
- package/navigation/NavigationEntry.ts +16 -0
- package/navigation/NavigationGraph.ts +26 -0
- package/navigation/OutletOwner.ts +13 -0
- package/navigation/collectOutlets.ts +36 -0
- package/navigation/diagnoseNavigation.ts +136 -0
- package/navigation/findHostingCycles.ts +41 -0
- package/navigation/index.ts +10 -0
- package/navigation/navigationEntriesFrom.ts +16 -0
- package/navigation/navigationRoute.ts +25 -0
- package/package.json +3 -3
- package/packageVersionRange.ts +18 -0
- package/templates/TemplateCatalogEntry.ts +35 -0
- package/templates/TemplateCatalogKind.ts +11 -0
- package/templates/TemplateSource.ts +15 -0
- package/templates/describeTemplateCatalog.ts +92 -0
- package/templates/index.ts +9 -0
- package/templates/templateMetadataRules.ts +25 -0
- package/templates/validateTemplateMetadata.ts +55 -0
- package/validateNavigationDestinations.ts +12 -32
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Finds cycles in a "renders inside" graph, where an edge from a screen to another means the first is
|
|
5
|
+
* placed in an outlet the second one's template owns. Screens are visited in the given order and edges in
|
|
6
|
+
* insertion order, so the same graph always yields the same cycles in the same order. Each set of screens
|
|
7
|
+
* is reported once, starting from the screen the walk reached it through.
|
|
8
|
+
*/ function findHostingCycles(screens, edges) {
|
|
9
|
+
const state = new Map();
|
|
10
|
+
const stack = [];
|
|
11
|
+
const reported = new Set();
|
|
12
|
+
const cycles = [];
|
|
13
|
+
const visit = (screen)=>{
|
|
14
|
+
state.set(screen, 'visiting');
|
|
15
|
+
stack.push(screen);
|
|
16
|
+
for (const host of edges.get(screen) ?? []){
|
|
17
|
+
const hostState = state.get(host);
|
|
18
|
+
if (hostState === 'visiting') {
|
|
19
|
+
const cycle = stack.slice(stack.indexOf(host));
|
|
20
|
+
const key = [
|
|
21
|
+
...cycle
|
|
22
|
+
].sort().join('\u0000');
|
|
23
|
+
if (!reported.has(key)) {
|
|
24
|
+
reported.add(key);
|
|
25
|
+
cycles.push(cycle);
|
|
26
|
+
}
|
|
27
|
+
} else if (hostState === undefined) {
|
|
28
|
+
visit(host);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
stack.pop();
|
|
32
|
+
state.set(screen, 'done');
|
|
33
|
+
};
|
|
34
|
+
for (const screen of screens){
|
|
35
|
+
if (!state.has(screen)) visit(screen);
|
|
36
|
+
}
|
|
37
|
+
return cycles;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { findHostingCycles };
|
|
41
|
+
//# sourceMappingURL=findHostingCycles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findHostingCycles.js","sources":["../../../navigation/findHostingCycles.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Finds cycles in a \"renders inside\" graph, where an edge from a screen to another means the first is\n * placed in an outlet the second one's template owns. Screens are visited in the given order and edges in\n * insertion order, so the same graph always yields the same cycles in the same order. Each set of screens\n * is reported once, starting from the screen the walk reached it through.\n */\nexport function findHostingCycles(screens: string[], edges: Map<string, string[]>): string[][] {\n const state = new Map<string, 'visiting' | 'done'>();\n const stack: string[] = [];\n const reported = new Set<string>();\n const cycles: string[][] = [];\n\n const visit = (screen: string) => {\n state.set(screen, 'visiting');\n stack.push(screen);\n for (const host of edges.get(screen) ?? []) {\n const hostState = state.get(host);\n if (hostState === 'visiting') {\n const cycle = stack.slice(stack.indexOf(host));\n const key = [...cycle].sort().join('\\u0000');\n if (!reported.has(key)) {\n reported.add(key);\n cycles.push(cycle);\n }\n } else if (hostState === undefined) {\n visit(host);\n }\n }\n stack.pop();\n state.set(screen, 'done');\n };\n\n for (const screen of screens) {\n if (!state.has(screen)) visit(screen);\n }\n\n return cycles;\n}\n"],"names":["findHostingCycles","screens","edges","state","Map","stack","reported","Set","cycles","visit","screen","set","push","host","get","hostState","cycle","slice","indexOf","key","sort","join","has","add","undefined","pop"],"mappings":"AAAA;AACA;AAEA;;;;;AAKC,IACM,SAASA,iBAAAA,CAAkBC,OAAiB,EAAEC,KAA4B,EAAA;AAC7E,IAAA,MAAMC,QAAQ,IAAIC,GAAAA,EAAAA;AAClB,IAAA,MAAMC,QAAkB,EAAE;AAC1B,IAAA,MAAMC,WAAW,IAAIC,GAAAA,EAAAA;AACrB,IAAA,MAAMC,SAAqB,EAAE;AAE7B,IAAA,MAAMC,QAAQ,CAACC,MAAAA,GAAAA;QACXP,KAAAA,CAAMQ,GAAG,CAACD,MAAAA,EAAQ,UAAA,CAAA;AAClBL,QAAAA,KAAAA,CAAMO,IAAI,CAACF,MAAAA,CAAAA;AACX,QAAA,KAAK,MAAMG,IAAAA,IAAQX,KAAAA,CAAMY,GAAG,CAACJ,MAAAA,CAAAA,IAAW,EAAE,CAAE;YACxC,MAAMK,SAAAA,GAAYZ,KAAAA,CAAMW,GAAG,CAACD,IAAAA,CAAAA;AAC5B,YAAA,IAAIE,cAAc,UAAA,EAAY;AAC1B,gBAAA,MAAMC,QAAQX,KAAAA,CAAMY,KAAK,CAACZ,KAAAA,CAAMa,OAAO,CAACL,IAAAA,CAAAA,CAAAA;AACxC,gBAAA,MAAMM,GAAAA,GAAM;AAAIH,oBAAAA,GAAAA;iBAAM,CAACI,IAAI,EAAA,CAAGC,IAAI,CAAC,QAAA,CAAA;AACnC,gBAAA,IAAI,CAACf,QAAAA,CAASgB,GAAG,CAACH,GAAAA,CAAAA,EAAM;AACpBb,oBAAAA,QAAAA,CAASiB,GAAG,CAACJ,GAAAA,CAAAA;AACbX,oBAAAA,MAAAA,CAAOI,IAAI,CAACI,KAAAA,CAAAA;AAChB,gBAAA;YACJ,CAAA,MAAO,IAAID,cAAcS,SAAAA,EAAW;gBAChCf,KAAAA,CAAMI,IAAAA,CAAAA;AACV,YAAA;AACJ,QAAA;AACAR,QAAAA,KAAAA,CAAMoB,GAAG,EAAA;QACTtB,KAAAA,CAAMQ,GAAG,CAACD,MAAAA,EAAQ,MAAA,CAAA;AACtB,IAAA,CAAA;IAEA,KAAK,MAAMA,UAAUT,OAAAA,CAAS;AAC1B,QAAA,IAAI,CAACE,KAAAA,CAAMmB,GAAG,CAACZ,SAASD,KAAAA,CAAMC,MAAAA,CAAAA;AAClC,IAAA;IAEA,OAAOF,MAAAA;AACX;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './NavigationDiagnostic';
|
|
2
|
+
export * from './NavigationDiagnosticCode';
|
|
3
|
+
export * from './NavigationEntry';
|
|
4
|
+
export * from './NavigationGraph';
|
|
5
|
+
export * from './diagnoseNavigation';
|
|
6
|
+
export * from './navigationEntriesFrom';
|
|
7
|
+
export * from './navigationRoute';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './NavigationDiagnostic';
|
|
2
|
+
export * from './NavigationDiagnosticCode';
|
|
3
|
+
export * from './NavigationEntry';
|
|
4
|
+
export * from './NavigationGraph';
|
|
5
|
+
export * from './diagnoseNavigation';
|
|
6
|
+
export * from './navigationEntriesFrom';
|
|
7
|
+
export * from './navigationRoute';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationEntriesFrom.d.ts","sourceRoot":"","sources":["../../../navigation/navigationEntriesFrom.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,eAAe,EAAE,CAKhF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Turns navigation contributions into entries for {@link diagnoseNavigation}. A legacy item carrying only
|
|
5
|
+
* `targetScreen` becomes a destination for that screen, so old and new content are checked the same way.
|
|
6
|
+
*/ function navigationEntriesFrom(items) {
|
|
7
|
+
return items.map((item)=>({
|
|
8
|
+
id: item.id,
|
|
9
|
+
destination: item.destination ?? {
|
|
10
|
+
screen: item.targetScreen,
|
|
11
|
+
routeParameterBindings: item.routeParameterBindings
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { navigationEntriesFrom };
|
|
17
|
+
//# sourceMappingURL=navigationEntriesFrom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationEntriesFrom.js","sources":["../../../navigation/navigationEntriesFrom.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { NavigationItem } from '@cratis/scene.model';\nimport { NavigationEntry } from './NavigationEntry';\n\n/**\n * Turns navigation contributions into entries for {@link diagnoseNavigation}. A legacy item carrying only\n * `targetScreen` becomes a destination for that screen, so old and new content are checked the same way.\n */\nexport function navigationEntriesFrom(items: NavigationItem[]): NavigationEntry[] {\n return items.map(item => ({\n id: item.id,\n destination: item.destination ?? { screen: item.targetScreen, routeParameterBindings: item.routeParameterBindings },\n }));\n}\n"],"names":["navigationEntriesFrom","items","map","item","id","destination","screen","targetScreen","routeParameterBindings"],"mappings":"AAAA;AACA;AAKA;;;IAIO,SAASA,qBAAAA,CAAsBC,KAAuB,EAAA;AACzD,IAAA,OAAOA,KAAAA,CAAMC,GAAG,CAACC,CAAAA,QAAS;AACtBC,YAAAA,EAAAA,EAAID,KAAKC,EAAE;YACXC,WAAAA,EAAaF,IAAAA,CAAKE,WAAW,IAAI;AAAEC,gBAAAA,MAAAA,EAAQH,KAAKI,YAAY;AAAEC,gBAAAA,sBAAAA,EAAwBL,KAAKK;AAAuB;SACtH,CAAA,CAAA;AACJ;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DestinationReference } from '@cratis/scene.model';
|
|
2
|
+
export type NavigationRouteKey = (destination: DestinationReference) => string | undefined;
|
|
3
|
+
export declare const authoredRouteKey: NavigationRouteKey;
|
|
4
|
+
export declare function navigationTarget(destination: DestinationReference, kind: string): string;
|
|
5
|
+
//# sourceMappingURL=navigationRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationRoute.d.ts","sourceRoot":"","sources":["../../../navigation/navigationRoute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAC;AAG3F,eAAO,MAAM,gBAAgB,EAAE,kBAA0E,CAAC;AAM1G,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGxF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** The default route key: the authored route override, trimmed, or none. */ const authoredRouteKey = (destination)=>destination.route?.trim() || undefined;
|
|
4
|
+
/**
|
|
5
|
+
* What a destination opens, so two destinations sharing a route are only a conflict when they open
|
|
6
|
+
* different things.
|
|
7
|
+
*/ function navigationTarget(destination, kind) {
|
|
8
|
+
const identity = destination.screen ?? [
|
|
9
|
+
destination.module,
|
|
10
|
+
destination.feature,
|
|
11
|
+
destination.slice
|
|
12
|
+
].filter((part)=>part).join('.');
|
|
13
|
+
return [
|
|
14
|
+
kind,
|
|
15
|
+
identity,
|
|
16
|
+
destination.dialog ?? '',
|
|
17
|
+
destination.outlet ?? ''
|
|
18
|
+
].join('|');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { authoredRouteKey, navigationTarget };
|
|
22
|
+
//# sourceMappingURL=navigationRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationRoute.js","sources":["../../../navigation/navigationRoute.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DestinationReference } from '@cratis/scene.model';\n\n/**\n * Decides which route a destination occupies, so destinations occupying the same one can be compared.\n *\n * The engine constructs no URLs (ADR-004), so it only compares what was authored. A renderer that derives\n * routes from stable identities, or treats parameter spellings as equivalent, supplies its own key - the same\n * derivation it uses when it builds the URL - and gets duplicate routes diagnosed by that rule instead.\n */\nexport type NavigationRouteKey = (destination: DestinationReference) => string | undefined;\n\n/** The default route key: the authored route override, trimmed, or none. */\nexport const authoredRouteKey: NavigationRouteKey = destination => destination.route?.trim() || undefined;\n\n/**\n * What a destination opens, so two destinations sharing a route are only a conflict when they open\n * different things.\n */\nexport function navigationTarget(destination: DestinationReference, kind: string): string {\n const identity = destination.screen ?? [destination.module, destination.feature, destination.slice].filter(part => part).join('.');\n return [kind, identity, destination.dialog ?? '', destination.outlet ?? ''].join('|');\n}\n"],"names":["authoredRouteKey","destination","route","trim","undefined","navigationTarget","kind","identity","screen","module","feature","slice","filter","part","join","dialog","outlet"],"mappings":"AAAA;AACA;AAaA,6EACO,MAAMA,gBAAAA,GAAuCC,CAAAA,cAAeA,WAAAA,CAAYC,KAAK,EAAEC,IAAAA,EAAAA,IAAUC;AAEhG;;;AAGC,IACM,SAASC,gBAAAA,CAAiBJ,WAAiC,EAAEK,IAAY,EAAA;IAC5E,MAAMC,QAAAA,GAAWN,WAAAA,CAAYO,MAAM,IAAI;AAACP,QAAAA,WAAAA,CAAYQ,MAAM;AAAER,QAAAA,WAAAA,CAAYS,OAAO;AAAET,QAAAA,WAAAA,CAAYU;AAAM,KAAA,CAACC,MAAM,CAACC,CAAAA,IAAAA,GAAQA,IAAAA,CAAAA,CAAMC,IAAI,CAAC,GAAA,CAAA;IAC9H,OAAO;AAACR,QAAAA,IAAAA;AAAMC,QAAAA,QAAAA;AAAUN,QAAAA,WAAAA,CAAYc,MAAM,IAAI,EAAA;AAAId,QAAAA,WAAAA,CAAYe,MAAM,IAAI;AAAG,KAAA,CAACF,IAAI,CAAC,GAAA,CAAA;AACrF;;"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function isVersionSatisfiedBy(version: string, range: string | undefined): boolean;
|
|
2
|
+
export declare function isValidVersionRange(range: string | undefined): boolean;
|
|
3
|
+
export declare function isValidVersion(version: string | undefined): boolean;
|
|
2
4
|
//# sourceMappingURL=packageVersionRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersionRange.d.ts","sourceRoot":"","sources":["../../packageVersionRange.ts"],"names":[],"mappings":"AAeA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CA2BxF"}
|
|
1
|
+
{"version":3,"file":"packageVersionRange.d.ts","sourceRoot":"","sources":["../../packageVersionRange.ts"],"names":[],"mappings":"AAeA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CA2BxF;AAOD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAItE;AAKD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEnE"}
|
|
@@ -40,6 +40,20 @@
|
|
|
40
40
|
return compare(actual, required) === 0;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a range is one {@link isVersionSatisfiedBy} understands. An empty range or `*` is valid and means
|
|
45
|
+
* "any version"; anything the parser cannot read is invalid, so declarations can be rejected up front
|
|
46
|
+
* instead of surfacing later as a conflict nobody can satisfy.
|
|
47
|
+
*/ function isValidVersionRange(range) {
|
|
48
|
+
const trimmed = range?.trim();
|
|
49
|
+
if (!trimmed || trimmed === '*') return true;
|
|
50
|
+
return parseVersion(splitRange(trimmed)[1]) !== undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether a value is a `major.minor.patch` version, optionally with a pre-release or build suffix.
|
|
54
|
+
*/ function isValidVersion(version) {
|
|
55
|
+
return version !== undefined && version.trim().length > 0 && parseVersion(version) !== undefined;
|
|
56
|
+
}
|
|
43
57
|
function splitRange(range) {
|
|
44
58
|
for (const operator of [
|
|
45
59
|
'>=',
|
|
@@ -107,5 +121,5 @@ function parseVersion(value) {
|
|
|
107
121
|
return components;
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
export { isVersionSatisfiedBy };
|
|
124
|
+
export { isValidVersion, isValidVersionRange, isVersionSatisfiedBy };
|
|
111
125
|
//# sourceMappingURL=packageVersionRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersionRange.js","sources":["../../packageVersionRange.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Checks a {@link PackageDependency.versionRange} against a package's actual version. A deliberately\n * small subset of semver — enough to express what a package declaration realistically needs, and small\n * enough that the C# twin in `Cratis.Scene.Engine` can match it exactly rather than approximately. Both\n * sides are asserted against the same shared fixture corpus.\n *\n * Supported: an empty range or `*` (anything), a bare or `=`-prefixed exact version, `^` (npm caret —\n * compatible within the leftmost non-zero component), `~` (patch-level changes), and the comparisons\n * `>=`, `>`, `<=`, `<`. Versions are read as `major.minor.patch` with any pre-release or build metadata\n * suffix ignored. Anything the parser does not recognize is treated as unsatisfiable rather than as\n * \"anything\", so a typo surfaces as a conflict instead of silently passing.\n */\nexport function isVersionSatisfiedBy(version: string, range: string | undefined): boolean {\n const trimmed = range?.trim();\n if (!trimmed || trimmed === '*') return true;\n\n const actual = parseVersion(version);\n if (!actual) return false;\n\n const [operator, literal] = splitRange(trimmed);\n const required = parseVersion(literal);\n if (!required) return false;\n\n switch (operator) {\n case '^':\n return compare(actual, required) >= 0 && compare(actual, caretUpperBound(required)) < 0;\n case '~':\n return compare(actual, required) >= 0 && compare(actual, [required[0], required[1] + 1, 0]) < 0;\n case '>=':\n return compare(actual, required) >= 0;\n case '>':\n return compare(actual, required) > 0;\n case '<=':\n return compare(actual, required) <= 0;\n case '<':\n return compare(actual, required) < 0;\n default:\n return compare(actual, required) === 0;\n }\n}\n\ntype Version = [number, number, number];\n\nfunction splitRange(range: string): [string, string] {\n for (const operator of ['>=', '<=', '^', '~', '>', '<', '=']) {\n if (range.startsWith(operator)) {\n return [operator === '=' ? '' : operator, range.substring(operator.length).trim()];\n }\n }\n\n return ['', range];\n}\n\n/**\n * npm's caret rule: compatibility is bounded by the leftmost non-zero component, so `^1.2.3` allows\n * anything below `2.0.0`, `^0.2.3` anything below `0.3.0`, and `^0.0.3` only `0.0.3` itself.\n */\nfunction caretUpperBound(version: Version): Version {\n if (version[0] > 0) return [version[0] + 1, 0, 0];\n if (version[1] > 0) return [0, version[1] + 1, 0];\n return [0, 0, version[2] + 1];\n}\n\nfunction compare(left: Version, right: Version): number {\n if (left[0] !== right[0]) return left[0] - right[0];\n if (left[1] !== right[1]) return left[1] - right[1];\n return left[2] - right[2];\n}\n\nfunction parseVersion(value: string): Version | undefined {\n let numeric = value.trim();\n const suffix = numeric.search(/[-+]/);\n if (suffix >= 0) {\n numeric = numeric.substring(0, suffix);\n }\n\n const parts = numeric.split('.');\n if (parts.length === 0 || parts.length > 3) return undefined;\n\n const components: Version = [0, 0, 0];\n for (let index = 0; index < parts.length; index++) {\n if (!/^\\d+$/.test(parts[index])) return undefined;\n components[index] = parseInt(parts[index], 10);\n }\n\n return components;\n}\n"],"names":["isVersionSatisfiedBy","version","range","trimmed","trim","actual","parseVersion","operator","literal","splitRange","required","compare","caretUpperBound","
|
|
1
|
+
{"version":3,"file":"packageVersionRange.js","sources":["../../packageVersionRange.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Checks a {@link PackageDependency.versionRange} against a package's actual version. A deliberately\n * small subset of semver — enough to express what a package declaration realistically needs, and small\n * enough that the C# twin in `Cratis.Scene.Engine` can match it exactly rather than approximately. Both\n * sides are asserted against the same shared fixture corpus.\n *\n * Supported: an empty range or `*` (anything), a bare or `=`-prefixed exact version, `^` (npm caret —\n * compatible within the leftmost non-zero component), `~` (patch-level changes), and the comparisons\n * `>=`, `>`, `<=`, `<`. Versions are read as `major.minor.patch` with any pre-release or build metadata\n * suffix ignored. Anything the parser does not recognize is treated as unsatisfiable rather than as\n * \"anything\", so a typo surfaces as a conflict instead of silently passing.\n */\nexport function isVersionSatisfiedBy(version: string, range: string | undefined): boolean {\n const trimmed = range?.trim();\n if (!trimmed || trimmed === '*') return true;\n\n const actual = parseVersion(version);\n if (!actual) return false;\n\n const [operator, literal] = splitRange(trimmed);\n const required = parseVersion(literal);\n if (!required) return false;\n\n switch (operator) {\n case '^':\n return compare(actual, required) >= 0 && compare(actual, caretUpperBound(required)) < 0;\n case '~':\n return compare(actual, required) >= 0 && compare(actual, [required[0], required[1] + 1, 0]) < 0;\n case '>=':\n return compare(actual, required) >= 0;\n case '>':\n return compare(actual, required) > 0;\n case '<=':\n return compare(actual, required) <= 0;\n case '<':\n return compare(actual, required) < 0;\n default:\n return compare(actual, required) === 0;\n }\n}\n\n/**\n * Whether a range is one {@link isVersionSatisfiedBy} understands. An empty range or `*` is valid and means\n * \"any version\"; anything the parser cannot read is invalid, so declarations can be rejected up front\n * instead of surfacing later as a conflict nobody can satisfy.\n */\nexport function isValidVersionRange(range: string | undefined): boolean {\n const trimmed = range?.trim();\n if (!trimmed || trimmed === '*') return true;\n return parseVersion(splitRange(trimmed)[1]) !== undefined;\n}\n\n/**\n * Whether a value is a `major.minor.patch` version, optionally with a pre-release or build suffix.\n */\nexport function isValidVersion(version: string | undefined): boolean {\n return version !== undefined && version.trim().length > 0 && parseVersion(version) !== undefined;\n}\n\ntype Version = [number, number, number];\n\nfunction splitRange(range: string): [string, string] {\n for (const operator of ['>=', '<=', '^', '~', '>', '<', '=']) {\n if (range.startsWith(operator)) {\n return [operator === '=' ? '' : operator, range.substring(operator.length).trim()];\n }\n }\n\n return ['', range];\n}\n\n/**\n * npm's caret rule: compatibility is bounded by the leftmost non-zero component, so `^1.2.3` allows\n * anything below `2.0.0`, `^0.2.3` anything below `0.3.0`, and `^0.0.3` only `0.0.3` itself.\n */\nfunction caretUpperBound(version: Version): Version {\n if (version[0] > 0) return [version[0] + 1, 0, 0];\n if (version[1] > 0) return [0, version[1] + 1, 0];\n return [0, 0, version[2] + 1];\n}\n\nfunction compare(left: Version, right: Version): number {\n if (left[0] !== right[0]) return left[0] - right[0];\n if (left[1] !== right[1]) return left[1] - right[1];\n return left[2] - right[2];\n}\n\nfunction parseVersion(value: string): Version | undefined {\n let numeric = value.trim();\n const suffix = numeric.search(/[-+]/);\n if (suffix >= 0) {\n numeric = numeric.substring(0, suffix);\n }\n\n const parts = numeric.split('.');\n if (parts.length === 0 || parts.length > 3) return undefined;\n\n const components: Version = [0, 0, 0];\n for (let index = 0; index < parts.length; index++) {\n if (!/^\\d+$/.test(parts[index])) return undefined;\n components[index] = parseInt(parts[index], 10);\n }\n\n return components;\n}\n"],"names":["isVersionSatisfiedBy","version","range","trimmed","trim","actual","parseVersion","operator","literal","splitRange","required","compare","caretUpperBound","isValidVersionRange","undefined","isValidVersion","length","startsWith","substring","left","right","value","numeric","suffix","search","parts","split","components","index","test","parseInt"],"mappings":"AAAA;AACA;AAEA;;;;;;;;;;;AAWC,IACM,SAASA,oBAAAA,CAAqBC,OAAe,EAAEC,KAAyB,EAAA;AAC3E,IAAA,MAAMC,UAAUD,KAAAA,EAAOE,IAAAA,EAAAA;AACvB,IAAA,IAAI,CAACD,OAAAA,IAAWA,OAAAA,KAAY,GAAA,EAAK,OAAO,IAAA;AAExC,IAAA,MAAME,SAASC,YAAAA,CAAaL,OAAAA,CAAAA;IAC5B,IAAI,CAACI,QAAQ,OAAO,KAAA;AAEpB,IAAA,MAAM,CAACE,QAAAA,EAAUC,OAAAA,CAAQ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model';
|
|
2
|
+
import { TemplateCatalogKind } from './TemplateCatalogKind';
|
|
3
|
+
export interface TemplateCatalogEntry {
|
|
4
|
+
package: string;
|
|
5
|
+
packageVersion: string;
|
|
6
|
+
kind: TemplateCatalogKind;
|
|
7
|
+
name: string;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
category?: string;
|
|
12
|
+
scopes?: TemplateScope[];
|
|
13
|
+
compatibility?: TemplateCompatibility;
|
|
14
|
+
attribution?: TemplateAttribution;
|
|
15
|
+
license?: string;
|
|
16
|
+
licenseUrl?: string;
|
|
17
|
+
compatible: boolean;
|
|
18
|
+
problems: string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=TemplateCatalogEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateCatalogEntry.d.ts","sourceRoot":"","sources":["../../../templates/TemplateCatalogEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D,MAAM,WAAW,oBAAoB;IAEjC,OAAO,EAAE,MAAM,CAAC;IAGhB,cAAc,EAAE,MAAM,CAAC;IAEvB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,UAAU,EAAE,OAAO,CAAC;IAGpB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateCatalogEntry.js","sourceRoot":"","sources":["../../../templates/TemplateCatalogEntry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateCatalogKind.d.ts","sourceRoot":"","sources":["../../../templates/TemplateCatalogKind.ts"],"names":[],"mappings":"AAMA,oBAAY,mBAAmB;IAC3B,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CACpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Which kind of template a catalog entry describes.
|
|
5
|
+
*/ var TemplateCatalogKind = /*#__PURE__*/ function(TemplateCatalogKind) {
|
|
6
|
+
TemplateCatalogKind["Layout"] = "Layout";
|
|
7
|
+
TemplateCatalogKind["ScreenTemplate"] = "ScreenTemplate";
|
|
8
|
+
TemplateCatalogKind["DialogTemplate"] = "DialogTemplate";
|
|
9
|
+
return TemplateCatalogKind;
|
|
10
|
+
}({});
|
|
11
|
+
|
|
12
|
+
export { TemplateCatalogKind };
|
|
13
|
+
//# sourceMappingURL=TemplateCatalogKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateCatalogKind.js","sources":["../../../templates/TemplateCatalogKind.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Which kind of template a catalog entry describes.\n */\nexport enum TemplateCatalogKind {\n Layout = 'Layout',\n ScreenTemplate = 'ScreenTemplate',\n DialogTemplate = 'DialogTemplate',\n}\n"],"names":["TemplateCatalogKind"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,mBAAAA,iBAAAA,SAAAA,mBAAAA,EAAAA;;;;AAAAA,IAAAA,OAAAA,mBAAAA;AAIX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DialogTemplate, Layout, ScenePackage, ScreenTemplate } from '@cratis/scene.model';
|
|
2
|
+
export interface TemplateSource {
|
|
3
|
+
manifest: ScenePackage;
|
|
4
|
+
layouts?: Layout[];
|
|
5
|
+
screenTemplates?: ScreenTemplate[];
|
|
6
|
+
dialogTemplates?: DialogTemplate[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=TemplateSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateSource.d.ts","sourceRoot":"","sources":["../../../templates/TemplateSource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM3F,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateSource.js","sourceRoot":"","sources":["../../../templates/TemplateSource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TemplateCatalogEntry } from './TemplateCatalogEntry';
|
|
2
|
+
import { TemplateSource } from './TemplateSource';
|
|
3
|
+
export declare function describeTemplateCatalog(sources: TemplateSource[], sceneVersion?: string): TemplateCatalogEntry[];
|
|
4
|
+
//# sourceMappingURL=describeTemplateCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeTemplateCatalog.d.ts","sourceRoot":"","sources":["../../../templates/describeTemplateCatalog.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYlD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,oBAAoB,EAAE,CAwChH"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isVersionSatisfiedBy } from '../packageVersionRange.js';
|
|
2
|
+
import { TemplateCatalogKind } from './TemplateCatalogKind.js';
|
|
3
|
+
import { validateTemplateMetadata } from './validateTemplateMetadata.js';
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* Describes every template the given packages provide, in package then layout, screen template, dialog
|
|
9
|
+
* template order, with its compatibility, attribution and license metadata and whether it can be used.
|
|
10
|
+
*
|
|
11
|
+
* A template is compatible when its metadata is complete and valid, the Scene version (when given) satisfies
|
|
12
|
+
* its Scene range, and every package it requires is among the given packages at a satisfying version and is
|
|
13
|
+
* either its own package or one that package depends on. Nothing is filtered out: a browser shows incompatible
|
|
14
|
+
* templates with their problems rather than hiding why they are unavailable.
|
|
15
|
+
*/ function describeTemplateCatalog(sources, sceneVersion) {
|
|
16
|
+
const versions = new Map(sources.map((source)=>[
|
|
17
|
+
source.manifest.name,
|
|
18
|
+
source.manifest.version
|
|
19
|
+
]));
|
|
20
|
+
const entries = [];
|
|
21
|
+
for (const source of sources){
|
|
22
|
+
const templates = [
|
|
23
|
+
...(source.layouts ?? []).map((template)=>({
|
|
24
|
+
kind: TemplateCatalogKind.Layout,
|
|
25
|
+
template
|
|
26
|
+
})),
|
|
27
|
+
...(source.screenTemplates ?? []).map((template)=>({
|
|
28
|
+
kind: TemplateCatalogKind.ScreenTemplate,
|
|
29
|
+
template
|
|
30
|
+
})),
|
|
31
|
+
...(source.dialogTemplates ?? []).map((template)=>({
|
|
32
|
+
kind: TemplateCatalogKind.DialogTemplate,
|
|
33
|
+
template
|
|
34
|
+
}))
|
|
35
|
+
];
|
|
36
|
+
for (const { kind, template } of templates){
|
|
37
|
+
const metadata = template.metadata;
|
|
38
|
+
const describable = template;
|
|
39
|
+
const problems = [
|
|
40
|
+
...validateTemplateMetadata(template.name, metadata),
|
|
41
|
+
...requirementProblems(template.name, metadata, source.manifest, versions, sceneVersion)
|
|
42
|
+
];
|
|
43
|
+
entries.push({
|
|
44
|
+
package: source.manifest.name,
|
|
45
|
+
packageVersion: source.manifest.version,
|
|
46
|
+
kind,
|
|
47
|
+
name: template.name,
|
|
48
|
+
displayName: describable.displayName,
|
|
49
|
+
description: describable.description,
|
|
50
|
+
type: metadata?.type,
|
|
51
|
+
category: metadata?.category,
|
|
52
|
+
scopes: metadata?.scopes,
|
|
53
|
+
compatibility: metadata?.compatibility,
|
|
54
|
+
attribution: metadata?.attribution,
|
|
55
|
+
license: metadata?.license,
|
|
56
|
+
licenseUrl: metadata?.licenseUrl,
|
|
57
|
+
compatible: problems.length === 0,
|
|
58
|
+
problems
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return entries;
|
|
63
|
+
}
|
|
64
|
+
function requirementProblems(name, metadata, owner, versions, sceneVersion) {
|
|
65
|
+
const problems = [];
|
|
66
|
+
const compatibility = metadata?.compatibility;
|
|
67
|
+
if (!compatibility) return problems;
|
|
68
|
+
if (sceneVersion !== undefined && compatibility.scene?.trim() && !isVersionSatisfiedBy(sceneVersion, compatibility.scene)) {
|
|
69
|
+
problems.push(`Template '${name}' requires Scene ${compatibility.scene} but the host runs ${sceneVersion}`);
|
|
70
|
+
}
|
|
71
|
+
for (const requirement of compatibility.packages ?? []){
|
|
72
|
+
if (!requirement.name?.trim()) continue;
|
|
73
|
+
if (requirement.name !== owner.name && !owner.dependencies.some((dependency)=>dependency.name === requirement.name)) {
|
|
74
|
+
problems.push(`Template '${name}' requires package '${requirement.name}', which its package '${owner.name}' does not depend on`);
|
|
75
|
+
}
|
|
76
|
+
const version = versions.get(requirement.name);
|
|
77
|
+
if (version === undefined) {
|
|
78
|
+
problems.push(`Template '${name}' requires package '${requirement.name}', which is not available`);
|
|
79
|
+
} else if (!isVersionSatisfiedBy(version, requirement.versionRange)) {
|
|
80
|
+
problems.push(`Template '${name}' requires package '${requirement.name}' ${requirement.versionRange} but version ${version} is available`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return problems;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { describeTemplateCatalog };
|
|
87
|
+
//# sourceMappingURL=describeTemplateCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeTemplateCatalog.js","sources":["../../../templates/describeTemplateCatalog.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ScenePackage, TemplateMetadata } from '@cratis/scene.model';\nimport { isVersionSatisfiedBy } from '../packageVersionRange';\nimport { TemplateCatalogEntry } from './TemplateCatalogEntry';\nimport { TemplateCatalogKind } from './TemplateCatalogKind';\nimport { TemplateSource } from './TemplateSource';\nimport { validateTemplateMetadata } from './validateTemplateMetadata';\n\n/**\n * Describes every template the given packages provide, in package then layout, screen template, dialog\n * template order, with its compatibility, attribution and license metadata and whether it can be used.\n *\n * A template is compatible when its metadata is complete and valid, the Scene version (when given) satisfies\n * its Scene range, and every package it requires is among the given packages at a satisfying version and is\n * either its own package or one that package depends on. Nothing is filtered out: a browser shows incompatible\n * templates with their problems rather than hiding why they are unavailable.\n */\nexport function describeTemplateCatalog(sources: TemplateSource[], sceneVersion?: string): TemplateCatalogEntry[] {\n const versions = new Map(sources.map(source => [source.manifest.name, source.manifest.version]));\n const entries: TemplateCatalogEntry[] = [];\n\n for (const source of sources) {\n const templates = [\n ...(source.layouts ?? []).map(template => ({ kind: TemplateCatalogKind.Layout, template })),\n ...(source.screenTemplates ?? []).map(template => ({ kind: TemplateCatalogKind.ScreenTemplate, template })),\n ...(source.dialogTemplates ?? []).map(template => ({ kind: TemplateCatalogKind.DialogTemplate, template })),\n ];\n\n for (const { kind, template } of templates) {\n const metadata = template.metadata;\n const describable = template as { displayName?: string; description?: string };\n const problems = [\n ...validateTemplateMetadata(template.name, metadata),\n ...requirementProblems(template.name, metadata, source.manifest, versions, sceneVersion),\n ];\n\n entries.push({\n package: source.manifest.name,\n packageVersion: source.manifest.version,\n kind,\n name: template.name,\n displayName: describable.displayName,\n description: describable.description,\n type: metadata?.type,\n category: metadata?.category,\n scopes: metadata?.scopes,\n compatibility: metadata?.compatibility,\n attribution: metadata?.attribution,\n license: metadata?.license,\n licenseUrl: metadata?.licenseUrl,\n compatible: problems.length === 0,\n problems,\n });\n }\n }\n\n return entries;\n}\n\nfunction requirementProblems(\n name: string,\n metadata: TemplateMetadata | undefined,\n owner: ScenePackage,\n versions: Map<string, string>,\n sceneVersion: string | undefined,\n): string[] {\n const problems: string[] = [];\n const compatibility = metadata?.compatibility;\n if (!compatibility) return problems;\n\n if (sceneVersion !== undefined && compatibility.scene?.trim() && !isVersionSatisfiedBy(sceneVersion, compatibility.scene)) {\n problems.push(`Template '${name}' requires Scene ${compatibility.scene} but the host runs ${sceneVersion}`);\n }\n\n for (const requirement of compatibility.packages ?? []) {\n if (!requirement.name?.trim()) continue;\n if (requirement.name !== owner.name && !owner.dependencies.some(dependency => dependency.name === requirement.name)) {\n problems.push(`Template '${name}' requires package '${requirement.name}', which its package '${owner.name}' does not depend on`);\n }\n\n const version = versions.get(requirement.name);\n if (version === undefined) {\n problems.push(`Template '${name}' requires package '${requirement.name}', which is not available`);\n } else if (!isVersionSatisfiedBy(version, requirement.versionRange)) {\n problems.push(`Template '${name}' requires package '${requirement.name}' ${requirement.versionRange} but version ${version} is available`);\n }\n }\n\n return problems;\n}\n"],"names":["describeTemplateCatalog","sources","sceneVersion","versions","Map","map","source","manifest","name","version","entries","templates","layouts","template","kind","TemplateCatalogKind","Layout","screenTemplates","ScreenTemplate","dialogTemplates","DialogTemplate","metadata","describable","problems","validateTemplateMetadata","requirementProblems","push","package","packageVersion","displayName","description","type","category","scopes","compatibility","attribution","license","licenseUrl","compatible","length","owner","undefined","scene","trim","isVersionSatisfiedBy","requirement","packages","dependencies","some","dependency","get","versionRange"],"mappings":";;;;AAAA;AACA;AASA;;;;;;;;AAQC,IACM,SAASA,uBAAAA,CAAwBC,OAAyB,EAAEC,YAAqB,EAAA;AACpF,IAAA,MAAMC,WAAW,IAAIC,GAAAA,CAAIH,QAAQI,GAAG,CAACC,CAAAA,MAAAA,GAAU;YAACA,MAAAA,CAAOC,QAAQ,CAACC,IAAI;YAAEF,MAAAA,CAAOC,QAAQ,CAACE;AAAQ,SAAA,CAAA,CAAA;AAC9F,IAAA,MAAMC,UAAkC,EAAE;IAE1C,KAAK,MAAMJ,UAAUL,OAAAA,CAAS;AAC1B,QAAA,MAAMU,SAAAA,GAAY;eACX,CAACL,MAAAA,CAAOM,OAAO,IAAI,EAAE,EAAEP,GAAG,CAACQ,CAAAA,QAAAA,IAAa;AAAEC,oBAAAA,IAAAA,EAAMC,oBAAoBC,MAAM;AAAEH,oBAAAA;iBAAS,CAAA,CAAA;eACrF,CAACP,MAAAA,CAAOW,eAAe,IAAI,EAAE,EAAEZ,GAAG,CAACQ,CAAAA,QAAAA,IAAa;AAAEC,oBAAAA,IAAAA,EAAMC,oBAAoBG,cAAc;AAAEL,oBAAAA;iBAAS,CAAA,CAAA;eACrG,CAACP,MAAAA,CAAOa,eAAe,IAAI,EAAE,EAAEd,GAAG,CAACQ,CAAAA,QAAAA,IAAa;AAAEC,oBAAAA,IAAAA,EAAMC,oBAAoBK,cAAc;AAAEP,oBAAAA;iBAAS,CAAA;AAC3G,SAAA;AAED,QAAA,KAAK,MAAM,EAAEC,IAAI,EAAED,QAAQ,EAAE,IAAIF,SAAAA,CAAW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AAC,yBAAyB,CAAC,CAAA;AACrG,QAAA,CAAA,MAAO,IAAI,CAACoC,oBAAAA,CAAqBnC,OAAAA,EAASoC,WAAAA,CAAYM,YAAY,CAAA,EAAG;YACjE5B,QAAAA,CAASG,IAAI,CAAC,CAAC,UAAU,EAAElB,IAAAA,CAAK,oBAAoB,EAAEqC,WAAAA,CAAYrC,IAAI,CAAC,EAAE,EAAEqC,YAAYM,YAAY,CAAC,aAAa,EAAE1C,OAAAA,CAAQ,aAAa,CAAC,CAAA;AAC7I,QAAA;AACJ,IAAA;IAEA,OAAOc,QAAAA;AACX;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './TemplateCatalogEntry';
|
|
2
|
+
export * from './TemplateCatalogKind';
|
|
3
|
+
export * from './TemplateSource';
|
|
4
|
+
export * from './describeTemplateCatalog';
|
|
5
|
+
export * from './templateMetadataRules';
|
|
6
|
+
export * from './validateTemplateMetadata';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../templates/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './TemplateCatalogEntry';
|
|
2
|
+
export * from './TemplateCatalogKind';
|
|
3
|
+
export * from './TemplateSource';
|
|
4
|
+
export * from './describeTemplateCatalog';
|
|
5
|
+
export * from './templateMetadataRules';
|
|
6
|
+
export * from './validateTemplateMetadata';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../templates/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateMetadataRules.d.ts","sourceRoot":"","sources":["../../../templates/templateMetadataRules.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGzD;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIvD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Whether a value is an absolute `https` URL with a host - the only kind of link a template browser
|
|
5
|
+
* should follow for attribution or license terms. Kept to plain string rules so the C# twin matches exactly.
|
|
6
|
+
*/ function isAbsoluteHttpsUrl(value) {
|
|
7
|
+
const prefix = 'https://';
|
|
8
|
+
return value.startsWith(prefix) && value.length > prefix.length && value[prefix.length] !== '/' && !/\s/.test(value);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether a value is a simple SPDX license expression: identifiers such as `MIT`, `Apache-2.0` or
|
|
12
|
+
* `LicenseRef-Acme`, optionally joined by `AND`, `OR` or `WITH`. Parentheses are not supported.
|
|
13
|
+
*/ function isSpdxExpression(value) {
|
|
14
|
+
const tokens = value.split(' ');
|
|
15
|
+
if (tokens.length % 2 === 0) return false;
|
|
16
|
+
return tokens.every((token, index)=>index % 2 === 1 ? [
|
|
17
|
+
'AND',
|
|
18
|
+
'OR',
|
|
19
|
+
'WITH'
|
|
20
|
+
].includes(token) : isSpdxIdentifier(token));
|
|
21
|
+
}
|
|
22
|
+
function isSpdxIdentifier(token) {
|
|
23
|
+
return token.length > 0 && [
|
|
24
|
+
...token
|
|
25
|
+
].every((character)=>/[A-Za-z0-9.+-]/.test(character));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { isAbsoluteHttpsUrl, isSpdxExpression };
|
|
29
|
+
//# sourceMappingURL=templateMetadataRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateMetadataRules.js","sources":["../../../templates/templateMetadataRules.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Whether a value is an absolute `https` URL with a host - the only kind of link a template browser\n * should follow for attribution or license terms. Kept to plain string rules so the C# twin matches exactly.\n */\nexport function isAbsoluteHttpsUrl(value: string): boolean {\n const prefix = 'https://';\n return value.startsWith(prefix) && value.length > prefix.length && value[prefix.length] !== '/' && !/\\s/.test(value);\n}\n\n/**\n * Whether a value is a simple SPDX license expression: identifiers such as `MIT`, `Apache-2.0` or\n * `LicenseRef-Acme`, optionally joined by `AND`, `OR` or `WITH`. Parentheses are not supported.\n */\nexport function isSpdxExpression(value: string): boolean {\n const tokens = value.split(' ');\n if (tokens.length % 2 === 0) return false;\n return tokens.every((token, index) => (index % 2 === 1 ? ['AND', 'OR', 'WITH'].includes(token) : isSpdxIdentifier(token)));\n}\n\nfunction isSpdxIdentifier(token: string): boolean {\n return token.length > 0 && [...token].every(character => /[A-Za-z0-9.+-]/.test(character));\n}\n"],"names":["isAbsoluteHttpsUrl","value","prefix","startsWith","length","test","isSpdxExpression","tokens","split","every","token","index","includes","isSpdxIdentifier","character"],"mappings":"AAAA;AACA;AAEA;;;IAIO,SAASA,kBAAAA,CAAmBC,KAAa,EAAA;AAC5C,IAAA,MAAMC,MAAAA,GAAS,UAAA;IACf,OAAOD,KAAAA,CAAME,UAAU,CAACD,MAAAA,CAAAA,IAAWD,MAAMG,MAAM,GAAGF,OAAOE,MAAM,IAAIH,KAAK,CAACC,MAAAA,CAAOE,MAAM,CAAC,KAAK,OAAO,CAAC,IAAA,CAAKC,IAAI,CAACJ,KAAAA,CAAAA;AAClH;AAEA;;;IAIO,SAASK,gBAAAA,CAAiBL,KAAa,EAAA;IAC1C,MAAMM,MAAAA,GAASN,KAAAA,CAAMO,KAAK,CAAC,GAAA,CAAA;AAC3B,IAAA,IAAID,MAAAA,CAAOH,MAAM,GAAG,CAAA,KAAM,GAAG,OAAO,KAAA;IACpC,OAAOG,MAAAA,CAAOE,KAAK,CAAC,CAACC,OAAOC,KAAAA,GAAWA,KAAAA,GAAQ,MAAM,CAAA,GAAI;AAAC,YAAA,KAAA;AAAO,YAAA,IAAA;AAAM,YAAA;SAAO,CAACC,QAAQ,CAACF,KAAAA,CAAAA,GAASG,gBAAAA,CAAiBH,KAAAA,CAAAA,CAAAA;AACtH;AAEA,SAASG,iBAAiBH,KAAa,EAAA;IACnC,OAAOA,KAAAA,CAAMN,MAAM,GAAG,CAAA,IAAK;AAAIM,QAAAA,GAAAA;AAAM,KAAA,CAACD,KAAK,CAACK,CAAAA,SAAAA,GAAa,gBAAA,CAAiBT,IAAI,CAACS,SAAAA,CAAAA,CAAAA;AACnF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateTemplateMetadata.d.ts","sourceRoot":"","sources":["../../../templates/validateTemplateMetadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AASvD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,EAAE,CA0CvG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isValidVersionRange } from '../packageVersionRange.js';
|
|
2
|
+
import { isAbsoluteHttpsUrl, isSpdxExpression } from './templateMetadataRules.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/**
|
|
7
|
+
* Checks that a template carries the compatibility, attribution and license metadata every shipped template
|
|
8
|
+
* needs, and that each value is well formed. The C# engine (`TemplateMetadataValidation.Validate`) reports the
|
|
9
|
+
* same problems in the same order; both are asserted against `template-metadata-fixtures.json`.
|
|
10
|
+
*/ function validateTemplateMetadata(name, metadata) {
|
|
11
|
+
const problems = [];
|
|
12
|
+
const compatibility = metadata?.compatibility;
|
|
13
|
+
if (!compatibility) {
|
|
14
|
+
problems.push(`Template '${name}' declares no compatibility`);
|
|
15
|
+
} else {
|
|
16
|
+
if (!compatibility.scene?.trim()) {
|
|
17
|
+
problems.push(`Template '${name}' declares no Scene version range`);
|
|
18
|
+
} else if (!isValidVersionRange(compatibility.scene)) {
|
|
19
|
+
problems.push(`Template '${name}' declares an invalid Scene version range '${compatibility.scene}'`);
|
|
20
|
+
}
|
|
21
|
+
for (const requirement of compatibility.packages ?? []){
|
|
22
|
+
if (!requirement.name?.trim()) {
|
|
23
|
+
problems.push(`Template '${name}' declares a package requirement without a name`);
|
|
24
|
+
} else if (!isValidVersionRange(requirement.versionRange)) {
|
|
25
|
+
problems.push(`Template '${name}' declares an invalid version range '${requirement.versionRange}' for package '${requirement.name}'`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const attribution = metadata?.attribution;
|
|
30
|
+
if (!attribution?.author?.trim()) {
|
|
31
|
+
problems.push(`Template '${name}' declares no author`);
|
|
32
|
+
}
|
|
33
|
+
if (attribution?.url !== undefined && !isAbsoluteHttpsUrl(attribution.url)) {
|
|
34
|
+
problems.push(`Template '${name}' declares an attribution URL '${attribution.url}' that is not an absolute https URL`);
|
|
35
|
+
}
|
|
36
|
+
if (!metadata?.license?.trim()) {
|
|
37
|
+
problems.push(`Template '${name}' declares no license`);
|
|
38
|
+
} else if (!isSpdxExpression(metadata.license)) {
|
|
39
|
+
problems.push(`Template '${name}' declares '${metadata.license}', which is not an SPDX license expression`);
|
|
40
|
+
}
|
|
41
|
+
if (metadata?.licenseUrl !== undefined && !isAbsoluteHttpsUrl(metadata.licenseUrl)) {
|
|
42
|
+
problems.push(`Template '${name}' declares a license URL '${metadata.licenseUrl}' that is not an absolute https URL`);
|
|
43
|
+
}
|
|
44
|
+
return problems;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { validateTemplateMetadata };
|
|
48
|
+
//# sourceMappingURL=validateTemplateMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateTemplateMetadata.js","sources":["../../../templates/validateTemplateMetadata.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { TemplateMetadata } from '@cratis/scene.model';\nimport { isValidVersionRange } from '../packageVersionRange';\nimport { isAbsoluteHttpsUrl, isSpdxExpression } from './templateMetadataRules';\n\n/**\n * Checks that a template carries the compatibility, attribution and license metadata every shipped template\n * needs, and that each value is well formed. The C# engine (`TemplateMetadataValidation.Validate`) reports the\n * same problems in the same order; both are asserted against `template-metadata-fixtures.json`.\n */\nexport function validateTemplateMetadata(name: string, metadata: TemplateMetadata | undefined): string[] {\n const problems: string[] = [];\n const compatibility = metadata?.compatibility;\n\n if (!compatibility) {\n problems.push(`Template '${name}' declares no compatibility`);\n } else {\n if (!compatibility.scene?.trim()) {\n problems.push(`Template '${name}' declares no Scene version range`);\n } else if (!isValidVersionRange(compatibility.scene)) {\n problems.push(`Template '${name}' declares an invalid Scene version range '${compatibility.scene}'`);\n }\n\n for (const requirement of compatibility.packages ?? []) {\n if (!requirement.name?.trim()) {\n problems.push(`Template '${name}' declares a package requirement without a name`);\n } else if (!isValidVersionRange(requirement.versionRange)) {\n problems.push(`Template '${name}' declares an invalid version range '${requirement.versionRange}' for package '${requirement.name}'`);\n }\n }\n }\n\n const attribution = metadata?.attribution;\n if (!attribution?.author?.trim()) {\n problems.push(`Template '${name}' declares no author`);\n }\n\n if (attribution?.url !== undefined && !isAbsoluteHttpsUrl(attribution.url)) {\n problems.push(`Template '${name}' declares an attribution URL '${attribution.url}' that is not an absolute https URL`);\n }\n\n if (!metadata?.license?.trim()) {\n problems.push(`Template '${name}' declares no license`);\n } else if (!isSpdxExpression(metadata.license)) {\n problems.push(`Template '${name}' declares '${metadata.license}', which is not an SPDX license expression`);\n }\n\n if (metadata?.licenseUrl !== undefined && !isAbsoluteHttpsUrl(metadata.licenseUrl)) {\n problems.push(`Template '${name}' declares a license URL '${metadata.licenseUrl}' that is not an absolute https URL`);\n }\n\n return problems;\n}\n"],"names":["validateTemplateMetadata","name","metadata","problems","compatibility","push","scene","trim","isValidVersionRange","requirement","packages","versionRange","attribution","author","url","undefined","isAbsoluteHttpsUrl","license","isSpdxExpression","licenseUrl"],"mappings":";;;AAAA;AACA;AAMA;;;;AAIC,IACM,SAASA,wBAAAA,CAAyBC,IAAY,EAAEC,QAAsC,EAAA;AACzF,IAAA,MAAMC,WAAqB,EAAE;AAC7B,IAAA,MAAMC,gBAAgBF,QAAAA,EAAUE,aAAAA;AAEhC,IAAA,IAAI,CAACA,aAAAA,EAAe;AAChBD,QAAAA,QAAAA,CAASE,IAAI,CAAC,CAAC,UAAU,EAAEJ,IAAAA,CAAK,2BAA2B,CAAC,CAAA;IAChE,CAAA,MAAO;AACH,QAAA,IAAI,CAACG,aAAAA,CAAcE,KAAK,EAAEC,IAAAA,EAAAA,EAAQ;AAC9BJ,YAAAA,QAAAA,CAASE,IAAI,CAAC,CAAC,UAAU,EAAEJ,IAAAA,CAAK,iCAAiC,CAAC,CAAA;AACtE,QAAA,CAAA,MAAO,IAAI,CAACO,mBAAAA,CAAoBJ,aAAAA,CAAcE,KAAK,CAAA,EAAG;AAClDH,YAAAA,QAAAA,CAASE,IAAI,CAAC,CAAC,UAAU,EAAEJ,IAAAA,CAAK,2CAA2C,EAAEG,aAAAA,CAAcE,KAAK,CAAC,CAAC,CAAC,CAAA;AACvG,QAAA;AAEA,QAAA,KAAK,MAAMG,WAAAA,IAAeL,aAAAA,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