@avis-studio/engine 0.0.0-stage → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. package/README.md +193 -2
  2. package/THIRD_PARTY_NOTICES.md +29 -0
  3. package/dist/a11y/focus.d.ts +60 -0
  4. package/dist/a11y/focus.js +222 -0
  5. package/dist/a11y/index.d.ts +2 -0
  6. package/dist/a11y/index.js +4 -0
  7. package/dist/a11y/semantics.d.ts +37 -0
  8. package/dist/a11y/semantics.js +88 -0
  9. package/dist/commands/builtins.d.ts +88 -0
  10. package/dist/commands/builtins.js +362 -0
  11. package/dist/commands/command.d.ts +23 -0
  12. package/dist/commands/command.js +20 -0
  13. package/dist/commands/draft.d.ts +33 -0
  14. package/dist/commands/draft.js +96 -0
  15. package/dist/commands/history.d.ts +34 -0
  16. package/dist/commands/history.js +80 -0
  17. package/dist/commands/index.d.ts +6 -0
  18. package/dist/commands/index.js +6 -0
  19. package/dist/commands/patch.d.ts +24 -0
  20. package/dist/commands/patch.js +44 -0
  21. package/dist/commands/transaction.d.ts +16 -0
  22. package/dist/commands/transaction.js +39 -0
  23. package/dist/core/diagnostics.d.ts +23 -0
  24. package/dist/core/diagnostics.js +23 -0
  25. package/dist/core/disposable.d.ts +14 -0
  26. package/dist/core/disposable.js +51 -0
  27. package/dist/core/engine.d.ts +108 -0
  28. package/dist/core/engine.js +323 -0
  29. package/dist/core/event-bus.d.ts +10 -0
  30. package/dist/core/event-bus.js +33 -0
  31. package/dist/core/ids.d.ts +13 -0
  32. package/dist/core/ids.js +6 -0
  33. package/dist/core/index.d.ts +7 -0
  34. package/dist/core/index.js +7 -0
  35. package/dist/core/plugin.d.ts +20 -0
  36. package/dist/core/plugin.js +47 -0
  37. package/dist/core/services.d.ts +14 -0
  38. package/dist/core/services.js +20 -0
  39. package/dist/devtools/index.d.ts +1 -0
  40. package/dist/devtools/index.js +2 -0
  41. package/dist/devtools/panel.d.ts +39 -0
  42. package/dist/devtools/panel.js +100 -0
  43. package/dist/dom/a11y-layer.d.ts +32 -0
  44. package/dist/dom/a11y-layer.js +358 -0
  45. package/dist/dom/anchor.d.ts +34 -0
  46. package/dist/dom/anchor.js +35 -0
  47. package/dist/dom/index.d.ts +6 -0
  48. package/dist/dom/index.js +8 -0
  49. package/dist/dom/menu.d.ts +24 -0
  50. package/dist/dom/menu.js +122 -0
  51. package/dist/dom/overlays.d.ts +29 -0
  52. package/dist/dom/overlays.js +82 -0
  53. package/dist/dom/paint/collect.d.ts +8 -0
  54. package/dist/dom/paint/collect.js +589 -0
  55. package/dist/dom/paint/css.d.ts +86 -0
  56. package/dist/dom/paint/css.js +526 -0
  57. package/dist/dom/paint/draw.d.ts +16 -0
  58. package/dist/dom/paint/draw.js +413 -0
  59. package/dist/dom/paint/ghost.d.ts +2 -0
  60. package/dist/dom/paint/ghost.js +8 -0
  61. package/dist/dom/paint/index.d.ts +6 -0
  62. package/dist/dom/paint/index.js +9 -0
  63. package/dist/dom/paint/text.d.ts +26 -0
  64. package/dist/dom/paint/text.js +209 -0
  65. package/dist/dom/paint/types.d.ts +174 -0
  66. package/dist/dom/paint/types.js +7 -0
  67. package/dist/dom/paint/watch.d.ts +10 -0
  68. package/dist/dom/paint/watch.js +109 -0
  69. package/dist/dom/position.d.ts +37 -0
  70. package/dist/dom/position.js +125 -0
  71. package/dist/dom/text-editor.d.ts +27 -0
  72. package/dist/dom/text-editor.js +128 -0
  73. package/dist/events/event.d.ts +122 -0
  74. package/dist/events/event.js +130 -0
  75. package/dist/events/eventer.d.ts +24 -0
  76. package/dist/events/eventer.js +83 -0
  77. package/dist/events/index.d.ts +3 -0
  78. package/dist/events/index.js +3 -0
  79. package/dist/events/interaction.d.ts +43 -0
  80. package/dist/events/interaction.js +203 -0
  81. package/dist/geometry/anchors.d.ts +14 -0
  82. package/dist/geometry/anchors.js +13 -0
  83. package/dist/geometry/bounds.d.ts +16 -0
  84. package/dist/geometry/bounds.js +42 -0
  85. package/dist/geometry/curves.d.ts +39 -0
  86. package/dist/geometry/curves.js +68 -0
  87. package/dist/geometry/index.d.ts +6 -0
  88. package/dist/geometry/index.js +6 -0
  89. package/dist/geometry/matrix.d.ts +22 -0
  90. package/dist/geometry/matrix.js +56 -0
  91. package/dist/geometry/spaces.d.ts +22 -0
  92. package/dist/geometry/spaces.js +28 -0
  93. package/dist/geometry/vec2.d.ts +12 -0
  94. package/dist/geometry/vec2.js +10 -0
  95. package/dist/index.d.ts +16 -0
  96. package/dist/index.js +22 -0
  97. package/dist/interaction/behaviors.d.ts +10 -0
  98. package/dist/interaction/behaviors.js +744 -0
  99. package/dist/interaction/controller.d.ts +180 -0
  100. package/dist/interaction/controller.js +269 -0
  101. package/dist/interaction/hit-test.d.ts +45 -0
  102. package/dist/interaction/hit-test.js +119 -0
  103. package/dist/interaction/index.d.ts +4 -0
  104. package/dist/interaction/index.js +7 -0
  105. package/dist/interaction/web-input.d.ts +13 -0
  106. package/dist/interaction/web-input.js +172 -0
  107. package/dist/layout/index.d.ts +1 -0
  108. package/dist/layout/index.js +2 -0
  109. package/dist/layout/layout.d.ts +27 -0
  110. package/dist/layout/layout.js +266 -0
  111. package/dist/react/canvas/graph.d.ts +83 -0
  112. package/dist/react/canvas/graph.js +89 -0
  113. package/dist/react/canvas/hooks.d.ts +42 -0
  114. package/dist/react/canvas/hooks.js +78 -0
  115. package/dist/react/canvas/index.d.ts +35 -0
  116. package/dist/react/canvas/index.js +8 -0
  117. package/dist/react/components.d.ts +55 -0
  118. package/dist/react/components.js +197 -0
  119. package/dist/react/context.d.ts +4 -0
  120. package/dist/react/context.js +9 -0
  121. package/dist/react/flow/api/LICENSE +21 -0
  122. package/dist/react/flow/api/externals.d.ts +12 -0
  123. package/dist/react/flow/api/react/additional-components/Background/Background.d.ts +7 -0
  124. package/dist/react/flow/api/react/additional-components/Background/Patterns.d.ts +17 -0
  125. package/dist/react/flow/api/react/additional-components/Background/index.d.ts +2 -0
  126. package/dist/react/flow/api/react/additional-components/Background/types.d.ts +25 -0
  127. package/dist/react/flow/api/react/additional-components/Controls/ControlButton.d.ts +2 -0
  128. package/dist/react/flow/api/react/additional-components/Controls/Controls.d.ts +7 -0
  129. package/dist/react/flow/api/react/additional-components/Controls/Icons/FitView.d.ts +1 -0
  130. package/dist/react/flow/api/react/additional-components/Controls/Icons/Lock.d.ts +1 -0
  131. package/dist/react/flow/api/react/additional-components/Controls/Icons/Minus.d.ts +1 -0
  132. package/dist/react/flow/api/react/additional-components/Controls/Icons/Plus.d.ts +1 -0
  133. package/dist/react/flow/api/react/additional-components/Controls/Icons/Unlock.d.ts +1 -0
  134. package/dist/react/flow/api/react/additional-components/Controls/index.d.ts +3 -0
  135. package/dist/react/flow/api/react/additional-components/Controls/types.d.ts +20 -0
  136. package/dist/react/flow/api/react/additional-components/EdgeToolbar/EdgeToolbar.d.ts +2 -0
  137. package/dist/react/flow/api/react/additional-components/EdgeToolbar/index.d.ts +2 -0
  138. package/dist/react/flow/api/react/additional-components/EdgeToolbar/types.d.ts +6 -0
  139. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMap.d.ts +8 -0
  140. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNode.d.ts +4 -0
  141. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNodes.d.ts +5 -0
  142. package/dist/react/flow/api/react/additional-components/MiniMap/index.d.ts +3 -0
  143. package/dist/react/flow/api/react/additional-components/MiniMap/types.d.ts +44 -0
  144. package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
  145. package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizer.d.ts +2 -0
  146. package/dist/react/flow/api/react/additional-components/NodeResizer/index.d.ts +3 -0
  147. package/dist/react/flow/api/react/additional-components/NodeResizer/types.d.ts +32 -0
  148. package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbar.d.ts +2 -0
  149. package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbarPortal.d.ts +4 -0
  150. package/dist/react/flow/api/react/additional-components/NodeToolbar/index.d.ts +2 -0
  151. package/dist/react/flow/api/react/additional-components/NodeToolbar/types.d.ts +9 -0
  152. package/dist/react/flow/api/react/additional-components/index.d.ts +6 -0
  153. package/dist/react/flow/api/react/components/A11yDescriptions/index.d.ts +7 -0
  154. package/dist/react/flow/api/react/components/Attribution/index.d.ts +8 -0
  155. package/dist/react/flow/api/react/components/BatchProvider/index.d.ts +10 -0
  156. package/dist/react/flow/api/react/components/BatchProvider/types.d.ts +6 -0
  157. package/dist/react/flow/api/react/components/BatchProvider/useQueue.d.ts +2 -0
  158. package/dist/react/flow/api/react/components/ConnectionLine/index.d.ts +11 -0
  159. package/dist/react/flow/api/react/components/EdgeLabelRenderer/index.d.ts +5 -0
  160. package/dist/react/flow/api/react/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +14 -0
  161. package/dist/react/flow/api/react/components/EdgeWrapper/index.d.ts +5 -0
  162. package/dist/react/flow/api/react/components/EdgeWrapper/utils.d.ts +11 -0
  163. package/dist/react/flow/api/react/components/Edges/BaseEdge.d.ts +2 -0
  164. package/dist/react/flow/api/react/components/Edges/BezierEdge.d.ts +4 -0
  165. package/dist/react/flow/api/react/components/Edges/EdgeAnchor.d.ts +13 -0
  166. package/dist/react/flow/api/react/components/Edges/EdgeText.d.ts +7 -0
  167. package/dist/react/flow/api/react/components/Edges/SimpleBezierEdge.d.ts +20 -0
  168. package/dist/react/flow/api/react/components/Edges/SmoothStepEdge.d.ts +4 -0
  169. package/dist/react/flow/api/react/components/Edges/StepEdge.d.ts +4 -0
  170. package/dist/react/flow/api/react/components/Edges/StraightEdge.d.ts +4 -0
  171. package/dist/react/flow/api/react/components/Edges/index.d.ts +5 -0
  172. package/dist/react/flow/api/react/components/Handle/index.d.ts +8 -0
  173. package/dist/react/flow/api/react/components/NodeWrapper/index.d.ts +4 -0
  174. package/dist/react/flow/api/react/components/NodeWrapper/useNodeObserver.d.ts +7 -0
  175. package/dist/react/flow/api/react/components/NodeWrapper/utils.d.ts +8 -0
  176. package/dist/react/flow/api/react/components/Nodes/DefaultNode.d.ts +2 -0
  177. package/dist/react/flow/api/react/components/Nodes/GroupNode.d.ts +1 -0
  178. package/dist/react/flow/api/react/components/Nodes/InputNode.d.ts +2 -0
  179. package/dist/react/flow/api/react/components/Nodes/OutputNode.d.ts +2 -0
  180. package/dist/react/flow/api/react/components/Nodes/utils.d.ts +12 -0
  181. package/dist/react/flow/api/react/components/NodesSelection/index.d.ts +8 -0
  182. package/dist/react/flow/api/react/components/Panel/index.d.ts +8 -0
  183. package/dist/react/flow/api/react/components/ReactFlowProvider/index.d.ts +20 -0
  184. package/dist/react/flow/api/react/components/SelectionListener/index.d.ts +6 -0
  185. package/dist/react/flow/api/react/components/StoreUpdater/index.d.ts +67 -0
  186. package/dist/react/flow/api/react/components/UserSelection/index.d.ts +1 -0
  187. package/dist/react/flow/api/react/components/ViewportPortal/index.d.ts +4 -0
  188. package/dist/react/flow/api/react/container/EdgeRenderer/MarkerDefinitions.d.ts +9 -0
  189. package/dist/react/flow/api/react/container/EdgeRenderer/MarkerSymbols.d.ts +8 -0
  190. package/dist/react/flow/api/react/container/EdgeRenderer/index.d.ts +12 -0
  191. package/dist/react/flow/api/react/container/FlowRenderer/index.d.ts +13 -0
  192. package/dist/react/flow/api/react/container/GraphView/index.d.ts +10 -0
  193. package/dist/react/flow/api/react/container/GraphView/useNodeOrEdgeTypesWarning.d.ts +3 -0
  194. package/dist/react/flow/api/react/container/GraphView/useStylesLoadedWarning.d.ts +1 -0
  195. package/dist/react/flow/api/react/container/NodeRenderer/index.d.ts +9 -0
  196. package/dist/react/flow/api/react/container/NodeRenderer/useResizeObserver.d.ts +1 -0
  197. package/dist/react/flow/api/react/container/Pane/index.d.ts +10 -0
  198. package/dist/react/flow/api/react/container/ReactFlow/Wrapper.d.ts +19 -0
  199. package/dist/react/flow/api/react/container/ReactFlow/index.d.ts +3 -0
  200. package/dist/react/flow/api/react/container/ReactFlow/init-values.d.ts +3 -0
  201. package/dist/react/flow/api/react/container/Viewport/index.d.ts +6 -0
  202. package/dist/react/flow/api/react/container/ZoomPane/index.d.ts +7 -0
  203. package/dist/react/flow/api/react/contexts/HandleConfigContext.d.ts +11 -0
  204. package/dist/react/flow/api/react/contexts/NodeIdContext.d.ts +5 -0
  205. package/dist/react/flow/api/react/contexts/StoreContext.d.ts +3 -0
  206. package/dist/react/flow/api/react/hooks/useColorModeClass.d.ts +2 -0
  207. package/dist/react/flow/api/react/hooks/useConnection.d.ts +3 -0
  208. package/dist/react/flow/api/react/hooks/useDrag.d.ts +12 -0
  209. package/dist/react/flow/api/react/hooks/useEdges.d.ts +2 -0
  210. package/dist/react/flow/api/react/hooks/useGlobalKeyHandler.d.ts +5 -0
  211. package/dist/react/flow/api/react/hooks/useHandleConnections.d.ts +10 -0
  212. package/dist/react/flow/api/react/hooks/useInternalNode.d.ts +2 -0
  213. package/dist/react/flow/api/react/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
  214. package/dist/react/flow/api/react/hooks/useKeyPress.d.ts +7 -0
  215. package/dist/react/flow/api/react/hooks/useMoveSelectedNodes.d.ts +5 -0
  216. package/dist/react/flow/api/react/hooks/useNodeConnections.d.ts +2 -0
  217. package/dist/react/flow/api/react/hooks/useNodes.d.ts +2 -0
  218. package/dist/react/flow/api/react/hooks/useNodesData.d.ts +4 -0
  219. package/dist/react/flow/api/react/hooks/useNodesEdgesState.d.ts +12 -0
  220. package/dist/react/flow/api/react/hooks/useNodesInitialized.d.ts +4 -0
  221. package/dist/react/flow/api/react/hooks/useOnEdgesChangeMiddleware.d.ts +3 -0
  222. package/dist/react/flow/api/react/hooks/useOnInitHandler.d.ts +2 -0
  223. package/dist/react/flow/api/react/hooks/useOnNodesChangeMiddleware.d.ts +3 -0
  224. package/dist/react/flow/api/react/hooks/useOnSelectionChange.d.ts +5 -0
  225. package/dist/react/flow/api/react/hooks/useOnViewportChange.d.ts +7 -0
  226. package/dist/react/flow/api/react/hooks/useReactFlow.d.ts +2 -0
  227. package/dist/react/flow/api/react/hooks/useResizeHandler.d.ts +2 -0
  228. package/dist/react/flow/api/react/hooks/useStore.d.ts +8 -0
  229. package/dist/react/flow/api/react/hooks/useUpdateNodeInternals.d.ts +2 -0
  230. package/dist/react/flow/api/react/hooks/useViewport.d.ts +2 -0
  231. package/dist/react/flow/api/react/hooks/useViewportHelper.d.ts +3 -0
  232. package/dist/react/flow/api/react/hooks/useViewportSync.d.ts +2 -0
  233. package/dist/react/flow/api/react/hooks/useVisibleEdgeIds.d.ts +1 -0
  234. package/dist/react/flow/api/react/hooks/useVisibleNodeIds.d.ts +1 -0
  235. package/dist/react/flow/api/react/index.d.ts +41 -0
  236. package/dist/react/flow/api/react/store/index.d.ts +18 -0
  237. package/dist/react/flow/api/react/store/initialState.d.ts +18 -0
  238. package/dist/react/flow/api/react/styles/utils.d.ts +2 -0
  239. package/dist/react/flow/api/react/types/component-props.d.ts +127 -0
  240. package/dist/react/flow/api/react/types/edges.d.ts +111 -0
  241. package/dist/react/flow/api/react/types/general.d.ts +53 -0
  242. package/dist/react/flow/api/react/types/index.d.ts +6 -0
  243. package/dist/react/flow/api/react/types/instance.d.ts +64 -0
  244. package/dist/react/flow/api/react/types/nodes.d.ts +41 -0
  245. package/dist/react/flow/api/react/types/store.d.ts +114 -0
  246. package/dist/react/flow/api/react/utils/changes.d.ts +15 -0
  247. package/dist/react/flow/api/react/utils/edges.d.ts +3 -0
  248. package/dist/react/flow/api/react/utils/general.d.ts +5 -0
  249. package/dist/react/flow/api/react/utils/index.d.ts +3 -0
  250. package/dist/react/flow/api/system/constants.d.ts +43 -0
  251. package/dist/react/flow/api/system/index.d.ts +8 -0
  252. package/dist/react/flow/api/system/types/changes.d.ts +48 -0
  253. package/dist/react/flow/api/system/types/edges.d.ts +72 -0
  254. package/dist/react/flow/api/system/types/general.d.ts +175 -0
  255. package/dist/react/flow/api/system/types/handles.d.ts +21 -0
  256. package/dist/react/flow/api/system/types/index.d.ts +7 -0
  257. package/dist/react/flow/api/system/types/nodes.d.ts +89 -0
  258. package/dist/react/flow/api/system/types/panzoom.d.ts +58 -0
  259. package/dist/react/flow/api/system/types/utils.d.ts +46 -0
  260. package/dist/react/flow/api/system/utils/attribution.d.ts +1 -0
  261. package/dist/react/flow/api/system/utils/connections.d.ts +4 -0
  262. package/dist/react/flow/api/system/utils/dom.d.ts +20 -0
  263. package/dist/react/flow/api/system/utils/edge-toolbar.d.ts +1 -0
  264. package/dist/react/flow/api/system/utils/edges/bezier-edge.d.ts +40 -0
  265. package/dist/react/flow/api/system/utils/edges/general.d.ts +44 -0
  266. package/dist/react/flow/api/system/utils/edges/index.d.ts +5 -0
  267. package/dist/react/flow/api/system/utils/edges/positions.d.ts +16 -0
  268. package/dist/react/flow/api/system/utils/edges/smoothstep-edge.d.ts +21 -0
  269. package/dist/react/flow/api/system/utils/edges/straight-edge.d.ts +13 -0
  270. package/dist/react/flow/api/system/utils/general.d.ts +56 -0
  271. package/dist/react/flow/api/system/utils/graph.d.ts +45 -0
  272. package/dist/react/flow/api/system/utils/index.d.ts +12 -0
  273. package/dist/react/flow/api/system/utils/marker.d.ts +8 -0
  274. package/dist/react/flow/api/system/utils/node-toolbar.d.ts +2 -0
  275. package/dist/react/flow/api/system/utils/shallow-node-data.d.ts +4 -0
  276. package/dist/react/flow/api/system/utils/store.d.ts +33 -0
  277. package/dist/react/flow/api/system/utils/types.d.ts +7 -0
  278. package/dist/react/flow/api/system/xydrag/XYDrag.d.ts +56 -0
  279. package/dist/react/flow/api/system/xydrag/index.d.ts +1 -0
  280. package/dist/react/flow/api/system/xydrag/utils.d.ts +22 -0
  281. package/dist/react/flow/api/system/xyhandle/XYHandle.d.ts +2 -0
  282. package/dist/react/flow/api/system/xyhandle/index.d.ts +1 -0
  283. package/dist/react/flow/api/system/xyhandle/types.d.ts +49 -0
  284. package/dist/react/flow/api/system/xyhandle/utils.d.ts +9 -0
  285. package/dist/react/flow/api/system/xyminimap/index.d.ts +27 -0
  286. package/dist/react/flow/api/system/xypanzoom/XYPanZoom.d.ts +11 -0
  287. package/dist/react/flow/api/system/xypanzoom/eventhandler.d.ts +45 -0
  288. package/dist/react/flow/api/system/xypanzoom/filter.d.ts +15 -0
  289. package/dist/react/flow/api/system/xypanzoom/index.d.ts +1 -0
  290. package/dist/react/flow/api/system/xypanzoom/utils.d.ts +8 -0
  291. package/dist/react/flow/api/system/xyresizer/XYResizer.d.ts +51 -0
  292. package/dist/react/flow/api/system/xyresizer/index.d.ts +2 -0
  293. package/dist/react/flow/api/system/xyresizer/types.d.ts +26 -0
  294. package/dist/react/flow/api/system/xyresizer/utils.d.ts +41 -0
  295. package/dist/react/flow/components.d.ts +148 -0
  296. package/dist/react/flow/components.js +526 -0
  297. package/dist/react/flow/configuration.d.ts +6 -0
  298. package/dist/react/flow/configuration.js +27 -0
  299. package/dist/react/flow/drag.d.ts +14 -0
  300. package/dist/react/flow/drag.js +273 -0
  301. package/dist/react/flow/extras.d.ts +155 -0
  302. package/dist/react/flow/extras.js +317 -0
  303. package/dist/react/flow/handle.d.ts +21 -0
  304. package/dist/react/flow/handle.js +149 -0
  305. package/dist/react/flow/hooks.d.ts +47 -0
  306. package/dist/react/flow/hooks.js +131 -0
  307. package/dist/react/flow/index.d.ts +78 -0
  308. package/dist/react/flow/index.js +73 -0
  309. package/dist/react/flow/queries.d.ts +20 -0
  310. package/dist/react/flow/queries.js +30 -0
  311. package/dist/react/flow/react-flow.d.ts +73 -0
  312. package/dist/react/flow/react-flow.js +1445 -0
  313. package/dist/react/flow/resize.d.ts +30 -0
  314. package/dist/react/flow/resize.js +49 -0
  315. package/dist/react/flow/store.d.ts +412 -0
  316. package/dist/react/flow/store.js +713 -0
  317. package/dist/react/flow/style.css +630 -0
  318. package/dist/react/flow/style.css.d.ts +2 -0
  319. package/dist/react/flow/system.d.ts +146 -0
  320. package/dist/react/flow/system.js +300 -0
  321. package/dist/react/flow/types.d.ts +131 -0
  322. package/dist/react/flow/types.js +1 -0
  323. package/dist/react/flow/utils.d.ts +77 -0
  324. package/dist/react/flow/utils.js +285 -0
  325. package/dist/react/hooks.d.ts +14 -0
  326. package/dist/react/hooks.js +44 -0
  327. package/dist/react/index.d.ts +3 -0
  328. package/dist/react/index.js +5 -0
  329. package/dist/render/backend.d.ts +26 -0
  330. package/dist/render/backend.js +5 -0
  331. package/dist/render/canvas2d/backend.d.ts +7 -0
  332. package/dist/render/canvas2d/backend.js +122 -0
  333. package/dist/render/canvas2d/index.d.ts +1 -0
  334. package/dist/render/canvas2d/index.js +2 -0
  335. package/dist/render/color.d.ts +9 -0
  336. package/dist/render/color.js +69 -0
  337. package/dist/render/commands.d.ts +69 -0
  338. package/dist/render/commands.js +1 -0
  339. package/dist/render/display-list.d.ts +65 -0
  340. package/dist/render/display-list.js +316 -0
  341. package/dist/render/images.d.ts +35 -0
  342. package/dist/render/images.js +83 -0
  343. package/dist/render/index.d.ts +14 -0
  344. package/dist/render/index.js +16 -0
  345. package/dist/render/painters.d.ts +35 -0
  346. package/dist/render/painters.js +109 -0
  347. package/dist/render/renderer.d.ts +70 -0
  348. package/dist/render/renderer.js +162 -0
  349. package/dist/render/scene-index.d.ts +21 -0
  350. package/dist/render/scene-index.js +64 -0
  351. package/dist/render/text.d.ts +8 -0
  352. package/dist/render/text.js +100 -0
  353. package/dist/render/theme.d.ts +21 -0
  354. package/dist/render/theme.js +33 -0
  355. package/dist/render/ui.d.ts +63 -0
  356. package/dist/render/ui.js +188 -0
  357. package/dist/render/webgl2/atlas.d.ts +36 -0
  358. package/dist/render/webgl2/atlas.js +93 -0
  359. package/dist/render/webgl2/backend.d.ts +19 -0
  360. package/dist/render/webgl2/backend.js +338 -0
  361. package/dist/render/webgl2/index.d.ts +2 -0
  362. package/dist/render/webgl2/index.js +3 -0
  363. package/dist/render/webgl2/shaders.d.ts +6 -0
  364. package/dist/render/webgl2/shaders.js +112 -0
  365. package/dist/render/webgpu/index.d.ts +1 -0
  366. package/dist/render/webgpu/index.js +3 -0
  367. package/dist/scene/builtins.d.ts +25 -0
  368. package/dist/scene/builtins.js +60 -0
  369. package/dist/scene/dirty.d.ts +11 -0
  370. package/dist/scene/dirty.js +10 -0
  371. package/dist/scene/index.d.ts +5 -0
  372. package/dist/scene/index.js +5 -0
  373. package/dist/scene/record.d.ts +40 -0
  374. package/dist/scene/record.js +12 -0
  375. package/dist/scene/scene-graph.d.ts +58 -0
  376. package/dist/scene/scene-graph.js +178 -0
  377. package/dist/scene/schema.d.ts +27 -0
  378. package/dist/scene/schema.js +32 -0
  379. package/dist/sdk/create-avis.d.ts +109 -0
  380. package/dist/sdk/create-avis.js +162 -0
  381. package/dist/sdk/index.d.ts +1 -0
  382. package/dist/sdk/index.js +2 -0
  383. package/dist/serialization/format.d.ts +46 -0
  384. package/dist/serialization/format.js +20 -0
  385. package/dist/serialization/index.d.ts +3 -0
  386. package/dist/serialization/index.js +3 -0
  387. package/dist/serialization/migrate.d.ts +7 -0
  388. package/dist/serialization/migrate.js +54 -0
  389. package/dist/serialization/serialize.d.ts +10 -0
  390. package/dist/serialization/serialize.js +114 -0
  391. package/dist/state/index.d.ts +2 -0
  392. package/dist/state/index.js +2 -0
  393. package/dist/state/selector.d.ts +6 -0
  394. package/dist/state/selector.js +29 -0
  395. package/dist/state/store.d.ts +91 -0
  396. package/dist/state/store.js +102 -0
  397. package/dist/style/computed.d.ts +84 -0
  398. package/dist/style/computed.js +296 -0
  399. package/dist/style/index.d.ts +6 -0
  400. package/dist/style/index.js +8 -0
  401. package/dist/style/style-engine.d.ts +33 -0
  402. package/dist/style/style-engine.js +113 -0
  403. package/dist/style/tokens.d.ts +49 -0
  404. package/dist/style/tokens.js +142 -0
  405. package/dist/style/utilities.d.ts +34 -0
  406. package/dist/style/utilities.js +341 -0
  407. package/dist/style/values.d.ts +30 -0
  408. package/dist/style/values.js +361 -0
  409. package/dist/style/variants.d.ts +38 -0
  410. package/dist/style/variants.js +55 -0
  411. package/dist/sync/index.d.ts +2 -0
  412. package/dist/sync/index.js +1 -0
  413. package/dist/sync/save-queue.d.ts +24 -0
  414. package/dist/sync/save-queue.js +88 -0
  415. package/dist/wasm/index.d.ts +2 -0
  416. package/dist/wasm/index.js +2 -0
  417. package/dist/wasm/load.d.ts +7 -0
  418. package/dist/wasm/load.js +47 -0
  419. package/dist/wasm/pkg/avis_engine_wasm.d.ts +84 -0
  420. package/dist/wasm/pkg/avis_engine_wasm.js +339 -0
  421. package/dist/wasm/pkg/avis_engine_wasm_bg.wasm +0 -0
  422. package/dist/wasm/reference.d.ts +38 -0
  423. package/dist/wasm/reference.js +174 -0
  424. package/package.json +76 -4
