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