@cratis/scene.engine 4.23.0 → 4.25.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/descriptors/componentBadge.ts +41 -0
- package/descriptors/index.ts +7 -0
- package/descriptors/matchComponentQuery.ts +55 -0
- package/descriptors/rankFrequentlyUsedComponents.ts +29 -0
- package/descriptors/validateComponentDescriptors.ts +122 -0
- package/dist/cjs/descriptors/componentBadge.js +35 -0
- package/dist/cjs/descriptors/componentBadge.js.map +1 -0
- package/dist/cjs/descriptors/matchComponentQuery.js +56 -0
- package/dist/cjs/descriptors/matchComponentQuery.js.map +1 -0
- package/dist/cjs/descriptors/rankFrequentlyUsedComponents.js +18 -0
- package/dist/cjs/descriptors/rankFrequentlyUsedComponents.js.map +1 -0
- package/dist/cjs/descriptors/validateComponentDescriptors.js +116 -0
- package/dist/cjs/descriptors/validateComponentDescriptors.js.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/templateApplicability.js.map +1 -1
- package/dist/cjs/templates/TemplateReferenceResolution.js +15 -0
- package/dist/cjs/templates/TemplateReferenceResolution.js.map +1 -0
- package/dist/cjs/templates/applicableTemplates.js +199 -0
- package/dist/cjs/templates/applicableTemplates.js.map +1 -0
- package/dist/cjs/templates/describeTemplateCatalog.js +11 -6
- package/dist/cjs/templates/describeTemplateCatalog.js.map +1 -1
- package/dist/cjs/templates/resolveTemplateReference.js +89 -0
- package/dist/cjs/templates/resolveTemplateReference.js.map +1 -0
- package/dist/cjs/templates/validateTemplateMetadata.js +9 -0
- package/dist/cjs/templates/validateTemplateMetadata.js.map +1 -1
- package/dist/esm/descriptors/componentBadge.d.ts +3 -0
- package/dist/esm/descriptors/componentBadge.d.ts.map +1 -0
- package/dist/esm/descriptors/componentBadge.js +33 -0
- package/dist/esm/descriptors/componentBadge.js.map +1 -0
- package/dist/esm/descriptors/index.d.ts +5 -0
- package/dist/esm/descriptors/index.d.ts.map +1 -0
- package/dist/esm/descriptors/index.js +5 -0
- package/dist/esm/descriptors/index.js.map +1 -0
- package/dist/esm/descriptors/matchComponentQuery.d.ts +9 -0
- package/dist/esm/descriptors/matchComponentQuery.d.ts.map +1 -0
- package/dist/esm/descriptors/matchComponentQuery.js +54 -0
- package/dist/esm/descriptors/matchComponentQuery.js.map +1 -0
- package/dist/esm/descriptors/rankFrequentlyUsedComponents.d.ts +7 -0
- package/dist/esm/descriptors/rankFrequentlyUsedComponents.d.ts.map +1 -0
- package/dist/esm/descriptors/rankFrequentlyUsedComponents.js +15 -0
- package/dist/esm/descriptors/rankFrequentlyUsedComponents.js.map +1 -0
- package/dist/esm/descriptors/validateComponentDescriptors.d.ts +3 -0
- package/dist/esm/descriptors/validateComponentDescriptors.d.ts.map +1 -0
- package/dist/esm/descriptors/validateComponentDescriptors.js +114 -0
- package/dist/esm/descriptors/validateComponentDescriptors.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/templateApplicability.d.ts +1 -2
- package/dist/esm/templateApplicability.d.ts.map +1 -1
- package/dist/esm/templateApplicability.js.map +1 -1
- package/dist/esm/templates/ApplicableTemplateSet.d.ts +27 -0
- package/dist/esm/templates/ApplicableTemplateSet.d.ts.map +1 -0
- package/dist/esm/templates/ApplicableTemplateSet.js +2 -0
- package/dist/esm/templates/ApplicableTemplateSet.js.map +1 -0
- package/dist/esm/templates/TemplateCatalogEntry.d.ts +3 -1
- package/dist/esm/templates/TemplateCatalogEntry.d.ts.map +1 -1
- package/dist/esm/templates/TemplateLibrary.d.ts +6 -0
- package/dist/esm/templates/TemplateLibrary.d.ts.map +1 -0
- package/dist/esm/templates/TemplateLibrary.js +2 -0
- package/dist/esm/templates/TemplateLibrary.js.map +1 -0
- package/dist/esm/templates/TemplateReferenceResolution.d.ts +16 -0
- package/dist/esm/templates/TemplateReferenceResolution.d.ts.map +1 -0
- package/dist/esm/templates/TemplateReferenceResolution.js +13 -0
- package/dist/esm/templates/TemplateReferenceResolution.js.map +1 -0
- package/dist/esm/templates/TemplateTarget.d.ts +9 -0
- package/dist/esm/templates/TemplateTarget.d.ts.map +1 -0
- package/dist/esm/templates/TemplateTarget.js +2 -0
- package/dist/esm/templates/TemplateTarget.js.map +1 -0
- package/dist/esm/templates/applicableTemplates.d.ts +9 -0
- package/dist/esm/templates/applicableTemplates.d.ts.map +1 -0
- package/dist/esm/templates/applicableTemplates.js +194 -0
- package/dist/esm/templates/applicableTemplates.js.map +1 -0
- package/dist/esm/templates/describeTemplateCatalog.d.ts.map +1 -1
- package/dist/esm/templates/describeTemplateCatalog.js +12 -7
- package/dist/esm/templates/describeTemplateCatalog.js.map +1 -1
- package/dist/esm/templates/index.d.ts +6 -0
- package/dist/esm/templates/index.d.ts.map +1 -1
- package/dist/esm/templates/index.js +6 -0
- package/dist/esm/templates/index.js.map +1 -1
- package/dist/esm/templates/resolveTemplateReference.d.ts +5 -0
- package/dist/esm/templates/resolveTemplateReference.d.ts.map +1 -0
- package/dist/esm/templates/resolveTemplateReference.js +87 -0
- package/dist/esm/templates/resolveTemplateReference.js.map +1 -0
- package/dist/esm/templates/validateTemplateMetadata.d.ts +2 -0
- package/dist/esm/templates/validateTemplateMetadata.d.ts.map +1 -1
- package/dist/esm/templates/validateTemplateMetadata.js +8 -1
- package/dist/esm/templates/validateTemplateMetadata.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/package.json +3 -3
- package/templateApplicability.ts +2 -1
- package/templates/ApplicableTemplateSet.ts +54 -0
- package/templates/TemplateCatalogEntry.ts +5 -1
- package/templates/TemplateLibrary.ts +16 -0
- package/templates/TemplateReferenceResolution.ts +35 -0
- package/templates/TemplateTarget.ts +23 -0
- package/templates/applicableTemplates.ts +148 -0
- package/templates/describeTemplateCatalog.ts +11 -7
- package/templates/index.ts +6 -0
- package/templates/resolveTemplateReference.ts +79 -0
- package/templates/validateTemplateMetadata.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../descriptors/index.ts"],"names":[],"mappings":"AAGA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../descriptors/index.ts"],"names":[],"mappings":"AAGA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentDescriptor } from '@cratis/scene.model';
|
|
2
|
+
export interface ComponentQueryMatch {
|
|
3
|
+
matched: boolean;
|
|
4
|
+
via?: 'name' | 'category' | 'keyword';
|
|
5
|
+
ranges: [number, number][];
|
|
6
|
+
keyword?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function matchComponentQuery(descriptor: Pick<ComponentDescriptor, 'component' | 'displayName' | 'category' | 'keywords'>, query: string): ComponentQueryMatch;
|
|
9
|
+
//# sourceMappingURL=matchComponentQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchComponentQuery.d.ts","sourceRoot":"","sources":["../../../descriptors/matchComponentQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,MAAM,WAAW,mBAAmB;IAEhC,OAAO,EAAE,OAAO,CAAC;IAGjB,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAGtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAG3B,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAWD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAcpK"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
* Decides whether a component is shown for the text typed in a picker's filter, and why.
|
|
5
|
+
*
|
|
6
|
+
* Matching is case-insensitive. The display name (or, when the descriptor has none, the bare component name) and the keywords match by
|
|
7
|
+
* substring. The category matches by the start of one of its words - `nav` finds every Navigation component, while `ta` does not find
|
|
8
|
+
* everything under `Data display`, which a substring match on the category would. A component is shown when any of the three
|
|
9
|
+
* match; it reports the first of name, category, keyword that did, so the picker highlights the name and shows a hint only when a
|
|
10
|
+
* keyword alone brought the component in. An empty filter matches everything and highlights nothing.
|
|
11
|
+
*/ function matchComponentQuery(descriptor, query) {
|
|
12
|
+
const needle = query.trim().toLowerCase();
|
|
13
|
+
if (needle.length === 0) return {
|
|
14
|
+
matched: true,
|
|
15
|
+
ranges: []
|
|
16
|
+
};
|
|
17
|
+
const name = descriptor.displayName ?? descriptor.component.slice(descriptor.component.lastIndexOf(':') + 1);
|
|
18
|
+
const ranges = occurrencesOf(name.toLowerCase(), needle);
|
|
19
|
+
if (ranges.length > 0) return {
|
|
20
|
+
matched: true,
|
|
21
|
+
via: 'name',
|
|
22
|
+
ranges
|
|
23
|
+
};
|
|
24
|
+
if (descriptor.category !== undefined && descriptor.category.toLowerCase().split(/\s+/).some((word)=>word.startsWith(needle))) {
|
|
25
|
+
return {
|
|
26
|
+
matched: true,
|
|
27
|
+
via: 'category',
|
|
28
|
+
ranges: []
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const keyword = (descriptor.keywords ?? []).find((candidate)=>candidate.toLowerCase().includes(needle));
|
|
32
|
+
return keyword === undefined ? {
|
|
33
|
+
matched: false,
|
|
34
|
+
ranges: []
|
|
35
|
+
} : {
|
|
36
|
+
matched: true,
|
|
37
|
+
via: 'keyword',
|
|
38
|
+
ranges: [],
|
|
39
|
+
keyword
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function occurrencesOf(text, needle) {
|
|
43
|
+
const found = [];
|
|
44
|
+
for(let at = text.indexOf(needle); at >= 0; at = text.indexOf(needle, at + needle.length)){
|
|
45
|
+
found.push([
|
|
46
|
+
at,
|
|
47
|
+
at + needle.length
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { matchComponentQuery };
|
|
54
|
+
//# sourceMappingURL=matchComponentQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchComponentQuery.js","sources":["../../../descriptors/matchComponentQuery.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 { ComponentDescriptor } from '@cratis/scene.model';\n\n/**\n * How a component answers a picker's filter text (spec PICK2).\n */\nexport interface ComponentQueryMatch {\n /** The component is shown for this filter. */\n matched: boolean;\n\n /** What matched, strongest first: the display name, the category, or one of the keywords. Absent when nothing matched. */\n via?: 'name' | 'category' | 'keyword';\n\n /** The `[start, end)` ranges of the display name to highlight. Empty unless the name matched. */\n ranges: [number, number][];\n\n /** The keyword the component matched through. Present only when `via` is `keyword`: the picker shows it as a hint. */\n keyword?: string;\n}\n\n/**\n * Decides whether a component is shown for the text typed in a picker's filter, and why.\n *\n * Matching is case-insensitive. The display name (or, when the descriptor has none, the bare component name) and the keywords match by\n * substring. The category matches by the start of one of its words - `nav` finds every Navigation component, while `ta` does not find\n * everything under `Data display`, which a substring match on the category would. A component is shown when any of the three\n * match; it reports the first of name, category, keyword that did, so the picker highlights the name and shows a hint only when a\n * keyword alone brought the component in. An empty filter matches everything and highlights nothing.\n */\nexport function matchComponentQuery(descriptor: Pick<ComponentDescriptor, 'component' | 'displayName' | 'category' | 'keywords'>, query: string): ComponentQueryMatch {\n const needle = query.trim().toLowerCase();\n if (needle.length === 0) return { matched: true, ranges: [] };\n\n const name = descriptor.displayName ?? descriptor.component.slice(descriptor.component.lastIndexOf(':') + 1);\n const ranges = occurrencesOf(name.toLowerCase(), needle);\n if (ranges.length > 0) return { matched: true, via: 'name', ranges };\n\n if (descriptor.category !== undefined && descriptor.category.toLowerCase().split(/\\s+/).some(word => word.startsWith(needle))) {\n return { matched: true, via: 'category', ranges: [] };\n }\n\n const keyword = (descriptor.keywords ?? []).find(candidate => candidate.toLowerCase().includes(needle));\n return keyword === undefined ? { matched: false, ranges: [] } : { matched: true, via: 'keyword', ranges: [], keyword };\n}\n\nfunction occurrencesOf(text: string, needle: string): [number, number][] {\n const found: [number, number][] = [];\n for (let at = text.indexOf(needle); at >= 0; at = text.indexOf(needle, at + needle.length)) {\n found.push([at, at + needle.length]);\n }\n\n return found;\n}\n"],"names":["matchComponentQuery","descriptor","query","needle","trim","toLowerCase","length","matched","ranges","name","displayName","component","slice","lastIndexOf","occurrencesOf","via","category","undefined","split","some","word","startsWith","keyword","keywords","find","candidate","includes","text","found","at","indexOf","push"],"mappings":"AAAA;AACA;AAqBA;;;;;;;;AAQC,IACM,SAASA,mBAAAA,CAAoBC,UAA4F,EAAEC,KAAa,EAAA;AAC3I,IAAA,MAAMC,MAAAA,GAASD,KAAAA,CAAME,IAAI,EAAA,CAAGC,WAAW,EAAA;AACvC,IAAA,IAAIF,MAAAA,CAAOG,MAAM,KAAK,CAAA,EAAG,OAAO;QAAEC,OAAAA,EAAS,IAAA;AAAMC,QAAAA,MAAAA,EAAQ;AAAG,KAAA;AAE5D,IAAA,MAAMC,IAAAA,GAAOR,UAAAA,CAAWS,WAAW,IAAIT,WAAWU,SAAS,CAACC,KAAK,CAACX,UAAAA,CAAWU,SAAS,CAACE,WAAW,CA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CAAC3B,MAAAA,EAAQ0B,EAAAA,GAAK1B,MAAAA,CAAOG,MAAM,CAAA,CAAG;AACxFsB,QAAAA,KAAAA,CAAMG,IAAI,CAAC;AAACF,YAAAA,EAAAA;AAAIA,YAAAA,EAAAA,GAAK1B,OAAOG;AAAO,SAAA,CAAA;AACvC,IAAA;IAEA,OAAOsB,KAAAA;AACX;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ComponentUsage {
|
|
2
|
+
count: number;
|
|
3
|
+
last: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const frequentlyUsedLimit = 6;
|
|
6
|
+
export declare function rankFrequentlyUsedComponents(usage: Readonly<Record<string, ComponentUsage>>, limit?: number): string[];
|
|
7
|
+
//# sourceMappingURL=rankFrequentlyUsedComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rankFrequentlyUsedComponents.d.ts","sourceRoot":"","sources":["../../../descriptors/rankFrequentlyUsedComponents.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAE3B,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,CAAC;CAChB;AAGD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAOrC,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,KAAK,GAAE,MAA4B,GAAG,MAAM,EAAE,CAM3I"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* How often and how recently one component was added to a canvas.
|
|
5
|
+
*/ /** The number of components the "Frequently used" group lists (spec PICK3). */ const frequentlyUsedLimit = 6;
|
|
6
|
+
/**
|
|
7
|
+
* The components the "Frequently used" group lists: at most `limit` (6 by default), the most used first, ties broken by the most
|
|
8
|
+
* recent use, and any remaining tie by the component name so the order is stable. Components never used, or whose count is not a
|
|
9
|
+
* positive number, are not listed, so a picker hides the group when this is empty.
|
|
10
|
+
*/ function rankFrequentlyUsedComponents(usage, limit = frequentlyUsedLimit) {
|
|
11
|
+
return Object.entries(usage).filter(([, entry])=>Number.isFinite(entry.count) && entry.count > 0).sort(([leftName, left], [rightName, right])=>right.count - left.count || right.last - left.last || leftName.localeCompare(rightName)).slice(0, Math.max(0, limit)).map(([name])=>name);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { frequentlyUsedLimit, rankFrequentlyUsedComponents };
|
|
15
|
+
//# sourceMappingURL=rankFrequentlyUsedComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rankFrequentlyUsedComponents.js","sources":["../../../descriptors/rankFrequentlyUsedComponents.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 * How often and how recently one component was added to a canvas.\n */\nexport interface ComponentUsage {\n /** How many times the component was added. */\n count: number;\n\n /** When it was last added, in milliseconds since the epoch. */\n last: number;\n}\n\n/** The number of components the \"Frequently used\" group lists (spec PICK3). */\nexport const frequentlyUsedLimit = 6;\n\n/**\n * The components the \"Frequently used\" group lists: at most `limit` (6 by default), the most used first, ties broken by the most\n * recent use, and any remaining tie by the component name so the order is stable. Components never used, or whose count is not a\n * positive number, are not listed, so a picker hides the group when this is empty.\n */\nexport function rankFrequentlyUsedComponents(usage: Readonly<Record<string, ComponentUsage>>, limit: number = frequentlyUsedLimit): string[] {\n return Object.entries(usage)\n .filter(([, entry]) => Number.isFinite(entry.count) && entry.count > 0)\n .sort(([leftName, left], [rightName, right]) => right.count - left.count || right.last - left.last || leftName.localeCompare(rightName))\n .slice(0, Math.max(0, limit))\n .map(([name]) => name);\n}\n"],"names":["frequentlyUsedLimit","rankFrequentlyUsedComponents","usage","limit","Object","entries","filter","entry","Number","isFinite","count","sort","leftName","left","rightName","right","last","localeCompare","slice","Math","max","map","name"],"mappings":"AAAA;AACA;AAEA;;AAEC,oFAUM,MAAMA,sBAAsB;AAEnC;;;;AAIC,IACM,SAASC,4BAAAA,CAA6BC,KAA+C,EAAEC,QAAgBH,mBAAmB,EAAA;AAC7H,IAAA,OAAOI,MAAAA,CAAOC,OAAO,CAACH,KAAAA,CAAAA,CACjBI,MAAM,CAAC,CAAC,GAAGC,KAAAA,CAAM,GAAKC,MAAAA,CAAOC,QAAQ,CAACF,KAAAA,CAAMG,KAAK,CAAA,IAAKH,KAAAA,CAAMG,KAAK,GAAG,CAAA,CAAA,CACpEC,IAAI,CAAC,CAAC,CAACC,QAAAA,EAAUC,IAAAA,CAAK,EAAE,CAACC,SAAAA,EAAWC,KAAAA,CAAM,GAAKA,KAAAA,CAAML,KAAK,GAAGG,IAAAA,CAAKH,KAAK,IAAIK,KAAAA,CAAMC,IAAI,GAAGH,IAAAA,CAAKG,IAAI,IAAIJ,QAAAA,CAASK,aAAa,CAACH,SAAAA,CAAAA,CAAAA,CAC5HI,KAAK,CAAC,CAAA,EAAGC,IAAAA,CAAKC,GAAG,CAAC,CAAA,EAAGjB,KAAAA,CAAAA,CAAAA,CACrBkB,GAAG,CAAC,CAAC,CAACC,IAAAA,CAAK,GAAKA,IAAAA,CAAAA;AACzB;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ComponentDescriptor, SceneDiagnostic } from '@cratis/scene.model';
|
|
2
|
+
export declare function validateComponentDescriptors(descriptors: readonly ComponentDescriptor[], registered?: readonly string[], knownCategories?: readonly string[]): SceneDiagnostic[];
|
|
3
|
+
//# sourceMappingURL=validateComponentDescriptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateComponentDescriptors.d.ts","sourceRoot":"","sources":["../../../descriptors/validateComponentDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EACnB,eAAe,EAClB,MAAM,qBAAqB,CAAC;AAgB7B,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,SAAS,mBAAmB,EAAE,EAC3C,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,EAC9B,eAAe,GAAE,SAAS,MAAM,EAAwB,GACzD,eAAe,EAAE,CA8BnB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { componentCategories, DiagnosticSeverity, DiagnosticCode, PropertyValueType, PropertyEditorKind } from '@cratis/scene.model';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Checks the component metadata a package ships - what a picker and a designer read without loading a component.
|
|
7
|
+
*
|
|
8
|
+
* - **CMP1** `componentCategoryMissing` (error): a registered component has no descriptor, or its descriptor declares no category.
|
|
9
|
+
* - `componentCategoryUnknown` (warning): the category is not one of the model's; a package may add its own, so this is a
|
|
10
|
+
* nudge towards the shared vocabulary, not a refusal.
|
|
11
|
+
* - `componentDesignModeInvalid` (error): the design-mode descriptor names an items or collection path that is not a `Collection`
|
|
12
|
+
* property of the component, or repeats an action id.
|
|
13
|
+
* - `propertyEditorOptionsInvalid` (error): an editor's parameters cannot work - a `reference` editor that does not say what it
|
|
14
|
+
* references, a step that is not positive, an empty list of slice kinds.
|
|
15
|
+
*
|
|
16
|
+
* `registered` is the bare or package-qualified names of the components the package registers; when given, each must be described.
|
|
17
|
+
* The result is in a stable order: registered components first (in the order given), then each descriptor's findings in its own order.
|
|
18
|
+
*/ function validateComponentDescriptors(descriptors, registered, knownCategories = componentCategories) {
|
|
19
|
+
const diagnostics = [];
|
|
20
|
+
const described = new Map(descriptors.map((descriptor)=>[
|
|
21
|
+
descriptor.component,
|
|
22
|
+
descriptor
|
|
23
|
+
]));
|
|
24
|
+
for (const component of registered ?? []){
|
|
25
|
+
if (!described.has(component)) {
|
|
26
|
+
diagnostics.push(missingCategory(component, `'${component}' is registered but has no descriptor, so it declares no category`));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const descriptor of descriptors){
|
|
30
|
+
const { component } = descriptor;
|
|
31
|
+
if (descriptor.category === undefined || descriptor.category.trim().length === 0) {
|
|
32
|
+
diagnostics.push(missingCategory(component, `'${component}' declares no category`));
|
|
33
|
+
} else if (!knownCategories.includes(descriptor.category)) {
|
|
34
|
+
diagnostics.push({
|
|
35
|
+
code: DiagnosticCode.ComponentCategoryUnknown,
|
|
36
|
+
severity: DiagnosticSeverity.Warning,
|
|
37
|
+
component,
|
|
38
|
+
message: `'${component}' declares the category '${descriptor.category}', which is not one of ${knownCategories.join(', ')}`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (descriptor.designMode) {
|
|
42
|
+
diagnostics.push(...validateDesignMode(descriptor, descriptor.designMode));
|
|
43
|
+
}
|
|
44
|
+
diagnostics.push(...validateEditorOptions(component, descriptor.properties, ''));
|
|
45
|
+
}
|
|
46
|
+
return diagnostics;
|
|
47
|
+
}
|
|
48
|
+
function missingCategory(component, message) {
|
|
49
|
+
return {
|
|
50
|
+
code: DiagnosticCode.ComponentCategoryMissing,
|
|
51
|
+
severity: DiagnosticSeverity.Error,
|
|
52
|
+
component,
|
|
53
|
+
message
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function invalidDesignMode(component, message) {
|
|
57
|
+
return {
|
|
58
|
+
code: DiagnosticCode.ComponentDesignModeInvalid,
|
|
59
|
+
severity: DiagnosticSeverity.Error,
|
|
60
|
+
component,
|
|
61
|
+
message
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function validateDesignMode(descriptor, designMode) {
|
|
65
|
+
const { component } = descriptor;
|
|
66
|
+
const diagnostics = [];
|
|
67
|
+
const collections = new Set(descriptor.properties.filter((property)=>property.valueType === PropertyValueType.Collection).map((property)=>property.path));
|
|
68
|
+
if (designMode.itemsPath !== undefined && !collections.has(designMode.itemsPath)) {
|
|
69
|
+
diagnostics.push(invalidDesignMode(component, `'${component}' names '${designMode.itemsPath}' as its design-mode items, which is not one of its Collection properties`));
|
|
70
|
+
}
|
|
71
|
+
const seenAdd = new Set();
|
|
72
|
+
for (const action of designMode.addActions){
|
|
73
|
+
if (seenAdd.has(action.id)) diagnostics.push(invalidDesignMode(component, `'${component}' declares the design-mode add action '${action.id}' more than once`));
|
|
74
|
+
seenAdd.add(action.id);
|
|
75
|
+
if (action.collectionPath !== undefined && !collections.has(action.collectionPath)) {
|
|
76
|
+
diagnostics.push(invalidDesignMode(component, `the design-mode add action '${action.id}' of '${component}' adds to '${action.collectionPath}', which is not one of its Collection properties`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const seenItem = new Set();
|
|
80
|
+
for (const action of designMode.itemToolbar){
|
|
81
|
+
if (seenItem.has(action.id)) diagnostics.push(invalidDesignMode(component, `'${component}' declares the design-mode item action '${action.id}' more than once`));
|
|
82
|
+
seenItem.add(action.id);
|
|
83
|
+
}
|
|
84
|
+
return diagnostics;
|
|
85
|
+
}
|
|
86
|
+
function validateEditorOptions(component, properties, parent) {
|
|
87
|
+
const diagnostics = [];
|
|
88
|
+
const invalid = (path, message)=>({
|
|
89
|
+
code: DiagnosticCode.PropertyEditorOptionsInvalid,
|
|
90
|
+
severity: DiagnosticSeverity.Error,
|
|
91
|
+
component,
|
|
92
|
+
path,
|
|
93
|
+
message: `'${component}' property '${path}' ${message}`
|
|
94
|
+
});
|
|
95
|
+
for (const property of properties){
|
|
96
|
+
const path = `${parent}${property.path}`;
|
|
97
|
+
const options = property.editorOptions;
|
|
98
|
+
if (property.editorKind === PropertyEditorKind.Reference && !options?.reference?.target) {
|
|
99
|
+
diagnostics.push(invalid(path, "uses the 'reference' editor without saying what it references (editorOptions.reference.target)"));
|
|
100
|
+
}
|
|
101
|
+
if (options?.step !== undefined && !(options.step > 0)) {
|
|
102
|
+
diagnostics.push(invalid(path, 'declares a step that is not greater than zero'));
|
|
103
|
+
}
|
|
104
|
+
if (options?.kinds !== undefined && options.kinds.length === 0) {
|
|
105
|
+
diagnostics.push(invalid(path, 'declares an empty list of kinds, which would offer nothing'));
|
|
106
|
+
}
|
|
107
|
+
if (property.item) diagnostics.push(...validateEditorOptions(component, property.item.properties, `${path}[].`));
|
|
108
|
+
if (property.properties) diagnostics.push(...validateEditorOptions(component, property.properties, `${path}.`));
|
|
109
|
+
}
|
|
110
|
+
return diagnostics;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { validateComponentDescriptors };
|
|
114
|
+
//# sourceMappingURL=validateComponentDescriptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateComponentDescriptors.js","sources":["../../../descriptors/validateComponentDescriptors.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 {\n ComponentDescriptor, ComponentDesignModeDescriptor, DiagnosticCode, DiagnosticSeverity, PropertyDescriptor, PropertyEditorKind, PropertyValueType,\n SceneDiagnostic, componentCategories,\n} from '@cratis/scene.model';\n\n/**\n * Checks the component metadata a package ships - what a picker and a designer read without loading a component.\n *\n * - **CMP1** `componentCategoryMissing` (error): a registered component has no descriptor, or its descriptor declares no category.\n * - `componentCategoryUnknown` (warning): the category is not one of the model's; a package may add its own, so this is a\n * nudge towards the shared vocabulary, not a refusal.\n * - `componentDesignModeInvalid` (error): the design-mode descriptor names an items or collection path that is not a `Collection`\n * property of the component, or repeats an action id.\n * - `propertyEditorOptionsInvalid` (error): an editor's parameters cannot work - a `reference` editor that does not say what it\n * references, a step that is not positive, an empty list of slice kinds.\n *\n * `registered` is the bare or package-qualified names of the components the package registers; when given, each must be described.\n * The result is in a stable order: registered components first (in the order given), then each descriptor's findings in its own order.\n */\nexport function validateComponentDescriptors(\n descriptors: readonly ComponentDescriptor[],\n registered?: readonly string[],\n knownCategories: readonly string[] = componentCategories\n): SceneDiagnostic[] {\n const diagnostics: SceneDiagnostic[] = [];\n const described = new Map(descriptors.map(descriptor => [descriptor.component, descriptor]));\n\n for (const component of registered ?? []) {\n if (!described.has(component)) {\n diagnostics.push(missingCategory(component, `'${component}' is registered but has no descriptor, so it declares no category`));\n }\n }\n\n for (const descriptor of descriptors) {\n const { component } = descriptor;\n\n if (descriptor.category === undefined || descriptor.category.trim().length === 0) {\n diagnostics.push(missingCategory(component, `'${component}' declares no category`));\n } else if (!knownCategories.includes(descriptor.category)) {\n diagnostics.push({\n code: DiagnosticCode.ComponentCategoryUnknown, severity: DiagnosticSeverity.Warning, component,\n message: `'${component}' declares the category '${descriptor.category}', which is not one of ${knownCategories.join(', ')}`,\n });\n }\n\n if (descriptor.designMode) {\n diagnostics.push(...validateDesignMode(descriptor, descriptor.designMode));\n }\n\n diagnostics.push(...validateEditorOptions(component, descriptor.properties, ''));\n }\n\n return diagnostics;\n}\n\nfunction missingCategory(component: string, message: string): SceneDiagnostic {\n return { code: DiagnosticCode.ComponentCategoryMissing, severity: DiagnosticSeverity.Error, component, message };\n}\n\nfunction invalidDesignMode(component: string, message: string): SceneDiagnostic {\n return { code: DiagnosticCode.ComponentDesignModeInvalid, severity: DiagnosticSeverity.Error, component, message };\n}\n\nfunction validateDesignMode(descriptor: ComponentDescriptor, designMode: ComponentDesignModeDescriptor): SceneDiagnostic[] {\n const { component } = descriptor;\n const diagnostics: SceneDiagnostic[] = [];\n const collections = new Set(descriptor.properties.filter(property => property.valueType === PropertyValueType.Collection).map(property => property.path));\n\n if (designMode.itemsPath !== undefined && !collections.has(designMode.itemsPath)) {\n diagnostics.push(invalidDesignMode(component, `'${component}' names '${designMode.itemsPath}' as its design-mode items, which is not one of its Collection properties`));\n }\n\n const seenAdd = new Set<string>();\n for (const action of designMode.addActions) {\n if (seenAdd.has(action.id)) diagnostics.push(invalidDesignMode(component, `'${component}' declares the design-mode add action '${action.id}' more than once`));\n seenAdd.add(action.id);\n\n if (action.collectionPath !== undefined && !collections.has(action.collectionPath)) {\n diagnostics.push(invalidDesignMode(component, `the design-mode add action '${action.id}' of '${component}' adds to '${action.collectionPath}', which is not one of its Collection properties`));\n }\n }\n\n const seenItem = new Set<string>();\n for (const action of designMode.itemToolbar) {\n if (seenItem.has(action.id)) diagnostics.push(invalidDesignMode(component, `'${component}' declares the design-mode item action '${action.id}' more than once`));\n seenItem.add(action.id);\n }\n\n return diagnostics;\n}\n\nfunction validateEditorOptions(component: string, properties: readonly PropertyDescriptor[], parent: string): SceneDiagnostic[] {\n const diagnostics: SceneDiagnostic[] = [];\n const invalid = (path: string, message: string): SceneDiagnostic => ({\n code: DiagnosticCode.PropertyEditorOptionsInvalid, severity: DiagnosticSeverity.Error, component, path, message: `'${component}' property '${path}' ${message}`,\n });\n\n for (const property of properties) {\n const path = `${parent}${property.path}`;\n const options = property.editorOptions;\n\n if (property.editorKind === PropertyEditorKind.Reference && !options?.reference?.target) {\n diagnostics.push(invalid(path, \"uses the 'reference' editor without saying what it references (editorOptions.reference.target)\"));\n }\n\n if (options?.step !== undefined && !(options.step > 0)) {\n diagnostics.push(invalid(path, 'declares a step that is not greater than zero'));\n }\n\n if (options?.kinds !== undefined && options.kinds.length === 0) {\n diagnostics.push(invalid(path, 'declares an empty list of kinds, which would offer nothing'));\n }\n\n if (property.item) diagnostics.push(...validateEditorOptions(component, property.item.properties, `${path}[].`));\n if (property.properties) diagnostics.push(...validateEditorOptions(component, property.properties, `${path}.`));\n }\n\n return diagnostics;\n}\n"],"names":["validateComponentDescriptors","descriptors","registered","knownCategories","componentCategories","diagnostics","described","Map","map","descriptor","component","has","push","missingCategory","category","undefined","trim","length","includes","code","DiagnosticCode","ComponentCategoryUnknown","severity","DiagnosticSeverity","Warning","message","join","designMode","validateDesignMode","validateEditorOptions","properties","ComponentCategoryMissing","Error","invalidDesignMode","ComponentDesignModeInvalid","collections","Set","filter","property","valueType","PropertyValueType","Collection","path","itemsPath","seenAdd","action","addActions","id","add","collectionPath","seenItem","itemToolbar","parent","invalid","PropertyEditorOptionsInvalid","options","editorOptions","editorKind","PropertyEditorKind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,CAAQO,IAAI,GAAG,CAAA,CAAA,EAAI;YACpDzD,WAAAA,CAAYO,IAAI,CAACyC,OAAAA,CAAQX,IAAAA,EAAM,+CAAA,CAAA,CAAA;AACnC,QAAA;QAEA,IAAIa,OAAAA,EAASQ,UAAUhD,SAAAA,IAAawC,OAAAA,CAAQQ,KAAK,CAAC9C,MAAM,KAAK,CAAA,EAAG;YAC5DZ,WAAAA,CAAYO,IAAI,CAACyC,OAAAA,CAAQX,IAAAA,EAAM,4DAAA,CAAA,CAAA;AACnC,QAAA;AAEA,QAAA,IAAIJ,SAAS0B,IAAI,EAAE3D,WAAAA,CAAYO,IAAI,IAAIiB,qBAAAA,CAAsBnB,SAAAA,EAAW4B,QAAAA,CAAS0B,IAAI,CAAClC,UAAU,EAAE,CAAA,EAAGY,IAAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAC9G,QAAA,IAAIJ,QAAAA,CAASR,UAAU,EAAEzB,WAAAA,CAAYO,IAAI,CAAA,GAAIiB,qBAAAA,CAAsBnB,SAAAA,EAAW4B,QAAAA,CAASR,UAAU,EAAE,CAAA,EAAGY,IAAAA,CAAK,CAAC,CAAC,CAAA,CAAA;AACjH,IAAA;IAEA,OAAOrC,WAAAA;AACX;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './panelKind';
|
|
|
16
16
|
export * from './flowNodeKind';
|
|
17
17
|
export * from './ComponentResolution';
|
|
18
18
|
export * from './icons';
|
|
19
|
+
export * from './descriptors';
|
|
19
20
|
export * from './resolveComponentName';
|
|
20
21
|
export * from './computeSizeClass';
|
|
21
22
|
export * from './evaluateFlowArrangement';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc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c,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -25,6 +25,10 @@ export { resolveIconLibraries } from './icons/resolveIconLibraries.js';
|
|
|
25
25
|
export { referencesOfEntry } from './icons/EffectiveIconEntry.js';
|
|
26
26
|
export { EffectiveIconCatalog } from './icons/EffectiveIconCatalog.js';
|
|
27
27
|
export { analyzeIconImpact } from './icons/analyzeIconImpact.js';
|
|
28
|
+
export { validateComponentDescriptors } from './descriptors/validateComponentDescriptors.js';
|
|
29
|
+
export { componentBadge } from './descriptors/componentBadge.js';
|
|
30
|
+
export { matchComponentQuery } from './descriptors/matchComponentQuery.js';
|
|
31
|
+
export { frequentlyUsedLimit, rankFrequentlyUsedComponents } from './descriptors/rankFrequentlyUsedComponents.js';
|
|
28
32
|
export { corePackage, effectivePackages, resolveComponentName } from './resolveComponentName.js';
|
|
29
33
|
export { computeSizeClass, defaultHeightBreakpoint, defaultWidthBreakpoint } from './computeSizeClass.js';
|
|
30
34
|
export { evaluateFlowArrangement } from './evaluateFlowArrangement.js';
|
|
@@ -39,9 +43,12 @@ export { availablePackagesFor, baseComponentLibraries, componentsForPackages, pa
|
|
|
39
43
|
export { isScreenTemplateResolutionValid, resolveScreenTemplates } from './resolveScreenTemplates.js';
|
|
40
44
|
export { filterApplicableScreenTemplates, validateDialogTemplateApplicability, validateLayoutApplicability, validateScreenTemplateApplicability } from './templateApplicability.js';
|
|
41
45
|
export { TemplateCatalogKind } from './templates/TemplateCatalogKind.js';
|
|
46
|
+
export { TemplateReferenceStatus } from './templates/TemplateReferenceResolution.js';
|
|
47
|
+
export { applicableTemplates, validateDialogTemplateForTarget, validateLayoutForTarget, validateScreenTemplateForTarget } from './templates/applicableTemplates.js';
|
|
42
48
|
export { describeTemplateCatalog } from './templates/describeTemplateCatalog.js';
|
|
49
|
+
export { resolveTemplateReference } from './templates/resolveTemplateReference.js';
|
|
43
50
|
export { isAbsoluteHttpsUrl, isSpdxExpression } from './templates/templateMetadataRules.js';
|
|
44
|
-
export { validateTemplateMetadata } from './templates/validateTemplateMetadata.js';
|
|
51
|
+
export { templateCategoryMissingCode, validateTemplateCategory, validateTemplateMetadata } from './templates/validateTemplateMetadata.js';
|
|
45
52
|
export { buildStarterProfile } from './buildStarterProfile.js';
|
|
46
53
|
export { incompatibleStarterThemes } from './incompatibleStarterThemes.js';
|
|
47
54
|
export { InteractionStop, runActions, runBindings } from './runActions.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { DialogTemplate, Layout, ScreenTemplate, TemplateScope } from '@cratis/scene.model';
|
|
2
|
-
type TemplateContainer = Pick<Layout, 'name' | 'slots'>;
|
|
2
|
+
export type TemplateContainer = Pick<Layout, 'name' | 'slots'>;
|
|
3
3
|
export declare function validateLayoutApplicability(layout: Layout | undefined, scope: TemplateScope): string[];
|
|
4
4
|
export declare function validateScreenTemplateApplicability(template: ScreenTemplate | undefined, scope: TemplateScope, container?: TemplateContainer): string[];
|
|
5
5
|
export declare function validateDialogTemplateApplicability(template: DialogTemplate | undefined, scope: TemplateScope): string[];
|
|
6
6
|
export declare function filterApplicableScreenTemplates(templates: readonly ScreenTemplate[], scope: TemplateScope, container?: TemplateContainer): ScreenTemplate[];
|
|
7
|
-
export {};
|
|
8
7
|
//# sourceMappingURL=templateApplicability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateApplicability.d.ts","sourceRoot":"","sources":["../../templateApplicability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAoB,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"templateApplicability.d.ts","sourceRoot":"","sources":["../../templateApplicability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAoB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI9G,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;AAG/D,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAEtG;AAMD,wBAAgB,mCAAmC,CAC/C,QAAQ,EAAE,cAAc,GAAG,SAAS,EACpC,KAAK,EAAE,aAAa,EACpB,SAAS,CAAC,EAAE,iBAAiB,GAC9B,MAAM,EAAE,CAYV;AAGD,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAExH;AAGD,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,SAAS,cAAc,EAAE,EACpC,KAAK,EAAE,aAAa,EACpB,SAAS,CAAC,EAAE,iBAAiB,GAC9B,cAAc,EAAE,CAElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateApplicability.js","sources":["../../templateApplicability.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 { DialogTemplate, Layout, ScreenTemplate, TemplateMetadata, TemplateScope } from '@cratis/scene.model';\n\ntype TemplateKind = 'Layout' | 'ScreenTemplate' | 'DialogTemplate';\
|
|
1
|
+
{"version":3,"file":"templateApplicability.js","sources":["../../templateApplicability.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 { DialogTemplate, Layout, ScreenTemplate, TemplateMetadata, TemplateScope } from '@cratis/scene.model';\n\ntype TemplateKind = 'Layout' | 'ScreenTemplate' | 'DialogTemplate';\n/** The containing layout or screen template against which a fitsSlot selection is checked. */\nexport type TemplateContainer = Pick<Layout, 'name' | 'slots'>;\n\n/** Validates application-shell selection without introducing a competing shell model. */\nexport function validateLayoutApplicability(layout: Layout | undefined, scope: TemplateScope): string[] {\n return layout ? validateRole(layout.name, 'Layout', layout.metadata, scope) : [];\n}\n\n/**\n * Validates selection at any depth of the application hierarchy, including qualified fitsSlot names.\n * Undefined represents outlet-only composition and is valid. Invalid author input is never rewritten.\n */\nexport function validateScreenTemplateApplicability(\n template: ScreenTemplate | undefined,\n scope: TemplateScope,\n container?: TemplateContainer,\n): string[] {\n if (!template) return [];\n const problems = validateRole(template.name, 'ScreenTemplate', template.metadata, scope);\n if (template.fitsSlot !== undefined) {\n const separator = template.fitsSlot.lastIndexOf('.');\n const qualifier = separator < 0 ? undefined : template.fitsSlot.slice(0, separator);\n const slot = separator < 0 ? template.fitsSlot : template.fitsSlot.slice(separator + 1);\n if (!container || (qualifier !== undefined && qualifier !== container.name) || !container.slots.some(candidate => candidate.name === slot)) {\n problems.push(`Template '${template.name}' does not fit slot '${template.fitsSlot}' on '${container?.name ?? '(no container)'}'`);\n }\n }\n return problems;\n}\n\n/** Validates an overlay template separately from slot-based screen composition. */\nexport function validateDialogTemplateApplicability(template: DialogTemplate | undefined, scope: TemplateScope): string[] {\n return template ? validateRole(template.name, 'DialogTemplate', template.metadata, scope) : [];\n}\n\n/** The shared picker predicate uses exactly the same rules as validation on apply. */\nexport function filterApplicableScreenTemplates(\n templates: readonly ScreenTemplate[],\n scope: TemplateScope,\n container?: TemplateContainer,\n): ScreenTemplate[] {\n return templates.filter(template => validateScreenTemplateApplicability(template, scope, container).length === 0);\n}\n\nfunction validateRole(name: string, kind: TemplateKind, metadata: TemplateMetadata | undefined, scope: TemplateScope): string[] {\n const problems: string[] = [];\n if (!Object.values(TemplateScope).includes(scope)) {\n problems.push(`Template '${name}' has unknown target scope '${scope}'`);\n } else if ((kind === 'Layout') !== (scope === TemplateScope.Application)) {\n problems.push(`Template '${name}' of kind '${kind}' cannot be applied at scope '${scope}'`);\n }\n if (metadata?.type === 'ApplicationShell' && kind !== 'Layout') {\n problems.push(`Template '${name}' of type 'ApplicationShell' must be a Layout`);\n }\n if (metadata?.type === 'Dialog' && kind !== 'DialogTemplate') {\n problems.push(`Template '${name}' of type 'Dialog' must be a DialogTemplate`);\n }\n if (kind === 'Layout' && ['Workspace', 'List', 'Detail', 'Form'].includes(metadata?.type ?? '')) {\n problems.push(`Template '${name}' of type '${metadata?.type}' must not be a Layout`);\n }\n for (const declaredScope of metadata?.scopes ?? []) {\n if (!Object.values(TemplateScope).includes(declaredScope)) {\n problems.push(`Template '${name}' declares unknown scope '${declaredScope}'`);\n }\n }\n if (metadata?.scopes !== undefined && !metadata.scopes.includes(scope)) {\n problems.push(`Template '${name}' does not declare scope '${scope}'`);\n }\n return problems;\n}\n"],"names":["validateLayoutApplicability","layout","scope","validateRole","name","metadata","validateScreenTemplateApplicability","template","container","problems","fitsSlot","undefined","separator","lastIndexOf","qualifier","slice","slot","slots","some","candidate","push","validateDialogTemplateApplicability","filterApplicableScreenTemplates","templates","filter","length","kind","Object","values","TemplateScope","includes","Application","type","declaredScope","scopes"],"mappings":";;AAAA;AACA;AAQA,0FACO,SAASA,2BAAAA,CAA4BC,MAA0B,EAAEC,KAAoB,EAAA;IACxF,OAAOD,MAAAA,GAASE,YAAAA,CAAaF,MAAAA,CAAOG,IAAI,EAAE,UAAUH,MAAAA,CAAOI,QAAQ,EAAEH,KAAAA,CAAAA,GAAS,EAAE;AACpF;AAEA;;;AAGC,IACM,SAASI,mCAAAA,CACZC,QAAoC,EACpCL,KAAoB,EACpBM,SAA6B,EAAA;IAE7B,IAAI,CAACD,QAAAA,EAAU,OAAO,EAAE;IACxB,MAAME,QAAAA,GAAWN,aAAaI,QAAAA,CAASH,IAAI,EAAE,gBAAA,EAAkBG,QAAAA,CAASF,QAAQ,EAAEH,KAAAA,CAAAA;IAClF,IAAIK,QAAAA,CAASG,QAAQ,KAAKC,SAAAA,EAAW;AACjC,QAAA,MAAMC,SAAAA,GAAYL,QAAAA,CAASG,QAAQ,CAACG,WAAW,CAAC,GAAA,CAAA;QAChD,MAAMC,SAAAA,GAAYF,YAAY,CAAA,GAAID,SAAAA,GAAYJ,SAASG,QAAQ,CAAC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AChD,QAAA,IAAI,CAACP,MAAAA,CAAOC,MAAM,CAACC,aAAAA,CAAAA,CAAeC,QAAQ,CAACG,aAAAA,CAAAA,EAAgB;YACvDxB,QAAAA,CAASW,IAAI,CAAC,CAAC,UAAU,EAAEhB,KAAK,0BAA0B,EAAE6B,aAAAA,CAAc,CAAC,CAAC,CAAA;AAChF,QAAA;AACJ,IAAA;IACA,IAAI5B,QAAAA,EAAU6B,WAAWvB,SAAAA,IAAa,CAACN,SAAS6B,MAAM,CAACJ,QAAQ,CAAC5B,KAAAA,CAAAA,EAAQ;QACpEO,QAAAA,CAASW,IAAI,CAAC,CAAC,UAAU,EAAEhB,KAAK,0BAA0B,EAAEF,KAAAA,CAAM,CAAC,CAAC,CAAA;AACxE,IAAA;IACA,OAAOO,QAAAA;AACX;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TemplateMetadata, TemplateReference } from '@cratis/scene.model';
|
|
2
|
+
import { TemplateCatalogKind } from './TemplateCatalogKind';
|
|
3
|
+
export interface ApplicableTemplate {
|
|
4
|
+
package: string;
|
|
5
|
+
packageVersion: string;
|
|
6
|
+
kind: TemplateCatalogKind;
|
|
7
|
+
name: string;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
metadata?: TemplateMetadata;
|
|
11
|
+
reference: TemplateReference;
|
|
12
|
+
}
|
|
13
|
+
export interface ApplicableTemplateGroup {
|
|
14
|
+
category?: string;
|
|
15
|
+
templates: ApplicableTemplate[];
|
|
16
|
+
}
|
|
17
|
+
export interface ApplicableBlueprint {
|
|
18
|
+
blueprint: string;
|
|
19
|
+
version: string;
|
|
20
|
+
displayName?: string;
|
|
21
|
+
categories: ApplicableTemplateGroup[];
|
|
22
|
+
}
|
|
23
|
+
export interface ApplicableTemplateSet {
|
|
24
|
+
own: ApplicableTemplateGroup[];
|
|
25
|
+
blueprints: ApplicableBlueprint[];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ApplicableTemplateSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicableTemplateSet.d.ts","sourceRoot":"","sources":["../../../templates/ApplicableTemplateSet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IAE/B,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,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAG5B,SAAS,EAAE,iBAAiB,CAAC;CAChC;AAGD,MAAM,WAAW,uBAAuB;IAEpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAGD,MAAM,WAAW,mBAAmB;IAEhC,SAAS,EAAE,MAAM,CAAC;IAGlB,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,UAAU,EAAE,uBAAuB,EAAE,CAAC;CACzC;AAGD,MAAM,WAAW,qBAAqB;IAElC,GAAG,EAAE,uBAAuB,EAAE,CAAC;IAG/B,UAAU,EAAE,mBAAmB,EAAE,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicableTemplateSet.js","sourceRoot":"","sources":["../../../templates/ApplicableTemplateSet.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TemplateAttribution, TemplateCompatibility, TemplateScope } from '@cratis/scene.model';
|
|
1
|
+
import { TemplateAttribution, TemplateCompatibility, TemplateScope, SliceKind } from '@cratis/scene.model';
|
|
2
2
|
import { TemplateCatalogKind } from './TemplateCatalogKind';
|
|
3
3
|
export interface TemplateCatalogEntry {
|
|
4
4
|
package: string;
|
|
@@ -10,11 +10,13 @@ export interface TemplateCatalogEntry {
|
|
|
10
10
|
type?: string;
|
|
11
11
|
category?: string;
|
|
12
12
|
scopes?: TemplateScope[];
|
|
13
|
+
sliceKinds?: SliceKind[];
|
|
13
14
|
compatibility?: TemplateCompatibility;
|
|
14
15
|
attribution?: TemplateAttribution;
|
|
15
16
|
license?: string;
|
|
16
17
|
licenseUrl?: string;
|
|
17
18
|
compatible: boolean;
|
|
18
19
|
problems: string[];
|
|
20
|
+
warnings: string[];
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=TemplateCatalogEntry.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"TemplateCatalogEntry.d.ts","sourceRoot":"","sources":["../../../templates/TemplateCatalogEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC3G,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,UAAU,CAAC,EAAE,SAAS,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;IAGnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateLibrary.d.ts","sourceRoot":"","sources":["../../../templates/TemplateLibrary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD,MAAM,WAAW,eAAe;IAE5B,GAAG,CAAC,EAAE,cAAc,CAAC;IAGrB,UAAU,EAAE,cAAc,EAAE,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateLibrary.js","sourceRoot":"","sources":["../../../templates/TemplateLibrary.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateCatalogKind } from './TemplateCatalogKind';
|
|
2
|
+
export declare enum TemplateReferenceStatus {
|
|
3
|
+
Resolved = "Resolved",
|
|
4
|
+
Malformed = "Malformed",
|
|
5
|
+
UnknownBlueprint = "UnknownBlueprint",
|
|
6
|
+
VersionNotSatisfied = "VersionNotSatisfied",
|
|
7
|
+
UnknownTemplate = "UnknownTemplate"
|
|
8
|
+
}
|
|
9
|
+
export interface TemplateReferenceResolution {
|
|
10
|
+
status: TemplateReferenceStatus;
|
|
11
|
+
package?: string;
|
|
12
|
+
packageVersion?: string;
|
|
13
|
+
kind?: TemplateCatalogKind;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=TemplateReferenceResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateReferenceResolution.d.ts","sourceRoot":"","sources":["../../../templates/TemplateReferenceResolution.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,oBAAY,uBAAuB;IAE/B,QAAQ,aAAa;IAErB,SAAS,cAAc;IAEvB,gBAAgB,qBAAqB;IAErC,mBAAmB,wBAAwB;IAE3C,eAAe,oBAAoB;CACtC;AAGD,MAAM,WAAW,2BAA2B;IACxC,MAAM,EAAE,uBAAuB,CAAC;IAGhC,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAG3B,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -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
|
+
/** The outcome of resolving a template reference against a template library. */ var TemplateReferenceStatus = /*#__PURE__*/ function(TemplateReferenceStatus) {
|
|
4
|
+
/** The reference names a template that exists, at a version the reference accepts. */ TemplateReferenceStatus["Resolved"] = "Resolved";
|
|
5
|
+
/** The reference is not well formed: an own reference carrying a blueprint or version, a blueprint reference without a blueprint, or an invalid version range. */ TemplateReferenceStatus["Malformed"] = "Malformed";
|
|
6
|
+
/** No blueprint package of that name is available. */ TemplateReferenceStatus["UnknownBlueprint"] = "UnknownBlueprint";
|
|
7
|
+
/** The installed version of the blueprint is outside the reference's version range: the blueprint has drifted from what was chosen. */ TemplateReferenceStatus["VersionNotSatisfied"] = "VersionNotSatisfied";
|
|
8
|
+
/** The blueprint or workspace has no template of that name. */ TemplateReferenceStatus["UnknownTemplate"] = "UnknownTemplate";
|
|
9
|
+
return TemplateReferenceStatus;
|
|
10
|
+
}({});
|
|
11
|
+
|
|
12
|
+
export { TemplateReferenceStatus };
|
|
13
|
+
//# sourceMappingURL=TemplateReferenceResolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateReferenceResolution.js","sources":["../../../templates/TemplateReferenceResolution.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 { TemplateCatalogKind } from './TemplateCatalogKind';\n\n/** The outcome of resolving a template reference against a template library. */\nexport enum TemplateReferenceStatus {\n /** The reference names a template that exists, at a version the reference accepts. */\n Resolved = 'Resolved',\n /** The reference is not well formed: an own reference carrying a blueprint or version, a blueprint reference without a blueprint, or an invalid version range. */\n Malformed = 'Malformed',\n /** No blueprint package of that name is available. */\n UnknownBlueprint = 'UnknownBlueprint',\n /** The installed version of the blueprint is outside the reference's version range: the blueprint has drifted from what was chosen. */\n VersionNotSatisfied = 'VersionNotSatisfied',\n /** The blueprint or workspace has no template of that name. */\n UnknownTemplate = 'UnknownTemplate',\n}\n\n/** The result of resolving a template reference. */\nexport interface TemplateReferenceResolution {\n status: TemplateReferenceStatus;\n\n /** The package providing the template, when it was found or its blueprint was. */\n package?: string;\n\n /** The installed version of that package. */\n packageVersion?: string;\n\n /** Which kind of template was found, when the status is Resolved. */\n kind?: TemplateCatalogKind;\n\n /** A diagnostic when the reference did not resolve. */\n message?: string;\n}\n"],"names":["TemplateReferenceStatus"],"mappings":"AAAA;AACA;AAIA,iFACO,IAAKA,uBAAAA,iBAAAA,SAAAA,uBAAAA,EAAAA;2FAC4E,uBAAA,CAAA,UAAA,CAAA,GAAA,UAAA;uKAE4E,uBAAA,CAAA,WAAA,CAAA,GAAA,WAAA;2DAE5G,uBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;4IAEiF,uBAAA,CAAA,qBAAA,CAAA,GAAA,qBAAA;oEAExE,uBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA;AATrDA,IAAAA,OAAAA,uBAAAA;AAWX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateScope, SliceKind } from '@cratis/scene.model';
|
|
2
|
+
import { TemplateContainer } from '../templateApplicability';
|
|
3
|
+
export interface TemplateTarget {
|
|
4
|
+
scope: TemplateScope;
|
|
5
|
+
sliceKind?: SliceKind;
|
|
6
|
+
container?: TemplateContainer;
|
|
7
|
+
chain?: string[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TemplateTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateTarget.d.ts","sourceRoot":"","sources":["../../../templates/TemplateTarget.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,MAAM,WAAW,cAAc;IAE3B,KAAK,EAAE,aAAa,CAAC;IAGrB,SAAS,CAAC,EAAE,SAAS,CAAC;IAGtB,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAM9B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateTarget.js","sourceRoot":"","sources":["../../../templates/TemplateTarget.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DialogTemplate, Layout, ScreenTemplate } from '@cratis/scene.model';
|
|
2
|
+
import { ApplicableTemplateSet } from './ApplicableTemplateSet';
|
|
3
|
+
import { TemplateLibrary } from './TemplateLibrary';
|
|
4
|
+
import { TemplateTarget } from './TemplateTarget';
|
|
5
|
+
export declare function applicableTemplates(library: TemplateLibrary, target: TemplateTarget): ApplicableTemplateSet;
|
|
6
|
+
export declare function validateLayoutForTarget(layout: Layout, target: TemplateTarget): string[];
|
|
7
|
+
export declare function validateScreenTemplateForTarget(template: ScreenTemplate, target: TemplateTarget): string[];
|
|
8
|
+
export declare function validateDialogTemplateForTarget(template: DialogTemplate, target: TemplateTarget): string[];
|
|
9
|
+
//# sourceMappingURL=applicableTemplates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applicableTemplates.d.ts","sourceRoot":"","sources":["../../../templates/applicableTemplates.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAA0F,MAAM,qBAAqB,CAAC;AAGrK,OAAO,EAAoE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAElI,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBlD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,GAAG,qBAAqB,CAU3G;AAGD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAExF;AAGD,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAuB1G;AAGD,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAE1G"}
|