@vibecook/ice 0.11.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/README.md +79 -50
  2. package/dist/chunk-BA7XJC27.js +2429 -0
  3. package/dist/chunk-BA7XJC27.js.map +1 -0
  4. package/dist/chunk-BKV4ZEU3.js +1 -0
  5. package/dist/chunk-BKV4ZEU3.js.map +1 -0
  6. package/dist/{chunk-VGVDJZSP.js → chunk-DYK6KNLG.js} +13206 -7387
  7. package/dist/chunk-DYK6KNLG.js.map +1 -0
  8. package/dist/chunk-ENIFIUEP.js +155 -0
  9. package/dist/chunk-ENIFIUEP.js.map +1 -0
  10. package/dist/chunk-IBWWLA6D.js +634 -0
  11. package/dist/chunk-IBWWLA6D.js.map +1 -0
  12. package/dist/{chunk-OR5FNVUE.js → chunk-JS6PG6YD.js} +398 -167
  13. package/dist/chunk-JS6PG6YD.js.map +1 -0
  14. package/dist/chunk-QXOCF56A.js +148 -0
  15. package/dist/chunk-QXOCF56A.js.map +1 -0
  16. package/dist/chunk-ZPUPBULB.js +7399 -0
  17. package/dist/chunk-ZPUPBULB.js.map +1 -0
  18. package/dist/desk-engine.js +36 -0
  19. package/dist/desk-engine.js.map +1 -0
  20. package/dist/desk-kit.js +244 -0
  21. package/dist/desk-kit.js.map +1 -0
  22. package/dist/desk-objects.js +12728 -0
  23. package/dist/desk-objects.js.map +1 -0
  24. package/dist/desk.js +469 -0
  25. package/dist/desk.js.map +1 -0
  26. package/dist/devtools.js +233 -189
  27. package/dist/devtools.js.map +1 -1
  28. package/dist/dom.js +7 -19
  29. package/dist/index.js +232 -20
  30. package/dist/kernel.js +53 -25
  31. package/dist/react.js +1045 -38
  32. package/dist/react.js.map +1 -1
  33. package/dist/types/packages/core/src/behavior/define-behavior.d.ts +11 -0
  34. package/dist/types/packages/core/src/behavior/runtime.d.ts +4 -0
  35. package/dist/types/packages/core/src/canvas/define-canvas-type.d.ts +86 -0
  36. package/dist/types/packages/core/src/canvas/define-container.d.ts +17 -0
  37. package/dist/types/packages/core/src/canvas/diagnostics.d.ts +27 -0
  38. package/dist/types/packages/core/src/canvas/engine-catalog.d.ts +70 -0
  39. package/dist/types/packages/core/src/canvas/extensions.d.ts +125 -0
  40. package/dist/types/packages/core/src/canvas/frame-behavior-host.d.ts +16 -0
  41. package/dist/types/packages/core/src/canvas/frame-preview.d.ts +79 -0
  42. package/dist/types/packages/core/src/canvas/frame-projection.d.ts +38 -0
  43. package/dist/types/packages/core/src/canvas/frame-view.d.ts +36 -0
  44. package/dist/types/packages/core/src/canvas/migrate.d.ts +14 -0
  45. package/dist/types/packages/core/src/canvas/placement.d.ts +30 -0
  46. package/dist/types/packages/core/src/canvas/presentation-transition.d.ts +100 -0
  47. package/dist/types/packages/core/src/canvas/runtime-extension-host.d.ts +16 -0
  48. package/dist/types/packages/core/src/canvas/session.d.ts +47 -0
  49. package/dist/types/packages/core/src/catalog/camera-derived.d.ts +16 -27
  50. package/dist/types/packages/core/src/catalog/desk.d.ts +326 -0
  51. package/dist/types/packages/core/src/catalog/gesture.d.ts +51 -0
  52. package/dist/types/packages/core/src/catalog/graph.d.ts +2 -2
  53. package/dist/types/packages/core/src/catalog/index.d.ts +2 -0
  54. package/dist/types/packages/core/src/catalog/pointer.d.ts +42 -0
  55. package/dist/types/packages/core/src/catalog/selection-presence.d.ts +7 -0
  56. package/dist/types/packages/core/src/catalog/settings-resources.d.ts +28 -2
  57. package/dist/types/packages/core/src/catalog/surface.d.ts +1 -0
  58. package/dist/types/packages/core/src/doc/doc-commit-sink.d.ts +18 -2
  59. package/dist/types/packages/core/src/doc/doc-kit.d.ts +21 -2
  60. package/dist/types/packages/core/src/doc/envelope.d.ts +5 -2
  61. package/dist/types/packages/core/src/doc/schema-migrate.d.ts +1 -1
  62. package/dist/types/packages/core/src/doc/version-gate.d.ts +21 -3
  63. package/dist/types/packages/core/src/engine/commit-sink.d.ts +10 -1
  64. package/dist/types/packages/core/src/engine/engine.d.ts +6 -0
  65. package/dist/types/packages/core/src/engine/frame-control.d.ts +74 -0
  66. package/dist/types/packages/core/src/engine/guests.d.ts +4 -1
  67. package/dist/types/packages/core/src/engine/world-doors.d.ts +12 -0
  68. package/dist/types/packages/core/src/facade/create-canvas-engine.d.ts +146 -13
  69. package/dist/types/packages/core/src/index.d.ts +33 -12
  70. package/dist/types/packages/core/src/input/queue.d.ts +3 -1
  71. package/dist/types/packages/core/src/interaction/install.d.ts +30 -0
  72. package/dist/types/packages/core/src/interaction/wakes.d.ts +24 -0
  73. package/dist/types/packages/core/src/nav/nav-geometry.d.ts +100 -0
  74. package/dist/types/packages/core/src/nav/nested-canvas.d.ts +47 -4
  75. package/dist/types/packages/core/src/ops/cascade.d.ts +2 -1
  76. package/dist/types/packages/core/src/ops/claims.d.ts +6 -0
  77. package/dist/types/packages/core/src/ops/insert.d.ts +4 -0
  78. package/dist/types/packages/core/src/ops/point-pick.d.ts +4 -1
  79. package/dist/types/packages/core/src/ops/sibling-order.d.ts +14 -4
  80. package/dist/types/packages/core/src/ops/tray.d.ts +48 -0
  81. package/dist/types/packages/core/src/presence/presence-kit.d.ts +5 -0
  82. package/dist/types/packages/core/src/schema/meta.d.ts +10 -0
  83. package/dist/types/packages/core/src/schema/prefab.d.ts +8 -0
  84. package/dist/types/packages/core/src/settings/defaults.d.ts +25 -6
  85. package/dist/types/packages/core/src/surface/gpu-device.d.ts +55 -0
  86. package/dist/types/packages/core/src/systems/camera-sim.d.ts +29 -0
  87. package/dist/types/packages/core/src/systems/chrome.d.ts +15 -23
  88. package/dist/types/packages/core/src/systems/drag-mods.d.ts +34 -0
  89. package/dist/types/packages/core/src/systems/held.d.ts +71 -0
  90. package/dist/types/packages/core/src/systems/insert-ghost.d.ts +2 -0
  91. package/dist/types/packages/core/src/systems/l0-input.d.ts +14 -0
  92. package/dist/types/packages/core/src/systems/l1-pick.d.ts +37 -1
  93. package/dist/types/packages/core/src/systems/l2-arbitrate.d.ts +18 -4
  94. package/dist/types/packages/core/src/systems/l3-behave.d.ts +4 -1
  95. package/dist/types/packages/core/src/systems/l3-claim.d.ts +7 -0
  96. package/dist/types/packages/core/src/systems/l3-connect.d.ts +1 -1
  97. package/dist/types/packages/core/src/systems/l3-drop.d.ts +30 -1
  98. package/dist/types/packages/core/src/systems/l3-marquee.d.ts +2 -1
  99. package/dist/types/packages/core/src/systems/l3-ports.d.ts +1 -1
  100. package/dist/types/packages/core/src/systems/l4-cursor.d.ts +5 -0
  101. package/dist/types/packages/core/src/systems/nav-flight.d.ts +85 -3
  102. package/dist/types/packages/core/src/systems/nav-tap.d.ts +44 -0
  103. package/dist/types/packages/core/src/systems/press-wheel.d.ts +11 -0
  104. package/dist/types/packages/core/src/systems/tray.d.ts +108 -0
  105. package/dist/types/packages/core/src/systems/zoom-through.d.ts +30 -0
  106. package/dist/types/packages/core/src/tools/define-tool.d.ts +10 -0
  107. package/dist/types/packages/core/src/widget/define-widget.d.ts +166 -63
  108. package/dist/types/packages/core/src/widget/equip.d.ts +14 -2
  109. package/dist/types/packages/core/src/widget/held-tools.d.ts +83 -0
  110. package/dist/types/packages/core/src/widget/menu-actions.d.ts +44 -0
  111. package/dist/types/packages/core/src/widget/mount-store.d.ts +21 -46
  112. package/dist/types/packages/core/src/widget/spawn.d.ts +1 -1
  113. package/dist/types/packages/desk/src/assets/blue-noise.gen.d.ts +10 -0
  114. package/dist/types/packages/desk/src/card/card.d.ts +103 -0
  115. package/dist/types/packages/desk/src/compose/ambient.d.ts +59 -0
  116. package/dist/types/packages/desk/src/compose/builder.d.ts +285 -0
  117. package/dist/types/packages/desk/src/compose/children.d.ts +3 -0
  118. package/dist/types/packages/desk/src/compose/index.d.ts +14 -0
  119. package/dist/types/packages/desk/src/compose/marks.d.ts +126 -0
  120. package/dist/types/packages/desk/src/compose/pick.d.ts +5 -0
  121. package/dist/types/packages/desk/src/compose/reflector.d.ts +111 -0
  122. package/dist/types/packages/desk/src/compose/tap.d.ts +5 -0
  123. package/dist/types/packages/desk/src/docs.d.ts +23 -0
  124. package/dist/types/packages/desk/src/engine/budget.d.ts +38 -0
  125. package/dist/types/packages/desk/src/engine/device.d.ts +54 -0
  126. package/dist/types/packages/desk/src/engine/index.d.ts +5 -0
  127. package/dist/types/packages/desk/src/engine/pipeline.d.ts +36 -0
  128. package/dist/types/packages/desk/src/engine/rasters.d.ts +66 -0
  129. package/dist/types/packages/desk/src/engine/records.d.ts +56 -0
  130. package/dist/types/packages/desk/src/engine/shader.d.ts +22 -0
  131. package/dist/types/packages/desk/src/engine/struct.d.ts +39 -0
  132. package/dist/types/packages/desk/src/engine/target.d.ts +26 -0
  133. package/dist/types/packages/desk/src/gpu-ablation.d.ts +61 -0
  134. package/dist/types/packages/desk/src/gpu-memory.d.ts +54 -0
  135. package/dist/types/packages/desk/src/gpu-profiler.d.ts +141 -0
  136. package/dist/types/packages/desk/src/gpu-wrap.d.ts +8 -0
  137. package/dist/types/packages/desk/src/ground.d.ts +388 -0
  138. package/dist/types/packages/desk/src/hold/focus.d.ts +53 -0
  139. package/dist/types/packages/desk/src/hold/pose.d.ts +132 -0
  140. package/dist/types/packages/desk/src/hold/shaders.d.ts +9 -0
  141. package/dist/types/packages/desk/src/host/editor.d.ts +18 -0
  142. package/dist/types/packages/desk/src/host/index.d.ts +9 -0
  143. package/dist/types/packages/desk/src/host/ink.d.ts +18 -0
  144. package/dist/types/packages/desk/src/host/layer.d.ts +430 -0
  145. package/dist/types/packages/desk/src/host/picture.d.ts +2 -0
  146. package/dist/types/packages/desk/src/host/surface.d.ts +5 -0
  147. package/dist/types/packages/desk/src/index.d.ts +13 -0
  148. package/dist/types/packages/desk/src/kind.d.ts +187 -0
  149. package/dist/types/packages/desk/src/kinds/world.d.ts +429 -0
  150. package/dist/types/packages/desk/src/kit/arrays.d.ts +88 -0
  151. package/dist/types/packages/desk/src/kit/blobs.d.ts +40 -0
  152. package/dist/types/packages/desk/src/kit/book.d.ts +2 -0
  153. package/dist/types/packages/desk/src/kit/editor.d.ts +103 -0
  154. package/dist/types/packages/desk/src/kit/eye.d.ts +37 -0
  155. package/dist/types/packages/desk/src/kit/hold.d.ts +1 -0
  156. package/dist/types/packages/desk/src/kit/index.d.ts +26 -0
  157. package/dist/types/packages/desk/src/kit/inside.d.ts +116 -0
  158. package/dist/types/packages/desk/src/kit/layer.d.ts +159 -0
  159. package/dist/types/packages/desk/src/kit/light.d.ts +3 -0
  160. package/dist/types/packages/desk/src/kit/mesh.d.ts +29 -0
  161. package/dist/types/packages/desk/src/kit/mips.d.ts +2 -0
  162. package/dist/types/packages/desk/src/kit/nav.d.ts +2 -0
  163. package/dist/types/packages/desk/src/kit/paper-tex.d.ts +5 -0
  164. package/dist/types/packages/desk/src/kit/physics.d.ts +44 -0
  165. package/dist/types/packages/desk/src/kit/place.d.ts +44 -0
  166. package/dist/types/packages/desk/src/kit/print.d.ts +30 -0
  167. package/dist/types/packages/desk/src/kit/raster.d.ts +34 -0
  168. package/dist/types/packages/desk/src/kit/sdf.d.ts +1 -0
  169. package/dist/types/packages/desk/src/kit/seeds.d.ts +11 -0
  170. package/dist/types/packages/desk/src/kit/services.d.ts +34 -0
  171. package/dist/types/packages/desk/src/kit/springs.d.ts +12 -0
  172. package/dist/types/packages/desk/src/kit/strokes.d.ts +93 -0
  173. package/dist/types/packages/desk/src/kit/text.d.ts +142 -0
  174. package/dist/types/packages/desk/src/kit/uniform.d.ts +8 -0
  175. package/dist/types/packages/desk/src/kit/view.d.ts +39 -0
  176. package/dist/types/packages/desk/src/kit/wgsl.d.ts +15 -0
  177. package/dist/types/packages/desk/src/lattice/line.d.ts +15 -0
  178. package/dist/types/packages/desk/src/lattice/lod.d.ts +52 -0
  179. package/dist/types/packages/desk/src/lattice/ruler.d.ts +88 -0
  180. package/dist/types/packages/desk/src/marks/assemble.d.ts +65 -0
  181. package/dist/types/packages/desk/src/marks/ease.d.ts +4 -0
  182. package/dist/types/packages/desk/src/marks/laser.d.ts +41 -0
  183. package/dist/types/packages/desk/src/marks/layout.d.ts +167 -0
  184. package/dist/types/packages/desk/src/marks/pass.d.ts +59 -0
  185. package/dist/types/packages/desk/src/marks/shaders.d.ts +12 -0
  186. package/dist/types/packages/desk/src/mat/grid.d.ts +50 -0
  187. package/dist/types/packages/desk/src/mat/lamp.d.ts +14 -0
  188. package/dist/types/packages/desk/src/mat/layout.d.ts +144 -0
  189. package/dist/types/packages/desk/src/mat/mat-pass.d.ts +83 -0
  190. package/dist/types/packages/desk/src/mat/night.d.ts +95 -0
  191. package/dist/types/packages/desk/src/mat/projector.d.ts +39 -0
  192. package/dist/types/packages/desk/src/mat/shaders.d.ts +17 -0
  193. package/dist/types/packages/desk/src/mat/tilt.d.ts +14 -0
  194. package/dist/types/packages/desk/src/nav/flight.d.ts +186 -0
  195. package/dist/types/packages/desk/src/nav/portal.d.ts +95 -0
  196. package/dist/types/packages/desk/src/object.d.ts +46 -0
  197. package/dist/types/packages/desk/src/pass-instrument.d.ts +89 -0
  198. package/dist/types/packages/desk/src/shaders.d.ts +12 -0
  199. package/dist/types/packages/desk/src/shaders.gen.d.ts +16 -0
  200. package/dist/types/packages/desk/src/submit-instrument.d.ts +36 -0
  201. package/dist/types/packages/desk/src/theme.d.ts +475 -0
  202. package/dist/types/packages/desk/src/tray/carry.d.ts +99 -0
  203. package/dist/types/packages/desk/src/tray/drawer.d.ts +113 -0
  204. package/dist/types/packages/desk/src/tray/flux.d.ts +46 -0
  205. package/dist/types/packages/desk/src/tray/index.d.ts +4 -0
  206. package/dist/types/packages/desk/src/tray/lattice.d.ts +71 -0
  207. package/dist/types/packages/desk/src/tray/layout.d.ts +7 -0
  208. package/dist/types/packages/desk/src/tray/look.d.ts +29 -0
  209. package/dist/types/packages/desk/src/tray/pass.d.ts +96 -0
  210. package/dist/types/packages/desk/src/tray/shaders.d.ts +10 -0
  211. package/dist/types/packages/desk/src/tray/specimens.d.ts +199 -0
  212. package/dist/types/packages/devtools/src/attach.d.ts +22 -8
  213. package/dist/types/packages/devtools/src/dock.d.ts +18 -14
  214. package/dist/types/packages/devtools/src/gpu-panel.d.ts +105 -0
  215. package/dist/types/packages/devtools/src/index.d.ts +5 -4
  216. package/dist/types/packages/dom/src/desk-host.d.ts +91 -0
  217. package/dist/types/packages/dom/src/host.d.ts +13 -14
  218. package/dist/types/packages/dom/src/index.d.ts +12 -10
  219. package/dist/types/packages/dom/src/loop.d.ts +18 -1
  220. package/dist/types/packages/dom/src/pointer-adapter.d.ts +5 -29
  221. package/dist/types/packages/dom/src/widget-focus.d.ts +17 -13
  222. package/dist/types/packages/ice/src/desk-engine.d.ts +2 -0
  223. package/dist/types/packages/ice/src/desk-kit.d.ts +6 -0
  224. package/dist/types/packages/ice/src/desk-objects.d.ts +5 -0
  225. package/dist/types/packages/ice/src/desk.d.ts +5 -0
  226. package/dist/types/packages/kernel/src/atlas-pack.d.ts +157 -0
  227. package/dist/types/packages/kernel/src/bezier.d.ts +0 -15
  228. package/dist/types/packages/kernel/src/coords.d.ts +0 -39
  229. package/dist/types/packages/kernel/src/index.d.ts +2 -2
  230. package/dist/types/packages/kernel/src/nav-flight.d.ts +6 -0
  231. package/dist/types/packages/kernel/src/tray.d.ts +155 -0
  232. package/dist/types/packages/objects/src/board/board-pass.d.ts +180 -0
  233. package/dist/types/packages/objects/src/board/board-pen.d.ts +36 -0
  234. package/dist/types/packages/objects/src/board/board.d.ts +104 -0
  235. package/dist/types/packages/objects/src/board/data.d.ts +31 -0
  236. package/dist/types/packages/objects/src/board/history.d.ts +33 -0
  237. package/dist/types/packages/objects/src/board/kind.d.ts +208 -0
  238. package/dist/types/packages/objects/src/board/layout.d.ts +102 -0
  239. package/dist/types/packages/objects/src/board/object.d.ts +7 -0
  240. package/dist/types/packages/objects/src/board/pen.d.ts +71 -0
  241. package/dist/types/packages/objects/src/board/shaders.d.ts +36 -0
  242. package/dist/types/packages/objects/src/board/stroke.d.ts +99 -0
  243. package/dist/types/packages/objects/src/board/theme.d.ts +150 -0
  244. package/dist/types/packages/objects/src/calendar/data.d.ts +97 -0
  245. package/dist/types/packages/objects/src/calendar/events.d.ts +58 -0
  246. package/dist/types/packages/objects/src/calendar/hand.d.ts +53 -0
  247. package/dist/types/packages/objects/src/calendar/host/input.d.ts +67 -0
  248. package/dist/types/packages/objects/src/calendar/host/print.d.ts +9 -0
  249. package/dist/types/packages/objects/src/calendar/kind.d.ts +297 -0
  250. package/dist/types/packages/objects/src/calendar/law.d.ts +151 -0
  251. package/dist/types/packages/objects/src/calendar/layout.d.ts +47 -0
  252. package/dist/types/packages/objects/src/calendar/month.d.ts +75 -0
  253. package/dist/types/packages/objects/src/calendar/object.d.ts +45 -0
  254. package/dist/types/packages/objects/src/calendar/pad.d.ts +42 -0
  255. package/dist/types/packages/objects/src/calendar/pass.d.ts +229 -0
  256. package/dist/types/packages/objects/src/calendar/print.d.ts +87 -0
  257. package/dist/types/packages/objects/src/calendar/printing.d.ts +80 -0
  258. package/dist/types/packages/objects/src/calendar/roll.d.ts +45 -0
  259. package/dist/types/packages/objects/src/calendar/shaders.d.ts +12 -0
  260. package/dist/types/packages/objects/src/calendar/sheet.d.ts +43 -0
  261. package/dist/types/packages/objects/src/calendar/tiles.d.ts +67 -0
  262. package/dist/types/packages/objects/src/calendar/turn.d.ts +73 -0
  263. package/dist/types/packages/objects/src/calendar/writing.d.ts +42 -0
  264. package/dist/types/packages/objects/src/index.d.ts +22 -0
  265. package/dist/types/packages/objects/src/kinds.d.ts +24 -0
  266. package/dist/types/packages/objects/src/minimat/inside.d.ts +17 -0
  267. package/dist/types/packages/objects/src/minimat/kind.d.ts +51 -0
  268. package/dist/types/packages/objects/src/minimat/layout.d.ts +83 -0
  269. package/dist/types/packages/objects/src/minimat/minimat.d.ts +179 -0
  270. package/dist/types/packages/objects/src/minimat/object.d.ts +8 -0
  271. package/dist/types/packages/objects/src/minimat/pass.d.ts +61 -0
  272. package/dist/types/packages/objects/src/minimat/shaders.d.ts +10 -0
  273. package/dist/types/packages/objects/src/minimat/theme.d.ts +98 -0
  274. package/dist/types/packages/objects/src/notebook/ink.d.ts +70 -0
  275. package/dist/types/packages/objects/src/notebook/kind.d.ts +236 -0
  276. package/dist/types/packages/objects/src/notebook/law.d.ts +129 -0
  277. package/dist/types/packages/objects/src/notebook/layout.d.ts +46 -0
  278. package/dist/types/packages/objects/src/notebook/leaf.d.ts +44 -0
  279. package/dist/types/packages/objects/src/notebook/mesh.d.ts +20 -0
  280. package/dist/types/packages/objects/src/notebook/motion.d.ts +107 -0
  281. package/dist/types/packages/objects/src/notebook/object.d.ts +8 -0
  282. package/dist/types/packages/objects/src/notebook/pages.d.ts +56 -0
  283. package/dist/types/packages/objects/src/notebook/pass.d.ts +197 -0
  284. package/dist/types/packages/objects/src/notebook/pick.d.ts +30 -0
  285. package/dist/types/packages/objects/src/notebook/raster.d.ts +28 -0
  286. package/dist/types/packages/objects/src/notebook/shaders.d.ts +11 -0
  287. package/dist/types/packages/objects/src/notebook/shape.d.ts +155 -0
  288. package/dist/types/packages/objects/src/notebook/theme.d.ts +76 -0
  289. package/dist/types/packages/objects/src/palette.d.ts +577 -0
  290. package/dist/types/packages/objects/src/paper/host/body.d.ts +30 -0
  291. package/dist/types/packages/objects/src/paper/kind.d.ts +81 -0
  292. package/dist/types/packages/objects/src/paper/layout.d.ts +73 -0
  293. package/dist/types/packages/objects/src/paper/object.d.ts +31 -0
  294. package/dist/types/packages/objects/src/paper/pages.d.ts +43 -0
  295. package/dist/types/packages/objects/src/paper/paper-pass.d.ts +86 -0
  296. package/dist/types/packages/objects/src/paper/paper.d.ts +117 -0
  297. package/dist/types/packages/objects/src/paper/shaders.d.ts +18 -0
  298. package/dist/types/packages/objects/src/paper/theme.d.ts +58 -0
  299. package/dist/types/packages/objects/src/paper/typing.d.ts +51 -0
  300. package/dist/types/packages/objects/src/paper/writing.d.ts +161 -0
  301. package/dist/types/packages/objects/src/photo/carry.d.ts +33 -0
  302. package/dist/types/packages/objects/src/photo/kind.d.ts +136 -0
  303. package/dist/types/packages/objects/src/photo/layout.d.ts +39 -0
  304. package/dist/types/packages/objects/src/photo/object.d.ts +5 -0
  305. package/dist/types/packages/objects/src/photo/photo-pass.d.ts +104 -0
  306. package/dist/types/packages/objects/src/photo/photo.d.ts +262 -0
  307. package/dist/types/packages/objects/src/photo/pictures.d.ts +152 -0
  308. package/dist/types/packages/objects/src/photo/sample.d.ts +9 -0
  309. package/dist/types/packages/objects/src/photo/shaders.d.ts +18 -0
  310. package/dist/types/packages/objects/src/preset.d.ts +44 -0
  311. package/dist/types/packages/objects/src/shaders.d.ts +3 -0
  312. package/dist/types/packages/objects/src/shaders.gen.d.ts +21 -0
  313. package/dist/types/packages/react/src/canvas-hooks.d.ts +12 -0
  314. package/dist/types/packages/react/src/desk.d.ts +56 -0
  315. package/dist/types/packages/react/src/engine-context.d.ts +2 -2
  316. package/dist/types/packages/react/src/frame-preview-boundary.d.ts +19 -0
  317. package/dist/types/packages/react/src/hooks.d.ts +9 -14
  318. package/dist/types/packages/react/src/index.d.ts +16 -9
  319. package/dist/types/packages/react/src/keymap.d.ts +21 -2
  320. package/dist/types/packages/react/src/selection-menu.d.ts +171 -0
  321. package/dist/types/packages/react/src/tray-bar.d.ts +124 -0
  322. package/package.json +64 -31
  323. package/dist/chunk-2TNVB2ON.js +0 -1163
  324. package/dist/chunk-2TNVB2ON.js.map +0 -1
  325. package/dist/chunk-OR5FNVUE.js.map +0 -1
  326. package/dist/chunk-Q665T4L7.js +0 -681
  327. package/dist/chunk-Q665T4L7.js.map +0 -1
  328. package/dist/chunk-VGVDJZSP.js.map +0 -1
  329. package/dist/ground.js +0 -1108
  330. package/dist/ground.js.map +0 -1
  331. package/dist/r3f.js +0 -1644
  332. package/dist/r3f.js.map +0 -1
  333. package/dist/types/packages/core/src/input/measure-queue.d.ts +0 -30
  334. package/dist/types/packages/core/src/settings/ground-config.d.ts +0 -101
  335. package/dist/types/packages/core/src/systems/measure-ingest.d.ts +0 -26
  336. package/dist/types/packages/devtools/src/gl-panel.d.ts +0 -69
  337. package/dist/types/packages/dom/src/measure-adapter.d.ts +0 -31
  338. package/dist/types/packages/dom/src/measure-wiring.d.ts +0 -49
  339. package/dist/types/packages/dom/src/planes.d.ts +0 -33
  340. package/dist/types/packages/dom/src/reflectors/chrome.d.ts +0 -33
  341. package/dist/types/packages/dom/src/reflectors/dom-widgets.d.ts +0 -59
  342. package/dist/types/packages/dom/src/reflectors/graybox.d.ts +0 -31
  343. package/dist/types/packages/dom/src/reflectors/plane-transform.d.ts +0 -38
  344. package/dist/types/packages/ground/src/index.d.ts +0 -69
  345. package/dist/types/packages/ground/src/layer.d.ts +0 -40
  346. package/dist/types/packages/ground/src/pass.d.ts +0 -41
  347. package/dist/types/packages/ground/src/passes/grid-contract.d.ts +0 -28
  348. package/dist/types/packages/ground/src/passes/grid-magnet-pass.d.ts +0 -2
  349. package/dist/types/packages/ground/src/passes/grid-magnet.d.ts +0 -31
  350. package/dist/types/packages/ground/src/passes/grid.d.ts +0 -10
  351. package/dist/types/packages/ground/src/passes/guides-collect.d.ts +0 -14
  352. package/dist/types/packages/ground/src/passes/guides.d.ts +0 -3
  353. package/dist/types/packages/ground/src/passes/magnet-collect.d.ts +0 -63
  354. package/dist/types/packages/ground/src/passes/soup-collect.d.ts +0 -35
  355. package/dist/types/packages/ground/src/passes/soup-mesh.d.ts +0 -8
  356. package/dist/types/packages/ground/src/passes/wires-collect.d.ts +0 -35
  357. package/dist/types/packages/ground/src/passes/wires.d.ts +0 -10
  358. package/dist/types/packages/ground/src/poles.d.ts +0 -47
  359. package/dist/types/packages/ground/src/renderer.d.ts +0 -15
  360. package/dist/types/packages/ice/src/ground.d.ts +0 -1
  361. package/dist/types/packages/ice/src/r3f.d.ts +0 -1
  362. package/dist/types/packages/kernel/src/eviction.d.ts +0 -23
  363. package/dist/types/packages/kernel/src/zoom-bands.d.ts +0 -19
  364. package/dist/types/packages/r3f/src/bridge.d.ts +0 -129
  365. package/dist/types/packages/r3f/src/composite-material.d.ts +0 -26
  366. package/dist/types/packages/r3f/src/compositor-pass.d.ts +0 -105
  367. package/dist/types/packages/r3f/src/dev-write-trap.d.ts +0 -30
  368. package/dist/types/packages/r3f/src/gl-root.d.ts +0 -96
  369. package/dist/types/packages/r3f/src/gl-router.d.ts +0 -70
  370. package/dist/types/packages/r3f/src/index.d.ts +0 -17
  371. package/dist/types/packages/r3f/src/island-state.d.ts +0 -112
  372. package/dist/types/packages/r3f/src/island.d.ts +0 -13
  373. package/dist/types/packages/r3f/src/pool.d.ts +0 -56
  374. package/dist/types/packages/r3f/src/preview-capture.d.ts +0 -19
  375. package/dist/types/packages/r3f/src/resource-registry.d.ts +0 -30
  376. package/dist/types/packages/r3f/src/self-sustain.d.ts +0 -39
  377. package/dist/types/packages/r3f/src/use-island-frame.d.ts +0 -39
  378. package/dist/types/packages/react/src/infinite-canvas.d.ts +0 -140
  379. package/dist/types/packages/react/src/preview-snapshots.d.ts +0 -17
  380. package/dist/types/packages/react/src/widget-preview.d.ts +0 -14
  381. package/dist/types/packages/react/src/widget-root.d.ts +0 -33
