@asyra/preset 0.5.8 → 0.6.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/CHANGELOG.md +28 -0
- package/README.md +2 -2
- package/dist/agent-activity.d.ts +61 -0
- package/dist/agent-activity.d.ts.map +1 -0
- package/dist/agent-activity.js +224 -0
- package/dist/agent-activity.js.map +1 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -2
- package/dist/catalog.js.map +1 -1
- package/dist/cleanup-reporter.d.ts.map +1 -1
- package/dist/cleanup-reporter.js.map +1 -1
- package/dist/components/fills.d.ts +3 -1
- package/dist/components/fills.d.ts.map +1 -1
- package/dist/components/fills.js +74 -0
- package/dist/components/fills.js.map +1 -1
- package/dist/components/frame.d.ts +2 -2
- package/dist/components/frame.d.ts.map +1 -1
- package/dist/components/frame.js +1 -0
- package/dist/components/frame.js.map +1 -1
- package/dist/components/group.d.ts +9 -21
- package/dist/components/group.d.ts.map +1 -1
- package/dist/components/group.js +188 -84
- package/dist/components/group.js.map +1 -1
- package/dist/components/oval.d.ts +2 -2
- package/dist/components/oval.d.ts.map +1 -1
- package/dist/components/oval.js +3 -1
- package/dist/components/oval.js.map +1 -1
- package/dist/components/rectangle.d.ts +2 -2
- package/dist/components/rectangle.d.ts.map +1 -1
- package/dist/components/rectangle.js +3 -1
- package/dist/components/rectangle.js.map +1 -1
- package/dist/components/shape-hit-area.d.ts.map +1 -1
- package/dist/components/shape-hit-area.js.map +1 -1
- package/dist/components/text.d.ts +9 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/text.js +61 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/vector-compound-fill.d.ts +8 -0
- package/dist/components/vector-compound-fill.d.ts.map +1 -0
- package/dist/components/vector-compound-fill.js +149 -0
- package/dist/components/vector-compound-fill.js.map +1 -0
- package/dist/components/vector.d.ts.map +1 -1
- package/dist/components/vector.js +85 -565
- package/dist/components/vector.js.map +1 -1
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/profile-provider.d.ts +2 -1
- package/dist/composition/profile-provider.d.ts.map +1 -1
- package/dist/composition/profile-provider.js +8 -2
- package/dist/composition/profile-provider.js.map +1 -1
- package/dist/composition/resolve.d.ts +2 -0
- package/dist/composition/resolve.d.ts.map +1 -1
- package/dist/composition/resolve.js +30 -6
- package/dist/composition/resolve.js.map +1 -1
- package/dist/defaults/install.d.ts.map +1 -1
- package/dist/defaults/install.js +2 -1
- package/dist/defaults/install.js.map +1 -1
- package/dist/defaults/installation.d.ts.map +1 -1
- package/dist/defaults/installation.js +2 -0
- package/dist/defaults/installation.js.map +1 -1
- package/dist/defaults/modules/selection.d.ts.map +1 -1
- package/dist/defaults/modules/selection.js.map +1 -1
- package/dist/defaults/modules/vector-editing.d.ts.map +1 -1
- package/dist/defaults/modules/vector-editing.js.map +1 -1
- package/dist/defaults/owned-state.d.ts.map +1 -1
- package/dist/defaults/owned-state.js.map +1 -1
- package/dist/defaults/private-manager.d.ts.map +1 -1
- package/dist/defaults/private-manager.js +2 -1
- package/dist/defaults/private-manager.js.map +1 -1
- package/dist/events/preset-event-names.d.ts +2 -0
- package/dist/events/preset-event-names.d.ts.map +1 -1
- package/dist/events/register-events.d.ts.map +1 -1
- package/dist/events/register-events.js +4 -2
- package/dist/events/register-events.js.map +1 -1
- package/dist/group-bounds.d.ts +36 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/group-bounds.js +141 -0
- package/dist/group-bounds.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/preset.d.ts.map +1 -1
- package/dist/preset.js +5 -3
- package/dist/preset.js.map +1 -1
- package/dist/props/components/anchor-points-component.d.ts.map +1 -1
- package/dist/props/components/anchor-points-component.js.map +1 -1
- package/dist/props/components/children-map-property-component.d.ts.map +1 -1
- package/dist/props/components/children-map-property-component.js.map +1 -1
- package/dist/props/components/fills-component.d.ts.map +1 -1
- package/dist/props/components/fills-component.js +3 -2
- package/dist/props/components/fills-component.js.map +1 -1
- package/dist/props/components/position-component.js +1 -1
- package/dist/props/components/position-component.js.map +1 -1
- package/dist/props/components/strokes-component.d.ts.map +1 -1
- package/dist/props/components/strokes-component.js +4 -3
- package/dist/props/components/strokes-component.js.map +1 -1
- package/dist/props/components/text-component.d.ts +67 -0
- package/dist/props/components/text-component.d.ts.map +1 -0
- package/dist/props/components/text-component.js +128 -0
- package/dist/props/components/text-component.js.map +1 -0
- package/dist/props/components/vector-networks-component.d.ts.map +1 -1
- package/dist/props/components/vector-networks-component.js.map +1 -1
- package/dist/props/components/vector-points-component.d.ts.map +1 -1
- package/dist/props/components/vector-points-component.js.map +1 -1
- package/dist/props/components/vector-segments-component.d.ts.map +1 -1
- package/dist/props/components/vector-segments-component.js.map +1 -1
- package/dist/props/register-property-schemas.d.ts.map +1 -1
- package/dist/props/register-property-schemas.js +6 -0
- package/dist/props/register-property-schemas.js.map +1 -1
- package/dist/render-layers/selection-overlay-render-layer.d.ts.map +1 -1
- package/dist/render-layers/selection-overlay-render-layer.js +7 -2
- package/dist/render-layers/selection-overlay-render-layer.js.map +1 -1
- package/dist/render-layers/vector-path-editing-render-layer.d.ts.map +1 -1
- package/dist/render-layers/vector-path-editing-render-layer.js.map +1 -1
- package/dist/selection/ids.d.ts.map +1 -1
- package/dist/selection/ids.js.map +1 -1
- package/dist/selection/register-default-selections.d.ts.map +1 -1
- package/dist/selection/register-default-selections.js +4 -2
- package/dist/selection/register-default-selections.js.map +1 -1
- package/dist/spatial/assets/binary.d.ts +22 -0
- package/dist/spatial/assets/binary.d.ts.map +1 -0
- package/dist/spatial/assets/binary.js +132 -0
- package/dist/spatial/assets/binary.js.map +1 -0
- package/dist/spatial/assets/decode.d.ts +23 -0
- package/dist/spatial/assets/decode.d.ts.map +1 -0
- package/dist/spatial/assets/decode.js +102 -0
- package/dist/spatial/assets/decode.js.map +1 -0
- package/dist/spatial/assets/preview-worker.d.ts +13 -0
- package/dist/spatial/assets/preview-worker.d.ts.map +1 -0
- package/dist/spatial/assets/preview-worker.js +188 -0
- package/dist/spatial/assets/preview-worker.js.map +1 -0
- package/dist/spatial/assets/scene.d.ts +13 -0
- package/dist/spatial/assets/scene.d.ts.map +1 -0
- package/dist/spatial/assets/scene.js +99 -0
- package/dist/spatial/assets/scene.js.map +1 -0
- package/dist/spatial/assets/schema.d.ts +22 -0
- package/dist/spatial/assets/schema.d.ts.map +1 -0
- package/dist/spatial/assets/schema.js +93 -0
- package/dist/spatial/assets/schema.js.map +1 -0
- package/dist/spatial/bounds.d.ts +15 -0
- package/dist/spatial/bounds.d.ts.map +1 -0
- package/dist/spatial/bounds.js +94 -0
- package/dist/spatial/bounds.js.map +1 -0
- package/dist/spatial/camera-controls.d.ts +53 -0
- package/dist/spatial/camera-controls.d.ts.map +1 -0
- package/dist/spatial/camera-controls.js +208 -0
- package/dist/spatial/camera-controls.js.map +1 -0
- package/dist/spatial/components.d.ts +20 -0
- package/dist/spatial/components.d.ts.map +1 -0
- package/dist/spatial/components.js +83 -0
- package/dist/spatial/components.js.map +1 -0
- package/dist/spatial/editing.d.ts +51 -0
- package/dist/spatial/editing.d.ts.map +1 -0
- package/dist/spatial/editing.js +152 -0
- package/dist/spatial/editing.js.map +1 -0
- package/dist/spatial/emissive-bloom.d.ts +22 -0
- package/dist/spatial/emissive-bloom.d.ts.map +1 -0
- package/dist/spatial/emissive-bloom.js +197 -0
- package/dist/spatial/emissive-bloom.js.map +1 -0
- package/dist/spatial/graphics.d.ts +9 -0
- package/dist/spatial/graphics.d.ts.map +1 -0
- package/dist/spatial/graphics.js +119 -0
- package/dist/spatial/graphics.js.map +1 -0
- package/dist/spatial/lazy-engine.d.ts +6 -0
- package/dist/spatial/lazy-engine.d.ts.map +1 -0
- package/dist/spatial/lazy-engine.js +92 -0
- package/dist/spatial/lazy-engine.js.map +1 -0
- package/dist/spatial/lighting.d.ts +28 -0
- package/dist/spatial/lighting.d.ts.map +1 -0
- package/dist/spatial/lighting.js +103 -0
- package/dist/spatial/lighting.js.map +1 -0
- package/dist/spatial/opaque-frame.d.ts +11 -0
- package/dist/spatial/opaque-frame.d.ts.map +1 -0
- package/dist/spatial/opaque-frame.js +131 -0
- package/dist/spatial/opaque-frame.js.map +1 -0
- package/dist/spatial/pose.d.ts +22 -0
- package/dist/spatial/pose.d.ts.map +1 -0
- package/dist/spatial/pose.js +83 -0
- package/dist/spatial/pose.js.map +1 -0
- package/dist/spatial/presentation.d.ts +16 -0
- package/dist/spatial/presentation.d.ts.map +1 -0
- package/dist/spatial/presentation.js +66 -0
- package/dist/spatial/presentation.js.map +1 -0
- package/dist/spatial/reflection-environment.d.ts +13 -0
- package/dist/spatial/reflection-environment.d.ts.map +1 -0
- package/dist/spatial/reflection-environment.js +63 -0
- package/dist/spatial/reflection-environment.js.map +1 -0
- package/dist/spatial/registration.d.ts +6 -0
- package/dist/spatial/registration.d.ts.map +1 -0
- package/dist/spatial/registration.js +82 -0
- package/dist/spatial/registration.js.map +1 -0
- package/dist/spatial/shadow-frame.d.ts +13 -0
- package/dist/spatial/shadow-frame.d.ts.map +1 -0
- package/dist/spatial/shadow-frame.js +60 -0
- package/dist/spatial/shadow-frame.js.map +1 -0
- package/dist/spatial/spatial-contract.d.ts +10 -0
- package/dist/spatial/spatial-contract.d.ts.map +1 -0
- package/dist/spatial/spatial-contract.js +414 -0
- package/dist/spatial/spatial-contract.js.map +1 -0
- package/dist/spatial/spatial-layer.d.ts +47 -0
- package/dist/spatial/spatial-layer.d.ts.map +1 -0
- package/dist/spatial/spatial-layer.js +224 -0
- package/dist/spatial/spatial-layer.js.map +1 -0
- package/dist/spatial/surface-contract.d.ts +4 -0
- package/dist/spatial/surface-contract.d.ts.map +1 -0
- package/dist/spatial/surface-contract.js +40 -0
- package/dist/spatial/surface-contract.js.map +1 -0
- package/dist/spatial/surface-textures.d.ts +8 -0
- package/dist/spatial/surface-textures.d.ts.map +1 -0
- package/dist/spatial/surface-textures.js +46 -0
- package/dist/spatial/surface-textures.js.map +1 -0
- package/dist/spatial/three-engine.d.ts +91 -0
- package/dist/spatial/three-engine.d.ts.map +1 -0
- package/dist/spatial/three-engine.js +1127 -0
- package/dist/spatial/three-engine.js.map +1 -0
- package/dist/spatial/transmission-capture.d.ts +13 -0
- package/dist/spatial/transmission-capture.d.ts.map +1 -0
- package/dist/spatial/transmission-capture.js +215 -0
- package/dist/spatial/transmission-capture.js.map +1 -0
- package/dist/spatial-assets.d.ts +4 -0
- package/dist/spatial-assets.d.ts.map +1 -0
- package/dist/spatial-assets.js +4 -0
- package/dist/spatial-assets.js.map +1 -0
- package/dist/spatial-contract.d.ts +3 -0
- package/dist/spatial-contract.d.ts.map +1 -0
- package/dist/spatial-contract.js +3 -0
- package/dist/spatial-contract.js.map +1 -0
- package/dist/spatial-engine.d.ts +5 -0
- package/dist/spatial-engine.d.ts.map +1 -0
- package/dist/spatial-engine.js +5 -0
- package/dist/spatial-engine.js.map +1 -0
- package/dist/spatial.d.ts +9 -0
- package/dist/spatial.d.ts.map +1 -0
- package/dist/spatial.js +9 -0
- package/dist/spatial.js.map +1 -0
- package/dist/subscriptions/data-channel.d.ts.map +1 -1
- package/dist/subscriptions/data-channel.js +372 -124
- package/dist/subscriptions/data-channel.js.map +1 -1
- package/dist/subscriptions/render-system.d.ts.map +1 -1
- package/dist/subscriptions/render-system.js +4 -2
- package/dist/subscriptions/render-system.js.map +1 -1
- package/dist/subscriptions/shared-channels.d.ts.map +1 -1
- package/dist/subscriptions/shared-channels.js +4 -2
- package/dist/subscriptions/shared-channels.js.map +1 -1
- package/dist/subscriptions/vector-selection.d.ts +4 -0
- package/dist/subscriptions/vector-selection.d.ts.map +1 -0
- package/dist/subscriptions/vector-selection.js +175 -0
- package/dist/subscriptions/vector-selection.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/register-properties.d.ts.map +1 -1
- package/dist/ui/register-properties.js +3 -2
- package/dist/ui/register-properties.js.map +1 -1
- package/dist/vector/synthetic-handle.d.ts.map +1 -1
- package/dist/vector/synthetic-handle.js.map +1 -1
- package/package.json +43 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineDataChannelObserver, EventTypes, propertyRegistry, renderSceneTreeStore, renderSelectionStore, subscribeToSynchronousEvent, uiContext, subscribeToFileLoadComplete } from '@asyra/core';
|
|
2
2
|
import { EntityTypes, SCENE_TREE_ACTIONS, SharedDataChannelNames, emitDiagnosticCounter, measureBrowserDragPhase } from '@asyra/utils';
|
|
3
|
-
import { subscribeToEventBatches } from '@asyra/reactive-events';
|
|
3
|
+
import { subscribeToEventBatches, subscribeToAppliedEventBatches } from '@asyra/reactive-events';
|
|
4
4
|
import { createCleanupReporter } from '../cleanup-reporter.js';
|
|
5
5
|
import { deriveGroupBounds } from '../components/group.js';
|
|
6
6
|
import { SelectionActions, SelectionChannels, SelectionEventNames } from '../selection/channels.js';
|
|
@@ -119,6 +119,10 @@ const updateRenderSceneTree = (change) => {
|
|
|
119
119
|
case SCENE_TREE_ACTIONS.REMOVE_SUBTREE:
|
|
120
120
|
case SCENE_TREE_ACTIONS.RESTORE_SUBTREE:
|
|
121
121
|
return recordRenderProjectionOutcome(renderSceneTreeStore.applySubtreeChange(change));
|
|
122
|
+
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_PROPERTY_BINDINGS: {
|
|
123
|
+
const { id, changes } = change;
|
|
124
|
+
return recordRenderProjectionOutcome(renderSceneTreeStore.updateElementPropertyBindings(id, changes));
|
|
125
|
+
}
|
|
122
126
|
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_DATA: {
|
|
123
127
|
const { id, changes, options } = change;
|
|
124
128
|
return recordRenderProjectionOutcome(renderSceneTreeStore.updateElementBatch(id, changes.map(({ key, before, after }) => ({
|
|
@@ -376,38 +380,6 @@ const syncVectorSelections = (core) => {
|
|
|
376
380
|
uiContext.set('vectorPointSelection', getSelectedIds(core, SelectionChannels.VECTOR_POINT));
|
|
377
381
|
uiContext.set('vectorSegmentSelection', getSelectedIds(core, SelectionChannels.VECTOR_SEGMENT));
|
|
378
382
|
};
|
|
379
|
-
// Build a depth-first flattened element id index from the scene-tree.
|
|
380
|
-
const collectChildrenIds = (deps, elementId, ids) => {
|
|
381
|
-
const element = deps.sceneTree.getElementById(elementId);
|
|
382
|
-
if (!element) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
ids.push(elementId);
|
|
386
|
-
const elementData = element.save();
|
|
387
|
-
if (elementData.type === EntityTypes.GROUP) {
|
|
388
|
-
const children = elementData.children ?? [];
|
|
389
|
-
children.forEach((childId) => {
|
|
390
|
-
collectChildrenIds(deps, childId, ids);
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
const getFlattenedElementIds = (deps) => {
|
|
395
|
-
const ids = [];
|
|
396
|
-
const workspace = deps.sceneTree.currentWorkspace;
|
|
397
|
-
if (!workspace) {
|
|
398
|
-
return ids;
|
|
399
|
-
}
|
|
400
|
-
const workspaceData = workspace.save();
|
|
401
|
-
const workspaceChildren = workspaceData.children ?? [];
|
|
402
|
-
workspaceChildren.forEach((childId) => {
|
|
403
|
-
collectChildrenIds(deps, childId, ids);
|
|
404
|
-
});
|
|
405
|
-
return ids;
|
|
406
|
-
};
|
|
407
|
-
// Publish flattened ids so UI can do fast filtering/lookup without tree traversal.
|
|
408
|
-
const syncFlattenedElementIds = (deps) => {
|
|
409
|
-
uiContext.set('flattenedElementIds', getFlattenedElementIds(deps));
|
|
410
|
-
};
|
|
411
383
|
// Published UI lookup map keyed by element id (used by element row rendering).
|
|
412
384
|
const getElementDataMap = (deps) => {
|
|
413
385
|
const dataMap = {};
|
|
@@ -419,8 +391,43 @@ const getElementDataMap = (deps) => {
|
|
|
419
391
|
});
|
|
420
392
|
return dataMap;
|
|
421
393
|
};
|
|
422
|
-
const
|
|
423
|
-
|
|
394
|
+
const syncHierarchyUIContext = (deps, lifetime) => {
|
|
395
|
+
const map = getElementDataMap(deps);
|
|
396
|
+
const flattenedIds = [];
|
|
397
|
+
const parents = new Map();
|
|
398
|
+
const children = new Map();
|
|
399
|
+
const subtreeSizes = new Map();
|
|
400
|
+
const workspace = deps.sceneTree.currentWorkspace?.save();
|
|
401
|
+
const visit = (elementId, parentId) => {
|
|
402
|
+
const row = map[elementId];
|
|
403
|
+
if (!row || parents.has(elementId)) {
|
|
404
|
+
throw new Error('Invalid loaded UI hierarchy');
|
|
405
|
+
}
|
|
406
|
+
const start = flattenedIds.length;
|
|
407
|
+
const childIds = Array.isArray(row.children)
|
|
408
|
+
? [...row.children]
|
|
409
|
+
: [];
|
|
410
|
+
flattenedIds.push(elementId);
|
|
411
|
+
parents.set(elementId, parentId);
|
|
412
|
+
if (childIds.length) {
|
|
413
|
+
children.set(elementId, childIds);
|
|
414
|
+
}
|
|
415
|
+
childIds.forEach((childId) => visit(childId, elementId));
|
|
416
|
+
subtreeSizes.set(elementId, flattenedIds.length - start);
|
|
417
|
+
};
|
|
418
|
+
if (workspace) {
|
|
419
|
+
children.set(workspace.id, [...workspace.children]);
|
|
420
|
+
workspace.children.forEach((id) => visit(id, workspace.id));
|
|
421
|
+
}
|
|
422
|
+
uiContext.set('flattenedElementIds', flattenedIds);
|
|
423
|
+
uiContext.set('elementDataMap', map);
|
|
424
|
+
lifetime.hierarchy = {
|
|
425
|
+
map: uiContext.get('elementDataMap') ?? map,
|
|
426
|
+
flattenedIds: uiContext.get('flattenedElementIds') ?? flattenedIds,
|
|
427
|
+
parents,
|
|
428
|
+
children,
|
|
429
|
+
subtreeSizes
|
|
430
|
+
};
|
|
424
431
|
};
|
|
425
432
|
const PROJECTED_ELEMENT_MAP_BUCKET_COUNT = 256;
|
|
426
433
|
const PROJECTED_ELEMENT_DELETED = Symbol('projected-element-deleted');
|
|
@@ -615,6 +622,7 @@ const sceneTreeChangeUpdatesProjectedHierarchy = (change) => {
|
|
|
615
622
|
return true;
|
|
616
623
|
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_COMPUTED_DATA:
|
|
617
624
|
return isProjectedHierarchyKey(change.key);
|
|
625
|
+
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_DATA:
|
|
618
626
|
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_COMPUTED_DATA_BATCH:
|
|
619
627
|
return change.changes.some(({ key }) => isProjectedHierarchyKey(key));
|
|
620
628
|
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_COMPUTED_DATA_PATCH:
|
|
@@ -623,7 +631,80 @@ const sceneTreeChangeUpdatesProjectedHierarchy = (change) => {
|
|
|
623
631
|
return false;
|
|
624
632
|
}
|
|
625
633
|
};
|
|
626
|
-
|
|
634
|
+
// A terminal ancestry proof is local to this publication, never a second tree.
|
|
635
|
+
const planProjectedTailAdditions = (changes, prepared) => {
|
|
636
|
+
if (!prepared ||
|
|
637
|
+
prepared.flattenedIds.length === 0 ||
|
|
638
|
+
changes.some((change) => change.action !== SCENE_TREE_ACTIONS.ADD_ELEMENT &&
|
|
639
|
+
change.action !== SCENE_TREE_ACTIONS.ADD_ELEMENTS)) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const tail = [];
|
|
643
|
+
const terminalIds = new Set();
|
|
644
|
+
let current = prepared.flattenedIds[prepared.flattenedIds.length - 1];
|
|
645
|
+
while (current) {
|
|
646
|
+
if (terminalIds.has(current)) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
emitDiagnosticCounter('ui-context-hierarchy-tail-visit');
|
|
650
|
+
terminalIds.add(current);
|
|
651
|
+
tail.push(current);
|
|
652
|
+
current = prepared.parents.get(current);
|
|
653
|
+
}
|
|
654
|
+
tail.reverse();
|
|
655
|
+
const appended = [];
|
|
656
|
+
const addedIds = new Set();
|
|
657
|
+
const childCounts = new Map();
|
|
658
|
+
for (const change of changes) {
|
|
659
|
+
let entries;
|
|
660
|
+
if (change.action === SCENE_TREE_ACTIONS.ADD_ELEMENTS) {
|
|
661
|
+
entries = change.entries;
|
|
662
|
+
}
|
|
663
|
+
else if (change.action === SCENE_TREE_ACTIONS.ADD_ELEMENT) {
|
|
664
|
+
entries = [change];
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
for (const { data, parentId, index } of entries) {
|
|
670
|
+
const id = data.id;
|
|
671
|
+
const parent = typeof parentId === 'string' ? parentId : data.parentId;
|
|
672
|
+
if (!id ||
|
|
673
|
+
!parent ||
|
|
674
|
+
prepared.parents.has(id) ||
|
|
675
|
+
prepared.children.has(id) ||
|
|
676
|
+
addedIds.has(id) ||
|
|
677
|
+
!terminalIds.has(parent) ||
|
|
678
|
+
(data.children !== undefined &&
|
|
679
|
+
(!Array.isArray(data.children) || data.children.length !== 0))) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const childCount = childCounts.get(parent) ?? prepared.children.get(parent)?.length ?? 0;
|
|
683
|
+
if (index !== undefined && index !== childCount) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (change.action === SCENE_TREE_ACTIONS.ADD_ELEMENTS &&
|
|
687
|
+
index === undefined) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
while (tail[tail.length - 1] !== parent) {
|
|
691
|
+
const previous = tail.pop();
|
|
692
|
+
if (previous === undefined) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
terminalIds.delete(previous);
|
|
696
|
+
}
|
|
697
|
+
tail.push(id);
|
|
698
|
+
terminalIds.add(id);
|
|
699
|
+
addedIds.add(id);
|
|
700
|
+
appended.push(id);
|
|
701
|
+
childCounts.set(parent, childCount + 1);
|
|
702
|
+
emitDiagnosticCounter('ui-context-hierarchy-append-entry');
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return appended.length ? appended : undefined;
|
|
706
|
+
};
|
|
707
|
+
const projectUIContextSceneTreeBatch = (changes, lifetime) => {
|
|
627
708
|
if (changes.length === 0) {
|
|
628
709
|
return;
|
|
629
710
|
}
|
|
@@ -631,32 +712,54 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
631
712
|
const updatesHierarchy = changes.some(sceneTreeChangeUpdatesProjectedHierarchy);
|
|
632
713
|
const current = uiContext.get('elementDataMap') ?? {};
|
|
633
714
|
const currentFlattenedIds = uiContext.get('flattenedElementIds') ?? [];
|
|
715
|
+
const retained = lifetime.hierarchy;
|
|
716
|
+
const reusable = retained?.map === current && retained.flattenedIds === currentFlattenedIds
|
|
717
|
+
? retained
|
|
718
|
+
: undefined;
|
|
719
|
+
// Re-entrant publication or failure must never consume an in-progress index.
|
|
720
|
+
lifetime.hierarchy = undefined;
|
|
721
|
+
const tailAdditions = planProjectedTailAdditions(changes, reusable);
|
|
722
|
+
const subtreeSizes = reusable?.subtreeSizes ?? new Map();
|
|
634
723
|
const mutation = createProjectedElementDataMapMutation(current, currentFlattenedIds);
|
|
635
724
|
const next = mutation.value;
|
|
636
725
|
let mapChanged = false;
|
|
637
|
-
const childrenByParent = new Map();
|
|
726
|
+
const childrenByParent = reusable?.children ?? new Map();
|
|
727
|
+
const parentIds = reusable?.parents ?? new Map();
|
|
728
|
+
const missingIds = new Set();
|
|
729
|
+
let membershipRowReads = 0;
|
|
638
730
|
const dirtyParentIds = new Set();
|
|
639
731
|
const changedElementIds = new Set();
|
|
640
732
|
const ensureMutableMap = () => {
|
|
641
733
|
mapChanged = true;
|
|
642
734
|
return next;
|
|
643
735
|
};
|
|
644
|
-
if (updatesHierarchy) {
|
|
736
|
+
if (updatesHierarchy && !reusable) {
|
|
737
|
+
emitDiagnosticCounter('ui-context-membership-prepare');
|
|
645
738
|
currentFlattenedIds.forEach((elementId) => {
|
|
646
|
-
|
|
647
|
-
|
|
739
|
+
membershipRowReads++;
|
|
740
|
+
const row = current[elementId];
|
|
741
|
+
if (!row) {
|
|
742
|
+
missingIds.add(elementId);
|
|
648
743
|
return;
|
|
744
|
+
}
|
|
745
|
+
const parentId = getProjectedParentId(row);
|
|
746
|
+
parentIds.set(elementId, parentId);
|
|
747
|
+
if (!parentId) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
649
750
|
const children = childrenByParent.get(parentId) ?? [];
|
|
650
751
|
children.push(elementId);
|
|
651
752
|
childrenByParent.set(parentId, children);
|
|
652
753
|
});
|
|
653
754
|
}
|
|
654
755
|
const removeMembership = (parentId, elementId) => {
|
|
655
|
-
if (!parentId)
|
|
756
|
+
if (!parentId) {
|
|
656
757
|
return;
|
|
758
|
+
}
|
|
657
759
|
const children = childrenByParent.get(parentId);
|
|
658
|
-
if (!children)
|
|
760
|
+
if (!children) {
|
|
659
761
|
return;
|
|
762
|
+
}
|
|
660
763
|
const index = children.indexOf(elementId);
|
|
661
764
|
if (index >= 0) {
|
|
662
765
|
children.splice(index, 1);
|
|
@@ -664,10 +767,17 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
664
767
|
}
|
|
665
768
|
};
|
|
666
769
|
const insertMembership = (parentId, elementId, requestedIndex) => {
|
|
667
|
-
if (!parentId)
|
|
770
|
+
if (!parentId) {
|
|
668
771
|
return;
|
|
772
|
+
}
|
|
669
773
|
emitDiagnosticCounter('ui-context-membership-add-scalar');
|
|
670
774
|
const children = childrenByParent.get(parentId) ?? [];
|
|
775
|
+
if (tailAdditions) {
|
|
776
|
+
children.push(elementId);
|
|
777
|
+
childrenByParent.set(parentId, children);
|
|
778
|
+
dirtyParentIds.add(parentId);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
671
781
|
const existingIndex = children.indexOf(elementId);
|
|
672
782
|
if (existingIndex >= 0) {
|
|
673
783
|
children.splice(existingIndex, 1);
|
|
@@ -692,6 +802,13 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
692
802
|
entriesByParent.set(parentId, parentEntries);
|
|
693
803
|
});
|
|
694
804
|
entriesByParent.forEach((parentEntries, parentId) => {
|
|
805
|
+
if (tailAdditions) {
|
|
806
|
+
const children = childrenByParent.get(parentId) ?? [];
|
|
807
|
+
parentEntries.forEach(({ elementId }) => children.push(elementId));
|
|
808
|
+
childrenByParent.set(parentId, children);
|
|
809
|
+
dirtyParentIds.add(parentId);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
695
812
|
const insertedIds = new Set(parentEntries.map(({ elementId }) => elementId));
|
|
696
813
|
const retainedChildren = (childrenByParent.get(parentId) ?? []).filter((childId) => !insertedIds.has(childId));
|
|
697
814
|
const insertionByIndex = new Map(parentEntries.map(({ elementId, index }) => [index, elementId]));
|
|
@@ -724,8 +841,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
724
841
|
});
|
|
725
842
|
removedIdsByParent.forEach((removedIds, parentId) => {
|
|
726
843
|
const children = childrenByParent.get(parentId);
|
|
727
|
-
if (!children)
|
|
844
|
+
if (!children) {
|
|
728
845
|
return;
|
|
846
|
+
}
|
|
729
847
|
const retainedChildren = children.filter((childId) => !removedIds.has(childId));
|
|
730
848
|
if (retainedChildren.length !== children.length) {
|
|
731
849
|
childrenByParent.set(parentId, retainedChildren);
|
|
@@ -735,8 +853,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
735
853
|
};
|
|
736
854
|
const setProjectedValue = (elementId, key, value) => {
|
|
737
855
|
const currentData = next[elementId];
|
|
738
|
-
if (!currentData)
|
|
856
|
+
if (!currentData) {
|
|
739
857
|
return;
|
|
858
|
+
}
|
|
740
859
|
if (!isProjectedHierarchyKey(key) &&
|
|
741
860
|
!shouldUpdateElementDataMapForComputedKey(key)) {
|
|
742
861
|
return;
|
|
@@ -774,8 +893,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
774
893
|
const { data, parentId, index } = change;
|
|
775
894
|
const elementData = cloneProjectedElementData(data);
|
|
776
895
|
const elementId = typeof elementData?.id === 'string' ? elementData.id : undefined;
|
|
777
|
-
if (!elementData || !elementId)
|
|
896
|
+
if (!elementData || !elementId) {
|
|
778
897
|
return;
|
|
898
|
+
}
|
|
779
899
|
const projectedParentId = typeof parentId === 'string'
|
|
780
900
|
? parentId
|
|
781
901
|
: getProjectedParentId(elementData);
|
|
@@ -798,6 +918,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
798
918
|
});
|
|
799
919
|
}
|
|
800
920
|
else {
|
|
921
|
+
if (tailAdditions) {
|
|
922
|
+
flushScalarAdditionMemberships();
|
|
923
|
+
}
|
|
801
924
|
insertMembership(projectedParentId, elementId, index);
|
|
802
925
|
}
|
|
803
926
|
break;
|
|
@@ -808,8 +931,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
808
931
|
entries.forEach(({ data, parentId, index }) => {
|
|
809
932
|
const elementData = cloneProjectedElementData(data);
|
|
810
933
|
const elementId = typeof elementData?.id === 'string' ? elementData.id : undefined;
|
|
811
|
-
if (!elementData || !elementId)
|
|
934
|
+
if (!elementData || !elementId) {
|
|
812
935
|
return;
|
|
936
|
+
}
|
|
813
937
|
elementData.parentId = parentId;
|
|
814
938
|
ensureMutableMap()[elementId] = elementData;
|
|
815
939
|
changedElementIds.add(elementId);
|
|
@@ -856,8 +980,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
856
980
|
});
|
|
857
981
|
affectedParentIds.forEach((parentId) => {
|
|
858
982
|
const children = childrenByParent.get(parentId);
|
|
859
|
-
if (!children)
|
|
983
|
+
if (!children) {
|
|
860
984
|
return;
|
|
985
|
+
}
|
|
861
986
|
const retainedChildren = children.filter((childId) => !movedIds.has(childId));
|
|
862
987
|
if (retainedChildren.length !== children.length) {
|
|
863
988
|
childrenByParent.set(parentId, retainedChildren);
|
|
@@ -904,8 +1029,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
904
1029
|
}
|
|
905
1030
|
subtree.removed.forEach(({ data, elementId }) => {
|
|
906
1031
|
const elementData = cloneProjectedElementData(data);
|
|
907
|
-
if (!elementData)
|
|
1032
|
+
if (!elementData) {
|
|
908
1033
|
return;
|
|
1034
|
+
}
|
|
909
1035
|
ensureMutableMap()[elementId] = elementData;
|
|
910
1036
|
changedElementIds.add(elementId);
|
|
911
1037
|
if (Array.isArray(elementData.children)) {
|
|
@@ -926,6 +1052,20 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
926
1052
|
});
|
|
927
1053
|
break;
|
|
928
1054
|
}
|
|
1055
|
+
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_PROPERTY_BINDINGS: {
|
|
1056
|
+
const { id, changes: bindings } = change;
|
|
1057
|
+
const current = next[id];
|
|
1058
|
+
if (!current) {
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
const props = { ...(current.props ?? {}) };
|
|
1062
|
+
bindings.forEach(({ key, after }) => {
|
|
1063
|
+
props[key] = after;
|
|
1064
|
+
});
|
|
1065
|
+
ensureMutableMap()[id] = { ...current, props };
|
|
1066
|
+
changedElementIds.add(id);
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
929
1069
|
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_DATA: {
|
|
930
1070
|
const { id, changes: updates } = change;
|
|
931
1071
|
updates.forEach(({ key, after }) => {
|
|
@@ -957,8 +1097,9 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
957
1097
|
flushScalarAdditionMemberships();
|
|
958
1098
|
dirtyParentIds.forEach((parentId) => {
|
|
959
1099
|
const parent = next[parentId];
|
|
960
|
-
if (!parent)
|
|
1100
|
+
if (!parent) {
|
|
961
1101
|
return;
|
|
1102
|
+
}
|
|
962
1103
|
ensureMutableMap()[parentId] = {
|
|
963
1104
|
...parent,
|
|
964
1105
|
children: [...(childrenByParent.get(parentId) ?? [])]
|
|
@@ -966,41 +1107,145 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
966
1107
|
changedElementIds.add(parentId);
|
|
967
1108
|
});
|
|
968
1109
|
let nextFlattenedIds = currentFlattenedIds;
|
|
1110
|
+
let completeHierarchy = Boolean(reusable);
|
|
969
1111
|
if (updatesHierarchy) {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
rootParentIds.push(parentId);
|
|
1112
|
+
completeHierarchy = true;
|
|
1113
|
+
changedElementIds.forEach((elementId) => {
|
|
1114
|
+
membershipRowReads++;
|
|
1115
|
+
const row = next[elementId];
|
|
1116
|
+
if (row) {
|
|
1117
|
+
parentIds.set(elementId, getProjectedParentId(row));
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
parentIds.delete(elementId);
|
|
1121
|
+
subtreeSizes.delete(elementId);
|
|
1122
|
+
missingIds.add(elementId);
|
|
982
1123
|
}
|
|
983
1124
|
});
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1125
|
+
const hasProjectedRow = (elementId) => {
|
|
1126
|
+
if (parentIds.has(elementId)) {
|
|
1127
|
+
return true;
|
|
1128
|
+
}
|
|
1129
|
+
if (missingIds.has(elementId)) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
membershipRowReads++;
|
|
1133
|
+
const row = next[elementId];
|
|
1134
|
+
if (!row) {
|
|
1135
|
+
missingIds.add(elementId);
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
parentIds.set(elementId, getProjectedParentId(row));
|
|
1139
|
+
return true;
|
|
992
1140
|
};
|
|
993
|
-
|
|
994
|
-
;
|
|
995
|
-
|
|
996
|
-
|
|
1141
|
+
if (tailAdditions) {
|
|
1142
|
+
emitDiagnosticCounter('ui-context-flattened-identity-copy', currentFlattenedIds.length);
|
|
1143
|
+
nextFlattenedIds = currentFlattenedIds.concat(tailAdditions);
|
|
1144
|
+
for (const id of tailAdditions) {
|
|
1145
|
+
subtreeSizes.set(id, 1);
|
|
1146
|
+
let parent = parentIds.get(id);
|
|
1147
|
+
while (parent && parentIds.has(parent)) {
|
|
1148
|
+
subtreeSizes.set(parent, (subtreeSizes.get(parent) ?? 1) + 1);
|
|
1149
|
+
parent = parentIds.get(parent);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
const rootParentIds = [];
|
|
1155
|
+
const rootParentIdSet = new Set();
|
|
1156
|
+
const changedSubtrees = new Set();
|
|
1157
|
+
for (const id of dirtyParentIds) {
|
|
1158
|
+
let currentId = id;
|
|
1159
|
+
while (currentId && !changedSubtrees.has(currentId)) {
|
|
1160
|
+
changedSubtrees.add(currentId);
|
|
1161
|
+
currentId = parentIds.get(currentId);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
if (reusable) {
|
|
1165
|
+
for (const parent of childrenByParent.keys()) {
|
|
1166
|
+
if (!parentIds.has(parent)) {
|
|
1167
|
+
rootParentIds.push(parent);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
const currentFlattenedIdSet = new Set(currentFlattenedIds);
|
|
1173
|
+
const orderedCandidates = [
|
|
1174
|
+
...currentFlattenedIds,
|
|
1175
|
+
...[...changedElementIds].filter((id) => !currentFlattenedIdSet.has(id))
|
|
1176
|
+
];
|
|
1177
|
+
orderedCandidates.forEach((elementId) => {
|
|
1178
|
+
emitDiagnosticCounter('ui-context-hierarchy-root-candidate');
|
|
1179
|
+
if (!hasProjectedRow(elementId)) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
const parentId = parentIds.get(elementId);
|
|
1183
|
+
if (parentId &&
|
|
1184
|
+
!rootParentIdSet.has(parentId) &&
|
|
1185
|
+
!hasProjectedRow(parentId)) {
|
|
1186
|
+
rootParentIdSet.add(parentId);
|
|
1187
|
+
rootParentIds.push(parentId);
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
let oldPositions;
|
|
1192
|
+
const flattenedElementIds = [];
|
|
1193
|
+
const visited = new Set();
|
|
1194
|
+
let collectedCount = 0;
|
|
1195
|
+
const collectProjectedChildren = (elementId, parentId) => {
|
|
1196
|
+
if (!visited.has(elementId) &&
|
|
1197
|
+
reusable &&
|
|
1198
|
+
!changedSubtrees.has(elementId) &&
|
|
1199
|
+
subtreeSizes.has(elementId) &&
|
|
1200
|
+
parentIds.get(elementId) === parentId) {
|
|
1201
|
+
oldPositions ?? (oldPositions = new Map(currentFlattenedIds.map((id, index) => [id, index])));
|
|
1202
|
+
const start = oldPositions.get(elementId);
|
|
1203
|
+
const size = subtreeSizes.get(elementId) ?? 0;
|
|
1204
|
+
if (start !== undefined &&
|
|
1205
|
+
size > 0 &&
|
|
1206
|
+
start + size <= currentFlattenedIds.length) {
|
|
1207
|
+
visited.add(elementId);
|
|
1208
|
+
for (let index = start; index < start + size; index++) {
|
|
1209
|
+
flattenedElementIds.push(currentFlattenedIds[index]);
|
|
1210
|
+
}
|
|
1211
|
+
collectedCount += size;
|
|
1212
|
+
emitDiagnosticCounter('ui-context-flattened-subtree-copy', size);
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
emitDiagnosticCounter('ui-context-hierarchy-node-visit');
|
|
1217
|
+
if (visited.has(elementId) || !hasProjectedRow(elementId)) {
|
|
1218
|
+
completeHierarchy = false;
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (parentIds.get(elementId) !== parentId) {
|
|
1222
|
+
completeHierarchy = false;
|
|
1223
|
+
}
|
|
1224
|
+
visited.add(elementId);
|
|
1225
|
+
collectedCount++;
|
|
1226
|
+
const start = flattenedElementIds.length;
|
|
1227
|
+
flattenedElementIds.push(elementId);
|
|
1228
|
+
(childrenByParent.get(elementId) ?? []).forEach((childId) => collectProjectedChildren(childId, elementId));
|
|
1229
|
+
subtreeSizes.set(elementId, flattenedElementIds.length - start);
|
|
1230
|
+
};
|
|
1231
|
+
rootParentIds.forEach((parentId) => {
|
|
1232
|
+
;
|
|
1233
|
+
(childrenByParent.get(parentId) ?? []).forEach((childId) => collectProjectedChildren(childId, parentId));
|
|
1234
|
+
});
|
|
1235
|
+
if (collectedCount !== parentIds.size) {
|
|
1236
|
+
completeHierarchy = false;
|
|
1237
|
+
}
|
|
1238
|
+
nextFlattenedIds = flattenedElementIds;
|
|
1239
|
+
}
|
|
997
1240
|
emitDiagnosticCounter('ui-context-sync-flattened-ids');
|
|
998
|
-
nextFlattenedIds
|
|
1241
|
+
emitDiagnosticCounter('ui-context-flattened-identity-output', nextFlattenedIds.length);
|
|
999
1242
|
}
|
|
1243
|
+
emitDiagnosticCounter('ui-context-membership-row-read', membershipRowReads);
|
|
1244
|
+
let projected = current;
|
|
1000
1245
|
if (mapChanged) {
|
|
1001
1246
|
emitDiagnosticCounter('ui-context-sync-element-data-map-entry', changedElementIds.size);
|
|
1002
1247
|
const subject = uiContext.getSubject('elementDataMap');
|
|
1003
|
-
|
|
1248
|
+
projected = mutation.commit(nextFlattenedIds);
|
|
1004
1249
|
if (subject) {
|
|
1005
1250
|
subject.next(projected);
|
|
1006
1251
|
}
|
|
@@ -1011,6 +1256,21 @@ const projectUIContextSceneTreeBatch = (changes) => {
|
|
|
1011
1256
|
if (updatesHierarchy) {
|
|
1012
1257
|
uiContext.set('flattenedElementIds', nextFlattenedIds);
|
|
1013
1258
|
}
|
|
1259
|
+
const publishedFlattenedIds = uiContext.get('flattenedElementIds');
|
|
1260
|
+
if (completeHierarchy &&
|
|
1261
|
+
!lifetime.disposed &&
|
|
1262
|
+
uiContext.get('elementDataMap') === projected &&
|
|
1263
|
+
// The registry preserves the old array when the new order is value-equal.
|
|
1264
|
+
(publishedFlattenedIds === nextFlattenedIds ||
|
|
1265
|
+
publishedFlattenedIds === currentFlattenedIds)) {
|
|
1266
|
+
lifetime.hierarchy = {
|
|
1267
|
+
map: projected,
|
|
1268
|
+
flattenedIds: publishedFlattenedIds,
|
|
1269
|
+
parents: parentIds,
|
|
1270
|
+
children: childrenByParent,
|
|
1271
|
+
subtreeSizes
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1014
1274
|
});
|
|
1015
1275
|
};
|
|
1016
1276
|
const createPendingUIContextSync = () => ({
|
|
@@ -1039,7 +1299,7 @@ const flushPendingUIContextSync = (lifetime, core, deps) => {
|
|
|
1039
1299
|
resetPendingUIContextSync(lifetime);
|
|
1040
1300
|
measureBrowserDragPhase('ui-context:flush', () => {
|
|
1041
1301
|
emitDiagnosticCounter('ui-context-transaction-flush');
|
|
1042
|
-
projectUIContextSceneTreeBatch(pending.sceneTreeChanges);
|
|
1302
|
+
projectUIContextSceneTreeBatch(pending.sceneTreeChanges, lifetime);
|
|
1043
1303
|
if (pending.removedElementIds.size > 0 &&
|
|
1044
1304
|
syncSelectionOnElementRemovals(core, [...pending.removedElementIds])) {
|
|
1045
1305
|
pending.elementSelectionAndDerived = true;
|
|
@@ -1141,8 +1401,9 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1141
1401
|
const uiContextSyncLifetime = createUIContextSyncLifetime();
|
|
1142
1402
|
let disposed = false;
|
|
1143
1403
|
const dispose = () => {
|
|
1144
|
-
if (disposed)
|
|
1404
|
+
if (disposed) {
|
|
1145
1405
|
return;
|
|
1406
|
+
}
|
|
1146
1407
|
disposed = true;
|
|
1147
1408
|
const failures = [];
|
|
1148
1409
|
for (let index = registeredObserverNames.length - 1; index >= 0; index--) {
|
|
@@ -1173,6 +1434,7 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1173
1434
|
}
|
|
1174
1435
|
}
|
|
1175
1436
|
uiContextSyncLifetime.disposed = true;
|
|
1437
|
+
uiContextSyncLifetime.hierarchy = undefined;
|
|
1176
1438
|
resetPendingUIContextSync(uiContextSyncLifetime);
|
|
1177
1439
|
if (failures.length > 0) {
|
|
1178
1440
|
throw failures[0];
|
|
@@ -1212,30 +1474,6 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1212
1474
|
}
|
|
1213
1475
|
}
|
|
1214
1476
|
});
|
|
1215
|
-
const uiContextSceneTreeDataChannelObserver = defineDataChannelObserver({
|
|
1216
|
-
name: 'preset.uiContext.sceneTree',
|
|
1217
|
-
channel: SharedDataChannelNames.SCENE_TREE,
|
|
1218
|
-
onBatch: (changes) => {
|
|
1219
|
-
if (uiContextSyncLifetime.disposed) {
|
|
1220
|
-
return;
|
|
1221
|
-
}
|
|
1222
|
-
changes
|
|
1223
|
-
.filter((change) => !isLocalComputedSceneTreeChange(change))
|
|
1224
|
-
.forEach((change) => {
|
|
1225
|
-
handleUIContextSceneTreeChange(change, core, deps, uiContextSyncLifetime);
|
|
1226
|
-
});
|
|
1227
|
-
flushPendingUIContextSync(uiContextSyncLifetime, core, deps);
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
const renderSceneTreeDataChannelObserver = defineDataChannelObserver({
|
|
1231
|
-
name: 'preset.render.sceneTree',
|
|
1232
|
-
channel: SharedDataChannelNames.SCENE_TREE,
|
|
1233
|
-
onBatch: (changes) => {
|
|
1234
|
-
if (!disposed) {
|
|
1235
|
-
updateRenderSceneTreeBatch(changes.filter((change) => !isLocalComputedSceneTreeChange(change)));
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
});
|
|
1239
1477
|
const uiContextSelectionDataChannelObserver = defineDataChannelObserver({
|
|
1240
1478
|
name: 'preset.uiContext.selection',
|
|
1241
1479
|
channel: SharedDataChannelNames.SELECTION,
|
|
@@ -1255,28 +1493,40 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1255
1493
|
if (propertyProjectionEnabled) {
|
|
1256
1494
|
registerObserver(canonicalPropertyDataChannelObserver);
|
|
1257
1495
|
}
|
|
1258
|
-
|
|
1496
|
+
const localSceneChangesFromEvents = (events) => events.flatMap((event) => {
|
|
1497
|
+
if (event.type === EventTypes.SCENE_TREE_CHANGED) {
|
|
1498
|
+
const { projectionOwner, changes } = event
|
|
1499
|
+
.payload;
|
|
1500
|
+
return projectionOwner === deps.sceneTree.projectionOwner
|
|
1501
|
+
? changes.filter((change) => !isLocalComputedSceneTreeChange(change))
|
|
1502
|
+
: [];
|
|
1503
|
+
}
|
|
1504
|
+
const computedEvent = toLocalComputedProjectionEvent(event);
|
|
1505
|
+
if (!computedEvent) {
|
|
1506
|
+
return [];
|
|
1507
|
+
}
|
|
1508
|
+
const change = toLocalComputedSceneTreeChange(computedEvent);
|
|
1509
|
+
return change ? [change] : [];
|
|
1510
|
+
});
|
|
1511
|
+
if (renderSceneEnabled) {
|
|
1512
|
+
eventSubscriptions.push(subscribeToAppliedEventBatches((events) => {
|
|
1513
|
+
if (!disposed) {
|
|
1514
|
+
updateRenderSceneTreeBatch(localSceneChangesFromEvents(events));
|
|
1515
|
+
}
|
|
1516
|
+
}));
|
|
1517
|
+
cleanupReporter.report();
|
|
1518
|
+
}
|
|
1519
|
+
if (uiContextEnabled) {
|
|
1259
1520
|
eventSubscriptions.push(subscribeToEventBatches((events) => {
|
|
1260
1521
|
if (disposed) {
|
|
1261
1522
|
return;
|
|
1262
1523
|
}
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
return [];
|
|
1267
|
-
}
|
|
1268
|
-
const change = toLocalComputedSceneTreeChange(computedEvent);
|
|
1269
|
-
return change ? [change] : [];
|
|
1270
|
-
});
|
|
1271
|
-
if (renderSceneEnabled) {
|
|
1272
|
-
updateRenderSceneTreeBatch(localComputedChanges);
|
|
1273
|
-
}
|
|
1274
|
-
if (uiContextEnabled && localComputedChanges.length > 0) {
|
|
1275
|
-
localComputedChanges.forEach((change) => {
|
|
1276
|
-
handleUIContextSceneTreeChange(change, core, deps, uiContextSyncLifetime);
|
|
1277
|
-
});
|
|
1278
|
-
flushPendingUIContextSync(uiContextSyncLifetime, core, deps);
|
|
1524
|
+
const changes = localSceneChangesFromEvents(events);
|
|
1525
|
+
if (changes.length === 0) {
|
|
1526
|
+
return;
|
|
1279
1527
|
}
|
|
1528
|
+
changes.forEach((change) => handleUIContextSceneTreeChange(change, core, deps, uiContextSyncLifetime));
|
|
1529
|
+
flushPendingUIContextSync(uiContextSyncLifetime, core, deps);
|
|
1280
1530
|
}));
|
|
1281
1531
|
cleanupReporter.report();
|
|
1282
1532
|
}
|
|
@@ -1290,8 +1540,7 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1290
1540
|
eventSubscriptions.push(subscribeToFileLoadComplete(() => {
|
|
1291
1541
|
if (uiContextEnabled) {
|
|
1292
1542
|
resetPendingUIContextSync(uiContextSyncLifetime);
|
|
1293
|
-
|
|
1294
|
-
syncElementDataMap(deps);
|
|
1543
|
+
syncHierarchyUIContext(deps, uiContextSyncLifetime);
|
|
1295
1544
|
syncElementSelectionAndDerived(core, deps);
|
|
1296
1545
|
}
|
|
1297
1546
|
if (vectorEditingEnabled) {
|
|
@@ -1341,7 +1590,6 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1341
1590
|
cleanupReporter.report();
|
|
1342
1591
|
}
|
|
1343
1592
|
if (renderSceneEnabled) {
|
|
1344
|
-
registerObserver(renderSceneTreeDataChannelObserver);
|
|
1345
1593
|
renderSceneTreeStore.reload();
|
|
1346
1594
|
}
|
|
1347
1595
|
if (selectionEnabled) {
|
|
@@ -1349,7 +1597,6 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1349
1597
|
registerObserver(renderSelectionDataChannelObserver);
|
|
1350
1598
|
}
|
|
1351
1599
|
if (uiContextEnabled) {
|
|
1352
|
-
registerObserver(uiContextSceneTreeDataChannelObserver);
|
|
1353
1600
|
registerObserver(uiContextSelectionDataChannelObserver);
|
|
1354
1601
|
}
|
|
1355
1602
|
if (vectorEditingEnabled) {
|
|
@@ -1357,8 +1604,9 @@ export const registerDefaultDataChannelObservers = (core, deps, onCleanupReady,
|
|
|
1357
1604
|
}
|
|
1358
1605
|
}
|
|
1359
1606
|
catch (error) {
|
|
1360
|
-
if (!cleanupReporter.hasReported())
|
|
1607
|
+
if (!cleanupReporter.hasReported()) {
|
|
1361
1608
|
dispose();
|
|
1609
|
+
}
|
|
1362
1610
|
throw error;
|
|
1363
1611
|
}
|
|
1364
1612
|
return dispose;
|