@cimplify/sdk 0.108.0 → 0.110.2

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 (608) hide show
  1. package/LICENSE +21 -0
  2. package/dist/advanced.d.mts +4 -3
  3. package/dist/advanced.d.ts +4 -3
  4. package/dist/advanced.js +24 -24
  5. package/dist/advanced.mjs +5 -5
  6. package/dist/animation-4EXBXRVX.js +27 -0
  7. package/dist/animation-6DICNWUP.mjs +6 -0
  8. package/dist/audio-DhvyjqdA.d.mts +249 -0
  9. package/dist/audio-m0w8cnxq.d.ts +249 -0
  10. package/dist/avatars.d.mts +110 -0
  11. package/dist/avatars.d.ts +110 -0
  12. package/dist/avatars.js +82 -0
  13. package/dist/avatars.mjs +5 -0
  14. package/dist/backend-gUCzs5Kg.d.mts +3866 -0
  15. package/dist/backend-gUCzs5Kg.d.ts +3866 -0
  16. package/dist/{catalogue-B4eLL8Mi.d.ts → catalogue-CPTMyBUz.d.mts} +109 -221
  17. package/dist/catalogue-DzrTXP3v.d.mts +541 -0
  18. package/dist/catalogue-DzrTXP3v.d.ts +541 -0
  19. package/dist/{catalogue-OT89_Ifs.d.mts → catalogue-OTuS5zp-.d.ts} +109 -221
  20. package/dist/chunk-22BD3RHN.mjs +1809 -0
  21. package/dist/chunk-25T4JHEA.mjs +21 -0
  22. package/dist/chunk-2AQ237Y4.js +508 -0
  23. package/dist/chunk-2IC4H6OV.mjs +48 -0
  24. package/dist/chunk-2LHLG4OB.mjs +71 -0
  25. package/dist/chunk-2O2CG465.js +1709 -0
  26. package/dist/chunk-2Q4DTHXK.js +316 -0
  27. package/dist/chunk-2QTQ6BUH.mjs +46 -0
  28. package/dist/chunk-2UN4SFLR.mjs +100 -0
  29. package/dist/chunk-2V75I7K3.js +454 -0
  30. package/dist/chunk-2V7IL4HC.js +10 -0
  31. package/dist/chunk-34XBXUMW.js +296 -0
  32. package/dist/chunk-3C4C654I.js +71 -0
  33. package/dist/chunk-3DAD2LDF.mjs +72 -0
  34. package/dist/chunk-3GXH2NFD.mjs +4 -0
  35. package/dist/chunk-3O47ZFW3.js +961 -0
  36. package/dist/chunk-3OY3VYNF.mjs +11 -0
  37. package/dist/chunk-3S6WPBZL.js +2936 -0
  38. package/dist/chunk-3TUOUP5T.js +399 -0
  39. package/dist/chunk-3VEH23I5.mjs +1380 -0
  40. package/dist/chunk-3ZYSAW2T.mjs +263 -0
  41. package/dist/chunk-4ANVF274.js +103 -0
  42. package/dist/chunk-4C7I3ELN.js +388 -0
  43. package/dist/chunk-4DYKAYFO.mjs +8 -0
  44. package/dist/chunk-4ZDR72SG.js +329 -0
  45. package/dist/chunk-52YS45RR.js +1066 -0
  46. package/dist/chunk-5325XSCH.js +107 -0
  47. package/dist/chunk-5AD5X6AV.js +13 -0
  48. package/dist/chunk-5BYDGGWO.mjs +197 -0
  49. package/dist/chunk-5C3C7VDM.mjs +55 -0
  50. package/dist/chunk-5HFMY3D7.js +660 -0
  51. package/dist/chunk-5LH2QN3T.js +1862 -0
  52. package/dist/chunk-5PJEXSOW.js +44 -0
  53. package/dist/chunk-5SXDH3Y7.js +90 -0
  54. package/dist/chunk-5YFBGGCK.mjs +502 -0
  55. package/dist/chunk-5YWN6H5Q.mjs +133 -0
  56. package/dist/chunk-66QP3SMN.js +402 -0
  57. package/dist/chunk-6DAEZKIG.mjs +385 -0
  58. package/dist/chunk-6DATW7TB.mjs +420 -0
  59. package/dist/{chunk-JRGK3NXR.mjs → chunk-6ETDAU62.mjs} +72 -212
  60. package/dist/chunk-6H254EVP.mjs +178 -0
  61. package/dist/chunk-6PFNJPBJ.mjs +820 -0
  62. package/dist/chunk-6PJWXIFX.mjs +357 -0
  63. package/dist/chunk-6SWKWCMS.js +80 -0
  64. package/dist/chunk-6VVXXX7S.js +808 -0
  65. package/dist/chunk-6WUBSMTX.js +1403 -0
  66. package/dist/chunk-73SGZLAQ.mjs +35 -0
  67. package/dist/chunk-76L2V6KD.mjs +4 -0
  68. package/dist/chunk-7AAIAVAA.js +1531 -0
  69. package/dist/chunk-7ARSJPV3.mjs +93 -0
  70. package/dist/chunk-7BHW5GTC.mjs +1234 -0
  71. package/dist/chunk-7DQSDKDU.js +6 -0
  72. package/dist/chunk-7IQQQENP.mjs +401 -0
  73. package/dist/chunk-7KFTYENS.js +11357 -0
  74. package/dist/chunk-7SM6XSPZ.js +3171 -0
  75. package/dist/chunk-7SXOHAIR.mjs +28 -0
  76. package/dist/chunk-A2MAX6S4.js +90 -0
  77. package/dist/chunk-A33OORT7.mjs +1530 -0
  78. package/dist/{chunk-U6ACF76H.mjs → chunk-A36JRXXH.mjs} +1075 -1845
  79. package/dist/chunk-A7BU3BK4.js +52 -0
  80. package/dist/chunk-A7MQSN2V.mjs +77 -0
  81. package/dist/chunk-A7V4L2IT.mjs +416 -0
  82. package/dist/chunk-AABEK6XU.js +226 -0
  83. package/dist/chunk-AGV33FWC.mjs +5005 -0
  84. package/dist/chunk-AHNR3BXI.js +108 -0
  85. package/dist/chunk-AQ5RLBU2.mjs +286 -0
  86. package/dist/chunk-AQOE6WCG.js +1270 -0
  87. package/dist/chunk-ATAWRACV.mjs +62 -0
  88. package/dist/chunk-ATCURNUV.js +14 -0
  89. package/dist/chunk-AWPV33OO.js +6 -0
  90. package/dist/chunk-AYJPHKYV.js +337 -0
  91. package/dist/chunk-AZ5BGWHB.js +162 -0
  92. package/dist/chunk-AZAXD44P.js +1373 -0
  93. package/dist/chunk-BBGKQIJJ.mjs +406 -0
  94. package/dist/chunk-BP4JLSUA.js +1453 -0
  95. package/dist/{chunk-SUCE7FWA.mjs → chunk-BTUSVHIE.mjs} +539 -978
  96. package/dist/chunk-BU6OK542.mjs +818 -0
  97. package/dist/chunk-CVSRWM6W.js +418 -0
  98. package/dist/chunk-CYBMFMJD.mjs +247 -0
  99. package/dist/chunk-DDJLDOUX.mjs +217 -0
  100. package/dist/{chunk-V32BCG7M.js → chunk-DFZWHNRG.js} +75 -215
  101. package/dist/chunk-DJ2C7AVG.js +644 -0
  102. package/dist/chunk-DS2VU4WW.mjs +102 -0
  103. package/dist/chunk-DSAG7T5P.js +7290 -0
  104. package/dist/chunk-E2QPPH7I.js +327 -0
  105. package/dist/chunk-E65WCTIG.mjs +1187 -0
  106. package/dist/{chunk-33VCYWVL.mjs → chunk-E6QQKDNE.mjs} +30 -42
  107. package/dist/chunk-ECDK6QBF.mjs +981 -0
  108. package/dist/chunk-EIB4OWVQ.mjs +620 -0
  109. package/dist/chunk-EQUZYCGO.js +250 -0
  110. package/dist/chunk-F3UJ6ZRM.mjs +313 -0
  111. package/dist/chunk-F63N2ZTQ.js +7023 -0
  112. package/dist/chunk-F6XRYEM3.mjs +26 -0
  113. package/dist/chunk-FE6VCE4K.js +5030 -0
  114. package/dist/chunk-FLWD6GRR.js +1372 -0
  115. package/dist/chunk-FQBFWJBS.mjs +110 -0
  116. package/dist/chunk-FXVJ2HFU.js +26 -0
  117. package/dist/chunk-FZMQMQBW.js +312 -0
  118. package/dist/chunk-G3EEC44R.js +53 -0
  119. package/dist/{chunk-KG3WT4PR.mjs → chunk-GCKWKLZF.mjs} +73 -104
  120. package/dist/chunk-GCX7TY4D.mjs +6826 -0
  121. package/dist/chunk-GDB6TCSD.js +450 -0
  122. package/dist/chunk-GDCV4IWO.mjs +21 -0
  123. package/dist/chunk-GDZT5LZ5.js +170 -0
  124. package/dist/chunk-GHPUYD4I.mjs +213 -0
  125. package/dist/chunk-GHS6MIL6.mjs +1432 -0
  126. package/dist/chunk-GPS2THCL.mjs +11 -0
  127. package/dist/{chunk-EV2EVOYS.js → chunk-GTJWQAGU.js} +31 -42
  128. package/dist/chunk-GVTI6UJQ.mjs +130 -0
  129. package/dist/chunk-GXKI64OT.mjs +1138 -0
  130. package/dist/chunk-GYDYF2WX.js +275 -0
  131. package/dist/chunk-GYLP6UG4.mjs +705 -0
  132. package/dist/chunk-H3OQKK6X.js +1158 -0
  133. package/dist/chunk-H5DFSCJ6.js +40 -0
  134. package/dist/chunk-HAGEIC2L.mjs +186 -0
  135. package/dist/chunk-HAJ4JRFO.js +293 -0
  136. package/dist/chunk-HDR72GB6.js +188 -0
  137. package/dist/chunk-HF5HPS4T.mjs +40 -0
  138. package/dist/chunk-HK6LOFDS.js +218 -0
  139. package/dist/chunk-HMWYTXCY.mjs +143 -0
  140. package/dist/chunk-HPCSRCMA.js +89 -0
  141. package/dist/chunk-HSEO6TPU.js +247 -0
  142. package/dist/chunk-I5FOHCLH.js +132 -0
  143. package/dist/chunk-IDLW4NWA.mjs +85 -0
  144. package/dist/chunk-IIDZ5WUX.js +61 -0
  145. package/dist/chunk-IR74FJHU.js +2332 -0
  146. package/dist/chunk-IRVFYAKP.mjs +100 -0
  147. package/dist/{chunk-XBL3TMPC.mjs → chunk-IZDWAL53.mjs} +1795 -3287
  148. package/dist/chunk-J2KZXIU3.js +51 -0
  149. package/dist/chunk-J2U6PJSO.js +91 -0
  150. package/dist/chunk-J5AJNY2N.js +283 -0
  151. package/dist/chunk-J6KQZ4FO.mjs +821 -0
  152. package/dist/{chunk-OWW5GUSB.js → chunk-JGBCIKJV.js} +7 -6
  153. package/dist/chunk-JKGTBMU7.mjs +25 -0
  154. package/dist/chunk-JR3TNEQC.js +422 -0
  155. package/dist/chunk-JURRXY2J.mjs +29 -0
  156. package/dist/chunk-K3HW5I2A.mjs +317 -0
  157. package/dist/chunk-K46SMZ66.mjs +103 -0
  158. package/dist/chunk-K4UDGE3Z.mjs +6 -0
  159. package/dist/chunk-KDQOR4QQ.mjs +350 -0
  160. package/dist/chunk-KDTVOLHI.mjs +288 -0
  161. package/dist/chunk-KGHJH5KJ.mjs +35 -0
  162. package/dist/chunk-KIZOA5LX.mjs +140 -0
  163. package/dist/chunk-KK6HYVBI.mjs +242 -0
  164. package/dist/chunk-KMKWGXMK.js +856 -0
  165. package/dist/chunk-KPA6K5IB.js +80 -0
  166. package/dist/chunk-KU7O4IXU.mjs +260 -0
  167. package/dist/chunk-KVFNRJOR.mjs +11142 -0
  168. package/dist/chunk-KZJRSXHK.js +2432 -0
  169. package/dist/chunk-LHWPRUJL.js +79 -0
  170. package/dist/chunk-LIV3KXJG.mjs +369 -0
  171. package/dist/chunk-LKV4LACG.js +21 -0
  172. package/dist/chunk-LUY45X3U.mjs +263 -0
  173. package/dist/chunk-LYEZZEEF.mjs +17 -0
  174. package/dist/chunk-M5EXQZYY.mjs +1519 -0
  175. package/dist/chunk-ME6HGG4I.mjs +1338 -0
  176. package/dist/chunk-MEXP6DA6.js +31 -0
  177. package/dist/chunk-MG52AW3H.js +902 -0
  178. package/dist/chunk-MIPO6F72.js +334 -0
  179. package/dist/{chunk-5QW7CQBA.js → chunk-MKIJQL5Q.js} +211 -321
  180. package/dist/chunk-MN3YETVN.mjs +17 -0
  181. package/dist/chunk-MOBSBXVE.mjs +2391 -0
  182. package/dist/chunk-MOMOZEUM.mjs +88 -0
  183. package/dist/chunk-MRFUNRAP.js +62 -0
  184. package/dist/chunk-MTIHEW2M.js +433 -0
  185. package/dist/chunk-N4RGGDEL.mjs +73 -0
  186. package/dist/chunk-NH654HAT.js +10 -0
  187. package/dist/chunk-NHJUGZUR.mjs +253 -0
  188. package/dist/chunk-NMQT4HG3.mjs +757 -0
  189. package/dist/chunk-NPSYB6DC.mjs +906 -0
  190. package/dist/chunk-NW2GPMSO.js +857 -0
  191. package/dist/chunk-NXKQOQ6L.js +76 -0
  192. package/dist/chunk-NXLAZIJZ.js +309 -0
  193. package/dist/chunk-NYWNA5CF.js +148 -0
  194. package/dist/chunk-NZTKLY2W.js +1442 -0
  195. package/dist/chunk-O2ICABUD.js +36 -0
  196. package/dist/chunk-OIVVQQ22.js +862 -0
  197. package/dist/chunk-OKC2B4O3.mjs +312 -0
  198. package/dist/chunk-OLWFPDBK.js +2220 -0
  199. package/dist/chunk-OMTVH334.js +3779 -0
  200. package/dist/chunk-OQRVEM56.mjs +362 -0
  201. package/dist/chunk-OXMIBOD4.js +337 -0
  202. package/dist/chunk-PBL6YL5L.mjs +288 -0
  203. package/dist/chunk-PDOELNNQ.js +97 -0
  204. package/dist/chunk-PDQJY2GZ.js +136 -0
  205. package/dist/chunk-PKOZXD2Q.js +1274 -0
  206. package/dist/chunk-PPF2BYFL.mjs +2191 -0
  207. package/dist/chunk-PQTQKNKD.js +539 -0
  208. package/dist/chunk-PRSR4FAV.mjs +81 -0
  209. package/dist/chunk-PTRNO5UD.js +95 -0
  210. package/dist/chunk-Q2Y3VMKH.js +2000 -0
  211. package/dist/chunk-QCZOE65N.js +96 -0
  212. package/dist/chunk-QDYFLATW.mjs +52 -0
  213. package/dist/chunk-QQABGCMM.js +22 -0
  214. package/dist/chunk-QS6TRHMR.js +345 -0
  215. package/dist/chunk-R56P64LB.mjs +208 -0
  216. package/dist/chunk-RCQ2MPBV.js +428 -0
  217. package/dist/chunk-RFVRPYR2.mjs +856 -0
  218. package/dist/chunk-RKBLPGPV.js +11521 -0
  219. package/dist/chunk-RM2V4IND.mjs +327 -0
  220. package/dist/chunk-RQXN5A34.mjs +613 -0
  221. package/dist/chunk-RUVGVNOF.mjs +2687 -0
  222. package/dist/chunk-SAFJIGYB.mjs +165 -0
  223. package/dist/chunk-SKQFLBDD.js +263 -0
  224. package/dist/chunk-SMK6JU2F.mjs +2092 -0
  225. package/dist/{chunk-UVRPC2P7.js → chunk-SNNEOS5Z.js} +1984 -3476
  226. package/dist/chunk-SPCRQ6NO.mjs +1246 -0
  227. package/dist/chunk-SWX4SALA.mjs +19 -0
  228. package/dist/{chunk-JVODCGFP.mjs → chunk-SYEO2WV4.mjs} +128 -238
  229. package/dist/chunk-T2QQMX2N.js +10 -0
  230. package/dist/chunk-T3AFF3L7.mjs +57 -0
  231. package/dist/chunk-T6Z2EXYL.js +712 -0
  232. package/dist/chunk-T7LOXGYX.js +118 -0
  233. package/dist/chunk-TJCAE7RC.mjs +1315 -0
  234. package/dist/chunk-TJI3K6RP.js +137 -0
  235. package/dist/chunk-TL2SVO4P.mjs +55 -0
  236. package/dist/chunk-TM63CYGN.mjs +399 -0
  237. package/dist/chunk-TU5RYTYU.mjs +13 -0
  238. package/dist/chunk-TVJZ4GPS.js +1553 -0
  239. package/dist/chunk-TWM6DLYF.js +371 -0
  240. package/dist/chunk-U63OC4TQ.js +30 -0
  241. package/dist/{chunk-L5GKVQVJ.js → chunk-U6BVSJZ6.js} +25 -57
  242. package/dist/chunk-U6UVWEAK.mjs +792 -0
  243. package/dist/chunk-UCEPNO6N.mjs +11048 -0
  244. package/dist/{chunk-ANT574FD.js → chunk-UCR5HRYM.js} +74 -105
  245. package/dist/chunk-UG5BTOTF.mjs +334 -0
  246. package/dist/chunk-UGH37BQW.mjs +157 -0
  247. package/dist/chunk-V7ZRH3PY.mjs +271 -0
  248. package/dist/chunk-VBGHBL3E.mjs +1394 -0
  249. package/dist/chunk-VRBDAS5I.js +920 -0
  250. package/dist/chunk-VVE3Y76O.js +230 -0
  251. package/dist/chunk-W65JIRI4.mjs +1182 -0
  252. package/dist/chunk-WHYKAT7G.js +62 -0
  253. package/dist/{chunk-YOIVZ6OA.mjs → chunk-WIZRUIZB.mjs} +25 -57
  254. package/dist/chunk-WKWTDZS7.js +385 -0
  255. package/dist/chunk-WLMINRC4.mjs +78 -0
  256. package/dist/chunk-WOF3AD3J.js +22 -0
  257. package/dist/chunk-WWKMOA76.js +1262 -0
  258. package/dist/chunk-X5A5FOWW.js +615 -0
  259. package/dist/chunk-X6CN6KQF.mjs +192 -0
  260. package/dist/chunk-XD2PMH46.mjs +517 -0
  261. package/dist/chunk-XJA2NGTI.mjs +88 -0
  262. package/dist/chunk-XJIHN3BY.mjs +8 -0
  263. package/dist/chunk-XK6UDWJS.js +203 -0
  264. package/dist/chunk-XPG3N5CF.mjs +415 -0
  265. package/dist/chunk-XVZ2NKSU.mjs +74 -0
  266. package/dist/chunk-XYP45OLE.js +117 -0
  267. package/dist/chunk-XZSDGZX6.mjs +301 -0
  268. package/dist/chunk-Y2EMGN4T.mjs +120 -0
  269. package/dist/chunk-Y3XWP5XW.mjs +298 -0
  270. package/dist/chunk-Y4K22JL6.js +228 -0
  271. package/dist/chunk-Y65LXQGA.mjs +3164 -0
  272. package/dist/chunk-Y66WVMO5.mjs +87 -0
  273. package/dist/chunk-Y7JWLB25.mjs +7280 -0
  274. package/dist/chunk-YCDXAJKU.js +175 -0
  275. package/dist/chunk-YRDQCCIS.js +152 -0
  276. package/dist/chunk-YV52DGSA.js +111 -0
  277. package/dist/chunk-YXGZQPUD.js +94 -0
  278. package/dist/chunk-Z3A3AFVU.mjs +102 -0
  279. package/dist/chunk-ZCY6YKKP.mjs +475 -0
  280. package/dist/chunk-ZEQHXVU5.js +215 -0
  281. package/dist/chunk-ZF7JCXCI.js +284 -0
  282. package/dist/chunk-ZJBRUH6V.js +29 -0
  283. package/dist/chunk-ZMIL4ZOA.js +365 -0
  284. package/dist/chunk-ZR5ULMN2.mjs +337 -0
  285. package/dist/chunk-ZXREOYOW.js +87 -0
  286. package/dist/{client-BSP9U1O1.d.mts → client-CX_WR0-J.d.mts} +2 -2
  287. package/dist/client-Dytx_ZTC.d.ts +230 -0
  288. package/dist/{client-B878xeAP.d.ts → client-dqOhP9Nc.d.ts} +2 -2
  289. package/dist/client-hTKbCuhG.d.mts +230 -0
  290. package/dist/clock-B-UAjkKa.d.mts +5 -0
  291. package/dist/clock-B-UAjkKa.d.ts +5 -0
  292. package/dist/config-BlXQluJR.d.mts +36 -0
  293. package/dist/config-BlXQluJR.d.ts +36 -0
  294. package/dist/courier-Cnn-edJ4.d.ts +95 -0
  295. package/dist/courier-FmGfkvIN.d.mts +95 -0
  296. package/dist/crowd-DdHFbqKK.d.ts +186 -0
  297. package/dist/crowd-hOVSAmA3.d.mts +186 -0
  298. package/dist/danfo-BEBapFlX.d.mts +146 -0
  299. package/dist/danfo-UQ_PTIIx.d.ts +146 -0
  300. package/dist/{elements-Bty6Qs_N.d.mts → elements-DdsRig-2.d.mts} +1548 -257
  301. package/dist/{elements-Bty6Qs_N.d.ts → elements-DdsRig-2.d.ts} +1548 -257
  302. package/dist/engines/godot.d.mts +56 -0
  303. package/dist/engines/godot.d.ts +56 -0
  304. package/dist/engines/godot.js +28 -0
  305. package/dist/engines/godot.mjs +3 -0
  306. package/dist/engines/wasm.d.mts +11 -0
  307. package/dist/engines/wasm.d.ts +11 -0
  308. package/dist/engines/wasm.js +178 -0
  309. package/dist/engines/wasm.mjs +176 -0
  310. package/dist/fallback-CrG_lTFk.d.mts +270 -0
  311. package/dist/fallback-CrG_lTFk.d.ts +270 -0
  312. package/dist/fallback-KDB4Y2CE.mjs +6 -0
  313. package/dist/fallback-Y26TQENE.js +19 -0
  314. package/dist/features-CZB4rmcD.d.mts +118 -0
  315. package/dist/features-CZB4rmcD.d.ts +118 -0
  316. package/dist/fit-BWiE7rgA.d.mts +44 -0
  317. package/dist/fit-DK0oT7zO.d.ts +44 -0
  318. package/dist/five-a-side-Bv1AOUy3.d.mts +115 -0
  319. package/dist/five-a-side-EC51SJY1.d.ts +115 -0
  320. package/dist/fluid-ARr0qUIL.d.ts +939 -0
  321. package/dist/fluid-DLlEj2cs.d.mts +939 -0
  322. package/dist/game/conformance.d.mts +84 -0
  323. package/dist/game/conformance.d.ts +84 -0
  324. package/dist/game/conformance.js +1025 -0
  325. package/dist/game/conformance.mjs +994 -0
  326. package/dist/game/heap.d.mts +40 -0
  327. package/dist/game/heap.d.ts +40 -0
  328. package/dist/game/heap.js +48 -0
  329. package/dist/game/heap.mjs +7 -0
  330. package/dist/game/kit/canvas.d.mts +240 -0
  331. package/dist/game/kit/canvas.d.ts +240 -0
  332. package/dist/game/kit/canvas.js +3566 -0
  333. package/dist/game/kit/canvas.mjs +1039 -0
  334. package/dist/game/kit/courier.d.mts +17 -0
  335. package/dist/game/kit/courier.d.ts +17 -0
  336. package/dist/game/kit/courier.js +66 -0
  337. package/dist/game/kit/courier.mjs +49 -0
  338. package/dist/game/kit/danfo.d.mts +11 -0
  339. package/dist/game/kit/danfo.d.ts +11 -0
  340. package/dist/game/kit/danfo.js +109 -0
  341. package/dist/game/kit/danfo.mjs +44 -0
  342. package/dist/game/kit/engine.d.mts +29 -0
  343. package/dist/game/kit/engine.d.ts +29 -0
  344. package/dist/game/kit/engine.js +183 -0
  345. package/dist/game/kit/engine.mjs +30 -0
  346. package/dist/game/kit/five-a-side.d.mts +11 -0
  347. package/dist/game/kit/five-a-side.d.ts +11 -0
  348. package/dist/game/kit/five-a-side.js +86 -0
  349. package/dist/game/kit/five-a-side.mjs +41 -0
  350. package/dist/game/kit/frontier.d.mts +344 -0
  351. package/dist/game/kit/frontier.d.ts +344 -0
  352. package/dist/game/kit/frontier.js +435 -0
  353. package/dist/game/kit/frontier.mjs +14 -0
  354. package/dist/game/kit/genesis.d.mts +752 -0
  355. package/dist/game/kit/genesis.d.ts +752 -0
  356. package/dist/game/kit/genesis.js +380 -0
  357. package/dist/game/kit/genesis.mjs +15 -0
  358. package/dist/game/kit/ludo.d.mts +15 -0
  359. package/dist/game/kit/ludo.d.ts +15 -0
  360. package/dist/game/kit/ludo.js +87 -0
  361. package/dist/game/kit/ludo.mjs +42 -0
  362. package/dist/game/kit/runner.d.mts +12 -0
  363. package/dist/game/kit/runner.d.ts +12 -0
  364. package/dist/game/kit/runner.js +83 -0
  365. package/dist/game/kit/runner.mjs +46 -0
  366. package/dist/game/kit/shootout.d.mts +13 -0
  367. package/dist/game/kit/shootout.d.ts +13 -0
  368. package/dist/game/kit/shootout.js +122 -0
  369. package/dist/game/kit/shootout.mjs +57 -0
  370. package/dist/game/kit/slots.d.mts +392 -0
  371. package/dist/game/kit/slots.d.ts +392 -0
  372. package/dist/game/kit/slots.js +215 -0
  373. package/dist/game/kit/slots.mjs +6 -0
  374. package/dist/game/kit/tycoon.d.mts +16 -0
  375. package/dist/game/kit/tycoon.d.ts +16 -0
  376. package/dist/game/kit/tycoon.js +145 -0
  377. package/dist/game/kit/tycoon.mjs +44 -0
  378. package/dist/game/kit/word.d.mts +11 -0
  379. package/dist/game/kit/word.d.ts +11 -0
  380. package/dist/game/kit/word.js +78 -0
  381. package/dist/game/kit/word.mjs +41 -0
  382. package/dist/game/kit/worlds.d.mts +18 -0
  383. package/dist/game/kit/worlds.d.ts +18 -0
  384. package/dist/game/kit/worlds.js +74 -0
  385. package/dist/game/kit/worlds.mjs +49 -0
  386. package/dist/game/kit.d.mts +53 -0
  387. package/dist/game/kit.d.ts +53 -0
  388. package/dist/game/kit.js +2610 -0
  389. package/dist/game/kit.mjs +101 -0
  390. package/dist/game/prepared.d.mts +14 -0
  391. package/dist/game/prepared.d.ts +14 -0
  392. package/dist/game/prepared.js +81 -0
  393. package/dist/game/prepared.mjs +32 -0
  394. package/dist/game-Bx8onkhX.d.mts +1451 -0
  395. package/dist/game-fgQy2YIm.d.ts +1451 -0
  396. package/dist/game-theme-CBTw1b_d.d.mts +35 -0
  397. package/dist/game-theme-Dg-ict5A.d.ts +35 -0
  398. package/dist/game.d.mts +3546 -0
  399. package/dist/game.d.ts +3546 -0
  400. package/dist/game.js +4455 -0
  401. package/dist/game.mjs +50 -0
  402. package/dist/graphics-C6YjWYvP.d.ts +5 -0
  403. package/dist/graphics-Dk2yQnYN.d.mts +5 -0
  404. package/dist/guest-DrsA00XD.d.mts +732 -0
  405. package/dist/guest-wIdfoT05.d.ts +732 -0
  406. package/dist/hit-stop-BKkVwTq7.d.mts +43 -0
  407. package/dist/hit-stop-D-8pPYnM.d.ts +43 -0
  408. package/dist/hot-Crn9XpHJ.d.ts +29 -0
  409. package/dist/hot-DH3nOhQD.d.mts +29 -0
  410. package/dist/{index-CQStGb3B.d.mts → index-6gkHMGAq.d.mts} +2 -2
  411. package/dist/index-B8ybCKJI.d.ts +41 -0
  412. package/dist/{index-DJwXmoaP.d.ts → index-B98Xac8e.d.ts} +2 -2
  413. package/dist/{index-B7oA_1XI.d.ts → index-B_ByTtIT.d.ts} +2 -2
  414. package/dist/index-DHjNHb1c.d.mts +41 -0
  415. package/dist/{index-DhUSTAhT.d.mts → index-DbAN_VQE.d.mts} +2 -2
  416. package/dist/index.d.mts +134 -24
  417. package/dist/index.d.ts +134 -24
  418. package/dist/index.js +407 -248
  419. package/dist/index.mjs +184 -58
  420. package/dist/interactives-authoring.d.mts +231 -0
  421. package/dist/interactives-authoring.d.ts +231 -0
  422. package/dist/interactives-authoring.js +1743 -0
  423. package/dist/interactives-authoring.mjs +1704 -0
  424. package/dist/interactives-canvas.global.js +148 -0
  425. package/dist/interactives-guest.d.mts +20 -0
  426. package/dist/interactives-guest.d.ts +20 -0
  427. package/dist/interactives-guest.js +63 -0
  428. package/dist/interactives-guest.json +1 -0
  429. package/dist/interactives-guest.mjs +61 -0
  430. package/dist/interactives-jsc.global.js +9357 -0
  431. package/dist/interactives-meters.d.mts +93 -0
  432. package/dist/interactives-meters.d.ts +93 -0
  433. package/dist/interactives-meters.js +252 -0
  434. package/dist/interactives-meters.mjs +68 -0
  435. package/dist/interactives-production.d.mts +430 -0
  436. package/dist/interactives-production.d.ts +430 -0
  437. package/dist/interactives-production.js +1231 -0
  438. package/dist/interactives-production.mjs +1170 -0
  439. package/dist/interactives-record.d.mts +112 -0
  440. package/dist/interactives-record.d.ts +112 -0
  441. package/dist/interactives-record.js +302 -0
  442. package/dist/interactives-record.mjs +295 -0
  443. package/dist/interactives-runtime.d.mts +61 -0
  444. package/dist/interactives-runtime.d.ts +61 -0
  445. package/dist/interactives-runtime.js +442 -0
  446. package/dist/interactives-runtime.mjs +25 -0
  447. package/dist/interactives-studio-kernel.global.js +1 -0
  448. package/dist/interactives-studio.d.mts +806 -0
  449. package/dist/interactives-studio.d.ts +806 -0
  450. package/dist/interactives-studio.js +5741 -0
  451. package/dist/interactives-studio.mjs +5651 -0
  452. package/dist/interactives-tick.d.mts +90 -0
  453. package/dist/interactives-tick.d.ts +90 -0
  454. package/dist/interactives-tick.js +203 -0
  455. package/dist/interactives-tick.mjs +6 -0
  456. package/dist/interactives-web.d.mts +762 -0
  457. package/dist/interactives-web.d.ts +762 -0
  458. package/dist/interactives-web.js +5000 -0
  459. package/dist/interactives-web.mjs +4628 -0
  460. package/dist/interactives.d.mts +2430 -0
  461. package/dist/interactives.d.ts +2430 -0
  462. package/dist/interactives.js +5723 -0
  463. package/dist/interactives.mjs +4333 -0
  464. package/dist/juice-CoHxlpKA.d.ts +42 -0
  465. package/dist/juice-DQztFS43.d.mts +42 -0
  466. package/dist/launch-T2f4_Di4.d.mts +151 -0
  467. package/dist/launch-d6oreMzR.d.ts +151 -0
  468. package/dist/library-DXYaMFhi.d.mts +69 -0
  469. package/dist/library-DXYaMFhi.d.ts +69 -0
  470. package/dist/link-BUTqGmyi.d.mts +38 -0
  471. package/dist/link-BUTqGmyi.d.ts +38 -0
  472. package/dist/lint.js +104 -204
  473. package/dist/lint.mjs +103 -203
  474. package/dist/local-D8_I6UeL.d.mts +6967 -0
  475. package/dist/local-VZkqsCzR.d.ts +6967 -0
  476. package/dist/lockstep-BLf6dglI.d.mts +321 -0
  477. package/dist/lockstep-D50Ia0JW.d.ts +321 -0
  478. package/dist/ludo-B8ClkDqr.d.ts +205 -0
  479. package/dist/ludo-BOuohQ-M.d.mts +205 -0
  480. package/dist/mock/cli.mjs +200 -56
  481. package/dist/mock/library.js +200 -56
  482. package/dist/mock/library.mjs +200 -56
  483. package/dist/mock/msw.js +200 -56
  484. package/dist/mock/msw.mjs +200 -56
  485. package/dist/native-BodxSh03.d.mts +16 -0
  486. package/dist/native-DUHMT8gA.d.ts +16 -0
  487. package/dist/network-ZXLD7l1b.d.mts +19 -0
  488. package/dist/network-ZXLD7l1b.d.ts +19 -0
  489. package/dist/online-XeymeM9s.d.ts +381 -0
  490. package/dist/online-d7W_Al9a.d.mts +381 -0
  491. package/dist/params-DxFb5G_U.d.mts +155 -0
  492. package/dist/params-DxFb5G_U.d.ts +155 -0
  493. package/dist/play-BRRlfLhX.d.ts +940 -0
  494. package/dist/play-ClrMd_e8.d.mts +940 -0
  495. package/dist/policy-CCw8tXLm.d.mts +3078 -0
  496. package/dist/policy-CMqOSQIu.d.ts +3078 -0
  497. package/dist/ports-B_0v_P3A.d.mts +13 -0
  498. package/dist/ports-CGU_3e_0.d.ts +13 -0
  499. package/dist/prefetch-BHnicOQj.d.ts +117 -0
  500. package/dist/prefetch-CBXgYacv.d.mts +117 -0
  501. package/dist/{price-CSztR02F.d.mts → price-BOzexBww.d.mts} +1 -1
  502. package/dist/{price-C_vasx9A.d.ts → price-C1h9sPxE.d.ts} +1 -1
  503. package/dist/protocol-C8qbpUbT.d.mts +242 -0
  504. package/dist/protocol-C8qbpUbT.d.ts +242 -0
  505. package/dist/rapier-AZHT4YI7.js +7886 -0
  506. package/dist/rapier-ODEPCQA6.mjs +7792 -0
  507. package/dist/react.d.mts +157 -15
  508. package/dist/react.d.ts +157 -15
  509. package/dist/react.js +5564 -5904
  510. package/dist/react.mjs +5451 -5808
  511. package/dist/runner-CQcLL7By.d.ts +189 -0
  512. package/dist/runner-D46Yj-wE.d.mts +189 -0
  513. package/dist/runtime-BRWfkf_q.d.mts +51 -0
  514. package/dist/runtime-DyuBMkKM.d.ts +51 -0
  515. package/dist/scheduling-D2ajXpMC.d.ts +224 -0
  516. package/dist/scheduling-DSRbbaZb.d.mts +224 -0
  517. package/dist/schema-BrWxzKp6.d.mts +63 -0
  518. package/dist/schema-BrWxzKp6.d.ts +63 -0
  519. package/dist/server/evict.js +34 -37
  520. package/dist/server/evict.mjs +34 -37
  521. package/dist/server/tanstack.d.mts +49 -3
  522. package/dist/server/tanstack.d.ts +49 -3
  523. package/dist/server/tanstack.js +169 -117
  524. package/dist/server/tanstack.mjs +166 -118
  525. package/dist/{server-Dckg4Vdr.d.ts → server-D29IIuDV.d.ts} +136 -130
  526. package/dist/{server-B6dW7-Lj.d.mts → server-DQMWPnc8.d.mts} +136 -130
  527. package/dist/server.d.mts +45 -5
  528. package/dist/server.d.ts +45 -5
  529. package/dist/server.js +171 -227
  530. package/dist/server.mjs +165 -225
  531. package/dist/session-grant-CJ27DwrT.d.mts +19 -0
  532. package/dist/session-grant-CJ27DwrT.d.ts +19 -0
  533. package/dist/shootout-BJZeX6FG.d.ts +140 -0
  534. package/dist/shootout-tcZd1Rxt.d.mts +140 -0
  535. package/dist/state-replica-stMtdkVD.d.mts +42 -0
  536. package/dist/state-replica-stMtdkVD.d.ts +42 -0
  537. package/dist/studio-CowqWqez.d.mts +14 -0
  538. package/dist/studio-CowqWqez.d.ts +14 -0
  539. package/dist/styles.css +1 -1
  540. package/dist/template-AhCdB1kW.d.mts +190 -0
  541. package/dist/template-BkEGVTQj.d.ts +190 -0
  542. package/dist/terrain-BMxEc6Oc.d.ts +429 -0
  543. package/dist/terrain-C-XC1Oui.d.mts +429 -0
  544. package/dist/testing/msw.d.mts +28 -4
  545. package/dist/testing/msw.d.ts +28 -4
  546. package/dist/testing/msw.js +15 -21
  547. package/dist/testing/msw.mjs +15 -21
  548. package/dist/testing/suite.d.mts +6 -5
  549. package/dist/testing/suite.d.ts +6 -5
  550. package/dist/testing/suite.js +89 -124
  551. package/dist/testing/suite.mjs +81 -116
  552. package/dist/testing.d.mts +27 -1227
  553. package/dist/testing.d.ts +27 -1227
  554. package/dist/testing.js +127 -131
  555. package/dist/testing.mjs +19 -23
  556. package/dist/tick-transport-C8QEh8Uw.d.mts +50 -0
  557. package/dist/tick-transport-UjHY3xK1.d.ts +50 -0
  558. package/dist/timeline-protocol-hp6e8zFB.d.mts +47 -0
  559. package/dist/timeline-protocol-hp6e8zFB.d.ts +47 -0
  560. package/dist/tokens-DhanQRQS.d.mts +21 -0
  561. package/dist/tokens-K8yxwd6G.d.ts +21 -0
  562. package/dist/tree-C-Io2Hbx.d.mts +35 -0
  563. package/dist/tree-CP_qSW4H.d.ts +35 -0
  564. package/dist/tycoon-B5KHk2Xx.d.mts +255 -0
  565. package/dist/tycoon-hmHo-3HX.d.ts +255 -0
  566. package/dist/types-BQkxPwZP.d.mts +219 -0
  567. package/dist/types-D_f6UUxM.d.ts +219 -0
  568. package/dist/ui-DwHicuFv.d.mts +563 -0
  569. package/dist/ui-hi7S2YcH.d.ts +563 -0
  570. package/dist/{sign-in-DQlIdqsi.d.mts → url-52ndUruG.d.mts} +15 -1
  571. package/dist/{sign-in-DQlIdqsi.d.ts → url-52ndUruG.d.ts} +15 -1
  572. package/dist/utils.d.mts +3 -3
  573. package/dist/utils.d.ts +3 -3
  574. package/dist/utils.js +37 -37
  575. package/dist/utils.mjs +4 -4
  576. package/dist/vars-Dc_PrhBK.d.mts +511 -0
  577. package/dist/vars-Dc_PrhBK.d.ts +511 -0
  578. package/dist/vm-IUARFFAI.mjs +63 -0
  579. package/dist/vm-N7L6MGGH.js +65 -0
  580. package/dist/weave-delivery-CW-Kstut.d.mts +360 -0
  581. package/dist/weave-delivery-CW-Kstut.d.ts +360 -0
  582. package/dist/web-Dss74a7v.d.ts +883 -0
  583. package/dist/web-f9ZQPoyw.d.mts +883 -0
  584. package/dist/web-transport-C7MkBL0a.d.ts +19 -0
  585. package/dist/web-transport-aYEqXMd9.d.mts +19 -0
  586. package/dist/weight-CPGjsgjV.d.ts +92 -0
  587. package/dist/weight-tF1ODR1p.d.mts +92 -0
  588. package/dist/word-BcX9Jcmv.d.mts +70 -0
  589. package/dist/word-C7sVPLHm.d.ts +70 -0
  590. package/dist/world-PvILHDR1.d.ts +2285 -0
  591. package/dist/world-qekkXjJv.d.mts +2285 -0
  592. package/dist/worlds-Br2Pb0Cs.d.ts +109 -0
  593. package/dist/worlds-D5ydYr7d.d.mts +109 -0
  594. package/engines/c/cimplify.h +108 -0
  595. package/engines/c/cimplify.lib.js +11 -0
  596. package/engines/godot/addons/cimplify/cimplify.gd +97 -0
  597. package/engines/rust/interactives-ctx/Cargo.toml +9 -0
  598. package/engines/rust/interactives-ctx/src/lib.rs +189 -0
  599. package/package.json +189 -3
  600. package/vendor/rapier3d-compat/LICENSE +201 -0
  601. package/vendor/rapier3d-compat/PATCHES.md +61 -0
  602. package/dist/chunk-2P4KXFB6.js +0 -274
  603. package/dist/chunk-3G6RQLXK.mjs +0 -21
  604. package/dist/chunk-3V4DVXV3.mjs +0 -254
  605. package/dist/chunk-EDK3LNM6.js +0 -2436
  606. package/dist/chunk-F7J3HK27.js +0 -4549
  607. package/dist/chunk-U4MW6PYU.mjs +0 -23
  608. package/dist/chunk-XREIZ56K.js +0 -26