package/dist/r3f.js DELETED
@@ -1,1644 +0,0 @@
1
- import {
2
- EngineProvider,
3
- hasPreviewSnapshot,
4
- setPreviewSnapshot
5
- } from "./chunk-Q665T4L7.js";
6
- import "./chunk-2TNVB2ON.js";
7
- import {
8
- Active,
9
- Camera,
10
- Culled,
11
- GESTURE_DEFAULTS,
12
- GestureSettings,
13
- Grab,
14
- Opacity,
15
- Position,
16
- PrefabId,
17
- RUNTIME_BUDGETS,
18
- Size,
19
- StackZ,
20
- StageMode,
21
- Viewport,
22
- Visible,
23
- createCanvasEngine,
24
- createSiblingOrderIndex,
25
- defineQuery,
26
- navFlightActive,
27
- pickTopAt,
28
- widgets
29
- } from "./chunk-VGVDJZSP.js";
30
- import {
31
- compositeCameraFrustum,
32
- computeIslandPhase,
33
- cubicBezierEase,
34
- fboPixelSize,
35
- isOutOfBand,
36
- screenToWorld,
37
- selectBand,
38
- selectEvictions,
39
- worldRectToComposite,
40
- worldToIsland
41
- } from "./chunk-OR5FNVUE.js";
42
-
43
- // ../r3f/src/island-state.ts
44
- var LIFT_DEFAULT_MS = 180;
45
- var FRESH_PAINTED_AT = { w: 0, h: 0, dpr: 1, band: 0 };
46
- function createIslandStateStore() {
47
- const entries = /* @__PURE__ */ new Map();
48
- let paintSeq = 0;
49
- const ensure = (key) => {
50
- let s = entries.get(key);
51
- if (s === void 0) {
52
- s = {
53
- phase: "Cold",
54
- paintGeneration: 0,
55
- fboGeneration: -1,
56
- paintedAt: FRESH_PAINTED_AT,
57
- animRefs: 0,
58
- animatedDecl: false,
59
- lastPaintSeq: 0,
60
- pendingDtMs: 0,
61
- compositeScale: 1,
62
- liftTarget: 1,
63
- liftFrom: 1,
64
- liftElapsedMs: 0,
65
- liftMs: 0,
66
- compositeOpacity: 1,
67
- opacityTarget: 1,
68
- opacityFrom: 1,
69
- opacityElapsedMs: 0,
70
- opacityMs: 0
71
- };
72
- entries.set(key, s);
73
- }
74
- return s;
75
- };
76
- return {
77
- ensure,
78
- get: (key) => entries.get(key),
79
- all: () => entries.entries(),
80
- bumpPaint(key) {
81
- ensure(key).paintGeneration += 1;
82
- },
83
- markPainted(key, at) {
84
- const s = ensure(key);
85
- s.fboGeneration = s.paintGeneration;
86
- s.paintedAt = at;
87
- s.lastPaintSeq = ++paintSeq;
88
- },
89
- markEvicted(key) {
90
- const s = entries.get(key);
91
- if (s !== void 0) s.fboGeneration = -1;
92
- },
93
- addAnimRef(key) {
94
- ensure(key).animRefs += 1;
95
- },
96
- removeAnimRef(key) {
97
- const s = entries.get(key);
98
- if (s !== void 0 && s.animRefs > 0) s.animRefs -= 1;
99
- },
100
- isAnimating(key) {
101
- const s = entries.get(key);
102
- return s !== void 0 && (s.animatedDecl || s.animRefs > 0);
103
- },
104
- setAnimatedDecl(key, animated) {
105
- ensure(key).animatedDecl = animated;
106
- },
107
- drop(key) {
108
- entries.delete(key);
109
- },
110
- clear() {
111
- entries.clear();
112
- }
113
- };
114
- }
115
-
116
- // ../r3f/src/dev-write-trap.ts
117
- function createRenderWriteTrap(world, enabled) {
118
- let armed = false;
119
- let unregister = null;
120
- if (enabled) {
121
- unregister = world.devOnWrite((kind) => {
122
- if (!armed) return;
123
- throw new Error(
124
- `ice: world mutation (${kind}) during the GL render pass \u2014 the render path never writes ECS (design-004 \xA73). Move the write to a system, an input fact, or an app op OUTSIDE useIslandFrame/render.`
125
- );
126
- });
127
- }
128
- return {
129
- enabled,
130
- begin() {
131
- if (!enabled) return;
132
- if (armed) throw new Error("ice: render write trap begin() while already armed.");
133
- armed = true;
134
- },
135
- end() {
136
- armed = false;
137
- },
138
- dispose() {
139
- armed = false;
140
- unregister?.();
141
- unregister = null;
142
- }
143
- };
144
- }
145
-
146
- // ../r3f/src/bridge.ts
147
- function createGLBridge(engine, opts = {}) {
148
- const world = engine.world;
149
- const state = createIslandStateStore();
150
- const islands = /* @__PURE__ */ new Map();
151
- const frameCbs = /* @__PURE__ */ new Map();
152
- const renderAssert = createRenderWriteTrap(world, opts.devAssertRenderWrites === true);
153
- const now = opts.now ?? (() => performance.now());
154
- let renderNow = null;
155
- let wantsFrame = false;
156
- let animDueAt = null;
157
- let rendering = false;
158
- const requestFrame = () => {
159
- wantsFrame = true;
160
- };
161
- const removeReflector = engine.registerReflector({
162
- name: "r3fInvalidator",
163
- // StageMode: a background-hold flip must re-fire the pass — freezing on
164
- // take, and (critically) REPAINTING Hot islands on release. The observe
165
- // list also keeps strata enforcement armed (a rig must observe — the
166
- // always-flush advance reflector below deliberately observes nothing).
167
- observe: { resources: [Camera, Viewport, StageMode] },
168
- flush: () => requestFrame()
169
- });
170
- const removeAdvanceReflector = engine.registerReflector({
171
- name: "r3fAdvance",
172
- always: true,
173
- flush: () => {
174
- if (rendering) return;
175
- const t = now();
176
- if (!wantsFrame && (animDueAt === null || t < animDueAt)) return;
177
- if (renderNow === null) return;
178
- wantsFrame = false;
179
- animDueAt = null;
180
- rendering = true;
181
- try {
182
- renderNow(t);
183
- } finally {
184
- rendering = false;
185
- }
186
- }
187
- });
188
- const order = createSiblingOrderIndex(world);
189
- const removeOrderObserver = order.observe(() => {
190
- if (order.stale()) requestFrame();
191
- });
192
- const removeWorldObserver = world.observe({
193
- onDestroy: (e) => {
194
- if (state.get(e) !== void 0) {
195
- state.drop(e);
196
- frameCbs.delete(e);
197
- requestFrame();
198
- }
199
- },
200
- onReset: () => {
201
- state.clear();
202
- frameCbs.clear();
203
- requestFrame();
204
- }
205
- });
206
- return {
207
- engine,
208
- state,
209
- renderAssert,
210
- order,
211
- registerIsland(entity, handle) {
212
- islands.set(entity, handle);
213
- const s = state.ensure(entity);
214
- const type = world.get(entity, PrefabId)?.id;
215
- const widget = typeof type === "string" ? widgets.get(type) : void 0;
216
- state.setAnimatedDecl(entity, widget?.animated === true);
217
- const unsubs = [
218
- // island dirt — content resolution/props changed, FBO stale:
219
- world.reactive.observeValue(entity, Size, () => {
220
- state.bumpPaint(entity);
221
- requestFrame();
222
- }),
223
- // composite dirt — quad transform changed, texture still good (order
224
- // dirt is bridge-scoped: the ChildOf reorder wake above):
225
- world.reactive.observeValue(entity, Position, () => requestFrame()),
226
- // composite dirt — the durable Opacity cell rides the quad's uOpacity,
227
- // never the island's FBO (a fade must not repaint the content):
228
- world.reactive.observeValue(entity, Opacity, () => requestFrame())
229
- ];
230
- for (const group of widget?.groups ?? []) {
231
- unsubs.push(
232
- world.reactive.observeValue(entity, group.component, () => {
233
- state.bumpPaint(entity);
234
- requestFrame();
235
- })
236
- );
237
- }
238
- if (s.fboGeneration < 0) state.bumpPaint(entity);
239
- requestFrame();
240
- return () => {
241
- for (const u of unsubs) u();
242
- islands.delete(entity);
243
- requestFrame();
244
- };
245
- },
246
- islandFor: (entity) => islands.get(entity),
247
- islands: () => islands.entries(),
248
- addFrameCallback(entity, cb) {
249
- let set = frameCbs.get(entity);
250
- if (set === void 0) {
251
- set = /* @__PURE__ */ new Set();
252
- frameCbs.set(entity, set);
253
- }
254
- set.add(cb);
255
- state.addAnimRef(entity);
256
- requestFrame();
257
- return () => {
258
- set.delete(cb);
259
- state.removeAnimRef(entity);
260
- };
261
- },
262
- frameCallbacksFor(entity) {
263
- const set = frameCbs.get(entity);
264
- return set === void 0 ? [] : [...set];
265
- },
266
- requestFrame,
267
- bumpPaint(entity) {
268
- state.bumpPaint(entity);
269
- requestFrame();
270
- },
271
- setCompositeScale(entity, scale, durationMs = LIFT_DEFAULT_MS) {
272
- const s = state.ensure(entity);
273
- if (s.liftTarget === scale) return;
274
- s.liftTarget = scale;
275
- if (durationMs <= 0) {
276
- s.compositeScale = scale;
277
- s.liftMs = 0;
278
- s.liftElapsedMs = 0;
279
- } else {
280
- s.liftFrom = s.compositeScale;
281
- s.liftMs = durationMs;
282
- s.liftElapsedMs = 0;
283
- }
284
- requestFrame();
285
- },
286
- setCompositeOpacity(entity, opacity, durationMs = LIFT_DEFAULT_MS) {
287
- const s = state.ensure(entity);
288
- if (s.opacityTarget === opacity) return;
289
- s.opacityTarget = opacity;
290
- if (durationMs <= 0) {
291
- s.compositeOpacity = opacity;
292
- s.opacityMs = 0;
293
- s.opacityElapsedMs = 0;
294
- } else {
295
- s.opacityFrom = s.compositeOpacity;
296
- s.opacityMs = durationMs;
297
- s.opacityElapsedMs = 0;
298
- }
299
- requestFrame();
300
- },
301
- setRenderNow(fn) {
302
- renderNow = fn;
303
- },
304
- schedulePass(plan) {
305
- if (plan === "now") {
306
- wantsFrame = true;
307
- animDueAt = null;
308
- } else if (plan === "none") {
309
- animDueAt = null;
310
- } else {
311
- animDueAt = now() + plan;
312
- }
313
- },
314
- uninstall() {
315
- removeReflector();
316
- removeAdvanceReflector();
317
- removeOrderObserver();
318
- removeWorldObserver();
319
- renderAssert.dispose();
320
- islands.clear();
321
- frameCbs.clear();
322
- state.clear();
323
- renderNow = null;
324
- wantsFrame = false;
325
- animDueAt = null;
326
- }
327
- };
328
- }
329
-
330
- // ../r3f/src/compositor-pass.ts
331
- var GRABBED_RENDER_ORDER = 1e9;
332
- var LIFT_EASE = cubicBezierEase(0.2, 0.9, 0.3, 1.2);
333
- var OPACITY_EASE = cubicBezierEase(0.25, 0.1, 0.25, 1);
334
- function runCompositorPass(ctx) {
335
- const { world, bridge, pool, quads, gl } = ctx;
336
- const stats = {
337
- repainted: 0,
338
- pendingPaints: 0,
339
- evicted: 0,
340
- fboBytes: 0,
341
- anyHot: false,
342
- liftAnimating: false
343
- };
344
- const cam = world.getResource(Camera);
345
- const vp = world.getResource(Viewport);
346
- if (cam === void 0 || vp === void 0 || vp.w === 0) return stats;
347
- const inFlight2 = navFlightActive(world);
348
- const inMotion = cam.gesturing || inFlight2;
349
- const backgrounded = (world.getResource(StageMode)?.backgroundHolds ?? 0) > 0;
350
- const frozen = inFlight2 || backgrounded;
351
- ctx.compCamera.setFrustum(compositeCameraFrustum(cam, vp.w, vp.h));
352
- const idleDpr = vp.dpr > 0 ? vp.dpr : 1;
353
- const targetDpr = inMotion ? Math.min(idleDpr, 1) : idleDpr;
354
- if (gl.getPixelRatio() !== targetDpr) gl.setPixelRatio(targetDpr);
355
- const phaseOf = (e) => {
356
- const alive = world.isAlive(e);
357
- const active = alive && world.hasTag(e, Active);
358
- const visible = alive && world.hasTag(e, Visible) && bridge.islandFor(e) !== void 0;
359
- const s = bridge.state.get(e);
360
- const hasFbo = s !== void 0 && s.fboGeneration >= 0 && pool.get(e) !== null;
361
- return computeIslandPhase(active, visible, bridge.state.isAnimating(e), hasFbo);
362
- };
363
- for (const [e, s] of bridge.state.all()) {
364
- s.phase = phaseOf(e);
365
- if (s.phase === "Hot") stats.anyHot = true;
366
- }
367
- const band = selectBand(cam.zoom);
368
- const effectiveDpr = Math.min(gl.getPixelRatio(), ctx.maxPaintDpr) * band;
369
- const toPaint = [];
370
- for (const [e, s] of bridge.state.all()) {
371
- if (bridge.islandFor(e) === void 0) continue;
372
- const wantsPhase = s.phase === "Hot" || s.phase === "Waking";
373
- const genDirty = s.paintGeneration > s.fboGeneration;
374
- const bandStale = !inMotion && s.fboGeneration >= 0 && isOutOfBand(cam.zoom, s.paintedAt.band);
375
- const paintable = frozen ? wantsPhase && s.fboGeneration < 0 : wantsPhase || genDirty || bandStale;
376
- if (paintable) {
377
- toPaint.push(e);
378
- if (s.phase === "Hot") s.pendingDtMs += ctx.dtMs;
379
- }
380
- }
381
- toPaint.sort((a, b) => {
382
- const sa = bridge.state.get(a);
383
- const sb = bridge.state.get(b);
384
- const coldA = sa !== void 0 && sa.fboGeneration < 0 ? 0 : 1;
385
- const coldB = sb !== void 0 && sb.fboGeneration < 0 ? 0 : 1;
386
- if (coldA !== coldB) return coldA - coldB;
387
- return (sa?.lastPaintSeq ?? 0) - (sb?.lastPaintSeq ?? 0);
388
- });
389
- const cap = Math.max(1, ctx.maxRepaintsPerFrame);
390
- for (const e of toPaint) {
391
- if (stats.repainted >= cap) {
392
- stats.pendingPaints = toPaint.length - stats.repainted;
393
- break;
394
- }
395
- const handle = bridge.islandFor(e);
396
- const s = bridge.state.get(e);
397
- const size = world.isAlive(e) ? world.get(e, Size) : void 0;
398
- if (handle === void 0 || s === void 0 || size === void 0 || size.w <= 0 || size.h <= 0) continue;
399
- if (s.phase === "Hot") {
400
- const owedMs = s.pendingDtMs;
401
- s.pendingDtMs = 0;
402
- for (const cb of bridge.frameCallbacksFor(e)) cb(owedMs);
403
- }
404
- ctx.islandCamera(e)?.setFrustum(size.w / 2, size.h / 2);
405
- const fbo = pool.acquire(e, size.w, size.h, effectiveDpr);
406
- gl.setRenderTarget(fbo);
407
- try {
408
- gl.clear();
409
- gl.render(handle.scene, handle.camera);
410
- } finally {
411
- gl.setRenderTarget(null);
412
- }
413
- const px = fboPixelSize(size.w, size.h, effectiveDpr, 1);
414
- bridge.state.markPainted(e, { w: px.width, h: px.height, dpr: effectiveDpr, band });
415
- stats.repainted += 1;
416
- }
417
- if (pool.bytesUsed() > ctx.maxFboBytes) {
418
- const candidates = [];
419
- for (const info of pool.entryInfos()) {
420
- const s = bridge.state.get(info.key);
421
- const phase = s === void 0 ? "Dormant" : phaseOf(info.key);
422
- if (s !== void 0) s.phase = phase;
423
- candidates.push({
424
- id: info.key,
425
- phase,
426
- bytes: info.bytes,
427
- lastUsedMs: info.lastUsedMs
428
- });
429
- }
430
- for (const key of selectEvictions(candidates, pool.bytesUsed(), ctx.maxFboBytes)) {
431
- if (bridge.state.get(key)?.phase === "Dormant") {
432
- console.debug(`[ice/r3f] evicting Dormant island ${key} \u2014 consider raising the FBO budget`);
433
- }
434
- pool.release(key);
435
- bridge.state.markEvicted(key);
436
- stats.evicted += 1;
437
- }
438
- }
439
- const liveKeys = /* @__PURE__ */ new Set();
440
- for (const [e] of bridge.state.all()) liveKeys.add(e);
441
- for (const info of pool.entryInfos()) {
442
- if (!liveKeys.has(info.key)) pool.release(info.key);
443
- }
444
- for (const key of quads.keys()) {
445
- if (!liveKeys.has(key)) quads.remove(key);
446
- }
447
- const hasChrome = (e) => {
448
- const type = world.get(e, PrefabId)?.id;
449
- return typeof type === "string" && widgets.get(type)?.chrome != null;
450
- };
451
- const composited = [];
452
- let clip = null;
453
- const ordinals = bridge.order.ordinals();
454
- for (const [e, s] of bridge.state.all()) {
455
- const quad = quads.ensure(e);
456
- const alive = world.isAlive(e);
457
- const fbo = pool.get(e);
458
- const pos = alive ? world.get(e, Position) : void 0;
459
- const size = alive ? world.get(e, Size) : void 0;
460
- if (s.phase === "Dormant" || fbo === null || s.fboGeneration < 0 || pos === void 0 || size === void 0) {
461
- quad.setVisible(false);
462
- continue;
463
- }
464
- const q = worldRectToComposite({ x: pos.x, y: pos.y, width: size.w, height: size.h });
465
- if (s.liftElapsedMs < s.liftMs) {
466
- s.liftElapsedMs += ctx.dtMs;
467
- const t = Math.min(1, s.liftElapsedMs / s.liftMs);
468
- s.compositeScale = t >= 1 ? s.liftTarget : s.liftFrom + (s.liftTarget - s.liftFrom) * LIFT_EASE(t);
469
- if (t < 1) stats.liftAnimating = true;
470
- }
471
- if (s.opacityElapsedMs < s.opacityMs) {
472
- s.opacityElapsedMs += ctx.dtMs;
473
- const t = Math.min(1, s.opacityElapsedMs / s.opacityMs);
474
- s.compositeOpacity = t >= 1 ? s.opacityTarget : s.opacityFrom + (s.opacityTarget - s.opacityFrom) * OPACITY_EASE(t);
475
- if (t < 1) stats.liftAnimating = true;
476
- }
477
- const lift = s.compositeScale;
478
- quad.setTransform(q.x, q.y, q.sx * lift, q.sy * lift);
479
- quad.setTexture(fbo.texture);
480
- const baseOpacity = world.get(e, Opacity)?.a ?? 1;
481
- quad.setOpacity(Math.min(1, Math.max(0, baseOpacity * s.compositeOpacity)));
482
- const grabbed = world.get(e, Grab) !== void 0;
483
- quad.setRenderOrder(
484
- grabbed || lift !== 1 ? GRABBED_RENDER_ORDER : ordinals.get(e) ?? world.get(e, StackZ)?.z ?? 0
485
- );
486
- quad.setVisible(true);
487
- pool.touch(e);
488
- composited.push({ key: e, quad });
489
- if (clip === null && grabbed && hasChrome(e)) {
490
- const hw = q.sx * lift / 2;
491
- const hh = q.sy * lift / 2;
492
- clip = { key: e, minX: q.x - hw, minY: q.y - hh, maxX: q.x + hw, maxY: q.y + hh };
493
- }
494
- }
495
- for (const { key, quad } of composited) {
496
- if (clip === null) quad.setDragClip(0, 0, 0, 0, false);
497
- else quad.setDragClip(clip.minX, clip.minY, clip.maxX, clip.maxY, key === clip.key);
498
- }
499
- gl.setRenderTarget(null);
500
- gl.clear();
501
- gl.render(ctx.compositeScene, ctx.compCamera.raw);
502
- stats.fboBytes = pool.bytesUsed();
503
- if (backgrounded) stats.anyHot = false;
504
- return stats;
505
- }
506
-
507
- // ../r3f/src/gl-root.tsx
508
- import { useFrame, useThree } from "@react-three/fiber";
509
- import {
510
- createElement as createElement2,
511
- useEffect as useEffect3,
512
- useMemo as useMemo2,
513
- useRef as useRef2,
514
- useSyncExternalStore
515
- } from "react";
516
- import { Mesh, OrthographicCamera as OrthographicCamera2, PlaneGeometry } from "three";
517
-
518
- // ../r3f/src/composite-material.ts
519
- import { ShaderMaterial } from "three";
520
- var VERTEX_SHADER = (
521
- /* glsl */
522
- `
523
- varying vec2 vUv;
524
- varying vec2 vWorld;
525
- void main() {
526
- vUv = uv;
527
- vWorld = (modelMatrix * vec4(position, 1.0)).xy;
528
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
529
- }
530
- `
531
- );
532
- var FRAGMENT_SHADER = (
533
- /* glsl */
534
- `
535
- uniform sampler2D map;
536
- uniform float uOpacity;
537
- uniform vec4 uDraggedRect;
538
- uniform float uIsDragged;
539
- varying vec2 vUv;
540
- varying vec2 vWorld;
541
-
542
- void main() {
543
- // Drag clip (v1 RFC-003, composite-space): while a chrome-carrying GL card
544
- // is dragged, every OTHER quad discards fragments inside its rect so the
545
- // card's P1 DOM chrome shows through. (0,0,0,0) rect \u21D2 measure-zero, off.
546
- if (uIsDragged < 0.5 &&
547
- vWorld.x >= uDraggedRect.x && vWorld.x <= uDraggedRect.z &&
548
- vWorld.y >= uDraggedRect.y && vWorld.y <= uDraggedRect.w) {
549
- discard;
550
- }
551
- vec4 c = texture2D(map, vUv);
552
- if (c.a < 0.001) discard;
553
- c.a *= uOpacity;
554
- gl_FragColor = c;
555
- #include <colorspace_fragment>
556
- }
557
- `
558
- );
559
- var CompositeMaterial = class extends ShaderMaterial {
560
- // Direct handles onto our two uniform cells. ShaderMaterial types `uniforms`
561
- // as an index signature, so `this.uniforms.map` reads as possibly-undefined
562
- // under strict indexing; holding the cells we created sidesteps that and keeps
563
- // the setters allocation-free.
564
- mapUniform;
565
- opacityUniform;
566
- draggedRectUniform;
567
- isDraggedUniform;
568
- constructor() {
569
- const uniforms = {
570
- map: { value: null },
571
- uOpacity: { value: 1 },
572
- // three uploads number[] as vec4 — no Vector4 allocation needed.
573
- uDraggedRect: { value: [0, 0, 0, 0] },
574
- uIsDragged: { value: 0 }
575
- };
576
- super({
577
- vertexShader: VERTEX_SHADER,
578
- fragmentShader: FRAGMENT_SHADER,
579
- uniforms,
580
- transparent: true,
581
- depthWrite: false,
582
- // Explicit: this pass must never tone-map (the FBO is already display-
583
- // ready). v1 left toneMapped at the ShaderMaterial default and relied on
584
- // the absent tonemapping chunk alone (CompositionMaterial.ts:140-142); we
585
- // set it false so the no-tone-map contract holds even if the shader ever
586
- // gains chunks. Behaviour is identical for the current shader.
587
- toneMapped: false
588
- });
589
- this.mapUniform = uniforms.map;
590
- this.opacityUniform = uniforms.uOpacity;
591
- this.draggedRectUniform = uniforms.uDraggedRect;
592
- this.isDraggedUniform = uniforms.uIsDragged;
593
- }
594
- /** Bind the island's FBO texture (null clears). */
595
- setMap(map) {
596
- this.mapUniform.value = map;
597
- }
598
- /** Composite opacity. Pass-through — no clamping; callers pass valid 0..1. */
599
- setOpacity(opacity) {
600
- this.opacityUniform.value = opacity;
601
- }
602
- /**
603
- * Drag clip, composite-space min/max (v1's uDraggedRect re-cut from screen
604
- * space). (0,0,0,0) = inactive. Mutates the vec4 in place — no allocation.
605
- */
606
- setDraggedRect(minX, minY, maxX, maxY) {
607
- const r = this.draggedRectUniform.value;
608
- r[0] = minX;
609
- r[1] = minY;
610
- r[2] = maxX;
611
- r[3] = maxY;
612
- }
613
- /** True on the dragged card's own quad — exempt from the clip. */
614
- setIsDragged(isDragged) {
615
- this.isDraggedUniform.value = isDragged ? 1 : 0;
616
- }
617
- // dispose() is inherited from ShaderMaterial — it fires the dispose event that
618
- // frees the compiled program; no override needed.
619
- };
620
-
621
- // ../r3f/src/island.tsx
622
- import { createPortal } from "@react-three/fiber";
623
- import { createElement, useEffect as useEffect2, useMemo } from "react";
624
- import { OrthographicCamera, Scene } from "three";
625
-
626
- // ../r3f/src/use-island-frame.ts
627
- import { createContext, useCallback, useContext, useEffect, useRef } from "react";
628
- var IslandContext = createContext(null);
629
- function useIslandContext() {
630
- const ctx = useContext(IslandContext);
631
- if (ctx === null) {
632
- throw new Error("ice: useIslandFrame/useIslandInvalidate must run inside a GL widget's island.");
633
- }
634
- return ctx;
635
- }
636
- function useIslandFrame(cb) {
637
- const { bridge, entity } = useIslandContext();
638
- const ref = useRef(cb);
639
- ref.current = cb;
640
- useEffect(() => bridge.addFrameCallback(entity, (dt) => ref.current(dt)), [bridge, entity]);
641
- }
642
- function useIslandInvalidate() {
643
- const { bridge, entity } = useIslandContext();
644
- return useCallback(() => bridge.bumpPaint(entity), [bridge, entity]);
645
- }
646
- function useIslandLift(scale, durationMs) {
647
- const { bridge, entity } = useIslandContext();
648
- useEffect(() => {
649
- bridge.setCompositeScale(entity, scale, durationMs);
650
- }, [bridge, entity, scale, durationMs]);
651
- useEffect(() => () => bridge.setCompositeScale(entity, 1), [bridge, entity]);
652
- }
653
- function useIslandOpacity(opacity, durationMs) {
654
- const { bridge, entity } = useIslandContext();
655
- useEffect(() => {
656
- bridge.setCompositeOpacity(entity, opacity, durationMs);
657
- }, [bridge, entity, opacity, durationMs]);
658
- useEffect(() => () => bridge.setCompositeOpacity(entity, 1), [bridge, entity]);
659
- }
660
-
661
- // ../r3f/src/island.tsx
662
- function Island({ bridge, world, entity, widget, environment }) {
663
- const scene = useMemo(() => new Scene(), []);
664
- const camera = useMemo(() => {
665
- const cam = new OrthographicCamera(-1, 1, 1, -1, 0.1, 2e3);
666
- cam.position.set(0, 0, 500);
667
- cam.lookAt(0, 0, 0);
668
- return cam;
669
- }, []);
670
- useEffect2(
671
- () => bridge.registerIsland(entity, { scene, camera }),
672
- [bridge, entity, scene, camera]
673
- );
674
- useEffect2(() => {
675
- scene.environment = environment ?? null;
676
- bridge.bumpPaint(entity);
677
- }, [environment, scene, bridge, entity]);
678
- const View = widget.component;
679
- if (View == null) return null;
680
- return createPortal(
681
- createElement(
682
- IslandContext.Provider,
683
- { value: { bridge, entity } },
684
- createElement(View, { entity, world })
685
- ),
686
- scene
687
- );
688
- }
689
-
690
- // ../r3f/src/pool.ts
691
- import { SRGBColorSpace, WebGLRenderTarget } from "three";
692
- var COLOR_BYTES_PER_PIXEL = 4;
693
- var DEPTH_BYTES_PER_PIXEL = 4;
694
- var SAMPLES = 4;
695
- function targetBytes(pixelWidth, pixelHeight) {
696
- const msaa = SAMPLES > 1;
697
- const colorBytes = COLOR_BYTES_PER_PIXEL * (msaa ? 1 + SAMPLES : 1);
698
- const depthBytes = DEPTH_BYTES_PER_PIXEL * (msaa ? SAMPLES : 1);
699
- return pixelWidth * pixelHeight * (colorBytes + depthBytes);
700
- }
701
- var RenderTargetPool = class {
702
- entries = /* @__PURE__ */ new Map();
703
- totalBytes = 0;
704
- disposed = false;
705
- now;
706
- /**
707
- * @param now Injected monotonic clock for LRU timestamps. Defaults to
708
- * `performance.now()`; tests pass a deterministic stub so `lastUsedMs`
709
- * assertions do not depend on wall-clock timing.
710
- */
711
- constructor(now = () => performance.now()) {
712
- this.now = now;
713
- }
714
- /**
715
- * Get or create an FBO for `key` at the requested world size and effective
716
- * device-pixel-ratio. Returns the existing target unchanged when its pixel
717
- * dimensions already match; otherwise disposes the stale target and allocates
718
- * a new one sized to the new resolution.
719
- */
720
- acquire(key, worldW, worldH, effectiveDpr) {
721
- if (this.disposed) {
722
- throw new Error("RenderTargetPool: cannot acquire after dispose");
723
- }
724
- const pixelWidth = Math.max(1, Math.round(worldW * effectiveDpr));
725
- const pixelHeight = Math.max(1, Math.round(worldH * effectiveDpr));
726
- const nowMs = this.now();
727
- const existing = this.entries.get(key);
728
- if (existing && existing.pixelWidth === pixelWidth && existing.pixelHeight === pixelHeight) {
729
- existing.lastUsedMs = nowMs;
730
- return existing.rt;
731
- }
732
- if (existing) {
733
- existing.rt.dispose();
734
- this.totalBytes -= existing.bytes;
735
- }
736
- const rt = new WebGLRenderTarget(pixelWidth, pixelHeight, { samples: SAMPLES });
737
- rt.texture.colorSpace = SRGBColorSpace;
738
- const bytes = targetBytes(pixelWidth, pixelHeight);
739
- this.entries.set(key, { rt, pixelWidth, pixelHeight, effectiveDpr, bytes, lastUsedMs: nowMs });
740
- this.totalBytes += bytes;
741
- return rt;
742
- }
743
- /** Look up an FBO without creating one. */
744
- get(key) {
745
- return this.entries.get(key)?.rt ?? null;
746
- }
747
- /**
748
- * Refresh `lastUsedMs` without re-acquiring. The compositor calls this for
749
- * every island it samples in the composition pass — without it, warm islands
750
- * that never repaint would freeze their timestamp at their last paint and the
751
- * LRU would treat still-visible islands as stale (design-004 §3).
752
- */
753
- touch(key) {
754
- const entry = this.entries.get(key);
755
- if (!entry) return;
756
- entry.lastUsedMs = this.now();
757
- }
758
- /**
759
- * Release `key`'s FBO. Returns true if something was released. Safe after
760
- * dispose — returns false rather than corrupting the byte counter or
761
- * double-disposing the target.
762
- */
763
- release(key) {
764
- if (this.disposed) return false;
765
- const entry = this.entries.get(key);
766
- if (!entry) return false;
767
- entry.rt.dispose();
768
- this.totalBytes = Math.max(0, this.totalBytes - entry.bytes);
769
- this.entries.delete(key);
770
- return true;
771
- }
772
- /** Total GPU bytes consumed by the pool. */
773
- bytesUsed() {
774
- return this.totalBytes;
775
- }
776
- /** Number of FBOs currently held. */
777
- size() {
778
- return this.entries.size;
779
- }
780
- /** True after `dispose()` — callers should re-create the pool instead of using it. */
781
- isDisposed() {
782
- return this.disposed;
783
- }
784
- /** Iterate live entries (key + target). */
785
- forEach(cb) {
786
- for (const [key, entry] of this.entries) cb(key, entry.rt);
787
- }
788
- /**
789
- * Snapshot of every live entry's `bytes` + `lastUsedMs` — the input an
790
- * eviction pass ranks by LRU.
791
- */
792
- entryInfos() {
793
- const out = [];
794
- for (const [key, entry] of this.entries) {
795
- out.push({ key, bytes: entry.bytes, lastUsedMs: entry.lastUsedMs });
796
- }
797
- return out;
798
- }
799
- /** Dispose every FBO. After this, acquire throws and release returns false. */
800
- dispose() {
801
- if (this.disposed) return;
802
- for (const entry of this.entries.values()) entry.rt.dispose();
803
- this.entries.clear();
804
- this.totalBytes = 0;
805
- this.disposed = true;
806
- }
807
- };
808
-
809
- // ../r3f/src/self-sustain.ts
810
- var RATE_CAP_SLACK_MS = 4;
811
- function selfSustainPlan(stats, elapsedMs, maxFps) {
812
- if (stats.liftAnimating) return "now";
813
- if (!stats.anyHot && stats.pendingPaints <= 0) return "none";
814
- const interval = 1e3 / Math.max(1, maxFps);
815
- const delay = interval - elapsedMs - RATE_CAP_SLACK_MS;
816
- return delay <= 0 ? "now" : delay;
817
- }
818
-
819
- // ../r3f/src/gl-root.tsx
820
- var visibleWidgetsQ = defineQuery([Visible]);
821
- var culledWidgetsQ = defineQuery([Culled]);
822
- function GLViews({
823
- engine,
824
- bridge,
825
- store,
826
- maxFboBytes = RUNTIME_BUDGETS.fboBytes,
827
- maxRepaintsPerFrame = 4,
828
- maxAnimationFps = 60,
829
- maxPaintDpr = 1.5,
830
- environment,
831
- onFrameStats
832
- }) {
833
- const world = engine.world;
834
- const gl = useThree((s) => s.gl);
835
- const scene = useThree((s) => s.scene);
836
- const set = useThree((s) => s.set);
837
- const advance2 = useThree((s) => s.advance);
838
- const frameloop = useThree((s) => s.frameloop);
839
- const clock = useThree((s) => s.clock);
840
- const poolRef = useRef2(null);
841
- if (poolRef.current === null || poolRef.current.isDisposed()) {
842
- poolRef.current = new RenderTargetPool();
843
- }
844
- const pool = poolRef.current;
845
- const quadGeometry = useMemo2(() => new PlaneGeometry(1, 1), []);
846
- const compCamera = useMemo2(() => new OrthographicCamera2(0, 1, 0, -1, 0.1, 1e4), []);
847
- useEffect3(() => {
848
- set({ camera: compCamera });
849
- }, [set, compCamera]);
850
- const quadsRef = useRef2(/* @__PURE__ */ new Map());
851
- const quads = useMemo2(
852
- () => ({
853
- ensure(key) {
854
- let mesh = quadsRef.current.get(key);
855
- if (mesh === void 0) {
856
- mesh = new Mesh(quadGeometry, new CompositeMaterial());
857
- mesh.frustumCulled = false;
858
- mesh.visible = false;
859
- scene.add(mesh);
860
- quadsRef.current.set(key, mesh);
861
- }
862
- const m = mesh;
863
- return {
864
- setTransform: (x, y, sx, sy) => {
865
- m.position.set(x, y, 0);
866
- m.scale.set(sx, sy, 1);
867
- },
868
- setTexture: (t) => m.material.setMap(t),
869
- setVisible: (v) => {
870
- m.visible = v;
871
- },
872
- setRenderOrder: (n) => {
873
- m.renderOrder = n;
874
- },
875
- setOpacity: (o) => m.material.setOpacity(o),
876
- setDragClip: (minX, minY, maxX, maxY, exempt) => {
877
- const mat = m.material;
878
- mat.setDraggedRect(minX, minY, maxX, maxY);
879
- mat.setIsDragged(exempt);
880
- }
881
- };
882
- },
883
- remove(key) {
884
- const mesh = quadsRef.current.get(key);
885
- if (mesh !== void 0) {
886
- scene.remove(mesh);
887
- mesh.material.dispose();
888
- quadsRef.current.delete(key);
889
- }
890
- },
891
- keys: () => [...quadsRef.current.keys()]
892
- }),
893
- [scene, quadGeometry]
894
- );
895
- const glLike = useMemo2(
896
- () => ({
897
- setRenderTarget: (t) => gl.setRenderTarget(t),
898
- clear: () => {
899
- gl.setClearColor(0, 0);
900
- gl.clear(true, true, false);
901
- },
902
- render: (s, c) => gl.render(s, c),
903
- setPixelRatio: (n) => gl.setPixelRatio(n),
904
- getPixelRatio: () => gl.getPixelRatio()
905
- }),
906
- [gl]
907
- );
908
- useEffect3(() => {
909
- clock.elapsedTime = performance.now() / 1e3;
910
- bridge.setRenderNow((nowMs) => advance2(nowMs / 1e3, true));
911
- return () => bridge.setRenderNow(null);
912
- }, [bridge, advance2, clock]);
913
- useEffect3(() => {
914
- if (frameloop !== "never") {
915
- console.warn(
916
- `[ice/r3f] GLViews: <Canvas frameloop="${frameloop}"> \u2014 use frameloop="never". The engine drives frames (reflect-phase advance); a self-scheduling loop renders out of phase with the DOM planes.`
917
- );
918
- }
919
- }, [frameloop]);
920
- const statsCbRef = useRef2(onFrameStats);
921
- statsCbRef.current = onFrameStats;
922
- const paintsOwedRef = useRef2(false);
923
- const gpuProfilerRef = useRef2(null);
924
- const gpuProfilerState = useRef2("idle");
925
- useEffect3(
926
- () => () => {
927
- gpuProfilerRef.current?.dispose();
928
- gpuProfilerRef.current = null;
929
- gpuProfilerState.current = "idle";
930
- },
931
- []
932
- );
933
- useEffect3(() => {
934
- const quadMap = quadsRef.current;
935
- return () => {
936
- for (const mesh of quadMap.values()) {
937
- scene.remove(mesh);
938
- mesh.material.dispose();
939
- }
940
- quadMap.clear();
941
- pool.dispose();
942
- for (const [key] of bridge.state.all()) bridge.state.markEvicted(key);
943
- };
944
- }, [scene, pool, bridge]);
945
- useFrame((_, delta) => {
946
- const profiling = statsCbRef.current !== void 0;
947
- if (profiling) {
948
- if (gpuProfilerState.current === "idle") {
949
- gpuProfilerState.current = "loading";
950
- void import("stats-gl").then(async ({ StatsProfiler }) => {
951
- const p = new StatsProfiler({ trackGPU: true });
952
- await p.init(gl);
953
- gpuProfilerRef.current = p;
954
- gpuProfilerState.current = "ready";
955
- }).catch(() => {
956
- gpuProfilerState.current = "failed";
957
- });
958
- }
959
- gl.info.autoReset = false;
960
- gl.info.reset();
961
- } else if (!gl.info.autoReset) {
962
- gl.info.autoReset = true;
963
- }
964
- const passStart = performance.now();
965
- bridge.renderAssert.begin();
966
- let stats;
967
- try {
968
- stats = runCompositorPass({
969
- world,
970
- bridge,
971
- pool,
972
- quads,
973
- gl: glLike,
974
- compCamera: {
975
- raw: compCamera,
976
- // the REAL camera — gl.render instanceof-checks it
977
- setFrustum: (f) => {
978
- compCamera.left = f.left;
979
- compCamera.right = f.right;
980
- compCamera.top = f.top;
981
- compCamera.bottom = f.bottom;
982
- compCamera.position.set(f.x, f.y, 1e3);
983
- compCamera.updateProjectionMatrix();
984
- }
985
- },
986
- islandCamera: (entity) => {
987
- const handle = bridge.islandFor(entity);
988
- if (handle === void 0) return void 0;
989
- return {
990
- setFrustum: (halfW, halfH) => {
991
- handle.camera.left = -halfW;
992
- handle.camera.right = halfW;
993
- handle.camera.top = halfH;
994
- handle.camera.bottom = -halfH;
995
- handle.camera.updateProjectionMatrix();
996
- }
997
- };
998
- },
999
- compositeScene: scene,
1000
- maxFboBytes,
1001
- maxRepaintsPerFrame,
1002
- maxPaintDpr,
1003
- dtMs: delta * 1e3
1004
- });
1005
- } finally {
1006
- bridge.renderAssert.end();
1007
- }
1008
- const cb = statsCbRef.current;
1009
- if (cb !== void 0) {
1010
- const gpu = gpuProfilerRef.current;
1011
- gpu?.update();
1012
- const d = gpu?.getData();
1013
- const info = gl.info;
1014
- let total = 0;
1015
- let hot = 0;
1016
- let warm = 0;
1017
- let waking = 0;
1018
- let cold = 0;
1019
- let dormant = 0;
1020
- let pixels = 0;
1021
- const bandHistogram = {};
1022
- for (const [e, s] of bridge.state.all()) {
1023
- total++;
1024
- if (s.phase === "Hot") hot++;
1025
- else if (s.phase === "Warm") warm++;
1026
- else if (s.phase === "Waking") waking++;
1027
- else if (s.phase === "Dormant") dormant++;
1028
- else cold++;
1029
- if (s.fboGeneration >= 0 && pool.get(e) !== null) {
1030
- pixels += s.paintedAt.w * s.paintedAt.h;
1031
- const key = `\xD7${s.paintedAt.band}`;
1032
- bandHistogram[key] = (bandHistogram[key] ?? 0) + 1;
1033
- }
1034
- }
1035
- let visibleWidgets = 0;
1036
- let culledWidgets = 0;
1037
- world.query(visibleWidgetsQ).each((b) => {
1038
- visibleWidgets += b.count;
1039
- });
1040
- world.query(culledWidgetsQ).each((b) => {
1041
- culledWidgets += b.count;
1042
- });
1043
- const zoom = world.getResource(Camera)?.zoom ?? 1;
1044
- const band = selectBand(zoom);
1045
- cb({
1046
- cpuMs: performance.now() - passStart,
1047
- gpuMs: d?.gpu ?? 0,
1048
- fps: d?.fps ?? 0,
1049
- drawCalls: info.render.calls,
1050
- triangles: info.render.triangles,
1051
- points: info.render.points,
1052
- lines: info.render.lines,
1053
- programs: info.programs?.length ?? 0,
1054
- geometries: info.memory.geometries,
1055
- textures: info.memory.textures,
1056
- renderTargets: pool.size(),
1057
- renderMegaPixels: pixels / 1e6,
1058
- fboBytes: pool.bytesUsed(),
1059
- fboBudgetBytes: maxFboBytes,
1060
- islands: { total, hot, warm, waking, cold, dormant },
1061
- bandHistogram,
1062
- repainted: stats.repainted,
1063
- pendingPaints: stats.pendingPaints,
1064
- evicted: stats.evicted,
1065
- zoom,
1066
- band,
1067
- effectiveDpr: Math.min(gl.getPixelRatio(), maxPaintDpr) * band,
1068
- visibleWidgets,
1069
- culledWidgets
1070
- });
1071
- }
1072
- bridge.schedulePass(selfSustainPlan(stats, performance.now() - passStart, maxAnimationFps));
1073
- paintsOwedRef.current = stats.pendingPaints > 0 || stats.liftAnimating;
1074
- }, 1);
1075
- useEffect3(
1076
- () => engine.frame.settleWhile("gl-paints", () => paintsOwedRef.current),
1077
- [engine]
1078
- );
1079
- const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
1080
- const islands = [];
1081
- for (const entry of entries) {
1082
- if (entry.hidden) continue;
1083
- if (!world.isAlive(entry.entity)) continue;
1084
- const type = world.get(entry.entity, PrefabId)?.id;
1085
- const widget = typeof type === "string" ? widgets.get(type) : void 0;
1086
- if (widget === void 0 || widget.surface !== "gl") continue;
1087
- islands.push(
1088
- createElement2(Island, {
1089
- key: String(entry.entity),
1090
- bridge,
1091
- world,
1092
- entity: entry.entity,
1093
- widget,
1094
- ...environment !== void 0 ? { environment } : {}
1095
- })
1096
- );
1097
- }
1098
- return createElement2("group", null, islands);
1099
- }
1100
-
1101
- // ../r3f/src/resource-registry.ts
1102
- var ResourceRegistry = class {
1103
- geometries = /* @__PURE__ */ new Map();
1104
- materials = /* @__PURE__ */ new Map();
1105
- textures = /* @__PURE__ */ new Map();
1106
- disposed = false;
1107
- acquireGeometry(key, factory) {
1108
- if (this.disposed) {
1109
- throw new Error("ResourceRegistry: cannot acquire after dispose");
1110
- }
1111
- const existing = this.geometries.get(key);
1112
- if (existing) {
1113
- existing.refCount++;
1114
- return existing.resource;
1115
- }
1116
- const resource = factory();
1117
- this.geometries.set(key, { resource, refCount: 1 });
1118
- return resource;
1119
- }
1120
- releaseGeometry(key) {
1121
- this.releaseFrom(this.geometries, key);
1122
- }
1123
- acquireMaterial(key, factory) {
1124
- if (this.disposed) {
1125
- throw new Error("ResourceRegistry: cannot acquire after dispose");
1126
- }
1127
- const existing = this.materials.get(key);
1128
- if (existing) {
1129
- existing.refCount++;
1130
- return existing.resource;
1131
- }
1132
- const resource = factory();
1133
- this.materials.set(key, { resource, refCount: 1 });
1134
- return resource;
1135
- }
1136
- releaseMaterial(key) {
1137
- this.releaseFrom(this.materials, key);
1138
- }
1139
- acquireTexture(key, factory) {
1140
- if (this.disposed) {
1141
- throw new Error("ResourceRegistry: cannot acquire after dispose");
1142
- }
1143
- const existing = this.textures.get(key);
1144
- if (existing) {
1145
- existing.refCount++;
1146
- return existing.resource;
1147
- }
1148
- const resource = factory();
1149
- this.textures.set(key, { resource, refCount: 1 });
1150
- return resource;
1151
- }
1152
- releaseTexture(key) {
1153
- this.releaseFrom(this.textures, key);
1154
- }
1155
- /** Number of distinct shared geometries currently held. */
1156
- geometryCount() {
1157
- return this.geometries.size;
1158
- }
1159
- /** Number of distinct shared materials currently held. */
1160
- materialCount() {
1161
- return this.materials.size;
1162
- }
1163
- /** Number of distinct shared textures currently held. */
1164
- textureCount() {
1165
- return this.textures.size;
1166
- }
1167
- /**
1168
- * Estimated GPU bytes for shared geometry attribute buffers. Best-effort —
1169
- * actual footprint depends on driver alignment, but a useful relative metric
1170
- * for the profiler.
1171
- */
1172
- geometryBytes() {
1173
- let total = 0;
1174
- for (const { resource } of this.geometries.values()) {
1175
- for (const attr of Object.values(resource.attributes)) {
1176
- if ("array" in attr && attr.array.byteLength) {
1177
- total += attr.array.byteLength;
1178
- }
1179
- }
1180
- if (resource.index) {
1181
- total += resource.index.array.byteLength;
1182
- }
1183
- }
1184
- return total;
1185
- }
1186
- /** Dispose every resource and clear the registry. */
1187
- dispose() {
1188
- if (this.disposed) return;
1189
- for (const { resource } of this.geometries.values()) resource.dispose();
1190
- for (const { resource } of this.materials.values()) resource.dispose();
1191
- for (const { resource } of this.textures.values()) resource.dispose();
1192
- this.geometries.clear();
1193
- this.materials.clear();
1194
- this.textures.clear();
1195
- this.disposed = true;
1196
- }
1197
- /** True after `dispose()` — callers should re-create the registry instead of using it. */
1198
- isDisposed() {
1199
- return this.disposed;
1200
- }
1201
- releaseFrom(map, key) {
1202
- const entry = map.get(key);
1203
- if (!entry) return;
1204
- entry.refCount--;
1205
- if (entry.refCount <= 0) {
1206
- queueMicrotask(() => {
1207
- const current = map.get(key);
1208
- if (current && current.refCount <= 0) {
1209
- current.resource.dispose();
1210
- map.delete(key);
1211
- }
1212
- });
1213
- }
1214
- }
1215
- };
1216
-
1217
- // ../r3f/src/gl-router.ts
1218
- import { Raycaster, Vector2 } from "three";
1219
- function handlersOf(obj) {
1220
- const inst = obj.__r3f;
1221
- if (inst === void 0 || (inst.eventCount ?? 0) === 0) return void 0;
1222
- return inst.handlers;
1223
- }
1224
- function createGLPointerRouter({ world, bridge, index }) {
1225
- const raycaster = new Raycaster();
1226
- const ndc = new Vector2();
1227
- const routerOrder = createSiblingOrderIndex(world);
1228
- const captures = /* @__PURE__ */ new Map();
1229
- const hovered = /* @__PURE__ */ new Map();
1230
- const unclaimedDowns = /* @__PURE__ */ new Map();
1231
- let hoverInteractive = false;
1232
- const chainInteractive = (hits) => {
1233
- for (const h of hits) {
1234
- for (let obj = h.object; obj !== null; obj = obj.parent) {
1235
- const handlers = handlersOf(obj);
1236
- if (handlers !== void 0 && (handlers.onPointerDown !== void 0 || handlers.onClick !== void 0)) {
1237
- return true;
1238
- }
1239
- }
1240
- }
1241
- return false;
1242
- };
1243
- const withinTapSlop = (downX, downY, upX, upY) => {
1244
- const slop = world.getResource(GestureSettings)?.tapSlopPx ?? GESTURE_DEFAULTS.tapSlopPx;
1245
- const dx = upX - downX;
1246
- const dy = upY - downY;
1247
- return dx * dx + dy * dy <= slop * slop;
1248
- };
1249
- const chainHas = (hits, target) => {
1250
- for (const h of hits) {
1251
- for (let obj = h.object; obj !== null; obj = obj.parent) {
1252
- if (obj === target) return true;
1253
- }
1254
- }
1255
- return false;
1256
- };
1257
- const filterToChain = (hits, target) => {
1258
- const kept = [];
1259
- for (const h of hits) {
1260
- for (let obj = h.object; obj !== null; obj = obj.parent) {
1261
- if (obj === target) {
1262
- kept.push(h);
1263
- break;
1264
- }
1265
- }
1266
- }
1267
- return kept;
1268
- };
1269
- const castAt = (screenX, screenY) => {
1270
- const cam = world.getResource(Camera);
1271
- if (cam === void 0) return void 0;
1272
- const w = screenToWorld(screenX, screenY, cam);
1273
- const hit = pickTopAt(world, index, w.x, w.y, 0, void 0, routerOrder.ordinals());
1274
- if (hit === void 0) return void 0;
1275
- const type = world.get(hit, PrefabId)?.id;
1276
- const widget = typeof type === "string" ? widgets.get(type) : void 0;
1277
- if (widget === void 0 || widget.surface !== "gl") return void 0;
1278
- const handle = bridge.islandFor(hit);
1279
- const pos = world.get(hit, Position);
1280
- const size = world.get(hit, Size);
1281
- if (handle === void 0 || pos === void 0 || size === void 0 || size.w <= 0 || size.h <= 0) {
1282
- return void 0;
1283
- }
1284
- const local = worldToIsland(w.x, w.y, { x: pos.x, y: pos.y, width: size.w, height: size.h });
1285
- ndc.set(local.x / (size.w / 2), local.y / (size.h / 2));
1286
- const cam3 = handle.camera;
1287
- cam3.left = -size.w / 2;
1288
- cam3.right = size.w / 2;
1289
- cam3.top = size.h / 2;
1290
- cam3.bottom = -size.h / 2;
1291
- cam3.updateProjectionMatrix();
1292
- cam3.updateMatrixWorld(true);
1293
- handle.scene.updateMatrixWorld(true);
1294
- raycaster.setFromCamera(ndc, cam3);
1295
- return { entity: hit, hits: raycaster.intersectObjects(handle.scene.children, true) };
1296
- };
1297
- const captureHits = (x, y, capture) => {
1298
- const cast = castAt(x, y);
1299
- if (cast === void 0 || cast.entity !== capture.entity) return [];
1300
- return capture.downObject === void 0 ? cast.hits : filterToChain(cast.hits, capture.downObject);
1301
- };
1302
- const dispatch = (type, eventType, entity, hits, native, only) => {
1303
- const visited = /* @__PURE__ */ new Set();
1304
- let stopped = false;
1305
- let claimedBy;
1306
- const targets = [];
1307
- if (hits.length === 0 && only !== void 0) {
1308
- targets.push({ obj: only, hit: void 0 });
1309
- }
1310
- for (const hit of hits) {
1311
- for (let obj = hit.object; obj !== null; obj = obj.parent) {
1312
- if (visited.has(obj)) continue;
1313
- visited.add(obj);
1314
- targets.push({ obj, hit });
1315
- }
1316
- }
1317
- for (const { obj, hit } of targets) {
1318
- const fn = handlersOf(obj)?.[type];
1319
- if (fn === void 0) continue;
1320
- let localStop = false;
1321
- const ev = {
1322
- type: eventType,
1323
- nativeEvent: native,
1324
- point: hit?.point,
1325
- distance: hit?.distance ?? 0,
1326
- object: hit?.object ?? obj,
1327
- eventObject: obj,
1328
- intersections: hits,
1329
- entity,
1330
- stopPropagation() {
1331
- localStop = true;
1332
- },
1333
- get stopped() {
1334
- return localStop;
1335
- }
1336
- };
1337
- fn(ev);
1338
- if (localStop) {
1339
- stopped = true;
1340
- claimedBy = obj;
1341
- break;
1342
- }
1343
- }
1344
- return { stopped, claimedBy };
1345
- };
1346
- const syncHover = (now, native) => {
1347
- const nowEntity = now?.entity;
1348
- const nowObjs = /* @__PURE__ */ new Set();
1349
- if (now !== void 0) {
1350
- for (const hit of now.hits) {
1351
- for (let obj = hit.object; obj !== null; obj = obj.parent) nowObjs.add(obj);
1352
- }
1353
- }
1354
- for (const [entity, prev] of hovered) {
1355
- const gone = [];
1356
- for (const obj of prev) {
1357
- if (entity !== nowEntity || !nowObjs.has(obj)) gone.push(obj);
1358
- }
1359
- for (const obj of gone) {
1360
- prev.delete(obj);
1361
- handlersOf(obj)?.onPointerOut?.({
1362
- type: "pointerout",
1363
- nativeEvent: native,
1364
- point: void 0,
1365
- distance: 0,
1366
- object: obj,
1367
- eventObject: obj,
1368
- intersections: [],
1369
- entity,
1370
- stopPropagation() {
1371
- },
1372
- stopped: false
1373
- });
1374
- }
1375
- if (prev.size === 0) hovered.delete(entity);
1376
- }
1377
- if (now !== void 0 && nowEntity !== void 0) {
1378
- let set = hovered.get(nowEntity);
1379
- if (set === void 0) {
1380
- set = /* @__PURE__ */ new Set();
1381
- hovered.set(nowEntity, set);
1382
- }
1383
- for (const obj of nowObjs) {
1384
- if (set.has(obj) || handlersOf(obj) === void 0) continue;
1385
- set.add(obj);
1386
- handlersOf(obj)?.onPointerOver?.({
1387
- type: "pointerover",
1388
- nativeEvent: native,
1389
- point: void 0,
1390
- distance: 0,
1391
- object: obj,
1392
- eventObject: obj,
1393
- intersections: now.hits,
1394
- entity: nowEntity,
1395
- stopPropagation() {
1396
- },
1397
- stopped: false
1398
- });
1399
- }
1400
- }
1401
- };
1402
- return {
1403
- route(kind, screenX, screenY, native) {
1404
- if (kind === "down") {
1405
- const cast = castAt(screenX, screenY);
1406
- if (cast === void 0) {
1407
- unclaimedDowns.delete(native.pointerId);
1408
- return false;
1409
- }
1410
- const { stopped, claimedBy } = dispatch("onPointerDown", "pointerdown", cast.entity, cast.hits, native);
1411
- if (stopped) {
1412
- unclaimedDowns.delete(native.pointerId);
1413
- captures.set(native.pointerId, {
1414
- entity: cast.entity,
1415
- downObject: claimedBy,
1416
- downX: screenX,
1417
- downY: screenY
1418
- });
1419
- return true;
1420
- }
1421
- const top = cast.hits[0]?.object;
1422
- if (top !== void 0) {
1423
- unclaimedDowns.set(native.pointerId, {
1424
- entity: cast.entity,
1425
- object: top,
1426
- downX: screenX,
1427
- downY: screenY
1428
- });
1429
- }
1430
- return false;
1431
- }
1432
- const capture = captures.get(native.pointerId);
1433
- if (kind === "move") {
1434
- if (capture !== void 0) {
1435
- hoverInteractive = true;
1436
- const hits2 = captureHits(screenX, screenY, capture);
1437
- dispatch("onPointerMove", "pointermove", capture.entity, hits2, native, capture.downObject);
1438
- return true;
1439
- }
1440
- hoverInteractive = false;
1441
- if (native.buttons === 0) {
1442
- const cast = castAt(screenX, screenY);
1443
- hoverInteractive = cast !== void 0 && chainInteractive(cast.hits);
1444
- syncHover(cast, native);
1445
- if (cast !== void 0) {
1446
- dispatch("onPointerMove", "pointermove", cast.entity, cast.hits, native);
1447
- }
1448
- }
1449
- return false;
1450
- }
1451
- if (capture === void 0) {
1452
- const pending = unclaimedDowns.get(native.pointerId);
1453
- unclaimedDowns.delete(native.pointerId);
1454
- if (kind === "up" && pending !== void 0 && withinTapSlop(pending.downX, pending.downY, screenX, screenY)) {
1455
- const cast = castAt(screenX, screenY);
1456
- if (cast !== void 0 && cast.entity === pending.entity && cast.hits[0]?.object === pending.object) {
1457
- dispatch("onClick", "click", cast.entity, cast.hits, native, pending.object);
1458
- }
1459
- }
1460
- return false;
1461
- }
1462
- captures.delete(native.pointerId);
1463
- const hits = captureHits(screenX, screenY, capture);
1464
- if (kind === "up") {
1465
- const { claimedBy } = dispatch("onPointerUp", "pointerup", capture.entity, hits, native, capture.downObject);
1466
- if (capture.downObject !== void 0 && (claimedBy === void 0 || claimedBy === capture.downObject) && chainHas(hits, capture.downObject) && withinTapSlop(capture.downX, capture.downY, screenX, screenY)) {
1467
- dispatch("onClick", "click", capture.entity, hits, native, capture.downObject);
1468
- }
1469
- } else {
1470
- dispatch("onPointerCancel", "pointercancel", capture.entity, hits, native, capture.downObject);
1471
- }
1472
- return true;
1473
- },
1474
- overInteractive: () => hoverInteractive
1475
- };
1476
- }
1477
-
1478
- // ../r3f/src/preview-capture.tsx
1479
- import { advance, createRoot } from "@react-three/fiber";
1480
- import { createElement as createElement3 } from "react";
1481
- var sandbox = null;
1482
- function ensureEntity(def) {
1483
- if (sandbox === null) {
1484
- const ce = createCanvasEngine();
1485
- ce.docs.create();
1486
- ce.world.sync();
1487
- ce.step(16);
1488
- sandbox = { ce, entities: /* @__PURE__ */ new Map() };
1489
- }
1490
- const hit = sandbox.entities.get(def.type);
1491
- if (hit !== void 0) return hit;
1492
- try {
1493
- const e = sandbox.ce.ops.spawnWidget(def.type, {
1494
- x: 0,
1495
- y: 0,
1496
- undoable: false,
1497
- ...def.previewProps !== void 0 ? { props: def.previewProps } : {}
1498
- });
1499
- sandbox.ce.world.sync();
1500
- sandbox.ce.step(32);
1501
- sandbox.entities.set(def.type, e);
1502
- return e;
1503
- } catch (err) {
1504
- console.warn(`ice: preview capture \u2014 sandbox spawn failed for "${def.type}".`, err);
1505
- return void 0;
1506
- }
1507
- }
1508
- function stubBridge(callbacks) {
1509
- const stub = {
1510
- addFrameCallback: (_e, cb) => {
1511
- callbacks.add(cb);
1512
- return () => callbacks.delete(cb);
1513
- },
1514
- bumpPaint: () => {
1515
- },
1516
- setCompositeScale: () => {
1517
- },
1518
- setCompositeOpacity: () => {
1519
- }
1520
- };
1521
- return stub;
1522
- }
1523
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
1524
- var inFlight = null;
1525
- function captureWidgetPreviews(opts = {}) {
1526
- if (inFlight !== null) return inFlight;
1527
- const run = doCapture(opts).finally(() => {
1528
- inFlight = null;
1529
- });
1530
- inFlight = run;
1531
- return run;
1532
- }
1533
- async function doCapture(opts) {
1534
- const wanted = opts.types ?? widgets.all().filter((d) => d.surface === "gl").map((d) => d.type);
1535
- const defs = wanted.map((t) => widgets.get(t)).filter((d) => d !== void 0 && d.surface === "gl" && d.component !== null && d.component !== void 0).filter((d) => !hasPreviewSnapshot(d.type));
1536
- if (defs.length === 0) return [];
1537
- const canvas = document.createElement("canvas");
1538
- const root = createRoot(canvas);
1539
- const captured = [];
1540
- let resolvedEnv;
1541
- try {
1542
- for (const def of defs) {
1543
- try {
1544
- const entity = ensureEntity(def);
1545
- if (entity === void 0 || sandbox === null) continue;
1546
- const { w, h } = def.defaultSize;
1547
- const scale = opts.scale ?? Math.min(2, 512 / Math.max(w, h));
1548
- const callbacks = /* @__PURE__ */ new Set();
1549
- root.configure({
1550
- frameloop: "never",
1551
- gl: { alpha: true, antialias: true, preserveDrawingBuffer: true },
1552
- orthographic: true,
1553
- // The island frustum verbatim (island.tsx / the paint pass): center
1554
- // origin, Y-up, camera on +Z looking at the content plane; `manual`
1555
- // pins it against R3F's resize auto-frustum.
1556
- camera: {
1557
- left: -w / 2,
1558
- right: w / 2,
1559
- top: h / 2,
1560
- bottom: -h / 2,
1561
- near: 0.1,
1562
- far: 2e3,
1563
- position: [0, 0, 500],
1564
- manual: true
1565
- },
1566
- size: { width: w, height: h, top: 0, left: 0 },
1567
- dpr: scale
1568
- });
1569
- const View = def.component;
1570
- const store = root.render(
1571
- createElement3(
1572
- EngineProvider,
1573
- { engine: sandbox.ce },
1574
- createElement3(
1575
- IslandContext.Provider,
1576
- { value: { bridge: stubBridge(callbacks), entity } },
1577
- createElement3(View, { entity, world: sandbox.ce.world })
1578
- )
1579
- )
1580
- );
1581
- if (resolvedEnv === void 0) {
1582
- resolvedEnv = typeof opts.environment === "function" ? opts.environment(store.getState().gl) : opts.environment ?? null;
1583
- }
1584
- store.getState().scene.environment = resolvedEnv;
1585
- const cam = store.getState().camera;
1586
- cam.left = -w / 2;
1587
- cam.right = w / 2;
1588
- cam.top = h / 2;
1589
- cam.bottom = -h / 2;
1590
- cam.near = 0.1;
1591
- cam.far = 2e3;
1592
- cam.position.set(0, 0, 500);
1593
- cam.lookAt(0, 0, 0);
1594
- cam.updateProjectionMatrix();
1595
- cam.updateMatrixWorld(true);
1596
- await sleep(30);
1597
- const frames = opts.settleFrames ?? 12;
1598
- for (let i = 0; i < frames; i++) {
1599
- for (const cb of callbacks) cb(16.7);
1600
- advance(i * 16.7 / 1e3, false, store.getState());
1601
- await sleep(16);
1602
- }
1603
- for (const cb of callbacks) cb(16.7);
1604
- advance(frames * 16.7 / 1e3, false, store.getState());
1605
- const snap = document.createElement("canvas");
1606
- snap.width = canvas.width;
1607
- snap.height = canvas.height;
1608
- snap.getContext("2d")?.drawImage(canvas, 0, 0);
1609
- setPreviewSnapshot(def.type, snap);
1610
- captured.push(def.type);
1611
- } catch (err) {
1612
- console.warn(`ice: preview capture failed for "${def.type}" \u2014 its tile keeps the fallback.`, err);
1613
- }
1614
- await new Promise((r) => {
1615
- const w = window;
1616
- if (w.requestIdleCallback !== void 0) w.requestIdleCallback(() => r(), { timeout: 500 });
1617
- else setTimeout(r, 50);
1618
- });
1619
- }
1620
- } finally {
1621
- root.unmount();
1622
- }
1623
- return captured;
1624
- }
1625
- export {
1626
- CompositeMaterial,
1627
- GLViews,
1628
- Island,
1629
- IslandContext,
1630
- RenderTargetPool,
1631
- ResourceRegistry,
1632
- captureWidgetPreviews,
1633
- createGLBridge,
1634
- createGLPointerRouter,
1635
- createIslandStateStore,
1636
- createRenderWriteTrap,
1637
- runCompositorPass,
1638
- useIslandContext,
1639
- useIslandFrame,
1640
- useIslandInvalidate,
1641
- useIslandLift,
1642
- useIslandOpacity
1643
- };
1644
- //# sourceMappingURL=r3f.js.map