@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
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import { BindingExpression } from '@cratis/scene.model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a {@link BindingExpression} to its current value. How a binding is actually resolved -
|
|
8
|
+
* against a Stage-produced data context, a Studio design-time fixture, or anything else - is owned by
|
|
9
|
+
* whoever drives the engine, not by the engine itself.
|
|
10
|
+
*/
|
|
11
|
+
export type BindingResolver = (binding: BindingExpression) => unknown;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The outcome of resolving a bare or package-qualified component name against a {@link UiProfile}'s
|
|
6
|
+
* package list.
|
|
7
|
+
*/
|
|
8
|
+
export interface ComponentResolution {
|
|
9
|
+
/** The bare component name within {@link package}. */
|
|
10
|
+
name: string;
|
|
11
|
+
|
|
12
|
+
/** The package the name resolved to. */
|
|
13
|
+
package: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Other active packages, in descending priority order, that also declare this name but were
|
|
17
|
+
* shadowed by {@link package} - this is what answers "why did this resolve to X and not Y". Always
|
|
18
|
+
* empty for a package-qualified reference, which resolves directly against its named package and
|
|
19
|
+
* never runs shadow tracking.
|
|
20
|
+
*/
|
|
21
|
+
shadows: string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* A dependency a selected package declares that nothing in the catalog can satisfy — so it cannot be
|
|
6
|
+
* pulled in automatically, and the selection is genuinely incomplete rather than merely under-specified.
|
|
7
|
+
*/
|
|
8
|
+
export interface MissingPackageDependency {
|
|
9
|
+
/**
|
|
10
|
+
* The package that declares the dependency.
|
|
11
|
+
*/
|
|
12
|
+
package: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The name of the package it depends on, which the catalog does not contain.
|
|
16
|
+
*/
|
|
17
|
+
dependsOn: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A dependency that resolved to a package the catalog does contain, but at a version its declared range
|
|
22
|
+
* does not accept.
|
|
23
|
+
*/
|
|
24
|
+
export interface PackageVersionConflict {
|
|
25
|
+
/**
|
|
26
|
+
* The package that declares the dependency.
|
|
27
|
+
*/
|
|
28
|
+
package: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The name of the package it depends on.
|
|
32
|
+
*/
|
|
33
|
+
dependsOn: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The range the declaring package asked for.
|
|
37
|
+
*/
|
|
38
|
+
requiredRange: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The version the catalog actually offers.
|
|
42
|
+
*/
|
|
43
|
+
actualVersion: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The outcome of expanding a chosen set of package names into the full set a {@link UiProfile} actually
|
|
48
|
+
* needs.
|
|
49
|
+
*/
|
|
50
|
+
export interface PackageSelection {
|
|
51
|
+
/**
|
|
52
|
+
* Every package the selection requires, in ascending override-priority order: a package always
|
|
53
|
+
* appears after the packages it depends on, so a package that layers on top of another shadows it on
|
|
54
|
+
* a name collision. That is the order a profile's `packages` list should carry.
|
|
55
|
+
*/
|
|
56
|
+
packages: string[];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The packages pulled in transitively that the caller did not choose — what a package picker tells
|
|
60
|
+
* the user it is about to add on their behalf.
|
|
61
|
+
*/
|
|
62
|
+
added: string[];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Dependencies nothing in the catalog can satisfy.
|
|
66
|
+
*/
|
|
67
|
+
missing: MissingPackageDependency[];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Dependencies satisfied by name but not by version.
|
|
71
|
+
*/
|
|
72
|
+
versionConflicts: PackageVersionConflict[];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Dependency cycles found while ordering, each listed as the packages involved. A cycle has no valid
|
|
76
|
+
* priority order, so its members are emitted in discovery order and reported here rather than
|
|
77
|
+
* silently arranged into one.
|
|
78
|
+
*/
|
|
79
|
+
cycles: string[][];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Whether a selection is complete and orderable — nothing missing, no version conflict, no cycle.
|
|
84
|
+
*/
|
|
85
|
+
export function isPackageSelectionValid(selection: PackageSelection): boolean {
|
|
86
|
+
return selection.missing.length === 0 && selection.versionConflicts.length === 0 && selection.cycles.length === 0;
|
|
87
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Scene
|
|
2
|
+
|
|
3
|
+
The object model and runtime for Screenplay-based UIs: `Scene.Model` (platform-agnostic screens, layouts,
|
|
4
|
+
forms, contribution points, ui profiles and themes), `Scene.Engine` (binding/resolution runtime), and
|
|
5
|
+
`Scene.React` (the React renderer).
|
|
6
|
+
|
|
7
|
+
## Packages / Deployables
|
|
8
|
+
|
|
9
|
+
[](http://nuget.org/packages/Cratis.Scene.Model)
|
|
10
|
+
[](https://www.npmjs.com/package/@cratis/scene.model)
|
|
11
|
+
[](https://www.npmjs.com/package/@cratis/scene.engine)
|
|
12
|
+
[](https://www.npmjs.com/package/@cratis/scene.react)
|
|
13
|
+
|
|
14
|
+
## Builds
|
|
15
|
+
|
|
16
|
+
[](https://github.com/cratis/scene/actions/workflows/dotnet-build.yml)
|
|
17
|
+
[](https://github.com/cratis/scene/actions/workflows/javascript-build.yml)
|
|
18
|
+
|
|
19
|
+
## Description
|
|
20
|
+
|
|
21
|
+
Scene owns the *object model and runtime* half of the Screenplay stack. `Scene.Model` is the platform-agnostic
|
|
22
|
+
C# object model that Stage translates Screenplay's parsed language constructs into, and that Studio's
|
|
23
|
+
design-time tooling reads and writes. `Scene.Engine` walks that graph, resolves bindings (data, action, form,
|
|
24
|
+
navigation contribution) and drives whichever renderer is plugged in — it does not know React exists.
|
|
25
|
+
`Scene.React` is one renderer implementing the abstract vocabulary against real React/DOM; sibling positions
|
|
26
|
+
are reserved for future `Scene.Native` / `Scene.Desktop` renderers. Vendor and internal component packages
|
|
27
|
+
(PrimeReact, internal widget libraries) are adapters plugging into the renderer contract, not part of it.
|
|
28
|
+
|
|
29
|
+
The design-time editor built on top of this object model lives in Studio, not here — see
|
|
30
|
+
[StudioIssues#156](https://github.com/Cratis/StudioIssues/issues/156).
|
|
31
|
+
|
|
32
|
+
## Support
|
|
33
|
+
|
|
34
|
+
Cratis is an open community, and we are glad to help users, teams evaluating the stack, and contributors.
|
|
35
|
+
|
|
36
|
+
| Channel | Details |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Discord | Join the community on [Discord](https://discord.gg/kt4AMpV8WV) for questions and discussions |
|
|
39
|
+
| GitHub Issues | [Report bugs or request features](https://github.com/Cratis/Scene/issues) |
|
|
40
|
+
| Documentation | Read the docs at [cratis.io](https://cratis.io) |
|
package/Renderer.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { ContentControl, ItemsControl, ExternalComponent, Panel } from '@cratis/scene.model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The contract a renderer implements to turn a resolved Scene element tree into `TOutput` - real
|
|
8
|
+
* React/DOM output for `Scene.React`, and whatever a future `Scene.Native` or `Scene.Desktop` renderer's
|
|
9
|
+
* own platform needs. One method per concrete element kind Scene.Model ships; an adapter package's own
|
|
10
|
+
* component types render through {@link renderExternalComponent} rather than needing their own method
|
|
11
|
+
* here, so this contract does not grow as vendor/internal widget libraries are added.
|
|
12
|
+
*/
|
|
13
|
+
export interface Renderer<TOutput> {
|
|
14
|
+
/**
|
|
15
|
+
* Renders a {@link ContentControl}, given its already-rendered content.
|
|
16
|
+
*/
|
|
17
|
+
renderContentControl(element: ContentControl, content: TOutput): TOutput;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Renders an {@link ItemsControl}, given its already-rendered items.
|
|
21
|
+
*/
|
|
22
|
+
renderItemsControl(element: ItemsControl, items: TOutput[]): TOutput;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Renders an {@link ExternalComponent}, given its already-rendered named slots.
|
|
26
|
+
*/
|
|
27
|
+
renderExternalComponent(element: ExternalComponent, slots: Record<string, TOutput[]>): TOutput;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Renders a {@link Panel}, given its already-rendered children.
|
|
31
|
+
*/
|
|
32
|
+
renderPanel(element: Panel, children: TOutput[]): TOutput;
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
import { Contribution } from '@cratis/scene.model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Aggregates every {@link Contribution} targeting a given contribution point, in render order - part of
|
|
8
|
+
* Cratis/Scene#2. A widget bound to a contribution point is never wired to a fixed source: call this
|
|
9
|
+
* again whenever the underlying contribution set changes and it recomputes, the same way a projection
|
|
10
|
+
* recomputes a read model from events.
|
|
11
|
+
*
|
|
12
|
+
* Resolving *which* contribution point a `contribute to` declaration targets (nearest enclosing, or an
|
|
13
|
+
* explicit override) already happened before a {@link Contribution} exists in this model - see its own
|
|
14
|
+
* doc comment - so there is no ambiguity left to resolve here, only ordering.
|
|
15
|
+
*
|
|
16
|
+
* @param contributions Every contribution in scope, targeting any contribution point.
|
|
17
|
+
* @param contributionPointName The name of the contribution point to aggregate.
|
|
18
|
+
* @returns The matching contributions, ordered by `order` ascending; contributions with no `order` sort after every ordered one, in their original relative order.
|
|
19
|
+
*/
|
|
20
|
+
export function aggregateContributions(contributions: Contribution[], contributionPointName: string): Contribution[] {
|
|
21
|
+
return contributions
|
|
22
|
+
.map((contribution, index) => ({ contribution, index }))
|
|
23
|
+
.filter(({ contribution }) => contribution.contributionPointName === contributionPointName)
|
|
24
|
+
.sort((a, b) => {
|
|
25
|
+
if (a.contribution.order === undefined && b.contribution.order === undefined) {
|
|
26
|
+
return a.index - b.index;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (a.contribution.order === undefined) {
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (b.contribution.order === undefined) {
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return a.contribution.order - b.contribution.order;
|
|
38
|
+
})
|
|
39
|
+
.map(({ contribution }) => contribution);
|
|
40
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import { SizeClass, UiProfile, UiStarter } from '@cratis/scene.model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builds the sandboxed {@link UiProfile} a {@link UiStarter}'s gallery boots through - part of
|
|
8
|
+
* Cratis/Scene#6. Studio runs a starter's gallery screens as a working mini-app rather than a simulated
|
|
9
|
+
* preview, so the gallery needs a real profile scoped to exactly the starter's own package list, not the
|
|
10
|
+
* consuming project's eventual profile. Studio's design-time tooling and Stage's build-time resolution
|
|
11
|
+
* use the C# twin of this function in `Cratis.Scene.Engine`; both sides are asserted against the same
|
|
12
|
+
* shared fixture corpus so they cannot drift apart.
|
|
13
|
+
*
|
|
14
|
+
* @param starter The {@link UiStarter} to build the profile for.
|
|
15
|
+
* @param targetPlatform The platform the gallery runs on (e.g. `web`).
|
|
16
|
+
* @param defaultSizeClass The size class assumed when the renderer cannot otherwise determine one.
|
|
17
|
+
* @returns A {@link UiProfile} named after the starter, scoped to exactly its own `packages`.
|
|
18
|
+
*/
|
|
19
|
+
export function buildStarterProfile(starter: UiStarter, targetPlatform: string, defaultSizeClass?: SizeClass): UiProfile {
|
|
20
|
+
return { name: starter.name, targetPlatform, packages: starter.packages, defaultSizeClass };
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import { HeightSizeClass, SizeClass, WidthSizeClass } from '@cratis/scene.model';
|
|
5
|
+
|
|
6
|
+
/** The default width, in device-independent pixels, at or above which {@link WidthSizeClass.Regular} applies. */
|
|
7
|
+
export const defaultWidthBreakpoint = 600;
|
|
8
|
+
|
|
9
|
+
/** The default height, in device-independent pixels, at or above which {@link HeightSizeClass.Regular} applies. */
|
|
10
|
+
export const defaultHeightBreakpoint = 600;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Computes the current {@link SizeClass} from actual available dimensions - shared by every renderer
|
|
14
|
+
* (`Scene.React`, any future native renderer, Studio's preview surface) so they all agree on when a class
|
|
15
|
+
* boundary is crossed. Reactive (recompute on resize) vs. fixed-per-launch (mobile, where orientation
|
|
16
|
+
* change is the only runtime variable) are both just "call this again when the dimensions you have
|
|
17
|
+
* available change" - the shape is the same either way, only the caller's triggering mechanism differs.
|
|
18
|
+
*
|
|
19
|
+
* @param width The available width, in device-independent pixels.
|
|
20
|
+
* @param height The available height, in device-independent pixels.
|
|
21
|
+
* @param widthBreakpoint The width at or above which {@link WidthSizeClass.Regular} applies. Defaults to {@link defaultWidthBreakpoint}.
|
|
22
|
+
* @param heightBreakpoint The height at or above which {@link HeightSizeClass.Regular} applies. Defaults to {@link defaultHeightBreakpoint}.
|
|
23
|
+
* @returns The computed {@link SizeClass}.
|
|
24
|
+
*/
|
|
25
|
+
export function computeSizeClass(width: number, height: number, widthBreakpoint = defaultWidthBreakpoint, heightBreakpoint = defaultHeightBreakpoint): SizeClass {
|
|
26
|
+
return {
|
|
27
|
+
width: width >= widthBreakpoint ? WidthSizeClass.Regular : WidthSizeClass.Compact,
|
|
28
|
+
height: height >= heightBreakpoint ? HeightSizeClass.Regular : HeightSizeClass.Compact,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* A dependency a selected package declares that nothing in the catalog can satisfy — so it cannot be
|
|
7
|
+
* pulled in automatically, and the selection is genuinely incomplete rather than merely under-specified.
|
|
8
|
+
*/ /**
|
|
9
|
+
* Whether a selection is complete and orderable — nothing missing, no version conflict, no cycle.
|
|
10
|
+
*/ function isPackageSelectionValid(selection) {
|
|
11
|
+
return selection.missing.length === 0 && selection.versionConflicts.length === 0 && selection.cycles.length === 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.isPackageSelectionValid = isPackageSelectionValid;
|
|
15
|
+
//# sourceMappingURL=PackageSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageSelection.js","sources":["../../PackageSelection.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 * A dependency a selected package declares that nothing in the catalog can satisfy — so it cannot be\n * pulled in automatically, and the selection is genuinely incomplete rather than merely under-specified.\n */\nexport interface MissingPackageDependency {\n /**\n * The package that declares the dependency.\n */\n package: string;\n\n /**\n * The name of the package it depends on, which the catalog does not contain.\n */\n dependsOn: string;\n}\n\n/**\n * A dependency that resolved to a package the catalog does contain, but at a version its declared range\n * does not accept.\n */\nexport interface PackageVersionConflict {\n /**\n * The package that declares the dependency.\n */\n package: string;\n\n /**\n * The name of the package it depends on.\n */\n dependsOn: string;\n\n /**\n * The range the declaring package asked for.\n */\n requiredRange: string;\n\n /**\n * The version the catalog actually offers.\n */\n actualVersion: string;\n}\n\n/**\n * The outcome of expanding a chosen set of package names into the full set a {@link UiProfile} actually\n * needs.\n */\nexport interface PackageSelection {\n /**\n * Every package the selection requires, in ascending override-priority order: a package always\n * appears after the packages it depends on, so a package that layers on top of another shadows it on\n * a name collision. That is the order a profile's `packages` list should carry.\n */\n packages: string[];\n\n /**\n * The packages pulled in transitively that the caller did not choose — what a package picker tells\n * the user it is about to add on their behalf.\n */\n added: string[];\n\n /**\n * Dependencies nothing in the catalog can satisfy.\n */\n missing: MissingPackageDependency[];\n\n /**\n * Dependencies satisfied by name but not by version.\n */\n versionConflicts: PackageVersionConflict[];\n\n /**\n * Dependency cycles found while ordering, each listed as the packages involved. A cycle has no valid\n * priority order, so its members are emitted in discovery order and reported here rather than\n * silently arranged into one.\n */\n cycles: string[][];\n}\n\n/**\n * Whether a selection is complete and orderable — nothing missing, no version conflict, no cycle.\n */\nexport function isPackageSelectionValid(selection: PackageSelection): boolean {\n return selection.missing.length === 0 && selection.versionConflicts.length === 0 && selection.cycles.length === 0;\n}\n"],"names":["isPackageSelectionValid","selection","missing","length","versionConflicts","cycles"],"mappings":";;AAAA;AACA;AAEA;;;;;IAiFO,SAASA,uBAAAA,CAAwBC,SAA2B,EAAA;AAC/D,IAAA,OAAOA,UAAUC,OAAO,CAACC,MAAM,KAAK,KAAKF,SAAAA,CAAUG,gBAAgB,CAACD,MAAM,KAAK,CAAA,IAAKF,SAAAA,CAAUI,MAAM,CAACF,MAAM,KAAK,CAAA;AACpH;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Aggregates every {@link Contribution} targeting a given contribution point, in render order - part of
|
|
7
|
+
* Cratis/Scene#2. A widget bound to a contribution point is never wired to a fixed source: call this
|
|
8
|
+
* again whenever the underlying contribution set changes and it recomputes, the same way a projection
|
|
9
|
+
* recomputes a read model from events.
|
|
10
|
+
*
|
|
11
|
+
* Resolving *which* contribution point a `contribute to` declaration targets (nearest enclosing, or an
|
|
12
|
+
* explicit override) already happened before a {@link Contribution} exists in this model - see its own
|
|
13
|
+
* doc comment - so there is no ambiguity left to resolve here, only ordering.
|
|
14
|
+
*
|
|
15
|
+
* @param contributions Every contribution in scope, targeting any contribution point.
|
|
16
|
+
* @param contributionPointName The name of the contribution point to aggregate.
|
|
17
|
+
* @returns The matching contributions, ordered by `order` ascending; contributions with no `order` sort after every ordered one, in their original relative order.
|
|
18
|
+
*/ function aggregateContributions(contributions, contributionPointName) {
|
|
19
|
+
return contributions.map((contribution, index)=>({
|
|
20
|
+
contribution,
|
|
21
|
+
index
|
|
22
|
+
})).filter(({ contribution })=>contribution.contributionPointName === contributionPointName).sort((a, b)=>{
|
|
23
|
+
if (a.contribution.order === undefined && b.contribution.order === undefined) {
|
|
24
|
+
return a.index - b.index;
|
|
25
|
+
}
|
|
26
|
+
if (a.contribution.order === undefined) {
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
if (b.contribution.order === undefined) {
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
return a.contribution.order - b.contribution.order;
|
|
33
|
+
}).map(({ contribution })=>contribution);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.aggregateContributions = aggregateContributions;
|
|
37
|
+
//# sourceMappingURL=aggregateContributions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateContributions.js","sources":["../../aggregateContributions.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 { Contribution } from '@cratis/scene.model';\n\n/**\n * Aggregates every {@link Contribution} targeting a given contribution point, in render order - part of\n * Cratis/Scene#2. A widget bound to a contribution point is never wired to a fixed source: call this\n * again whenever the underlying contribution set changes and it recomputes, the same way a projection\n * recomputes a read model from events.\n *\n * Resolving *which* contribution point a `contribute to` declaration targets (nearest enclosing, or an\n * explicit override) already happened before a {@link Contribution} exists in this model - see its own\n * doc comment - so there is no ambiguity left to resolve here, only ordering.\n *\n * @param contributions Every contribution in scope, targeting any contribution point.\n * @param contributionPointName The name of the contribution point to aggregate.\n * @returns The matching contributions, ordered by `order` ascending; contributions with no `order` sort after every ordered one, in their original relative order.\n */\nexport function aggregateContributions(contributions: Contribution[], contributionPointName: string): Contribution[] {\n return contributions\n .map((contribution, index) => ({ contribution, index }))\n .filter(({ contribution }) => contribution.contributionPointName === contributionPointName)\n .sort((a, b) => {\n if (a.contribution.order === undefined && b.contribution.order === undefined) {\n return a.index - b.index;\n }\n\n if (a.contribution.order === undefined) {\n return 1;\n }\n\n if (b.contribution.order === undefined) {\n return -1;\n }\n\n return a.contribution.order - b.contribution.order;\n })\n .map(({ contribution }) => contribution);\n}\n"],"names":["aggregateContributions","contributions","contributionPointName","map","contribution","index","filter","sort","a","b","order","undefined"],"mappings":";;AAAA;AACA;AAIA;;;;;;;;;;;;;AAaC,IACM,SAASA,sBAAAA,CAAuBC,aAA6B,EAAEC,qBAA6B,EAAA;AAC/F,IAAA,OAAOD,cACFE,GAAG,CAAC,CAACC,YAAAA,EAAcC,SAAW;AAAED,YAAAA,YAAAA;AAAcC,YAAAA;AAAM,SAAA,CAAA,CAAA,CACpDC,MAAM,CAAC,CAAC,EAAEF,YAAY,EAAE,GAAKA,YAAAA,CAAaF,qBAAqB,KAAKA,qBAAAA,CAAAA,CACpEK,IAAI,CAAC,CAACC,CAAAA,EAAGC,CAAAA,GAAAA;QACN,IAAID,CAAAA,CAAEJ,YAAY,CAACM,KAAK,KAAKC,SAAAA,IAAaF,CAAAA,CAAEL,YAAY,CAACM,KAAK,KAAKC,SAAAA,EAAW;AAC1E,YAAA,OAAOH,CAAAA,CAAEH,KAAK,GAAGI,CAAAA,CAAEJ,KAAK;AAC5B,QAAA;AAEA,QAAA,IAAIG,CAAAA,CAAEJ,YAAY,CAACM,KAAK,KAAKC,SAAAA,EAAW;YACpC,OAAO,CAAA;AACX,QAAA;AAEA,QAAA,IAAIF,CAAAA,CAAEL,YAAY,CAACM,KAAK,KAAKC,SAAAA,EAAW;AACpC,YAAA,OAAO,EAAC;AACZ,QAAA;QAEA,OAAOH,CAAAA,CAAEJ,YAAY,CAACM,KAAK,GAAGD,CAAAA,CAAEL,YAAY,CAACM,KAAK;AACtD,IAAA,CAAA,CAAA,CACCP,GAAG,CAAC,CAAC,EAAEC,YAAY,EAAE,GAAKA,YAAAA,CAAAA;AACnC;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Builds the sandboxed {@link UiProfile} a {@link UiStarter}'s gallery boots through - part of
|
|
7
|
+
* Cratis/Scene#6. Studio runs a starter's gallery screens as a working mini-app rather than a simulated
|
|
8
|
+
* preview, so the gallery needs a real profile scoped to exactly the starter's own package list, not the
|
|
9
|
+
* consuming project's eventual profile. Studio's design-time tooling and Stage's build-time resolution
|
|
10
|
+
* use the C# twin of this function in `Cratis.Scene.Engine`; both sides are asserted against the same
|
|
11
|
+
* shared fixture corpus so they cannot drift apart.
|
|
12
|
+
*
|
|
13
|
+
* @param starter The {@link UiStarter} to build the profile for.
|
|
14
|
+
* @param targetPlatform The platform the gallery runs on (e.g. `web`).
|
|
15
|
+
* @param defaultSizeClass The size class assumed when the renderer cannot otherwise determine one.
|
|
16
|
+
* @returns A {@link UiProfile} named after the starter, scoped to exactly its own `packages`.
|
|
17
|
+
*/ function buildStarterProfile(starter, targetPlatform, defaultSizeClass) {
|
|
18
|
+
return {
|
|
19
|
+
name: starter.name,
|
|
20
|
+
targetPlatform,
|
|
21
|
+
packages: starter.packages,
|
|
22
|
+
defaultSizeClass
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.buildStarterProfile = buildStarterProfile;
|
|
27
|
+
//# sourceMappingURL=buildStarterProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildStarterProfile.js","sources":["../../buildStarterProfile.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 { SizeClass, UiProfile, UiStarter } from '@cratis/scene.model';\n\n/**\n * Builds the sandboxed {@link UiProfile} a {@link UiStarter}'s gallery boots through - part of\n * Cratis/Scene#6. Studio runs a starter's gallery screens as a working mini-app rather than a simulated\n * preview, so the gallery needs a real profile scoped to exactly the starter's own package list, not the\n * consuming project's eventual profile. Studio's design-time tooling and Stage's build-time resolution\n * use the C# twin of this function in `Cratis.Scene.Engine`; both sides are asserted against the same\n * shared fixture corpus so they cannot drift apart.\n *\n * @param starter The {@link UiStarter} to build the profile for.\n * @param targetPlatform The platform the gallery runs on (e.g. `web`).\n * @param defaultSizeClass The size class assumed when the renderer cannot otherwise determine one.\n * @returns A {@link UiProfile} named after the starter, scoped to exactly its own `packages`.\n */\nexport function buildStarterProfile(starter: UiStarter, targetPlatform: string, defaultSizeClass?: SizeClass): UiProfile {\n return { name: starter.name, targetPlatform, packages: starter.packages, defaultSizeClass };\n}\n"],"names":["buildStarterProfile","starter","targetPlatform","defaultSizeClass","name","packages"],"mappings":";;AAAA;AACA;AAIA;;;;;;;;;;;;AAYC,IACM,SAASA,mBAAAA,CAAoBC,OAAkB,EAAEC,cAAsB,EAAEC,gBAA4B,EAAA;IACxG,OAAO;AAAEC,QAAAA,IAAAA,EAAMH,QAAQG,IAAI;AAAEF,QAAAA,cAAAA;AAAgBG,QAAAA,QAAAA,EAAUJ,QAAQI,QAAQ;AAAEF,QAAAA;AAAiB,KAAA;AAC9F;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/** The default width, in device-independent pixels, at or above which {@link WidthSizeClass.Regular} applies. */ const defaultWidthBreakpoint = 600;
|
|
8
|
+
/** The default height, in device-independent pixels, at or above which {@link HeightSizeClass.Regular} applies. */ const defaultHeightBreakpoint = 600;
|
|
9
|
+
/**
|
|
10
|
+
* Computes the current {@link SizeClass} from actual available dimensions - shared by every renderer
|
|
11
|
+
* (`Scene.React`, any future native renderer, Studio's preview surface) so they all agree on when a class
|
|
12
|
+
* boundary is crossed. Reactive (recompute on resize) vs. fixed-per-launch (mobile, where orientation
|
|
13
|
+
* change is the only runtime variable) are both just "call this again when the dimensions you have
|
|
14
|
+
* available change" - the shape is the same either way, only the caller's triggering mechanism differs.
|
|
15
|
+
*
|
|
16
|
+
* @param width The available width, in device-independent pixels.
|
|
17
|
+
* @param height The available height, in device-independent pixels.
|
|
18
|
+
* @param widthBreakpoint The width at or above which {@link WidthSizeClass.Regular} applies. Defaults to {@link defaultWidthBreakpoint}.
|
|
19
|
+
* @param heightBreakpoint The height at or above which {@link HeightSizeClass.Regular} applies. Defaults to {@link defaultHeightBreakpoint}.
|
|
20
|
+
* @returns The computed {@link SizeClass}.
|
|
21
|
+
*/ function computeSizeClass(width, height, widthBreakpoint = defaultWidthBreakpoint, heightBreakpoint = defaultHeightBreakpoint) {
|
|
22
|
+
return {
|
|
23
|
+
width: width >= widthBreakpoint ? scene_model.WidthSizeClass.Regular : scene_model.WidthSizeClass.Compact,
|
|
24
|
+
height: height >= heightBreakpoint ? scene_model.HeightSizeClass.Regular : scene_model.HeightSizeClass.Compact
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.computeSizeClass = computeSizeClass;
|
|
29
|
+
exports.defaultHeightBreakpoint = defaultHeightBreakpoint;
|
|
30
|
+
exports.defaultWidthBreakpoint = defaultWidthBreakpoint;
|
|
31
|
+
//# sourceMappingURL=computeSizeClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeSizeClass.js","sources":["../../computeSizeClass.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 { HeightSizeClass, SizeClass, WidthSizeClass } from '@cratis/scene.model';\n\n/** The default width, in device-independent pixels, at or above which {@link WidthSizeClass.Regular} applies. */\nexport const defaultWidthBreakpoint = 600;\n\n/** The default height, in device-independent pixels, at or above which {@link HeightSizeClass.Regular} applies. */\nexport const defaultHeightBreakpoint = 600;\n\n/**\n * Computes the current {@link SizeClass} from actual available dimensions - shared by every renderer\n * (`Scene.React`, any future native renderer, Studio's preview surface) so they all agree on when a class\n * boundary is crossed. Reactive (recompute on resize) vs. fixed-per-launch (mobile, where orientation\n * change is the only runtime variable) are both just \"call this again when the dimensions you have\n * available change\" - the shape is the same either way, only the caller's triggering mechanism differs.\n *\n * @param width The available width, in device-independent pixels.\n * @param height The available height, in device-independent pixels.\n * @param widthBreakpoint The width at or above which {@link WidthSizeClass.Regular} applies. Defaults to {@link defaultWidthBreakpoint}.\n * @param heightBreakpoint The height at or above which {@link HeightSizeClass.Regular} applies. Defaults to {@link defaultHeightBreakpoint}.\n * @returns The computed {@link SizeClass}.\n */\nexport function computeSizeClass(width: number, height: number, widthBreakpoint = defaultWidthBreakpoint, heightBreakpoint = defaultHeightBreakpoint): SizeClass {\n return {\n width: width >= widthBreakpoint ? WidthSizeClass.Regular : WidthSizeClass.Compact,\n height: height >= heightBreakpoint ? HeightSizeClass.Regular : HeightSizeClass.Compact,\n };\n}\n"],"names":["defaultWidthBreakpoint","defaultHeightBreakpoint","computeSizeClass","width","height","widthBreakpoint","heightBreakpoint","WidthSizeClass","Regular","Compact","HeightSizeClass"],"mappings":";;;;AAAA;AACA;AAIA,kHACO,MAAMA,sBAAAA,GAAyB;AAEtC,oHACO,MAAMC,uBAAAA,GAA0B;AAEvC;;;;;;;;;;;;IAaO,SAASC,gBAAAA,CAAiBC,KAAa,EAAEC,MAAc,EAAEC,eAAAA,GAAkBL,sBAAsB,EAAEM,gBAAAA,GAAmBL,uBAAuB,EAAA;IAChJ,OAAO;AACHE,QAAAA,KAAAA,EAAOA,SAASE,eAAAA,GAAkBE,0BAAAA,CAAeC,OAAO,GAAGD,2BAAeE,OAAO;AACjFL,QAAAA,MAAAA,EAAQA,UAAUE,gBAAAA,GAAmBI,2BAAAA,CAAgBF,OAAO,GAAGE,4BAAgBD;AACnF,KAAA;AACJ;;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Type guards distinguishing the concrete element kinds Scene.Model ships, by the property each kind
|
|
7
|
+
* alone declares. A tree produced by Stage or Studio only ever carries these concrete shapes - `Element`,
|
|
8
|
+
* `VisualElement`, `FrameworkElement` and `Control` are never instantiated directly.
|
|
9
|
+
*/ function isContentControl(element) {
|
|
10
|
+
return 'content' in element;
|
|
11
|
+
}
|
|
12
|
+
function isItemsControl(element) {
|
|
13
|
+
return 'itemsSource' in element && 'itemTemplate' in element;
|
|
14
|
+
}
|
|
15
|
+
function isExternalComponent(element) {
|
|
16
|
+
return 'componentName' in element;
|
|
17
|
+
}
|
|
18
|
+
function isPanel(element) {
|
|
19
|
+
return 'children' in element;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.isContentControl = isContentControl;
|
|
23
|
+
exports.isExternalComponent = isExternalComponent;
|
|
24
|
+
exports.isItemsControl = isItemsControl;
|
|
25
|
+
exports.isPanel = isPanel;
|
|
26
|
+
//# sourceMappingURL=elementKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementKind.js","sources":["../../elementKind.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, ContentControl, ItemsControl, ExternalComponent, Panel } from '@cratis/scene.model';\n\n/**\n * Type guards distinguishing the concrete element kinds Scene.Model ships, by the property each kind\n * alone declares. A tree produced by Stage or Studio only ever carries these concrete shapes - `Element`,\n * `VisualElement`, `FrameworkElement` and `Control` are never instantiated directly.\n */\n\nexport function isContentControl(element: SceneElement): element is ContentControl {\n return 'content' in element;\n}\n\nexport function isItemsControl(element: SceneElement): element is ItemsControl {\n return 'itemsSource' in element && 'itemTemplate' in element;\n}\n\nexport function isExternalComponent(element: SceneElement): element is ExternalComponent {\n return 'componentName' in element;\n}\n\nexport function isPanel(element: SceneElement): element is Panel {\n return 'children' in element;\n}\n"],"names":["isContentControl","element","isItemsControl","isExternalComponent","isPanel"],"mappings":";;AAAA;AACA;AAIA;;;;IAMO,SAASA,gBAAAA,CAAiBC,OAAqB,EAAA;AAClD,IAAA,OAAO,SAAA,IAAaA,OAAAA;AACxB;AAEO,SAASC,eAAeD,OAAqB,EAAA;IAChD,OAAO,aAAA,IAAiBA,WAAW,cAAA,IAAkBA,OAAAA;AACzD;AAEO,SAASE,oBAAoBF,OAAqB,EAAA;AACrD,IAAA,OAAO,eAAA,IAAmBA,OAAAA;AAC9B;AAEO,SAASG,QAAQH,OAAqB,EAAA;AACzC,IAAA,OAAO,UAAA,IAAcA,OAAAA;AACzB;;;;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Selects the {@link FlowNode} tree that applies for a given {@link SizeClass} - part of Cratis/Scene#4.
|
|
7
|
+
*
|
|
8
|
+
* @param arrangement The {@link FlowArrangement} to evaluate.
|
|
9
|
+
* @param sizeClass The current {@link SizeClass}.
|
|
10
|
+
* @returns The most specific matching override's root (both dimensions targeted beats one; the last declared wins among equally specific matches), or `arrangement.root` when no override matches.
|
|
11
|
+
*/ function evaluateFlowArrangement(arrangement, sizeClass) {
|
|
12
|
+
let best;
|
|
13
|
+
for (const candidate of arrangement.overrides ?? []){
|
|
14
|
+
if (!matches(candidate, sizeClass)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!best || specificity(candidate) >= specificity(best)) {
|
|
18
|
+
best = candidate;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return best?.root ?? arrangement.root;
|
|
22
|
+
}
|
|
23
|
+
function matches(override, sizeClass) {
|
|
24
|
+
return (override.width === undefined || override.width === sizeClass.width) && (override.height === undefined || override.height === sizeClass.height);
|
|
25
|
+
}
|
|
26
|
+
function specificity(override) {
|
|
27
|
+
return (override.width !== undefined ? 1 : 0) + (override.height !== undefined ? 1 : 0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.evaluateFlowArrangement = evaluateFlowArrangement;
|
|
31
|
+
//# sourceMappingURL=evaluateFlowArrangement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateFlowArrangement.js","sources":["../../evaluateFlowArrangement.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 { FlowArrangement, FlowNode, FlowOverride, SizeClass } from '@cratis/scene.model';\n\n/**\n * Selects the {@link FlowNode} tree that applies for a given {@link SizeClass} - part of Cratis/Scene#4.\n *\n * @param arrangement The {@link FlowArrangement} to evaluate.\n * @param sizeClass The current {@link SizeClass}.\n * @returns The most specific matching override's root (both dimensions targeted beats one; the last declared wins among equally specific matches), or `arrangement.root` when no override matches.\n */\nexport function evaluateFlowArrangement(arrangement: FlowArrangement, sizeClass: SizeClass): FlowNode {\n let best: FlowOverride | undefined;\n for (const candidate of arrangement.overrides ?? []) {\n if (!matches(candidate, sizeClass)) {\n continue;\n }\n\n if (!best || specificity(candidate) >= specificity(best)) {\n best = candidate;\n }\n }\n\n return best?.root ?? arrangement.root;\n}\n\nfunction matches(override: FlowOverride, sizeClass: SizeClass): boolean {\n return (override.width === undefined || override.width === sizeClass.width) &&\n (override.height === undefined || override.height === sizeClass.height);\n}\n\nfunction specificity(override: FlowOverride): number {\n return (override.width !== undefined ? 1 : 0) + (override.height !== undefined ? 1 : 0);\n}\n"],"names":["evaluateFlowArrangement","arrangement","sizeClass","best","candidate","overrides","matches","specificity","root","override","width","undefined","height"],"mappings":";;AAAA;AACA;AAIA;;;;;;AAMC,IACM,SAASA,uBAAAA,CAAwBC,WAA4B,EAAEC,SAAoB,EAAA;IACtF,IAAIC,IAAAA;AACJ,IAAA,KAAK,MAAMC,SAAAA,IAAaH,WAAAA,CAAYI,SAAS,IAAI,EAAE,CAAE;QACjD,IAAI,CAACC,OAAAA,CAAQF,SAAAA,EAAWF,SAAAA,CAAAA,EAAY;AAChC,YAAA;AACJ,QAAA;AAEA,QAAA,IAAI,CAACC,IAAAA,IAAQI,WAAAA,CAAYH,SAAAA,CAAAA,IAAcG,YAAYJ,IAAAA,CAAAA,EAAO;YACtDA,IAAAA,GAAOC,SAAAA;AACX,QAAA;AACJ,IAAA;IAEA,OAAOD,IAAAA,EAAMK,IAAAA,IAAQP,WAAAA,CAAYO,IAAI;AACzC;AAEA,SAASF,OAAAA,CAAQG,QAAsB,EAAEP,SAAoB,EAAA;IACzD,OAAQO,CAAAA,QAAAA,CAASC,KAAK,KAAKC,SAAAA,IAAaF,QAAAA,CAASC,KAAK,KAAKR,SAAAA,CAAUQ,KAAK,MACrED,QAAAA,CAASG,MAAM,KAAKD,SAAAA,IAAaF,SAASG,MAAM,KAAKV,SAAAA,CAAUU,MAAM,CAAD;AAC7E;AAEA,SAASL,YAAYE,QAAsB,EAAA;AACvC,IAAA,OAAO,CAACA,QAAAA,CAASC,KAAK,KAAKC,SAAAA,GAAY,CAAA,GAAI,CAAA,KAAMF,QAAAA,CAASG,MAAM,KAAKD,SAAAA,GAAY,IAAI,CAAA,CAAA;AACzF;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Selects the {@link FreeformVariant} that targets a given {@link SizeClass} - part of Cratis/Scene#4.
|
|
7
|
+
*
|
|
8
|
+
* @param arrangement The {@link FreeformArrangement} to evaluate.
|
|
9
|
+
* @param sizeClass The current {@link SizeClass}.
|
|
10
|
+
* @returns The variant whose size class exactly matches, or `undefined` when nothing targets it. There is deliberately no fallback here - a size class with no matching variant is a design-time/build-time warning elsewhere, never a silently picked variant.
|
|
11
|
+
*/ function evaluateFreeformArrangement(arrangement, sizeClass) {
|
|
12
|
+
return arrangement.variants.find((variant)=>variant.sizeClass.width === sizeClass.width && variant.sizeClass.height === sizeClass.height);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.evaluateFreeformArrangement = evaluateFreeformArrangement;
|
|
16
|
+
//# sourceMappingURL=evaluateFreeformArrangement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateFreeformArrangement.js","sources":["../../evaluateFreeformArrangement.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 { FreeformArrangement, FreeformVariant, SizeClass } from '@cratis/scene.model';\n\n/**\n * Selects the {@link FreeformVariant} that targets a given {@link SizeClass} - part of Cratis/Scene#4.\n *\n * @param arrangement The {@link FreeformArrangement} to evaluate.\n * @param sizeClass The current {@link SizeClass}.\n * @returns The variant whose size class exactly matches, or `undefined` when nothing targets it. There is deliberately no fallback here - a size class with no matching variant is a design-time/build-time warning elsewhere, never a silently picked variant.\n */\nexport function evaluateFreeformArrangement(arrangement: FreeformArrangement, sizeClass: SizeClass): FreeformVariant | undefined {\n return arrangement.variants.find(variant => variant.sizeClass.width === sizeClass.width && variant.sizeClass.height === sizeClass.height);\n}\n"],"names":["evaluateFreeformArrangement","arrangement","sizeClass","variants","find","variant","width","height"],"mappings":";;AAAA;AACA;AAIA;;;;;;AAMC,IACM,SAASA,2BAAAA,CAA4BC,WAAgC,EAAEC,SAAoB,EAAA;IAC9F,OAAOD,WAAAA,CAAYE,QAAQ,CAACC,IAAI,CAACC,CAAAA,OAAAA,GAAWA,QAAQH,SAAS,CAACI,KAAK,KAAKJ,SAAAA,CAAUI,KAAK,IAAID,OAAAA,CAAQH,SAAS,CAACK,MAAM,KAAKL,SAAAA,CAAUK,MAAM,CAAA;AAC5I;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Selects the {@link FreeformSlotVariant} that targets a given {@link SizeClass} - the counterpart to
|
|
7
|
+
* {@link evaluateFreeformArrangement} for a `Layout`'s own macro `arrangement`, which places the layout's
|
|
8
|
+
* slots themselves rather than the content of one slot.
|
|
9
|
+
*
|
|
10
|
+
* @param arrangement The {@link FreeformSlotArrangement} to evaluate.
|
|
11
|
+
* @param sizeClass The current {@link SizeClass}.
|
|
12
|
+
* @returns The variant whose size class exactly matches, or `undefined` when nothing targets it. There is deliberately no fallback here - a size class with no matching variant is a design-time/build-time warning elsewhere, never a silently picked variant.
|
|
13
|
+
*/ function evaluateFreeformSlotArrangement(arrangement, sizeClass) {
|
|
14
|
+
return arrangement.variants.find((variant)=>variant.sizeClass.width === sizeClass.width && variant.sizeClass.height === sizeClass.height);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.evaluateFreeformSlotArrangement = evaluateFreeformSlotArrangement;
|
|
18
|
+
//# sourceMappingURL=evaluateFreeformSlotArrangement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateFreeformSlotArrangement.js","sources":["../../evaluateFreeformSlotArrangement.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 { FreeformSlotArrangement, FreeformSlotVariant, SizeClass } from '@cratis/scene.model';\n\n/**\n * Selects the {@link FreeformSlotVariant} that targets a given {@link SizeClass} - the counterpart to\n * {@link evaluateFreeformArrangement} for a `Layout`'s own macro `arrangement`, which places the layout's\n * slots themselves rather than the content of one slot.\n *\n * @param arrangement The {@link FreeformSlotArrangement} to evaluate.\n * @param sizeClass The current {@link SizeClass}.\n * @returns The variant whose size class exactly matches, or `undefined` when nothing targets it. There is deliberately no fallback here - a size class with no matching variant is a design-time/build-time warning elsewhere, never a silently picked variant.\n */\nexport function evaluateFreeformSlotArrangement(arrangement: FreeformSlotArrangement, sizeClass: SizeClass): FreeformSlotVariant | undefined {\n return arrangement.variants.find(variant => variant.sizeClass.width === sizeClass.width && variant.sizeClass.height === sizeClass.height);\n}\n"],"names":["evaluateFreeformSlotArrangement","arrangement","sizeClass","variants","find","variant","width","height"],"mappings":";;AAAA;AACA;AAIA;;;;;;;;AAQC,IACM,SAASA,+BAAAA,CAAgCC,WAAoC,EAAEC,SAAoB,EAAA;IACtG,OAAOD,WAAAA,CAAYE,QAAQ,CAACC,IAAI,CAACC,CAAAA,OAAAA,GAAWA,QAAQH,SAAS,CAACI,KAAK,KAAKJ,SAAAA,CAAUI,KAAK,IAAID,OAAAA,CAAQH,SAAS,CAACK,MAAM,KAAKL,SAAAA,CAAUK,MAAM,CAAA;AAC5I;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* Type guards distinguishing the concrete nodes a flow arrangement tree is built from.
|
|
9
|
+
*
|
|
10
|
+
* Leaves are told apart the same way `elementKind` tells element kinds apart - by the property each one
|
|
11
|
+
* alone declares. Containers cannot be: a row and a column have exactly the same members, so no structural
|
|
12
|
+
* test can separate them. They carry an explicit {@link FlowContainerKind} instead, which is what makes
|
|
13
|
+
* them a discriminated union rather than three identical shapes, and what lets a renderer decide between
|
|
14
|
+
* a horizontal and a vertical arrangement at all.
|
|
15
|
+
*/ function isFlowContainer(node) {
|
|
16
|
+
return 'kind' in node && 'children' in node;
|
|
17
|
+
}
|
|
18
|
+
function isFlowRow(node) {
|
|
19
|
+
return isFlowContainer(node) && node.kind === scene_model.FlowContainerKind.Row;
|
|
20
|
+
}
|
|
21
|
+
function isFlowColumn(node) {
|
|
22
|
+
return isFlowContainer(node) && node.kind === scene_model.FlowContainerKind.Column;
|
|
23
|
+
}
|
|
24
|
+
function isFlowGrid(node) {
|
|
25
|
+
return isFlowContainer(node) && node.kind === scene_model.FlowContainerKind.Grid;
|
|
26
|
+
}
|
|
27
|
+
function isFlowLeaf(node) {
|
|
28
|
+
return 'content' in node;
|
|
29
|
+
}
|
|
30
|
+
function isFlowSlotLeaf(node) {
|
|
31
|
+
return 'slotName' in node;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.isFlowColumn = isFlowColumn;
|
|
35
|
+
exports.isFlowContainer = isFlowContainer;
|
|
36
|
+
exports.isFlowGrid = isFlowGrid;
|
|
37
|
+
exports.isFlowLeaf = isFlowLeaf;
|
|
38
|
+
exports.isFlowRow = isFlowRow;
|
|
39
|
+
exports.isFlowSlotLeaf = isFlowSlotLeaf;
|
|
40
|
+
//# sourceMappingURL=flowNodeKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowNodeKind.js","sources":["../../flowNodeKind.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 { FlowColumn, FlowContainer, FlowContainerKind, FlowGrid, FlowLeaf, FlowNode, FlowRow, FlowSlotLeaf } from '@cratis/scene.model';\n\n/**\n * Type guards distinguishing the concrete nodes a flow arrangement tree is built from.\n *\n * Leaves are told apart the same way `elementKind` tells element kinds apart - by the property each one\n * alone declares. Containers cannot be: a row and a column have exactly the same members, so no structural\n * test can separate them. They carry an explicit {@link FlowContainerKind} instead, which is what makes\n * them a discriminated union rather than three identical shapes, and what lets a renderer decide between\n * a horizontal and a vertical arrangement at all.\n */\n\nexport function isFlowContainer(node: FlowNode): node is FlowContainer {\n return 'kind' in node && 'children' in node;\n}\n\nexport function isFlowRow(node: FlowNode): node is FlowRow {\n return isFlowContainer(node) && node.kind === FlowContainerKind.Row;\n}\n\nexport function isFlowColumn(node: FlowNode): node is FlowColumn {\n return isFlowContainer(node) && node.kind === FlowContainerKind.Column;\n}\n\nexport function isFlowGrid(node: FlowNode): node is FlowGrid {\n return isFlowContainer(node) && node.kind === FlowContainerKind.Grid;\n}\n\nexport function isFlowLeaf(node: FlowNode): node is FlowLeaf {\n return 'content' in node;\n}\n\nexport function isFlowSlotLeaf(node: FlowNode): node is FlowSlotLeaf {\n return 'slotName' in node;\n}\n"],"names":["isFlowContainer","node","isFlowRow","kind","FlowContainerKind","Row","isFlowColumn","Column","isFlowGrid","Grid","isFlowLeaf","isFlowSlotLeaf"],"mappings":";;;;AAAA;AACA;AAIA;;;;;;;;IAUO,SAASA,eAAAA,CAAgBC,IAAc,EAAA;IAC1C,OAAO,MAAA,IAAUA,QAAQ,UAAA,IAAcA,IAAAA;AAC3C;AAEO,SAASC,UAAUD,IAAc,EAAA;AACpC,IAAA,OAAOD,gBAAgBC,IAAAA,CAAAA,IAASA,IAAAA,CAAKE,IAAI,KAAKC,8BAAkBC,GAAG;AACvE;AAEO,SAASC,aAAaL,IAAc,EAAA;AACvC,IAAA,OAAOD,gBAAgBC,IAAAA,CAAAA,IAASA,IAAAA,CAAKE,IAAI,KAAKC,8BAAkBG,MAAM;AAC1E;AAEO,SAASC,WAAWP,IAAc,EAAA;AACrC,IAAA,OAAOD,gBAAgBC,IAAAA,CAAAA,IAASA,IAAAA,CAAKE,IAAI,KAAKC,8BAAkBK,IAAI;AACxE;AAEO,SAASC,WAAWT,IAAc,EAAA;AACrC,IAAA,OAAO,SAAA,IAAaA,IAAAA;AACxB;AAEO,SAASU,eAAeV,IAAc,EAAA;AACzC,IAAA,OAAO,UAAA,IAAcA,IAAAA;AACzB;;;;;;;;;"}
|