@@ -0,0 +1,620 @@
1
+ import { dataTables, hasData, COMPUTE_SPACE_GPU, writeWideArg, COMPUTE_DEFERRED, routeEvents } from './chunk-E65WCTIG.mjs';
2
+ import { Op, crossRow, XOP, stageEnds, RING_HEADER_WORDS, DEFAULT_EVENT_CAPACITY, XOP_GATHER, XOP_FIELD, DATA_TABLES } from './chunk-SMK6JU2F.mjs';
3
+ import { GameError } from './chunk-XJIHN3BY.mjs';
4
+
5
+ // src/game/kernel/route.ts
6
+ var GPU_DEVICE_CLASSES = ["unknown", "mobile", "desktop", "discrete"], CPU_BACKENDS = ["interpreter", "cranelift", "wasm"];
7
+ var PRESSURE_SCALE = [64, 44, 28], MIN_JOB_TILES = 4, LANE_GAIN = 3, LANE_UNIT = 4, MOBILE_SCALE = 5, MOBILE_UNIT = 4, DESKTOP_CPU = {
8
+ interpreter: { op: 47, pair: 12e3, math: 3e3, gridRow: 2e4, launch: 5e6 },
9
+ cranelift: { op: 40, pair: 12e3, math: 3400, gridRow: 2e4, launch: 5e6 },
10
+ wasm: { op: 30, pair: 8e3, math: 3500, gridRow: 25e3, launch: 0 }
11
+ };
12
+ function mobile(c) {
13
+ let m = (v) => Math.floor(v * (5) / (4));
14
+ return { op: m(c.op), pair: m(c.pair), math: m(c.math), gridRow: m(c.gridRow), launch: m(c.launch) };
15
+ }
16
+ var MOBILE_CPU = { interpreter: mobile(DESKTOP_CPU.interpreter), cranelift: mobile(DESKTOP_CPU.cranelift), wasm: mobile(DESKTOP_CPU.wasm) }, DESKTOP_GPU = {
17
+ setFixed: 9e8,
18
+ setOp: 1,
19
+ gather: 1,
20
+ launch: 4e7,
21
+ batchedLaunch: 3e7,
22
+ stage: 1e7,
23
+ grid: 15e7,
24
+ op: 5,
25
+ pair: 25,
26
+ math: 700,
27
+ uploadWord: 80,
28
+ sync: 1e8,
29
+ readbackWord: 50,
30
+ enter: 51,
31
+ leave: 70
32
+ }, DISCRETE_GPU = {
33
+ setFixed: 1e9,
34
+ setOp: 1,
35
+ gather: 1,
36
+ launch: 5e7,
37
+ batchedLaunch: 38e6,
38
+ stage: 1e7,
39
+ grid: 12e7,
40
+ op: 2,
41
+ pair: 10,
42
+ math: 300,
43
+ uploadWord: 300,
44
+ sync: 2e8,
45
+ readbackWord: 300,
46
+ enter: 51,
47
+ leave: 70
48
+ }, MOBILE_GPU = {
49
+ setFixed: 12e8,
50
+ setOp: 3,
51
+ gather: 3,
52
+ launch: 35e6,
53
+ batchedLaunch: 25e6,
54
+ stage: 15e6,
55
+ grid: 2e8,
56
+ op: 12,
57
+ pair: 60,
58
+ math: 1700,
59
+ uploadWord: 120,
60
+ sync: 15e7,
61
+ readbackWord: 90,
62
+ enter: 48,
63
+ leave: 70
64
+ };
65
+ function cpuCosts(machine) {
66
+ let family = machine.class === "desktop" || machine.class === "discrete" ? DESKTOP_CPU : MOBILE_CPU;
67
+ return family[machine.backend] ?? family.interpreter;
68
+ }
69
+ function gpuCosts(device) {
70
+ return device === "desktop" ? DESKTOP_GPU : device === "discrete" ? DISCRETE_GPU : MOBILE_GPU;
71
+ }
72
+ var V8_AGENT = /Chrome\/|Chromium\/|Edg\//, JSC_AGENT = /AppleWebKit\//, detectedEngine = null;
73
+ function detectEngine() {
74
+ let g = globalThis;
75
+ if (g.HermesInternal !== void 0) return "jsc-nojit";
76
+ let versions = g.process?.versions;
77
+ if (versions?.bun !== void 0) return "jsc";
78
+ if (versions?.v8 !== void 0) return "v8";
79
+ let agent = g.navigator?.userAgent;
80
+ return typeof agent == "string" ? V8_AGENT.test(agent) ? "v8" : JSC_AGENT.test(agent) ? "jsc" : "v8" : "jsc-nojit";
81
+ }
82
+ var WASM_PROBE = Uint8Array.from([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 127, 3, 2, 1, 0, 7, 5, 1, 1, 102, 0, 0, 10, 6, 1, 4, 0, 65, 42, 11]), WASM_PROBE_RESULT = 42, wasmWorks = null;
83
+ function wasmInstantiates() {
84
+ if (wasmWorks !== null) return wasmWorks;
85
+ let wasm = globalThis.WebAssembly;
86
+ try {
87
+ let run = wasm === void 0 ? null : new wasm.Instance(new wasm.Module(WASM_PROBE)).exports.f;
88
+ wasmWorks = typeof run == "function" && run() === (42);
89
+ } catch {
90
+ wasmWorks = false;
91
+ }
92
+ return wasmWorks;
93
+ }
94
+ function hostEngine() {
95
+ return (detectedEngine ?? (detectedEngine = detectEngine()), detectedEngine);
96
+ }
97
+ function gpuDeviceClass(code) {
98
+ return GPU_DEVICE_CLASSES[code] ?? "unknown";
99
+ }
100
+ function kernelMachine(device, backend = "interpreter", budgetNs = 0, pressure = 0) {
101
+ return { class: device, backend, budgetNs, pressure };
102
+ }
103
+ function clamp(value, low, high) {
104
+ return Math.min(Math.max(value, low), high);
105
+ }
106
+ function rowPs(value) {
107
+ return Math.min(value, 2097152);
108
+ }
109
+ function fixedPs(value) {
110
+ return Math.min(value, 68719476736);
111
+ }
112
+ function scale(value, permille) {
113
+ return Math.floor(value * permille / 1e3);
114
+ }
115
+ function modelRows(rows) {
116
+ return Math.min(rows, 16777216);
117
+ }
118
+ function emptyEstimate() {
119
+ return { cpuLaunch: 0, cpuRow: 0, cpuSerialRow: 0, lanes: 1, gpuFixed: 0, gpuRow: 0 };
120
+ }
121
+ function fillEstimate(work, machine, out) {
122
+ let cpu = cpuCosts(machine), gpu = gpuCosts(machine.class), instructions = clamp(work.instructions, 1, 4096), columns = Math.min(work.columns, 256), math = Math.min(work.transcendentals, 256), lanes = machine.backend === "wasm" ? 1 : clamp(work.lanes, 1, 64), pairs = work.pairs ? 24 : 0, gpuFixed = (work.batched && !work.readback ? gpu.batchedLaunch : gpu.launch) + Math.min(work.stages, 64) * gpu.stage, gpuRow = instructions * gpu.op + math * gpu.math + pairs * gpu.pair;
123
+ return work.pairs && (gpuFixed += gpu.grid), work.resident || (gpuRow += columns * gpu.uploadWord), work.readback && (gpuFixed += gpu.sync, gpuRow += columns * gpu.readbackWord), out.cpuLaunch = fixedPs(cpu.launch), out.cpuRow = rowPs(instructions * cpu.op + pairs * cpu.pair + math * cpu.math), out.cpuSerialRow = rowPs(work.pairs ? cpu.gridRow : 0), out.lanes = lanes, out.gpuFixed = fixedPs(gpuFixed), out.gpuRow = rowPs(gpuRow), out;
124
+ }
125
+ function estimateRoute(work, machine) {
126
+ return fillEstimate(work, machine, emptyEstimate());
127
+ }
128
+ function scaleEstimate(e, pin, rowBound = 2097152) {
129
+ return e.cpuLaunch = fixedPs(scale(e.cpuLaunch, pin.cpu)), e.cpuRow = Math.min(scale(e.cpuRow, pin.cpu), rowBound), e.cpuSerialRow = Math.min(scale(e.cpuSerialRow, pin.cpu), rowBound), e.gpuFixed = fixedPs(scale(e.gpuFixed, pin.gpu)), e.gpuRow = Math.min(scale(e.gpuRow, pin.gpu), rowBound), e;
130
+ }
131
+ var SET_ROW_BOUND = 16777216;
132
+ function copyEstimate(from, out) {
133
+ return out.cpuLaunch = from.cpuLaunch, out.cpuRow = from.cpuRow, out.cpuSerialRow = from.cpuSerialRow, out.lanes = from.lanes, out.gpuFixed = from.gpuFixed, out.gpuRow = from.gpuRow, out;
134
+ }
135
+ var ENGINE_CPU = {
136
+ v8: { op: 30, gather: 1400, math: 3500, step: 8e3 },
137
+ jsc: { op: 195, gather: 4300, math: 22e3, step: 4300 },
138
+ "jsc-nojit": { op: 1370, gather: 12300, math: 16e4, step: 50800 }
139
+ };
140
+ function setRowPs(value) {
141
+ return Math.min(value, 16777216);
142
+ }
143
+ function engineRow(cpuSet, form, engine, machine) {
144
+ let c = ENGINE_CPU[engine], row = form === "script" ? cpuSet.steps * c.step : cpuSet.instructions * c.op + cpuSet.gathers * c.gather + cpuSet.transcendentals * c.math;
145
+ return machine.class === "desktop" || machine.class === "discrete" ? row : Math.floor(row * (5) / (4));
146
+ }
147
+ function fillSetEstimate(cpuSet, gpuSet, machine, out, form = "wasm", engine = hostEngine()) {
148
+ let gpu = gpuCosts(machine.class), parts = clamp(gpuSet.parts, 1, 256);
149
+ out.cpuLaunch = 0, out.cpuRow = setRowPs(engineRow(cpuSet, form, engine, machine)), out.cpuSerialRow = 0, out.lanes = 1;
150
+ let gpuFixed = gpu.setFixed + (parts - 1) * gpu.batchedLaunch + Math.min(gpuSet.stages, 64 * 256) * gpu.stage, gpuRow = gpuSet.instructions * gpu.setOp + gpuSet.gathers * gpu.gather + gpuSet.transcendentals * gpu.math + gpuSet.upload * gpu.uploadWord + gpuSet.readback * gpu.readbackWord;
151
+ return out.gpuFixed = fixedPs(gpuFixed), out.gpuRow = setRowPs(gpuRow), out;
152
+ }
153
+ function lanesFor(rows, lanes) {
154
+ let tiles = Math.ceil(rows / 2048);
155
+ return tiles < (4) || lanes <= 1 ? 1 : Math.min(tiles, lanes);
156
+ }
157
+ function estimatedCpu(e, rows) {
158
+ let n = modelRows(rows), lanes = lanesFor(n, e.lanes), speedup = (4) + (3) * (lanes - 1);
159
+ return (lanes > 1 ? e.cpuLaunch : 0) + Math.floor(n * e.cpuRow * (4) / speedup) + n * e.cpuSerialRow;
160
+ }
161
+ function estimatedGpu(e, rows) {
162
+ return e.gpuFixed + modelRows(rows) * e.gpuRow;
163
+ }
164
+ function want(e, rows, machine, current) {
165
+ let margins = gpuCosts(machine.class), cpu = estimatedCpu(e, rows), gpu = estimatedGpu(e, rows), damp = PRESSURE_SCALE[Math.min(Math.max(machine.pressure | 0, 0), 2)];
166
+ if (current === "gpu") return gpu * 64 > cpu * Math.floor(margins.leave * damp / 64) ? "cpu" : "gpu";
167
+ let over = machine.budgetNs > 0 && cpu > machine.budgetNs * 1e3, enter = Math.floor((over ? Math.max(margins.enter, 64) : margins.enter) * damp / 64);
168
+ return gpu * 64 < cpu * enter ? "gpu" : "cpu";
169
+ }
170
+ function chooseDevice(work, machine) {
171
+ return want(estimateRoute(work, machine), work.rows, machine, "cpu");
172
+ }
173
+ function threshold(work, machine, from) {
174
+ let e = estimateRoute(work, machine), at = (rows) => want(e, rows, machine, from);
175
+ if (at(16777216) === "cpu") return null;
176
+ if (at(1) === "gpu") return 1;
177
+ let low = 1, high = 16777216;
178
+ for (; high - low > 1; ) {
179
+ let mid = low + Math.floor((high - low) / 2);
180
+ at(mid) === "gpu" ? high = mid : low = mid;
181
+ }
182
+ return high;
183
+ }
184
+ function crossoverRows(work, machine) {
185
+ return threshold(work, machine, "cpu");
186
+ }
187
+ function leaveBelowRows(work, machine) {
188
+ return threshold(work, machine, "gpu");
189
+ }
190
+ function medianOf(samples, length) {
191
+ if (length === 0) return 1e3;
192
+ for (let i = 1; i < length; i++) {
193
+ let value = samples[i], j = i - 1;
194
+ for (; j >= 0 && samples[j] > value; )
195
+ samples[j + 1] = samples[j], j--;
196
+ samples[j + 1] = value;
197
+ }
198
+ return samples[length >> 1];
199
+ }
200
+ function calibrationRuns(runs) {
201
+ return runs <= 0 ? 0 : runs < 4 ? 4 : runs > 32 ? 32 : runs & -2;
202
+ }
203
+ var KernelRouter = class _KernelRouter {
204
+ constructor(machineState, runs, pin, preset) {
205
+ this.machineState = machineState;
206
+ this.preset = preset;
207
+ this.current = "cpu";
208
+ this.decided = false;
209
+ this.streak = 0;
210
+ this.switched = 0;
211
+ this.taken = 0;
212
+ this.pending = false;
213
+ this.cpuSamples = new Uint32Array(16);
214
+ this.gpuSamples = new Uint32Array(16);
215
+ this.cpuLength = 0;
216
+ this.gpuLength = 0;
217
+ this.scratch = emptyEstimate();
218
+ this.base = emptyEstimate();
219
+ this.runs = calibrationRuns(runs), this.pinned = pin;
220
+ }
221
+ static model(machine) {
222
+ return new _KernelRouter(machine, 0, null, null);
223
+ }
224
+ static calibrating(machine, runs) {
225
+ return new _KernelRouter(machine, runs, null, null);
226
+ }
227
+ static pinned(machine, pin) {
228
+ return new _KernelRouter(machine, 0, pin, null);
229
+ }
230
+ static replaying(machine, runs, pin) {
231
+ return new _KernelRouter(machine, runs, null, pin);
232
+ }
233
+ get machine() {
234
+ return this.machineState;
235
+ }
236
+ set machine(next) {
237
+ this.machineState = next;
238
+ }
239
+ get device() {
240
+ return this.current;
241
+ }
242
+ get pin() {
243
+ return this.pinned;
244
+ }
245
+ get switches() {
246
+ return this.switched;
247
+ }
248
+ get calibrating() {
249
+ return this.pinned === null && this.taken < this.runs;
250
+ }
251
+ get calibrationRuns() {
252
+ return this.runs;
253
+ }
254
+ get sampling() {
255
+ return this.pending;
256
+ }
257
+ route(work) {
258
+ return this.routeEstimate(fillEstimate(work, this.machineState, this.base), work.rows);
259
+ }
260
+ routeEstimate(e, rows, rowBound = 2097152) {
261
+ if (this.pending = false, this.calibrating) {
262
+ let cpu = estimatedCpu(e, rows), gpu = estimatedGpu(e, rows);
263
+ if (gpu * 16 >= cpu && cpu * 16 >= gpu) {
264
+ let device = this.taken < this.runs / 2 ? "cpu" : "gpu";
265
+ return this.taken++, this.pending = true, this.current = device, this.streak = 0, this.decided = false, device;
266
+ }
267
+ }
268
+ let next = want(this.pinned === null ? e : scaleEstimate(copyEstimate(e, this.scratch), this.pinned, rowBound), rows, this.machineState, this.current);
269
+ return this.decided ? (next === this.current ? this.streak = 0 : (this.streak++, this.streak >= 3 && (this.current = next, this.streak = 0, this.switched++)), this.current) : (this.decided = true, this.streak = 0, this.current = next, next);
270
+ }
271
+ record(device, work, ns) {
272
+ this.pending && this.recordEstimate(device, fillEstimate(work, this.machineState, this.base), work.rows, ns);
273
+ }
274
+ recordEstimate(device, e, rows, ns) {
275
+ if (!this.pending) return;
276
+ this.pending = false;
277
+ let half = this.runs / 2;
278
+ if (!(this.taken === 1 || this.taken === half + 1)) {
279
+ let model = Math.max(device === "cpu" ? estimatedCpu(e, rows) : estimatedGpu(e, rows), 1), measured = Math.min(Math.max(Math.floor(ns), 0), 4294967296) * 1e3, ratio = clamp(Math.floor(measured * 1e3 / model), 250, 4e3);
280
+ device === "cpu" && this.cpuLength < 16 ? this.cpuSamples[this.cpuLength++] = ratio : device === "gpu" && this.gpuLength < 16 && (this.gpuSamples[this.gpuLength++] = ratio);
281
+ }
282
+ if (this.taken >= this.runs) {
283
+ let cpu = medianOf(this.cpuSamples, this.cpuLength), gpu = medianOf(this.gpuSamples, this.gpuLength);
284
+ this.pinned = this.preset ?? { cpu, gpu }, this.decided = false, this.streak = 0;
285
+ }
286
+ }
287
+ };
288
+
289
+ // src/game/kernel/rowops.ts
290
+ var KERNEL_ARRAY_PREFIX = "#", KERNEL_TABLE_PREFIX = "%", MAX_ARRAY_LENGTH = 1 << 24, arrays = /* @__PURE__ */ new Map();
291
+ function kernelArray(name, desc) {
292
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new GameError("invalid_argument", `kernel array name "${name}" must be letters, digits and underscores`);
293
+ if (!Number.isInteger(desc.length) || desc.length < 1 || desc.length > MAX_ARRAY_LENGTH) throw new GameError("invalid_argument", `kernel array ${name} needs a whole length from 1 to ${MAX_ARRAY_LENGTH}`);
294
+ let data = desc.kind === "f32" ? new Float32Array(desc.length) : desc.kind === "i32" ? new Int32Array(desc.length) : new Uint32Array(desc.length), array = { name, kind: desc.kind, length: desc.length, data };
295
+ return arrays.set(name, array), array;
296
+ }
297
+ function kernelArrayNamed(name) {
298
+ return arrays.get(name) ?? null;
299
+ }
300
+ function compiledOnly(name) {
301
+ throw new GameError("unsupported_feature", `${name}() combines every row, so it runs only in a compiled kernel; build the game (cimplify build or cimplify dev) so the kernel has bytecode`);
302
+ }
303
+ function rowSum(value) {
304
+ return compiledOnly("rowSum");
305
+ }
306
+ function rowMin(value) {
307
+ return compiledOnly("rowMin");
308
+ }
309
+ function rowMax(value) {
310
+ return compiledOnly("rowMax");
311
+ }
312
+ function rowCount(when) {
313
+ return compiledOnly("rowCount");
314
+ }
315
+ function rowArgMin(value) {
316
+ return compiledOnly("rowArgMin");
317
+ }
318
+ function rowArgMax(value) {
319
+ return compiledOnly("rowArgMax");
320
+ }
321
+ function rowPrefixSum(value, exclusive) {
322
+ return compiledOnly("rowPrefixSum");
323
+ }
324
+ function rowScan(value, op, exclusive) {
325
+ return compiledOnly("rowScan");
326
+ }
327
+ function rowRecur(a, b, exclusive) {
328
+ return compiledOnly("rowRecur");
329
+ }
330
+ function rowFeedback(b, a1, a2) {
331
+ return compiledOnly("rowFeedback");
332
+ }
333
+ function rowPhase(increment, period, exclusive) {
334
+ return compiledOnly("rowPhase");
335
+ }
336
+ function rowPhase64(increment, period, exclusive) {
337
+ return compiledOnly("rowPhase64");
338
+ }
339
+ function histogram(bins, bin) {
340
+ compiledOnly("histogram");
341
+ }
342
+ function scatterAdd(target, index, value) {
343
+ compiledOnly("scatterAdd");
344
+ }
345
+ function compactRows(list) {
346
+ return compiledOnly("compactRows");
347
+ }
348
+ function sortRows(list, key, descending) {
349
+ return compiledOnly("sortRows");
350
+ }
351
+ function topRows(list, key, k, smallest) {
352
+ return compiledOnly("topRows");
353
+ }
354
+ function groupRows(key) {
355
+ return compiledOnly("groupRows");
356
+ }
357
+ function dedupRows(key) {
358
+ return compiledOnly("dedupRows");
359
+ }
360
+
361
+ // src/game/kernel/gpu.ts
362
+ var GPU_KERNEL_EXPORT_NAMES = [
363
+ "engine_kernel_gpu_ready",
364
+ "engine_kernel_gpu_bind",
365
+ "engine_kernel_gpu_unbind",
366
+ "engine_kernel_gpu_run",
367
+ "engine_kernel_gpu_frame",
368
+ "engine_kernel_gpu_sync",
369
+ "engine_kernel_gpu_touch",
370
+ "engine_kernel_gpu_events",
371
+ "engine_kernel_gpu_clear_events"
372
+ ], GPU_KERNEL_OPTIONAL_EXPORT_NAMES = ["engine_kernel_gpu_mirror", "engine_kernel_gpu_class"], SAMPLER_PREFIX = "@", OP_MASK = 255, DST_SHIFT = 8, TRANSCENDENTAL_OPS = /* @__PURE__ */ new Set([Op.FPOW, Op.FATAN2, Op.FLOG2, Op.FSIN, Op.FCOS, Op.FTAN, Op.FASIN, Op.FACOS, Op.FATAN, Op.FEXP, Op.FLOG]), shapes = /* @__PURE__ */ new WeakMap();
373
+ function programShape(program) {
374
+ let known = shapes.get(program);
375
+ if (known !== void 0) return known;
376
+ let shape = { instructions: 0, pairs: false, stages: 1, transcendentals: 0, gathers: 0 };
377
+ if (program.byteLength >= 16 * (4)) {
378
+ let view = new DataView(program.buffer, program.byteOffset, program.byteLength), word = (at) => view.getUint32(at * (4), true), start = 16 + word(4) + word(5) + word(6) + word(9) * 4 + word(14) * 4, total = program.byteLength / (4), stages = 1, previous = false, transcendentals = 0, gathers = 0;
379
+ for (let at = start; at + 4 <= total; at += 4) {
380
+ let head = word(at), op = head & (255);
381
+ TRANSCENDENTAL_OPS.has(op) && transcendentals++, op === XOP && (head >>> (8) === XOP_GATHER || head >>> (8) === XOP_FIELD) && gathers++;
382
+ let ends = crossRow(op) || op === XOP && stageEnds(head >>> (8));
383
+ ends && !previous && stages++, previous = ends || previous && op === Op.EXT;
384
+ }
385
+ shape = { instructions: word(8), pairs: (word(2) & 1) !== 0, stages, transcendentals, gathers };
386
+ }
387
+ return shapes.set(program, shape), shape;
388
+ }
389
+ var NO_FIELDS = Object.freeze([]), WIDTHS = { vec2: 2, vec3: 3, vec4: 4 }, NO_LIST = 255, ALL_COLUMNS = 255, WORD = 4, MAX_ARG_WORDS = 64, TRUE_BITS = 4294967295, UNSUPPORTED = -5, OVER_LIMITS = -1, GPU_TABLES_LOG_PREFIX = "[kernel tables] ", GPU_JOINED_TABLE_WORDS = DATA_TABLES, DEVICE_UNKNOWN = 0, DEVICE_READY = 1, DEVICE_NONE = 2, AXES = ["x", "y", "z", "w"];
390
+ function gpuTablesLogLine(route) {
391
+ let how = route.path === "gpu" ? "table reads run on the GPU (nine storage buffers per stage)" : route.path === "cpu-limits" ? "table reads run on the CPU: this device allows fewer than nine storage buffers per stage, or the tables exceed its binding size" : "table reads run on the CPU: the kernel writes other tables or uses lists, tallies or picks";
392
+ return `${GPU_TABLES_LOG_PREFIX}${route.kernel}: ${how}`;
393
+ }
394
+ function sameJoined(a, b) {
395
+ if (a === null || b === null) return a === b;
396
+ if (a.length !== b.length) return false;
397
+ for (let k = 0; k < a.length; k++) if (a[k] !== b[k] || a[k] !== void 0 && !a[k].valid) return false;
398
+ return true;
399
+ }
400
+ function scalarPositions(meta) {
401
+ let tables = meta.data?.tables;
402
+ if (tables === void 0 || tables.length === 0) return null;
403
+ let positions = [];
404
+ for (let k = 0; positions.length < meta.args.length; k++) tables.some((t) => t.position === k) || positions.push(k);
405
+ return Int32Array.from(positions);
406
+ }
407
+ var NO_ARRAYS = Object.freeze([]);
408
+ function arraySlots(meta) {
409
+ let out = null;
410
+ for (let slot of meta.slots) {
411
+ let table = slot.field.startsWith(KERNEL_TABLE_PREFIX);
412
+ if (!table && !slot.field.startsWith(KERNEL_ARRAY_PREFIX)) continue;
413
+ let name = slot.field.slice(1);
414
+ out ?? (out = []), out.push({ name, arg: table ? meta.args.findIndex((a) => a.name === name) : -1, write: slot.write });
415
+ }
416
+ return out ?? NO_ARRAYS;
417
+ }
418
+ function columnField(field) {
419
+ return field.startsWith(KERNEL_TABLE_PREFIX) || field.startsWith(KERNEL_ARRAY_PREFIX) ? field.slice(1) : field;
420
+ }
421
+ function sameMemory(a, b) {
422
+ return a.buffer === b.buffer && a.byteOffset === b.byteOffset;
423
+ }
424
+ var GpuKernels = class _GpuKernels {
425
+ constructor(exports, memory) {
426
+ this.exports = exports;
427
+ this.memory = memory;
428
+ this.entries = /* @__PURE__ */ new Map();
429
+ this.routes = [];
430
+ this.touched = /* @__PURE__ */ new Set();
431
+ this.resident = /* @__PURE__ */ new WeakSet();
432
+ this.pending = /* @__PURE__ */ new Set();
433
+ this.engineClass = null;
434
+ this.argsAt = 0;
435
+ this.argsBuffer = null;
436
+ this.words = new Uint32Array(0);
437
+ this.floats = new Float32Array(0);
438
+ this.priority = 0;
439
+ this.compute = null;
440
+ this.onTables = (route) => console.info(gpuTablesLogLine(route));
441
+ this.device = (0);
442
+ this.mirrored = /* @__PURE__ */ new WeakMap();
443
+ }
444
+ static bind(symbols, memory) {
445
+ for (let name of GPU_KERNEL_EXPORT_NAMES) if (typeof symbols[name] != "function") return null;
446
+ return typeof symbols.engine_alloc != "function" || typeof symbols.engine_free != "function" ? null : new _GpuKernels(symbols, memory);
447
+ }
448
+ available() {
449
+ return this.device === (0) && (this.device = this.exports.engine_kernel_gpu_ready() === 1 ? (1) : (2)), this.device === (1);
450
+ }
451
+ deviceClass(fallback) {
452
+ if (this.engineClass === null) {
453
+ let ask = this.exports.engine_kernel_gpu_class;
454
+ this.engineClass = typeof ask == "function" && this.available() ? gpuDeviceClass(ask()) : "unknown";
455
+ }
456
+ return this.engineClass === "unknown" ? fallback : this.engineClass;
457
+ }
458
+ hostBackend() {
459
+ return wasmInstantiates() && this.memory instanceof WebAssembly.Memory ? "wasm" : "interpreter";
460
+ }
461
+ work(meta, program, table, rows, lanes, readback, batched = false) {
462
+ let shape = programShape(program);
463
+ return { rows, instructions: shape.instructions, pairs: shape.pairs, stages: shape.stages, columns: meta.slots.length, resident: this.resident.has(table), readback, lanes, transcendentals: shape.transcendentals, batched };
464
+ }
465
+ beforeCpu(table) {
466
+ this.pending.has(table) && this.sync();
467
+ }
468
+ afterCpu(table, meta) {
469
+ if (this.resident.has(table)) {
470
+ if (meta === null) {
471
+ this.exports.engine_kernel_gpu_touch(table.id, (255)), this.resident.delete(table);
472
+ return;
473
+ }
474
+ for (let slot of meta.slots) slot.write && slot.field in table.schema && this.exports.engine_kernel_gpu_touch(table.id, table.column(slot.field, slot.component));
475
+ }
476
+ }
477
+ tablesRoute(entry, meta, path) {
478
+ entry.routed || (entry.routed = true, this.onTables?.({ kernel: meta.name, path }));
479
+ }
480
+ joinedOf(entry, meta, table, args) {
481
+ let known = entry.joined, list = meta.data?.tables;
482
+ if (known === null || list === void 0)
483
+ return entry.joined = dataTables(meta, table, args), entry.joined;
484
+ known[0] = table;
485
+ for (let k = 0; k < list.length; k++) {
486
+ let value = args[list[k].position];
487
+ if (typeof value != "object" || value === null || !("schema" in value))
488
+ return entry.joined = dataTables(meta, table, args), entry.joined;
489
+ known[list[k].table] = value;
490
+ }
491
+ return known;
492
+ }
493
+ binding(meta, bytes, table, args) {
494
+ let entry = this.entries.get(bytes);
495
+ if (entry === void 0 && (entry = { eligible: true, routed: false, bound: [], arrays: arraySlots(meta), scalars: scalarPositions(meta), data: hasData(meta), joined: null }, this.entries.set(bytes, entry)), !entry.eligible) return (-5);
496
+ let data = entry.data, joined = data ? this.joinedOf(entry, meta, table, args) : null;
497
+ if (joined !== null && joined.some((t, k) => k > 0 && t !== void 0 && !t.native)) return (-5);
498
+ for (let b of entry.bound) if (b.table === table && table.valid && sameJoined(b.joined, joined)) return b.binding;
499
+ for (let k = entry.bound.length - 1; k >= 0; k--)
500
+ entry.bound[k].table.valid || (this.exports.engine_kernel_gpu_unbind(entry.bound[k].binding), this.compute?.unbound(COMPUTE_SPACE_GPU, entry.bound[k].binding), entry.bound.splice(k, 1));
501
+ if (meta.slots.some((slot) => slot.field.startsWith(SAMPLER_PREFIX)) || entry.arrays.some((a) => !this.carries(table, a, meta)))
502
+ return entry.eligible = false, (-5);
503
+ let columns = new Uint32Array(meta.slots.length + (joined === null ? 0 : GPU_JOINED_TABLE_WORDS));
504
+ for (let k = 0; k < meta.slots.length; k++) {
505
+ let slot = meta.slots[k];
506
+ if (slot.pool !== void 0) {
507
+ columns[k] = 4294967295;
508
+ continue;
509
+ }
510
+ let source = joined !== null && slot.table !== void 0 && slot.table > 0 ? joined[slot.table] : table, field = columnField(slot.field);
511
+ if (!(field in source.schema)) throw new GameError("invalid_argument", `kernel ${meta.name} reads ${slot.field}, which ${source === table ? "this" : "the joined"} table does not have`);
512
+ columns[k] = source.column(field, field === slot.field ? slot.component : 0);
513
+ }
514
+ if (joined !== null) for (let t = 0; t < GPU_JOINED_TABLE_WORDS; t++) columns[meta.slots.length + t] = t < joined.length && joined[t] !== void 0 ? joined[t].id : 4294967295;
515
+ let programAt = this.copyIn(bytes), columnsAt = this.copyIn(new Uint8Array(columns.buffer)), binding = this.exports.engine_kernel_gpu_bind(programAt, bytes.byteLength, table.id, columnsAt, columns.length);
516
+ if (this.exports.engine_free(programAt, Math.max(bytes.byteLength, (4)), (4)), this.exports.engine_free(columnsAt, Math.max(columns.byteLength, (4)), (4)), binding === (-5) || data && binding === (-1))
517
+ return entry.eligible = false, data && this.tablesRoute(entry, meta, binding === (-5) ? "cpu-ineligible" : "cpu-limits"), (-5);
518
+ if (binding < 0) throw new GameError("invalid_argument", `the engine refused GPU kernel ${meta.name} (${binding})`);
519
+ return data && this.tablesRoute(entry, meta, "gpu"), entry.bound.push({ table, joined: joined === null ? null : joined.slice(), binding }), this.compute?.bound(COMPUTE_SPACE_GPU, binding, meta.name, this.priority), meta.channels !== void 0 && meta.channels.length > 0 && this.routes.push({ binding, meta }), binding;
520
+ }
521
+ carries(table, array, meta) {
522
+ let kind = table.schema[array.name];
523
+ if (kind !== "f32" && kind !== "i32" && kind !== "u32") return false;
524
+ let slot = meta.slots.find((s) => columnField(s.field) === array.name && s.field !== array.name);
525
+ return slot !== void 0 && slot.kind === kind;
526
+ }
527
+ stage(entry, table, args) {
528
+ for (let array of entry.arrays) {
529
+ let column = table.values(array.name), source = array.arg >= 0 ? args[array.arg] : kernelArrayNamed(array.name)?.data;
530
+ if (!(source instanceof column.constructor)) return false;
531
+ let data = source;
532
+ if (!sameMemory(data, column)) {
533
+ if (array.write || data.length > column.length) return false;
534
+ column.set(data), this.touched.has(table) && this.exports.engine_kernel_gpu_touch(table.id, table.column(array.name, 0));
535
+ }
536
+ }
537
+ return true;
538
+ }
539
+ copyIn(bytes) {
540
+ let at = this.exports.engine_alloc(Math.max(bytes.byteLength, (4)), (4));
541
+ if (at === 0) throw new GameError("capacity_exceeded", "engine memory cannot hold a GPU kernel binding");
542
+ return new Uint8Array(this.memory.buffer, at, bytes.byteLength).set(bytes), at;
543
+ }
544
+ argViews() {
545
+ let buffer = this.memory.buffer;
546
+ if (this.argsAt === 0 && (this.argsAt = this.exports.engine_alloc((64) * (4), (4)), this.argsAt === 0))
547
+ throw new GameError("capacity_exceeded", "engine memory cannot hold kernel arguments");
548
+ this.argsBuffer !== buffer && (this.words = new Uint32Array(buffer, this.argsAt, (64)), this.floats = new Float32Array(buffer, this.argsAt, (64)), this.argsBuffer = buffer);
549
+ }
550
+ writeArg(at, arg, value) {
551
+ if (arg.kind === "f64" || arg.kind === "u64") return writeWideArg(this.words, at, arg.kind, value);
552
+ if (arg.width === 1 && ArrayBuffer.isView(value))
553
+ return this.words[at] = value.length >>> 0, at + 1;
554
+ if (arg.width > 1 && (Array.isArray(value) || ArrayBuffer.isView(value))) {
555
+ let items = value;
556
+ for (let k = 0; k < arg.width; k++)
557
+ arg.kind === "f32" ? this.floats[at + k] = items[k] : this.words[at + k] = items[k] >>> 0;
558
+ return at + arg.width;
559
+ }
560
+ if (arg.width > 1) {
561
+ let vector = value;
562
+ for (let k = 0; k < arg.width; k++) this.floats[at + k] = vector[AXES[k]];
563
+ return at + arg.width;
564
+ }
565
+ return arg.kind === "f32" ? this.floats[at] = value : arg.kind === "bool" ? this.words[at] = value ? (4294967295) : 0 : this.words[at] = value >>> 0, at + 1;
566
+ }
567
+ eligible(bytes) {
568
+ return this.device !== (2) && this.entries.get(bytes)?.eligible !== false;
569
+ }
570
+ mirror(table, fields) {
571
+ let known = this.mirrored.get(table);
572
+ if (known === fields || known !== void 0 && known.length === fields.length && known.every((f, k) => f === fields[k])) return;
573
+ let set = this.exports.engine_kernel_gpu_mirror;
574
+ if (typeof set == "function") {
575
+ this.mirrored.set(table, fields), set(table.id, (255), 0);
576
+ for (let field of fields) {
577
+ if (!(field in table.schema)) throw new GameError("invalid_argument", `onGpu mirrors ${field}, which this table does not have`);
578
+ let width = WIDTHS[table.schema[field]] ?? 1;
579
+ for (let k = 0; k < width; k++) set(table.id, table.column(field, k), 1);
580
+ }
581
+ }
582
+ }
583
+ run(meta, bytes, table, selection, args, now, mirror = NO_FIELDS) {
584
+ if (!table.native || meta.argWords > (64) || !this.available()) return null;
585
+ let binding = this.binding(meta, bytes, table, args);
586
+ if (binding === (-5)) return null;
587
+ let entry = this.entries.get(bytes);
588
+ if (entry.arrays.length > 0 && !this.stage(entry, table, args)) return null;
589
+ this.mirror(table, mirror), this.argViews();
590
+ let at = 0, scalars = entry.scalars;
591
+ for (let k = 0; k < meta.args.length; k++) at = this.writeArg(at, meta.args[k], args[scalars === null ? k : scalars[k]]);
592
+ let list = selection ? selection.index : (255);
593
+ this.compute?.prioritise(COMPUTE_SPACE_GPU, binding, this.priority);
594
+ let ran = this.exports.engine_kernel_gpu_run(binding, list, this.argsAt, at);
595
+ if (ran === COMPUTE_DEFERRED && this.priority !== 0) return 0;
596
+ if (ran < 0) throw new GameError("invalid_argument", `GPU kernel ${meta.name} failed (${ran})`);
597
+ return this.touched.add(table), this.resident.add(table), now ? (this.exports.engine_kernel_gpu_sync(), this.pending.clear(), this.route()) : this.pending.add(table), ran;
598
+ }
599
+ touch(table, field, component = 0) {
600
+ this.touched.has(table) && (field === void 0 && this.resident.delete(table), this.exports.engine_kernel_gpu_touch(table.id, field === void 0 ? (255) : table.column(field, component)));
601
+ }
602
+ sync() {
603
+ this.touched.size !== 0 && (this.exports.engine_kernel_gpu_sync(), this.pending.clear(), this.route());
604
+ }
605
+ frame() {
606
+ this.touched.size !== 0 && (this.exports.engine_kernel_gpu_frame(), this.route());
607
+ }
608
+ route() {
609
+ for (let { binding, meta } of this.routes) {
610
+ let at = this.exports.engine_kernel_gpu_events(binding);
611
+ at === 0 || meta.channels === void 0 || (routeEvents(new Uint32Array(this.memory.buffer, at, RING_HEADER_WORDS + DEFAULT_EVENT_CAPACITY * 10), meta.channels), this.exports.engine_kernel_gpu_clear_events(binding));
612
+ }
613
+ }
614
+ dispose() {
615
+ for (let entry of this.entries.values()) for (let b of entry.bound) this.exports.engine_kernel_gpu_unbind(b.binding);
616
+ this.argsAt !== 0 && this.exports.engine_free(this.argsAt, (64) * (4), (4)), this.entries.clear(), this.routes.length = 0, this.touched.clear(), this.pending.clear(), this.argsAt = 0;
617
+ }
618
+ };
619
+
620
+ export { CPU_BACKENDS, GPU_KERNEL_EXPORT_NAMES, GPU_KERNEL_OPTIONAL_EXPORT_NAMES, GpuKernels, KERNEL_ARRAY_PREFIX, KERNEL_TABLE_PREFIX, KernelRouter, NO_FIELDS, SET_ROW_BOUND, chooseDevice, compactRows, crossoverRows, dedupRows, emptyEstimate, fillSetEstimate, groupRows, histogram, hostEngine, kernelArray, kernelArrayNamed, kernelMachine, leaveBelowRows, programShape, rowArgMax, rowArgMin, rowCount, rowFeedback, rowMax, rowMin, rowPhase, rowPhase64, rowPrefixSum, rowRecur, rowScan, rowSum, scatterAdd, sortRows, topRows, wasmInstantiates };