@weasel-js/core 1.9.2 → 1.9.4

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 (542) hide show
  1. package/CHANGELOG.md +393 -0
  2. package/README.md +2 -2
  3. package/dist/WeaselProvider.js +5 -5
  4. package/dist/affordances/composeAffordanceLayer.js +10 -20
  5. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  6. package/dist/affordances/cornerResize.js +25 -17
  7. package/dist/affordances/cornerResize.js.map +1 -1
  8. package/dist/affordances/hitAffordanceRegions.js +27 -20
  9. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  10. package/dist/affordances/rotationHandle.js +18 -18
  11. package/dist/affordances/rotationHandle.js.map +1 -1
  12. package/dist/animation/behaviors/momentum.js +93 -55
  13. package/dist/animation/behaviors/momentum.js.map +1 -1
  14. package/dist/animation/loop.js +10 -12
  15. package/dist/animation/loop.js.map +1 -1
  16. package/dist/animation/reflow.js +8 -8
  17. package/dist/animation/reflow.js.map +1 -1
  18. package/dist/animation/stagger.js +64 -56
  19. package/dist/animation/stagger.js.map +1 -1
  20. package/dist/animation/timeline/booking.js +62 -54
  21. package/dist/animation/timeline/booking.js.map +1 -1
  22. package/dist/animation/timeline/createTimeline.js +85 -76
  23. package/dist/animation/timeline/createTimeline.js.map +1 -1
  24. package/dist/animation/timeline/sampleTrack.js +13 -5
  25. package/dist/animation/timeline/sampleTrack.js.map +1 -1
  26. package/dist/animation/useAnimator.js +45 -35
  27. package/dist/animation/useAnimator.js.map +1 -1
  28. package/dist/animation/wrappers/animateLifecycle.js +31 -24
  29. package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
  30. package/dist/animation/wrappers/animateOnSetPose.js +28 -26
  31. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
  32. package/dist/animation/wrappers/instantPose.js +13 -0
  33. package/dist/animation/wrappers/instantPose.js.map +1 -0
  34. package/dist/{poseDescriptor-D-OH-tu5.d.ts → autoPoseDescriptor-Ct7yqivU.d.ts} +28 -3
  35. package/dist/barrel/chrome.js +16 -0
  36. package/dist/barrel/input.js +19 -0
  37. package/dist/barrel/interactions.js +42 -0
  38. package/dist/barrel/paint.js +18 -0
  39. package/dist/barrel/paths.js +19 -0
  40. package/dist/barrel/renderer.js +20 -0
  41. package/dist/barrel/routing.js +51 -0
  42. package/dist/barrel/text.js +18 -0
  43. package/dist/barrel/viewport.js +52 -0
  44. package/dist/builtins-DPcdghtB.d.ts +1223 -0
  45. package/dist/canvas/Canvas.js +363 -448
  46. package/dist/canvas/Canvas.js.map +1 -1
  47. package/dist/canvas/CanvasView.js +164 -165
  48. package/dist/canvas/CanvasView.js.map +1 -1
  49. package/dist/canvas/CursorCoordsHud.js +37 -32
  50. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  51. package/dist/canvas/DrawCanvas.js +49 -43
  52. package/dist/canvas/DrawCanvas.js.map +1 -1
  53. package/dist/canvas/MinimapCanvas.js +26 -25
  54. package/dist/canvas/MinimapCanvas.js.map +1 -1
  55. package/dist/canvas/NodeShape.js +59 -377
  56. package/dist/canvas/NodeShape.js.map +1 -1
  57. package/dist/canvas/PickHud.js +50 -47
  58. package/dist/canvas/PickHud.js.map +1 -1
  59. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +167 -0
  60. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
  61. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +13 -13
  62. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +67 -0
  63. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
  64. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
  65. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
  66. package/dist/canvas/SceneCanvas/coordTrace.js +10 -0
  67. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
  68. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +146 -92
  69. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  70. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
  71. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
  72. package/dist/canvas/SceneCanvas/features.js +1 -0
  73. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  74. package/dist/canvas/SceneCanvas/isDev.js +12 -0
  75. package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
  76. package/dist/canvas/SceneCanvas/poseGeometry.js +29 -28
  77. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  78. package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
  79. package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/props.js +38 -0
  81. package/dist/canvas/SceneCanvas/props.js.map +1 -0
  82. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
  83. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  84. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  85. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +46 -48
  86. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  87. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +33 -33
  88. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  89. package/dist/canvas/SceneCanvas.js +534 -788
  90. package/dist/canvas/SceneCanvas.js.map +1 -1
  91. package/dist/canvas/SceneViewCanvas.js +45 -43
  92. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  93. package/dist/canvas/buildSceneLayer.js +91 -0
  94. package/dist/canvas/buildSceneLayer.js.map +1 -0
  95. package/dist/canvas/buildSceneTree.js +16 -19
  96. package/dist/canvas/buildSceneTree.js.map +1 -1
  97. package/dist/canvas/canvasRenderer.js +68 -52
  98. package/dist/canvas/canvasRenderer.js.map +1 -1
  99. package/dist/canvas/deps/changes.js +13 -0
  100. package/dist/canvas/deps/changes.js.map +1 -0
  101. package/dist/canvas/deps/editAnchors.js +28 -28
  102. package/dist/canvas/deps/insert.js +119 -91
  103. package/dist/canvas/deps/insert.js.map +1 -1
  104. package/dist/canvas/deps/slice.js +46 -45
  105. package/dist/canvas/deps/slice.js.map +1 -1
  106. package/dist/canvas/deps/textEdit.js +10 -9
  107. package/dist/canvas/deps/textEdit.js.map +1 -1
  108. package/dist/canvas/derivedPath.js +46 -23
  109. package/dist/canvas/derivedPath.js.map +1 -1
  110. package/dist/canvas/getNodeAtPoint.js +7 -7
  111. package/dist/canvas/getNodeAtPoint.js.map +1 -1
  112. package/dist/canvas/hud.module.js +1 -1
  113. package/dist/canvas/hud.module.js.map +1 -1
  114. package/dist/canvas/kitRequirements.js +2 -2
  115. package/dist/canvas/kitRequirements.js.map +1 -1
  116. package/dist/canvas/layerOrder.js +13 -6
  117. package/dist/canvas/layerOrder.js.map +1 -1
  118. package/dist/canvas/minimapMath.js +12 -10
  119. package/dist/canvas/minimapMath.js.map +1 -1
  120. package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
  121. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
  122. package/dist/canvas/nodeShapes/imagePainter.js +87 -0
  123. package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
  124. package/dist/canvas/nodeShapes/memo.js +9 -0
  125. package/dist/canvas/nodeShapes/memo.js.map +1 -0
  126. package/dist/canvas/nodeShapes/nodePaint.js +57 -0
  127. package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
  128. package/dist/canvas/nodeShapes/pathPainter.js +38 -0
  129. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
  130. package/dist/canvas/nodeShapes/poseBox.js +20 -0
  131. package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
  132. package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
  133. package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
  134. package/dist/canvas/nodeShapes/shapePainter.js +72 -0
  135. package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
  136. package/dist/canvas/nodeShapes/textPainter.js +55 -0
  137. package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
  138. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  139. package/dist/canvas/paintCull.js +10 -11
  140. package/dist/canvas/paintCull.js.map +1 -1
  141. package/dist/canvas/pickWalk.js +52 -63
  142. package/dist/canvas/pickWalk.js.map +1 -1
  143. package/dist/canvas/poseRotation.js +11 -23
  144. package/dist/canvas/poseRotation.js.map +1 -1
  145. package/dist/canvas/renderDebugSnapshot.js +5 -5
  146. package/dist/canvas/renderSceneToPixels.js +3 -1
  147. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  148. package/dist/canvas/sceneAdapter.js +66 -148
  149. package/dist/canvas/sceneAdapter.js.map +1 -1
  150. package/dist/canvas/sceneClipboard.js +112 -0
  151. package/dist/canvas/sceneClipboard.js.map +1 -0
  152. package/dist/canvas/sceneSlotWiring.js +4 -4
  153. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  154. package/dist/canvas/sceneViewRender.js +39 -40
  155. package/dist/canvas/sceneViewRender.js.map +1 -1
  156. package/dist/canvas/useCanvasRenderer.js +14 -6
  157. package/dist/canvas/useCanvasRenderer.js.map +1 -1
  158. package/dist/canvas/useCanvasView.js +58 -0
  159. package/dist/canvas/useCanvasView.js.map +1 -0
  160. package/dist/canvas/useFrameLoop.js +35 -26
  161. package/dist/canvas/useFrameLoop.js.map +1 -1
  162. package/dist/canvas/useSceneLayerList.js +21 -0
  163. package/dist/canvas/useSceneLayerList.js.map +1 -0
  164. package/dist/clipboard.d.ts +10 -6
  165. package/dist/clone.d.ts +4 -3
  166. package/dist/core/adapters/arrayAdapter.js +48 -39
  167. package/dist/core/adapters/arrayAdapter.js.map +1 -1
  168. package/dist/core/device/index.js +5 -4
  169. package/dist/core/device/useDeviceProfile.js +38 -44
  170. package/dist/core/device/useDeviceProfile.js.map +1 -1
  171. package/dist/core/device/watchDevicePixelRatio.js +17 -0
  172. package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
  173. package/dist/core/fillInPoseFrame.js.map +1 -1
  174. package/dist/core/geometry/poseDescriptor.js +21 -19
  175. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  176. package/dist/core/geometry/poseFrame.js +44 -0
  177. package/dist/core/geometry/poseFrame.js.map +1 -0
  178. package/dist/core/geometry/poseRotation.js.map +1 -1
  179. package/dist/core/geometry/regionHit.js +9 -10
  180. package/dist/core/geometry/regionHit.js.map +1 -1
  181. package/dist/core/geometry/unionBounds.js +31 -29
  182. package/dist/core/geometry/unionBounds.js.map +1 -1
  183. package/dist/core/isPlainObject.js +2 -11
  184. package/dist/core/ops/arrange.js +1 -0
  185. package/dist/core/ops/arrange.js.map +1 -1
  186. package/dist/core/ops/create.js +10 -5
  187. package/dist/core/ops/create.js.map +1 -1
  188. package/dist/core/ops/delete.js +12 -24
  189. package/dist/core/ops/delete.js.map +1 -1
  190. package/dist/core/ops/reorder/index.js +43 -40
  191. package/dist/core/ops/reorder/index.js.map +1 -1
  192. package/dist/core/ops/reorder/setChildOrder.js +34 -0
  193. package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
  194. package/dist/core/paintKinds.js +5 -5
  195. package/dist/core/paintKinds.js.map +1 -1
  196. package/dist/core/scene/NodeProperties.js.map +1 -1
  197. package/dist/core/scene/appliedLog.js +37 -0
  198. package/dist/core/scene/appliedLog.js.map +1 -0
  199. package/dist/core/scene/arrivalWindow.js +101 -0
  200. package/dist/core/scene/arrivalWindow.js.map +1 -0
  201. package/dist/core/scene/derivedPath.js.map +1 -1
  202. package/dist/core/scene/historyFacade.js +84 -0
  203. package/dist/core/scene/historyFacade.js.map +1 -0
  204. package/dist/core/scene/kitOps.js +173 -0
  205. package/dist/core/scene/kitOps.js.map +1 -0
  206. package/dist/core/scene/layerStack.js +38 -0
  207. package/dist/core/scene/layerStack.js.map +1 -0
  208. package/dist/core/scene/lockGuard.js +37 -0
  209. package/dist/core/scene/lockGuard.js.map +1 -0
  210. package/dist/core/scene/nodeFnFields.js +5 -6
  211. package/dist/core/scene/nodeFnFields.js.map +1 -1
  212. package/dist/core/scene/nodeMemo.js +45 -19
  213. package/dist/core/scene/nodeMemo.js.map +1 -1
  214. package/dist/core/scene/nodeStore.js +126 -0
  215. package/dist/core/scene/nodeStore.js.map +1 -0
  216. package/dist/core/scene/pickability.js +6 -0
  217. package/dist/core/scene/pickability.js.map +1 -0
  218. package/dist/core/scene/poseFeed.js +38 -38
  219. package/dist/core/scene/poseFeed.js.map +1 -1
  220. package/dist/core/scene/poseOverrides.js +34 -38
  221. package/dist/core/scene/poseOverrides.js.map +1 -1
  222. package/dist/core/scene/renderOrder.js +84 -0
  223. package/dist/core/scene/renderOrder.js.map +1 -0
  224. package/dist/core/scene/scene.js +289 -866
  225. package/dist/core/scene/scene.js.map +1 -1
  226. package/dist/core/scene/serialization.js +68 -0
  227. package/dist/core/scene/serialization.js.map +1 -0
  228. package/dist/core/scene/treeOrder.js +13 -0
  229. package/dist/core/scene/treeOrder.js.map +1 -0
  230. package/dist/core/scene/types.js.map +1 -1
  231. package/dist/core/viewport/meanScale.js +1 -1
  232. package/dist/core/viewport/meanScale.js.map +1 -1
  233. package/dist/core/viewport/view.js +12 -12
  234. package/dist/core/viewport/view.js.map +1 -1
  235. package/dist/core/viewport/zoomBounds.js +10 -8
  236. package/dist/core/viewport/zoomBounds.js.map +1 -1
  237. package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-CtCb8a3G.d.ts} +1 -1
  238. package/dist/debug/createDebugOverlayLayer.js +14 -14
  239. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  240. package/dist/debug/flag.js +2 -41
  241. package/dist/features/chrome-caps/useHoverTracking.js +22 -17
  242. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  243. package/dist/features/focus/gateLayer.js +3 -4
  244. package/dist/features/focus/gateLayer.js.map +1 -1
  245. package/dist/features/images/imageCache.js +19 -9
  246. package/dist/features/images/imageCache.js.map +1 -1
  247. package/dist/features/ingestion/contentHandlers.js +14 -11
  248. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  249. package/dist/features/ingestion/index.js +1 -1
  250. package/dist/features/ingestion/registerKitHandlers.js +7 -7
  251. package/dist/features/ingestion/weaselJsonHandler.js +17 -14
  252. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
  253. package/dist/features/meshPaint/lazyKind.js +201 -35
  254. package/dist/features/meshPaint/lazyKind.js.map +1 -1
  255. package/dist/features/meshPaint/meshPaint.js +82 -79
  256. package/dist/features/meshPaint/meshPaint.js.map +1 -1
  257. package/dist/features/minimap/createMinimapContribution.js +42 -42
  258. package/dist/features/minimap/layers.js +44 -62
  259. package/dist/features/minimap/layers.js.map +1 -1
  260. package/dist/features/parallax/createParallaxPlane.js +10 -14
  261. package/dist/features/parallax/createParallaxPlane.js.map +1 -1
  262. package/dist/features/paths/anchorEdits.js +19 -8
  263. package/dist/features/paths/anchorEdits.js.map +1 -1
  264. package/dist/features/paths/anchors.js +31 -26
  265. package/dist/features/paths/anchors.js.map +1 -1
  266. package/dist/features/paths/booleans.js +2 -2
  267. package/dist/features/paths/index.js +13 -11
  268. package/dist/features/paths/markerCommands.js +37 -36
  269. package/dist/features/paths/markerCommands.js.map +1 -1
  270. package/dist/features/paths/pathInWorld.js +19 -19
  271. package/dist/features/paths/pathInWorld.js.map +1 -1
  272. package/dist/features/paths/pathLayer.js.map +1 -1
  273. package/dist/features/paths/strokeToPath.js +40 -0
  274. package/dist/features/paths/strokeToPath.js.map +1 -0
  275. package/dist/features/paths/tessellate/stroke.js.map +1 -1
  276. package/dist/features/patterns/commandPaint.js +18 -0
  277. package/dist/features/patterns/commandPaint.js.map +1 -0
  278. package/dist/features/patterns/index.js +5 -17
  279. package/dist/features/patterns/index.js.map +1 -1
  280. package/dist/features/patterns/rasterizeTile.js +17 -0
  281. package/dist/features/patterns/rasterizeTile.js.map +1 -0
  282. package/dist/features/patterns/resolveSpec.js +52 -44
  283. package/dist/features/patterns/resolveSpec.js.map +1 -1
  284. package/dist/features/poseRun/usePoseRun.js +8 -3
  285. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  286. package/dist/features/selection/SelectionContext.js +5 -0
  287. package/dist/features/selection/SelectionContext.js.map +1 -1
  288. package/dist/features/selection/overlay.js +18 -18
  289. package/dist/features/selection/overlay.js.map +1 -1
  290. package/dist/features/text/domOffsets.js +82 -0
  291. package/dist/features/text/domOffsets.js.map +1 -0
  292. package/dist/features/text/domRuns.js +103 -131
  293. package/dist/features/text/domRuns.js.map +1 -1
  294. package/dist/features/text/hitTest.js +5 -2
  295. package/dist/features/text/hitTest.js.map +1 -1
  296. package/dist/features/text/isTextData.js +8 -0
  297. package/dist/features/text/isTextData.js.map +1 -0
  298. package/dist/features/text/overlayDirection.js +15 -0
  299. package/dist/features/text/overlayDirection.js.map +1 -0
  300. package/dist/features/text/runs/rangeStyle.js +32 -34
  301. package/dist/features/text/runs/rangeStyle.js.map +1 -1
  302. package/dist/features/text/textCommand.js +34 -33
  303. package/dist/features/text/textCommand.js.map +1 -1
  304. package/dist/features/text/textToPath.js +40 -40
  305. package/dist/features/text/textToPath.js.map +1 -1
  306. package/dist/features/text/useSceneTextEdit.js +76 -82
  307. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  308. package/dist/features/text/useTextEdit.js +184 -160
  309. package/dist/features/text/useTextEdit.js.map +1 -1
  310. package/dist/features/tiling/createTiledLayer.js +24 -22
  311. package/dist/features/tiling/createTiledLayer.js.map +1 -1
  312. package/dist/index.d.ts +11010 -7700
  313. package/dist/index.js +316 -309
  314. package/dist/input/keyState.js +42 -43
  315. package/dist/input/keyState.js.map +1 -1
  316. package/dist/input/useKeyModifiers.js +11 -0
  317. package/dist/input/useKeyModifiers.js.map +1 -0
  318. package/dist/interactions/actions/align/align.js +8 -8
  319. package/dist/interactions/actions/clipboard/clipboardOps.js +34 -32
  320. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
  321. package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
  322. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
  323. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
  324. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -1
  325. package/dist/interactions/actions/defaultCommitAdapter.js +20 -18
  326. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
  327. package/dist/interactions/actions/defaults/align.js +9 -10
  328. package/dist/interactions/actions/defaults/align.js.map +1 -1
  329. package/dist/interactions/actions/defaults/anchorEditing.js +59 -81
  330. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  331. package/dist/interactions/actions/defaults/areaSelect.js +35 -38
  332. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  333. package/dist/interactions/actions/defaults/clipboard.js +26 -10
  334. package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
  335. package/dist/interactions/actions/defaults/clone.js +44 -60
  336. package/dist/interactions/actions/defaults/clone.js.map +1 -1
  337. package/dist/interactions/actions/defaults/copySubtree.js +40 -0
  338. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
  339. package/dist/interactions/actions/defaults/distribute.js +14 -13
  340. package/dist/interactions/actions/defaults/distribute.js.map +1 -1
  341. package/dist/interactions/actions/defaults/duplicate.js +17 -57
  342. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  343. package/dist/interactions/actions/defaults/editAnchors.js +18 -18
  344. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  345. package/dist/interactions/actions/defaults/flip.js +52 -46
  346. package/dist/interactions/actions/defaults/flip.js.map +1 -1
  347. package/dist/interactions/actions/defaults/group.js +43 -48
  348. package/dist/interactions/actions/defaults/group.js.map +1 -1
  349. package/dist/interactions/actions/defaults/ingest.js +35 -33
  350. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  351. package/dist/interactions/actions/defaults/insert.js +50 -51
  352. package/dist/interactions/actions/defaults/insert.js.map +1 -1
  353. package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -7
  354. package/dist/interactions/actions/defaults/lassoSelect.js +67 -70
  355. package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
  356. package/dist/interactions/actions/defaults/move.js +267 -249
  357. package/dist/interactions/actions/defaults/move.js.map +1 -1
  358. package/dist/interactions/actions/defaults/nudge.js +40 -68
  359. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  360. package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
  361. package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
  362. package/dist/interactions/actions/defaults/reorder.js +2 -0
  363. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  364. package/dist/interactions/actions/defaults/resize.js +104 -98
  365. package/dist/interactions/actions/defaults/resize.js.map +1 -1
  366. package/dist/interactions/actions/defaults/rotate.js +111 -110
  367. package/dist/interactions/actions/defaults/rotate.js.map +1 -1
  368. package/dist/interactions/actions/defaults/setFill.js +7 -7
  369. package/dist/interactions/actions/defaults/setFillOpacity.js +4 -4
  370. package/dist/interactions/actions/defaults/setStroke.js +12 -12
  371. package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
  372. package/dist/interactions/actions/defaults/sliceOps.js +19 -19
  373. package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
  374. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  375. package/dist/interactions/actions/edit-anchors/geometry.js +28 -23
  376. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
  377. package/dist/interactions/actions/flip/helpers.js +30 -17
  378. package/dist/interactions/actions/flip/helpers.js.map +1 -1
  379. package/dist/interactions/actions/hitSelection.js +8 -0
  380. package/dist/interactions/actions/hitSelection.js.map +1 -0
  381. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
  382. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
  383. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
  384. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
  385. package/dist/interactions/actions/move/behaviors/snapToContainer.js +32 -21
  386. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  387. package/dist/interactions/actions/move/gestureAdapter.js +32 -15
  388. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
  389. package/dist/interactions/actions/move/landedDescendants.js +33 -0
  390. package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
  391. package/dist/interactions/actions/outlines/createOutlines.js +18 -18
  392. package/dist/interactions/actions/poseDescriptorDep.js +16 -4
  393. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
  394. package/dist/interactions/actions/poseFrame.js +11 -6
  395. package/dist/interactions/actions/poseFrame.js.map +1 -1
  396. package/dist/interactions/actions/previewOverrides.js +5 -5
  397. package/dist/interactions/actions/previewOverrides.js.map +1 -1
  398. package/dist/interactions/actions/selectionSubtree.js +69 -0
  399. package/dist/interactions/actions/selectionSubtree.js.map +1 -0
  400. package/dist/interactions/actions/useStandardActions.js +66 -62
  401. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  402. package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
  403. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
  404. package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
  405. package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
  406. package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
  407. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
  408. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +8 -6
  409. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
  410. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
  411. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
  412. package/dist/{math-Drrw4ewZ.d.ts → math-J-ACHyEg.d.ts} +1 -2
  413. package/dist/math.d.ts +2 -3
  414. package/dist/move.d.ts +12 -11
  415. package/dist/{originProjection-DEklpDc_.d.ts → originProjection-gHnOup4e.d.ts} +1 -1
  416. package/dist/{registerProgram-BMZRDgrh.d.ts → registerProgram-T9S_PfAX.d.ts} +18 -7
  417. package/dist/renderer/DrawCommand.js.map +1 -1
  418. package/dist/renderer/WeaselRenderer.js +75 -73
  419. package/dist/renderer/WeaselRenderer.js.map +1 -1
  420. package/dist/renderer/cache/GLImageCache.js +15 -5
  421. package/dist/renderer/cache/GLImageCache.js.map +1 -1
  422. package/dist/renderer/cache/GLMeshCache.js +23 -23
  423. package/dist/renderer/cache/GLMeshCache.js.map +1 -1
  424. package/dist/renderer/cache/GLTextureCache.js +18 -1
  425. package/dist/renderer/cache/GLTextureCache.js.map +1 -1
  426. package/dist/renderer/cache/cache.js.map +1 -1
  427. package/dist/renderer/cache/markerCommandCache.js.map +1 -1
  428. package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
  429. package/dist/renderer/cullDrawCommands.js +11 -11
  430. package/dist/renderer/draw/batch.js +133 -0
  431. package/dist/renderer/draw/batch.js.map +1 -0
  432. package/dist/renderer/draw/clip.js +89 -0
  433. package/dist/renderer/draw/clip.js.map +1 -0
  434. package/dist/renderer/draw/customShader.js +230 -0
  435. package/dist/renderer/draw/customShader.js.map +1 -0
  436. package/dist/renderer/draw/drawTriangles.js +8 -0
  437. package/dist/renderer/draw/drawTriangles.js.map +1 -0
  438. package/dist/renderer/draw/effects.js +28 -0
  439. package/dist/renderer/draw/effects.js.map +1 -0
  440. package/dist/renderer/draw/flushBatch.js +35 -0
  441. package/dist/renderer/draw/flushBatch.js.map +1 -0
  442. package/dist/renderer/draw/gradient.js +90 -0
  443. package/dist/renderer/draw/gradient.js.map +1 -0
  444. package/dist/renderer/draw/image.js +38 -0
  445. package/dist/renderer/draw/image.js.map +1 -0
  446. package/dist/renderer/draw/mesh.js +16 -0
  447. package/dist/renderer/draw/mesh.js.map +1 -0
  448. package/dist/renderer/draw/paintBind.js +70 -0
  449. package/dist/renderer/draw/paintBind.js.map +1 -0
  450. package/dist/renderer/draw/pathPaint.js +142 -0
  451. package/dist/renderer/draw/pathPaint.js.map +1 -0
  452. package/dist/renderer/draw/scratchPass.js +83 -0
  453. package/dist/renderer/draw/scratchPass.js.map +1 -0
  454. package/dist/renderer/draw/stencil.js +28 -0
  455. package/dist/renderer/draw/stencil.js.map +1 -0
  456. package/dist/renderer/draw/text.js +167 -0
  457. package/dist/renderer/draw/text.js.map +1 -0
  458. package/dist/renderer/draw/uniforms.js +77 -0
  459. package/dist/renderer/draw/uniforms.js.map +1 -0
  460. package/dist/renderer/draw.js +60 -1116
  461. package/dist/renderer/draw.js.map +1 -1
  462. package/dist/renderer/effects/EffectTargets.js +3 -0
  463. package/dist/renderer/effects/EffectTargets.js.map +1 -1
  464. package/dist/renderer/effects/composite.js +7 -5
  465. package/dist/renderer/effects/composite.js.map +1 -1
  466. package/dist/renderer/index.js +18 -17
  467. package/dist/renderer/math/color.js +63 -83
  468. package/dist/renderer/math/color.js.map +1 -1
  469. package/dist/renderer/math/mat3.js +15 -11
  470. package/dist/renderer/math/mat3.js.map +1 -1
  471. package/dist/renderer/math/viewToMat3.js +1 -1
  472. package/dist/renderer/math/viewToMat3.js.map +1 -1
  473. package/dist/renderer/shaders/ShaderProgram.js +13 -13
  474. package/dist/renderer/shaders/ShaderProgram.js.map +1 -1
  475. package/dist/renderer/shaders/glyphPaint.js +3 -3
  476. package/dist/renderer/shaders/glyphPaint.js.map +1 -1
  477. package/dist/renderer/shaders/gradFill.js +2 -1
  478. package/dist/renderer/shaders/gradFill.js.map +1 -1
  479. package/dist/renderer/shaders/pathFill.js +2 -1
  480. package/dist/renderer/shaders/pathFill.js.map +1 -1
  481. package/dist/renderer/shaders/patternFill.js +2 -1
  482. package/dist/renderer/shaders/patternFill.js.map +1 -1
  483. package/dist/renderer/shaders/registerProgram.js.map +1 -1
  484. package/dist/renderer/strokeLengths.js.map +1 -1
  485. package/dist/renderer/textures/registerTexture.js +25 -5
  486. package/dist/renderer/textures/registerTexture.js.map +1 -1
  487. package/dist/renderer.d.ts +16 -15
  488. package/dist/renderer.js +17 -16
  489. package/dist/resize.d.ts +5 -6
  490. package/dist/resize.js +5 -5
  491. package/dist/style.css +1 -1
  492. package/dist/test-hook/install.js +12 -6
  493. package/dist/test-hook/install.js.map +1 -1
  494. package/dist/{test-seams-CuIxe0xY.d.ts → test-seams-DM2B87-g.d.ts} +4 -4
  495. package/dist/test-seams.d.ts +2 -2
  496. package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
  497. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  498. package/dist/tools/builtin/hand/useHandTool.js +1 -0
  499. package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
  500. package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
  501. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
  502. package/dist/tools/builtin/line/useLineTool.js +1 -0
  503. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  504. package/dist/tools/builtin/pen/usePenTool.js +153 -103
  505. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  506. package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
  507. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
  508. package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
  509. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  510. package/dist/tools/builtin/rect/useRectTool.js +1 -0
  511. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  512. package/dist/tools/builtin/select/selectionContributions.js +24 -23
  513. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  514. package/dist/tools/builtin/select/useSelectTool.js +51 -48
  515. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  516. package/dist/tools/builtin/shared/pointerFollower.js +17 -0
  517. package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
  518. package/dist/tools/builtin/slice/useSliceTool.js +49 -54
  519. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  520. package/dist/tools/builtin/star/useStarTool.js +22 -16
  521. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  522. package/dist/tools/builtin/text/useTextTool.js +13 -2
  523. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  524. package/dist/tools/useKeybindings.js +14 -30
  525. package/dist/tools/useKeybindings.js.map +1 -1
  526. package/dist/{types-B_9g6hMM.d.ts → types-B4iJRHC3.d.ts} +5 -1
  527. package/dist/{types-A37hYkeR.d.ts → types-k-5Oqh-U.d.ts} +31 -7
  528. package/dist/util/color.js +3 -3
  529. package/dist/util/color.js.map +1 -1
  530. package/dist/util/paint.js.map +1 -1
  531. package/dist/version.js +1 -1
  532. package/package.json +20 -18
  533. package/dist/autoPoseDescriptor-vCdt55xm.d.ts +0 -27
  534. package/dist/builtins-C-VgUlWI.d.ts +0 -4514
  535. package/dist/core/isPlainObject.js.map +0 -1
  536. package/dist/debug/flag.js.map +0 -1
  537. package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
  538. package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
  539. package/dist/renderer/shaders/imageFill.js +0 -14
  540. package/dist/renderer/shaders/imageFill.js.map +0 -1
  541. package/dist/tools/prefs.js +0 -47
  542. package/dist/tools/prefs.js.map +0 -1