@@ -0,0 +1,30 @@
1
+ import type { Rgba } from "../render/color.js";
2
+ export type Shadow = {
3
+ x: number;
4
+ y: number;
5
+ blur: number;
6
+ spread: number;
7
+ color: Rgba;
8
+ inset: boolean;
9
+ };
10
+ /** Splits at top-level occurrences of `separator` (outside parentheses). */
11
+ export declare function splitTop(text: string, separator: "," | " "): string[];
12
+ /**
13
+ * Replaces var(--x, fallback) and --theme(--x, fallback) with the values
14
+ * `lookup` gives (themselves resolved), or the fallback. Null when a
15
+ * variable has neither, or on a cycle.
16
+ */
17
+ export declare function substituteVars(text: string, lookup: (name: string) => string | undefined, seen?: ReadonlySet<string>): string | null;
18
+ /** A length in px (`%` of `percentOf` when given); null when it isn't one. */
19
+ export declare function evalLength(text: string, options?: {
20
+ fontSize?: number;
21
+ percentOf?: number;
22
+ }): number | null;
23
+ /** A plain number (unitless), or a percentage as a fraction. */
24
+ export declare function evalNumber(text: string): number | null;
25
+ /** The colour (no var() left in it), or null. */
26
+ export declare function evalColor(input: string): Rgba | null;
27
+ /** A colour with Tailwind's /alpha modifier applied (`bg-primary/50`). */
28
+ export declare const withOpacity: (color: Rgba, opacity: number) => Rgba;
29
+ /** A box-shadow list; null when it can't be read; [] for "none". */
30
+ export declare function evalShadows(text: string): Shadow[] | null;
@@ -0,0 +1,361 @@
1
+ const ROOT_FONT = 16;
2
+ /** The index of the parenthesis closing the one at `open`. */
3
+ function closing(text, open) {
4
+ let depth = 0;
5
+ for (let i = open; i < text.length; i++) {
6
+ if (text[i] === "(")
7
+ depth++;
8
+ else if (text[i] === ")" && --depth === 0)
9
+ return i;
10
+ }
11
+ return -1;
12
+ }
13
+ /** Splits at top-level occurrences of `separator` (outside parentheses). */
14
+ export function splitTop(text, separator) {
15
+ const out = [];
16
+ let depth = 0;
17
+ let start = 0;
18
+ for (let i = 0; i < text.length; i++) {
19
+ const c = text[i];
20
+ if (c === "(")
21
+ depth++;
22
+ else if (c === ")")
23
+ depth--;
24
+ else if (depth === 0 && (separator === " " ? /\s/.test(c) : c === separator)) {
25
+ out.push(text.slice(start, i));
26
+ start = i + 1;
27
+ }
28
+ }
29
+ out.push(text.slice(start));
30
+ return out.map((part) => part.trim()).filter(Boolean);
31
+ }
32
+ /**
33
+ * Replaces var(--x, fallback) and --theme(--x, fallback) with the values
34
+ * `lookup` gives (themselves resolved), or the fallback. Null when a
35
+ * variable has neither, or on a cycle.
36
+ */
37
+ export function substituteVars(text, lookup, seen = new Set()) {
38
+ let out = text;
39
+ for (let guard = 0; guard < 100; guard++) {
40
+ const match = /(var|--theme)\(/.exec(out);
41
+ if (!match)
42
+ return out;
43
+ const open = match.index + match[0].length - 1;
44
+ const close = closing(out, open);
45
+ if (close < 0)
46
+ return null;
47
+ const [name, ...rest] = splitTop(out.slice(open + 1, close), ",");
48
+ const fallback = rest.length ? rest.join(",") : undefined;
49
+ let value;
50
+ if (seen.has(name))
51
+ return null;
52
+ const raw = lookup(name);
53
+ if (raw !== undefined)
54
+ value = substituteVars(raw, lookup, new Set([...seen, name]));
55
+ if ((value === null || value === undefined) && fallback !== undefined && fallback !== "initial") {
56
+ value = substituteVars(fallback, lookup, seen);
57
+ }
58
+ if (value === null || value === undefined)
59
+ return null;
60
+ out = out.slice(0, match.index) + value + out.slice(close + 1);
61
+ }
62
+ return null;
63
+ }
64
+ function parseQuantity(text, fontSize) {
65
+ const m = /^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)(px|rem|em|%|deg|turn|rad)?$/i.exec(text.trim());
66
+ if (!m)
67
+ return null;
68
+ const n = parseFloat(m[1]);
69
+ switch ((m[2] ?? "").toLowerCase()) {
70
+ case "px":
71
+ return { value: n, unit: "px" };
72
+ case "rem":
73
+ return { value: n * ROOT_FONT, unit: "px" };
74
+ case "em":
75
+ return { value: n * fontSize, unit: "px" };
76
+ case "%":
77
+ return { value: n, unit: "%" };
78
+ case "deg":
79
+ return { value: n, unit: "deg" };
80
+ case "turn":
81
+ return { value: n * 360, unit: "deg" };
82
+ case "rad":
83
+ return { value: (n * 180) / Math.PI, unit: "deg" };
84
+ default:
85
+ return { value: n, unit: "" };
86
+ }
87
+ }
88
+ /** calc() arithmetic with * and / before + and -. */
89
+ function evalExpression(text, fontSize) {
90
+ const tokens = [];
91
+ let i = 0;
92
+ const s = text.trim();
93
+ while (i < s.length) {
94
+ const c = s[i];
95
+ if (/\s/.test(c)) {
96
+ i++;
97
+ continue;
98
+ }
99
+ if (c === "(" || /^(calc|min|max|clamp)\(/i.test(s.slice(i))) {
100
+ const open = s.indexOf("(", i);
101
+ const close = closing(s, open);
102
+ if (close < 0)
103
+ return null;
104
+ const name = s.slice(i, open).toLowerCase();
105
+ const inner = s.slice(open + 1, close);
106
+ let value;
107
+ if (name === "min" || name === "max" || name === "clamp") {
108
+ const parts = splitTop(inner, ",").map((part) => evalExpression(part, fontSize));
109
+ if (parts.some((part) => !part))
110
+ return null;
111
+ const values = parts.map((part) => part.value);
112
+ value = {
113
+ value: name === "min"
114
+ ? Math.min(...values)
115
+ : name === "max"
116
+ ? Math.max(...values)
117
+ : Math.min(Math.max(values[1], values[0]), values[2]),
118
+ unit: parts[0].unit,
119
+ };
120
+ }
121
+ else {
122
+ value = evalExpression(inner, fontSize);
123
+ }
124
+ if (!value)
125
+ return null;
126
+ tokens.push(value);
127
+ i = close + 1;
128
+ continue;
129
+ }
130
+ // An operator: * and / always; + and - when spaced or after a value.
131
+ if ("*/".includes(c) || ((c === "+" || c === "-") && tokens.length && typeof tokens[tokens.length - 1] !== "string")) {
132
+ tokens.push(c);
133
+ i++;
134
+ continue;
135
+ }
136
+ const m = /^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?(?:px|rem|em|%|deg|turn|rad)?/i.exec(s.slice(i));
137
+ if (!m)
138
+ return null;
139
+ const quantity = parseQuantity(m[0], fontSize);
140
+ if (!quantity)
141
+ return null;
142
+ tokens.push(quantity);
143
+ i += m[0].length;
144
+ }
145
+ const reduce = (ops) => {
146
+ for (let k = 1; k < tokens.length - 1; k++) {
147
+ const op = tokens[k];
148
+ if (typeof op !== "string" || !ops.includes(op))
149
+ continue;
150
+ const a = tokens[k - 1];
151
+ const b = tokens[k + 1];
152
+ if (typeof a === "string" || typeof b === "string")
153
+ return false;
154
+ const unit = a.unit || b.unit;
155
+ const value = op === "*" ? a.value * b.value : op === "/" ? a.value / b.value : op === "+" ? a.value + b.value : a.value - b.value;
156
+ tokens.splice(k - 1, 3, { value, unit });
157
+ k--;
158
+ }
159
+ return true;
160
+ };
161
+ if (!reduce("*/") || !reduce("+-") || tokens.length !== 1 || typeof tokens[0] === "string")
162
+ return null;
163
+ return tokens[0];
164
+ }
165
+ /** A length in px (`%` of `percentOf` when given); null when it isn't one. */
166
+ export function evalLength(text, options = {}) {
167
+ const q = evalExpression(text, options.fontSize ?? ROOT_FONT);
168
+ if (!q)
169
+ return null;
170
+ if (q.unit === "%")
171
+ return options.percentOf === undefined ? null : (q.value / 100) * options.percentOf;
172
+ return q.value;
173
+ }
174
+ /** A plain number (unitless), or a percentage as a fraction. */
175
+ export function evalNumber(text) {
176
+ const q = evalExpression(text, ROOT_FONT);
177
+ if (!q)
178
+ return null;
179
+ return q.unit === "%" ? q.value / 100 : q.value;
180
+ }
181
+ // ---- colours ------------------------------------------------------------------
182
+ const NAMED = {
183
+ transparent: [0, 0, 0, 0],
184
+ black: [0, 0, 0, 1],
185
+ white: [1, 1, 1, 1],
186
+ };
187
+ const clamp01 = (v) => Math.min(1, Math.max(0, v));
188
+ const toLinear = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
189
+ const toGamma = (c) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
190
+ function oklabToSrgb(L, a, b) {
191
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
192
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
193
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
194
+ return [
195
+ clamp01(toGamma(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s)),
196
+ clamp01(toGamma(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s)),
197
+ clamp01(toGamma(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s)),
198
+ ];
199
+ }
200
+ function srgbToOklab([r, g, b]) {
201
+ const lr = toLinear(r);
202
+ const lg = toLinear(g);
203
+ const lb = toLinear(b);
204
+ const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
205
+ const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
206
+ const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
207
+ return [
208
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
209
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
210
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
211
+ ];
212
+ }
213
+ function hslToRgb(h, s, l) {
214
+ const k = (n) => (n + h / 30) % 12;
215
+ const a = s * Math.min(l, 1 - l);
216
+ const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
217
+ return [f(0), f(8), f(4)];
218
+ }
219
+ /** A channel: "none" is 0; a percentage scales to `percent`. */
220
+ function channel(text, percent) {
221
+ if (text === "none")
222
+ return 0;
223
+ const q = evalExpression(text, ROOT_FONT);
224
+ if (!q)
225
+ return null;
226
+ return q.unit === "%" ? (q.value / 100) * percent : q.value;
227
+ }
228
+ /** The colour (no var() left in it), or null. */
229
+ export function evalColor(input) {
230
+ const text = input.trim().toLowerCase();
231
+ if (NAMED[text])
232
+ return NAMED[text];
233
+ if (text.startsWith("#")) {
234
+ const hex = text.slice(1);
235
+ const full = hex.length === 3 || hex.length === 4 ? [...hex].map((c) => c + c).join("") : hex;
236
+ if (!/^[0-9a-f]{6}([0-9a-f]{2})?$/.test(full))
237
+ return null;
238
+ const n = (i) => parseInt(full.slice(i, i + 2), 16) / 255;
239
+ return [n(0), n(2), n(4), full.length === 8 ? n(6) : 1];
240
+ }
241
+ const fn = /^([a-z-]+)\((.*)\)$/s.exec(text);
242
+ if (!fn)
243
+ return null;
244
+ const [, name, body] = fn;
245
+ if (name === "color-mix")
246
+ return colorMix(body);
247
+ // Modern (space and slash) or legacy (comma) syntax.
248
+ const [main, alphaText] = body.includes("/") ? body.split("/") : [body, undefined];
249
+ const parts = main.includes(",") ? splitTop(main, ",") : splitTop(main, " ");
250
+ const alphaPart = alphaText ?? (parts.length === 4 ? parts.pop() : undefined);
251
+ const alpha = alphaPart === undefined ? 1 : channel(alphaPart.trim(), 1);
252
+ if (parts.length !== 3 || alpha === null)
253
+ return null;
254
+ let rgb = null;
255
+ if (name === "rgb" || name === "rgba") {
256
+ const [r, g, b] = parts.map((part) => channel(part, 255));
257
+ if (r === null || g === null || b === null)
258
+ return null;
259
+ rgb = [r / 255, g / 255, b / 255];
260
+ }
261
+ else if (name === "hsl" || name === "hsla") {
262
+ const [h, s, l] = [channel(parts[0], 1), channel(parts[1], 1), channel(parts[2], 1)];
263
+ if (h === null || s === null || l === null)
264
+ return null;
265
+ rgb = hslToRgb(h, parts[1].endsWith("%") ? s : s / 100, parts[2].endsWith("%") ? l : l / 100);
266
+ }
267
+ else if (name === "oklch") {
268
+ const [L, C, H] = [channel(parts[0], 1), channel(parts[1], 0.4), channel(parts[2], 1)];
269
+ if (L === null || C === null || H === null)
270
+ return null;
271
+ const h = (H * Math.PI) / 180;
272
+ rgb = oklabToSrgb(L, C * Math.cos(h), C * Math.sin(h));
273
+ }
274
+ else if (name === "oklab") {
275
+ const [L, a, b] = [channel(parts[0], 1), channel(parts[1], 0.4), channel(parts[2], 0.4)];
276
+ if (L === null || a === null || b === null)
277
+ return null;
278
+ rgb = oklabToSrgb(L, a, b);
279
+ }
280
+ if (!rgb)
281
+ return null;
282
+ return [clamp01(rgb[0]), clamp01(rgb[1]), clamp01(rgb[2]), clamp01(alpha)];
283
+ }
284
+ /** color-mix(in srgb | oklab | oklch, a p%, b q%) as CSS Color 5 mixes. */
285
+ function colorMix(body) {
286
+ const [space, first, second] = splitTop(body, ",");
287
+ if (!space || !first || !second)
288
+ return null;
289
+ const side = (part) => {
290
+ const pieces = splitTop(part, " ");
291
+ const pct = pieces.find((piece) => /%$/.test(piece));
292
+ const color = evalColor(pieces.filter((piece) => piece !== pct).join(" "));
293
+ return { color, pct: pct === undefined ? null : parseFloat(pct) / 100 };
294
+ };
295
+ const a = side(first);
296
+ const b = side(second);
297
+ if (!a.color || !b.color)
298
+ return null;
299
+ let p1 = a.pct;
300
+ let p2 = b.pct;
301
+ if (p1 === null && p2 === null)
302
+ p1 = p2 = 0.5;
303
+ else if (p1 === null)
304
+ p1 = 1 - p2;
305
+ else if (p2 === null)
306
+ p2 = 1 - p1;
307
+ const sum = p1 + p2;
308
+ if (sum <= 0)
309
+ return null;
310
+ const w1 = p1 / sum;
311
+ const w2 = p2 / sum;
312
+ // Premultiplied mixing; the alpha shrinks when the percentages sum under 100%.
313
+ const alpha = a.color[3] * w1 + b.color[3] * w2;
314
+ const multiplier = Math.min(1, sum);
315
+ const premix = (x, y) => alpha ? x.map((value, k) => (value * a.color[3] * w1 + y[k] * b.color[3] * w2) / alpha) : x.map(() => 0);
316
+ let rgb;
317
+ if (/oklab|oklch/.test(space)) {
318
+ const mixed = premix(srgbToOklab(a.color), srgbToOklab(b.color));
319
+ rgb = oklabToSrgb(mixed[0], mixed[1], mixed[2]);
320
+ }
321
+ else {
322
+ rgb = premix(a.color.slice(0, 3), b.color.slice(0, 3));
323
+ }
324
+ return [clamp01(rgb[0]), clamp01(rgb[1]), clamp01(rgb[2]), clamp01(alpha * multiplier)];
325
+ }
326
+ /** A colour with Tailwind's /alpha modifier applied (`bg-primary/50`). */
327
+ export const withOpacity = (color, opacity) => [color[0], color[1], color[2], color[3] * opacity];
328
+ // ---- shadows --------------------------------------------------------------------
329
+ /** A box-shadow list; null when it can't be read; [] for "none". */
330
+ export function evalShadows(text) {
331
+ if (text.trim() === "none" || text.trim() === "0 0 #0000")
332
+ return [];
333
+ const out = [];
334
+ for (const layer of splitTop(text, ",")) {
335
+ const parts = splitTop(layer, " ");
336
+ const inset = parts.includes("inset");
337
+ const lengths = [];
338
+ let color = null;
339
+ for (const part of parts) {
340
+ if (part === "inset")
341
+ continue;
342
+ const length = evalLength(part);
343
+ if (length !== null && lengths.length < 4 && !/^#|\(/.test(part))
344
+ lengths.push(length);
345
+ else
346
+ color = evalColor(part);
347
+ }
348
+ if (lengths.length < 2)
349
+ return null;
350
+ out.push({
351
+ x: lengths[0],
352
+ y: lengths[1],
353
+ blur: lengths[2] ?? 0,
354
+ spread: lengths[3] ?? 0,
355
+ color: color ?? [0, 0, 0, 1],
356
+ inset,
357
+ });
358
+ }
359
+ // Tailwind's empty layers (transparent, no offset) draw nothing.
360
+ return out.filter((shadow) => shadow.color[3] > 0);
361
+ }
@@ -0,0 +1,38 @@
1
+ type VariantValues = Record<string, string>;
2
+ type VariantMap = Record<string, VariantValues>;
3
+ type Key<T> = T extends "true" | "false" ? boolean | T : T;
4
+ export type VariantProps<V extends VariantMap> = {
5
+ [K in keyof V]?: Key<keyof V[K] & string> | null;
6
+ };
7
+ export type VariantConfig<V extends VariantMap> = {
8
+ base?: string;
9
+ variants?: V;
10
+ compoundVariants?: (VariantProps<V> & {
11
+ [K in keyof V]?: Key<keyof V[K] & string> | Key<keyof V[K] & string>[];
12
+ } & {
13
+ class?: string;
14
+ className?: string;
15
+ })[];
16
+ defaultVariants?: VariantProps<V>;
17
+ };
18
+ /** CVA's `cva(base, { variants, compoundVariants, defaultVariants })`. */
19
+ export declare function variants<V extends VariantMap>(config: VariantConfig<V>): (props?: VariantProps<V> & {
20
+ class?: string;
21
+ className?: string;
22
+ }) => string;
23
+ type SlotClasses<S extends string> = Partial<Record<S, string>>;
24
+ export type SlotConfig<S extends string, V extends Record<string, Record<string, SlotClasses<S>>>> = {
25
+ slots: Record<S, string>;
26
+ variants?: V;
27
+ compoundVariants?: ({
28
+ [K in keyof V]?: Key<keyof V[K] & string> | Key<keyof V[K] & string>[];
29
+ } & {
30
+ class: SlotClasses<S>;
31
+ })[];
32
+ defaultVariants?: {
33
+ [K in keyof V]?: Key<keyof V[K] & string>;
34
+ };
35
+ };
36
+ /** Variants with slots (Root, Trigger, Content, Header, Label, Indicator…). */
37
+ export declare function slotVariants<S extends string, V extends Record<string, Record<string, SlotClasses<S>>>>(config: SlotConfig<S, V>): (props?: { [K in keyof V]?: Key<keyof V[K] & string> | null; }) => Record<S, string>;
38
+ export {};
@@ -0,0 +1,55 @@
1
+ const join = (...parts) => parts.filter(Boolean).join(" ");
2
+ function pick(config, props) {
3
+ const chosen = {};
4
+ for (const key of Object.keys(config.variants ?? {})) {
5
+ const value = props[key] !== undefined && props[key] !== null ? props[key] : config.defaultVariants?.[key];
6
+ if (value !== undefined && value !== null)
7
+ chosen[key] = String(value);
8
+ }
9
+ return chosen;
10
+ }
11
+ /** CVA's `cva(base, { variants, compoundVariants, defaultVariants })`. */
12
+ export function variants(config) {
13
+ return (props = {}) => {
14
+ const chosen = pick(config, props);
15
+ const classes = [config.base];
16
+ for (const [key, value] of Object.entries(chosen))
17
+ classes.push(config.variants?.[key]?.[value]);
18
+ for (const compound of config.compoundVariants ?? []) {
19
+ const { class: cls, className, ...conditions } = compound;
20
+ const ok = Object.entries(conditions).every(([key, expected]) => {
21
+ const value = chosen[key];
22
+ return Array.isArray(expected) ? expected.map(String).includes(value) : String(expected) === value;
23
+ });
24
+ if (ok)
25
+ classes.push(cls, className);
26
+ }
27
+ classes.push(props.class, props.className);
28
+ return join(...classes);
29
+ };
30
+ }
31
+ /** Variants with slots (Root, Trigger, Content, Header, Label, Indicator…). */
32
+ export function slotVariants(config) {
33
+ return (props = {}) => {
34
+ const out = { ...config.slots };
35
+ const add = (classes) => {
36
+ for (const slot of Object.keys(classes ?? {}))
37
+ out[slot] = join(out[slot], classes[slot]);
38
+ };
39
+ const chosen = {};
40
+ for (const key of Object.keys(config.variants ?? {})) {
41
+ const value = props[key] ?? config.defaultVariants?.[key];
42
+ if (value === undefined || value === null)
43
+ continue;
44
+ chosen[key] = String(value);
45
+ add(config.variants?.[key]?.[String(value)]);
46
+ }
47
+ for (const compound of config.compoundVariants ?? []) {
48
+ const { class: classes, ...conditions } = compound;
49
+ const ok = Object.entries(conditions).every(([key, expected]) => Array.isArray(expected) ? expected.map(String).includes(chosen[key]) : String(expected) === chosen[key]);
50
+ if (ok)
51
+ add(classes);
52
+ }
53
+ return out;
54
+ };
55
+ }
@@ -0,0 +1,2 @@
1
+ export { createSaveQueue } from "./save-queue.js";
2
+ export type { SaveQueue, SaveQueueOptions, SaveQueueSnapshot } from "./save-queue.js";
@@ -0,0 +1 @@
1
+ export { createSaveQueue } from "./save-queue.js";
@@ -0,0 +1,24 @@
1
+ /** Backend-neutral, coalescing save queue. The host owns auth, schema and revision policy. */
2
+ export type SaveQueueSnapshot<T> = {
3
+ status: "idle" | "pending" | "saving" | "error" | "paused";
4
+ pending: {
5
+ value: T;
6
+ sequence: number;
7
+ } | null;
8
+ error: unknown;
9
+ };
10
+ export type SaveQueueOptions<T> = {
11
+ save(value: T): Promise<void>;
12
+ debounceMs?: number;
13
+ onError?(error: unknown): void;
14
+ };
15
+ export declare function createSaveQueue<T>(options: SaveQueueOptions<T>): {
16
+ getSnapshot: () => SaveQueueSnapshot<T>;
17
+ subscribe(listener: () => void): () => void;
18
+ enqueue(value: T): void;
19
+ flush: () => Promise<boolean>;
20
+ pause(error?: unknown): void;
21
+ resume(): void;
22
+ dispose(): void;
23
+ };
24
+ export type SaveQueue<T> = ReturnType<typeof createSaveQueue<T>>;
@@ -0,0 +1,88 @@
1
+ export function createSaveQueue(options) {
2
+ const listeners = new Set();
3
+ let state = { status: "idle", pending: null, error: null };
4
+ let timer;
5
+ let active = null;
6
+ let sequence = 0, paused = false, disposed = false;
7
+ const publish = (next) => {
8
+ state = next;
9
+ for (const listener of listeners)
10
+ listener();
11
+ };
12
+ const cancelTimer = () => { clearTimeout(timer); timer = undefined; };
13
+ const schedule = () => {
14
+ cancelTimer();
15
+ if (!paused && !disposed)
16
+ timer = setTimeout(() => { void flush(); }, options.debounceMs ?? 800);
17
+ };
18
+ async function drain() {
19
+ while (state.pending && !paused && !disposed) {
20
+ const pending = state.pending;
21
+ publish({ ...state, status: "saving", error: null });
22
+ try {
23
+ await options.save(pending.value);
24
+ }
25
+ catch (error) {
26
+ if (!disposed) {
27
+ publish({ ...state, status: paused ? "paused" : "error", error });
28
+ options.onError?.(error);
29
+ }
30
+ return false;
31
+ }
32
+ if (disposed)
33
+ return false;
34
+ const remaining = state.pending?.sequence === pending.sequence ? null : state.pending;
35
+ publish({ status: paused ? "paused" : remaining ? "pending" : "idle", pending: remaining, error: null });
36
+ }
37
+ return state.pending === null;
38
+ }
39
+ function flush() {
40
+ cancelTimer();
41
+ if (disposed || paused)
42
+ return Promise.resolve(state.pending === null);
43
+ if (active)
44
+ return active;
45
+ // Start in a microtask so a synchronous subscriber cannot begin a second drain.
46
+ const running = Promise.resolve().then(drain);
47
+ active = running.finally(() => {
48
+ active = null;
49
+ if (state.pending && state.status !== "error")
50
+ schedule();
51
+ });
52
+ return active;
53
+ }
54
+ return {
55
+ getSnapshot: () => state,
56
+ subscribe(listener) {
57
+ if (disposed)
58
+ return () => { };
59
+ listeners.add(listener);
60
+ return () => { listeners.delete(listener); };
61
+ },
62
+ enqueue(value) {
63
+ if (disposed)
64
+ throw new Error("Cannot edit a disposed save queue");
65
+ publish({ status: paused ? "paused" : active ? "saving" : "pending", pending: { value, sequence: ++sequence }, error: paused ? state.error : null });
66
+ // An active drain takes the latest pending value next, without a second writer.
67
+ if (!active)
68
+ schedule();
69
+ },
70
+ flush,
71
+ pause(error = state.error) { paused = true; cancelTimer(); publish({ ...state, status: "paused", error }); },
72
+ resume() {
73
+ if (disposed)
74
+ return;
75
+ paused = false;
76
+ publish({ ...state, status: state.pending ? "pending" : "idle" });
77
+ if (state.pending && !active)
78
+ schedule();
79
+ },
80
+ dispose() {
81
+ disposed = true;
82
+ cancelTimer();
83
+ listeners.clear();
84
+ // An in-flight server commit cannot be undone by disposing its client.
85
+ // Retain the snapshot for the host; never fabricate an acknowledgement.
86
+ },
87
+ };
88
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./reference.js";
2
+ export * from "./load.js";
@@ -0,0 +1,2 @@
1
+ export * from "./reference.js";
2
+ export * from "./load.js";
@@ -0,0 +1,7 @@
1
+ import { type Kernels } from "./reference.js";
2
+ export type LoadedKernels = Kernels & {
3
+ source: "wasm" | "reference";
4
+ };
5
+ export declare function loadKernels(): Promise<LoadedKernels>;
6
+ /** Synchronous load from the module's bytes (tests, workers). */
7
+ export declare function loadKernelsSync(bytes: BufferSource): Promise<LoadedKernels>;
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Loads the shipped Rust kernels (assets/kernels, refreshed by engine:wasm),
3
+ * or falls back to the TypeScript reference if runtime loading fails.
4
+ */
5
+ import { referenceKernels } from "./reference.js";
6
+ /** The Rust exports behind the `Kernels` interface. */
7
+ function fromModule(module) {
8
+ return {
9
+ source: "wasm",
10
+ version: module.version,
11
+ mat2d_multiply: (a, b) => Float64Array.from(module.mat2d_multiply(a, b)),
12
+ createSpatialGrid(cell) {
13
+ const grid = new module.SpatialGrid(cell);
14
+ return {
15
+ get size() {
16
+ return grid.size;
17
+ },
18
+ insert: (id, minX, minY, maxX, maxY) => grid.insert(id, minX, minY, maxX, maxY),
19
+ remove: (id) => grid.remove(id),
20
+ clear: () => grid.clear(),
21
+ query: (minX, minY, maxX, maxY) => grid.query(minX, minY, maxX, maxY),
22
+ free: () => grid.free(),
23
+ };
24
+ },
25
+ strokeBezier: (controls, halfWidth, segments) => module.stroke_bezier(Float64Array.from(controls), halfWidth, segments),
26
+ };
27
+ }
28
+ let loading = null;
29
+ export function loadKernels() {
30
+ loading ??= (async () => {
31
+ try {
32
+ const module = await import("./pkg/avis_engine_wasm.js");
33
+ await module.default();
34
+ return fromModule(module);
35
+ }
36
+ catch {
37
+ return { source: "reference", ...referenceKernels };
38
+ }
39
+ })();
40
+ return loading;
41
+ }
42
+ /** Synchronous load from the module's bytes (tests, workers). */
43
+ export async function loadKernelsSync(bytes) {
44
+ const module = await import("./pkg/avis_engine_wasm.js");
45
+ module.initSync({ module: bytes });
46
+ return fromModule(module);
47
+ }