@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,69 @@
1
+ import type { Mat2D } from "../geometry/matrix.js";
2
+ import type { Rgba } from "./color.js";
3
+ export type FontSpec = {
4
+ family: string;
5
+ size: number;
6
+ weight: number;
7
+ style?: "normal" | "italic";
8
+ };
9
+ export type RectCommand = {
10
+ kind: "rect";
11
+ matrix: Mat2D;
12
+ w: number;
13
+ h: number;
14
+ radius: number;
15
+ fill: Rgba | null;
16
+ stroke: Rgba | null;
17
+ /** Inside the box, in local units. */
18
+ strokeWidth: number;
19
+ nodeId?: string;
20
+ };
21
+ export type ImageCommand = {
22
+ kind: "image";
23
+ matrix: Mat2D;
24
+ w: number;
25
+ h: number;
26
+ radius: number;
27
+ src: string;
28
+ /** How the image fills the box: CSS object-fit's cover or contain. */
29
+ fit: "cover" | "contain" | "fill";
30
+ opacity: number;
31
+ nodeId?: string;
32
+ };
33
+ /** One line of laid-out text; `y` is its top. */
34
+ export type TextCommand = {
35
+ kind: "text";
36
+ matrix: Mat2D;
37
+ x: number;
38
+ y: number;
39
+ text: string;
40
+ font: FontSpec;
41
+ lineHeight: number;
42
+ color: Rgba;
43
+ /** Extra space between letters, local units. */
44
+ letterSpacing?: number;
45
+ nodeId?: string;
46
+ };
47
+ /** A box's soft shadow (CSS box-shadow, outer), drawn under the box. */
48
+ export type ShadowCommand = {
49
+ kind: "shadow";
50
+ matrix: Mat2D;
51
+ w: number;
52
+ h: number;
53
+ radius: number;
54
+ x: number;
55
+ y: number;
56
+ blur: number;
57
+ spread: number;
58
+ color: Rgba;
59
+ nodeId?: string;
60
+ };
61
+ /** Triangles in world space (x, y pairs): strokes and curves. */
62
+ export type MeshCommand = {
63
+ kind: "mesh";
64
+ vertices: Float32Array;
65
+ color: Rgba;
66
+ relationId?: string;
67
+ };
68
+ export type RenderCommand = RectCommand | ImageCommand | TextCommand | MeshCommand | ShadowCommand;
69
+ export declare const fontString: (font: FontSpec, scale?: number) => string;
@@ -0,0 +1 @@
1
+ export const fontString = (font, scale = 1) => `${font.style === "italic" ? "italic " : ""}${font.weight} ${font.size * scale}px ${font.family}`;
@@ -0,0 +1,65 @@
1
+ import type { Engine } from "../core/engine.js";
2
+ import type { Bounds } from "../geometry/bounds.js";
3
+ import { translated } from "../geometry/matrix.js";
4
+ import type { Kernels } from "../wasm/reference.js";
5
+ import { type Rgba } from "./color.js";
6
+ import type { RenderCommand } from "./commands.js";
7
+ import type { StyleEngine } from "../style/style-engine.js";
8
+ import type { PainterRegistry } from "./painters.js";
9
+ import type { SceneIndex } from "./scene-index.js";
10
+ import type { TextMeasurer } from "./text.js";
11
+ import type { RenderTheme } from "./theme.js";
12
+ export type OverlayOptions = {
13
+ /** Resize and rotation handles on the single selected node. */
14
+ transformHandles: boolean;
15
+ handleSize: number;
16
+ rotateOffset: number;
17
+ };
18
+ export type DisplayListOptions = {
19
+ theme: RenderTheme;
20
+ painters: PainterRegistry;
21
+ measure: TextMeasurer;
22
+ kernels: Pick<Kernels, "strokeBezier">;
23
+ overlay: OverlayOptions | false;
24
+ /** React Flow's handles, drawn on every node. */
25
+ anchors: boolean;
26
+ /** Styled nodes and token colours. */
27
+ style?: StyleEngine;
28
+ onUnknownColor?: (css: string) => void;
29
+ };
30
+ export type DisplayListStats = {
31
+ nodes: number;
32
+ visibleNodes: number;
33
+ relations: number;
34
+ visibleRelations: number;
35
+ commands: number;
36
+ cacheHits: number;
37
+ };
38
+ export { translated };
39
+ export declare class DisplayListBuilder {
40
+ private readonly engine;
41
+ private readonly index;
42
+ private options;
43
+ private nodeCache;
44
+ private relationCache;
45
+ private colors;
46
+ private styleVersion;
47
+ /** Per frame: who is hovered, selected, dragged, focused. */
48
+ private frameState;
49
+ constructor(engine: Engine, index: SceneIndex, options: DisplayListOptions);
50
+ /** Overlay settings change with the interaction's; they need no repaint of nodes. */
51
+ setOverlay(overlay: OverlayOptions | false): void;
52
+ setOptions(options: Partial<DisplayListOptions>): void;
53
+ /** A CSS colour, through the tokens when there are any. */
54
+ color: (css: string) => Rgba;
55
+ private stateOf;
56
+ private stateKey;
57
+ /** The node's commands, from the cache while nothing it depends on changed. */
58
+ private paintNode;
59
+ private relation;
60
+ build(view: Bounds, zoom: number): {
61
+ commands: RenderCommand[];
62
+ stats: DisplayListStats;
63
+ };
64
+ private overlay;
65
+ }
@@ -0,0 +1,316 @@
1
+ import { intersects } from "../geometry/bounds.js";
2
+ import { bezierControls } from "../geometry/curves.js";
3
+ import { translated } from "../geometry/matrix.js";
4
+ import { relationCurve } from "../interaction/hit-test.js";
5
+ import { parseColor, withAlpha } from "./color.js";
6
+ export { translated };
7
+ const translation = (x, y) => Float64Array.of(1, 0, 0, 1, x, y);
8
+ const scaleOf = (m) => Math.hypot(m[0], m[1]) || 1;
9
+ const OPPOSITE = { left: "right", right: "left", top: "bottom", bottom: "top" };
10
+ const NO_STATES = [];
11
+ export class DisplayListBuilder {
12
+ engine;
13
+ index;
14
+ options;
15
+ nodeCache = new Map();
16
+ relationCache = new Map();
17
+ colors = new Map();
18
+ styleVersion = "";
19
+ /** Per frame: who is hovered, selected, dragged, focused. */
20
+ frameState = { hovered: null, selected: new Set(), dragging: new Set(), focused: null, states: {} };
21
+ constructor(engine, index, options) {
22
+ this.engine = engine;
23
+ this.index = index;
24
+ this.options = options;
25
+ }
26
+ /** Overlay settings change with the interaction's; they need no repaint of nodes. */
27
+ setOverlay(overlay) {
28
+ this.options.overlay = overlay;
29
+ }
30
+ setOptions(options) {
31
+ this.options = { ...this.options, ...options };
32
+ this.nodeCache.clear();
33
+ this.colors.clear();
34
+ }
35
+ /** A CSS colour, through the tokens when there are any. */
36
+ color = (css) => {
37
+ let out = this.colors.get(css);
38
+ if (!out) {
39
+ const style = this.options.style;
40
+ out = (style && style.tokens.color(css, style.mode())) || parseColor(css, this.options.onUnknownColor);
41
+ this.colors.set(css, out);
42
+ }
43
+ return out;
44
+ };
45
+ stateOf(id) {
46
+ const f = this.frameState;
47
+ return {
48
+ hovered: f.hovered === id,
49
+ selected: f.selected.has(id),
50
+ dragging: f.dragging.has(id),
51
+ focused: f.focused === id,
52
+ states: f.states[id] ?? NO_STATES,
53
+ };
54
+ }
55
+ stateKey(state) {
56
+ return `${+state.hovered}${+state.selected}${+state.dragging}${+state.focused}|${state.states.join(",")}`;
57
+ }
58
+ /** The node's commands, from the cache while nothing it depends on changed. */
59
+ paintNode(node, stats) {
60
+ const size = this.engine.scene.sizeOf(node);
61
+ const cached = this.nodeCache.get(node.id);
62
+ const state = this.stateOf(node.id);
63
+ const stateKey = this.stateKey(state);
64
+ if (cached &&
65
+ cached.record === node.record &&
66
+ cached.world === node.world &&
67
+ cached.w === size.w &&
68
+ cached.h === size.h &&
69
+ cached.state === stateKey) {
70
+ stats.cacheHits++;
71
+ return cached;
72
+ }
73
+ const commands = [];
74
+ this.options.painters.get(node.record.type)(node, size, commands, {
75
+ theme: this.options.theme,
76
+ measure: this.options.measure,
77
+ color: this.color,
78
+ state,
79
+ style: this.options.style,
80
+ });
81
+ const first = commands.find((command) => command.kind === "rect");
82
+ if (this.options.anchors) {
83
+ const fill = this.color(this.options.theme.anchorFill);
84
+ const stroke = this.color(this.options.theme.anchorStroke);
85
+ for (const anchor of this.engine.schemas.anchors(node.record)) {
86
+ commands.push({
87
+ kind: "rect",
88
+ matrix: translated(node.world, anchor.x, anchor.y),
89
+ w: anchor.w,
90
+ h: anchor.h,
91
+ radius: Math.min(anchor.w, anchor.h) / 2,
92
+ fill,
93
+ stroke,
94
+ strokeWidth: 1,
95
+ nodeId: node.id,
96
+ });
97
+ }
98
+ }
99
+ const entry = {
100
+ record: node.record,
101
+ world: node.world,
102
+ w: size.w,
103
+ h: size.h,
104
+ state: stateKey,
105
+ commands,
106
+ radius: first?.kind === "rect" ? first.radius : 0,
107
+ };
108
+ this.nodeCache.set(node.id, entry);
109
+ return entry;
110
+ }
111
+ relation(id, zoom) {
112
+ const document = this.engine.store.get().document;
113
+ const record = document.relations[id];
114
+ const source = this.engine.scene.get(record.source.nodeId);
115
+ const target = this.engine.scene.get(record.target.nodeId);
116
+ if (!source || !target)
117
+ return null;
118
+ // Thin lines keep at least 1.2 screen px (in steps, so the cache holds).
119
+ const step = zoom < 1 ? Math.round(Math.log2(zoom) * 4) : 0;
120
+ const halfWidth = Math.max(0.5, 0.6 / 2 ** (step / 4));
121
+ const key = [
122
+ step,
123
+ source.world.join(),
124
+ target.world.join(),
125
+ JSON.stringify(this.engine.scene.sizeOf(source)),
126
+ JSON.stringify(this.engine.scene.sizeOf(target)),
127
+ ].join("|");
128
+ const cached = this.relationCache.get(id);
129
+ if (cached && cached.key === key)
130
+ return cached;
131
+ const curve = relationCurve(this.engine, id);
132
+ if (!curve)
133
+ return null;
134
+ const xs = [curve[0], curve[2], curve[4], curve[6]];
135
+ const ys = [curve[1], curve[3], curve[5], curve[7]];
136
+ const entry = {
137
+ key,
138
+ vertices: this.options.kernels.strokeBezier(curve, halfWidth, 32),
139
+ bounds: {
140
+ minX: Math.min(...xs) - halfWidth,
141
+ minY: Math.min(...ys) - halfWidth,
142
+ maxX: Math.max(...xs) + halfWidth,
143
+ maxY: Math.max(...ys) + halfWidth,
144
+ },
145
+ };
146
+ this.relationCache.set(id, entry);
147
+ return entry;
148
+ }
149
+ build(view, zoom) {
150
+ const { engine } = this;
151
+ const { document, interaction, a11y, style } = engine.store.get();
152
+ const theme = this.options.theme;
153
+ // A new mode or token set repaints everything (colours are resolved in it).
154
+ const version = this.options.style?.version() ?? "";
155
+ if (version !== this.styleVersion) {
156
+ this.styleVersion = version;
157
+ this.nodeCache.clear();
158
+ this.colors.clear();
159
+ }
160
+ this.frameState = {
161
+ hovered: interaction.hoveredId,
162
+ selected: new Set(interaction.selectedIds),
163
+ dragging: new Set(interaction.gesture === "drag" ? Object.keys(interaction.preview) : []),
164
+ focused: a11y.logicalFocusId,
165
+ states: style.nodeStates,
166
+ };
167
+ const relationIds = Object.keys(document.relations);
168
+ const stats = {
169
+ nodes: engine.scene.size,
170
+ visibleNodes: 0,
171
+ relations: relationIds.length,
172
+ visibleRelations: 0,
173
+ commands: 0,
174
+ cacheHits: 0,
175
+ };
176
+ const commands = [];
177
+ // Relations, under the nodes (React Flow's edges).
178
+ const selectedRelations = new Set(interaction.selectedRelationIds);
179
+ const relationColor = this.color(theme.relation);
180
+ const relationSelected = this.color(theme.relationSelected);
181
+ for (const id of relationIds) {
182
+ const entry = this.relation(id, zoom);
183
+ if (!entry || !intersects(entry.bounds, view))
184
+ continue;
185
+ stats.visibleRelations++;
186
+ commands.push({
187
+ kind: "mesh",
188
+ vertices: entry.vertices,
189
+ color: selectedRelations.has(id) ? relationSelected : relationColor,
190
+ relationId: id,
191
+ });
192
+ }
193
+ for (const id of this.relationCache.keys())
194
+ if (!document.relations[id])
195
+ this.relationCache.delete(id);
196
+ // Nodes, back to front; a hidden node hides its subtree.
197
+ const hidden = new Map();
198
+ const isHidden = (node) => {
199
+ let value = hidden.get(node.id);
200
+ if (value === undefined) {
201
+ value = !node.record.visible || (node.parent ? isHidden(node.parent) : false);
202
+ hidden.set(node.id, value);
203
+ }
204
+ return value;
205
+ };
206
+ const entries = new Map();
207
+ for (const node of this.index.query(view)) {
208
+ if (isHidden(node))
209
+ continue;
210
+ stats.visibleNodes++;
211
+ const entry = this.paintNode(node, stats);
212
+ entries.set(node.id, entry);
213
+ for (const command of entry.commands)
214
+ commands.push(command);
215
+ }
216
+ for (const id of this.nodeCache.keys())
217
+ if (!document.nodes[id])
218
+ this.nodeCache.delete(id);
219
+ if (this.options.overlay)
220
+ this.overlay(commands, zoom, entries, this.options.overlay);
221
+ stats.commands = commands.length;
222
+ return { commands, stats };
223
+ }
224
+ overlay(commands, zoom, entries, options) {
225
+ const { engine } = this;
226
+ const { interaction, document } = engine.store.get();
227
+ const accent = this.color(this.options.theme.accent);
228
+ const px = 1 / zoom;
229
+ const outline = (id, width) => {
230
+ const node = engine.scene.get(id);
231
+ if (!node)
232
+ return;
233
+ const size = engine.scene.sizeOf(node);
234
+ const scale = scaleOf(node.world);
235
+ commands.push({
236
+ kind: "rect",
237
+ matrix: node.world,
238
+ w: size.w,
239
+ h: size.h,
240
+ radius: entries.get(id)?.radius ?? this.nodeCache.get(id)?.radius ?? 0,
241
+ fill: null,
242
+ stroke: accent,
243
+ strokeWidth: (width * px) / scale,
244
+ });
245
+ };
246
+ const selected = new Set(interaction.selectedIds);
247
+ if (interaction.hoveredId && !selected.has(interaction.hoveredId) && !interaction.gesture) {
248
+ outline(interaction.hoveredId, 1);
249
+ }
250
+ for (const id of interaction.selectedIds)
251
+ outline(id, 2);
252
+ // Transform handles on a single selected node.
253
+ if (options.transformHandles && interaction.selectedIds.length === 1 && !interaction.marquee) {
254
+ const node = engine.scene.get(interaction.selectedIds[0]);
255
+ if (node && !document.nodes[node.id]?.locked) {
256
+ const size = engine.scene.sizeOf(node);
257
+ const scale = scaleOf(node.world);
258
+ const s = (options.handleSize * px) / scale;
259
+ const white = this.color(this.options.theme.anchorStroke);
260
+ const handle = (x, y, round) => commands.push({
261
+ kind: "rect",
262
+ matrix: translated(node.world, x - s / 2, y - s / 2),
263
+ w: s,
264
+ h: s,
265
+ radius: round ? s / 2 : (1 * px) / scale,
266
+ fill: white,
267
+ stroke: accent,
268
+ strokeWidth: px / scale,
269
+ });
270
+ for (const [x, y] of [
271
+ [0, 0],
272
+ [size.w, 0],
273
+ [size.w, size.h],
274
+ [0, size.h],
275
+ ]) {
276
+ handle(x, y, false);
277
+ }
278
+ handle(size.w / 2, -(options.rotateOffset * px) / scale, true);
279
+ }
280
+ }
281
+ // The marquee.
282
+ if (interaction.marquee) {
283
+ const box = interaction.marquee;
284
+ commands.push({
285
+ kind: "rect",
286
+ matrix: translation(box.minX, box.minY),
287
+ w: box.maxX - box.minX,
288
+ h: box.maxY - box.minY,
289
+ radius: 0,
290
+ fill: withAlpha(accent, 0.08),
291
+ stroke: accent,
292
+ strokeWidth: px,
293
+ });
294
+ }
295
+ // The connection being dragged.
296
+ const connection = interaction.connection;
297
+ if (connection) {
298
+ const side = connection.from.anchor.side;
299
+ const targetSide = connection.target?.anchor.side ?? OPPOSITE[side];
300
+ const curve = bezierControls({
301
+ sourceX: connection.from.point.x,
302
+ sourceY: connection.from.point.y,
303
+ sourceSide: side,
304
+ targetX: connection.to.x,
305
+ targetY: connection.to.y,
306
+ targetSide,
307
+ });
308
+ const refused = connection.target && !connection.target.valid;
309
+ commands.push({
310
+ kind: "mesh",
311
+ vertices: this.options.kernels.strokeBezier(curve, px, 32),
312
+ color: refused ? this.color(this.options.theme.invalid) : accent,
313
+ });
314
+ }
315
+ }
316
+ }
@@ -0,0 +1,35 @@
1
+ export type LoadedImage = {
2
+ source: CanvasImageSource;
3
+ width: number;
4
+ height: number;
5
+ };
6
+ export type ImageLoader = (src: string) => Promise<LoadedImage>;
7
+ export declare const defaultImageLoader: ImageLoader;
8
+ export declare class ImageStore {
9
+ private entries;
10
+ private readonly loader;
11
+ private readonly onChange;
12
+ /** Bumps whenever an image arrives (backends drop stale textures by it). */
13
+ version: number;
14
+ constructor(loader?: ImageLoader, onChange?: () => void);
15
+ /** The image when it is ready; starts loading it otherwise. */
16
+ get(src: string): LoadedImage | null;
17
+ state(src: string): "failed" | "loading" | "ready" | null;
18
+ /** Sets an image directly (tests, images already decoded). */
19
+ set(src: string, image: LoadedImage): void;
20
+ clear(): void;
21
+ }
22
+ /**
23
+ * Where an image goes in a w×h box (CSS object-fit): the source crop and
24
+ * the destination, both in their own units.
25
+ */
26
+ export declare function fitImage(fit: "cover" | "contain" | "fill", w: number, h: number, iw: number, ih: number): {
27
+ sx: number;
28
+ sy: number;
29
+ sw: number;
30
+ sh: number;
31
+ dx: number;
32
+ dy: number;
33
+ dw: number;
34
+ dh: number;
35
+ };
@@ -0,0 +1,83 @@
1
+ export const defaultImageLoader = async (src) => {
2
+ if (typeof createImageBitmap !== "undefined" && typeof fetch !== "undefined") {
3
+ const response = await fetch(src);
4
+ const bitmap = await createImageBitmap(await response.blob());
5
+ return { source: bitmap, width: bitmap.width, height: bitmap.height };
6
+ }
7
+ if (typeof Image === "undefined")
8
+ throw new Error("No image decoder here");
9
+ const image = new Image();
10
+ image.crossOrigin = "anonymous";
11
+ image.src = src;
12
+ await image.decode();
13
+ return { source: image, width: image.naturalWidth, height: image.naturalHeight };
14
+ };
15
+ export class ImageStore {
16
+ entries = new Map();
17
+ loader;
18
+ onChange;
19
+ /** Bumps whenever an image arrives (backends drop stale textures by it). */
20
+ version = 0;
21
+ constructor(loader = defaultImageLoader, onChange = () => { }) {
22
+ this.loader = loader;
23
+ this.onChange = onChange;
24
+ }
25
+ /** The image when it is ready; starts loading it otherwise. */
26
+ get(src) {
27
+ const entry = this.entries.get(src);
28
+ if (entry)
29
+ return entry.image ?? null;
30
+ this.entries.set(src, { state: "loading" });
31
+ this.loader(src).then((image) => {
32
+ if (!this.entries.has(src))
33
+ return;
34
+ this.entries.set(src, { state: "ready", image });
35
+ this.version++;
36
+ this.onChange();
37
+ }, () => {
38
+ if (this.entries.has(src))
39
+ this.entries.set(src, { state: "failed" });
40
+ });
41
+ return null;
42
+ }
43
+ state(src) {
44
+ return this.entries.get(src)?.state ?? null;
45
+ }
46
+ /** Sets an image directly (tests, images already decoded). */
47
+ set(src, image) {
48
+ this.entries.set(src, { state: "ready", image });
49
+ this.version++;
50
+ }
51
+ clear() {
52
+ for (const entry of this.entries.values()) {
53
+ const source = entry.image?.source;
54
+ source?.close?.();
55
+ }
56
+ this.entries.clear();
57
+ }
58
+ }
59
+ /**
60
+ * Where an image goes in a w×h box (CSS object-fit): the source crop and
61
+ * the destination, both in their own units.
62
+ */
63
+ export function fitImage(fit, w, h, iw, ih) {
64
+ if (fit === "fill" || !iw || !ih || !w || !h) {
65
+ return { sx: 0, sy: 0, sw: iw, sh: ih, dx: 0, dy: 0, dw: w, dh: h };
66
+ }
67
+ const box = w / h;
68
+ const image = iw / ih;
69
+ if (fit === "cover") {
70
+ if (image > box) {
71
+ const sw = ih * box;
72
+ return { sx: (iw - sw) / 2, sy: 0, sw, sh: ih, dx: 0, dy: 0, dw: w, dh: h };
73
+ }
74
+ const sh = iw / box;
75
+ return { sx: 0, sy: (ih - sh) / 2, sw: iw, sh, dx: 0, dy: 0, dw: w, dh: h };
76
+ }
77
+ if (image > box) {
78
+ const dh = w / image;
79
+ return { sx: 0, sy: 0, sw: iw, sh: ih, dx: 0, dy: (h - dh) / 2, dw: w, dh };
80
+ }
81
+ const dw = h * image;
82
+ return { sx: 0, sy: 0, sw: iw, sh: ih, dx: (w - dw) / 2, dy: 0, dw, dh: h };
83
+ }
@@ -0,0 +1,14 @@
1
+ export * from "./color.js";
2
+ export * from "./commands.js";
3
+ export * from "./theme.js";
4
+ export * from "./text.js";
5
+ export * from "./images.js";
6
+ export * from "./painters.js";
7
+ export * from "./scene-index.js";
8
+ export * from "./display-list.js";
9
+ export * from "./backend.js";
10
+ export * from "./renderer.js";
11
+ export * from "./ui.js";
12
+ export * from "./canvas2d/backend.js";
13
+ export * from "./webgl2/backend.js";
14
+ export { TextAtlas, scaleStep, ATLAS_SIZE } from "./webgl2/atlas.js";
@@ -0,0 +1,16 @@
1
+ // AVIS Engine · render — Phase 3: render commands, painters, culling,
2
+ // the WebGL2 backend and the Canvas2D fallback (docs/canvas-engine-plan.md).
3
+ export * from "./color.js";
4
+ export * from "./commands.js";
5
+ export * from "./theme.js";
6
+ export * from "./text.js";
7
+ export * from "./images.js";
8
+ export * from "./painters.js";
9
+ export * from "./scene-index.js";
10
+ export * from "./display-list.js";
11
+ export * from "./backend.js";
12
+ export * from "./renderer.js";
13
+ export * from "./ui.js";
14
+ export * from "./canvas2d/backend.js";
15
+ export * from "./webgl2/backend.js";
16
+ export { TextAtlas, scaleStep, ATLAS_SIZE } from "./webgl2/atlas.js";
@@ -0,0 +1,35 @@
1
+ import type { Disposable } from "../core/disposable.js";
2
+ import type { SceneNode } from "../scene/scene-graph.js";
3
+ import type { Size } from "../scene/record.js";
4
+ import type { Rgba } from "./color.js";
5
+ import type { FontSpec, RenderCommand } from "./commands.js";
6
+ import type { StyleEngine } from "../style/style-engine.js";
7
+ import { type NodeVisualState } from "./ui.js";
8
+ import { type TextMeasurer } from "./text.js";
9
+ import type { RenderTheme } from "./theme.js";
10
+ export type PaintContext = {
11
+ theme: RenderTheme;
12
+ measure: TextMeasurer;
13
+ /** A CSS colour as floats, tokens resolved (unknown ones are reported and drawn magenta). */
14
+ color(css: string): Rgba;
15
+ /** The node's state (hover, selected, dragging, focus, the app's states). */
16
+ state: NodeVisualState;
17
+ /** The styling engine, when there is one (styled nodes need it). */
18
+ style?: StyleEngine;
19
+ };
20
+ export type NodePainter = (node: SceneNode, size: Size, out: RenderCommand[], ctx: PaintContext) => void;
21
+ /** Lines of text inside a box, top-left, clamped to its height. */
22
+ export declare function paintText(node: SceneNode, out: RenderCommand[], ctx: PaintContext, text: string, box: {
23
+ x: number;
24
+ y: number;
25
+ w: number;
26
+ h: number;
27
+ }, font: FontSpec, color: Rgba, lineHeight?: number): void;
28
+ /** Unregistered types: a card with their title, label or name. */
29
+ export declare const fallbackPainter: NodePainter;
30
+ export declare const BUILTIN_PAINTERS: Record<string, NodePainter>;
31
+ export declare class PainterRegistry {
32
+ private painters;
33
+ register(type: string, painter: NodePainter): Disposable;
34
+ get(type: string): NodePainter;
35
+ }