@weasel-js/core 1.9.3 → 1.10.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 +1106 -0
- package/README.md +7 -5
- package/dist/WeaselProvider.js +5 -7
- package/dist/WeaselProvider.js.map +1 -1
- package/dist/affordances/composeAffordanceLayer.js +91 -93
- package/dist/affordances/composeAffordanceLayer.js.map +1 -1
- package/dist/affordances/cornerResize.js +27 -18
- package/dist/affordances/cornerResize.js.map +1 -1
- package/dist/affordances/hitAffordanceRegions.js +65 -104
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/affordances/rotationHandle.js +22 -21
- package/dist/affordances/rotationHandle.js.map +1 -1
- package/dist/animation/behaviors/coast.js +21 -0
- package/dist/animation/behaviors/coast.js.map +1 -0
- package/dist/animation/behaviors/coastByWrite.js +107 -0
- package/dist/animation/behaviors/coastByWrite.js.map +1 -0
- package/dist/animation/behaviors/coastOnTargets.js +94 -0
- package/dist/animation/behaviors/coastOnTargets.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +38 -88
- package/dist/animation/behaviors/momentum.js.map +1 -1
- package/dist/animation/clipTargets.js +12 -0
- package/dist/animation/clipTargets.js.map +1 -0
- package/dist/animation/index.js +15 -20
- package/dist/animation/poseHelpers.js +112 -33
- package/dist/animation/poseHelpers.js.map +1 -1
- package/dist/animation/poseTarget.js +115 -0
- package/dist/animation/poseTarget.js.map +1 -0
- package/dist/animation/reflow.js +113 -83
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/rewind.js +66 -0
- package/dist/animation/rewind.js.map +1 -0
- package/dist/animation/rig/bindRig.js +85 -53
- package/dist/animation/rig/bindRig.js.map +1 -1
- package/dist/animation/rig/rigNode.js +93 -0
- package/dist/animation/rig/rigNode.js.map +1 -0
- package/dist/animation/rig/rigSeat.js +26 -0
- package/dist/animation/rig/rigSeat.js.map +1 -0
- package/dist/animation/rig/skinBinding.js +56 -0
- package/dist/animation/rig/skinBinding.js.map +1 -0
- package/dist/animation/rig/useRig.js +31 -16
- package/dist/animation/rig/useRig.js.map +1 -1
- package/dist/animation/wrappers/animateLifecycle.js +32 -24
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
- package/dist/animation/wrappers/animateOnSetPose.js +31 -29
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
- package/dist/animation/wrappers/instantPose.js +13 -0
- package/dist/animation/wrappers/instantPose.js.map +1 -0
- package/dist/animation/writtenPoseTarget.js +33 -0
- package/dist/animation/writtenPoseTarget.js.map +1 -0
- package/dist/{autoPoseDescriptor-vCdt55xm.d.ts → autoPoseDescriptor-DHg5KqaJ.d.ts} +1 -1
- package/dist/barrel/canvas.js +31 -0
- package/dist/barrel/chrome.js +16 -0
- package/dist/barrel/input.js +18 -0
- package/dist/barrel/interactions.js +38 -0
- package/dist/barrel/paint.js +11 -0
- package/dist/barrel/paths.js +12 -0
- package/dist/barrel/renderer.js +14 -0
- package/dist/barrel/routing.js +57 -0
- package/dist/barrel/scene.js +37 -0
- package/dist/barrel/text.js +9 -0
- package/dist/barrel/viewport.js +42 -0
- package/dist/canvas/Canvas.js +280 -559
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +147 -167
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/CursorCoordsHud.js +53 -49
- package/dist/canvas/CursorCoordsHud.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +40 -51
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/ModalityHud.js.map +1 -1
- package/dist/canvas/NodeShape.js +55 -374
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/PickHud.js +50 -47
- package/dist/canvas/PickHud.js.map +1 -1
- package/dist/canvas/SceneCanvas/DevHuds.js +40 -0
- package/dist/canvas/SceneCanvas/DevHuds.js.map +1 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +126 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +27 -31
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +64 -0
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/coordTrace.js +46 -0
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +138 -85
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +74 -43
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/isDev.js +12 -0
- package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +31 -34
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
- package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
- package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
- package/dist/canvas/SceneCanvas/props.js +39 -0
- package/dist/canvas/SceneCanvas/props.js.map +1 -0
- package/dist/canvas/SceneCanvas/toolRegistry.js +23 -0
- package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +6 -1
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinTools.js +21 -0
- package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasCamera.js +38 -0
- package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +20 -0
- package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js +16 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasTools.js +67 -0
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +29 -29
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useHeldModifiers.js +20 -0
- package/dist/canvas/SceneCanvas/useHeldModifiers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useNodeAtPoint.js +26 -0
- package/dist/canvas/SceneCanvas/useNodeAtPoint.js.map +1 -0
- package/dist/canvas/SceneCanvas/useNodeKinds.js +26 -0
- package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +48 -48
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +47 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +66 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneChrome.js +59 -0
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js +23 -0
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +74 -78
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSlotLayers.js +37 -0
- package/dist/canvas/SceneCanvas/useSceneSlotLayers.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js +38 -0
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewLayerGate.js +20 -0
- package/dist/canvas/SceneCanvas/useViewLayerGate.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +9 -1
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -1
- package/dist/canvas/SceneCanvas/worldPointAt.js +9 -0
- package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +311 -969
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +42 -46
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/adapterDerivedPath.js +26 -0
- package/dist/canvas/adapterDerivedPath.js.map +1 -0
- package/dist/canvas/affordanceAt.js +11 -1
- package/dist/canvas/affordanceAt.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js +111 -0
- package/dist/canvas/buildSceneLayer.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +16 -19
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/canvasRenderer.js +67 -55
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/colorOverrides.js.map +1 -1
- package/dist/canvas/defaultDrawOne.js +12 -12
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/areaSelect.js +4 -4
- package/dist/canvas/deps/areaSelect.js.map +1 -1
- package/dist/canvas/deps/changes.js +13 -0
- package/dist/canvas/deps/changes.js.map +1 -0
- package/dist/canvas/deps/debug.js.map +1 -1
- package/dist/canvas/deps/editAnchors.js +38 -57
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/geometryProjection.js.map +1 -1
- package/dist/canvas/deps/hitTestArea.js +31 -26
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +130 -91
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/lassoSelect.js +5 -5
- package/dist/canvas/deps/lassoSelect.js.map +1 -1
- package/dist/canvas/deps/poseDescriptor.js +1 -1
- package/dist/canvas/deps/poseDescriptor.js.map +1 -1
- package/dist/canvas/deps/resizePolicy.js.map +1 -1
- package/dist/canvas/deps/slice.js +26 -26
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/deps/textEdit.js +6 -5
- package/dist/canvas/deps/textEdit.js.map +1 -1
- package/dist/canvas/deps/view.js.map +1 -1
- package/dist/canvas/derivedPath.js +47 -22
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/drawEnvelope.js +8 -4
- package/dist/canvas/drawEnvelope.js.map +1 -1
- package/dist/canvas/getNodeAtPoint.js +4 -8
- package/dist/canvas/getNodeAtPoint.js.map +1 -1
- package/dist/canvas/hud.module.js +1 -1
- package/dist/canvas/hud.module.js.map +1 -1
- package/dist/canvas/insertPreviewExtent.js.map +1 -1
- package/dist/canvas/kitRequirements.js +2 -2
- package/dist/canvas/kitRequirements.js.map +1 -1
- package/dist/canvas/layerOrder.js +13 -6
- package/dist/canvas/layerOrder.js.map +1 -1
- package/dist/canvas/layerSlots.js +6 -1
- package/dist/canvas/layerSlots.js.map +1 -1
- package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/imagePainter.js +87 -0
- package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/memo.js +9 -0
- package/dist/canvas/nodeShapes/memo.js.map +1 -0
- package/dist/canvas/nodeShapes/nodePaint.js +68 -0
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
- package/dist/canvas/nodeShapes/pathPainter.js +39 -0
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/poseBox.js +20 -0
- package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/shapePainter.js +72 -0
- package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/textPainter.js +55 -0
- package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/paintCull.js +11 -14
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/{features/cursor → canvas}/paintedCursorLayer.js +2 -2
- package/dist/canvas/paintedCursorLayer.js.map +1 -0
- package/dist/canvas/pickWalk.js +59 -68
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/planeClips.js +18 -19
- package/dist/canvas/planeClips.js.map +1 -1
- package/dist/canvas/poseCascade.js +41 -0
- package/dist/canvas/poseCascade.js.map +1 -0
- package/dist/canvas/poseRotation.js +9 -23
- package/dist/canvas/poseRotation.js.map +1 -1
- package/dist/canvas/rasterReadback.js +22 -0
- package/dist/canvas/rasterReadback.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +11 -11
- package/dist/canvas/renderDebugSnapshot.js.map +1 -1
- package/dist/canvas/renderNeeds.js +3 -3
- package/dist/canvas/renderNeeds.js.map +1 -1
- package/dist/canvas/renderSceneToPixels.js +64 -81
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +68 -214
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +112 -0
- package/dist/canvas/sceneClipboard.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +4 -4
- package/dist/canvas/sceneLayerPaint.js.map +1 -1
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +39 -39
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/slopsDebugLayer.js +4 -4
- package/dist/canvas/slopsDebugLayer.js.map +1 -1
- package/dist/canvas/surface.module.js +6 -0
- package/dist/canvas/surface.module.js.map +1 -0
- package/dist/canvas/surfaceBox.js +16 -0
- package/dist/canvas/surfaceBox.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +26 -6
- package/dist/canvas/useCanvasRenderer.js.map +1 -1
- package/dist/canvas/useCanvasSurface.js +31 -0
- package/dist/canvas/useCanvasSurface.js.map +1 -0
- package/dist/canvas/useCanvasView.js +67 -0
- package/dist/canvas/useCanvasView.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +39 -31
- package/dist/canvas/useFrameLoop.js.map +1 -1
- package/dist/canvas/useHostAnchor.js +35 -33
- package/dist/canvas/useHostAnchor.js.map +1 -1
- package/dist/canvas/useLateContentRedraw.js +8 -8
- package/dist/canvas/useLateContentRedraw.js.map +1 -1
- package/dist/canvas/useSceneLayerList.js +11 -0
- package/dist/canvas/useSceneLayerList.js.map +1 -0
- package/dist/canvas/useSurfaceInput.js +42 -0
- package/dist/canvas/useSurfaceInput.js.map +1 -0
- package/dist/canvas/useToolCursor.js +29 -0
- package/dist/canvas/useToolCursor.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +46 -85
- package/dist/canvas/useViewHelpers.js.map +1 -1
- package/dist/canvas/viewInputs.js.map +1 -1
- package/dist/canvas/viewRegistry.js +25 -27
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/canvas/watchElementMove.js +43 -0
- package/dist/canvas/watchElementMove.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -1
- package/dist/clipboard.d.ts +16 -19
- package/dist/{types-B_9g6hMM.d.ts → clone-2a5hVbBd.d.ts} +123 -74
- package/dist/clone.d.ts +4 -7
- package/dist/clone.js +0 -2
- package/dist/core/device/index.js +5 -4
- package/dist/core/device/targets.js.map +1 -1
- package/dist/core/device/useDeviceProfile.js +38 -44
- package/dist/core/device/useDeviceProfile.js.map +1 -1
- package/dist/core/device/watchDevicePixelRatio.js +17 -0
- package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
- package/dist/{interactions/actions/resize → core/geometry}/autoPoseDescriptor.js +8 -7
- package/dist/core/geometry/autoPoseDescriptor.js.map +1 -0
- package/dist/core/geometry/pathPoseDescriptor.js +88 -0
- package/dist/core/geometry/pathPoseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +68 -19
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/regionHit.js +31 -34
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/geometry/targetFrame.js +94 -0
- package/dist/core/geometry/targetFrame.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +30 -29
- package/dist/core/geometry/unionBounds.js.map +1 -1
- package/dist/core/isPlainObject.js +2 -11
- package/dist/core/layers/backgroundFill.js +31 -0
- package/dist/core/layers/backgroundFill.js.map +1 -0
- package/dist/{features/groups → core/layers}/children.js +1 -1
- package/dist/core/layers/children.js.map +1 -0
- package/dist/core/layers/gateLayer.js +13 -0
- package/dist/core/layers/gateLayer.js.map +1 -0
- package/dist/core/layers/layerGroup.js +40 -0
- package/dist/core/layers/layerGroup.js.map +1 -0
- package/dist/core/layers/render.js +50 -76
- package/dist/core/layers/render.js.map +1 -1
- package/dist/core/ops/arrange.js +1 -0
- package/dist/core/ops/arrange.js.map +1 -1
- package/dist/core/ops/create.js +10 -5
- package/dist/core/ops/create.js.map +1 -1
- package/dist/core/ops/createHistory.js +9 -9
- package/dist/core/ops/createHistory.js.map +1 -1
- package/dist/core/ops/delete.js +12 -24
- package/dist/core/ops/delete.js.map +1 -1
- package/dist/core/ops/reorder/index.js +43 -40
- package/dist/core/ops/reorder/index.js.map +1 -1
- package/dist/core/ops/reorder/setChildOrder.js +34 -0
- package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
- package/dist/core/paint/meshKind.js +16 -0
- package/dist/core/paint/meshKind.js.map +1 -0
- package/dist/{features/meshPaint/lazyKind.js → core/paint/meshKindLazy.js} +282 -105
- package/dist/core/paint/meshKindLazy.js.map +1 -0
- package/dist/core/paint/paintKindEntry.js +8 -0
- package/dist/core/paint/paintKindEntry.js.map +1 -0
- package/dist/core/paint/paintKinds.js +144 -0
- package/dist/core/paint/paintKinds.js.map +1 -0
- package/dist/core/paint/registerMesh.js +7 -0
- package/dist/core/paint/registerMesh.js.map +1 -0
- package/dist/core/scene/NodeProperties.js.map +1 -1
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/appliedLog.js +37 -0
- package/dist/core/scene/appliedLog.js.map +1 -0
- package/dist/core/scene/arrivalWindow.js +102 -0
- package/dist/core/scene/arrivalWindow.js.map +1 -0
- package/dist/core/scene/boundOps.js +40 -0
- package/dist/core/scene/boundOps.js.map +1 -0
- package/dist/core/scene/composeFrame.js +9 -6
- package/dist/core/scene/composeFrame.js.map +1 -1
- package/dist/{features/groups → core/scene}/composePose.js +18 -18
- package/dist/core/scene/composePose.js.map +1 -0
- package/dist/core/scene/depMemo.js +31 -6
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/derivedPath.js +19 -20
- package/dist/core/scene/derivedPath.js.map +1 -1
- package/dist/core/scene/editMode.js +26 -0
- package/dist/core/scene/editMode.js.map +1 -0
- package/dist/core/scene/effectivePose.js +38 -39
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +98 -0
- package/dist/core/scene/fieldEdits.js.map +1 -0
- package/dist/core/scene/historyFacade.js +130 -0
- package/dist/core/scene/historyFacade.js.map +1 -0
- package/dist/core/scene/historyForm.js +6 -0
- package/dist/core/scene/historyForm.js.map +1 -0
- package/dist/core/scene/kitOps.js +185 -0
- package/dist/core/scene/kitOps.js.map +1 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layerStack.js +131 -0
- package/dist/core/scene/layerStack.js.map +1 -0
- package/dist/core/scene/layoutPass.js +58 -59
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/lockGuard.js +37 -0
- package/dist/core/scene/lockGuard.js.map +1 -0
- package/dist/{features/groups → core/scene}/nestedHit.js +3 -3
- package/dist/core/scene/nestedHit.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +10 -11
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +45 -19
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/nodeStore.js +127 -0
- package/dist/core/scene/nodeStore.js.map +1 -0
- package/dist/core/scene/notifier.js +37 -0
- package/dist/core/scene/notifier.js.map +1 -0
- package/dist/core/scene/opTable.js +50 -0
- package/dist/core/scene/opTable.js.map +1 -0
- package/dist/core/scene/outerOps.js +66 -0
- package/dist/core/scene/outerOps.js.map +1 -0
- package/dist/core/scene/poseFeed.js +38 -38
- package/dist/core/scene/poseFeed.js.map +1 -1
- package/dist/core/scene/poseHold.js +39 -0
- package/dist/core/scene/poseHold.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +44 -40
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/poseSnapshot.js.map +1 -1
- package/dist/core/scene/reconcileSpecs.js +3 -2
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/recorder.js +86 -0
- package/dist/core/scene/recorder.js.map +1 -0
- package/dist/core/scene/renderOrder.js +84 -0
- package/dist/core/scene/renderOrder.js.map +1 -0
- package/dist/core/scene/scene.js +80 -1266
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneEdits.js +58 -0
- package/dist/core/scene/sceneEdits.js.map +1 -0
- package/dist/core/scene/sceneMutators.js +49 -0
- package/dist/core/scene/sceneMutators.js.map +1 -0
- package/dist/core/scene/scenePoseAdapter.js +16 -0
- package/dist/core/scene/scenePoseAdapter.js.map +1 -0
- package/dist/core/scene/sceneRecording.js +90 -0
- package/dist/core/scene/sceneRecording.js.map +1 -0
- package/dist/core/scene/sceneSelection.js +28 -0
- package/dist/core/scene/sceneSelection.js.map +1 -0
- package/dist/core/scene/sceneState.js +49 -0
- package/dist/core/scene/sceneState.js.map +1 -0
- package/dist/core/scene/serialization.js +71 -0
- package/dist/core/scene/serialization.js.map +1 -0
- package/dist/core/scene/staleReplay.js +51 -0
- package/dist/core/scene/staleReplay.js.map +1 -0
- package/dist/core/scene/statedFields.js +9 -0
- package/dist/core/scene/statedFields.js.map +1 -0
- package/dist/core/scene/treeEdits.js +127 -0
- package/dist/core/scene/treeEdits.js.map +1 -0
- package/dist/core/scene/treeOrder.js +13 -0
- package/dist/core/scene/treeOrder.js.map +1 -0
- package/dist/core/scene/treeReads.js +26 -0
- package/dist/core/scene/treeReads.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/{features/groups → core/scene}/unionOfChildren.js +3 -3
- package/dist/core/scene/unionOfChildren.js.map +1 -0
- package/dist/core/scene/unitScopes.js +13 -0
- package/dist/core/scene/unitScopes.js.map +1 -0
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/core/selection/readOnlySelection.js +32 -0
- package/dist/core/selection/readOnlySelection.js.map +1 -0
- package/dist/core/selection/usePublishSceneSelection.js +26 -0
- package/dist/core/selection/usePublishSceneSelection.js.map +1 -0
- package/dist/core/selection/useSelection.js +34 -25
- package/dist/core/selection/useSelection.js.map +1 -1
- package/dist/core/shapeKinds.js.map +1 -1
- package/dist/core/stylus/stylus.js.map +1 -1
- package/dist/core/stylus/usePointerStylus.js.map +1 -1
- package/dist/core/usePaintKinds.js +1 -1
- package/dist/core/usePaintKinds.js.map +1 -1
- package/dist/core/viewport/clientToWorld.js.map +1 -1
- package/dist/core/viewport/fitViewToBounds.js.map +1 -1
- package/dist/core/viewport/parallax.js.map +1 -1
- package/dist/core/viewport/screenSlop.js +11 -11
- package/dist/core/viewport/screenSlop.js.map +1 -1
- package/dist/core/viewport/useCanvasSize.js.map +1 -1
- package/dist/core/viewport/useDecayLoop.js +8 -8
- package/dist/core/viewport/useDecayLoop.js.map +1 -1
- package/dist/core/viewport/useNodeOverlayFrame.js +84 -0
- package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +102 -43
- package/dist/core/viewport/useViewAnimation.js.map +1 -1
- package/dist/core/viewport/view.js +9 -9
- package/dist/core/viewport/view.js.map +1 -1
- package/dist/core/viewport/wheelHandler.js.map +1 -1
- package/dist/core/viewport/zoomBounds.js +10 -8
- package/dist/core/viewport/zoomBounds.js.map +1 -1
- package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-BEshc4z3.d.ts} +11 -24
- package/dist/debug/createDebugOverlayLayer.js +97 -97
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/createDebugSink.js.map +1 -1
- package/dist/debug/flag.js +2 -41
- package/dist/debug/frameStats.js.map +1 -1
- package/dist/debug/useDebugSink.js +52 -0
- package/dist/debug/useDebugSink.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -1
- package/dist/features/chrome-caps/conditions.js.map +1 -1
- package/dist/features/chrome-caps/defaults.js.map +1 -1
- package/dist/features/chrome-caps/resolve.js.map +1 -1
- package/dist/features/chrome-caps/useChromeCaps.js +54 -0
- package/dist/features/chrome-caps/useChromeCaps.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +22 -17
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +28 -19
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/ingestion/imageHandler.js +21 -24
- package/dist/features/ingestion/imageHandler.js.map +1 -1
- package/dist/features/ingestion/openFilePicker.js.map +1 -1
- package/dist/features/ingestion/placement.js +16 -0
- package/dist/features/ingestion/placement.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +7 -7
- package/dist/features/ingestion/svgHandler.js +5 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -1
- package/dist/features/ingestion/textHandler.js +28 -0
- package/dist/features/ingestion/textHandler.js.map +1 -0
- package/dist/features/ingestion/useCanvasIngestion.js +48 -0
- package/dist/features/ingestion/useCanvasIngestion.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +22 -14
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
- package/dist/features/longPress/longPressFeedback.js.map +1 -1
- package/dist/features/modes/modeLayers.js +7 -7
- package/dist/features/modes/modeLayers.js.map +1 -1
- package/dist/features/paths/editablePath.js +47 -0
- package/dist/features/paths/editablePath.js.map +1 -0
- package/dist/features/paths/index.js +9 -14
- package/dist/features/paths/pathEditState.js +41 -0
- package/dist/features/paths/pathEditState.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +36 -38
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -1
- package/dist/features/paths/pathLayer.js +3 -2
- package/dist/features/paths/pathLayer.js.map +1 -1
- package/dist/features/paths/penPreviewLayer.js +86 -88
- package/dist/features/paths/penPreviewLayer.js.map +1 -1
- package/dist/features/paths/usePathEdit.js +34 -0
- package/dist/features/paths/usePathEdit.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +44 -52
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/selection/overlay.js +171 -179
- package/dist/features/selection/overlay.js.map +1 -1
- package/dist/features/text/index.js +6 -0
- package/dist/features/text/textLayer.js +1 -1
- package/dist/features/text/textLayer.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +100 -93
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/viewports/viewportLayer.js +25 -36
- package/dist/features/viewports/viewportLayer.js.map +1 -1
- package/dist/index.d.ts +8473 -9141
- package/dist/index.js +269 -307
- package/dist/input/keyState.js +38 -39
- package/dist/input/keyState.js.map +1 -1
- package/dist/input/useKeyModifiers.js +11 -0
- package/dist/input/useKeyModifiers.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -1
- package/dist/interactions/actions/{defaults/align.js → align/action.js} +18 -20
- package/dist/interactions/actions/align/action.js.map +1 -0
- package/dist/interactions/actions/align/align.js +20 -20
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/action.js +65 -0
- package/dist/interactions/actions/booleans/action.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +69 -78
- package/dist/interactions/actions/booleans/booleans.js.map +1 -1
- package/dist/interactions/actions/booleans/operands.js +40 -0
- package/dist/interactions/actions/booleans/operands.js.map +1 -0
- package/dist/interactions/actions/booleans/pieces.js +45 -0
- package/dist/interactions/actions/booleans/pieces.js.map +1 -0
- package/dist/interactions/actions/booleans/placement.js +24 -0
- package/dist/interactions/actions/booleans/placement.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +11 -9
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -1
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -1
- package/dist/interactions/actions/{defaults/clipboard.js → clipboard/action.js} +31 -15
- package/dist/interactions/actions/clipboard/action.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +44 -42
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
- package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
- package/dist/interactions/actions/clone/action.js +98 -0
- package/dist/interactions/actions/clone/action.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors.js +52 -0
- package/dist/interactions/actions/clone/behaviors.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +7 -32
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +60 -84
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/areaSelect.js +35 -38
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/copySubtree.js +40 -0
- package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +13 -53
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +40 -50
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +24 -1
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -1
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +39 -1
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +44 -38
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +11 -12
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +40 -69
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
- package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/reorder.js +2 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/setFill.js +14 -8
- package/dist/interactions/actions/defaults/setFill.js.map +1 -1
- package/dist/interactions/actions/defaults/setFillOpacity.js +7 -4
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -1
- package/dist/interactions/actions/defaults/setStroke.js +12 -12
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
- package/dist/interactions/actions/defaults/sliceOps.js +8 -10
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -1
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
- package/dist/interactions/actions/distribute/action.js +66 -0
- package/dist/interactions/actions/distribute/action.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +11 -11
- package/dist/interactions/actions/distribute/distribute.js.map +1 -1
- package/dist/interactions/actions/{defaults/editAnchors.js → edit-anchors/action.js} +7 -9
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +30 -27
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +124 -0
- package/dist/interactions/actions/flip/action.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +30 -17
- package/dist/interactions/actions/flip/helpers.js.map +1 -1
- package/dist/interactions/actions/gestureFrames.js +18 -0
- package/dist/interactions/actions/gestureFrames.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +47 -20
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
- package/dist/interactions/actions/hitSelection.js +8 -0
- package/dist/interactions/actions/hitSelection.js.map +1 -0
- package/dist/interactions/actions/insert/action.js +72 -0
- package/dist/interactions/actions/insert/action.js.map +1 -0
- package/dist/interactions/actions/insert/commit.js +28 -0
- package/dist/interactions/actions/insert/commit.js.map +1 -0
- package/dist/interactions/actions/insert/extras.js +65 -0
- package/dist/interactions/actions/insert/extras.js.map +1 -0
- package/dist/interactions/actions/insert/frame.js +48 -0
- package/dist/interactions/actions/insert/frame.js.map +1 -0
- package/dist/interactions/actions/insert/geometry.js +35 -0
- package/dist/interactions/actions/insert/geometry.js.map +1 -0
- package/dist/interactions/actions/insert/rotateAction.js +21 -0
- package/dist/interactions/actions/insert/rotateAction.js.map +1 -0
- package/dist/interactions/actions/insert/session.js +59 -0
- package/dist/interactions/actions/insert/session.js.map +1 -0
- package/dist/interactions/actions/insert/shape.js +34 -0
- package/dist/interactions/actions/insert/shape.js.map +1 -0
- package/dist/interactions/actions/lasso-select/action.js +143 -0
- package/dist/interactions/actions/lasso-select/action.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
- package/dist/interactions/actions/move/action.js +87 -0
- package/dist/interactions/actions/move/action.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/layoutDrop.js +51 -0
- package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js +15 -0
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +39 -27
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/capture.js +99 -0
- package/dist/interactions/actions/move/capture.js.map +1 -0
- package/dist/interactions/actions/move/commit/index.js +41 -0
- package/dist/interactions/actions/move/commit/index.js.map +1 -0
- package/dist/interactions/actions/move/commit/layoutDrop.js +44 -0
- package/dist/interactions/actions/move/commit/layoutDrop.js.map +1 -0
- package/dist/interactions/actions/move/commit/layoutRelease.js +100 -0
- package/dist/interactions/actions/move/commit/layoutRelease.js.map +1 -0
- package/dist/interactions/actions/move/commit/rebase.js +18 -0
- package/dist/interactions/actions/move/commit/rebase.js.map +1 -0
- package/dist/interactions/actions/move/commit/reparent.js +65 -0
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -0
- package/dist/interactions/actions/move/delta.js +51 -0
- package/dist/interactions/actions/move/delta.js.map +1 -0
- package/dist/interactions/actions/move/frame.js +59 -0
- package/dist/interactions/actions/move/frame.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +22 -30
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
- package/dist/interactions/actions/move/landedDescendants.js +33 -0
- package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
- package/dist/interactions/actions/move/layout/container.js +94 -0
- package/dist/interactions/actions/move/layout/container.js.map +1 -0
- package/dist/interactions/actions/move/layout/dragged.js +58 -0
- package/dist/interactions/actions/move/layout/dragged.js.map +1 -0
- package/dist/interactions/actions/move/layout/dropPass.js +122 -0
- package/dist/interactions/actions/move/layout/dropPass.js.map +1 -0
- package/dist/interactions/actions/move/layout/exits.js +38 -0
- package/dist/interactions/actions/move/layout/exits.js.map +1 -0
- package/dist/interactions/actions/move/layout/glide.js +48 -0
- package/dist/interactions/actions/move/layout/glide.js.map +1 -0
- package/dist/interactions/actions/move/session.js +63 -0
- package/dist/interactions/actions/move/session.js.map +1 -0
- package/dist/interactions/actions/move/translate.js +61 -0
- package/dist/interactions/actions/move/translate.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +16 -63
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlinesAction.js +51 -0
- package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -0
- package/dist/interactions/actions/outlines/outlineStroke.js +72 -0
- package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -0
- package/dist/interactions/actions/outlines/outlineStrokeAction.js +37 -0
- package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -0
- package/dist/interactions/actions/outlines/replaceWithPaths.js +54 -0
- package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -0
- package/dist/interactions/actions/outlines/strokeRegion.js +27 -0
- package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -0
- package/dist/interactions/actions/planeInput.js.map +1 -1
- package/dist/interactions/actions/pointerState.js +12 -0
- package/dist/interactions/actions/pointerState.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +16 -4
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
- package/dist/interactions/actions/poseFrame.js +25 -20
- package/dist/interactions/actions/poseFrame.js.map +1 -1
- package/dist/interactions/actions/resize/action.js +55 -0
- package/dist/interactions/actions/resize/action.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -1
- package/dist/interactions/actions/resize/boxFrame.js +16 -0
- package/dist/interactions/actions/resize/boxFrame.js.map +1 -0
- package/dist/interactions/actions/resize/capture.js +85 -0
- package/dist/interactions/actions/resize/capture.js.map +1 -0
- package/dist/interactions/actions/resize/commit.js +69 -0
- package/dist/interactions/actions/resize/commit.js.map +1 -0
- package/dist/interactions/actions/resize/frame.js +74 -0
- package/dist/interactions/actions/resize/frame.js.map +1 -0
- package/dist/interactions/actions/resize/pointSnap.js +111 -0
- package/dist/interactions/actions/resize/pointSnap.js.map +1 -0
- package/dist/interactions/actions/resize/ruleBounds.js +9 -0
- package/dist/interactions/actions/resize/ruleBounds.js.map +1 -0
- package/dist/interactions/actions/resize/session.js +49 -0
- package/dist/interactions/actions/resize/session.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -1
- package/dist/interactions/actions/resolvePreviews.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +56 -0
- package/dist/interactions/actions/rotate/action.js.map +1 -0
- package/dist/interactions/actions/rotate/behaviors/index.js +7 -0
- package/dist/interactions/actions/rotate/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/rotate/behaviors/snapRotation.js +12 -0
- package/dist/interactions/actions/rotate/behaviors/snapRotation.js.map +1 -0
- package/dist/interactions/actions/rotate/commit.js +40 -0
- package/dist/interactions/actions/rotate/commit.js.map +1 -0
- package/dist/interactions/actions/rotate/frame.js +65 -0
- package/dist/interactions/actions/rotate/frame.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +12 -12
- package/dist/interactions/actions/rotate/handle.js.map +1 -1
- package/dist/interactions/actions/rotate/session.js +92 -0
- package/dist/interactions/actions/rotate/session.js.map +1 -0
- package/dist/interactions/actions/selectionSubtree.js +69 -0
- package/dist/interactions/actions/selectionSubtree.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -1
- package/dist/interactions/actions/useStandardActions.js +87 -78
- package/dist/interactions/actions/useStandardActions.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
- package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +62 -41
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
- package/dist/interactions/gestures/shared/originProjection.js +1 -1
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -1
- package/dist/interactions/gestures/shared/screenTolerance.js +8 -2
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
- package/dist/interactions/gestures/shared/snap.js.map +1 -1
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
- package/dist/layout/arrivals.js +20 -23
- package/dist/layout/arrivals.js.map +1 -1
- package/dist/math-CYUjoyyU.d.ts +33 -0
- package/dist/math.d.ts +5 -3
- package/dist/math.js +6 -6
- package/dist/mesh.d.ts +4 -268
- package/dist/mesh.js +3 -7
- package/dist/move.d.ts +14 -11
- package/dist/{originProjection-DEklpDc_.d.ts → originProjection-PPT88jZv.d.ts} +1 -1
- package/dist/patterns-builtin.d.ts +1 -118
- package/dist/patterns-builtin.js +2 -3
- package/dist/{poseDescriptor-D-OH-tu5.d.ts → poseDescriptor-Bqk-11Rl.d.ts} +26 -36
- package/dist/renderer.d.ts +1 -91
- package/dist/renderer.js +2 -18
- package/dist/resize.d.ts +10 -22
- package/dist/resize.js +6 -6
- package/dist/style.css +1 -1
- package/dist/test-hook/install.js +12 -6
- package/dist/test-hook/install.js.map +1 -1
- package/dist/test-hook/useTestHook.js +22 -0
- package/dist/test-hook/useTestHook.js.map +1 -0
- package/dist/test-seams-D0pyV3pR.d.ts +149 -0
- package/dist/test-seams.d.ts +4 -4
- package/dist/test-seams.js +2 -2
- package/dist/tools/builtin/bone/boneActions.js +130 -0
- package/dist/tools/builtin/bone/boneActions.js.map +1 -0
- package/dist/tools/builtin/bone/boneOverlay.js +58 -0
- package/dist/tools/builtin/bone/boneOverlay.js.map +1 -0
- package/dist/tools/builtin/bone/placedRig.js +24 -0
- package/dist/tools/builtin/bone/placedRig.js.map +1 -0
- package/dist/tools/builtin/bone/rigEditState.js +21 -0
- package/dist/tools/builtin/bone/rigEditState.js.map +1 -0
- package/dist/tools/builtin/bone/useBoneTool.js +98 -0
- package/dist/tools/builtin/bone/useBoneTool.js.map +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/hand/useHandTool.js +1 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
- package/dist/tools/builtin/image/useImageTool.js.map +1 -1
- package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +1 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +198 -150
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +36 -0
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +25 -24
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +42 -67
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/shared/pointerFollower.js +17 -0
- package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +72 -82
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +22 -16
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +9 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/tools/builtin/weight/useWeightTool.js +77 -0
- package/dist/tools/builtin/weight/useWeightTool.js.map +1 -0
- package/dist/tools/builtin/weight/weightActions.js +112 -0
- package/dist/tools/builtin/weight/weightActions.js.map +1 -0
- package/dist/tools/builtin/weight/weightOverlay.js +61 -0
- package/dist/tools/builtin/weight/weightOverlay.js.map +1 -0
- package/dist/tools/overlayBinding.js.map +1 -1
- package/dist/tools/useKeybindings.js +12 -22
- package/dist/tools/useKeybindings.js.map +1 -1
- package/dist/{types-A37hYkeR.d.ts → types-CIKDwlsP.d.ts} +113 -169
- package/dist/util/color.js +3 -3
- package/dist/util/color.js.map +1 -1
- package/dist/util/paint.js +1 -1
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +28 -21
- package/dist/animation/colorHelpers.js +0 -135
- package/dist/animation/colorHelpers.js.map +0 -1
- package/dist/animation/colorRegistry.js +0 -37
- package/dist/animation/colorRegistry.js.map +0 -1
- package/dist/animation/engine/axes.js +0 -36
- package/dist/animation/engine/axes.js.map +0 -1
- package/dist/animation/engine/codec.js +0 -170
- package/dist/animation/engine/codec.js.map +0 -1
- package/dist/animation/engine/integrator.js +0 -12
- package/dist/animation/engine/integrator.js.map +0 -1
- package/dist/animation/loop.js +0 -62
- package/dist/animation/loop.js.map +0 -1
- package/dist/animation/observe.js +0 -23
- package/dist/animation/observe.js.map +0 -1
- package/dist/animation/rig/blendPoses.js +0 -43
- package/dist/animation/rig/blendPoses.js.map +0 -1
- package/dist/animation/rig/mirrorPose.js +0 -19
- package/dist/animation/rig/mirrorPose.js.map +0 -1
- package/dist/animation/rig/resolveSkeleton.js +0 -33
- package/dist/animation/rig/resolveSkeleton.js.map +0 -1
- package/dist/animation/rig/solveIk.js +0 -103
- package/dist/animation/rig/solveIk.js.map +0 -1
- package/dist/animation/rig/types.js +0 -12
- package/dist/animation/rig/types.js.map +0 -1
- package/dist/animation/slew.js +0 -27
- package/dist/animation/slew.js.map +0 -1
- package/dist/animation/stagger.js +0 -138
- package/dist/animation/stagger.js.map +0 -1
- package/dist/animation/timeline/booking.js +0 -106
- package/dist/animation/timeline/booking.js.map +0 -1
- package/dist/animation/timeline/createTimeline.js +0 -116
- package/dist/animation/timeline/createTimeline.js.map +0 -1
- package/dist/animation/timeline/sampleTrack.js +0 -71
- package/dist/animation/timeline/sampleTrack.js.map +0 -1
- package/dist/animation/useAnimator.js +0 -378
- package/dist/animation/useAnimator.js.map +0 -1
- package/dist/builtins-C-VgUlWI.d.ts +0 -4514
- package/dist/canvas/MinimapCanvas.js +0 -139
- package/dist/canvas/MinimapCanvas.js.map +0 -1
- package/dist/canvas/deps/poseComposition.js +0 -11
- package/dist/canvas/deps/poseComposition.js.map +0 -1
- package/dist/canvas/minimapMath.js +0 -80
- package/dist/canvas/minimapMath.js.map +0 -1
- package/dist/canvas/toolPreview.js +0 -39
- package/dist/canvas/toolPreview.js.map +0 -1
- package/dist/core/adapters/arrayAdapter.js +0 -85
- package/dist/core/adapters/arrayAdapter.js.map +0 -1
- package/dist/core/adapters/useArrayAdapter.js +0 -13
- package/dist/core/adapters/useArrayAdapter.js.map +0 -1
- package/dist/core/fillInPoseFrame.js +0 -102
- package/dist/core/fillInPoseFrame.js.map +0 -1
- package/dist/core/geometry/poseRotation.js +0 -58
- package/dist/core/geometry/poseRotation.js.map +0 -1
- package/dist/core/gradient.js +0 -136
- package/dist/core/gradient.js.map +0 -1
- package/dist/core/isPlainObject.js.map +0 -1
- package/dist/core/markerInset.js +0 -24
- package/dist/core/markerInset.js.map +0 -1
- package/dist/core/mixed.js +0 -6
- package/dist/core/mixed.js.map +0 -1
- package/dist/core/paintKinds.js +0 -156
- package/dist/core/paintKinds.js.map +0 -1
- package/dist/core/strokeMarkerShapes.js +0 -139
- package/dist/core/strokeMarkerShapes.js.map +0 -1
- package/dist/core/strokeMarkers.js +0 -28
- package/dist/core/strokeMarkers.js.map +0 -1
- package/dist/core/viewport/meanScale.js +0 -8
- package/dist/core/viewport/meanScale.js.map +0 -1
- package/dist/core/viewport/pxExtent.js +0 -42
- package/dist/core/viewport/pxExtent.js.map +0 -1
- package/dist/debug/flag.js.map +0 -1
- package/dist/features/cursor/paintedCursorLayer.js.map +0 -1
- package/dist/features/focus/gateLayer.js +0 -14
- package/dist/features/focus/gateLayer.js.map +0 -1
- package/dist/features/focus/useCanvasFocus.js +0 -29
- package/dist/features/focus/useCanvasFocus.js.map +0 -1
- package/dist/features/groups/children.js.map +0 -1
- package/dist/features/groups/composePose.js.map +0 -1
- package/dist/features/groups/nestedHit.js.map +0 -1
- package/dist/features/groups/unionOfChildren.js.map +0 -1
- package/dist/features/images/imageCache.js +0 -94
- package/dist/features/images/imageCache.js.map +0 -1
- package/dist/features/ingestion/index.js +0 -8
- package/dist/features/meshPaint/bake.js +0 -79
- package/dist/features/meshPaint/bake.js.map +0 -1
- package/dist/features/meshPaint/bakeCache.js +0 -59
- package/dist/features/meshPaint/bakeCache.js.map +0 -1
- package/dist/features/meshPaint/handles.js +0 -86
- package/dist/features/meshPaint/handles.js.map +0 -1
- package/dist/features/meshPaint/lazyKind.js.map +0 -1
- package/dist/features/meshPaint/meshPaint.js +0 -236
- package/dist/features/meshPaint/meshPaint.js.map +0 -1
- package/dist/features/meshPaint/meshShader.js +0 -6
- package/dist/features/meshPaint/meshShader.js.map +0 -1
- package/dist/features/meshPaint/register.js +0 -7
- package/dist/features/meshPaint/register.js.map +0 -1
- package/dist/features/meshPaint/surface.js +0 -110
- package/dist/features/meshPaint/surface.js.map +0 -1
- package/dist/features/minimap/actions.js +0 -53
- package/dist/features/minimap/actions.js.map +0 -1
- package/dist/features/minimap/createMinimapContribution.js +0 -96
- package/dist/features/minimap/createMinimapContribution.js.map +0 -1
- package/dist/features/minimap/layers.js +0 -103
- package/dist/features/minimap/layers.js.map +0 -1
- package/dist/features/overlays/useNodeOverlayFrame.js +0 -103
- package/dist/features/overlays/useNodeOverlayFrame.js.map +0 -1
- package/dist/features/parallax/createParallaxLayer.js +0 -26
- package/dist/features/parallax/createParallaxLayer.js.map +0 -1
- package/dist/features/parallax/createParallaxPlane.js +0 -26
- package/dist/features/parallax/createParallaxPlane.js.map +0 -1
- package/dist/features/paths/anchorEdits.js +0 -156
- package/dist/features/paths/anchorEdits.js.map +0 -1
- package/dist/features/paths/anchors.js +0 -154
- package/dist/features/paths/anchors.js.map +0 -1
- package/dist/features/paths/booleans.js +0 -2
- package/dist/features/paths/markerCommands.js +0 -148
- package/dist/features/paths/markerCommands.js.map +0 -1
- package/dist/features/paths/markerSites.js +0 -59
- package/dist/features/paths/markerSites.js.map +0 -1
- package/dist/features/paths/markers.js +0 -95
- package/dist/features/paths/markers.js.map +0 -1
- package/dist/features/paths/nearestAnchor.js +0 -36
- package/dist/features/paths/nearestAnchor.js.map +0 -1
- package/dist/features/paths/pathInWorld.js +0 -41
- package/dist/features/paths/pathInWorld.js.map +0 -1
- package/dist/features/paths/poseDescriptor.js +0 -39
- package/dist/features/paths/poseDescriptor.js.map +0 -1
- package/dist/features/paths/tessellate/dash.js +0 -52
- package/dist/features/paths/tessellate/dash.js.map +0 -1
- package/dist/features/paths/tessellate/insets.js +0 -32
- package/dist/features/paths/tessellate/insets.js.map +0 -1
- package/dist/features/paths/tessellate/metric.js +0 -72
- package/dist/features/paths/tessellate/metric.js.map +0 -1
- package/dist/features/paths/tessellate/stroke.js +0 -170
- package/dist/features/paths/tessellate/stroke.js.map +0 -1
- package/dist/features/paths/tessellate/vertexWidths.js +0 -32
- package/dist/features/paths/tessellate/vertexWidths.js.map +0 -1
- package/dist/features/patterns/index.js +0 -23
- package/dist/features/patterns/index.js.map +0 -1
- package/dist/features/patterns/patterns-builtin.js +0 -38
- package/dist/features/patterns/patterns-builtin.js.map +0 -1
- package/dist/features/patterns/resolveSpec.js +0 -57
- package/dist/features/patterns/resolveSpec.js.map +0 -1
- package/dist/features/patterns/tileGeometry.js +0 -158
- package/dist/features/patterns/tileGeometry.js.map +0 -1
- package/dist/features/pointer/PointerContext.js +0 -45
- package/dist/features/pointer/PointerContext.js.map +0 -1
- package/dist/features/selection/SelectionContext.js +0 -46
- package/dist/features/selection/SelectionContext.js.map +0 -1
- package/dist/features/simulation/createSimulation.js +0 -61
- package/dist/features/simulation/createSimulation.js.map +0 -1
- package/dist/features/simulation/types.js +0 -6
- package/dist/features/simulation/types.js.map +0 -1
- package/dist/features/simulation/useSimulation.js +0 -74
- package/dist/features/simulation/useSimulation.js.map +0 -1
- package/dist/features/text/domRuns.js +0 -258
- package/dist/features/text/domRuns.js.map +0 -1
- package/dist/features/text/fitTextPose.js +0 -38
- package/dist/features/text/fitTextPose.js.map +0 -1
- package/dist/features/text/hitTest.js +0 -45
- package/dist/features/text/hitTest.js.map +0 -1
- package/dist/features/text/renderLabel.js +0 -14
- package/dist/features/text/renderLabel.js.map +0 -1
- package/dist/features/text/runs/effectiveRangeStyle.js +0 -66
- package/dist/features/text/runs/effectiveRangeStyle.js.map +0 -1
- package/dist/features/text/runs/flagRange.js +0 -53
- package/dist/features/text/runs/flagRange.js.map +0 -1
- package/dist/features/text/runs/rangeStyle.js +0 -135
- package/dist/features/text/runs/rangeStyle.js.map +0 -1
- package/dist/features/text/textCommand.js +0 -59
- package/dist/features/text/textCommand.js.map +0 -1
- package/dist/features/text/textToPath.js +0 -181
- package/dist/features/text/textToPath.js.map +0 -1
- package/dist/features/text/useTextEdit.js +0 -467
- package/dist/features/text/useTextEdit.js.map +0 -1
- package/dist/features/tiling/createTiledLayer.js +0 -63
- package/dist/features/tiling/createTiledLayer.js.map +0 -1
- package/dist/features/tiling/tiledProject.js +0 -14
- package/dist/features/tiling/tiledProject.js.map +0 -1
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +0 -26
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +0 -1
- package/dist/interactions/actions/defaults/align.js.map +0 -1
- package/dist/interactions/actions/defaults/booleans.js +0 -52
- package/dist/interactions/actions/defaults/booleans.js.map +0 -1
- package/dist/interactions/actions/defaults/clipboard.js.map +0 -1
- package/dist/interactions/actions/defaults/clone.js +0 -107
- package/dist/interactions/actions/defaults/clone.js.map +0 -1
- package/dist/interactions/actions/defaults/createOutlines.js +0 -47
- package/dist/interactions/actions/defaults/createOutlines.js.map +0 -1
- package/dist/interactions/actions/defaults/distribute.js +0 -66
- package/dist/interactions/actions/defaults/distribute.js.map +0 -1
- package/dist/interactions/actions/defaults/editAnchors.js.map +0 -1
- package/dist/interactions/actions/defaults/flip.js +0 -119
- package/dist/interactions/actions/defaults/flip.js.map +0 -1
- package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
- package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
- package/dist/interactions/actions/defaults/insert.js +0 -288
- package/dist/interactions/actions/defaults/insert.js.map +0 -1
- package/dist/interactions/actions/defaults/lassoSelect.js +0 -156
- package/dist/interactions/actions/defaults/lassoSelect.js.map +0 -1
- package/dist/interactions/actions/defaults/move.js +0 -760
- package/dist/interactions/actions/defaults/move.js.map +0 -1
- package/dist/interactions/actions/defaults/resize.js +0 -335
- package/dist/interactions/actions/defaults/resize.js.map +0 -1
- package/dist/interactions/actions/defaults/rotate.js +0 -184
- package/dist/interactions/actions/defaults/rotate.js.map +0 -1
- package/dist/interactions/actions/previewOverrides.js +0 -25
- package/dist/interactions/actions/previewOverrides.js.map +0 -1
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +0 -1
- package/dist/math-Drrw4ewZ.d.ts +0 -160
- package/dist/registerProgram-BMZRDgrh.d.ts +0 -197
- package/dist/renderer/DrawCommand.js +0 -6
- package/dist/renderer/DrawCommand.js.map +0 -1
- package/dist/renderer/WeaselRenderer.js +0 -331
- package/dist/renderer/WeaselRenderer.js.map +0 -1
- package/dist/renderer/batchClip.js +0 -46
- package/dist/renderer/batchClip.js.map +0 -1
- package/dist/renderer/cache/GLImageCache.js +0 -64
- package/dist/renderer/cache/GLImageCache.js.map +0 -1
- package/dist/renderer/cache/GLMeshCache.js +0 -102
- package/dist/renderer/cache/GLMeshCache.js.map +0 -1
- package/dist/renderer/cache/GLTextureCache.js +0 -51
- package/dist/renderer/cache/GLTextureCache.js.map +0 -1
- package/dist/renderer/cache/GradientRampAtlas.js +0 -82
- package/dist/renderer/cache/GradientRampAtlas.js.map +0 -1
- package/dist/renderer/cache/cache.js +0 -13
- package/dist/renderer/cache/cache.js.map +0 -1
- package/dist/renderer/cache/markerCommandCache.js +0 -63
- package/dist/renderer/cache/markerCommandCache.js.map +0 -1
- package/dist/renderer/cache/outlineMeshCache.js +0 -15
- package/dist/renderer/cache/outlineMeshCache.js.map +0 -1
- package/dist/renderer/cache/outlineStrokeMeshCache.js +0 -36
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +0 -1
- package/dist/renderer/cache/strokeMeshCache.js +0 -55
- package/dist/renderer/cache/strokeMeshCache.js.map +0 -1
- package/dist/renderer/cullDrawCommands.js +0 -90
- package/dist/renderer/cullDrawCommands.js.map +0 -1
- package/dist/renderer/draw.js +0 -1135
- package/dist/renderer/draw.js.map +0 -1
- package/dist/renderer/drawBatch.js +0 -198
- package/dist/renderer/drawBatch.js.map +0 -1
- package/dist/renderer/effects/EffectTargets.js +0 -45
- package/dist/renderer/effects/EffectTargets.js.map +0 -1
- package/dist/renderer/effects/builtins.js +0 -31
- package/dist/renderer/effects/builtins.js.map +0 -1
- package/dist/renderer/effects/composite.js +0 -9
- package/dist/renderer/effects/composite.js.map +0 -1
- package/dist/renderer/effects/effectPrelude.js +0 -10
- package/dist/renderer/effects/effectPrelude.js.map +0 -1
- package/dist/renderer/effects/types.js +0 -10
- package/dist/renderer/effects/types.js.map +0 -1
- package/dist/renderer/glyphOutlineMesh.js +0 -67
- package/dist/renderer/glyphOutlineMesh.js.map +0 -1
- package/dist/renderer/index.js +0 -19
- package/dist/renderer/math/color.js +0 -341
- package/dist/renderer/math/color.js.map +0 -1
- package/dist/renderer/math/mat3.js +0 -76
- package/dist/renderer/math/mat3.js.map +0 -1
- package/dist/renderer/math/patternSpace.js +0 -22
- package/dist/renderer/math/patternSpace.js.map +0 -1
- package/dist/renderer/math/viewToMat3.js +0 -19
- package/dist/renderer/math/viewToMat3.js.map +0 -1
- package/dist/renderer/paintResources.js +0 -18
- package/dist/renderer/paintResources.js.map +0 -1
- package/dist/renderer/paintScratch.js +0 -37
- package/dist/renderer/paintScratch.js.map +0 -1
- package/dist/renderer/shaders/ShaderProgram.js +0 -74
- package/dist/renderer/shaders/ShaderProgram.js.map +0 -1
- package/dist/renderer/shaders/batchFill.js +0 -119
- package/dist/renderer/shaders/batchFill.js.map +0 -1
- package/dist/renderer/shaders/customPrelude.js +0 -34
- package/dist/renderer/shaders/customPrelude.js.map +0 -1
- package/dist/renderer/shaders/extractUniformNames.js +0 -184
- package/dist/renderer/shaders/extractUniformNames.js.map +0 -1
- package/dist/renderer/shaders/glyphPaint.js +0 -61
- package/dist/renderer/shaders/glyphPaint.js.map +0 -1
- package/dist/renderer/shaders/gradFill.js +0 -30
- package/dist/renderer/shaders/gradFill.js.map +0 -1
- package/dist/renderer/shaders/imageFill.js +0 -14
- package/dist/renderer/shaders/imageFill.js.map +0 -1
- package/dist/renderer/shaders/pathFill.js +0 -13
- package/dist/renderer/shaders/pathFill.js.map +0 -1
- package/dist/renderer/shaders/patternFill.js +0 -24
- package/dist/renderer/shaders/patternFill.js.map +0 -1
- package/dist/renderer/shaders/registerProgram.js +0 -18
- package/dist/renderer/shaders/registerProgram.js.map +0 -1
- package/dist/renderer/spriteSheet.js +0 -14
- package/dist/renderer/spriteSheet.js.map +0 -1
- package/dist/renderer/state/GroupState.js +0 -77
- package/dist/renderer/state/GroupState.js.map +0 -1
- package/dist/renderer/strokeLengths.js +0 -50
- package/dist/renderer/strokeLengths.js.map +0 -1
- package/dist/renderer/syntheticItalic.js +0 -6
- package/dist/renderer/syntheticItalic.js.map +0 -1
- package/dist/renderer/textures/registerTexture.js +0 -14
- package/dist/renderer/textures/registerTexture.js.map +0 -1
- package/dist/scheduling/useVisibleRaf.js +0 -69
- package/dist/scheduling/useVisibleRaf.js.map +0 -1
- package/dist/test-seams-CuIxe0xY.d.ts +0 -356
- package/dist/tools/prefs.js +0 -62
- package/dist/tools/prefs.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domRuns.js","names":["solidColor","p","TRANSFORMS","EMPTY_STYLE","parseLetterSpacing","n","raw","unit","isSmallCapsPiece","el","cssFontVariant","v","styleStateFromElement","parent","next","tag","fw","ownWeight","fs","td","size","va","rawShift","shift","tt","fv","family","ls","px","styleEquals","a","b","toRun","run","style","BREAK_ATTR","restoreBreak","text","code","appendOverlayText","from","c","isHardLineBreak","span","domToRuns","fragments","visit","node","restored","nextStyle","child","runs","j","merged","f","SMALL_CAPS_SCALE_PROPERTY","smallCapsPieces","shown","transformRunTexts","transform","caps","smallCapsText","small","s","i","out","at","ch","last","writeSmallCaps","piece","SMALL_CAPS_SCALE","runsToDom","DEFAULT_TEXT_STYLE","base","scale","smallCapsScaleFor","numericWeight","cssFontFamily","color","decorations","sourceText","piecesMatch","want","have","normalizeSmallCaps","changed","variant","t","charOffsetToDomPosition","remaining","offset","walker","len","domPositionToCharOffset","total","cur","point"],"sources":["../../../src/features/text/domRuns.ts"],"sourcesContent":["/**\n * Pure DOM ↔ `StyledRun[]` serializers for the contenteditable overlay\n * used by `useTextEdit`. The overlay's children are a flat sequence of\n * `<span data-run>` elements, each carrying one run's text and inline\n * styles. Newlines inside a run are literal `\\n` characters; the overlay\n * has `white-space: pre-wrap` so they render as line breaks. The browser\n * breaks at no other UAX #14 hard break, so each of those is written as a\n * `<span data-break>` holding a `\\n` in its place — one character for one,\n * which keeps DOM offsets equal to source offsets.\n *\n * A small-caps run is the one exception to one text node per span: its\n * lowercase letters sit in `<span data-small-caps>` pieces, uppercased and\n * sized at the scale the canvas draws them with, since a browser's own\n * synthesis uses a fixed factor of its own. The pieces are presentation\n * only — `domToRuns` reads straight through them.\n */\n\nimport type { FillStyle } from '@weasel-js/paint';\nimport {\n DEFAULT_TEXT_STYLE, isHardLineBreak, numericWeight, smallCapsScaleFor, smallCapsText, transformRunTexts,\n SMALL_CAPS_SCALE,\n type FontVariantCaps, type ResolvedTextStyle, type StyledRun, type TextTransform,\n} from '@weasel-js/text';\nimport { cssFontFamily } from '@weasel-js/font';\n\nfunction solidColor(p: FillStyle | undefined): string | null {\n if (!p) return null;\n if ('color' in p) return p.color;\n return null;\n}\n\ninterface StyleState {\n bold: boolean;\n italic: boolean;\n underline: boolean;\n strikethrough: boolean;\n overline: boolean;\n fontWeight?: number;\n fontSize?: number;\n fontFamily?: string;\n color?: string;\n letterSpacing?: number;\n script?: 'super' | 'sub';\n baselineShift?: number;\n fontScale?: number;\n textTransform?: TextTransform;\n fontVariantCaps?: FontVariantCaps;\n}\n\nconst TRANSFORMS: ReadonlySet<string> = new Set(['none', 'uppercase', 'lowercase', 'capitalize']);\n\nconst EMPTY_STYLE: StyleState = {\n bold: false,\n italic: false,\n underline: false,\n strikethrough: false,\n overline: false,\n};\n\n/**\n * Parse a CSS `letter-spacing` value into world units. `runsToDom` only ever\n * writes `px`, but paste is a live path into the contenteditable and CSSOM\n * keeps whatever unit the pasted markup used. Any other unit is still\n * numerically coerced — `parseFloat` reads the leading digits — but flagged,\n * since e.g. `0.1em` silently becomes `0.1` world units, off by a factor of\n * the font size. Mirrors `parseLetterSpacing` in the SVG reader.\n */\nfunction parseLetterSpacing(raw: string): number | undefined {\n const n = parseFloat(raw);\n if (!Number.isFinite(n)) return undefined;\n const unit = /^-?[\\d.]+([a-z%]+)$/i.exec(raw.trim())?.[1]?.toLowerCase();\n if (unit && unit !== 'px') {\n console.warn(\n `weasel domRuns: letter-spacing \"${raw}\" uses unit \"${unit}\", which is not converted; treated as ${n} world units`,\n );\n }\n return n;\n}\n\n/** A small-caps piece is presentation `runsToDom` split a run into, not styling. */\nconst isSmallCapsPiece = (el: Element): boolean => el.hasAttribute('data-small-caps');\n\n/** The element's own `font-variant`, from the shorthand or the caps longhand\n * pasted markup may carry alone. */\nfunction cssFontVariant(el: HTMLElement): FontVariantCaps | undefined {\n const v = el.style.fontVariant || el.style.getPropertyValue('font-variant-caps');\n return v === 'small-caps' || v === 'normal' ? v : undefined;\n}\n\nfunction styleStateFromElement(el: Element, parent: StyleState): StyleState {\n if (isSmallCapsPiece(el)) return parent;\n const next: StyleState = { ...parent };\n const tag = el.tagName;\n if (tag === 'B' || tag === 'STRONG') {\n next.bold = true;\n next.fontWeight = undefined;\n }\n if (tag === 'I' || tag === 'EM') next.italic = true;\n // `runsToDom` never emits these, but a browser contenteditable can (Cmd+U\n // runs the native `underline` command, which produces `<u>` in Chrome), so\n // read them for the same reason `<b>`/`<i>` are read.\n if (tag === 'U') next.underline = true;\n if (tag === 'S' || tag === 'STRIKE' || tag === 'DEL') next.strikethrough = true;\n if (tag === 'SUP') next.script = 'super';\n if (tag === 'SUB') next.script = 'sub';\n if (el instanceof HTMLElement) {\n // 700 and 400 are the bold flag on and off, which is what pasted markup\n // means by them. A run's own weight is written with an attribute beside\n // the CSS, so a stored 400 or 700 comes back as the weight it was.\n const fw = el.style.fontWeight;\n const ownWeight = Number(el.getAttribute('data-font-weight') ?? fw);\n if (el.hasAttribute('data-font-weight') || !['', '700', 'bold', '400', 'normal'].includes(fw)) {\n if (Number.isFinite(ownWeight) && ownWeight > 0) {\n next.fontWeight = ownWeight;\n next.bold = false;\n }\n } else if (fw !== '') {\n next.bold = fw === '700' || fw === 'bold';\n next.fontWeight = undefined;\n }\n const fs = el.style.fontStyle;\n if (fs === 'italic') next.italic = true;\n if (fs === 'normal') next.italic = false;\n // Decoration accumulates down the tree — unlike `font-weight`/`font-style`\n // above, `text-decoration` does not inherit, it *propagates*, and a\n // descendant cannot cancel what an ancestor drew. So OR the flags in\n // rather than overwriting: `<u><span style=\"text-decoration: line-through\">`\n // renders both lines, and that is a reachable shape here, since `runsToDom`\n // emits the span and an unintercepted Cmd+U supplies the `<u>`. An explicit\n // `none` contributes no tokens and cancels nothing.\n //\n // A declaration block carrying only the longhand serializes the shorthand\n // as `''` (the shorthand needs the full set), and browsers and pasted HTML\n // both produce that, so fall back to `text-decoration-line`.\n const td = el.style.textDecoration || el.style.textDecorationLine;\n if (td && !td.includes('none')) {\n next.underline ||= td.includes('underline');\n next.strikethrough ||= td.includes('line-through');\n next.overline ||= td.includes('overline');\n }\n // A percentage is `fontScale`'s own spelling — CSS resolves it against the\n // parent, which is exactly what the field means. Any other unit is an\n // absolute size.\n if (el.style.fontSize) {\n const size = parseFloat(el.style.fontSize);\n if (Number.isFinite(size)) {\n if (el.style.fontSize.trim().endsWith('%')) next.fontScale = size / 100;\n else next.fontSize = size;\n }\n }\n const va = el.style.verticalAlign;\n if (va === 'super' || va === 'sub') next.script = va === 'super' ? 'super' : 'sub';\n if (va === 'baseline') next.script = undefined;\n const rawShift = el.getAttribute('data-baseline-shift');\n if (rawShift != null) {\n const shift = parseFloat(rawShift);\n if (Number.isFinite(shift)) next.baselineShift = shift;\n }\n const tt = el.style.textTransform;\n if (TRANSFORMS.has(tt)) next.textTransform = tt as TextTransform;\n const fv = cssFontVariant(el);\n if (fv) next.fontVariantCaps = fv;\n // The attribute holds the run's family; the CSS holds the face it maps to.\n const family = el.getAttribute('data-font-family') ?? el.style.fontFamily;\n if (family) next.fontFamily = family;\n if (el.style.color) next.color = el.style.color;\n const ls = el.style.letterSpacing;\n if (ls === 'normal') {\n next.letterSpacing = undefined;\n } else if (ls) {\n const px = parseLetterSpacing(ls);\n if (px != null) next.letterSpacing = px;\n }\n }\n return next;\n}\n\nfunction styleEquals(a: StyleState, b: StyleState): boolean {\n return (\n a.bold === b.bold &&\n a.italic === b.italic &&\n a.underline === b.underline &&\n a.strikethrough === b.strikethrough &&\n a.overline === b.overline &&\n a.fontWeight === b.fontWeight &&\n a.fontSize === b.fontSize &&\n a.fontFamily === b.fontFamily &&\n a.color === b.color &&\n a.letterSpacing === b.letterSpacing &&\n a.script === b.script &&\n a.baselineShift === b.baselineShift &&\n a.fontScale === b.fontScale &&\n a.textTransform === b.textTransform &&\n a.fontVariantCaps === b.fontVariantCaps\n );\n}\n\nfunction toRun(text: string, style: StyleState): StyledRun {\n const run: StyledRun = { text };\n if (style.bold) run.bold = true;\n if (style.italic) run.italic = true;\n if (style.fontWeight != null) run.fontWeight = style.fontWeight;\n if (style.fontSize != null) run.fontSize = style.fontSize;\n if (style.fontFamily != null) run.fontFamily = style.fontFamily;\n if (style.color != null) run.fill = { fill: 'solid', color: style.color };\n // `letterSpacing: 0` is a meaningful override (it cancels node-level\n // tracking for this run), so test for presence, not truthiness.\n if (style.letterSpacing != null) run.letterSpacing = style.letterSpacing;\n // Run-level flags are additive over the node style — a run cannot un-set\n // one — so an undecorated run gets an absent key, never `false`.\n if (style.underline) run.underline = true;\n if (style.strikethrough) run.strikethrough = true;\n if (style.overline) run.overline = true;\n if (style.script != null) run.script = style.script;\n // Both are meaningful at values that test falsy — a 0 shift cancels an\n // inherited script's rise — so test for presence, as `letterSpacing` does.\n if (style.baselineShift != null) run.baselineShift = style.baselineShift;\n if (style.fontScale != null) run.fontScale = style.fontScale;\n if (style.textTransform != null) run.textTransform = style.textTransform;\n if (style.fontVariantCaps != null) run.fontVariantCaps = style.fontVariantCaps;\n return run;\n}\n\nconst BREAK_ATTR = 'data-break';\n\n/** A break stand-in's source text: its hard break, and anything typed into it after. */\nfunction restoreBreak(el: Element): string {\n const text = el.textContent ?? '';\n const code = parseInt(el.getAttribute(BREAK_ATTR) ?? '', 16);\n return text.startsWith('\\n') && Number.isFinite(code) ? String.fromCharCode(code) + text.slice(1) : text;\n}\n\n/**\n * Append `text` to `parent` as the overlay sets it: a hard break the browser\n * would not break at becomes a `<span data-break>` holding a `\\n`, carrying\n * the original's code as hex for `domToRuns` to restore. A CR that opens a\n * CRLF is left as it is — the LF breaks, and the CR draws nothing.\n */\nexport function appendOverlayText(parent: Node, text: string): void {\n let from = 0;\n for (let i = 0; i < text.length; i++) {\n const c = text.charCodeAt(i);\n if (c === 10 || !isHardLineBreak(c) || (c === 13 && text.charCodeAt(i + 1) === 10)) continue;\n if (i > from) parent.appendChild(document.createTextNode(text.slice(from, i)));\n const span = document.createElement('span');\n span.setAttribute(BREAK_ATTR, c.toString(16));\n span.textContent = '\\n';\n parent.appendChild(span);\n from = i + 1;\n }\n if (from < text.length) parent.appendChild(document.createTextNode(text.slice(from)));\n}\n\n/** Walk an overlay tree and emit a coalesced `StyledRun[]`. */\nexport function domToRuns(parent: HTMLElement): StyledRun[] {\n const fragments: Array<{ text: string; style: StyleState }> = [];\n\n function visit(node: Node, style: StyleState): void {\n if (node.nodeType === Node.TEXT_NODE) {\n const text = (node as Text).data;\n if (text.length > 0) fragments.push({ text, style });\n return;\n }\n if (node.nodeType !== Node.ELEMENT_NODE) return;\n const el = node as Element;\n if (el.tagName === 'BR') {\n fragments.push({ text: '\\n', style });\n return;\n }\n if (el.hasAttribute(BREAK_ATTR)) {\n const restored = restoreBreak(el);\n if (restored.length > 0) fragments.push({ text: restored, style });\n return;\n }\n if (el.tagName === 'DIV' && fragments.length > 0) {\n fragments.push({ text: '\\n', style });\n }\n const nextStyle = styleStateFromElement(el, style);\n for (const child of Array.from(el.childNodes)) {\n visit(child, nextStyle);\n }\n }\n\n for (const child of Array.from(parent.childNodes)) {\n visit(child, EMPTY_STYLE);\n }\n\n // Coalesce adjacent fragments with identical style.\n const runs: StyledRun[] = [];\n let i = 0;\n while (i < fragments.length) {\n let j = i + 1;\n while (j < fragments.length && styleEquals(fragments[i].style, fragments[j].style)) {\n j++;\n }\n const merged = fragments.slice(i, j).map((f) => f.text).join('');\n runs.push(toRun(merged, fragments[i].style));\n i = j;\n }\n return runs;\n}\n\n/** What a run inherits from its node, for the overlay's small caps: which\n * runs have it, and the face and transform that decide their pieces. */\nexport type OverlayRunBase = Pick<\n ResolvedTextStyle, 'fontFamily' | 'fontWeight' | 'fontStyle' | 'textTransform' | 'fontVariantCaps'\n>;\n\n/** The custom property carrying a small-caps run's scale down to its pieces. */\nexport const SMALL_CAPS_SCALE_PROPERTY = '--weasel-small-caps';\n\n/** A run's source text cut where small caps changes size, per `smallCapsText`\n * over the text as `transform` draws it. */\nfunction smallCapsPieces(text: string, transform: TextTransform): Array<{ text: string; small: boolean }> {\n const [shown] = transformRunTexts([text], [transform]);\n const caps = smallCapsText(shown.text, shown.srcMap);\n const small = new Array<boolean>(text.length).fill(false);\n caps.small?.forEach((s, i) => {\n if (s) small[caps.srcMap ? caps.srcMap.starts[i] : i] = true;\n });\n const out: Array<{ text: string; small: boolean }> = [];\n let at = 0;\n for (const ch of text) {\n const last = out[out.length - 1];\n if (last && last.small === small[at]) last.text += ch;\n else out.push({ text: ch, small: small[at] });\n at += ch.length;\n }\n return out;\n}\n\n/** Replace `span`'s children with `text`, its small-caps letters in pieces. */\nfunction writeSmallCaps(span: HTMLElement, text: string, transform: TextTransform): void {\n span.replaceChildren();\n for (const p of smallCapsPieces(text, transform)) {\n if (!p.small) { appendOverlayText(span, p.text); continue; }\n const piece = document.createElement('span');\n piece.setAttribute('data-small-caps', '');\n piece.style.fontSize = `calc(var(${SMALL_CAPS_SCALE_PROPERTY}, ${SMALL_CAPS_SCALE}) * 1em)`;\n piece.style.textTransform = 'uppercase';\n piece.textContent = p.text;\n span.appendChild(piece);\n }\n}\n\n/**\n * Build a flat sequence of `<span data-run>` children from `runs`, replacing\n * any existing children of `parent`. `base` is the node's style, which a run\n * inheriting small caps needs to be split by; without it the kit defaults\n * stand in.\n */\nexport function runsToDom(\n runs: readonly StyledRun[],\n parent: HTMLElement,\n base: OverlayRunBase = DEFAULT_TEXT_STYLE,\n): void {\n parent.replaceChildren();\n for (const run of runs) {\n const span = document.createElement('span');\n span.setAttribute('data-run', '');\n if ((run.fontVariantCaps ?? base.fontVariantCaps) === 'small-caps') {\n const scale = smallCapsScaleFor(\n run.fontFamily ?? base.fontFamily,\n run.fontWeight ?? (run.bold ? 700 : numericWeight(base.fontWeight)),\n run.italic ? 'italic' : base.fontStyle,\n );\n span.style.setProperty(SMALL_CAPS_SCALE_PROPERTY, String(scale));\n writeSmallCaps(span, run.text, run.textTransform ?? base.textTransform);\n } else {\n appendOverlayText(span, run.text);\n }\n // CSS as well as the pieces: it is what pasted markup says, and it gives a\n // letter typed outside a piece a small cap until the next normalize.\n if (run.fontVariantCaps != null) span.style.fontVariant = run.fontVariantCaps;\n if (run.fontWeight != null) {\n span.style.fontWeight = String(run.fontWeight);\n span.setAttribute('data-font-weight', String(run.fontWeight));\n } else if (run.bold) span.style.fontWeight = '700';\n if (run.italic) span.style.fontStyle = 'italic';\n // An absolute size wins over a relative one, as it does in `resolveRuns`.\n if (run.fontSize != null) span.style.fontSize = `${run.fontSize}px`;\n else if (run.fontScale != null) span.style.fontSize = `${run.fontScale * 100}%`;\n if (run.fontFamily != null) {\n span.style.fontFamily = cssFontFamily(run.fontFamily, {\n weight: run.fontWeight ?? (run.bold ? 700 : undefined),\n style: run.italic ? 'italic' : undefined,\n });\n span.setAttribute('data-font-family', run.fontFamily);\n }\n const color = solidColor(run.fill);\n if (color != null) span.style.color = color;\n // Decoration goes on the span as an inline style rather than `<u>`/`<s>`\n // wrappers: one representation for `domToRuns` to unwrap, and one element\n // per run so the caret-offset walkers stay flat.\n const decorations: string[] = [];\n if (run.underline) decorations.push('underline');\n if (run.strikethrough) decorations.push('line-through');\n if (run.overline) decorations.push('overline');\n if (decorations.length > 0) span.style.textDecoration = decorations.join(' ');\n if (run.script != null) span.style.verticalAlign = run.script;\n // The one run field with no CSS spelling: `vertical-align` takes a length\n // or a percentage of the *line height*, and this is a fraction of the\n // parent's font size. An attribute keeps the round-trip exact; the canvas\n // underneath is what actually draws the run at its offset.\n if (run.baselineShift != null) {\n span.setAttribute('data-baseline-shift', String(run.baselineShift));\n }\n // World units — the overlay's own node-level tracking is screen-scaled,\n // but a run override is stored as-is so the round-trip is lossless. CSS\n // `letter-spacing` is inherited and a child declaration *replaces* the\n // inherited value, so this composes with the overlay's rather than adding.\n if (run.letterSpacing != null) span.style.letterSpacing = `${run.letterSpacing}px`;\n // CSS draws the transform, so the span's text stays the source and the\n // caret-offset walkers below need no map.\n if (run.textTransform != null) span.style.textTransform = run.textTransform;\n parent.appendChild(span);\n }\n}\n\n/** `el`'s text as `domToRuns` reads it: each break stand-in restored. */\nfunction sourceText(el: Element): string {\n let out = '';\n for (const n of el.childNodes) {\n if (n.nodeType === Node.TEXT_NODE) out += (n as Text).data;\n else if (n instanceof Element) out += n.hasAttribute(BREAK_ATTR) ? restoreBreak(n) : sourceText(n);\n }\n return out;\n}\n\n/** Whether `span`'s children are the pieces `writeSmallCaps` would write. */\nfunction piecesMatch(span: HTMLElement, transform: TextTransform): boolean {\n const want = smallCapsPieces(sourceText(span), transform);\n const have: Array<{ text: string; small: boolean }> = [];\n for (const n of span.childNodes) {\n let small: boolean;\n let text: string;\n if (n.nodeType === Node.TEXT_NODE) { small = false; text = (n as Text).data; }\n else if (n instanceof HTMLElement && n.hasAttribute(BREAK_ATTR)) { small = false; text = restoreBreak(n); }\n else if (n instanceof HTMLElement && isSmallCapsPiece(n) && n.children.length === 0) { small = true; text = n.textContent ?? ''; }\n else return false;\n if (text.length === 0) continue;\n const last = have[have.length - 1];\n if (last && last.small === small) last.text += text;\n else have.push({ text, small });\n }\n return want.length === have.length\n && want.every((p, i) => p.text === have[i].text && p.small === have[i].small);\n}\n\n/**\n * Put every run span's small-caps pieces back where its text now needs them —\n * typing lands a letter in whichever piece holds the caret, not the one its\n * case belongs in. Returns whether anything was rewritten, which moves the\n * DOM selection: the caller restores it by character offset.\n */\nexport function normalizeSmallCaps(parent: HTMLElement): boolean {\n let changed = false;\n const visit = (el: HTMLElement, variant: FontVariantCaps, transform: TextTransform): void => {\n const v = cssFontVariant(el) ?? variant;\n const tt = el.style.textTransform;\n const t = TRANSFORMS.has(tt) ? (tt as TextTransform) : transform;\n if (el.hasAttribute('data-run')) {\n if (v === 'small-caps') {\n if (!piecesMatch(el, t)) { writeSmallCaps(el, sourceText(el), t); changed = true; }\n } else if (el.querySelector('[data-small-caps]')) {\n const text = sourceText(el);\n el.replaceChildren();\n appendOverlayText(el, text);\n changed = true;\n }\n return;\n }\n for (const child of el.children) if (child instanceof HTMLElement) visit(child, v, t);\n };\n visit(parent, 'normal', 'none');\n return changed;\n}\n\n/**\n * Walk the overlay's text nodes in document order and find the text node\n * + offset that corresponds to plain-text character position `offset`.\n * Offsets beyond the total text length clamp to the end of the last text\n * node. Returns `{ node: parent, offset: 0 }` when there are no text nodes.\n */\nexport function charOffsetToDomPosition(\n parent: HTMLElement,\n offset: number,\n): { node: Node; offset: number } | null {\n let remaining = offset;\n const walker = document.createTreeWalker(parent, NodeFilter.SHOW_TEXT);\n let last: Text | null = null;\n let node = walker.nextNode() as Text | null;\n while (node) {\n const len = node.data.length;\n if (remaining <= len) {\n return { node, offset: remaining };\n }\n remaining -= len;\n last = node;\n node = walker.nextNode() as Text | null;\n }\n if (last) return { node: last, offset: last.data.length };\n return { node: parent, offset: 0 };\n}\n\n/**\n * Inverse of `charOffsetToDomPosition`. Walks text nodes in document order;\n * sums the lengths of every text node preceding `node` and adds `offset`.\n *\n * When `node` is an element the DOM offset indexes *child nodes*, not\n * characters, so it can't simply be added — `(overlay, 0)` is the start of\n * the text and `(overlay, childNodes.length)` its end. That shape is not\n * exotic: `Range.selectNodeContents`, which `useTextEdit` uses for its\n * select-all caret, produces exactly it. So resolve an element position by\n * counting the text that precedes the boundary point. A text node can never\n * *contain* that point (the container isn't one), so each is wholly before\n * or wholly after it.\n */\nexport function domPositionToCharOffset(\n parent: HTMLElement,\n node: Node,\n offset: number,\n): number {\n let total = 0;\n const walker = document.createTreeWalker(parent, NodeFilter.SHOW_TEXT);\n let cur = walker.nextNode() as Text | null;\n if (node.nodeType === Node.TEXT_NODE) {\n while (cur) {\n if (cur === node) return total + offset;\n total += cur.data.length;\n cur = walker.nextNode() as Text | null;\n }\n return total;\n }\n const point = document.createRange();\n point.setStart(node, Math.max(0, Math.min(offset, node.childNodes.length)));\n point.collapse(true);\n while (cur) {\n if (point.comparePoint(cur, 0) < 0) total += cur.data.length;\n cur = walker.nextNode() as Text | null;\n }\n return total;\n}\n"],"mappings":";;;AAyBA,SAASA,EAAW,GAAyC;CAG3D,OAFKC,KACD,WAAWA,IAAUA,EAAE,QACpB;AACT;AAoBA,IAAMC,oBAAkC,IAAI,IAAI;CAAC;CAAQ;CAAa;CAAa;AAAY,CAAC,GAE1FC,IAA0B;CAC9B,MAAM;CACN,QAAQ;CACR,WAAW;CACX,eAAe;CACf,UAAU;AACZ;AAUA,SAASC,EAAmB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,OAAOiD,IAAK;GACV,IAAIA,MAAQjD,GAAM,OAAOgD,IAAQJ;GAEjC,AADA,KAASK,EAAI,KAAK,QAClB,IAAMJ,EAAO,SAAS;EACxB;EACA,OAAOG;CACT;CACA,IAAME,IAAQ,SAAS,YAAY;CAGnC,KAFAA,EAAM,SAASlD,GAAM,KAAK,IAAI,GAAG,KAAK,IAAI4C,GAAQ5C,EAAK,WAAW,MAAM,CAAC,CAAC,GAC1EkD,EAAM,SAAS,EAAI,GACZD,IAEL,AADIC,EAAM,aAAaD,GAAK,CAAC,IAAI,MAAG,KAASA,EAAI,KAAK,SACtD,IAAMJ,EAAO,SAAS;CAExB,OAAOG;AACT"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { layoutTextPose as e } from "@weasel-js/text";
|
|
2
|
-
//#region src/features/text/fitTextPose.ts
|
|
3
|
-
function t(t, r = {}) {
|
|
4
|
-
let i = r.axis ?? "height", { padX: a, padY: o } = n(r.padding), { bounds: s } = e(i === "height" ? {
|
|
5
|
-
...t,
|
|
6
|
-
width: t.width - a * 2
|
|
7
|
-
} : {
|
|
8
|
-
...t,
|
|
9
|
-
style: {
|
|
10
|
-
...t.style,
|
|
11
|
-
wrap: !1
|
|
12
|
-
}
|
|
13
|
-
}).laid;
|
|
14
|
-
return i === "height" ? {
|
|
15
|
-
...t,
|
|
16
|
-
height: s.height + o * 2
|
|
17
|
-
} : {
|
|
18
|
-
...t,
|
|
19
|
-
width: s.width + a * 2,
|
|
20
|
-
height: s.height + o * 2
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function n(e) {
|
|
24
|
-
return e == null ? {
|
|
25
|
-
padX: 0,
|
|
26
|
-
padY: 0
|
|
27
|
-
} : typeof e == "number" ? {
|
|
28
|
-
padX: e,
|
|
29
|
-
padY: e
|
|
30
|
-
} : {
|
|
31
|
-
padX: e.x ?? 0,
|
|
32
|
-
padY: e.y ?? 0
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { t as fitTextPose };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=fitTextPose.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fitTextPose.js","names":["fitTextPose","axis","opts","resolvePadding","layoutTextPose","pose","padX","bounds","padY","p"],"sources":["../../../src/features/text/fitTextPose.ts"],"sourcesContent":["/**\n * Resize a text node's pose to fit its content. Pure helper — does not own\n * scene state. Call it whenever the text, style, or relevant axis changes,\n * and write the returned pose back through your adapter.\n *\n * Two modes:\n *\n * - `axis: 'height'` (default): keep `pose.width`, recompute `height` as\n * the block height plus optional vertical padding — wrapped at the width\n * inside the horizontal padding when the style declares `wrap`. The\n * common case for column-layout text — chat bubbles, sticky notes.\n *\n * - `axis: 'both'`: ignore wrapping; recompute both `width` (longest\n * `\\n`-split line) and `height` (line count × line height) plus padding.\n * For badges and inline labels where the rect hugs the text on both\n * axes. Newlines are still respected.\n *\n * `pose.x` / `pose.y` are preserved. The caller picks the anchor — if you\n * want a different growth direction (e.g. anchor bottom-right), adjust\n * `x` / `y` after calling.\n */\n\nimport { layoutTextPose } from '@weasel-js/text';\nimport type { TextPose } from '@weasel-js/text';\n\n/** Options for `fitTextPose`. */\nexport interface FitTextPoseOptions {\n /** Which axis (or axes) to recompute. Default: `'height'`. */\n axis?: 'height' | 'both';\n /** Padding (world units) added to all four sides. Default 0. */\n padding?: number | { x?: number; y?: number };\n}\n\n/** Recompute a `TextPose`'s `width`/`height` to fit its content; pure helper, doesn't mutate scene state. */\nexport function fitTextPose(\n pose: TextPose,\n opts: FitTextPoseOptions = {},\n): TextPose {\n const axis = opts.axis ?? 'height';\n const { padX, padY } = resolvePadding(opts.padding);\n const { bounds } = layoutTextPose(axis === 'height'\n ? { ...pose, width: pose.width - padX * 2 }\n : { ...pose, style: { ...pose.style, wrap: false } }).laid;\n if (axis === 'height') return { ...pose, height: bounds.height + padY * 2 };\n return {\n ...pose,\n width: bounds.width + padX * 2,\n height: bounds.height + padY * 2,\n };\n}\n\nfunction resolvePadding(p: FitTextPoseOptions['padding']): { padX: number; padY: number } {\n if (p == null) return { padX: 0, padY: 0 };\n if (typeof p === 'number') return { padX: p, padY: p };\n return { padX: p.x ?? 0, padY: p.y ?? 0 };\n}\n"],"mappings":";;AAkCA,SAAgBA,EACd,GACA,IAA2B,CAAC,GAClB;CACV,IAAMC,IAAOC,EAAK,QAAQ,UACpB,EAAE,SAAM,YAASC,EAAeD,EAAK,OAAO,GAC5C,EAAE,cAAWE,EAAeH,MAAS,WACvC;EAAE,GAAGI;EAAM,OAAOA,EAAK,QAAQC,IAAO;CAAE,IACxC;EAAE,GAAGD;EAAM,OAAO;GAAE,GAAGA,EAAK;GAAO,MAAM;EAAM;CAAE,CAAC,CAAC,CAAC;CAExD,OADIJ,MAAS,WAAiB;EAAE,GAAGI;EAAM,QAAQE,EAAO,SAASC,IAAO;CAAE,IACnE;EACL,GAAGH;EACH,OAAOE,EAAO,QAAQD,IAAO;EAC7B,QAAQC,EAAO,SAASC,IAAO;CACjC;AACF;AAEA,SAASL,EAAe,GAAkE;CAGxF,OAFIM,KAAK,OAAa;EAAE,MAAM;EAAG,MAAM;CAAE,IACrC,OAAOA,KAAM,WAAiB;EAAE,MAAMA;EAAG,MAAMA;CAAE,IAC9C;EAAE,MAAMA,EAAE,KAAK;EAAG,MAAMA,EAAE,KAAK;CAAE;AAC1C"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { layoutTextPose as e } from "@weasel-js/text";
|
|
2
|
-
//#region src/features/text/hitTest.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
let t = [];
|
|
5
|
-
for (let n of e) {
|
|
6
|
-
let e = t[t.length - 1];
|
|
7
|
-
if (e && e.srcIndex === n.srcIndex && e.srcEnd === n.srcEnd) {
|
|
8
|
-
let r = Math.min(e.x, n.x), i = Math.max(e.x + e.advance, n.x + n.advance);
|
|
9
|
-
t[t.length - 1] = {
|
|
10
|
-
...e,
|
|
11
|
-
x: r,
|
|
12
|
-
advance: i - r
|
|
13
|
-
};
|
|
14
|
-
} else t.push(n);
|
|
15
|
-
}
|
|
16
|
-
return t;
|
|
17
|
-
}
|
|
18
|
-
function n(e, t, n, r = {}) {
|
|
19
|
-
let i = r.padding ?? 0;
|
|
20
|
-
return e >= n.x - i && e <= n.x + n.width + i && t >= n.y - i && t <= n.y + n.height + i;
|
|
21
|
-
}
|
|
22
|
-
function r(n, r, i) {
|
|
23
|
-
let { laid: a, x: o, y: s } = e(i), c = a.lines;
|
|
24
|
-
if (c.length === 0) return 0;
|
|
25
|
-
let l = c[c.length - 1];
|
|
26
|
-
if (r < s + c[0].y0) return c[0].cells[0]?.srcIndex ?? c[0].srcEnd;
|
|
27
|
-
if (r >= s + l.y1) return l.srcEnd;
|
|
28
|
-
let u = l;
|
|
29
|
-
for (let e of c) if (r < s + e.y1) {
|
|
30
|
-
u = e;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
if (u.cells.length === 0) return u.srcEnd;
|
|
34
|
-
let d = t(u.cells), f = d.map((e, t) => t).sort((e, t) => d[e].x - d[t].x);
|
|
35
|
-
for (let e of f) {
|
|
36
|
-
let t = d[e];
|
|
37
|
-
if (!(n >= o + t.x + t.advance / 2)) return t.level % 2 == 1 ? t.srcEnd : t.srcIndex;
|
|
38
|
-
}
|
|
39
|
-
let p = d[f[f.length - 1]];
|
|
40
|
-
return p.level % 2 == 1 ? p.srcIndex : p.srcEnd;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { r as caretIndexAt, n as pointInTextPose };
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=hitTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hitTest.js","names":["sourceClusters","out","c","cells","prev","x0","x1","pointInTextPose","p","opts","x","pose","y","caretIndexAt","dx","dy","layoutTextPose","lines","laid","last","line","candidate","visual","i","a","b","trailing"],"sources":["../../../src/features/text/hitTest.ts"],"sourcesContent":["/**\n * Hit-testing for text nodes.\n *\n * `pointInTextPose` does a coarse pose-rect test — suitable for click-to-edit\n * where the pose rect is the authoritative bounding box (selection outline,\n * drag target).\n *\n * `caretIndexAt` does the finer test: given a world-space (x, y) inside the\n * pose, returns the corresponding character offset so the consumer can place\n * the caret on click. It reads the caret stops off `layoutTextPose`, the\n * layout the painters draw and `textLineBoxes` picks against, so the caret\n * cannot land on a different line — or between different glyphs — than the\n * one under the pointer.\n */\n\nimport { layoutTextPose } from '@weasel-js/text';\nimport type { LaidOutCell, TextPose } from '@weasel-js/text';\n\n/**\n * Merge neighboring cells drawn from one source character — the two `S`s an\n * uppercased `ß` becomes — into one cell spanning both, so no caret stop falls\n * between them.\n */\nfunction sourceClusters(cells: readonly LaidOutCell[]): LaidOutCell[] {\n const out: LaidOutCell[] = [];\n for (const c of cells) {\n const prev = out[out.length - 1];\n if (prev && prev.srcIndex === c.srcIndex && prev.srcEnd === c.srcEnd) {\n const x0 = Math.min(prev.x, c.x);\n const x1 = Math.max(prev.x + prev.advance, c.x + c.advance);\n out[out.length - 1] = { ...prev, x: x0, advance: x1 - x0 };\n } else {\n out.push(c);\n }\n }\n return out;\n}\n\n/** Options for `pointInTextPose`. */\nexport interface PointInTextPoseOpts {\n /** Extra padding (world units) added to the rect on all sides. Default 0. */\n padding?: number;\n}\n\n/** Coarse pose-rect hit-test for a text node — suitable for click-to-edit dispatch. */\nexport function pointInTextPose(\n x: number,\n y: number,\n pose: TextPose,\n opts: PointInTextPoseOpts = {},\n): boolean {\n const p = opts.padding ?? 0;\n return (\n x >= pose.x - p &&\n x <= pose.x + pose.width + p &&\n y >= pose.y - p &&\n y <= pose.y + pose.height + p\n );\n}\n\n/**\n * Map a world-space point inside `pose` to a character offset into the pose's\n * text (0..length). Clicks above the first line clamp to 0; clicks below the\n * last line clamp to the end. Within a line, the caret lands between two\n * glyphs at whichever side of the advance cell's midpoint `x` falls on — the\n * standard \"snap caret to nearest character boundary\" rule.\n *\n * Honors `pose.runs` (a mixed-size line snaps on the cells each run actually\n * produced) and `pose.verticalAlign`. The offset is into the runs'\n * concatenated text, which `TextPose` requires to equal `pose.text`.\n */\nexport function caretIndexAt(x: number, y: number, pose: TextPose): number {\n const { laid, x: dx, y: dy } = layoutTextPose(pose);\n const lines = laid.lines;\n if (lines.length === 0) return 0;\n\n const last = lines[lines.length - 1];\n if (y < dy + lines[0].y0) return lines[0].cells[0]?.srcIndex ?? lines[0].srcEnd;\n if (y >= dy + last.y1) return last.srcEnd;\n\n let line = last;\n for (const candidate of lines) {\n if (y < dy + candidate.y1) { line = candidate; break; }\n }\n\n // Cells are in logical order and their x values need not ascend, so the\n // sweep has to be in visual order and each cell's own extent is what it is\n // tested against — the next cell along is not its right edge.\n if (line.cells.length === 0) return line.srcEnd;\n const cells = sourceClusters(line.cells);\n const visual = cells.map((_, i) => i).sort((a, b) => cells[a].x - cells[b].x);\n\n for (const i of visual) {\n const c = cells[i];\n if (x >= dx + c.x + c.advance / 2) continue;\n // A right-to-left cell reads the other way, so its visually-leading half\n // is the character's logical end.\n return c.level % 2 === 1 ? c.srcEnd : c.srcIndex;\n }\n const trailing = cells[visual[visual.length - 1]];\n return trailing.level % 2 === 1 ? trailing.srcIndex : trailing.srcEnd;\n}\n"],"mappings":";;AAuBA,SAASA,EAAe,GAA8C;CACpE,IAAMC,IAAqB,CAAC;CAC5B,KAAK,IAAMC,KAAKC,GAAO;EACrB,IAAMC,IAAOH,EAAIA,EAAI,SAAS;EAC9B,IAAIG,KAAQA,EAAK,aAAaF,EAAE,YAAYE,EAAK,WAAWF,EAAE,QAAQ;GACpE,IAAMG,IAAK,KAAK,IAAID,EAAK,GAAGF,EAAE,CAAC,GACzBI,IAAK,KAAK,IAAIF,EAAK,IAAIA,EAAK,SAASF,EAAE,IAAIA,EAAE,OAAO;GAC1D,EAAID,EAAI,SAAS,KAAK;IAAE,GAAGG;IAAM,GAAGC;IAAI,SAASC,IAAKD;GAAG;EAC3D,OACE,EAAI,KAAK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AAQ,KAAM,IAAIA,EAAS,WAAWA,EAAS;AACjE"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/features/text/renderLabel.ts
|
|
2
|
-
function e(e, n, r, i, a = {}) {
|
|
3
|
-
let { align: o = "center", fontSize: s = 13, renderText: c, width: l, height: u, padX: d = 4, padY: f = 1, cornerRadius: p = 3 } = a;
|
|
4
|
-
e.save(), e.font = `${s}px sans-serif`, e.textBaseline = "top";
|
|
5
|
-
let m = l ?? e.measureText(n).width, h = u ?? s, g = m + d * 2, _ = h + f * 2, v = o === "center" ? r - g / 2 : r - d;
|
|
6
|
-
e.fillStyle = "rgba(0, 0, 0, 0.75)", e.beginPath(), e.roundRect(v, i - f, g, _, p), e.fill(), e.textAlign = o === "center" ? "center" : "left", (c ?? t)(e, n, r, i), e.restore();
|
|
7
|
-
}
|
|
8
|
-
var t = (e, t, n, r) => {
|
|
9
|
-
e.fillStyle = "#FFFFFF", e.fillText(t, n, r);
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { t as defaultLabelTextRenderer, e as renderLabel };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=renderLabel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderLabel.js","names":["renderLabel","options","ctx","fontSize","contentW","width","text","contentH","height","w","padX","h","padY","rx","align","x","y","cornerRadius","renderText","defaultLabelTextRenderer"],"sources":["../../../src/features/text/renderLabel.ts"],"sourcesContent":["import type { TextRenderer } from '@weasel-js/text';\n\n\n/** Visual options for `renderLabel`. */\nexport interface LabelOptions {\n align?: 'center' | 'left';\n fontSize?: number;\n renderText?: TextRenderer;\n /** Override the pill width (content width, excluding padding). */\n width?: number;\n /** Override the pill height (content height, excluding padding). */\n height?: number;\n /** Horizontal padding inside the pill. Default 4 (screen-pixel default). */\n padX?: number;\n /** Vertical padding inside the pill. Default 1 (screen-pixel default). */\n padY?: number;\n /** Corner radius of the pill background. Default 3 (screen-pixel default). */\n cornerRadius?: number;\n}\n\n/** Render a text label with a 75%-opaque black pill background and white text. */\nexport function renderLabel(\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n options: LabelOptions = {},\n): void {\n const {\n align = 'center',\n fontSize = 13,\n renderText,\n width,\n height,\n padX = 4,\n padY = 1,\n cornerRadius = 3,\n } = options;\n\n ctx.save();\n ctx.font = `${fontSize}px sans-serif`;\n ctx.textBaseline = 'top';\n const contentW = width ?? ctx.measureText(text).width;\n const contentH = height ?? fontSize;\n const w = contentW + padX * 2;\n const h = contentH + padY * 2;\n const rx = align === 'center' ? x - w / 2 : x - padX;\n\n ctx.fillStyle = 'rgba(0, 0, 0, 0.75)';\n ctx.beginPath();\n ctx.roundRect(rx, y - padY, w, h, cornerRadius);\n ctx.fill();\n\n ctx.textAlign = align === 'center' ? 'center' : 'left';\n const tx = align === 'center' ? x : x;\n (renderText ?? defaultLabelTextRenderer)(ctx, text, tx, y);\n ctx.restore();\n}\n\n/** Default `TextRenderer` used by `renderLabel`: white fill, no styling. */\nexport const defaultLabelTextRenderer: TextRenderer = (ctx, text, x, y) => {\n ctx.fillStyle = '#FFFFFF';\n ctx.fillText(text, x, y);\n};\n"],"mappings":";AAqBA,SAAgBA,EACd,GACA,GACA,GACA,GACA,IAAwB,CAAC,GACnB;CACN,IAAM,EACJ,WAAQ,UACR,cAAW,IACX,eACA,UACA,WACA,UAAO,GACP,UAAO,GACP,kBAAe,MACbC;CAIJ,AAFAC,EAAI,KAAK,GACT,EAAI,OAAO,GAAGC,EAAS,gBACvB,EAAI,eAAe;CACnB,IAAMC,IAAWC,KAASH,EAAI,YAAYI,CAAI,CAAC,CAAC,OAC1CC,IAAWC,KAAUL,GACrBM,IAAIL,IAAWM,IAAO,GACtBC,IAAIJ,IAAWK,IAAO,GACtBC,IAAKC,MAAU,WAAWC,IAAIN,IAAI,IAAIM,IAAIL;CAUhD,AARA,EAAI,YAAY,uBAChBR,EAAI,UAAU,GACdA,EAAI,UAAUW,GAAIG,IAAIJ,GAAMH,GAAGE,GAAGM,CAAY,GAC9Cf,EAAI,KAAK,GAET,EAAI,YAAYY,MAAU,WAAW,WAAW,SAE/CI,KAAcC,EAAA,CAA0BjB,GAAKI,GADdS,GACwBC,CAAC,GACzDd,EAAI,QAAQ;AACd;AAGA,IAAaiB,KAA0C,GAAK,GAAM,GAAG,MAAM;CAEzE,AADA,EAAI,YAAY,WAChBjB,EAAI,SAASI,GAAMS,GAAGC,CAAC;AACzB"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { MIXED as e } from "../../../core/mixed.js";
|
|
2
|
-
import { nodeHasFlag as t } from "./flagRange.js";
|
|
3
|
-
import { isBoldWeight as n, numericWeight as r, resolveTextStyle as i } from "@weasel-js/text";
|
|
4
|
-
//#region src/features/text/runs/effectiveRangeStyle.ts
|
|
5
|
-
var a = [
|
|
6
|
-
"italic",
|
|
7
|
-
"underline",
|
|
8
|
-
"strikethrough",
|
|
9
|
-
"overline"
|
|
10
|
-
];
|
|
11
|
-
function o(t, i) {
|
|
12
|
-
let a = r(i?.fontWeight ?? 400), o = t?.fontWeight;
|
|
13
|
-
if (o === e) return {
|
|
14
|
-
fontWeight: e,
|
|
15
|
-
bold: e
|
|
16
|
-
};
|
|
17
|
-
if (o !== void 0) return {
|
|
18
|
-
fontWeight: o,
|
|
19
|
-
bold: n(o)
|
|
20
|
-
};
|
|
21
|
-
let s = t?.bold;
|
|
22
|
-
if (s === e) return a === 700 ? {
|
|
23
|
-
fontWeight: 700,
|
|
24
|
-
bold: !0
|
|
25
|
-
} : {
|
|
26
|
-
fontWeight: e,
|
|
27
|
-
bold: n(a) ? !0 : e
|
|
28
|
-
};
|
|
29
|
-
let c = s === !0 ? 700 : a;
|
|
30
|
-
return {
|
|
31
|
-
fontWeight: c,
|
|
32
|
-
bold: n(c)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
var s = [
|
|
36
|
-
"fontFamily",
|
|
37
|
-
"fontSize",
|
|
38
|
-
"letterSpacing",
|
|
39
|
-
"fill",
|
|
40
|
-
"script",
|
|
41
|
-
"baselineShift",
|
|
42
|
-
"fontScale",
|
|
43
|
-
"textTransform",
|
|
44
|
-
"fontVariantCaps"
|
|
45
|
-
];
|
|
46
|
-
function c(e, n, r) {
|
|
47
|
-
let c = i(n, r), l = n ?? {}, u = {
|
|
48
|
-
fontFamily: c.fontFamily,
|
|
49
|
-
fontSize: c.fontSize,
|
|
50
|
-
letterSpacing: c.letterSpacing,
|
|
51
|
-
textTransform: c.textTransform,
|
|
52
|
-
fontVariantCaps: c.fontVariantCaps
|
|
53
|
-
};
|
|
54
|
-
c.fill !== null && (u.fill = c.fill), Object.assign(u, o(e, n));
|
|
55
|
-
for (let n of a) {
|
|
56
|
-
let r = t(l, n), i = e?.[n];
|
|
57
|
-
u[n] = r || i === void 0 ? r : i;
|
|
58
|
-
}
|
|
59
|
-
if (e === null) return u;
|
|
60
|
-
for (let t of s) e[t] !== void 0 && (u[t] = e[t]);
|
|
61
|
-
return u;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { c as effectiveRangeStyle, o as rangeWeight };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=effectiveRangeStyle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectiveRangeStyle.js","names":["FLAGS","rangeWeight","node","numericWeight","style","own","range","MIXED","isBoldWeight","flag","weight","OVERRIDES","effectiveRangeStyle","resolved","resolveTextStyle","paint","out","key","on","nodeHasFlag","run"],"sources":["../../../../src/features/text/runs/effectiveRangeStyle.ts"],"sourcesContent":["import { isBoldWeight, numericWeight, resolveTextStyle } from '@weasel-js/text';\nimport type { TextPaint, TextStyle } from '@weasel-js/text';\nimport { nodeHasFlag } from './flagRange';\nimport { MIXED } from './rangeStyle';\nimport type { Mixed, RangeStyle } from './rangeStyle';\n\nconst FLAGS = ['italic', 'underline', 'strikethrough', 'overline'] as const;\n\n/**\n * The weight a range renders at, and whether that reads as bold, resolved as\n * `resolveRuns` resolves a run: its own `fontWeight`, else 700 for `bold`,\n * else the node's weight.\n */\nexport function rangeWeight(\n range: RangeStyle | null,\n style: TextStyle | undefined,\n): { fontWeight: number | Mixed; bold: boolean | Mixed } {\n const node = numericWeight(style?.fontWeight ?? 400);\n const own = range?.fontWeight;\n if (own === MIXED) return { fontWeight: MIXED, bold: MIXED };\n if (own !== undefined) return { fontWeight: own, bold: isBoldWeight(own) };\n const flag = range?.bold;\n if (flag === MIXED) {\n // Flagged runs draw at 700, the rest at the node's weight.\n if (node === 700) return { fontWeight: 700, bold: true };\n return { fontWeight: MIXED, bold: isBoldWeight(node) ? true : MIXED };\n }\n const weight = flag === true ? 700 : node;\n return { fontWeight: weight, bold: isBoldWeight(weight) };\n}\n\n/** Keys a run overrides outright. `script` and the two primitives it presets\n * have no node-level counterpart, so they only ever come from the range. */\nconst OVERRIDES = [\n 'fontFamily', 'fontSize', 'letterSpacing', 'fill', 'script', 'baselineShift', 'fontScale',\n 'textTransform', 'fontVariantCaps',\n] as const;\n\n/**\n * What is actually rendering across a range: `range` (from `styleAtRange`,\n * or `useTextEdit`'s `rangeStyle`) resolved against the node's own `style`\n * and `paint`, as the canvas resolves runs. `null` reads the node alone.\n *\n * Flags are additive — a run can turn one on, never off — so a node flag\n * makes the flag `true` across the range, `MIXED` runs included. Every other\n * key is the run's value where the range sets one, otherwise the node's.\n * The node level is resolved first, so the result has a value for every\n * key but the run-only ones, and for `fill` unless the node is unfilled.\n * Bold is read off the weight that renders (see {@link rangeWeight}), since\n * a run's own `fontWeight` can take a bold node's text back to regular.\n */\nexport function effectiveRangeStyle(\n range: RangeStyle | null,\n style: TextStyle | undefined,\n paint?: TextPaint,\n): RangeStyle {\n const resolved = resolveTextStyle(style, paint);\n const node = style ?? {};\n const out: RangeStyle = {\n fontFamily: resolved.fontFamily,\n fontSize: resolved.fontSize,\n letterSpacing: resolved.letterSpacing,\n textTransform: resolved.textTransform,\n fontVariantCaps: resolved.fontVariantCaps,\n };\n if (resolved.fill !== null) out.fill = resolved.fill;\n Object.assign(out, rangeWeight(range, style));\n for (const key of FLAGS) {\n const on = nodeHasFlag(node, key);\n const run = range?.[key];\n out[key] = on || run === undefined ? on : run;\n }\n if (range === null) return out;\n for (const key of OVERRIDES) {\n if (range[key] !== undefined) (out as Record<string, unknown>)[key] = range[key];\n }\n return out;\n}\n"],"mappings":";;;;AAMA,IAAMA,IAAQ;CAAC;CAAU;CAAa;CAAiB;AAAU;AAOjE,SAAgBC,EACd,GACA,GACuD;CACvD,IAAMC,IAAOC,EAAcC,GAAO,cAAc,GAAG,GAC7CC,IAAMC,GAAO;CACnB,IAAID,MAAQE,GAAO,OAAO;EAAE,YAAYA;EAAO,MAAMA;CAAM;CAC3D,IAAIF,MAAQ,KAAA,GAAW,OAAO;EAAE,YAAYA;EAAK,MAAMG,EAAaH,CAAG;CAAE;CACzE,IAAMI,IAAOH,GAAO;CACpB,IAAIG,MAASF,GAGX,OADIL,MAAS,MAAY;EAAE,YAAY;EAAK,MAAM;CAAK,IAChD;EAAE,YAAYK;EAAO,MAAMC,EAAaN,CAAI,IAAI,KAAOK;CAAM;CAEtE,IAAMG,IAASD,MAAS,KAAO,MAAMP;CACrC,OAAO;EAAE,YAAYQ;EAAQ,MAAMF,EAAaE,CAAM;CAAE;AAC1D;AAIA,IAAMC,IAAY;CAChB;CAAc;CAAY;CAAiB;CAAQ;CAAU;CAAiB;CAC9E;CAAiB;AACnB;AAeA,SAAgBC,EACd,GACA,GACA,GACY;CACZ,IAAMC,IAAWC,EAAiBV,GAAOW,CAAK,GACxCb,IAAOE,KAAS,CAAC,GACjBY,IAAkB;EACtB,YAAYH,EAAS;EACrB,UAAUA,EAAS;EACnB,eAAeA,EAAS;EACxB,eAAeA,EAAS;EACxB,iBAAiBA,EAAS;CAC5B;CAEA,AADIA,EAAS,SAAS,SAAM,EAAI,OAAOA,EAAS,OAChD,OAAO,OAAOG,GAAKf,EAAYK,GAAOF,CAAK,CAAC;CAC5C,KAAK,IAAMa,KAAOjB,GAAO;EACvB,IAAMkB,IAAKC,EAAYjB,GAAMe,CAAG,GAC1BG,IAAMd,IAAQW;EACpB,EAAIA,KAAOC,KAAME,MAAQ,KAAA,IAAYF,IAAKE;CAC5C;CACA,IAAId,MAAU,MAAM,OAAOU;CAC3B,KAAK,IAAMC,KAAON,GAChB,AAAIL,EAAMW,OAAS,KAAA,MAAW,EAAiCA,KAAOX,EAAMW;CAE9E,OAAOD;AACT"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { applyStyleToRange as e } from "./rangeStyle.js";
|
|
2
|
-
import { isBoldWeight as t } from "@weasel-js/text";
|
|
3
|
-
//#region src/features/text/runs/flagRange.ts
|
|
4
|
-
function n(e, n) {
|
|
5
|
-
switch (n) {
|
|
6
|
-
case "bold": return e.fontWeight !== void 0 && t(e.fontWeight);
|
|
7
|
-
case "italic": return e.fontStyle === "italic";
|
|
8
|
-
case "underline": return e.underline === !0;
|
|
9
|
-
case "strikethrough": return e.strikethrough === !0;
|
|
10
|
-
case "overline": return e.overline === !0;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function r(e) {
|
|
14
|
-
return n(e, "bold") ? {
|
|
15
|
-
bold: !1,
|
|
16
|
-
fontWeight: 400
|
|
17
|
-
} : { bold: !1 };
|
|
18
|
-
}
|
|
19
|
-
function i(e, t) {
|
|
20
|
-
let n = { ...e };
|
|
21
|
-
switch (t) {
|
|
22
|
-
case "italic":
|
|
23
|
-
n.fontStyle = "normal";
|
|
24
|
-
break;
|
|
25
|
-
case "underline":
|
|
26
|
-
delete n.underline;
|
|
27
|
-
break;
|
|
28
|
-
case "strikethrough":
|
|
29
|
-
delete n.strikethrough;
|
|
30
|
-
break;
|
|
31
|
-
case "overline": delete n.overline;
|
|
32
|
-
}
|
|
33
|
-
return n;
|
|
34
|
-
}
|
|
35
|
-
function a(t, a, o, s, c, l) {
|
|
36
|
-
if (l || !n(a, c)) return {
|
|
37
|
-
runs: e(t, o, s, { [c]: l }),
|
|
38
|
-
style: a
|
|
39
|
-
};
|
|
40
|
-
if (c === "bold") return {
|
|
41
|
-
runs: e(t, o, s, r(a)),
|
|
42
|
-
style: a
|
|
43
|
-
};
|
|
44
|
-
let u = t.reduce((e, t) => e + t.text.length, 0), d = Math.max(0, o), f = Math.min(u, s), p = e(t, 0, u, { [c]: !0 });
|
|
45
|
-
return d < f && (p = e(p, d, f, { [c]: !1 })), {
|
|
46
|
-
runs: p,
|
|
47
|
-
style: i(a, c)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { n as nodeHasFlag, a as setFlagOverRange, r as unboldPatch };
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=flagRange.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flagRange.js","names":["nodeHasFlag","key","style","isBoldWeight","unboldPatch","clearNodeFlag","next","setFlagOverRange","value","applyStyleToRange","runs","start","end","total","n","r","lo","hi"],"sources":["../../../../src/features/text/runs/flagRange.ts"],"sourcesContent":["/**\n * Turning a run-level flag **off** inside a node that sets it.\n *\n * Run flags are additive over the node's `TextStyle` — a run turns `bold` /\n * `italic` / `underline` / `strikethrough` on, never off (see the contract at\n * the top of `rangeStyle.ts`). So \"select a word inside an underlined node and\n * hit U\" is unrepresentable by the stored shape, and the character bar can\n * only refuse.\n *\n * This resolves it by rewriting rather than by widening the model: clear the\n * flag on the node, and set it on every run *outside* the range. The rendered\n * result is identical and the edit becomes expressible, with `StyledRun`\n * unchanged — so nothing a document can already contain changes meaning, which\n * matters while the flags are heading for a persisted format.\n *\n * The alternative was a tri-state run flag (`true` / `false` / inherit). It\n * cannot cover `italic`: that is a boolean on a run but `fontStyle` on the\n * node, so a run's `false` has no node-level boolean to override.\n *\n * `bold` needs neither: a run carries a numeric `fontWeight`, which overrides\n * the node's outright, so lowering bold writes a regular weight over the\n * range and leaves the node and the rest of the text alone.\n */\n\nimport { isBoldWeight } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextStyle } from '@weasel-js/text';\nimport { applyStyleToRange } from './rangeStyle';\nimport type { RunStylePatch } from './rangeStyle';\n\n/** The additive run flags. */\nexport type FlagKey = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'overline';\n\n/** The result of toggling a style flag over a text range: the rewritten runs\n * and node style, and whether the change could be made at all. */\nexport interface SetFlagResult {\n runs: StyledRun[];\n style: TextStyle;\n}\n\n/** Does the node style carry this flag? */\nexport function nodeHasFlag(style: TextStyle, key: FlagKey): boolean {\n switch (key) {\n case 'bold': return style.fontWeight !== undefined && isBoldWeight(style.fontWeight);\n case 'italic': return style.fontStyle === 'italic';\n case 'underline': return style.underline === true;\n case 'strikethrough': return style.strikethrough === true;\n case 'overline': return style.overline === true;\n }\n}\n\n/** The patch that takes bold off a range: the flag, and — in a node that is\n * itself bold — a regular weight to override the node's. */\nexport function unboldPatch(style: TextStyle): RunStylePatch {\n return nodeHasFlag(style, 'bold') ? { bold: false, fontWeight: 400 } : { bold: false };\n}\n\n/** The node style with `key` cleared. */\nfunction clearNodeFlag(style: TextStyle, key: Exclude<FlagKey, 'bold'>): TextStyle {\n const next = { ...style };\n switch (key) {\n case 'italic': next.fontStyle = 'normal'; break;\n case 'underline': delete next.underline; break;\n case 'strikethrough': delete next.strikethrough; break;\n case 'overline': delete next.overline; break;\n }\n return next;\n}\n\n/**\n * Set `key` to `value` over `[start, end)`.\n *\n * Turning a flag **on**, or off in a node that doesn't set it, is the ordinary\n * additive write and leaves `style` alone. Turning it off in a node that *does*\n * set it takes the rewrite: the node flag is cleared and the flag is written\n * onto the complement of the range. Bold is the exception, written as a\n * weight over the range alone (see {@link unboldPatch}).\n *\n * `runs` is normalized on every path, so the complement collapses back to one\n * run when the range is empty and the whole array coalesces as usual.\n */\nexport function setFlagOverRange(\n runs: readonly StyledRun[],\n style: TextStyle,\n start: number,\n end: number,\n key: FlagKey,\n value: boolean,\n): SetFlagResult {\n if (value || !nodeHasFlag(style, key)) {\n return { runs: applyStyleToRange(runs, start, end, { [key]: value }), style };\n }\n\n if (key === 'bold') {\n return { runs: applyStyleToRange(runs, start, end, unboldPatch(style)), style };\n }\n\n const total = runs.reduce((n, r) => n + r.text.length, 0);\n const lo = Math.max(0, start);\n const hi = Math.min(total, end);\n\n // Raise the flag on everything, then lower it over the range. Doing it in\n // that order rather than patching the two complement spans keeps one code\n // path for a range at either edge, where one span is empty.\n let next = applyStyleToRange(runs, 0, total, { [key]: true });\n if (lo < hi) next = applyStyleToRange(next, lo, hi, { [key]: false });\n\n return { runs: next, style: clearNodeFlag(style, key) };\n}\n"],"mappings":";;;AAyCA,SAAgBA,EAAY,GAAkB,GAAuB;CACnE,QAAQC,GAAR;EACE,KAAK,QAAQ,OAAOC,EAAM,eAAe,KAAA,KAAaC,EAAaD,EAAM,UAAU;EACnF,KAAK,UAAU,OAAOA,EAAM,cAAc;EAC1C,KAAK,aAAa,OAAOA,EAAM,cAAc;EAC7C,KAAK,iBAAiB,OAAOA,EAAM,kBAAkB;EACrD,KAAK,YAAY,OAAOA,EAAM,aAAa;CAC7C;AACF;AAIA,SAAgBE,EAAY,GAAiC;CAC3D,OAAOJ,EAAYE,GAAO,MAAM,IAAI;EAAE,MAAM;EAAO,YAAY;CAAI,IAAI,EAAE,MAAM,GAAM;AACvF;AAGA,SAASG,EAAc,GAAkB,GAA0C;CACjF,IAAMC,IAAO,EAAE,GAAGJ,EAAM;CACxB,QAAQD,GAAR;EACE,KAAK;GAAU,EAAK,YAAY;GAAU;EAC1C,KAAK;GAAa,OAAOK,EAAK;GAAW;EACzC,KAAK;GAAiB,OAAOA,EAAK;GAAe;EACjD,KAAK,YAAY,OAAOA,EAAK;CAC/B;CACA,OAAOA;AACT;AAcA,SAAgBC,EACd,GACA,GACA,GACA,GACA,GACA,GACe;CACf,IAAIC,KAAS,CAACR,EAAYE,GAAOD,CAAG,GAClC,OAAO;EAAE,MAAMQ,EAAkBC,GAAMC,GAAOC,GAAK,GAAGX,IAAMO,EAAM,CAAC;EAAG;CAAM;CAG9E,IAAIP,MAAQ,QACV,OAAO;EAAE,MAAMQ,EAAkBC,GAAMC,GAAOC,GAAKR,EAAYF,CAAK,CAAC;EAAG;CAAM;CAGhF,IAAMW,IAAQH,EAAK,QAAQ,GAAG,MAAMI,IAAIC,EAAE,KAAK,QAAQ,CAAC,GAClDC,IAAK,KAAK,IAAI,GAAGL,CAAK,GACtBM,IAAK,KAAK,IAAIJ,GAAOD,CAAG,GAK1BN,IAAOG,EAAkBC,GAAM,GAAGG,GAAO,GAAGZ,IAAM,GAAK,CAAC;CAG5D,OAFIe,IAAKC,MAAI,IAAOR,EAAkBH,GAAMU,GAAIC,GAAI,GAAGhB,IAAM,GAAM,CAAC,IAE7D;EAAE,MAAMK;EAAM,OAAOD,EAAcH,GAAOD,CAAG;CAAE;AACxD"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { MIXED as e } from "../../../core/mixed.js";
|
|
2
|
-
//#region src/features/text/runs/rangeStyle.ts
|
|
3
|
-
var t = [
|
|
4
|
-
"bold",
|
|
5
|
-
"fontWeight",
|
|
6
|
-
"italic",
|
|
7
|
-
"underline",
|
|
8
|
-
"strikethrough",
|
|
9
|
-
"overline",
|
|
10
|
-
"fontFamily",
|
|
11
|
-
"fontSize",
|
|
12
|
-
"letterSpacing",
|
|
13
|
-
"fill",
|
|
14
|
-
"stroke",
|
|
15
|
-
"script",
|
|
16
|
-
"baselineShift",
|
|
17
|
-
"fontScale",
|
|
18
|
-
"textTransform",
|
|
19
|
-
"fontVariantCaps"
|
|
20
|
-
], n = /* @__PURE__ */ new Set([
|
|
21
|
-
"bold",
|
|
22
|
-
"italic",
|
|
23
|
-
"underline",
|
|
24
|
-
"strikethrough",
|
|
25
|
-
"overline"
|
|
26
|
-
]);
|
|
27
|
-
function r(e) {
|
|
28
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
29
|
-
}
|
|
30
|
-
function i(e, t) {
|
|
31
|
-
if (Object.is(e, t)) return !0;
|
|
32
|
-
if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => i(e, t[n]));
|
|
33
|
-
if (r(e) && r(t)) {
|
|
34
|
-
let n = Object.keys(e);
|
|
35
|
-
return n.length === Object.keys(t).length && n.every((n) => n in t && i(e[n], t[n]));
|
|
36
|
-
}
|
|
37
|
-
return !1;
|
|
38
|
-
}
|
|
39
|
-
function a(e, t) {
|
|
40
|
-
let r = e[t];
|
|
41
|
-
return n.has(t) ? r ?? !1 : r;
|
|
42
|
-
}
|
|
43
|
-
var o = /* @__PURE__ */ new Set(["fill", "stroke"]);
|
|
44
|
-
function s(e, t, n) {
|
|
45
|
-
return o.has(e) ? i(t, n) : Object.is(t, n);
|
|
46
|
-
}
|
|
47
|
-
function c(e, n) {
|
|
48
|
-
return t.every((t) => s(t, a(e, t), a(n, t)));
|
|
49
|
-
}
|
|
50
|
-
function l(e) {
|
|
51
|
-
let t = 0;
|
|
52
|
-
for (let n of e) t += n.text.length;
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
function u(n, r, i) {
|
|
56
|
-
let o = Math.max(0, r), c = i;
|
|
57
|
-
if (!(o < c)) return {};
|
|
58
|
-
let l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = !1, f = 0;
|
|
59
|
-
for (let e of n) {
|
|
60
|
-
let n = f + e.text.length, r = Math.max(f, o), i = Math.min(n, c);
|
|
61
|
-
if (f = n, r < i) {
|
|
62
|
-
for (let n of t) {
|
|
63
|
-
let t = a(e, n);
|
|
64
|
-
d ? !u.has(n) && !s(n, l.get(n), t) && u.add(n) : l.set(n, t);
|
|
65
|
-
}
|
|
66
|
-
d = !0;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (!d) return {};
|
|
70
|
-
let p = {};
|
|
71
|
-
for (let n of t) if (u.has(n)) p[n] = e;
|
|
72
|
-
else {
|
|
73
|
-
let e = l.get(n);
|
|
74
|
-
e !== void 0 && (p[n] = e);
|
|
75
|
-
}
|
|
76
|
-
return p;
|
|
77
|
-
}
|
|
78
|
-
function d(e) {
|
|
79
|
-
return e.some((e) => t.some((t) => {
|
|
80
|
-
let n = e[t];
|
|
81
|
-
return n !== void 0 && n !== !1;
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
function f(e) {
|
|
85
|
-
if ("bold" in e && !("fontWeight" in e)) return "fontWeight";
|
|
86
|
-
if (e.fontWeight !== void 0 && !("bold" in e)) return "bold";
|
|
87
|
-
}
|
|
88
|
-
function p(e, t) {
|
|
89
|
-
let n = { ...e }, r = f(t);
|
|
90
|
-
r !== void 0 && delete n[r];
|
|
91
|
-
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
|
|
92
|
-
return n;
|
|
93
|
-
}
|
|
94
|
-
function m(e, n) {
|
|
95
|
-
let r = { ...e }, i = f(n);
|
|
96
|
-
i !== void 0 && delete r[i];
|
|
97
|
-
for (let e of t) {
|
|
98
|
-
if (!(e in n)) continue;
|
|
99
|
-
let t = n[e];
|
|
100
|
-
t === void 0 || t === !1 ? delete r[e] : r[e] = t;
|
|
101
|
-
}
|
|
102
|
-
return r;
|
|
103
|
-
}
|
|
104
|
-
function h(e) {
|
|
105
|
-
let t = [];
|
|
106
|
-
for (let n of e) {
|
|
107
|
-
if (n.text.length === 0) continue;
|
|
108
|
-
let e = t[t.length - 1];
|
|
109
|
-
e && c(e, n) ? e.text += n.text : t.push({ ...n });
|
|
110
|
-
}
|
|
111
|
-
return t;
|
|
112
|
-
}
|
|
113
|
-
function g(e, t, n, r) {
|
|
114
|
-
let i = Math.max(0, t), a = Math.min(l(e), n);
|
|
115
|
-
if (!(i < a)) return h(e);
|
|
116
|
-
let o = [], s = 0;
|
|
117
|
-
for (let t of e) {
|
|
118
|
-
let e = s + t.text.length, n = Math.max(s, i), c = Math.min(e, a);
|
|
119
|
-
n < c ? (s < n && o.push({
|
|
120
|
-
...t,
|
|
121
|
-
text: t.text.slice(0, n - s)
|
|
122
|
-
}), o.push(m({
|
|
123
|
-
...t,
|
|
124
|
-
text: t.text.slice(n - s, c - s)
|
|
125
|
-
}, r)), c < e && o.push({
|
|
126
|
-
...t,
|
|
127
|
-
text: t.text.slice(c - s)
|
|
128
|
-
})) : o.push({ ...t }), s = e;
|
|
129
|
-
}
|
|
130
|
-
return h(o);
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
export { e as MIXED, g as applyStyleToRange, p as patchRangeStyle, d as runsCarryStyling, u as styleAtRange, f as supersededKey };
|
|
134
|
-
|
|
135
|
-
//# sourceMappingURL=rangeStyle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rangeStyle.js","names":["STYLE_KEYS","FLAG_KEYS","isPlainObject","v","deepEqual","a","b","item","i","keys","k","valueAt","value","run","key","STRUCTURAL_KEYS","sameValue","sameStyle","totalLength","n","runs","styleAtRange","lo","start","hi","end","first","mixed","seen","pos","runEnd","style","MIXED","runsCarryStyling","supersededKey","patch","patchRangeStyle","out","range","superseded","patchRun","next","coalesceRuns","prev","applyStyleToRange"],"sources":["../../../../src/features/text/runs/rangeStyle.ts"],"sourcesContent":["/**\n * Range-addressed styling over `StyledRun[]`. The panel addresses node paths;\n * a caret addresses a character range — these are the functions for the\n * second case. Pure and React-free so the semantics are unit-testable, the\n * same split `SelectionPanel` makes between `model.ts` and its component.\n *\n * Character offsets index the concatenated run text (`runsToPlainText`), and\n * a range is half-open: `[start, end)`. Ranges are clamped, never wrapped —\n * a negative `start` clamps to 0, an `end` past the text clamps to its\n * length, and a collapsed or inverted range (`start >= end`) is empty.\n * Offsets are UTF-16 code units, as everywhere else in this feature, so a\n * boundary can bisect a surrogate pair (`[1, 2)` over `'a👍b'` splits the\n * thumbs-up into lone surrogates). A caret-derived range never does this.\n *\n * **Run-level flags are additive over the node's `TextStyle`: a run can\n * turn `bold` / `italic` / `underline` / `strikethrough` on, never off.**\n * So a flag is stored only when true, and absent reads as `false`. A run\n * that must be lighter than a bold node says so with its own numeric\n * `fontWeight`, which `bold` is a preset over (see {@link supersededKey}).\n * For the boolean decorations there is no such primitive: both levels are\n * booleans, so a tri-state\n * (`true` / `false` / inherit) is expressible and we are collapsing it by\n * choice, to keep one canonical form per styling. Resolution must therefore\n * read decorations as `run.underline || style.underline` — a `??` would\n * make \"select a word in an underlined node, hit U to turn it off\" look\n * supported by the type while this file discards the `false` that expresses it.\n *\n * Copies here are shallow: a `fill` object is shared by reference between\n * the input runs, the patch, every run the patch touched, and the value\n * `styleAtRange` reports. Treat `fill` values as immutable.\n */\n\nimport { MIXED } from 'core/mixed';\nimport type { Mixed } from 'core/mixed';\nimport type { StyledRun } from '@weasel-js/text';\n\nexport { MIXED };\nexport type { Mixed };\n\n/** Every styleable key of a run, each either a concrete value or MIXED (the\n * runs in the range disagree at that key). */\nexport type RangeStyle = {\n [K in Exclude<keyof StyledRun, 'text'>]?: StyledRun[K] | Mixed;\n};\n\n/**\n * What `applyStyleToRange` writes. `text` is deliberately not part of it —\n * this is a styling operation, not an edit.\n */\nexport type RunStylePatch = Partial<Omit<StyledRun, 'text'>>;\n\n/** Every key of a run that carries styling — i.e. everything but `text`. */\nexport type StyleKey = Exclude<keyof StyledRun, 'text'>;\n\nconst STYLE_KEYS = [\n 'bold',\n 'fontWeight',\n 'italic',\n 'underline',\n 'strikethrough',\n 'overline',\n 'fontFamily',\n 'fontSize',\n 'letterSpacing',\n 'fill',\n 'stroke',\n 'script',\n 'baselineShift',\n 'fontScale',\n 'textTransform',\n 'fontVariantCaps',\n] as const satisfies readonly StyleKey[];\n\n// Every function here iterates STYLE_KEYS, so a key missing from the list is\n// invisible: `applyStyleToRange` would drop it when patching a run and\n// `sameStyle` would merge two runs that differ in it, silently discarding\n// one value. `satisfies` only checks the entries that ARE listed, so this\n// assertion checks the other direction — adding a key to `StyledRun`\n// without adding it here is a compile error.\ntype MissingStyleKey = Exclude<StyleKey, (typeof STYLE_KEYS)[number]>;\ntype AssertNoMissingStyleKey = [MissingStyleKey] extends [never] ? true : never;\nconst STYLE_KEYS_ARE_EXHAUSTIVE: AssertNoMissingStyleKey = true;\nvoid STYLE_KEYS_ARE_EXHAUSTIVE;\n\n/** The additive flags: absent and `false` mean the same thing, so both read as `false`. */\nconst FLAG_KEYS: ReadonlySet<StyleKey> = new Set<StyleKey>([\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'overline',\n]);\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Structural equality over the JSON-ish values a run can hold. This assumes\n * `FillStyle` stays acyclic and plain — every member of the union is data\n * (`TextureHandle` is `{ id }`, so patterns compare by id, which is right).\n * A fill that grew a cyclic or class-valued field would recurse forever.\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((item, i) => deepEqual(item, b[i]));\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((k) => k in b && deepEqual(a[k], b[k]));\n }\n return false;\n}\n\n/** A run's value at `key`, with flags normalized so absent reads as `false`. */\nfunction valueAt(run: StyledRun, key: StyleKey): StyledRun[StyleKey] {\n const value = run[key];\n if (FLAG_KEYS.has(key)) return (value as boolean | undefined) ?? false;\n return value;\n}\n\n/** The structural values. Everything else is a primitive, and\n * `applyStyleToRange` spreads runs, so reference identity isn't reliable. */\nconst STRUCTURAL_KEYS: ReadonlySet<StyleKey> = new Set<StyleKey>(['fill', 'stroke']);\n\nfunction sameValue(key: StyleKey, a: unknown, b: unknown): boolean {\n return STRUCTURAL_KEYS.has(key) ? deepEqual(a, b) : Object.is(a, b);\n}\n\n/** Do two runs carry the same styling (their `text` aside)? */\nfunction sameStyle(a: StyledRun, b: StyledRun): boolean {\n return STYLE_KEYS.every((key) => sameValue(key, valueAt(a, key), valueAt(b, key)));\n}\n\n/** Total character length of a run array — the domain of its offsets. */\nfunction totalLength(runs: readonly StyledRun[]): number {\n let n = 0;\n for (const run of runs) n += run.text.length;\n return n;\n}\n\n/**\n * The styling shared by every run overlapping `[start, end)`: a concrete\n * value where the range agrees, `MIXED` where it doesn't. Keys no run\n * in range sets are absent (they inherit the node's `TextStyle`) — except\n * the additive flags, which read as `false` rather than `undefined` since a\n * run cannot un-set them. An empty range reads as `{}`. A reported `fill`\n * is the run's own object, not a copy — treat it as immutable.\n */\nexport function styleAtRange(\n runs: readonly StyledRun[],\n start: number,\n end: number,\n): RangeStyle {\n const lo = Math.max(0, start);\n const hi = end;\n // Negated `<` rather than `>=` so a non-numeric offset reads as empty\n // instead of matching every run.\n if (!(lo < hi)) return {};\n\n const first = new Map<StyleKey, unknown>();\n const mixed = new Set<StyleKey>();\n let seen = false;\n let pos = 0;\n\n for (const run of runs) {\n const runEnd = pos + run.text.length;\n const a = Math.max(pos, lo);\n const b = Math.min(runEnd, hi);\n pos = runEnd;\n if (!(a < b)) continue;\n\n for (const key of STYLE_KEYS) {\n const value = valueAt(run, key);\n if (!seen) first.set(key, value);\n else if (!mixed.has(key) && !sameValue(key, first.get(key), value)) {\n mixed.add(key);\n }\n }\n seen = true;\n }\n\n if (!seen) return {};\n\n const style: Record<string, unknown> = {};\n for (const key of STYLE_KEYS) {\n if (mixed.has(key)) style[key] = MIXED;\n else {\n const value = first.get(key);\n if (value !== undefined) style[key] = value;\n }\n }\n return style as RangeStyle;\n}\n\n/**\n * Does any run carry styling of its own? Per the additive-flags contract\n * above, absent and `false` are the same state — \"no run-level override\" —\n * so an array that is nothing but text reads as `false`, whether it came\n * from a plain-text edit or from styling that was toggled back off.\n *\n * This is how the commit path tells \"the edit produced run styling\" from\n * \"the edit produced text\", which is the question that decides whether a\n * node grows a `runs` array. Iterating `STYLE_KEYS` rather than the run's\n * own keys is what keeps it honest as `StyledRun` grows: a new styleable\n * key is a compile error at `STYLE_KEYS` until it's listed, and then this\n * sees it for free.\n */\nexport function runsCarryStyling(runs: readonly StyledRun[]): boolean {\n return runs.some((run) =>\n STYLE_KEYS.some((key) => {\n const value = run[key];\n return value !== undefined && value !== false;\n }),\n );\n}\n\n/**\n * The key a patch clears without naming it. `bold` is a preset over\n * `fontWeight`, and a run keeps at most one of the two: writing either drops\n * the other, so a Bold toggle is not hidden under a weight it cannot beat and\n * a picked weight is not shadowed by a stale flag. Naming both writes both.\n */\nexport function supersededKey(patch: RunStylePatch): 'bold' | 'fontWeight' | undefined {\n if ('bold' in patch && !('fontWeight' in patch)) return 'fontWeight';\n if (patch.fontWeight !== undefined && !('bold' in patch)) return 'bold';\n return undefined;\n}\n\n/**\n * `range` with `patch` laid over it, keyed as a write of `patch` would leave\n * the runs — for showing styling armed for the next keystroke over the\n * styling at the caret. A key the patch leaves `undefined` keeps the range's\n * value; the key it supersedes is dropped.\n */\nexport function patchRangeStyle(range: RangeStyle, patch: RunStylePatch): RangeStyle {\n const out: Record<string, unknown> = { ...range };\n const superseded = supersededKey(patch);\n if (superseded !== undefined) delete out[superseded];\n for (const [key, value] of Object.entries(patch)) {\n if (value !== undefined) out[key] = value;\n }\n return out as RangeStyle;\n}\n\n/** Apply `patch` to one run, deleting rather than storing \"no override\". */\nfunction patchRun(run: StyledRun, patch: RunStylePatch): StyledRun {\n const next: StyledRun = { ...run };\n const superseded = supersededKey(patch);\n if (superseded !== undefined) delete next[superseded];\n for (const key of STYLE_KEYS) {\n if (!(key in patch)) continue;\n const value = patch[key];\n // Per the additive-flags contract at the top of the file, `false` is not\n // a storable state — it means \"no run-level override\", same as\n // `undefined`. Deleting keeps one canonical form (coalescing already\n // treats absent and `false` as equal, so this isn't what makes runs\n // merge — it's what keeps the stored shape from drifting).\n if (value === undefined || value === false) delete next[key];\n else (next as unknown as Record<string, unknown>)[key] = value;\n }\n return next;\n}\n\n/** Merge neighbors that ended up styled identically; drop empty runs. */\nfunction coalesceRuns(runs: readonly StyledRun[]): StyledRun[] {\n const out: StyledRun[] = [];\n for (const run of runs) {\n if (run.text.length === 0) continue;\n const prev = out[out.length - 1];\n if (prev && sameStyle(prev, run)) prev.text += run.text;\n else out.push({ ...run });\n }\n return out;\n}\n\n/**\n * Write `patch` over `[start, end)`, splitting runs at the boundaries and\n * coalescing neighbors that end up identical. A patch value of `undefined`\n * or `false` deletes the key instead of storing it — see the additive-flags\n * contract at the top of the file.\n *\n * Returns a new array of new runs; neither the input array nor its runs are\n * mutated (though a nested `fill` is shared by reference). Normalization —\n * merging identical neighbors, dropping empty runs — applies to the whole\n * array, not just the patched span, and to every call, including one whose\n * range is empty and so patches nothing.\n */\nexport function applyStyleToRange(\n runs: readonly StyledRun[],\n start: number,\n end: number,\n patch: RunStylePatch,\n): StyledRun[] {\n const lo = Math.max(0, start);\n const hi = Math.min(totalLength(runs), end);\n // A collapsed caret is the common call, so it takes the same normalization\n // as any other range rather than a laxer copy-only path.\n if (!(lo < hi)) return coalesceRuns(runs);\n\n const out: StyledRun[] = [];\n let pos = 0;\n for (const run of runs) {\n const runEnd = pos + run.text.length;\n const a = Math.max(pos, lo);\n const b = Math.min(runEnd, hi);\n if (a < b) {\n if (pos < a) out.push({ ...run, text: run.text.slice(0, a - pos) });\n out.push(patchRun({ ...run, text: run.text.slice(a - pos, b - pos) }, patch));\n if (b < runEnd) out.push({ ...run, text: run.text.slice(b - pos) });\n } else {\n out.push({ ...run });\n }\n pos = runEnd;\n }\n\n return coalesceRuns(out);\n}\n"],"mappings":";;AAsDA,IAAMA,IAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAcMC,oBAAmC,IAAI,IAAc;CACzD;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAASC,EAAc,GAA0C;CAC/D,OAAO,OAAOC,KAAM,cAAYA,KAAc,CAAC,MAAM,QAAQA,CAAC;AAChE;AAQA,SAASC,EAAU,GAAY,GAA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,KAAGgC,EAAI,KAAK;GAAE,GAAGxB;GAAK,MAAMA,EAAI,KAAK,MAAM,GAAGR,IAAIwB,CAAG;EAAE,CAAC,GAClEQ,EAAI,KAAKG,EAAS;GAAE,GAAG3B;GAAK,MAAMA,EAAI,KAAK,MAAMR,IAAIwB,GAAKvB,IAAIuB,CAAG;EAAE,GAAGM,CAAK,CAAC,GACxE7B,IAAIwB,KAAQO,EAAI,KAAK;GAAE,GAAGxB;GAAK,MAAMA,EAAI,KAAK,MAAMP,IAAIuB,CAAG;EAAE,CAAC,KAElEQ,EAAI,KAAK,EAAE,GAAGxB,EAAI,CAAC,GAErB,IAAMiB;CACR;CAEA,OAAOY,EAAaL,CAAG;AACzB"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { fillInPoseFrame as e } from "../../core/fillInPoseFrame.js";
|
|
2
|
-
import { resolveFillPattern as t } from "../patterns/resolveSpec.js";
|
|
3
|
-
import { resolveAlign as n, resolveRuns as r, resolveTextStyle as i, textPoseLayoutInput as a } from "@weasel-js/text";
|
|
4
|
-
//#region src/features/text/textCommand.ts
|
|
5
|
-
function o(e, t, a, o, s, c, l, u, d, f = 1) {
|
|
6
|
-
let p = i(o, u, f);
|
|
7
|
-
return {
|
|
8
|
-
kind: "text",
|
|
9
|
-
x: e,
|
|
10
|
-
y: t,
|
|
11
|
-
runs: r(a, p, f),
|
|
12
|
-
align: n(p.align, p.direction),
|
|
13
|
-
justify: p.align === "justify",
|
|
14
|
-
maxWidth: s,
|
|
15
|
-
style: o ?? {},
|
|
16
|
-
height: c,
|
|
17
|
-
verticalAlign: l,
|
|
18
|
-
width: d
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function s(e, t, n, r, i, a, s, c, l, u = 1) {
|
|
22
|
-
return o(e, t, [{ text: n }], r, i, a, s, c, l, u);
|
|
23
|
-
}
|
|
24
|
-
function c(e, t = 1) {
|
|
25
|
-
let { runs: n, opts: r } = a(e, t);
|
|
26
|
-
return {
|
|
27
|
-
kind: "text",
|
|
28
|
-
x: e.x,
|
|
29
|
-
y: e.y,
|
|
30
|
-
runs: l(n, e),
|
|
31
|
-
align: r.align,
|
|
32
|
-
justify: r.justify,
|
|
33
|
-
maxWidth: r.maxWidth,
|
|
34
|
-
width: r.alignWidth,
|
|
35
|
-
style: e.style ?? {},
|
|
36
|
-
height: e.height,
|
|
37
|
-
verticalAlign: e.verticalAlign
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function l(n, r) {
|
|
41
|
-
return n.every((e) => u(e.fill) && u(e.stroke?.paint)) ? n : n.map((n) => {
|
|
42
|
-
let i = n.fill && t(e(n.fill, r)), a = n.stroke?.paint && t(e(n.stroke.paint, r));
|
|
43
|
-
return {
|
|
44
|
-
...n,
|
|
45
|
-
fill: i,
|
|
46
|
-
stroke: n.stroke && {
|
|
47
|
-
...n.stroke,
|
|
48
|
-
paint: a || void 0
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function u(e) {
|
|
54
|
-
return e == null || (e.fill ?? "solid") === "solid";
|
|
55
|
-
}
|
|
56
|
-
//#endregion
|
|
57
|
-
export { s as textCommand, c as textCommandFromPose, o as textCommandFromRuns };
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=textCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textCommand.js","names":["textCommandFromRuns","resolved","resolveTextStyle","style","paint","scale","resolveRuns","runs","resolveAlign","textCommand","x","y","maxWidth","height","verticalAlign","width","textCommandFromPose","textPoseLayoutInput","pose","runsInPoseFrame","opts","isSolid","r","fill","resolveFillPattern","fillInPoseFrame","box"],"sources":["../../../src/features/text/textCommand.ts"],"sourcesContent":["/**\n * Build a `TextDrawCommand`. `textCommandFromPose` is the command for a text\n * node — what `kit:text` and `createTextLayer` both emit. `textCommand` takes\n * a plain string and wraps it in one run; `textCommandFromRuns` takes the\n * styled runs directly, for text that has no pose. All three\n * resolve through `resolveTextStyle` + `resolveRuns`, so every emitter of a\n * text command derives `align` and per-run resolution the same way — a\n * caller that assembles the command by hand is one field away from a\n * silently different result.\n *\n * `paint` is the node's `data.fill` / `data.stroke`. A caller with no node —\n * a HUD widget, a debug overlay — states its color on the run instead.\n *\n * `scale` is the view scale a `{ px }` `fontSize` or `letterSpacing` resolves\n * against — for a world-space layer, the mean of `view.scale.x` and\n * `view.scale.y`. It has to be applied here and not at draw time, because a\n * screen-pixel size moves the glyph advances and so the wrap points.\n */\n\nimport type { DrawCommand, TextDrawCommand } from '../../renderer';\nimport type { TextPaint, TextPose, TextStyle } from '@weasel-js/text';\nimport { resolveAlign, resolveTextStyle, textPoseLayoutInput } from '@weasel-js/text';\nimport { resolveRuns } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextVerticalAlign, ResolvedRun } from '@weasel-js/text';\nimport type { FillStyle } from '@weasel-js/paint';\nimport { fillInPoseFrame, type FillPoseBox } from '../../core/fillInPoseFrame';\nimport { resolveFillPattern } from '../patterns/resolveSpec';\n\n/** Build a draw command from styled runs, for text with no pose. `style`\n * supplies the defaults each run inherits; the rest match `textCommand`. */\nexport function textCommandFromRuns(\n x: number,\n y: number,\n runs: readonly StyledRun[],\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n const resolved = resolveTextStyle(style, paint, scale);\n return {\n kind: 'text',\n x,\n y,\n runs: resolveRuns(runs, resolved, scale),\n align: resolveAlign(resolved.align, resolved.direction),\n justify: resolved.align === 'justify',\n maxWidth,\n style: style ?? {},\n height,\n verticalAlign,\n width,\n };\n}\n\n/** Build a draw command for a single unstyled string. Text is laid out with\n * the registered font's metrics, wrapped at `maxWidth`, aligned across\n * `width` (default `maxWidth`) and within `height` when `verticalAlign` is\n * given. */\nexport function textCommand(\n x: number,\n y: number,\n text: string,\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n return textCommandFromRuns(\n x, y, [{ text }], style, maxWidth, height, verticalAlign, paint, width, scale,\n );\n}\n\n/**\n * The draw command for a text pose. Its wrap width, alignment box and runs\n * come from `textPoseLayoutInput`, so the renderer lays it out into exactly\n * the lines `layoutTextPose` reports for the same pose.\n *\n * Each run's paints are resolved against the pose box the way every other\n * node's are — a `'bounds'` paint mapped onto it, a pattern spec swapped for\n * its texture — since the renderer can do neither.\n */\nexport function textCommandFromPose(pose: TextPose, scale = 1): TextDrawCommand {\n const { runs, opts } = textPoseLayoutInput(pose, scale);\n return {\n kind: 'text',\n x: pose.x,\n y: pose.y,\n runs: runsInPoseFrame(runs, pose),\n align: opts.align,\n justify: opts.justify,\n maxWidth: opts.maxWidth,\n width: opts.alignWidth,\n style: pose.style ?? {},\n height: pose.height,\n verticalAlign: pose.verticalAlign,\n };\n}\n\nfunction runsInPoseFrame(runs: ResolvedRun[], box: FillPoseBox): ResolvedRun[] {\n if (runs.every((r) => isSolid(r.fill) && isSolid(r.stroke?.paint))) return runs;\n return runs.map((r) => {\n const fill = r.fill && resolveFillPattern(fillInPoseFrame(r.fill, box));\n const paint = r.stroke?.paint && resolveFillPattern(fillInPoseFrame(r.stroke.paint, box));\n return { ...r, fill, stroke: r.stroke && { ...r.stroke, paint: paint || undefined } };\n });\n}\n\nfunction isSolid(paint: FillStyle | null | undefined): boolean {\n return paint == null || (paint.fill ?? 'solid') === 'solid';\n}\n"],"mappings":";;;;AA+BA,SAAgBA,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IAAQ,GACK;CACb,IAAMC,IAAWC,EAAiBC,GAAOC,GAAOC,CAAK;CACrD,OAAO;EACL,MAAM;EACN;EACA;EACA,MAAMC,EAAYC,GAAMN,GAAUI,CAAK;EACvC,OAAOG,EAAaP,EAAS,OAAOA,EAAS,SAAS;EACtD,SAASA,EAAS,U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