@weasel-js/core 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +764 -0
- package/README.md +7 -8
- package/dist/WeaselProvider.js +15 -0
- package/dist/WeaselProvider.js.map +1 -0
- package/dist/affordances/composeAffordanceLayer.js +224 -0
- package/dist/affordances/composeAffordanceLayer.js.map +1 -0
- package/dist/affordances/cornerResize.js +69 -0
- package/dist/affordances/cornerResize.js.map +1 -0
- package/dist/affordances/hitAffordanceRegions.js +138 -0
- package/dist/affordances/hitAffordanceRegions.js.map +1 -0
- package/dist/affordances/pathAnchors.js +66 -0
- package/dist/affordances/pathAnchors.js.map +1 -0
- package/dist/affordances/rotationHandle.js +103 -0
- package/dist/affordances/rotationHandle.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +118 -0
- package/dist/animation/behaviors/momentum.js.map +1 -0
- package/dist/animation/colorHelpers.js +135 -0
- package/dist/animation/colorHelpers.js.map +1 -0
- package/dist/animation/colorRegistry.js +37 -0
- package/dist/animation/colorRegistry.js.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/loop.js +62 -0
- package/dist/animation/loop.js.map +1 -0
- package/dist/animation/observe.js +23 -0
- package/dist/animation/observe.js.map +1 -0
- package/dist/animation/poseHelpers.js +50 -0
- package/dist/animation/poseHelpers.js.map +1 -0
- package/dist/animation/reflow.js +121 -0
- package/dist/animation/reflow.js.map +1 -0
- package/dist/animation/rig/bindRig.js +74 -0
- package/dist/animation/rig/bindRig.js.map +1 -0
- package/dist/animation/rig/blendPoses.js +43 -0
- package/dist/animation/rig/blendPoses.js.map +1 -0
- package/dist/animation/rig/mirrorPose.js +19 -0
- package/dist/animation/rig/mirrorPose.js.map +1 -0
- package/dist/animation/rig/resolveSkeleton.js +33 -0
- package/dist/animation/rig/resolveSkeleton.js.map +1 -0
- package/dist/animation/rig/solveIk.js +103 -0
- package/dist/animation/rig/solveIk.js.map +1 -0
- package/dist/animation/rig/types.js +12 -0
- package/dist/animation/rig/types.js.map +1 -0
- package/dist/animation/rig/useRig.js +23 -0
- package/dist/animation/rig/useRig.js.map +1 -0
- package/dist/animation/slew.js +27 -0
- package/dist/animation/slew.js.map +1 -0
- package/dist/animation/stagger.js +138 -0
- package/dist/animation/stagger.js.map +1 -0
- package/dist/animation/timeline/booking.js +106 -0
- package/dist/animation/timeline/booking.js.map +1 -0
- package/dist/animation/timeline/createTimeline.js +116 -0
- package/dist/animation/timeline/createTimeline.js.map +1 -0
- package/dist/animation/timeline/sampleTrack.js +29 -0
- package/dist/animation/timeline/sampleTrack.js.map +1 -0
- package/dist/animation/useAnimator.js +329 -0
- package/dist/animation/useAnimator.js.map +1 -0
- package/dist/animation/wrappers/animateLifecycle.js +40 -0
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -0
- package/dist/animation/wrappers/animateOnSetPose.js +44 -0
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -0
- package/dist/{autoPoseDescriptor-_XOyF7t4.d.ts → autoPoseDescriptor-BT_vp9FO.d.ts} +2 -2
- package/dist/{builtins-DLn2lCr_.d.ts → builtins-BSUfH8nU.d.ts} +738 -513
- package/dist/canvas/Canvas.js +608 -0
- package/dist/canvas/Canvas.js.map +1 -0
- package/dist/canvas/CanvasView.js +255 -0
- package/dist/canvas/CanvasView.js.map +1 -0
- package/dist/canvas/CursorCoordsHud.js +75 -0
- package/dist/canvas/CursorCoordsHud.js.map +1 -0
- package/dist/canvas/DrawCanvas.js +67 -0
- package/dist/canvas/DrawCanvas.js.map +1 -0
- package/dist/canvas/MinimapCanvas.js +139 -0
- package/dist/canvas/MinimapCanvas.js.map +1 -0
- package/dist/canvas/ModalityHud.js +66 -0
- package/dist/canvas/ModalityHud.js.map +1 -0
- package/dist/canvas/NodeShape.js +391 -0
- package/dist/canvas/NodeShape.js.map +1 -0
- package/dist/canvas/PickHud.js +93 -0
- package/dist/canvas/PickHud.js.map +1 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +51 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js +42 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +549 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +26 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js +69 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -0
- package/dist/canvas/SceneCanvas/features.js +97 -0
- package/dist/canvas/SceneCanvas/features.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +46 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +48 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +70 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js +75 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +172 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +69 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +127 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +30 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +992 -0
- package/dist/canvas/SceneCanvas.js.map +1 -0
- package/dist/canvas/SceneViewCanvas.js +54 -0
- package/dist/canvas/SceneViewCanvas.js.map +1 -0
- package/dist/canvas/accentColor.js +9 -0
- package/dist/canvas/accentColor.js.map +1 -0
- package/dist/canvas/affordanceAt.js +63 -0
- package/dist/canvas/affordanceAt.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +65 -0
- package/dist/canvas/buildSceneTree.js.map +1 -0
- package/dist/canvas/canvasRenderer.js +89 -0
- package/dist/canvas/canvasRenderer.js.map +1 -0
- package/dist/canvas/colorOverrides.js +16 -0
- package/dist/canvas/colorOverrides.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +43 -0
- package/dist/canvas/defaultDrawOne.js.map +1 -0
- package/dist/canvas/deps/areaSelect.js +19 -0
- package/dist/canvas/deps/areaSelect.js.map +1 -0
- package/dist/canvas/deps/debug.js +9 -0
- package/dist/canvas/deps/debug.js.map +1 -0
- package/dist/canvas/deps/dispatcher.js +11 -0
- package/dist/canvas/deps/dispatcher.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +101 -0
- package/dist/canvas/deps/editAnchors.js.map +1 -0
- package/dist/canvas/deps/geometryProjection.js +11 -0
- package/dist/canvas/deps/geometryProjection.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +51 -0
- package/dist/canvas/deps/hitTestArea.js.map +1 -0
- package/dist/canvas/deps/ingestion.js +31 -0
- package/dist/canvas/deps/ingestion.js.map +1 -0
- package/dist/canvas/deps/insert.js +116 -0
- package/dist/canvas/deps/insert.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +20 -0
- package/dist/canvas/deps/lassoSelect.js.map +1 -0
- package/dist/canvas/deps/layout.js +34 -0
- package/dist/canvas/deps/layout.js.map +1 -0
- package/dist/canvas/deps/nodeAtPoint.js +19 -0
- package/dist/canvas/deps/nodeAtPoint.js.map +1 -0
- package/dist/canvas/deps/poseComposition.js +11 -0
- package/dist/canvas/deps/poseComposition.js.map +1 -0
- package/dist/canvas/deps/poseDescriptor.js +12 -0
- package/dist/canvas/deps/poseDescriptor.js.map +1 -0
- package/dist/canvas/deps/resizePolicy.js +35 -0
- package/dist/canvas/deps/resizePolicy.js.map +1 -0
- package/dist/canvas/deps/slice.js +99 -0
- package/dist/canvas/deps/slice.js.map +1 -0
- package/dist/canvas/deps/snap.js +11 -0
- package/dist/canvas/deps/snap.js.map +1 -0
- package/dist/canvas/deps/textEdit.js +21 -0
- package/dist/canvas/deps/textEdit.js.map +1 -0
- package/dist/canvas/deps/view.js +43 -0
- package/dist/canvas/deps/view.js.map +1 -0
- package/dist/canvas/derivedPath.js +47 -0
- package/dist/canvas/derivedPath.js.map +1 -0
- package/dist/canvas/drawEnvelope.js +22 -0
- package/dist/canvas/drawEnvelope.js.map +1 -0
- package/dist/canvas/getNodeAtPoint.js +18 -0
- package/dist/canvas/getNodeAtPoint.js.map +1 -0
- package/dist/canvas/hostAnchor.js +29 -0
- package/dist/canvas/hostAnchor.js.map +1 -0
- package/dist/canvas/hud.module.js +18 -0
- package/dist/canvas/hud.module.js.map +1 -0
- package/dist/canvas/insertPreviewExtent.js +103 -0
- package/dist/canvas/insertPreviewExtent.js.map +1 -0
- package/dist/canvas/kitRequirements.js +177 -0
- package/dist/canvas/kitRequirements.js.map +1 -0
- package/dist/canvas/layerOrder.js +66 -0
- package/dist/canvas/layerOrder.js.map +1 -0
- package/dist/canvas/layerSlots.js +14 -0
- package/dist/canvas/layerSlots.js.map +1 -0
- package/dist/canvas/minimapMath.js +80 -0
- package/dist/canvas/minimapMath.js.map +1 -0
- package/dist/canvas/mountedCanvases.js +20 -0
- package/dist/canvas/mountedCanvases.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js +17 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -0
- package/dist/canvas/paintCull.js +20 -0
- package/dist/canvas/paintCull.js.map +1 -0
- package/dist/canvas/pickWalk.js +158 -0
- package/dist/canvas/pickWalk.js.map +1 -0
- package/dist/canvas/planeClips.js +30 -0
- package/dist/canvas/planeClips.js.map +1 -0
- package/dist/canvas/poseRotation.js +35 -0
- package/dist/canvas/poseRotation.js.map +1 -0
- package/dist/canvas/rasterToPng.js +21 -0
- package/dist/canvas/rasterToPng.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +32 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -0
- package/dist/canvas/renderNeeds.js +25 -0
- package/dist/canvas/renderNeeds.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +143 -0
- package/dist/canvas/renderSceneToPixels.js.map +1 -0
- package/dist/canvas/sceneAdapter.js +270 -0
- package/dist/canvas/sceneAdapter.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +37 -0
- package/dist/canvas/sceneLayerPaint.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +20 -0
- package/dist/canvas/sceneSlotWiring.js.map +1 -0
- package/dist/canvas/sceneViewRender.js +72 -0
- package/dist/canvas/sceneViewRender.js.map +1 -0
- package/dist/canvas/slopsDebugLayer.js +61 -0
- package/dist/canvas/slopsDebugLayer.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +15 -0
- package/dist/canvas/surfaceContribution.js.map +1 -0
- package/dist/canvas/toolPreview.js +39 -0
- package/dist/canvas/toolPreview.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +11 -0
- package/dist/canvas/useCanvasRenderer.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +60 -0
- package/dist/canvas/useFrameLoop.js.map +1 -0
- package/dist/canvas/useHostAnchor.js +71 -0
- package/dist/canvas/useHostAnchor.js.map +1 -0
- package/dist/canvas/useLateContentRedraw.js +21 -0
- package/dist/canvas/useLateContentRedraw.js.map +1 -0
- package/dist/canvas/useRedrawOn.js +21 -0
- package/dist/canvas/useRedrawOn.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +120 -0
- package/dist/canvas/useViewHelpers.js.map +1 -0
- package/dist/canvas/viewInputs.js +17 -0
- package/dist/canvas/viewInputs.js.map +1 -0
- package/dist/canvas/viewRegistry.js +61 -0
- package/dist/canvas/viewRegistry.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js +14 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -0
- package/dist/clipboard.d.ts +10 -5
- package/dist/clipboard.js +3 -5
- package/dist/clone.d.ts +3 -3
- package/dist/clone.js +2 -5
- package/dist/core/adapters/arrayAdapter.js +85 -0
- package/dist/core/adapters/arrayAdapter.js.map +1 -0
- package/dist/core/adapters/useArrayAdapter.js +13 -0
- package/dist/core/adapters/useArrayAdapter.js.map +1 -0
- package/dist/core/applyOps.js +12 -0
- package/dist/core/applyOps.js.map +1 -0
- package/dist/core/device/index.js +4 -0
- package/dist/core/device/targets.js +17 -0
- package/dist/core/device/targets.js.map +1 -0
- package/dist/core/device/useDeviceProfile.js +75 -0
- package/dist/core/device/useDeviceProfile.js.map +1 -0
- package/dist/core/fillInPoseFrame.js +102 -0
- package/dist/core/fillInPoseFrame.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +98 -0
- package/dist/core/geometry/poseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseRotation.js +58 -0
- package/dist/core/geometry/poseRotation.js.map +1 -0
- package/dist/core/geometry/regionHit.js +102 -0
- package/dist/core/geometry/regionHit.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +60 -0
- package/dist/core/geometry/unionBounds.js.map +1 -0
- package/dist/core/gradient.js +136 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/isPlainObject.js +11 -0
- package/dist/core/isPlainObject.js.map +1 -0
- package/dist/core/layers/render.js +150 -0
- package/dist/core/layers/render.js.map +1 -0
- package/dist/core/markerInset.js +24 -0
- package/dist/core/markerInset.js.map +1 -0
- package/dist/core/mixed.js +6 -0
- package/dist/core/mixed.js.map +1 -0
- package/dist/core/ops/arrange.js +31 -0
- package/dist/core/ops/arrange.js.map +1 -0
- package/dist/core/ops/create.js +32 -0
- package/dist/core/ops/create.js.map +1 -0
- package/dist/core/ops/createHistory.js +20 -0
- package/dist/core/ops/createHistory.js.map +1 -0
- package/dist/core/ops/delete.js +89 -0
- package/dist/core/ops/delete.js.map +1 -0
- package/dist/core/ops/registry.js +17 -0
- package/dist/core/ops/registry.js.map +1 -0
- package/dist/core/ops/reorder/algorithms.js +55 -0
- package/dist/core/ops/reorder/algorithms.js.map +1 -0
- package/dist/core/ops/reorder/index.js +140 -0
- package/dist/core/ops/reorder/index.js.map +1 -0
- package/dist/core/ops/reparent.js +52 -0
- package/dist/core/ops/reparent.js.map +1 -0
- package/dist/core/ops/select.js +34 -0
- package/dist/core/ops/select.js.map +1 -0
- package/dist/core/ops/setData.js +34 -0
- package/dist/core/ops/setData.js.map +1 -0
- package/dist/core/ops/setLayer.js +34 -0
- package/dist/core/ops/setLayer.js.map +1 -0
- package/dist/core/ops/setLayout.js +31 -0
- package/dist/core/ops/setLayout.js.map +1 -0
- package/dist/core/ops/setPath.js +57 -0
- package/dist/core/ops/setPath.js.map +1 -0
- package/dist/core/ops/setText.js +34 -0
- package/dist/core/ops/setText.js.map +1 -0
- package/dist/core/ops/slot.js +37 -0
- package/dist/core/ops/slot.js.map +1 -0
- package/dist/core/ops/transform.js +42 -0
- package/dist/core/ops/transform.js.map +1 -0
- package/dist/core/paintKinds.js +156 -0
- package/dist/core/paintKinds.js.map +1 -0
- package/dist/core/scene/NodeProperties.js +20 -0
- package/dist/core/scene/NodeProperties.js.map +1 -0
- package/dist/core/scene/NodeRouting.js +24 -0
- package/dist/core/scene/NodeRouting.js.map +1 -0
- package/dist/core/scene/arrivals.js +12 -0
- package/dist/core/scene/arrivals.js.map +1 -0
- package/dist/core/scene/composeFrame.js +29 -0
- package/dist/core/scene/composeFrame.js.map +1 -0
- package/dist/core/scene/depMemo.js +18 -0
- package/dist/core/scene/depMemo.js.map +1 -0
- package/dist/core/scene/dependents.js +66 -0
- package/dist/core/scene/dependents.js.map +1 -0
- package/dist/core/scene/derivedPath.js +31 -0
- package/dist/core/scene/derivedPath.js.map +1 -0
- package/dist/core/scene/effectivePose.js +78 -0
- package/dist/core/scene/effectivePose.js.map +1 -0
- package/dist/core/scene/kitRegistry.js +33 -0
- package/dist/core/scene/kitRegistry.js.map +1 -0
- package/dist/core/scene/layoutPass.js +96 -0
- package/dist/core/scene/layoutPass.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +83 -0
- package/dist/core/scene/nodeFnFields.js.map +1 -0
- package/dist/core/scene/nodeMemo.js +28 -0
- package/dist/core/scene/nodeMemo.js.map +1 -0
- package/dist/core/scene/poseFeed.js +87 -0
- package/dist/core/scene/poseFeed.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +52 -0
- package/dist/core/scene/poseOverrides.js.map +1 -0
- package/dist/core/scene/poseSnapshot.js +54 -0
- package/dist/core/scene/poseSnapshot.js.map +1 -0
- package/dist/core/scene/scene.js +1271 -0
- package/dist/core/scene/scene.js.map +1 -0
- package/dist/core/scene/types.js +6 -0
- package/dist/core/scene/types.js.map +1 -0
- package/dist/core/scene/useScene.js +32 -0
- package/dist/core/scene/useScene.js.map +1 -0
- package/dist/core/selection/chromeState.js +31 -0
- package/dist/core/selection/chromeState.js.map +1 -0
- package/dist/core/selection/selectionTarget.js +6 -0
- package/dist/core/selection/selectionTarget.js.map +1 -0
- package/dist/core/selection/useSelection.js +71 -0
- package/dist/core/selection/useSelection.js.map +1 -0
- package/dist/core/shapeKinds.js +54 -0
- package/dist/core/shapeKinds.js.map +1 -0
- package/dist/core/strokeMarkerShapes.js +139 -0
- package/dist/core/strokeMarkerShapes.js.map +1 -0
- package/dist/core/strokeMarkers.js +28 -0
- package/dist/core/strokeMarkers.js.map +1 -0
- package/dist/core/stylus/stylus.js +39 -0
- package/dist/core/stylus/stylus.js.map +1 -0
- package/dist/core/stylus/usePointerStylus.js +51 -0
- package/dist/core/stylus/usePointerStylus.js.map +1 -0
- package/dist/core/usePaintKinds.js +17 -0
- package/dist/core/usePaintKinds.js.map +1 -0
- package/dist/core/viewport/clampView.js +24 -0
- package/dist/core/viewport/clampView.js.map +1 -0
- package/dist/core/viewport/clientToWorld.js +8 -0
- package/dist/core/viewport/clientToWorld.js.map +1 -0
- package/dist/core/viewport/createVelocityTracker.js +39 -0
- package/dist/core/viewport/createVelocityTracker.js.map +1 -0
- package/dist/core/viewport/fitToBounds.js +18 -0
- package/dist/core/viewport/fitToBounds.js.map +1 -0
- package/dist/core/viewport/fitViewToBounds.js +36 -0
- package/dist/core/viewport/fitViewToBounds.js.map +1 -0
- package/dist/core/viewport/interpolateView.js +34 -0
- package/dist/core/viewport/interpolateView.js.map +1 -0
- package/dist/core/viewport/meanScale.js +8 -0
- package/dist/core/viewport/meanScale.js.map +1 -0
- package/dist/core/viewport/parallax.js +111 -0
- package/dist/core/viewport/parallax.js.map +1 -0
- package/dist/core/viewport/pxExtent.js +42 -0
- package/dist/core/viewport/pxExtent.js.map +1 -0
- package/dist/core/viewport/sceneNodeClientRect.js +18 -0
- package/dist/core/viewport/sceneNodeClientRect.js.map +1 -0
- package/dist/core/viewport/screenSlop.js +27 -0
- package/dist/core/viewport/screenSlop.js.map +1 -0
- package/dist/core/viewport/useAutoCenter.js +32 -0
- package/dist/core/viewport/useAutoCenter.js.map +1 -0
- package/dist/core/viewport/useCanvasSize.js +29 -0
- package/dist/core/viewport/useCanvasSize.js.map +1 -0
- package/dist/core/viewport/useDecayLoop.js +63 -0
- package/dist/core/viewport/useDecayLoop.js.map +1 -0
- package/dist/core/viewport/useVelocityTracker.js +10 -0
- package/dist/core/viewport/useVelocityTracker.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +63 -0
- package/dist/core/viewport/useViewAnimation.js.map +1 -0
- package/dist/core/viewport/view.js +37 -0
- package/dist/core/viewport/view.js.map +1 -0
- package/dist/core/viewport/viewTransform.js +11 -0
- package/dist/core/viewport/viewTransform.js.map +1 -0
- package/dist/core/viewport/viewportWorldRect.js +13 -0
- package/dist/core/viewport/viewportWorldRect.js.map +1 -0
- package/dist/core/viewport/wheelHandler.js +30 -0
- package/dist/core/viewport/wheelHandler.js.map +1 -0
- package/dist/core/viewport/zoomAt.js +22 -0
- package/dist/core/viewport/zoomAt.js.map +1 -0
- package/dist/core/viewport/zoomBounds.js +20 -0
- package/dist/core/viewport/zoomBounds.js.map +1 -0
- package/dist/{pointSnapToGrid-Dp2IxLGb.d.ts → cornerHandles-CDcZOV8h.d.ts} +3 -13
- package/dist/debug/createDebugOverlayLayer.js +358 -0
- package/dist/debug/createDebugOverlayLayer.js.map +1 -0
- package/dist/debug/createDebugSink.js +83 -0
- package/dist/debug/createDebugSink.js.map +1 -0
- package/dist/debug/defaultTheme.js +31 -0
- package/dist/debug/defaultTheme.js.map +1 -0
- package/dist/debug/flag.js +41 -0
- package/dist/debug/flag.js.map +1 -0
- package/dist/debug/frameStats.js +16 -0
- package/dist/debug/frameStats.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +32 -0
- package/dist/debug/parseDebugFlags.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js +16 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -0
- package/dist/features/chrome-caps/conditions.js +36 -0
- package/dist/features/chrome-caps/conditions.js.map +1 -0
- package/dist/features/chrome-caps/defaults.js +26 -0
- package/dist/features/chrome-caps/defaults.js.map +1 -0
- package/dist/features/chrome-caps/index.js +7 -0
- package/dist/features/chrome-caps/resolve.js +23 -0
- package/dist/features/chrome-caps/resolve.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +27 -0
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -0
- package/dist/features/cursor/paintedCursorLayer.js +60 -0
- package/dist/features/cursor/paintedCursorLayer.js.map +1 -0
- package/dist/features/focus/gateLayer.js +14 -0
- package/dist/features/focus/gateLayer.js.map +1 -0
- package/dist/features/focus/useCanvasFocus.js +29 -0
- package/dist/features/focus/useCanvasFocus.js.map +1 -0
- package/dist/features/groups/children.js +23 -0
- package/dist/features/groups/children.js.map +1 -0
- package/dist/features/groups/composePose.js +67 -0
- package/dist/features/groups/composePose.js.map +1 -0
- package/dist/features/groups/nestedHit.js +40 -0
- package/dist/features/groups/nestedHit.js.map +1 -0
- package/dist/features/groups/unionOfChildren.js +15 -0
- package/dist/features/groups/unionOfChildren.js.map +1 -0
- package/dist/features/images/imageCache.js +94 -0
- package/dist/features/images/imageCache.js.map +1 -0
- package/dist/features/ingestion/contentHandlers.js +37 -0
- package/dist/features/ingestion/contentHandlers.js.map +1 -0
- package/dist/features/ingestion/imageHandler.js +45 -0
- package/dist/features/ingestion/imageHandler.js.map +1 -0
- package/dist/features/ingestion/index.js +8 -0
- package/dist/features/ingestion/openFilePicker.js +15 -0
- package/dist/features/ingestion/openFilePicker.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +26 -0
- package/dist/features/ingestion/registerKitHandlers.js.map +1 -0
- package/dist/features/ingestion/svgHandler.js +58 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +39 -0
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -0
- package/dist/features/longPress/longPressFeedback.js +96 -0
- package/dist/features/longPress/longPressFeedback.js.map +1 -0
- package/dist/features/meshPaint/bake.js +79 -0
- package/dist/features/meshPaint/bake.js.map +1 -0
- package/dist/features/meshPaint/bakeCache.js +59 -0
- package/dist/features/meshPaint/bakeCache.js.map +1 -0
- package/dist/features/meshPaint/handles.js +86 -0
- package/dist/features/meshPaint/handles.js.map +1 -0
- package/dist/features/meshPaint/lazyKind.js +1298 -0
- package/dist/features/meshPaint/lazyKind.js.map +1 -0
- package/dist/features/meshPaint/meshPaint.js +236 -0
- package/dist/features/meshPaint/meshPaint.js.map +1 -0
- package/dist/features/meshPaint/meshShader.js +6 -0
- package/dist/features/meshPaint/meshShader.js.map +1 -0
- package/dist/features/meshPaint/register.js +7 -0
- package/dist/features/meshPaint/register.js.map +1 -0
- package/dist/features/meshPaint/surface.js +110 -0
- package/dist/features/meshPaint/surface.js.map +1 -0
- package/dist/features/minimap/actions.js +53 -0
- package/dist/features/minimap/actions.js.map +1 -0
- package/dist/features/minimap/createMinimapContribution.js +96 -0
- package/dist/features/minimap/createMinimapContribution.js.map +1 -0
- package/dist/features/minimap/layers.js +103 -0
- package/dist/features/minimap/layers.js.map +1 -0
- package/dist/features/modes/modeLayers.js +113 -0
- package/dist/features/modes/modeLayers.js.map +1 -0
- package/dist/features/overlays/useNodeOverlayFrame.js +103 -0
- package/dist/features/overlays/useNodeOverlayFrame.js.map +1 -0
- package/dist/features/parallax/createParallaxLayer.js +26 -0
- package/dist/features/parallax/createParallaxLayer.js.map +1 -0
- package/dist/features/parallax/createParallaxPlane.js +26 -0
- package/dist/features/parallax/createParallaxPlane.js.map +1 -0
- package/dist/features/paths/anchorEdits.js +156 -0
- package/dist/features/paths/anchorEdits.js.map +1 -0
- package/dist/features/paths/anchors.js +154 -0
- package/dist/features/paths/anchors.js.map +1 -0
- package/dist/features/paths/booleans.js +2 -0
- package/dist/features/paths/index.js +15 -0
- package/dist/features/paths/markerCommands.js +116 -0
- package/dist/features/paths/markerCommands.js.map +1 -0
- package/dist/features/paths/markerSites.js +59 -0
- package/dist/features/paths/markerSites.js.map +1 -0
- package/dist/features/paths/markers.js +95 -0
- package/dist/features/paths/markers.js.map +1 -0
- package/dist/features/paths/nearestAnchor.js +36 -0
- package/dist/features/paths/nearestAnchor.js.map +1 -0
- package/dist/features/paths/originProjection.js +16 -0
- package/dist/features/paths/originProjection.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +137 -0
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -0
- package/dist/features/paths/pathInWorld.js +41 -0
- package/dist/features/paths/pathInWorld.js.map +1 -0
- package/dist/features/paths/pathLayer.js +44 -0
- package/dist/features/paths/pathLayer.js.map +1 -0
- package/dist/features/paths/penPreviewLayer.js +220 -0
- package/dist/features/paths/penPreviewLayer.js.map +1 -0
- package/dist/features/paths/poseDescriptor.js +44 -0
- package/dist/features/paths/poseDescriptor.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js +230 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -0
- package/dist/features/patterns/index.js +23 -0
- package/dist/features/patterns/index.js.map +1 -0
- package/dist/features/patterns/patterns-builtin.js +38 -0
- package/dist/features/patterns/patterns-builtin.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +57 -0
- package/dist/features/patterns/resolveSpec.js.map +1 -0
- package/dist/features/patterns/tileGeometry.js +158 -0
- package/dist/features/patterns/tileGeometry.js.map +1 -0
- package/dist/features/pointer/PointerContext.js +45 -0
- package/dist/features/pointer/PointerContext.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +70 -0
- package/dist/features/poseRun/usePoseRun.js.map +1 -0
- package/dist/features/selection/SelectionContext.js +46 -0
- package/dist/features/selection/SelectionContext.js.map +1 -0
- package/dist/features/selection/overlay.js +442 -0
- package/dist/features/selection/overlay.js.map +1 -0
- package/dist/features/simulation/createSimulation.js +61 -0
- package/dist/features/simulation/createSimulation.js.map +1 -0
- package/dist/features/simulation/types.js +6 -0
- package/dist/features/simulation/types.js.map +1 -0
- package/dist/features/simulation/useSimulation.js +74 -0
- package/dist/features/simulation/useSimulation.js.map +1 -0
- package/dist/features/text/domRuns.js +258 -0
- package/dist/features/text/domRuns.js.map +1 -0
- package/dist/features/text/fitTextPose.js +38 -0
- package/dist/features/text/fitTextPose.js.map +1 -0
- package/dist/features/text/hitTest.js +45 -0
- package/dist/features/text/hitTest.js.map +1 -0
- package/dist/features/text/renderLabel.js +14 -0
- package/dist/features/text/renderLabel.js.map +1 -0
- package/dist/features/text/runs/effectiveRangeStyle.js +66 -0
- package/dist/features/text/runs/effectiveRangeStyle.js.map +1 -0
- package/dist/features/text/runs/flagRange.js +53 -0
- package/dist/features/text/runs/flagRange.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +135 -0
- package/dist/features/text/runs/rangeStyle.js.map +1 -0
- package/dist/features/text/textCommand.js +59 -0
- package/dist/features/text/textCommand.js.map +1 -0
- package/dist/features/text/textLayer.js +35 -0
- package/dist/features/text/textLayer.js.map +1 -0
- package/dist/features/text/textToPath.js +181 -0
- package/dist/features/text/textToPath.js.map +1 -0
- package/dist/features/text/useSceneTextEdit.js +138 -0
- package/dist/features/text/useSceneTextEdit.js.map +1 -0
- package/dist/features/text/useTextEdit.js +465 -0
- package/dist/features/text/useTextEdit.js.map +1 -0
- package/dist/features/tiling/createTiledLayer.js +63 -0
- package/dist/features/tiling/createTiledLayer.js.map +1 -0
- package/dist/features/tiling/tiledProject.js +14 -0
- package/dist/features/tiling/tiledProject.js.map +1 -0
- package/dist/features/viewports/viewResolver.js +59 -0
- package/dist/features/viewports/viewResolver.js.map +1 -0
- package/dist/features/viewports/viewportLayer.js +58 -0
- package/dist/features/viewports/viewportLayer.js.map +1 -0
- package/dist/icons/ArrowIcon.js +23 -0
- package/dist/icons/ArrowIcon.js.map +1 -0
- package/dist/icons/EllipseIcon.js +21 -0
- package/dist/icons/EllipseIcon.js.map +1 -0
- package/dist/icons/EyedropperIcon.js +49 -0
- package/dist/icons/EyedropperIcon.js.map +1 -0
- package/dist/icons/HandIcon.js +59 -0
- package/dist/icons/HandIcon.js.map +1 -0
- package/dist/icons/ImageIcon.js +34 -0
- package/dist/icons/ImageIcon.js.map +1 -0
- package/dist/icons/LassoIcon.js +22 -0
- package/dist/icons/LassoIcon.js.map +1 -0
- package/dist/icons/LineIcon.js +22 -0
- package/dist/icons/LineIcon.js.map +1 -0
- package/dist/icons/PenIcon.js +36 -0
- package/dist/icons/PenIcon.js.map +1 -0
- package/dist/icons/PencilIcon.js +25 -0
- package/dist/icons/PencilIcon.js.map +1 -0
- package/dist/icons/PolygonIcon.js +19 -0
- package/dist/icons/PolygonIcon.js.map +1 -0
- package/dist/icons/RectIcon.js +37 -0
- package/dist/icons/RectIcon.js.map +1 -0
- package/dist/icons/SelectIcon.js +20 -0
- package/dist/icons/SelectIcon.js.map +1 -0
- package/dist/icons/StarIcon.js +19 -0
- package/dist/icons/StarIcon.js.map +1 -0
- package/dist/icons/TextIcon.js +19 -0
- package/dist/icons/TextIcon.js.map +1 -0
- package/dist/icons/UnknownIcon.js +33 -0
- package/dist/icons/UnknownIcon.js.map +1 -0
- package/dist/icons/_base.js +12 -0
- package/dist/icons/_base.js.map +1 -0
- package/dist/index.css +2 -62
- package/dist/index.d.ts +1955 -1891
- package/dist/index.js +312 -13
- package/dist/input/keyState.js +76 -0
- package/dist/input/keyState.js.map +1 -0
- package/dist/input/useKeyState.js +22 -0
- package/dist/input/useKeyState.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js +32 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -0
- package/dist/interactions/actions/align/align.js +81 -0
- package/dist/interactions/actions/align/align.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +120 -0
- package/dist/interactions/actions/booleans/booleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +20 -0
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js +9 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +94 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -0
- package/dist/interactions/actions/clipboard/materializePaste.js +25 -0
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -0
- package/dist/interactions/actions/clipboard/wireFormat.js +43 -0
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +26 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +42 -0
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -0
- package/dist/interactions/actions/defaults/align.js +71 -0
- package/dist/interactions/actions/defaults/align.js.map +1 -0
- package/dist/interactions/actions/defaults/anchorEditing.js +235 -0
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -0
- package/dist/interactions/actions/defaults/areaSelect.js +75 -0
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/booleans.js +52 -0
- package/dist/interactions/actions/defaults/booleans.js.map +1 -0
- package/dist/interactions/actions/defaults/cancelGesture.js +24 -0
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -0
- package/dist/interactions/actions/defaults/clearSelection.js +19 -0
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/clipboard.js +78 -0
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -0
- package/dist/interactions/actions/defaults/clone.js +96 -0
- package/dist/interactions/actions/defaults/clone.js.map +1 -0
- package/dist/interactions/actions/defaults/createOutlines.js +47 -0
- package/dist/interactions/actions/defaults/createOutlines.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js +85 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -0
- package/dist/interactions/actions/defaults/delete.js +61 -0
- package/dist/interactions/actions/defaults/delete.js.map +1 -0
- package/dist/interactions/actions/defaults/distribute.js +66 -0
- package/dist/interactions/actions/defaults/distribute.js.map +1 -0
- package/dist/interactions/actions/defaults/duplicate.js +83 -0
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -0
- package/dist/interactions/actions/defaults/editAnchors.js +100 -0
- package/dist/interactions/actions/defaults/editAnchors.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +29 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js +20 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/escape.js +26 -0
- package/dist/interactions/actions/defaults/escape.js.map +1 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js +22 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/flip.js +119 -0
- package/dist/interactions/actions/defaults/flip.js.map +1 -0
- package/dist/interactions/actions/defaults/freshNodeId.js +10 -0
- package/dist/interactions/actions/defaults/freshNodeId.js.map +1 -0
- package/dist/interactions/actions/defaults/group.js +131 -0
- package/dist/interactions/actions/defaults/group.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js +40 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js +10 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js +173 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +171 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js +63 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js +280 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +53 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/ingest.js +58 -0
- package/dist/interactions/actions/defaults/ingest.js.map +1 -0
- package/dist/interactions/actions/defaults/insert.js +288 -0
- package/dist/interactions/actions/defaults/insert.js.map +1 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js +50 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -0
- package/dist/interactions/actions/defaults/lassoSelect.js +156 -0
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/move.js +656 -0
- package/dist/interactions/actions/defaults/move.js.map +1 -0
- package/dist/interactions/actions/defaults/nudge.js +110 -0
- package/dist/interactions/actions/defaults/nudge.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js +63 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -0
- package/dist/interactions/actions/defaults/reorder.js +143 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -0
- package/dist/interactions/actions/defaults/requiresSelection.js +10 -0
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/resize.js +332 -0
- package/dist/interactions/actions/defaults/resize.js.map +1 -0
- package/dist/interactions/actions/defaults/rotate.js +181 -0
- package/dist/interactions/actions/defaults/rotate.js.map +1 -0
- package/dist/interactions/actions/defaults/selectAll.js +27 -0
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +27 -0
- package/dist/interactions/actions/defaults/setFill.js.map +1 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js +15 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/setStroke.js +36 -0
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +21 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/slice.js +39 -0
- package/dist/interactions/actions/defaults/slice.js.map +1 -0
- package/dist/interactions/actions/defaults/sliceOps.js +60 -0
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -0
- package/dist/interactions/actions/defaults/toolActivate.js +35 -0
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js +26 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -0
- package/dist/interactions/actions/defaults/undoRedo.js +51 -0
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js +88 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js +57 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportZoom.js +143 -0
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +42 -0
- package/dist/interactions/actions/distribute/distribute.js.map +1 -0
- package/dist/interactions/actions/distribute/plan.js +29 -0
- package/dist/interactions/actions/distribute/plan.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +61 -0
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/handles.js +43 -0
- package/dist/interactions/actions/edit-anchors/handles.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +35 -0
- package/dist/interactions/actions/flip/helpers.js.map +1 -0
- package/dist/interactions/actions/geometryProjection.js +18 -0
- package/dist/interactions/actions/geometryProjection.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +44 -0
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +39 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +36 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +67 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +37 -0
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +84 -0
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js +9 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js.map +1 -0
- package/dist/interactions/actions/planeInput.js +168 -0
- package/dist/interactions/actions/planeInput.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +9 -0
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -0
- package/dist/interactions/actions/poseFrame.js +38 -0
- package/dist/interactions/actions/poseFrame.js.map +1 -0
- package/dist/interactions/actions/previewOverrides.js +25 -0
- package/dist/interactions/actions/previewOverrides.js.map +1 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js +32 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js +18 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/index.js +8 -0
- package/dist/interactions/actions/resize/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js +24 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -0
- package/dist/interactions/actions/resize/cornerHandles.js +72 -0
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js +60 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -0
- package/dist/interactions/actions/resolvePreviews.js +61 -0
- package/dist/interactions/actions/resolvePreviews.js.map +1 -0
- package/dist/interactions/actions/rotate/geometry.js +46 -0
- package/dist/interactions/actions/rotate/geometry.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +27 -0
- package/dist/interactions/actions/rotate/handle.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js +42 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +142 -0
- package/dist/interactions/actions/useStandardActions.js.map +1 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js +111 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js +117 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -0
- package/dist/interactions/gestures/dragRect/dragRect.js +164 -0
- package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +46 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +118 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -0
- package/dist/interactions/gestures/shared/originProjection.js +42 -0
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -0
- package/dist/interactions/gestures/shared/screenTolerance.js +21 -0
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -0
- package/dist/interactions/gestures/shared/snap.js +24 -0
- package/dist/interactions/gestures/shared/snap.js.map +1 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +30 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -0
- package/dist/layout/arrivals.js +36 -0
- package/dist/layout/arrivals.js.map +1 -0
- package/dist/{math-MCQcf_gc.d.ts → math-CUMxmZzn.d.ts} +8 -116
- package/dist/math.d.ts +4 -5
- package/dist/math.js +6 -4
- package/dist/mesh.d.ts +268 -0
- package/dist/mesh.js +7 -0
- package/dist/move.d.ts +7 -49
- package/dist/move.js +3 -142
- package/dist/originProjection-BSn4xiEy.d.ts +57 -0
- package/dist/patterns-builtin.js +3 -3
- package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-CjSXMf8X.d.ts} +3 -3
- package/dist/registerProgram-ateHDGjw.d.ts +193 -0
- package/dist/renderer/DrawCommand.js +6 -0
- package/dist/renderer/DrawCommand.js.map +1 -0
- package/dist/renderer/WeaselRenderer.js +328 -0
- package/dist/renderer/WeaselRenderer.js.map +1 -0
- package/dist/renderer/cache/GLImageCache.js +64 -0
- package/dist/renderer/cache/GLImageCache.js.map +1 -0
- package/dist/renderer/cache/GLMeshCache.js +102 -0
- package/dist/renderer/cache/GLMeshCache.js.map +1 -0
- package/dist/renderer/cache/GLTextureCache.js +51 -0
- package/dist/renderer/cache/GLTextureCache.js.map +1 -0
- package/dist/renderer/cache/GradientRampAtlas.js +82 -0
- package/dist/renderer/cache/GradientRampAtlas.js.map +1 -0
- package/dist/renderer/cache/cache.js +13 -0
- package/dist/renderer/cache/cache.js.map +1 -0
- package/dist/renderer/cache/markerCommandCache.js +59 -0
- package/dist/renderer/cache/markerCommandCache.js.map +1 -0
- package/dist/renderer/cache/outlineMeshCache.js +15 -0
- package/dist/renderer/cache/outlineMeshCache.js.map +1 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js +31 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -0
- package/dist/renderer/cache/strokeMeshCache.js +44 -0
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -0
- package/dist/renderer/cullDrawCommands.js +89 -0
- package/dist/renderer/cullDrawCommands.js.map +1 -0
- package/dist/renderer/draw.js +1109 -0
- package/dist/renderer/draw.js.map +1 -0
- package/dist/renderer/drawBatch.js +168 -0
- package/dist/renderer/drawBatch.js.map +1 -0
- package/dist/renderer/effects/EffectTargets.js +45 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -0
- package/dist/renderer/effects/builtins.js +31 -0
- package/dist/renderer/effects/builtins.js.map +1 -0
- package/dist/renderer/effects/composite.js +9 -0
- package/dist/renderer/effects/composite.js.map +1 -0
- package/dist/renderer/effects/effectPrelude.js +10 -0
- package/dist/renderer/effects/effectPrelude.js.map +1 -0
- package/dist/renderer/effects/types.js +10 -0
- package/dist/renderer/effects/types.js.map +1 -0
- package/dist/renderer/index.js +19 -0
- package/dist/renderer/math/color.js +341 -0
- package/dist/renderer/math/color.js.map +1 -0
- package/dist/renderer/math/mat3.js +71 -0
- package/dist/renderer/math/mat3.js.map +1 -0
- package/dist/renderer/math/patternSpace.js +22 -0
- package/dist/renderer/math/patternSpace.js.map +1 -0
- package/dist/renderer/math/viewToMat3.js +19 -0
- package/dist/renderer/math/viewToMat3.js.map +1 -0
- package/dist/renderer/paintResources.js +18 -0
- package/dist/renderer/paintResources.js.map +1 -0
- package/dist/renderer/paintScratch.js +37 -0
- package/dist/renderer/paintScratch.js.map +1 -0
- package/dist/renderer/shaders/ShaderProgram.js +74 -0
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -0
- package/dist/renderer/shaders/batchFill.js +118 -0
- package/dist/renderer/shaders/batchFill.js.map +1 -0
- package/dist/renderer/shaders/customPrelude.js +34 -0
- package/dist/renderer/shaders/customPrelude.js.map +1 -0
- package/dist/renderer/shaders/extractUniformNames.js +184 -0
- package/dist/renderer/shaders/extractUniformNames.js.map +1 -0
- package/dist/renderer/shaders/glyphPaint.js +61 -0
- package/dist/renderer/shaders/glyphPaint.js.map +1 -0
- package/dist/renderer/shaders/gradFill.js +30 -0
- package/dist/renderer/shaders/gradFill.js.map +1 -0
- package/dist/renderer/shaders/imageFill.js +14 -0
- package/dist/renderer/shaders/imageFill.js.map +1 -0
- package/dist/renderer/shaders/pathFill.js +13 -0
- package/dist/renderer/shaders/pathFill.js.map +1 -0
- package/dist/renderer/shaders/patternFill.js +24 -0
- package/dist/renderer/shaders/patternFill.js.map +1 -0
- package/dist/renderer/shaders/registerProgram.js +18 -0
- package/dist/renderer/shaders/registerProgram.js.map +1 -0
- package/dist/renderer/spriteSheet.js +14 -0
- package/dist/renderer/spriteSheet.js.map +1 -0
- package/dist/renderer/state/GroupState.js +77 -0
- package/dist/renderer/state/GroupState.js.map +1 -0
- package/dist/renderer/syntheticItalic.js +6 -0
- package/dist/renderer/syntheticItalic.js.map +1 -0
- package/dist/renderer/textures/registerTexture.js +14 -0
- package/dist/renderer/textures/registerTexture.js.map +1 -0
- package/dist/renderer.d.ts +11 -21
- package/dist/renderer.js +18 -13
- package/dist/resize.d.ts +10 -46
- package/dist/resize.js +7 -5
- package/dist/routing.js +2 -3
- package/dist/scheduling/useVisibleRaf.js +69 -0
- package/dist/scheduling/useVisibleRaf.js.map +1 -0
- package/dist/test-hook/createTestHook.js +39 -0
- package/dist/test-hook/createTestHook.js.map +1 -0
- package/dist/test-hook/install.js +12 -0
- package/dist/test-hook/install.js.map +1 -0
- package/dist/test-seams-fYf6m5pu.d.ts +356 -0
- package/dist/test-seams.d.ts +6 -0
- package/dist/test-seams.js +3 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +33 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +55 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -0
- package/dist/tools/builtin/hand/dragPanContribution.js +17 -0
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -0
- package/dist/tools/builtin/hand/useHandTool.js +31 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -0
- package/dist/tools/builtin/image/useImageTool.js +41 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js +42 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -0
- package/dist/tools/builtin/line/useLineTool.js +33 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -0
- package/dist/tools/builtin/pen/usePenTool.js +414 -0
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js +36 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -0
- package/dist/tools/builtin/pickTopMostHit.js +45 -0
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js +81 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +32 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +109 -0
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -0
- package/dist/tools/builtin/select/useSelectTool.js +162 -0
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -0
- package/dist/tools/builtin/shared/insertToolOptions.js +8 -0
- package/dist/tools/builtin/shared/insertToolOptions.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +263 -0
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -0
- package/dist/tools/builtin/star/useStarTool.js +82 -0
- package/dist/tools/builtin/star/useStarTool.js.map +1 -0
- package/dist/tools/builtin/text/useTextTool.js +177 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -0
- package/dist/tools/overlayBinding.js +8 -0
- package/dist/tools/overlayBinding.js.map +1 -0
- package/dist/tools/prefs.js +47 -0
- package/dist/tools/prefs.js.map +1 -0
- package/dist/tools/useKeybindings.js +66 -0
- package/dist/tools/useKeybindings.js.map +1 -0
- package/dist/{types-D-9QWBy5.d.ts → types-CA54-mAZ.d.ts} +181 -13
- package/dist/{types-qYpyTAiZ.d.ts → types-DSjd6W3n.d.ts} +32 -6
- package/dist/util/color.js +26 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/constrainTo45.js +17 -0
- package/dist/util/constrainTo45.js.map +1 -0
- package/dist/util/paint.js +72 -0
- package/dist/util/paint.js.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +29 -19
- package/dist/chunk-3TY6FHAF.js +0 -170
- package/dist/chunk-3TY6FHAF.js.map +0 -1
- package/dist/chunk-DGWNNKGD.js +0 -248
- package/dist/chunk-DGWNNKGD.js.map +0 -1
- package/dist/chunk-G4ZGQMY7.js +0 -33372
- package/dist/chunk-G4ZGQMY7.js.map +0 -1
- package/dist/chunk-L5YNZYEG.js +0 -648
- package/dist/chunk-L5YNZYEG.js.map +0 -1
- package/dist/chunk-LU4IJ52W.js +0 -111
- package/dist/chunk-LU4IJ52W.js.map +0 -1
- package/dist/chunk-M24CLARN.js +0 -28
- package/dist/chunk-M24CLARN.js.map +0 -1
- package/dist/chunk-NE27EOLP.js +0 -146
- package/dist/chunk-NE27EOLP.js.map +0 -1
- package/dist/chunk-PNNZSYRD.js +0 -318
- package/dist/chunk-PNNZSYRD.js.map +0 -1
- package/dist/chunk-UPZY4ART.js +0 -29
- package/dist/chunk-UPZY4ART.js.map +0 -1
- package/dist/chunk-WPNA6L5O.js +0 -250
- package/dist/chunk-WPNA6L5O.js.map +0 -1
- package/dist/chunk-XMAWPGTK.js +0 -128
- package/dist/chunk-XMAWPGTK.js.map +0 -1
- package/dist/clipboard.js.map +0 -1
- package/dist/clone.js.map +0 -1
- package/dist/grid-CY5UKlZh.d.ts +0 -98
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/insert.d.ts +0 -36
- package/dist/insert.js +0 -81
- package/dist/insert.js.map +0 -1
- package/dist/math.js.map +0 -1
- package/dist/move.js.map +0 -1
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/patterns-builtin.js.map +0 -1
- package/dist/renderer.css +0 -62
- package/dist/renderer.css.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/dist/resize.js.map +0 -1
- package/dist/routing.js.map +0 -1
- package/dist/types-D2tTKEU0.d.ts +0 -18
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createSimulation as e } from "./createSimulation.js";
|
|
2
|
+
import { useVisibleRaf as t } from "../../scheduling/useVisibleRaf.js";
|
|
3
|
+
import { useLayoutEffect as n, useMemo as r, useRef as i } from "react";
|
|
4
|
+
import { useLatest as a } from "@weasel-js/react";
|
|
5
|
+
//#region src/features/simulation/useSimulation.ts
|
|
6
|
+
function o(o) {
|
|
7
|
+
let s = a(o), c = i(null);
|
|
8
|
+
c.current ??= e(o);
|
|
9
|
+
let l = c.current, u = i(!1), d = i(!0), f = t(() => {
|
|
10
|
+
m();
|
|
11
|
+
}, {
|
|
12
|
+
requestFrame: o.requestFrame,
|
|
13
|
+
cancelFrame: o.cancelFrame
|
|
14
|
+
}), p = () => {
|
|
15
|
+
f.cancel();
|
|
16
|
+
}, m = () => {
|
|
17
|
+
if (d.current) {
|
|
18
|
+
if (l.tick(), s.current.onTick?.(l.nodes), l.alpha() < l.alphaMin()) {
|
|
19
|
+
p(), u.current || (u.current = !0, s.current.onEnd?.());
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
f.request();
|
|
23
|
+
}
|
|
24
|
+
}, h = () => {
|
|
25
|
+
d.current && f.request();
|
|
26
|
+
};
|
|
27
|
+
return n(() => (d.current = !0, f.request(), () => {
|
|
28
|
+
d.current = !1, f.cancel();
|
|
29
|
+
}), [f]), r(() => {
|
|
30
|
+
let e = {
|
|
31
|
+
get nodes() {
|
|
32
|
+
return l.nodes;
|
|
33
|
+
},
|
|
34
|
+
setNodes(t) {
|
|
35
|
+
return l.setNodes(t), e;
|
|
36
|
+
},
|
|
37
|
+
setForces(t) {
|
|
38
|
+
return l.setForces(t), e;
|
|
39
|
+
},
|
|
40
|
+
alpha(t) {
|
|
41
|
+
return t === void 0 ? l.alpha() : (l.alpha(t), t >= l.alphaMin() && (u.current = !1), e);
|
|
42
|
+
},
|
|
43
|
+
alphaTarget(t) {
|
|
44
|
+
return t === void 0 ? l.alphaTarget() : (l.alphaTarget(t), t > 0 && (u.current = !1), e);
|
|
45
|
+
},
|
|
46
|
+
alphaDecay(t) {
|
|
47
|
+
return t === void 0 ? l.alphaDecay() : (l.alphaDecay(t), e);
|
|
48
|
+
},
|
|
49
|
+
alphaMin(t) {
|
|
50
|
+
return t === void 0 ? l.alphaMin() : (l.alphaMin(t), e);
|
|
51
|
+
},
|
|
52
|
+
velocityDecay(t) {
|
|
53
|
+
return t === void 0 ? l.velocityDecay() : (l.velocityDecay(t), e);
|
|
54
|
+
},
|
|
55
|
+
restart() {
|
|
56
|
+
return l.alpha() < l.alphaMin() && l.alpha(1), u.current = !1, h(), e;
|
|
57
|
+
},
|
|
58
|
+
stop() {
|
|
59
|
+
return p(), e;
|
|
60
|
+
},
|
|
61
|
+
tick(t = 1) {
|
|
62
|
+
return l.tick(t), e;
|
|
63
|
+
},
|
|
64
|
+
isSettled() {
|
|
65
|
+
return l.isSettled();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return e;
|
|
69
|
+
}, []);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { o as useSimulation };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=useSimulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSimulation.js","names":["useSimulation","optsRef","useLatest","opts","coreRef","useRef","createSimulation","core","endedRef","mountedRef","frameLoop","useVisibleRaf","stopRaf","rafTick","startRaf","useLayoutEffect","useMemo","h","newNodes","newForces","value","iterations"],"sources":["../../../src/features/simulation/useSimulation.ts"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { useVisibleRaf } from '../../scheduling/useVisibleRaf';\nimport { createSimulation } from './createSimulation';\nimport {\n type Simulation,\n type SimulationCore,\n type SimulationForce,\n type SimulationNode,\n type UseSimulationOptions,\n} from './types';\n\n/**\n * Continuous N-body simulation primitive: `createSimulation`'s integrator on a\n * frame loop.\n *\n * The kit is adapter-agnostic — `onTick(nodes)` fires after each integration\n * step and the consumer decides how (and whether) to write through to scene\n * state. Per-tick history bypass and settle-commit semantics are consumer\n * concerns; the kit doesn't have an opinion.\n */\nexport function useSimulation<TNode extends SimulationNode>(\n opts: UseSimulationOptions<TNode>,\n): Simulation<TNode> {\n const optsRef = useLatest(opts);\n\n const coreRef = useRef<SimulationCore<TNode> | null>(null);\n coreRef.current ??= createSimulation(opts);\n const core = coreRef.current;\n\n /** Whether onEnd has fired since the last energization (restart / alpha set / target raise). */\n const endedRef = useRef(false);\n const mountedRef = useRef(true);\n\n // The loop runs behind the visibility gate: a settling simulation stops\n // integrating on a page nobody is looking at, and picks up where it left off.\n // Its step is fixed rather than time-based, so there is no clock to rebase.\n // The gate defaults an absent clock to `requestAnimationFrame`, so an\n // injected one passes straight through rather than being defaulted twice.\n const frameLoop = useVisibleRaf(\n () => { rafTick(); },\n {\n requestFrame: opts.requestFrame,\n cancelFrame: opts.cancelFrame,\n },\n );\n\n const stopRaf = (): void => { frameLoop.cancel(); };\n\n const rafTick = (): void => {\n if (!mountedRef.current) return;\n\n core.tick();\n optsRef.current.onTick?.(core.nodes);\n\n if (core.alpha() < core.alphaMin()) {\n stopRaf();\n if (!endedRef.current) {\n endedRef.current = true;\n optsRef.current.onEnd?.();\n }\n return;\n }\n\n frameLoop.request();\n };\n\n const startRaf = (): void => {\n if (!mountedRef.current) return;\n frameLoop.request();\n };\n\n // Starts on every mount, StrictMode's simulated remount included, and in a\n // layout effect so a host's own layout effects can already `stop()` it.\n // `createSimulation` has already primed the nodes.\n useLayoutEffect(() => {\n mountedRef.current = true;\n frameLoop.request();\n return () => {\n mountedRef.current = false;\n frameLoop.cancel();\n };\n }, [frameLoop]);\n\n // Stable handle. All methods read through the core, so a fixed identity is safe.\n const handle = useMemo<Simulation<TNode>>(() => {\n /* eslint-disable @typescript-eslint/no-explicit-any */\n const h: any = {\n get nodes() {\n return core.nodes;\n },\n setNodes(newNodes: TNode[]) {\n core.setNodes(newNodes);\n return h;\n },\n setForces(newForces: SimulationForce<TNode>[]) {\n core.setForces(newForces);\n return h;\n },\n alpha(value?: number) {\n if (value === undefined) return core.alpha();\n core.alpha(value);\n if (value >= core.alphaMin()) endedRef.current = false;\n return h;\n },\n alphaTarget(value?: number) {\n if (value === undefined) return core.alphaTarget();\n core.alphaTarget(value);\n if (value > 0) endedRef.current = false;\n return h;\n },\n alphaDecay(value?: number) {\n if (value === undefined) return core.alphaDecay();\n core.alphaDecay(value);\n return h;\n },\n alphaMin(value?: number) {\n if (value === undefined) return core.alphaMin();\n core.alphaMin(value);\n return h;\n },\n velocityDecay(value?: number) {\n if (value === undefined) return core.velocityDecay();\n core.velocityDecay(value);\n return h;\n },\n restart() {\n if (core.alpha() < core.alphaMin()) core.alpha(1);\n endedRef.current = false;\n startRaf();\n return h;\n },\n stop() {\n stopRaf();\n return h;\n },\n tick(iterations: number = 1) {\n core.tick(iterations);\n return h;\n },\n isSettled() {\n return core.isSettled();\n },\n };\n return h as Simulation<TNode>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return handle;\n}\n"],"mappings":";;;;;AAqBA,SAAgBA,EACd,GACmB;CACnB,IAAMC,IAAUC,EAAUC,CAAI,GAExBC,IAAUC,EAAqC,IAAI;CACzD,EAAQ,YAAYC,EAAiBH,CAAI;CACzC,IAAMI,IAAOH,EAAQ,SAGfI,IAAWH,EAAO,EAAK,GACvBI,IAAaJ,EAAO,EAAI,GAOxBK,IAAYC,QACV;EAAE,EAAQ;CAAG,GACnB;EACE,cAAcR,EAAK;EACnB,aAAaA,EAAK;CACpB,CACF,GAEMS,UAAsB;EAAE,EAAU,OAAO;CAAG,GAE5CC,UAAsB;EAC1B,IAAKJ,EAAW,SAKhB;OAHAF,EAAK,KAAK,GACVN,EAAQ,QAAQ,SAASM,EAAK,KAAK,GAE/BA,EAAK,MAAM,IAAIA,EAAK,SAAS,GAAG;IAElC,AADAK,EAAQ,GACHJ,EAAS,YACZ,EAAS,UAAU,IACnBP,EAAQ,QAAQ,QAAQ;IAE1B;GACF;GAEA,EAAU,QAAQ;EAFlB;CAGF,GAEMa,UAAuB;EAC3B,AAAKL,EAAW,WAChBC,EAAU,QAAQ;CACpB;CA+EA,OA1EAK,SACE,EAAW,UAAU,IACrBL,EAAU,QAAQ,SACL;EAEX,AADA,EAAW,UAAU,IACrBA,EAAU,OAAO;CACnB,IACC,CAACA,CAAS,CAAC,GAGCM,QAAiC;EAE9C,IAAMC,IAAS;GACb,IAAI,QAAQ;IACV,OAAOV,EAAK;GACd;GACA,SAAS,GAAmB;IAE1B,OADAA,EAAK,SAASW,CAAQ,GACfD;GACT;GACA,UAAU,GAAqC;IAE7C,OADAV,EAAK,UAAUY,CAAS,GACjBF;GACT;GACA,MAAM,GAAgB;IAIpB,OAHIG,MAAU,KAAA,IAAkBb,EAAK,MAAM,KAC3CA,EAAK,MAAMa,CAAK,GACZA,KAASb,EAAK,SAAS,MAAG,EAAS,UAAU,KAC1CU;GACT;GACA,YAAY,GAAgB;IAI1B,OAHIG,MAAU,KAAA,IAAkBb,EAAK,YAAY,KACjDA,EAAK,YAAYa,CAAK,GAClBA,IAAQ,MAAG,EAAS,UAAU,KAC3BH;GACT;GACA,WAAW,GAAgB;IAGzB,OAFIG,MAAU,KAAA,IAAkBb,EAAK,WAAW,KAChDA,EAAK,WAAWa,CAAK,GACdH;GACT;GACA,SAAS,GAAgB;IAGvB,OAFIG,MAAU,KAAA,IAAkBb,EAAK,SAAS,KAC9CA,EAAK,SAASa,CAAK,GACZH;GACT;GACA,cAAc,GAAgB;IAG5B,OAFIG,MAAU,KAAA,IAAkBb,EAAK,cAAc,KACnDA,EAAK,cAAca,CAAK,GACjBH;GACT;GACA,UAAU;IAIR,OAHIV,EAAK,MAAM,IAAIA,EAAK,SAAS,KAAGA,EAAK,MAAM,CAAC,GAChD,EAAS,UAAU,IACnBO,EAAS,GACFG;GACT;GACA,OAAO;IAEL,OADAL,EAAQ,GACDK;GACT;GACA,KAAK,IAAqB,GAAG;IAE3B,OADAV,EAAK,KAAKc,CAAU,GACbJ;GACT;GACA,YAAY;IACV,OAAOV,EAAK,UAAU;GACxB;EACF;EACA,OAAOU;CAGT,GAAG,CAAC,CAEG;AACT"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { cssFontFamily as e } from "@weasel-js/font";
|
|
2
|
+
import { DEFAULT_TEXT_STYLE as t, SMALL_CAPS_SCALE as n, isHardLineBreak as r, numericWeight as i, smallCapsScaleFor as a, smallCapsText as o, transformRunTexts as s } from "@weasel-js/text";
|
|
3
|
+
//#region src/features/text/domRuns.ts
|
|
4
|
+
function c(e) {
|
|
5
|
+
return e && "color" in e ? e.color : null;
|
|
6
|
+
}
|
|
7
|
+
var l = /* @__PURE__ */ new Set([
|
|
8
|
+
"none",
|
|
9
|
+
"uppercase",
|
|
10
|
+
"lowercase",
|
|
11
|
+
"capitalize"
|
|
12
|
+
]), u = {
|
|
13
|
+
bold: !1,
|
|
14
|
+
italic: !1,
|
|
15
|
+
underline: !1,
|
|
16
|
+
strikethrough: !1,
|
|
17
|
+
overline: !1
|
|
18
|
+
};
|
|
19
|
+
function d(e) {
|
|
20
|
+
let t = parseFloat(e);
|
|
21
|
+
if (!Number.isFinite(t)) return;
|
|
22
|
+
let n = /^-?[\d.]+([a-z%]+)$/i.exec(e.trim())?.[1]?.toLowerCase();
|
|
23
|
+
return n && n !== "px" && console.warn(`weasel domRuns: letter-spacing "${e}" uses unit "${n}", which is not converted; treated as ${t} world units`), t;
|
|
24
|
+
}
|
|
25
|
+
var f = (e) => e.hasAttribute("data-small-caps");
|
|
26
|
+
function p(e) {
|
|
27
|
+
let t = e.style.fontVariant || e.style.getPropertyValue("font-variant-caps");
|
|
28
|
+
return t === "small-caps" || t === "normal" ? t : void 0;
|
|
29
|
+
}
|
|
30
|
+
function m(e, t) {
|
|
31
|
+
if (f(e)) return t;
|
|
32
|
+
let n = { ...t }, r = e.tagName;
|
|
33
|
+
if ((r === "B" || r === "STRONG") && (n.bold = !0, n.fontWeight = void 0), (r === "I" || r === "EM") && (n.italic = !0), r === "U" && (n.underline = !0), (r === "S" || r === "STRIKE" || r === "DEL") && (n.strikethrough = !0), r === "SUP" && (n.script = "super"), r === "SUB" && (n.script = "sub"), e instanceof HTMLElement) {
|
|
34
|
+
let t = e.style.fontWeight, r = Number(e.getAttribute("data-font-weight") ?? t);
|
|
35
|
+
e.hasAttribute("data-font-weight") || ![
|
|
36
|
+
"",
|
|
37
|
+
"700",
|
|
38
|
+
"bold",
|
|
39
|
+
"400",
|
|
40
|
+
"normal"
|
|
41
|
+
].includes(t) ? Number.isFinite(r) && r > 0 && (n.fontWeight = r, n.bold = !1) : t !== "" && (n.bold = t === "700" || t === "bold", n.fontWeight = void 0);
|
|
42
|
+
let i = e.style.fontStyle;
|
|
43
|
+
i === "italic" && (n.italic = !0), i === "normal" && (n.italic = !1);
|
|
44
|
+
let a = e.style.textDecoration || e.style.textDecorationLine;
|
|
45
|
+
if (a && !a.includes("none") && (n.underline ||= a.includes("underline"), n.strikethrough ||= a.includes("line-through"), n.overline ||= a.includes("overline")), e.style.fontSize) {
|
|
46
|
+
let t = parseFloat(e.style.fontSize);
|
|
47
|
+
Number.isFinite(t) && (e.style.fontSize.trim().endsWith("%") ? n.fontScale = t / 100 : n.fontSize = t);
|
|
48
|
+
}
|
|
49
|
+
let o = e.style.verticalAlign;
|
|
50
|
+
(o === "super" || o === "sub") && (n.script = o === "super" ? "super" : "sub"), o === "baseline" && (n.script = void 0);
|
|
51
|
+
let s = e.getAttribute("data-baseline-shift");
|
|
52
|
+
if (s != null) {
|
|
53
|
+
let e = parseFloat(s);
|
|
54
|
+
Number.isFinite(e) && (n.baselineShift = e);
|
|
55
|
+
}
|
|
56
|
+
let c = e.style.textTransform;
|
|
57
|
+
l.has(c) && (n.textTransform = c);
|
|
58
|
+
let u = p(e);
|
|
59
|
+
u && (n.fontVariantCaps = u);
|
|
60
|
+
let f = e.getAttribute("data-font-family") ?? e.style.fontFamily;
|
|
61
|
+
f && (n.fontFamily = f), e.style.color && (n.color = e.style.color);
|
|
62
|
+
let m = e.style.letterSpacing;
|
|
63
|
+
if (m === "normal") n.letterSpacing = void 0;
|
|
64
|
+
else if (m) {
|
|
65
|
+
let e = d(m);
|
|
66
|
+
e != null && (n.letterSpacing = e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
function h(e, t) {
|
|
72
|
+
return e.bold === t.bold && e.italic === t.italic && e.underline === t.underline && e.strikethrough === t.strikethrough && e.overline === t.overline && e.fontWeight === t.fontWeight && e.fontSize === t.fontSize && e.fontFamily === t.fontFamily && e.color === t.color && e.letterSpacing === t.letterSpacing && e.script === t.script && e.baselineShift === t.baselineShift && e.fontScale === t.fontScale && e.textTransform === t.textTransform && e.fontVariantCaps === t.fontVariantCaps;
|
|
73
|
+
}
|
|
74
|
+
function g(e, t) {
|
|
75
|
+
let n = { text: e };
|
|
76
|
+
return t.bold && (n.bold = !0), t.italic && (n.italic = !0), t.fontWeight != null && (n.fontWeight = t.fontWeight), t.fontSize != null && (n.fontSize = t.fontSize), t.fontFamily != null && (n.fontFamily = t.fontFamily), t.color != null && (n.fill = {
|
|
77
|
+
fill: "solid",
|
|
78
|
+
color: t.color
|
|
79
|
+
}), t.letterSpacing != null && (n.letterSpacing = t.letterSpacing), t.underline && (n.underline = !0), t.strikethrough && (n.strikethrough = !0), t.overline && (n.overline = !0), t.script != null && (n.script = t.script), t.baselineShift != null && (n.baselineShift = t.baselineShift), t.fontScale != null && (n.fontScale = t.fontScale), t.textTransform != null && (n.textTransform = t.textTransform), t.fontVariantCaps != null && (n.fontVariantCaps = t.fontVariantCaps), n;
|
|
80
|
+
}
|
|
81
|
+
var _ = "data-break";
|
|
82
|
+
function v(e) {
|
|
83
|
+
let t = e.textContent ?? "", n = parseInt(e.getAttribute(_) ?? "", 16);
|
|
84
|
+
return t.startsWith("\n") && Number.isFinite(n) ? String.fromCharCode(n) + t.slice(1) : t;
|
|
85
|
+
}
|
|
86
|
+
function y(e, t) {
|
|
87
|
+
let n = 0;
|
|
88
|
+
for (let i = 0; i < t.length; i++) {
|
|
89
|
+
let a = t.charCodeAt(i);
|
|
90
|
+
if (a === 10 || !r(a) || a === 13 && t.charCodeAt(i + 1) === 10) continue;
|
|
91
|
+
i > n && e.appendChild(document.createTextNode(t.slice(n, i)));
|
|
92
|
+
let o = document.createElement("span");
|
|
93
|
+
o.setAttribute(_, a.toString(16)), o.textContent = "\n", e.appendChild(o), n = i + 1;
|
|
94
|
+
}
|
|
95
|
+
n < t.length && e.appendChild(document.createTextNode(t.slice(n)));
|
|
96
|
+
}
|
|
97
|
+
function b(e) {
|
|
98
|
+
let t = [];
|
|
99
|
+
function n(e, r) {
|
|
100
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
101
|
+
let n = e.data;
|
|
102
|
+
n.length > 0 && t.push({
|
|
103
|
+
text: n,
|
|
104
|
+
style: r
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
109
|
+
let i = e;
|
|
110
|
+
if (i.tagName === "BR") {
|
|
111
|
+
t.push({
|
|
112
|
+
text: "\n",
|
|
113
|
+
style: r
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (i.hasAttribute(_)) {
|
|
118
|
+
let e = v(i);
|
|
119
|
+
e.length > 0 && t.push({
|
|
120
|
+
text: e,
|
|
121
|
+
style: r
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
i.tagName === "DIV" && t.length > 0 && t.push({
|
|
126
|
+
text: "\n",
|
|
127
|
+
style: r
|
|
128
|
+
});
|
|
129
|
+
let a = m(i, r);
|
|
130
|
+
for (let e of Array.from(i.childNodes)) n(e, a);
|
|
131
|
+
}
|
|
132
|
+
for (let t of Array.from(e.childNodes)) n(t, u);
|
|
133
|
+
let r = [], i = 0;
|
|
134
|
+
for (; i < t.length;) {
|
|
135
|
+
let e = i + 1;
|
|
136
|
+
for (; e < t.length && h(t[i].style, t[e].style);) e++;
|
|
137
|
+
let n = t.slice(i, e).map((e) => e.text).join("");
|
|
138
|
+
r.push(g(n, t[i].style)), i = e;
|
|
139
|
+
}
|
|
140
|
+
return r;
|
|
141
|
+
}
|
|
142
|
+
var x = "--weasel-small-caps";
|
|
143
|
+
function S(e, t) {
|
|
144
|
+
let [n] = s([e], [t]), r = o(n.text, n.srcMap), i = Array(e.length).fill(!1);
|
|
145
|
+
r.small?.forEach((e, t) => {
|
|
146
|
+
e && (i[r.srcMap ? r.srcMap.starts[t] : t] = !0);
|
|
147
|
+
});
|
|
148
|
+
let a = [], c = 0;
|
|
149
|
+
for (let t of e) {
|
|
150
|
+
let e = a[a.length - 1];
|
|
151
|
+
e && e.small === i[c] ? e.text += t : a.push({
|
|
152
|
+
text: t,
|
|
153
|
+
small: i[c]
|
|
154
|
+
}), c += t.length;
|
|
155
|
+
}
|
|
156
|
+
return a;
|
|
157
|
+
}
|
|
158
|
+
function C(e, t, r) {
|
|
159
|
+
e.replaceChildren();
|
|
160
|
+
for (let i of S(t, r)) {
|
|
161
|
+
if (!i.small) {
|
|
162
|
+
y(e, i.text);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
let t = document.createElement("span");
|
|
166
|
+
t.setAttribute("data-small-caps", ""), t.style.fontSize = `calc(var(${x}, ${n}) * 1em)`, t.style.textTransform = "uppercase", t.textContent = i.text, e.appendChild(t);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function w(n, r, o = t) {
|
|
170
|
+
r.replaceChildren();
|
|
171
|
+
for (let t of n) {
|
|
172
|
+
let n = document.createElement("span");
|
|
173
|
+
if (n.setAttribute("data-run", ""), (t.fontVariantCaps ?? o.fontVariantCaps) === "small-caps") {
|
|
174
|
+
let e = a(t.fontFamily ?? o.fontFamily, t.fontWeight ?? (t.bold ? 700 : i(o.fontWeight)), t.italic ? "italic" : o.fontStyle);
|
|
175
|
+
n.style.setProperty(x, String(e)), C(n, t.text, t.textTransform ?? o.textTransform);
|
|
176
|
+
} else y(n, t.text);
|
|
177
|
+
t.fontVariantCaps != null && (n.style.fontVariant = t.fontVariantCaps), t.fontWeight == null ? t.bold && (n.style.fontWeight = "700") : (n.style.fontWeight = String(t.fontWeight), n.setAttribute("data-font-weight", String(t.fontWeight))), t.italic && (n.style.fontStyle = "italic"), t.fontSize == null ? t.fontScale != null && (n.style.fontSize = `${t.fontScale * 100}%`) : n.style.fontSize = `${t.fontSize}px`, t.fontFamily != null && (n.style.fontFamily = e(t.fontFamily, {
|
|
178
|
+
weight: t.fontWeight ?? (t.bold ? 700 : void 0),
|
|
179
|
+
style: t.italic ? "italic" : void 0
|
|
180
|
+
}), n.setAttribute("data-font-family", t.fontFamily));
|
|
181
|
+
let s = c(t.fill);
|
|
182
|
+
s != null && (n.style.color = s);
|
|
183
|
+
let l = [];
|
|
184
|
+
t.underline && l.push("underline"), t.strikethrough && l.push("line-through"), t.overline && l.push("overline"), l.length > 0 && (n.style.textDecoration = l.join(" ")), t.script != null && (n.style.verticalAlign = t.script), t.baselineShift != null && n.setAttribute("data-baseline-shift", String(t.baselineShift)), t.letterSpacing != null && (n.style.letterSpacing = `${t.letterSpacing}px`), t.textTransform != null && (n.style.textTransform = t.textTransform), r.appendChild(n);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function T(e) {
|
|
188
|
+
let t = "";
|
|
189
|
+
for (let n of e.childNodes) n.nodeType === Node.TEXT_NODE ? t += n.data : n instanceof Element && (t += n.hasAttribute(_) ? v(n) : T(n));
|
|
190
|
+
return t;
|
|
191
|
+
}
|
|
192
|
+
function E(e, t) {
|
|
193
|
+
let n = S(T(e), t), r = [];
|
|
194
|
+
for (let t of e.childNodes) {
|
|
195
|
+
let e, n;
|
|
196
|
+
if (t.nodeType === Node.TEXT_NODE) e = !1, n = t.data;
|
|
197
|
+
else if (t instanceof HTMLElement && t.hasAttribute(_)) e = !1, n = v(t);
|
|
198
|
+
else if (t instanceof HTMLElement && f(t) && t.children.length === 0) e = !0, n = t.textContent ?? "";
|
|
199
|
+
else return !1;
|
|
200
|
+
if (n.length === 0) continue;
|
|
201
|
+
let i = r[r.length - 1];
|
|
202
|
+
i && i.small === e ? i.text += n : r.push({
|
|
203
|
+
text: n,
|
|
204
|
+
small: e
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return n.length === r.length && n.every((e, t) => e.text === r[t].text && e.small === r[t].small);
|
|
208
|
+
}
|
|
209
|
+
function D(e) {
|
|
210
|
+
let t = !1, n = (e, r, i) => {
|
|
211
|
+
let a = p(e) ?? r, o = e.style.textTransform, s = l.has(o) ? o : i;
|
|
212
|
+
if (e.hasAttribute("data-run")) {
|
|
213
|
+
if (a === "small-caps") E(e, s) || (C(e, T(e), s), t = !0);
|
|
214
|
+
else if (e.querySelector("[data-small-caps]")) {
|
|
215
|
+
let n = T(e);
|
|
216
|
+
e.replaceChildren(), y(e, n), t = !0;
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
for (let t of e.children) t instanceof HTMLElement && n(t, a, s);
|
|
221
|
+
};
|
|
222
|
+
return n(e, "normal", "none"), t;
|
|
223
|
+
}
|
|
224
|
+
function O(e, t) {
|
|
225
|
+
let n = t, r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), i = null, a = r.nextNode();
|
|
226
|
+
for (; a;) {
|
|
227
|
+
let e = a.data.length;
|
|
228
|
+
if (n <= e) return {
|
|
229
|
+
node: a,
|
|
230
|
+
offset: n
|
|
231
|
+
};
|
|
232
|
+
n -= e, i = a, a = r.nextNode();
|
|
233
|
+
}
|
|
234
|
+
return i ? {
|
|
235
|
+
node: i,
|
|
236
|
+
offset: i.data.length
|
|
237
|
+
} : {
|
|
238
|
+
node: e,
|
|
239
|
+
offset: 0
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function k(e, t, n) {
|
|
243
|
+
let r = 0, i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), a = i.nextNode();
|
|
244
|
+
if (t.nodeType === Node.TEXT_NODE) {
|
|
245
|
+
for (; a;) {
|
|
246
|
+
if (a === t) return r + n;
|
|
247
|
+
r += a.data.length, a = i.nextNode();
|
|
248
|
+
}
|
|
249
|
+
return r;
|
|
250
|
+
}
|
|
251
|
+
let o = document.createRange();
|
|
252
|
+
for (o.setStart(t, Math.max(0, Math.min(n, t.childNodes.length))), o.collapse(!0); a;) o.comparePoint(a, 0) < 0 && (r += a.data.length), a = i.nextNode();
|
|
253
|
+
return r;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { x as SMALL_CAPS_SCALE_PROPERTY, y as appendOverlayText, O as charOffsetToDomPosition, k as domPositionToCharOffset, b as domToRuns, D as normalizeSmallCaps, w as runsToDom };
|
|
257
|
+
|
|
258
|
+
//# sourceMappingURL=domRuns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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.coll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AInC,AAFA,KAAaG,GACb,IAAO9C,GACP,IAAO6C,EAAO,SAAS;CACzB;CAEA,OADIxB,IAAa;EAAE,MAAMA;EAAM,QAAQA,EAAK,KAAK;CAAO,IACjD;EAAE,MAAMvD;EAAQ,QAAQ;CAAE;AACnC;AAeA,SAAgBiF,EACd,GACA,GACA,GACQ;CACR,IAAIC,IAAQ,GACNH,IAAS,SAAS,iBAAiB/E,GAAQ,WAAW,SAAS,GACjEmF,IAAMJ,EAAO,SAAS;CAC1B,IAAI7C,EAAK,aAAa,KAAK,WAAW;EACpC,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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;EACr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,CAAC,CAAC,CAAC,MAAM,GAAG,MAAMpB,EAAMqB,EAAE,CAAC,IAAIrB,EAAMsB,EAAE,CAAC,CAAC;CAE5E,KAAK,IAAMF,KAAKD,GAAQ;EACtB,IAAMpB,IAAIC,EAAMoB;EAChB,IAAI,OAAKT,IAAKZ,EAAE,IAAIA,EAAE,UAAU,IAGhC,OAAOA,EAAE,QAAQ,KAAM,IAAIA,EAAE,SAASA,EAAE;CAC1C;CACA,IAAMwB,IAAWvB,EAAMmB,EAAOA,EAAO,SAAS;CAC9C,OAAOI,EAAS,QAAQ,KAAM,IAAIA,EAAS,WAAWA,EAAS;AACjE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;C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