@@ -1,1135 +1,79 @@
1
- import { createPaintResources as e } from "./paintResources.js";
2
- import { BATCH_TEXTURE_SLOTS as t, PAINT_MODE_CONIC as n, PAINT_MODE_PLAIN as r, PAINT_MODE_RADIAL as i } from "./shaders/batchFill.js";
3
- import { resolveColor as a } from "./math/color.js";
4
- import { mat3 as o } from "./math/mat3.js";
5
- import { IDENTITY_COLOR_MATRIX as s } from "./state/GroupState.js";
6
- import { getTexture as c } from "./textures/registerTexture.js";
7
- import { getPaintKind as l } from "../core/paintKinds.js";
8
- import { SPRITE_STRIDE as u } from "./DrawCommand.js";
9
- import { patternTileSpace as d } from "./math/patternSpace.js";
10
- import { getMesh as f } from "./cache/cache.js";
11
- import { metricKeepsRects as p } from "../features/paths/tessellate/metric.js";
12
- import { resolveStrokeWidth as m } from "../features/paths/tessellate/stroke.js";
13
- import { strokeMesh as h } from "./cache/strokeMeshCache.js";
14
- import { SYNTHETIC_ITALIC_RADIANS as g } from "./syntheticItalic.js";
15
- import { outlineGroupMesh as _, outlineGroupStrokeMesh as v } from "./glyphOutlineMesh.js";
16
- import { resolveStrokeLengths as y } from "./strokeLengths.js";
17
- import { cachedMarkerCommands as b } from "./cache/markerCommandCache.js";
18
- import { axisAlignedClipRect as ee, intersectClipRects as x } from "./batchClip.js";
19
- import { COMPOSITE_PROGRAM_ID as S } from "./effects/composite.js";
20
- import { GLYPH_MODE_MSDF as te, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
21
- import { cachedLayoutRuns as ce, resolveTextStyle as le, verticalAlignOffset as ue } from "@weasel-js/text";
22
- import { tessellate as de } from "@weasel-js/geom/tessellate";
1
+ import "./math/mat3.js";
2
+ import "./cache/cache.js";
3
+ import { compositeProgramId as e } from "./effects/composite.js";
4
+ import { applyClipTest as t } from "./draw/stencil.js";
5
+ import { drawShader as n, warnOnceUniform as r } from "./draw/customShader.js";
6
+ import { drawFullscreenQuad as i, returnToRenderTarget as a } from "./draw/effects.js";
7
+ import { flushBatch as o } from "./draw/flushBatch.js";
8
+ import { enterGroupClip as s, flushForOwnDraw as c, leaveClip as l } from "./draw/clip.js";
9
+ import "./draw/batch.js";
10
+ import { drawPath as u } from "./draw/pathPaint.js";
11
+ import { OUTLINE_MIN_SCREEN_PX as d, drawText as f } from "./draw/text.js";
12
+ import { drawImage as p, drawSprites as m } from "./draw/image.js";
23
13
  //#region src/renderer/draw.ts
24
- function C(e, t, n) {
25
- e.gl.drawElements(e.gl.TRIANGLES, t, n, 0), e.stats && e.stats.drawCalls++;
26
- }
27
- var fe = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap();
28
- function w(e, t) {
29
- let n = fe.get(e);
30
- n || (n = /* @__PURE__ */ new WeakMap(), fe.set(e, n));
31
- let r = n.get(t);
32
- return r || (r = {}, n.set(t, r)), r;
33
- }
34
- function T(e, t) {
35
- if (e === void 0 || e.length !== t.length) return !1;
36
- for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
37
- return !0;
38
- }
39
- function me(e, t, n, r, i, a) {
40
- let o = t.uniform("u_color");
41
- if (o === void 0) return;
42
- let s = w(e, t), c = s.color;
43
- (c === void 0 || c[0] !== n || c[1] !== r || c[2] !== i || c[3] !== a) && (e.gl.uniform4f(o, n, r, i, a), s.color = [
44
- n,
45
- r,
46
- i,
47
- a
48
- ]);
49
- }
50
- function E(e, t, n) {
51
- let r = t.uniform("u_alpha");
52
- if (r === void 0) return;
53
- let i = w(e, t);
54
- i.alpha !== n && (e.gl.uniform1f(r, n), i.alpha = n);
55
- }
56
- var D = o.identity();
57
- function he(e) {
58
- let t = pe.get(e);
59
- return t || (t = o.screenToClip(e.widthCss, e.heightCss), pe.set(e, t)), t;
60
- }
61
- var O = /* @__PURE__ */ new Float32Array(16);
62
- function k(e, t, n = e.state.colorMatrix) {
63
- let r = e.gl, i = w(e, t), a = t.uniform("u_colorMatrix");
64
- if (a !== void 0) {
65
- for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++) O[t * 4 + e] = n[e * 5 + t];
66
- T(i.colorMatrix, O) || (r.uniformMatrix4fv(a, !1, O), i.colorMatrix = Float32Array.from(O));
67
- }
68
- let o = t.uniform("u_colorBias");
69
- if (o !== void 0) {
70
- let e = [
71
- n[4],
72
- n[9],
73
- n[14],
74
- n[19]
75
- ];
76
- T(i.colorBias, e) || (r.uniform4f(o, e[0], e[1], e[2], e[3]), i.colorBias = Float32Array.from(e));
77
- }
78
- }
79
- function ge(e, t) {
80
- return e.flattenTolerance === void 0 ? f(t) : de(t, { flattenTolerance: e.flattenTolerance });
81
- }
82
- function _e(e, t) {
83
- return e.flattenTolerance === void 0 ? e.meshCache.handleFor(t) : e.meshCache.uploadTransient(t);
84
- }
85
- function ve(e, t) {
86
- return _e(e, ge(e, t));
87
- }
88
- function A(e, t) {
14
+ function h(e, t) {
89
15
  switch (t.kind) {
90
- case "group": return Ae(e, t);
91
- case "path": return Fe(e, t);
92
- case "text": return Dt(e, t);
93
- case "image": return Vt(e, t);
94
- case "sprites": return Ht(e, t);
95
- case "shader": return F(e), Ee(e, t);
96
- }
97
- }
98
- var ye = /* @__PURE__ */ new Set();
99
- function be(e, t) {
100
- let n = `${e}:${t}`;
101
- ye.has(n) || (ye.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
102
- }
103
- function xe(e, t, n, r, i) {
104
- if (typeof n == "object" && n && !Array.isArray(n) && !(n instanceof Float32Array) && "id" in n && typeof n.id == "string") {
105
- let a = n, o = c(a.id);
106
- if (!o) {
107
- (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel setUniform: TextureHandle "${a.id}" not registered`);
108
- return;
109
- }
110
- let s = i.value++;
111
- r.upload(a.id, o.source), r.bind(a.id, s), e.uniform1i(t, s);
112
- return;
113
- }
114
- if (n instanceof Float32Array) {
115
- if (n.length === 9) e.uniformMatrix3fv(t, !1, n);
116
- else if (n.length === 16) e.uniformMatrix4fv(t, !1, n);
117
- else if (typeof process > "u" || process.env.NODE_ENV !== "production") throw TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${n.length}`);
118
- return;
119
- }
120
- if (Array.isArray(n)) {
121
- let r = n;
122
- switch (r.length) {
123
- case 2:
124
- e.uniform2fv(t, r);
125
- break;
126
- case 3:
127
- e.uniform3fv(t, r);
128
- break;
129
- case 4:
130
- e.uniform4fv(t, r);
131
- break;
132
- default: if (typeof process > "u" || process.env.NODE_ENV !== "production") throw TypeError(`weasel setUniform: array length ${r.length} not supported`);
133
- }
134
- return;
135
- }
136
- if (typeof n == "number") {
137
- e.uniform1f(t, n);
138
- return;
139
- }
140
- }
141
- var Se = {
142
- float: {
143
- fn: "uniform1fv",
144
- n: 1
145
- },
146
- vec2: {
147
- fn: "uniform2fv",
148
- n: 2
149
- },
150
- vec3: {
151
- fn: "uniform3fv",
152
- n: 3
153
- },
154
- vec4: {
155
- fn: "uniform4fv",
156
- n: 4
157
- },
158
- int: {
159
- fn: "uniform1iv",
160
- n: 1
161
- },
162
- ivec2: {
163
- fn: "uniform2iv",
164
- n: 2
165
- },
166
- ivec3: {
167
- fn: "uniform3iv",
168
- n: 3
169
- },
170
- ivec4: {
171
- fn: "uniform4iv",
172
- n: 4
173
- },
174
- bool: {
175
- fn: "uniform1iv",
176
- n: 1
177
- },
178
- bvec2: {
179
- fn: "uniform2iv",
180
- n: 2
181
- },
182
- bvec3: {
183
- fn: "uniform3iv",
184
- n: 3
185
- },
186
- bvec4: {
187
- fn: "uniform4iv",
188
- n: 4
189
- },
190
- uint: {
191
- fn: "uniform1uiv",
192
- n: 1
193
- },
194
- uvec2: {
195
- fn: "uniform2uiv",
196
- n: 2
197
- },
198
- uvec3: {
199
- fn: "uniform3uiv",
200
- n: 3
201
- },
202
- uvec4: {
203
- fn: "uniform4uiv",
204
- n: 4
205
- },
206
- mat2: {
207
- fn: "uniformMatrix2fv",
208
- n: 4,
209
- matrix: !0
210
- },
211
- mat3: {
212
- fn: "uniformMatrix3fv",
213
- n: 9,
214
- matrix: !0
215
- },
216
- mat4: {
217
- fn: "uniformMatrix4fv",
218
- n: 16,
219
- matrix: !0
220
- },
221
- mat2x2: {
222
- fn: "uniformMatrix2fv",
223
- n: 4,
224
- matrix: !0
225
- },
226
- mat3x3: {
227
- fn: "uniformMatrix3fv",
228
- n: 9,
229
- matrix: !0
230
- },
231
- mat4x4: {
232
- fn: "uniformMatrix4fv",
233
- n: 16,
234
- matrix: !0
235
- },
236
- mat2x3: {
237
- fn: "uniformMatrix2x3fv",
238
- n: 6,
239
- matrix: !0
240
- },
241
- mat2x4: {
242
- fn: "uniformMatrix2x4fv",
243
- n: 8,
244
- matrix: !0
245
- },
246
- mat3x2: {
247
- fn: "uniformMatrix3x2fv",
248
- n: 6,
249
- matrix: !0
250
- },
251
- mat3x4: {
252
- fn: "uniformMatrix3x4fv",
253
- n: 12,
254
- matrix: !0
255
- },
256
- mat4x2: {
257
- fn: "uniformMatrix4x2fv",
258
- n: 8,
259
- matrix: !0
260
- },
261
- mat4x3: {
262
- fn: "uniformMatrix4x3fv",
263
- n: 12,
264
- matrix: !0
265
- }
266
- };
267
- function Ce(e) {
268
- return Array.isArray(e) || e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array;
269
- }
270
- function we(e, t, n, r) {
271
- let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = Se[n.type];
272
- if (!a) {
273
- i && console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);
274
- return;
275
- }
276
- if (r.length % a.n !== 0 || r.length > a.n * n.size) {
277
- if (i) throw TypeError(`weasel setUniform: "${t}" is ${n.type}[${n.size}], so its value must hold a multiple of ${a.n} numbers, at most ${a.n * n.size}; got ${r.length}`);
278
- return;
279
- }
280
- if (r.length === 0) return;
281
- let o = e[a.fn];
282
- a.matrix ? o.call(e, n.location, !1, r) : o.call(e, n.location, r);
283
- }
284
- function Te(e, t, n, r, i, a) {
285
- for (let [o, s] of Object.entries(r)) {
286
- let r = t.uniformArray(o);
287
- if (r && Ce(s)) {
288
- we(e, o, r, s);
289
- continue;
290
- }
291
- let c = t.uniform(o);
292
- if (c === void 0) {
293
- be(n, o);
294
- continue;
295
- }
296
- xe(e, c, s, i, a);
297
- }
298
- }
299
- function Ee(e, t) {
300
- let { gl: n, programRegistry: r, quadVbo: i, quadIbo: a, textureCache: s } = e, c = r.get(t.program.id);
301
- if (!c) {
302
- console.warn(`weasel drawShader: program "${t.program.id}" not compiled on this renderer. Call renderer.registerProgram(handle) after the module-level registerProgram().`);
303
- return;
304
- }
305
- if (!i || !a) {
306
- console.warn("weasel drawShader: quad geometry not initialized");
307
- return;
308
- }
309
- n.useProgram(c.handle);
310
- let l = c.attribute("a_position"), u = c.attribute("a_uv");
311
- n.bindBuffer(n.ARRAY_BUFFER, i), l !== void 0 && (n.enableVertexAttribArray(l), n.vertexAttribPointer(l, 2, n.FLOAT, !1, 16, 0)), u !== void 0 && (n.enableVertexAttribArray(u), n.vertexAttribPointer(u, 2, n.FLOAT, !1, 16, 8)), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, a);
312
- let d = o.screenToClip(e.widthCss, e.heightCss), f = c.uniform("u_proj");
313
- f !== void 0 && n.uniformMatrix3fv(f, !1, d);
314
- let p = c.uniform("u_bounds");
315
- p !== void 0 && n.uniform4f(p, t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h);
316
- let m = c.uniform("u_view");
317
- m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Te(n, c, t.program.id, t.uniforms, s, { value: 1 }), Z(e), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
318
- }
319
- function De(e, t, n, r, i) {
320
- let a = e.gl;
321
- F(e);
322
- let o = e.renderTarget ?? null, s = e.clipDepth, c = e.clipStack, l = e.drawBatch.clip, u = a.isEnabled(a.SCISSOR_TEST), d = n.acquire(r, i), f = e.state.pushIsolated({ transform: t.transform });
323
- e.clipDepth = 0, e.clipStack = [], e.drawBatch.clip = null, a.bindFramebuffer(a.FRAMEBUFFER, d.fbo), e.renderTarget = d, a.viewport(0, 0, r, i), a.disable(a.SCISSOR_TEST), a.stencilMask(255), a.clear(a.COLOR_BUFFER_BIT | a.STENCIL_BUFFER_BIT);
324
- for (let n of t.children) A(e, n);
325
- q(e), a.disable(a.BLEND);
326
- for (let o of t.effects) {
327
- let t = e.ensureProgram?.(o.program.id) ?? null;
16
+ case "group": return _(e, t);
17
+ case "path": return u(e, t);
18
+ case "text": return f(e, t);
19
+ case "image": return p(e, t);
20
+ case "sprites": return m(e, t);
21
+ case "shader": return c(e), n(e, t);
22
+ }
23
+ }
24
+ function g(n, s, l, u, d) {
25
+ let f = n.gl;
26
+ c(n);
27
+ let p = n.renderTarget ?? null, m = n.clipDepth, g = n.clipStack, _ = n.drawBatch.clip, v = f.isEnabled(f.SCISSOR_TEST), y = l.acquire(u, d), b = n.state.pushIsolated({
28
+ transform: s.transform,
29
+ alpha: s.alpha,
30
+ colorMatrix: s.colorMatrix
31
+ });
32
+ n.clipDepth = 0, n.clipStack = [], n.drawBatch.clip = null, f.bindFramebuffer(f.FRAMEBUFFER, y.fbo), n.renderTarget = y, f.viewport(0, 0, u, d), f.disable(f.SCISSOR_TEST), f.stencilMask(255), f.clear(f.COLOR_BUFFER_BIT | f.STENCIL_BUFFER_BIT);
33
+ for (let e of s.children) h(n, e);
34
+ o(n), f.disable(f.BLEND), f.disable(f.STENCIL_TEST);
35
+ for (let e of s.effects) {
36
+ let t = n.ensureProgram?.(e.program.id) ?? null;
328
37
  if (!t) {
329
- be(o.program.id, "(program)");
38
+ r(e.program.id, "(program)");
330
39
  continue;
331
40
  }
332
- let s = n.acquire(r, i);
333
- a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), ke(e, t, d.texture, r, i, o.uniforms, void 0, o.program.id), n.release(d), d = s;
334
- }
335
- a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o, Oe(e, r, i, u);
336
- let p = e.ensureProgram?.(S) ?? null;
337
- p && (Z(e), ke(e, p, d.texture, r, i, void 0, {
338
- alpha: f.alpha,
339
- colorMatrix: f.colorMatrix
340
- })), n.release(d);
341
- }
342
- function Oe(e, t, n, r) {
343
- let i = e.gl, a = e.renderTarget ?? null;
344
- i.bindFramebuffer(i.FRAMEBUFFER, a ? a.fbo : null), a ? i.viewport(0, 0, t, n) : (e.restoreTargetRect?.(), r && i.enable(i.SCISSOR_TEST));
345
- }
346
- function ke(e, t, n, r, i, a, o, s) {
347
- let c = e.gl;
348
- c.useProgram(t.handle);
349
- let l = t.attribute("a_position"), u = t.attribute("a_uv");
350
- c.bindBuffer(c.ARRAY_BUFFER, e.quadVbo), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, e.quadIbo), l !== void 0 && l >= 0 && (c.enableVertexAttribArray(l), c.vertexAttribPointer(l, 2, c.FLOAT, !1, 16, 0)), u !== void 0 && u >= 0 && (c.enableVertexAttribArray(u), c.vertexAttribPointer(u, 2, c.FLOAT, !1, 16, 8)), c.activeTexture(c.TEXTURE0), c.bindTexture(c.TEXTURE_2D, n);
351
- let d = t.uniform("u_source");
352
- d !== void 0 && c.uniform1i(d, 0);
353
- let f = t.uniform("u_resolution");
354
- f !== void 0 && c.uniform2f(f, r, i);
355
- let p = t.uniform("u_texel");
356
- if (p !== void 0 && c.uniform2f(p, 1 / r, 1 / i), o) {
357
- let n = t.uniform("u_alpha");
358
- n !== void 0 && c.uniform1f(n, o.alpha), k(e, t, o.colorMatrix);
41
+ let a = l.acquire(u, d);
42
+ f.bindFramebuffer(f.FRAMEBUFFER, a.fbo), f.viewport(0, 0, u, d), f.clear(f.COLOR_BUFFER_BIT), i(n, t, y.texture, u, d, e.uniforms, void 0, e.program.id), l.release(y), y = a;
359
43
  }
