@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,1380 @@
1
+ import { IdentityCaptureError } from './chunk-5C3C7VDM.mjs';
2
+ import { TreeDiffer, readReplayMessage } from './chunk-UGH37BQW.mjs';
3
+ import { PackageAssembler, decodeChunk, ChunkKind } from './chunk-KDQOR4QQ.mjs';
4
+ import { readinessProbe } from './chunk-LYEZZEEF.mjs';
5
+ import { StudioAssembler, StudioSender, reportMetersTo, openStudioChannel, deliverStudio, requestMeters } from './chunk-HAGEIC2L.mjs';
6
+ import { readNetworkHint, hotAccepted, relinkingDefinitions, applyHot } from './chunk-K46SMZ66.mjs';
7
+ import { createGenerate } from './chunk-OKC2B4O3.mjs';
8
+ import { GameUi } from './chunk-PPF2BYFL.mjs';
9
+ import { TEXT_DICTIONARIES_ASSET } from './chunk-DS2VU4WW.mjs';
10
+ import { sha256Into } from './chunk-5YWN6H5Q.mjs';
11
+ import { peekFrameCode, frameLength, FrameCode, decodePresenceTick, decodeCounterValue, decodeFastValue, decodeRoomInputFrame, decodeChannelFrame, writeChannelHeader, writeRoomInputHeader, writeFastReadHeader, encodeCounterAdd, encodeMoveInput } from './chunk-OQRVEM56.mjs';
12
+ import { FRAME_LIMITS, FRAME_LAYOUT, FRAME_CODES, CTX_CAPABILITIES } from './chunk-SPCRQ6NO.mjs';
13
+ import { TAG_BYTES, BRIDGE_LIMITS, MessageTag, MessageWriter, PONG_BYTES, MILESTONE_BYTES, SESSION_COMPLETE_BYTES, ChunkBatch, CHUNK_REQUEST_ENTRY_BYTES, CHUNK_RELEASE_ENTRY_BYTES, ChunkPriority, Milestone, writeSessionComplete, readJson, INSPECTOR_SHOWN, CHUNK_REQUESTS_VERSION, LIFECYCLE_BY_CODE, DIGEST_BYTES, hex, readChunkFailed } from './chunk-V7ZRH3PY.mjs';
14
+ import { breakDictionaries, registerBreakDictionaries } from './chunk-GYLP6UG4.mjs';
15
+ import { encodeBase64, decodeBase64 } from './chunk-2IC4H6OV.mjs';
16
+ import { requestInspector } from './chunk-MOMOZEUM.mjs';
17
+ import { withdrawWasm, guardedWebAssembly } from './chunk-N4RGGDEL.mjs';
18
+
19
+ // src/interactives/runtime/lanes.ts
20
+ var PRESENCE_ROUTE = 0, FRAME_CODE_SLOTS = 16;
21
+ function subscribe(route, slot, listener) {
22
+ return route.set(slot, [...route.get(slot) ?? [], listener]), () => {
23
+ let remaining = (route.get(slot) ?? []).filter((l) => l !== listener);
24
+ remaining.length === 0 ? route.delete(slot) : route.set(slot, remaining);
25
+ };
26
+ }
27
+ function copyInto(source, target, at, length) {
28
+ for (let i = 0; i < length; i++) target[at + i] = source[i];
29
+ }
30
+ function deliver(route, slot, message, view) {
31
+ let listeners = route.get(slot);
32
+ if (listeners !== void 0)
33
+ for (let i = 0; i < listeners.length; i++) listeners[i](message, view);
34
+ }
35
+ var FrameLane = class {
36
+ constructor(bridge) {
37
+ this.bridge = bridge;
38
+ this.length = TAG_BYTES;
39
+ this.scheduled = false;
40
+ this.channel = { flags: 0, slot: 0, sequence: 0, sender: 0, payload_offset: 0, payload_length: 0 };
41
+ this.roomInput = {
42
+ flags: 0,
43
+ action: 0,
44
+ sequence: 0,
45
+ client_tick: 0,
46
+ sender: 0,
47
+ payload_offset: 0,
48
+ payload_length: 0
49
+ };
50
+ this.fastValue = {
51
+ status: 0,
52
+ slot: 0,
53
+ correlation: 0,
54
+ stamp_low: 0,
55
+ stamp_high: 0,
56
+ value_offset: 0,
57
+ value_length: 0
58
+ };
59
+ this.counterValue = { status: 0, slot: 0, correlation: 0, value: 0 };
60
+ this.presence = {
61
+ flags: 0,
62
+ server_tick: 0,
63
+ cell_index: 0,
64
+ acked_input: 0,
65
+ layer: 0,
66
+ baseline_age: 0,
67
+ count: 0,
68
+ entries_offset: 0
69
+ };
70
+ this.channels = /* @__PURE__ */ new Map();
71
+ this.roomInputs = /* @__PURE__ */ new Map();
72
+ this.fastValues = /* @__PURE__ */ new Map();
73
+ this.counterValues = /* @__PURE__ */ new Map();
74
+ this.presenceTicks = /* @__PURE__ */ new Map();
75
+ this.faults = new Uint32Array((16));
76
+ this.flush = () => {
77
+ this.scheduled = false, this.length !== TAG_BYTES && (this.bridge.send(this.out, this.length), this.length = TAG_BYTES);
78
+ };
79
+ this.out = new Uint8Array(BRIDGE_LIMITS.frame_outbox_bytes), this.out[0] = MessageTag.frames, this.view = new DataView(this.out.buffer);
80
+ }
81
+ reserve(bytes) {
82
+ return this.length + bytes > this.out.length && this.flush(), this.scheduled || (this.scheduled = true, queueMicrotask(this.flush)), this.length;
83
+ }
84
+ commit(written) {
85
+ return written > 0 && (this.length += written), written;
86
+ }
87
+ receive(bytes) {
88
+ let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), end = bytes.byteLength, offset = TAG_BYTES;
89
+ for (; offset < end; ) {
90
+ let code = peekFrameCode(view, offset, end), total = frameLength(view, offset, end);
91
+ if (code < 0 || total < 0) {
92
+ this.faults[0] += 1;
93
+ return;
94
+ }
95
+ switch (code) {
96
+ case FrameCode.channel:
97
+ decodeChannelFrame(view, offset, end, this.channel) > 0 && deliver(this.channels, this.channel.slot, this.channel, view);
98
+ break;
99
+ case FrameCode.room_input:
100
+ decodeRoomInputFrame(view, offset, end, this.roomInput) > 0 && deliver(this.roomInputs, this.roomInput.sender, this.roomInput, view);
101
+ break;
102
+ case FrameCode.fast_value:
103
+ decodeFastValue(view, offset, end, this.fastValue) > 0 && deliver(this.fastValues, this.fastValue.slot, this.fastValue, view);
104
+ break;
105
+ case FrameCode.counter_value:
106
+ decodeCounterValue(view, offset, end, this.counterValue) > 0 && deliver(this.counterValues, this.counterValue.slot, this.counterValue, view);
107
+ break;
108
+ case FrameCode.presence_tick:
109
+ decodePresenceTick(view, offset, end, this.presence) > 0 && deliver(this.presenceTicks, (0), this.presence, view);
110
+ break;
111
+ default:
112
+ this.faults[code] += 1;
113
+ }
114
+ offset += total;
115
+ }
116
+ }
117
+ };
118
+ function onSlot(route, slot, listener) {
119
+ return subscribe(route, slot, listener);
120
+ }
121
+ function onPresence(lane, listener) {
122
+ return subscribe(lane.presenceTicks, (0), listener);
123
+ }
124
+ var PayloadPublisher = class {
125
+ constructor(lane, slot, maxPayload, headerBytes) {
126
+ this.lane = lane;
127
+ this.slot = slot;
128
+ this.headerBytes = headerBytes;
129
+ this.sequence = 0;
130
+ this.max_payload_bytes = maxPayload, this.scratch = new Uint8Array(maxPayload), this.scratchView = new DataView(this.scratch.buffer);
131
+ }
132
+ payload() {
133
+ return this.scratchView;
134
+ }
135
+ send(length, flags = 0) {
136
+ if (length < 0 || length > this.max_payload_bytes) return -1;
137
+ let offset = this.lane.reserve(this.headerBytes + length), written = this.header(offset, length, flags);
138
+ if (written < 0) return written;
139
+ copyInto(this.scratch, this.lane.out, offset + this.headerBytes, length), this.lane.commit(written);
140
+ let sent = this.sequence;
141
+ return this.sequence = this.sequence + 1 >>> 0, sent;
142
+ }
143
+ }, ChannelPublisher = class extends PayloadPublisher {
144
+ constructor(lane, slot, maxPayload) {
145
+ super(lane, slot, Math.min(maxPayload, FRAME_LIMITS.max_channel_payload_bytes), FRAME_LAYOUT.channel.header_bytes);
146
+ this.frame = { flags: 0, slot: 0, sequence: 0, sender: 0 };
147
+ this.frame.slot = slot;
148
+ }
149
+ header(offset, length, flags) {
150
+ return this.frame.flags = flags, this.frame.sequence = this.sequence, writeChannelHeader(this.lane.view, offset, this.frame, length);
151
+ }
152
+ }, RoomInputPublisher = class extends PayloadPublisher {
153
+ constructor(lane, slot) {
154
+ super(lane, slot, FRAME_LIMITS.max_room_input_payload_bytes, FRAME_LAYOUT.room_input.header_bytes);
155
+ this.frame = { flags: 0, action: 0, sequence: 0, client_tick: 0, sender: 0 };
156
+ this.frame.sender = slot;
157
+ }
158
+ header(offset, length, flags) {
159
+ return this.frame.flags = flags, this.frame.sequence = this.sequence, writeRoomInputHeader(this.lane.view, offset, this.frame, length);
160
+ }
161
+ }, LaneFastReader = class {
162
+ constructor(lane, slot, target) {
163
+ this.lane = lane;
164
+ this.slot = slot;
165
+ this.keyBytes = new Uint8Array(FRAME_LIMITS.max_fast_key_bytes);
166
+ this.frame = { target: FRAME_CODES.fast_target[target], slot, correlation: 0 };
167
+ }
168
+ key() {
169
+ return this.keyBytes;
170
+ }
171
+ read(key_length, correlation) {
172
+ if (key_length < 0 || key_length > this.keyBytes.length) return -1;
173
+ let offset = this.lane.reserve(FRAME_LAYOUT.fast_read.header_bytes + key_length);
174
+ this.frame.correlation = correlation >>> 0;
175
+ let written = writeFastReadHeader(this.lane.view, offset, this.frame, key_length);
176
+ return written < 0 ? written : (copyInto(this.keyBytes, this.lane.out, offset + FRAME_LAYOUT.fast_read.header_bytes, key_length), this.lane.commit(written));
177
+ }
178
+ on_value(listener) {
179
+ return subscribe(this.lane.fastValues, this.slot, listener);
180
+ }
181
+ }, LaneCounter = class {
182
+ constructor(lane, slot) {
183
+ this.lane = lane;
184
+ this.slot = slot;
185
+ this.frame = { status: 0, slot: 0, correlation: 0, value: 0 };
186
+ this.frame.slot = slot;
187
+ }
188
+ add(delta, correlation) {
189
+ let offset = this.lane.reserve(FRAME_LAYOUT.counter_add.header_bytes);
190
+ return this.frame.correlation = correlation >>> 0, this.frame.value = delta, this.lane.commit(encodeCounterAdd(this.lane.view, offset, this.frame));
191
+ }
192
+ on_value(listener) {
193
+ return subscribe(this.lane.counterValues, this.slot, (frame) => listener(frame));
194
+ }
195
+ };
196
+ function sendMove(lane, input) {
197
+ let offset = lane.reserve(FRAME_LAYOUT.move_input.header_bytes);
198
+ return lane.commit(encodeMoveInput(lane.view, offset, input));
199
+ }
200
+
201
+ // src/interactives/runtime/local-families.ts
202
+ var UINT32 = 4294967296, SEED_WORDS = 4, CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", SHORT_ALPHABET = "abcdefghijkmnopqrstuvwxyz23456789", HEX = "0123456789abcdef", UUID_BYTES = 16, ULID_TIME_CHARS = 10, ULID_RANDOM_CHARS = 16, UUID_V7 = 112, UUID_VARIANT = 128, RANDOM_POOL_BYTES = 256, RandomPool = class {
203
+ constructor(services) {
204
+ this.services = services;
205
+ this.bytes = new Uint8Array((256));
206
+ this.words = new Uint32Array(this.bytes.buffer);
207
+ this.cursor = (256);
208
+ }
209
+ u32() {
210
+ this.cursor + 4 > (256) && (this.services.random_fill(this.bytes), this.cursor = 0);
211
+ let word = this.words[this.cursor >> 2];
212
+ return this.cursor += 4, word;
213
+ }
214
+ byte() {
215
+ return this.u32() & 255;
216
+ }
217
+ }, Xoshiro128 = class {
218
+ constructor(words) {
219
+ this.a = words[0] >>> 0, this.b = words[1] >>> 0, this.c = words[2] >>> 0, this.d = words[3] >>> 0 || 1;
220
+ }
221
+ next_u32() {
222
+ let result = Math.imul(rotl(Math.imul(this.b, 5), 7), 9) >>> 0, t = this.b << 9;
223
+ return this.c ^= this.a, this.d ^= this.b, this.b ^= this.c, this.a ^= this.d, this.c ^= t, this.d = rotl(this.d, 11), result;
224
+ }
225
+ next_float() {
226
+ return this.next_u32() / (4294967296);
227
+ }
228
+ };
229
+ function rotl(x, k) {
230
+ return (x << k | x >>> 32 - k) >>> 0;
231
+ }
232
+ function localRandom(services) {
233
+ let pool = new RandomPool(services);
234
+ return {
235
+ cosmetic: () => pool.u32() / (4294967296),
236
+ async seed(request) {
237
+ let words = [0, 0, 0, 0];
238
+ for (let i = 0; i < (4); i++) words[i] = pool.u32();
239
+ return { label: request.label, recorded: false, scope: request.scope, words };
240
+ },
241
+ stream: (grant) => new Xoshiro128(grant.words)
242
+ };
243
+ }
244
+ function localCrypto(services) {
245
+ return {
246
+ sha256: (input, out) => sha256Into(input, out),
247
+ random_bytes: (out) => services.random_fill(out),
248
+ verify: (key, message, signature) => services.verify_ed25519(key, message, signature)
249
+ };
250
+ }
251
+ function localIds(services) {
252
+ let pool = new RandomPool(services), uuid = new Uint8Array((16));
253
+ return {
254
+ uuid_v7() {
255
+ let ms = services.now_ms(), high = Math.floor(ms / (4294967296)), low = ms >>> 0;
256
+ uuid[0] = high >>> 8 & 255, uuid[1] = high & 255, uuid[2] = low >>> 24, uuid[3] = low >>> 16 & 255, uuid[4] = low >>> 8 & 255, uuid[5] = low & 255;
257
+ for (let i = 6; i < (16); i++) uuid[i] = pool.byte();
258
+ uuid[6] = (112) | uuid[6] & 15, uuid[8] = (128) | uuid[8] & 63;
259
+ let out = "";
260
+ for (let i = 0; i < (16); i++)
261
+ (i === 4 || i === 6 || i === 8 || i === 10) && (out += "-"), out += HEX[uuid[i] >>> 4] + HEX[uuid[i] & 15];
262
+ return out;
263
+ },
264
+ ulid() {
265
+ let ms = services.now_ms(), time = "";
266
+ for (let i = 0; i < (10); i++)
267
+ time = CROCKFORD[ms % 32] + time, ms = Math.floor(ms / 32);
268
+ let random = "";
269
+ for (let i = 0; i < (16); i++) random += CROCKFORD[pool.byte() & 31];
270
+ return time + random;
271
+ },
272
+ short(length) {
273
+ let out = "";
274
+ for (let i = 0; i < length; i++) out += SHORT_ALPHABET[pool.u32() % SHORT_ALPHABET.length];
275
+ return out;
276
+ },
277
+ fill: (out) => services.random_fill(out)
278
+ };
279
+ }
280
+ function localClock(services, offsetMs) {
281
+ let now = () => services.now_ms() + offsetMs;
282
+ return {
283
+ now,
284
+ async sync() {
285
+ return { now: now(), source: "app_clock", display_offset_ms: offsetMs, room_tick: null };
286
+ }
287
+ };
288
+ }
289
+ function localLocale(info) {
290
+ let numbers = /* @__PURE__ */ new Map(), money = /* @__PURE__ */ new Map(), time = new Intl.DateTimeFormat(info.language, { timeStyle: "short", timeZone: info.time_zone });
291
+ return {
292
+ ...info,
293
+ format_number(value, fraction_digits) {
294
+ let digits = fraction_digits ?? -1, format = numbers.get(digits);
295
+ return format === void 0 && (format = new Intl.NumberFormat(
296
+ info.language,
297
+ digits < 0 ? {} : { minimumFractionDigits: digits, maximumFractionDigits: digits }
298
+ ), numbers.set(digits, format)), format.format(value);
299
+ },
300
+ format_money(amount, currency) {
301
+ let code = currency ?? info.currency, format = money.get(code);
302
+ return format === void 0 && (format = new Intl.NumberFormat(info.language, { style: "currency", currency: code }), money.set(code, format)), format.format(Number(amount));
303
+ },
304
+ format_time: (unix_ms) => time.format(unix_ms)
305
+ };
306
+ }
307
+
308
+ // src/interactives/runtime/guest-ctx.ts
309
+ var GuestUnavailableError = class extends Error {
310
+ constructor(member) {
311
+ super(`ctx.${member} is not available in the native profile`), this.name = "GuestUnavailableError", this.member = member;
312
+ }
313
+ }, CLIP_FAILURES = /* @__PURE__ */ new Set(["unavailable", "nothing_recorded", "unknown_clip", "camera_consent", "failed"]), ClipError = class extends Error {
314
+ constructor(code) {
315
+ super(`the clip was not saved (${code})`);
316
+ this.code = code;
317
+ this.name = "ClipError";
318
+ }
319
+ };
320
+ function mediaRef(value) {
321
+ if (value === null || typeof value != "object") throw new ClipError("unavailable");
322
+ let reply = value;
323
+ if (typeof reply.media_id == "string") return typeof reply.url == "string" ? { media_id: reply.media_id, url: reply.url } : { media_id: reply.media_id };
324
+ let code = reply.error?.code;
325
+ throw new ClipError(typeof code == "string" && CLIP_FAILURES.has(code) ? code : "failed");
326
+ }
327
+ function clipMedia(core) {
328
+ return {
329
+ open: () => Promise.reject(new GuestUnavailableError("media.open")),
330
+ async record_clip(_surface, max_duration_ms) {
331
+ let started = await core.command({ kind: "clip_start", max_ms: max_duration_ms }, true);
332
+ if (started === null || typeof started != "object" || typeof started.clip != "number") throw new ClipError("unavailable");
333
+ let clip = started.clip;
334
+ return {
335
+ stop: async () => mediaRef(await core.command({ kind: "clip_stop", clip }, true)),
336
+ cancel: () => {
337
+ core.command({ kind: "clip_cancel", clip }, false);
338
+ }
339
+ };
340
+ },
341
+ keep_clip: async (ms) => mediaRef(await core.command({ kind: "clip_keep", ms }, true)),
342
+ save_replay: async (replay) => mediaRef(await core.command({ kind: "replay_save", replay: encodeBase64(replay) }, true)),
343
+ on_replay: (listener) => core.on_replay === void 0 ? () => {
344
+ } : core.on_replay(listener)
345
+ };
346
+ }
347
+ var EMPTY = {};
348
+ function unavailable(member) {
349
+ throw new GuestUnavailableError(member);
350
+ }
351
+ function missing(prefix, members) {
352
+ let out = {};
353
+ for (let member of members)
354
+ Object.defineProperty(out, member, { get: () => unavailable(`${prefix}.${member}`), enumerable: true });
355
+ return out;
356
+ }
357
+ function realtimeOf(handle, profile) {
358
+ let tick = handle.tick;
359
+ if (profile === null || tick === null || tick === void 0) return null;
360
+ let dialers = profile.dialers(tick.endpoints);
361
+ return { ticket: decodeBase64(tick.ticket), expires_at: tick.expires_at, primary: dialers.primary, fallback: dialers.fallback };
362
+ }
363
+ function createGuestCtx(core, profile = null) {
364
+ let call = (operation) => (request) => core.call(operation, request), call0 = (operation) => () => core.call(operation, EMPTY), bound = (operation, field, value) => (request) => core.call(operation, { ...request, [field]: value }), fixed = (operation, request) => () => core.call(operation, request), events = (grant) => ({
365
+ on_event(listener) {
366
+ return core.subscribe(grant, (event) => listener(event.event));
367
+ }
368
+ }), familyEvents = (family) => ({
369
+ on_event(listener) {
370
+ return core.family(family, (event) => listener(event.event));
371
+ }
372
+ }), program = { ...core.program, set_status: call("program.set_status"), ready: () => core.mark("ready_for_input") }, openStore = async (request) => {
373
+ let handle = await core.call("store.open", request), store_id = handle.store_id, grant = null;
374
+ return {
375
+ handle,
376
+ get: bound("store.get", "store_id", store_id),
377
+ list: bound("store.list", "store_id", store_id),
378
+ commit: bound("store.commit", "store_id", store_id),
379
+ checkpoint: bound("store.checkpoint", "store_id", store_id),
380
+ restore: bound("store.restore", "store_id", store_id),
381
+ migrate: bound("store.migrate", "store_id", store_id),
382
+ on_event(listener) {
383
+ grant ?? (grant = core.call("store.subscribe", { store_id }).then((subscription) => subscription.grant));
384
+ let stop = null, stopped = false;
385
+ return grant.then((g) => {
386
+ stopped || (stop = core.subscribe(g, (event) => listener(event.event)));
387
+ }), () => {
388
+ stopped = true, stop?.();
389
+ };
390
+ }
391
+ };
392
+ }, roomApi = (handle) => {
393
+ let room_id = handle.state.room_id;
394
+ return {
395
+ handle,
396
+ realtime: realtimeOf(handle, profile),
397
+ inputs: new RoomInputPublisher(core.lane, handle.slot),
398
+ leave: fixed("room.leave", { room_id }),
399
+ state: fixed("room.state", { room_id }),
400
+ move: bound("room.move", "room_id", room_id),
401
+ view: fixed("room.view", { room_id }),
402
+ history: bound("room.history", "room_id", room_id),
403
+ control: bound("room.control", "room_id", room_id),
404
+ commit_result: bound("room.commit_result", "room_id", room_id),
405
+ on_input: (listener) => onSlot(core.lane.roomInputs, handle.slot, listener),
406
+ ...events(handle.grant)
407
+ };
408
+ }, channelApi = (handle) => {
409
+ let publisher = new ChannelPublisher(core.lane, handle.slot, handle.max_payload_bytes);
410
+ return {
411
+ handle,
412
+ slot: handle.slot,
413
+ max_payload_bytes: publisher.max_payload_bytes,
414
+ payload: () => publisher.payload(),
415
+ send: (length, flags) => publisher.send(length, flags),
416
+ on_message: (listener) => onSlot(core.lane.channels, handle.slot, listener),
417
+ close: fixed("channel.close", { channel_id: handle.channel_id }),
418
+ on_event: (listener) => core.family("channel", (event) => listener(event.event))
419
+ };
420
+ }, worldAdmin = (world_id) => ({
421
+ invite: bound("world.invite", "world_id", world_id),
422
+ set_role: bound("world.set_role", "world_id", world_id),
423
+ moderate: bound("world.moderate", "world_id", world_id)
424
+ }), worldSessionApi = (session) => {
425
+ let world_id = session.world_id;
426
+ return {
427
+ session,
428
+ realtime: realtimeOf(session, profile),
429
+ ...worldAdmin(world_id),
430
+ move: (input) => sendMove(core.lane, input),
431
+ on_presence: (listener) => onPresence(core.lane, listener),
432
+ emote: bound("world.emote", "world_id", world_id),
433
+ set_visibility: bound("world.set_visibility", "world_id", world_id),
434
+ enter_venue: bound("world.enter_venue", "world_id", world_id),
435
+ exit_venue: call("world.exit_venue"),
436
+ nearby: bound("world.nearby", "world_id", world_id),
437
+ leave: fixed("world.leave", { world_id }),
438
+ ...events(session.grant)
439
+ };
440
+ }, gameUi = null, ui = {
441
+ game: (options) => {
442
+ if (gameUi !== null) return gameUi;
443
+ let assets = profile?.assets, packaged = assets?.has?.(TEXT_DICTIONARIES_ASSET) === true, created = new GameUi(
444
+ { submit: (bytes, length) => core.game_ui(bytes, length) },
445
+ { ...options, reserve: TAG_BYTES, dictionaries: options?.dictionaries ?? packaged }
446
+ );
447
+ return packaged && assets !== void 0 && breakDictionaries() === null && assets.take(TEXT_DICTIONARIES_ASSET).then(
448
+ (bytes) => {
449
+ registerBreakDictionaries(bytes.slice().buffer);
450
+ },
451
+ () => {
452
+ }
453
+ ), core.on_game_ui((bytes) => created.dispatch(bytes, TAG_BYTES)), gameUi = created, created;
454
+ },
455
+ render: (tree) => core.render(tree),
456
+ present: (mode) => core.command({ kind: "present", mode }, true).then(() => {
457
+ }),
458
+ open_sheet: (request) => core.command({ kind: "open_sheet", request }, true),
459
+ open_handoff: (handoff_id) => core.command({ kind: "open_handoff", handoff_id }, true),
460
+ toast: (text) => {
461
+ core.command({ kind: "toast", text }, false);
462
+ },
463
+ haptic: (haptic) => {
464
+ core.command({ kind: "haptic", haptic }, false);
465
+ },
466
+ announce: (text) => {
467
+ core.command({ kind: "announce", text }, false);
468
+ },
469
+ on_event: (listener) => core.on_ui(listener)
470
+ }, loop = profile?.loop, camera = profile?.camera, gameBase = missing("game", loop === void 0 ? ["kit_version", "loop", "scenes", "camera", "feel"] : ["kit_version", "scenes", "camera", "feel"]);
471
+ loop !== void 0 && Object.defineProperty(gameBase, "loop", { value: loop, enumerable: true });
472
+ let game = Object.assign(gameBase, {
473
+ create_physics: () => unavailable("game.create_physics"),
474
+ saves: () => unavailable("game.saves"),
475
+ turns: () => unavailable("game.turns"),
476
+ leaderboards: {
477
+ async submit(request) {
478
+ let receipt = await core.call("game.leaderboards.submit", request);
479
+ return receipt.status !== "rejected" && core.complete({ outcome: "finished", score: receipt.score }), receipt;
480
+ },
481
+ page: call("game.leaderboards.page")
482
+ },
483
+ achievements: { list: call0("game.achievements.list"), progress: call("game.achievements.progress") },
484
+ economy: {
485
+ catalogue: call0("game.economy.catalogue"),
486
+ balances: call("game.economy.balances"),
487
+ grant: call("game.economy.grant"),
488
+ spend: call("game.economy.spend"),
489
+ propose_trade: call("game.economy.trade.propose"),
490
+ accept_trade: call("game.economy.trade.accept"),
491
+ cancel_trade: call("game.economy.trade.cancel"),
492
+ exchange: call("game.economy.exchange")
493
+ }
494
+ });
495
+ return {
496
+ program,
497
+ session: {
498
+ complete(request) {
499
+ return core.complete({ outcome: request.outcome, score: request.score ?? null }), core.call("program.complete", request);
500
+ }
501
+ },
502
+ clock: localClock(core.services, core.clock_offset_ms),
503
+ random: localRandom(core.services),
504
+ locale: localLocale(core.locale),
505
+ identity: {
506
+ current: call0("identity.current"),
507
+ personas: call("identity.personas"),
508
+ profile: call0("identity.profile")
509
+ },
510
+ social: {
511
+ friends: call("social.friends"),
512
+ challenge: call("social.challenge"),
513
+ invite: call("social.invite"),
514
+ post: call("social.post"),
515
+ remix_lineage: call0("social.remix_lineage"),
516
+ avatars: call("social.avatars"),
517
+ avatar_consent: call("social.avatar_consent")
518
+ },
519
+ open_store: openStore,
520
+ async schedule(request) {
521
+ let task = await core.call("schedule.create", request), ref = { task_id: task.task_id };
522
+ return {
523
+ task,
524
+ status: fixed("schedule.status", ref),
525
+ cancel: fixed("schedule.cancel", ref),
526
+ ...familyEvents("schedule")
527
+ };
528
+ },
529
+ compute: call("compute.invoke"),
530
+ async create_worker(request) {
531
+ let handle = await core.call("worker.create", request);
532
+ return {
533
+ handle,
534
+ post: bound("worker.post", "worker_id", handle.worker_id),
535
+ terminate: fixed("worker.terminate", { worker_id: handle.worker_id }),
536
+ ...events(handle.grant)
537
+ };
538
+ },
539
+ create_local_worker: () => unavailable("create_local_worker"),
540
+ create_room: async (request) => roomApi(await core.call("room.create", request)),
541
+ join_room: async (request) => roomApi(await core.call("room.join", request)),
542
+ create_channel: async (request) => channelApi(await core.call("channel.open", request)),
543
+ create_world: async (request) => {
544
+ let handle = await core.call("world.create", request);
545
+ return { handle, ...worldAdmin(handle.world_id) };
546
+ },
547
+ join_world: async (request) => worldSessionApi(await core.call("world.join", request)),
548
+ list_worlds: call("world.list"),
549
+ game,
550
+ services: {
551
+ catalogue: { search: call("services.catalogue.search"), product: call("services.catalogue.product") },
552
+ cart: { get: call("services.cart.get"), add: call("services.cart.add"), update: call("services.cart.update") },
553
+ delivery: { quote: call("services.delivery.quote") },
554
+ purchase_intents: {
555
+ create: call("services.purchase_intents.create"),
556
+ status: call("services.purchase_intents.status")
557
+ },
558
+ orders: { list: call("services.orders.list"), get: call("services.orders.get") },
559
+ scheduling: {
560
+ availability: call("services.scheduling.availability"),
561
+ book: call("services.scheduling.book")
562
+ },
563
+ places: {
564
+ search: call("services.places.search"),
565
+ get: call("services.places.get"),
566
+ contribute: call("services.places.contribute")
567
+ },
568
+ arcs: {
569
+ progress: call("services.arcs.progress"),
570
+ record: call("services.arcs.record"),
571
+ challenges: call("services.arcs.challenges")
572
+ }
573
+ },
574
+ gifts: { kinds: call("gifts.kinds"), send: call("gifts.send"), prizes: call("gifts.prizes"), ...familyEvents("gifts") },
575
+ wallet: {
576
+ offers: call0("wallet.offers"),
577
+ spend: call("wallet.spend"),
578
+ entitlements: call0("wallet.entitlements"),
579
+ allowance: call0("wallet.allowance"),
580
+ consume: call("wallet.consume")
581
+ },
582
+ ads: { placement: call("ads.placement"), sponsored_items: call("ads.sponsored_items") },
583
+ notify: { status: call0("notify.status"), request_opt_in: call("notify.request_opt_in"), send: call("notify.send") },
584
+ moderate: { submit: call("moderate.submit"), status: call("moderate.status") },
585
+ report: { submit: call("report.submit"), block: call("report.block") },
586
+ actions: { prepare: call("actions.prepare"), execute: call("actions.execute"), receipt: call("actions.receipt") },
587
+ provider: { call: call("provider.call"), subscribe: call("provider.subscribe"), ...familyEvents("provider") },
588
+ flow: {
589
+ status: call("flow.status"),
590
+ checkpoint: call("flow.checkpoint"),
591
+ resume: call("flow.resume"),
592
+ report_result: call("flow.report_result")
593
+ },
594
+ agent: {
595
+ ask: call("agent.ask"),
596
+ cancel: call("agent.cancel"),
597
+ request_edit: call("agent.request_edit"),
598
+ ...familyEvents("agent")
599
+ },
600
+ share: call("share.open"),
601
+ db: { describe: call0("db.describe"), migrate: call("db.migrate"), query: call("db.query") },
602
+ tx: { begin: call("tx.begin"), stage: call("tx.stage"), commit: call("tx.commit"), abort: call("tx.abort") },
603
+ async open_kv(request) {
604
+ let handle = await core.call("kv.open", request), namespace_id = handle.namespace_id;
605
+ return {
606
+ handle,
607
+ fast: new LaneFastReader(core.lane, handle.slot, "kv"),
608
+ get: bound("kv.get", "namespace_id", namespace_id),
609
+ set: bound("kv.set", "namespace_id", namespace_id),
610
+ compare_and_set: bound("kv.compare_and_set", "namespace_id", namespace_id),
611
+ delete: bound("kv.delete", "namespace_id", namespace_id),
612
+ list: bound("kv.list", "namespace_id", namespace_id)
613
+ };
614
+ },
615
+ async open_cache(request) {
616
+ let handle = await core.call("cache.open", request), namespace_id = handle.namespace_id;
617
+ return {
618
+ handle,
619
+ fast: new LaneFastReader(core.lane, handle.slot, "cache"),
620
+ get: bound("cache.get", "namespace_id", namespace_id),
621
+ set: bound("cache.set", "namespace_id", namespace_id),
622
+ delete: bound("cache.delete", "namespace_id", namespace_id)
623
+ };
624
+ },
625
+ async open_counter(request) {
626
+ let handle = await core.call("counter.open", request), counter_id = handle.counter_id, fast = new LaneCounter(core.lane, handle.slot);
627
+ return {
628
+ handle,
629
+ add_fast: (delta, correlation) => fast.add(delta, correlation),
630
+ on_value: (listener) => fast.on_value(listener),
631
+ add: bound("counter.add", "counter_id", counter_id),
632
+ read: bound("counter.read", "counter_id", counter_id),
633
+ rate_limit: bound("counter.rate_limit", "counter_id", counter_id),
634
+ rank: bound("counter.rank", "counter_id", counter_id),
635
+ rank_range: bound("counter.rank_range", "counter_id", counter_id),
636
+ rank_of: bound("counter.rank_of", "counter_id", counter_id)
637
+ };
638
+ },
639
+ blob: {
640
+ put: call("blob.put"),
641
+ transfer: () => unavailable("blob.transfer"),
642
+ commit: call("blob.commit"),
643
+ get: call("blob.get"),
644
+ read: () => unavailable("blob.read"),
645
+ list: call("blob.list"),
646
+ delete: call("blob.delete")
647
+ },
648
+ queue: {
649
+ enqueue: call("queue.enqueue"),
650
+ status: call("queue.status"),
651
+ cancel: call("queue.cancel"),
652
+ stats: call("queue.stats"),
653
+ ...familyEvents("queue")
654
+ },
655
+ search: { index: call("search.index"), query: call("search.query"), remove: call("search.remove") },
656
+ ai: {
657
+ generate: call("ai.generate"),
658
+ converse: call("ai.converse"),
659
+ speak: call("ai.speak"),
660
+ transcribe: call("ai.transcribe"),
661
+ image: call("ai.image"),
662
+ translate: call("ai.translate"),
663
+ prefetch: call("ai.prefetch"),
664
+ cancel: call("ai.cancel"),
665
+ forget: call("ai.forget"),
666
+ usage: call0("ai.usage"),
667
+ content: call("ai.content"),
668
+ content_prefetch: call("ai.content_prefetch"),
669
+ watch(run, listener) {
670
+ return run.grant ? core.subscribe(run.grant, (event) => listener(event.event)) : (run.result && listener({ kind: "completed", result: run.result }), () => {
671
+ });
672
+ },
673
+ ...familyEvents("ai")
674
+ },
675
+ generate: createGenerate({ content: call("ai.content"), content_prefetch: call("ai.content_prefetch") }),
676
+ pubsub: {
677
+ async subscribe(request) {
678
+ let subscription = await core.call("pubsub.subscribe", request), publisher = new ChannelPublisher(core.lane, subscription.slot, subscription.max_payload_bytes);
679
+ return {
680
+ subscription,
681
+ slot: subscription.slot,
682
+ max_payload_bytes: publisher.max_payload_bytes,
683
+ payload: () => publisher.payload(),
684
+ send: (length, flags) => publisher.send(length, flags),
685
+ publish: bound("pubsub.publish", "topic", subscription.topic),
686
+ on_message: (listener) => onSlot(core.lane.channels, subscription.slot, listener),
687
+ close: () => core.call("events.cancel", { subscription_id: subscription.grant.subscription_id }).then(() => {
688
+ })
689
+ };
690
+ }
691
+ },
692
+ analytics: { track: call("analytics.track"), record: call("analytics.record"), summary: call("analytics.summary") },
693
+ secrets: { handle: call("secrets.handle"), sign: call("secrets.sign") },
694
+ ui,
695
+ graphics: profile?.graphics ?? missing("graphics", ["features", "engine", "acquire_surface", "attach_engine", "on_context_lost", "on_context_restored"]),
696
+ input: profile?.input ?? missing("input", ["bind", "pointers", "remap"]),
697
+ audio: profile?.audio ?? missing("audio", ["unlocked", "unlock", "bus", "load", "play", "stop"]),
698
+ media: clipMedia(core),
699
+ files: missing("files", ["pick", "save"]),
700
+ assets: profile?.assets ?? missing("assets", ["take", "module"]),
701
+ camera: {
702
+ request: call("camera.request"),
703
+ release: call("camera.release"),
704
+ track_face: camera ? (grant) => camera.track_face(grant) : () => unavailable("camera.track_face"),
705
+ view: camera ? (grant, placement) => camera.view(grant, placement) : () => unavailable("camera.view"),
706
+ capture_identity: camera ? (grant) => camera.capture_identity(grant) : () => Promise.reject(new IdentityCaptureError("unavailable"))
707
+ },
708
+ lifecycle: core.lifecycle,
709
+ events: {
710
+ subscribe: (family, listener) => core.family(family, (event) => listener(event.event)),
711
+ cancel: call("events.cancel"),
712
+ resume: call("events.resume")
713
+ },
714
+ crypto: localCrypto(core.services),
715
+ id: localIds(core.services),
716
+ on_dispose: (callback) => core.on_dispose(callback)
717
+ };
718
+ }
719
+
720
+ // src/interactives/runtime/guards.ts
721
+ var WASM_GLOBAL = "WebAssembly", GuardError = class extends Error {
722
+ constructor(member) {
723
+ super(`${member} is not available to Interactives; reach the platform through ctx`), this.name = "GuardError";
724
+ }
725
+ }, REMOVED_GLOBALS = [
726
+ "eval",
727
+ "Function",
728
+ "fetch",
729
+ "XMLHttpRequest",
730
+ "WebSocket",
731
+ "WebTransport",
732
+ "EventSource",
733
+ "importScripts",
734
+ "Worker",
735
+ "SharedWorker",
736
+ "indexedDB",
737
+ "caches",
738
+ "WebAssembly",
739
+ "postMessage",
740
+ "onmessage",
741
+ "onmessageerror",
742
+ "addEventListener",
743
+ "removeEventListener",
744
+ "close",
745
+ "BroadcastChannel",
746
+ "navigator",
747
+ "location",
748
+ "__cimplify_host"
749
+ ], FROZEN_GLOBALS = [
750
+ "Object",
751
+ "Array",
752
+ "Function",
753
+ "String",
754
+ "Number",
755
+ "Boolean",
756
+ "Symbol",
757
+ "BigInt",
758
+ "Promise",
759
+ "Map",
760
+ "Set",
761
+ "WeakMap",
762
+ "WeakSet",
763
+ "WeakRef",
764
+ "RegExp",
765
+ "Date",
766
+ "Error",
767
+ "TypeError",
768
+ "RangeError",
769
+ "SyntaxError",
770
+ "ReferenceError",
771
+ "EvalError",
772
+ "URIError",
773
+ "AggregateError",
774
+ "ArrayBuffer",
775
+ "DataView",
776
+ "Int8Array",
777
+ "Uint8Array",
778
+ "Uint8ClampedArray",
779
+ "Int16Array",
780
+ "Uint16Array",
781
+ "Int32Array",
782
+ "Uint32Array",
783
+ "Float32Array",
784
+ "Float64Array",
785
+ "BigInt64Array",
786
+ "BigUint64Array",
787
+ "JSON",
788
+ "Math",
789
+ "Reflect",
790
+ "Intl",
791
+ "TextEncoder",
792
+ "TextDecoder"
793
+ ], STRING_TIMERS = ["setTimeout", "setInterval"], OVERRIDABLE = ["constructor", "toString", "valueOf", "toJSON", "name", "message"], CODE_CONSTRUCTOR_SOURCES = [
794
+ () => Object.getPrototypeOf(async () => {
795
+ }),
796
+ () => Object.getPrototypeOf(function* () {
797
+ }),
798
+ () => Object.getPrototypeOf(async function* () {
799
+ })
800
+ ];
801
+ function thrower(member) {
802
+ return () => {
803
+ throw new GuardError(member);
804
+ };
805
+ }
806
+ function seal(target, name, value) {
807
+ let existing = Object.getOwnPropertyDescriptor(target, name);
808
+ existing !== void 0 && existing.configurable === false || Object.defineProperty(target, name, { value, writable: false, enumerable: false, configurable: false });
809
+ }
810
+ function enableOverride(target, name) {
811
+ let found = Object.getOwnPropertyDescriptor(target, name);
812
+ if (found === void 0 || !("value" in found) || found.configurable === false) return;
813
+ let value = found.value;
814
+ Object.defineProperty(target, name, {
815
+ get() {
816
+ return value;
817
+ },
818
+ set(next) {
819
+ if (this === target) throw new GuardError(`assigning ${name} on a shared prototype`);
820
+ Object.defineProperty(this, name, { value: next, writable: true, enumerable: true, configurable: true });
821
+ },
822
+ enumerable: found.enumerable,
823
+ configurable: false
824
+ });
825
+ }
826
+ function freezeDeep(root, seen) {
827
+ if (typeof root != "object" && typeof root != "function" || root === null || seen.has(root)) return;
828
+ seen.add(root);
829
+ let prototype = root.prototype;
830
+ for (let name of OVERRIDABLE) enableOverride(root, name);
831
+ if (typeof prototype == "object" && prototype !== null)
832
+ for (let name of OVERRIDABLE) enableOverride(prototype, name);
833
+ Object.freeze(root);
834
+ for (let key of Reflect.ownKeys(root)) {
835
+ let descriptor = Object.getOwnPropertyDescriptor(root, key);
836
+ descriptor && "value" in descriptor && freezeDeep(descriptor.value, seen);
837
+ }
838
+ freezeDeep(Object.getPrototypeOf(root), seen);
839
+ }
840
+ function hardenGlobals(global, onTask, runtimeWasm = false) {
841
+ runtimeWasm || withdrawWasm();
842
+ let functionThrower = thrower("Function");
843
+ seal(Function.prototype, "constructor", functionThrower);
844
+ for (let source of CODE_CONSTRUCTOR_SOURCES) seal(source(), "constructor", functionThrower);
845
+ for (let name of REMOVED_GLOBALS)
846
+ name !== "Function" && (name in global || Object.getOwnPropertyDescriptor(global, name) !== void 0) && seal(global, name, name === WASM_GLOBAL && runtimeWasm ? guardedWebAssembly() : void 0);
847
+ seal(global, "eval", thrower("eval"));
848
+ for (let name of STRING_TIMERS) {
849
+ let timer = global[name];
850
+ if (typeof timer != "function") continue;
851
+ let schedule = timer;
852
+ seal(global, name, (handler, ...rest) => {
853
+ if (typeof handler != "function") throw new GuardError(`${name} with a string`);
854
+ let task = handler;
855
+ return schedule((...args) => (onTask(), task(...args)), ...rest);
856
+ });
857
+ }
858
+ let seen = /* @__PURE__ */ new Set();
859
+ for (let name of FROZEN_GLOBALS) freezeDeep(global[name], seen);
860
+ for (let source of CODE_CONSTRUCTOR_SOURCES) freezeDeep(source(), seen);
861
+ seal(global, "Function", functionThrower), lockGlobal(global);
862
+ }
863
+ function lockGlobal(global) {
864
+ try {
865
+ Object.freeze(global);
866
+ return;
867
+ } catch {
868
+ for (let key of Reflect.ownKeys(global)) {
869
+ let descriptor = Object.getOwnPropertyDescriptor(global, key);
870
+ if (descriptor === void 0 || descriptor.configurable === false) continue;
871
+ let locked = "value" in descriptor ? { value: descriptor.value, writable: false, configurable: false } : { configurable: false };
872
+ Reflect.defineProperty(global, key, locked);
873
+ }
874
+ }
875
+ Reflect.preventExtensions(global);
876
+ }
877
+
878
+ // src/interactives/runtime/slice.ts
879
+ var TICK_GLOBAL = "__cimplify_tick", TICKS_PER_CHECK = 1024, DEFAULT_SLICE_MS = 2e3, SliceExceeded = class extends Error {
880
+ constructor() {
881
+ super("the Interactive ran past its time slice without returning to the host"), this.name = "SliceExceeded";
882
+ }
883
+ };
884
+ function clockBudget(now, slice_ms = 2e3) {
885
+ let deadline = Number.POSITIVE_INFINITY;
886
+ return {
887
+ begin() {
888
+ deadline = now() + slice_ms;
889
+ },
890
+ over() {
891
+ return now() > deadline;
892
+ }
893
+ };
894
+ }
895
+ var COUNT = 0, Slice = class {
896
+ constructor(budget) {
897
+ this.budget = budget;
898
+ this.counter = new Int32Array(1);
899
+ this.exceeded = false;
900
+ this.tick = () => {
901
+ let c = this.counter;
902
+ ++c[(0)] < 1024 || this.check();
903
+ };
904
+ }
905
+ get dead() {
906
+ return this.exceeded;
907
+ }
908
+ begin() {
909
+ this.exceeded || this.budget.begin();
910
+ }
911
+ check() {
912
+ let c = this.counter;
913
+ if (c[(0)] = 0, !this.exceeded) {
914
+ if (!this.budget.over()) return;
915
+ this.exceeded = true;
916
+ }
917
+ throw c[(0)] = 1024, new SliceExceeded();
918
+ }
919
+ };
920
+
921
+ // src/interactives/runtime/guest.ts
922
+ var CTX_REQUEST_DEADLINE_MS = 5e3, CTX_CONFIRMED_REQUEST_DEADLINE_MS = 3e5, CTX_LONG_REQUEST_DEADLINES_MS = {
923
+ ai: 12e4,
924
+ compute: 6e4,
925
+ worker: 6e4,
926
+ agent: 12e4,
927
+ flow: 3e5,
928
+ share: 3e5,
929
+ camera: 3e5
930
+ }, CAPABILITY_FAMILIES = CTX_CAPABILITIES, NEVER_CONFIRMED = "never", SEGMENT = ".";
931
+ function ctxFamilyOf(operation) {
932
+ let name = operation;
933
+ for (; !(name in CAPABILITY_FAMILIES); ) {
934
+ let at = name.lastIndexOf(SEGMENT);
935
+ if (at < 0) return operation.slice(0, Math.max(0, operation.indexOf(SEGMENT)));
936
+ name = name.slice(0, at);
937
+ }
938
+ return name;
939
+ }
940
+ function ctxRequestDeadlineMs(family) {
941
+ let long = CTX_LONG_REQUEST_DEADLINES_MS[family];
942
+ return long !== void 0 ? long : (CAPABILITY_FAMILIES[family]?.confirmation ?? NEVER_CONFIRMED) === NEVER_CONFIRMED ? (5e3) : (3e5);
943
+ }
944
+ function timerStart() {
945
+ return typeof globalThis.setTimeout == "function" ? globalThis.setTimeout.bind(globalThis) : null;
946
+ }
947
+ function timerStop() {
948
+ return typeof globalThis.clearTimeout == "function" ? globalThis.clearTimeout.bind(globalThis) : null;
949
+ }
950
+ var SLICE_MESSAGE = new SliceExceeded().message, LIFECYCLE_STATE = {
951
+ ready: "ready",
952
+ visible: "visible",
953
+ hidden: "hidden",
954
+ suspend: "suspended",
955
+ resume: "visible",
956
+ revision_update: null,
957
+ dispose: "disposed"
958
+ };
959
+ function describe(error, phase) {
960
+ return error instanceof Error ? error.message : phase === "slice" ? SLICE_MESSAGE : typeof error == "object" && error !== null ? JSON.stringify(error) : String(error);
961
+ }
962
+ function remove(list, item) {
963
+ let at = list.indexOf(item);
964
+ at >= 0 && list.splice(at, 1);
965
+ }
966
+ var GuestRuntime = class {
967
+ constructor(options) {
968
+ this.options = options;
969
+ this.writer = new MessageWriter();
970
+ this.pending = /* @__PURE__ */ new Map();
971
+ this.subscriptions = /* @__PURE__ */ new Map();
972
+ this.families = /* @__PURE__ */ new Map();
973
+ this.uiListeners = [];
974
+ this.gameUiListeners = [];
975
+ this.replies = /* @__PURE__ */ new Map();
976
+ this.lifecycleListeners = /* @__PURE__ */ new Map();
977
+ this.disposers = [];
978
+ this.replayListeners = [];
979
+ this.heldReplay = null;
980
+ this.differ = new TreeDiffer();
981
+ this.pong = new Uint8Array(PONG_BYTES);
982
+ this.milestoneMessage = new Uint8Array(MILESTONE_BYTES);
983
+ this.completeMessage = new Uint8Array(SESSION_COMPLETE_BYTES);
984
+ this.reached = /* @__PURE__ */ new Set();
985
+ this.pongView = new DataView(this.pong.buffer);
986
+ this.boot = null;
987
+ this.state = "loading";
988
+ this.nextRequest = 0;
989
+ this.nextCommand = 0;
990
+ this.sliceReported = false;
991
+ this.arriving = [];
992
+ this.wanted = /* @__PURE__ */ new Map();
993
+ this.requested = new ChunkBatch(MessageTag.chunk_request, CHUNK_REQUEST_ENTRY_BYTES);
994
+ this.released = new ChunkBatch(MessageTag.chunk_release, CHUNK_RELEASE_ENTRY_BYTES);
995
+ this.chunkFlushQueued = false;
996
+ this.studioIn = new StudioAssembler();
997
+ this.studioOut = new StudioSender(MessageTag.studio_report, (frame) => this.bridge.send(frame, frame.length));
998
+ this.flushChunks = () => {
999
+ this.chunkFlushQueued = false, this.released.size > 0 && this.bridge.send(this.released.bytes, this.released.seal()), this.requested.size > 0 && this.bridge.send(this.requested.bytes, this.requested.seal());
1000
+ };
1001
+ this.chunkChannel = {
1002
+ request: (digest, priority) => this.queueChunk(this.requested, digest, priority),
1003
+ release: (digest) => this.queueChunk(this.released, digest, ChunkPriority.now)
1004
+ };
1005
+ this.starting = false;
1006
+ this.startTimer = void 0;
1007
+ this.stopTimer = void 0;
1008
+ this.lifecycle = lifecycleOf(this);
1009
+ this.bridge = options.bridge, this.services = options.services, this.assembler = new PackageAssembler(options.on_runtime_wasm ?? null, options.native_runtimes ?? null, options.assets ?? null), this.lane = new FrameLane(this.bridge), this.bridge.on_message((bytes) => this.receive(bytes)), reportMetersTo((live) => this.send(this.writer.json(MessageTag.meter_report, live)), options.heap_bytes ?? null), this.pong[0] = MessageTag.pong, this.send(this.writer.tag(MessageTag.ready));
1010
+ }
1011
+ get program() {
1012
+ return this.boot.program;
1013
+ }
1014
+ get locale() {
1015
+ return this.boot.locale;
1016
+ }
1017
+ get clock_offset_ms() {
1018
+ return this.boot.clock_offset_ms;
1019
+ }
1020
+ current() {
1021
+ return this.state;
1022
+ }
1023
+ onLifecycle(event, listener) {
1024
+ let list = this.lifecycleListeners.get(event) ?? [];
1025
+ return list.push(listener), this.lifecycleListeners.set(event, list), () => remove(list, listener);
1026
+ }
1027
+ needRuntime(unit, priority = ChunkPriority.now) {
1028
+ let digest = this.assembler.lateRuntime(unit);
1029
+ return digest === null || this.assembler.holdsWasm(digest) ? false : (this.queueChunk(this.requested, digest, priority), true);
1030
+ }
1031
+ mark(name) {
1032
+ let code = Milestone[name];
1033
+ this.reached.has(code) || (this.reached.add(code), this.milestoneMessage[0] = MessageTag.milestone, this.milestoneMessage[1] = code, this.bridge.send(this.milestoneMessage, MILESTONE_BYTES));
1034
+ }
1035
+ send(length) {
1036
+ this.bridge.send(this.writer.bytes, length);
1037
+ }
1038
+ fault(phase, error) {
1039
+ if (this.services.slice.dead) {
1040
+ if (this.sliceReported) return;
1041
+ this.sliceReported = true, phase = "slice";
1042
+ }
1043
+ let fault = {
1044
+ phase,
1045
+ message: describe(error, phase),
1046
+ stack: error instanceof Error && typeof error.stack == "string" ? error.stack : null
1047
+ };
1048
+ this.send(this.writer.json(MessageTag.fault, fault));
1049
+ }
1050
+ call(operation, request) {
1051
+ let boot = this.boot, request_id = `g${this.nextRequest++}`, envelope = {
1052
+ contract_version: 1,
1053
+ request_id,
1054
+ interactive_id: boot.program.interactive_id,
1055
+ revision: boot.program.revision,
1056
+ deadline_ms: boot.deadline_ms,
1057
+ call: { operation, arguments: request }
1058
+ }, family = ctxFamilyOf(operation), deadline = this.options.request_deadline_ms?.(family) ?? ctxRequestDeadlineMs(family);
1059
+ this.startTimer ?? (this.startTimer = timerStart());
1060
+ let startTimer = this.startTimer;
1061
+ return new Promise((resolve, reject) => {
1062
+ let timer = startTimer === null ? null : startTimer(() => this.expire(request_id, family), deadline);
1063
+ this.pending.set(request_id, { resolve, reject, timer }), this.send(this.writer.json(MessageTag.request, envelope));
1064
+ });
1065
+ }
1066
+ expire(request_id, family) {
1067
+ let waiting = this.pending.get(request_id);
1068
+ waiting !== void 0 && (this.pending.delete(request_id), waiting.reject({ code: "unavailable", family, retry_after_ms: null }));
1069
+ }
1070
+ subscribe(grant, listener) {
1071
+ return this.listen(this.subscriptions, grant.subscription_id, listener);
1072
+ }
1073
+ family(family, listener) {
1074
+ return this.listen(this.families, family, listener);
1075
+ }
1076
+ listen(table, key, listener) {
1077
+ return table.set(key, [...table.get(key) ?? [], listener]), () => {
1078
+ let rest = (table.get(key) ?? []).filter((l) => l !== listener);
1079
+ rest.length === 0 ? table.delete(key) : table.set(key, rest);
1080
+ };
1081
+ }
1082
+ render(tree) {
1083
+ if (this.state !== "disposed")
1084
+ try {
1085
+ let patches = this.differ.diff(tree);
1086
+ patches.length > 0 && this.send(this.writer.json(MessageTag.render, patches));
1087
+ } catch (error) {
1088
+ this.fault("render", error);
1089
+ }
1090
+ }
1091
+ command(command, awaited) {
1092
+ let id = awaited ? ++this.nextCommand : 0;
1093
+ return this.send(this.writer.json(MessageTag.ui_command, { id, command })), awaited ? new Promise((resolve) => this.replies.set(id, resolve)) : Promise.resolve(void 0);
1094
+ }
1095
+ on_ui(listener) {
1096
+ return this.uiListeners.push(listener), () => remove(this.uiListeners, listener);
1097
+ }
1098
+ complete(message) {
1099
+ this.state !== "disposed" && this.bridge.send(this.completeMessage, writeSessionComplete(this.completeMessage, message));
1100
+ }
1101
+ game_ui(bytes, length) {
1102
+ this.state !== "disposed" && (bytes[0] = MessageTag.game_ui, this.bridge.send(bytes, length));
1103
+ }
1104
+ on_game_ui(listener) {
1105
+ return this.gameUiListeners.push(listener), () => remove(this.gameUiListeners, listener);
1106
+ }
1107
+ dispatchGameUi(bytes) {
1108
+ for (let i = 0; i < this.gameUiListeners.length; i++)
1109
+ try {
1110
+ this.gameUiListeners[i](bytes);
1111
+ } catch (error) {
1112
+ this.fault("run", error);
1113
+ }
1114
+ }
1115
+ on_dispose(callback) {
1116
+ this.disposers.push(callback);
1117
+ }
1118
+ receive(bytes) {
1119
+ this.services.slice.begin();
1120
+ try {
1121
+ this.handle(bytes);
1122
+ } catch (error) {
1123
+ this.fault("run", error);
1124
+ }
1125
+ this.services.slice.dead && this.fault("slice", null);
1126
+ }
1127
+ notify(listeners, event) {
1128
+ if (listeners !== void 0)
1129
+ for (let i = 0; i < listeners.length; i++)
1130
+ try {
1131
+ listeners[i](event);
1132
+ } catch (error) {
1133
+ this.fault("run", error);
1134
+ }
1135
+ }
1136
+ handle(bytes) {
1137
+ switch (bytes[0]) {
1138
+ case MessageTag.response:
1139
+ this.answer(readJson(bytes));
1140
+ return;
1141
+ case MessageTag.event:
1142
+ this.deliver(readJson(bytes));
1143
+ return;
1144
+ case MessageTag.frames:
1145
+ this.lane.receive(bytes);
1146
+ return;
1147
+ case MessageTag.ui_event:
1148
+ this.dispatchUi(readJson(bytes));
1149
+ return;
1150
+ case MessageTag.ui_reply:
1151
+ this.reply(readJson(bytes));
1152
+ return;
1153
+ case MessageTag.game_ui_event:
1154
+ this.dispatchGameUi(bytes);
1155
+ return;
1156
+ case MessageTag.ping:
1157
+ this.answerPing(bytes);
1158
+ return;
1159
+ case MessageTag.lifecycle:
1160
+ this.transition(LIFECYCLE_BY_CODE[bytes[TAG_BYTES]] ?? null);
1161
+ return;
1162
+ case MessageTag.boot:
1163
+ this.boot = readJson(bytes), this.options.on_boot?.(this.boot), (this.boot.chunk_requests ?? 0) >= CHUNK_REQUESTS_VERSION && this.options.assets?.connect?.(this.chunkChannel), this.boot.network !== void 0 && this.options.assets?.network?.(this.boot.network);
1164
+ return;
1165
+ case MessageTag.network: {
1166
+ let hint = readNetworkHint(bytes);
1167
+ hint !== null && this.options.assets?.network?.(hint);
1168
+ return;
1169
+ }
1170
+ case MessageTag.inspector:
1171
+ requestInspector(bytes[TAG_BYTES] === INSPECTOR_SHOWN);
1172
+ return;
1173
+ case MessageTag.meters:
1174
+ requestMeters(readJson(bytes));
1175
+ return;
1176
+ case MessageTag.studio: {
1177
+ openStudioChannel((message2) => this.studioOut.post(message2));
1178
+ let message = this.studioIn.accept(bytes);
1179
+ message !== null && deliverStudio(message);
1180
+ return;
1181
+ }
1182
+ case MessageTag.chunk_failed:
1183
+ this.chunkFailed(bytes);
1184
+ return;
1185
+ case MessageTag.chunk:
1186
+ this.acceptChunk(bytes);
1187
+ return;
1188
+ case MessageTag.stage:
1189
+ this.stageChunk(bytes);
1190
+ return;
1191
+ case MessageTag.chunk_ref:
1192
+ this.acceptRef(bytes, false);
1193
+ return;
1194
+ case MessageTag.stage_ref:
1195
+ this.acceptRef(bytes, true);
1196
+ return;
1197
+ case MessageTag.warm:
1198
+ this.warm(readJson(bytes));
1199
+ return;
1200
+ case MessageTag.start:
1201
+ this.start();
1202
+ return;
1203
+ case MessageTag.hot:
1204
+ this.hot(readJson(bytes));
1205
+ return;
1206
+ case MessageTag.replay: {
1207
+ let opened = readReplayMessage(bytes);
1208
+ if (opened === null) return;
1209
+ this.replayListeners.length === 0 && (this.heldReplay = opened);
1210
+ for (let i = 0; i < this.replayListeners.length; i++) this.replayListeners[i](opened.replay, opened.mode);
1211
+ return;
1212
+ }
1213
+ }
1214
+ }
1215
+ on_replay(listener) {
1216
+ this.replayListeners.push(listener);
1217
+ let held = this.heldReplay;
1218
+ return this.heldReplay = null, held !== null && listener(held.replay, held.mode), () => remove(this.replayListeners, listener);
1219
+ }
1220
+ async hot(request) {
1221
+ let done = (result) => this.send(this.writer.json(MessageTag.hot_done, result)), linker = this.services.linker;
1222
+ if (!this.starting || this.state === "loading" || this.state === "disposed") return done({ swapped: false, reason: "the Interactive is not running" });
1223
+ if (linker.relink === void 0) return done({ swapped: false, reason: "this host cannot swap code in place" });
1224
+ if (!hotAccepted()) return done({ swapped: false, reason: "the Interactive does not accept code swaps" });
1225
+ await this.arrivals();
1226
+ let changedAssets = this.assembler.swapIndex(request.chunks);
1227
+ if (changedAssets === null) return done({ swapped: false, reason: "more than the code and assets changed" });
1228
+ try {
1229
+ let { entry, modules } = this.assembler.modules(new Set(this.boot?.bytecode_modules ?? [])), linked = await relinkingDefinitions(() => linker.relink.call(linker, modules, entry, this.services.slice.tick)), report = applyHot(linked, changedAssets);
1230
+ done(report === null ? { swapped: !1, reason: "the new code has no hot export" } : { swapped: !0, report });
1231
+ } catch (error) {
1232
+ done({ swapped: false, reason: error instanceof Error ? error.message : String(error) });
1233
+ }
1234
+ }
1235
+ acceptChunk(bytes) {
1236
+ readinessProbe()?.chunk(bytes.length - TAG_BYTES - DIGEST_BYTES);
1237
+ try {
1238
+ this.assembler.accept(bytes.subarray(TAG_BYTES, TAG_BYTES + DIGEST_BYTES), bytes.subarray(TAG_BYTES + DIGEST_BYTES));
1239
+ } catch (error) {
1240
+ this.fault("boot", error);
1241
+ }
1242
+ this.arrived(bytes);
1243
+ }
1244
+ arrived(bytes) {
1245
+ if (this.wanted.size === 0) return;
1246
+ let digest = hex(bytes.subarray(TAG_BYTES, TAG_BYTES + DIGEST_BYTES)), resolve = this.wanted.get(digest);
1247
+ resolve !== void 0 && (this.wanted.delete(digest), resolve());
1248
+ }
1249
+ acceptRef(bytes, staged) {
1250
+ let digest = hex(bytes.subarray(TAG_BYTES, TAG_BYTES + DIGEST_BYTES)), payload = hex(bytes.subarray(TAG_BYTES + DIGEST_BYTES, TAG_BYTES + DIGEST_BYTES + DIGEST_BYTES));
1251
+ this.arriving.push(this.fetchRef(digest, payload, staged));
1252
+ }
1253
+ async fetchRef(digest, payload, staged) {
1254
+ let fetched = this.options.fetch_wasm?.(digest, payload) ?? null, bytes = fetched === null ? null : await fetched.catch(() => null);
1255
+ if (bytes === null) {
1256
+ await this.want(digest);
1257
+ return;
1258
+ }
1259
+ staged ? this.options.on_staged_wasm?.(digest, this.assembler.stage(digest, bytes)) : this.assembler.acceptWasmPayload(digest, bytes);
1260
+ }
1261
+ want(digest) {
1262
+ return new Promise((resolve) => {
1263
+ this.wanted.set(digest, resolve), this.queueChunk(this.requested, digest, ChunkPriority.now);
1264
+ });
1265
+ }
1266
+ queueChunk(batch, digest, priority) {
1267
+ batch.full && this.flushChunks(), batch.add(digest, priority) && (this.chunkFlushQueued || (this.chunkFlushQueued = true, queueMicrotask(this.flushChunks)));
1268
+ }
1269
+ chunkFailed(bytes) {
1270
+ let failed = readChunkFailed(bytes);
1271
+ failed !== null && (this.wanted.has(failed.digest) && (this.wanted.delete(failed.digest), this.fault("boot", new Error(`the host could not deliver chunk ${failed.digest} (${failed.reason})`))), this.options.assets?.fail?.(failed.digest, failed.reason));
1272
+ }
1273
+ async arrivals() {
1274
+ for (; this.arriving.length > 0; ) await Promise.all(this.arriving.splice(0));
1275
+ }
1276
+ async warm(image) {
1277
+ await this.arrivals(), await this.options.on_warm?.(image)?.catch(() => {
1278
+ }), this.send(this.writer.tag(MessageTag.warmed));
1279
+ }
1280
+ stageChunk(bytes) {
1281
+ try {
1282
+ let chunk = decodeChunk(bytes.subarray(TAG_BYTES + DIGEST_BYTES)), digest = hex(bytes.subarray(TAG_BYTES, TAG_BYTES + DIGEST_BYTES));
1283
+ chunk.kind === ChunkKind.data ? this.options.assets?.accept(digest, chunk.payload) : chunk.kind === ChunkKind.wasm ? this.options.on_staged_wasm?.(digest, this.assembler.stage(digest, chunk.payload)) : chunk.kind === ChunkKind.code && this.options.on_staged_code?.(this.assembler.stageCode(digest, chunk.payload));
1284
+ } catch (error) {
1285
+ this.fault("boot", error);
1286
+ }
1287
+ this.arrived(bytes);
1288
+ }
1289
+ answerPing(bytes) {
1290
+ this.pong[1] = bytes[1], this.pong[2] = bytes[2], this.pong[3] = bytes[3], this.pong[4] = bytes[4], this.pongView.setFloat64(5, this.options.heap_bytes?.() ?? 0, true), this.bridge.send(this.pong, PONG_BYTES);
1291
+ }
1292
+ answer(envelope) {
1293
+ let waiting = this.pending.get(envelope.request_id);
1294
+ waiting !== void 0 && (this.pending.delete(envelope.request_id), this.stopTimer ?? (this.stopTimer = timerStop()), waiting.timer !== null && this.stopTimer !== null && this.stopTimer(waiting.timer), envelope.outcome.status === "ok" ? waiting.resolve(envelope.outcome.response.result) : waiting.reject(envelope.outcome.error));
1295
+ }
1296
+ deliver(envelope) {
1297
+ let event = envelope.event;
1298
+ if (event.family === "ui") {
1299
+ this.dispatchUi(event.event);
1300
+ return;
1301
+ }
1302
+ this.notify(this.subscriptions.get(envelope.subscription_id), event), this.notify(this.families.get(event.family), event);
1303
+ }
1304
+ dispatchUi(event) {
1305
+ if (this.state === "disposed") return;
1306
+ let listeners = this.uiListeners.slice();
1307
+ for (let i = 0; i < listeners.length; i++)
1308
+ try {
1309
+ listeners[i](event);
1310
+ } catch (error) {
1311
+ this.fault("run", error);
1312
+ }
1313
+ }
1314
+ reply(reply) {
1315
+ let resolve = this.replies.get(reply.id);
1316
+ resolve !== void 0 && (this.replies.delete(reply.id), resolve(reply.value));
1317
+ }
1318
+ transition(event) {
1319
+ if (event === null || this.state === "disposed") return;
1320
+ let next = LIFECYCLE_STATE[event];
1321
+ next !== null && (this.state = next);
1322
+ let listeners = (this.lifecycleListeners.get(event) ?? []).slice();
1323
+ for (let listener of listeners)
1324
+ try {
1325
+ listener();
1326
+ } catch (error) {
1327
+ this.fault("run", error);
1328
+ }
1329
+ if (event === "dispose") {
1330
+ for (let i = this.disposers.length - 1; i >= 0; i--)
1331
+ try {
1332
+ this.disposers[i]();
1333
+ } catch (error) {
1334
+ this.fault("run", error);
1335
+ }
1336
+ this.disposers.length = 0, this.uiListeners.length = 0, this.lane.flush(), this.send(this.writer.tag(MessageTag.disposed));
1337
+ }
1338
+ }
1339
+ async start() {
1340
+ if (this.boot === null || this.state !== "loading" || this.starting) {
1341
+ this.fault("start", new Error("start arrived before boot or twice"));
1342
+ return;
1343
+ }
1344
+ this.starting = true, await this.arrivals();
1345
+ try {
1346
+ this.services.harden();
1347
+ } catch (error) {
1348
+ this.fault("guard", error);
1349
+ return;
1350
+ }
1351
+ let entry;
1352
+ try {
1353
+ let { entry: path, modules, runtimes } = this.assembler.modules(new Set(this.boot.bytecode_modules ?? [])), linked = await this.services.linker.link(modules, path, this.services.slice.tick, runtimes);
1354
+ if (typeof linked.default != "function") throw new Error(`${path} does not export a default function`);
1355
+ entry = linked.default;
1356
+ } catch (error) {
1357
+ this.fault("link", error);
1358
+ return;
1359
+ }
1360
+ this.mark("linked");
1361
+ try {
1362
+ let ctx = (this.options.ctx ?? createGuestCtx)(this);
1363
+ this.transition("ready"), this.mark("main_entered"), await entry(ctx);
1364
+ } catch (error) {
1365
+ this.fault("start", error);
1366
+ return;
1367
+ }
1368
+ this.current() === "ready" && this.transition("visible"), this.send(this.writer.tag(MessageTag.started));
1369
+ }
1370
+ };
1371
+ function lifecycleOf(runtime) {
1372
+ return {
1373
+ get state() {
1374
+ return runtime.current();
1375
+ },
1376
+ on: (event, listener) => runtime.onLifecycle(event, listener)
1377
+ };
1378
+ }
1379
+
1380
+ export { CTX_CONFIRMED_REQUEST_DEADLINE_MS, CTX_LONG_REQUEST_DEADLINES_MS, CTX_REQUEST_DEADLINE_MS, ChannelPublisher, ClipError, DEFAULT_SLICE_MS, FrameLane, GuardError, GuestRuntime, GuestUnavailableError, LaneCounter, LaneFastReader, RoomInputPublisher, Slice, SliceExceeded, TICKS_PER_CHECK, TICK_GLOBAL, clockBudget, createGuestCtx, ctxFamilyOf, ctxRequestDeadlineMs, hardenGlobals };