@cratis/scene.engine 0.1.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/BindingResolver.ts +11 -0
- package/ComponentResolution.ts +22 -0
- package/PackageSelection.ts +87 -0
- package/README.md +40 -0
- package/Renderer.ts +33 -0
- package/aggregateContributions.ts +40 -0
- package/buildStarterProfile.ts +21 -0
- package/computeSizeClass.ts +30 -0
- package/dist/cjs/PackageSelection.js +15 -0
- package/dist/cjs/PackageSelection.js.map +1 -0
- package/dist/cjs/aggregateContributions.js +37 -0
- package/dist/cjs/aggregateContributions.js.map +1 -0
- package/dist/cjs/buildStarterProfile.js +27 -0
- package/dist/cjs/buildStarterProfile.js.map +1 -0
- package/dist/cjs/computeSizeClass.js +31 -0
- package/dist/cjs/computeSizeClass.js.map +1 -0
- package/dist/cjs/elementKind.js +26 -0
- package/dist/cjs/elementKind.js.map +1 -0
- package/dist/cjs/evaluateFlowArrangement.js +31 -0
- package/dist/cjs/evaluateFlowArrangement.js.map +1 -0
- package/dist/cjs/evaluateFreeformArrangement.js +16 -0
- package/dist/cjs/evaluateFreeformArrangement.js.map +1 -0
- package/dist/cjs/evaluateFreeformSlotArrangement.js +18 -0
- package/dist/cjs/evaluateFreeformSlotArrangement.js.map +1 -0
- package/dist/cjs/flowNodeKind.js +40 -0
- package/dist/cjs/flowNodeKind.js.map +1 -0
- package/dist/cjs/incompatibleStarterThemes.js +29 -0
- package/dist/cjs/incompatibleStarterThemes.js.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/packageCatalog.js +63 -0
- package/dist/cjs/packageCatalog.js.map +1 -0
- package/dist/cjs/packageVersionRange.js +113 -0
- package/dist/cjs/packageVersionRange.js.map +1 -0
- package/dist/cjs/renderElement.js +39 -0
- package/dist/cjs/renderElement.js.map +1 -0
- package/dist/cjs/resolveComponentName.js +67 -0
- package/dist/cjs/resolveComponentName.js.map +1 -0
- package/dist/cjs/resolvePackageDependencies.js +149 -0
- package/dist/cjs/resolvePackageDependencies.js.map +1 -0
- package/dist/cjs/resolveScreenTemplates.js +136 -0
- package/dist/cjs/resolveScreenTemplates.js.map +1 -0
- package/dist/cjs/themeCompatibility.js +45 -0
- package/dist/cjs/themeCompatibility.js.map +1 -0
- package/dist/esm/BindingResolver.d.ts +3 -0
- package/dist/esm/BindingResolver.d.ts.map +1 -0
- package/dist/esm/BindingResolver.js +2 -0
- package/dist/esm/BindingResolver.js.map +1 -0
- package/dist/esm/ComponentResolution.d.ts +6 -0
- package/dist/esm/ComponentResolution.d.ts.map +1 -0
- package/dist/esm/ComponentResolution.js +2 -0
- package/dist/esm/ComponentResolution.js.map +1 -0
- package/dist/esm/PackageSelection.d.ts +19 -0
- package/dist/esm/PackageSelection.d.ts.map +1 -0
- package/dist/esm/PackageSelection.js +13 -0
- package/dist/esm/PackageSelection.js.map +1 -0
- package/dist/esm/Renderer.d.ts +8 -0
- package/dist/esm/Renderer.d.ts.map +1 -0
- package/dist/esm/Renderer.js +2 -0
- package/dist/esm/Renderer.js.map +1 -0
- package/dist/esm/aggregateContributions.d.ts +3 -0
- package/dist/esm/aggregateContributions.d.ts.map +1 -0
- package/dist/esm/aggregateContributions.js +35 -0
- package/dist/esm/aggregateContributions.js.map +1 -0
- package/dist/esm/buildStarterProfile.d.ts +3 -0
- package/dist/esm/buildStarterProfile.d.ts.map +1 -0
- package/dist/esm/buildStarterProfile.js +25 -0
- package/dist/esm/buildStarterProfile.js.map +1 -0
- package/dist/esm/computeSizeClass.d.ts +5 -0
- package/dist/esm/computeSizeClass.d.ts.map +1 -0
- package/dist/esm/computeSizeClass.js +27 -0
- package/dist/esm/computeSizeClass.js.map +1 -0
- package/dist/esm/elementKind.d.ts +6 -0
- package/dist/esm/elementKind.d.ts.map +1 -0
- package/dist/esm/elementKind.js +21 -0
- package/dist/esm/elementKind.js.map +1 -0
- package/dist/esm/evaluateFlowArrangement.d.ts +3 -0
- package/dist/esm/evaluateFlowArrangement.d.ts.map +1 -0
- package/dist/esm/evaluateFlowArrangement.js +29 -0
- package/dist/esm/evaluateFlowArrangement.js.map +1 -0
- package/dist/esm/evaluateFreeformArrangement.d.ts +3 -0
- package/dist/esm/evaluateFreeformArrangement.d.ts.map +1 -0
- package/dist/esm/evaluateFreeformArrangement.js +14 -0
- package/dist/esm/evaluateFreeformArrangement.js.map +1 -0
- package/dist/esm/evaluateFreeformSlotArrangement.d.ts +3 -0
- package/dist/esm/evaluateFreeformSlotArrangement.d.ts.map +1 -0
- package/dist/esm/evaluateFreeformSlotArrangement.js +16 -0
- package/dist/esm/evaluateFreeformSlotArrangement.js.map +1 -0
- package/dist/esm/flowNodeKind.d.ts +8 -0
- package/dist/esm/flowNodeKind.d.ts.map +1 -0
- package/dist/esm/flowNodeKind.js +33 -0
- package/dist/esm/flowNodeKind.js.map +1 -0
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.d.ts +2 -0
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.d.ts.map +1 -0
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.js +23 -0
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.js.map +1 -0
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.js +16 -0
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.d.ts +2 -0
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.d.ts.map +1 -0
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.js +17 -0
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.js.map +1 -0
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.js +43 -0
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.js +46 -0
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.js +25 -0
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.js +17 -0
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.js +22 -0
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_packageDependencies/fixtures.d.ts +38 -0
- package/dist/esm/for_packageDependencies/fixtures.d.ts.map +1 -0
- package/dist/esm/for_packageDependencies/fixtures.js +5 -0
- package/dist/esm/for_packageDependencies/fixtures.js.map +1 -0
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.js +29 -0
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.js +10 -0
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.d.ts +2 -0
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.d.ts.map +1 -0
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.js +46 -0
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.js.map +1 -0
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.js +20 -0
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js +30 -0
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.d.ts +2 -0
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.d.ts.map +1 -0
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.js +18 -0
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.js.map +1 -0
- package/dist/esm/incompatibleStarterThemes.d.ts +3 -0
- package/dist/esm/incompatibleStarterThemes.d.ts.map +1 -0
- package/dist/esm/incompatibleStarterThemes.js +27 -0
- package/dist/esm/incompatibleStarterThemes.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/packageCatalog.d.ts +7 -0
- package/dist/esm/packageCatalog.d.ts.map +1 -0
- package/dist/esm/packageCatalog.js +57 -0
- package/dist/esm/packageCatalog.js.map +1 -0
- package/dist/esm/packageVersionRange.d.ts +2 -0
- package/dist/esm/packageVersionRange.d.ts.map +1 -0
- package/dist/esm/packageVersionRange.js +111 -0
- package/dist/esm/packageVersionRange.js.map +1 -0
- package/dist/esm/renderElement.d.ts +5 -0
- package/dist/esm/renderElement.d.ts.map +1 -0
- package/dist/esm/renderElement.js +37 -0
- package/dist/esm/renderElement.js.map +1 -0
- package/dist/esm/resolveComponentName.d.ts +7 -0
- package/dist/esm/resolveComponentName.d.ts.map +1 -0
- package/dist/esm/resolveComponentName.js +63 -0
- package/dist/esm/resolveComponentName.js.map +1 -0
- package/dist/esm/resolvePackageDependencies.d.ts +4 -0
- package/dist/esm/resolvePackageDependencies.d.ts.map +1 -0
- package/dist/esm/resolvePackageDependencies.js +147 -0
- package/dist/esm/resolvePackageDependencies.js.map +1 -0
- package/dist/esm/resolveScreenTemplates.d.ts +20 -0
- package/dist/esm/resolveScreenTemplates.d.ts.map +1 -0
- package/dist/esm/resolveScreenTemplates.js +133 -0
- package/dist/esm/resolveScreenTemplates.js.map +1 -0
- package/dist/esm/themeCompatibility.d.ts +5 -0
- package/dist/esm/themeCompatibility.d.ts.map +1 -0
- package/dist/esm/themeCompatibility.js +41 -0
- package/dist/esm/themeCompatibility.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/elementKind.ts +26 -0
- package/evaluateFlowArrangement.ts +35 -0
- package/evaluateFreeformArrangement.ts +15 -0
- package/evaluateFreeformSlotArrangement.ts +17 -0
- package/flowNodeKind.ts +38 -0
- package/for_aggregateContributions/when_aggregating_by_contribution_point.ts +31 -0
- package/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.ts +32 -0
- package/for_computeSizeClass/when_computing_the_size_class.ts +23 -0
- package/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +67 -0
- package/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +68 -0
- package/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +47 -0
- package/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.ts +34 -0
- package/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.ts +26 -0
- package/for_packageDependencies/fixtures.ts +44 -0
- package/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.ts +39 -0
- package/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.ts +13 -0
- package/for_renderElement/when_rendering_a_mixed_tree.ts +58 -0
- package/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.ts +36 -0
- package/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.ts +49 -0
- package/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.ts +37 -0
- package/incompatibleStarterThemes.ts +24 -0
- package/index.ts +23 -0
- package/package.json +45 -0
- package/packageCatalog.ts +65 -0
- package/packageVersionRange.ts +90 -0
- package/renderElement.ts +40 -0
- package/resolveComponentName.ts +66 -0
- package/resolvePackageDependencies.ts +156 -0
- package/resolveScreenTemplates.ts +191 -0
- package/themeCompatibility.ts +46 -0
package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_resolving_against_the_shared_fixture_corpus.d.ts","sourceRoot":"","sources":["../../../for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { resolveComponentName } from '../index';
|
|
4
|
+
const manifestPath = join(import.meta.dirname, '..', '..', '..', '..', 'package-resolution-fixtures.json');
|
|
5
|
+
const corpus = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
6
|
+
describe('when resolving against the shared fixture corpus', () => {
|
|
7
|
+
for (const fixtureCase of corpus.cases) {
|
|
8
|
+
it(`should match the expected resolution for "${fixtureCase.name}"`, () => {
|
|
9
|
+
const profile = { name: 'test', targetPlatform: 'web', packages: fixtureCase.profile.packages };
|
|
10
|
+
const actual = resolveComponentName(fixtureCase.requestedName, profile, fixtureCase.catalog);
|
|
11
|
+
if (fixtureCase.expected === null) {
|
|
12
|
+
(actual === undefined).should.be.true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
actual.should.deep.equal(fixtureCase.expected);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=when_resolving_against_the_shared_fixture_corpus.js.map
|
package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_resolving_against_the_shared_fixture_cor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
|
+
{"version":3,"file":"when_resolving_against_the_shared_fixture_corpus.d.ts","sourceRoot":"","sources":["../../../for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.ts"],"names":[],"mappings":""}
|
package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { isScreenTemplateResolutionValid, resolveScreenTemplates } from '../index';
|
|
4
|
+
const fixturePath = join(import.meta.dirname, '..', '..', '..', '..', 'screen-template-fixtures.json');
|
|
5
|
+
const corpus = JSON.parse(readFileSync(fixturePath, 'utf-8'));
|
|
6
|
+
describe('when resolving against the shared fixture corpus', () => {
|
|
7
|
+
for (const fixtureCase of corpus.cases) {
|
|
8
|
+
const layout = { name: fixtureCase.layout.name, slots: fixtureCase.layout.slots.map((name) => ({ name })) };
|
|
9
|
+
const templates = fixtureCase.templates.map((template) => ({
|
|
10
|
+
name: template.name,
|
|
11
|
+
fitsSlot: template.fitsSlot ?? undefined,
|
|
12
|
+
slots: template.slots.map((name) => ({ name })),
|
|
13
|
+
}));
|
|
14
|
+
const resolution = resolveScreenTemplates(layout, templates);
|
|
15
|
+
it(`should place every template where the corpus expects for "${fixtureCase.name}"`, () => {
|
|
16
|
+
resolution.placements.should.deep.equal(fixtureCase.expectedPlacements);
|
|
17
|
+
});
|
|
18
|
+
it(`should report the expected unplaced templates for "${fixtureCase.name}"`, () => {
|
|
19
|
+
resolution.unplaced.should.deep.equal(fixtureCase.expectedUnplaced);
|
|
20
|
+
});
|
|
21
|
+
it(`should report the expected cycles for "${fixtureCase.name}"`, () => {
|
|
22
|
+
resolution.cycles.should.deep.equal(fixtureCase.expectedCycles);
|
|
23
|
+
});
|
|
24
|
+
it(`should consider "${fixtureCase.name}" valid only when nothing is wrong`, () => {
|
|
25
|
+
const expectedValid = fixtureCase.expectedUnplaced.length === 0 && fixtureCase.expectedCycles.length === 0;
|
|
26
|
+
isScreenTemplateResolutionValid(resolution).should.equal(expectedValid);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=when_resolving_against_the_shared_fixture_corpus.js.map
|
package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_resolving_against_the_shared_fixture_corpus.js","sourceRoot":"","sources":["../../../for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAWnF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,+BAA+B,CAAC,CAAC;AACvG,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAA6B,CAAC;AAE1F,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC9D,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACrC,MAAM,MAAM,GAAW,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACpH,MAAM,SAAS,GAAqB,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACzE,IAAI,EAAE,QAAQ,CAAC,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pus.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_checking_against_the_shared_fixture_corpus.d.ts","sourceRoot":"","sources":["../../../for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { applicableThemePackages, incompatiblePackages } from '../index';
|
|
4
|
+
const manifestPath = join(import.meta.dirname, '..', '..', '..', '..', 'theme-compatibility-fixtures.json');
|
|
5
|
+
const corpus = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
6
|
+
describe('when checking against the shared fixture corpus', () => {
|
|
7
|
+
for (const fixtureCase of corpus.cases) {
|
|
8
|
+
const theme = { name: 'test-theme', compatibleWith: fixtureCase.theme.compatibleWith };
|
|
9
|
+
const profile = { name: 'test-profile', targetPlatform: 'web', packages: fixtureCase.profile.packages };
|
|
10
|
+
it(`should match the expected incompatible packages for "${fixtureCase.name}"`, () => {
|
|
11
|
+
incompatiblePackages(theme, profile).should.deep.equal(fixtureCase.expectedIncompatible);
|
|
12
|
+
});
|
|
13
|
+
it(`should match the expected applicable packages for "${fixtureCase.name}"`, () => {
|
|
14
|
+
applicableThemePackages(theme, profile).should.deep.equal(fixtureCase.expectedApplicable);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=when_checking_against_the_shared_fixture_corpus.js.map
|
package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_checking_against_the_shared_fixture_corpus.js","sourceRoot":"","sources":["../../../for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MA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.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAclE,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,CAMrG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { incompatiblePackages } from './themeCompatibility.js';
|
|
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
|
+
* Finds the {@link UiStarter.themes} that are not compatible with the starter's own {@link UiStarter.packages} -
|
|
7
|
+
* part of Cratis/Scene#6. A starter is versioned per package combination it targets, so a theme it ships
|
|
8
|
+
* as a choice that turns out incompatible with the starter's own packages is exactly the gap
|
|
9
|
+
* `themeCompatibility` already surfaces for a {@link UiProfile}; this reuses that rule rather than
|
|
10
|
+
* reimplementing it for starters.
|
|
11
|
+
*
|
|
12
|
+
* @param starter The {@link UiStarter} to check.
|
|
13
|
+
* @param themes Every known {@link Theme}, keyed by name.
|
|
14
|
+
* @returns The names in `starter.themes` that are either unknown to `themes` or incompatible with `starter.packages`.
|
|
15
|
+
*/ function incompatibleStarterThemes(starter, themes) {
|
|
16
|
+
const profile = {
|
|
17
|
+
name: starter.name,
|
|
18
|
+
packages: starter.packages
|
|
19
|
+
};
|
|
20
|
+
return starter.themes.filter((name)=>{
|
|
21
|
+
const theme = themes[name];
|
|
22
|
+
return !theme || incompatiblePackages(theme, profile).length > 0;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { incompatibleStarterThemes };
|
|
27
|
+
//# sourceMappingURL=incompatibleStarterThemes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incompatibleStarterThemes.js","sources":["../../incompatibleStarterThemes.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 { Theme, UiProfile, UiStarter } from '@cratis/scene.model';\nimport { incompatiblePackages } from './themeCompatibility';\n\n/**\n * Finds the {@link UiStarter.themes} that are not compatible with the starter's own {@link UiStarter.packages} -\n * part of Cratis/Scene#6. A starter is versioned per package combination it targets, so a theme it ships\n * as a choice that turns out incompatible with the starter's own packages is exactly the gap\n * `themeCompatibility` already surfaces for a {@link UiProfile}; this reuses that rule rather than\n * reimplementing it for starters.\n *\n * @param starter The {@link UiStarter} to check.\n * @param themes Every known {@link Theme}, keyed by name.\n * @returns The names in `starter.themes` that are either unknown to `themes` or incompatible with `starter.packages`.\n */\nexport function incompatibleStarterThemes(starter: UiStarter, themes: Record<string, Theme>): string[] {\n const profile: UiProfile = { name: starter.name, targetPlatform: '', packages: starter.packages };\n return starter.themes.filter(name => {\n const theme = themes[name];\n return !theme || incompatiblePackages(theme, profile).length > 0;\n });\n}\n"],"names":["incompatibleStarterThemes","starter","themes","profile","name","packages","filter","theme","incompatiblePackages","length"],"mappings":";;AAAA;AACA;AAKA;;;;;;;;;;AAUC,IACM,SAASA,yBAAAA,CAA0BC,OAAkB,EAAEC,MAA6B,EAAA;AACvF,IAAA,MAAMC,OAAAA,GAAqB;AAAEC,QAAAA,IAAAA,EAAMH,QAAQG,IAAI;QAAsBC,QAAAA,EAAUJ,QAAQI;AAAS,KAAA;AAChG,IAAA,OAAOJ,OAAAA,CAAQC,MAAM,CAACI,MAAM,CAACF,CAAAA,IAAAA,GAAAA;QACzB,MAAMG,KAAAA,GAAQL,MAAM,CAACE,IAAAA,CAAK;AAC1B,QAAA,OAAO,CAACG,KAAAA,IAASC,oBAAAA,CAAqBD,KAAAA,EAAOJ,OAAAA,CAAAA,CAASM,MAAM,GAAG,CAAA;AACnE,IAAA,CAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './Renderer';
|
|
2
|
+
export * from './BindingResolver';
|
|
3
|
+
export * from './renderElement';
|
|
4
|
+
export * from './elementKind';
|
|
5
|
+
export * from './flowNodeKind';
|
|
6
|
+
export * from './ComponentResolution';
|
|
7
|
+
export * from './resolveComponentName';
|
|
8
|
+
export * from './computeSizeClass';
|
|
9
|
+
export * from './evaluateFlowArrangement';
|
|
10
|
+
export * from './evaluateFreeformArrangement';
|
|
11
|
+
export * from './evaluateFreeformSlotArrangement';
|
|
12
|
+
export * from './aggregateContributions';
|
|
13
|
+
export * from './themeCompatibility';
|
|
14
|
+
export * from './PackageSelection';
|
|
15
|
+
export * from './packageVersionRange';
|
|
16
|
+
export * from './resolvePackageDependencies';
|
|
17
|
+
export * from './packageCatalog';
|
|
18
|
+
export * from './resolveScreenTemplates';
|
|
19
|
+
export * from './buildStarterProfile';
|
|
20
|
+
export * from './incompatibleStarterThemes';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,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,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { renderElement } from './renderElement.js';
|
|
2
|
+
export { isContentControl, isExternalComponent, isItemsControl, isPanel } from './elementKind.js';
|
|
3
|
+
export { isFlowColumn, isFlowContainer, isFlowGrid, isFlowLeaf, isFlowRow, isFlowSlotLeaf } from './flowNodeKind.js';
|
|
4
|
+
export { corePackage, effectivePackages, resolveComponentName } from './resolveComponentName.js';
|
|
5
|
+
export { computeSizeClass, defaultHeightBreakpoint, defaultWidthBreakpoint } from './computeSizeClass.js';
|
|
6
|
+
export { evaluateFlowArrangement } from './evaluateFlowArrangement.js';
|
|
7
|
+
export { evaluateFreeformArrangement } from './evaluateFreeformArrangement.js';
|
|
8
|
+
export { evaluateFreeformSlotArrangement } from './evaluateFreeformSlotArrangement.js';
|
|
9
|
+
export { aggregateContributions } from './aggregateContributions.js';
|
|
10
|
+
export { applicableThemePackages, incompatiblePackages, isThemeCompatible } from './themeCompatibility.js';
|
|
11
|
+
export { isPackageSelectionValid } from './PackageSelection.js';
|
|
12
|
+
export { isVersionSatisfiedBy } from './packageVersionRange.js';
|
|
13
|
+
export { resolvePackageDependencies } from './resolvePackageDependencies.js';
|
|
14
|
+
export { availablePackagesFor, baseComponentLibraries, componentsForPackages, packagesOfKind, toComponentCatalog } from './packageCatalog.js';
|
|
15
|
+
export { isScreenTemplateResolutionValid, resolveScreenTemplates } from './resolveScreenTemplates.js';
|
|
16
|
+
export { buildStarterProfile } from './buildStarterProfile.js';
|
|
17
|
+
export { incompatibleStarterThemes } from './incompatibleStarterThemes.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PackageKind, ScenePackage } from '@cratis/scene.model';
|
|
2
|
+
export declare function packagesOfKind(catalog: ScenePackage[], kind: PackageKind): ScenePackage[];
|
|
3
|
+
export declare function baseComponentLibraries(catalog: ScenePackage[]): ScenePackage[];
|
|
4
|
+
export declare function availablePackagesFor(catalog: ScenePackage[], selected: string[]): ScenePackage[];
|
|
5
|
+
export declare function componentsForPackages(catalog: ScenePackage[], selected: string[]): string[];
|
|
6
|
+
export declare function toComponentCatalog(catalog: ScenePackage[]): Record<string, string[]>;
|
|
7
|
+
//# sourceMappingURL=packageCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageCatalog.d.ts","sourceRoot":"","sources":["../../packageCatalog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKhE,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CAEzF;AAYD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAI9E;AAWD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAKhG;AAMD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI3F;AAKD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAOpF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PackageKind } from '@cratis/scene.model';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* The packages of a given kind.
|
|
7
|
+
*/ function packagesOfKind(catalog, kind) {
|
|
8
|
+
return catalog.filter((scenePackage)=>scenePackage.kind === kind);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The component libraries a profile can be founded on — the ones that do not themselves layer on another
|
|
12
|
+
* component library.
|
|
13
|
+
*
|
|
14
|
+
* "Base" is not a declared property; it falls out of the dependency graph. PrimeReact depends on a
|
|
15
|
+
* styling package but on no other component library, so it is a base. `@cratis/components` depends on
|
|
16
|
+
* PrimeReact, so it is not — it is something you add on top of a base you already picked. Deriving it
|
|
17
|
+
* this way means a third party shipping their own library gets classified correctly without having to
|
|
18
|
+
* declare anything extra.
|
|
19
|
+
*/ function baseComponentLibraries(catalog) {
|
|
20
|
+
const libraries = packagesOfKind(catalog, PackageKind.ComponentLibrary);
|
|
21
|
+
const names = new Set(libraries.map((scenePackage)=>scenePackage.name));
|
|
22
|
+
return libraries.filter((scenePackage)=>!scenePackage.dependencies.some((dependency)=>names.has(dependency.name)));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The packages that can be added to a selection without pulling anything else in — every dependency they
|
|
26
|
+
* declare is already selected.
|
|
27
|
+
*
|
|
28
|
+
* This is the "what else works with what I have picked" list: choose PrimeReact and Tailwind, and
|
|
29
|
+
* `@cratis/components` becomes available because both of its dependencies are now met. It is
|
|
30
|
+
* deliberately stricter than {@link resolvePackageDependencies}, which will happily add the missing
|
|
31
|
+
* dependencies for you — a picker wants to show what fits, not what would drag more in.
|
|
32
|
+
*/ function availablePackagesFor(catalog, selected) {
|
|
33
|
+
const chosen = new Set(selected);
|
|
34
|
+
return catalog.filter((scenePackage)=>!chosen.has(scenePackage.name) && scenePackage.dependencies.every((dependency)=>chosen.has(dependency.name)));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Every component name the selected packages declare between them, without duplicates, sorted so a
|
|
38
|
+
* component picker has a stable list to show.
|
|
39
|
+
*/ function componentsForPackages(catalog, selected) {
|
|
40
|
+
const chosen = new Set(selected);
|
|
41
|
+
const components = catalog.filter((scenePackage)=>chosen.has(scenePackage.name)).flatMap((scenePackage)=>scenePackage.components);
|
|
42
|
+
return [
|
|
43
|
+
...new Set(components)
|
|
44
|
+
].sort();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds the component-name catalog `resolveComponentName` resolves against.
|
|
48
|
+
*/ function toComponentCatalog(catalog) {
|
|
49
|
+
const components = {};
|
|
50
|
+
for (const scenePackage of catalog){
|
|
51
|
+
components[scenePackage.name] = scenePackage.components;
|
|
52
|
+
}
|
|
53
|
+
return components;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { availablePackagesFor, baseComponentLibraries, componentsForPackages, packagesOfKind, toComponentCatalog };
|
|
57
|
+
//# sourceMappingURL=packageCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageCatalog.js","sources":["../../packageCatalog.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';\n\n/**\n * The packages of a given kind.\n */\nexport function packagesOfKind(catalog: ScenePackage[], kind: PackageKind): ScenePackage[] {\n return catalog.filter((scenePackage) => scenePackage.kind === kind);\n}\n\n/**\n * The component libraries a profile can be founded on — the ones that do not themselves layer on another\n * component library.\n *\n * \"Base\" is not a declared property; it falls out of the dependency graph. PrimeReact depends on a\n * styling package but on no other component library, so it is a base. `@cratis/components` depends on\n * PrimeReact, so it is not — it is something you add on top of a base you already picked. Deriving it\n * this way means a third party shipping their own library gets classified correctly without having to\n * declare anything extra.\n */\nexport function baseComponentLibraries(catalog: ScenePackage[]): ScenePackage[] {\n const libraries = packagesOfKind(catalog, PackageKind.ComponentLibrary);\n const names = new Set(libraries.map((scenePackage) => scenePackage.name));\n return libraries.filter((scenePackage) => !scenePackage.dependencies.some((dependency) => names.has(dependency.name)));\n}\n\n/**\n * The packages that can be added to a selection without pulling anything else in — every dependency they\n * declare is already selected.\n *\n * This is the \"what else works with what I have picked\" list: choose PrimeReact and Tailwind, and\n * `@cratis/components` becomes available because both of its dependencies are now met. It is\n * deliberately stricter than {@link resolvePackageDependencies}, which will happily add the missing\n * dependencies for you — a picker wants to show what fits, not what would drag more in.\n */\nexport function availablePackagesFor(catalog: ScenePackage[], selected: string[]): ScenePackage[] {\n const chosen = new Set(selected);\n return catalog.filter(\n (scenePackage) => !chosen.has(scenePackage.name) && scenePackage.dependencies.every((dependency) => chosen.has(dependency.name))\n );\n}\n\n/**\n * Every component name the selected packages declare between them, without duplicates, sorted so a\n * component picker has a stable list to show.\n */\nexport function componentsForPackages(catalog: ScenePackage[], selected: string[]): string[] {\n const chosen = new Set(selected);\n const components = catalog.filter((scenePackage) => chosen.has(scenePackage.name)).flatMap((scenePackage) => scenePackage.components);\n return [...new Set(components)].sort();\n}\n\n/**\n * Builds the component-name catalog `resolveComponentName` resolves against.\n */\nexport function toComponentCatalog(catalog: ScenePackage[]): Record<string, string[]> {\n const components: Record<string, string[]> = {};\n for (const scenePackage of catalog) {\n components[scenePackage.name] = scenePackage.components;\n }\n\n return components;\n}\n"],"names":["packagesOfKind","catalog","kind","filter","scenePackage","baseComponentLibraries","libraries","PackageKind","ComponentLibrary","names","Set","map","name","dependencies","some","dependency","has","availablePackagesFor","selected","chosen","every","componentsForPackages","components","flatMap","sort","toComponentCatalog"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,cAAAA,CAAeC,OAAuB,EAAEC,IAAiB,EAAA;AACrE,IAAA,OAAOD,QAAQE,MAAM,CAAC,CAACC,YAAAA,GAAiBA,YAAAA,CAAaF,IAAI,KAAKA,IAAAA,CAAAA;AAClE;AAEA;;;;;;;;;IAUO,SAASG,sBAAAA,CAAuBJ,OAAuB,EAAA;AAC1D,IAAA,MAAMK,SAAAA,GAAYN,cAAAA,CAAeC,OAAAA,EAASM,WAAAA,CAAYC,gBAAgB,CAAA;IACtE,MAAMC,KAAAA,GAAQ,IAAIC,GAAAA,CAAIJ,SAAAA,CAAUK,GAAG,CAAC,CAACP,YAAAA,GAAiBA,YAAAA,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IAEA,OAAOA,UAAAA;AACX;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersionRange.d.ts","sourceRoot":"","sources":["../../packageVersionRange.ts"],"names":[],"mappings":"AAeA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CA2BxF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Checks a {@link PackageDependency.versionRange} against a package's actual version. A deliberately
|
|
5
|
+
* small subset of semver — enough to express what a package declaration realistically needs, and small
|
|
6
|
+
* enough that the C# twin in `Cratis.Scene.Engine` can match it exactly rather than approximately. Both
|
|
7
|
+
* sides are asserted against the same shared fixture corpus.
|
|
8
|
+
*
|
|
9
|
+
* Supported: an empty range or `*` (anything), a bare or `=`-prefixed exact version, `^` (npm caret —
|
|
10
|
+
* compatible within the leftmost non-zero component), `~` (patch-level changes), and the comparisons
|
|
11
|
+
* `>=`, `>`, `<=`, `<`. Versions are read as `major.minor.patch` with any pre-release or build metadata
|
|
12
|
+
* suffix ignored. Anything the parser does not recognize is treated as unsatisfiable rather than as
|
|
13
|
+
* "anything", so a typo surfaces as a conflict instead of silently passing.
|
|
14
|
+
*/ function isVersionSatisfiedBy(version, range) {
|
|
15
|
+
const trimmed = range?.trim();
|
|
16
|
+
if (!trimmed || trimmed === '*') return true;
|
|
17
|
+
const actual = parseVersion(version);
|
|
18
|
+
if (!actual) return false;
|
|
19
|
+
const [operator, literal] = splitRange(trimmed);
|
|
20
|
+
const required = parseVersion(literal);
|
|
21
|
+
if (!required) return false;
|
|
22
|
+
switch(operator){
|
|
23
|
+
case '^':
|
|
24
|
+
return compare(actual, required) >= 0 && compare(actual, caretUpperBound(required)) < 0;
|
|
25
|
+
case '~':
|
|
26
|
+
return compare(actual, required) >= 0 && compare(actual, [
|
|
27
|
+
required[0],
|
|
28
|
+
required[1] + 1,
|
|
29
|
+
0
|
|
30
|
+
]) < 0;
|
|
31
|
+
case '>=':
|
|
32
|
+
return compare(actual, required) >= 0;
|
|
33
|
+
case '>':
|
|
34
|
+
return compare(actual, required) > 0;
|
|
35
|
+
case '<=':
|
|
36
|
+
return compare(actual, required) <= 0;
|
|
37
|
+
case '<':
|
|
38
|
+
return compare(actual, required) < 0;
|
|
39
|
+
default:
|
|
40
|
+
return compare(actual, required) === 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function splitRange(range) {
|
|
44
|
+
for (const operator of [
|
|
45
|
+
'>=',
|
|
46
|
+
'<=',
|
|
47
|
+
'^',
|
|
48
|
+
'~',
|
|
49
|
+
'>',
|
|
50
|
+
'<',
|
|
51
|
+
'='
|
|
52
|
+
]){
|
|
53
|
+
if (range.startsWith(operator)) {
|
|
54
|
+
return [
|
|
55
|
+
operator === '=' ? '' : operator,
|
|
56
|
+
range.substring(operator.length).trim()
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
'',
|
|
62
|
+
range
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* npm's caret rule: compatibility is bounded by the leftmost non-zero component, so `^1.2.3` allows
|
|
67
|
+
* anything below `2.0.0`, `^0.2.3` anything below `0.3.0`, and `^0.0.3` only `0.0.3` itself.
|
|
68
|
+
*/ function caretUpperBound(version) {
|
|
69
|
+
if (version[0] > 0) return [
|
|
70
|
+
version[0] + 1,
|
|
71
|
+
0,
|
|
72
|
+
0
|
|
73
|
+
];
|
|
74
|
+
if (version[1] > 0) return [
|
|
75
|
+
0,
|
|
76
|
+
version[1] + 1,
|
|
77
|
+
0
|
|
78
|
+
];
|
|
79
|
+
return [
|
|
80
|
+
0,
|
|
81
|
+
0,
|
|
82
|
+
version[2] + 1
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function compare(left, right) {
|
|
86
|
+
if (left[0] !== right[0]) return left[0] - right[0];
|
|
87
|
+
if (left[1] !== right[1]) return left[1] - right[1];
|
|
88
|
+
return left[2] - right[2];
|
|
89
|
+
}
|
|
90
|
+
function parseVersion(value) {
|
|
91
|
+
let numeric = value.trim();
|
|
92
|
+
const suffix = numeric.search(/[-+]/);
|
|
93
|
+
if (suffix >= 0) {
|
|
94
|
+
numeric = numeric.substring(0, suffix);
|
|
95
|
+
}
|
|
96
|
+
const parts = numeric.split('.');
|
|
97
|
+
if (parts.length === 0 || parts.length > 3) return undefined;
|
|
98
|
+
const components = [
|
|
99
|
+
0,
|
|
100
|
+
0,
|
|
101
|
+
0
|
|
102
|
+
];
|
|
103
|
+
for(let index = 0; index < parts.length; index++){
|
|
104
|
+
if (!/^\d+$/.test(parts[index])) return undefined;
|
|
105
|
+
components[index] = parseInt(parts[index], 10);
|
|
106
|
+
}
|
|
107
|
+
return components;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { isVersionSatisfiedBy };
|
|
111
|
+
//# sourceMappingURL=packageVersionRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersionRange.js","sources":["../../packageVersionRange.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Checks a {@link PackageDependency.versionRange} against a package's actual version. A deliberately\n * small subset of semver — enough to express what a package declaration realistically needs, and small\n * enough that the C# twin in `Cratis.Scene.Engine` can match it exactly rather than approximately. Both\n * sides are asserted against the same shared fixture corpus.\n *\n * Supported: an empty range or `*` (anything), a bare or `=`-prefixed exact version, `^` (npm caret —\n * compatible within the leftmost non-zero component), `~` (patch-level changes), and the comparisons\n * `>=`, `>`, `<=`, `<`. Versions are read as `major.minor.patch` with any pre-release or build metadata\n * suffix ignored. Anything the parser does not recognize is treated as unsatisfiable rather than as\n * \"anything\", so a typo surfaces as a conflict instead of silently passing.\n */\nexport function isVersionSatisfiedBy(version: string, range: string | undefined): boolean {\n const trimmed = range?.trim();\n if (!trimmed || trimmed === '*') return true;\n\n const actual = parseVersion(version);\n if (!actual) return false;\n\n const [operator, literal] = splitRange(trimmed);\n const required = parseVersion(literal);\n if (!required) return false;\n\n switch (operator) {\n case '^':\n return compare(actual, required) >= 0 && compare(actual, caretUpperBound(required)) < 0;\n case '~':\n return compare(actual, required) >= 0 && compare(actual, [required[0], required[1] + 1, 0]) < 0;\n case '>=':\n return compare(actual, required) >= 0;\n case '>':\n return compare(actual, required) > 0;\n case '<=':\n return compare(actual, required) <= 0;\n case '<':\n return compare(actual, required) < 0;\n default:\n return compare(actual, required) === 0;\n }\n}\n\ntype Version = [number, number, number];\n\nfunction splitRange(range: string): [string, string] {\n for (const operator of ['>=', '<=', '^', '~', '>', '<', '=']) {\n if (range.startsWith(operator)) {\n return [operator === '=' ? '' : operator, range.substring(operator.length).trim()];\n }\n }\n\n return ['', range];\n}\n\n/**\n * npm's caret rule: compatibility is bounded by the leftmost non-zero component, so `^1.2.3` allows\n * anything below `2.0.0`, `^0.2.3` anything below `0.3.0`, and `^0.0.3` only `0.0.3` itself.\n */\nfunction caretUpperBound(version: Version): Version {\n if (version[0] > 0) return [version[0] + 1, 0, 0];\n if (version[1] > 0) return [0, version[1] + 1, 0];\n return [0, 0, version[2] + 1];\n}\n\nfunction compare(left: Version, right: Version): number {\n if (left[0] !== right[0]) return left[0] - right[0];\n if (left[1] !== right[1]) return left[1] - right[1];\n return left[2] - right[2];\n}\n\nfunction parseVersion(value: string): Version | undefined {\n let numeric = value.trim();\n const suffix = numeric.search(/[-+]/);\n if (suffix >= 0) {\n numeric = numeric.substring(0, suffix);\n }\n\n const parts = numeric.split('.');\n if (parts.length === 0 || parts.length > 3) return undefined;\n\n const components: Version = [0, 0, 0];\n for (let index = 0; index < parts.length; index++) {\n if (!/^\\d+$/.test(parts[index])) return undefined;\n components[index] = parseInt(parts[index], 10);\n }\n\n return components;\n}\n"],"names":["isVersionSatisfiedBy","version","range","trimmed","trim","actual","parseVersion","operator","literal","splitRange","required","compare","caretUpperBound","startsWith","substring","length","left","right","value","numeric","suffix","search","parts","split","undefined","components","index","test","parseInt"],"mappings":"AAAA;AACA;AAEA;;;;;;;;;;;AAWC,IACM,SAASA,oBAAAA,CAAqBC,OAAe,EAAEC,KAAyB,EAAA;AAC3E,IAAA,MAAMC,UAAUD,KAAAA,EAAOE,IAAAA,EAAAA;AACvB,IAAA,IAAI,CAACD,OAAAA,IAAWA,OAAAA,KAAY,GAAA,EAAK,OAAO,IAAA;AAExC,IAAA,MAAME,SAASC,YAAAA,CAAaL,OAAAA,CAAAA;IAC5B,IAAI,CAACI,QAAQ,OAAO,KAAA;AAEpB,IAAA,MAAM,CAACE,QAAAA,EAAUC,OAAAA,CAAQ,GAAGC,UAAAA,CAAWN,OAAAA,CAAAA;AACvC,IAAA,MAAMO,WAAWJ,YAAAA,CAAaE,OAAAA,CAAAA;IAC9B,IAAI,CAACE,UAAU,OAAO,KAAA;IAEtB,OAAQH,QAAAA;QACJ,KAAK,GAAA;AACD,YAAA,OAAOI,QAAQN,MAAAA,EAAQK,QAAAA,CAAAA,IAAa,KAAKC,OAAAA,CAAQN,MAAAA,EAAQO,gBAAgBF,QAAAA,CAAAA,CAAAA,GAAa,CAAA;QAC1F,KAAK,GAAA;AACD,YAAA,OAAOC,OAAAA,CAAQN,MAAAA,EAAQK,QAAAA,CAAAA,IAAa,CAAA,IAAKC,QAAQN,MAAAA,EAAQ;AAACK,gBAAAA,QAAQ,CAAC,CAAA,CAAE;gBAAEA,QAAQ,CAAC,EAAE,GAAG,CAAA;AAAG,gBAAA;aAAE,CAAA,GAAI,CAAA;QAClG,KAAK,IAAA;YACD,OAAOC,OAAAA,CAAQN,QAAQK,QAAAA,CAAAA,IAAa,CAAA;QACxC,KAAK,GAAA;YACD,OAAOC,OAAAA,CAAQN,QAAQK,QAAAA,CAAAA,GAAY,CAAA;Q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|
|
1
|
+
import { SceneElement } from '@cratis/scene.model';
|
|
2
|
+
import { Renderer } from './Renderer';
|
|
3
|
+
import { BindingResolver } from './BindingResolver';
|
|
4
|
+
export declare function renderElement<TOutput>(element: SceneElement, renderer: Renderer<TOutput>, resolveBinding: BindingResolver): TOutput;
|
|
5
|
+
//# sourceMappingURL=renderElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderElement.d.ts","sourceRoot":"","sources":["../../renderElement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAUpD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,eAAe,GAAG,OAAO,CAwBnI"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isContentControl, isItemsControl, isExternalComponent, isPanel } from './elementKind.js';
|
|
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
|
+
* Walks a Scene element tree, rendering each node's children before the node itself, and hands the
|
|
7
|
+
* result to the supplied {@link Renderer}. This is a structural tree walk only - resolving a `ui
|
|
8
|
+
* profile`'s package list, aggregating contribution points, and computing layout arrangement are the
|
|
9
|
+
* jobs of the profile resolution, contribution runtime and layout engines (Scene#3, Scene#2, Scene#4),
|
|
10
|
+
* layered on top of this walk rather than folded into it.
|
|
11
|
+
*/ function renderElement(element, renderer, resolveBinding) {
|
|
12
|
+
if (isContentControl(element)) {
|
|
13
|
+
return renderer.renderContentControl(element, renderElement(element.content, renderer, resolveBinding));
|
|
14
|
+
}
|
|
15
|
+
if (isItemsControl(element)) {
|
|
16
|
+
const items = resolveBinding(element.itemsSource);
|
|
17
|
+
const itemCount = Array.isArray(items) ? items.length : 0;
|
|
18
|
+
const rendered = Array.from({
|
|
19
|
+
length: itemCount
|
|
20
|
+
}, ()=>renderElement(element.itemTemplate, renderer, resolveBinding));
|
|
21
|
+
return renderer.renderItemsControl(element, rendered);
|
|
22
|
+
}
|
|
23
|
+
if (isExternalComponent(element)) {
|
|
24
|
+
const slots = Object.fromEntries(Object.entries(element.slots).map(([name, children])=>[
|
|
25
|
+
name,
|
|
26
|
+
children.map((child)=>renderElement(child, renderer, resolveBinding))
|
|
27
|
+
]));
|
|
28
|
+
return renderer.renderExternalComponent(element, slots);
|
|
29
|
+
}
|
|
30
|
+
if (isPanel(element)) {
|
|
31
|
+
return renderer.renderPanel(element, element.children.map((child)=>renderElement(child, renderer, resolveBinding)));
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Scene element '${element.id}' is not a recognized concrete kind (ContentControl, ItemsControl, ExternalComponent or Panel).`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { renderElement };
|
|
37
|
+
//# sourceMappingURL=renderElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderElement.js","sources":["../../renderElement.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 { SceneElement } from '@cratis/scene.model';\nimport { Renderer } from './Renderer';\nimport { BindingResolver } from './BindingResolver';\nimport { isContentControl, isItemsControl, isExternalComponent, isPanel } from './elementKind';\n\n/**\n * Walks a Scene element tree, rendering each node's children before the node itself, and hands the\n * result to the supplied {@link Renderer}. This is a structural tree walk only - resolving a `ui\n * profile`'s package list, aggregating contribution points, and computing layout arrangement are the\n * jobs of the profile resolution, contribution runtime and layout engines (Scene#3, Scene#2, Scene#4),\n * layered on top of this walk rather than folded into it.\n */\nexport function renderElement<TOutput>(element: SceneElement, renderer: Renderer<TOutput>, resolveBinding: BindingResolver): TOutput {\n if (isContentControl(element)) {\n return renderer.renderContentControl(element, renderElement(element.content, renderer, resolveBinding));\n }\n\n if (isItemsControl(element)) {\n const items = resolveBinding(element.itemsSource);\n const itemCount = Array.isArray(items) ? items.length : 0;\n const rendered = Array.from({ length: itemCount }, () => renderElement(element.itemTemplate, renderer, resolveBinding));\n return renderer.renderItemsControl(element, rendered);\n }\n\n if (isExternalComponent(element)) {\n const slots = Object.fromEntries(\n Object.entries(element.slots).map(([name, children]) => [name, children.map(child => renderElement(child, renderer, resolveBinding))]),\n );\n return renderer.renderExternalComponent(element, slots);\n }\n\n if (isPanel(element)) {\n return renderer.renderPanel(element, element.children.map(child => renderElement(child, renderer, resolveBinding)));\n }\n\n throw new Error(`Scene element '${element.id}' is not a recognized concrete kind (ContentControl, ItemsControl, ExternalComponent or Panel).`);\n}\n"],"names":["renderElement","element","renderer","resolveBinding","isContentControl","renderContentControl","content","isItemsControl","items","itemsSource","itemCount","Array","isArray","length","rendered","from","itemTemplate","renderItemsControl","isExternalComponent","slots","Object","fromEntries","entries","map","name","children","child","renderExternalComponent","isPanel","renderPanel","Error","id"],"mappings":";;AAAA;AACA;AAOA;;;;;;AAMC,IACM,SAASA,aAAAA,CAAuBC,OAAqB,EAAEC,QAA2B,EAAEC,cAA+B,EAAA;AACtH,IAAA,IAAIC,iBAAiBH,OAAAA,CAAAA,EAAU;QAC3B,OAAOC,QAAAA,CAASG,oBAAoB,CAACJ,OAAAA,EAASD,cAAcC,OAAAA,CAAQK,OAAO,EAAEJ,QAAAA,EAAUC,cAAAA,CAAAA,CAAAA;AAC3F,IAAA;AAEA,IAAA,IAAII,eAAeN,OAAAA,CAAAA,EAAU;QACzB,MAAMO,KAAAA,GAAQL,cAAAA,CAAeF,OAAAA,CAAQQ,WAAW,CAAA;AAChD,QAAA,MAAMC,YAAYC,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,GAASA,KAAAA,CAAMK,MAAM,GAAG,CAAA;QACxD,MAAMC,QAAAA,GAAWH,KAAAA,CAAMI,IAAI,CAAC;YAAEF,MAAAA,EAAQH;AAAU,SAAA,EAAG,IAAMV,aAAAA,CAAcC,OAAAA,CAAQe,YAAY,EAAEd,QAAAA,EAAUC,cAAAA,CAAAA,CAAAA;QACvG,OAAOD,QAAAA,CAASe,kBAAkB,CAAChB,OAAAA,EAASa,QAAAA,CAAAA;AAChD,IAAA;AAEA,IAAA,IAAII,oBAAoBjB,OAAAA,CAAAA,EAAU;AAC9B,QAAA,MAAMkB,QAAQC,MAAAA,CAAOC,WAAW,CAC5BD,MAAAA,CAAOE,OAAO,CAACrB,OAAAA,CAAQkB,KAAK,CAAA,CAAEI,GAAG,CAAC,CAAC,CAACC,IAAAA,EAAMC,SAAS,GAAK;AAACD,gBAAAA,IAAAA;AAAMC,gBAAAA,QAAAA,CAASF,GAAG,CAACG,CAAAA,KAAAA,GAAS1B,aAAAA,CAAc0B,OAAOxB,QAAAA,EAAUC,cAAAA,CAAAA;AAAiB,aAAA,CAAA,CAAA;QAEzI,OAAOD,QAAAA,CAASyB,uBAAuB,CAAC1B,OAAAA,EAASkB,KAAAA,CAAAA;AACrD,IAAA;AAEA,IAAA,IAAIS,QAAQ3B,OAAAA,CAAAA,EAAU;AAClB,QAAA,OAAOC,QAAAA,CAAS2B,WAAW,CAAC5B,OAAAA,EAASA,OAAAA,CAAQwB,QAAQ,CAACF,GAAG,CAACG,CAAAA,KAAAA,GAAS1B,aAAAA,CAAc0B,OAAOxB,QAAAA,EAAUC,cAAAA,CAAAA,CAAAA,CAAAA;AACtG,IAAA;IAEA,MAAM,IAAI2B,MAAM,CAAC,eAAe,EAAE7B,OAAAA,CAAQ8B,EAAE,CAAC,+FAA+F,CAAC,CAAA;AACjJ;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UiProfile } from '@cratis/scene.model';
|
|
2
|
+
import { ComponentResolution } from './ComponentResolution';
|
|
3
|
+
export declare const corePackage = "core";
|
|
4
|
+
export type PackageCatalog = Record<string, string[]>;
|
|
5
|
+
export declare function effectivePackages(profile: UiProfile): string[];
|
|
6
|
+
export declare function resolveComponentName(requestedName: string, profile: UiProfile, catalog: PackageCatalog): ComponentResolution | undefined;
|
|
7
|
+
//# sourceMappingURL=resolveComponentName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveComponentName.d.ts","sourceRoot":"","sources":["../../resolveComponentName.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,WAAW,SAAS,CAAC;AAGlC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAUtD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,EAAE,CAE9D;AAoBD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,mBAAmB,GAAG,SAAS,CAmBxI"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** The name of the package that is always present as the final fallback, regardless of what a {@link UiProfile} lists in its own `packages`. */ const corePackage = 'core';
|
|
4
|
+
/**
|
|
5
|
+
* Computes a {@link UiProfile}'s effective package priority order - its own declared packages, with
|
|
6
|
+
* {@link corePackage} prepended as the final fallback when not already present. {@link corePackage} is
|
|
7
|
+
* the lowest-priority fallback, so it belongs at the front of the ascending-priority order, not the
|
|
8
|
+
* back - prepending it (rather than appending) is what makes every explicitly listed package outrank it.
|
|
9
|
+
*
|
|
10
|
+
* @returns The packages in ascending priority order - the last entry wins when more than one declares the same name.
|
|
11
|
+
*/ function effectivePackages(profile) {
|
|
12
|
+
return profile.packages.includes(corePackage) ? profile.packages : [
|
|
13
|
+
corePackage,
|
|
14
|
+
...profile.packages
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a component name against a {@link UiProfile} - the runtime half of Cratis/Scene#3, run
|
|
19
|
+
* whenever a profile is applied. Studio's design-time tooling and Stage's build-time resolution use the
|
|
20
|
+
* C# twin of this algorithm in `Cratis.Scene.Engine`; both sides are asserted against the same shared
|
|
21
|
+
* fixture corpus so they cannot drift apart.
|
|
22
|
+
*
|
|
23
|
+
* A name containing a `.` is package-qualified - everything before the last `.` is the package,
|
|
24
|
+
* everything after is the bare name - and resolves directly against that one package, bypassing shadow
|
|
25
|
+
* tracking and the profile's priority order entirely (an author naming the package explicitly has
|
|
26
|
+
* already disambiguated). A name with no `.` is bare and resolves by walking {@link effectivePackages}
|
|
27
|
+
* from highest to lowest priority; every other active package that also declares the name is recorded in
|
|
28
|
+
* the result's `shadows`, not discarded, so a caller can explain the pick rather than only report it.
|
|
29
|
+
*
|
|
30
|
+
* @param requestedName The name as written on a screen - bare (`button`) or package-qualified (`Internal.Widgets.TrendChart`).
|
|
31
|
+
* @param profile The {@link UiProfile} whose package list to resolve against.
|
|
32
|
+
* @param catalog Every active package's declared component names, keyed by package name.
|
|
33
|
+
* @returns The {@link ComponentResolution}, or `undefined` when nothing in scope declares the name.
|
|
34
|
+
*/ function resolveComponentName(requestedName, profile, catalog) {
|
|
35
|
+
const lastDot = requestedName.lastIndexOf('.');
|
|
36
|
+
if (lastDot >= 0) {
|
|
37
|
+
const qualifiedPackage = requestedName.slice(0, lastDot);
|
|
38
|
+
const qualifiedName = requestedName.slice(lastDot + 1);
|
|
39
|
+
return declares(catalog, qualifiedPackage, qualifiedName) ? {
|
|
40
|
+
name: qualifiedName,
|
|
41
|
+
package: qualifiedPackage,
|
|
42
|
+
shadows: []
|
|
43
|
+
} : undefined;
|
|
44
|
+
}
|
|
45
|
+
const priority = effectivePackages(profile);
|
|
46
|
+
const matches = [];
|
|
47
|
+
for(let index = priority.length - 1; index >= 0; index--){
|
|
48
|
+
if (declares(catalog, priority[index], requestedName)) {
|
|
49
|
+
matches.push(priority[index]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return matches.length === 0 ? undefined : {
|
|
53
|
+
name: requestedName,
|
|
54
|
+
package: matches[0],
|
|
55
|
+
shadows: matches.slice(1)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function declares(catalog, packageName, name) {
|
|
59
|
+
return catalog[packageName]?.includes(name) ?? false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { corePackage, effectivePackages, resolveComponentName };
|
|
63
|
+
//# sourceMappingURL=resolveComponentName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveComponentName.js","sources":["../../resolveComponentName.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 { UiProfile } from '@cratis/scene.model';\nimport { ComponentResolution } from './ComponentResolution';\n\n/** The name of the package that is always present as the final fallback, regardless of what a {@link UiProfile} lists in its own `packages`. */\nexport const corePackage = 'core';\n\n/** Every active package's declared component names, keyed by package name. */\nexport type PackageCatalog = Record<string, string[]>;\n\n/**\n * Computes a {@link UiProfile}'s effective package priority order - its own declared packages, with\n * {@link corePackage} prepended as the final fallback when not already present. {@link corePackage} is\n * the lowest-priority fallback, so it belongs at the front of the ascending-priority order, not the\n * back - prepending it (rather than appending) is what makes every explicitly listed package outrank it.\n *\n * @returns The packages in ascending priority order - the last entry wins when more than one declares the same name.\n */\nexport function effectivePackages(profile: UiProfile): string[] {\n return profile.packages.includes(corePackage) ? profile.packages : [corePackage, ...profile.packages];\n}\n\n/**\n * Resolves a component name against a {@link UiProfile} - the runtime half of Cratis/Scene#3, run\n * whenever a profile is applied. Studio's design-time tooling and Stage's build-time resolution use the\n * C# twin of this algorithm in `Cratis.Scene.Engine`; both sides are asserted against the same shared\n * fixture corpus so they cannot drift apart.\n *\n * A name containing a `.` is package-qualified - everything before the last `.` is the package,\n * everything after is the bare name - and resolves directly against that one package, bypassing shadow\n * tracking and the profile's priority order entirely (an author naming the package explicitly has\n * already disambiguated). A name with no `.` is bare and resolves by walking {@link effectivePackages}\n * from highest to lowest priority; every other active package that also declares the name is recorded in\n * the result's `shadows`, not discarded, so a caller can explain the pick rather than only report it.\n *\n * @param requestedName The name as written on a screen - bare (`button`) or package-qualified (`Internal.Widgets.TrendChart`).\n * @param profile The {@link UiProfile} whose package list to resolve against.\n * @param catalog Every active package's declared component names, keyed by package name.\n * @returns The {@link ComponentResolution}, or `undefined` when nothing in scope declares the name.\n */\nexport function resolveComponentName(requestedName: string, profile: UiProfile, catalog: PackageCatalog): ComponentResolution | undefined {\n const lastDot = requestedName.lastIndexOf('.');\n if (lastDot >= 0) {\n const qualifiedPackage = requestedName.slice(0, lastDot);\n const qualifiedName = requestedName.slice(lastDot + 1);\n return declares(catalog, qualifiedPackage, qualifiedName)\n ? { name: qualifiedName, package: qualifiedPackage, shadows: [] }\n : undefined;\n }\n\n const priority = effectivePackages(profile);\n const matches: string[] = [];\n for (let index = priority.length - 1; index >= 0; index--) {\n if (declares(catalog, priority[index], requestedName)) {\n matches.push(priority[index]);\n }\n }\n\n return matches.length === 0 ? undefined : { name: requestedName, package: matches[0], shadows: matches.slice(1) };\n}\n\nfunction declares(catalog: PackageCatalog, packageName: string, name: string): boolean {\n return catalog[packageName]?.includes(name) ?? false;\n}\n"],"names":["corePackage","effectivePackages","profile","packages","includes","resolveComponentName","requestedName","catalog","lastDot","lastIndexOf","qualifiedPackage","slice","qualifiedName","declares","name","package","shadows","undefined","priority","matches","index","length","push","packageName"],"mappings":"AAAA;AACA;AAKA,iJACO,MAAMA,WAAAA,GAAc;AAK3B;;;;;;;IAQO,SAASC,iBAAAA,CAAkBC,OAAkB,EAAA;IAChD,OAAOA,OAAAA,CAAQC,QAAQ,CAACC,QAA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AO,CAAC,CAAA,CAAE;QAAEH,OAAAA,EAASG,OAAAA,CAAQR,KAAK,CAAC,CAAA;AAAG,KAAA;AACpH;AAEA,SAASE,QAAAA,CAASN,OAAuB,EAAEgB,WAAmB,EAAET,IAAY,EAAA;AACxE,IAAA,OAAOP,OAAO,CAACgB,WAAAA,CAAY,EAAEnB,SAASU,IAAAA,CAAAA,IAAS,KAAA;AACnD;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ScenePackage } from '@cratis/scene.model';
|
|
2
|
+
import { PackageSelection } from './PackageSelection';
|
|
3
|
+
export declare function resolvePackageDependencies(selected: string[], catalog: ScenePackage[]): PackageSelection;
|
|
4
|
+
//# sourceMappingURL=resolvePackageDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePackageDependencies.d.ts","sourceRoot":"","sources":["../../resolvePackageDependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA4B,gBAAgB,EAA0B,MAAM,oBAAoB,CAAC;AAiBxG,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAiDxG"}
|