@cratis/scene.engine 4.27.0 → 4.28.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 +15 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/structure/ApplicationStructureIndex.js +10 -0
- package/dist/cjs/structure/ApplicationStructureIndex.js.map +1 -1
- package/dist/cjs/toolbar/SliceDialogSource.js +14 -0
- package/dist/cjs/toolbar/SliceDialogSource.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarDiagnosticCode.js +16 -0
- package/dist/cjs/toolbar/ToolbarDiagnosticCode.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarDiagnosticSeverity.js +14 -0
- package/dist/cjs/toolbar/ToolbarDiagnosticSeverity.js.map +1 -0
- package/dist/cjs/toolbar/sliceDialogFor.js +38 -0
- package/dist/cjs/toolbar/sliceDialogFor.js.map +1 -0
- package/dist/cjs/toolbar/toolbarButtons.js +93 -0
- package/dist/cjs/toolbar/toolbarButtons.js.map +1 -0
- package/dist/cjs/toolbar/validateToolbarButtons.js +59 -0
- package/dist/cjs/toolbar/validateToolbarButtons.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 +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/structure/ApplicationStructureIndex.d.ts +1 -0
- package/dist/esm/structure/ApplicationStructureIndex.d.ts.map +1 -1
- package/dist/esm/structure/ApplicationStructureIndex.js +10 -0
- package/dist/esm/structure/ApplicationStructureIndex.js.map +1 -1
- package/dist/esm/toolbar/ResolvedToolbarButton.d.ts +13 -0
- package/dist/esm/toolbar/ResolvedToolbarButton.d.ts.map +1 -0
- package/dist/esm/toolbar/ResolvedToolbarButton.js +2 -0
- package/dist/esm/toolbar/ResolvedToolbarButton.js.map +1 -0
- package/dist/esm/toolbar/SliceDialog.d.ts +8 -0
- package/dist/esm/toolbar/SliceDialog.d.ts.map +1 -0
- package/dist/esm/toolbar/SliceDialog.js +2 -0
- package/dist/esm/toolbar/SliceDialog.js.map +1 -0
- package/dist/esm/toolbar/SliceDialogSource.d.ts +5 -0
- package/dist/esm/toolbar/SliceDialogSource.d.ts.map +1 -0
- package/dist/esm/toolbar/SliceDialogSource.js +12 -0
- package/dist/esm/toolbar/SliceDialogSource.js.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnostic.d.ts +9 -0
- package/dist/esm/toolbar/ToolbarDiagnostic.d.ts.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnostic.js +2 -0
- package/dist/esm/toolbar/ToolbarDiagnostic.js.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnosticCode.d.ts +6 -0
- package/dist/esm/toolbar/ToolbarDiagnosticCode.d.ts.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnosticCode.js +14 -0
- package/dist/esm/toolbar/ToolbarDiagnosticCode.js.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnosticSeverity.d.ts +5 -0
- package/dist/esm/toolbar/ToolbarDiagnosticSeverity.d.ts.map +1 -0
- package/dist/esm/toolbar/ToolbarDiagnosticSeverity.js +12 -0
- package/dist/esm/toolbar/ToolbarDiagnosticSeverity.js.map +1 -0
- package/dist/esm/toolbar/index.d.ts +10 -0
- package/dist/esm/toolbar/index.d.ts.map +1 -0
- package/dist/esm/toolbar/index.js +10 -0
- package/dist/esm/toolbar/index.js.map +1 -0
- package/dist/esm/toolbar/sliceDialogFor.d.ts +5 -0
- package/dist/esm/toolbar/sliceDialogFor.d.ts.map +1 -0
- package/dist/esm/toolbar/sliceDialogFor.js +35 -0
- package/dist/esm/toolbar/sliceDialogFor.js.map +1 -0
- package/dist/esm/toolbar/toolbarButtons.d.ts +10 -0
- package/dist/esm/toolbar/toolbarButtons.d.ts.map +1 -0
- package/dist/esm/toolbar/toolbarButtons.js +89 -0
- package/dist/esm/toolbar/toolbarButtons.js.map +1 -0
- package/dist/esm/toolbar/validateToolbarButtons.d.ts +5 -0
- package/dist/esm/toolbar/validateToolbarButtons.d.ts.map +1 -0
- package/dist/esm/toolbar/validateToolbarButtons.js +57 -0
- package/dist/esm/toolbar/validateToolbarButtons.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/package.json +3 -3
- package/structure/ApplicationStructureIndex.ts +11 -0
- package/toolbar/ResolvedToolbarButton.ts +34 -0
- package/toolbar/SliceDialog.ts +21 -0
- package/toolbar/SliceDialogSource.ts +13 -0
- package/toolbar/ToolbarDiagnostic.ts +22 -0
- package/toolbar/ToolbarDiagnosticCode.ts +17 -0
- package/toolbar/ToolbarDiagnosticSeverity.ts +13 -0
- package/toolbar/index.ts +12 -0
- package/toolbar/sliceDialogFor.ts +31 -0
- package/toolbar/toolbarButtons.ts +83 -0
- package/toolbar/validateToolbarButtons.ts +61 -0
package/dist/cjs/index.js
CHANGED
|
@@ -99,6 +99,12 @@ var describeSampleDataCatalog = require('./sampleData/describeSampleDataCatalog.
|
|
|
99
99
|
var findSampleRowLiterals = require('./sampleData/findSampleRowLiterals.js');
|
|
100
100
|
var StructureDiagnosticCode = require('./structure/StructureDiagnosticCode.js');
|
|
101
101
|
var ApplicationStructureIndex = require('./structure/ApplicationStructureIndex.js');
|
|
102
|
+
var ToolbarDiagnosticCode = require('./toolbar/ToolbarDiagnosticCode.js');
|
|
103
|
+
var ToolbarDiagnosticSeverity = require('./toolbar/ToolbarDiagnosticSeverity.js');
|
|
104
|
+
var SliceDialogSource = require('./toolbar/SliceDialogSource.js');
|
|
105
|
+
var sliceDialogFor = require('./toolbar/sliceDialogFor.js');
|
|
106
|
+
var toolbarButtons = require('./toolbar/toolbarButtons.js');
|
|
107
|
+
var validateToolbarButtons = require('./toolbar/validateToolbarButtons.js');
|
|
102
108
|
|
|
103
109
|
|
|
104
110
|
|
|
@@ -297,4 +303,13 @@ exports.findSampleRowLiterals = findSampleRowLiterals.findSampleRowLiterals;
|
|
|
297
303
|
exports.findTemplateSampleRowLiterals = findSampleRowLiterals.findTemplateSampleRowLiterals;
|
|
298
304
|
exports.StructureDiagnosticCode = StructureDiagnosticCode.StructureDiagnosticCode;
|
|
299
305
|
exports.ApplicationStructureIndex = ApplicationStructureIndex.ApplicationStructureIndex;
|
|
306
|
+
exports.ToolbarDiagnosticCode = ToolbarDiagnosticCode.ToolbarDiagnosticCode;
|
|
307
|
+
exports.ToolbarDiagnosticSeverity = ToolbarDiagnosticSeverity.ToolbarDiagnosticSeverity;
|
|
308
|
+
exports.SliceDialogSource = SliceDialogSource.SliceDialogSource;
|
|
309
|
+
exports.defaultSliceDialogTemplate = sliceDialogFor.defaultSliceDialogTemplate;
|
|
310
|
+
exports.sliceDialogFor = sliceDialogFor.sliceDialogFor;
|
|
311
|
+
exports.normalizeToolbarButton = toolbarButtons.normalizeToolbarButton;
|
|
312
|
+
exports.resolveToolbarButton = toolbarButtons.resolveToolbarButton;
|
|
313
|
+
exports.toolbarButtonFromItem = toolbarButtons.toolbarButtonFromItem;
|
|
314
|
+
exports.validateToolbarButtons = validateToolbarButtons.validateToolbarButtons;
|
|
300
315
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/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,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
3
4
|
var StructureDiagnosticCode = require('./StructureDiagnosticCode.js');
|
|
4
5
|
|
|
5
6
|
// Copyright (c) Cratis. All rights reserved.
|
|
@@ -85,6 +86,15 @@ var StructureDiagnosticCode = require('./StructureDiagnosticCode.js');
|
|
|
85
86
|
...this.featuresByName.get(name.toLowerCase()) ?? []
|
|
86
87
|
];
|
|
87
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.
|
|
91
|
+
* @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.
|
|
92
|
+
* @returns The qualified ids of the matching state change slices, in declaration order.
|
|
93
|
+
*/ findSlicesByCommand(command) {
|
|
94
|
+
return [
|
|
95
|
+
...this.slices.entries()
|
|
96
|
+
].filter(([qualified, slice])=>slice.kind === scene_model.SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command)).map(([qualified])=>qualified);
|
|
97
|
+
}
|
|
88
98
|
indexContainer(path, features, slices) {
|
|
89
99
|
const seen = new Map();
|
|
90
100
|
const featureNames = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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 { ApplicationStructure, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","path","featureNames","sliceNames","key","byName","push","slice","first","code","StructureDiagnosticCode","StructureDuplicateId","message","StructureAmbiguousName"],"mappings":";;;;AAAA;AACA;AAMA;;;;;;;AAOC,IACM,MAAMA,yBAAAA,CAAAA;;AACQC,IAAAA,OAAAA,GAAU,IAAIC,GAAAA,EAAAA;AACdC,IAAAA,QAAAA,GAAW,IAAID,GAAAA,EAAAA;AACfE,IAAAA,MAAAA,GAAS,IAAIF,GAAAA,EAAAA;AACbG,IAAAA,cAAAA,GAAiB,IAAIH,GAAAA,EAAAA;AAEtC,oEACSI,WAAAA,GAAqC,EAAE;AAEhD;;;QAIA,WAAA,CAAY,SAAwC,CAAE;aAAjCC,SAAAA,GAAAA,SAAAA;AACjB,QAAA,MAAMC,OAAO,IAAIN,GAAAA,EAAAA;AACjB,QAAA,MAAMO,QAAQ,IAAIP,GAAAA,EAAAA;AAElB,QAAA,KAAK,MAAMQ,MAAAA,IAAUH,SAAAA,CAAUN,OAAO,CAAE;YACpC,MAAMU,SAAAA,GAAYD,OAAOE,EAAE;AAC3B,YAAA,IAAI,CAAC,IAAI,CAACC,KAAK,CAACL,IAAAA,EAAMG,WAAW,QAAA,CAAA,EAAW;AAE5C,YAAA,IAAI,CAACV,OAAO,CAACa,GAAG,CAACH,SAAAA,EAAWD,MAAAA,CAAAA;AAC5B,YAAA,IAAI,CAACK,mBAAmB,CAACN,OAAO,QAAA,EAAUC,MAAAA,CAAOM,IAAI,EAAEL,SAAAA,CAAAA;YACvD,IAAI,CAACM,cAAc,CAACN,SA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ACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAACsB,GAAAA,EAAKzB,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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 { ApplicationStructure, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n /**\n * Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.\n * @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.\n * @returns The qualified ids of the matching state change slices, in declaration order.\n */\n findSlicesByCommand(command: string): string[] {\n return [...this.slices.entries()]\n .filter(([qualified, slice]) => slice.kind === SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command))\n .map(([qualified]) => qualified);\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","findSlicesByCommand","command","entries","filter","slice","SliceKind","StateChange","map","path","featureNames","sliceNames","key","byName","push","first","code","StructureDiagnosticCode","StructureDuplicateId","message","StructureAmbiguousName"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;;AAOC,I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AA,EAAID;AACR,aAAA,CAAA;AACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAAC8B,GAAAA,EAAKjC,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
* Where a slice's dialog template comes from.
|
|
7
|
+
*/ var SliceDialogSource = /*#__PURE__*/ function(SliceDialogSource) {
|
|
8
|
+
/** The slice names its own dialog template. */ SliceDialogSource["Slice"] = "slice";
|
|
9
|
+
/** The slice names none, so the default form dialog is used. */ SliceDialogSource["Default"] = "default";
|
|
10
|
+
return SliceDialogSource;
|
|
11
|
+
}({});
|
|
12
|
+
|
|
13
|
+
exports.SliceDialogSource = SliceDialogSource;
|
|
14
|
+
//# sourceMappingURL=SliceDialogSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceDialogSource.js","sources":["../../../toolbar/SliceDialogSource.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 * Where a slice's dialog template comes from.\n */\nexport enum SliceDialogSource {\n /** The slice names its own dialog template. */\n Slice = 'slice',\n\n /** The slice names none, so the default form dialog is used. */\n Default = 'default',\n}\n"],"names":["SliceDialogSource"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,iBAAAA,iBAAAA,SAAAA,iBAAAA,EAAAA;oDACqC,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAA;qEAGiB,iBAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAJtDA,IAAAA,OAAAA,iBAAAA;AAMX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
* What is wrong with a toolbar button. The values are shared with the C# engine so both report the same code for
|
|
7
|
+
* the same toolbar.
|
|
8
|
+
*/ var ToolbarDiagnosticCode = /*#__PURE__*/ function(ToolbarDiagnosticCode) {
|
|
9
|
+
/** A button invokes a slice the application structure does not have. */ ToolbarDiagnosticCode["ToolbarButtonSliceNotFound"] = "toolbarButtonSliceNotFound";
|
|
10
|
+
/** A button invokes a slice that is not a state change; state views and automations never take user input. */ ToolbarDiagnosticCode["ToolbarButtonSliceNotStateChange"] = "toolbarButtonSliceNotStateChange";
|
|
11
|
+
/** A button has no slice yet. It is allowed while designing, and flagged. */ ToolbarDiagnosticCode["ToolbarButtonSliceEmpty"] = "toolbarButtonSliceEmpty";
|
|
12
|
+
return ToolbarDiagnosticCode;
|
|
13
|
+
}({});
|
|
14
|
+
|
|
15
|
+
exports.ToolbarDiagnosticCode = ToolbarDiagnosticCode;
|
|
16
|
+
//# sourceMappingURL=ToolbarDiagnosticCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarDiagnosticCode.js","sources":["../../../toolbar/ToolbarDiagnosticCode.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 * What is wrong with a toolbar button. The values are shared with the C# engine so both report the same code for\n * the same toolbar.\n */\nexport enum ToolbarDiagnosticCode {\n /** A button invokes a slice the application structure does not have. */\n ToolbarButtonSliceNotFound = 'toolbarButtonSliceNotFound',\n\n /** A button invokes a slice that is not a state change; state views and automations never take user input. */\n ToolbarButtonSliceNotStateChange = 'toolbarButtonSliceNotStateChange',\n\n /** A button has no slice yet. It is allowed while designing, and flagged. */\n ToolbarButtonSliceEmpty = 'toolbarButtonSliceEmpty',\n}\n"],"names":["ToolbarDiagnosticCode"],"mappings":";;AAAA;AACA;AAEA;;;IAIO,IAAKA,qBAAAA,iBAAAA,SAAAA,qBAAAA,EAAAA;6EAC8D,qBAAA,CAAA,4BAAA,CAAA,GAAA,4BAAA;mHAGsC,qBAAA,CAAA,kCAAA,CAAA,GAAA,kCAAA;kFAGjC,qBAAA,CAAA,yBAAA,CAAA,GAAA,yBAAA;AAPnEA,IAAAA,OAAAA,qBAAAA;AASX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
* How serious a toolbar diagnostic is.
|
|
7
|
+
*/ var ToolbarDiagnosticSeverity = /*#__PURE__*/ function(ToolbarDiagnosticSeverity) {
|
|
8
|
+
/** The button cannot work. */ ToolbarDiagnosticSeverity["Error"] = "error";
|
|
9
|
+
/** The button is allowed but incomplete. */ ToolbarDiagnosticSeverity["Warning"] = "warning";
|
|
10
|
+
return ToolbarDiagnosticSeverity;
|
|
11
|
+
}({});
|
|
12
|
+
|
|
13
|
+
exports.ToolbarDiagnosticSeverity = ToolbarDiagnosticSeverity;
|
|
14
|
+
//# sourceMappingURL=ToolbarDiagnosticSeverity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarDiagnosticSeverity.js","sources":["../../../toolbar/ToolbarDiagnosticSeverity.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 serious a toolbar diagnostic is.\n */\nexport enum ToolbarDiagnosticSeverity {\n /** The button cannot work. */\n Error = 'error',\n\n /** The button is allowed but incomplete. */\n Warning = 'warning',\n}\n"],"names":["ToolbarDiagnosticSeverity"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,yBAAAA,iBAAAA,SAAAA,yBAAAA,EAAAA;mCACoB,yBAAA,CAAA,OAAA,CAAA,GAAA,OAAA;iDAGc,yBAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAJlCA,IAAAA,OAAAA,yBAAAA;AAMX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var SliceDialogSource = require('./SliceDialogSource.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
/** The dialog template used when a slice names none. */ const defaultSliceDialogTemplate = 'FormDialog';
|
|
9
|
+
/**
|
|
10
|
+
* Works out the task dialog a state change slice opens, once, so no host decides it again (TB4): the slice's own
|
|
11
|
+
* dialog template when it names one, else the default form dialog.
|
|
12
|
+
*
|
|
13
|
+
* The C# engine (`SliceDialogs.For`) resolves the same dialog; both are asserted against `toolbar-slice-fixtures.json`.
|
|
14
|
+
*
|
|
15
|
+
* @param index The modules, features and slices of the application.
|
|
16
|
+
* @param sliceId The slice's qualified id.
|
|
17
|
+
* @param defaultTemplate The template used when the slice names none; {@link defaultSliceDialogTemplate} when absent.
|
|
18
|
+
* @returns The dialog, or undefined when there is no such slice or it is not a state change.
|
|
19
|
+
*/ function sliceDialogFor(index, sliceId, defaultTemplate) {
|
|
20
|
+
const slice = index.findSlice(sliceId);
|
|
21
|
+
if (slice?.kind !== scene_model.SliceKind.StateChange) return undefined;
|
|
22
|
+
const command = slice.command ?? slice.id;
|
|
23
|
+
return slice.dialogTemplate ? {
|
|
24
|
+
slice: sliceId,
|
|
25
|
+
command,
|
|
26
|
+
template: slice.dialogTemplate,
|
|
27
|
+
source: SliceDialogSource.SliceDialogSource.Slice
|
|
28
|
+
} : {
|
|
29
|
+
slice: sliceId,
|
|
30
|
+
command,
|
|
31
|
+
template: defaultTemplate ?? defaultSliceDialogTemplate,
|
|
32
|
+
source: SliceDialogSource.SliceDialogSource.Default
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.defaultSliceDialogTemplate = defaultSliceDialogTemplate;
|
|
37
|
+
exports.sliceDialogFor = sliceDialogFor;
|
|
38
|
+
//# sourceMappingURL=sliceDialogFor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliceDialogFor.js","sources":["../../../toolbar/sliceDialogFor.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 { SliceKind } from '@cratis/scene.model';\nimport { ApplicationStructureIndex } from '../structure';\nimport { SliceDialog } from './SliceDialog';\nimport { SliceDialogSource } from './SliceDialogSource';\n\n/** The dialog template used when a slice names none. */\nexport const defaultSliceDialogTemplate = 'FormDialog';\n\n/**\n * Works out the task dialog a state change slice opens, once, so no host decides it again (TB4): the slice's own\n * dialog template when it names one, else the default form dialog.\n *\n * The C# engine (`SliceDialogs.For`) resolves the same dialog; both are asserted against `toolbar-slice-fixtures.json`.\n *\n * @param index The modules, features and slices of the application.\n * @param sliceId The slice's qualified id.\n * @param defaultTemplate The template used when the slice names none; {@link defaultSliceDialogTemplate} when absent.\n * @returns The dialog, or undefined when there is no such slice or it is not a state change.\n */\nexport function sliceDialogFor(index: ApplicationStructureIndex, sliceId: string, defaultTemplate?: string): SliceDialog | undefined {\n const slice = index.findSlice(sliceId);\n if (slice?.kind !== SliceKind.StateChange) return undefined;\n\n const command = slice.command ?? slice.id;\n return slice.dialogTemplate\n ? { slice: sliceId, command, template: slice.dialogTemplate, source: SliceDialogSource.Slice }\n : { slice: sliceId, command, template: defaultTemplate ?? defaultSliceDialogTemplate, source: SliceDialogSource.Default };\n}\n"],"names":["defaultSliceDialogTemplate","sliceDialogFor","index","sliceId","defaultTemplate","slice","findSlice","kind","SliceKind","StateChange","undefined","command","id","dialogTemplate","template","source","SliceDialogSource","Slice","Default"],"mappings":";;;;;AAAA;AACA;AAOA,yDACO,MAAMA,0BAAAA,GAA6B;AAE1C;;;;;;;;;;AAUC,IACM,SAASC,cAAAA,CAAeC,KAAgC,EAAEC,OAAe,EAAEC,eAAwB,EAAA;IACtG,MAAMC,KAAAA,GAAQH,KAAAA,CAAMI,SAAS,CAACH,OAAAA,CAAAA;AAC9B,IAAA,IAAIE,KAAAA,EAAOE,IAAAA,KAASC,qBAAAA,CAAUC,WAAW,EAAE,OAAOC,SAAAA;AAElD,IAAA,MAAMC,OAAAA,GAAUN,KAAAA,CAAMM,OAAO,IAAIN,MAAMO,EAAE;IACzC,OAAOP,KAAAA,CAAMQ,cAAc,GACrB;QAAER,KAAAA,EAAOF,OAAAA;AAASQ,QAAAA,OAAAA;AAASG,QAAAA,QAAAA,EAAUT,MAAMQ,cAAc;AAAEE,QAAAA,MAAAA,EAAQC,oCAAkBC;KAAM,GAC3F;QAAEZ,KAAAA,EAAOF,OAAAA;AAASQ,QAAAA,OAAAA;AAASG,QAAAA,QAAAA,EAAUV,eAAAA,IAAmBJ,0BAAAA;AAA4Be,QAAAA,MAAAA,EAAQC,oCAAkBE;AAAQ,KAAA;AAChI;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var sliceDialogFor = require('./sliceDialogFor.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
function text(properties, name) {
|
|
9
|
+
const value = properties[name];
|
|
10
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads a button from the properties of a `core:toolbarItem` element: `label` (or `name`), `kind`, `slice`,
|
|
14
|
+
* `emphasis`, `icon` and `target`.
|
|
15
|
+
*
|
|
16
|
+
* The C# engine (`ToolbarButtons.FromItem`) reads the same; both are asserted against `toolbar-slice-fixtures.json`.
|
|
17
|
+
*
|
|
18
|
+
* @param id The element id.
|
|
19
|
+
* @param properties The element properties.
|
|
20
|
+
* @returns The button, or undefined when the item does not invoke a command or slice - a navigate or dialog item.
|
|
21
|
+
*/ function toolbarButtonFromItem(id, properties) {
|
|
22
|
+
const slice = text(properties, 'slice');
|
|
23
|
+
const action = text(properties, 'kind')?.toLowerCase() === 'action';
|
|
24
|
+
if (slice === undefined && !action) return undefined;
|
|
25
|
+
const button = {
|
|
26
|
+
id,
|
|
27
|
+
title: text(properties, 'label') ?? text(properties, 'name') ?? id
|
|
28
|
+
};
|
|
29
|
+
if (slice !== undefined) button.slice = slice;
|
|
30
|
+
const emphasis = text(properties, 'emphasis')?.toLowerCase();
|
|
31
|
+
if (emphasis === scene_model.ToolbarEmphasis.Primary || emphasis === scene_model.ToolbarEmphasis.Secondary || emphasis === scene_model.ToolbarEmphasis.Quiet) button.emphasis = emphasis;
|
|
32
|
+
const icon = text(properties, 'icon');
|
|
33
|
+
if (icon !== undefined) button.icon = icon;
|
|
34
|
+
const target = text(properties, 'target');
|
|
35
|
+
if (target !== undefined) button.target = target;
|
|
36
|
+
return button;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts a hand-authored button to a slice-backed one: a button with no slice whose command is accepted by exactly
|
|
40
|
+
* one state change slice names that slice instead.
|
|
41
|
+
* @param index The modules, features and slices of the application.
|
|
42
|
+
* @param button The button.
|
|
43
|
+
* @returns The button to use, and whether it was converted. A button that cannot be converted is returned as it is.
|
|
44
|
+
*/ function normalizeToolbarButton(index, button) {
|
|
45
|
+
if (button.slice || !button.target) return {
|
|
46
|
+
button,
|
|
47
|
+
converted: false
|
|
48
|
+
};
|
|
49
|
+
const matches = index.findSlicesByCommand(button.target);
|
|
50
|
+
if (matches.length !== 1) return {
|
|
51
|
+
button,
|
|
52
|
+
converted: false
|
|
53
|
+
};
|
|
54
|
+
const { target, ...rest } = button;
|
|
55
|
+
return {
|
|
56
|
+
button: {
|
|
57
|
+
...rest,
|
|
58
|
+
slice: matches[0]
|
|
59
|
+
},
|
|
60
|
+
converted: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolves a button: its slice, command and task dialog, without any rendering. This is what a renderer, Stage and the
|
|
65
|
+
* Studio preview call.
|
|
66
|
+
*
|
|
67
|
+
* The C# engine (`ToolbarButtons.Resolve`) resolves the same; both are asserted against `toolbar-slice-fixtures.json`.
|
|
68
|
+
*
|
|
69
|
+
* @param index The modules, features and slices of the application.
|
|
70
|
+
* @param button The button.
|
|
71
|
+
* @param defaultDialogTemplate The dialog template used when a slice names none.
|
|
72
|
+
*/ function resolveToolbarButton(index, button, defaultDialogTemplate) {
|
|
73
|
+
const { button: normalized, converted } = normalizeToolbarButton(index, button);
|
|
74
|
+
const dialog = normalized.slice ? sliceDialogFor.sliceDialogFor(index, normalized.slice, defaultDialogTemplate) : undefined;
|
|
75
|
+
const resolved = {
|
|
76
|
+
id: normalized.id,
|
|
77
|
+
title: normalized.title,
|
|
78
|
+
emphasis: normalized.emphasis ?? scene_model.ToolbarEmphasis.Secondary,
|
|
79
|
+
converted
|
|
80
|
+
};
|
|
81
|
+
if (normalized.icon !== undefined) resolved.icon = normalized.icon;
|
|
82
|
+
if (normalized.slice) resolved.slice = normalized.slice;
|
|
83
|
+
if (dialog) {
|
|
84
|
+
resolved.command = dialog.command;
|
|
85
|
+
resolved.dialog = dialog;
|
|
86
|
+
}
|
|
87
|
+
return resolved;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
exports.normalizeToolbarButton = normalizeToolbarButton;
|
|
91
|
+
exports.resolveToolbarButton = resolveToolbarButton;
|
|
92
|
+
exports.toolbarButtonFromItem = toolbarButtonFromItem;
|
|
93
|
+
//# sourceMappingURL=toolbarButtons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarButtons.js","sources":["../../../toolbar/toolbarButtons.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 { ToolbarButton, ToolbarEmphasis } from '@cratis/scene.model';\nimport { ApplicationStructureIndex } from '../structure';\nimport { ResolvedToolbarButton } from './ResolvedToolbarButton';\nimport { sliceDialogFor } from './sliceDialogFor';\n\nfunction text(properties: Record<string, unknown>, name: string): string | undefined {\n const value = properties[name];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * Reads a button from the properties of a `core:toolbarItem` element: `label` (or `name`), `kind`, `slice`,\n * `emphasis`, `icon` and `target`.\n *\n * The C# engine (`ToolbarButtons.FromItem`) reads the same; both are asserted against `toolbar-slice-fixtures.json`.\n *\n * @param id The element id.\n * @param properties The element properties.\n * @returns The button, or undefined when the item does not invoke a command or slice - a navigate or dialog item.\n */\nexport function toolbarButtonFromItem(id: string, properties: Record<string, unknown>): ToolbarButton | undefined {\n const slice = text(properties, 'slice');\n const action = text(properties, 'kind')?.toLowerCase() === 'action';\n if (slice === undefined && !action) return undefined;\n\n const button: ToolbarButton = { id, title: text(properties, 'label') ?? text(properties, 'name') ?? id };\n if (slice !== undefined) button.slice = slice;\n\n const emphasis = text(properties, 'emphasis')?.toLowerCase();\n if (emphasis === ToolbarEmphasis.Primary || emphasis === ToolbarEmphasis.Secondary || emphasis === ToolbarEmphasis.Quiet) button.emphasis = emphasis;\n\n const icon = text(properties, 'icon');\n if (icon !== undefined) button.icon = icon;\n\n const target = text(properties, 'target');\n if (target !== undefined) button.target = target;\n return button;\n}\n\n/**\n * Converts a hand-authored button to a slice-backed one: a button with no slice whose command is accepted by exactly\n * one state change slice names that slice instead.\n * @param index The modules, features and slices of the application.\n * @param button The button.\n * @returns The button to use, and whether it was converted. A button that cannot be converted is returned as it is.\n */\nexport function normalizeToolbarButton(index: ApplicationStructureIndex, button: ToolbarButton): { button: ToolbarButton; converted: boolean } {\n if (button.slice || !button.target) return { button, converted: false };\n\n const matches = index.findSlicesByCommand(button.target);\n if (matches.length !== 1) return { button, converted: false };\n\n const { target, ...rest } = button;\n void target;\n return { button: { ...rest, slice: matches[0] }, converted: true };\n}\n\n/**\n * Resolves a button: its slice, command and task dialog, without any rendering. This is what a renderer, Stage and the\n * Studio preview call.\n *\n * The C# engine (`ToolbarButtons.Resolve`) resolves the same; both are asserted against `toolbar-slice-fixtures.json`.\n *\n * @param index The modules, features and slices of the application.\n * @param button The button.\n * @param defaultDialogTemplate The dialog template used when a slice names none.\n */\nexport function resolveToolbarButton(index: ApplicationStructureIndex, button: ToolbarButton, defaultDialogTemplate?: string): ResolvedToolbarButton {\n const { button: normalized, converted } = normalizeToolbarButton(index, button);\n const dialog = normalized.slice ? sliceDialogFor(index, normalized.slice, defaultDialogTemplate) : undefined;\n const resolved: ResolvedToolbarButton = { id: normalized.id, title: normalized.title, emphasis: normalized.emphasis ?? ToolbarEmphasis.Secondary, converted };\n if (normalized.icon !== undefined) resolved.icon = normalized.icon;\n if (normalized.slice) resolved.slice = normalized.slice;\n if (dialog) {\n resolved.command = dialog.command;\n resolved.dialog = dialog;\n }\n\n return resolved;\n}\n"],"names":["text","properties","name","value","length","undefined","toolbarButtonFromItem","id","slice","action","toLowerCase","button","title","emphasis","ToolbarEmphasis","Primary","Secondary","Quiet","icon","target","normalizeToolbarButton","index","converted","matches","findSlicesByCommand","rest","resolveToolbarButton","defaultDialogTemplate","normalized","dialog","sliceDialogFor","resolved","command"],"mappings":";;;;;AAAA;AACA;AAOA,SAASA,IAAAA,CAAKC,UAAmC,EAAEC,IAAY,EAAA;IAC3D,MAAMC,KAAAA,GAAQF,UAAU,CAACC,IAAAA,CAAK;AAC9B,IAAA,OAAO,OAAOC,KAAAA,KAAU,QAAA,IAAYA,MAAMC,MAAM,GAAG,IAAID,KAAAA,GAAQE,SAAAA;AACnE;AAEA;;;;;;;;;AASC,IACM,SAASC,qBAAAA,CAAsBC,EAAU,EAAEN,UAAmC,EAAA;IACjF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ACvD,IAAA,IAAIqB,MAAAA,EAAQ;QACRE,QAAAA,CAASC,OAAO,GAAGH,MAAAA,CAAOG,OAAO;AACjCD,QAAAA,QAAAA,CAASF,MAAM,GAAGA,MAAAA;AACtB,IAAA;IAEA,OAAOE,QAAAA;AACX;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var ApplicationStructureIndex = require('../structure/ApplicationStructureIndex.js');
|
|
5
|
+
var ToolbarDiagnosticCode = require('./ToolbarDiagnosticCode.js');
|
|
6
|
+
var ToolbarDiagnosticSeverity = require('./ToolbarDiagnosticSeverity.js');
|
|
7
|
+
var toolbarButtons = require('./toolbarButtons.js');
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
10
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
11
|
+
/**
|
|
12
|
+
* Validates the buttons of a toolbar against the application structure: a button must invoke a state change slice
|
|
13
|
+
* (TB3), and a button without a slice is allowed but flagged (TB5). A hand-authored button that names a command is
|
|
14
|
+
* converted first, and a button whose command no single slice accepts is a legacy button that still validates.
|
|
15
|
+
*
|
|
16
|
+
* The C# engine (`ToolbarButtonValidation.Validate`) reports the same codes, severities and messages in the same
|
|
17
|
+
* order; both are asserted against `toolbar-slice-fixtures.json`.
|
|
18
|
+
*
|
|
19
|
+
* @param structure The modules, features and slices of the application.
|
|
20
|
+
* @param toolbar The toolbar.
|
|
21
|
+
* @returns The problems found, in button order.
|
|
22
|
+
*/ function validateToolbarButtons(structure, toolbar) {
|
|
23
|
+
const index = structure instanceof ApplicationStructureIndex.ApplicationStructureIndex ? structure : new ApplicationStructureIndex.ApplicationStructureIndex(structure);
|
|
24
|
+
const diagnostics = [];
|
|
25
|
+
for (const authored of toolbar.buttons){
|
|
26
|
+
const { button } = toolbarButtons.normalizeToolbarButton(index, authored);
|
|
27
|
+
if (!button.slice) {
|
|
28
|
+
if (!button.target) {
|
|
29
|
+
diagnostics.push({
|
|
30
|
+
code: ToolbarDiagnosticCode.ToolbarDiagnosticCode.ToolbarButtonSliceEmpty,
|
|
31
|
+
severity: ToolbarDiagnosticSeverity.ToolbarDiagnosticSeverity.Warning,
|
|
32
|
+
message: `Toolbar button '${button.id}' has no slice to invoke.`,
|
|
33
|
+
button: button.id
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const slice = index.findSlice(button.slice);
|
|
39
|
+
if (!slice) {
|
|
40
|
+
diagnostics.push({
|
|
41
|
+
code: ToolbarDiagnosticCode.ToolbarDiagnosticCode.ToolbarButtonSliceNotFound,
|
|
42
|
+
severity: ToolbarDiagnosticSeverity.ToolbarDiagnosticSeverity.Error,
|
|
43
|
+
message: `Toolbar button '${button.id}' invokes slice '${button.slice}', which does not exist.`,
|
|
44
|
+
button: button.id
|
|
45
|
+
});
|
|
46
|
+
} else if (slice.kind !== scene_model.SliceKind.StateChange) {
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
code: ToolbarDiagnosticCode.ToolbarDiagnosticCode.ToolbarButtonSliceNotStateChange,
|
|
49
|
+
severity: ToolbarDiagnosticSeverity.ToolbarDiagnosticSeverity.Error,
|
|
50
|
+
message: `Toolbar button '${button.id}' invokes slice '${button.slice}', which is ${slice.kind === scene_model.SliceKind.StateView ? 'a state view' : 'an automation'}; only a state change can be invoked from a toolbar.`,
|
|
51
|
+
button: button.id
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return diagnostics;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.validateToolbarButtons = validateToolbarButtons;
|
|
59
|
+
//# sourceMappingURL=validateToolbarButtons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateToolbarButtons.js","sources":["../../../toolbar/validateToolbarButtons.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 { ApplicationStructure, SliceKind, Toolbar } from '@cratis/scene.model';\nimport { ApplicationStructureIndex } from '../structure';\nimport { ToolbarDiagnostic } from './ToolbarDiagnostic';\nimport { ToolbarDiagnosticCode } from './ToolbarDiagnosticCode';\nimport { ToolbarDiagnosticSeverity } from './ToolbarDiagnosticSeverity';\nimport { normalizeToolbarButton } from './toolbarButtons';\n\n/**\n * Validates the buttons of a toolbar against the application structure: a button must invoke a state change slice\n * (TB3), and a button without a slice is allowed but flagged (TB5). A hand-authored button that names a command is\n * converted first, and a button whose command no single slice accepts is a legacy button that still validates.\n *\n * The C# engine (`ToolbarButtonValidation.Validate`) reports the same codes, severities and messages in the same\n * order; both are asserted against `toolbar-slice-fixtures.json`.\n *\n * @param structure The modules, features and slices of the application.\n * @param toolbar The toolbar.\n * @returns The problems found, in button order.\n */\nexport function validateToolbarButtons(structure: ApplicationStructure | ApplicationStructureIndex, toolbar: Toolbar): ToolbarDiagnostic[] {\n const index = structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure);\n const diagnostics: ToolbarDiagnostic[] = [];\n\n for (const authored of toolbar.buttons) {\n const { button } = normalizeToolbarButton(index, authored);\n if (!button.slice) {\n if (!button.target) {\n diagnostics.push({\n code: ToolbarDiagnosticCode.ToolbarButtonSliceEmpty,\n severity: ToolbarDiagnosticSeverity.Warning,\n message: `Toolbar button '${button.id}' has no slice to invoke.`,\n button: button.id,\n });\n }\n\n continue;\n }\n\n const slice = index.findSlice(button.slice);\n if (!slice) {\n diagnostics.push({\n code: ToolbarDiagnosticCode.ToolbarButtonSliceNotFound,\n severity: ToolbarDiagnosticSeverity.Error,\n message: `Toolbar button '${button.id}' invokes slice '${button.slice}', which does not exist.`,\n button: button.id,\n });\n } else if (slice.kind !== SliceKind.StateChange) {\n diagnostics.push({\n code: ToolbarDiagnosticCode.ToolbarButtonSliceNotStateChange,\n severity: ToolbarDiagnosticSeverity.Error,\n message: `Toolbar button '${button.id}' invokes slice '${button.slice}', which is ${slice.kind === SliceKind.StateView ? 'a state view' : 'an automation'}; only a state change can be invoked from a toolbar.`,\n button: button.id,\n });\n }\n }\n\n return diagnostics;\n}\n"],"names":["validateToolbarButtons","structure","toolbar","index","ApplicationStructureIndex","diagnostics","authored","buttons","button","normalizeToolbarButton","slice","target","push","code","ToolbarDiagnosticCode","ToolbarButtonSliceEmpty","severity","ToolbarDiagnosticSeverity","Warning","message","id","findSlice","ToolbarButtonSliceNotFound","Error","kind","SliceKind","StateChange","ToolbarButtonSliceNotStateChange","StateView"],"mappings":";;;;;;;;AAAA;AACA;AASA;;;;;;;;;;;AAWC,IACM,SAASA,sBAAAA,CAAuBC,SAA2D,EAAEC,OAAgB,EAAA;AAChH,IAAA,MAAMC,KAAAA,GAAQF,SAAAA,YAAqBG,mDAAAA,GAA4BH,SAAAA,GAAY,IAAIG,mDAAAA,CAA0BH,SAAAA,CAAAA;AACzG,IAAA,MAAMI,cAAmC,EAAE;AAE3C,IAAA,KAAK,MAAMC,QAAAA,IAAYJ,OAAAA,CAAQK,OAAO,CAAE;AACpC,QAAA,MAAM,EAAEC,MAAM,EAAE,GAAGC,sCAAuBN,KAAAA,EAAOG,QAAAA,CAAAA;QACjD,IAAI,CAACE,MAAAA,CAAOE,KAAK,EAAE;YACf,IAAI,CAACF,MAAAA,CAAOG,MAAM,EAAE;AAChBN,gBAAAA,WAAAA,CAAYO,IAAI,CAAC;AACbC,oBAAAA,IAAAA,EAAMC,4CAAsBC,uBAAuB;AACnDC,oBAAAA,QAAAA,EAAUC,oDAA0BC,OAAO;AAC3CC,oBAAAA,OAAAA,EAAS,CAAC,gBAAgB,EAAEX,OAAOY,EAAE,CAAC,yBAAyB,CAAC;AAChEZ,oBAAAA,MAAAA,EAAQA,OAAOY;AACnB,iBAAA,CAAA;AACJ,YAAA;AAEA,YAAA;AACJ,QAAA;AAEA,QAAA,MAAMV,KAAAA,GAAQP,KAAAA,CAAMkB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AAC3C,cAAc,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,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -97,4 +97,10 @@ export { describeSampleDataCatalog, generatedSampleDataName, sampleDataLabelSepa
|
|
|
97
97
|
export { findDescriptorSampleRowLiterals, findSampleRowLiterals, findTemplateSampleRowLiterals } from './sampleData/findSampleRowLiterals.js';
|
|
98
98
|
export { StructureDiagnosticCode } from './structure/StructureDiagnosticCode.js';
|
|
99
99
|
export { ApplicationStructureIndex } from './structure/ApplicationStructureIndex.js';
|
|
100
|
+
export { ToolbarDiagnosticCode } from './toolbar/ToolbarDiagnosticCode.js';
|
|
101
|
+
export { ToolbarDiagnosticSeverity } from './toolbar/ToolbarDiagnosticSeverity.js';
|
|
102
|
+
export { SliceDialogSource } from './toolbar/SliceDialogSource.js';
|
|
103
|
+
export { defaultSliceDialogTemplate, sliceDialogFor } from './toolbar/sliceDialogFor.js';
|
|
104
|
+
export { normalizeToolbarButton, resolveToolbarButton, toolbarButtonFromItem } from './toolbar/toolbarButtons.js';
|
|
105
|
+
export { validateToolbarButtons } from './toolbar/validateToolbarButtons.js';
|
|
100
106
|
//# sourceMappingURL=index.js.map
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -15,6 +15,7 @@ export declare class ApplicationStructureIndex {
|
|
|
15
15
|
findSlice(qualifiedId: string): SliceNode | undefined;
|
|
16
16
|
kindOf(sliceId: string): SliceKind | undefined;
|
|
17
17
|
findFeaturesByName(name: string): string[];
|
|
18
|
+
findSlicesByCommand(command: string): string[];
|
|
18
19
|
private indexContainer;
|
|
19
20
|
private claim;
|
|
20
21
|
private reportAmbiguousName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationStructureIndex.d.ts","sourceRoot":"","sources":["../../../structure/ApplicationStructureIndex.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,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E,MAAM,uBAAuB,CAAC;AAW5D,qBAAa,yBAAyB;IAatB,QAAQ,CAAC,SAAS,EAAE,oBAAoB;IAZpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAG9D,QAAQ,CAAC,WAAW,EAAE,mBAAmB,EAAE,CAAM;IAMjD,YAAqB,SAAS,EAAE,oBAAoB,EAYnD;IAOD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEnD;IAOD,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAExD;IAOD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEtD;IAOD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGnD;IAOD,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEpD;IAOD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7C;IAOD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzC;IAOD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAI7C;IAED,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,mBAAmB;CAc9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SliceKind } from '@cratis/scene.model';
|
|
1
2
|
import { StructureDiagnosticCode } from './StructureDiagnosticCode.js';
|
|
2
3
|
|
|
3
4
|
// Copyright (c) Cratis. All rights reserved.
|
|
@@ -83,6 +84,15 @@ import { StructureDiagnosticCode } from './StructureDiagnosticCode.js';
|
|
|
83
84
|
...this.featuresByName.get(name.toLowerCase()) ?? []
|
|
84
85
|
];
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.
|
|
89
|
+
* @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.
|
|
90
|
+
* @returns The qualified ids of the matching state change slices, in declaration order.
|
|
91
|
+
*/ findSlicesByCommand(command) {
|
|
92
|
+
return [
|
|
93
|
+
...this.slices.entries()
|
|
94
|
+
].filter(([qualified, slice])=>slice.kind === SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command)).map(([qualified])=>qualified);
|
|
95
|
+
}
|
|
86
96
|
indexContainer(path, features, slices) {
|
|
87
97
|
const seen = new Map();
|
|
88
98
|
const featureNames = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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 { ApplicationStructure, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","path","featureNames","sliceNames","key","byName","push","slice","first","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SAAAA,EAAW;YACrBlB,IAAAA,CAAKM,GAAG,CAACH,SAAAA,EAAWmB,IAAAA,CAAAA;YACpB,OAAO,IAAA;AACX,QAAA;AAEA,QAAA,IAAI,CAACxB,WAAW,CAACgC,IAAI,CAAC;AAClBG,YAAAA,IAAAA,EAAMC,wBAAwBC,oBAAoB;YAClDC,OAAAA,EAAS,CAAC,IAAI,EAAEjC,SAAAA,CAAU,wCAAwC,EAAE6B,KAAAA,CAAM,MAAM,CAAC;YACjF5B,EAAAA,EAAID;AACR,SAAA,CAAA;QACA,OAAO,KAAA;AACX,IAAA;AAEQI,IAAAA,mBAAAA,CAAoBN,KAA0B,EAAEqB,IAAY,EAAEd,IAAY,EAAEL,SAAiB,EAAQ;QACzG,MAAMyB,GAAAA,GAAMpB,KAAKgB,WAAW,EAAA;QAC5B,MAAMQ,KAAAA,GAAQ/B,KAAAA,CAAMW,GAAG,CAACgB,GAAAA,CAAAA;AACxB,QAAA,IAAII,UAAUd,SAAAA,EAAW;AACrB,YAAA,IAAI,CAACpB,WAAW,CAACgC,IAAI,CAAC;AAClBG,gBAAAA,IAAAA,EAAMC,wBAAwBG,sBAAsB;AACpDD,gBAAAA,OAAAA,EAAS,CAAC,IAAI,EAAEd,IAAAA,CAAK,OAAO,EAAEd,IAAAA,CAAK,mBAAmB,EAAEwB,KAAAA,CAAM,OAAO,EAAE7B,SAAAA,CAAU,EAAE,CAAC;gBACpFC,EAAAA,EAAID;AACR,aAAA,CAAA;AACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAACsB,GAAAA,EAAKzB,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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 { ApplicationStructure, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n /**\n * Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.\n * @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.\n * @returns The qualified ids of the matching state change slices, in declaration order.\n */\n findSlicesByCommand(command: string): string[] {\n return [...this.slices.entries()]\n .filter(([qualified, slice]) => slice.kind === SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command))\n .map(([qualified]) => qualified);\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","findSlicesByCommand","command","entries","filter","slice","SliceKind","StateChange","map","path","featureNames","sliceNames","key","byName","push","first","code","StructureDiagnosticCode","StructureDuplicateId","message","StructureAmbiguousName"],"mappings":";;;AAAA;AACA;AAMA;;;;;;;AAOC,IACM,MAAMA,yBAAAA,CAAAA;;AACQC,IAAAA,OAAAA,GAAU,IAAIC,GAAAA,EAAAA;AACdC,IAAAA,QAAAA,GAAW,IAAID,GAAAA,EAAAA;AACfE,IAAAA,MAAAA,GAAS,IAAIF,GAAAA,EAAAA;AACbG,IAAAA,cAAAA,GAAiB,IAAIH,GAAAA,EAAAA;AAEtC,oEACSI,WAAAA,GAAqC,EAAE;AAEhD;;;QAIA,WAAA,CAAY,SAAwC,CAAE;aAAjCC,SAAAA,GAAAA,S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B,QAAA,IAAIoC,UAAUrB,SAAAA,EAAW;YACrBlB,IAAAA,CAAKM,GAAG,CAACH,SAAAA,EAAWmB,IAAAA,CAAAA;YACpB,OAAO,IAAA;AACX,QAAA;AAEA,QAAA,IAAI,CAACxB,WAAW,CAACwC,IAAI,CAAC;AAClBE,YAAAA,IAAAA,EAAMC,wBAAwBC,oBAAoB;YAClDC,OAAAA,EAAS,CAAC,IAAI,EAAExC,SAAAA,CAAU,wCAAwC,EAAEoC,KAAAA,CAAM,MAAM,CAAC;YACjFnC,EAAAA,EAAID;AACR,SAAA,CAAA;QACA,OAAO,KAAA;AACX,IAAA;AAEQI,IAAAA,mBAAAA,CAAoBN,KAA0B,EAAEqB,IAAY,EAAEd,IAAY,EAAEL,SAAiB,EAAQ;QACzG,MAAMiC,GAAAA,GAAM5B,KAAKgB,WAAW,EAAA;QAC5B,MAAMe,KAAAA,GAAQtC,KAAAA,CAAMW,GAAG,CAACwB,GAAAA,CAAAA;AACxB,QAAA,IAAIG,UAAUrB,SAAAA,EAAW;AACrB,YAAA,IAAI,CAACpB,WAAW,CAACwC,IAAI,CAAC;AAClBE,gBAAAA,IAAAA,EAAMC,wBAAwBG,sBAAsB;AACpDD,gBAAAA,OAAAA,EAAS,CAAC,IAAI,EAAErB,IAAAA,CAAK,OAAO,EAAEd,IAAAA,CAAK,mBAAmB,EAAE+B,KAAAA,CAAM,OAAO,EAAEpC,SAAAA,CAAU,EAAE,CAAC;gBACpFC,EAAAA,EAAID;AACR,aAAA,CAAA;AACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAAC8B,GAAAA,EAAKjC,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ToolbarEmphasis } from '@cratis/scene.model';
|
|
2
|
+
import { SliceDialog } from './SliceDialog';
|
|
3
|
+
export interface ResolvedToolbarButton {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
emphasis: ToolbarEmphasis;
|
|
7
|
+
icon?: string;
|
|
8
|
+
slice?: string;
|
|
9
|
+
converted: boolean;
|
|
10
|
+
command?: string;
|
|
11
|
+
dialog?: SliceDialog;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ResolvedToolbarButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedToolbarButton.d.ts","sourceRoot":"","sources":["../../../toolbar/ResolvedToolbarButton.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,MAAM,WAAW,qBAAqB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,QAAQ,EAAE,eAAe,CAAC;IAG1B,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,SAAS,EAAE,OAAO,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedToolbarButton.js","sourceRoot":"","sources":["../../../toolbar/ResolvedToolbarButton.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceDialog.d.ts","sourceRoot":"","sources":["../../../toolbar/SliceDialog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxD,MAAM,WAAW,WAAW;IAExB,KAAK,EAAE,MAAM,CAAC;IAGd,OAAO,EAAE,MAAM,CAAC;IAGhB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,iBAAiB,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceDialog.js","sourceRoot":"","sources":["../../../toolbar/SliceDialog.ts"],"names":[],"mappings":""}
|