@weasel-js/core 1.9.3 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1139) hide show
  1. package/CHANGELOG.md +1106 -0
  2. package/README.md +7 -5
  3. package/dist/WeaselProvider.js +5 -7
  4. package/dist/WeaselProvider.js.map +1 -1
  5. package/dist/affordances/composeAffordanceLayer.js +91 -93
  6. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  7. package/dist/affordances/cornerResize.js +27 -18
  8. package/dist/affordances/cornerResize.js.map +1 -1
  9. package/dist/affordances/hitAffordanceRegions.js +65 -104
  10. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  11. package/dist/affordances/pathAnchors.js.map +1 -1
  12. package/dist/affordances/rotationHandle.js +22 -21
  13. package/dist/affordances/rotationHandle.js.map +1 -1
  14. package/dist/animation/behaviors/coast.js +21 -0
  15. package/dist/animation/behaviors/coast.js.map +1 -0
  16. package/dist/animation/behaviors/coastByWrite.js +107 -0
  17. package/dist/animation/behaviors/coastByWrite.js.map +1 -0
  18. package/dist/animation/behaviors/coastOnTargets.js +94 -0
  19. package/dist/animation/behaviors/coastOnTargets.js.map +1 -0
  20. package/dist/animation/behaviors/momentum.js +38 -88
  21. package/dist/animation/behaviors/momentum.js.map +1 -1
  22. package/dist/animation/clipTargets.js +12 -0
  23. package/dist/animation/clipTargets.js.map +1 -0
  24. package/dist/animation/index.js +15 -20
  25. package/dist/animation/poseHelpers.js +112 -33
  26. package/dist/animation/poseHelpers.js.map +1 -1
  27. package/dist/animation/poseTarget.js +115 -0
  28. package/dist/animation/poseTarget.js.map +1 -0
  29. package/dist/animation/reflow.js +113 -83
  30. package/dist/animation/reflow.js.map +1 -1
  31. package/dist/animation/rewind.js +66 -0
  32. package/dist/animation/rewind.js.map +1 -0
  33. package/dist/animation/rig/bindRig.js +85 -53
  34. package/dist/animation/rig/bindRig.js.map +1 -1
  35. package/dist/animation/rig/rigNode.js +93 -0
  36. package/dist/animation/rig/rigNode.js.map +1 -0
  37. package/dist/animation/rig/rigSeat.js +26 -0
  38. package/dist/animation/rig/rigSeat.js.map +1 -0
  39. package/dist/animation/rig/skinBinding.js +56 -0
  40. package/dist/animation/rig/skinBinding.js.map +1 -0
  41. package/dist/animation/rig/useRig.js +31 -16
  42. package/dist/animation/rig/useRig.js.map +1 -1
  43. package/dist/animation/wrappers/animateLifecycle.js +32 -24
  44. package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
  45. package/dist/animation/wrappers/animateOnSetPose.js +31 -29
  46. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
  47. package/dist/animation/wrappers/instantPose.js +13 -0
  48. package/dist/animation/wrappers/instantPose.js.map +1 -0
  49. package/dist/animation/writtenPoseTarget.js +33 -0
  50. package/dist/animation/writtenPoseTarget.js.map +1 -0
  51. package/dist/{autoPoseDescriptor-vCdt55xm.d.ts → autoPoseDescriptor-DHg5KqaJ.d.ts} +1 -1
  52. package/dist/barrel/canvas.js +31 -0
  53. package/dist/barrel/chrome.js +16 -0
  54. package/dist/barrel/input.js +18 -0
  55. package/dist/barrel/interactions.js +38 -0
  56. package/dist/barrel/paint.js +11 -0
  57. package/dist/barrel/paths.js +12 -0
  58. package/dist/barrel/renderer.js +14 -0
  59. package/dist/barrel/routing.js +57 -0
  60. package/dist/barrel/scene.js +37 -0
  61. package/dist/barrel/text.js +9 -0
  62. package/dist/barrel/viewport.js +42 -0
  63. package/dist/canvas/Canvas.js +280 -559
  64. package/dist/canvas/Canvas.js.map +1 -1
  65. package/dist/canvas/CanvasView.js +147 -167
  66. package/dist/canvas/CanvasView.js.map +1 -1
  67. package/dist/canvas/CursorCoordsHud.js +53 -49
  68. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  69. package/dist/canvas/DrawCanvas.js +40 -51
  70. package/dist/canvas/DrawCanvas.js.map +1 -1
  71. package/dist/canvas/ModalityHud.js.map +1 -1
  72. package/dist/canvas/NodeShape.js +55 -374
  73. package/dist/canvas/NodeShape.js.map +1 -1
  74. package/dist/canvas/PickHud.js +50 -47
  75. package/dist/canvas/PickHud.js.map +1 -1
  76. package/dist/canvas/SceneCanvas/DevHuds.js +40 -0
  77. package/dist/canvas/SceneCanvas/DevHuds.js.map +1 -0
  78. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +126 -0
  79. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +27 -31
  81. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
  82. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +64 -0
  83. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
  84. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
  85. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
  86. package/dist/canvas/SceneCanvas/coordTrace.js +46 -0
  87. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
  88. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +138 -85
  89. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  90. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
  91. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
  92. package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -1
  93. package/dist/canvas/SceneCanvas/features.js +74 -43
  94. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  95. package/dist/canvas/SceneCanvas/isDev.js +12 -0
  96. package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
  97. package/dist/canvas/SceneCanvas/poseGeometry.js +31 -34
  98. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  99. package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
  100. package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
  101. package/dist/canvas/SceneCanvas/props.js +39 -0
  102. package/dist/canvas/SceneCanvas/props.js.map +1 -0
  103. package/dist/canvas/SceneCanvas/toolRegistry.js +23 -0
  104. package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -0
  105. package/dist/canvas/SceneCanvas/useActionsPropResolver.js +6 -1
  106. package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
  107. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
  108. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  109. package/dist/canvas/SceneCanvas/useBuiltinTools.js +21 -0
  110. package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -0
  111. package/dist/canvas/SceneCanvas/useCanvasCamera.js +38 -0
  112. package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -0
  113. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +20 -0
  114. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -0
  115. package/dist/canvas/SceneCanvas/useCanvasSelection.js +16 -0
  116. package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -0
  117. package/dist/canvas/SceneCanvas/useCanvasTools.js +67 -0
  118. package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -0
  119. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +29 -29
  120. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  121. package/dist/canvas/SceneCanvas/useHeldModifiers.js +20 -0
  122. package/dist/canvas/SceneCanvas/useHeldModifiers.js.map +1 -0
  123. package/dist/canvas/SceneCanvas/useNodeAtPoint.js +26 -0
  124. package/dist/canvas/SceneCanvas/useNodeAtPoint.js.map +1 -0
  125. package/dist/canvas/SceneCanvas/useNodeKinds.js +26 -0
  126. package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -0
  127. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +48 -48
  128. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  129. package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +47 -0
  130. package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -0
  131. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +66 -0
  132. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -0
  133. package/dist/canvas/SceneCanvas/useSceneChrome.js +59 -0
  134. package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -0
  135. package/dist/canvas/SceneCanvas/useSceneRedrawSources.js +23 -0
  136. package/dist/canvas/SceneCanvas/useSceneRedrawSources.js.map +1 -0
  137. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +74 -78
  138. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  139. package/dist/canvas/SceneCanvas/useSceneSlotLayers.js +37 -0
  140. package/dist/canvas/SceneCanvas/useSceneSlotLayers.js.map +1 -0
  141. package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js +38 -0
  142. package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js.map +1 -0
  143. package/dist/canvas/SceneCanvas/useViewLayerGate.js +20 -0
  144. package/dist/canvas/SceneCanvas/useViewLayerGate.js.map +1 -0
  145. package/dist/canvas/SceneCanvas/useViewportActions.js +9 -1
  146. package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -1
  147. package/dist/canvas/SceneCanvas/worldPointAt.js +9 -0
  148. package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -0
  149. package/dist/canvas/SceneCanvas.js +311 -969
  150. package/dist/canvas/SceneCanvas.js.map +1 -1
  151. package/dist/canvas/SceneViewCanvas.js +42 -46
  152. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  153. package/dist/canvas/adapterDerivedPath.js +26 -0
  154. package/dist/canvas/adapterDerivedPath.js.map +1 -0
  155. package/dist/canvas/affordanceAt.js +11 -1
  156. package/dist/canvas/affordanceAt.js.map +1 -1
  157. package/dist/canvas/buildSceneLayer.js +111 -0
  158. package/dist/canvas/buildSceneLayer.js.map +1 -0
  159. package/dist/canvas/buildSceneTree.js +16 -19
  160. package/dist/canvas/buildSceneTree.js.map +1 -1
  161. package/dist/canvas/canvasRenderer.js +67 -55
  162. package/dist/canvas/canvasRenderer.js.map +1 -1
  163. package/dist/canvas/colorOverrides.js.map +1 -1
  164. package/dist/canvas/defaultDrawOne.js +12 -12
  165. package/dist/canvas/defaultDrawOne.js.map +1 -1
  166. package/dist/canvas/deps/areaSelect.js +4 -4
  167. package/dist/canvas/deps/areaSelect.js.map +1 -1
  168. package/dist/canvas/deps/changes.js +13 -0
  169. package/dist/canvas/deps/changes.js.map +1 -0
  170. package/dist/canvas/deps/debug.js.map +1 -1
  171. package/dist/canvas/deps/editAnchors.js +38 -57
  172. package/dist/canvas/deps/editAnchors.js.map +1 -1
  173. package/dist/canvas/deps/geometryProjection.js.map +1 -1
  174. package/dist/canvas/deps/hitTestArea.js +31 -26
  175. package/dist/canvas/deps/hitTestArea.js.map +1 -1
  176. package/dist/canvas/deps/insert.js +130 -91
  177. package/dist/canvas/deps/insert.js.map +1 -1
  178. package/dist/canvas/deps/lassoSelect.js +5 -5
  179. package/dist/canvas/deps/lassoSelect.js.map +1 -1
  180. package/dist/canvas/deps/poseDescriptor.js +1 -1
  181. package/dist/canvas/deps/poseDescriptor.js.map +1 -1
  182. package/dist/canvas/deps/resizePolicy.js.map +1 -1
  183. package/dist/canvas/deps/slice.js +26 -26
  184. package/dist/canvas/deps/slice.js.map +1 -1
  185. package/dist/canvas/deps/textEdit.js +6 -5
  186. package/dist/canvas/deps/textEdit.js.map +1 -1
  187. package/dist/canvas/deps/view.js.map +1 -1
  188. package/dist/canvas/derivedPath.js +47 -22
  189. package/dist/canvas/derivedPath.js.map +1 -1
  190. package/dist/canvas/drawEnvelope.js +8 -4
  191. package/dist/canvas/drawEnvelope.js.map +1 -1
  192. package/dist/canvas/getNodeAtPoint.js +4 -8
  193. package/dist/canvas/getNodeAtPoint.js.map +1 -1
  194. package/dist/canvas/hud.module.js +1 -1
  195. package/dist/canvas/hud.module.js.map +1 -1
  196. package/dist/canvas/insertPreviewExtent.js.map +1 -1
  197. package/dist/canvas/kitRequirements.js +2 -2
  198. package/dist/canvas/kitRequirements.js.map +1 -1
  199. package/dist/canvas/layerOrder.js +13 -6
  200. package/dist/canvas/layerOrder.js.map +1 -1
  201. package/dist/canvas/layerSlots.js +6 -1
  202. package/dist/canvas/layerSlots.js.map +1 -1
  203. package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
  204. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
  205. package/dist/canvas/nodeShapes/imagePainter.js +87 -0
  206. package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
  207. package/dist/canvas/nodeShapes/memo.js +9 -0
  208. package/dist/canvas/nodeShapes/memo.js.map +1 -0
  209. package/dist/canvas/nodeShapes/nodePaint.js +68 -0
  210. package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
  211. package/dist/canvas/nodeShapes/pathPainter.js +39 -0
  212. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
  213. package/dist/canvas/nodeShapes/poseBox.js +20 -0
  214. package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
  215. package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
  216. package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
  217. package/dist/canvas/nodeShapes/shapePainter.js +72 -0
  218. package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
  219. package/dist/canvas/nodeShapes/textPainter.js +55 -0
  220. package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
  221. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  222. package/dist/canvas/paintCull.js +11 -14
  223. package/dist/canvas/paintCull.js.map +1 -1
  224. package/dist/{features/cursor → canvas}/paintedCursorLayer.js +2 -2
  225. package/dist/canvas/paintedCursorLayer.js.map +1 -0
  226. package/dist/canvas/pickWalk.js +59 -68
  227. package/dist/canvas/pickWalk.js.map +1 -1
  228. package/dist/canvas/planeClips.js +18 -19
  229. package/dist/canvas/planeClips.js.map +1 -1
  230. package/dist/canvas/poseCascade.js +41 -0
  231. package/dist/canvas/poseCascade.js.map +1 -0
  232. package/dist/canvas/poseRotation.js +9 -23
  233. package/dist/canvas/poseRotation.js.map +1 -1
  234. package/dist/canvas/rasterReadback.js +22 -0
  235. package/dist/canvas/rasterReadback.js.map +1 -0
  236. package/dist/canvas/renderDebugSnapshot.js +11 -11
  237. package/dist/canvas/renderDebugSnapshot.js.map +1 -1
  238. package/dist/canvas/renderNeeds.js +3 -3
  239. package/dist/canvas/renderNeeds.js.map +1 -1
  240. package/dist/canvas/renderSceneToPixels.js +64 -81
  241. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  242. package/dist/canvas/sceneAdapter.js +68 -214
  243. package/dist/canvas/sceneAdapter.js.map +1 -1
  244. package/dist/canvas/sceneClipboard.js +112 -0
  245. package/dist/canvas/sceneClipboard.js.map +1 -0
  246. package/dist/canvas/sceneLayerPaint.js +4 -4
  247. package/dist/canvas/sceneLayerPaint.js.map +1 -1
  248. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  249. package/dist/canvas/sceneViewRender.js +39 -39
  250. package/dist/canvas/sceneViewRender.js.map +1 -1
  251. package/dist/canvas/slopsDebugLayer.js +4 -4
  252. package/dist/canvas/slopsDebugLayer.js.map +1 -1
  253. package/dist/canvas/surface.module.js +6 -0
  254. package/dist/canvas/surface.module.js.map +1 -0
  255. package/dist/canvas/surfaceBox.js +16 -0
  256. package/dist/canvas/surfaceBox.js.map +1 -0
  257. package/dist/canvas/useCanvasRenderer.js +26 -6
  258. package/dist/canvas/useCanvasRenderer.js.map +1 -1
  259. package/dist/canvas/useCanvasSurface.js +31 -0
  260. package/dist/canvas/useCanvasSurface.js.map +1 -0
  261. package/dist/canvas/useCanvasView.js +67 -0
  262. package/dist/canvas/useCanvasView.js.map +1 -0
  263. package/dist/canvas/useFrameLoop.js +39 -31
  264. package/dist/canvas/useFrameLoop.js.map +1 -1
  265. package/dist/canvas/useHostAnchor.js +35 -33
  266. package/dist/canvas/useHostAnchor.js.map +1 -1
  267. package/dist/canvas/useLateContentRedraw.js +8 -8
  268. package/dist/canvas/useLateContentRedraw.js.map +1 -1
  269. package/dist/canvas/useSceneLayerList.js +11 -0
  270. package/dist/canvas/useSceneLayerList.js.map +1 -0
  271. package/dist/canvas/useSurfaceInput.js +42 -0
  272. package/dist/canvas/useSurfaceInput.js.map +1 -0
  273. package/dist/canvas/useToolCursor.js +29 -0
  274. package/dist/canvas/useToolCursor.js.map +1 -0
  275. package/dist/canvas/useViewHelpers.js +46 -85
  276. package/dist/canvas/useViewHelpers.js.map +1 -1
  277. package/dist/canvas/viewInputs.js.map +1 -1
  278. package/dist/canvas/viewRegistry.js +25 -27
  279. package/dist/canvas/viewRegistry.js.map +1 -1
  280. package/dist/canvas/watchElementMove.js +43 -0
  281. package/dist/canvas/watchElementMove.js.map +1 -0
  282. package/dist/canvas/wrapNodeOutput.js.map +1 -1
  283. package/dist/clipboard.d.ts +16 -19
  284. package/dist/{types-B_9g6hMM.d.ts → clone-2a5hVbBd.d.ts} +123 -74
  285. package/dist/clone.d.ts +4 -7
  286. package/dist/clone.js +0 -2
  287. package/dist/core/device/index.js +5 -4
  288. package/dist/core/device/targets.js.map +1 -1
  289. package/dist/core/device/useDeviceProfile.js +38 -44
  290. package/dist/core/device/useDeviceProfile.js.map +1 -1
  291. package/dist/core/device/watchDevicePixelRatio.js +17 -0
  292. package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
  293. package/dist/{interactions/actions/resize → core/geometry}/autoPoseDescriptor.js +8 -7
  294. package/dist/core/geometry/autoPoseDescriptor.js.map +1 -0
  295. package/dist/core/geometry/pathPoseDescriptor.js +88 -0
  296. package/dist/core/geometry/pathPoseDescriptor.js.map +1 -0
  297. package/dist/core/geometry/poseDescriptor.js +68 -19
  298. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  299. package/dist/core/geometry/regionHit.js +31 -34
  300. package/dist/core/geometry/regionHit.js.map +1 -1
  301. package/dist/core/geometry/targetFrame.js +94 -0
  302. package/dist/core/geometry/targetFrame.js.map +1 -0
  303. package/dist/core/geometry/unionBounds.js +30 -29
  304. package/dist/core/geometry/unionBounds.js.map +1 -1
  305. package/dist/core/isPlainObject.js +2 -11
  306. package/dist/core/layers/backgroundFill.js +31 -0
  307. package/dist/core/layers/backgroundFill.js.map +1 -0
  308. package/dist/{features/groups → core/layers}/children.js +1 -1
  309. package/dist/core/layers/children.js.map +1 -0
  310. package/dist/core/layers/gateLayer.js +13 -0
  311. package/dist/core/layers/gateLayer.js.map +1 -0
  312. package/dist/core/layers/layerGroup.js +40 -0
  313. package/dist/core/layers/layerGroup.js.map +1 -0
  314. package/dist/core/layers/render.js +50 -76
  315. package/dist/core/layers/render.js.map +1 -1
  316. package/dist/core/ops/arrange.js +1 -0
  317. package/dist/core/ops/arrange.js.map +1 -1
  318. package/dist/core/ops/create.js +10 -5
  319. package/dist/core/ops/create.js.map +1 -1
  320. package/dist/core/ops/createHistory.js +9 -9
  321. package/dist/core/ops/createHistory.js.map +1 -1
  322. package/dist/core/ops/delete.js +12 -24
  323. package/dist/core/ops/delete.js.map +1 -1
  324. package/dist/core/ops/reorder/index.js +43 -40
  325. package/dist/core/ops/reorder/index.js.map +1 -1
  326. package/dist/core/ops/reorder/setChildOrder.js +34 -0
  327. package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
  328. package/dist/core/paint/meshKind.js +16 -0
  329. package/dist/core/paint/meshKind.js.map +1 -0
  330. package/dist/{features/meshPaint/lazyKind.js → core/paint/meshKindLazy.js} +282 -105
  331. package/dist/core/paint/meshKindLazy.js.map +1 -0
  332. package/dist/core/paint/paintKindEntry.js +8 -0
  333. package/dist/core/paint/paintKindEntry.js.map +1 -0
  334. package/dist/core/paint/paintKinds.js +144 -0
  335. package/dist/core/paint/paintKinds.js.map +1 -0
  336. package/dist/core/paint/registerMesh.js +7 -0
  337. package/dist/core/paint/registerMesh.js.map +1 -0
  338. package/dist/core/scene/NodeProperties.js.map +1 -1
  339. package/dist/core/scene/NodeRouting.js.map +1 -1
  340. package/dist/core/scene/appliedLog.js +37 -0
  341. package/dist/core/scene/appliedLog.js.map +1 -0
  342. package/dist/core/scene/arrivalWindow.js +102 -0
  343. package/dist/core/scene/arrivalWindow.js.map +1 -0
  344. package/dist/core/scene/boundOps.js +40 -0
  345. package/dist/core/scene/boundOps.js.map +1 -0
  346. package/dist/core/scene/composeFrame.js +9 -6
  347. package/dist/core/scene/composeFrame.js.map +1 -1
  348. package/dist/{features/groups → core/scene}/composePose.js +18 -18
  349. package/dist/core/scene/composePose.js.map +1 -0
  350. package/dist/core/scene/depMemo.js +31 -6
  351. package/dist/core/scene/depMemo.js.map +1 -1
  352. package/dist/core/scene/derivedPath.js +19 -20
  353. package/dist/core/scene/derivedPath.js.map +1 -1
  354. package/dist/core/scene/editMode.js +26 -0
  355. package/dist/core/scene/editMode.js.map +1 -0
  356. package/dist/core/scene/effectivePose.js +38 -39
  357. package/dist/core/scene/effectivePose.js.map +1 -1
  358. package/dist/core/scene/fieldEdits.js +98 -0
  359. package/dist/core/scene/fieldEdits.js.map +1 -0
  360. package/dist/core/scene/historyFacade.js +130 -0
  361. package/dist/core/scene/historyFacade.js.map +1 -0
  362. package/dist/core/scene/historyForm.js +6 -0
  363. package/dist/core/scene/historyForm.js.map +1 -0
  364. package/dist/core/scene/kitOps.js +185 -0
  365. package/dist/core/scene/kitOps.js.map +1 -0
  366. package/dist/core/scene/kitRegistry.js.map +1 -1
  367. package/dist/core/scene/layerStack.js +131 -0
  368. package/dist/core/scene/layerStack.js.map +1 -0
  369. package/dist/core/scene/layoutPass.js +58 -59
  370. package/dist/core/scene/layoutPass.js.map +1 -1
  371. package/dist/core/scene/lockGuard.js +37 -0
  372. package/dist/core/scene/lockGuard.js.map +1 -0
  373. package/dist/{features/groups → core/scene}/nestedHit.js +3 -3
  374. package/dist/core/scene/nestedHit.js.map +1 -0
  375. package/dist/core/scene/nodeFnFields.js +10 -11
  376. package/dist/core/scene/nodeFnFields.js.map +1 -1
  377. package/dist/core/scene/nodeMemo.js +45 -19
  378. package/dist/core/scene/nodeMemo.js.map +1 -1
  379. package/dist/core/scene/nodeStore.js +127 -0
  380. package/dist/core/scene/nodeStore.js.map +1 -0
  381. package/dist/core/scene/notifier.js +37 -0
  382. package/dist/core/scene/notifier.js.map +1 -0
  383. package/dist/core/scene/opTable.js +50 -0
  384. package/dist/core/scene/opTable.js.map +1 -0
  385. package/dist/core/scene/outerOps.js +66 -0
  386. package/dist/core/scene/outerOps.js.map +1 -0
  387. package/dist/core/scene/poseFeed.js +38 -38
  388. package/dist/core/scene/poseFeed.js.map +1 -1
  389. package/dist/core/scene/poseHold.js +39 -0
  390. package/dist/core/scene/poseHold.js.map +1 -0
  391. package/dist/core/scene/poseOverrides.js +44 -40
  392. package/dist/core/scene/poseOverrides.js.map +1 -1
  393. package/dist/core/scene/poseSnapshot.js.map +1 -1
  394. package/dist/core/scene/reconcileSpecs.js +3 -2
  395. package/dist/core/scene/reconcileSpecs.js.map +1 -1
  396. package/dist/core/scene/recorder.js +86 -0
  397. package/dist/core/scene/recorder.js.map +1 -0
  398. package/dist/core/scene/renderOrder.js +84 -0
  399. package/dist/core/scene/renderOrder.js.map +1 -0
  400. package/dist/core/scene/scene.js +80 -1266
  401. package/dist/core/scene/scene.js.map +1 -1
  402. package/dist/core/scene/sceneEdits.js +58 -0
  403. package/dist/core/scene/sceneEdits.js.map +1 -0
  404. package/dist/core/scene/sceneMutators.js +49 -0
  405. package/dist/core/scene/sceneMutators.js.map +1 -0
  406. package/dist/core/scene/scenePoseAdapter.js +16 -0
  407. package/dist/core/scene/scenePoseAdapter.js.map +1 -0
  408. package/dist/core/scene/sceneRecording.js +90 -0
  409. package/dist/core/scene/sceneRecording.js.map +1 -0
  410. package/dist/core/scene/sceneSelection.js +28 -0
  411. package/dist/core/scene/sceneSelection.js.map +1 -0
  412. package/dist/core/scene/sceneState.js +49 -0
  413. package/dist/core/scene/sceneState.js.map +1 -0
  414. package/dist/core/scene/serialization.js +71 -0
  415. package/dist/core/scene/serialization.js.map +1 -0
  416. package/dist/core/scene/staleReplay.js +51 -0
  417. package/dist/core/scene/staleReplay.js.map +1 -0
  418. package/dist/core/scene/statedFields.js +9 -0
  419. package/dist/core/scene/statedFields.js.map +1 -0
  420. package/dist/core/scene/treeEdits.js +127 -0
  421. package/dist/core/scene/treeEdits.js.map +1 -0
  422. package/dist/core/scene/treeOrder.js +13 -0
  423. package/dist/core/scene/treeOrder.js.map +1 -0
  424. package/dist/core/scene/treeReads.js +26 -0
  425. package/dist/core/scene/treeReads.js.map +1 -0
  426. package/dist/core/scene/types.js.map +1 -1
  427. package/dist/{features/groups → core/scene}/unionOfChildren.js +3 -3
  428. package/dist/core/scene/unionOfChildren.js.map +1 -0
  429. package/dist/core/scene/unitScopes.js +13 -0
  430. package/dist/core/scene/unitScopes.js.map +1 -0
  431. package/dist/core/scene/useScene.js.map +1 -1
  432. package/dist/core/selection/readOnlySelection.js +32 -0
  433. package/dist/core/selection/readOnlySelection.js.map +1 -0
  434. package/dist/core/selection/usePublishSceneSelection.js +26 -0
  435. package/dist/core/selection/usePublishSceneSelection.js.map +1 -0
  436. package/dist/core/selection/useSelection.js +34 -25
  437. package/dist/core/selection/useSelection.js.map +1 -1
  438. package/dist/core/shapeKinds.js.map +1 -1
  439. package/dist/core/stylus/stylus.js.map +1 -1
  440. package/dist/core/stylus/usePointerStylus.js.map +1 -1
  441. package/dist/core/usePaintKinds.js +1 -1
  442. package/dist/core/usePaintKinds.js.map +1 -1
  443. package/dist/core/viewport/clientToWorld.js.map +1 -1
  444. package/dist/core/viewport/fitViewToBounds.js.map +1 -1
  445. package/dist/core/viewport/parallax.js.map +1 -1
  446. package/dist/core/viewport/screenSlop.js +11 -11
  447. package/dist/core/viewport/screenSlop.js.map +1 -1
  448. package/dist/core/viewport/useCanvasSize.js.map +1 -1
  449. package/dist/core/viewport/useDecayLoop.js +8 -8
  450. package/dist/core/viewport/useDecayLoop.js.map +1 -1
  451. package/dist/core/viewport/useNodeOverlayFrame.js +84 -0
  452. package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -0
  453. package/dist/core/viewport/useViewAnimation.js +102 -43
  454. package/dist/core/viewport/useViewAnimation.js.map +1 -1
  455. package/dist/core/viewport/view.js +9 -9
  456. package/dist/core/viewport/view.js.map +1 -1
  457. package/dist/core/viewport/wheelHandler.js.map +1 -1
  458. package/dist/core/viewport/zoomBounds.js +10 -8
  459. package/dist/core/viewport/zoomBounds.js.map +1 -1
  460. package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-BEshc4z3.d.ts} +11 -24
  461. package/dist/debug/createDebugOverlayLayer.js +97 -97
  462. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  463. package/dist/debug/createDebugSink.js.map +1 -1
  464. package/dist/debug/flag.js +2 -41
  465. package/dist/debug/frameStats.js.map +1 -1
  466. package/dist/debug/useDebugSink.js +52 -0
  467. package/dist/debug/useDebugSink.js.map +1 -0
  468. package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -1
  469. package/dist/features/chrome-caps/conditions.js.map +1 -1
  470. package/dist/features/chrome-caps/defaults.js.map +1 -1
  471. package/dist/features/chrome-caps/resolve.js.map +1 -1
  472. package/dist/features/chrome-caps/useChromeCaps.js +54 -0
  473. package/dist/features/chrome-caps/useChromeCaps.js.map +1 -0
  474. package/dist/features/chrome-caps/useHoverTracking.js +22 -17
  475. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  476. package/dist/features/ingestion/contentHandlers.js +28 -19
  477. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  478. package/dist/features/ingestion/imageHandler.js +21 -24
  479. package/dist/features/ingestion/imageHandler.js.map +1 -1
  480. package/dist/features/ingestion/openFilePicker.js.map +1 -1
  481. package/dist/features/ingestion/placement.js +16 -0
  482. package/dist/features/ingestion/placement.js.map +1 -0
  483. package/dist/features/ingestion/registerKitHandlers.js +7 -7
  484. package/dist/features/ingestion/svgHandler.js +5 -0
  485. package/dist/features/ingestion/svgHandler.js.map +1 -1
  486. package/dist/features/ingestion/textHandler.js +28 -0
  487. package/dist/features/ingestion/textHandler.js.map +1 -0
  488. package/dist/features/ingestion/useCanvasIngestion.js +48 -0
  489. package/dist/features/ingestion/useCanvasIngestion.js.map +1 -0
  490. package/dist/features/ingestion/weaselJsonHandler.js +22 -14
  491. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
  492. package/dist/features/longPress/longPressFeedback.js.map +1 -1
  493. package/dist/features/modes/modeLayers.js +7 -7
  494. package/dist/features/modes/modeLayers.js.map +1 -1
  495. package/dist/features/paths/editablePath.js +47 -0
  496. package/dist/features/paths/editablePath.js.map +1 -0
  497. package/dist/features/paths/index.js +9 -14
  498. package/dist/features/paths/pathEditState.js +41 -0
  499. package/dist/features/paths/pathEditState.js.map +1 -0
  500. package/dist/features/paths/pathEditingOverlayLayer.js +36 -38
  501. package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -1
  502. package/dist/features/paths/pathLayer.js +3 -2
  503. package/dist/features/paths/pathLayer.js.map +1 -1
  504. package/dist/features/paths/penPreviewLayer.js +86 -88
  505. package/dist/features/paths/penPreviewLayer.js.map +1 -1
  506. package/dist/features/paths/usePathEdit.js +34 -0
  507. package/dist/features/paths/usePathEdit.js.map +1 -0
  508. package/dist/features/poseRun/usePoseRun.js +44 -52
  509. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  510. package/dist/features/selection/overlay.js +171 -179
  511. package/dist/features/selection/overlay.js.map +1 -1
  512. package/dist/features/text/index.js +6 -0
  513. package/dist/features/text/textLayer.js +1 -1
  514. package/dist/features/text/textLayer.js.map +1 -1
  515. package/dist/features/text/useSceneTextEdit.js +100 -93
  516. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  517. package/dist/features/viewports/viewportLayer.js +25 -36
  518. package/dist/features/viewports/viewportLayer.js.map +1 -1
  519. package/dist/index.d.ts +8473 -9141
  520. package/dist/index.js +269 -307
  521. package/dist/input/keyState.js +38 -39
  522. package/dist/input/keyState.js.map +1 -1
  523. package/dist/input/useKeyModifiers.js +11 -0
  524. package/dist/input/useKeyModifiers.js.map +1 -0
  525. package/dist/interactions/actions/actionShortcuts.js.map +1 -1
  526. package/dist/interactions/actions/{defaults/align.js → align/action.js} +18 -20
  527. package/dist/interactions/actions/align/action.js.map +1 -0
  528. package/dist/interactions/actions/align/align.js +20 -20
  529. package/dist/interactions/actions/align/align.js.map +1 -1
  530. package/dist/interactions/actions/booleans/action.js +65 -0
  531. package/dist/interactions/actions/booleans/action.js.map +1 -0
  532. package/dist/interactions/actions/booleans/booleans.js +69 -78
  533. package/dist/interactions/actions/booleans/booleans.js.map +1 -1
  534. package/dist/interactions/actions/booleans/operands.js +40 -0
  535. package/dist/interactions/actions/booleans/operands.js.map +1 -0
  536. package/dist/interactions/actions/booleans/pieces.js +45 -0
  537. package/dist/interactions/actions/booleans/pieces.js.map +1 -0
  538. package/dist/interactions/actions/booleans/placement.js +24 -0
  539. package/dist/interactions/actions/booleans/placement.js.map +1 -0
  540. package/dist/interactions/actions/booleans/useBooleans.js +11 -9
  541. package/dist/interactions/actions/booleans/useBooleans.js.map +1 -1
  542. package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -1
  543. package/dist/interactions/actions/{defaults/clipboard.js → clipboard/action.js} +31 -15
  544. package/dist/interactions/actions/clipboard/action.js.map +1 -0
  545. package/dist/interactions/actions/clipboard/clipboardOps.js +44 -42
  546. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
  547. package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
  548. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
  549. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
  550. package/dist/interactions/actions/clone/action.js +98 -0
  551. package/dist/interactions/actions/clone/action.js.map +1 -0
  552. package/dist/interactions/actions/clone/behaviors.js +52 -0
  553. package/dist/interactions/actions/clone/behaviors.js.map +1 -0
  554. package/dist/interactions/actions/defaultCommitAdapter.js +7 -32
  555. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
  556. package/dist/interactions/actions/defaults/anchorEditing.js +60 -84
  557. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  558. package/dist/interactions/actions/defaults/areaSelect.js +35 -38
  559. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  560. package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
  561. package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
  562. package/dist/interactions/actions/defaults/copySubtree.js +40 -0
  563. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
  564. package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
  565. package/dist/interactions/actions/defaults/delete.js.map +1 -1
  566. package/dist/interactions/actions/defaults/duplicate.js +13 -53
  567. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  568. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  569. package/dist/interactions/actions/defaults/group.js +40 -50
  570. package/dist/interactions/actions/defaults/group.js.map +1 -1
  571. package/dist/interactions/actions/defaults/icons/booleanIcons.js +24 -1
  572. package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -1
  573. package/dist/interactions/actions/defaults/icons/outlineIcons.js +39 -1
  574. package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -1
  575. package/dist/interactions/actions/defaults/ingest.js +44 -38
  576. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  577. package/dist/interactions/actions/defaults/insertPathAnchor.js +11 -12
  578. package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
  579. package/dist/interactions/actions/defaults/nudge.js +40 -69
  580. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  581. package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
  582. package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
  583. package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
  584. package/dist/interactions/actions/defaults/reorder.js +2 -0
  585. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  586. package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
  587. package/dist/interactions/actions/defaults/setFill.js +14 -8
  588. package/dist/interactions/actions/defaults/setFill.js.map +1 -1
  589. package/dist/interactions/actions/defaults/setFillOpacity.js +7 -4
  590. package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -1
  591. package/dist/interactions/actions/defaults/setStroke.js +12 -12
  592. package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
  593. package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
  594. package/dist/interactions/actions/defaults/sliceOps.js +8 -10
  595. package/dist/interactions/actions/defaults/sliceOps.js.map +1 -1
  596. package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
  597. package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
  598. package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
  599. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  600. package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
  601. package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
  602. package/dist/interactions/actions/distribute/action.js +66 -0
  603. package/dist/interactions/actions/distribute/action.js.map +1 -0
  604. package/dist/interactions/actions/distribute/distribute.js +11 -11
  605. package/dist/interactions/actions/distribute/distribute.js.map +1 -1
  606. package/dist/interactions/actions/{defaults/editAnchors.js → edit-anchors/action.js} +7 -9
  607. package/dist/interactions/actions/edit-anchors/action.js.map +1 -0
  608. package/dist/interactions/actions/edit-anchors/geometry.js +30 -27
  609. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
  610. package/dist/interactions/actions/flip/action.js +124 -0
  611. package/dist/interactions/actions/flip/action.js.map +1 -0
  612. package/dist/interactions/actions/flip/helpers.js +30 -17
  613. package/dist/interactions/actions/flip/helpers.js.map +1 -1
  614. package/dist/interactions/actions/gestureFrames.js +18 -0
  615. package/dist/interactions/actions/gestureFrames.js.map +1 -0
  616. package/dist/interactions/actions/gestureLifecycle.js +47 -20
  617. package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
  618. package/dist/interactions/actions/hitSelection.js +8 -0
  619. package/dist/interactions/actions/hitSelection.js.map +1 -0
  620. package/dist/interactions/actions/insert/action.js +72 -0
  621. package/dist/interactions/actions/insert/action.js.map +1 -0
  622. package/dist/interactions/actions/insert/commit.js +28 -0
  623. package/dist/interactions/actions/insert/commit.js.map +1 -0
  624. package/dist/interactions/actions/insert/extras.js +65 -0
  625. package/dist/interactions/actions/insert/extras.js.map +1 -0
  626. package/dist/interactions/actions/insert/frame.js +48 -0
  627. package/dist/interactions/actions/insert/frame.js.map +1 -0
  628. package/dist/interactions/actions/insert/geometry.js +35 -0
  629. package/dist/interactions/actions/insert/geometry.js.map +1 -0
  630. package/dist/interactions/actions/insert/rotateAction.js +21 -0
  631. package/dist/interactions/actions/insert/rotateAction.js.map +1 -0
  632. package/dist/interactions/actions/insert/session.js +59 -0
  633. package/dist/interactions/actions/insert/session.js.map +1 -0
  634. package/dist/interactions/actions/insert/shape.js +34 -0
  635. package/dist/interactions/actions/insert/shape.js.map +1 -0
  636. package/dist/interactions/actions/lasso-select/action.js +143 -0
  637. package/dist/interactions/actions/lasso-select/action.js.map +1 -0
  638. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
  639. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
  640. package/dist/interactions/actions/move/action.js +87 -0
  641. package/dist/interactions/actions/move/action.js.map +1 -0
  642. package/dist/interactions/actions/move/behaviors/layoutDrop.js +51 -0
  643. package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -0
  644. package/dist/interactions/actions/move/behaviors/reparentOnDrop.js +15 -0
  645. package/dist/interactions/actions/move/behaviors/reparentOnDrop.js.map +1 -0
  646. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
  647. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
  648. package/dist/interactions/actions/move/behaviors/snapToContainer.js +39 -27
  649. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  650. package/dist/interactions/actions/move/capture.js +99 -0
  651. package/dist/interactions/actions/move/capture.js.map +1 -0
  652. package/dist/interactions/actions/move/commit/index.js +41 -0
  653. package/dist/interactions/actions/move/commit/index.js.map +1 -0
  654. package/dist/interactions/actions/move/commit/layoutDrop.js +44 -0
  655. package/dist/interactions/actions/move/commit/layoutDrop.js.map +1 -0
  656. package/dist/interactions/actions/move/commit/layoutRelease.js +100 -0
  657. package/dist/interactions/actions/move/commit/layoutRelease.js.map +1 -0
  658. package/dist/interactions/actions/move/commit/rebase.js +18 -0
  659. package/dist/interactions/actions/move/commit/rebase.js.map +1 -0
  660. package/dist/interactions/actions/move/commit/reparent.js +65 -0
  661. package/dist/interactions/actions/move/commit/reparent.js.map +1 -0
  662. package/dist/interactions/actions/move/delta.js +51 -0
  663. package/dist/interactions/actions/move/delta.js.map +1 -0
  664. package/dist/interactions/actions/move/frame.js +59 -0
  665. package/dist/interactions/actions/move/frame.js.map +1 -0
  666. package/dist/interactions/actions/move/gestureAdapter.js +22 -30
  667. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
  668. package/dist/interactions/actions/move/landedDescendants.js +33 -0
  669. package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
  670. package/dist/interactions/actions/move/layout/container.js +94 -0
  671. package/dist/interactions/actions/move/layout/container.js.map +1 -0
  672. package/dist/interactions/actions/move/layout/dragged.js +58 -0
  673. package/dist/interactions/actions/move/layout/dragged.js.map +1 -0
  674. package/dist/interactions/actions/move/layout/dropPass.js +122 -0
  675. package/dist/interactions/actions/move/layout/dropPass.js.map +1 -0
  676. package/dist/interactions/actions/move/layout/exits.js +38 -0
  677. package/dist/interactions/actions/move/layout/exits.js.map +1 -0
  678. package/dist/interactions/actions/move/layout/glide.js +48 -0
  679. package/dist/interactions/actions/move/layout/glide.js.map +1 -0
  680. package/dist/interactions/actions/move/session.js +63 -0
  681. package/dist/interactions/actions/move/session.js.map +1 -0
  682. package/dist/interactions/actions/move/translate.js +61 -0
  683. package/dist/interactions/actions/move/translate.js.map +1 -0
  684. package/dist/interactions/actions/outlines/createOutlines.js +16 -63
  685. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
  686. package/dist/interactions/actions/outlines/createOutlinesAction.js +51 -0
  687. package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -0
  688. package/dist/interactions/actions/outlines/outlineStroke.js +72 -0
  689. package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -0
  690. package/dist/interactions/actions/outlines/outlineStrokeAction.js +37 -0
  691. package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -0
  692. package/dist/interactions/actions/outlines/replaceWithPaths.js +54 -0
  693. package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -0
  694. package/dist/interactions/actions/outlines/strokeRegion.js +27 -0
  695. package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -0
  696. package/dist/interactions/actions/planeInput.js.map +1 -1
  697. package/dist/interactions/actions/pointerState.js +12 -0
  698. package/dist/interactions/actions/pointerState.js.map +1 -0
  699. package/dist/interactions/actions/poseDescriptorDep.js +16 -4
  700. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
  701. package/dist/interactions/actions/poseFrame.js +25 -20
  702. package/dist/interactions/actions/poseFrame.js.map +1 -1
  703. package/dist/interactions/actions/resize/action.js +55 -0
  704. package/dist/interactions/actions/resize/action.js.map +1 -0
  705. package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -1
  706. package/dist/interactions/actions/resize/boxFrame.js +16 -0
  707. package/dist/interactions/actions/resize/boxFrame.js.map +1 -0
  708. package/dist/interactions/actions/resize/capture.js +85 -0
  709. package/dist/interactions/actions/resize/capture.js.map +1 -0
  710. package/dist/interactions/actions/resize/commit.js +69 -0
  711. package/dist/interactions/actions/resize/commit.js.map +1 -0
  712. package/dist/interactions/actions/resize/frame.js +74 -0
  713. package/dist/interactions/actions/resize/frame.js.map +1 -0
  714. package/dist/interactions/actions/resize/pointSnap.js +111 -0
  715. package/dist/interactions/actions/resize/pointSnap.js.map +1 -0
  716. package/dist/interactions/actions/resize/ruleBounds.js +9 -0
  717. package/dist/interactions/actions/resize/ruleBounds.js.map +1 -0
  718. package/dist/interactions/actions/resize/session.js +49 -0
  719. package/dist/interactions/actions/resize/session.js.map +1 -0
  720. package/dist/interactions/actions/resolveOverlays.js.map +1 -1
  721. package/dist/interactions/actions/resolvePreviews.js.map +1 -1
  722. package/dist/interactions/actions/rotate/action.js +56 -0
  723. package/dist/interactions/actions/rotate/action.js.map +1 -0
  724. package/dist/interactions/actions/rotate/behaviors/index.js +7 -0
  725. package/dist/interactions/actions/rotate/behaviors/index.js.map +1 -0
  726. package/dist/interactions/actions/rotate/behaviors/snapRotation.js +12 -0
  727. package/dist/interactions/actions/rotate/behaviors/snapRotation.js.map +1 -0
  728. package/dist/interactions/actions/rotate/commit.js +40 -0
  729. package/dist/interactions/actions/rotate/commit.js.map +1 -0
  730. package/dist/interactions/actions/rotate/frame.js +65 -0
  731. package/dist/interactions/actions/rotate/frame.js.map +1 -0
  732. package/dist/interactions/actions/rotate/handle.js +12 -12
  733. package/dist/interactions/actions/rotate/handle.js.map +1 -1
  734. package/dist/interactions/actions/rotate/session.js +92 -0
  735. package/dist/interactions/actions/rotate/session.js.map +1 -0
  736. package/dist/interactions/actions/selectionSubtree.js +69 -0
  737. package/dist/interactions/actions/selectionSubtree.js.map +1 -0
  738. package/dist/interactions/actions/spatialReference.js.map +1 -1
  739. package/dist/interactions/actions/useStandardActions.js +87 -78
  740. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  741. package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
  742. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
  743. package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
  744. package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
  745. package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
  746. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
  747. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +62 -41
  748. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
  749. package/dist/interactions/gestures/shared/originProjection.js +1 -1
  750. package/dist/interactions/gestures/shared/originProjection.js.map +1 -1
  751. package/dist/interactions/gestures/shared/screenTolerance.js +8 -2
  752. package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
  753. package/dist/interactions/gestures/shared/snap.js.map +1 -1
  754. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
  755. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
  756. package/dist/layout/arrivals.js +20 -23
  757. package/dist/layout/arrivals.js.map +1 -1
  758. package/dist/math-CYUjoyyU.d.ts +33 -0
  759. package/dist/math.d.ts +5 -3
  760. package/dist/math.js +6 -6
  761. package/dist/mesh.d.ts +4 -268
  762. package/dist/mesh.js +3 -7
  763. package/dist/move.d.ts +14 -11
  764. package/dist/{originProjection-DEklpDc_.d.ts → originProjection-PPT88jZv.d.ts} +1 -1
  765. package/dist/patterns-builtin.d.ts +1 -118
  766. package/dist/patterns-builtin.js +2 -3
  767. package/dist/{poseDescriptor-D-OH-tu5.d.ts → poseDescriptor-Bqk-11Rl.d.ts} +26 -36
  768. package/dist/renderer.d.ts +1 -91
  769. package/dist/renderer.js +2 -18
  770. package/dist/resize.d.ts +10 -22
  771. package/dist/resize.js +6 -6
  772. package/dist/style.css +1 -1
  773. package/dist/test-hook/install.js +12 -6
  774. package/dist/test-hook/install.js.map +1 -1
  775. package/dist/test-hook/useTestHook.js +22 -0
  776. package/dist/test-hook/useTestHook.js.map +1 -0
  777. package/dist/test-seams-D0pyV3pR.d.ts +149 -0
  778. package/dist/test-seams.d.ts +4 -4
  779. package/dist/test-seams.js +2 -2
  780. package/dist/tools/builtin/bone/boneActions.js +130 -0
  781. package/dist/tools/builtin/bone/boneActions.js.map +1 -0
  782. package/dist/tools/builtin/bone/boneOverlay.js +58 -0
  783. package/dist/tools/builtin/bone/boneOverlay.js.map +1 -0
  784. package/dist/tools/builtin/bone/placedRig.js +24 -0
  785. package/dist/tools/builtin/bone/placedRig.js.map +1 -0
  786. package/dist/tools/builtin/bone/rigEditState.js +21 -0
  787. package/dist/tools/builtin/bone/rigEditState.js.map +1 -0
  788. package/dist/tools/builtin/bone/useBoneTool.js +98 -0
  789. package/dist/tools/builtin/bone/useBoneTool.js.map +1 -0
  790. package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
  791. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  792. package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
  793. package/dist/tools/builtin/hand/useHandTool.js +1 -0
  794. package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
  795. package/dist/tools/builtin/image/useImageTool.js.map +1 -1
  796. package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
  797. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
  798. package/dist/tools/builtin/line/useLineTool.js +1 -0
  799. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  800. package/dist/tools/builtin/pen/usePenTool.js +198 -150
  801. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  802. package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
  803. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
  804. package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
  805. package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
  806. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  807. package/dist/tools/builtin/rect/useRectTool.js +1 -0
  808. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  809. package/dist/tools/builtin/select/adapterPointQuery.js +36 -0
  810. package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -0
  811. package/dist/tools/builtin/select/selectionContributions.js +25 -24
  812. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  813. package/dist/tools/builtin/select/useSelectTool.js +42 -67
  814. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  815. package/dist/tools/builtin/shared/pointerFollower.js +17 -0
  816. package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
  817. package/dist/tools/builtin/slice/useSliceTool.js +72 -82
  818. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  819. package/dist/tools/builtin/star/useStarTool.js +22 -16
  820. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  821. package/dist/tools/builtin/text/useTextTool.js +9 -0
  822. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  823. package/dist/tools/builtin/weight/useWeightTool.js +77 -0
  824. package/dist/tools/builtin/weight/useWeightTool.js.map +1 -0
  825. package/dist/tools/builtin/weight/weightActions.js +112 -0
  826. package/dist/tools/builtin/weight/weightActions.js.map +1 -0
  827. package/dist/tools/builtin/weight/weightOverlay.js +61 -0
  828. package/dist/tools/builtin/weight/weightOverlay.js.map +1 -0
  829. package/dist/tools/overlayBinding.js.map +1 -1
  830. package/dist/tools/useKeybindings.js +12 -22
  831. package/dist/tools/useKeybindings.js.map +1 -1
  832. package/dist/{types-A37hYkeR.d.ts → types-CIKDwlsP.d.ts} +113 -169
  833. package/dist/util/color.js +3 -3
  834. package/dist/util/color.js.map +1 -1
  835. package/dist/util/paint.js +1 -1
  836. package/dist/util/paint.js.map +1 -1
  837. package/dist/version.js +1 -1
  838. package/package.json +28 -21
  839. package/dist/animation/colorHelpers.js +0 -135
  840. package/dist/animation/colorHelpers.js.map +0 -1
  841. package/dist/animation/colorRegistry.js +0 -37
  842. package/dist/animation/colorRegistry.js.map +0 -1
  843. package/dist/animation/engine/axes.js +0 -36
  844. package/dist/animation/engine/axes.js.map +0 -1
  845. package/dist/animation/engine/codec.js +0 -170
  846. package/dist/animation/engine/codec.js.map +0 -1
  847. package/dist/animation/engine/integrator.js +0 -12
  848. package/dist/animation/engine/integrator.js.map +0 -1
  849. package/dist/animation/loop.js +0 -62
  850. package/dist/animation/loop.js.map +0 -1
  851. package/dist/animation/observe.js +0 -23
  852. package/dist/animation/observe.js.map +0 -1
  853. package/dist/animation/rig/blendPoses.js +0 -43
  854. package/dist/animation/rig/blendPoses.js.map +0 -1
  855. package/dist/animation/rig/mirrorPose.js +0 -19
  856. package/dist/animation/rig/mirrorPose.js.map +0 -1
  857. package/dist/animation/rig/resolveSkeleton.js +0 -33
  858. package/dist/animation/rig/resolveSkeleton.js.map +0 -1
  859. package/dist/animation/rig/solveIk.js +0 -103
  860. package/dist/animation/rig/solveIk.js.map +0 -1
  861. package/dist/animation/rig/types.js +0 -12
  862. package/dist/animation/rig/types.js.map +0 -1
  863. package/dist/animation/slew.js +0 -27
  864. package/dist/animation/slew.js.map +0 -1
  865. package/dist/animation/stagger.js +0 -138
  866. package/dist/animation/stagger.js.map +0 -1
  867. package/dist/animation/timeline/booking.js +0 -106
  868. package/dist/animation/timeline/booking.js.map +0 -1
  869. package/dist/animation/timeline/createTimeline.js +0 -116
  870. package/dist/animation/timeline/createTimeline.js.map +0 -1
  871. package/dist/animation/timeline/sampleTrack.js +0 -71
  872. package/dist/animation/timeline/sampleTrack.js.map +0 -1
  873. package/dist/animation/useAnimator.js +0 -378
  874. package/dist/animation/useAnimator.js.map +0 -1
  875. package/dist/builtins-C-VgUlWI.d.ts +0 -4514
  876. package/dist/canvas/MinimapCanvas.js +0 -139
  877. package/dist/canvas/MinimapCanvas.js.map +0 -1
  878. package/dist/canvas/deps/poseComposition.js +0 -11
  879. package/dist/canvas/deps/poseComposition.js.map +0 -1
  880. package/dist/canvas/minimapMath.js +0 -80
  881. package/dist/canvas/minimapMath.js.map +0 -1
  882. package/dist/canvas/toolPreview.js +0 -39
  883. package/dist/canvas/toolPreview.js.map +0 -1
  884. package/dist/core/adapters/arrayAdapter.js +0 -85
  885. package/dist/core/adapters/arrayAdapter.js.map +0 -1
  886. package/dist/core/adapters/useArrayAdapter.js +0 -13
  887. package/dist/core/adapters/useArrayAdapter.js.map +0 -1
  888. package/dist/core/fillInPoseFrame.js +0 -102
  889. package/dist/core/fillInPoseFrame.js.map +0 -1
  890. package/dist/core/geometry/poseRotation.js +0 -58
  891. package/dist/core/geometry/poseRotation.js.map +0 -1
  892. package/dist/core/gradient.js +0 -136
  893. package/dist/core/gradient.js.map +0 -1
  894. package/dist/core/isPlainObject.js.map +0 -1
  895. package/dist/core/markerInset.js +0 -24
  896. package/dist/core/markerInset.js.map +0 -1
  897. package/dist/core/mixed.js +0 -6
  898. package/dist/core/mixed.js.map +0 -1
  899. package/dist/core/paintKinds.js +0 -156
  900. package/dist/core/paintKinds.js.map +0 -1
  901. package/dist/core/strokeMarkerShapes.js +0 -139
  902. package/dist/core/strokeMarkerShapes.js.map +0 -1
  903. package/dist/core/strokeMarkers.js +0 -28
  904. package/dist/core/strokeMarkers.js.map +0 -1
  905. package/dist/core/viewport/meanScale.js +0 -8
  906. package/dist/core/viewport/meanScale.js.map +0 -1
  907. package/dist/core/viewport/pxExtent.js +0 -42
  908. package/dist/core/viewport/pxExtent.js.map +0 -1
  909. package/dist/debug/flag.js.map +0 -1
  910. package/dist/features/cursor/paintedCursorLayer.js.map +0 -1
  911. package/dist/features/focus/gateLayer.js +0 -14
  912. package/dist/features/focus/gateLayer.js.map +0 -1
  913. package/dist/features/focus/useCanvasFocus.js +0 -29
  914. package/dist/features/focus/useCanvasFocus.js.map +0 -1
  915. package/dist/features/groups/children.js.map +0 -1
  916. package/dist/features/groups/composePose.js.map +0 -1
  917. package/dist/features/groups/nestedHit.js.map +0 -1
  918. package/dist/features/groups/unionOfChildren.js.map +0 -1
  919. package/dist/features/images/imageCache.js +0 -94
  920. package/dist/features/images/imageCache.js.map +0 -1
  921. package/dist/features/ingestion/index.js +0 -8
  922. package/dist/features/meshPaint/bake.js +0 -79
  923. package/dist/features/meshPaint/bake.js.map +0 -1
  924. package/dist/features/meshPaint/bakeCache.js +0 -59
  925. package/dist/features/meshPaint/bakeCache.js.map +0 -1
  926. package/dist/features/meshPaint/handles.js +0 -86
  927. package/dist/features/meshPaint/handles.js.map +0 -1
  928. package/dist/features/meshPaint/lazyKind.js.map +0 -1
  929. package/dist/features/meshPaint/meshPaint.js +0 -236
  930. package/dist/features/meshPaint/meshPaint.js.map +0 -1
  931. package/dist/features/meshPaint/meshShader.js +0 -6
  932. package/dist/features/meshPaint/meshShader.js.map +0 -1
  933. package/dist/features/meshPaint/register.js +0 -7
  934. package/dist/features/meshPaint/register.js.map +0 -1
  935. package/dist/features/meshPaint/surface.js +0 -110
  936. package/dist/features/meshPaint/surface.js.map +0 -1
  937. package/dist/features/minimap/actions.js +0 -53
  938. package/dist/features/minimap/actions.js.map +0 -1
  939. package/dist/features/minimap/createMinimapContribution.js +0 -96
  940. package/dist/features/minimap/createMinimapContribution.js.map +0 -1
  941. package/dist/features/minimap/layers.js +0 -103
  942. package/dist/features/minimap/layers.js.map +0 -1
  943. package/dist/features/overlays/useNodeOverlayFrame.js +0 -103
  944. package/dist/features/overlays/useNodeOverlayFrame.js.map +0 -1
  945. package/dist/features/parallax/createParallaxLayer.js +0 -26
  946. package/dist/features/parallax/createParallaxLayer.js.map +0 -1
  947. package/dist/features/parallax/createParallaxPlane.js +0 -26
  948. package/dist/features/parallax/createParallaxPlane.js.map +0 -1
  949. package/dist/features/paths/anchorEdits.js +0 -156
  950. package/dist/features/paths/anchorEdits.js.map +0 -1
  951. package/dist/features/paths/anchors.js +0 -154
  952. package/dist/features/paths/anchors.js.map +0 -1
  953. package/dist/features/paths/booleans.js +0 -2
  954. package/dist/features/paths/markerCommands.js +0 -148
  955. package/dist/features/paths/markerCommands.js.map +0 -1
  956. package/dist/features/paths/markerSites.js +0 -59
  957. package/dist/features/paths/markerSites.js.map +0 -1
  958. package/dist/features/paths/markers.js +0 -95
  959. package/dist/features/paths/markers.js.map +0 -1
  960. package/dist/features/paths/nearestAnchor.js +0 -36
  961. package/dist/features/paths/nearestAnchor.js.map +0 -1
  962. package/dist/features/paths/pathInWorld.js +0 -41
  963. package/dist/features/paths/pathInWorld.js.map +0 -1
  964. package/dist/features/paths/poseDescriptor.js +0 -39
  965. package/dist/features/paths/poseDescriptor.js.map +0 -1
  966. package/dist/features/paths/tessellate/dash.js +0 -52
  967. package/dist/features/paths/tessellate/dash.js.map +0 -1
  968. package/dist/features/paths/tessellate/insets.js +0 -32
  969. package/dist/features/paths/tessellate/insets.js.map +0 -1
  970. package/dist/features/paths/tessellate/metric.js +0 -72
  971. package/dist/features/paths/tessellate/metric.js.map +0 -1
  972. package/dist/features/paths/tessellate/stroke.js +0 -170
  973. package/dist/features/paths/tessellate/stroke.js.map +0 -1
  974. package/dist/features/paths/tessellate/vertexWidths.js +0 -32
  975. package/dist/features/paths/tessellate/vertexWidths.js.map +0 -1
  976. package/dist/features/patterns/index.js +0 -23
  977. package/dist/features/patterns/index.js.map +0 -1
  978. package/dist/features/patterns/patterns-builtin.js +0 -38
  979. package/dist/features/patterns/patterns-builtin.js.map +0 -1
  980. package/dist/features/patterns/resolveSpec.js +0 -57
  981. package/dist/features/patterns/resolveSpec.js.map +0 -1
  982. package/dist/features/patterns/tileGeometry.js +0 -158
  983. package/dist/features/patterns/tileGeometry.js.map +0 -1
  984. package/dist/features/pointer/PointerContext.js +0 -45
  985. package/dist/features/pointer/PointerContext.js.map +0 -1
  986. package/dist/features/selection/SelectionContext.js +0 -46
  987. package/dist/features/selection/SelectionContext.js.map +0 -1
  988. package/dist/features/simulation/createSimulation.js +0 -61
  989. package/dist/features/simulation/createSimulation.js.map +0 -1
  990. package/dist/features/simulation/types.js +0 -6
  991. package/dist/features/simulation/types.js.map +0 -1
  992. package/dist/features/simulation/useSimulation.js +0 -74
  993. package/dist/features/simulation/useSimulation.js.map +0 -1
  994. package/dist/features/text/domRuns.js +0 -258
  995. package/dist/features/text/domRuns.js.map +0 -1
  996. package/dist/features/text/fitTextPose.js +0 -38
  997. package/dist/features/text/fitTextPose.js.map +0 -1
  998. package/dist/features/text/hitTest.js +0 -45
  999. package/dist/features/text/hitTest.js.map +0 -1
  1000. package/dist/features/text/renderLabel.js +0 -14
  1001. package/dist/features/text/renderLabel.js.map +0 -1
  1002. package/dist/features/text/runs/effectiveRangeStyle.js +0 -66
  1003. package/dist/features/text/runs/effectiveRangeStyle.js.map +0 -1
  1004. package/dist/features/text/runs/flagRange.js +0 -53
  1005. package/dist/features/text/runs/flagRange.js.map +0 -1
  1006. package/dist/features/text/runs/rangeStyle.js +0 -135
  1007. package/dist/features/text/runs/rangeStyle.js.map +0 -1
  1008. package/dist/features/text/textCommand.js +0 -59
  1009. package/dist/features/text/textCommand.js.map +0 -1
  1010. package/dist/features/text/textToPath.js +0 -181
  1011. package/dist/features/text/textToPath.js.map +0 -1
  1012. package/dist/features/text/useTextEdit.js +0 -467
  1013. package/dist/features/text/useTextEdit.js.map +0 -1
  1014. package/dist/features/tiling/createTiledLayer.js +0 -63
  1015. package/dist/features/tiling/createTiledLayer.js.map +0 -1
  1016. package/dist/features/tiling/tiledProject.js +0 -14
  1017. package/dist/features/tiling/tiledProject.js.map +0 -1
  1018. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +0 -26
  1019. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +0 -1
  1020. package/dist/interactions/actions/defaults/align.js.map +0 -1
  1021. package/dist/interactions/actions/defaults/booleans.js +0 -52
  1022. package/dist/interactions/actions/defaults/booleans.js.map +0 -1
  1023. package/dist/interactions/actions/defaults/clipboard.js.map +0 -1
  1024. package/dist/interactions/actions/defaults/clone.js +0 -107
  1025. package/dist/interactions/actions/defaults/clone.js.map +0 -1
  1026. package/dist/interactions/actions/defaults/createOutlines.js +0 -47
  1027. package/dist/interactions/actions/defaults/createOutlines.js.map +0 -1
  1028. package/dist/interactions/actions/defaults/distribute.js +0 -66
  1029. package/dist/interactions/actions/defaults/distribute.js.map +0 -1
  1030. package/dist/interactions/actions/defaults/editAnchors.js.map +0 -1
  1031. package/dist/interactions/actions/defaults/flip.js +0 -119
  1032. package/dist/interactions/actions/defaults/flip.js.map +0 -1
  1033. package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
  1034. package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
  1035. package/dist/interactions/actions/defaults/insert.js +0 -288
  1036. package/dist/interactions/actions/defaults/insert.js.map +0 -1
  1037. package/dist/interactions/actions/defaults/lassoSelect.js +0 -156
  1038. package/dist/interactions/actions/defaults/lassoSelect.js.map +0 -1
  1039. package/dist/interactions/actions/defaults/move.js +0 -760
  1040. package/dist/interactions/actions/defaults/move.js.map +0 -1
  1041. package/dist/interactions/actions/defaults/resize.js +0 -335
  1042. package/dist/interactions/actions/defaults/resize.js.map +0 -1
  1043. package/dist/interactions/actions/defaults/rotate.js +0 -184
  1044. package/dist/interactions/actions/defaults/rotate.js.map +0 -1
  1045. package/dist/interactions/actions/previewOverrides.js +0 -25
  1046. package/dist/interactions/actions/previewOverrides.js.map +0 -1
  1047. package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +0 -1
  1048. package/dist/math-Drrw4ewZ.d.ts +0 -160
  1049. package/dist/registerProgram-BMZRDgrh.d.ts +0 -197
  1050. package/dist/renderer/DrawCommand.js +0 -6
  1051. package/dist/renderer/DrawCommand.js.map +0 -1
  1052. package/dist/renderer/WeaselRenderer.js +0 -331
  1053. package/dist/renderer/WeaselRenderer.js.map +0 -1
  1054. package/dist/renderer/batchClip.js +0 -46
  1055. package/dist/renderer/batchClip.js.map +0 -1
  1056. package/dist/renderer/cache/GLImageCache.js +0 -64
  1057. package/dist/renderer/cache/GLImageCache.js.map +0 -1
  1058. package/dist/renderer/cache/GLMeshCache.js +0 -102
  1059. package/dist/renderer/cache/GLMeshCache.js.map +0 -1
  1060. package/dist/renderer/cache/GLTextureCache.js +0 -51
  1061. package/dist/renderer/cache/GLTextureCache.js.map +0 -1
  1062. package/dist/renderer/cache/GradientRampAtlas.js +0 -82
  1063. package/dist/renderer/cache/GradientRampAtlas.js.map +0 -1
  1064. package/dist/renderer/cache/cache.js +0 -13
  1065. package/dist/renderer/cache/cache.js.map +0 -1
  1066. package/dist/renderer/cache/markerCommandCache.js +0 -63
  1067. package/dist/renderer/cache/markerCommandCache.js.map +0 -1
  1068. package/dist/renderer/cache/outlineMeshCache.js +0 -15
  1069. package/dist/renderer/cache/outlineMeshCache.js.map +0 -1
  1070. package/dist/renderer/cache/outlineStrokeMeshCache.js +0 -36
  1071. package/dist/renderer/cache/outlineStrokeMeshCache.js.map +0 -1
  1072. package/dist/renderer/cache/strokeMeshCache.js +0 -55
  1073. package/dist/renderer/cache/strokeMeshCache.js.map +0 -1
  1074. package/dist/renderer/cullDrawCommands.js +0 -90
  1075. package/dist/renderer/cullDrawCommands.js.map +0 -1
  1076. package/dist/renderer/draw.js +0 -1135
  1077. package/dist/renderer/draw.js.map +0 -1
  1078. package/dist/renderer/drawBatch.js +0 -198
  1079. package/dist/renderer/drawBatch.js.map +0 -1
  1080. package/dist/renderer/effects/EffectTargets.js +0 -45
  1081. package/dist/renderer/effects/EffectTargets.js.map +0 -1
  1082. package/dist/renderer/effects/builtins.js +0 -31
  1083. package/dist/renderer/effects/builtins.js.map +0 -1
  1084. package/dist/renderer/effects/composite.js +0 -9
  1085. package/dist/renderer/effects/composite.js.map +0 -1
  1086. package/dist/renderer/effects/effectPrelude.js +0 -10
  1087. package/dist/renderer/effects/effectPrelude.js.map +0 -1
  1088. package/dist/renderer/effects/types.js +0 -10
  1089. package/dist/renderer/effects/types.js.map +0 -1
  1090. package/dist/renderer/glyphOutlineMesh.js +0 -67
  1091. package/dist/renderer/glyphOutlineMesh.js.map +0 -1
  1092. package/dist/renderer/index.js +0 -19
  1093. package/dist/renderer/math/color.js +0 -341
  1094. package/dist/renderer/math/color.js.map +0 -1
  1095. package/dist/renderer/math/mat3.js +0 -76
  1096. package/dist/renderer/math/mat3.js.map +0 -1
  1097. package/dist/renderer/math/patternSpace.js +0 -22
  1098. package/dist/renderer/math/patternSpace.js.map +0 -1
  1099. package/dist/renderer/math/viewToMat3.js +0 -19
  1100. package/dist/renderer/math/viewToMat3.js.map +0 -1
  1101. package/dist/renderer/paintResources.js +0 -18
  1102. package/dist/renderer/paintResources.js.map +0 -1
  1103. package/dist/renderer/paintScratch.js +0 -37
  1104. package/dist/renderer/paintScratch.js.map +0 -1
  1105. package/dist/renderer/shaders/ShaderProgram.js +0 -74
  1106. package/dist/renderer/shaders/ShaderProgram.js.map +0 -1
  1107. package/dist/renderer/shaders/batchFill.js +0 -119
  1108. package/dist/renderer/shaders/batchFill.js.map +0 -1
  1109. package/dist/renderer/shaders/customPrelude.js +0 -34
  1110. package/dist/renderer/shaders/customPrelude.js.map +0 -1
  1111. package/dist/renderer/shaders/extractUniformNames.js +0 -184
  1112. package/dist/renderer/shaders/extractUniformNames.js.map +0 -1
  1113. package/dist/renderer/shaders/glyphPaint.js +0 -61
  1114. package/dist/renderer/shaders/glyphPaint.js.map +0 -1
  1115. package/dist/renderer/shaders/gradFill.js +0 -30
  1116. package/dist/renderer/shaders/gradFill.js.map +0 -1
  1117. package/dist/renderer/shaders/imageFill.js +0 -14
  1118. package/dist/renderer/shaders/imageFill.js.map +0 -1
  1119. package/dist/renderer/shaders/pathFill.js +0 -13
  1120. package/dist/renderer/shaders/pathFill.js.map +0 -1
  1121. package/dist/renderer/shaders/patternFill.js +0 -24
  1122. package/dist/renderer/shaders/patternFill.js.map +0 -1
  1123. package/dist/renderer/shaders/registerProgram.js +0 -18
  1124. package/dist/renderer/shaders/registerProgram.js.map +0 -1
  1125. package/dist/renderer/spriteSheet.js +0 -14
  1126. package/dist/renderer/spriteSheet.js.map +0 -1
  1127. package/dist/renderer/state/GroupState.js +0 -77
  1128. package/dist/renderer/state/GroupState.js.map +0 -1
  1129. package/dist/renderer/strokeLengths.js +0 -50
  1130. package/dist/renderer/strokeLengths.js.map +0 -1
  1131. package/dist/renderer/syntheticItalic.js +0 -6
  1132. package/dist/renderer/syntheticItalic.js.map +0 -1
  1133. package/dist/renderer/textures/registerTexture.js +0 -14
  1134. package/dist/renderer/textures/registerTexture.js.map +0 -1
  1135. package/dist/scheduling/useVisibleRaf.js +0 -69
  1136. package/dist/scheduling/useVisibleRaf.js.map +0 -1
  1137. package/dist/test-seams-CuIxe0xY.d.ts +0 -356
  1138. package/dist/tools/prefs.js +0 -62
  1139. package/dist/tools/prefs.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"WeaselRenderer.js","names":["customUniformNames","CUSTOM_KIT_UNIFORMS","extractUniformNames","vertSrc","fragSrc","compileCustomProgram","src","CUSTOM_VERT_SRC","program","ShaderProgram","gl","extractUniformArrays","CUSTOM_ATTRIBUTES","now","GLYPH_PAINT_SOURCES","GLYPH_PATTERN_FRAG_SRC","GLYPH_PATTERN_UNIFORMS","GLYPH_GRAD_FRAG_SRC","GLYPH_GRAD_UNIFORMS","GLYPH_TEXTURE_FRAG_SRC","GLYPH_TEXTURE_UNIFORMS","WeaselRenderer","GroupState","createPaintResources","opts","EffectTargets","PaintScratch","attrs","DEFAULT_BAKE_BUDGET","OUTLINE_MIN_SCREEN_PX","VERT_SRC","FRAG_SRC","PATH_FILL_UNIFORMS","PATH_FILL_ATTRIBUTES","VCOLOR_VERT_SRC","VCOLOR_FRAG_SRC","PATH_FILL_VCOLOR_ATTRIBUTES","IMAGE_VERT_SRC","IMAGE_FRAG_SRC","IMAGE_FILL_UNIFORMS","IMAGE_FILL_ATTRIBUTES","BATCH_VERT_SRC","BATCH_FRAG_SRC","BATCH_FILL_UNIFORMS","BATCH_FILL_ATTRIBUTES","GRAD_VERT_SRC","GRAD_FRAG_SRC","GRAD_FILL_UNIFORMS","GRAD_FILL_ATTRIBUTES","PATTERN_VERT_SRC","PATTERN_FRAG_SRC","PATTERN_FILL_UNIFORMS","PATTERN_FILL_ATTRIBUTES","aPos","GLMeshCache","GLTextureCache","GLImageCache","GradientRampAtlas","DrawBatch","createWhiteTexture","QUAD_VERTICES","QUAD_INDICES","getProgramSource","handle","previous","id","compiled","e","existing","kind","frag","uniforms","GLYPH_PAINT_VERT_SRC","GLYPH_PAINT_ATTRIBUTES","w","h","x","y","target","markAllFontsNotUploaded","prog","t0","counters","spanStats","resetBakeBudget","ctx","spans","next","si","span","commands","drawsBefore","spanT0","flushBatch","tolerance","dims","tex"],"sources":["../../src/renderer/WeaselRenderer.ts"],"sourcesContent":["import { createPaintResources, type OwnedPaintResources } from './paintResources';\nimport { ShaderProgram } from './shaders/ShaderProgram';\nimport {\n VERT_SRC,\n FRAG_SRC,\n VCOLOR_VERT_SRC,\n VCOLOR_FRAG_SRC,\n PATH_FILL_UNIFORMS,\n PATH_FILL_ATTRIBUTES,\n PATH_FILL_VCOLOR_ATTRIBUTES,\n} from './shaders/pathFill';\nimport {\n markAllFontsNotUploaded,\n resetBakeBudget,\n DEFAULT_BAKE_BUDGET,\n} from '@weasel-js/font';\nimport {\n IMAGE_VERT_SRC,\n IMAGE_FRAG_SRC,\n IMAGE_FILL_UNIFORMS,\n IMAGE_FILL_ATTRIBUTES,\n} from './shaders/imageFill';\nimport {\n BATCH_VERT_SRC,\n BATCH_FRAG_SRC,\n BATCH_FILL_UNIFORMS,\n BATCH_FILL_ATTRIBUTES,\n} from './shaders/batchFill';\nimport {\n GRAD_VERT_SRC,\n GRAD_FRAG_SRC,\n GRAD_FILL_UNIFORMS,\n GRAD_FILL_ATTRIBUTES,\n} from './shaders/gradFill';\nimport {\n PATTERN_VERT_SRC,\n PATTERN_FRAG_SRC,\n PATTERN_FILL_UNIFORMS,\n PATTERN_FILL_ATTRIBUTES,\n} from './shaders/patternFill';\nimport {\n GLYPH_PAINT_VERT_SRC,\n GLYPH_PATTERN_FRAG_SRC,\n GLYPH_GRAD_FRAG_SRC,\n GLYPH_TEXTURE_FRAG_SRC,\n GLYPH_PATTERN_UNIFORMS,\n GLYPH_GRAD_UNIFORMS,\n GLYPH_TEXTURE_UNIFORMS,\n GLYPH_PAINT_ATTRIBUTES,\n} from './shaders/glyphPaint';\nimport { PaintScratch } from './paintScratch';\nimport { GLMeshCache } from './cache/GLMeshCache';\nimport { GLTextureCache } from './cache/GLTextureCache';\nimport { GLImageCache, type ImageMinification } from './cache/GLImageCache';\nimport { GradientRampAtlas } from './cache/GradientRampAtlas';\nimport { GroupState } from './state/GroupState';\nimport type { DrawCommand } from './DrawCommand';\nimport type { GlMat3 } from './math/mat3';\nimport {\n dispatch, flushBatch, OUTLINE_MIN_SCREEN_PX, type DrawContext, type GlyphPaintKind,\n} from './draw';\nimport { DrawBatch } from './drawBatch';\nimport {\n CUSTOM_VERT_SRC, CUSTOM_ATTRIBUTES, CUSTOM_KIT_UNIFORMS,\n QUAD_VERTICES, QUAD_INDICES,\n} from './shaders/customPrelude';\nimport { getProgramSource, type ProgramSource, type ShaderProgramHandle } from './shaders/registerProgram';\nimport { EffectTargets } from './effects/EffectTargets';\nimport { extractUniformArrays, extractUniformNames } from './shaders/extractUniformNames';\n\n/** Every uniform a custom program may be written through. Both stages, not\n * just the fragment one: a name never looked up is written through `null`,\n * which GL accepts silently, so the uniform keeps its zero default. */\nfunction customUniformNames(vertSrc: string, fragSrc: string): string[] {\n return [...CUSTOM_KIT_UNIFORMS, ...extractUniformNames(vertSrc), ...extractUniformNames(fragSrc)];\n}\n\n/** Compile a registered program's source against `gl`, with every uniform\n * location and array base it may be written through. */\nfunction compileCustomProgram(gl: WebGL2RenderingContext, src: ProgramSource): ShaderProgram {\n const vertSrc = src.vert === '' ? CUSTOM_VERT_SRC : src.vert;\n const program = new ShaderProgram(gl, vertSrc, src.frag);\n program.lookupUniforms(customUniformNames(vertSrc, src.frag));\n program.lookupUniformArrays(new Map([...extractUniformArrays(vertSrc), ...extractUniformArrays(src.frag)]));\n program.lookupAttributes(CUSTOM_ATTRIBUTES);\n return program;\n}\n\n/** How to construct a `WeaselRenderer`: the GL context or canvas to draw\n * into, the output size, and the quality knobs that separate screen\n * rendering from print. */\n/** A run of top-level commands, `[start, end)` by index, that\n * {@link WeaselRenderer.lastFrameStats} accounts for separately — one render\n * layer's commands, say. Spans are in order and do not overlap. */\nexport interface RenderSpan {\n id: string;\n start: number;\n end: number;\n}\n\n/** Per-frame options for {@link WeaselRenderer.render}. */\nexport interface RenderOptions {\n spans?: readonly RenderSpan[];\n}\n\n/** What one span cost. A batched run is drawn when something closes it, so\n * its draw call counts toward the span that closed it. */\nexport interface RenderSpanStats {\n id: string;\n drawCalls: number;\n ms: number;\n}\n\n/** What one `render()` cost. See {@link WeaselRenderer.lastFrameStats}. */\nexport interface RenderStats {\n drawCalls: number;\n ms: number;\n spans: RenderSpanStats[];\n}\n\nfunction now(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/** Construction options for {@link WeaselRenderer}. Pass `gl` or `canvas`;\n * a context passed in must have a stencil buffer. */\nexport interface WeaselRendererOptions {\n /** A WebGL2 context to draw with. Wins over `canvas`. */\n gl?: WebGL2RenderingContext;\n /** A canvas to open a stencil-backed WebGL2 context on, when `gl` is absent. */\n canvas?: HTMLCanvasElement;\n /** Drawing size in CSS pixels. */\n width: number;\n /** Drawing size in CSS pixels. */\n height: number;\n /** Device pixels per CSS pixel. */\n dpr: number;\n /** MIN_FILTER strategy for image/pattern textures (`GLImageCache`).\n * Default `'linear'` — the existing screen behavior. The headless\n * `renderSceneToPixels` path passes `'mipmap'` for print-quality\n * minification. Explicitly passing `'linear'` is always valid. */\n imageMinification?: ImageMinification;\n /** Flatness tolerance for curve tessellation, in WORLD units (see\n * `TessellateOptions.flattenTolerance`). When set, path fills are\n * tessellated fresh at this tolerance per frame (transient pool) instead\n * of served from the Path-identity mesh cache — the cache key does not\n * include tolerance. Default: unset — the existing cached behavior at\n * `DEFAULT_FLATTEN_TOLERANCE`. The headless path derives this from the\n * requested output scale; screen callers normally leave it unset. */\n flattenTolerance?: number;\n /** Per-render synchronous bake budget for dynamic canvas-SDF glyphs.\n * Default DEFAULT_BAKE_BUDGET (16). The headless renderSceneToPixels\n * path passes Infinity so print never defers a glyph. */\n bakeBudget?: number;\n /** On-screen glyph size, in CSS pixels, at or above which text renders from\n * tessellated font outlines instead of a distance field — see\n * `OUTLINE_MIN_SCREEN_PX`. Only faces registered with\n * `registerFontOutlines` are affected; everything else keeps its SDF tier\n * whatever this says. Pass `Infinity` to disable the tier outright, or 0\n * to use outlines wherever they exist (what the headless path does, since\n * print has no reason to sample a field it could evaluate exactly). */\n textOutlineMinScreenSize?: number;\n}\n\n/** Where a renderer draws inside a buffer it does not own.\n *\n * The rect's SIZE is the renderer's own `width`/`height` — `resize()` owns\n * that, and a second copy here could disagree with the one `DrawContext`\n * reports to screen-space layers. */\nexport interface RenderTarget {\n /** Top-left of this renderer's output within the drawing buffer, in CSS\n * pixels, with the origin at the buffer's top-left. GL's bottom-left origin\n * is handled internally. */\n origin: { x: number; y: number };\n /** Clear colour and stencil within the rect before drawing. Default true.\n * Pass false only when the caller clears the whole buffer itself on behalf\n * of every co-tenant — a frame that clears neither inherits its neighbour's\n * stencil bits, and even-odd fills then fill their holes. */\n clear?: boolean;\n}\n\n/** Each glyph-paint program's fragment stage and the uniforms it looks up. */\nconst GLYPH_PAINT_SOURCES: Record<GlyphPaintKind, readonly [string, readonly string[]]> = {\n pattern: [GLYPH_PATTERN_FRAG_SRC, GLYPH_PATTERN_UNIFORMS],\n gradient: [GLYPH_GRAD_FRAG_SRC, GLYPH_GRAD_UNIFORMS],\n texture: [GLYPH_TEXTURE_FRAG_SRC, GLYPH_TEXTURE_UNIFORMS],\n};\n\n/**\n * The WebGL2 renderer: takes a list of draw commands and paints them.\n *\n * It knows nothing about the scene — commands are the whole interface, which\n * is what lets layers, HUD widgets and overlays all draw through the same\n * pipeline. GPU resources (meshes, textures, gradient ramps) are cached across\n * frames and keyed by identity, so re-issuing the same command is cheap.\n */\nexport class WeaselRenderer {\n private readonly gl: WebGL2RenderingContext;\n private stats: RenderStats = { drawCalls: 0, ms: 0, spans: [] };\n private pathFill: ShaderProgram;\n private pathFillVColor: ShaderProgram;\n private imageFill: ShaderProgram;\n private batchFill: ShaderProgram;\n private gradFill: ShaderProgram;\n private patternFill: ShaderProgram;\n /** Compiled on first use: only atlas text under a texture paint needs one. */\n private glyphPaintPrograms = new Map<GlyphPaintKind, ShaderProgram>();\n private meshCache: GLMeshCache;\n private textureCache: GLTextureCache;\n private imageCache: GLImageCache;\n private gradRamps: GradientRampAtlas;\n private programRegistry = new Map<string, ShaderProgram>();\n /** The source each compiled custom program was built from — or, after a\n * failed recompile, the source that failed, so it is not retried every frame. */\n private programSources = new Map<string, ProgramSource>();\n private quadVbo: WebGLBuffer | null = null;\n private quadIbo: WebGLBuffer | null = null;\n private drawBatch: DrawBatch;\n /** 1x1 white, so a batch flush sampling no image still samples something —\n * see `shaders/batchFill.ts`. */\n private whiteTexture: WebGLTexture | null = null;\n private readonly groupState = new GroupState();\n private widthCss: number;\n private heightCss: number;\n private dpr: number;\n private canvas: HTMLCanvasElement | null = null;\n private target: RenderTarget | null = null;\n /** Offscreen buffers for group effects. Allocates nothing until a group\n * with effects asks, so a canvas without them pays no memory. */\n private readonly effectTargets: EffectTargets;\n private readonly paintScratch: PaintScratch;\n private readonly imageMinification: ImageMinification;\n private flattenTolerance?: number;\n private readonly bakeBudget: number;\n private readonly textOutlineMinScreenSize: number;\n private contextLost = false;\n private boundOnLost = (e: Event) => this.onContextLost(e);\n private boundOnRestored = () => this.onContextRestored();\n /** True after `dispose()`. A disposed renderer ignores further `render()`\n * calls and `registerProgram()` calls. */\n private disposed = false;\n /** What registered paint kinds hang their GPU state on. One per context\n * generation: a restore releases it and opens the next. */\n private paintResources: OwnedPaintResources = createPaintResources();\n\n constructor(opts: WeaselRendererOptions) {\n if (!opts.gl && !opts.canvas) {\n throw new Error('WeaselRenderer requires either gl or canvas');\n }\n const gl = opts.gl ?? opts.canvas!.getContext('webgl2', { stencil: true });\n if (!gl) throw new Error('WeaselRenderer: WebGL2 not available');\n this.gl = gl as WebGL2RenderingContext;\n this.effectTargets = new EffectTargets(this.gl);\n this.paintScratch = new PaintScratch(this.gl);\n\n // Bits 0-7 are load-bearing: bit 0 for even-odd fills and stenciled\n // strokes, bits 1-7 for clip depth (`renderer/draw.ts`). Without a stencil\n // buffer both render wrong rather than not at all, so refuse the context\n // instead of painting a plausible lie. A stub that cannot answer is not a\n // stencil-less context — only an explicit `false` is.\n const attrs = typeof this.gl.getContextAttributes === 'function'\n ? this.gl.getContextAttributes()\n : null;\n if (attrs && attrs.stencil === false) {\n throw new Error(\n 'WeaselRenderer: the supplied WebGL2 context has no stencil buffer. '\n + 'Create it with { stencil: true } — clips and even-odd fills need one.',\n );\n }\n\n this.widthCss = opts.width;\n this.heightCss = opts.height;\n this.dpr = opts.dpr;\n this.imageMinification = opts.imageMinification ?? 'linear';\n this.flattenTolerance = opts.flattenTolerance;\n this.bakeBudget = opts.bakeBudget ?? DEFAULT_BAKE_BUDGET;\n this.textOutlineMinScreenSize = opts.textOutlineMinScreenSize ?? OUTLINE_MIN_SCREEN_PX;\n\n this.canvas = opts.canvas ?? null;\n if (this.canvas) {\n this.canvas.width = Math.round(opts.width * opts.dpr);\n this.canvas.height = Math.round(opts.height * opts.dpr);\n if (this.canvas.style) {\n this.canvas.style.width = `${opts.width}px`;\n this.canvas.style.height = `${opts.height}px`;\n }\n this.canvas.addEventListener('webglcontextlost', this.boundOnLost);\n this.canvas.addEventListener('webglcontextrestored', this.boundOnRestored);\n }\n\n this.applyGlState();\n this.applyTarget();\n\n this.pathFill = new ShaderProgram(this.gl, VERT_SRC, FRAG_SRC);\n this.pathFill.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFill.lookupAttributes(PATH_FILL_ATTRIBUTES);\n\n this.pathFillVColor = new ShaderProgram(this.gl, VCOLOR_VERT_SRC, VCOLOR_FRAG_SRC);\n this.pathFillVColor.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFillVColor.lookupAttributes(PATH_FILL_VCOLOR_ATTRIBUTES);\n\n this.imageFill = new ShaderProgram(this.gl, IMAGE_VERT_SRC, IMAGE_FRAG_SRC);\n this.imageFill.lookupUniforms(IMAGE_FILL_UNIFORMS);\n this.imageFill.lookupAttributes(IMAGE_FILL_ATTRIBUTES);\n\n this.batchFill = new ShaderProgram(this.gl, BATCH_VERT_SRC, BATCH_FRAG_SRC);\n this.batchFill.lookupUniforms(BATCH_FILL_UNIFORMS);\n this.batchFill.lookupAttributes(BATCH_FILL_ATTRIBUTES);\n\n this.gradFill = new ShaderProgram(this.gl, GRAD_VERT_SRC, GRAD_FRAG_SRC);\n this.gradFill.lookupUniforms(GRAD_FILL_UNIFORMS);\n this.gradFill.lookupAttributes(GRAD_FILL_ATTRIBUTES);\n\n this.patternFill = new ShaderProgram(this.gl, PATTERN_VERT_SRC, PATTERN_FRAG_SRC);\n this.patternFill.lookupUniforms(PATTERN_FILL_UNIFORMS);\n this.patternFill.lookupAttributes(PATTERN_FILL_ATTRIBUTES);\n\n const aPos = this.pathFill.attribute('a_position');\n if (aPos === undefined) throw new Error('WeaselRenderer: a_position not found in path-fill shader');\n this.meshCache = new GLMeshCache(this.gl, aPos);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n }\n\n private uploadQuadGeometry(): void {\n const gl = this.gl;\n this.quadVbo = gl.createBuffer();\n this.quadIbo = gl.createBuffer();\n if (!this.quadVbo || !this.quadIbo) {\n throw new Error('WeaselRenderer: failed to create quad geometry buffers');\n }\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVbo);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD_VERTICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.quadIbo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUAD_INDICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n }\n\n /**\n * Compile a consumer-registered shader program against this renderer's GL context.\n *\n * Call once per renderer after the module-level `registerProgram()`.\n * Throws `ShaderCompileError` if compilation fails.\n *\n * In dev mode, calling again with the same handle replaces the compiled program.\n *\n * @experimental\n */\n registerProgram(handle: ShaderProgramHandle): void {\n // A disposed renderer must not compile programs into the cleared registry.\n if (this.disposed) return;\n const src = getProgramSource(handle.id);\n if (!src) {\n throw new Error(\n `WeaselRenderer.registerProgram: program \"${handle.id}\" not found in source registry. ` +\n `Call the module-level registerProgram() first.`,\n );\n }\n this.installProgram(handle.id, src, compileCustomProgram(this.gl, src));\n }\n\n private installProgram(id: string, src: ProgramSource, program: ShaderProgram): void {\n const previous = this.programRegistry.get(id);\n if (previous) this.gl.deleteProgram(previous.handle);\n this.programRegistry.set(id, program);\n this.programSources.set(id, src);\n }\n\n /** Recompile every program whose module-level source was re-registered\n * since it was compiled. A source that fails keeps the old program drawing. */\n private refreshPrograms(): void {\n for (const [id, compiled] of this.programSources) {\n const src = getProgramSource(id);\n if (!src || src === compiled) continue;\n if (src.vert === compiled.vert && src.frag === compiled.frag) {\n this.programSources.set(id, src);\n continue;\n }\n try {\n this.installProgram(id, src, compileCustomProgram(this.gl, src));\n } catch (e) {\n this.programSources.set(id, src);\n console.error(`weasel: failed to recompile re-registered program \"${id}\"; still drawing the previous one:`, e);\n }\n }\n }\n\n /**\n * The compiled program for `id`, compiling it against this context on first\n * use. Unlike {@link registerProgram} this neither throws on a missing\n * source nor on a compile failure: a paint kind asking for a program it\n * never registered must decline the paint, not take down the frame.\n */\n private ensureProgram(id: string): ShaderProgram | null {\n const existing = this.programRegistry.get(id);\n if (existing) return existing;\n if (this.disposed || !getProgramSource(id)) return null;\n try {\n this.registerProgram({ id });\n } catch (e) {\n console.error(`weasel: failed to compile paint program \"${id}\":`, e);\n return null;\n }\n return this.programRegistry.get(id) ?? null;\n }\n\n private glyphPaintProgram(kind: GlyphPaintKind): ShaderProgram {\n const existing = this.glyphPaintPrograms.get(kind);\n if (existing) return existing;\n const [frag, uniforms] = GLYPH_PAINT_SOURCES[kind];\n const program = new ShaderProgram(this.gl, GLYPH_PAINT_VERT_SRC, frag);\n program.lookupUniforms(uniforms);\n program.lookupAttributes(GLYPH_PAINT_ATTRIBUTES);\n this.glyphPaintPrograms.set(kind, program);\n return program;\n }\n\n /** The GL state every frame assumes. Applied per `render()` rather than once\n * at construction because a co-tenant sharing this context moves all of it\n * between our frames. */\n private applyGlState(): void {\n const gl = this.gl;\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.CULL_FACE);\n gl.clearColor(0, 0, 0, 0);\n }\n\n /** Viewport and scissor for this frame. Re-applied inside `render()` because\n * a co-tenant on the same context moves both between our frames. */\n private applyTarget(): void {\n const gl = this.gl;\n const w = Math.round(this.widthCss * this.dpr);\n const h = Math.round(this.heightCss * this.dpr);\n if (!this.target) {\n gl.disable(gl.SCISSOR_TEST);\n gl.viewport(0, 0, w, h);\n return;\n }\n const x = Math.round(this.target.origin.x * this.dpr);\n const y = gl.drawingBufferHeight - Math.round(this.target.origin.y * this.dpr) - h;\n gl.viewport(x, y, w, h);\n gl.scissor(x, y, w, h);\n gl.enable(gl.SCISSOR_TEST);\n }\n\n /** Confine this renderer to a rect of its drawing buffer, or pass null to\n * give it the whole buffer back. Takes effect from the next `render()`. */\n setTarget(target: RenderTarget | null): void {\n this.target = target;\n this.applyTarget();\n }\n\n getTarget(): RenderTarget | null {\n return this.target;\n }\n\n isContextLost(): boolean {\n return this.contextLost;\n }\n\n private onContextLost(e: Event): void {\n e.preventDefault();\n this.contextLost = true;\n }\n\n private onContextRestored(): void {\n this.contextLost = false;\n this.applyGlState();\n this.applyTarget();\n // Every framebuffer, texture and renderbuffer the pool held died with the\n // context. `releaseAll` deletes handles that are already gone, which is a\n // no-op, and drops the bookkeeping that would otherwise hand a dead FBO to\n // the next group with effects.\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n this.paintResources.release();\n this.paintResources = createPaintResources();\n this.pathFill = new ShaderProgram(this.gl, VERT_SRC, FRAG_SRC);\n this.pathFill.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFill.lookupAttributes(PATH_FILL_ATTRIBUTES);\n this.pathFillVColor = new ShaderProgram(this.gl, VCOLOR_VERT_SRC, VCOLOR_FRAG_SRC);\n this.pathFillVColor.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFillVColor.lookupAttributes(PATH_FILL_VCOLOR_ATTRIBUTES); this.imageFill = new ShaderProgram(this.gl, IMAGE_VERT_SRC, IMAGE_FRAG_SRC);\n this.imageFill.lookupUniforms(IMAGE_FILL_UNIFORMS);\n this.imageFill.lookupAttributes(IMAGE_FILL_ATTRIBUTES);\n\n this.batchFill = new ShaderProgram(this.gl, BATCH_VERT_SRC, BATCH_FRAG_SRC);\n this.batchFill.lookupUniforms(BATCH_FILL_UNIFORMS);\n this.batchFill.lookupAttributes(BATCH_FILL_ATTRIBUTES);\n this.gradFill = new ShaderProgram(this.gl, GRAD_VERT_SRC, GRAD_FRAG_SRC);\n this.gradFill.lookupUniforms(GRAD_FILL_UNIFORMS);\n this.gradFill.lookupAttributes(GRAD_FILL_ATTRIBUTES);\n\n this.patternFill = new ShaderProgram(this.gl, PATTERN_VERT_SRC, PATTERN_FRAG_SRC);\n this.patternFill.lookupUniforms(PATTERN_FILL_UNIFORMS);\n this.patternFill.lookupAttributes(PATTERN_FILL_ATTRIBUTES);\n this.glyphPaintPrograms.clear();\n const aPos = this.pathFill.attribute('a_position');\n if (aPos === undefined) throw new Error('a_position missing after restore');\n this.meshCache = new GLMeshCache(this.gl, aPos);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache.abandon();\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n markAllFontsNotUploaded();\n\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n for (const id of this.programRegistry.keys()) {\n const src = getProgramSource(id);\n if (!src) continue;\n try {\n this.programRegistry.set(id, compileCustomProgram(this.gl, src));\n this.programSources.set(id, src);\n } catch (e) {\n console.error(`weasel: failed to recompile program \"${id}\" after context restore:`, e);\n }\n }\n }\n\n /** Free every GL resource this renderer created and detach context-loss\n * listeners when a canvas was supplied. Idempotent.\n *\n * That covers the built-in and consumer-registered programs (their shaders\n * go with them), the shared quad geometry, the batch, the effect targets,\n * and every cache: atlas and gradient-ramp textures, bitmap and pattern\n * textures, and meshes — transient, persistent, and those whose Path was\n * already collected. The context itself is left alone, so a caller-owned\n * context can host renderer after renderer without accumulating anything.\n *\n * A disposed renderer ignores further `render()` and `registerProgram()`\n * calls. */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n const gl = this.gl;\n if (this.canvas) {\n this.canvas.removeEventListener('webglcontextlost', this.boundOnLost);\n this.canvas.removeEventListener('webglcontextrestored', this.boundOnRestored);\n }\n this.meshCache.dispose();\n this.paintResources.release();\n for (const prog of [\n this.pathFill, this.pathFillVColor, this.imageFill, this.batchFill, this.gradFill, this.patternFill,\n ...this.glyphPaintPrograms.values(),\n ]) {\n gl.deleteProgram(prog.handle);\n }\n this.glyphPaintPrograms.clear();\n for (const prog of this.programRegistry.values()) {\n gl.deleteProgram(prog.handle);\n }\n this.programRegistry.clear();\n this.programSources.clear();\n this.textureCache.free();\n this.imageCache.dispose();\n this.gradRamps.free();\n if (this.quadVbo) gl.deleteBuffer(this.quadVbo);\n if (this.quadIbo) gl.deleteBuffer(this.quadIbo);\n this.drawBatch.dispose();\n if (this.whiteTexture) gl.deleteTexture(this.whiteTexture);\n this.whiteTexture = null;\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n }\n\n /**\n * Draw one frame.\n *\n * `viewMatrix` is the frame's world→screen transform. It is only consulted\n * by `units: 'world'` gradients, which fall back to screen space without\n * it — every other command carries its own transform in the stream, so\n * callers with no view concept can keep calling `render(commands)`.\n */\n render(commands: DrawCommand[], viewMatrix?: GlMat3, opts?: RenderOptions): void {\n if (this.contextLost || this.disposed) return;\n const t0 = now();\n const counters = { drawCalls: 0 };\n const spanStats: RenderSpanStats[] = [];\n this.stats = { drawCalls: 0, ms: 0, spans: spanStats };\n const gl = this.gl;\n // Free GL resources whose Mesh was GC'd since the last frame. Done here\n // (top of render, before any draws) because GL state is known clean —\n // no VAO bound, no draw in flight. Deleting from the FinalizationRegistry\n // callback directly was racy and caused mid-draw crashes.\n this.meshCache.drainPendingDeletes();\n this.refreshPrograms();\n // New frame: refill the dynamic-glyph synchronous bake budget.\n resetBakeBudget(this.bakeBudget);\n this.groupState.reset();\n this.applyGlState();\n this.applyTarget();\n // Ensure all stencil bits are cleared regardless of any mask left over\n // from the previous frame's clip ops.\n if (this.target?.clear !== false) {\n gl.stencilMask(0xFF);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);\n }\n const ctx: DrawContext = {\n gl,\n pathFill: this.pathFill,\n pathFillVColor: this.pathFillVColor,\n imageFill: this.imageFill,\n batchFill: this.batchFill,\n gradFill: this.gradFill,\n patternFill: this.patternFill,\n meshCache: this.meshCache,\n textureCache: this.textureCache,\n imageCache: this.imageCache,\n gradRamps: this.gradRamps,\n programRegistry: this.programRegistry,\n ensureProgram: (id) => this.ensureProgram(id),\n glyphPaintProgram: (kind) => this.glyphPaintProgram(kind),\n quadVbo: this.quadVbo,\n quadIbo: this.quadIbo,\n drawBatch: this.drawBatch,\n whiteTexture: this.whiteTexture,\n state: this.groupState,\n widthCss: this.widthCss,\n heightCss: this.heightCss,\n clipDepth: 0,\n clipStack: [],\n flattenTolerance: this.flattenTolerance,\n textOutlineMinScreenSize: this.textOutlineMinScreenSize,\n viewMatrix,\n effectTargets: this.effectTargets,\n paintScratch: this.paintScratch,\n renderTarget: null,\n deviceWidth: Math.round(this.widthCss * this.dpr),\n deviceHeight: Math.round(this.heightCss * this.dpr),\n restoreTargetRect: () => this.applyTarget(),\n paintResources: this.paintResources,\n stats: counters,\n };\n // A frame that threw part-way left its clip here.\n this.drawBatch.clip = null;\n const spans = opts?.spans ?? [];\n let next = 0;\n for (let si = 0; si < spans.length; si++) {\n const span = spans[si];\n for (; next < span.start; next++) dispatch(ctx, commands[next]);\n const drawsBefore = counters.drawCalls;\n const spanT0 = now();\n for (; next < span.end; next++) dispatch(ctx, commands[next]);\n // The stream's closing flush belongs to whatever it closes.\n if (si === spans.length - 1 && next >= commands.length) flushBatch(ctx);\n spanStats.push({ id: span.id, drawCalls: counters.drawCalls - drawsBefore, ms: now() - spanT0 });\n }\n for (; next < commands.length; next++) dispatch(ctx, commands[next]);\n // The stream ended, so whatever is still staged has nothing left that\n // could merge with it.\n flushBatch(ctx);\n // Free transient resources allocated during this frame (e.g. per-frame\n // stroke ribbons from tessellateStroke). Done after all draws complete\n // so we never delete a buffer that's still bound to a pending draw.\n this.meshCache.freeTransient();\n this.stats.drawCalls = counters.drawCalls;\n this.stats.ms = now() - t0;\n }\n\n /** What the last `render()` cost: GL draw calls issued and CPU milliseconds\n * spent issuing them, in total and per requested span. GPU time is not\n * measured; the GPU runs asynchronously. */\n lastFrameStats(): RenderStats {\n return this.stats;\n }\n\n /** Change the curve-flattening tolerance after construction. `undefined`\n * restores the cached `DEFAULT_FLATTEN_TOLERANCE` route. */\n setFlattenTolerance(tolerance: number | undefined): void {\n this.flattenTolerance = tolerance;\n }\n\n resize(dims: { width: number; height: number; dpr: number }): void {\n this.widthCss = dims.width;\n this.heightCss = dims.height;\n this.dpr = dims.dpr;\n if (this.canvas) {\n this.canvas.width = Math.round(dims.width * dims.dpr);\n this.canvas.height = Math.round(dims.height * dims.dpr);\n if (this.canvas.style) {\n this.canvas.style.width = `${dims.width}px`;\n this.canvas.style.height = `${dims.height}px`;\n }\n }\n this.applyTarget();\n }\n\n /** @internal */ _gl(): WebGL2RenderingContext { return this.gl; }\n /** @internal */ _pathFill(): ShaderProgram { return this.pathFill; }\n /** @internal */ _pathFillVColor(): ShaderProgram { return this.pathFillVColor; }\n /** @internal */ _drawBatch(): DrawBatch { return this.drawBatch; }\n /** @internal */ _imageFill(): ShaderProgram { return this.imageFill; }\n /** @internal */ _batchFill(): ShaderProgram { return this.batchFill; }\n /** @internal */ _gradFill(): ShaderProgram { return this.gradFill; }\n /** @internal */ _patternFill(): ShaderProgram { return this.patternFill; }\n /** @internal */ _meshCache(): GLMeshCache { return this.meshCache; }\n /** @internal */ _textureCache(): GLTextureCache { return this.textureCache; }\n /** @internal */ _imageCache(): GLImageCache { return this.imageCache; }\n /** @internal */ _gradRamps(): GradientRampAtlas { return this.gradRamps; }\n /** @internal */ _groupState(): GroupState { return this.groupState; }\n /** @internal */ _widthCss(): number { return this.widthCss; }\n /** @internal */ _heightCss(): number { return this.heightCss; }\n /** @internal */ _dpr(): number { return this.dpr; }\n}\n\n/** The 1x1 opaque white texture a batch flush binds when its run samples no\n * image. NEAREST both ways: one texel, so there is nothing to filter, and a\n * mipmap filter on a texture with no mipmaps is incomplete. */\nfunction createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture | null {\n const tex = gl.createTexture();\n if (!tex) return null;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,\n new Uint8Array([255, 255, 255, 255]),\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TE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AAO,KAAK;CAAK;AACrD;AAKA,SAASpC,EAAmB,GAAiD;CAC3E,IAAMqC,IAAMtF,EAAG,cAAc;CAY7B,OAXKsF,KACLtF,EAAG,YAAYA,EAAG,YAAYsF,CAAG,GACjCtF,EAAG,WACDA,EAAG,YAAY,GAAGA,EAAG,MAAM,GAAG,GAAG,GAAGA,EAAG,MAAMA,EAAG,eAChD,IAAI,WAAW;EAAC;EAAK;EAAK;EAAK;CAAG,CAAC,CACrC,GACAA,EAAG,cAAcA,EAAG,YAAYA,EAAG,oBAAoBA,EAAG,OAAO,GACjEA,EAAG,cAAcA,EAAG,YAAYA,EAAG,oBAAoBA,EAAG,OAAO,GACjEA,EAAG,cAAcA,EAAG,YAAYA,EAAG,gBAAgBA,EAAG,aAAa,GACnEA,EAAG,cAAcA,EAAG,YAAYA,EAAG,gBAAgBA,EAAG,aAAa,GACnEA,EAAG,YAAYA,EAAG,YAAY,IAAI,GAC3BsF,KAXU;AAYnB"}
