@weasel-js/core 1.7.0 → 1.7.2
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 +794 -0
- package/README.md +14 -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-vCdt55xm.d.ts} +2 -2
- package/dist/{builtins-DLn2lCr_.d.ts → builtins-C-gRyVRx.d.ts} +742 -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 +102 -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 +93 -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-BCrDp_mH.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 +39 -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.d.ts +1960 -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 +107 -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 +760 -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 +335 -0
- package/dist/interactions/actions/defaults/resize.js.map +1 -0
- package/dist/interactions/actions/defaults/rotate.js +184 -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 +181 -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 +31 -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-Drrw4ewZ.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-DEklpDc_.d.ts +57 -0
- package/dist/patterns-builtin.js +3 -3
- package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-D-OH-tu5.d.ts} +0 -4
- 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/style.css +2 -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-A37hYkeR.d.ts} +185 -15
- package/dist/{types-qYpyTAiZ.d.ts → types-B_9g6hMM.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 +31 -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 +0 -62
- 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,53 @@
|
|
|
1
|
+
import { applyStyleToRange as e } from "./rangeStyle.js";
|
|
2
|
+
import { isBoldWeight as t } from "@weasel-js/text";
|
|
3
|
+
//#region src/features/text/runs/flagRange.ts
|
|
4
|
+
function n(e, n) {
|
|
5
|
+
switch (n) {
|
|
6
|
+
case "bold": return e.fontWeight !== void 0 && t(e.fontWeight);
|
|
7
|
+
case "italic": return e.fontStyle === "italic";
|
|
8
|
+
case "underline": return e.underline === !0;
|
|
9
|
+
case "strikethrough": return e.strikethrough === !0;
|
|
10
|
+
case "overline": return e.overline === !0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
return n(e, "bold") ? {
|
|
15
|
+
bold: !1,
|
|
16
|
+
fontWeight: 400
|
|
17
|
+
} : { bold: !1 };
|
|
18
|
+
}
|
|
19
|
+
function i(e, t) {
|
|
20
|
+
let n = { ...e };
|
|
21
|
+
switch (t) {
|
|
22
|
+
case "italic":
|
|
23
|
+
n.fontStyle = "normal";
|
|
24
|
+
break;
|
|
25
|
+
case "underline":
|
|
26
|
+
delete n.underline;
|
|
27
|
+
break;
|
|
28
|
+
case "strikethrough":
|
|
29
|
+
delete n.strikethrough;
|
|
30
|
+
break;
|
|
31
|
+
case "overline": delete n.overline;
|
|
32
|
+
}
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
function a(t, a, o, s, c, l) {
|
|
36
|
+
if (l || !n(a, c)) return {
|
|
37
|
+
runs: e(t, o, s, { [c]: l }),
|
|
38
|
+
style: a
|
|
39
|
+
};
|
|
40
|
+
if (c === "bold") return {
|
|
41
|
+
runs: e(t, o, s, r(a)),
|
|
42
|
+
style: a
|
|
43
|
+
};
|
|
44
|
+
let u = t.reduce((e, t) => e + t.text.length, 0), d = Math.max(0, o), f = Math.min(u, s), p = e(t, 0, u, { [c]: !0 });
|
|
45
|
+
return d < f && (p = e(p, d, f, { [c]: !1 })), {
|
|
46
|
+
runs: p,
|
|
47
|
+
style: i(a, c)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { n as nodeHasFlag, a as setFlagOverRange, r as unboldPatch };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=flagRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagRange.js","names":["nodeHasFlag","key","style","isBoldWeight","unboldPatch","clearNodeFlag","next","setFlagOverRange","value","applyStyleToRange","runs","start","end","total","n","r","lo","hi"],"sources":["../../../../src/features/text/runs/flagRange.ts"],"sourcesContent":["/**\n * Turning a run-level flag **off** inside a node that sets it.\n *\n * Run flags are additive over the node's `TextStyle` — a run turns `bold` /\n * `italic` / `underline` / `strikethrough` on, never off (see the contract at\n * the top of `rangeStyle.ts`). So \"select a word inside an underlined node and\n * hit U\" is unrepresentable by the stored shape, and the character bar can\n * only refuse.\n *\n * This resolves it by rewriting rather than by widening the model: clear the\n * flag on the node, and set it on every run *outside* the range. The rendered\n * result is identical and the edit becomes expressible, with `StyledRun`\n * unchanged — so nothing a document can already contain changes meaning, which\n * matters while the flags are heading for a persisted format.\n *\n * The alternative was a tri-state run flag (`true` / `false` / inherit). It\n * cannot cover `italic`: that is a boolean on a run but `fontStyle` on the\n * node, so a run's `false` has no node-level boolean to override.\n *\n * `bold` needs neither: a run carries a numeric `fontWeight`, which overrides\n * the node's outright, so lowering bold writes a regular weight over the\n * range and leaves the node and the rest of the text alone.\n */\n\nimport { isBoldWeight } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextStyle } from '@weasel-js/text';\nimport { applyStyleToRange } from './rangeStyle';\nimport type { RunStylePatch } from './rangeStyle';\n\n/** The additive run flags. */\nexport type FlagKey = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'overline';\n\n/** The result of toggling a style flag over a text range: the rewritten runs\n * and node style, and whether the change could be made at all. */\nexport interface SetFlagResult {\n runs: StyledRun[];\n style: TextStyle;\n}\n\n/** Does the node style carry this flag? */\nexport function nodeHasFlag(style: TextStyle, key: FlagKey): boolean {\n switch (key) {\n case 'bold': return style.fontWeight !== undefined && isBoldWeight(style.fontWeight);\n case 'italic': return style.fontStyle === 'italic';\n case 'underline': return style.underline === true;\n case 'strikethrough': return style.strikethrough === true;\n case 'overline': return style.overline === true;\n }\n}\n\n/** The patch that takes bold off a range: the flag, and — in a node that is\n * itself bold — a regular weight to override the node's. */\nexport function unboldPatch(style: TextStyle): RunStylePatch {\n return nodeHasFlag(style, 'bold') ? { bold: false, fontWeight: 400 } : { bold: false };\n}\n\n/** The node style with `key` cleared. */\nfunction clearNodeFlag(style: TextStyle, key: Exclude<FlagKey, 'bold'>): TextStyle {\n const next = { ...style };\n switch (key) {\n case 'italic': next.fontStyle = 'normal'; break;\n case 'underline': delete next.underline; break;\n case 'strikethrough': delete next.strikethrough; break;\n case 'overline': delete next.overline; break;\n }\n return next;\n}\n\n/**\n * Set `key` to `value` over `[start, end)`.\n *\n * Turning a flag **on**, or off in a node that doesn't set it, is the ordinary\n * additive write and leaves `style` alone. Turning it off in a node that *does*\n * set it takes the rewrite: the node flag is cleared and the flag is written\n * onto the complement of the range. Bold is the exception, written as a\n * weight over the range alone (see {@link unboldPatch}).\n *\n * `runs` is normalized on every path, so the complement collapses back to one\n * run when the range is empty and the whole array coalesces as usual.\n */\nexport function setFlagOverRange(\n runs: readonly StyledRun[],\n style: TextStyle,\n start: number,\n end: number,\n key: FlagKey,\n value: boolean,\n): SetFlagResult {\n if (value || !nodeHasFlag(style, key)) {\n return { runs: applyStyleToRange(runs, start, end, { [key]: value }), style };\n }\n\n if (key === 'bold') {\n return { runs: applyStyleToRange(runs, start, end, unboldPatch(style)), style };\n }\n\n const total = runs.reduce((n, r) => n + r.text.length, 0);\n const lo = Math.max(0, start);\n const hi = Math.min(total, end);\n\n // Raise the flag on everything, then lower it over the range. Doing it in\n // that order rather than patching the two complement spans keeps one code\n // path for a range at either edge, where one span is empty.\n let next = applyStyleToRange(runs, 0, total, { [key]: true });\n if (lo < hi) next = applyStyleToRange(next, lo, hi, { [key]: false });\n\n return { runs: next, style: clearNodeFlag(style, key) };\n}\n"],"mappings":";;;AAyCA,SAAgBA,EAAY,GAAkB,GAAuB;CACnE,QAAQC,GAAR;EACE,KAAK,QAAQ,OAAOC,EAAM,eAAe,KAAA,KAAaC,EAAaD,EAAM,UAAU;EACnF,KAAK,UAAU,OAAOA,EAAM,cAAc;EAC1C,KAAK,aAAa,OAAOA,EAAM,cAAc;EAC7C,KAAK,iBAAiB,OAAOA,EAAM,kBAAkB;EACrD,KAAK,YAAY,OAAOA,EAAM,aAAa;CAC7C;AACF;AAIA,SAAgBE,EAAY,GAAiC;CAC3D,OAAOJ,EAAYE,GAAO,MAAM,IAAI;EAAE,MAAM;EAAO,YAAY;CAAI,IAAI,EAAE,MAAM,GAAM;AACvF;AAGA,SAASG,EAAc,GAAkB,GAA0C;CACjF,IAAMC,IAAO,EAAE,GAAGJ,EAAM;CACxB,QAAQD,GAAR;EACE,KAAK;GAAU,EAAK,YAAY;GAAU;EAC1C,KAAK;GAAa,OAAOK,EAAK;GAAW;EACzC,KAAK;GAAiB,OAAOA,EAAK;GAAe;EACjD,KAAK,YAAY,OAAOA,EAAK;CAC/B;CACA,OAAOA;AACT;AAcA,SAAgBC,EACd,GACA,GACA,GACA,GACA,GACA,GACe;CACf,IAAIC,KAAS,CAACR,EAAYE,GAAOD,CAAG,GAClC,OAAO;EAAE,MAAMQ,EAAkBC,GAAMC,GAAOC,GAAK,GAAGX,IAAMO,EAAM,CAAC;EAAG;CAAM;CAG9E,IAAIP,MAAQ,QACV,OAAO;EAAE,MAAMQ,EAAkBC,GAAMC,GAAOC,GAAKR,EAAYF,CAAK,CAAC;EAAG;CAAM;CAGhF,IAAMW,IAAQH,EAAK,QAAQ,GAAG,MAAMI,IAAIC,EAAE,KAAK,QAAQ,CAAC,GAClDC,IAAK,KAAK,IAAI,GAAGL,CAAK,GACtBM,IAAK,KAAK,IAAIJ,GAAOD,CAAG,GAK1BN,IAAOG,EAAkBC,GAAM,GAAGG,GAAO,GAAGZ,IAAM,GAAK,CAAC;CAG5D,OAFIe,IAAKC,MAAI,IAAOR,EAAkBH,GAAMU,GAAIC,GAAI,GAAGhB,IAAM,GAAM,CAAC,IAE7D;EAAE,MAAMK;EAAM,OAAOD,EAAcH,GAAOD,CAAG;CAAE;AACxD"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { MIXED as e } from "../../../core/mixed.js";
|
|
2
|
+
//#region src/features/text/runs/rangeStyle.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"bold",
|
|
5
|
+
"fontWeight",
|
|
6
|
+
"italic",
|
|
7
|
+
"underline",
|
|
8
|
+
"strikethrough",
|
|
9
|
+
"overline",
|
|
10
|
+
"fontFamily",
|
|
11
|
+
"fontSize",
|
|
12
|
+
"letterSpacing",
|
|
13
|
+
"fill",
|
|
14
|
+
"stroke",
|
|
15
|
+
"script",
|
|
16
|
+
"baselineShift",
|
|
17
|
+
"fontScale",
|
|
18
|
+
"textTransform",
|
|
19
|
+
"fontVariantCaps"
|
|
20
|
+
], n = /* @__PURE__ */ new Set([
|
|
21
|
+
"bold",
|
|
22
|
+
"italic",
|
|
23
|
+
"underline",
|
|
24
|
+
"strikethrough",
|
|
25
|
+
"overline"
|
|
26
|
+
]);
|
|
27
|
+
function r(e) {
|
|
28
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
29
|
+
}
|
|
30
|
+
function i(e, t) {
|
|
31
|
+
if (Object.is(e, t)) return !0;
|
|
32
|
+
if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => i(e, t[n]));
|
|
33
|
+
if (r(e) && r(t)) {
|
|
34
|
+
let n = Object.keys(e);
|
|
35
|
+
return n.length === Object.keys(t).length && n.every((n) => n in t && i(e[n], t[n]));
|
|
36
|
+
}
|
|
37
|
+
return !1;
|
|
38
|
+
}
|
|
39
|
+
function a(e, t) {
|
|
40
|
+
let r = e[t];
|
|
41
|
+
return n.has(t) ? r ?? !1 : r;
|
|
42
|
+
}
|
|
43
|
+
var o = /* @__PURE__ */ new Set(["fill", "stroke"]);
|
|
44
|
+
function s(e, t, n) {
|
|
45
|
+
return o.has(e) ? i(t, n) : Object.is(t, n);
|
|
46
|
+
}
|
|
47
|
+
function c(e, n) {
|
|
48
|
+
return t.every((t) => s(t, a(e, t), a(n, t)));
|
|
49
|
+
}
|
|
50
|
+
function l(e) {
|
|
51
|
+
let t = 0;
|
|
52
|
+
for (let n of e) t += n.text.length;
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
function u(n, r, i) {
|
|
56
|
+
let o = Math.max(0, r), c = i;
|
|
57
|
+
if (!(o < c)) return {};
|
|
58
|
+
let l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = !1, f = 0;
|
|
59
|
+
for (let e of n) {
|
|
60
|
+
let n = f + e.text.length, r = Math.max(f, o), i = Math.min(n, c);
|
|
61
|
+
if (f = n, r < i) {
|
|
62
|
+
for (let n of t) {
|
|
63
|
+
let t = a(e, n);
|
|
64
|
+
d ? !u.has(n) && !s(n, l.get(n), t) && u.add(n) : l.set(n, t);
|
|
65
|
+
}
|
|
66
|
+
d = !0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!d) return {};
|
|
70
|
+
let p = {};
|
|
71
|
+
for (let n of t) if (u.has(n)) p[n] = e;
|
|
72
|
+
else {
|
|
73
|
+
let e = l.get(n);
|
|
74
|
+
e !== void 0 && (p[n] = e);
|
|
75
|
+
}
|
|
76
|
+
return p;
|
|
77
|
+
}
|
|
78
|
+
function d(e) {
|
|
79
|
+
return e.some((e) => t.some((t) => {
|
|
80
|
+
let n = e[t];
|
|
81
|
+
return n !== void 0 && n !== !1;
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
function f(e) {
|
|
85
|
+
if ("bold" in e && !("fontWeight" in e)) return "fontWeight";
|
|
86
|
+
if (e.fontWeight !== void 0 && !("bold" in e)) return "bold";
|
|
87
|
+
}
|
|
88
|
+
function p(e, t) {
|
|
89
|
+
let n = { ...e }, r = f(t);
|
|
90
|
+
r !== void 0 && delete n[r];
|
|
91
|
+
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
|
|
92
|
+
return n;
|
|
93
|
+
}
|
|
94
|
+
function m(e, n) {
|
|
95
|
+
let r = { ...e }, i = f(n);
|
|
96
|
+
i !== void 0 && delete r[i];
|
|
97
|
+
for (let e of t) {
|
|
98
|
+
if (!(e in n)) continue;
|
|
99
|
+
let t = n[e];
|
|
100
|
+
t === void 0 || t === !1 ? delete r[e] : r[e] = t;
|
|
101
|
+
}
|
|
102
|
+
return r;
|
|
103
|
+
}
|
|
104
|
+
function h(e) {
|
|
105
|
+
let t = [];
|
|
106
|
+
for (let n of e) {
|
|
107
|
+
if (n.text.length === 0) continue;
|
|
108
|
+
let e = t[t.length - 1];
|
|
109
|
+
e && c(e, n) ? e.text += n.text : t.push({ ...n });
|
|
110
|
+
}
|
|
111
|
+
return t;
|
|
112
|
+
}
|
|
113
|
+
function g(e, t, n, r) {
|
|
114
|
+
let i = Math.max(0, t), a = Math.min(l(e), n);
|
|
115
|
+
if (!(i < a)) return h(e);
|
|
116
|
+
let o = [], s = 0;
|
|
117
|
+
for (let t of e) {
|
|
118
|
+
let e = s + t.text.length, n = Math.max(s, i), c = Math.min(e, a);
|
|
119
|
+
n < c ? (s < n && o.push({
|
|
120
|
+
...t,
|
|
121
|
+
text: t.text.slice(0, n - s)
|
|
122
|
+
}), o.push(m({
|
|
123
|
+
...t,
|
|
124
|
+
text: t.text.slice(n - s, c - s)
|
|
125
|
+
}, r)), c < e && o.push({
|
|
126
|
+
...t,
|
|
127
|
+
text: t.text.slice(c - s)
|
|
128
|
+
})) : o.push({ ...t }), s = e;
|
|
129
|
+
}
|
|
130
|
+
return h(o);
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { e as MIXED, g as applyStyleToRange, p as patchRangeStyle, d as runsCarryStyling, u as styleAtRange, f as supersededKey };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=rangeStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rangeStyle.js","names":["STYLE_KEYS","FLAG_KEYS","isPlainObject","v","deepEqual","a","b","item","i","keys","k","valueAt","value","run","key","STRUCTURAL_KEYS","sameValue","sameStyle","totalLength","n","runs","styleAtRange","lo","start","hi","end","first","mixed","seen","pos","runEnd","style","MIXED","runsCarryStyling","supersededKey","patch","patchRangeStyle","out","range","superseded","patchRun","next","coalesceRuns","prev","applyStyleToRange"],"sources":["../../../../src/features/text/runs/rangeStyle.ts"],"sourcesContent":["/**\n * Range-addressed styling over `StyledRun[]`. The panel addresses node paths;\n * a caret addresses a character range — these are the functions for the\n * second case. Pure and React-free so the semantics are unit-testable, the\n * same split `SelectionPanel` makes between `model.ts` and its component.\n *\n * Character offsets index the concatenated run text (`runsToPlainText`), and\n * a range is half-open: `[start, end)`. Ranges are clamped, never wrapped —\n * a negative `start` clamps to 0, an `end` past the text clamps to its\n * length, and a collapsed or inverted range (`start >= end`) is empty.\n * Offsets are UTF-16 code units, as everywhere else in this feature, so a\n * boundary can bisect a surrogate pair (`[1, 2)` over `'a👍b'` splits the\n * thumbs-up into lone surrogates). A caret-derived range never does this.\n *\n * **Run-level flags are additive over the node's `TextStyle`: a run can\n * turn `bold` / `italic` / `underline` / `strikethrough` on, never off.**\n * So a flag is stored only when true, and absent reads as `false`. A run\n * that must be lighter than a bold node says so with its own numeric\n * `fontWeight`, which `bold` is a preset over (see {@link supersededKey}).\n * For the boolean decorations there is no such primitive: both levels are\n * booleans, so a tri-state\n * (`true` / `false` / inherit) is expressible and we are collapsing it by\n * choice, to keep one canonical form per styling. Resolution must therefore\n * read decorations as `run.underline || style.underline` — a `??` would\n * make \"select a word in an underlined node, hit U to turn it off\" look\n * supported by the type while this file discards the `false` that expresses it.\n *\n * Copies here are shallow: a `fill` object is shared by reference between\n * the input runs, the patch, every run the patch touched, and the value\n * `styleAtRange` reports. Treat `fill` values as immutable.\n */\n\nimport { MIXED } from 'core/mixed';\nimport type { Mixed } from 'core/mixed';\nimport type { StyledRun } from '@weasel-js/text';\n\nexport { MIXED };\nexport type { Mixed };\n\n/** Every styleable key of a run, each either a concrete value or MIXED (the\n * runs in the range disagree at that key). */\nexport type RangeStyle = {\n [K in Exclude<keyof StyledRun, 'text'>]?: StyledRun[K] | Mixed;\n};\n\n/**\n * What `applyStyleToRange` writes. `text` is deliberately not part of it —\n * this is a styling operation, not an edit.\n */\nexport type RunStylePatch = Partial<Omit<StyledRun, 'text'>>;\n\n/** Every key of a run that carries styling — i.e. everything but `text`. */\nexport type StyleKey = Exclude<keyof StyledRun, 'text'>;\n\nconst STYLE_KEYS = [\n 'bold',\n 'fontWeight',\n 'italic',\n 'underline',\n 'strikethrough',\n 'overline',\n 'fontFamily',\n 'fontSize',\n 'letterSpacing',\n 'fill',\n 'stroke',\n 'script',\n 'baselineShift',\n 'fontScale',\n 'textTransform',\n 'fontVariantCaps',\n] as const satisfies readonly StyleKey[];\n\n// Every function here iterates STYLE_KEYS, so a key missing from the list is\n// invisible: `applyStyleToRange` would drop it when patching a run and\n// `sameStyle` would merge two runs that differ in it, silently discarding\n// one value. `satisfies` only checks the entries that ARE listed, so this\n// assertion checks the other direction — adding a key to `StyledRun`\n// without adding it here is a compile error.\ntype MissingStyleKey = Exclude<StyleKey, (typeof STYLE_KEYS)[number]>;\ntype AssertNoMissingStyleKey = [MissingStyleKey] extends [never] ? true : never;\nconst STYLE_KEYS_ARE_EXHAUSTIVE: AssertNoMissingStyleKey = true;\nvoid STYLE_KEYS_ARE_EXHAUSTIVE;\n\n/** The additive flags: absent and `false` mean the same thing, so both read as `false`. */\nconst FLAG_KEYS: ReadonlySet<StyleKey> = new Set<StyleKey>([\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'overline',\n]);\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Structural equality over the JSON-ish values a run can hold. This assumes\n * `FillStyle` stays acyclic and plain — every member of the union is data\n * (`TextureHandle` is `{ id }`, so patterns compare by id, which is right).\n * A fill that grew a cyclic or class-valued field would recurse forever.\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((item, i) => deepEqual(item, b[i]));\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((k) => k in b && deepEqual(a[k], b[k]));\n }\n return false;\n}\n\n/** A run's value at `key`, with flags normalized so absent reads as `false`. */\nfunction valueAt(run: StyledRun, key: StyleKey): StyledRun[StyleKey] {\n const value = run[key];\n if (FLAG_KEYS.has(key)) return (value as boolean | undefined) ?? false;\n return value;\n}\n\n/** The structural values. Everything else is a primitive, and\n * `applyStyleToRange` spreads runs, so reference identity isn't reliable. */\nconst STRUCTURAL_KEYS: ReadonlySet<StyleKey> = new Set<StyleKey>(['fill', 'stroke']);\n\nfunction sameValue(key: StyleKey, a: unknown, b: unknown): boolean {\n return STRUCTURAL_KEYS.has(key) ? deepEqual(a, b) : Object.is(a, b);\n}\n\n/** Do two runs carry the same styling (their `text` aside)? */\nfunction sameStyle(a: StyledRun, b: StyledRun): boolean {\n return STYLE_KEYS.every((key) => sameValue(key, valueAt(a, key), valueAt(b, key)));\n}\n\n/** Total character length of a run array — the domain of its offsets. */\nfunction totalLength(runs: readonly StyledRun[]): number {\n let n = 0;\n for (const run of runs) n += run.text.length;\n return n;\n}\n\n/**\n * The styling shared by every run overlapping `[start, end)`: a concrete\n * value where the range agrees, `MIXED` where it doesn't. Keys no run\n * in range sets are absent (they inherit the node's `TextStyle`) — except\n * the additive flags, which read as `false` rather than `undefined` since a\n * run cannot un-set them. An empty range reads as `{}`. A reported `fill`\n * is the run's own object, not a copy — treat it as immutable.\n */\nexport function styleAtRange(\n runs: readonly StyledRun[],\n start: number,\n end: number,\n): RangeStyle {\n const lo = Math.max(0, start);\n const hi = end;\n // Negated `<` rather than `>=` so a non-numeric offset reads as empty\n // instead of matching every run.\n if (!(lo < hi)) return {};\n\n const first = new Map<StyleKey, unknown>();\n const mixed = new Set<StyleKey>();\n let seen = false;\n let pos = 0;\n\n for (const run of runs) {\n const runEnd = pos + run.text.length;\n const a = Math.max(pos, lo);\n const b = Math.min(runEnd, hi);\n pos = runEnd;\n if (!(a < b)) continue;\n\n for (const key of STYLE_KEYS) {\n const value = valueAt(run, key);\n if (!seen) first.set(key, value);\n else if (!mixed.has(key) && !sameValue(key, first.get(key), value)) {\n mixed.add(key);\n }\n }\n seen = true;\n }\n\n if (!seen) return {};\n\n const style: Record<string, unknown> = {};\n for (const key of STYLE_KEYS) {\n if (mixed.has(key)) style[key] = MIXED;\n else {\n const value = first.get(key);\n if (value !== undefined) style[key] = value;\n }\n }\n return style as RangeStyle;\n}\n\n/**\n * Does any run carry styling of its own? Per the additive-flags contract\n * above, absent and `false` are the same state — \"no run-level override\" —\n * so an array that is nothing but text reads as `false`, whether it came\n * from a plain-text edit or from styling that was toggled back off.\n *\n * This is how the commit path tells \"the edit produced run styling\" from\n * \"the edit produced text\", which is the question that decides whether a\n * node grows a `runs` array. Iterating `STYLE_KEYS` rather than the run's\n * own keys is what keeps it honest as `StyledRun` grows: a new styleable\n * key is a compile error at `STYLE_KEYS` until it's listed, and then this\n * sees it for free.\n */\nexport function runsCarryStyling(runs: readonly StyledRun[]): boolean {\n return runs.some((run) =>\n STYLE_KEYS.some((key) => {\n const value = run[key];\n return value !== undefined && value !== false;\n }),\n );\n}\n\n/**\n * The key a patch clears without naming it. `bold` is a preset over\n * `fontWeight`, and a run keeps at most one of the two: writing either drops\n * the other, so a Bold toggle is not hidden under a weight it cannot beat and\n * a picked weight is not shadowed by a stale flag. Naming both writes both.\n */\nexport function supersededKey(patch: RunStylePatch): 'bold' | 'fontWeight' | undefined {\n if ('bold' in patch && !('fontWeight' in patch)) return 'fontWeight';\n if (patch.fontWeight !== undefined && !('bold' in patch)) return 'bold';\n return undefined;\n}\n\n/**\n * `range` with `patch` laid over it, keyed as a write of `patch` would leave\n * the runs — for showing styling armed for the next keystroke over the\n * styling at the caret. A key the patch leaves `undefined` keeps the range's\n * value; the key it supersedes is dropped.\n */\nexport function patchRangeStyle(range: RangeStyle, patch: RunStylePatch): RangeStyle {\n const out: Record<string, unknown> = { ...range };\n const superseded = supersededKey(patch);\n if (superseded !== undefined) delete out[superseded];\n for (const [key, value] of Object.entries(patch)) {\n if (value !== undefined) out[key] = value;\n }\n return out as RangeStyle;\n}\n\n/** Apply `patch` to one run, deleting rather than storing \"no override\". */\nfunction patchRun(run: StyledRun, patch: RunStylePatch): StyledRun {\n const next: StyledRun = { ...run };\n const superseded = supersededKey(patch);\n if (superseded !== undefined) delete next[superseded];\n for (const key of STYLE_KEYS) {\n if (!(key in patch)) continue;\n const value = patch[key];\n // Per the additive-flags contract at the top of the file, `false` is not\n // a storable state — it means \"no run-level override\", same as\n // `undefined`. Deleting keeps one canonical form (coalescing already\n // treats absent and `false` as equal, so this isn't what makes runs\n // merge — it's what keeps the stored shape from drifting).\n if (value === undefined || value === false) delete next[key];\n else (next as unknown as Record<string, unknown>)[key] = value;\n }\n return next;\n}\n\n/** Merge neighbors that ended up styled identically; drop empty runs. */\nfunction coalesceRuns(runs: readonly StyledRun[]): StyledRun[] {\n const out: StyledRun[] = [];\n for (const run of runs) {\n if (run.text.length === 0) continue;\n const prev = out[out.length - 1];\n if (prev && sameStyle(prev, run)) prev.text += run.text;\n else out.push({ ...run });\n }\n return out;\n}\n\n/**\n * Write `patch` over `[start, end)`, splitting runs at the boundaries and\n * coalescing neighbors that end up identical. A patch value of `undefined`\n * or `false` deletes the key instead of storing it — see the additive-flags\n * contract at the top of the file.\n *\n * Returns a new array of new runs; neither the input array nor its runs are\n * mutated (though a nested `fill` is shared by reference). Normalization —\n * merging identical neighbors, dropping empty runs — applies to the whole\n * array, not just the patched span, and to every call, including one whose\n * range is empty and so patches nothing.\n */\nexport function applyStyleToRange(\n runs: readonly StyledRun[],\n start: number,\n end: number,\n patch: RunStylePatch,\n): StyledRun[] {\n const lo = Math.max(0, start);\n const hi = Math.min(totalLength(runs), end);\n // A collapsed caret is the common call, so it takes the same normalization\n // as any other range rather than a laxer copy-only path.\n if (!(lo < hi)) return coalesceRuns(runs);\n\n const out: StyledRun[] = [];\n let pos = 0;\n for (const run of runs) {\n const runEnd = pos + run.text.length;\n const a = Math.max(pos, lo);\n const b = Math.min(runEnd, hi);\n if (a < b) {\n if (pos < a) out.push({ ...run, text: run.text.slice(0, a - pos) });\n out.push(patchRun({ ...run, text: run.text.slice(a - pos, b - pos) }, patch));\n if (b < runEnd) out.push({ ...run, text: run.text.slice(b - pos) });\n } else {\n out.push({ ...run });\n }\n pos = runEnd;\n }\n\n return coalesceRuns(out);\n}\n"],"mappings":";;AAsDA,IAAMA,IAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAcMC,oBAAmC,IAAI,IAAc;CACzD;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAASC,EAAc,GAA0C;CAC/D,OAAO,OAAOC,KAAM,cAAYA,KAAc,CAAC,MAAM,QAAQA,CAAC;AAChE;AAQA,SAASC,EAAU,GAAY,GAAqB;CAClD,IAAI,OAAO,GAAGC,GAAGC,CAAC,GAAG,OAAO;CAC5B,IAAI,MAAM,QAAQD,CAAC,KAAK,MAAM,QAAQC,CAAC,GACrC,OAAOD,EAAE,WAAWC,EAAE,UAAUD,EAAE,OAAO,GAAM,MAAMD,EAAUG,GAAMD,EAAEE,EAAE,CAAC;CAE5E,IAAIN,EAAcG,CAAC,KAAKH,EAAcI,CAAC,GAAG;EACxC,IAAMG,IAAO,OAAO,KAAKJ,CAAC;EAE1B,OADII,EAAK,WAAW,OAAO,KAAKH,CAAC,CAAC,CAAC,UAC5BG,EAAK,OAAO,MAAMC,KAAKJ,KAAKF,EAAUC,EAAEK,IAAIJ,EAAEI,EAAE,CAAC;CAC1D;CACA,OAAO;AACT;AAGA,SAASC,EAAQ,GAAgB,GAAoC;CACnE,IAAMC,IAAQC,EAAIC;CAElB,OADIb,EAAU,IAAIa,CAAG,IAAWF,KAAiC,KAC1DA;AACT;AAIA,IAAMG,oBAAyC,IAAI,IAAc,CAAC,QAAQ,QAAQ,CAAC;AAEnF,SAASC,EAAU,GAAe,GAAY,GAAqB;CACjE,OAAOD,EAAgB,IAAID,CAAG,IAAIV,EAAUC,GAAGC,CAAC,IAAI,OAAO,GAAGD,GAAGC,CAAC;AACpE;AAGA,SAASW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AOwB;AACT;AAcA,SAAgBO,EACd,GACA,GACA,GACA,GACa;CACb,IAAMtB,IAAK,KAAK,IAAI,GAAGC,CAAK,GACtBC,IAAK,KAAK,IAAIN,EAAYE,CAAI,GAAGK,CAAG;CAG1C,IAAI,EAAEH,IAAKE,IAAK,OAAOkB,EAAatB,CAAI;CAExC,IAAMiB,IAAmB,CAAC,GACtBR,IAAM;CACV,KAAK,IAAMhB,KAAOO,GAAM;EACtB,IAAMU,IAASD,IAAMhB,EAAI,KAAK,QACxBR,IAAI,KAAK,IAAIwB,GAAKP,CAAE,GACpBhB,IAAI,KAAK,IAAIwB,GAAQN,CAAE;EAQ7B,AAPInB,IAAIC,KACFuB,IAAMxB,KAAGgC,EAAI,KAAK;GAAE,GAAGxB;GAAK,MAAMA,EAAI,KAAK,MAAM,GAAGR,IAAIwB,CAAG;EAAE,CAAC,GAClEQ,EAAI,KAAKG,EAAS;GAAE,GAAG3B;GAAK,MAAMA,EAAI,KAAK,MAAMR,IAAIwB,GAAKvB,IAAIuB,CAAG;EAAE,GAAGM,CAAK,CAAC,GACxE7B,IAAIwB,KAAQO,EAAI,KAAK;GAAE,GAAGxB;GAAK,MAAMA,EAAI,KAAK,MAAMP,IAAIuB,CAAG;EAAE,CAAC,KAElEQ,EAAI,KAAK,EAAE,GAAGxB,EAAI,CAAC,GAErB,IAAMiB;CACR;CAEA,OAAOY,EAAaL,CAAG;AACzB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { fillInPoseFrame as e } from "../../core/fillInPoseFrame.js";
|
|
2
|
+
import { resolveFillPattern as t } from "../patterns/resolveSpec.js";
|
|
3
|
+
import { resolveAlign as n, resolveRuns as r, resolveTextStyle as i, textPoseLayoutInput as a } from "@weasel-js/text";
|
|
4
|
+
//#region src/features/text/textCommand.ts
|
|
5
|
+
function o(e, t, a, o, s, c, l, u, d, f = 1) {
|
|
6
|
+
let p = i(o, u, f);
|
|
7
|
+
return {
|
|
8
|
+
kind: "text",
|
|
9
|
+
x: e,
|
|
10
|
+
y: t,
|
|
11
|
+
runs: r(a, p, f),
|
|
12
|
+
align: n(p.align, p.direction),
|
|
13
|
+
justify: p.align === "justify",
|
|
14
|
+
maxWidth: s,
|
|
15
|
+
style: o ?? {},
|
|
16
|
+
height: c,
|
|
17
|
+
verticalAlign: l,
|
|
18
|
+
width: d
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function s(e, t, n, r, i, a, s, c, l, u = 1) {
|
|
22
|
+
return o(e, t, [{ text: n }], r, i, a, s, c, l, u);
|
|
23
|
+
}
|
|
24
|
+
function c(e, t = 1) {
|
|
25
|
+
let { runs: n, opts: r } = a(e, t);
|
|
26
|
+
return {
|
|
27
|
+
kind: "text",
|
|
28
|
+
x: e.x,
|
|
29
|
+
y: e.y,
|
|
30
|
+
runs: l(n, e),
|
|
31
|
+
align: r.align,
|
|
32
|
+
justify: r.justify,
|
|
33
|
+
maxWidth: r.maxWidth,
|
|
34
|
+
width: r.alignWidth,
|
|
35
|
+
style: e.style ?? {},
|
|
36
|
+
height: e.height,
|
|
37
|
+
verticalAlign: e.verticalAlign
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function l(n, r) {
|
|
41
|
+
return n.every((e) => u(e.fill) && u(e.stroke?.paint)) ? n : n.map((n) => {
|
|
42
|
+
let i = n.fill && t(e(n.fill, r)), a = n.stroke?.paint && t(e(n.stroke.paint, r));
|
|
43
|
+
return {
|
|
44
|
+
...n,
|
|
45
|
+
fill: i,
|
|
46
|
+
stroke: n.stroke && {
|
|
47
|
+
...n.stroke,
|
|
48
|
+
paint: a || void 0
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function u(e) {
|
|
54
|
+
return e == null || (e.fill ?? "solid") === "solid";
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { s as textCommand, c as textCommandFromPose, o as textCommandFromRuns };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=textCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textCommand.js","names":["textCommandFromRuns","resolved","resolveTextStyle","style","paint","scale","resolveRuns","runs","resolveAlign","textCommand","x","y","maxWidth","height","verticalAlign","width","textCommandFromPose","textPoseLayoutInput","pose","runsInPoseFrame","opts","isSolid","r","fill","resolveFillPattern","fillInPoseFrame","box"],"sources":["../../../src/features/text/textCommand.ts"],"sourcesContent":["/**\n * Build a `TextDrawCommand`. `textCommandFromPose` is the command for a text\n * node — what `kit:text` and `createTextLayer` both emit. `textCommand` takes\n * a plain string and wraps it in one run; `textCommandFromRuns` takes the\n * styled runs directly, for text that has no pose. All three\n * resolve through `resolveTextStyle` + `resolveRuns`, so every emitter of a\n * text command derives `align` and per-run resolution the same way — a\n * caller that assembles the command by hand is one field away from a\n * silently different result.\n *\n * `paint` is the node's `data.fill` / `data.stroke`. A caller with no node —\n * a HUD widget, a debug overlay — states its color on the run instead.\n *\n * `scale` is the view scale a `{ px }` `fontSize` or `letterSpacing` resolves\n * against — for a world-space layer, the mean of `view.scale.x` and\n * `view.scale.y`. It has to be applied here and not at draw time, because a\n * screen-pixel size moves the glyph advances and so the wrap points.\n */\n\nimport type { DrawCommand, TextDrawCommand } from '../../renderer';\nimport type { TextPaint, TextPose, TextStyle } from '@weasel-js/text';\nimport { resolveAlign, resolveTextStyle, textPoseLayoutInput } from '@weasel-js/text';\nimport { resolveRuns } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextVerticalAlign, ResolvedRun } from '@weasel-js/text';\nimport type { FillStyle } from '@weasel-js/paint';\nimport { fillInPoseFrame, type FillPoseBox } from '../../core/fillInPoseFrame';\nimport { resolveFillPattern } from '../patterns/resolveSpec';\n\n/** Build a draw command from styled runs, for text with no pose. `style`\n * supplies the defaults each run inherits; the rest match `textCommand`. */\nexport function textCommandFromRuns(\n x: number,\n y: number,\n runs: readonly StyledRun[],\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n const resolved = resolveTextStyle(style, paint, scale);\n return {\n kind: 'text',\n x,\n y,\n runs: resolveRuns(runs, resolved, scale),\n align: resolveAlign(resolved.align, resolved.direction),\n justify: resolved.align === 'justify',\n maxWidth,\n style: style ?? {},\n height,\n verticalAlign,\n width,\n };\n}\n\n/** Build a draw command for a single unstyled string. Text is laid out with\n * the registered font's metrics, wrapped at `maxWidth`, aligned across\n * `width` (default `maxWidth`) and within `height` when `verticalAlign` is\n * given. */\nexport function textCommand(\n x: number,\n y: number,\n text: string,\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n return textCommandFromRuns(\n x, y, [{ text }], style, maxWidth, height, verticalAlign, paint, width, scale,\n );\n}\n\n/**\n * The draw command for a text pose. Its wrap width, alignment box and runs\n * come from `textPoseLayoutInput`, so the renderer lays it out into exactly\n * the lines `layoutTextPose` reports for the same pose.\n *\n * Each run's paints are resolved against the pose box the way every other\n * node's are — a `'bounds'` paint mapped onto it, a pattern spec swapped for\n * its texture — since the renderer can do neither.\n */\nexport function textCommandFromPose(pose: TextPose, scale = 1): TextDrawCommand {\n const { runs, opts } = textPoseLayoutInput(pose, scale);\n return {\n kind: 'text',\n x: pose.x,\n y: pose.y,\n runs: runsInPoseFrame(runs, pose),\n align: opts.align,\n justify: opts.justify,\n maxWidth: opts.maxWidth,\n width: opts.alignWidth,\n style: pose.style ?? {},\n height: pose.height,\n verticalAlign: pose.verticalAlign,\n };\n}\n\nfunction runsInPoseFrame(runs: ResolvedRun[], box: FillPoseBox): ResolvedRun[] {\n if (runs.every((r) => isSolid(r.fill) && isSolid(r.stroke?.paint))) return runs;\n return runs.map((r) => {\n const fill = r.fill && resolveFillPattern(fillInPoseFrame(r.fill, box));\n const paint = r.stroke?.paint && resolveFillPattern(fillInPoseFrame(r.stroke.paint, box));\n return { ...r, fill, stroke: r.stroke && { ...r.stroke, paint: paint || undefined } };\n });\n}\n\nfunction isSolid(paint: FillStyle | null | undefined): boolean {\n return paint == null || (paint.fill ?? 'solid') === 'solid';\n}\n"],"mappings":";;;;AA+BA,SAAgBA,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IAAQ,GACK;CACb,IAAMC,IAAWC,EAAiBC,GAAOC,GAAOC,CAAK;CACrD,OAAO;EACL,MAAM;EACN;EACA;EACA,MAAMC,EAAYC,GAAMN,GAAUI,CAAK;EACvC,OAAOG,EAAaP,EAAS,OAAOA,EAAS,SAAS;EACtD,SAASA,EAAS,UAAU;EAC5B;EACA,OAAOE,KAAS,CAAC;EACjB;EACA;EACA;CACF;AACF;AAMA,SAAgBM,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IAAQ,GACK;CACb,OAAOT,EACLU,GAAGC,GAAG,CAAC,EAAE,QAAK,CAAC,GAAGR,GAAOS,GAAUC,GAAQC,GAAeV,GAAOW,GAAOV,CAC1E;AACF;AAWA,SAAgBW,EAAoB,GAAgB,IAAQ,GAAoB;CAC9E,IAAM,EAAE,SAAM,YAASC,EAAoBC,GAAMb,CAAK;CACtD,OAAO;EACL,MAAM;EACN,GAAGa,EAAK;EACR,GAAGA,EAAK;EACR,MAAMC,EAAgBZ,GAAMW,CAAI;EAChC,OAAOE,EAAK;EACZ,SAASA,EAAK;EACd,UAAUA,EAAK;EACf,OAAOA,EAAK;EACZ,OAAOF,EAAK,SAAS,CAAC;EACtB,QAAQA,EAAK;EACb,eAAeA,EAAK;CACtB;AACF;AAEA,SAASC,EAAgB,GAAqB,GAAiC;CAE7E,OADIZ,EAAK,OAAO,MAAMc,EAAQC,EAAE,IAAI,KAAKD,EAAQC,EAAE,QAAQ,KAAK,CAAC,IAAUf,IACpEA,EAAK,KAAK,MAAM;EACrB,IAAMgB,IAAOD,EAAE,QAAQE,EAAmBC,EAAgBH,EAAE,MAAMI,CAAG,CAAC,GAChEtB,IAAQkB,EAAE,QAAQ,SAASE,EAAmBC,EAAgBH,EAAE,OAAO,OAAOI,CAAG,CAAC;EACxF,OAAO;GAAE,GAAGJ;GAAG;GAAM,QAAQA,EAAE,UAAU;IAAE,GAAGA,EAAE;IAAQ,OAAOlB,KAAS,KAAA;GAAU;EAAE;CACtF,CAAC;AACH;AAEA,SAASiB,EAAQ,GAA8C;CAC7D,OAAOjB,KAAS,SAASA,EAAM,QAAQ,aAAa;AACtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { textCommandFromPose as e } from "./textCommand.js";
|
|
2
|
+
import { runsToPlainText as t } from "@weasel-js/text";
|
|
3
|
+
//#region src/features/text/textLayer.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let { id: r = "text", label: i = "Text", getTexts: a, getPose: o, isHidden: s, clipToBounds: c = !1 } = n;
|
|
6
|
+
return {
|
|
7
|
+
id: r,
|
|
8
|
+
label: i,
|
|
9
|
+
draw: (n, r) => {
|
|
10
|
+
let i = (r.scale.x + r.scale.y) / 2, l = [];
|
|
11
|
+
for (let n of a()) {
|
|
12
|
+
if (s?.(n)) continue;
|
|
13
|
+
let r = o(n);
|
|
14
|
+
if (r.runs && r.runs.length > 0 && t(r.runs) !== r.text) throw Error("weasel createTextLayer: TextPose invariant violated — runsToPlainText(runs) !== text. Either omit `runs` or keep it synchronized with `text`.");
|
|
15
|
+
let a = e(r, i);
|
|
16
|
+
c ? l.push({
|
|
17
|
+
kind: "group",
|
|
18
|
+
clip: {
|
|
19
|
+
kind: "rect",
|
|
20
|
+
x: r.x,
|
|
21
|
+
y: r.y,
|
|
22
|
+
width: r.width,
|
|
23
|
+
height: r.height
|
|
24
|
+
},
|
|
25
|
+
children: [a]
|
|
26
|
+
}) : l.push(a);
|
|
27
|
+
}
|
|
28
|
+
return l;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { n as createTextLayer };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=textLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textLayer.js","names":["createTextLayer","opts","scale","view","children","node","getTexts","isHidden","pose","getPose","runsToPlainText","textCmd","textCommandFromPose","clipToBounds"],"sources":["../../../src/features/text/textLayer.ts"],"sourcesContent":["/**\n * Text RenderLayer for text that is not in a scene: one `textCommandFromPose`\n * command per item, the same command the `kit:text` node painter emits, so an\n * item lays out — and wraps, or doesn't, per its style — as a node would.\n *\n * The GL renderer uses MSDF text. The resolved style's `fontFamily` must\n * be registered via `registerFont(family, variant, metricsUrl, atlasUrl)`\n * from the renderer module *before* the GL backend dispatches this layer.\n * Unregistered families render with a warning and no glyphs (see\n * `TextDrawCommand`'s contract).\n */\n\nimport { type DrawCommand } from '../../renderer';\nimport type { TextPose } from '@weasel-js/text';\n\nimport type { RenderLayer } from 'core/layers/render';\nimport { textCommandFromPose } from './textCommand';\nimport { runsToPlainText } from '@weasel-js/text';\n\n\n/** Options for `createTextLayer`. */\nexport interface CreateTextLayerOpts<T> {\n id?: string;\n label?: string;\n getTexts: () => readonly T[];\n getPose: (node: T) => TextPose;\n /** Optional per-node hide hook (e.g., suppress while editing). */\n isHidden?: (node: T) => boolean;\n /** When `true`, each text command is wrapped in a clipped group so any\n * overflow beyond the pose's `(width × height)` is hidden. Default\n * `false` (legacy: text can spill outside the declared bounds). Opt-in\n * so existing consumers who rely on overflow keep working. */\n clipToBounds?: boolean;\n}\n\n/** Build a `RenderLayer` that emits one `TextDrawCommand` per text node. */\nexport function createTextLayer<T>(opts: CreateTextLayerOpts<T>): RenderLayer<unknown> {\n const { id = 'text', label = 'Text', getTexts, getPose, isHidden, clipToBounds = false } = opts;\n return {\n id,\n label,\n draw: (_data, view) => {\n // A world-space layer, so a `{ px }` size in a pose's style resolves\n // against the live camera. Radial in effect — one factor for both axes.\n const scale = (view.scale.x + view.scale.y) / 2;\n const children: DrawCommand[] = [];\n for (const node of getTexts()) {\n if (isHidden?.(node)) continue;\n const pose = getPose(node);\n if (pose.runs && pose.runs.length > 0 && runsToPlainText(pose.runs) !== pose.text) {\n throw new Error(\n `weasel createTextLayer: TextPose invariant violated — ` +\n `runsToPlainText(runs) !== text. Either omit \\`runs\\` or keep it ` +\n `synchronized with \\`text\\`.`,\n );\n }\n const textCmd = textCommandFromPose(pose, scale);\n if (clipToBounds) {\n children.push({\n kind: 'group',\n clip: { kind: 'rect', x: pose.x, y: pose.y, width: pose.width, height: pose.height },\n children: [textCmd],\n });\n } else {\n children.push(textCmd);\n }\n }\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n return children;\n },\n };\n}\n"],"mappings":";;;AAoCA,SAAgBA,EAAmB,GAAoD;CACrF,IAAM,EAAE,QAAK,QAAQ,WAAQ,QAAQ,aAAU,YAAS,aAAU,kBAAe,OAAUC;CAC3F,OAAO;EACL;EACA;EACA,OAAO,GAAO,MAAS;GAGrB,IAAMC,KAASC,EAAK,MAAM,IAAIA,EAAK,MAAM,KAAK,GACxCC,IAA0B,CAAC;GACjC,KAAK,IAAMC,KAAQC,EAAS,GAAG;IAC7B,IAAIC,IAAWF,CAAI,GAAG;IACtB,IAAMG,IAAOC,EAAQJ,CAAI;IACzB,IAAIG,EAAK,QAAQA,EAAK,KAAK,SAAS,KAAKE,EAAgBF,EAAK,IAAI,MAAMA,EAAK,MAC3E,MAAU,MACR,+IAGF;IAEF,IAAMG,IAAUC,EAAoBJ,GAAMN,CAAK;IAC/C,AAAIW,IACFT,EAAS,KAAK;KACZ,MAAM;KACN,MAAM;MAAE,MAAM;MAAQ,GAAGI,EAAK;MAAG,GAAGA,EAAK;MAAG,OAAOA,EAAK;MAAO,QAAQA,EAAK;KAAO;KACnF,UAAU,CAACG,CAAO;IACpB,CAAC,IAEDP,EAAS,KAAKO,CAAO;GAEzB;GAEA,OAAOP;EACT;CACF;AACF"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { SYNTHETIC_ITALIC_RADIANS as e } from "../../renderer/syntheticItalic.js";
|
|
2
|
+
import { poseRotationOf as t } from "../../core/geometry/poseRotation.js";
|
|
3
|
+
import { loadFontOutlines as n, outlineStatus as r, resolveFontVariant as i } from "@weasel-js/font";
|
|
4
|
+
import { PATH_L as a, PATH_M as o, PATH_Z as s, pathFromD as c, pathSignedArea as l, reversePath as u, rotateAboutPoint as d, transformPath as f } from "@weasel-js/geom";
|
|
5
|
+
import { layoutRuns as p, textPoseLayoutInput as m, verticalAlignOffset as h } from "@weasel-js/text";
|
|
6
|
+
//#region src/features/text/textToPath.ts
|
|
7
|
+
var g = class extends Error {
|
|
8
|
+
reason;
|
|
9
|
+
family;
|
|
10
|
+
weight;
|
|
11
|
+
style;
|
|
12
|
+
constructor(e, t, n, r, i) {
|
|
13
|
+
super(`textToPath: "${t}" ${n}/${r} — ${i}`), this.name = "TextOutlinesError", this.reason = e, this.family = t, this.weight = n, this.style = r;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function _(e) {
|
|
17
|
+
let t = /* @__PURE__ */ new Map(), n = (e, n, r) => {
|
|
18
|
+
t.set(`${e}|${n}|${r}`, {
|
|
19
|
+
family: e,
|
|
20
|
+
weight: n,
|
|
21
|
+
style: r
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
for (let t of e) {
|
|
25
|
+
n(t.fontFamily, t.fontWeight, t.fontStyle);
|
|
26
|
+
let { family: e, weight: r, style: a } = i(t.fontFamily, t.fontWeight, t.fontStyle).resolved;
|
|
27
|
+
n(e, r, a);
|
|
28
|
+
}
|
|
29
|
+
return [...t.values()];
|
|
30
|
+
}
|
|
31
|
+
function v(e) {
|
|
32
|
+
let { fontFamily: t, fontWeight: a, fontStyle: o } = e, s = (e, n) => {
|
|
33
|
+
throw new g(e, t, a, o, n);
|
|
34
|
+
}, c = r(t, a, o);
|
|
35
|
+
(c === "idle" || c === "loading") && (n(t, {
|
|
36
|
+
weight: a,
|
|
37
|
+
style: o
|
|
38
|
+
}), s("outlines-loading", "its outlines have not loaded yet; await loadTextOutlines first."));
|
|
39
|
+
let l = i(t, a, o), { family: u, weight: d, style: f } = l.resolved;
|
|
40
|
+
if (l.synthetic.bold && s("synthetic-bold", `drawn as a faux bold of ${u} ${d}/${f}, which has no geometry to embolden. Register outlines for the real bold face.`), l.source === "outline") return;
|
|
41
|
+
let p = r(u, d, f);
|
|
42
|
+
p === null && s("no-outlines", `served by ${u} ${d}/${f}, which has no outlines registered. Call registerFontOutlines for it.`), (p === "idle" || p === "loading") && (n(u, {
|
|
43
|
+
weight: d,
|
|
44
|
+
style: f
|
|
45
|
+
}), s("outlines-loading", `the outlines of ${u} ${d}/${f} have not loaded yet; await loadTextOutlines first.`)), p === "failed" && s("outlines-failed", `the outlines registered for ${u} ${d}/${f} failed to load.`);
|
|
46
|
+
}
|
|
47
|
+
var y = 4096, b = /* @__PURE__ */ new Map();
|
|
48
|
+
function x(e) {
|
|
49
|
+
let t = b.get(e);
|
|
50
|
+
return t || (t = c(e), l(t) < 0 && (t = u(t)), b.size >= y && b.clear(), b.set(e, t), t);
|
|
51
|
+
}
|
|
52
|
+
function S(e) {
|
|
53
|
+
let t = 0, n = 0;
|
|
54
|
+
for (let r of e) t += r.commands.length, n += r.coords.length;
|
|
55
|
+
let r = new Uint8Array(t), i = new Float32Array(n), a = 0, o = 0;
|
|
56
|
+
for (let t of e) r.set(t.commands, a), a += t.commands.length, i.set(t.coords, o), o += t.coords.length;
|
|
57
|
+
return {
|
|
58
|
+
kind: "polygon",
|
|
59
|
+
commands: r,
|
|
60
|
+
coords: i,
|
|
61
|
+
fillRule: "nonzero"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function C(e, t, n, r) {
|
|
65
|
+
return {
|
|
66
|
+
kind: "polygon",
|
|
67
|
+
commands: new Uint8Array([
|
|
68
|
+
o,
|
|
69
|
+
a,
|
|
70
|
+
a,
|
|
71
|
+
a,
|
|
72
|
+
s
|
|
73
|
+
]),
|
|
74
|
+
coords: new Float32Array([
|
|
75
|
+
e,
|
|
76
|
+
t,
|
|
77
|
+
n,
|
|
78
|
+
t,
|
|
79
|
+
n,
|
|
80
|
+
r,
|
|
81
|
+
e,
|
|
82
|
+
r
|
|
83
|
+
]),
|
|
84
|
+
fillRule: "nonzero"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function w(e, t) {
|
|
88
|
+
return JSON.stringify([e, t ?? null]);
|
|
89
|
+
}
|
|
90
|
+
function T(n, r, i) {
|
|
91
|
+
let a = {
|
|
92
|
+
x: r.x,
|
|
93
|
+
y: r.y,
|
|
94
|
+
width: r.width,
|
|
95
|
+
height: r.height,
|
|
96
|
+
text: n.text,
|
|
97
|
+
runs: n.runs,
|
|
98
|
+
style: n.style,
|
|
99
|
+
verticalAlign: n.verticalAlign,
|
|
100
|
+
fill: n.fill,
|
|
101
|
+
stroke: n.stroke
|
|
102
|
+
}, { runs: o, opts: s } = m(a, i.scale ?? 1);
|
|
103
|
+
for (let e of o) v(e);
|
|
104
|
+
let c = [], l = /* @__PURE__ */ new Map(), u = o.map((e) => {
|
|
105
|
+
let t = w(e.fill, e.stroke), n = l.get(t);
|
|
106
|
+
n === void 0 && (n = c.length, l.set(t, n), c.push(e.stroke === void 0 ? { fill: e.fill } : {
|
|
107
|
+
fill: e.fill,
|
|
108
|
+
stroke: e.stroke
|
|
109
|
+
}));
|
|
110
|
+
let { stroke: r, ...i } = e;
|
|
111
|
+
return {
|
|
112
|
+
...i,
|
|
113
|
+
fill: {
|
|
114
|
+
fill: "solid",
|
|
115
|
+
color: `#${n.toString(16).padStart(6, "0")}`
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}), _ = (e) => e !== null && "color" in e ? parseInt(e.color.slice(1), 16) : 0, y = p(u, {
|
|
119
|
+
...s,
|
|
120
|
+
outlineMinSize: 0
|
|
121
|
+
});
|
|
122
|
+
for (let e of y.groups) if (e.source !== "outline" && e.quads.length > 0) throw new g("no-outlines", e.family, e.weight, e.style, "a fallback face serving some of the text's characters has no outlines registered.");
|
|
123
|
+
let b = r.x, T = r.y + h(n.verticalAlign, r.height, y.bounds.height), E = c.map(() => []);
|
|
124
|
+
for (let t of y.groups) {
|
|
125
|
+
let n = E[_(t.fill)], r = t.synthetic.italic ? Math.tan(e) : 0;
|
|
126
|
+
for (let e of t.glyphs) {
|
|
127
|
+
let t = e.scale, i = [
|
|
128
|
+
t,
|
|
129
|
+
0,
|
|
130
|
+
-r * t,
|
|
131
|
+
t,
|
|
132
|
+
e.x + b,
|
|
133
|
+
e.baselineY + T
|
|
134
|
+
];
|
|
135
|
+
n.push(f(x(e.d), i));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (let e of y.decorations) E[_(e.fill)].push(C(e.x0 + b, e.y0 + T, e.x1 + b, e.y1 + T));
|
|
139
|
+
let D = t(r);
|
|
140
|
+
return {
|
|
141
|
+
paints: c,
|
|
142
|
+
paths: E.map((e) => {
|
|
143
|
+
let t = S(e);
|
|
144
|
+
return !D || t.commands.length === 0 ? t : f(t, d(D.cx, D.cy, D.rotation));
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function E(e, t, n = {}) {
|
|
149
|
+
return S(T(e, t, n).paths);
|
|
150
|
+
}
|
|
151
|
+
function D(e, t, n = {}) {
|
|
152
|
+
let { paints: r, paths: i } = T(e, t, n), a = [];
|
|
153
|
+
return r.forEach((e, t) => {
|
|
154
|
+
i[t].commands.length > 0 && a.push({
|
|
155
|
+
...e,
|
|
156
|
+
path: i[t]
|
|
157
|
+
});
|
|
158
|
+
}), a;
|
|
159
|
+
}
|
|
160
|
+
async function O(e, t = {}) {
|
|
161
|
+
let r = {
|
|
162
|
+
x: 0,
|
|
163
|
+
y: 0,
|
|
164
|
+
width: 0,
|
|
165
|
+
height: 0,
|
|
166
|
+
text: e.text,
|
|
167
|
+
runs: e.runs,
|
|
168
|
+
style: e.style
|
|
169
|
+
}, { runs: i } = m(r, t.scale ?? 1);
|
|
170
|
+
await Promise.all(_(i).map((e) => n(e.family, {
|
|
171
|
+
weight: e.weight,
|
|
172
|
+
style: e.style
|
|
173
|
+
}))), await Promise.all(_(i).map((e) => n(e.family, {
|
|
174
|
+
weight: e.weight,
|
|
175
|
+
style: e.style
|
|
176
|
+
})));
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { g as TextOutlinesError, O as loadTextOutlines, E as textToPath, D as textToPathsByPaint };
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=textToPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textToPath.js","names":["TextOutlinesError","family","weight","style","detail","reason","facesOf","out","add","r","runs","resolveFontVariant","assertOutlinable","run","fail","fontFamily","fontWeight","fontStyle","requested","outlineStatus","loadFontOutlines","status","EM_CACHE_LIMIT","emCache","emGlyph","p","d","pathFromD","pathSignedArea","reversePath","concat","nc","nk","parts","commands","coords","ci","ki","ruleContour","PATH_M","PATH_L","PATH_Z","x0","y0","x1","y1","paintKey","fill","stroke","walkOutlines","textPose","pose","data","resolved","layoutOpts","textPoseLayoutInput","opts","paints","indexOf","key","i","_stroke","rest","groupOf","laid","layoutRuns","g","dx","dy","verticalAlignOffset","shear","SYNTHETIC_ITALIC_RADIANS","glyph","s","m","transformPath","rot","poseRotationOf","path","rotateAboutPoint","textToPath","textToPathsByPaint","paths","paint","loadTextOutlines","f"],"sources":["../../../src/features/text/textToPath.ts"],"sourcesContent":["/**\n * Text as path geometry: the glyph outlines a text node draws, placed in\n * world space and composed into one `Path`. What \"Create Outlines\" replaces a\n * text node with, and what a Boolean op reads when a text node is an operand.\n *\n * The walk is `layoutRuns`', so the glyphs land exactly where the renderer's\n * outline tier puts them — same pen positions, same baselines, same synthetic\n * italic shear — but with the tier forced on for every glyph whatever its\n * size, and with paint set aside: unfilled text has outlines too.\n * `textToPathsByPaint` is the same walk, split by the paint each glyph wears.\n */\n\nimport type { FillStyle, Stroke } from '@weasel-js/paint';\n\nimport {\n loadFontOutlines, outlineStatus, resolveFontVariant, type FontStyle,\n} from '@weasel-js/font';\nimport {\n layoutRuns, textPoseLayoutInput, verticalAlignOffset,\n type ResolvedRun, type StyledRun, type TextPose, type TextStyle, type TextVerticalAlign,\n} from '@weasel-js/text';\nimport {\n PATH_L, PATH_M, PATH_Z, pathFromD, pathSignedArea, reversePath, rotateAboutPoint,\n transformPath, type Mat3, type PolygonPath,\n} from '@weasel-js/geom';\nimport { poseRotationOf } from 'core/geometry/poseRotation';\nimport type { PathInWorldPose } from 'features/paths/pathInWorld';\nimport { SYNTHETIC_ITALIC_RADIANS } from 'renderer/syntheticItalic';\n\n/** The fields of a text node's data that decide its glyph geometry, and the\n * paint `textToPathsByPaint` splits it by. Paint never changes the geometry. */\nexport interface TextOutlineSource {\n text: string;\n runs?: readonly StyledRun[];\n style?: TextStyle;\n verticalAlign?: TextVerticalAlign;\n /** The node's `data.fill`: `null` is no fill, absent the default black. */\n fill?: FillStyle | null;\n /** The node's `data.stroke`: absent or `null` is no stroke. */\n stroke?: Stroke | null;\n}\n\n/** One paint's share of a text node's outlines — see {@link textToPathsByPaint}. */\nexport interface TextPaintPath {\n /** The resolved fill these glyphs wear: the run's own, else the node's.\n * `null` for unfilled text, painted by its stroke alone. */\n fill: FillStyle | null;\n /** The resolved stroke — the run's own, else the node's — or absent. */\n stroke?: Stroke;\n /** World-space outlines, as {@link textToPath} builds them. */\n path: PolygonPath;\n}\n\n/** A text node as {@link textToPath} reads it: its data and its pose. */\nexport interface TextNodeSource {\n data: TextOutlineSource;\n pose: PathInWorldPose;\n}\n\n/** Options for {@link textToPath}. */\nexport interface TextToPathOptions {\n /** The view scale a `{ px }` `fontSize` or `letterSpacing` resolves\n * against, as for `textCommandFromPose`. Default 1. */\n scale?: number;\n}\n\n/**\n * Why a text node has no outline geometry to give:\n *\n * - `'no-outlines'` — the face that serves it has no outlines registered\n * (`registerFontOutlines`), so there is no geometry to read.\n * - `'outlines-loading'` — registered but not parsed yet. `loadTextOutlines`\n * waits for it; the call has already started the load.\n * - `'outlines-failed'` — registered, and the bytes did not load or parse.\n * - `'synthetic-bold'` — the requested weight is faked from a lighter face.\n * The renderer thickens the distance field for that, and a path has no\n * field to thicken; emboldening geometry needs outline offsetting, which\n * the kit does not have. Converting would silently lighten the text.\n */\nexport type TextOutlinesFailure =\n | 'no-outlines'\n | 'outlines-loading'\n | 'outlines-failed'\n | 'synthetic-bold';\n\n/** Thrown by {@link textToPath} when some run of the text has no outline\n * geometry. Names the run's requested face. */\nexport class TextOutlinesError extends Error {\n readonly reason: TextOutlinesFailure;\n readonly family: string;\n readonly weight: number;\n readonly style: FontStyle;\n\n constructor(reason: TextOutlinesFailure, family: string, weight: number, style: FontStyle, detail: string) {\n super(`textToPath: \"${family}\" ${weight}/${style} — ${detail}`);\n this.name = 'TextOutlinesError';\n this.reason = reason;\n this.family = family;\n this.weight = weight;\n this.style = style;\n }\n}\n\n/** The face every run is set in, before and after variant resolution. */\nfunction facesOf(runs: readonly ResolvedRun[]): { family: string; weight: number; style: FontStyle }[] {\n const out = new Map<string, { family: string; weight: number; style: FontStyle }>();\n const add = (family: string, weight: number, style: FontStyle) => {\n out.set(`${family}|${weight}|${style}`, { family, weight, style });\n };\n for (const r of runs) {\n add(r.fontFamily, r.fontWeight, r.fontStyle);\n const { family, weight, style } = resolveFontVariant(r.fontFamily, r.fontWeight, r.fontStyle).resolved;\n add(family, weight, style);\n }\n return [...out.values()];\n}\n\nfunction assertOutlinable(run: ResolvedRun): void {\n const { fontFamily, fontWeight, fontStyle } = run;\n const fail = (reason: TextOutlinesFailure, detail: string): never => {\n throw new TextOutlinesError(reason, fontFamily, fontWeight, fontStyle, detail);\n };\n const requested = outlineStatus(fontFamily, fontWeight, fontStyle);\n if (requested === 'idle' || requested === 'loading') {\n void loadFontOutlines(fontFamily, { weight: fontWeight, style: fontStyle });\n fail('outlines-loading', 'its outlines have not loaded yet; await loadTextOutlines first.');\n }\n const r = resolveFontVariant(fontFamily, fontWeight, fontStyle);\n const { family, weight, style } = r.resolved;\n if (r.synthetic.bold) {\n fail('synthetic-bold', `drawn as a faux bold of ${family} ${weight}/${style}, which has no ` +\n 'geometry to embolden. Register outlines for the real bold face.');\n }\n if (r.source === 'outline') return;\n const status = outlineStatus(family, weight, style);\n if (status === null) {\n fail('no-outlines', `served by ${family} ${weight}/${style}, which has no outlines ` +\n 'registered. Call registerFontOutlines for it.');\n }\n if (status === 'idle' || status === 'loading') {\n void loadFontOutlines(family, { weight, style });\n fail('outlines-loading', `the outlines of ${family} ${weight}/${style} have not loaded yet; ` +\n 'await loadTextOutlines first.');\n }\n if (status === 'failed') {\n fail('outlines-failed', `the outlines registered for ${family} ${weight}/${style} failed to load.`);\n }\n}\n\n// Em-space glyph geometry, wound one way, keyed by the outline data itself so a\n// re-registered face cannot serve stale geometry. The cap bounds a document\n// that cycles through many faces.\nconst EM_CACHE_LIMIT = 4096;\nconst emCache = new Map<string, PolygonPath>();\n\n/** A glyph's em-space path, wound positive so glyphs from faces that disagree\n * on winding — TrueType against CFF — still fill their overlaps under\n * `'nonzero'`, and so do the decoration rules drawn across them. */\nfunction emGlyph(d: string): PolygonPath {\n let p = emCache.get(d);\n if (p) return p;\n p = pathFromD(d);\n if (pathSignedArea(p) < 0) p = reversePath(p);\n if (emCache.size >= EM_CACHE_LIMIT) emCache.clear();\n emCache.set(d, p);\n return p;\n}\n\nfunction concat(parts: readonly PolygonPath[]): PolygonPath {\n let nc = 0, nk = 0;\n for (const p of parts) { nc += p.commands.length; nk += p.coords.length; }\n const commands = new Uint8Array(nc);\n const coords = new Float32Array(nk);\n let ci = 0, ki = 0;\n for (const p of parts) {\n commands.set(p.commands, ci); ci += p.commands.length;\n coords.set(p.coords, ki); ki += p.coords.length;\n }\n return { kind: 'polygon', commands, coords, fillRule: 'nonzero' };\n}\n\nfunction ruleContour(x0: number, y0: number, x1: number, y1: number): PolygonPath {\n return {\n kind: 'polygon',\n commands: new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]),\n coords: new Float32Array([x0, y0, x1, y0, x1, y1, x0, y1]),\n fillRule: 'nonzero',\n };\n}\n\n/** Paint identity for grouping. Paint is plain data, so structural equality\n * is exact — a gradient set on two runs separately is still one paint. */\nfunction paintKey(fill: FillStyle | null, stroke: Stroke | undefined): string {\n return JSON.stringify([fill, stroke ?? null]);\n}\n\n/**\n * The one glyph walk behind both entry points. Each resolved run is repainted\n * with an opaque solid whose color is its paint group's index, so the layout's\n * own groups and decoration rules come back labeled with it; nothing else in\n * the layout reads paint once `outlineMinSize` is 0, so the geometry is what\n * it would be with no paint at all.\n */\nfunction walkOutlines(\n data: TextOutlineSource,\n pose: PathInWorldPose,\n opts: TextToPathOptions,\n): { paints: { fill: FillStyle | null; stroke?: Stroke }[]; paths: PolygonPath[] } {\n const textPose: TextPose = {\n x: pose.x, y: pose.y, width: pose.width, height: pose.height,\n text: data.text,\n runs: data.runs as StyledRun[] | undefined,\n style: data.style,\n verticalAlign: data.verticalAlign,\n fill: data.fill,\n stroke: data.stroke,\n };\n const { runs: resolved, opts: layoutOpts } = textPoseLayoutInput(textPose, opts.scale ?? 1);\n for (const run of resolved) assertOutlinable(run);\n\n const paints: { fill: FillStyle | null; stroke?: Stroke }[] = [];\n const indexOf = new Map<string, number>();\n const runs = resolved.map((run): ResolvedRun => {\n const key = paintKey(run.fill, run.stroke);\n let i = indexOf.get(key);\n if (i === undefined) {\n i = paints.length;\n indexOf.set(key, i);\n paints.push(run.stroke !== undefined ? { fill: run.fill, stroke: run.stroke } : { fill: run.fill });\n }\n const { stroke: _stroke, ...rest } = run;\n return { ...rest, fill: { fill: 'solid', color: `#${i.toString(16).padStart(6, '0')}` } };\n });\n const groupOf = (fill: FillStyle | null): number =>\n fill !== null && 'color' in fill ? parseInt(fill.color.slice(1), 16) : 0;\n\n const laid = layoutRuns(runs, { ...layoutOpts, outlineMinSize: 0 });\n // A code point the run's own face lacks escalates to a fallback face, which\n // the per-run check above never saw.\n for (const g of laid.groups) {\n if (g.source !== 'outline' && g.quads.length > 0) {\n throw new TextOutlinesError('no-outlines', g.family, g.weight, g.style,\n 'a fallback face serving some of the text\\'s characters has no outlines registered.');\n }\n }\n\n const dx = pose.x;\n const dy = pose.y + verticalAlignOffset(data.verticalAlign, pose.height, laid.bounds.height);\n const parts: PolygonPath[][] = paints.map(() => []);\n for (const g of laid.groups) {\n const out = parts[groupOf(g.fill)]!;\n const shear = g.synthetic.italic ? Math.tan(SYNTHETIC_ITALIC_RADIANS) : 0;\n for (const glyph of g.glyphs) {\n const s = glyph.scale;\n // The renderer's placement (`mergeGlyphMeshes`): x = pen + (ex - ey·shear)·s.\n const m: Mat3 = [s, 0, -shear * s, s, glyph.x + dx, glyph.baselineY + dy];\n out.push(transformPath(emGlyph(glyph.d), m) as PolygonPath);\n }\n }\n for (const r of laid.decorations) {\n parts[groupOf(r.fill)]!.push(ruleContour(r.x0 + dx, r.y0 + dy, r.x1 + dx, r.y1 + dy));\n }\n\n const rot = poseRotationOf(pose);\n const paths = parts.map((p) => {\n const path = concat(p);\n if (!rot || path.commands.length === 0) return path;\n return transformPath(path, rotateAboutPoint(rot.cx, rot.cy, rot.rotation)) as PolygonPath;\n });\n return { paints, paths };\n}\n\n/**\n * The outline geometry of a text node, in world space: every glyph and every\n * underline, strikethrough and overline rule it draws, as one `'nonzero'`\n * compound path whose filled region is their union. Glyphs keep the font's\n * curves; overlapping contours are not merged — run the result through\n * `pathUnion` for that, at the cost of flattening the curves.\n *\n * `pose` is the node's box and rotation. Synthetic italic is sheared exactly\n * as the renderer shears it. Throws {@link TextOutlinesError} when any run's\n * face cannot supply outlines — never returns a partial or empty path for\n * that. Text with no ink (empty, or only spaces) returns an empty path.\n */\nexport function textToPath(\n data: TextOutlineSource,\n pose: PathInWorldPose,\n opts: TextToPathOptions = {},\n): PolygonPath {\n return concat(walkOutlines(data, pose, opts).paths);\n}\n\n/**\n * {@link textToPath}, split by paint: one path per distinct resolved fill and\n * stroke, each gathering the glyphs and decoration rules that wear it — a\n * rule takes the fill of the run it underlines. Groups come in the order\n * their paint first appears in the text; a paint whose runs put down no ink\n * has none. Together the paths cover exactly what `textToPath` covers.\n *\n * Paint resolves as the renderer resolves it: a run's `fill` / `stroke`, else\n * the node's `data.fill` / `data.stroke` from `data`, else the default black\n * fill and no stroke. Throws as `textToPath` does.\n */\nexport function textToPathsByPaint(\n data: TextOutlineSource,\n pose: PathInWorldPose,\n opts: TextToPathOptions = {},\n): TextPaintPath[] {\n const { paints, paths } = walkOutlines(data, pose, opts);\n const out: TextPaintPath[] = [];\n paints.forEach((paint, i) => {\n if (paths[i]!.commands.length > 0) out.push({ ...paint, path: paths[i]! });\n });\n return out;\n}\n\n/**\n * Load the outlines of every face `data` is set in — the requested faces and\n * the ones they resolve to — so a following {@link textToPath} does not fail\n * with `'outlines-loading'`. Resolves once each has loaded or failed.\n */\nexport async function loadTextOutlines(\n data: TextOutlineSource,\n opts: TextToPathOptions = {},\n): Promise<void> {\n const textPose: TextPose = {\n x: 0, y: 0, width: 0, height: 0,\n text: data.text,\n runs: data.runs as StyledRun[] | undefined,\n style: data.style,\n };\n const { runs } = textPoseLayoutInput(textPose, opts.scale ?? 1);\n await Promise.all(facesOf(runs).map((f) => loadFontOutlines(f.family, { weight: f.weight, style: f.style })));\n // An outline-only family resolves to its own face only once that face has\n // parsed; before, it resolved to whatever stood in. Ask again.\n await Promise.all(facesOf(runs).map((f) => loadFontOutlines(f.family, { weight: f.weight, style: f.style })));\n}\n\n"],"mappings":";;;;;;AAuFA,IAAaA,IAAb,cAAuC,MAAM;CAC3C;CACA;CACA;CACA;CAEA,YAAY,GAA6B,GAAgB,GAAgB,GAAkB,GAAgB;EAMzG,AALA,MAAM,gBAAgBC,EAAO,IAAIC,EAAO,GAAGC,EAAM,KAAKC,GAAQ,GAC9D,KAAK,OAAO,qBACZ,KAAK,SAASC,GACd,KAAK,SAASJ,GACd,KAAK,SAASC,GACd,K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