360
- a && Te(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
44
+ f.enable(f.BLEND), n.state.pop(), n.clipDepth = m, n.clipStack = g, n.drawBatch.clip = _, n.renderTarget = p, a(n, u, d, v);
45
+ let x = n.ensureProgram?.(e()) ?? null;
46
+ x && (t(n), i(n, x, y.texture, u, d, void 0, {
47
+ alpha: b.alpha,
48
+ colorMatrix: b.colorMatrix
49
+ })), l.release(y);
361
50
  }
362
- function Ae(e, t) {
51
+ function _(e, t) {
363
52
  if (t.effects && t.effects.length > 0 && e.effectTargets && e.deviceWidth && e.deviceHeight) {
364
- De(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
53
+ if (t.clip) {
54
+ e.state.push({ transform: t.transform });
55
+ try {
56
+ s(e, t.clip);
57
+ } finally {
58
+ e.state.pop();
59
+ }
60
+ }
61
+ g(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight), t.clip && l(e);
365
62
  return;
366
63
  }
367
64
  if (e.state.push({
368
65
  transform: t.transform,
369
66
  alpha: t.alpha,
370
67
  colorMatrix: t.colorMatrix
371
- }), t.clip) {
372
- let n = e.clipStack.reduce((e, t) => e + +(t.depth === 0), 0);
373
- if (e.clipDepth + n + 1 > 7) throw e.state.pop(), Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");
374
- je(e, t.clip);
375
- }
376
- for (let n of t.children) A(e, n);
377
- t.clip && Me(e), e.state.pop();
378
- }
379
- function je(e, t) {
380
- let n = e.state.transform, r = ee(t, n);
381
- if (r === null) {
382
- j(e);
383
- let r = e.clipDepth + 1;
384
- _t(e, t, r), e.clipDepth = r, e.clipStack.push({
385
- path: t,
386
- transform: n,
387
- rect: null,
388
- depth: r
389
- });
390
- } else e.clipStack.push({
391
- path: t,
392
- transform: n,
393
- rect: r,
394
- depth: 0
395
- });
396
- Ne(e);
397
- }
398
- function Me(e) {
399
- let t = e.clipStack.pop();
400
- t.depth > 0 && (vt(e, t.path, t.depth - 1, t.transform), e.clipDepth = t.depth - 1), Ne(e);
401
- }
402
- function j(e) {
403
- for (let t of e.clipStack) {
404
- if (t.depth !== 0) continue;
405
- let n = e.clipDepth + 1;
406
- _t(e, t.path, n, t.transform), t.depth = n, e.clipDepth = n;
407
- }
408
- }
409
- function Ne(e) {
410
- let t = null;
411
- for (let n of e.clipStack) n.rect && (t = t ? x(t, n.rect) : n.rect);
412
- e.drawBatch.clip = t;
413
- }
414
- function Pe(e) {
415
- let t = e.clipStack;
416
- if (t.length === 0 || e.uncut) return e.clipDepth;
417
- for (let e = t.length - 1; e >= 0; e--) if (t[e].rect === null) return t[e].depth;
418
- for (let e of t) if (e.depth > 0) return e.depth - 1;
419
- return e.clipDepth;
420
- }
421
- function M(e) {
422
- j(e);
423
- let t = e.drawBatch.clip;
424
- return e.drawBatch.clip = null, e.uncut = !0, t;
425
- }
426
- function N(e, t) {
427
- e.drawBatch.clip = t, e.uncut = !1;
428
- }
429
- function P(e, t, n, r) {
430
- let i = M(e);
431
- r(e, t, n), N(e, i);
432
- }
433
- function F(e) {
434
- q(e), e.clipStack.length > 0 && j(e);
435
- }
436
- function Fe(e, t) {
437
- t.fill && Ie(e, t), t.stroke?.paint && bt(e, t);
438
- }
439
- function Ie(e, t) {
440
- let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = G(e, n, i);
441
- if (o === null) return;
442
- if (o !== void 0 && t.path.kind === "rect") {
443
- o.kind === "ramp" ? $e(e, t.path, o) : Ge(e, t.path, o);
444
- return;
445
- }
446
- let s = ge(e, t.path);
447
- if (K(e, s, o)) return;
448
- let c = _e(e, s);
449
- r && i ? nt(e, t, a, c) : c.requiresStencil ? yt(e, n, c) : ct(e, n, c);
450
- }
451
- var Le = new Int32Array(Array.from({ length: t }, (e, t) => t)), I = new Float32Array(2 * t);
452
- function Re(e) {
453
- return e === s || T(s, e);
454
- }
455
- function L(e, t, n, r, i = 0) {
456
- if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth : Pe(e)) || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && ze(t, n, r) < 0) return !1;
457
- let a = e.state.colorMatrix;
458
- return t.colorMatrix === a || T(t.colorMatrix, a);
459
- }
460
- function ze(e, t, n) {
461
- for (let r = 0; r < e.textures.length; r++) {
462
- let i = e.textures[r];
463
- if (i.kind === "bitmap" && i.image === t) return i.sampling === n ? r + 1 : -1;
464
- }
465
- return R(e);
466
- }
467
- function Be(e) {
468
- for (let t = 0; t < e.textures.length; t++) if (e.textures[t].kind === "ramps") return t + 1;
469
- return R(e);
470
- }
471
- function Ve(e, t) {
472
- for (let n = 0; n < e.textures.length; n++) {
473
- let r = e.textures[n];
474
- if (r.kind === "atlas" && r.id === t) return n + 1;
475
- }
476
- return R(e);
477
- }
478
- function R(e) {
479
- return e.textures.length + 1 < t ? e.textures.length + 1 : -1;
480
- }
481
- var z = {
482
- maxVertices: 96,
483
- maxVerticesInRun: 1024
484
- };
485
- function He(e, t) {
486
- if (t.requiresStencil) return !1;
487
- let n = e.drawBatch.length > 0 ? z.maxVerticesInRun : z.maxVertices;
488
- return t.vertices.length >> 1 <= n;
489
- }
490
- function B(e, t) {
491
- return e.batchState !== void 0 && !L(e, e.batchState) && q(e), e.drawBatch.wouldOverflow(t) && q(e), V(e);
492
- }
493
- function V(e) {
494
- if (e.batchState === void 0) {
495
- let t = e.state.colorMatrix, n = Re(t);
496
- e.batchState = {
497
- alpha: n ? 1 : e.state.alpha,
498
- colorMatrix: t,
499
- clipDepth: Pe(e),
500
- synthBold: 0,
501
- foldsAlpha: n,
502
- textures: []
503
- };
504
- }
505
- return e.batchState;
506
- }
507
- function H(e, t, n) {
508
- e.batchState !== void 0 && !L(e, e.batchState, t, n) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
509
- let r = V(e), i = ze(r, t, n);
510
- return i > r.textures.length && (r.textures.push({
511
- kind: "bitmap",
512
- image: t,
513
- sampling: n
514
- }), i = r.textures.length), {
515
- staged: r,
516
- slot: i
517
- };
518
- }
519
- function U(e, t, n, r) {
520
- e.batchState !== void 0 && (!L(e, e.batchState, void 0, void 0, r) || Ve(e.batchState, t) < 0) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
521
- let i = V(e);
522
- i.synthBold = r;
523
- let a = Ve(i, t);
524
- return a > i.textures.length && (i.textures.push({
525
- kind: "atlas",
526
- id: t,
527
- fieldScale: n
528
- }), a = i.textures.length), {
529
- staged: i,
530
- slot: a
531
- };
532
- }
533
- function Ue(e, t, n, r) {
534
- e.gradRamps.wouldReshape(t, n) && q(e), e.batchState !== void 0 && (!L(e, e.batchState) || Be(e.batchState) < 0) && q(e), e.drawBatch.wouldOverflow(r) && q(e);
535
- let i = V(e), a = Be(i);
536
- return a > i.textures.length && (i.textures.push({ kind: "ramps" }), a = i.textures.length), {
537
- staged: i,
538
- slot: a,
539
- rowV: e.gradRamps.rowV(e.gradRamps.upload(t, n))
540
- };
541
- }
542
- function W(e, t, n) {
543
- return (n ?? 1) * (t.foldsAlpha ? e.state.alpha : 1);
544
- }
545
- function We(e, t, n) {
546
- let [r, i, o, s] = a(n.color);
547
- return [
548
- r,
549
- i,
550
- o,
551
- s * W(e, t, n.opacity)
552
- ];
553
- }
554
- function Ge(e, t, n) {
555
- let [r, i, a, o] = We(e, B(e, 4), n);
556
- e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) || P(e, t, n, Ge);
557
- }
558
- function Ke(e, t, n) {
559
- let [r, i, a, o] = We(e, B(e, t.vertices.length >> 1), n);
560
- e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) || P(e, t, n, Ke);
561
- }
562
- function G(e, t, a) {
563
- if (a) return;
564
- let o = t.fill ?? "solid";
565
- if (o === "solid") {
566
- let e = t;
567
- return {
568
- kind: "solid",
569
- color: e.color,
570
- opacity: e.opacity
571
- };
572
- }
573
- if (o !== "linear-gradient" && o !== "radial-gradient" && o !== "conic-gradient") return;
574
- let s = t, c = Je(e, s.units);
575
- return c ? s.fill === "linear-gradient" ? qe(s, r, Ye(c, s)) : s.fill === "radial-gradient" ? qe(s, i, Xe(c, s)) : qe(s, n, Ze(c, s)) : null;
576
- }
577
- function qe(e, t, n) {
578
- return {
579
- kind: "ramp",
580
- stops: e.stops,
581
- space: e.interpolate ?? "rgb",
582
- opacity: e.opacity,
583
- mode: t,
584
- uv: n
585
- };
586
- }
587
- function Je(e, t) {
588
- let n = X(e, t);
589
- return n && o.multiply(n, e.state.transform);
590
- }
591
- function Ye(e, t) {
592
- let n = t.to.x - t.from.x, r = t.to.y - t.from.y, i = Math.hypot(n, r) || 1, a = 1 / (i * i);
593
- return {
594
- ux: (e[0] * n + e[1] * r) * a,
595
- uy: (e[3] * n + e[4] * r) * a,
596
- u0: ((e[6] - t.from.x) * n + (e[7] - t.from.y) * r) * a,
597
- vx: 0,
598
- vy: 0,
599
- v0: 0
600
- };
601
- }
602
- function Xe(e, t) {
603
- let n = 1 / Math.max(t.radius, 1e-4);
604
- return {
605
- ux: e[0] * n,
606
- uy: e[3] * n,
607
- u0: (e[6] - t.center.x) * n,
608
- vx: e[1] * n,
609
- vy: e[4] * n,
610
- v0: (e[7] - t.center.y) * n
611
- };
612
- }
613
- function Ze(e, t) {
614
- let n = Math.cos(t.angle), r = Math.sin(t.angle), i = e[6] - t.center.x, a = e[7] - t.center.y;
615
- return {
616
- ux: n * e[0] + r * e[1],
617
- uy: n * e[3] + r * e[4],
618
- u0: n * i + r * a,
619
- vx: n * e[1] - r * e[0],
620
- vy: n * e[4] - r * e[3],
621
- v0: n * a - r * i
622
- };
623
- }
624
- function Qe(e, t) {
625
- return e.mode === r ? {
626
- uv: {
627
- ...e.uv,
628
- v0: t
629
- },
630
- post: 1
631
- } : {
632
- uv: e.uv,
633
- post: t
634
- };
635
- }
636
- function $e(e, t, n) {
637
- let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, 4), { uv: o, post: s } = Qe(n, a);
638
- e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, $e);
639
- }
640
- function et(e, t, n) {
641
- let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = Qe(n, a);
642
- e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, et);
643
- }
644
- function K(e, t, n) {
645
- return n !== void 0 && He(e, t) ? (n.kind === "ramp" ? et(e, t, n) : Ke(e, t, n), !0) : (F(e), !1);
646
- }
647
- function q(e) {
648
- let t = e.drawBatch, n = e.batchState;
649
- if (t.length === 0 || n === void 0) {
650
- e.batchState = void 0;
651
- return;
652
- }
653
- let r = e.gl, i = e.batchFill;
654
- r.useProgram(i.handle);
655
- let a = t.uploadAndBind();
656
- J(e, i, D), me(e, i, 1, 1, 1, 1), E(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), k(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
657
- for (let t = 0; t < n.textures.length; t++) {
658
- let i = n.textures[t];
659
- if (i.kind === "atlas") {
660
- e.textureCache.bind(i.id, t + 1), I[2 * (t + 1)] = i.fieldScale[0], I[2 * (t + 1) + 1] = i.fieldScale[1];
661
- continue;
662
- }
663
- if (i.kind === "ramps") {
664
- e.gradRamps.bind(t + 1);
665
- continue;
666
- }
667
- e.imageCache.bind(i.image, t + 1), e.imageCache.setMagFilter(i.image, i.sampling === "nearest" ? r.NEAREST : r.LINEAR);
668
- }
669
- r.uniform1iv(i.uniform("u_samplers"), Le), r.uniform2fv(i.uniform("u_fieldScale"), I), Z(e, n.clipDepth), C(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
670
- }
671
- function tt(e, t) {
672
- let n = t.anchorA, r = t.anchorB, i = t.anchorT;
673
- if (!n || !r || !i) return new Float32Array(e);
674
- let a = n.length, o = new Float32Array(a * 4);
675
- for (let t = 0; t < a; t++) {
676
- let a = n[t] * 4, s = r[t] * 4, c = i[t];
677
- o[t * 4 + 0] = e[a + 0] + (e[s + 0] - e[a + 0]) * c, o[t * 4 + 1] = e[a + 1] + (e[s + 1] - e[a + 1]) * c, o[t * 4 + 2] = e[a + 2] + (e[s + 2] - e[a + 2]) * c, o[t * 4 + 3] = e[a + 3] + (e[s + 3] - e[a + 3]) * c;
678
- }
679
- return o;
680
- }
681
- function nt(e, t, n, r) {
682
- let i = e.gl, a = e.pathFillVColor;
683
- i.useProgram(a.handle), i.bindVertexArray(r.vao), J(e, a), Y(e, a, n.color, n.opacity), k(e, a);
684
- let o = tt(t.vertexColors, r), s = i.createBuffer();
685
- if (!s) throw Error("drawPathFillVColor: createBuffer (color VBO) returned null");
686
- i.bindBuffer(i.ARRAY_BUFFER, s), i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
687
- let c = a.attribute("a_vertexColor");
688
- c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e), C(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
689
- }
690
- function J(e, t, n = e.state.transform, r = he(e)) {
691
- let i = e.gl, a = w(e, t);
692
- T(a.proj, r) || (i.uniformMatrix3fv(t.uniform("u_proj"), !1, r), a.proj = Float32Array.from(r)), T(a.model, n) || (i.uniformMatrix3fv(t.uniform("u_model"), !1, n), a.model = Float32Array.from(n));
693
- }
694
- function Y(e, t, n, r) {
695
- let [i, o, s, c] = a(n);
696
- me(e, t, i, o, s, c * (r ?? 1)), E(e, t, e.state.alpha);
697
- }
698
- function rt(e, t) {
699
- let n = t.fill ?? "solid";
700
- if (n === "solid") return lt(e, t);
701
- if (n === "pattern") return ut(e, t);
702
- if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return mt(e, t);
703
- let r = l(n)?.bind;
704
- return r ? r(it(e), t) : null;
705
- }
706
- function it(e) {
707
- let t = at.get(e);
708
- if (t) return t;
709
- let n = {
710
- gl: e.gl,
711
- get alpha() {
712
- return e.state.alpha;
713
- },
714
- program: (t) => e.ensureProgram?.(t) ?? e.programRegistry.get(t) ?? null,
715
- setProjAndModel: (t) => J(e, t),
716
- spaceInverse: (t) => X(e, t),
717
- spaceToDevice: (t) => pt(e, t),
718
- get maxTextureSize() {
719
- return e.imageCache.maxTextureSide;
720
- },
721
- resources: e.paintResources ?? st(e.gl),
722
- bindRamp: (t, n, r) => {
723
- let i = e.gradRamps.upload(t, r);
724
- return e.gradRamps.bind(n), e.gradRamps.rowV(i);
725
- }
726
- };
727
- return at.set(e, n), n;
728
- }
729
- var at = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap();
730
- function st(t) {
731
- let n = ot.get(t);
732
- return n || (n = e(), ot.set(t, n)), n;
733
- }
734
- function ct(e, t, n) {
735
- if (!rt(e, t)) return;
736
- let r = e.gl;
737
- r.bindVertexArray(n.vao), Z(e), C(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
738
- }
739
- function lt(e, t) {
740
- let n = e.pathFill;
741
- return e.gl.useProgram(n.handle), J(e, n), Y(e, n, t.color, t.opacity), k(e, n), n;
742
- }
743
- function ut(e, t) {
744
- return dt(e, e.patternFill, t, e.state.transform);
745
- }
746
- function dt(e, t, n, r) {
747
- let i = n.pattern, a = c(i.id);
748
- if (!a) return (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel: pattern TextureHandle "${i.id}" not registered`), null;
749
- let o = X(e, n.units);
750
- if (!o) return null;
751
- let s = d(o, n.origin ?? {
752
- x: 0,
753
- y: 0
754
- }, n.transform);
755
- if (!s) return null;
756
- e.textureCache.upload(i.id, a.source, "repeat");
757
- let l = e.gl;
758
- l.useProgram(t.handle), J(e, t, r), k(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
759
- let [u, f] = ft(a.source);
760
- return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), E(e, t, e.state.alpha), t;
761
- }
762
- function ft(e) {
763
- let t = "naturalWidth" in e ? e.naturalWidth : e.width, n = "naturalHeight" in e ? e.naturalHeight : e.height;
764
- return [t || 1, n || 1];
765
- }
766
- function X(e, t) {
767
- return t === "local" ? o.invert(e.state.transform) : t === "world" && e.viewMatrix ? o.invert(e.viewMatrix) : o.identity();
768
- }
769
- function pt(e, t) {
770
- let n = X(e, t), r = n && o.invert(n);
771
- if (!r) return null;
772
- let i = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1;
773
- return o.multiply(o.scaled(o.identity(), i, i), r);
774
- }
775
- function mt(e, t) {
776
- return ht(e, e.gradFill, t, e.state.transform);
777
- }
778
- function ht(e, t, n, r) {
779
- let i = X(e, n.units);
780
- if (!i) return null;
781
- let a = e.gl, o = e.gradRamps.upload(n.stops, n.interpolate ?? "rgb");
782
- if (a.useProgram(t.handle), J(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), k(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), E(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
783
- a.uniform1i(t.uniform("u_gradKind"), 0);
784
- let e = n.to.x - n.from.x, r = n.to.y - n.from.y, i = Math.hypot(e, r) || 1;
785
- a.uniform2f(t.uniform("u_gradP0"), n.from.x, n.from.y), a.uniform2f(t.uniform("u_gradDir"), e / i, r / i), a.uniform1f(t.uniform("u_gradLen"), i), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), 0);
786
- } else n.fill === "radial-gradient" ? (a.uniform1i(t.uniform("u_gradKind"), 1), a.uniform2f(t.uniform("u_gradP0"), n.center.x, n.center.y), a.uniform2f(t.uniform("u_gradDir"), 0, 0), a.uniform1f(t.uniform("u_gradLen"), 0), a.uniform1f(t.uniform("u_gradRadius"), n.radius), a.uniform1f(t.uniform("u_gradAngle"), 0)) : (a.uniform1i(t.uniform("u_gradKind"), 2), a.uniform2f(t.uniform("u_gradP0"), n.center.x, n.center.y), a.uniform2f(t.uniform("u_gradDir"), 0, 0), a.uniform1f(t.uniform("u_gradLen"), 0), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), n.angle));
787
- return t;
788
- }
789
- function Z(e, t = e.clipDepth) {
790
- let n = e.gl;
791
- if (t === 0) {
792
- n.disable(n.STENCIL_TEST);
793
- return;
794
- }
795
- let r = Q(t);
796
- n.enable(n.STENCIL_TEST), n.stencilFunc(n.EQUAL, r, r), n.stencilOp(n.KEEP, n.KEEP, n.KEEP);
797
- }
798
- function Q(e) {
799
- return e === 0 ? 0 : (1 << e + 1) - 1 & 254;
800
- }
801
- function gt(e, t, n) {
802
- let r = e.gl, i = ve(e, t);
803
- r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao), J(e, e.pathFill, n), C(e, i.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
804
- }
805
- function _t(e, t, n, r = e.state.transform) {
806
- q(e);
807
- let i = e.gl, a = Q(n - 1), o = 1 << n, s = a | o;
808
- i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
809
- }
810
- function vt(e, t, n, r = e.state.transform) {
811
- e.batchState !== void 0 && e.batchState.clipDepth > n && q(e);
812
- let i = e.gl;
813
- i.enable(i.STENCIL_TEST);
814
- let a = 1 << n + 1, o = Q(n) | a;
815
- i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
816
- }
817
- function yt(e, t, n) {
818
- let r = e.gl;
819
- r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), J(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), C(e, n.indexCount, e.gl.UNSIGNED_INT);
820
- let i = Q(e.clipDepth);
821
- r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), rt(e, t) && C(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
822
- }
823
- function bt(e, t) {
824
- let { cmd: n, spaces: r } = y(e.state.transform, t), i = n.stroke, a = i.align ?? "center", o = r.ribbon?.metric;
825
- (n.path.kind === "polygon" || o !== void 0 && !p(o)) && a !== "center" ? (F(e), wt(e, n, a, r)) : xt(e, n, r);
826
- let s = m(i.width ?? 1, 1), c = b(n.path, t.stroke, i, s, e.flattenTolerance, r);
827
- for (let t of c) Fe(e, t);
828
- }
829
- function xt(e, t, n) {
830
- let r = t.stroke, i = r.paint, a = i.fill === void 0 || i.fill === "solid", o = i, s = h(t.path, r, e.flattenTolerance, n);
831
- if (s.indices.length === 0) return;
832
- let c = !!(r.vertexColors && r.vertexColors.length > 0), l = G(e, i, c);
833
- if (l === null || K(e, s, l)) return;
834
- let u = c ? e.meshCache.uploadTransient(s) : e.meshCache.uploadRecurring(s);
835
- if (!a && !c) {
836
- ct(e, i, u);
837
- return;
838
- }
839
- let d = e.gl;
840
- if (c) {
841
- let t = e.pathFillVColor;
842
- d.useProgram(t.handle), d.bindVertexArray(u.vao), J(e, t), Y(e, t, a ? o.color : "#ffffff", i.opacity), k(e, t);
843
- let n = tt(r.vertexColors, u), s = d.createBuffer();
844
- if (!s) throw Error("drawPathStrokeUnclipped: createBuffer (color VBO) returned null");
845
- d.bindBuffer(d.ARRAY_BUFFER, s), d.bufferData(d.ARRAY_BUFFER, n, d.DYNAMIC_DRAW);
846
- let c = t.attribute("a_vertexColor");
847
- c !== void 0 && (d.enableVertexAttribArray(c), d.vertexAttribPointer(c, 4, d.FLOAT, !1, 0, 0)), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null), d.deleteBuffer(s);
848
- return;
849
- }
850
- d.useProgram(e.pathFill.handle), d.bindVertexArray(u.vao), J(e, e.pathFill), Y(e, e.pathFill, o.color, o.opacity), k(e, e.pathFill), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null);
851
- }
852
- var St = /* @__PURE__ */ new WeakMap();
853
- function Ct(e) {
854
- let t = St.get(e);
855
- return t === void 0 && (t = e.map((e) => e * 2), St.set(e, t)), t;
856
- }
857
- function wt(e, t, n, r) {
858
- let i = t.stroke, a = i.paint, o = a.fill === void 0 || a.fill === "solid", s = a, c = {
859
- ...i,
860
- width: m(i.width ?? 1, 1) * 2,
861
- ...i.vertexWidths ? { vertexWidths: Ct(i.vertexWidths) } : {},
862
- align: "center"
863
- }, l = !!(i.vertexColors && i.vertexColors.length > 0), u = ve(e, t.path), d = h(t.path, c, e.flattenTolerance, r);
864
- if (d.indices.length === 0) return;
865
- let f = l ? e.meshCache.uploadTransient(d) : e.meshCache.uploadRecurring(d), p = e.gl, g = l ? e.pathFillVColor : e.pathFill;
866
- p.useProgram(g.handle), J(e, g), p.enable(p.STENCIL_TEST), p.colorMask(!1, !1, !1, !1), p.stencilMask(1), p.stencilFunc(p.ALWAYS, 1, 1), p.stencilOp(p.KEEP, p.KEEP, p.REPLACE), p.bindVertexArray(u.vao), C(e, u.indexCount, e.gl.UNSIGNED_INT);
867
- let _ = Q(e.clipDepth);
868
- p.colorMask(!0, !0, !0, !0), n === "inner" ? p.stencilFunc(p.EQUAL, _ | 1, _ | 1) : p.stencilFunc(p.EQUAL, _, _ | 1), p.stencilOp(p.KEEP, p.KEEP, p.KEEP);
869
- let v = g;
870
- if (l ? (Y(e, g, o ? s.color : "#ffffff", a.opacity), k(e, g)) : v = rt(e, a), !v) {
871
- p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null);
872
- return;
873
- }
874
- p.bindVertexArray(f.vao);
875
- let y = null;
876
- if (l) {
877
- let e = tt(i.vertexColors, f);
878
- if (y = p.createBuffer(), !y) throw Error("drawPathStrokeStenciled: createBuffer (color VBO) returned null");
879
- p.bindBuffer(p.ARRAY_BUFFER, y), p.bufferData(p.ARRAY_BUFFER, e, p.DYNAMIC_DRAW);
880
- let t = v.attribute("a_vertexColor");
881
- t !== void 0 && (p.enableVertexAttribArray(t), p.vertexAttribPointer(t, 4, p.FLOAT, !1, 0, 0));
882
- }
883
- C(e, f.indexCount, e.gl.UNSIGNED_INT), p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null), y && p.deleteBuffer(y);
884
- }
885
- var Tt = 48;
886
- function Et(e) {
887
- let t = Math.hypot(e[0], e[1]), n = Math.hypot(e[3], e[4]);
888
- return Math.sqrt(t * n) || 1;
889
- }
890
- function Dt(e, t) {
891
- let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? Tt, s = Number.isFinite(o) ? o / Et(e.state.transform) : void 0, c = ce(t.runs, {
892
- maxWidth: a,
893
- alignWidth: t.width,
894
- lineHeight: r,
895
- align: i,
896
- justify: t.justify,
897
- outlineMinSize: s
898
- });
899
- if (c.groups.length === 0 && c.decorations.length === 0) return;
900
- let l = t.x, u = t.y + ue(t.verticalAlign, t.height, c.bounds.height);
901
- for (let t of c.groups) t.source === "outline" ? Ot(e, t, l, u) : Nt(e, t, l, u);
902
- At(e, c.decorations, l, u);
903
- }
904
- function Ot(e, t, n, r) {
905
- let i = t.fill;
906
- if (i !== null) {
907
- let a = _(t, n, r);
908
- a && kt(e, i, a);
909
- }
910
- let a = t.stroke?.paint;
911
- if (!a) return;
912
- let o = v(t, n, r, e.state.transform);
913
- o && kt(e, a, o);
914
- }
915
- function kt(e, t, n) {
916
- let r = G(e, t, !1);
917
- r !== null && (K(e, n, r) || ct(e, t, e.meshCache.uploadTransient(n)));
918
- }
919
- function At(e, t, n, r) {
920
- for (let i of t) {
921
- if (Pt(i.fill) !== null) {
922
- kt(e, i.fill, jt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
923
- continue;
924
- }
925
- let [t, o, s, c] = "color" in i.fill ? a(i.fill.color) : [
926
- 0,
927
- 0,
928
- 0,
929
- 1
930
- ], l;
931
- for (;;) {
932
- let a = B(e, 4);
933
- if (e.drawBatch.pushRect(i.x0 + n, i.y0 + r, i.x1 - i.x0, i.y1 - i.y0, e.state.transform, t, o, s, c * (a.foldsAlpha ? e.state.alpha : 1))) break;
934
- l = M(e);
935
- }
936
- l !== void 0 && N(e, l);
937
- }
938
- }
939
- function jt(e, t, n, r) {
940
- return {
941
- vertices: new Float32Array([
942
- e,
943
- t,
944
- n,
945
- t,
946
- n,
947
- r,
948
- e,
949
- r
950
- ]),
951
- indices: new Uint32Array([
952
- 0,
953
- 1,
954
- 2,
955
- 0,
956
- 2,
957
- 3
958
- ])
959
- };
960
- }
961
- var Mt = .08;
962
- function Nt(e, t, n, r) {
963
- if (t.source === "canvas") {
964
- if (!oe(e.textureCache, t.page)) return;
965
- } else if (!ie(t.family, t.weight, t.style, e.textureCache)) return;
966
- if (t.quads.length === 0) return;
967
- let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne : te, s = ae(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
968
- if (!s) return;
969
- let c = t.synthetic.bold ? Mt : 0, l = t.synthetic.italic ? Math.tan(g) : 0, u = Pt(t.fill);
970
- if (u !== null) {
971
- Ft(e, t, n, r, u, i, o, c, l, s);
972
- return;
973
- }
974
- let d = t.fill !== null && "color" in t.fill ? a(t.fill.color) : [
975
- 0,
976
- 0,
977
- 0,
978
- 1
979
- ], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
980
- for (let a of t.quads) {
981
- f.wouldOverflow(4) && (q(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
982
- let t;
983
- for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], _, h, o);) t = M(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
984
- t !== void 0 && (N(e, t), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
985
- }
986
- }
987
- function Pt(e) {
988
- let t = e?.fill ?? "solid";
989
- return t === "pattern" ? "pattern" : t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient" ? "gradient" : t === "solid" ? null : "texture";
990
- }
991
- var $ = 1;
992
- function Ft(e, t, n, r, i, a, o, s, c, l) {
993
- let u = e.glyphPaintProgram?.(i);
994
- if (!u) return;
995
- F(e);
996
- let d = t.fill, f = e.state.transform, p;
997
- if (i === "pattern") p = dt(e, u, d, D);
998
- else if (i === "gradient") p = ht(e, u, d, D);
999
- else {
1000
- let i = zt(e, d, Lt(t, n, r, c, f));
1001
- p = i && Bt(e, u, i);
1002
- }
1003
- if (!p) return;
1004
- let m = e.gl;
1005
- e.textureCache.bind(a, $), m.uniform1i(u.uniform("u_atlas"), $), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Z(e);
1006
- let h = e.drawBatch, g = h.clip;
1007
- h.clip = null;
1008
- for (let i of t.quads) h.wouldOverflow(4) && It(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, $, o);
1009
- It(e), h.clip = g, m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
1010
- }
1011
- function It(e) {
1012
- let t = e.drawBatch;
1013
- t.length !== 0 && (C(e, t.uploadAndBind(), e.gl.UNSIGNED_INT), t.reset());
1014
- }
1015
- function Lt(e, t, n, r, i) {
1016
- let a = {
1017
- x0: Infinity,
1018
- y0: Infinity,
1019
- x1: -Infinity,
1020
- y1: -Infinity
1021
- }, o = (e, t) => {
1022
- let n = i[0] * e + i[3] * t + i[6], r = i[1] * e + i[4] * t + i[7];
1023
- n < a.x0 && (a.x0 = n), n > a.x1 && (a.x1 = n), r < a.y0 && (a.y0 = r), r > a.y1 && (a.y1 = r);
1024
- };
1025
- for (let i of e.quads) {
1026
- let e = i.x0 + t, a = i.x1 + t, s = i.y0 + n, c = i.y1 + n, l = i.baselineY + n, u = (l - s) * r, d = (l - c) * r;
1027
- o(e + u, s), o(a + u, s), o(a + d, c), o(e + d, c);
1028
- }
1029
- return a;
1030
- }
1031
- var Rt = {
1032
- vertices: new Float32Array([
1033
- 0,
1034
- 0,
1035
- 1,
1036
- 0,
1037
- 1,
1038
- 1,
1039
- 0,
1040
- 1
1041
- ]),
1042
- indices: new Uint32Array([
1043
- 0,
1044
- 1,
1045
- 2,
1046
- 0,
1047
- 2,
1048
- 3
1049
- ])
1050
- };
1051
- function zt(e, t, n) {
1052
- let r = e.paintScratch, i = l(t.fill)?.bind;
1053
- if (!r || !i) return null;
1054
- let a = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1, o = e.deviceWidth ?? Math.round(e.widthCss), s = e.deviceHeight ?? Math.round(e.heightCss), c = Math.max(0, Math.floor(n.x0 * a)), u = Math.max(0, Math.floor(n.y0 * a)), d = e.imageCache.maxTextureSide, f = Math.min(d, Math.min(o, Math.ceil(n.x1 * a)) - c), p = Math.min(d, Math.min(s, Math.ceil(n.y1 * a)) - u);
1055
- if (!(f > 0 && p > 0)) return null;
1056
- let m = c / a, h = u / a, g = f / a, _ = p / a, v = new Float32Array([
1057
- g,
1058
- 0,
1059
- 0,
1060
- 0,
1061
- _,
1062
- 0,
1063
- m,
1064
- h,
1065
- 1
1066
- ]), y = new Float32Array([
1067
- 2 / g,
1068
- 0,
1069
- 0,
1070
- 0,
1071
- 2 / _,
1072
- 0,
1073
- -1 - 2 * m / g,
1074
- -1 - 2 * h / _,
1075
- 1
1076
- ]), b = it(e), ee = {
1077
- ...b,
1078
- alpha: e.state.alpha,
1079
- maxTextureSize: b.maxTextureSize,
1080
- setProjAndModel: (t) => J(e, t, v, y)
1081
- }, x = e.gl, S = r.acquire(f, p), te = x.isEnabled(x.SCISSOR_TEST);
1082
- x.activeTexture(x.TEXTURE0), x.bindTexture(x.TEXTURE_2D, null), x.bindFramebuffer(x.FRAMEBUFFER, S.fbo), x.viewport(0, 0, f, p), x.disable(x.SCISSOR_TEST), x.disable(x.STENCIL_TEST), x.clear(x.COLOR_BUFFER_BIT), x.disable(x.BLEND);
1083
- let ne = i(ee, t);
1084
- return ne && (x.bindVertexArray(e.meshCache.uploadRecurring(Rt).vao), C(e, Rt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), Oe(e, o, s, te), ne ? {
1085
- texture: S.texture,
1086
- uvFromScreen: new Float32Array([
1087
- a / S.width,
1088
- 0,
1089
- 0,
1090
- 0,
1091
- a / S.height,
1092
- 0,
1093
- -c / S.width,
1094
- -u / S.height,
1095
- 1
1096
- ])
1097
- } : null;
1098
- }
1099
- function Bt(e, t, n) {
1100
- let r = e.gl;
1101
- return r.useProgram(t.handle), J(e, t, D), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
1102
- }
1103
- function Vt(e, t) {
1104
- e.imageCache.upload(t.image, t.image);
1105
- let { staged: n, slot: r } = H(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
1106
- if (i) {
1107
- let e = t.image.width, n = t.image.height;
1108
- a = i.x / e, s = (i.x + i.w) / e, o = i.y / n, c = (i.y + i.h) / n;
1109
- }
1110
- if (t.flipX) {
1111
- let e = a;
1112
- a = s, s = e;
1113
- }
1114
- if (t.flipY) {
1115
- let e = o;
1116
- o = c, c = e;
1117
- }
1118
- e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) || P(e, t, void 0, Vt);
1119
- }
1120
- function Ht(e, t) {
1121
- let n = t.sprites, r = Math.floor(n.length / u);
1122
- if (r === 0) return;
1123
- e.imageCache.upload(t.image, t.image);
1124
- let i = t.sampling ?? "linear", { staged: a, slot: o } = H(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
1125
- for (let p = 0, m = 0; p < r; p++, m += u) {
1126
- s.wouldOverflow(4) && (q(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1127
- let r = n[m + 4], u = n[m + 5], p = n[m + 6], h = n[m + 7], g;
1128
- for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g = M(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1;
1129
- g !== void 0 && (N(e, g), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
68
+ }), t.clip) try {
69
+ s(e, t.clip);
70
+ } catch (t) {
71
+ throw e.state.pop(), t;
1130
72
  }
73
+ for (let n of t.children) h(e, n);
74
+ t.clip && l(e), e.state.pop();
1131
75
  }
1132
76
  //#endregion
1133
- export { Tt as OUTLINE_MIN_SCREEN_PX, A as dispatch, Ae as drawGroup, q as flushBatch, f as getMesh, o as mat3, z as meshBatching, vt as popClip, _t as pushClip, xe as setUniform, K as tryStageFill };
77
+ export { d as OUTLINE_MIN_SCREEN_PX, h as dispatch, _ as drawGroup, o as flushBatch };
1134
78
 
1135
79
  //# sourceMappingURL=draw.js.map