@@ -1,46 +0,0 @@
1
- //#region src/renderer/batchClip.ts
2
- function e(e, t) {
3
- if (e.kind !== "rect" || !(t[1] === 0 && t[3] === 0 || t[0] === 0 && t[4] === 0)) return null;
4
- let n = t[0] * e.x + t[3] * e.y + t[6], r = t[1] * e.x + t[4] * e.y + t[7], i = e.x + e.width, a = e.y + e.height, o = t[0] * i + t[3] * a + t[6], s = t[1] * i + t[4] * a + t[7];
5
- return {
6
- x0: Math.min(n, o),
7
- y0: Math.min(r, s),
8
- x1: Math.max(n, o),
9
- y1: Math.max(r, s)
10
- };
11
- }
12
- function t(e, t) {
13
- return {
14
- x0: Math.max(e.x0, t.x0),
15
- y0: Math.max(e.y0, t.y0),
16
- x1: Math.min(e.x1, t.x1),
17
- y1: Math.min(e.y1, t.y1)
18
- };
19
- }
20
- function n(e, t, n, i, a, o) {
21
- let s = r(e, t, n, 0, i.x0, 1, o);
22
- return s = r(o, s, n, 0, i.x1, -1, a), s = r(a, s, n, 1, i.y0, 1, o), r(o, s, n, 1, i.y1, -1, a);
23
- }
24
- function r(e, t, n, r, i, a, o) {
25
- if (t === 0) return 0;
26
- let s = 0, c = t - 1, l = a * (e[c * n + r] - i) >= 0;
27
- for (let u = 0; u < t; u++) {
28
- let t = a * (e[u * n + r] - i) >= 0;
29
- if (t !== l) {
30
- let t = c * n, a = u * n, l = (i - e[t + r]) / (e[a + r] - e[t + r]), d = s * n;
31
- for (let r = 0; r < n; r++) o[d + r] = e[t + r] + l * (e[a + r] - e[t + r]);
32
- o[d + r] = i, s++;
33
- }
34
- if (t) {
35
- let t = s * n, r = u * n;
36
- for (let i = 0; i < n; i++) o[t + i] = e[r + i];
37
- s++;
38
- }
39
- c = u, l = t;
40
- }
41
- return s;
42
- }
43
- //#endregion
44
- export { e as axisAlignedClipRect, n as clipConvexPolygon, t as intersectClipRects };
45
-
46
- //# sourceMappingURL=batchClip.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batchClip.js","names":["axisAlignedClipRect","path","m","ax","ay","x1","y1","bx","by","intersectClipRects","a","b","clipConvexPolygon","count","clipEdge","src","n","stride","rect","tmp","dst","prev","prevIn","sign","axis","at","cur","curIn","t","o","k","c"],"sources":["../../src/renderer/batchClip.ts"],"sourcesContent":["/**\n * Clipping staged geometry to an axis-aligned rect on the CPU, so a rect clip\n * needs no stencil and does not break the run.\n *\n * A stencil clip is GL state, so content inside one cannot share a draw with\n * content outside it, and every clipped group paid a flush on the way in and\n * another on the way out. A rect under a transform that keeps it axis-aligned\n * is the common clip, and for that one the clip can ride the geometry instead:\n * cut each staged polygon to the rect before it joins the run.\n *\n * Exact, not approximate: every attribute a batch vertex carries is affine\n * across the polygon it belongs to, so interpolating along a cut edge gives\n * the value the rasterizer would have produced there, and the cut polygon\n * covers the same pixel centers the stencil would have passed.\n */\n\nimport type { Path } from '@weasel-js/geom';\nimport type { GlMat3 } from './math/mat3';\n\n/** In the space batch vertices are staged in: after the model transform,\n * before the projection. */\nexport interface ClipRect {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\n/**\n * `path` under `m` as a `ClipRect`, or `null` when it is not one: not a rect\n * path, or a transform that rotates or skews it off the axes.\n */\nexport function axisAlignedClipRect(path: Path, m: GlMat3): ClipRect | null {\n if (path.kind !== 'rect') return null;\n const keepsAxes = (m[1] === 0 && m[3] === 0) || (m[0] === 0 && m[4] === 0);\n if (!keepsAxes) return null;\n const ax = m[0] * path.x + m[3] * path.y + m[6];\n const ay = m[1] * path.x + m[4] * path.y + m[7];\n const x1 = path.x + path.width;\n const y1 = path.y + path.height;\n const bx = m[0] * x1 + m[3] * y1 + m[6];\n const by = m[1] * x1 + m[4] * y1 + m[7];\n return {\n x0: Math.min(ax, bx), y0: Math.min(ay, by),\n x1: Math.max(ax, bx), y1: Math.max(ay, by),\n };\n}\n\nexport function intersectClipRects(a: ClipRect, b: ClipRect): ClipRect {\n return {\n x0: Math.max(a.x0, b.x0), y0: Math.max(a.y0, b.y0),\n x1: Math.min(a.x1, b.x1), y1: Math.min(a.y1, b.y1),\n };\n}\n\n/**\n * Cut the convex polygon of `n` vertices in `src` (each `stride` floats, x and\n * y first) to `rect`, writing the result to `dst`. Returns the vertex count,\n * which is below 3 when nothing is left. `tmp` must hold as many floats as\n * `dst`; both need room for `n + 4` vertices.\n */\nexport function clipConvexPolygon(\n src: Float32Array, n: number, stride: number, rect: ClipRect,\n dst: Float32Array, tmp: Float32Array,\n): number {\n // Four passes, ping-ponging so the last one lands in `dst`.\n let count = clipEdge(src, n, stride, 0, rect.x0, 1, tmp);\n count = clipEdge(tmp, count, stride, 0, rect.x1, -1, dst);\n count = clipEdge(dst, count, stride, 1, rect.y0, 1, tmp);\n return clipEdge(tmp, count, stride, 1, rect.y1, -1, dst);\n}\n\n/** One Sutherland–Hodgman pass: keep the side of `axis = at` where\n * `sign * (v - at) >= 0`. */\nfunction clipEdge(\n src: Float32Array, n: number, stride: number,\n axis: 0 | 1, at: number, sign: 1 | -1, out: Float32Array,\n): number {\n if (n === 0) return 0;\n let m = 0;\n let prev = n - 1;\n let prevIn = sign * (src[prev * stride + axis] - at) >= 0;\n for (let cur = 0; cur < n; cur++) {\n const curIn = sign * (src[cur * stride + axis] - at) >= 0;\n if (curIn !== prevIn) {\n const a = prev * stride;\n const b = cur * stride;\n const t = (at - src[a + axis]) / (src[b + axis] - src[a + axis]);\n const o = m * stride;\n for (let k = 0; k < stride; k++) out[o + k] = src[a + k] + t * (src[b + k] - src[a + k]);\n // On the line exactly, whatever the interpolation rounded to.\n out[o + axis] = at;\n m++;\n }\n if (curIn) {\n const o = m * stride;\n const c = cur * stride;\n for (let k = 0; k < stride; k++) out[o + k] = src[c + k];\n m++;\n }\n prev = cur;\n prevIn = curIn;\n }\n return m;\n}\n"],"mappings":";AAgCA,SAAgBA,EAAoB,GAAY,GAA4B;CAG1E,IAFIC,EAAK,SAAS,UAEd,EADeC,EAAE,OAAO,KAAKA,EAAE,OAAO,KAAOA,EAAE,OAAO,KAAKA,EAAE,OAAO,IACxD,OAAO;CACvB,IAAMC,IAAKD,EAAE,KAAKD,EAAK,IAAIC,EAAE,KAAKD,EAAK,IAAIC,EAAE,IACvCE,IAAKF,EAAE,KAAKD,EAAK,IAAIC,EAAE,KAAKD,EAAK,IAAIC,EAAE,IACvCG,IAAKJ,EAAK,IAAIA,EAAK,OACnBK,IAAKL,EAAK,IAAIA,EAAK,QACnBM,IAAKL,EAAE,KAAKG,IAAKH,EAAE,KAAKI,IAAKJ,EAAE,IAC/BM,IAAKN,EAAE,KAAKG,IAAKH,EAAE,KAAKI,IAAKJ,EAAE;CACrC,OAAO;EACL,IAAI,KAAK,IAAIC,GAAII,CAAE;EAAG,IAAI,KAAK,IAAIH,GAAII,CAAE;EACzC,IAAI,KAAK,IAAIL,GAAII,CAAE;EAAG,IAAI,KAAK,IAAIH,GAAII,CAAE;CAC3C;AACF;AAEA,SAAgBC,EAAmB,GAAa,GAAuB;CACrE,OAAO;EACL,IAAI,KAAK,IAAIC,EAAE,IAAIC,EAAE,EAAE;EAAG,IAA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AAIL,IAAMT;GAChB,KAAK,IAAIa,IAAI,GAAGA,IAAIb,GAAQ,KAAK,EAAIY,IAAIC,KAAKf,EAAIgB,IAAID;GACtD;EACF;EAEA,AADA,IAAOJ,GACP,IAASC;CACX;CACA,OAAOzB;AACT"}
@@ -1,64 +0,0 @@
1
- //#region src/renderer/cache/GLImageCache.ts
2
- var e = 4096, t = /* @__PURE__ */ new Set();
3
- function n(e) {
4
- for (let n of t) n.release(e);
5
- }
6
- function r() {
7
- let n = Infinity;
8
- for (let e of t) n = Math.min(n, e.maxTextureSide);
9
- return Number.isFinite(n) ? n : e;
10
- }
11
- var i = class {
12
- gl;
13
- minification;
14
- maxTextureSide;
15
- map = /* @__PURE__ */ new WeakMap();
16
- textures = /* @__PURE__ */ new Set();
17
- magFilters = /* @__PURE__ */ new WeakMap();
18
- constructor(n, r = "linear") {
19
- this.gl = n, this.minification = r;
20
- let i = n.getParameter(n.MAX_TEXTURE_SIZE);
21
- this.maxTextureSide = typeof i == "number" && i > 0 ? i : e, t.add(this);
22
- }
23
- release(e) {
24
- let t = this.map.get(e);
25
- t && (this.gl.deleteTexture(t), this.textures.delete(t), this.map.delete(e), this.magFilters.delete(e));
26
- }
27
- dispose() {
28
- for (let e of this.textures) this.gl.deleteTexture(e);
29
- this.abandon();
30
- }
31
- abandon() {
32
- this.textures.clear(), t.delete(this);
33
- }
34
- upload(e, t, n) {
35
- let r = this.map.get(e);
36
- if (r) return r;
37
- let i = this.gl, o = i.createTexture();
38
- if (!o) throw Error("GLImageCache: createTexture failed");
39
- i.bindTexture(i.TEXTURE_2D, o), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, t), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, this.minification === "mipmap" ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.LINEAR), this.magFilters.set(e, i.LINEAR);
40
- let [s, c] = a(i, n);
41
- return i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, s), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, c), this.minification === "mipmap" && i.generateMipmap(i.TEXTURE_2D), i.bindTexture(i.TEXTURE_2D, null), this.map.set(e, o), this.textures.add(o), o;
42
- }
43
- bind(e, t) {
44
- let n = this.map.get(e);
45
- if (!n) throw Error("GLImageCache: image not uploaded; call upload() first");
46
- let r = this.gl;
47
- r.activeTexture(r.TEXTURE0 + t), r.bindTexture(r.TEXTURE_2D, n);
48
- }
49
- setMagFilter(e, t) {
50
- this.magFilters.get(e) !== t && (this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, t), this.magFilters.set(e, t));
51
- }
52
- };
53
- function a(e, t) {
54
- switch (t) {
55
- case "repeat": return [e.REPEAT, e.REPEAT];
56
- case "repeat-x": return [e.REPEAT, e.CLAMP_TO_EDGE];
57
- case "repeat-y": return [e.CLAMP_TO_EDGE, e.REPEAT];
58
- default: return [e.CLAMP_TO_EDGE, e.CLAMP_TO_EDGE];
59
- }
60
- }
61
- //#endregion
62
- export { i as GLImageCache, r as maxImageTextureSide, n as releaseImageSource };
63
-
64
- //# sourceMappingURL=GLImageCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GLImageCache.js","names":["DEFAULT_MAX_TEXTURE_SIDE","live","releaseImageSource","cache","key","maxImageTextureSide","side","GLImageCache","gl","minification","reported","tex","existing","source","wrapS","wrapT","wrapModes","repetition","unit","filter","rep"],"sources":["../../../src/renderer/cache/GLImageCache.ts"],"sourcesContent":["/**\n * GL texture upload cache for ImageBitmap objects.\n *\n * Key: ImageBitmap (or pattern source object) identity (WeakMap) — lets GC\n * reclaim unreferenced bitmaps. The GL textures are NOT freed when the source\n * is gc'd; a source's owner that knows it will never be drawn again frees them\n * with {@link releaseImageSource}, and `dispose` frees them all.\n *\n * Wrapping is set once at upload time per the `repetition` parameter:\n * - undefined / 'no-repeat' → CLAMP_TO_EDGE\n * - 'repeat' → REPEAT (both axes)\n * - 'repeat-x' → REPEAT on S, CLAMP on T\n * - 'repeat-y' → CLAMP on S, REPEAT on T\n *\n * Convention §2: texels stored straight; shader premultiplies.\n */\n\nexport type PatternRepetition = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n\n/** MIN_FILTER strategy for uploaded textures. */\nexport type ImageMinification = 'linear' | 'mipmap';\n\ntype TexSource = ImageBitmap | ImageData | HTMLCanvasElement | HTMLImageElement;\n\n/** Assumed when no live context has reported its `MAX_TEXTURE_SIZE`. Above\n * WebGL2's guaranteed 2048, and at or below what every current GPU reports. */\nconst DEFAULT_MAX_TEXTURE_SIDE = 4096;\n\nconst live = new Set<GLImageCache>();\n\n/** Free `key`'s texture in every live renderer. For an owner that has replaced\n * a source and will never draw the old one again — a later draw of it simply\n * re-uploads. */\nexport function releaseImageSource(key: object): void {\n for (const cache of live) cache.release(key);\n}\n\n/** The largest texture side every live renderer can hold: the smallest\n * `MAX_TEXTURE_SIZE` among them, or a conservative default when none is live. */\nexport function maxImageTextureSide(): number {\n let side = Infinity;\n for (const cache of live) side = Math.min(side, cache.maxTextureSide);\n return Number.isFinite(side) ? side : DEFAULT_MAX_TEXTURE_SIDE;\n}\n\nexport class GLImageCache {\n /** This context's `MAX_TEXTURE_SIZE`. */\n readonly maxTextureSide: number;\n\n private readonly map = new WeakMap<object, WebGLTexture>();\n /** Every texture `map` holds, so `dispose` can reach them — a WeakMap\n * cannot be enumerated. */\n private readonly textures = new Set<WebGLTexture>();\n /**\n * MAG_FILTER each texture currently carries, so a redundant write can be\n * skipped.\n *\n * The batch sets this per flush — the same bitmap can be drawn at both\n * filters in one frame, and the value has to be right at the draw rather than\n * at upload. Filtering is state on the *texture object*, though, not on the\n * unit, so re-asserting a value it already has is a write to a live texture\n * for no reason. On a large sheet that is not free: a consumer's wall samples\n * a 5652px-square atlas, 122MB resident, and measured `sampling: 'nearest'`\n * costing up to 8x `'linear'` there — where the linear pass re-asserts the\n * upload default and the nearest pass changes state on every draw.\n *\n * Whether that is the cause is unproven (see `docs/TODO.md`), but the write\n * was redundant either way.\n */\n private readonly magFilters = new WeakMap<object, number>();\n\n /** `minification` selects the MIN_FILTER strategy for uploaded textures.\n * `'linear'` (default) is the screen path's existing behavior. `'mipmap'`\n * generates mipmaps and filters LINEAR_MIPMAP_LINEAR — required for\n * quality minification when a large source bitmap is drawn small (the\n * headless print/export path); bilinear-only minification undersamples\n * and produces moiré. */\n constructor(\n private readonly gl: WebGL2RenderingContext,\n private readonly minification: ImageMinification = 'linear',\n ) {\n const reported: unknown = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.maxTextureSide = typeof reported === 'number' && reported > 0\n ? reported\n : DEFAULT_MAX_TEXTURE_SIDE;\n live.add(this);\n }\n\n /** Delete `key`'s texture, if it has one. */\n release(key: object): void {\n const tex = this.map.get(key);\n if (!tex) return;\n this.gl.deleteTexture(tex);\n this.textures.delete(tex);\n this.map.delete(key);\n this.magFilters.delete(key);\n }\n\n /** Delete every texture this cache uploaded and stop answering\n * {@link releaseImageSource} and {@link maxImageTextureSide}. Idempotent. */\n dispose(): void {\n for (const tex of this.textures) this.gl.deleteTexture(tex);\n this.abandon();\n }\n\n /** {@link dispose} without the deletes, for a cache whose context was lost:\n * its textures died with it. */\n abandon(): void {\n this.textures.clear();\n live.delete(this);\n }\n\n upload(\n key: object,\n source: TexSource,\n repetition?: PatternRepetition,\n ): WebGLTexture {\n const existing = this.map.get(key);\n if (existing) return existing;\n\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error('GLImageCache: createTexture failed');\n\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source as TexImageSource);\n gl.texParameteri(\n gl.TEXTURE_2D,\n gl.TEXTURE_MIN_FILTER,\n this.minification === 'mipmap' ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR,\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n this.magFilters.set(key, gl.LINEAR);\n\n const [wrapS, wrapT] = wrapModes(gl, repetition);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n if (this.minification === 'mipmap') gl.generateMipmap(gl.TEXTURE_2D);\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n this.map.set(key, tex);\n this.textures.add(tex);\n return tex;\n }\n\n bind(key: object, unit: number): void {\n const tex = this.map.get(key);\n if (!tex) throw new Error('GLImageCache: image not uploaded; call upload() first');\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n }\n\n /** Set `key`'s MAG_FILTER, skipping the call when it already holds that\n * value. Its texture must be bound to the active unit — callers pair this\n * with `bind`. */\n setMagFilter(key: object, filter: number): void {\n if (this.magFilters.get(key) === filter) return;\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, filter);\n this.magFilters.set(key, filter);\n }\n}\n\nfunction wrapModes(\n gl: WebGL2RenderingContext,\n rep?: PatternRepetition,\n): [number, number] {\n switch (rep) {\n case 'repeat': return [gl.REPEAT, gl.REPEAT];\n case 'repeat-x': return [gl.REPEAT, gl.CLAMP_TO_EDGE];\n case 'repeat-y': return [gl.CLAMP_TO_EDGE, gl.REPEAT];\n default: return [gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE];\n }\n}\n"],"mappings":";AA0BA,IAAMA,IAA2B,MAE3BC,oBAAO,IAAI,IAAkB;AAKnC,SAAgBC,EAAmB,GAAmB;CACpD,KAAK,IAAMC,KAASF,GAAM,EAAM,QAAQG,CAAG;AAC7C;AAIA,SAAgBC,IAA8B;CAC5C,IAAIC,IAAO;CACX,KAAK,IAAMH,KAASF,G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
3
- gl;
4
- aPositionLoc;
5
- map = /* @__PURE__ */ new WeakMap();
6
- seen = /* @__PURE__ */ new WeakSet();
7
- finalizer;
8
- persistent = /* @__PURE__ */ new Set();
9
- pendingDeletes = [];
10
- disposed = !1;
11
- transientThisFrame = [];
12
- constructor(e, t) {
13
- this.gl = e, this.aPositionLoc = t, this.finalizer = new FinalizationRegistry((e) => {
14
- this.persistent.delete(e) && this.pendingDeletes.push(e);
15
- });
16
- }
17
- handleFor(e) {
18
- let t = this.map.get(e);
19
- if (t) return t;
20
- let { handle: n, vbo: r, ibo: i } = this.upload(e);
21
- this.map.set(e, n);
22
- let a = {
23
- vao: n.vao,
24
- vbo: r,
25
- ibo: i
26
- };
27
- return this.persistent.add(a), this.finalizer.register(e, a, e), n;
28
- }
29
- uploadTransient(e) {
30
- let { handle: t, vbo: n, ibo: r } = this.upload(e);
31
- return this.transientThisFrame.push({
32
- vao: t.vao,
33
- vbo: n,
34
- ibo: r
35
- }), t;
36
- }
37
- uploadRecurring(e) {
38
- return this.seen.has(e) ? this.handleFor(e) : (this.seen.add(e), this.uploadTransient(e));
39
- }
40
- freeTransient() {
41
- if (this.transientThisFrame.length === 0) return;
42
- let e = this.gl;
43
- if (e.isContextLost()) {
44
- this.transientThisFrame.length = 0;
45
- return;
46
- }
47
- for (let t of this.transientThisFrame) e.deleteVertexArray(t.vao), e.deleteBuffer(t.vbo), e.deleteBuffer(t.ibo);
48
- this.transientThisFrame.length = 0;
49
- }
50
- _transientCount() {
51
- return this.transientThisFrame.length;
52
- }
53
- drainPendingDeletes() {
54
- if (this.pendingDeletes.length === 0) return;
55
- let e = this.gl;
56
- if (e.isContextLost()) {
57
- this.pendingDeletes.length = 0;
58
- return;
59
- }
60
- for (let t of this.pendingDeletes) e.deleteVertexArray(t.vao), e.deleteBuffer(t.vbo), e.deleteBuffer(t.ibo);
61
- this.pendingDeletes.length = 0;
62
- }
63
- dispose() {
64
- if (!this.disposed) {
65
- this.disposed = !0, this.freeTransient();
66
- for (let e of this.persistent) this.pendingDeletes.push(e);
67
- this.persistent.clear(), this.drainPendingDeletes();
68
- }
69
- }
70
- _pendingDeleteCount() {
71
- return this.pendingDeletes.length;
72
- }
73
- _enqueueDeleteForTest(e) {
74
- this.pendingDeletes.push(e);
75
- }
76
- upload(e) {
77
- let t = this.gl, n = t.createVertexArray();
78
- if (!n) throw Error("createVertexArray returned null");
79
- t.bindVertexArray(n);
80
- let r = t.createBuffer();
81
- if (!r) throw Error("createBuffer (VBO) returned null");
82
- t.bindBuffer(t.ARRAY_BUFFER, r), t.bufferData(t.ARRAY_BUFFER, e.vertices, t.STATIC_DRAW), t.enableVertexAttribArray(this.aPositionLoc), t.vertexAttribPointer(this.aPositionLoc, 2, t.FLOAT, !1, 0, 0);
83
- let i = t.createBuffer();
84
- if (!i) throw Error("createBuffer (IBO) returned null");
85
- return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, i), t.bufferData(t.ELEMENT_ARRAY_BUFFER, e.indices, t.STATIC_DRAW), t.bindVertexArray(null), {
86
- handle: {
87
- vao: n,
88
- indexCount: e.indices.length,
89
- requiresStencil: e.requiresStencil ?? !1,
90
- anchorA: e.anchorA,
91
- anchorB: e.anchorB,
92
- anchorT: e.anchorT
93
- },
94
- vbo: r,
95
- ibo: i
96
- };
97
- }
98
- };
99
- //#endregion
100
- export { e as GLMeshCache };
101
-
102
- //# sourceMappingURL=GLMeshCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GLMeshCache.js","names":["GLMeshCache","gl","aPositionLoc","resources","cached","mesh","handle","r","vao","vbo","ibo"],"sources":["../../../src/renderer/cache/GLMeshCache.ts"],"sourcesContent":["import type { Mesh } from '@weasel-js/geom/tessellate';\n\nexport interface GLMeshHandle {\n readonly vao: WebGLVertexArrayObject;\n readonly indexCount: number;\n readonly requiresStencil: boolean;\n readonly anchorA?: Uint32Array;\n readonly anchorB?: Uint32Array;\n readonly anchorT?: Float32Array;\n}\n\n/** Resources to release when a Mesh is reclaimed by GC. */\ninterface MeshResources {\n vao: WebGLVertexArrayObject;\n vbo: WebGLBuffer;\n ibo: WebGLBuffer;\n}\n\n/**\n * Caches GL-side buffers + VAO per `Mesh` identity. Upload happens lazily\n * on first `handleFor(mesh)` call.\n *\n * **GC-aware cleanup (deferred-delete queue):** when a Mesh becomes\n * unreachable, the WeakMap entry is dropped automatically — but the\n * underlying GL resources (VAO, VBO, IBO) would leak forever without an\n * explicit `gl.delete*` call. We register each Mesh with a\n * `FinalizationRegistry`; when the Mesh is reclaimed, the finalizer pushes\n * the resources onto an internal queue. The renderer drains this queue at\n * the start of each `render()` call (via `drainPendingDeletes()`), when GL\n * is in a known state — no VAO bound, no draw mid-flight. Deleting from the\n * finalizer directly was racy (it could fire between two `gl.bindVertexArray`\n * calls inside `dispatch()`, sometimes corrupting the next draw); deferring\n * the actual delete to a known-safe point keeps the use-after-free risk to\n * zero.\n *\n * Caveats:\n * - Finalizer timing is non-deterministic; resources may live for a frame\n * or two beyond their Mesh, but they will be reclaimed.\n * - If the GL context is lost between finalizer and drain, the drain\n * no-ops safely (`gl.isContextLost()` makes deletes no-ops, and\n * `gl.deleteBuffer(null)` is allowed).\n *\n * The cache is GL-context-bound; if the context is lost and re-created, the\n * renderer should construct a new GLMeshCache. (Context loss handling lives\n * in `WeaselRenderer`.)\n */\nexport class GLMeshCache {\n private readonly map = new WeakMap<Mesh, GLMeshHandle>();\n /** Meshes this context has drawn at least once; see `uploadRecurring`. */\n private readonly seen = new WeakSet<Mesh>();\n private readonly finalizer: FinalizationRegistry<MeshResources>;\n /** Every persistent upload not yet freed, so `dispose` can reach them. */\n private readonly persistent = new Set<MeshResources>();\n private readonly pendingDeletes: MeshResources[] = [];\n private disposed = false;\n /** Transient resources allocated this frame; freed at end of render(). */\n private readonly transientThisFrame: MeshResources[] = [];\n\n constructor(\n private readonly gl: WebGL2RenderingContext,\n private readonly aPositionLoc: number,\n ) {\n this.finalizer = new FinalizationRegistry<MeshResources>((resources) => {\n // Defer the actual gl.delete* until the renderer's next render(),\n // when no VAO/buffer is bound mid-draw. Direct deletion from the\n // finalizer caused use-after-free crashes when GC fired between\n // bindVertexArray and drawElements inside dispatch().\n if (!this.persistent.delete(resources)) return;\n this.pendingDeletes.push(resources);\n });\n }\n\n handleFor(mesh: Mesh): GLMeshHandle {\n const cached = this.map.get(mesh);\n if (cached) return cached;\n const { handle, vbo, ibo } = this.upload(mesh);\n this.map.set(mesh, handle);\n const resources = { vao: handle.vao, vbo, ibo };\n this.persistent.add(resources);\n // Register so the GL resources get freed when `mesh` is GC'd. The\n // unregister token (mesh) lets us cancel if the Mesh is somehow\n // re-uploaded under a different cache, though that's not a normal flow.\n this.finalizer.register(mesh, resources, mesh);\n return handle;\n }\n\n /**\n * Upload a Mesh that the caller knows is single-use (e.g. the per-frame\n * stroke ribbon from `tessellateStroke`). Returns a handle backed by fresh\n * GL resources that the renderer will free deterministically at the end\n * of the current frame via `freeTransient()`. Bypasses the WeakMap cache\n * and the FinalizationRegistry, so transient meshes never wait on GC.\n */\n uploadTransient(mesh: Mesh): GLMeshHandle {\n const { handle, vbo, ibo } = this.upload(mesh);\n this.transientThisFrame.push({ vao: handle.vao, vbo, ibo });\n return handle;\n }\n\n /**\n * Upload a Mesh that may or may not recur across frames. Its first sight in\n * *this* context takes `uploadTransient`; every later one takes the\n * persistent handle. One transient upload to find out is cheaper than\n * stranding a persistent VAO on a mesh that never returns, whose release\n * would wait on GC. The transient upload does not populate the persistent\n * map, so steady-state reuse begins on the third frame.\n */\n uploadRecurring(mesh: Mesh): GLMeshHandle {\n if (this.seen.has(mesh)) return this.handleFor(mesh);\n this.seen.add(mesh);\n return this.uploadTransient(mesh);\n }\n\n /**\n * Free all transient resources allocated since the last call. Called by\n * the renderer at the end of each `render()`. Safe under context loss.\n */\n freeTransient(): void {\n if (this.transientThisFrame.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.transientThisFrame.length = 0;\n return;\n }\n for (const r of this.transientThisFrame) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.transientThisFrame.length = 0;\n }\n\n /** @internal — for tests asserting the transient-list size. */\n _transientCount(): number {\n return this.transientThisFrame.length;\n }\n\n /**\n * Free GL resources whose Mesh has been GC'd since the last drain.\n * Called by the renderer at the top of each `render()`, before any draws.\n */\n drainPendingDeletes(): void {\n if (this.pendingDeletes.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.pendingDeletes.length = 0;\n return;\n }\n for (const r of this.pendingDeletes) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.pendingDeletes.length = 0;\n }\n\n /**\n * Free every GL resource this cache holds — persistent, pending and\n * transient — and ignore finalizers from here on. Idempotent. Unlike the\n * other paths this does not wait on GC, which is what lets a renderer on a\n * context it does not own give back everything it uploaded.\n */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.freeTransient();\n for (const r of this.persistent) this.pendingDeletes.push(r);\n this.persistent.clear();\n this.drainPendingDeletes();\n }\n\n /** @internal — for tests asserting the queue size. */\n _pendingDeleteCount(): number {\n return this.pendingDeletes.length;\n }\n\n /** @internal — for tests that need to simulate the finalizer firing. */\n _enqueueDeleteForTest(resources: MeshResources): void {\n this.pendingDeletes.push(resources);\n }\n\n private upload(mesh: Mesh): { handle: GLMeshHandle; vbo: WebGLBuffer; ibo: WebGLBuffer } {\n const gl = this.gl;\n const vao = gl.createVertexArray();\n if (!vao) throw new Error('createVertexArray returned null');\n gl.bindVertexArray(vao);\n\n const vbo = gl.createBuffer();\n if (!vbo) throw new Error('createBuffer (VBO) returned null');\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n gl.bufferData(gl.ARRAY_BUFFER, mesh.vertices, gl.STATIC_DRAW);\n\n gl.enableVertexAttribArray(this.aPositionLoc);\n gl.vertexAttribPointer(this.aPositionLoc, 2, gl.FLOAT, false, 0, 0);\n\n const ibo = gl.createBuffer();\n if (!ibo) throw new Error('createBuffer (IBO) returned null');\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, mesh.indices, gl.STATIC_DRAW);\n\n gl.bindVertexArray(null);\n\n return {\n handle: {\n vao,\n indexCount: mesh.indices.length,\n requiresStencil: mesh.requiresStencil ?? false,\n anchorA: mesh.anchorA,\n anchorB: mesh.anchorB,\n anchorT: mesh.anchorT,\n },\n vbo,\n ibo,\n };\n }\n}\n"],"mappings":";AA8CA,IAAaA,IAAb,MAAyB;CAaJ;CACA;CAbnB,sBAAuB,IAAI,QAA4B;CAEvD,uBAAwB,IAAI,QAAc;CAC1C;CAEA,6BAA8B,IAAI,IAAmB;CACrD,iBAAmD,CAAC;CACpD,WAAmB;CAEnB,qBAAuD,CAAC;CAExD,YACE,GACA,GACA;EACA,AAHiB,KAAA,KAAAC,GACA,KAAA,eAAAC,GAEjB,KAAK,YAAY,IAAI,sBAAqC,MAAc;GAKtE,AAAK,KAAK,WAAW,OAAOC,CAAS,KACrC,KAAK,eAAe,KAAKA,CAAS;EACpC,CAAC;CACH;CAEA,UAAU,GAA0B;EAClC,IAAMC,IAAS,KAAK,IAAI,IAAIC,CAAI;EAChC,IAAID,GAAQ,OAAOA;EACnB,IAAM,EAAE,WAAQ,QAAK,WAAQ,KAAK,OAAOC,CAAI;EAC7C,KAAK,IAAI,IAAIA,GAAMC,CAAM;EACzB,IAAMH,IAAY;GAAE,KAAKG,EAAO;GAAK;GAAK;EAAI;EAM9C,OALA,KAAK,WAAW,IAAIH,CAAS,GAI7B,KAAK,UAAU,SAASE,GAAMF,GAAWE,CAAI,GACtCC;CACT;CASA,gBAAgB,GAA0B;EACxC,IAAM,EAAE,WAAQ,QAAK,WAAQ,KAAK,OAAOD,CAAI;EAE7C,OADA,KAAK,mBAAmB,KAAK;GAAE,KAAKC,EAAO;GAAK;GAAK;EAAI,CAAC,GACnDA;CACT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K,MAAU,MAAM,iCAAiC;EAC3D,EAAG,gBAAgBA,CAAG;EAEtB,IAAMC,IAAMR,EAAG,aAAa;EAC5B,IAAI,CAACQ,GAAK,MAAU,MAAM,kCAAkC;EAK5D,AAJAR,EAAG,WAAWA,EAAG,cAAcQ,CAAG,GAClCR,EAAG,WAAWA,EAAG,cAAcI,EAAK,UAAUJ,EAAG,WAAW,GAE5DA,EAAG,wBAAwB,KAAK,YAAY,GAC5CA,EAAG,oBAAoB,KAAK,cAAc,GAAGA,EAAG,OAAO,IAAO,GAAG,CAAC;EAElE,IAAMS,IAAMT,EAAG,aAAa;EAC5B,IAAI,CAACS,GAAK,MAAU,MAAM,kCAAkC;EAM5D,OALAT,EAAG,WAAWA,EAAG,sBAAsBS,CAAG,GAC1CT,EAAG,WAAWA,EAAG,sBAAsBI,EAAK,SAASJ,EAAG,WAAW,GAEnEA,EAAG,gBAAgB,IAAI,GAEhB;GACL,QAAQ;IACN;IACA,YAAYI,EAAK,QAAQ;IACzB,iBAAiBA,EAAK,mBAAmB;IACzC,SAASA,EAAK;IACd,SAASA,EAAK;IACd,SAASA,EAAK;GAChB;GACA;GACA;EACF;CACF;AACF"}
@@ -1,51 +0,0 @@
1
- //#region src/renderer/cache/GLTextureCache.ts
2
- var e = class {
3
- gl;
4
- map = /* @__PURE__ */ new Map();
5
- wraps = /* @__PURE__ */ new Map();
6
- constructor(e) {
7
- this.gl = e;
8
- }
9
- has(e) {
10
- return this.map.has(e);
11
- }
12
- upload(e, t, n = "clamp") {
13
- let r = this.map.get(e);
14
- if (r) return this.wraps.get(e) !== n && this.applyWrap(e, r, n), e;
15
- let i = this.gl, a = i.createTexture();
16
- if (!a) throw Error(`GLTextureCache: createTexture failed for id="${e}"`);
17
- let o = n === "repeat" ? i.REPEAT : i.CLAMP_TO_EDGE;
18
- return i.bindTexture(i.TEXTURE_2D, a), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, t), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.LINEAR), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.LINEAR), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, o), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, o), i.bindTexture(i.TEXTURE_2D, null), this.map.set(e, a), this.wraps.set(e, n), e;
19
- }
20
- applyWrap(e, t, n) {
21
- let r = this.gl, i = n === "repeat" ? r.REPEAT : r.CLAMP_TO_EDGE;
22
- r.bindTexture(r.TEXTURE_2D, t), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, i), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, i), r.bindTexture(r.TEXTURE_2D, null), this.wraps.set(e, n);
23
- }
24
- uploadR8(e, t, n, r) {
25
- if (this.map.has(e)) return;
26
- let i = this.gl, a = i.createTexture();
27
- if (!a) throw Error(`GLTextureCache: createTexture failed for id="${e}"`);
28
- i.bindTexture(i.TEXTURE_2D, a), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(i.TEXTURE_2D, 0, i.R8, t, n, 0, i.RED, i.UNSIGNED_BYTE, r), i.pixelStorei(i.UNPACK_ALIGNMENT, 4), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.LINEAR), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.LINEAR), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.bindTexture(i.TEXTURE_2D, null), this.map.set(e, a), this.wraps.set(e, "clamp");
29
- }
30
- subImageR8(e, t, n, r, i, a) {
31
- let o = this.map.get(e);
32
- if (!o) throw Error(`GLTextureCache: texture "${e}" not uploaded`);
33
- let s = this.gl;
34
- s.bindTexture(s.TEXTURE_2D, o), s.pixelStorei(s.UNPACK_ALIGNMENT, 1), s.texSubImage2D(s.TEXTURE_2D, 0, t, n, r, i, s.RED, s.UNSIGNED_BYTE, a), s.pixelStorei(s.UNPACK_ALIGNMENT, 4), s.bindTexture(s.TEXTURE_2D, null);
35
- }
36
- bind(e, t) {
37
- let n = this.map.get(e);
38
- if (!n) throw Error(`GLTextureCache: texture "${e}" not uploaded`);
39
- let r = this.gl;
40
- r.activeTexture(r.TEXTURE0 + t), r.bindTexture(r.TEXTURE_2D, n);
41
- }
42
- free() {
43
- let e = this.gl;
44
- for (let t of this.map.values()) e.deleteTexture(t);
45
- this.map.clear(), this.wraps.clear();
46
- }
47
- };
48
- //#endregion
49
- export { e as GLTextureCache };
50
-
51
- //# sourceMappingURL=GLTextureCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GLTextureCache.js","names":["GLTextureCache","gl","id","cached","wrap","tex","wrapMode","source","mode","width","height","data","x","y","w","h","unit"],"sources":["../../../src/renderer/cache/GLTextureCache.ts"],"sourcesContent":["/**\n * GL texture upload + cache for MSDF font atlases (and future images).\n *\n * Textures are keyed by a string id (the font family name or image id).\n * Pixels are uploaded once per id; a later upload of the same id reuses the\n * texture and only re-applies its wrap mode when that changed.\n * The cache is GL-context-bound; discard and create a new one on context loss.\n *\n * Atlas format: RGBA UNSIGNED_BYTE, linear filtering, no mipmaps.\n * Mipmap generation is deliberately skipped — MSDF works correctly with\n * linear filtering, and mipmap resampling corrupts the multi-channel SDF signal.\n */\n\ntype TexSource = HTMLImageElement | ImageBitmap | ImageData | HTMLCanvasElement;\n\n/** How a texture samples outside `0..1`. Pattern tiles need `'repeat'`;\n * everything else clamps. WebGL2 allows `REPEAT` on NPOT textures, so a\n * tile of any size tiles correctly. */\nexport type TextureWrap = 'clamp' | 'repeat';\n\nexport class GLTextureCache {\n private readonly map = new Map<string, WebGLTexture>();\n private readonly wraps = new Map<string, TextureWrap>();\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n has(id: string): boolean {\n return this.map.has(id);\n }\n\n /** Uploads the pixels once per id. `wrap` is re-applied whenever it differs\n * from what the id was last uploaded under: the same registered image can\n * be a clamped shader texture in one draw and a repeating pattern tile in\n * the next, and first-upload-wins gave the second one the first one's mode. */\n upload(id: string, source: TexSource, wrap: TextureWrap = 'clamp'): string {\n const cached = this.map.get(id);\n if (cached) {\n if (this.wraps.get(id) !== wrap) this.applyWrap(id, cached, wrap);\n return id;\n }\n\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n\n const wrapMode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source as TexImageSource);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapMode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapMode);\n\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n this.map.set(id, tex);\n this.wraps.set(id, wrap);\n return id;\n }\n\n private applyWrap(id: string, tex: WebGLTexture, wrap: TextureWrap): void {\n const gl = this.gl;\n const mode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, mode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, mode);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.wraps.set(id, wrap);\n }\n\n /** Create a single-channel R8 texture from raw bytes (full upload).\n * No-op if `id` already exists. Same LINEAR/CLAMP params as `upload`;\n * UNPACK_ALIGNMENT dropped to 1 for non-4-aligned row widths. */\n uploadR8(id: string, width: number, height: number, data: Uint8Array): void {\n if (this.map.has(id)) return;\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8, width, height, 0, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.map.set(id, tex);\n this.wraps.set(id, 'clamp');\n }\n\n /** Patch a rect of an existing R8 texture with tightly-packed w×h bytes. */\n subImageR8(id: string, x: number, y: number, w: number, h: number, data: Uint8Array): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, w, h, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n bind(id: string, unit: number): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n }\n\n /**\n * Delete every uploaded GL texture and clear the map. Called by\n * `WeaselRenderer.dispose()`. The cache is unusable but refillable\n * afterward — a subsequent `upload()` for a previously-seen id re-creates\n * the texture rather than restoring the deleted one.\n */\n free(): void {\n const gl = this.gl;\n for (const tex of this.map.values()) {\n gl.deleteTexture(tex);\n }\n this.map.clear();\n this.wraps.clear();\n }\n}\n"],"mappings":";AAoBA,IAAaA,IAAb,MAA4B;CAIG;CAH7B,sBAAuB,IAAI,IAA0B;CACrD,wBAAyB,IAAI,IAAyB;CAEtD,YAAY,GAA6C;EAA5B,KAAA,KAAAC;CAA6B;CAE1D,IAAI,GAAqB;EACvB,OAAO,KAAK,IAAI,IAAIC,CAAE;CACxB;CAMA,OAAO,GAAY,GAAmB,IAAoB,SAAiB;EACzE,IAAMC,IAAS,KAAK,IAAI,IAAID,CAAE;EAC9B,IAAIC,GAEF,OADI,KAAK,MAAM,IAAID,CAAE,MAAME,KAAM,KAAK,UAAUF,GAAIC,GAAQC,CAAI,GACzDF;EAGT,IAAMD,IAAK,KAAK,IACVI,IAAMJ,EAAG,cAAc;EAC7B,IAAI,CAACI,GAAK,MAAU,MAAM,gDAAgDH,EAAG,EAAE;EAE/E,IAAMI,IAAWF,MAAS,WAAWH,EAAG,SAASA,EAAG;EAcpD,OAZAA,EAAG,YAAYA,EAAG,YAAYI,CAAG,GACjCJ,EAAG,WAAWA,EAAG,YAAY,GAAGA,EAAG,MAAMA,EAAG,MAAMA,EAAG,eAAeM,CAAwB,GAE5FN,EAAG,cAAcA,EAAG,YAAYA,EAAG,oBAAoBA,EAAG,MAAM,GAChEA,EAAG,cAAcA,EAAG,YAAYA,EAAG,oBAAoBA,EAAG,MAAM,GAChEA,EAAG,cAAcA,EAAG,YAAYA,EAAG,gBAAgBK,CAAQ,GAC3DL,EAAG,cAAcA,EAAG,YAAYA,EAAG,gBAAgBK,CAAQ,GAE3DL,EAAG,YAAYA,EAAG,YAAY,IAAI,GAElC,KAAK,I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,GAAY,GAAW,GAAW,GAAW,GAAW,GAAwB;EACzF,IAAMG,IAAM,KAAK,IAAI,IAAIH,CAAE;EAC3B,IAAI,CAACG,GAAK,MAAU,MAAM,4BAA4BH,EAAG,eAAe;EACxE,IAAMD,IAAK,KAAK;EAKhB,AAJAA,EAAG,YAAYA,EAAG,YAAYI,CAAG,GACjCJ,EAAG,YAAYA,EAAG,kBAAkB,CAAC,GACrCA,EAAG,cAAcA,EAAG,YAAY,GAAGW,GAAGC,GAAGC,GAAGC,GAAGd,EAAG,KAAKA,EAAG,eAAeU,CAAI,GAC7EV,EAAG,YAAYA,EAAG,kBAAkB,CAAC,GACrCA,EAAG,YAAYA,EAAG,YAAY,IAAI;CACpC;CAEA,KAAK,GAAY,GAAoB;EACnC,IAAMI,IAAM,KAAK,IAAI,IAAIH,CAAE;EAC3B,IAAI,CAACG,GAAK,MAAU,MAAM,4BAA4BH,EAAG,eAAe;EACxE,IAAMD,IAAK,KAAK;EAEhB,AADAA,EAAG,cAAcA,EAAG,WAAWe,CAAI,GACnCf,EAAG,YAAYA,EAAG,YAAYI,CAAG;CACnC;CAQA,OAAa;EACX,IAAMJ,IAAK,KAAK;EAChB,KAAK,IAAMI,KAAO,KAAK,IAAI,OAAO,GAChC,EAAG,cAAcA,CAAG;EAGtB,AADA,KAAK,IAAI,MAAM,GACf,KAAK,MAAM,MAAM;CACnB;AACF"}
@@ -1,82 +0,0 @@
1
- import { resolveGradientStops as e, sampleResolvedStops as t } from "../../core/gradient.js";
2
- //#region src/renderer/cache/GradientRampAtlas.ts
3
- var n = 256, r = 16, i = 1024;
4
- function a(r, i = "rgb") {
5
- let a = new Uint8ClampedArray(n * 4);
6
- if (r.length === 0) return a;
7
- let o = e(r);
8
- for (let e = 0; e < n; e++) {
9
- let [n, r, s, c] = t(o, e / 255, i);
10
- a[e * 4] = n * 255, a[e * 4 + 1] = r * 255, a[e * 4 + 2] = s * 255, a[e * 4 + 3] = c * 255;
11
- }
12
- return a;
13
- }
14
- function o(e, t) {
15
- return `${t}|${JSON.stringify(e)}`;
16
- }
17
- var s = class {
18
- gl;
19
- rowByKey = /* @__PURE__ */ new Map();
20
- texture = null;
21
- rows = 0;
22
- pixels = /* @__PURE__ */ new Uint8ClampedArray();
23
- totalQueries = 0;
24
- cacheHits = 0;
25
- constructor(e) {
26
- this.gl = e;
27
- }
28
- get height() {
29
- return this.rows;
30
- }
31
- upload(e, t = "rgb") {
32
- let n = o(e, t);
33
- this.totalQueries++;
34
- let r = this.rowByKey.get(n);
35
- if (r !== void 0) return this.cacheHits++, this.rowByKey.delete(n), this.rowByKey.set(n, r), r;
36
- let i = this.claimRow();
37
- return this.writeRow(i, a(e, t)), this.rowByKey.set(n, i), i;
38
- }
39
- wouldReshape(e, t = "rgb") {
40
- return this.rowByKey.size !== 0 && !this.rowByKey.has(o(e, t)) && this.rowByKey.size >= this.rows;
41
- }
42
- rowV(e) {
43
- return (e + .5) / (this.rows || 1);
44
- }
45
- bind(e) {
46
- let t = this.gl;
47
- t.activeTexture(t.TEXTURE0 + e), t.bindTexture(t.TEXTURE_2D, this.texture);
48
- }
49
- hitRate() {
50
- return this.totalQueries === 0 ? 0 : this.cacheHits / this.totalQueries;
51
- }
52
- resetStats() {
53
- this.totalQueries = 0, this.cacheHits = 0;
54
- }
55
- free() {
56
- this.texture && this.gl.deleteTexture(this.texture), this.texture = null, this.rows = 0, this.pixels = /* @__PURE__ */ new Uint8ClampedArray(), this.rowByKey.clear();
57
- }
58
- claimRow() {
59
- if (this.rowByKey.size < this.rows) return this.rowByKey.size;
60
- if (this.rows < i) return this.resize(this.rows === 0 ? r : this.rows * 2), this.rowByKey.size;
61
- let [e, t] = this.rowByKey.entries().next().value;
62
- return this.rowByKey.delete(e), t;
63
- }
64
- resize(e) {
65
- let t = this.gl, r = new Uint8ClampedArray(n * e * 4);
66
- if (r.set(this.pixels), this.pixels = r, this.rows = e, this.texture) t.bindTexture(t.TEXTURE_2D, this.texture);
67
- else {
68
- let e = t.createTexture();
69
- if (!e) throw Error("GradientRampAtlas: createTexture failed");
70
- this.texture = e, t.bindTexture(t.TEXTURE_2D, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE);
71
- }
72
- t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, n, e, 0, t.RGBA, t.UNSIGNED_BYTE, this.pixels), t.bindTexture(t.TEXTURE_2D, null);
73
- }
74
- writeRow(e, t) {
75
- let r = this.gl;
76
- this.pixels.set(t, e * n * 4), r.bindTexture(r.TEXTURE_2D, this.texture), r.texSubImage2D(r.TEXTURE_2D, 0, 0, e, n, 1, r.RGBA, r.UNSIGNED_BYTE, t), r.bindTexture(r.TEXTURE_2D, null);
77
- }
78
- };
79
- //#endregion
80
- export { s as GradientRampAtlas, i as RAMP_ATLAS_MAX_ROWS, n as RAMP_WIDTH, a as buildGradientRamp };
81
-
82
- //# sourceMappingURL=GradientRampAtlas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GradientRampAtlas.js","names":["RAMP_WIDTH","INITIAL_ROWS","RAMP_ATLAS_MAX_ROWS","buildGradientRamp","data","stops","resolved","resolveGradientStops","i","r","g","b","a","sampleResolvedStops","space","rampKey","GradientRampAtlas","gl","key","existing","row","unit","lruKey","lruRow","next","rows","tex","ramp"],"sources":["../../../src/renderer/cache/GradientRampAtlas.ts"],"sourcesContent":["/**\n * CPU gradient-ramp builder + the GL texture every baked ramp lives in.\n *\n * Each unique stop list is baked once into a 256-texel strip and written to its\n * own **row** of one RGBA texture, keyed by `JSON.stringify(stops)`. One\n * texture rather than one per ramp is what lets a gradient take a batch texture\n * slot the way a bitmap or a font atlas does: every gradient in a frame samples\n * the same unit, so a run does not break per gradient. The atlas is\n * GL-context-bound; discard and recreate on context loss.\n *\n * Output convention §2: texels are stored as straight RGBA. The fragment\n * shader applies premultiplication before writing outColor.\n */\n\nimport type { ColorSpace, GradStop } from '@weasel-js/paint';\nimport { resolveGradientStops, sampleResolvedStops } from '../../core/gradient';\n\n/** Texels across one ramp — the resolution a gradient is sampled at. */\nexport const RAMP_WIDTH = 256;\n\n/** Rows the atlas starts at, doubling from there. */\nconst INITIAL_ROWS = 16;\n\n/**\n * Rows the atlas stops growing at, past which the least recently used row is\n * recycled.\n *\n * WebGL2 guarantees `MAX_TEXTURE_SIZE` of at least 2048, so this is available\n * everywhere without a `getParameter` — which the GL recorder would answer with\n * a recording function rather than a number. A cap is also what bounds an\n * animating gradient, which mints a new stop list every frame and would\n * otherwise grow the atlas until it could not grow again.\n */\nexport const RAMP_ATLAS_MAX_ROWS = 1024;\n\n/** Bake gradient stops into a 256-entry RGBA lookup strip, which the shader\n * samples instead of evaluating stops per fragment. `space` is the gradient's\n * `interpolate` — the ramp is where a non-sRGB blend is paid for, once. */\nexport function buildGradientRamp(stops: GradStop[], space: ColorSpace = 'rgb'): Uint8ClampedArray {\n const data = new Uint8ClampedArray(RAMP_WIDTH * 4);\n if (stops.length === 0) return data;\n\n const resolved = resolveGradientStops(stops);\n for (let i = 0; i < RAMP_WIDTH; i++) {\n const [r, g, b, a] = sampleResolvedStops(resolved, i / (RAMP_WIDTH - 1), space);\n data[i * 4] = r * 255;\n data[i * 4 + 1] = g * 255;\n data[i * 4 + 2] = b * 255;\n data[i * 4 + 3] = a * 255;\n }\n\n return data;\n}\n\n/** The row identity. Two gradients with the same stops and different\n * `interpolate` bake to different texels, so the space is part of the key. */\nfunction rampKey(stops: GradStop[], space: ColorSpace): string {\n return `${space}|${JSON.stringify(stops)}`;\n}\n\nexport class GradientRampAtlas {\n /** Row per stop list, in least-recently-used order: a hit re-inserts, so the\n * first entry is the row a full atlas recycles. */\n private readonly rowByKey = new Map<string, number>();\n private texture: WebGLTexture | null = null;\n private rows = 0;\n /** Mirror of the texture, so growth can respecify it without re-baking every\n * ramp it already holds. */\n private pixels = new Uint8ClampedArray(0);\n private totalQueries = 0;\n private cacheHits = 0;\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n /** Rows the atlas currently holds — its texture height. */\n get height(): number {\n return this.rows;\n }\n\n /**\n * Bake `stops` into a row and return it, reusing the row an identical stop\n * list already holds.\n *\n * **A returned row outlives the frame only while the atlas has room.** Past\n * `RAMP_ATLAS_MAX_ROWS` an upload recycles the least recently used row, which\n * rewrites texels a row handed out earlier still names. Nothing that defers\n * its draw past this call may hold a row across another `upload` without\n * arranging to be flushed first.\n */\n upload(stops: GradStop[], space: ColorSpace = 'rgb'): number {\n const key = rampKey(stops, space);\n this.totalQueries++;\n const existing = this.rowByKey.get(key);\n if (existing !== undefined) {\n this.cacheHits++;\n this.rowByKey.delete(key);\n this.rowByKey.set(key, existing);\n return existing;\n }\n\n const row = this.claimRow();\n this.writeRow(row, buildGradientRamp(stops, space));\n this.rowByKey.set(key, row);\n return row;\n }\n\n /**\n * Whether uploading `stops` would move where existing rows sit — by growing\n * the atlas, which changes every row's `v`, or by recycling one, which\n * rewrites its texels.\n *\n * Anything holding a row past this call asks first and gets itself out of\n * the way, because neither can be undone once it has happened.\n */\n wouldReshape(stops: GradStop[], space: ColorSpace = 'rgb'): boolean {\n // An atlas holding nothing has no row to move, so its first growth is free.\n if (this.rowByKey.size === 0) return false;\n return !this.rowByKey.has(rampKey(stops, space))\n && this.rowByKey.size >= this.rows;\n }\n\n /**\n * The `v` a row is sampled at — its center.\n *\n * The center is load-bearing: the atlas filters LINEAR, so a `v` anywhere\n * else blends the ramp beside it into this one. At the center the neighbor's\n * weight is exactly zero.\n */\n rowV(row: number): number {\n return (row + 0.5) / (this.rows || 1);\n }\n\n bind(unit: number): void {\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n\n hitRate(): number {\n if (this.totalQueries === 0) return 0;\n return this.cacheHits / this.totalQueries;\n }\n\n resetStats(): void {\n this.totalQueries = 0;\n this.cacheHits = 0;\n }\n\n /**\n * Delete the atlas texture and forget every row in it. Called by\n * `WeaselRenderer.dispose()`. The CPU mirror goes with it, so the atlas is\n * unusable but refillable afterward (stats are left as-is; call\n * `resetStats()` separately if desired).\n */\n free(): void {\n if (this.texture) this.gl.deleteTexture(this.texture);\n this.texture = null;\n this.rows = 0;\n this.pixels = new Uint8ClampedArray(0);\n this.rowByKey.clear();\n }\n\n /** The row the next ramp is written to: a free one, a taller atlas, or the\n * least recently used row of a full one. */\n private claimRow(): number {\n if (this.rowByKey.size < this.rows) return this.rowByKey.size;\n if (this.rows < RAMP_ATLAS_MAX_ROWS) {\n this.resize(this.rows === 0 ? INITIAL_ROWS : this.rows * 2);\n return this.rowByKey.size;\n }\n const [lruKey, lruRow] = this.rowByKey.entries().next().value as [string, number];\n this.rowByKey.delete(lruKey);\n return lruRow;\n }\n\n /** Grow to `rows`, keeping every row at the index it already had — a row\n * index is a stable name, and callers hold them. */\n private resize(rows: number): void {\n const gl = this.gl;\n const next = new Uint8ClampedArray(RAMP_WIDTH * rows * 4);\n next.set(this.pixels);\n this.pixels = next;\n this.rows = rows;\n\n if (!this.texture) {\n const tex = gl.createTexture();\n if (!tex) throw new Error('GradientRampAtlas: createTexture failed');\n this.texture = tex;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA,\n RAMP_WIDTH, rows, 0,\n gl.RGBA, gl.UNSIGNED_BYTE, this.pixels,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n private writeRow(row: number, ramp: Uint8ClampedArray): void {\n const gl = this.gl;\n this.pixels.set(ramp, row * RAMP_WIDTH * 4);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texSubImage2D(\n gl.TEXTURE_2D, 0, 0, row,\n RAMP_WIDTH, 1,\n gl.RGBA, gl.UNSIGNED_BYTE, ramp,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n}\n"],"mappings":";;AAkBA,IAAaA,IAAa,KAGpBC,IAAe,IAYRC,IAAsB;AAKnC,SAAgBC,EAAkB,GAAmB,IAAoB,OAA0B;CACjG,IAAMC,IAAO,IAAI,kBAAkBJ,IAAa,CAAC;CACjD,IAAIK,EAAM,WAAW,GAAG,OAAOD;CAE/B,IAAME,IAAWC,EAAqBF,CAAK;CAC3C,KAAK,IAAIG,IAAI,GAAGA,IAAIR,GAAY,KAAK;EACnC,IAAM,CAACS,GAAGC,GAAGC,GAAGC,KAAKC,EAAoBP,GAAUE,IAAK,KAAiBM,CAAK;EAI9E,AAHA,EAAKN,IAAI,KAASC,IAAI,KACtB,EAAKD,IAAI,IAAI,KAAKE,IAAI,KACtB,EAAKF,IAAI,IAAI,KAAKG,IAAI,KACtB,EAAKH,IAAI,IAAI,KAAKI,IAAI;CACxB;CAEA,OAAOR;AACT;AAIA,SAASW,EAAQ,GAAmB,GAA2B;CAC7D,OAAO,GAAGD,EAAM,GAAG,KAAK,UAAUT,CAAK;AACzC;AAEA,IAAaW,IAAb,MAA+B;CAYA;CAT7B,2BAA4B,IAAI,IAAoB;CACpD,UAAuC;CACvC,OAAe;CAGf,yBAAiB,IAAI,kBAAmB;CACxC,eAAuB;CACvB,YAAoB;CAEpB,YAAY,GAA6C;EAA5B,KAAA,KAAAC;CAA6B;CAG1D,IAAI,SAAiB;EACnB,OAA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IAAI;CACpC;AACF"}
@@ -1,13 +0,0 @@
1
- import { tessellate as e } from "@weasel-js/geom/tessellate";
2
- //#region src/renderer/cache/cache.ts
3
- var t = /* @__PURE__ */ new WeakMap();
4
- function n(n) {
5
- let r = t.get(n);
6
- if (r !== void 0) return r;
7
- let i = e(n);
8
- return t.set(n, i), i;
9
- }
10
- //#endregion
11
- export { n as getMesh };
12
-
13
- //# sourceMappingURL=cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","names":["cache","getMesh","cached","path","mesh","tessellate"],"sources":["../../../src/renderer/cache/cache.ts"],"sourcesContent":["import type { Path } from '@weasel-js/core';\nimport { type Mesh, tessellate } from '@weasel-js/geom/tessellate';\n\nlet cache = new WeakMap<Path, Mesh>();\n\n/**\n * Return the tessellated Mesh for `path`, computing and caching on first call.\n * Cached by Path identity (WeakMap) — different Path objects with the same\n * coords are distinct cache entries.\n *\n * Note: solid-fill rect paths bypass this cache entirely — they go into the\n * rect batch in `draw.ts`. The cache only serves polygon paths (where tessellation is\n * non-trivial and Path-object stability is the right contract).\n *\n * Also bypassed whenever `DrawContext.flattenTolerance` is set: `fillMeshHandle`\n * (see `../draw`) routes custom-tolerance fills through a fresh transient\n * tessellation instead of this cache.\n */\nexport function getMesh(path: Path): Mesh {\n const cached = cache.get(path);\n if (cached !== undefined) return cached;\n const mesh = tessellate(path);\n cache.set(path, mesh);\n return mesh;\n}\n\n/** Test helper. Do not call from product code. */\nexport function _resetCacheForTests(): void {\n cache = new WeakMap();\n}\n"],"mappings":";;AAGA,IAAIA,oBAAQ,IAAI,QAAoB;AAepC,SAAgBC,EAAQ,GAAkB;CACxC,IAAMC,IAASF,EAAM,IAAIG,CAAI;CAC7B,IAAID,MAAW,KAAA,GAAW,OAAOA;CACjC,IAAME,IAAOC,EAAWF,CAAI;CAE5B,OADAH,EAAM,IAAIG,GAAMC,CAAI,GACbA;AACT"}