@cratis/scene.engine 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editing/DescriptorCatalog.js +42 -0
- package/dist/cjs/editing/DescriptorCatalog.js.map +1 -0
- package/dist/cjs/editing/EditSession.js +44 -0
- package/dist/cjs/editing/EditSession.js.map +1 -0
- package/dist/cjs/editing/applyEdit.js +83 -0
- package/dist/cjs/editing/applyEdit.js.map +1 -0
- package/dist/cjs/editing/applyEffectiveConfiguration.js +62 -0
- package/dist/cjs/editing/applyEffectiveConfiguration.js.map +1 -0
- package/dist/cjs/editing/collectComponents.js +34 -0
- package/dist/cjs/editing/collectComponents.js.map +1 -0
- package/dist/cjs/editing/describeNode.js +63 -0
- package/dist/cjs/editing/describeNode.js.map +1 -0
- package/dist/cjs/editing/diagnostics.js +36 -0
- package/dist/cjs/editing/diagnostics.js.map +1 -0
- package/dist/cjs/editing/documentPaths.js +45 -0
- package/dist/cjs/editing/documentPaths.js.map +1 -0
- package/dist/cjs/editing/exposureEdits.js +106 -0
- package/dist/cjs/editing/exposureEdits.js.map +1 -0
- package/dist/cjs/editing/exposureGrants.js +115 -0
- package/dist/cjs/editing/exposureGrants.js.map +1 -0
- package/dist/cjs/editing/indexDocument.js +400 -0
- package/dist/cjs/editing/indexDocument.js.map +1 -0
- package/dist/cjs/editing/inspect.js +127 -0
- package/dist/cjs/editing/inspect.js.map +1 -0
- package/dist/cjs/editing/instanceEdits.js +255 -0
- package/dist/cjs/editing/instanceEdits.js.map +1 -0
- package/dist/cjs/editing/layoutTypeDescriptors.js +425 -0
- package/dist/cjs/editing/layoutTypeDescriptors.js.map +1 -0
- package/dist/cjs/editing/layoutTypeEdits.js +141 -0
- package/dist/cjs/editing/layoutTypeEdits.js.map +1 -0
- package/dist/cjs/editing/nodeIds.js +115 -0
- package/dist/cjs/editing/nodeIds.js.map +1 -0
- package/dist/cjs/editing/pathAccess.js +53 -0
- package/dist/cjs/editing/pathAccess.js.map +1 -0
- package/dist/cjs/editing/propertyEdits.js +118 -0
- package/dist/cjs/editing/propertyEdits.js.map +1 -0
- package/dist/cjs/editing/resolveEffectiveConfiguration.js +200 -0
- package/dist/cjs/editing/resolveEffectiveConfiguration.js.map +1 -0
- package/dist/cjs/editing/resolveTemplateChain.js +100 -0
- package/dist/cjs/editing/resolveTemplateChain.js.map +1 -0
- package/dist/cjs/editing/structureEdits.js +231 -0
- package/dist/cjs/editing/structureEdits.js.map +1 -0
- package/dist/cjs/editing/validateBinding.js +111 -0
- package/dist/cjs/editing/validateBinding.js.map +1 -0
- package/dist/cjs/editing/validateValue.js +114 -0
- package/dist/cjs/editing/validateValue.js.map +1 -0
- package/dist/cjs/index.js +51 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/editing/DescriptorCatalog.d.ts +9 -0
- package/dist/esm/editing/DescriptorCatalog.d.ts.map +1 -0
- package/dist/esm/editing/DescriptorCatalog.js +38 -0
- package/dist/esm/editing/DescriptorCatalog.js.map +1 -0
- package/dist/esm/editing/DocumentIndex.d.ts +31 -0
- package/dist/esm/editing/DocumentIndex.d.ts.map +1 -0
- package/dist/esm/editing/DocumentIndex.js +2 -0
- package/dist/esm/editing/DocumentIndex.js.map +1 -0
- package/dist/esm/editing/EditOutcome.d.ts +7 -0
- package/dist/esm/editing/EditOutcome.d.ts.map +1 -0
- package/dist/esm/editing/EditOutcome.js +2 -0
- package/dist/esm/editing/EditOutcome.js.map +1 -0
- package/dist/esm/editing/EditSession.d.ts +20 -0
- package/dist/esm/editing/EditSession.d.ts.map +1 -0
- package/dist/esm/editing/EditSession.js +42 -0
- package/dist/esm/editing/EditSession.js.map +1 -0
- package/dist/esm/editing/EditingContext.d.ts +8 -0
- package/dist/esm/editing/EditingContext.d.ts.map +1 -0
- package/dist/esm/editing/EditingContext.js +2 -0
- package/dist/esm/editing/EditingContext.js.map +1 -0
- package/dist/esm/editing/TemplateChain.d.ts +13 -0
- package/dist/esm/editing/TemplateChain.d.ts.map +1 -0
- package/dist/esm/editing/TemplateChain.js +2 -0
- package/dist/esm/editing/TemplateChain.js.map +1 -0
- package/dist/esm/editing/applyEdit.d.ts +5 -0
- package/dist/esm/editing/applyEdit.d.ts.map +1 -0
- package/dist/esm/editing/applyEdit.js +81 -0
- package/dist/esm/editing/applyEdit.js.map +1 -0
- package/dist/esm/editing/applyEffectiveConfiguration.d.ts +3 -0
- package/dist/esm/editing/applyEffectiveConfiguration.d.ts.map +1 -0
- package/dist/esm/editing/applyEffectiveConfiguration.js +60 -0
- package/dist/esm/editing/applyEffectiveConfiguration.js.map +1 -0
- package/dist/esm/editing/collectComponents.d.ts +3 -0
- package/dist/esm/editing/collectComponents.d.ts.map +1 -0
- package/dist/esm/editing/collectComponents.js +32 -0
- package/dist/esm/editing/collectComponents.js.map +1 -0
- package/dist/esm/editing/describeNode.d.ts +11 -0
- package/dist/esm/editing/describeNode.d.ts.map +1 -0
- package/dist/esm/editing/describeNode.js +60 -0
- package/dist/esm/editing/describeNode.js.map +1 -0
- package/dist/esm/editing/diagnostics.d.ts +6 -0
- package/dist/esm/editing/diagnostics.d.ts.map +1 -0
- package/dist/esm/editing/diagnostics.js +32 -0
- package/dist/esm/editing/diagnostics.js.map +1 -0
- package/dist/esm/editing/documentPaths.d.ts +8 -0
- package/dist/esm/editing/documentPaths.d.ts.map +1 -0
- package/dist/esm/editing/documentPaths.js +41 -0
- package/dist/esm/editing/documentPaths.js.map +1 -0
- package/dist/esm/editing/exposureEdits.d.ts +5 -0
- package/dist/esm/editing/exposureEdits.d.ts.map +1 -0
- package/dist/esm/editing/exposureEdits.js +103 -0
- package/dist/esm/editing/exposureEdits.js.map +1 -0
- package/dist/esm/editing/exposureGrants.d.ts +21 -0
- package/dist/esm/editing/exposureGrants.d.ts.map +1 -0
- package/dist/esm/editing/exposureGrants.js +112 -0
- package/dist/esm/editing/exposureGrants.js.map +1 -0
- package/dist/esm/editing/given/a_layout_document.d.ts +14 -0
- package/dist/esm/editing/given/a_layout_document.d.ts.map +1 -0
- package/dist/esm/editing/given/a_layout_document.js +67 -0
- package/dist/esm/editing/given/a_layout_document.js.map +1 -0
- package/dist/esm/editing/given/a_scene_document.d.ts +20 -0
- package/dist/esm/editing/given/a_scene_document.d.ts.map +1 -0
- package/dist/esm/editing/given/a_scene_document.js +110 -0
- package/dist/esm/editing/given/a_scene_document.js.map +1 -0
- package/dist/esm/editing/index.d.ts +19 -0
- package/dist/esm/editing/index.d.ts.map +1 -0
- package/dist/esm/editing/index.js +19 -0
- package/dist/esm/editing/index.js.map +1 -0
- package/dist/esm/editing/indexDocument.d.ts +6 -0
- package/dist/esm/editing/indexDocument.d.ts.map +1 -0
- package/dist/esm/editing/indexDocument.js +396 -0
- package/dist/esm/editing/indexDocument.js.map +1 -0
- package/dist/esm/editing/inspect.d.ts +8 -0
- package/dist/esm/editing/inspect.d.ts.map +1 -0
- package/dist/esm/editing/inspect.js +124 -0
- package/dist/esm/editing/inspect.js.map +1 -0
- package/dist/esm/editing/instanceEdits.d.ts +9 -0
- package/dist/esm/editing/instanceEdits.d.ts.map +1 -0
- package/dist/esm/editing/instanceEdits.js +248 -0
- package/dist/esm/editing/instanceEdits.js.map +1 -0
- package/dist/esm/editing/layoutTypeDescriptors.d.ts +5 -0
- package/dist/esm/editing/layoutTypeDescriptors.d.ts.map +1 -0
- package/dist/esm/editing/layoutTypeDescriptors.js +421 -0
- package/dist/esm/editing/layoutTypeDescriptors.js.map +1 -0
- package/dist/esm/editing/layoutTypeEdits.d.ts +4 -0
- package/dist/esm/editing/layoutTypeEdits.d.ts.map +1 -0
- package/dist/esm/editing/layoutTypeEdits.js +139 -0
- package/dist/esm/editing/layoutTypeEdits.js.map +1 -0
- package/dist/esm/editing/nodeIds.d.ts +14 -0
- package/dist/esm/editing/nodeIds.d.ts.map +1 -0
- package/dist/esm/editing/nodeIds.js +102 -0
- package/dist/esm/editing/nodeIds.js.map +1 -0
- package/dist/esm/editing/pathAccess.d.ts +7 -0
- package/dist/esm/editing/pathAccess.d.ts.map +1 -0
- package/dist/esm/editing/pathAccess.js +48 -0
- package/dist/esm/editing/pathAccess.js.map +1 -0
- package/dist/esm/editing/propertyEdits.d.ts +15 -0
- package/dist/esm/editing/propertyEdits.d.ts.map +1 -0
- package/dist/esm/editing/propertyEdits.js +113 -0
- package/dist/esm/editing/propertyEdits.js.map +1 -0
- package/dist/esm/editing/resolveEffectiveConfiguration.d.ts +5 -0
- package/dist/esm/editing/resolveEffectiveConfiguration.d.ts.map +1 -0
- package/dist/esm/editing/resolveEffectiveConfiguration.js +198 -0
- package/dist/esm/editing/resolveEffectiveConfiguration.js.map +1 -0
- package/dist/esm/editing/resolveTemplateChain.d.ts +4 -0
- package/dist/esm/editing/resolveTemplateChain.d.ts.map +1 -0
- package/dist/esm/editing/resolveTemplateChain.js +98 -0
- package/dist/esm/editing/resolveTemplateChain.js.map +1 -0
- package/dist/esm/editing/structureEdits.d.ts +6 -0
- package/dist/esm/editing/structureEdits.d.ts.map +1 -0
- package/dist/esm/editing/structureEdits.js +227 -0
- package/dist/esm/editing/structureEdits.js.map +1 -0
- package/dist/esm/editing/validateBinding.d.ts +7 -0
- package/dist/esm/editing/validateBinding.d.ts.map +1 -0
- package/dist/esm/editing/validateBinding.js +108 -0
- package/dist/esm/editing/validateBinding.js.map +1 -0
- package/dist/esm/editing/validateValue.d.ts +8 -0
- package/dist/esm/editing/validateValue.d.ts.map +1 -0
- package/dist/esm/editing/validateValue.js +111 -0
- package/dist/esm/editing/validateValue.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/editing/DescriptorCatalog.ts +51 -0
- package/editing/DocumentIndex.ts +73 -0
- package/editing/EditOutcome.ts +21 -0
- package/editing/EditSession.ts +50 -0
- package/editing/EditingContext.ts +23 -0
- package/editing/TemplateChain.ts +36 -0
- package/editing/applyEdit.ts +69 -0
- package/editing/applyEffectiveConfiguration.ts +53 -0
- package/editing/collectComponents.ts +36 -0
- package/editing/describeNode.ts +61 -0
- package/editing/diagnostics.ts +30 -0
- package/editing/documentPaths.ts +40 -0
- package/editing/exposureEdits.ts +119 -0
- package/editing/exposureGrants.ts +159 -0
- package/editing/given/a_layout_document.ts +88 -0
- package/editing/given/a_scene_document.ts +135 -0
- package/editing/index.ts +21 -0
- package/editing/indexDocument.ts +237 -0
- package/editing/inspect.ts +142 -0
- package/editing/instanceEdits.ts +243 -0
- package/editing/layoutTypeDescriptors.ts +191 -0
- package/editing/layoutTypeEdits.ts +135 -0
- package/editing/nodeIds.ts +111 -0
- package/editing/pathAccess.ts +81 -0
- package/editing/propertyEdits.ts +119 -0
- package/editing/resolveEffectiveConfiguration.ts +202 -0
- package/editing/resolveTemplateChain.ts +109 -0
- package/editing/structureEdits.ts +234 -0
- package/editing/validateBinding.ts +103 -0
- package/editing/validateValue.ts +130 -0
- package/index.ts +1 -0
- package/package.json +5 -4
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.d.ts +0 -2
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.d.ts.map +0 -1
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.js +0 -23
- package/dist/esm/for_aggregateContributions/when_aggregating_by_contribution_point.js.map +0 -1
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.js +0 -16
- package/dist/esm/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.d.ts +0 -2
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.d.ts.map +0 -1
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.js +0 -17
- package/dist/esm/for_computeSizeClass/when_computing_the_size_class.js.map +0 -1
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.js +0 -43
- package/dist/esm/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.js +0 -46
- package/dist/esm/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.js +0 -25
- package/dist/esm/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.js +0 -17
- package/dist/esm/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.js +0 -22
- package/dist/esm/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_packageDependencies/fixtures.d.ts +0 -38
- package/dist/esm/for_packageDependencies/fixtures.d.ts.map +0 -1
- package/dist/esm/for_packageDependencies/fixtures.js +0 -5
- package/dist/esm/for_packageDependencies/fixtures.js.map +0 -1
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.js +0 -29
- package/dist/esm/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.js +0 -10
- package/dist/esm/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_panelKind/when_telling_the_panels_apart.d.ts +0 -2
- package/dist/esm/for_panelKind/when_telling_the_panels_apart.d.ts.map +0 -1
- package/dist/esm/for_panelKind/when_telling_the_panels_apart.js +0 -38
- package/dist/esm/for_panelKind/when_telling_the_panels_apart.js.map +0 -1
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.d.ts +0 -2
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.d.ts.map +0 -1
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.js +0 -46
- package/dist/esm/for_renderElement/when_rendering_a_mixed_tree.js.map +0 -1
- package/dist/esm/for_resolveBehaviors/when_resolving_additive_attachments.d.ts +0 -2
- package/dist/esm/for_resolveBehaviors/when_resolving_additive_attachments.d.ts.map +0 -1
- package/dist/esm/for_resolveBehaviors/when_resolving_additive_attachments.js +0 -68
- package/dist/esm/for_resolveBehaviors/when_resolving_additive_attachments.js.map +0 -1
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.js +0 -20
- package/dist/esm/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js +0 -30
- package/dist/esm/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_resolveStrings/when_resolving_a_strings_reference.d.ts +0 -2
- package/dist/esm/for_resolveStrings/when_resolving_a_strings_reference.d.ts.map +0 -1
- package/dist/esm/for_resolveStrings/when_resolving_a_strings_reference.js +0 -69
- package/dist/esm/for_resolveStrings/when_resolving_a_strings_reference.js.map +0 -1
- package/dist/esm/for_runActions/given/a_recording_dispatcher.d.ts +0 -21
- package/dist/esm/for_runActions/given/a_recording_dispatcher.d.ts.map +0 -1
- package/dist/esm/for_runActions/given/a_recording_dispatcher.js +0 -45
- package/dist/esm/for_runActions/given/a_recording_dispatcher.js.map +0 -1
- package/dist/esm/for_runActions/when_running_a_sequence_of_actions.d.ts +0 -2
- package/dist/esm/for_runActions/when_running_a_sequence_of_actions.d.ts.map +0 -1
- package/dist/esm/for_runActions/when_running_a_sequence_of_actions.js +0 -126
- package/dist/esm/for_runActions/when_running_a_sequence_of_actions.js.map +0 -1
- package/dist/esm/for_runActions/when_running_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_runActions/when_running_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_runActions/when_running_against_the_shared_fixture_corpus.js +0 -61
- package/dist/esm/for_runActions/when_running_against_the_shared_fixture_corpus.js.map +0 -1
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.d.ts +0 -2
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.d.ts.map +0 -1
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.js +0 -18
- package/dist/esm/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.js.map +0 -1
- package/for_aggregateContributions/when_aggregating_by_contribution_point.ts +0 -31
- package/for_buildStarterProfile/when_checking_against_the_shared_fixture_corpus.ts +0 -32
- package/for_computeSizeClass/when_computing_the_size_class.ts +0 -23
- package/for_evaluateFlowArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +0 -67
- package/for_evaluateFreeformArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +0 -68
- package/for_evaluateFreeformSlotArrangement/when_evaluating_against_the_shared_fixture_corpus.ts +0 -47
- package/for_incompatibleStarterThemes/when_checking_against_the_shared_fixture_corpus.ts +0 -34
- package/for_packageCatalog/when_querying_against_the_shared_fixture_corpus.ts +0 -26
- package/for_packageDependencies/fixtures.ts +0 -44
- package/for_packageDependencies/when_resolving_against_the_shared_fixture_corpus.ts +0 -39
- package/for_packageVersionRange/when_checking_against_the_shared_fixture_corpus.ts +0 -13
- package/for_panelKind/when_telling_the_panels_apart.ts +0 -47
- package/for_renderElement/when_rendering_a_mixed_tree.ts +0 -58
- package/for_resolveBehaviors/when_resolving_additive_attachments.ts +0 -100
- package/for_resolveComponentName/when_resolving_against_the_shared_fixture_corpus.ts +0 -36
- package/for_resolveScreenTemplates/when_resolving_against_the_shared_fixture_corpus.ts +0 -49
- package/for_resolveStrings/when_resolving_a_strings_reference.ts +0 -85
- package/for_runActions/given/a_recording_dispatcher.ts +0 -72
- package/for_runActions/when_running_a_sequence_of_actions.ts +0 -226
- package/for_runActions/when_running_against_the_shared_fixture_corpus.ts +0 -124
- package/for_themeCompatibility/when_checking_against_the_shared_fixture_corpus.ts +0 -37
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var layoutTypeDescriptors = require('./layoutTypeDescriptors.js');
|
|
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
|
+
* Builds a catalog from the component descriptors of the active packages, plus the built-in layout types.
|
|
9
|
+
*
|
|
10
|
+
* When two descriptors name the same component the later one wins, which is the same override-priority rule
|
|
11
|
+
* the profile's package order already means for components.
|
|
12
|
+
*/ function createDescriptorCatalog(componentDescriptors = []) {
|
|
13
|
+
const byComponent = new Map();
|
|
14
|
+
for (const descriptor of componentDescriptors)byComponent.set(descriptor.component, descriptor);
|
|
15
|
+
return {
|
|
16
|
+
components: [
|
|
17
|
+
...byComponent.values()
|
|
18
|
+
],
|
|
19
|
+
layoutTypes: layoutTypeDescriptors.layoutTypeDescriptors
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Finds the descriptor of a component by the name an element carries.
|
|
24
|
+
*
|
|
25
|
+
* An exact match wins. Otherwise a bare name (`dataTable`) finds the one descriptor whose component ends in
|
|
26
|
+
* `:dataTable`; a bare name that several packages describe has no single answer, so it finds none.
|
|
27
|
+
*/ function findComponentDescriptor(catalog, componentName) {
|
|
28
|
+
const exact = catalog.components.find((descriptor)=>descriptor.component === componentName);
|
|
29
|
+
if (exact) return exact;
|
|
30
|
+
const matches = catalog.components.filter((descriptor)=>descriptor.component.endsWith(`:${componentName}`));
|
|
31
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Finds the descriptor of a layout type.
|
|
35
|
+
*/ function findLayoutTypeDescriptor(catalog, type) {
|
|
36
|
+
return catalog.layoutTypes.find((descriptor)=>descriptor.type === type);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.createDescriptorCatalog = createDescriptorCatalog;
|
|
40
|
+
exports.findComponentDescriptor = findComponentDescriptor;
|
|
41
|
+
exports.findLayoutTypeDescriptor = findLayoutTypeDescriptor;
|
|
42
|
+
//# sourceMappingURL=DescriptorCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptorCatalog.js","sources":["../../../editing/DescriptorCatalog.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentDescriptor, LayoutTypeDescriptor } from '@cratis/scene.model';\nimport { layoutTypeDescriptors } from './layoutTypeDescriptors';\n\n/**\n * Everything an editor knows how to describe: the component descriptors packages contribute, and the layout types\n * the model itself defines.\n *\n * It is a derived view over what packages ship - not a registry anything registers into. Build one from the\n * descriptors of the packages a profile lists, and rebuild it when the list changes.\n */\nexport interface DescriptorCatalog {\n components: ComponentDescriptor[];\n layoutTypes: LayoutTypeDescriptor[];\n}\n\n/**\n * Builds a catalog from the component descriptors of the active packages, plus the built-in layout types.\n *\n * When two descriptors name the same component the later one wins, which is the same override-priority rule\n * the profile's package order already means for components.\n */\nexport function createDescriptorCatalog(componentDescriptors: ComponentDescriptor[] = []): DescriptorCatalog {\n const byComponent = new Map<string, ComponentDescriptor>();\n for (const descriptor of componentDescriptors) byComponent.set(descriptor.component, descriptor);\n\n return { components: [...byComponent.values()], layoutTypes: layoutTypeDescriptors };\n}\n\n/**\n * Finds the descriptor of a component by the name an element carries.\n *\n * An exact match wins. Otherwise a bare name (`dataTable`) finds the one descriptor whose component ends in\n * `:dataTable`; a bare name that several packages describe has no single answer, so it finds none.\n */\nexport function findComponentDescriptor(catalog: DescriptorCatalog, componentName: string): ComponentDescriptor | undefined {\n const exact = catalog.components.find(descriptor => descriptor.component === componentName);\n if (exact) return exact;\n\n const matches = catalog.components.filter(descriptor => descriptor.component.endsWith(`:${componentName}`));\n return matches.length === 1 ? matches[0] : undefined;\n}\n\n/**\n * Finds the descriptor of a layout type.\n */\nexport function findLayoutTypeDescriptor(catalog: DescriptorCatalog, type: string): LayoutTypeDescriptor | undefined {\n return catalog.layoutTypes.find(descriptor => descriptor.type === type);\n}\n"],"names":["createDescriptorCatalog","componentDescriptors","byComponent","Map","descriptor","set","component","components","values","layoutTypes","layoutTypeDescriptors","findComponentDescriptor","catalog","componentName","exact","find","matches","filter","endsWith","length","undefined","findLayoutTypeDescriptor","type"],"mappings":";;;;AAAA;AACA;AAiBA;;;;;AAKC,IACM,SAASA,uBAAAA,CAAwBC,oBAAAA,GAA8C,EAAE,EAAA;AACpF,IAAA,MAAMC,cAAc,IAAIC,GAAAA,EAAAA;IACxB,KAAK,MAAMC,cAAcH,oBAAAA,CAAsBC,WAAAA,CAAYG,GAAG,CAACD,UAAAA,CAAWE,SAAS,EAAEF,UAAAA,CAAAA;IAErF,OAAO;QAAEG,UAAAA,EAAY;AAAIL,YAAAA,GAAAA,WAAAA,CAAYM,MAAM;AAAG,SAAA;QAAEC,WAAAA,EAAaC;AAAsB,KAAA;AACvF;AAEA;;;;;AAKC,IACM,SAASC,uBAAAA,CAAwBC,OAA0B,EAAEC,aAAqB,EAAA;IACrF,MAAMC,KAAAA,GAAQF,OAAAA,CAAQL,UAAU,CAACQ,IAAI,CAACX,CAAAA,UAAAA,GAAcA,UAAAA,CAAWE,SAAS,KAAKO,aAAAA,CAAAA;AAC7E,IAAA,IAAIC,OAAO,OAAOA,KAAAA;AAElB,IAAA,MAAME,UAAUJ,OAAAA,CAAQL,UAAU,CAACU,MAAM,CAACb,CAAAA,UAAAA,GAAcA,UAAAA,CAAWE,SAAS,CAACY,QAAQ,CAAC,CAAC,CAAC,EAAEL,aAAAA,CAAAA,CAAe,CAAA,CAAA;AACzG,IAAA,OAAOG,QAAQG,MAAM,KAAK,IAAIH,OAAO,CAAC,EAAE,GAAGI,SAAAA;AAC/C;AAEA;;AAEC,IACM,SAASC,wBAAAA,CAAyBT,OAA0B,EAAEU,IAAY,EAAA;IAC7E,OAAOV,OAAAA,CAAQH,WAAW,CAACM,IAAI,CAACX,CAAAA,UAAAA,GAAcA,UAAAA,CAAWkB,IAAI,KAAKA,IAAAA,CAAAA;AACtE;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var exposureGrants = require('./exposureGrants.js');
|
|
5
|
+
var indexDocument = require('./indexDocument.js');
|
|
6
|
+
var inspect = require('./inspect.js');
|
|
7
|
+
var resolveEffectiveConfiguration = require('./resolveEffectiveConfiguration.js');
|
|
8
|
+
var resolveTemplateChain = require('./resolveTemplateChain.js');
|
|
9
|
+
|
|
10
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
11
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
12
|
+
/**
|
|
13
|
+
* Everything an edit needs to decide whether it is allowed, worked out once against the document as it was.
|
|
14
|
+
*/ class EditSession {
|
|
15
|
+
document;
|
|
16
|
+
context;
|
|
17
|
+
index;
|
|
18
|
+
chain;
|
|
19
|
+
grants;
|
|
20
|
+
configuration;
|
|
21
|
+
constructor(document, context){
|
|
22
|
+
this.document = document;
|
|
23
|
+
this.context = context;
|
|
24
|
+
this.index = indexDocument.indexDocument(document);
|
|
25
|
+
this.chain = resolveTemplateChain.resolveTemplateChain(document, context.scope);
|
|
26
|
+
this.grants = exposureGrants.computeExposureGrants(this.chain, context.catalog);
|
|
27
|
+
this.configuration = resolveEffectiveConfiguration.resolveEffectiveConfiguration(this.chain, document.instanceContributions, context.catalog);
|
|
28
|
+
}
|
|
29
|
+
/** The instance id the scope contributes as, or `undefined` when the scope was not found. */ get scopeInstance() {
|
|
30
|
+
return this.chain.levels.at(-1)?.instance;
|
|
31
|
+
}
|
|
32
|
+
/** What the scope's instance may configure on inherited components. */ get scopeGrants() {
|
|
33
|
+
return (this.scopeInstance === undefined ? undefined : this.grants.byInstance.get(this.scopeInstance)) ?? new Map();
|
|
34
|
+
}
|
|
35
|
+
/** Whether the scope itself owns the node. */ isLocal(record) {
|
|
36
|
+
return inspect.provenanceOf(record, this.chain, this.scopeGrants).kind === scene_model.ProvenanceKind.Local;
|
|
37
|
+
}
|
|
38
|
+
/** Where an inherited node comes from, for a message. */ sourceOf(record) {
|
|
39
|
+
return record.owner;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.EditSession = EditSession;
|
|
44
|
+
//# sourceMappingURL=EditSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditSession.js","sources":["../../../editing/EditSession.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 { ProvenanceKind, SceneDocument } from '@cratis/scene.model';\nimport { EditingContext } from './EditingContext';\nimport { DocumentIndex, NodeRecord } from './DocumentIndex';\nimport { ExposureGrant, ExposureGrants, computeExposureGrants } from './exposureGrants';\nimport { indexDocument } from './indexDocument';\nimport { provenanceOf } from './inspect';\nimport { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration';\nimport { resolveTemplateChain } from './resolveTemplateChain';\nimport { TemplateChain } from './TemplateChain';\nimport { EffectiveConfiguration } from '@cratis/scene.model';\n\n/**\n * Everything an edit needs to decide whether it is allowed, worked out once against the document as it was.\n */\nexport class EditSession {\n readonly index: DocumentIndex;\n readonly chain: TemplateChain;\n readonly grants: ExposureGrants;\n readonly configuration: EffectiveConfiguration;\n\n constructor(readonly document: SceneDocument, readonly context: EditingContext) {\n this.index = indexDocument(document);\n this.chain = resolveTemplateChain(document, context.scope);\n this.grants = computeExposureGrants(this.chain, context.catalog);\n this.configuration = resolveEffectiveConfiguration(this.chain, document.instanceContributions, context.catalog);\n }\n\n /** The instance id the scope contributes as, or `undefined` when the scope was not found. */\n get scopeInstance(): string | undefined {\n return this.chain.levels.at(-1)?.instance;\n }\n\n /** What the scope's instance may configure on inherited components. */\n get scopeGrants(): Map<string, ExposureGrant> {\n return (this.scopeInstance === undefined ? undefined : this.grants.byInstance.get(this.scopeInstance)) ?? new Map();\n }\n\n /** Whether the scope itself owns the node. */\n isLocal(record: NodeRecord): boolean {\n return provenanceOf(record, this.chain, this.scopeGrants).kind === ProvenanceKind.Local;\n }\n\n /** Where an inherited node comes from, for a message. */\n sourceOf(record: NodeRecord): string {\n return record.owner;\n }\n}\n"],"names":["EditSession","index","chain","grants","configuration","context","document","indexDocument","resolveTemplateChain","scope","computeExposureGrants","catalog","resolveEffectiveConfiguration","instanceContributions","scopeInstance","levels","at","instance","scopeGrants","undefined","byInstance","get","Map","isLocal","record","provenanceOf","kind","ProvenanceKind","Local","sourceOf","owner"],"mappings":";;;;;;;;;AAAA;AACA;AAaA;;AAEC,IACM,MAAMA,WAAAA,CAAAA;;;IACAC,KAAAA;IACAC,KAAAA;IACAC,MAAAA;IACAC,aAAAA;AAET,IAAA,WAAA,CAAY,QAAgC,EAAWC,OAAuB,CAAE;aAA3DC,QAAAA,GAAAA,QAAAA;aAAkCD,OAAAA,GAAAA,OAAAA;QACnD,IAAI,CAACJ,KAAK,GAAGM,2BAAAA,CAAcD,QAAAA,CAAAA;AAC3B,QAAA,IAAI,CAACJ,KAAK,GAAGM,yCAAAA,CAAqBF,QAAAA,EAAUD,QAAQI,KAAK,CAAA;QACzD,IAAI,CAACN,MAAM,GAAGO,oCAAAA,CAAsB,IAAI,CAACR,KAAK,EAAEG,OAAAA,CAAQM,OAAO,CAAA;AAC/D,QAAA,IAAI,CAACP,aAAa,GAAGQ,2DAAAA,CAA8B,IAAI,CAACV,KAAK,EAAEI,QAAAA,CAASO,qBAAqB,EAAER,OAAAA,CAAQM,OAAO,CAAA;AAClH,IAAA;kGAGA,IAAIG,aAAAA,GAAoC;QACpC,OAAO,IAAI,CAACZ,KAAK,CAACa,MAAM,CAACC,EAAE,CAAC,EAAC,CAAA,EAAIC,QAAAA;AACrC,IAAA;4EAGA,IAAIC,WAAAA,GAA0C;QAC1C,OAAQ,CAAA,IAAI,CAACJ,aAAa,KAAKK,SAAAA,GAAYA,YAAY,IAAI,CAAChB,MAAM,CAACiB,UAAU,CAACC,GAAG,CAAC,IAAI,CAACP,aAAa,CAAA,KAAM,IAAIQ,GAAAA,EAAAA;AAClH,IAAA;mDAGAC,OAAAA,CAAQC,MAAkB,EAAW;AACjC,QAAA,OAAOC,oBAAAA,CAAaD,MAAAA,EAAQ,IAAI,CAACtB,KAAK,EAAE,IAAI,CAACgB,WAAW,CAAA,CAAEQ,IAAI,KAAKC,2BAAeC,KAAK;AAC3F,IAAA;8DAGAC,QAAAA,CAASL,MAAkB,EAAU;AACjC,QAAA,OAAOA,OAAOM,KAAK;AACvB,IAAA;AACJ;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var diagnostics = require('./diagnostics.js');
|
|
5
|
+
var EditSession = require('./EditSession.js');
|
|
6
|
+
var exposureEdits = require('./exposureEdits.js');
|
|
7
|
+
var instanceEdits = require('./instanceEdits.js');
|
|
8
|
+
var layoutTypeEdits = require('./layoutTypeEdits.js');
|
|
9
|
+
var pathAccess = require('./pathAccess.js');
|
|
10
|
+
var propertyEdits = require('./propertyEdits.js');
|
|
11
|
+
var structureEdits = require('./structureEdits.js');
|
|
12
|
+
|
|
13
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
14
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
15
|
+
function run(session, edit, clone, diagnostics$1) {
|
|
16
|
+
const handle = (handler)=>handler(session, edit, clone, diagnostics$1);
|
|
17
|
+
switch(edit.kind){
|
|
18
|
+
case scene_model.SceneEditKind.SetProperty:
|
|
19
|
+
return handle(propertyEdits.applySetProperty);
|
|
20
|
+
case scene_model.SceneEditKind.ResetProperty:
|
|
21
|
+
return handle(propertyEdits.applyResetProperty);
|
|
22
|
+
case scene_model.SceneEditKind.ChangeLayoutType:
|
|
23
|
+
return handle(layoutTypeEdits.applyChangeLayoutType);
|
|
24
|
+
case scene_model.SceneEditKind.InsertNode:
|
|
25
|
+
return handle(structureEdits.applyInsertNode);
|
|
26
|
+
case scene_model.SceneEditKind.MoveNode:
|
|
27
|
+
return handle(structureEdits.applyMoveNode);
|
|
28
|
+
case scene_model.SceneEditKind.RemoveNode:
|
|
29
|
+
return handle(structureEdits.applyRemoveNode);
|
|
30
|
+
case scene_model.SceneEditKind.SetInstanceValue:
|
|
31
|
+
return handle(instanceEdits.applySetInstanceValue);
|
|
32
|
+
case scene_model.SceneEditKind.ResetInstanceValue:
|
|
33
|
+
return handle(instanceEdits.applyResetInstanceValue);
|
|
34
|
+
case scene_model.SceneEditKind.AddCollectionItem:
|
|
35
|
+
return handle(instanceEdits.applyAddCollectionItem);
|
|
36
|
+
case scene_model.SceneEditKind.RemoveCollectionItem:
|
|
37
|
+
return handle(instanceEdits.applyRemoveCollectionItem);
|
|
38
|
+
case scene_model.SceneEditKind.ReorderCollectionItem:
|
|
39
|
+
return handle(instanceEdits.applyReorderCollectionItem);
|
|
40
|
+
case scene_model.SceneEditKind.EditCollectionItem:
|
|
41
|
+
return handle(instanceEdits.applyEditCollectionItem);
|
|
42
|
+
case scene_model.SceneEditKind.ExposeProperty:
|
|
43
|
+
return handle(exposureEdits.applyExposeProperty);
|
|
44
|
+
case scene_model.SceneEditKind.UnexposeProperty:
|
|
45
|
+
return handle(exposureEdits.applyUnexposeProperty);
|
|
46
|
+
default:
|
|
47
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.InvalidEdit, `'${edit.kind}' is not an edit this engine knows.`));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Applies one edit to a document.
|
|
52
|
+
*
|
|
53
|
+
* Pure and immutable: the document passed in is never changed, and the result is a new document. Edits are plain
|
|
54
|
+
* data, so a host can persist them and build undo and redo by keeping the documents either side. On any error the
|
|
55
|
+
* prior document comes back - the same object - together with the diagnostics, so a refused edit leaves nothing
|
|
56
|
+
* half done.
|
|
57
|
+
*
|
|
58
|
+
* What an edit may touch follows the editing scope. Nodes the scope owns are edited directly; inherited nodes are
|
|
59
|
+
* read-only, and their exposed properties are configured with the instance edits, which are checked against what
|
|
60
|
+
* each owner exposed.
|
|
61
|
+
*
|
|
62
|
+
* @param model The document to edit.
|
|
63
|
+
* @param edit What to do.
|
|
64
|
+
* @param context The catalog and the editing scope.
|
|
65
|
+
*/ function applyEdit(model, edit, context) {
|
|
66
|
+
const session = new EditSession.EditSession(model, context);
|
|
67
|
+
const clone = pathAccess.cloneData(model);
|
|
68
|
+
const diagnostics$1 = [];
|
|
69
|
+
run(session, edit, clone, diagnostics$1);
|
|
70
|
+
if (diagnostics.hasErrors(diagnostics$1)) return {
|
|
71
|
+
model,
|
|
72
|
+
diagnostics: diagnostics$1,
|
|
73
|
+
applied: false
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
model: clone,
|
|
77
|
+
diagnostics: diagnostics$1,
|
|
78
|
+
applied: true
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.applyEdit = applyEdit;
|
|
83
|
+
//# sourceMappingURL=applyEdit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyEdit.js","sources":["../../../editing/applyEdit.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 { DiagnosticCode, SceneDiagnostic, SceneDocument, SceneEdit, SceneEditKind } from '@cratis/scene.model';\nimport { errorDiagnostic, hasErrors } from './diagnostics';\nimport { EditOutcome } from './EditOutcome';\nimport { EditingContext } from './EditingContext';\nimport { EditSession } from './EditSession';\nimport { applyExposeProperty, applyUnexposeProperty } from './exposureEdits';\nimport {\n applyAddCollectionItem, applyEditCollectionItem, applyRemoveCollectionItem, applyReorderCollectionItem,\n applyResetInstanceValue, applySetInstanceValue,\n} from './instanceEdits';\nimport { applyChangeLayoutType } from './layoutTypeEdits';\nimport { cloneData } from './pathAccess';\nimport { applyResetProperty, applySetProperty } from './propertyEdits';\nimport { applyInsertNode, applyMoveNode, applyRemoveNode } from './structureEdits';\n\ntype Handler<TEdit extends SceneEdit> = (session: EditSession, edit: TEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]) => void;\n\nfunction run(session: EditSession, edit: SceneEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]): void {\n const handle = <TEdit extends SceneEdit>(handler: Handler<TEdit>) => handler(session, edit as TEdit, clone, diagnostics);\n\n switch (edit.kind) {\n case SceneEditKind.SetProperty: return handle(applySetProperty);\n case SceneEditKind.ResetProperty: return handle(applyResetProperty);\n case SceneEditKind.ChangeLayoutType: return handle(applyChangeLayoutType);\n case SceneEditKind.InsertNode: return handle(applyInsertNode);\n case SceneEditKind.MoveNode: return handle(applyMoveNode);\n case SceneEditKind.RemoveNode: return handle(applyRemoveNode);\n case SceneEditKind.SetInstanceValue: return handle(applySetInstanceValue);\n case SceneEditKind.ResetInstanceValue: return handle(applyResetInstanceValue);\n case SceneEditKind.AddCollectionItem: return handle(applyAddCollectionItem);\n case SceneEditKind.RemoveCollectionItem: return handle(applyRemoveCollectionItem);\n case SceneEditKind.ReorderCollectionItem: return handle(applyReorderCollectionItem);\n case SceneEditKind.EditCollectionItem: return handle(applyEditCollectionItem);\n case SceneEditKind.ExposeProperty: return handle(applyExposeProperty);\n case SceneEditKind.UnexposeProperty: return handle(applyUnexposeProperty);\n default:\n diagnostics.push(errorDiagnostic(DiagnosticCode.InvalidEdit, `'${(edit as { kind?: string }).kind}' is not an edit this engine knows.`));\n }\n}\n\n/**\n * Applies one edit to a document.\n *\n * Pure and immutable: the document passed in is never changed, and the result is a new document. Edits are plain\n * data, so a host can persist them and build undo and redo by keeping the documents either side. On any error the\n * prior document comes back - the same object - together with the diagnostics, so a refused edit leaves nothing\n * half done.\n *\n * What an edit may touch follows the editing scope. Nodes the scope owns are edited directly; inherited nodes are\n * read-only, and their exposed properties are configured with the instance edits, which are checked against what\n * each owner exposed.\n *\n * @param model The document to edit.\n * @param edit What to do.\n * @param context The catalog and the editing scope.\n */\nexport function applyEdit(model: SceneDocument, edit: SceneEdit, context: EditingContext): EditOutcome {\n const session = new EditSession(model, context);\n const clone = cloneData(model);\n const diagnostics: SceneDiagnostic[] = [];\n\n run(session, edit, clone, diagnostics);\n\n if (hasErrors(diagnostics)) return { model, diagnostics, applied: false };\n return { model: clone, diagnostics, applied: true };\n}\n"],"names":["run","session","edit","clone","diagnostics","handle","handler","kind","SceneEditKind","SetProperty","applySetProperty","ResetProperty","applyResetProperty","ChangeLayoutType","applyChangeLayoutType","InsertNode","applyInsertNode","MoveNode","applyMoveNode","RemoveNode","applyRemoveNode","SetInstanceValue","applySetInstanceValue","ResetInstanceValue","applyResetInstanceValue","AddCollectionItem","applyAddCollectionItem","RemoveCollectionItem","applyRemoveCollectionItem","ReorderCollectionItem","applyReorderCollectionItem","EditCollectionItem","applyEditCollectionItem","ExposeProperty","applyExposeProperty","UnexposeProperty","applyUnexposeProperty","push","errorDiagnostic","DiagnosticCode","InvalidEdit","applyEdit","model","context","EditSession","cloneData","hasErrors","applied"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAmBA,SAASA,IAAIC,OAAoB,EAAEC,IAAe,EAAEC,KAAoB,EAAEC,aAA8B,EAAA;AACpG,IAAA,MAAMC,SAAS,CAA0BC,OAAAA,GAA4BA,OAAAA,CAAQL,OAAAA,EAASC,MAAeC,KAAAA,EAAOC,aAAAA,CAAAA;AAE5G,IAAA,OAAQF,KAAKK,IAAI;AACb,QAAA,KAAKC,0BAAcC,WAAW;AAAE,YAAA,OAAOJ,MAAAA,CAAOK,8BAAAA,CAAAA;AAC9C,QAAA,KAAKF,0BAAcG,aAAa;AAAE,YAAA,OAAON,MAAAA,CAAOO,gCAAAA,CAAAA;AAChD,QAAA,KAAKJ,0BAAcK,gBAAgB;AAAE,YAAA,OAAOR,MAAAA,CAAOS,qCAAAA,CAAAA;AACnD,QAAA,KAAKN,0BAAcO,UAAU;AAAE,YAAA,OAAOV,MAAAA,CAAOW,8BAAAA,CAAAA;AAC7C,QAAA,KAAKR,0BAAcS,QAAQ;AAAE,YAAA,OAAOZ,MAAAA,CAAOa,4BAAAA,CAAAA;AAC3C,QAAA,KAAKV,0BAAcW,UAAU;AAAE,YAAA,OAAOd,MAAAA,CAAOe,8BAAAA,CAAAA;AAC7C,QAAA,KAAKZ,0BAAca,gBAAgB;AAAE,YAAA,OAAOhB,MAAAA,CAAOiB,mCAAAA,CAAAA;AACnD,QAAA,KAAKd,0BAAce,kBAAkB;AAAE,YAAA,OAAOlB,MAAAA,CAAOmB,qCAAAA,CAAAA;AACrD,QAAA,KAAKhB,0BAAciB,iBAAiB;AAAE,YAAA,OAAOpB,MAAAA,CAAOqB,oCAAAA,CAAAA;AACpD,QAAA,KAAKlB,0BAAcmB,oBAAoB;AAAE,YAAA,OAAOtB,MAAAA,CAAOuB,uCAAAA,CAAAA;AACvD,QAAA,KAAKpB,0BAAcqB,qBAAqB;AAAE,YAAA,OAAOxB,MAAAA,CAAOyB,wCAAAA,CAAAA;AACxD,QAAA,KAAKtB,0BAAcuB,kBAAkB;AAAE,YAAA,OAAO1B,MAAAA,CAAO2B,qCAAAA,CAAAA;AACrD,QAAA,KAAKxB,0BAAcyB,cAAc;AAAE,YAAA,OAAO5B,MAAAA,CAAO6B,iCAAAA,CAAAA;AACjD,QAAA,KAAK1B,0BAAc2B,gBAAgB;AAAE,YAAA,OAAO9B,MAAAA,CAAO+B,mCAAAA,CAAAA;AACnD,QAAA;AACIhC,YAAAA,aAAAA,CAAYiC,IAAI,CAACC,2BAAAA,CAAgBC,0BAAAA,CAAeC,WAAW,EAAE,CAAC,CAAC,EAAE,IAACtC,CAA2BK,IAAI,CAAC,mCAAmC,CAAC,CAAA,CAAA;AAC9I;AACJ;AAEA;;;;;;;;;;;;;;;AAeC,IACM,SAASkC,SAAAA,CAAUC,KAAoB,EAAExC,IAAe,EAAEyC,OAAuB,EAAA;IACpF,MAAM1C,OAAAA,GAAU,IAAI2C,uBAAAA,CAAYF,KAAAA,EAAOC,OAAAA,CAAAA;AACvC,IAAA,MAAMxC,QAAQ0C,oBAAAA,CAAUH,KAAAA,CAAAA;AACxB,IAAA,MAAMtC,gBAAiC,EAAE;IAEzCJ,GAAAA,CAAIC,OAAAA,EAASC,MAAMC,KAAAA,EAAOC,aAAAA,CAAAA;IAE1B,IAAI0C,qBAAAA,CAAU1C,gBAAc,OAAO;AAAEsC,QAAAA,KAAAA;AAAOtC,qBAAAA,aAAAA;QAAa2C,OAAAA,EAAS;AAAM,KAAA;IACxE,OAAO;QAAEL,KAAAA,EAAOvC,KAAAA;AAAOC,qBAAAA,aAAAA;QAAa2C,OAAAA,EAAS;AAAK,KAAA;AACtD;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var elementKind = require('../elementKind.js');
|
|
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
|
+
* Returns the element tree a renderer should draw once effective configuration is applied: each configurable
|
|
9
|
+
* component carries its resolved properties.
|
|
10
|
+
*
|
|
11
|
+
* Pure, and structure-sharing - an element with nothing to change comes back as the same object, so a renderer
|
|
12
|
+
* that memoizes on identity does not redraw what did not change. There is no design-time flag here or anywhere
|
|
13
|
+
* downstream: a screen being edited and a screen being played go through this same function.
|
|
14
|
+
*
|
|
15
|
+
* @param element The element tree from the template or screen.
|
|
16
|
+
* @param configuration What {@link resolveEffectiveConfiguration} produced for the chain the tree sits in.
|
|
17
|
+
*/ function applyEffectiveConfiguration(element, configuration) {
|
|
18
|
+
if (elementKind.isExternalComponent(element)) {
|
|
19
|
+
const resolved = configuration.components.find((candidate)=>candidate.component === element.id);
|
|
20
|
+
let changed = resolved !== undefined;
|
|
21
|
+
const slots = {};
|
|
22
|
+
for (const [name, children] of Object.entries(element.slots)){
|
|
23
|
+
const mapped = children.map((child)=>applyEffectiveConfiguration(child, configuration));
|
|
24
|
+
if (mapped.some((child, index)=>child !== children[index])) changed = true;
|
|
25
|
+
slots[name] = mapped;
|
|
26
|
+
}
|
|
27
|
+
const updated = {
|
|
28
|
+
...element,
|
|
29
|
+
properties: resolved?.properties ?? element.properties,
|
|
30
|
+
slots
|
|
31
|
+
};
|
|
32
|
+
return changed ? updated : element;
|
|
33
|
+
}
|
|
34
|
+
if (elementKind.isContentControl(element)) {
|
|
35
|
+
const content = applyEffectiveConfiguration(element.content, configuration);
|
|
36
|
+
const updated = {
|
|
37
|
+
...element,
|
|
38
|
+
content
|
|
39
|
+
};
|
|
40
|
+
return content === element.content ? element : updated;
|
|
41
|
+
}
|
|
42
|
+
if (elementKind.isItemsControl(element)) {
|
|
43
|
+
const itemTemplate = applyEffectiveConfiguration(element.itemTemplate, configuration);
|
|
44
|
+
const updated = {
|
|
45
|
+
...element,
|
|
46
|
+
itemTemplate
|
|
47
|
+
};
|
|
48
|
+
return itemTemplate === element.itemTemplate ? element : updated;
|
|
49
|
+
}
|
|
50
|
+
if (elementKind.isPanel(element)) {
|
|
51
|
+
const children = element.children.map((child)=>applyEffectiveConfiguration(child, configuration));
|
|
52
|
+
const updated = {
|
|
53
|
+
...element,
|
|
54
|
+
children
|
|
55
|
+
};
|
|
56
|
+
return children.some((child, index)=>child !== element.children[index]) ? updated : element;
|
|
57
|
+
}
|
|
58
|
+
return element;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.applyEffectiveConfiguration = applyEffectiveConfiguration;
|
|
62
|
+
//# sourceMappingURL=applyEffectiveConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyEffectiveConfiguration.js","sources":["../../../editing/applyEffectiveConfiguration.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 { ContentControl, EffectiveConfiguration, ExternalComponent, ItemsControl, Panel, SceneElement } from '@cratis/scene.model';\nimport { isContentControl, isExternalComponent, isItemsControl, isPanel } from '../elementKind';\n\n/**\n * Returns the element tree a renderer should draw once effective configuration is applied: each configurable\n * component carries its resolved properties.\n *\n * Pure, and structure-sharing - an element with nothing to change comes back as the same object, so a renderer\n * that memoizes on identity does not redraw what did not change. There is no design-time flag here or anywhere\n * downstream: a screen being edited and a screen being played go through this same function.\n *\n * @param element The element tree from the template or screen.\n * @param configuration What {@link resolveEffectiveConfiguration} produced for the chain the tree sits in.\n */\nexport function applyEffectiveConfiguration(element: SceneElement, configuration: EffectiveConfiguration): SceneElement {\n if (isExternalComponent(element)) {\n const resolved = configuration.components.find(candidate => candidate.component === element.id);\n let changed = resolved !== undefined;\n\n const slots: typeof element.slots = {};\n for (const [name, children] of Object.entries(element.slots)) {\n const mapped = children.map(child => applyEffectiveConfiguration(child, configuration));\n if (mapped.some((child, index) => child !== children[index])) changed = true;\n slots[name] = mapped;\n }\n\n const updated: ExternalComponent = { ...element, properties: resolved?.properties ?? element.properties, slots };\n return changed ? updated : element;\n }\n\n if (isContentControl(element)) {\n const content = applyEffectiveConfiguration(element.content, configuration);\n const updated: ContentControl = { ...element, content };\n return content === element.content ? element : updated;\n }\n\n if (isItemsControl(element)) {\n const itemTemplate = applyEffectiveConfiguration(element.itemTemplate, configuration);\n const updated: ItemsControl = { ...element, itemTemplate };\n return itemTemplate === element.itemTemplate ? element : updated;\n }\n\n if (isPanel(element)) {\n const children = element.children.map(child => applyEffectiveConfiguration(child, configuration));\n const updated: Panel = { ...element, children };\n return children.some((child, index) => child !== element.children[index]) ? updated : element;\n }\n\n return element;\n}\n"],"names":["applyEffectiveConfiguration","element","configuration","isExternalComponent","resolved","components","find","candidate","component","id","changed","undefined","slots","name","children","Object","entries","mapped","map","child","some","index","updated","properties","isContentControl","content","isItemsControl","itemTemplate","isPanel"],"mappings":";;;;AAAA;AACA;AAKA;;;;;;;;;;AAUC,IACM,SAASA,2BAAAA,CAA4BC,OAAqB,EAAEC,aAAqC,EAAA;AACpG,IAAA,IAAIC,gCAAoBF,OAAAA,CAAAA,EAAU;AAC9B,QAAA,MAAMG,QAAAA,GAAWF,aAAAA,CAAcG,UAAU,CAACC,IAAI,CAACC,CAAAA,SAAAA,GAAaA,SAAAA,CAAUC,SAAS,KAAKP,OAAAA,CAAQQ,EAAE,CAAA;AAC9F,QAAA,IAAIC,UAAUN,QAAAA,KAAaO,SAAAA;AAE3B,QAAA,MAAMC,QAA8B,EAAC;QACrC,KAAK,MAAM,CAACC,IAAAA,EAAMC,QAAAA,CAAS,IAAIC,OAAOC,OAAO,CAACf,OAAAA,CAAQW,KAAK,CAAA,CAAG;AAC1D,YAAA,MAAMK,SAASH,QAAAA,CAASI,GAAG,CAACC,CAAAA,KAAAA,GAASnB,4BAA4BmB,KAAAA,EAAOjB,aAAAA,CAAAA,CAAAA;YACxE,IAAIe,MAAAA,CAAOG,IAAI,CAAC,CAACD,KAAAA,EAAOE,KAAAA,GAAUF,KAAAA,KAAUL,QAAQ,CAACO,KAAAA,CAAM,CAAA,EAAGX,OAAAA,GAAU,IAAA;YACxEE,KAAK,CAACC,KAAK,GAAGI,MAAAA;AAClB,QAAA;AAEA,QAAA,MAAMK,OAAAA,GAA6B;AAAE,YAAA,GAAGrB,OAAO;YAAEsB,UAAAA,EAAYnB,QAAAA,EAAUmB,UAAAA,IAActB,OAAAA,CAAQsB,UAAU;AAAEX,YAAAA;AAAM,SAAA;AAC/G,QAAA,OAAOF,UAAUY,OAAAA,GAAUrB,OAAAA;AAC/B,IAAA;AAEA,IAAA,IAAIuB,6BAAiBvB,OAAAA,CAAAA,EAAU;AAC3B,QAAA,MAAMwB,OAAAA,GAAUzB,2BAAAA,CAA4BC,OAAAA,CAAQwB,OAAO,EAAEvB,aAAAA,CAAAA;AAC7D,QAAA,MAAMoB,OAAAA,GAA0B;AAAE,YAAA,GAAGrB,OAAO;AAAEwB,YAAAA;AAAQ,SAAA;AACtD,QAAA,OAAOA,OAAAA,KAAYxB,OAAAA,CAAQwB,OAAO,GAAGxB,OAAAA,GAAUqB,OAAAA;AACnD,IAAA;AAEA,IAAA,IAAII,2BAAezB,OAAAA,CAAAA,EAAU;AACzB,QAAA,MAAM0B,YAAAA,GAAe3B,2BAAAA,CAA4BC,OAAAA,CAAQ0B,YAAY,EAAEzB,aAAAA,CAAAA;AACvE,QAAA,MAAMoB,OAAAA,GAAwB;AAAE,YAAA,GAAGrB,OAAO;AAAE0B,YAAAA;AAAa,SAAA;AACzD,QAAA,OAAOA,YAAAA,KAAiB1B,OAAAA,CAAQ0B,YAAY,GAAG1B,OAAAA,GAAUqB,OAAAA;AAC7D,IAAA;AAEA,IAAA,IAAIM,oBAAQ3B,OAAAA,CAAAA,EAAU;QAClB,MAAMa,QAAAA,GAAWb,QAAQa,QAAQ,CAACI,GAAG,CAACC,CAAAA,KAAAA,GAASnB,2BAAAA,CAA4BmB,KAAAA,EAAOjB,aAAAA,CAAAA,CAAAA;AAClF,QAAA,MAAMoB,OAAAA,GAAiB;AAAE,YAAA,GAAGrB,OAAO;AAAEa,YAAAA;AAAS,SAAA;AAC9C,QAAA,OAAOA,QAAAA,CAASM,IAAI,CAAC,CAACD,KAAAA,EAAOE,KAAAA,GAAUF,KAAAA,KAAUlB,OAAAA,CAAQa,QAAQ,CAACO,KAAAA,CAAM,CAAA,GAAIC,OAAAA,GAAUrB,OAAAA;AAC1F,IAAA;IAEA,OAAOA,OAAAA;AACX;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
function isExternalComponentValue(value) {
|
|
6
|
+
const candidate = value;
|
|
7
|
+
return typeof candidate.id === 'string' && typeof candidate.componentName === 'string' && candidate.properties !== null && typeof candidate.properties === 'object';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Finds every external component anywhere inside a layout, template, dialog template or screen, each once by id.
|
|
11
|
+
*
|
|
12
|
+
* It scans the value's structure rather than following a fixed list of properties, so a component is found
|
|
13
|
+
* wherever the model keeps it - slot content, a flow leaf, a freeform placement, a panel's children, another
|
|
14
|
+
* component's slot. A freeform arrangement repeats an element across its size-class variants; the first copy
|
|
15
|
+
* is the one returned.
|
|
16
|
+
*/ function collectComponents(owner) {
|
|
17
|
+
const found = new Map();
|
|
18
|
+
const visit = (value)=>{
|
|
19
|
+
if (value === null || typeof value !== 'object') return;
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
for (const item of value)visit(item);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (isExternalComponentValue(value) && !found.has(value.id)) found.set(value.id, value);
|
|
25
|
+
for (const child of Object.values(value))visit(child);
|
|
26
|
+
};
|
|
27
|
+
visit(owner);
|
|
28
|
+
return [
|
|
29
|
+
...found.values()
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.collectComponents = collectComponents;
|
|
34
|
+
//# sourceMappingURL=collectComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectComponents.js","sources":["../../../editing/collectComponents.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 { ExternalComponent } from '@cratis/scene.model';\n\nfunction isExternalComponentValue(value: object): value is ExternalComponent {\n const candidate = value as Partial<ExternalComponent>;\n return typeof candidate.id === 'string' && typeof candidate.componentName === 'string'\n && candidate.properties !== null && typeof candidate.properties === 'object';\n}\n\n/**\n * Finds every external component anywhere inside a layout, template, dialog template or screen, each once by id.\n *\n * It scans the value's structure rather than following a fixed list of properties, so a component is found\n * wherever the model keeps it - slot content, a flow leaf, a freeform placement, a panel's children, another\n * component's slot. A freeform arrangement repeats an element across its size-class variants; the first copy\n * is the one returned.\n */\nexport function collectComponents(owner: unknown): ExternalComponent[] {\n const found = new Map<string, ExternalComponent>();\n\n const visit = (value: unknown): void => {\n if (value === null || typeof value !== 'object') return;\n if (Array.isArray(value)) {\n for (const item of value) visit(item);\n return;\n }\n\n if (isExternalComponentValue(value) && !found.has(value.id)) found.set(value.id, value);\n for (const child of Object.values(value)) visit(child);\n };\n\n visit(owner);\n return [...found.values()];\n}\n"],"names":["isExternalComponentValue","value","candidate","id","componentName","properties","collectComponents","owner","found","Map","visit","Array","isArray","item","has","set","child","Object","values"],"mappings":";;AAAA;AACA;AAIA,SAASA,yBAAyBC,KAAa,EAAA;AAC3C,IAAA,MAAMC,SAAAA,GAAYD,KAAAA;AAClB,IAAA,OAAO,OAAOC,SAAAA,CAAUC,EAAE,KAAK,QAAA,IAAY,OAAOD,SAAAA,CAAUE,aAAa,KAAK,QAAA,IACvEF,UAAUG,UAAU,KAAK,QAAQ,OAAOH,SAAAA,CAAUG,UAAU,KAAK,QAAA;AAC5E;AAEA;;;;;;;IAQO,SAASC,iBAAAA,CAAkBC,KAAc,EAAA;AAC5C,IAAA,MAAMC,QAAQ,IAAIC,GAAAA,EAAAA;AAElB,IAAA,MAAMC,QAAQ,CAACT,KAAAA,GAAAA;AACX,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQ,OAAOA,KAAAA,KAAU,QAAA,EAAU;QACjD,IAAIU,KAAAA,CAAMC,OAAO,CAACX,KAAAA,CAAAA,EAAQ;YACtB,KAAK,MAAMY,IAAAA,IAAQZ,KAAAA,CAAOS,KAAAA,CAAMG,IAAAA,CAAAA;AAChC,YAAA;AACJ,QAAA;AAEA,QAAA,IAAIb,wBAAAA,CAAyBC,KAAAA,CAAAA,IAAU,CAACO,KAAAA,CAAMM,GAAG,CAACb,KAAAA,CAAME,EAAE,CAAA,EAAGK,KAAAA,CAAMO,GAAG,CAACd,KAAAA,CAAME,EAAE,EAAEF,KAAAA,CAAAA;AACjF,QAAA,KAAK,MAAMe,KAAAA,IAASC,MAAAA,CAAOC,MAAM,CAACjB,OAAQS,KAAAA,CAAMM,KAAAA,CAAAA;AACpD,IAAA,CAAA;IAEAN,KAAAA,CAAMH,KAAAA,CAAAA;IACN,OAAO;AAAIC,QAAAA,GAAAA,KAAAA,CAAMU,MAAM;AAAG,KAAA;AAC9B;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var DescriptorCatalog = require('./DescriptorCatalog.js');
|
|
5
|
+
var diagnostics = require('./diagnostics.js');
|
|
6
|
+
var pathAccess = require('./pathAccess.js');
|
|
7
|
+
var layoutTypeDescriptors = require('./layoutTypeDescriptors.js');
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
10
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
11
|
+
const layoutTypes = new Set(Object.values(scene_model.LayoutType));
|
|
12
|
+
/**
|
|
13
|
+
* Works out which descriptors apply to a node.
|
|
14
|
+
*
|
|
15
|
+
* A component takes its descriptor from the catalog by the name it carries; a layout node takes its layout type's;
|
|
16
|
+
* a placement and a template have their own fixed sets. A component nothing describes has no editable
|
|
17
|
+
* properties, and says so rather than failing.
|
|
18
|
+
*/ function describeNode(record, catalog) {
|
|
19
|
+
const diagnostics$1 = [];
|
|
20
|
+
if (record.kind === scene_model.SceneNodeKind.Placement) return {
|
|
21
|
+
properties: layoutTypeDescriptors.placementProperties,
|
|
22
|
+
diagnostics: diagnostics$1
|
|
23
|
+
};
|
|
24
|
+
if (record.kind === scene_model.SceneNodeKind.ScreenTemplate || record.kind === scene_model.SceneNodeKind.DialogTemplate) return {
|
|
25
|
+
properties: layoutTypeDescriptors.templateProperties,
|
|
26
|
+
diagnostics: diagnostics$1
|
|
27
|
+
};
|
|
28
|
+
if (layoutTypes.has(record.typeId)) {
|
|
29
|
+
const descriptor = DescriptorCatalog.findLayoutTypeDescriptor(catalog, record.typeId);
|
|
30
|
+
return {
|
|
31
|
+
properties: descriptor?.properties ?? [],
|
|
32
|
+
capabilities: descriptor?.capabilities,
|
|
33
|
+
diagnostics: diagnostics$1
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (record.kind === scene_model.SceneNodeKind.Element && record.value.componentName !== undefined) {
|
|
37
|
+
const descriptor = DescriptorCatalog.findComponentDescriptor(catalog, record.typeId);
|
|
38
|
+
if (!descriptor) {
|
|
39
|
+
diagnostics$1.push(diagnostics.warningDiagnostic(scene_model.DiagnosticCode.MissingComponentDescriptor, `Nothing describes the component '${record.typeId}', so none of its properties can be edited.`, {
|
|
40
|
+
nodeId: record.id
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
properties: descriptor?.properties ?? [],
|
|
45
|
+
diagnostics: diagnostics$1
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
properties: [],
|
|
50
|
+
diagnostics: diagnostics$1
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reads a descriptor's value from a node: from the property bag of a component, from the node itself otherwise.
|
|
55
|
+
*/ function readNodeValue(record, path) {
|
|
56
|
+
const value = record.value;
|
|
57
|
+
const isComponent = record.kind === scene_model.SceneNodeKind.Element && value.componentName !== undefined;
|
|
58
|
+
return pathAccess.getValueAtPath(isComponent ? value.properties : value, path);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.describeNode = describeNode;
|
|
62
|
+
exports.readNodeValue = readNodeValue;
|
|
63
|
+
//# sourceMappingURL=describeNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeNode.js","sources":["../../../editing/describeNode.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n DiagnosticCode, LayoutCapabilities, LayoutType, PropertyDescriptor, SceneDiagnostic, SceneNodeKind,\n} from '@cratis/scene.model';\nimport { DescriptorCatalog, findComponentDescriptor, findLayoutTypeDescriptor } from './DescriptorCatalog';\nimport { NodeRecord } from './DocumentIndex';\nimport { warningDiagnostic } from './diagnostics';\nimport { getValueAtPath } from './pathAccess';\nimport { placementProperties, templateProperties } from './layoutTypeDescriptors';\n\n/**\n * What describes a node: its editable properties, and for a layout node what the type can do.\n */\nexport interface NodeDescription {\n properties: PropertyDescriptor[];\n capabilities?: LayoutCapabilities;\n diagnostics: SceneDiagnostic[];\n}\n\nconst layoutTypes = new Set<string>(Object.values(LayoutType));\n\n/**\n * Works out which descriptors apply to a node.\n *\n * A component takes its descriptor from the catalog by the name it carries; a layout node takes its layout type's;\n * a placement and a template have their own fixed sets. A component nothing describes has no editable\n * properties, and says so rather than failing.\n */\nexport function describeNode(record: NodeRecord, catalog: DescriptorCatalog): NodeDescription {\n const diagnostics: SceneDiagnostic[] = [];\n\n if (record.kind === SceneNodeKind.Placement) return { properties: placementProperties, diagnostics };\n if (record.kind === SceneNodeKind.ScreenTemplate || record.kind === SceneNodeKind.DialogTemplate) return { properties: templateProperties, diagnostics };\n\n if (layoutTypes.has(record.typeId)) {\n const descriptor = findLayoutTypeDescriptor(catalog, record.typeId);\n return { properties: descriptor?.properties ?? [], capabilities: descriptor?.capabilities, diagnostics };\n }\n\n if (record.kind === SceneNodeKind.Element && (record.value as { componentName?: unknown }).componentName !== undefined) {\n const descriptor = findComponentDescriptor(catalog, record.typeId);\n if (!descriptor) {\n diagnostics.push(warningDiagnostic(DiagnosticCode.MissingComponentDescriptor, `Nothing describes the component '${record.typeId}', so none of its properties can be edited.`, { nodeId: record.id }));\n }\n\n return { properties: descriptor?.properties ?? [], diagnostics };\n }\n\n return { properties: [], diagnostics };\n}\n\n/**\n * Reads a descriptor's value from a node: from the property bag of a component, from the node itself otherwise.\n */\nexport function readNodeValue(record: NodeRecord, path: string): unknown {\n const value = record.value as Record<string, unknown>;\n const isComponent = record.kind === SceneNodeKind.Element && value.componentName !== undefined;\n return getValueAtPath(isComponent ? (value.properties as Record<string, unknown>) : value, path);\n}\n"],"names":["layoutTypes","Set","Object","values","LayoutType","describeNode","record","catalog","diagnostics","kind","SceneNodeKind","Placement","properties","placementProperties","ScreenTemplate","DialogTemplate","templateProperties","has","typeId","descriptor","findLayoutTypeDescriptor","capabilities","Element","value","componentName","undefined","findComponentDescriptor","push","warningDiagnostic","DiagnosticCode","MissingComponentDescriptor","nodeId","id","readNodeValue","path","isComponent","getValueAtPath"],"mappings":";;;;;;;;AAAA;AACA;AAoBA,MAAMA,WAAAA,GAAc,IAAIC,GAAAA,CAAYC,MAAAA,CAAOC,MAAM,CAACC,sBAAAA,CAAAA,CAAAA;AAElD;;;;;;AAMC,IACM,SAASC,YAAAA,CAAaC,MAAkB,EAAEC,OAA0B,EAAA;AACvE,IAAA,MAAMC,gBAAiC,EAAE;AAEzC,IAAA,IAAIF,OAAOG,IAAI,KAAKC,yBAAAA,CAAcC,SAAS,EAAE,OAAO;QAAEC,UAAAA,EAAYC,yCAAAA;AAAqBL,qBAAAA;AAAY,KAAA;AACnG,IAAA,IAAIF,MAAAA,CAAOG,IAAI,KAAKC,yBAAAA,CAAcI,cAAc,IAAIR,MAAAA,CAAOG,IAAI,KAAKC,yBAAAA,CAAcK,cAAc,EAAE,OAAO;QAAEH,UAAAA,EAAYI,wCAAAA;AAAoBR,qBAAAA;AAAY,KAAA;AAEvJ,IAAA,IAAIR,WAAAA,CAAYiB,GAAG,CAACX,MAAAA,CAAOY,MAAM,CAAA,EAAG;AAChC,QAAA,MAAMC,UAAAA,GAAaC,0CAAAA,CAAyBb,OAAAA,EAASD,MAAAA,CAAOY,MAAM,CAAA;QAClE,OAAO;YAAEN,UAAAA,EAAYO,UAAAA,EAAYP,cAAc,EAAE;AAAES,YAAAA,YAAAA,EAAcF,UAAAA,EAAYE,YAAAA;AAAcb,yBAAAA;AAAY,SAAA;AAC3G,IAAA;AAEA,IAAA,IAAIF,MAAAA,CAAOG,IAAI,KAAKC,yBAAAA,CAAcY,OAAO,IAAI,MAAChB,CAAOiB,KAAK,CAAiCC,aAAa,KAAKC,SAAAA,EAAW;AACpH,QAAA,MAAMN,UAAAA,GAAaO,yCAAAA,CAAwBnB,OAAAA,EAASD,MAAAA,CAAOY,MAAM,CAAA;AACjE,QAAA,IAAI,CAACC,UAAAA,EAAY;AACbX,YAAAA,aAAAA,CAAYmB,IAAI,CAACC,6BAAAA,CAAkBC,0BAAAA,CAAeC,0BAA0B,EAAE,CAAC,iCAAiC,EAAExB,MAAAA,CAAOY,MAAM,CAAC,2CAA2C,CAAC,EAAE;AAAEa,gBAAAA,MAAAA,EAAQzB,OAAO0B;AAAG,aAAA,CAAA,CAAA;AACtM,QAAA;QAEA,OAAO;YAAEpB,UAAAA,EAAYO,UAAAA,EAAYP,cAAc,EAAE;AAAEJ,yBAAAA;AAAY,SAAA;AACnE,IAAA;IAEA,OAAO;AAAEI,QAAAA,UAAAA,EAAY,EAAE;AAAEJ,qBAAAA;AAAY,KAAA;AACzC;AAEA;;AAEC,IACM,SAASyB,aAAAA,CAAc3B,MAAkB,EAAE4B,IAAY,EAAA;IAC1D,MAAMX,KAAAA,GAAQjB,OAAOiB,KAAK;IAC1B,MAAMY,WAAAA,GAAc7B,OAAOG,IAAI,KAAKC,0BAAcY,OAAO,IAAIC,KAAAA,CAAMC,aAAa,KAAKC,SAAAA;AACrF,IAAA,OAAOW,yBAAAA,CAAeD,WAAAA,GAAeZ,KAAAA,CAAMX,UAAU,GAA+BW,KAAAA,EAAOW,IAAAA,CAAAA;AAC/F;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
* Builds an error diagnostic: the edit or resolution step that produced it did not happen.
|
|
9
|
+
*/ function errorDiagnostic(code, message, context = {}) {
|
|
10
|
+
return {
|
|
11
|
+
code,
|
|
12
|
+
severity: scene_model.DiagnosticSeverity.Error,
|
|
13
|
+
message,
|
|
14
|
+
...context
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds a warning diagnostic: the work went ahead, and the author should know something about it.
|
|
19
|
+
*/ function warningDiagnostic(code, message, context = {}) {
|
|
20
|
+
return {
|
|
21
|
+
code,
|
|
22
|
+
severity: scene_model.DiagnosticSeverity.Warning,
|
|
23
|
+
message,
|
|
24
|
+
...context
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether any diagnostic is an error.
|
|
29
|
+
*/ function hasErrors(diagnostics) {
|
|
30
|
+
return diagnostics.some((diagnostic)=>diagnostic.severity === scene_model.DiagnosticSeverity.Error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.errorDiagnostic = errorDiagnostic;
|
|
34
|
+
exports.hasErrors = hasErrors;
|
|
35
|
+
exports.warningDiagnostic = warningDiagnostic;
|
|
36
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sources":["../../../editing/diagnostics.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 { DiagnosticCode, DiagnosticSeverity, SceneDiagnostic } from '@cratis/scene.model';\n\n/**\n * The context a diagnostic can carry besides its code and message.\n */\nexport type DiagnosticContext = Partial<Omit<SceneDiagnostic, 'code' | 'severity' | 'message'>>;\n\n/**\n * Builds an error diagnostic: the edit or resolution step that produced it did not happen.\n */\nexport function errorDiagnostic(code: DiagnosticCode, message: string, context: DiagnosticContext = {}): SceneDiagnostic {\n return { code, severity: DiagnosticSeverity.Error, message, ...context };\n}\n\n/**\n * Builds a warning diagnostic: the work went ahead, and the author should know something about it.\n */\nexport function warningDiagnostic(code: DiagnosticCode, message: string, context: DiagnosticContext = {}): SceneDiagnostic {\n return { code, severity: DiagnosticSeverity.Warning, message, ...context };\n}\n\n/**\n * Whether any diagnostic is an error.\n */\nexport function hasErrors(diagnostics: SceneDiagnostic[]): boolean {\n return diagnostics.some(diagnostic => diagnostic.severity === DiagnosticSeverity.Error);\n}\n"],"names":["errorDiagnostic","code","message","context","severity","DiagnosticSeverity","Error","warningDiagnostic","Warning","hasErrors","diagnostics","some","diagnostic"],"mappings":";;;;AAAA;AACA;AASA;;IAGO,SAASA,eAAAA,CAAgBC,IAAoB,EAAEC,OAAe,EAAEC,OAAAA,GAA6B,EAAE,EAAA;IAClG,OAAO;AAAEF,QAAAA,IAAAA;AAAMG,QAAAA,QAAAA,EAAUC,+BAAmBC,KAAK;AAAEJ,QAAAA,OAAAA;AAAS,QAAA,GAAGC;AAAQ,KAAA;AAC3E;AAEA;;IAGO,SAASI,iBAAAA,CAAkBN,IAAoB,EAAEC,OAAe,EAAEC,OAAAA,GAA6B,EAAE,EAAA;IACpG,OAAO;AAAEF,QAAAA,IAAAA;AAAMG,QAAAA,QAAAA,EAAUC,+BAAmBG,OAAO;AAAEN,QAAAA,OAAAA;AAAS,QAAA,GAAGC;AAAQ,KAAA;AAC7E;AAEA;;IAGO,SAASM,SAAAA,CAAUC,WAA8B,EAAA;IACpD,OAAOA,WAAAA,CAAYC,IAAI,CAACC,CAAAA,aAAcA,UAAAA,CAAWR,QAAQ,KAAKC,8BAAAA,CAAmBC,KAAK,CAAA;AAC1F;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
* Reads the value at a document path.
|
|
7
|
+
*/ function getAtPath(root, path) {
|
|
8
|
+
let current = root;
|
|
9
|
+
for (const key of path){
|
|
10
|
+
if (current === null || typeof current !== 'object') return undefined;
|
|
11
|
+
current = current[key];
|
|
12
|
+
}
|
|
13
|
+
return current;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads the array at a path, creating it - and any objects on the way - when it is not there yet. Mutates `root`,
|
|
17
|
+
* which callers hold a copy of.
|
|
18
|
+
*/ function ensureArrayAt(root, path) {
|
|
19
|
+
let current = root;
|
|
20
|
+
path.forEach((key, position)=>{
|
|
21
|
+
if (current[key] === undefined) current[key] = position === path.length - 1 ? [] : {};
|
|
22
|
+
current = current[key];
|
|
23
|
+
});
|
|
24
|
+
return current;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The paths a change to `path` must be made at: the path itself and, for a node inside a freeform element, the same
|
|
28
|
+
* place in every other size-class variant's copy.
|
|
29
|
+
*/ function mirroredPaths(mirror, path) {
|
|
30
|
+
if (!mirror || mirror.prefix.some((key, position)=>path[position] !== key)) return [
|
|
31
|
+
path
|
|
32
|
+
];
|
|
33
|
+
return [
|
|
34
|
+
path,
|
|
35
|
+
...mirror.others.map((other)=>[
|
|
36
|
+
...other,
|
|
37
|
+
...path.slice(mirror.prefix.length)
|
|
38
|
+
])
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.ensureArrayAt = ensureArrayAt;
|
|
43
|
+
exports.getAtPath = getAtPath;
|
|
44
|
+
exports.mirroredPaths = mirroredPaths;
|
|
45
|
+
//# sourceMappingURL=documentPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentPaths.js","sources":["../../../editing/documentPaths.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 { DocumentPath } from './DocumentIndex';\n\n/**\n * Reads the value at a document path.\n */\nexport function getAtPath(root: unknown, path: DocumentPath): unknown {\n let current = root;\n for (const key of path) {\n if (current === null || typeof current !== 'object') return undefined;\n current = (current as Record<string | number, unknown>)[key];\n }\n\n return current;\n}\n\n/**\n * Reads the array at a path, creating it - and any objects on the way - when it is not there yet. Mutates `root`,\n * which callers hold a copy of.\n */\nexport function ensureArrayAt(root: unknown, path: DocumentPath): unknown[] {\n let current = root as Record<string | number, unknown>;\n path.forEach((key, position) => {\n if (current[key] === undefined) current[key] = position === path.length - 1 ? [] : {};\n current = current[key] as Record<string | number, unknown>;\n });\n\n return current as unknown as unknown[];\n}\n\n/**\n * The paths a change to `path` must be made at: the path itself and, for a node inside a freeform element, the same\n * place in every other size-class variant's copy.\n */\nexport function mirroredPaths(mirror: { prefix: DocumentPath; others: DocumentPath[] } | undefined, path: DocumentPath): DocumentPath[] {\n if (!mirror || mirror.prefix.some((key, position) => path[position] !== key)) return [path];\n return [path, ...mirror.others.map(other => [...other, ...path.slice(mirror.prefix.length)])];\n}\n"],"names":["getAtPath","root","path","current","key","undefined","ensureArrayAt","forEach","position","length","mirroredPaths","mirror","prefix","some","others","map","other","slice"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,SAAAA,CAAUC,IAAa,EAAEC,IAAkB,EAAA;AACvD,IAAA,IAAIC,OAAAA,GAAUF,IAAAA;IACd,KAAK,MAAMG,OAAOF,IAAAA,CAAM;AACpB,QAAA,IAAIC,OAAAA,KAAY,IAAA,IAAQ,OAAOA,OAAAA,KAAY,UAAU,OAAOE,SAAAA;QAC5DF,OAAAA,GAAWA,OAA4C,CAACC,GAAAA,CAAI;AAChE,IAAA;IAEA,OAAOD,OAAAA;AACX;AAEA;;;AAGC,IACM,SAASG,aAAAA,CAAcL,IAAa,EAAEC,IAAkB,EAAA;AAC3D,IAAA,IAAIC,OAAAA,GAAUF,IAAAA;IACdC,IAAAA,CAAKK,OAAO,CAAC,CAACH,GAAAA,EAAKI,QAAAA,GAAAA;AACf,QAAA,IAAIL,OAAO,CAACC,GAAAA,CAAI,KAAKC,SAAAA,EAAWF,OAAO,CAACC,GAAAA,CAAI,GAAGI,QAAAA,KAAaN,KAAKO,MAAM,GAAG,CAAA,GAAI,EAAE,GAAG,EAAC;QACpFN,OAAAA,GAAUA,OAAO,CAACC,GAAAA,CAAI;AAC1B,IAAA,CAAA,CAAA;IAEA,OAAOD,OAAAA;AACX;AAEA;;;AAGC,IACM,SAASO,aAAAA,CAAcC,MAAoE,EAAET,IAAkB,EAAA;AAClH,IAAA,IAAI,CAACS,MAAAA,IAAUA,MAAAA,CAAOC,MAAM,CAACC,IAAI,CAAC,CAACT,GAAAA,EAAKI,WAAaN,IAAI,CAACM,QAAAA,CAAS,KAAKJ,MAAM,OAAO;AAACF,QAAAA;AAAK,KAAA;IAC3F,OAAO;AAACA,QAAAA,IAAAA;AAASS,QAAAA,GAAAA,MAAAA,CAAOG,MAAM,CAACC,GAAG,CAACC,CAAAA,KAAAA,GAAS;AAAIA,gBAAAA,GAAAA,KAAAA;AAAUd,gBAAAA,GAAAA,IAAAA,CAAKe,KAAK,CAACN,MAAAA,CAAOC,MAAM,CAACH,MAAM;AAAE,aAAA;AAAE,KAAA;AACjG;;;;"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var DescriptorCatalog = require('./DescriptorCatalog.js');
|
|
5
|
+
var diagnostics = require('./diagnostics.js');
|
|
6
|
+
var exposureGrants = require('./exposureGrants.js');
|
|
7
|
+
var pathAccess = require('./pathAccess.js');
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
10
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
11
|
+
function ownsDeclaration(session, owner, diagnostics$1) {
|
|
12
|
+
const level = session.chain.levels.at(-1);
|
|
13
|
+
if (!level || level.owner !== owner) {
|
|
14
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.NodeNotEditable, `Exposure is declared by the layout or template that owns the component. '${owner}' is not what is being edited.`));
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function validateExposure(session, property, diagnostics$1) {
|
|
20
|
+
const context = {
|
|
21
|
+
component: property.component,
|
|
22
|
+
path: property.path
|
|
23
|
+
};
|
|
24
|
+
const level = session.chain.levels.at(-1);
|
|
25
|
+
const reExposed = property.reExposes !== undefined;
|
|
26
|
+
if (!reExposed && !level.elements.some((candidate)=>candidate.id === property.component)) {
|
|
27
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.ExposureTargetMissing, `'${level.owner}' has no component '${property.component}'.`, context));
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const grant = reExposed ? session.scopeGrants.get(exposureGrants.grantKey(property.component, property.path)) : undefined;
|
|
31
|
+
if (reExposed && (!grant || grant.owner !== property.reExposes)) {
|
|
32
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.ReExposureBroken, `'${property.reExposes}' does not expose '${property.path}' on '${property.component}' to '${level.owner}', so it cannot be passed on.`, context));
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const element = level.elements.find((candidate)=>candidate.id === property.component);
|
|
36
|
+
const descriptor = grant ? grant.descriptor : DescriptorCatalog.findComponentDescriptor(session.context.catalog, element.componentName)?.properties.find((candidate)=>candidate.path === property.path);
|
|
37
|
+
if (!descriptor) {
|
|
38
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.ExposureTargetMissing, `There is no editable property '${property.path}' on '${property.component}'.`, context));
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const operations = property.operations ?? [];
|
|
42
|
+
if (descriptor.valueType !== scene_model.PropertyValueType.Collection) {
|
|
43
|
+
if (operations.length > 0 || property.editableFields !== undefined) {
|
|
44
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.InvalidEdit, `'${descriptor.label}' is not a collection, so operations and editable fields do not apply.`, context));
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const known = Object.values(scene_model.CollectionOperation);
|
|
50
|
+
const unknown = operations.find((operation)=>!known.includes(operation));
|
|
51
|
+
if (unknown !== undefined) {
|
|
52
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.InvalidEdit, `'${unknown}' is not a collection operation.`, context));
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const fields = descriptor.item?.properties.map((candidate)=>candidate.path) ?? [];
|
|
56
|
+
const unknownField = property.editableFields?.find((field)=>!fields.includes(field));
|
|
57
|
+
if (unknownField !== undefined) {
|
|
58
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.UnknownCollectionField, `Items of '${descriptor.label}' have no field '${unknownField}'.`, context));
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (grant && (operations.some((operation)=>!grant.operations.includes(operation)) || grant.editableFields !== undefined && (property.editableFields ?? fields).some((field)=>!grant.editableFields.includes(field)))) {
|
|
62
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.ExposureWidensOwner, `'${property.reExposes}' exposed less of '${descriptor.label}' than this re-exposes.`, context));
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Applies an exposure declaration to a copy of the document.
|
|
69
|
+
*
|
|
70
|
+
* Exposure only narrows: the property has to be one the component's descriptor supports, a collection's
|
|
71
|
+
* operations and fields have to exist, and a re-exposure cannot grant more than the owner it passes on.
|
|
72
|
+
*/ function applyExposeProperty(session, edit, clone, diagnostics) {
|
|
73
|
+
if (!ownsDeclaration(session, edit.owner, diagnostics) || !validateExposure(session, edit.property, diagnostics)) return;
|
|
74
|
+
let declaration = clone.exposures.find((candidate)=>candidate.owner === edit.owner);
|
|
75
|
+
if (!declaration) {
|
|
76
|
+
declaration = {
|
|
77
|
+
owner: edit.owner,
|
|
78
|
+
properties: []
|
|
79
|
+
};
|
|
80
|
+
clone.exposures.push(declaration);
|
|
81
|
+
}
|
|
82
|
+
const same = (candidate)=>candidate.component === edit.property.component && candidate.path === edit.property.path && candidate.reExposes === edit.property.reExposes;
|
|
83
|
+
const position = declaration.properties.findIndex(same);
|
|
84
|
+
if (position >= 0) declaration.properties[position] = pathAccess.cloneData(edit.property);
|
|
85
|
+
else declaration.properties.push(pathAccess.cloneData(edit.property));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Applies an exposure withdrawal to a copy of the document. Values already saved against it are not touched.
|
|
89
|
+
*/ function applyUnexposeProperty(session, edit, clone, diagnostics$1) {
|
|
90
|
+
if (!ownsDeclaration(session, edit.owner, diagnostics$1)) return;
|
|
91
|
+
const declaration = clone.exposures.find((candidate)=>candidate.owner === edit.owner);
|
|
92
|
+
const remaining = declaration?.properties.filter((candidate)=>!(candidate.component === edit.component && candidate.path === edit.path));
|
|
93
|
+
if (!declaration || remaining.length === declaration.properties.length) {
|
|
94
|
+
diagnostics$1.push(diagnostics.errorDiagnostic(scene_model.DiagnosticCode.ExposureTargetMissing, `'${edit.owner}' does not expose '${edit.path}' on '${edit.component}'.`, {
|
|
95
|
+
component: edit.component,
|
|
96
|
+
path: edit.path
|
|
97
|
+
}));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (remaining.length === 0) clone.exposures.splice(clone.exposures.indexOf(declaration), 1);
|
|
101
|
+
else declaration.properties = remaining;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.applyExposeProperty = applyExposeProperty;
|
|
105
|
+
exports.applyUnexposeProperty = applyUnexposeProperty;
|
|
106
|
+
//# sourceMappingURL=exposureEdits.js.map
|