@cratis/scene.engine 4.3.0 → 4.4.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/editing/collectIconUsages.js +86 -0
- package/dist/cjs/editing/collectIconUsages.js.map +1 -0
- package/dist/cjs/editing/diagnoseIcons.js +67 -0
- package/dist/cjs/editing/diagnoseIcons.js.map +1 -0
- package/dist/cjs/editing/iconDiagnostics.js +103 -0
- package/dist/cjs/editing/iconDiagnostics.js.map +1 -0
- package/dist/cjs/editing/inspect.js +28 -1
- package/dist/cjs/editing/inspect.js.map +1 -1
- package/dist/cjs/editing/instanceEdits.js +15 -3
- package/dist/cjs/editing/instanceEdits.js.map +1 -1
- package/dist/cjs/editing/propertyEdits.js +7 -0
- package/dist/cjs/editing/propertyEdits.js.map +1 -1
- package/dist/cjs/icons/EffectiveIconCatalog.js +212 -0
- package/dist/cjs/icons/EffectiveIconCatalog.js.map +1 -0
- package/dist/cjs/icons/EffectiveIconEntry.js +22 -0
- package/dist/cjs/icons/EffectiveIconEntry.js.map +1 -0
- package/dist/cjs/icons/analyzeIconImpact.js +48 -0
- package/dist/cjs/icons/analyzeIconImpact.js.map +1 -0
- package/dist/cjs/icons/matchesIconQuery.js +22 -0
- package/dist/cjs/icons/matchesIconQuery.js.map +1 -0
- package/dist/cjs/icons/resolveIconLibraries.js +45 -0
- package/dist/cjs/icons/resolveIconLibraries.js.map +1 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/editing/EditingContext.d.ts +2 -0
- package/dist/esm/editing/EditingContext.d.ts.map +1 -1
- package/dist/esm/editing/collectIconUsages.d.ts +5 -0
- package/dist/esm/editing/collectIconUsages.d.ts.map +1 -0
- package/dist/esm/editing/collectIconUsages.js +84 -0
- package/dist/esm/editing/collectIconUsages.js.map +1 -0
- package/dist/esm/editing/diagnoseIcons.d.ts +4 -0
- package/dist/esm/editing/diagnoseIcons.d.ts.map +1 -0
- package/dist/esm/editing/diagnoseIcons.js +65 -0
- package/dist/esm/editing/diagnoseIcons.js.map +1 -0
- package/dist/esm/editing/iconDiagnostics.d.ts +11 -0
- package/dist/esm/editing/iconDiagnostics.d.ts.map +1 -0
- package/dist/esm/editing/iconDiagnostics.js +99 -0
- package/dist/esm/editing/iconDiagnostics.js.map +1 -0
- package/dist/esm/editing/index.d.ts +3 -0
- package/dist/esm/editing/index.d.ts.map +1 -1
- package/dist/esm/editing/index.js +3 -0
- package/dist/esm/editing/index.js.map +1 -1
- package/dist/esm/editing/inspect.d.ts.map +1 -1
- package/dist/esm/editing/inspect.js +29 -2
- package/dist/esm/editing/inspect.js.map +1 -1
- package/dist/esm/editing/instanceEdits.d.ts.map +1 -1
- package/dist/esm/editing/instanceEdits.js +17 -5
- package/dist/esm/editing/instanceEdits.js.map +1 -1
- package/dist/esm/editing/propertyEdits.d.ts.map +1 -1
- package/dist/esm/editing/propertyEdits.js +9 -2
- package/dist/esm/editing/propertyEdits.js.map +1 -1
- package/dist/esm/icons/EffectiveIconCatalog.d.ts +25 -0
- package/dist/esm/icons/EffectiveIconCatalog.d.ts.map +1 -0
- package/dist/esm/icons/EffectiveIconCatalog.js +210 -0
- package/dist/esm/icons/EffectiveIconCatalog.js.map +1 -0
- package/dist/esm/icons/EffectiveIconEntry.d.ts +9 -0
- package/dist/esm/icons/EffectiveIconEntry.d.ts.map +1 -0
- package/dist/esm/icons/EffectiveIconEntry.js +20 -0
- package/dist/esm/icons/EffectiveIconEntry.js.map +1 -0
- package/dist/esm/icons/IconCatalogSource.d.ts +6 -0
- package/dist/esm/icons/IconCatalogSource.d.ts.map +1 -0
- package/dist/esm/icons/IconCatalogSource.js +2 -0
- package/dist/esm/icons/IconCatalogSource.js.map +1 -0
- package/dist/esm/icons/IconDiagnostic.d.ts +9 -0
- package/dist/esm/icons/IconDiagnostic.d.ts.map +1 -0
- package/dist/esm/icons/IconDiagnostic.js +2 -0
- package/dist/esm/icons/IconDiagnostic.js.map +1 -0
- package/dist/esm/icons/IconImpactReport.d.ts +18 -0
- package/dist/esm/icons/IconImpactReport.d.ts.map +1 -0
- package/dist/esm/icons/IconImpactReport.js +2 -0
- package/dist/esm/icons/IconImpactReport.js.map +1 -0
- package/dist/esm/icons/IconLibraryResolution.d.ts +7 -0
- package/dist/esm/icons/IconLibraryResolution.d.ts.map +1 -0
- package/dist/esm/icons/IconLibraryResolution.js +2 -0
- package/dist/esm/icons/IconLibraryResolution.js.map +1 -0
- package/dist/esm/icons/IconQuery.d.ts +7 -0
- package/dist/esm/icons/IconQuery.d.ts.map +1 -0
- package/dist/esm/icons/IconQuery.js +2 -0
- package/dist/esm/icons/IconQuery.js.map +1 -0
- package/dist/esm/icons/IconResolution.d.ts +14 -0
- package/dist/esm/icons/IconResolution.d.ts.map +1 -0
- package/dist/esm/icons/IconResolution.js +2 -0
- package/dist/esm/icons/IconResolution.js.map +1 -0
- package/dist/esm/icons/IconSearchResult.d.ts +7 -0
- package/dist/esm/icons/IconSearchResult.d.ts.map +1 -0
- package/dist/esm/icons/IconSearchResult.js +2 -0
- package/dist/esm/icons/IconSearchResult.js.map +1 -0
- package/dist/esm/icons/IconUsage.d.ts +6 -0
- package/dist/esm/icons/IconUsage.d.ts.map +1 -0
- package/dist/esm/icons/IconUsage.js +2 -0
- package/dist/esm/icons/IconUsage.js.map +1 -0
- package/dist/esm/icons/ResolvedIconLibrary.d.ts +8 -0
- package/dist/esm/icons/ResolvedIconLibrary.d.ts.map +1 -0
- package/dist/esm/icons/ResolvedIconLibrary.js +2 -0
- package/dist/esm/icons/ResolvedIconLibrary.js.map +1 -0
- package/dist/esm/icons/analyzeIconImpact.d.ts +5 -0
- package/dist/esm/icons/analyzeIconImpact.d.ts.map +1 -0
- package/dist/esm/icons/analyzeIconImpact.js +46 -0
- package/dist/esm/icons/analyzeIconImpact.js.map +1 -0
- package/dist/esm/icons/index.d.ts +14 -0
- package/dist/esm/icons/index.d.ts.map +1 -0
- package/dist/esm/icons/index.js +14 -0
- package/dist/esm/icons/index.js.map +1 -0
- package/dist/esm/icons/matchesIconQuery.d.ts +4 -0
- package/dist/esm/icons/matchesIconQuery.d.ts.map +1 -0
- package/dist/esm/icons/matchesIconQuery.js +20 -0
- package/dist/esm/icons/matchesIconQuery.js.map +1 -0
- package/dist/esm/icons/resolveIconLibraries.d.ts +4 -0
- package/dist/esm/icons/resolveIconLibraries.d.ts.map +1 -0
- package/dist/esm/icons/resolveIconLibraries.js +43 -0
- package/dist/esm/icons/resolveIconLibraries.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 +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/editing/EditingContext.ts +11 -0
- package/editing/collectIconUsages.ts +78 -0
- package/editing/diagnoseIcons.ts +60 -0
- package/editing/iconDiagnostics.ts +90 -0
- package/editing/index.ts +3 -0
- package/editing/inspect.ts +25 -2
- package/editing/instanceEdits.ts +13 -5
- package/editing/propertyEdits.ts +10 -2
- package/icons/EffectiveIconCatalog.ts +199 -0
- package/icons/EffectiveIconEntry.ts +36 -0
- package/icons/IconCatalogSource.ts +23 -0
- package/icons/IconDiagnostic.ts +45 -0
- package/icons/IconImpactReport.ts +63 -0
- package/icons/IconLibraryResolution.ts +22 -0
- package/icons/IconQuery.ts +27 -0
- package/icons/IconResolution.ts +25 -0
- package/icons/IconSearchResult.ts +21 -0
- package/icons/IconUsage.ts +21 -0
- package/icons/ResolvedIconLibrary.ts +32 -0
- package/icons/analyzeIconImpact.ts +41 -0
- package/icons/index.ts +16 -0
- package/icons/matchesIconQuery.ts +19 -0
- package/icons/resolveIconLibraries.ts +47 -0
- package/index.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var resolvePackageDependencies = require('../resolvePackageDependencies.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
|
+
/**
|
|
9
|
+
* Finds the icon libraries a profile's packages make active - the ones it lists and the ones its other
|
|
10
|
+
* packages declare a dependency on - through the normal package resolver, so an icon library is
|
|
11
|
+
* selected, ordered and version-checked exactly as any other package is.
|
|
12
|
+
*
|
|
13
|
+
* Several libraries coexist. Nothing here ranks them: two libraries that both ship `home` stay two
|
|
14
|
+
* different icons, told apart by the library in their {@link IconReference}.
|
|
15
|
+
*
|
|
16
|
+
* @param selected The package names the profile lists.
|
|
17
|
+
* @param catalog Every package that could be selected.
|
|
18
|
+
*/ function resolveIconLibraries(selected, catalog) {
|
|
19
|
+
const selection = resolvePackageDependencies.resolvePackageDependencies(selected, catalog);
|
|
20
|
+
const index = new Map(catalog.map((scenePackage)=>[
|
|
21
|
+
scenePackage.name,
|
|
22
|
+
scenePackage
|
|
23
|
+
]));
|
|
24
|
+
const chosen = new Set(selected);
|
|
25
|
+
const active = selection.packages.map((name)=>index.get(name)).filter((scenePackage)=>scenePackage !== undefined);
|
|
26
|
+
const libraries = active.filter((scenePackage)=>scenePackage.kind === scene_model.PackageKind.IconLibrary).map((scenePackage)=>({
|
|
27
|
+
library: scenePackage.name,
|
|
28
|
+
package: scenePackage,
|
|
29
|
+
isSelected: chosen.has(scenePackage.name),
|
|
30
|
+
requiredBy: active.filter((other)=>other.dependencies.some((dependency)=>dependency.name === scenePackage.name)).map((other)=>other.name)
|
|
31
|
+
}));
|
|
32
|
+
const libraryNames = new Set(libraries.map((resolved)=>resolved.library));
|
|
33
|
+
const diagnostics = selection.versionConflicts.filter((conflict)=>libraryNames.has(conflict.dependsOn)).map((conflict)=>({
|
|
34
|
+
kind: 'incompatible-version',
|
|
35
|
+
library: conflict.dependsOn,
|
|
36
|
+
message: `'${conflict.package}' needs the icon library '${conflict.dependsOn}' at '${conflict.requiredRange}', but version ${conflict.actualVersion} is what is available`
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
libraries,
|
|
40
|
+
diagnostics
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.resolveIconLibraries = resolveIconLibraries;
|
|
45
|
+
//# sourceMappingURL=resolveIconLibraries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveIconLibraries.js","sources":["../../../icons/resolveIconLibraries.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { resolvePackageDependencies } from '../resolvePackageDependencies';\nimport { IconDiagnostic } from './IconDiagnostic';\nimport { IconLibraryResolution } from './IconLibraryResolution';\n\n/**\n * Finds the icon libraries a profile's packages make active - the ones it lists and the ones its other\n * packages declare a dependency on - through the normal package resolver, so an icon library is\n * selected, ordered and version-checked exactly as any other package is.\n *\n * Several libraries coexist. Nothing here ranks them: two libraries that both ship `home` stay two\n * different icons, told apart by the library in their {@link IconReference}.\n *\n * @param selected The package names the profile lists.\n * @param catalog Every package that could be selected.\n */\nexport function resolveIconLibraries(selected: string[], catalog: ScenePackage[]): IconLibraryResolution {\n const selection = resolvePackageDependencies(selected, catalog);\n const index = new Map(catalog.map((scenePackage) => [scenePackage.name, scenePackage]));\n const chosen = new Set(selected);\n const active = selection.packages.map((name) => index.get(name)).filter((scenePackage): scenePackage is ScenePackage => scenePackage !== undefined);\n\n const libraries = active\n .filter((scenePackage) => scenePackage.kind === PackageKind.IconLibrary)\n .map((scenePackage) => ({\n library: scenePackage.name,\n package: scenePackage,\n isSelected: chosen.has(scenePackage.name),\n requiredBy: active\n .filter((other) => other.dependencies.some((dependency) => dependency.name === scenePackage.name))\n .map((other) => other.name),\n }));\n\n const libraryNames = new Set(libraries.map((resolved) => resolved.library));\n const diagnostics: IconDiagnostic[] = selection.versionConflicts\n .filter((conflict) => libraryNames.has(conflict.dependsOn))\n .map((conflict) => ({\n kind: 'incompatible-version',\n library: conflict.dependsOn,\n message: `'${conflict.package}' needs the icon library '${conflict.dependsOn}' at '${conflict.requiredRange}', but version ${conflict.actualVersion} is what is available`,\n }));\n\n return { libraries, diagnostics };\n}\n"],"names":["resolveIconLibraries","selected","catalog","selection","resolvePackageDependencies","index","Map","map","scenePackage","name","chosen","Set","active","packages","get","filter","undefined","libraries","kind","PackageKind","IconLibrary","library","package","isSelected","has","requiredBy","other","dependencies","some","dependency","libraryNames","resolved","diagnostics","versionConflicts","conflict","dependsOn","message","requiredRange","actualVersion"],"mappings":";;;;;AAAA;AACA;AAOA;;;;;;;;;;AAUC,IACM,SAASA,oBAAAA,CAAqBC,QAAkB,EAAEC,OAAuB,EAAA;IAC5E,MAAMC,SAAAA,GAAYC,sDAA2BH,QAAAA,EAAUC,OAAAA,CAAAA;AACvD,IAAA,MAAMG,QAAQ,IAAIC,GAAAA,CAAIJ,QAAQK,GAAG,CAAC,CAACC,YAAAA,GAAiB;AAACA,YAAAA,YAAAA,CAAaC,IAAI;AAAED,YAAAA;AAAa,SAAA,CAAA,CAAA;IACrF,MAAME,MAAAA,GAAS,IAAIC,GAAAA,CAAIV,QAAAA,CAAAA;AACvB,IAAA,MAAMW,SAAST,SAAAA,CAAUU,QAAQ,CAACN,GAAG,CAAC,CAACE,IAAAA,GAASJ,KAAAA,CAAMS,GAAG,CAACL,IAAAA,CAAAA,CAAAA,CAAOM,MAAM,CAAC,CAACP,eAA+CA,YAAAA,KAAiBQ,SAAAA,CAAAA;AAEzI,IAAA,MAAMC,YAAYL,MAAAA,CACbG,MAAM,CAAC,CAACP,eAAiBA,YAAAA,CAAaU,IAAI,KAAKC,uBAAAA,CAAYC,WAAW,CAAA,CACtEb,GAAG,CAAC,CAACC,gBAAkB;AACpBa,YAAAA,OAAAA,EAASb,aAAaC,IAAI;YAC1Ba,OAAAA,EAASd,YAAAA;AACTe,YAAAA,UAAAA,EAAYb,MAAAA,CAAOc,GAAG,CAAChB,YAAAA,CAAaC,IAAI,CAAA;YACxCgB,UAAAA,EAAYb,MAAAA,CACPG,MAAM,CAAC,CAACW,QAAUA,KAAAA,CAAMC,YAAY,CAACC,IAAI,CAAC,CAACC,aAAeA,UAAAA,CAAWpB,IAAI,KAAKD,YAAAA,CAAaC,IAAI,CAAA,CAAA,CAC/FF,GAAG,CAAC,CAACmB,KAAAA,GAAUA,KAAAA,CAAMjB,IAAI;SAClC,CAAA,CAAA;IAEJ,MAAMqB,YAAAA,GAAe,IAAInB,GAAAA,CAAIM,SAAAA,CAAUV,GAAG,CAAC,CAACwB,QAAAA,GAAaA,QAAAA,CAASV,OAAO,CAAA,CAAA;AACzE,IAAA,MAAMW,cAAgC7B,SAAAA,CAAU8B,gBAAgB,CAC3DlB,MAAM,CAAC,CAACmB,QAAAA,GAAaJ,YAAAA,CAAaN,GAAG,CAACU,SAASC,SAAS,CAAA,CAAA,CACxD5B,GAAG,CAAC,CAAC2B,YAAc;YAChBhB,IAAAA,EAAM,sBAAA;AACNG,YAAAA,OAAAA,EAASa,SAASC,SAAS;YAC3BC,OAAAA,EAAS,CAAC,CAAC,EAAEF,QAAAA,CAASZ,OAAO,CAAC,0BAA0B,EAAEY,QAAAA,CAASC,SAAS,CAAC,MAAM,EAAED,QAAAA,CAASG,aAAa,CAAC,eAAe,EAAEH,QAAAA,CAASI,aAAa,CAAC,qBAAqB;SAC7K,CAAA,CAAA;IAEJ,OAAO;AAAErB,QAAAA,SAAAA;AAAWe,QAAAA;AAAY,KAAA;AACpC;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,6 +4,10 @@ var renderElement = require('./renderElement.js');
|
|
|
4
4
|
var elementKind = require('./elementKind.js');
|
|
5
5
|
var panelKind = require('./panelKind.js');
|
|
6
6
|
var flowNodeKind = require('./flowNodeKind.js');
|
|
7
|
+
var resolveIconLibraries = require('./icons/resolveIconLibraries.js');
|
|
8
|
+
var EffectiveIconEntry = require('./icons/EffectiveIconEntry.js');
|
|
9
|
+
var EffectiveIconCatalog = require('./icons/EffectiveIconCatalog.js');
|
|
10
|
+
var analyzeIconImpact = require('./icons/analyzeIconImpact.js');
|
|
7
11
|
var resolveComponentName = require('./resolveComponentName.js');
|
|
8
12
|
var computeSizeClass = require('./computeSizeClass.js');
|
|
9
13
|
var evaluateFlowArrangement = require('./evaluateFlowArrangement.js');
|
|
@@ -35,6 +39,9 @@ var applyEffectiveConfiguration = require('./editing/applyEffectiveConfiguration
|
|
|
35
39
|
var indexDocument = require('./editing/indexDocument.js');
|
|
36
40
|
var inspect = require('./editing/inspect.js');
|
|
37
41
|
var applyEdit = require('./editing/applyEdit.js');
|
|
42
|
+
var iconDiagnostics = require('./editing/iconDiagnostics.js');
|
|
43
|
+
var diagnoseIcons = require('./editing/diagnoseIcons.js');
|
|
44
|
+
var collectIconUsages = require('./editing/collectIconUsages.js');
|
|
38
45
|
|
|
39
46
|
|
|
40
47
|
|
|
@@ -54,6 +61,10 @@ exports.isFlowGrid = flowNodeKind.isFlowGrid;
|
|
|
54
61
|
exports.isFlowLeaf = flowNodeKind.isFlowLeaf;
|
|
55
62
|
exports.isFlowRow = flowNodeKind.isFlowRow;
|
|
56
63
|
exports.isFlowSlotLeaf = flowNodeKind.isFlowSlotLeaf;
|
|
64
|
+
exports.resolveIconLibraries = resolveIconLibraries.resolveIconLibraries;
|
|
65
|
+
exports.referencesOfEntry = EffectiveIconEntry.referencesOfEntry;
|
|
66
|
+
exports.EffectiveIconCatalog = EffectiveIconCatalog.EffectiveIconCatalog;
|
|
67
|
+
exports.analyzeIconImpact = analyzeIconImpact.analyzeIconImpact;
|
|
57
68
|
exports.corePackage = resolveComponentName.corePackage;
|
|
58
69
|
exports.effectivePackages = resolveComponentName.effectivePackages;
|
|
59
70
|
exports.resolveComponentName = resolveComponentName.resolveComponentName;
|
|
@@ -126,4 +137,9 @@ exports.panelLayoutType = indexDocument.panelLayoutType;
|
|
|
126
137
|
exports.inspect = inspect.inspect;
|
|
127
138
|
exports.provenanceOf = inspect.provenanceOf;
|
|
128
139
|
exports.applyEdit = applyEdit.applyEdit;
|
|
140
|
+
exports.iconProblem = iconDiagnostics.iconProblem;
|
|
141
|
+
exports.iconProblemsOfItems = iconDiagnostics.iconProblemsOfItems;
|
|
142
|
+
exports.iconProblemsOfProperty = iconDiagnostics.iconProblemsOfProperty;
|
|
143
|
+
exports.diagnoseIcons = diagnoseIcons.diagnoseIcons;
|
|
144
|
+
exports.collectIconUsages = collectIconUsages.collectIconUsages;
|
|
129
145
|
//# 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,8 +1,10 @@
|
|
|
1
1
|
import { EditingScope, QueryCandidate } from '@cratis/scene.model';
|
|
2
|
+
import { EffectiveIconCatalog } from '../icons/EffectiveIconCatalog';
|
|
2
3
|
import { DescriptorCatalog } from './DescriptorCatalog';
|
|
3
4
|
export interface EditingContext {
|
|
4
5
|
catalog: DescriptorCatalog;
|
|
5
6
|
scope: EditingScope;
|
|
6
7
|
queryCandidates?: QueryCandidate[];
|
|
8
|
+
iconCatalog?: EffectiveIconCatalog;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=EditingContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditingContext.d.ts","sourceRoot":"","sources":["../../../editing/EditingContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,MAAM,WAAW,cAAc;IAE3B,OAAO,EAAE,iBAAiB,CAAC;IAG3B,KAAK,EAAE,YAAY,CAAC;IAMpB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACtC"}
|
|
1
|
+
{"version":3,"file":"EditingContext.d.ts","sourceRoot":"","sources":["../../../editing/EditingContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,MAAM,WAAW,cAAc;IAE3B,OAAO,EAAE,iBAAiB,CAAC;IAG3B,KAAK,EAAE,YAAY,CAAC;IAMpB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAUnC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SceneDocument } from '@cratis/scene.model';
|
|
2
|
+
import { IconUsage } from '../icons/IconUsage';
|
|
3
|
+
import { DescriptorCatalog } from './DescriptorCatalog';
|
|
4
|
+
export declare function collectIconUsages(document: SceneDocument, catalog: DescriptorCatalog): IconUsage[];
|
|
5
|
+
//# sourceMappingURL=collectIconUsages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectIconUsages.d.ts","sourceRoot":"","sources":["../../../editing/collectIconUsages.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+D,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAsCjF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,GAAG,SAAS,EAAE,CA6BlG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PropertyValueType } from '@cratis/scene.model';
|
|
2
|
+
import { collectComponents } from './collectComponents.js';
|
|
3
|
+
import { findComponentDescriptor } from './DescriptorCatalog.js';
|
|
4
|
+
import { getValueAtPath } from './pathAccess.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 iconFields(property) {
|
|
9
|
+
return (property.item?.properties ?? []).filter((field)=>field.valueType === PropertyValueType.Icon).map((field)=>field.path);
|
|
10
|
+
}
|
|
11
|
+
function usagesOf(property, value, items, location) {
|
|
12
|
+
if (property.valueType === PropertyValueType.Icon) {
|
|
13
|
+
return value === undefined ? [] : [
|
|
14
|
+
{
|
|
15
|
+
value: value,
|
|
16
|
+
location: `${location}:${property.path}`
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
return property.valueType === PropertyValueType.Collection ? (items ?? []).flatMap((item)=>iconFields(property).filter((field)=>item.values[field] !== undefined).map((field)=>({
|
|
21
|
+
value: item.values[field],
|
|
22
|
+
location: `${location}:${property.path}:${item.id}:${field}`
|
|
23
|
+
}))) : [];
|
|
24
|
+
}
|
|
25
|
+
function ownerItems(value) {
|
|
26
|
+
return (Array.isArray(value) ? value : []).filter((item)=>item !== null && typeof item === 'object').map(({ id, ...values })=>({
|
|
27
|
+
id: String(id),
|
|
28
|
+
values
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Finds every icon value stored anywhere in a document - the values components carry themselves, and the values
|
|
33
|
+
* and collection-item icon fields that template instances contributed - as the `IconUsage`s that
|
|
34
|
+
* `analyzeIconImpact` takes, so "what would removing this library break" can be asked of a whole document.
|
|
35
|
+
*
|
|
36
|
+
* Each usage's `location` reads `<owner or instance>:<component>:<path>[:<itemId>:<field>]`, where the first part is
|
|
37
|
+
* the contributing instance id (`screen:Orders`) for a contributed value and the name of the owning layout or
|
|
38
|
+
* template for a value the component carries. Values are read as stored; none are changed.
|
|
39
|
+
*
|
|
40
|
+
* @param document The document to read.
|
|
41
|
+
* @param catalog The descriptors saying which properties are icons.
|
|
42
|
+
*/ function collectIconUsages(document, catalog) {
|
|
43
|
+
const usages = [];
|
|
44
|
+
const componentNames = new Map();
|
|
45
|
+
const owners = [
|
|
46
|
+
...document.layouts.map((layout)=>({
|
|
47
|
+
name: layout.name,
|
|
48
|
+
value: layout
|
|
49
|
+
})),
|
|
50
|
+
...document.screenTemplates.map((template)=>({
|
|
51
|
+
name: template.name,
|
|
52
|
+
value: template
|
|
53
|
+
})),
|
|
54
|
+
...document.dialogTemplates.map((template)=>({
|
|
55
|
+
name: template.name,
|
|
56
|
+
value: template
|
|
57
|
+
})),
|
|
58
|
+
...document.screens.map((screen)=>({
|
|
59
|
+
name: screen.name,
|
|
60
|
+
value: screen
|
|
61
|
+
}))
|
|
62
|
+
];
|
|
63
|
+
for (const owner of owners){
|
|
64
|
+
for (const component of collectComponents(owner.value)){
|
|
65
|
+
if (!componentNames.has(component.id)) componentNames.set(component.id, component.componentName);
|
|
66
|
+
for (const property of findComponentDescriptor(catalog, component.componentName)?.properties ?? []){
|
|
67
|
+
const value = getValueAtPath(component.properties, property.path);
|
|
68
|
+
usages.push(...usagesOf(property, value, ownerItems(value), `${owner.name}:${component.id}`));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const contribution of document.instanceContributions){
|
|
73
|
+
const componentName = componentNames.get(contribution.component);
|
|
74
|
+
const property = componentName === undefined ? undefined : findComponentDescriptor(catalog, componentName)?.properties.find((candidate)=>candidate.path === contribution.path);
|
|
75
|
+
if (property) usages.push(...contributedUsages(property, contribution));
|
|
76
|
+
}
|
|
77
|
+
return usages;
|
|
78
|
+
}
|
|
79
|
+
function contributedUsages(property, contribution) {
|
|
80
|
+
return usagesOf(property, contribution.value, contribution.items, `${contribution.instance}:${contribution.component}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { collectIconUsages };
|
|
84
|
+
//# sourceMappingURL=collectIconUsages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectIconUsages.js","sources":["../../../editing/collectIconUsages.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 { InstanceContribution, PropertyDescriptor, PropertyValueType, SceneDocument } from '@cratis/scene.model';\nimport { IconUsage } from '../icons/IconUsage';\nimport { collectComponents } from './collectComponents';\nimport { DescriptorCatalog, findComponentDescriptor } from './DescriptorCatalog';\nimport { getValueAtPath } from './pathAccess';\n\nfunction iconFields(property: PropertyDescriptor): string[] {\n return (property.item?.properties ?? []).filter((field) => field.valueType === PropertyValueType.Icon).map((field) => field.path);\n}\n\nfunction usagesOf(property: PropertyDescriptor, value: unknown, items: { id: string; values: Record<string, unknown> }[] | undefined, location: string): IconUsage[] {\n if (property.valueType === PropertyValueType.Icon) {\n return value === undefined ? [] : [{ value: value as IconUsage['value'], location: `${location}:${property.path}` }];\n }\n\n return property.valueType === PropertyValueType.Collection\n ? (items ?? []).flatMap((item) =>\n iconFields(property)\n .filter((field) => item.values[field] !== undefined)\n .map((field) => ({ value: item.values[field] as IconUsage['value'], location: `${location}:${property.path}:${item.id}:${field}` })))\n : [];\n}\n\nfunction ownerItems(value: unknown): { id: string; values: Record<string, unknown> }[] {\n return (Array.isArray(value) ? value : [])\n .filter((item): item is Record<string, unknown> => item !== null && typeof item === 'object')\n .map(({ id, ...values }) => ({ id: String(id), values }));\n}\n\n/**\n * Finds every icon value stored anywhere in a document - the values components carry themselves, and the values\n * and collection-item icon fields that template instances contributed - as the `IconUsage`s that\n * `analyzeIconImpact` takes, so \"what would removing this library break\" can be asked of a whole document.\n *\n * Each usage's `location` reads `<owner or instance>:<component>:<path>[:<itemId>:<field>]`, where the first part is\n * the contributing instance id (`screen:Orders`) for a contributed value and the name of the owning layout or\n * template for a value the component carries. Values are read as stored; none are changed.\n *\n * @param document The document to read.\n * @param catalog The descriptors saying which properties are icons.\n */\nexport function collectIconUsages(document: SceneDocument, catalog: DescriptorCatalog): IconUsage[] {\n const usages: IconUsage[] = [];\n const componentNames = new Map<string, string>();\n\n const owners: { name: string; value: unknown }[] = [\n ...document.layouts.map((layout) => ({ name: layout.name, value: layout })),\n ...document.screenTemplates.map((template) => ({ name: template.name, value: template })),\n ...document.dialogTemplates.map((template) => ({ name: template.name, value: template })),\n ...document.screens.map((screen) => ({ name: screen.name, value: screen })),\n ];\n\n for (const owner of owners) {\n for (const component of collectComponents(owner.value)) {\n if (!componentNames.has(component.id)) componentNames.set(component.id, component.componentName);\n\n for (const property of findComponentDescriptor(catalog, component.componentName)?.properties ?? []) {\n const value = getValueAtPath(component.properties, property.path);\n usages.push(...usagesOf(property, value, ownerItems(value), `${owner.name}:${component.id}`));\n }\n }\n }\n\n for (const contribution of document.instanceContributions) {\n const componentName = componentNames.get(contribution.component);\n const property = componentName === undefined ? undefined : findComponentDescriptor(catalog, componentName)?.properties.find((candidate) => candidate.path === contribution.path);\n if (property) usages.push(...contributedUsages(property, contribution));\n }\n\n return usages;\n}\n\nfunction contributedUsages(property: PropertyDescriptor, contribution: InstanceContribution): IconUsage[] {\n return usagesOf(property, contribution.value, contribution.items, `${contribution.instance}:${contribution.component}`);\n}\n"],"names":["iconFields","property","item","properties","filter","field","valueType","PropertyValueType","Icon","map","path","usagesOf","value","items","location","undefined","Collection","flatMap","values","id","ownerItems","Array","isArray","String","collectIconUsages","document","catalog","usages","componentNames","Map","owners","layouts","layout","name","screenTemplates","template","dialogTemplates","screens","screen","owner","component","collectComponents","has","set","componentName","findComponentDescriptor","getValueAtPath","push","contribution","instanceContributions","get","find","candidate","contributedUsages","instance"],"mappings":";;;;;AAAA;AACA;AAQA,SAASA,WAAWC,QAA4B,EAAA;IAC5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,EAAE+C,YAAkC,EAAA;AACvF,IAAA,OAAOrC,SAASV,QAAAA,EAAU+C,YAAAA,CAAapC,KAAK,EAAEoC,aAAanC,KAAK,EAAE,CAAA,EAAGmC,YAAAA,CAAaM,QAAQ,CAAC,CAAC,EAAEN,YAAAA,CAAaR,SAAS,CAAA,CAAE,CAAA;AAC1H;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SceneDiagnostic, SceneDocument } from '@cratis/scene.model';
|
|
2
|
+
import { EditingContext } from './EditingContext';
|
|
3
|
+
export declare function diagnoseIcons(document: SceneDocument, context: EditingContext): SceneDiagnostic[];
|
|
4
|
+
//# sourceMappingURL=diagnoseIcons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnoseIcons.d.ts","sourceRoot":"","sources":["../../../editing/diagnoseIcons.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6D,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEhI,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuBlD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,eAAe,EAAE,CA+BjG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PropertyValueType, DiagnosticSeverity } from '@cratis/scene.model';
|
|
2
|
+
import { findComponentDescriptor } from './DescriptorCatalog.js';
|
|
3
|
+
import { iconProblemsOfProperty, iconProblemsOfItems } from './iconDiagnostics.js';
|
|
4
|
+
import { getValueAtPath } from './pathAccess.js';
|
|
5
|
+
import { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration.js';
|
|
6
|
+
import { resolveTemplateChain } from './resolveTemplateChain.js';
|
|
7
|
+
|
|
8
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
9
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
10
|
+
function isIconBearing(property) {
|
|
11
|
+
return property.valueType === PropertyValueType.Icon || property.valueType === PropertyValueType.Collection && (property.item?.properties ?? []).some((field)=>field.valueType === PropertyValueType.Icon);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reports every icon in what the editing scope renders - the template chain's own values and what each instance
|
|
15
|
+
* contributed - that the profile's icon catalog cannot supply: a library the profile lacks, an icon or variant a
|
|
16
|
+
* library no longer has, a library at an incompatible version.
|
|
17
|
+
*
|
|
18
|
+
* It reports; it never changes anything. The offending values stay in the document, still applied (a renderer
|
|
19
|
+
* shows its fallback), and apply again as soon as the icon is available, so removing a library is reversible.
|
|
20
|
+
* Each diagnostic names the component, property, collection item and - for a contributed value - the instance.
|
|
21
|
+
*
|
|
22
|
+
* Returns nothing when the context carries no `iconCatalog`. Load the catalogs first (`iconCatalog.load()`) for
|
|
23
|
+
* definite answers; an icon from an unloaded library is reported as not verified.
|
|
24
|
+
*/ function diagnoseIcons(document, context) {
|
|
25
|
+
const iconCatalog = context.iconCatalog;
|
|
26
|
+
if (!iconCatalog) return [];
|
|
27
|
+
const chain = resolveTemplateChain(document, context.scope);
|
|
28
|
+
const configuration = resolveEffectiveConfiguration(chain, document.instanceContributions, context.catalog);
|
|
29
|
+
const diagnostics = [];
|
|
30
|
+
for (const level of chain.levels){
|
|
31
|
+
for (const element of level.elements){
|
|
32
|
+
const descriptor = findComponentDescriptor(context.catalog, element.componentName);
|
|
33
|
+
const configured = configuration.components.find((candidate)=>candidate.component === element.id);
|
|
34
|
+
for (const property of (descriptor?.properties ?? []).filter(isIconBearing)){
|
|
35
|
+
const effective = configured?.values.find((candidate)=>candidate.path === property.path);
|
|
36
|
+
const where = {
|
|
37
|
+
component: element.id,
|
|
38
|
+
...effective?.contributedBy === undefined ? {} : {
|
|
39
|
+
instance: effective.contributedBy
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (property.valueType === PropertyValueType.Icon) {
|
|
43
|
+
const value = effective ? effective.value : getValueAtPath(element.properties, property.path);
|
|
44
|
+
diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, value, DiagnosticSeverity.Warning, where));
|
|
45
|
+
} else if (effective?.items) {
|
|
46
|
+
const items = effective.items.map((item)=>({
|
|
47
|
+
id: item.id,
|
|
48
|
+
values: item.values,
|
|
49
|
+
instance: item.origin === 'owner' ? undefined : item.origin
|
|
50
|
+
}));
|
|
51
|
+
diagnostics.push(...iconProblemsOfItems(iconCatalog, property.item, items, DiagnosticSeverity.Warning, {
|
|
52
|
+
component: element.id,
|
|
53
|
+
path: property.path
|
|
54
|
+
}));
|
|
55
|
+
} else {
|
|
56
|
+
diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, getValueAtPath(element.properties, property.path), DiagnosticSeverity.Warning, where));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return diagnostics;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { diagnoseIcons };
|
|
65
|
+
//# sourceMappingURL=diagnoseIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnoseIcons.js","sources":["../../../editing/diagnoseIcons.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 { DiagnosticSeverity, PropertyDescriptor, PropertyValueType, SceneDiagnostic, SceneDocument } from '@cratis/scene.model';\nimport { findComponentDescriptor } from './DescriptorCatalog';\nimport { EditingContext } from './EditingContext';\nimport { iconProblemsOfItems, iconProblemsOfProperty } from './iconDiagnostics';\nimport { getValueAtPath } from './pathAccess';\nimport { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration';\nimport { resolveTemplateChain } from './resolveTemplateChain';\n\nfunction isIconBearing(property: PropertyDescriptor): boolean {\n return property.valueType === PropertyValueType.Icon\n || (property.valueType === PropertyValueType.Collection && (property.item?.properties ?? []).some((field) => field.valueType === PropertyValueType.Icon));\n}\n\n/**\n * Reports every icon in what the editing scope renders - the template chain's own values and what each instance\n * contributed - that the profile's icon catalog cannot supply: a library the profile lacks, an icon or variant a\n * library no longer has, a library at an incompatible version.\n *\n * It reports; it never changes anything. The offending values stay in the document, still applied (a renderer\n * shows its fallback), and apply again as soon as the icon is available, so removing a library is reversible.\n * Each diagnostic names the component, property, collection item and - for a contributed value - the instance.\n *\n * Returns nothing when the context carries no `iconCatalog`. Load the catalogs first (`iconCatalog.load()`) for\n * definite answers; an icon from an unloaded library is reported as not verified.\n */\nexport function diagnoseIcons(document: SceneDocument, context: EditingContext): SceneDiagnostic[] {\n const iconCatalog = context.iconCatalog;\n if (!iconCatalog) return [];\n\n const chain = resolveTemplateChain(document, context.scope);\n const configuration = resolveEffectiveConfiguration(chain, document.instanceContributions, context.catalog);\n const diagnostics: SceneDiagnostic[] = [];\n\n for (const level of chain.levels) {\n for (const element of level.elements) {\n const descriptor = findComponentDescriptor(context.catalog, element.componentName);\n const configured = configuration.components.find((candidate) => candidate.component === element.id);\n\n for (const property of (descriptor?.properties ?? []).filter(isIconBearing)) {\n const effective = configured?.values.find((candidate) => candidate.path === property.path);\n const where = { component: element.id, ...(effective?.contributedBy === undefined ? {} : { instance: effective.contributedBy }) };\n\n if (property.valueType === PropertyValueType.Icon) {\n const value = effective ? effective.value : getValueAtPath(element.properties, property.path);\n diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, value, DiagnosticSeverity.Warning, where));\n } else if (effective?.items) {\n const items = effective.items.map((item) => ({ id: item.id, values: item.values, instance: item.origin === 'owner' ? undefined : item.origin }));\n diagnostics.push(...iconProblemsOfItems(iconCatalog, property.item, items, DiagnosticSeverity.Warning, { component: element.id, path: property.path }));\n } else {\n diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, getValueAtPath(element.properties, property.path), DiagnosticSeverity.Warning, where));\n }\n }\n }\n }\n\n return diagnostics;\n}\n"],"names":["isIconBearing","property","valueType","PropertyValueType","Icon","Collection","item","properties","some","field","diagnoseIcons","document","context","iconCatalog","chain","resolveTemplateChain","scope","configuration","resolveEffectiveConfiguration","instanceContributions","catalog","diagnostics","level","levels","element","elements","descriptor","findComponentDescriptor","componentName","configured","components","find","candidate","component","id","filter","effective","values","path","where","contributedBy","undefined","instance","value","getValueAtPath","push","iconProblemsOfProperty","DiagnosticSeverity","Warning","items","map","origin","iconProblemsOfItems"],"mappings":";;;;;;;AAAA;AACA;AAUA,SAASA,cAAcC,QAA4B,EAAA;AAC/C,IAAA,OAAOA,QAAAA,CAASC,SAAS,KAAKC,iBAAAA,CAAkBC,IAAI,IAC5CH,QAAAA,CAASC,SAAS,KAAKC,iBAAAA,CAAkBE,UAAU,IAAI,CAACJ,QAAAA,CAASK,IAAI,EAAEC,UAAAA,IAAc,EAAC,EAAGC,IAAI,CAAC,CAACC,KAAAA,GAAUA,KAAAA,CAAMP,SAAS,KAAKC,kBAAkBC,IAAI,CAAA;AAC/J;AAEA;;;;;;;;;;;AAWC,IACM,SAASM,aAAAA,CAAcC,QAAuB,EAAEC,OAAuB,EAAA;IAC1E,MAAMC,WAAAA,GAAcD,QAAQC,WAAW;IACvC,IAAI,CAACA,WAAAA,EAAa,OAAO,EAAE;AAE3B,IAAA,MAAMC,KAAAA,GAAQC,oBAAAA,CAAqBJ,QAAAA,EAAUC,OAAAA,CAAQI,KAAK,CAAA;AAC1D,IAAA,MAAMC,gBAAgBC,6BAAAA,CAA8BJ,KAAAA,EAAOH,SAASQ,qBAAqB,EAAEP,QAAQQ,OAAO,CAAA;AAC1G,IAAA,MAAMC,cAAiC,EAAE;AAEzC,IAAA,KAAK,MAAMC,KAAAA,IAASR,KAAAA,CAAMS,MAAM,CAAE;AAC9B,QAAA,KAAK,MAAMC,OAAAA,IAAWF,KAAAA,CAAMG,QAAQ,CAAE;AAClC,YAAA,MAAMC,aAAaC,uBAAAA,CAAwBf,OAAAA,CAAQQ,OAAO,EAAEI,QAAQI,aAAa,CAAA;AACjF,YAAA,MAAMC,UAAAA,GAAaZ,aAAAA,CAAca,UAAU,CAACC,IAAI,CAAC,CAAC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B,WAAAA,CAAYwB,IAAI,CAAA,GAAIO,mBAAAA,CAAoBvC,WAAAA,EAAaZ,QAAAA,CAASK,IAAI,EAAE2C,KAAAA,EAAOF,kBAAAA,CAAmBC,OAAO,EAAE;AAAEf,wBAAAA,SAAAA,EAAWT,QAAQU,EAAE;AAAEI,wBAAAA,IAAAA,EAAMrC,SAASqC;AAAK,qBAAA,CAAA,CAAA;gBACxJ,CAAA,MAAO;AACHjB,oBAAAA,WAAAA,CAAYwB,IAAI,CAAA,GAAIC,sBAAAA,CAAuBjC,WAAAA,EAAaZ,UAAU2C,cAAAA,CAAepB,OAAAA,CAAQjB,UAAU,EAAEN,QAAAA,CAASqC,IAAI,CAAA,EAAGS,kBAAAA,CAAmBC,OAAO,EAAET,KAAAA,CAAAA,CAAAA;AACrJ,gBAAA;AACJ,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAOlB,WAAAA;AACX;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CollectionItemDescriptor, DiagnosticSeverity, PropertyDescriptor, SceneDiagnostic } from '@cratis/scene.model';
|
|
2
|
+
import { EffectiveIconCatalog } from '../icons/EffectiveIconCatalog';
|
|
3
|
+
import { DiagnosticContext } from './diagnostics';
|
|
4
|
+
export declare function iconProblem(catalog: EffectiveIconCatalog, value: unknown, severity: DiagnosticSeverity, context: DiagnosticContext): SceneDiagnostic | undefined;
|
|
5
|
+
export declare function iconProblemsOfItems(catalog: EffectiveIconCatalog, itemDescriptor: CollectionItemDescriptor | undefined, items: {
|
|
6
|
+
id: string;
|
|
7
|
+
values: Record<string, unknown>;
|
|
8
|
+
instance?: string;
|
|
9
|
+
}[], severity: DiagnosticSeverity, context: DiagnosticContext): SceneDiagnostic[];
|
|
10
|
+
export declare function iconProblemsOfProperty(catalog: EffectiveIconCatalog, descriptor: PropertyDescriptor, value: unknown, severity: DiagnosticSeverity, context: DiagnosticContext): SceneDiagnostic[];
|
|
11
|
+
//# sourceMappingURL=iconDiagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconDiagnostics.d.ts","sourceRoot":"","sources":["../../../editing/iconDiagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAkB,kBAAkB,EAAE,kBAAkB,EAAqB,eAAe,EAAmB,MAAM,qBAAqB,CAAC;AAC5K,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAwBlD,wBAAgB,WAAW,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,SAAS,CAchK;AAQD,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,oBAAoB,EAC7B,cAAc,EAAE,wBAAwB,GAAG,SAAS,EACpD,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3E,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,iBAAiB,GAC3B,eAAe,EAAE,CAQnB;AASD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,GAAG,eAAe,EAAE,CAcjM"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { DiagnosticCode, isIconReference, DiagnosticSeverity, PropertyValueType } 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
|
+
const codes = {
|
|
6
|
+
'missing-library': DiagnosticCode.MissingIconLibrary,
|
|
7
|
+
'missing-icon': DiagnosticCode.MissingIcon,
|
|
8
|
+
'missing-variant': DiagnosticCode.MissingIconVariant,
|
|
9
|
+
'incompatible-version': DiagnosticCode.IncompatibleIconLibrary,
|
|
10
|
+
'catalog-unavailable': DiagnosticCode.IconCatalogUnavailable
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Checks one icon value against the effective icon catalog.
|
|
14
|
+
*
|
|
15
|
+
* Nothing is rewritten or dropped: this only reports. A value whose library, icon or variant is missing, or
|
|
16
|
+
* whose library is at an incompatible version, produces a diagnostic of the given severity - an error when
|
|
17
|
+
* the value is being *set* (the edit is refused), a warning when it is already stored (it is kept, and
|
|
18
|
+
* applies again if the icon comes back). A value that cannot be judged yet, because its library's catalog has
|
|
19
|
+
* not been loaded, produces an `IconNotVerified` warning rather than silently passing.
|
|
20
|
+
*
|
|
21
|
+
* @param catalog The effective catalog of the profile being edited.
|
|
22
|
+
* @param value The value; anything that is not an icon reference is left to `validateValue`.
|
|
23
|
+
* @param severity How serious a definite problem is.
|
|
24
|
+
* @param context What the diagnostic is about.
|
|
25
|
+
*/ function iconProblem(catalog, value, severity, context) {
|
|
26
|
+
if (!isIconReference(value)) return undefined;
|
|
27
|
+
const resolution = catalog.lookup(value);
|
|
28
|
+
if (resolution === undefined) {
|
|
29
|
+
return {
|
|
30
|
+
code: DiagnosticCode.IconNotVerified,
|
|
31
|
+
severity: DiagnosticSeverity.Warning,
|
|
32
|
+
message: `The catalog of the icon library '${value.library}' is not loaded, so '${value.key}' could not be verified.`,
|
|
33
|
+
...context
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return resolution.isResolved ? undefined : {
|
|
37
|
+
code: codes[resolution.diagnostic.kind],
|
|
38
|
+
severity,
|
|
39
|
+
message: `${resolution.diagnostic.message}.`,
|
|
40
|
+
...context
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks the icon fields of collection items.
|
|
45
|
+
*
|
|
46
|
+
* @param itemDescriptor What the items look like.
|
|
47
|
+
* @param items The items, each with its id and field values.
|
|
48
|
+
*/ function iconProblemsOfItems(catalog, itemDescriptor, items, severity, context) {
|
|
49
|
+
const iconFields = (itemDescriptor?.properties ?? []).filter((field)=>field.valueType === PropertyValueType.Icon);
|
|
50
|
+
return items.flatMap((item)=>iconFields.flatMap((field)=>{
|
|
51
|
+
const problem = iconProblem(catalog, item.values[field.path], severity, {
|
|
52
|
+
...context,
|
|
53
|
+
itemId: item.id,
|
|
54
|
+
...item.instance === undefined ? {} : {
|
|
55
|
+
instance: item.instance
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return problem ? [
|
|
59
|
+
{
|
|
60
|
+
...problem,
|
|
61
|
+
message: `'${field.label}' of '${item.id}': ${problem.message}`
|
|
62
|
+
}
|
|
63
|
+
] : [];
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Checks a property's value - an icon, or a collection whose items have icon fields - against the effective icon
|
|
68
|
+
* catalog. Any other kind of property has nothing to check.
|
|
69
|
+
*
|
|
70
|
+
* @param descriptor The property.
|
|
71
|
+
* @param value The value; for a collection, the flat items (`{ id, ...fields }`) as they are stored.
|
|
72
|
+
*/ function iconProblemsOfProperty(catalog, descriptor, value, severity, context) {
|
|
73
|
+
if (descriptor.valueType === PropertyValueType.Icon) {
|
|
74
|
+
const problem = iconProblem(catalog, value, severity, {
|
|
75
|
+
...context,
|
|
76
|
+
path: descriptor.path
|
|
77
|
+
});
|
|
78
|
+
return problem ? [
|
|
79
|
+
{
|
|
80
|
+
...problem,
|
|
81
|
+
message: `'${descriptor.label}': ${problem.message}`
|
|
82
|
+
}
|
|
83
|
+
] : [];
|
|
84
|
+
}
|
|
85
|
+
if (descriptor.valueType === PropertyValueType.Collection && Array.isArray(value)) {
|
|
86
|
+
const items = value.filter((item)=>item !== null && typeof item === 'object').map(({ id, ...values })=>({
|
|
87
|
+
id: String(id),
|
|
88
|
+
values
|
|
89
|
+
}));
|
|
90
|
+
return iconProblemsOfItems(catalog, descriptor.item, items, severity, {
|
|
91
|
+
...context,
|
|
92
|
+
path: descriptor.path
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { iconProblem, iconProblemsOfItems, iconProblemsOfProperty };
|
|
99
|
+
//# sourceMappingURL=iconDiagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconDiagnostics.js","sources":["../../../editing/iconDiagnostics.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 { CollectionItemDescriptor, DiagnosticCode, DiagnosticSeverity, PropertyDescriptor, PropertyValueType, SceneDiagnostic, isIconReference } from '@cratis/scene.model';\nimport { EffectiveIconCatalog } from '../icons/EffectiveIconCatalog';\nimport { IconDiagnosticKind } from '../icons/IconDiagnostic';\nimport { DiagnosticContext } from './diagnostics';\n\nconst codes: Record<IconDiagnosticKind, DiagnosticCode> = {\n 'missing-library': DiagnosticCode.MissingIconLibrary,\n 'missing-icon': DiagnosticCode.MissingIcon,\n 'missing-variant': DiagnosticCode.MissingIconVariant,\n 'incompatible-version': DiagnosticCode.IncompatibleIconLibrary,\n 'catalog-unavailable': DiagnosticCode.IconCatalogUnavailable,\n};\n\n/**\n * Checks one icon value against the effective icon catalog.\n *\n * Nothing is rewritten or dropped: this only reports. A value whose library, icon or variant is missing, or\n * whose library is at an incompatible version, produces a diagnostic of the given severity - an error when\n * the value is being *set* (the edit is refused), a warning when it is already stored (it is kept, and\n * applies again if the icon comes back). A value that cannot be judged yet, because its library's catalog has\n * not been loaded, produces an `IconNotVerified` warning rather than silently passing.\n *\n * @param catalog The effective catalog of the profile being edited.\n * @param value The value; anything that is not an icon reference is left to `validateValue`.\n * @param severity How serious a definite problem is.\n * @param context What the diagnostic is about.\n */\nexport function iconProblem(catalog: EffectiveIconCatalog, value: unknown, severity: DiagnosticSeverity, context: DiagnosticContext): SceneDiagnostic | undefined {\n if (!isIconReference(value)) return undefined;\n\n const resolution = catalog.lookup(value);\n if (resolution === undefined) {\n return {\n code: DiagnosticCode.IconNotVerified,\n severity: DiagnosticSeverity.Warning,\n message: `The catalog of the icon library '${value.library}' is not loaded, so '${value.key}' could not be verified.`,\n ...context,\n };\n }\n\n return resolution.isResolved ? undefined : { code: codes[resolution.diagnostic.kind], severity, message: `${resolution.diagnostic.message}.`, ...context };\n}\n\n/**\n * Checks the icon fields of collection items.\n *\n * @param itemDescriptor What the items look like.\n * @param items The items, each with its id and field values.\n */\nexport function iconProblemsOfItems(\n catalog: EffectiveIconCatalog,\n itemDescriptor: CollectionItemDescriptor | undefined,\n items: { id: string; values: Record<string, unknown>; instance?: string }[],\n severity: DiagnosticSeverity,\n context: DiagnosticContext\n): SceneDiagnostic[] {\n const iconFields = (itemDescriptor?.properties ?? []).filter((field) => field.valueType === PropertyValueType.Icon);\n return items.flatMap((item) =>\n iconFields.flatMap((field) => {\n const problem = iconProblem(catalog, item.values[field.path], severity, { ...context, itemId: item.id, ...(item.instance === undefined ? {} : { instance: item.instance }) });\n return problem ? [{ ...problem, message: `'${field.label}' of '${item.id}': ${problem.message}` }] : [];\n })\n );\n}\n\n/**\n * Checks a property's value - an icon, or a collection whose items have icon fields - against the effective icon\n * catalog. Any other kind of property has nothing to check.\n *\n * @param descriptor The property.\n * @param value The value; for a collection, the flat items (`{ id, ...fields }`) as they are stored.\n */\nexport function iconProblemsOfProperty(catalog: EffectiveIconCatalog, descriptor: PropertyDescriptor, value: unknown, severity: DiagnosticSeverity, context: DiagnosticContext): SceneDiagnostic[] {\n if (descriptor.valueType === PropertyValueType.Icon) {\n const problem = iconProblem(catalog, value, severity, { ...context, path: descriptor.path });\n return problem ? [{ ...problem, message: `'${descriptor.label}': ${problem.message}` }] : [];\n }\n\n if (descriptor.valueType === PropertyValueType.Collection && Array.isArray(value)) {\n const items = value\n .filter((item): item is Record<string, unknown> => item !== null && typeof item === 'object')\n .map(({ id, ...values }) => ({ id: String(id), values }));\n return iconProblemsOfItems(catalog, descriptor.item, items, severity, { ...context, path: descriptor.path });\n }\n\n return [];\n}\n"],"names":["codes","DiagnosticCode","MissingIconLibrary","MissingIcon","MissingIconVariant","IncompatibleIconLibrary","IconCatalogUnavailable","iconProblem","catalog","value","severity","context","isIconReference","undefined","resolution","lookup","code","IconNotVerified","DiagnosticSeverity","Warning","message","library","key","isResolved","diagnostic","kind","iconProblemsOfItems","itemDescriptor","items","iconFields","properties","filter","field","valueType","PropertyValueType","Icon","flatMap","item","problem","values","path","itemId","id","instance","label","iconProblemsOfProperty","descriptor","Collection","Array","isArray","map","String"],"mappings":";;AAAA;AACA;AAOA,MAAMA,KAAAA,GAAoD;AACtD,IAAA,iBAAA,EAAmBC,eAAeC,kBAAkB;AACpD,IAAA,cAAA,EAAgBD,eAAeE,WAAW;AAC1C,IAAA,iBAAA,EAAmBF,eAAeG,kBAAkB;AACpD,IAAA,sBAAA,EAAwBH,eAAeI,uBAAuB;AAC9D,IAAA,qBAAA,EAAuBJ,eAAeK;AAC1C,CAAA;AAEA;;;;;;;;;;;;;IAcO,SAASC,WAAAA,CAAYC,OAA6B,EAAEC,KAAc,EAAEC,QAA4B,EAAEC,OAA0B,EAAA;IAC/H,IAAI,CAACC,eAAAA,CAAgBH,KAAAA,CAAAA,EAAQ,OAAOI,SAAAA;IAEpC,MAAMC,UAAAA,GAAaN,OAAAA,CAAQO,MAAM,CAACN,KAAAA,CAAAA;AAClC,IAAA,IAAIK,eAAeD,SAAAA,EAAW;QAC1B,OAAO;AACHG,YAAAA,IAAAA,EAAMf,eAAegB,eAAe;AACpCP,YAAAA,QAAAA,EAAUQ,mBAAmBC,OAAO;AACpCC,YAAAA,OAAAA,EAAS,CAAC,iCAAiC,EAAEX,KAAAA,CAAMY,OAAO,CAAC,qBAAqB,EAAEZ,KAAAA,CAAMa,GAAG,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E6B,YAAAA,IAAAA,EAAMM,WAAWN;AAAK,SAAA,CAAA;AAC9G,IAAA;AAEA,IAAA,OAAO,EAAE;AACb;;"}
|
|
@@ -16,4 +16,7 @@ export * from './EditingContext';
|
|
|
16
16
|
export * from './inspect';
|
|
17
17
|
export * from './EditOutcome';
|
|
18
18
|
export * from './applyEdit';
|
|
19
|
+
export * from './iconDiagnostics';
|
|
20
|
+
export * from './diagnoseIcons';
|
|
21
|
+
export * from './collectIconUsages';
|
|
19
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editing/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editing/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -16,4 +16,7 @@ export * from './EditingContext';
|
|
|
16
16
|
export * from './inspect';
|
|
17
17
|
export * from './EditOutcome';
|
|
18
18
|
export * from './applyEdit';
|
|
19
|
+
export * from './iconDiagnostics';
|
|
20
|
+
export * from './diagnoseIcons';
|
|
21
|
+
export * from './collectIconUsages';
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../editing/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../editing/index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../editing/inspect.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../editing/inspect.ts"],"names":[],"mappings":"AAGA,OAAO,EACyF,cAAc,EAC1G,cAAc,EAA0E,aAAa,EACxG,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAY,MAAM,kBAAkB,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUhD,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,GAAG,cAAc,CAO1I;AA0FD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,CAyCpH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { SceneNodeKind, DiagnosticCode, ProvenanceKind, PropertyValueType, ValueSource, EditTarget } from '@cratis/scene.model';
|
|
1
|
+
import { SceneNodeKind, DiagnosticCode, ProvenanceKind, PropertyValueType, ValueSource, EditTarget, DiagnosticSeverity } from '@cratis/scene.model';
|
|
2
2
|
import { describeNode, readNodeValue } from './describeNode.js';
|
|
3
3
|
import { computeExposureGrants, grantKey } from './exposureGrants.js';
|
|
4
|
+
import { iconProblemsOfProperty, iconProblemsOfItems } from './iconDiagnostics.js';
|
|
4
5
|
import { indexDocument } from './indexDocument.js';
|
|
5
6
|
import { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration.js';
|
|
6
7
|
import { resolveTemplateChain } from './resolveTemplateChain.js';
|
|
@@ -74,6 +75,28 @@ function inspectProperty(descriptor, record, provenance, scopeInstance, grants,
|
|
|
74
75
|
}
|
|
75
76
|
return inspected;
|
|
76
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Reports icons the profile cannot supply - on the node itself and in configuration contributed to it. The values
|
|
80
|
+
* stay where they are; these are warnings.
|
|
81
|
+
*/ function iconDiagnosticsOf(properties, iconCatalog, nodeId) {
|
|
82
|
+
return properties.flatMap((property)=>{
|
|
83
|
+
const descriptor = property.descriptor;
|
|
84
|
+
if (descriptor.valueType !== PropertyValueType.Collection) {
|
|
85
|
+
return iconProblemsOfProperty(iconCatalog, descriptor, property.effectiveValue, DiagnosticSeverity.Warning, {
|
|
86
|
+
nodeId
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const items = (property.items ?? []).map((item)=>({
|
|
90
|
+
id: item.id,
|
|
91
|
+
values: item.values,
|
|
92
|
+
instance: item.origin === 'owner' ? undefined : item.origin
|
|
93
|
+
}));
|
|
94
|
+
return iconProblemsOfItems(iconCatalog, descriptor.item, items, DiagnosticSeverity.Warning, {
|
|
95
|
+
nodeId,
|
|
96
|
+
path: descriptor.path
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
77
100
|
/**
|
|
78
101
|
* Describes one node for an editor: what it is, where it comes from, what can be edited on it - with current and
|
|
79
102
|
* effective values and effective editability - and what can be done with it.
|
|
@@ -106,6 +129,10 @@ function inspectProperty(descriptor, record, provenance, scopeInstance, grants,
|
|
|
106
129
|
if (chain.levels.length === 0) {
|
|
107
130
|
diagnostics.push(...chain.diagnostics.filter((diagnostic)=>diagnostic.code === DiagnosticCode.UnknownScope));
|
|
108
131
|
}
|
|
132
|
+
const properties = description.properties.map((descriptor)=>inspectProperty(descriptor, record, provenance, scopeInstance, scopeGrants, configuredValues));
|
|
133
|
+
if (context.iconCatalog) {
|
|
134
|
+
diagnostics.push(...iconDiagnosticsOf(properties, context.iconCatalog, nodeId));
|
|
135
|
+
}
|
|
109
136
|
return {
|
|
110
137
|
nodeId,
|
|
111
138
|
kind: record.kind,
|
|
@@ -113,7 +140,7 @@ function inspectProperty(descriptor, record, provenance, scopeInstance, grants,
|
|
|
113
140
|
label: record.label,
|
|
114
141
|
parentId: record.parentId,
|
|
115
142
|
provenance,
|
|
116
|
-
properties
|
|
143
|
+
properties,
|
|
117
144
|
capabilities: description.capabilities,
|
|
118
145
|
removable: isRemovable(record, provenance),
|
|
119
146
|
diagnostics
|