@asyra/core 0.2.4 → 0.5.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/LICENSE +21 -0
- package/README.md +52 -0
- package/dist/apis/create-apis.d.ts +8 -0
- package/dist/apis/create-apis.d.ts.map +1 -0
- package/dist/apis/create-apis.js +272 -0
- package/dist/apis/create-apis.js.map +1 -0
- package/dist/apis/element-properties.d.ts +10 -0
- package/dist/apis/element-properties.d.ts.map +1 -0
- package/dist/apis/element-properties.js +33 -0
- package/dist/apis/element-properties.js.map +1 -0
- package/dist/apis/element-selection.d.ts +4 -2
- package/dist/apis/element-selection.d.ts.map +1 -1
- package/dist/apis/element-selection.js +155 -6
- package/dist/apis/element-selection.js.map +1 -1
- package/dist/apis/feature-system.d.ts +11 -0
- package/dist/apis/feature-system.d.ts.map +1 -0
- package/dist/apis/feature-system.js +9 -0
- package/dist/apis/feature-system.js.map +1 -0
- package/dist/apis/index.d.ts +1 -2
- package/dist/apis/index.d.ts.map +1 -1
- package/dist/apis/index.js +1 -24
- package/dist/apis/index.js.map +1 -1
- package/dist/apis/input-system.d.ts +1 -1
- package/dist/apis/input-system.d.ts.map +1 -1
- package/dist/apis/props.d.ts +18 -2
- package/dist/apis/props.d.ts.map +1 -1
- package/dist/apis/props.js +28 -9
- package/dist/apis/props.js.map +1 -1
- package/dist/apis/render.d.ts +39 -2
- package/dist/apis/render.d.ts.map +1 -1
- package/dist/apis/render.js +35 -2
- package/dist/apis/render.js.map +1 -1
- package/dist/apis/scene-bounds.d.ts +4 -0
- package/dist/apis/scene-bounds.d.ts.map +1 -0
- package/dist/apis/scene-bounds.js +112 -0
- package/dist/apis/scene-bounds.js.map +1 -0
- package/dist/apis/scene-tree.d.ts +24 -2
- package/dist/apis/scene-tree.d.ts.map +1 -1
- package/dist/apis/scene-tree.js +116 -25
- package/dist/apis/scene-tree.js.map +1 -1
- package/dist/apis/system-properties.d.ts +18 -0
- package/dist/apis/system-properties.d.ts.map +1 -0
- package/dist/apis/system-properties.js +21 -0
- package/dist/apis/system-properties.js.map +1 -0
- package/dist/apis/ui-context.d.ts +10 -0
- package/dist/apis/ui-context.d.ts.map +1 -0
- package/dist/apis/ui-context.js +22 -0
- package/dist/apis/ui-context.js.map +1 -0
- package/dist/canvas-pipeline-debugger/debugger.d.ts +29 -0
- package/dist/canvas-pipeline-debugger/debugger.d.ts.map +1 -0
- package/dist/canvas-pipeline-debugger/debugger.js +251 -0
- package/dist/canvas-pipeline-debugger/debugger.js.map +1 -0
- package/dist/canvas-pipeline-debugger/index.d.ts +2 -0
- package/dist/canvas-pipeline-debugger/index.d.ts.map +1 -0
- package/dist/canvas-pipeline-debugger/index.js +2 -0
- package/dist/canvas-pipeline-debugger/index.js.map +1 -0
- package/dist/core.d.ts +196 -40
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1055 -38
- package/dist/core.js.map +1 -1
- package/dist/data-channel-observer.d.ts +35 -0
- package/dist/data-channel-observer.d.ts.map +1 -0
- package/dist/data-channel-observer.js +77 -0
- package/dist/data-channel-observer.js.map +1 -0
- package/dist/define-component.d.ts +102 -0
- package/dist/define-component.d.ts.map +1 -0
- package/dist/define-component.js +429 -0
- package/dist/define-component.js.map +1 -0
- package/dist/define-property-component.d.ts +29 -0
- package/dist/define-property-component.d.ts.map +1 -0
- package/dist/define-property-component.js +140 -0
- package/dist/define-property-component.js.map +1 -0
- package/dist/feature-integration.d.ts +16 -0
- package/dist/feature-integration.d.ts.map +1 -0
- package/dist/feature-integration.js +19 -0
- package/dist/feature-integration.js.map +1 -0
- package/dist/index.d.ts +43 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/types/canonical-changes.d.ts +39 -0
- package/dist/types/canonical-changes.d.ts.map +1 -0
- package/dist/types/canonical-changes.js +2 -0
- package/dist/types/canonical-changes.js.map +1 -0
- package/dist/types/deps.d.ts +0 -2
- package/dist/types/deps.d.ts.map +1 -1
- package/dist/types/element-properties.d.ts +24 -0
- package/dist/types/element-properties.d.ts.map +1 -0
- package/dist/types/element-properties.js +2 -0
- package/dist/types/element-properties.js.map +1 -0
- package/dist/types/element-selection.d.ts +5 -1
- package/dist/types/element-selection.d.ts.map +1 -1
- package/dist/types/feature-system.d.ts +5 -0
- package/dist/types/feature-system.d.ts.map +1 -0
- package/dist/types/feature-system.js +2 -0
- package/dist/types/feature-system.js.map +1 -0
- package/dist/types/index.d.ts +18 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/load-migration.d.ts +12 -0
- package/dist/types/load-migration.d.ts.map +1 -0
- package/dist/types/load-migration.js +16 -0
- package/dist/types/load-migration.js.map +1 -0
- package/dist/types/load-validation.d.ts +12 -0
- package/dist/types/load-validation.d.ts.map +1 -0
- package/dist/types/load-validation.js +2 -0
- package/dist/types/load-validation.js.map +1 -0
- package/dist/types/props.d.ts +8 -1
- package/dist/types/props.d.ts.map +1 -1
- package/dist/types/render.d.ts +20 -1
- package/dist/types/render.d.ts.map +1 -1
- package/dist/types/scene-tree.d.ts +21 -9
- package/dist/types/scene-tree.d.ts.map +1 -1
- package/dist/types/system-properties.d.ts +19 -0
- package/dist/types/system-properties.d.ts.map +1 -0
- package/dist/types/system-properties.js +2 -0
- package/dist/types/system-properties.js.map +1 -0
- package/dist/types/ui-context.d.ts +11 -0
- package/dist/types/ui-context.d.ts.map +1 -0
- package/dist/types/ui-context.js +2 -0
- package/dist/types/ui-context.js.map +1 -0
- package/dist/types/vector.d.ts +131 -0
- package/dist/types/vector.d.ts.map +1 -0
- package/dist/types/vector.js +83 -0
- package/dist/types/vector.js.map +1 -0
- package/package.json +39 -12
- package/.turbo/turbo-test$colon$ci.log +0 -132
- package/.turbo/turbo-test$colon$local.log +0 -30
- package/.turbo/turbo-test.log +0 -0
- package/CHANGELOG.md +0 -69
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -991
- package/coverage/coverage-final.json +0 -14952
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -236
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/apis/element-selection.ts.html +0 -133
- package/coverage/src/apis/index.html +0 -266
- package/coverage/src/apis/index.ts.html +0 -175
- package/coverage/src/apis/input-system.ts.html +0 -121
- package/coverage/src/apis/interaction-core.ts.html +0 -190
- package/coverage/src/apis/props.ts.html +0 -124
- package/coverage/src/apis/render.ts.html +0 -130
- package/coverage/src/apis/scene-tree.ts.html +0 -292
- package/coverage/src/apis/system-context.ts.html +0 -154
- package/coverage/src/apis/transaction.ts.html +0 -124
- package/coverage/src/apis/undo.ts.html +0 -124
- package/coverage/src/apis/viewport.ts.html +0 -193
- package/coverage/src/combinations.ts.html +0 -223
- package/coverage/src/core.ts.html +0 -559
- package/coverage/src/index.html +0 -146
- package/coverage/src/index.ts.html +0 -97
- package/coverage/src/requests/factory.ts.html +0 -127
- package/coverage/src/requests/index.html +0 -206
- package/coverage/src/requests/index.ts.html +0 -154
- package/coverage/src/requests/props.ts.html +0 -133
- package/coverage/src/requests/render.ts.html +0 -187
- package/coverage/src/requests/scene-tree.ts.html +0 -163
- package/coverage/src/requests/selection.ts.html +0 -127
- package/coverage/src/requests/system-context.ts.html +0 -130
- package/coverage/src/subscribes/index.html +0 -116
- package/coverage/src/subscribes/index.ts.html +0 -109
- package/coverage/src/subscribes/input-system/index.html +0 -176
- package/coverage/src/subscribes/input-system/index.ts.html +0 -226
- package/coverage/src/subscribes/input-system/primary-tool.ts.html +0 -160
- package/coverage/src/subscribes/input-system/render.ts.html +0 -484
- package/coverage/src/subscribes/input-system/undo.ts.html +0 -172
- package/coverage/src/subscribes/input-system/viewport.ts.html +0 -259
- package/coverage/src/subscribes/interaction-core/create-element.ts.html +0 -151
- package/coverage/src/subscribes/interaction-core/index.html +0 -236
- package/coverage/src/subscribes/interaction-core/index.ts.html +0 -289
- package/coverage/src/subscribes/interaction-core/primary-tool.ts.html +0 -109
- package/coverage/src/subscribes/interaction-core/reset-element-size.ts.html +0 -127
- package/coverage/src/subscribes/interaction-core/resize-element.ts.html +0 -181
- package/coverage/src/subscribes/interaction-core/select-elements.ts.html +0 -109
- package/coverage/src/subscribes/interaction-core/transaction.ts.html +0 -130
- package/coverage/src/subscribes/interaction-core/undoredo.ts.html +0 -133
- package/coverage/src/subscribes/interaction-core/viewport.ts.html +0 -193
- package/coverage/src/types/deps.ts.html +0 -118
- package/coverage/src/types/element-selection.ts.html +0 -100
- package/coverage/src/types/index.html +0 -266
- package/coverage/src/types/index.ts.html +0 -385
- package/coverage/src/types/input-system.ts.html +0 -100
- package/coverage/src/types/interaction-core.ts.html +0 -127
- package/coverage/src/types/props.ts.html +0 -109
- package/coverage/src/types/render.ts.html +0 -106
- package/coverage/src/types/requests/factory.ts.html +0 -127
- package/coverage/src/types/requests/index.html +0 -206
- package/coverage/src/types/requests/index.ts.html +0 -214
- package/coverage/src/types/requests/props.ts.html +0 -133
- package/coverage/src/types/requests/render.ts.html +0 -139
- package/coverage/src/types/requests/scene-tree.ts.html +0 -133
- package/coverage/src/types/requests/selection.ts.html +0 -127
- package/coverage/src/types/requests/system-context.ts.html +0 -142
- package/coverage/src/types/scene-tree.ts.html +0 -178
- package/coverage/src/types/system-context/index.html +0 -161
- package/coverage/src/types/system-context/index.ts.html +0 -112
- package/coverage/src/types/system-context/key-state.ts.html +0 -106
- package/coverage/src/types/system-context/mouse-state.ts.html +0 -106
- package/coverage/src/types/system-context/primary-tool.ts.html +0 -112
- package/coverage/src/types/transaction.ts.html +0 -103
- package/coverage/src/types/undo.ts.html +0 -103
- package/coverage/src/types/viewport.ts.html +0 -127
- package/dist/__tests__/core.test.d.ts +0 -2
- package/dist/__tests__/core.test.d.ts.map +0 -1
- package/dist/__tests__/core.test.js +0 -122
- package/dist/__tests__/core.test.js.map +0 -1
- package/dist/apis/interaction-core.d.ts +0 -3
- package/dist/apis/interaction-core.d.ts.map +0 -1
- package/dist/apis/interaction-core.js +0 -22
- package/dist/apis/interaction-core.js.map +0 -1
- package/dist/apis/system-context.d.ts +0 -3
- package/dist/apis/system-context.d.ts.map +0 -1
- package/dist/apis/system-context.js +0 -16
- package/dist/apis/system-context.js.map +0 -1
- package/dist/apis/transaction.d.ts +0 -3
- package/dist/apis/transaction.d.ts.map +0 -1
- package/dist/apis/transaction.js +0 -12
- package/dist/apis/transaction.js.map +0 -1
- package/dist/apis/undo.d.ts +0 -3
- package/dist/apis/undo.d.ts.map +0 -1
- package/dist/apis/undo.js +0 -12
- package/dist/apis/undo.js.map +0 -1
- package/dist/apis/viewport.d.ts +0 -4
- package/dist/apis/viewport.d.ts.map +0 -1
- package/dist/apis/viewport.js +0 -27
- package/dist/apis/viewport.js.map +0 -1
- package/dist/combinations.d.ts +0 -4
- package/dist/combinations.d.ts.map +0 -1
- package/dist/combinations.js +0 -42
- package/dist/combinations.js.map +0 -1
- package/dist/requests/factory copy.d.ts +0 -7
- package/dist/requests/factory copy.d.ts.map +0 -1
- package/dist/requests/factory copy.js +0 -10
- package/dist/requests/factory copy.js.map +0 -1
- package/dist/requests/factory.d.ts +0 -7
- package/dist/requests/factory.d.ts.map +0 -1
- package/dist/requests/factory.js +0 -10
- package/dist/requests/factory.js.map +0 -1
- package/dist/requests/index.d.ts +0 -3
- package/dist/requests/index.d.ts.map +0 -1
- package/dist/requests/index.js +0 -21
- package/dist/requests/index.js.map +0 -1
- package/dist/requests/primary-tool.d.ts +0 -7
- package/dist/requests/primary-tool.d.ts.map +0 -1
- package/dist/requests/primary-tool.js +0 -13
- package/dist/requests/primary-tool.js.map +0 -1
- package/dist/requests/props copy.d.ts +0 -7
- package/dist/requests/props copy.d.ts.map +0 -1
- package/dist/requests/props copy.js +0 -13
- package/dist/requests/props copy.js.map +0 -1
- package/dist/requests/props.d.ts +0 -7
- package/dist/requests/props.d.ts.map +0 -1
- package/dist/requests/props.js +0 -13
- package/dist/requests/props.js.map +0 -1
- package/dist/requests/render.d.ts +0 -3
- package/dist/requests/render.d.ts.map +0 -1
- package/dist/requests/render.js +0 -22
- package/dist/requests/render.js.map +0 -1
- package/dist/requests/scene-tree.d.ts +0 -7
- package/dist/requests/scene-tree.d.ts.map +0 -1
- package/dist/requests/scene-tree.js +0 -17
- package/dist/requests/scene-tree.js.map +0 -1
- package/dist/requests/selection.d.ts +0 -7
- package/dist/requests/selection.d.ts.map +0 -1
- package/dist/requests/selection.js +0 -10
- package/dist/requests/selection.js.map +0 -1
- package/dist/requests/system-context copy.d.ts +0 -7
- package/dist/requests/system-context copy.d.ts.map +0 -1
- package/dist/requests/system-context copy.js +0 -19
- package/dist/requests/system-context copy.js.map +0 -1
- package/dist/requests/system-context.d.ts +0 -7
- package/dist/requests/system-context.d.ts.map +0 -1
- package/dist/requests/system-context.js +0 -10
- package/dist/requests/system-context.js.map +0 -1
- package/dist/requests/types.d.ts +0 -7
- package/dist/requests/types.d.ts.map +0 -1
- package/dist/requests/types.js +0 -4
- package/dist/requests/types.js.map +0 -1
- package/dist/requests/viewport.d.ts +0 -19
- package/dist/requests/viewport.d.ts.map +0 -1
- package/dist/requests/viewport.js +0 -6
- package/dist/requests/viewport.js.map +0 -1
- package/dist/subscribes/index.d.ts +0 -3
- package/dist/subscribes/index.d.ts.map +0 -1
- package/dist/subscribes/index.js +0 -7
- package/dist/subscribes/index.js.map +0 -1
- package/dist/subscribes/input-system/index.d.ts +0 -3
- package/dist/subscribes/input-system/index.d.ts.map +0 -1
- package/dist/subscribes/input-system/index.js +0 -26
- package/dist/subscribes/input-system/index.js.map +0 -1
- package/dist/subscribes/input-system/primary-tool.d.ts +0 -10
- package/dist/subscribes/input-system/primary-tool.d.ts.map +0 -1
- package/dist/subscribes/input-system/primary-tool.js +0 -15
- package/dist/subscribes/input-system/primary-tool.js.map +0 -1
- package/dist/subscribes/input-system/render.d.ts +0 -16
- package/dist/subscribes/input-system/render.d.ts.map +0 -1
- package/dist/subscribes/input-system/render.js +0 -97
- package/dist/subscribes/input-system/render.js.map +0 -1
- package/dist/subscribes/input-system/undo.d.ts +0 -10
- package/dist/subscribes/input-system/undo.d.ts.map +0 -1
- package/dist/subscribes/input-system/undo.js +0 -18
- package/dist/subscribes/input-system/undo.js.map +0 -1
- package/dist/subscribes/input-system/viewport.d.ts +0 -11
- package/dist/subscribes/input-system/viewport.d.ts.map +0 -1
- package/dist/subscribes/input-system/viewport.js +0 -36
- package/dist/subscribes/input-system/viewport.js.map +0 -1
- package/dist/subscribes/interaction-core/create-and-resize.d.ts +0 -5
- package/dist/subscribes/interaction-core/create-and-resize.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/create-and-resize.js +0 -86
- package/dist/subscribes/interaction-core/create-and-resize.js.map +0 -1
- package/dist/subscribes/interaction-core/create-element copy.d.ts +0 -3
- package/dist/subscribes/interaction-core/create-element copy.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/create-element copy.js +0 -17
- package/dist/subscribes/interaction-core/create-element copy.js.map +0 -1
- package/dist/subscribes/interaction-core/create-element.d.ts +0 -3
- package/dist/subscribes/interaction-core/create-element.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/create-element.js +0 -17
- package/dist/subscribes/interaction-core/create-element.js.map +0 -1
- package/dist/subscribes/interaction-core/index.d.ts +0 -3
- package/dist/subscribes/interaction-core/index.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/index.js +0 -42
- package/dist/subscribes/interaction-core/index.js.map +0 -1
- package/dist/subscribes/interaction-core/input-to-decision.d.ts +0 -5
- package/dist/subscribes/interaction-core/input-to-decision.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/input-to-decision.js +0 -48
- package/dist/subscribes/interaction-core/input-to-decision.js.map +0 -1
- package/dist/subscribes/interaction-core/primary-tool.d.ts +0 -3
- package/dist/subscribes/interaction-core/primary-tool.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/primary-tool.js +0 -7
- package/dist/subscribes/interaction-core/primary-tool.js.map +0 -1
- package/dist/subscribes/interaction-core/reset-element-size.d.ts +0 -5
- package/dist/subscribes/interaction-core/reset-element-size.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/reset-element-size.js +0 -9
- package/dist/subscribes/interaction-core/reset-element-size.js.map +0 -1
- package/dist/subscribes/interaction-core/resize-element.d.ts +0 -3
- package/dist/subscribes/interaction-core/resize-element.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/resize-element.js +0 -24
- package/dist/subscribes/interaction-core/resize-element.js.map +0 -1
- package/dist/subscribes/interaction-core/select-elements.d.ts +0 -3
- package/dist/subscribes/interaction-core/select-elements.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/select-elements.js +0 -7
- package/dist/subscribes/interaction-core/select-elements.js.map +0 -1
- package/dist/subscribes/interaction-core/transaction.d.ts +0 -3
- package/dist/subscribes/interaction-core/transaction.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/transaction.js +0 -10
- package/dist/subscribes/interaction-core/transaction.js.map +0 -1
- package/dist/subscribes/interaction-core/undoredo.d.ts +0 -3
- package/dist/subscribes/interaction-core/undoredo.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/undoredo.js +0 -15
- package/dist/subscribes/interaction-core/undoredo.js.map +0 -1
- package/dist/subscribes/interaction-core/viewport.d.ts +0 -3
- package/dist/subscribes/interaction-core/viewport.d.ts.map +0 -1
- package/dist/subscribes/interaction-core/viewport.js +0 -29
- package/dist/subscribes/interaction-core/viewport.js.map +0 -1
- package/dist/subscribes/render.d.ts +0 -6
- package/dist/subscribes/render.d.ts.map +0 -1
- package/dist/subscribes/render.js +0 -28
- package/dist/subscribes/render.js.map +0 -1
- package/dist/types/interaction-core.d.ts +0 -11
- package/dist/types/interaction-core.d.ts.map +0 -1
- package/dist/types/interaction-core.js +0 -2
- package/dist/types/interaction-core.js.map +0 -1
- package/dist/types/requests/factory copy.d.ts +0 -12
- package/dist/types/requests/factory copy.d.ts.map +0 -1
- package/dist/types/requests/factory copy.js +0 -2
- package/dist/types/requests/factory copy.js.map +0 -1
- package/dist/types/requests/factory.d.ts +0 -12
- package/dist/types/requests/factory.d.ts.map +0 -1
- package/dist/types/requests/factory.js +0 -2
- package/dist/types/requests/factory.js.map +0 -1
- package/dist/types/requests/index.d.ts +0 -17
- package/dist/types/requests/index.d.ts.map +0 -1
- package/dist/types/requests/index.js +0 -4
- package/dist/types/requests/index.js.map +0 -1
- package/dist/types/requests/primary-tool.d.ts +0 -13
- package/dist/types/requests/primary-tool.d.ts.map +0 -1
- package/dist/types/requests/primary-tool.js +0 -2
- package/dist/types/requests/primary-tool.js.map +0 -1
- package/dist/types/requests/props copy.d.ts +0 -14
- package/dist/types/requests/props copy.d.ts.map +0 -1
- package/dist/types/requests/props copy.js +0 -2
- package/dist/types/requests/props copy.js.map +0 -1
- package/dist/types/requests/props.d.ts +0 -14
- package/dist/types/requests/props.d.ts.map +0 -1
- package/dist/types/requests/props.js +0 -2
- package/dist/types/requests/props.js.map +0 -1
- package/dist/types/requests/render.d.ts +0 -15
- package/dist/types/requests/render.d.ts.map +0 -1
- package/dist/types/requests/render.js +0 -2
- package/dist/types/requests/render.js.map +0 -1
- package/dist/types/requests/scene-tree.d.ts +0 -14
- package/dist/types/requests/scene-tree.d.ts.map +0 -1
- package/dist/types/requests/scene-tree.js +0 -2
- package/dist/types/requests/scene-tree.js.map +0 -1
- package/dist/types/requests/selection.d.ts +0 -12
- package/dist/types/requests/selection.d.ts.map +0 -1
- package/dist/types/requests/selection.js +0 -2
- package/dist/types/requests/selection.js.map +0 -1
- package/dist/types/requests/system-context.d.ts +0 -17
- package/dist/types/requests/system-context.d.ts.map +0 -1
- package/dist/types/requests/system-context.js +0 -2
- package/dist/types/requests/system-context.js.map +0 -1
- package/dist/types/requests/system.d.ts +0 -13
- package/dist/types/requests/system.d.ts.map +0 -1
- package/dist/types/requests/system.js +0 -2
- package/dist/types/requests/system.js.map +0 -1
- package/dist/types/requests/viewport.d.ts +0 -20
- package/dist/types/requests/viewport.d.ts.map +0 -1
- package/dist/types/requests/viewport.js +0 -6
- package/dist/types/requests/viewport.js.map +0 -1
- package/dist/types/requests.d.ts +0 -8
- package/dist/types/requests.d.ts.map +0 -1
- package/dist/types/requests.js +0 -2
- package/dist/types/requests.js.map +0 -1
- package/dist/types/system-context/index.d.ts +0 -8
- package/dist/types/system-context/index.d.ts.map +0 -1
- package/dist/types/system-context/index.js +0 -4
- package/dist/types/system-context/index.js.map +0 -1
- package/dist/types/system-context/key-state.d.ts +0 -6
- package/dist/types/system-context/key-state.d.ts.map +0 -1
- package/dist/types/system-context/key-state.js +0 -2
- package/dist/types/system-context/key-state.js.map +0 -1
- package/dist/types/system-context/mouse-state.d.ts +0 -6
- package/dist/types/system-context/mouse-state.d.ts.map +0 -1
- package/dist/types/system-context/mouse-state.js +0 -2
- package/dist/types/system-context/mouse-state.js.map +0 -1
- package/dist/types/system-context/primary-tool.d.ts +0 -8
- package/dist/types/system-context/primary-tool.d.ts.map +0 -1
- package/dist/types/system-context/primary-tool.js +0 -2
- package/dist/types/system-context/primary-tool.js.map +0 -1
- package/dist/types/transaction.d.ts +0 -6
- package/dist/types/transaction.d.ts.map +0 -1
- package/dist/types/transaction.js +0 -2
- package/dist/types/transaction.js.map +0 -1
- package/dist/types/undo.d.ts +0 -6
- package/dist/types/undo.d.ts.map +0 -1
- package/dist/types/undo.js +0 -2
- package/dist/types/undo.js.map +0 -1
- package/dist/types/viewport.d.ts +0 -12
- package/dist/types/viewport.d.ts.map +0 -1
- package/dist/types/viewport.js +0 -2
- package/dist/types/viewport.js.map +0 -1
- package/src/__tests__/core.test.ts +0 -153
- package/src/apis/element-selection.ts +0 -16
- package/src/apis/index.ts +0 -30
- package/src/apis/input-system.ts +0 -12
- package/src/apis/interaction-core.ts +0 -35
- package/src/apis/props.ts +0 -13
- package/src/apis/render.ts +0 -15
- package/src/apis/scene-tree.ts +0 -69
- package/src/apis/system-context.ts +0 -23
- package/src/apis/transaction.ts +0 -13
- package/src/apis/undo.ts +0 -13
- package/src/apis/viewport.ts +0 -36
- package/src/combinations.ts +0 -46
- package/src/core.ts +0 -158
- package/src/index.ts +0 -4
- package/src/requests/factory.ts +0 -14
- package/src/requests/index.ts +0 -23
- package/src/requests/props.ts +0 -16
- package/src/requests/render.ts +0 -34
- package/src/requests/scene-tree.ts +0 -26
- package/src/requests/selection.ts +0 -14
- package/src/requests/system-context.ts +0 -15
- package/src/subscribes/index.ts +0 -8
- package/src/subscribes/input-system/index.ts +0 -47
- package/src/subscribes/input-system/primary-tool.ts +0 -25
- package/src/subscribes/input-system/render.ts +0 -133
- package/src/subscribes/input-system/undo.ts +0 -29
- package/src/subscribes/input-system/viewport.ts +0 -58
- package/src/subscribes/interaction-core/create-element.ts +0 -22
- package/src/subscribes/interaction-core/index.ts +0 -68
- package/src/subscribes/interaction-core/primary-tool.ts +0 -8
- package/src/subscribes/interaction-core/reset-element-size.ts +0 -12
- package/src/subscribes/interaction-core/resize-element.ts +0 -31
- package/src/subscribes/interaction-core/select-elements.ts +0 -8
- package/src/subscribes/interaction-core/transaction.ts +0 -15
- package/src/subscribes/interaction-core/undoredo.ts +0 -16
- package/src/subscribes/interaction-core/viewport.ts +0 -35
- package/src/types/deps.ts +0 -11
- package/src/types/element-selection.ts +0 -5
- package/src/types/index.ts +0 -100
- package/src/types/input-system.ts +0 -5
- package/src/types/interaction-core.ts +0 -14
- package/src/types/props.ts +0 -8
- package/src/types/render.ts +0 -7
- package/src/types/requests/factory.ts +0 -14
- package/src/types/requests/index.ts +0 -43
- package/src/types/requests/props.ts +0 -16
- package/src/types/requests/render.ts +0 -18
- package/src/types/requests/scene-tree.ts +0 -16
- package/src/types/requests/selection.ts +0 -14
- package/src/types/requests/system-context.ts +0 -19
- package/src/types/scene-tree.ts +0 -31
- package/src/types/system-context/index.ts +0 -9
- package/src/types/system-context/key-state.ts +0 -7
- package/src/types/system-context/mouse-state.ts +0 -7
- package/src/types/system-context/primary-tool.ts +0 -9
- package/src/types/transaction.ts +0 -6
- package/src/types/undo.ts +0 -6
- package/src/types/viewport.ts +0 -14
- package/test-setup.ts +0 -6
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -8
package/dist/core.js
CHANGED
|
@@ -1,76 +1,1093 @@
|
|
|
1
|
+
import { isRecord } from '@asyra/utils';
|
|
1
2
|
import factory from '@asyra/factory';
|
|
2
3
|
import inputSystem from '@asyra/input-system';
|
|
3
|
-
import sceneTree from '@asyra/scene-tree';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import sceneTree, { componentRegistry } from '@asyra/scene-tree';
|
|
5
|
+
import props, { commitDeclarativePropertyTypeDefinition, getDeclarativePropertyTypeDefinition, getPropertyComponent, getPropertySchema, registerPropertySchema, registerPropertyComponent, unregisterPropertyRegistration, PropertyTypeDefinitionError } from '@asyra/props-manager';
|
|
6
|
+
import { defineFeature as defineFeatureRuntime, getFeature as getFeatureRuntime, unregisterFeature as unregisterFeatureRuntime, getFeatureRegistry } from '@asyra/feature-system';
|
|
6
7
|
import selection from '@asyra/selection';
|
|
7
8
|
import systemContext from '@asyra/system-context';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
9
|
+
import render, { RenderAdapter, MissingRenderEngineProviderError, renderStrategyRegistry } from '@asyra/render';
|
|
10
|
+
import { propertyRegistry } from '@asyra/ui-context';
|
|
11
|
+
import { eventRegistry, fileLoadComplete } from '@asyra/reactive-events';
|
|
12
|
+
import { createAPIs } from './apis/index.js';
|
|
13
|
+
import { LOAD_HOOK_EXECUTION_ERROR_CODES, LoadHookExecutionError } from './types/load-migration.js';
|
|
14
|
+
import * as dataChannelObserver from './data-channel-observer.js';
|
|
15
|
+
import { definePropertyComponent as definePropertyComponentRuntime, definePropertyChildRelation as definePropertyChildRelationRuntime, getPropertyChildRelations as getPropertyChildRelationsRuntime, removePropertyChildRelation as removePropertyChildRelationRuntime } from './define-property-component.js';
|
|
16
|
+
import { defineComponent as defineComponentRuntime, defineComponentPropertyRelationForSceneTree as defineComponentPropertyRelationRuntime, getComponentPropertyRelations as getComponentPropertyRelationsRuntime, removeComponentPropertyRelationForSceneTree as removeComponentPropertyRelationRuntime, unregisterComponent as unregisterComponentRuntime, unregisterComponentGraphRegistration } from './define-component.js';
|
|
17
|
+
import { RegistrationGraph, RegistrationRelationError } from '@asyra/utils';
|
|
14
18
|
const DEFAULT_VERSION = '1.0.0';
|
|
15
19
|
const DATA_VERSION = '1.0.0';
|
|
20
|
+
const INLINE_COMPONENT_RENDER_RELATION = 'component-owner';
|
|
21
|
+
let didWarnAboutSetPersistence = false;
|
|
22
|
+
const EMPTY_SCENE_TREE_DATA = {
|
|
23
|
+
workspace: '',
|
|
24
|
+
workspaceList: [],
|
|
25
|
+
elements: {}
|
|
26
|
+
};
|
|
27
|
+
const cloneSerializationSnapshot = (data) => {
|
|
28
|
+
if (typeof globalThis.structuredClone === 'function') {
|
|
29
|
+
return globalThis.structuredClone(data);
|
|
30
|
+
}
|
|
31
|
+
return JSON.parse(JSON.stringify(data));
|
|
32
|
+
};
|
|
33
|
+
const cloneLoadObservation = (value) => {
|
|
34
|
+
if (typeof globalThis.structuredClone === 'function') {
|
|
35
|
+
return globalThis.structuredClone(value);
|
|
36
|
+
}
|
|
37
|
+
return JSON.parse(JSON.stringify(value));
|
|
38
|
+
};
|
|
16
39
|
class Core {
|
|
17
40
|
constructor(deps) {
|
|
18
41
|
this.deps = deps;
|
|
19
42
|
this.version = DEFAULT_VERSION;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
this.renderEngineProviderToken = null;
|
|
44
|
+
this.loadSource = null;
|
|
45
|
+
this.saveHooks = [];
|
|
46
|
+
this.loadHooks = [];
|
|
47
|
+
this.loadDiagnosticsHooks = [];
|
|
48
|
+
this.compositionOpen = true;
|
|
49
|
+
this.propertyTypeRedefinitionInProgress = false;
|
|
50
|
+
this.redefinedPropertyTypes = new Set();
|
|
51
|
+
this.registrationGraph = new RegistrationGraph({
|
|
52
|
+
isCompositionOpen: () => this.compositionOpen
|
|
27
53
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, apis);
|
|
54
|
+
this.defaultRenderer = new RenderAdapter(deps.render);
|
|
55
|
+
this.renderer = this.defaultRenderer;
|
|
56
|
+
this.dataChannelObservers =
|
|
57
|
+
deps.dataChannelObservers ??
|
|
58
|
+
new dataChannelObserver.DataChannelObserverRegistry(deps.factory);
|
|
59
|
+
const apis = createAPIs(deps.sceneTree, deps.render, deps.selection, deps.props, deps.factory);
|
|
35
60
|
Object.assign(this, apis);
|
|
61
|
+
const setSystemProperty = this.setSystemProperty;
|
|
62
|
+
this.setSystemProperty = ((key, value) => {
|
|
63
|
+
setSystemProperty(key, value);
|
|
64
|
+
deps.render.requestRender();
|
|
65
|
+
});
|
|
66
|
+
const unregisterSystemProperty = this.unregisterSystemProperty;
|
|
67
|
+
this.unregisterSystemProperty = ((key) => {
|
|
68
|
+
this.assertCompositionOpen('unregister-registration');
|
|
69
|
+
return unregisterSystemProperty(key);
|
|
70
|
+
});
|
|
71
|
+
const defineUIProperty = this.defineUIProperty;
|
|
72
|
+
const registerUIProperty = this.registerUIProperty;
|
|
73
|
+
this.defineUIProperty = ((key, config) => {
|
|
74
|
+
this.assertCompositionOpen('register-node');
|
|
75
|
+
const source = { kind: 'ui-property', key };
|
|
76
|
+
if (this.registrationGraph.getRegistration(source) ||
|
|
77
|
+
propertyRegistry.getAllPropertyKeys().includes(key)) {
|
|
78
|
+
this.registrationConflict(source, `[PropertyRegistry] Property "${key}" is already registered`);
|
|
79
|
+
}
|
|
80
|
+
this.preflightRegistrationDefinition(source, config.registration);
|
|
81
|
+
defineUIProperty(key, config);
|
|
82
|
+
this.ensureUIPropertyNode(key, config.registration);
|
|
83
|
+
this.defineRegistrationRelations(source, config.registration);
|
|
84
|
+
});
|
|
85
|
+
this.registerUIProperty = ((key, config) => {
|
|
86
|
+
this.assertCompositionOpen('register-node');
|
|
87
|
+
const source = { kind: 'ui-property', key };
|
|
88
|
+
if (this.registrationGraph.getRegistration(source) ||
|
|
89
|
+
propertyRegistry.getAllPropertyKeys().includes(key)) {
|
|
90
|
+
this.registrationConflict(source, `[PropertyRegistry] Property "${key}" is already registered`);
|
|
91
|
+
}
|
|
92
|
+
this.preflightRegistrationDefinition(source, config.registration);
|
|
93
|
+
registerUIProperty(key, config);
|
|
94
|
+
this.ensureUIPropertyNode(key, config.registration);
|
|
95
|
+
this.defineRegistrationRelations(source, config.registration);
|
|
96
|
+
});
|
|
36
97
|
}
|
|
37
|
-
|
|
38
|
-
|
|
98
|
+
/** Set an advanced full renderer replacement before startup. */
|
|
99
|
+
setRenderer(renderer) {
|
|
100
|
+
this.assertCompositionOpen('register-node');
|
|
101
|
+
this.renderer = renderer;
|
|
102
|
+
}
|
|
103
|
+
destroyRenderer() {
|
|
104
|
+
this.renderer.destroy();
|
|
105
|
+
}
|
|
106
|
+
setRenderEngineProvider(provider) {
|
|
107
|
+
this.assertCompositionOpen('register-node');
|
|
108
|
+
if (this.renderEngineProviderToken) {
|
|
109
|
+
throw new Error('Core render engine provider is already configured');
|
|
110
|
+
}
|
|
111
|
+
const renderCleanup = this.deps.render.setEngineProvider(provider);
|
|
112
|
+
const token = Symbol('core-render-engine-provider');
|
|
113
|
+
this.renderEngineProviderToken = token;
|
|
114
|
+
return () => {
|
|
115
|
+
if (this.renderEngineProviderToken !== token) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.assertCompositionOpen('unregister-registration');
|
|
119
|
+
renderCleanup();
|
|
120
|
+
this.renderEngineProviderToken = null;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
hasRenderEngineProvider() {
|
|
124
|
+
return this.renderEngineProviderToken !== null;
|
|
125
|
+
}
|
|
126
|
+
isCompositionOpen() {
|
|
127
|
+
return this.compositionOpen;
|
|
128
|
+
}
|
|
129
|
+
registerDataChannelObserver(registration) {
|
|
130
|
+
this.dataChannelObservers.register(registration);
|
|
131
|
+
}
|
|
132
|
+
unregisterDataChannelObserver(name) {
|
|
133
|
+
return this.dataChannelObservers.unregister(name);
|
|
134
|
+
}
|
|
135
|
+
registerSharedDataChannel(name, channel) {
|
|
136
|
+
this.deps.factory.registerSharedDataChannel(name, channel);
|
|
137
|
+
}
|
|
138
|
+
unregisterSharedDataChannel(name) {
|
|
139
|
+
return this.deps.factory.unregisterSharedDataChannel(name);
|
|
140
|
+
}
|
|
141
|
+
hasSharedDataChannel(name) {
|
|
142
|
+
return this.deps.factory.hasSharedDataChannel(name);
|
|
143
|
+
}
|
|
144
|
+
createLocalSharedDataChannel() {
|
|
145
|
+
return this.deps.factory.createLocalSharedDataChannel();
|
|
146
|
+
}
|
|
147
|
+
/** Set the read-only source used during Core startup. */
|
|
148
|
+
setLoadSource(source) {
|
|
149
|
+
this.loadSource = source;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated Use setLoadSource. Core does not call provider save or clear.
|
|
153
|
+
* This compatibility adapter remains available through the 0.2.x migration
|
|
154
|
+
* window and is planned for removal in the next major release.
|
|
155
|
+
*/
|
|
156
|
+
setPersistence(provider) {
|
|
157
|
+
if (!didWarnAboutSetPersistence) {
|
|
158
|
+
console.warn('Core.setPersistence is deprecated. Use Core.setLoadSource; Core never saves or clears through this compatibility surface.');
|
|
159
|
+
didWarnAboutSetPersistence = true;
|
|
160
|
+
}
|
|
161
|
+
this.setLoadSource(provider);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Register a hook to transform data before saving
|
|
165
|
+
* @param hook - Function that receives and returns CoreData
|
|
166
|
+
*/
|
|
167
|
+
registerSaveHook(hook) {
|
|
168
|
+
this.saveHooks.push(hook);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Register an app-owned hook in the synchronous load-migration chain.
|
|
172
|
+
* @param hook - Function that receives raw input and returns a versioned document
|
|
173
|
+
*/
|
|
174
|
+
registerLoadHook(hook) {
|
|
175
|
+
this.loadHooks.push(hook);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Register a hook to receive non-blocking load diagnostics.
|
|
179
|
+
* Hooks are called after load validation/apply finishes.
|
|
180
|
+
*/
|
|
181
|
+
registerLoadDiagnosticsHook(hook) {
|
|
182
|
+
this.loadDiagnosticsHooks.push(hook);
|
|
183
|
+
return () => {
|
|
184
|
+
const hookIndex = this.loadDiagnosticsHooks.indexOf(hook);
|
|
185
|
+
if (hookIndex === -1) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
this.loadDiagnosticsHooks.splice(hookIndex, 1);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Start the framework with a custom renderer
|
|
193
|
+
* @param container - DOM element to attach canvas to
|
|
194
|
+
* @param renderOptions - Options for renderer initialization
|
|
195
|
+
*/
|
|
196
|
+
async start(container, renderOptions) {
|
|
197
|
+
if (this.propertyTypeRedefinitionInProgress) {
|
|
198
|
+
throw new RegistrationRelationError({
|
|
199
|
+
ok: false,
|
|
200
|
+
code: 'UNREGISTER_FAILED',
|
|
201
|
+
operation: 'transfer-owner',
|
|
202
|
+
message: 'Core cannot start while a property type redefinition is in progress'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
this.compositionOpen = false;
|
|
206
|
+
this.registrationGraph.validateRelations();
|
|
207
|
+
this.validateRedefinedPropertyRelations();
|
|
208
|
+
const renderer = this.renderer;
|
|
209
|
+
// Phase 1: Initialize renderer
|
|
210
|
+
let result;
|
|
211
|
+
try {
|
|
212
|
+
result = await renderer.init(container, renderOptions);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (renderer !== this.defaultRenderer ||
|
|
216
|
+
!(error instanceof MissingRenderEngineProviderError) ||
|
|
217
|
+
this.hasRenderEngineProvider()) {
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
result = { canvas: null, instance: null };
|
|
221
|
+
}
|
|
222
|
+
if (result.canvas && container) {
|
|
223
|
+
container.appendChild(result.canvas);
|
|
224
|
+
// Setup input system to watch the canvas
|
|
225
|
+
this.setupInputSystem(result.canvas);
|
|
226
|
+
}
|
|
227
|
+
this.dataChannelObservers.init();
|
|
228
|
+
// Phase 2: Load canonical data from the configured read-only source.
|
|
229
|
+
await this.loadFromSource();
|
|
230
|
+
// Phase 3: Initialize features
|
|
231
|
+
this.initFeatureSystem({
|
|
232
|
+
inputSystem: this.deps.inputSystem,
|
|
233
|
+
systemContext: this.deps.systemContext
|
|
234
|
+
});
|
|
235
|
+
// Phase 4: Notify ready
|
|
236
|
+
this.renderIsReady();
|
|
237
|
+
}
|
|
238
|
+
async loadFromSource() {
|
|
239
|
+
if (!this.loadSource) {
|
|
39
240
|
return;
|
|
40
241
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
242
|
+
const data = await this.loadSource.load();
|
|
243
|
+
this.load(data);
|
|
244
|
+
}
|
|
245
|
+
registerEvent(event) {
|
|
246
|
+
return eventRegistry.register(event);
|
|
247
|
+
}
|
|
248
|
+
unregisterEvent(event) {
|
|
249
|
+
return eventRegistry.unregister(event);
|
|
250
|
+
}
|
|
251
|
+
subscribeEvent(event, handler) {
|
|
252
|
+
const eventName = typeof event === 'string' ? event : event.eventName;
|
|
253
|
+
const registration = eventRegistry.get(event);
|
|
254
|
+
if (!registration) {
|
|
255
|
+
throw new Error(`[Core] Event "${eventName}" is not registered. Register it before subscribing.`);
|
|
256
|
+
}
|
|
257
|
+
const subscription = registration.subscribe(handler);
|
|
258
|
+
return () => subscription.unsubscribe();
|
|
259
|
+
}
|
|
260
|
+
registerPropertySchema(schema, options, registration) {
|
|
261
|
+
this.assertCompositionOpen('register-node');
|
|
262
|
+
const source = { kind: 'property', key: schema.type };
|
|
263
|
+
if (getPropertySchema(schema.type) ||
|
|
264
|
+
this.registrationGraph.hasPendingCleanup(source)) {
|
|
265
|
+
this.registrationConflict(source, `Property schema "${schema.type}" is already registered`);
|
|
266
|
+
}
|
|
267
|
+
this.preflightRegistrationDefinition(source, registration);
|
|
268
|
+
registerPropertySchema(schema, options);
|
|
269
|
+
this.ensurePropertyNode(schema.type, registration);
|
|
270
|
+
this.defineRegistrationRelations(source, registration);
|
|
271
|
+
}
|
|
272
|
+
getPropertySchema(type) {
|
|
273
|
+
return getPropertySchema(type);
|
|
274
|
+
}
|
|
275
|
+
definePropertyComponent(definition) {
|
|
276
|
+
this.assertCompositionOpen('register-node');
|
|
277
|
+
const source = { kind: 'property', key: definition.type };
|
|
278
|
+
if (getPropertyComponent(definition.type) ||
|
|
279
|
+
this.registrationGraph.hasPendingCleanup(source)) {
|
|
280
|
+
this.registrationConflict(source, `Property component "${definition.type}" is already registered`);
|
|
44
281
|
}
|
|
45
|
-
|
|
46
|
-
|
|
282
|
+
this.preflightRegistrationDefinition(source, definition.registration, 'children' in definition && definition.children
|
|
283
|
+
? [definition.children.key]
|
|
284
|
+
: []);
|
|
285
|
+
if ('children' in definition &&
|
|
286
|
+
definition.children &&
|
|
287
|
+
!getPropertyComponent(definition.children.childType)) {
|
|
288
|
+
throw new RegistrationRelationError({
|
|
289
|
+
ok: false,
|
|
290
|
+
code: 'RELATION_TARGET_NOT_FOUND',
|
|
291
|
+
operation: 'define-relation',
|
|
292
|
+
message: `Child property runtime "${definition.children.childType}" is not registered`,
|
|
293
|
+
source: { kind: 'property', key: definition.type },
|
|
294
|
+
relationName: definition.children.key,
|
|
295
|
+
target: { kind: 'property', key: definition.children.childType }
|
|
296
|
+
});
|
|
47
297
|
}
|
|
48
|
-
|
|
49
|
-
this.
|
|
298
|
+
if ('children' in definition && definition.children) {
|
|
299
|
+
this.assertRelationEndpointNotPending({ kind: 'property', key: definition.children.childType }, 'define-relation', source, definition.children.key, { kind: 'property', key: definition.children.childType });
|
|
50
300
|
}
|
|
51
|
-
|
|
301
|
+
const Constructor = definePropertyComponentRuntime(definition);
|
|
302
|
+
this.ensurePropertyNode(definition.type, definition.registration);
|
|
303
|
+
if ('children' in definition && definition.children) {
|
|
304
|
+
this.ensurePropertyNode(definition.children.childType);
|
|
305
|
+
this.registrationGraph.defineRelation({ kind: 'property', key: definition.type }, {
|
|
306
|
+
name: definition.children.key,
|
|
307
|
+
target: { kind: 'property', key: definition.children.childType },
|
|
308
|
+
onTargetUnregister: 'detach'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
this.defineRegistrationRelations(source, definition.registration);
|
|
312
|
+
return Constructor;
|
|
313
|
+
}
|
|
314
|
+
registerPropertyComponent(type, component, options) {
|
|
315
|
+
this.assertCompositionOpen('register-node');
|
|
316
|
+
const source = { kind: 'property', key: type };
|
|
317
|
+
if (getPropertyComponent(type) ||
|
|
318
|
+
this.registrationGraph.hasPendingCleanup(source)) {
|
|
319
|
+
this.registrationConflict(source, `Property component "${type}" is already registered`);
|
|
320
|
+
}
|
|
321
|
+
registerPropertyComponent(type, component, options);
|
|
322
|
+
this.ensurePropertyNode(type);
|
|
323
|
+
}
|
|
324
|
+
getPropertyComponent(type) {
|
|
325
|
+
return getPropertyComponent(type);
|
|
326
|
+
}
|
|
327
|
+
getPropertyTypeDefinition(type) {
|
|
328
|
+
this.assertCompositionOpen('transfer-owner', true);
|
|
329
|
+
return getDeclarativePropertyTypeDefinition(type);
|
|
330
|
+
}
|
|
331
|
+
redefinePropertyType(type, update) {
|
|
332
|
+
const target = { kind: 'property', key: type };
|
|
333
|
+
this.assertPropertyTypeRedefinitionTarget(target);
|
|
334
|
+
this.propertyTypeRedefinitionInProgress = true;
|
|
335
|
+
try {
|
|
336
|
+
const current = getDeclarativePropertyTypeDefinition(type);
|
|
337
|
+
if (!current) {
|
|
338
|
+
throw new PropertyTypeDefinitionError({
|
|
339
|
+
ok: false,
|
|
340
|
+
code: 'PROPERTY_TYPE_DEFINITION_DRIFT',
|
|
341
|
+
type,
|
|
342
|
+
message: `Property type "${type}" has no declarative definition`
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const next = update(current);
|
|
346
|
+
this.assertPropertyTypeRedefinitionTarget(target, true);
|
|
347
|
+
const committed = commitDeclarativePropertyTypeDefinition(type, next, this.deps.props);
|
|
348
|
+
this.registrationGraph.transferRegistrationOwner(target, {
|
|
349
|
+
packageName: 'app',
|
|
350
|
+
name: type
|
|
351
|
+
});
|
|
352
|
+
this.redefinedPropertyTypes.add(type);
|
|
353
|
+
return committed;
|
|
354
|
+
}
|
|
355
|
+
finally {
|
|
356
|
+
this.propertyTypeRedefinitionInProgress = false;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
unregisterPropertyRegistration(type, scope = 'all') {
|
|
360
|
+
this.assertCompositionOpen('unregister-registration');
|
|
361
|
+
return unregisterPropertyRegistration(type, this.deps.props, scope);
|
|
362
|
+
}
|
|
363
|
+
definePropertyChildRelation(parentPropertyType, relation) {
|
|
364
|
+
this.assertRelationCanBeDefined({ kind: 'property', key: parentPropertyType }, relation.key, { kind: 'property', key: relation.childType });
|
|
365
|
+
const result = definePropertyChildRelationRuntime(parentPropertyType, relation, this.deps.props);
|
|
366
|
+
this.registrationGraph.defineRelation({ kind: 'property', key: parentPropertyType }, {
|
|
367
|
+
name: relation.key,
|
|
368
|
+
target: { kind: 'property', key: relation.childType },
|
|
369
|
+
onTargetUnregister: 'detach'
|
|
370
|
+
});
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
removePropertyChildRelation(parentPropertyType, key) {
|
|
374
|
+
this.assertRelationCanBeRemoved({ kind: 'property', key: parentPropertyType }, key);
|
|
375
|
+
const result = removePropertyChildRelationRuntime(parentPropertyType, key, this.deps.props);
|
|
376
|
+
this.registrationGraph.removeRelation({ kind: 'property', key: parentPropertyType }, key);
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
getPropertyChildRelations(parentPropertyType) {
|
|
380
|
+
return getPropertyChildRelationsRuntime(parentPropertyType);
|
|
381
|
+
}
|
|
382
|
+
unregisterPropertyType(type) {
|
|
383
|
+
this.assertCompositionOpen('unregister-registration');
|
|
384
|
+
const result = this.registrationGraph.unregister({
|
|
385
|
+
kind: 'property',
|
|
386
|
+
key: type
|
|
387
|
+
});
|
|
388
|
+
this.redefinedPropertyTypes.delete(type);
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
defineComponent(definition) {
|
|
392
|
+
this.assertCompositionOpen('register-node');
|
|
393
|
+
const componentRef = { kind: 'component', key: definition.type };
|
|
394
|
+
if (this.registrationGraph.getRegistration(componentRef) ||
|
|
395
|
+
componentRegistry.has(definition.type)) {
|
|
396
|
+
this.registrationConflict(componentRef, `Component "${definition.type}" is already registered`);
|
|
397
|
+
}
|
|
398
|
+
const inlineRenderRef = {
|
|
399
|
+
kind: 'render-strategy',
|
|
400
|
+
key: definition.type
|
|
401
|
+
};
|
|
402
|
+
if (definition.renderStrategy &&
|
|
403
|
+
(this.registrationGraph.getRegistration(inlineRenderRef) ||
|
|
404
|
+
renderStrategyRegistry.has(definition.type))) {
|
|
405
|
+
this.registrationConflict(inlineRenderRef, `Render strategy for "${definition.type}" is already registered`);
|
|
406
|
+
}
|
|
407
|
+
const propertyNames = new Set();
|
|
408
|
+
for (const property of definition.properties) {
|
|
409
|
+
if (propertyNames.has(property.name)) {
|
|
410
|
+
throw new RegistrationRelationError({
|
|
411
|
+
ok: false,
|
|
412
|
+
code: 'DUPLICATE_RELATION',
|
|
413
|
+
operation: 'define-relation',
|
|
414
|
+
message: `Component property relation "${definition.type}/${property.name}" is duplicated`,
|
|
415
|
+
source: { kind: 'component', key: definition.type },
|
|
416
|
+
relationName: property.name
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
propertyNames.add(property.name);
|
|
420
|
+
if (!getPropertyComponent(property.type)) {
|
|
421
|
+
throw new RegistrationRelationError({
|
|
422
|
+
ok: false,
|
|
423
|
+
code: 'RELATION_TARGET_NOT_FOUND',
|
|
424
|
+
operation: 'define-relation',
|
|
425
|
+
message: `Property runtime "${property.type}" is not registered`,
|
|
426
|
+
source: { kind: 'component', key: definition.type },
|
|
427
|
+
relationName: property.name,
|
|
428
|
+
target: { kind: 'property', key: property.type }
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
this.assertRelationEndpointNotPending({ kind: 'property', key: property.type }, 'define-relation', componentRef, property.name, { kind: 'property', key: property.type });
|
|
432
|
+
}
|
|
433
|
+
const source = componentRef;
|
|
434
|
+
this.preflightRegistrationDefinition(source, definition.registration, [
|
|
435
|
+
...propertyNames
|
|
436
|
+
]);
|
|
437
|
+
defineComponentRuntime(definition);
|
|
438
|
+
this.ensureComponentNode(definition.type, definition.registration);
|
|
439
|
+
if (definition.renderStrategy) {
|
|
440
|
+
this.ensureRenderStrategyNode(definition.type, definition.registration?.owner
|
|
441
|
+
? { owner: definition.registration.owner }
|
|
442
|
+
: undefined);
|
|
443
|
+
this.registrationGraph.defineRelation(inlineRenderRef, {
|
|
444
|
+
name: INLINE_COMPONENT_RENDER_RELATION,
|
|
445
|
+
target: componentRef,
|
|
446
|
+
onTargetUnregister: 'unregister-source'
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
definition.properties.forEach((property) => {
|
|
450
|
+
this.ensurePropertyNode(property.type);
|
|
451
|
+
this.registrationGraph.defineRelation({ kind: 'component', key: definition.type }, {
|
|
452
|
+
name: property.name,
|
|
453
|
+
target: { kind: 'property', key: property.type },
|
|
454
|
+
onTargetUnregister: 'detach'
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
this.defineRegistrationRelations(source, definition.registration);
|
|
458
|
+
}
|
|
459
|
+
unregisterComponent(type, options = {}) {
|
|
460
|
+
this.assertCompositionOpen('unregister-registration');
|
|
461
|
+
if (!this.registrationGraph.getRegistration({ kind: 'component', key: type })) {
|
|
462
|
+
return unregisterComponentRuntime(type, options);
|
|
463
|
+
}
|
|
464
|
+
this.registrationGraph.unregister({ kind: 'component', key: type });
|
|
465
|
+
if (options.detailed) {
|
|
466
|
+
return { ok: true, removed: [`component:${type}`], skipped: [] };
|
|
467
|
+
}
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
defineComponentPropertyRelation(componentType, property) {
|
|
471
|
+
this.assertRelationCanBeDefined({ kind: 'component', key: componentType }, property.name, { kind: 'property', key: property.type });
|
|
472
|
+
const result = defineComponentPropertyRelationRuntime(componentType, property, this.deps.sceneTree);
|
|
473
|
+
this.registrationGraph.defineRelation({ kind: 'component', key: componentType }, {
|
|
474
|
+
name: property.name,
|
|
475
|
+
target: { kind: 'property', key: property.type },
|
|
476
|
+
onTargetUnregister: 'detach'
|
|
477
|
+
});
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
removeComponentPropertyRelation(componentType, propertyName) {
|
|
481
|
+
this.assertRelationCanBeRemoved({ kind: 'component', key: componentType }, propertyName);
|
|
482
|
+
const result = removeComponentPropertyRelationRuntime(componentType, propertyName, this.deps.sceneTree);
|
|
483
|
+
this.registrationGraph.removeRelation({ kind: 'component', key: componentType }, propertyName);
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
getComponentPropertyRelations(componentType) {
|
|
487
|
+
return getComponentPropertyRelationsRuntime(componentType);
|
|
488
|
+
}
|
|
489
|
+
defineFeature(name, keyConfig, definition) {
|
|
490
|
+
this.assertCompositionOpen('register-node');
|
|
491
|
+
const source = { kind: 'feature', key: name };
|
|
492
|
+
if (this.registrationGraph.getRegistration(source) ||
|
|
493
|
+
getFeatureRegistry().has(name)) {
|
|
494
|
+
this.registrationConflict(source, `Feature "${name}" is already registered`);
|
|
495
|
+
}
|
|
496
|
+
this.preflightRegistrationDefinition(source, definition.registration);
|
|
497
|
+
const registration = defineFeatureRuntime(name, keyConfig, definition);
|
|
498
|
+
this.ensureFeatureNode(name, definition.registration);
|
|
499
|
+
this.defineRegistrationRelations(source, definition.registration);
|
|
500
|
+
return {
|
|
501
|
+
api: registration.api,
|
|
502
|
+
dispose: () => this.unregisterFeature(name)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
getFeature(featureName) {
|
|
506
|
+
return getFeatureRuntime(featureName);
|
|
507
|
+
}
|
|
508
|
+
unregisterFeature(featureName) {
|
|
509
|
+
this.assertCompositionOpen('unregister-registration');
|
|
510
|
+
if (this.registrationGraph.getRegistration({
|
|
511
|
+
kind: 'feature',
|
|
512
|
+
key: featureName
|
|
513
|
+
})) {
|
|
514
|
+
this.registrationGraph.unregister({ kind: 'feature', key: featureName });
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
return unregisterFeatureRuntime(featureName);
|
|
518
|
+
}
|
|
519
|
+
registerRenderStrategy(type, strategy, registration) {
|
|
520
|
+
this.assertCompositionOpen('register-node');
|
|
521
|
+
const source = { kind: 'render-strategy', key: type };
|
|
522
|
+
if (this.registrationGraph.getRegistration(source) ||
|
|
523
|
+
renderStrategyRegistry.has(type)) {
|
|
524
|
+
this.registrationConflict(source, `Render strategy for "${type}" is already registered`);
|
|
525
|
+
}
|
|
526
|
+
this.preflightRegistrationDefinition(source, registration);
|
|
527
|
+
renderStrategyRegistry.register(type, strategy);
|
|
528
|
+
this.ensureRenderStrategyNode(type, registration);
|
|
529
|
+
this.defineRegistrationRelations(source, registration);
|
|
530
|
+
}
|
|
531
|
+
unregisterRenderStrategy(type) {
|
|
532
|
+
this.assertCompositionOpen('unregister-registration');
|
|
533
|
+
if (this.registrationGraph.getRegistration({
|
|
534
|
+
kind: 'render-strategy',
|
|
535
|
+
key: type
|
|
536
|
+
})) {
|
|
537
|
+
this.registrationGraph.unregister({ kind: 'render-strategy', key: type });
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
return renderStrategyRegistry.unregister(type);
|
|
541
|
+
}
|
|
542
|
+
unregisterUIProperty(key) {
|
|
543
|
+
this.assertCompositionOpen('unregister-registration');
|
|
544
|
+
const exists = propertyRegistry.getAllPropertyKeys().includes(key);
|
|
545
|
+
if (this.registrationGraph.getRegistration({ kind: 'ui-property', key })) {
|
|
546
|
+
this.registrationGraph.unregister({ kind: 'ui-property', key });
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
propertyRegistry.unregister(key);
|
|
550
|
+
return exists;
|
|
551
|
+
}
|
|
552
|
+
getRegistration(ref) {
|
|
553
|
+
return this.registrationGraph.getRegistration(ref);
|
|
554
|
+
}
|
|
555
|
+
getRegistrations() {
|
|
556
|
+
return this.registrationGraph.getRegistrations();
|
|
557
|
+
}
|
|
558
|
+
getRegistrationRelations() {
|
|
559
|
+
return this.registrationGraph.getRelations();
|
|
560
|
+
}
|
|
561
|
+
defineSelection(type, selection) {
|
|
562
|
+
this.deps.selection.register(type, selection);
|
|
563
|
+
}
|
|
564
|
+
registerSelection(type, selection) {
|
|
565
|
+
this.defineSelection(type, selection);
|
|
566
|
+
}
|
|
567
|
+
unregisterSelection(type) {
|
|
568
|
+
return this.deps.selection.unregister(type);
|
|
569
|
+
}
|
|
570
|
+
getSelection(type) {
|
|
571
|
+
return this.deps.selection.get(type);
|
|
572
|
+
}
|
|
573
|
+
getPresetDependencies() {
|
|
574
|
+
return {
|
|
575
|
+
sceneTree: this.deps.sceneTree,
|
|
576
|
+
systemContext: this.deps.systemContext,
|
|
577
|
+
render: this.deps.render
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
assertCompositionOpen(operation, allowDuringPropertyRedefinition = false) {
|
|
581
|
+
if (this.compositionOpen &&
|
|
582
|
+
(allowDuringPropertyRedefinition ||
|
|
583
|
+
!this.propertyTypeRedefinitionInProgress)) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
throw new RegistrationRelationError({
|
|
587
|
+
ok: false,
|
|
588
|
+
code: this.compositionOpen ? 'UNREGISTER_FAILED' : 'COMPOSITION_CLOSED',
|
|
589
|
+
operation,
|
|
590
|
+
message: this.compositionOpen
|
|
591
|
+
? 'Registration mutation is blocked while a property type redefinition is in progress'
|
|
592
|
+
: 'Registration composition is permanently closed'
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
assertPropertyTypeRedefinitionTarget(target, allowInProgress = false) {
|
|
596
|
+
this.assertCompositionOpen('transfer-owner', allowInProgress);
|
|
597
|
+
if (!this.registrationGraph.getRegistration(target)) {
|
|
598
|
+
throw new RegistrationRelationError({
|
|
599
|
+
ok: false,
|
|
600
|
+
code: 'REGISTRATION_NOT_FOUND',
|
|
601
|
+
operation: 'transfer-owner',
|
|
602
|
+
message: `Registration "${target.kind}:${target.key}" was not found`,
|
|
603
|
+
registration: target
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
if (this.registrationGraph.hasPendingCleanup(target)) {
|
|
607
|
+
throw new RegistrationRelationError({
|
|
608
|
+
ok: false,
|
|
609
|
+
code: 'UNREGISTER_FAILED',
|
|
610
|
+
operation: 'transfer-owner',
|
|
611
|
+
message: `Registration "${target.kind}:${target.key}" has pending cleanup`,
|
|
612
|
+
registration: target
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
validateRedefinedPropertyRelations() {
|
|
617
|
+
this.redefinedPropertyTypes.forEach((type) => {
|
|
618
|
+
const target = { kind: 'property', key: type };
|
|
619
|
+
const definition = getDeclarativePropertyTypeDefinition(type);
|
|
620
|
+
if (!definition) {
|
|
621
|
+
this.failStructuralPropertyRelation(target, type, target, `Redefined property type "${type}" is no longer registered`);
|
|
622
|
+
}
|
|
623
|
+
const fieldsByKey = new Map(definition.fields.map((field) => [field.key, field]));
|
|
624
|
+
const dynamicReservedKeys = new Set([
|
|
625
|
+
'id',
|
|
626
|
+
'type',
|
|
627
|
+
...definition.fields.map((field) => field.key),
|
|
628
|
+
...definition.dynamicReservedKeys
|
|
629
|
+
]);
|
|
630
|
+
const aliasIsProjected = (alias) => {
|
|
631
|
+
const field = fieldsByKey.get(alias);
|
|
632
|
+
if (field)
|
|
633
|
+
return field.project;
|
|
634
|
+
return definition.allowDynamicKeys && !dynamicReservedKeys.has(alias);
|
|
635
|
+
};
|
|
636
|
+
this.registrationGraph
|
|
637
|
+
.getIncomingRelations(target)
|
|
638
|
+
.forEach((relation) => {
|
|
639
|
+
if (relation.source.kind !== 'component')
|
|
640
|
+
return;
|
|
641
|
+
const componentRelation = getComponentPropertyRelationsRuntime(relation.source.key).find((candidate) => candidate.name === relation.name &&
|
|
642
|
+
candidate.property.type === type);
|
|
643
|
+
if (!componentRelation) {
|
|
644
|
+
this.failStructuralPropertyRelation(relation.source, relation.name, target, `Component property relation "${relation.source.key}/${relation.name}" no longer resolves to "${type}"`);
|
|
645
|
+
}
|
|
646
|
+
componentRelation.property.alias?.forEach((alias) => {
|
|
647
|
+
if (aliasIsProjected(alias))
|
|
648
|
+
return;
|
|
649
|
+
this.failStructuralPropertyRelation(relation.source, relation.name, target, `Component property alias "${relation.source.key}/${relation.name}.${alias}" is not projected by "${type}"`);
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
getPropertyChildRelationsRuntime(type).forEach((relation) => {
|
|
653
|
+
if (fieldsByKey.get(relation.key)?.project)
|
|
654
|
+
return;
|
|
655
|
+
this.failStructuralPropertyRelation(relation.source, relation.name, relation.target, `Property child key "${type}.${relation.key}" is not projected by its redefined type`);
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
failStructuralPropertyRelation(source, relationName, target, message) {
|
|
660
|
+
throw new RegistrationRelationError({
|
|
661
|
+
ok: false,
|
|
662
|
+
code: 'DANGLING_RELATION',
|
|
663
|
+
operation: 'validate-relations',
|
|
664
|
+
message,
|
|
665
|
+
source,
|
|
666
|
+
relationName,
|
|
667
|
+
target
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
registrationConflict(ref, message = `Registration "${ref.kind}:${ref.key}" must be unregistered before it can be defined again`) {
|
|
671
|
+
throw new RegistrationRelationError({
|
|
672
|
+
ok: false,
|
|
673
|
+
code: 'UNREGISTER_FAILED',
|
|
674
|
+
operation: 'register-node',
|
|
675
|
+
message,
|
|
676
|
+
registration: ref
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
assertRelationCanBeDefined(source, relationName, target) {
|
|
680
|
+
this.assertCompositionOpen('define-relation');
|
|
681
|
+
if (!this.registrationGraph.getRegistration(source)) {
|
|
682
|
+
throw new RegistrationRelationError({
|
|
683
|
+
ok: false,
|
|
684
|
+
code: 'REGISTRATION_NOT_FOUND',
|
|
685
|
+
operation: 'define-relation',
|
|
686
|
+
message: `Registration "${source.kind}:${source.key}" was not found`,
|
|
687
|
+
source,
|
|
688
|
+
relationName
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
this.assertRelationEndpointNotPending(source, 'define-relation', source, relationName, target);
|
|
692
|
+
if (!this.registrationGraph.getRegistration(target)) {
|
|
693
|
+
throw new RegistrationRelationError({
|
|
694
|
+
ok: false,
|
|
695
|
+
code: 'RELATION_TARGET_NOT_FOUND',
|
|
696
|
+
operation: 'define-relation',
|
|
697
|
+
message: `Relation target "${target.kind}:${target.key}" was not found`,
|
|
698
|
+
source,
|
|
699
|
+
relationName,
|
|
700
|
+
target
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
this.assertRelationEndpointNotPending(target, 'define-relation', source, relationName, target);
|
|
704
|
+
if (this.registrationGraph
|
|
705
|
+
.getOutgoingRelations(source)
|
|
706
|
+
.some((relation) => relation.name === relationName)) {
|
|
707
|
+
throw new RegistrationRelationError({
|
|
708
|
+
ok: false,
|
|
709
|
+
code: 'DUPLICATE_RELATION',
|
|
710
|
+
operation: 'define-relation',
|
|
711
|
+
message: `Relation "${source.kind}:${source.key}/${relationName}" is already defined`,
|
|
712
|
+
source,
|
|
713
|
+
relationName
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
assertRelationCanBeRemoved(source, relationName) {
|
|
718
|
+
this.assertCompositionOpen('remove-relation');
|
|
719
|
+
if (!this.registrationGraph.getRegistration(source)) {
|
|
720
|
+
throw new RegistrationRelationError({
|
|
721
|
+
ok: false,
|
|
722
|
+
code: 'REGISTRATION_NOT_FOUND',
|
|
723
|
+
operation: 'remove-relation',
|
|
724
|
+
message: `Registration "${source.kind}:${source.key}" was not found`,
|
|
725
|
+
source,
|
|
726
|
+
relationName
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
this.assertRelationEndpointNotPending(source, 'remove-relation', source, relationName);
|
|
730
|
+
if (!this.registrationGraph
|
|
731
|
+
.getOutgoingRelations(source)
|
|
732
|
+
.some((relation) => relation.name === relationName)) {
|
|
733
|
+
throw new RegistrationRelationError({
|
|
734
|
+
ok: false,
|
|
735
|
+
code: 'RELATION_NOT_FOUND',
|
|
736
|
+
operation: 'remove-relation',
|
|
737
|
+
message: `Relation "${source.kind}:${source.key}/${relationName}" was not found`,
|
|
738
|
+
source,
|
|
739
|
+
relationName
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
preflightRegistrationDefinition(source, registration, reservedRelationNames = []) {
|
|
744
|
+
if (!registration?.relations?.length)
|
|
745
|
+
return;
|
|
746
|
+
const relationNames = new Set([
|
|
747
|
+
...reservedRelationNames,
|
|
748
|
+
...this.registrationGraph
|
|
749
|
+
.getOutgoingRelations(source)
|
|
750
|
+
.map((relation) => relation.name)
|
|
751
|
+
]);
|
|
752
|
+
registration.relations.forEach((relation) => {
|
|
753
|
+
if (relationNames.has(relation.name)) {
|
|
754
|
+
throw new RegistrationRelationError({
|
|
755
|
+
ok: false,
|
|
756
|
+
code: 'DUPLICATE_RELATION',
|
|
757
|
+
operation: 'define-relation',
|
|
758
|
+
message: `Registration relation "${source.kind}:${source.key}/${relation.name}" is duplicated`,
|
|
759
|
+
source,
|
|
760
|
+
relationName: relation.name,
|
|
761
|
+
target: relation.target
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
relationNames.add(relation.name);
|
|
765
|
+
if (!this.registrationGraph.getRegistration(relation.target)) {
|
|
766
|
+
throw new RegistrationRelationError({
|
|
767
|
+
ok: false,
|
|
768
|
+
code: 'RELATION_TARGET_NOT_FOUND',
|
|
769
|
+
operation: 'define-relation',
|
|
770
|
+
message: `Relation target "${relation.target.kind}:${relation.target.key}" was not found`,
|
|
771
|
+
source,
|
|
772
|
+
relationName: relation.name,
|
|
773
|
+
target: relation.target
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
this.assertRelationEndpointNotPending(relation.target, 'define-relation', source, relation.name, relation.target);
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
assertRelationEndpointNotPending(ref, operation, source, relationName, target) {
|
|
780
|
+
if (!this.registrationGraph.hasPendingCleanup(ref))
|
|
781
|
+
return;
|
|
782
|
+
throw new RegistrationRelationError({
|
|
783
|
+
ok: false,
|
|
784
|
+
code: 'UNREGISTER_FAILED',
|
|
785
|
+
operation,
|
|
786
|
+
message: `Registration "${ref.kind}:${ref.key}" still has pending cleanup`,
|
|
787
|
+
registration: ref,
|
|
788
|
+
source,
|
|
789
|
+
relationName,
|
|
790
|
+
target
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
defineRegistrationRelations(source, registration) {
|
|
794
|
+
registration?.relations?.forEach((relation) => {
|
|
795
|
+
this.registrationGraph.defineRelation(source, relation);
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
ensurePropertyNode(type, registration) {
|
|
799
|
+
if (this.registrationGraph.getRegistration({ kind: 'property', key: type })) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
this.registrationGraph.registerNode({
|
|
803
|
+
ref: { kind: 'property', key: type },
|
|
804
|
+
owner: registration?.owner,
|
|
805
|
+
handlers: {
|
|
806
|
+
isPresent: () => Boolean(getPropertyComponent(type)),
|
|
807
|
+
preflightUnregister: () => this.assertPropertyTypeUnused(type),
|
|
808
|
+
preflightDetachRelation: () => this.assertPropertyTypeUnused(type),
|
|
809
|
+
detachRelation: (relation) => {
|
|
810
|
+
removePropertyChildRelationRuntime(type, relation.name, this.deps.props);
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
resources: [
|
|
814
|
+
{
|
|
815
|
+
key: `property:${type}`,
|
|
816
|
+
dispose: () => {
|
|
817
|
+
unregisterPropertyRegistration(type, this.deps.props, 'all');
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
ensureComponentNode(type, registration) {
|
|
824
|
+
if (this.registrationGraph.getRegistration({ kind: 'component', key: type })) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
this.registrationGraph.registerNode({
|
|
828
|
+
ref: { kind: 'component', key: type },
|
|
829
|
+
owner: registration?.owner,
|
|
830
|
+
handlers: {
|
|
831
|
+
isPresent: () => componentRegistry.has(type),
|
|
832
|
+
preflightUnregister: () => this.assertComponentTypeUnused(type),
|
|
833
|
+
preflightDetachRelation: () => this.assertComponentTypeUnused(type),
|
|
834
|
+
detachRelation: (relation) => {
|
|
835
|
+
removeComponentPropertyRelationRuntime(type, relation.name, this.deps.sceneTree);
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
resources: [
|
|
839
|
+
{
|
|
840
|
+
key: `component:${type}`,
|
|
841
|
+
dispose: () => {
|
|
842
|
+
unregisterComponentGraphRegistration(type);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
]
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
ensureFeatureNode(name, registration) {
|
|
849
|
+
this.registrationGraph.registerNode({
|
|
850
|
+
ref: { kind: 'feature', key: name },
|
|
851
|
+
owner: registration?.owner,
|
|
852
|
+
handlers: { isPresent: () => getFeatureRegistry().has(name) },
|
|
853
|
+
resources: [
|
|
854
|
+
{
|
|
855
|
+
key: `feature:${name}`,
|
|
856
|
+
dispose: () => {
|
|
857
|
+
unregisterFeatureRuntime(name);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
]
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
ensureRenderStrategyNode(type, registration) {
|
|
864
|
+
this.registrationGraph.registerNode({
|
|
865
|
+
ref: { kind: 'render-strategy', key: type },
|
|
866
|
+
owner: registration?.owner,
|
|
867
|
+
handlers: { isPresent: () => renderStrategyRegistry.has(type) },
|
|
868
|
+
resources: [
|
|
869
|
+
{
|
|
870
|
+
key: `render-strategy:${type}`,
|
|
871
|
+
dispose: () => {
|
|
872
|
+
renderStrategyRegistry.unregister(type);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
]
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
ensureUIPropertyNode(key, registration) {
|
|
879
|
+
if (this.registrationGraph.getRegistration({ kind: 'ui-property', key })) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
this.registrationGraph.registerNode({
|
|
883
|
+
ref: { kind: 'ui-property', key },
|
|
884
|
+
owner: registration?.owner,
|
|
885
|
+
handlers: {
|
|
886
|
+
isPresent: () => propertyRegistry.getAllPropertyKeys().includes(key)
|
|
887
|
+
},
|
|
888
|
+
resources: [
|
|
889
|
+
{
|
|
890
|
+
key: `ui-property:${key}`,
|
|
891
|
+
dispose: () => propertyRegistry.unregister(key)
|
|
892
|
+
}
|
|
893
|
+
]
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
assertPropertyTypeUnused(type) {
|
|
897
|
+
const propertyIds = this.deps.props.getPropertyIdsByType(type);
|
|
898
|
+
if (propertyIds.length === 0)
|
|
899
|
+
return;
|
|
900
|
+
throw new RegistrationRelationError({
|
|
901
|
+
ok: false,
|
|
902
|
+
code: 'REGISTRATION_IN_USE',
|
|
903
|
+
operation: 'unregister-registration',
|
|
904
|
+
message: `Property registration "${type}" is in use by: ${propertyIds.join(', ')}`,
|
|
905
|
+
registration: { kind: 'property', key: type }
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
assertComponentTypeUnused(type) {
|
|
909
|
+
const activeIds = [];
|
|
910
|
+
this.deps.sceneTree.getAllElements().forEach((element) => {
|
|
911
|
+
if (element.get('type') === type)
|
|
912
|
+
activeIds.push(element.get('id'));
|
|
913
|
+
});
|
|
914
|
+
if (activeIds.length === 0)
|
|
915
|
+
return;
|
|
916
|
+
throw new RegistrationRelationError({
|
|
917
|
+
ok: false,
|
|
918
|
+
code: 'REGISTRATION_IN_USE',
|
|
919
|
+
operation: 'unregister-registration',
|
|
920
|
+
message: `Component registration "${type}" is in use by: ${activeIds.join(', ')}`,
|
|
921
|
+
registration: { kind: 'component', key: type }
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
load(data) {
|
|
925
|
+
if (data == null) {
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
this.applyLoadedData(data);
|
|
52
929
|
}
|
|
53
930
|
async save() {
|
|
54
|
-
const propsData = await this.propsSaveData();
|
|
55
931
|
const sceneTreeData = await this.sceneTreeSaveData();
|
|
56
|
-
const
|
|
932
|
+
const systemContextData = this.deps.systemContext.saveManagedProperties();
|
|
933
|
+
let data = {
|
|
57
934
|
version: this.version,
|
|
58
935
|
sceneTree: sceneTreeData,
|
|
59
|
-
props:
|
|
936
|
+
props: this.deps.props.save()
|
|
937
|
+
};
|
|
938
|
+
if (Object.keys(systemContextData).length > 0) {
|
|
939
|
+
data.systemContext = systemContextData;
|
|
940
|
+
}
|
|
941
|
+
data = cloneSerializationSnapshot(data);
|
|
942
|
+
for (const hook of this.saveHooks) {
|
|
943
|
+
data = hook(data);
|
|
944
|
+
}
|
|
945
|
+
return cloneSerializationSnapshot(data);
|
|
946
|
+
}
|
|
947
|
+
normalizeLoadData(rawData, diagnostics, pathPrefix = 'core') {
|
|
948
|
+
if (!isRecord(rawData)) {
|
|
949
|
+
diagnostics.push({
|
|
950
|
+
scope: 'core',
|
|
951
|
+
path: pathPrefix,
|
|
952
|
+
message: 'Expected object payload for core load; fallback to safe defaults'
|
|
953
|
+
});
|
|
954
|
+
return {
|
|
955
|
+
version: DATA_VERSION,
|
|
956
|
+
sceneTree: EMPTY_SCENE_TREE_DATA,
|
|
957
|
+
props: {}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
const version = typeof rawData.version === 'string' ? rawData.version : DATA_VERSION;
|
|
961
|
+
if (typeof rawData.version !== 'string') {
|
|
962
|
+
diagnostics.push({
|
|
963
|
+
scope: 'core',
|
|
964
|
+
path: `${pathPrefix}.version`,
|
|
965
|
+
message: 'Invalid version type; fallback to default version'
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
const sceneTree = isRecord(rawData.sceneTree)
|
|
969
|
+
? rawData.sceneTree
|
|
970
|
+
: EMPTY_SCENE_TREE_DATA;
|
|
971
|
+
if (!isRecord(rawData.sceneTree)) {
|
|
972
|
+
diagnostics.push({
|
|
973
|
+
scope: 'core',
|
|
974
|
+
path: `${pathPrefix}.sceneTree`,
|
|
975
|
+
message: 'Invalid sceneTree payload type; fallback to empty scene data'
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
const props = (isRecord(rawData.props) ? rawData.props : {});
|
|
979
|
+
if (!isRecord(rawData.props)) {
|
|
980
|
+
diagnostics.push({
|
|
981
|
+
scope: 'core',
|
|
982
|
+
path: `${pathPrefix}.props`,
|
|
983
|
+
message: 'Invalid props payload type; fallback to empty props map'
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
const normalized = {
|
|
987
|
+
version,
|
|
988
|
+
sceneTree,
|
|
989
|
+
props
|
|
990
|
+
};
|
|
991
|
+
if ('systemContext' in rawData) {
|
|
992
|
+
normalized.systemContext = rawData.systemContext;
|
|
993
|
+
}
|
|
994
|
+
return normalized;
|
|
995
|
+
}
|
|
996
|
+
runLoadHooks(data) {
|
|
997
|
+
let nextData = data;
|
|
998
|
+
const loadHooks = [...this.loadHooks];
|
|
999
|
+
for (const [hookIndex, hook] of loadHooks.entries()) {
|
|
1000
|
+
const result = hook(nextData);
|
|
1001
|
+
if (isRecord(result) &&
|
|
1002
|
+
'then' in result &&
|
|
1003
|
+
typeof result.then === 'function') {
|
|
1004
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
1005
|
+
throw new LoadHookExecutionError(LOAD_HOOK_EXECUTION_ERROR_CODES.ASYNC_UNSUPPORTED, hookIndex);
|
|
1006
|
+
}
|
|
1007
|
+
if (!isRecord(result) || typeof result.version !== 'string') {
|
|
1008
|
+
throw new LoadHookExecutionError(LOAD_HOOK_EXECUTION_ERROR_CODES.INVALID_RESULT, hookIndex);
|
|
1009
|
+
}
|
|
1010
|
+
nextData = result;
|
|
1011
|
+
}
|
|
1012
|
+
return nextData;
|
|
1013
|
+
}
|
|
1014
|
+
applyLoadedData(rawData) {
|
|
1015
|
+
const diagnostics = [];
|
|
1016
|
+
const migrated = this.runLoadHooks(rawData);
|
|
1017
|
+
const normalizedAfterHooks = this.normalizeLoadData(migrated, diagnostics, this.loadHooks.length > 0 ? 'core.hooks' : 'core.input');
|
|
1018
|
+
const propsValidation = this.deps.props.validateLoadData(normalizedAfterHooks.props);
|
|
1019
|
+
diagnostics.push(...propsValidation.diagnostics.map((item) => ({
|
|
1020
|
+
scope: 'props-manager',
|
|
1021
|
+
path: item.path,
|
|
1022
|
+
message: item.message
|
|
1023
|
+
})));
|
|
1024
|
+
const sceneValidation = this.deps.sceneTree.validateLoadData(normalizedAfterHooks.sceneTree);
|
|
1025
|
+
diagnostics.push(...sceneValidation.diagnostics.map((item) => ({
|
|
1026
|
+
scope: 'scene-tree',
|
|
1027
|
+
path: item.path,
|
|
1028
|
+
message: item.message
|
|
1029
|
+
})));
|
|
1030
|
+
const systemValidation = this.deps.systemContext.validateManagedProperties(normalizedAfterHooks.systemContext);
|
|
1031
|
+
diagnostics.push(...systemValidation.diagnostics.map((item) => ({
|
|
1032
|
+
scope: 'system-context',
|
|
1033
|
+
path: item.path,
|
|
1034
|
+
message: item.message
|
|
1035
|
+
})));
|
|
1036
|
+
if (sceneValidation.valid === false) {
|
|
1037
|
+
throw new Error('[Core] Scene Tree rejected invalid hierarchy before package apply');
|
|
1038
|
+
}
|
|
1039
|
+
this.deps.sceneTree.preflightLoadPropertyRelations(sceneValidation, propsValidation.data);
|
|
1040
|
+
this.deps.props.applyValidatedLoad(propsValidation);
|
|
1041
|
+
this.deps.sceneTree.applyValidatedLoad(sceneValidation);
|
|
1042
|
+
this.deps.systemContext.applyValidatedManagedProperties(systemValidation);
|
|
1043
|
+
this.version = normalizedAfterHooks.version;
|
|
1044
|
+
fileLoadComplete();
|
|
1045
|
+
this.emitLoadDiagnostics(diagnostics, () => this.composeLoadedData(normalizedAfterHooks.version, sceneValidation.data, propsValidation.data));
|
|
1046
|
+
}
|
|
1047
|
+
composeLoadedData(version, sceneTree, props) {
|
|
1048
|
+
const data = {
|
|
1049
|
+
version,
|
|
1050
|
+
sceneTree,
|
|
1051
|
+
props
|
|
60
1052
|
};
|
|
1053
|
+
const managedProperties = this.deps.systemContext.saveManagedProperties();
|
|
1054
|
+
if (Object.keys(managedProperties).length > 0) {
|
|
1055
|
+
data.systemContext = managedProperties;
|
|
1056
|
+
}
|
|
61
1057
|
return data;
|
|
62
1058
|
}
|
|
1059
|
+
emitLoadDiagnostics(diagnostics, createData) {
|
|
1060
|
+
const hooks = [...this.loadDiagnosticsHooks];
|
|
1061
|
+
if (diagnostics.length === 0 || hooks.length === 0) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
let data;
|
|
1065
|
+
try {
|
|
1066
|
+
data = createData();
|
|
1067
|
+
}
|
|
1068
|
+
catch {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
for (const hook of hooks) {
|
|
1072
|
+
try {
|
|
1073
|
+
hook(cloneLoadObservation(diagnostics), cloneLoadObservation(data));
|
|
1074
|
+
}
|
|
1075
|
+
catch {
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
63
1080
|
}
|
|
64
1081
|
export { Core };
|
|
65
1082
|
const core = new Core({
|
|
66
1083
|
inputSystem,
|
|
67
1084
|
factory,
|
|
1085
|
+
dataChannelObservers: dataChannelObserver.getDefaultDataChannelObserverRegistry(),
|
|
68
1086
|
props,
|
|
69
1087
|
render,
|
|
70
1088
|
sceneTree,
|
|
71
1089
|
selection,
|
|
72
|
-
systemContext
|
|
73
|
-
interactionCore
|
|
1090
|
+
systemContext
|
|
74
1091
|
});
|
|
75
1092
|
export default core;
|
|
76
1093
|
//# sourceMappingURL=core.js.map
|