@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.
- package/LICENSE +21 -0
- package/dist/advanced.d.mts +4 -3
- package/dist/advanced.d.ts +4 -3
- package/dist/advanced.js +24 -24
- package/dist/advanced.mjs +5 -5
- package/dist/animation-4EXBXRVX.js +27 -0
- package/dist/animation-6DICNWUP.mjs +6 -0
- package/dist/audio-DhvyjqdA.d.mts +249 -0
- package/dist/audio-m0w8cnxq.d.ts +249 -0
- package/dist/avatars.d.mts +110 -0
- package/dist/avatars.d.ts +110 -0
- package/dist/avatars.js +82 -0
- package/dist/avatars.mjs +5 -0
- package/dist/backend-gUCzs5Kg.d.mts +3866 -0
- package/dist/backend-gUCzs5Kg.d.ts +3866 -0
- package/dist/{catalogue-B4eLL8Mi.d.ts → catalogue-CPTMyBUz.d.mts} +109 -221
- package/dist/catalogue-DzrTXP3v.d.mts +541 -0
- package/dist/catalogue-DzrTXP3v.d.ts +541 -0
- package/dist/{catalogue-OT89_Ifs.d.mts → catalogue-OTuS5zp-.d.ts} +109 -221
- package/dist/chunk-22BD3RHN.mjs +1809 -0
- package/dist/chunk-25T4JHEA.mjs +21 -0
- package/dist/chunk-2AQ237Y4.js +508 -0
- package/dist/chunk-2IC4H6OV.mjs +48 -0
- package/dist/chunk-2LHLG4OB.mjs +71 -0
- package/dist/chunk-2O2CG465.js +1709 -0
- package/dist/chunk-2Q4DTHXK.js +316 -0
- package/dist/chunk-2QTQ6BUH.mjs +46 -0
- package/dist/chunk-2UN4SFLR.mjs +100 -0
- package/dist/chunk-2V75I7K3.js +454 -0
- package/dist/chunk-2V7IL4HC.js +10 -0
- package/dist/chunk-34XBXUMW.js +296 -0
- package/dist/chunk-3C4C654I.js +71 -0
- package/dist/chunk-3DAD2LDF.mjs +72 -0
- package/dist/chunk-3GXH2NFD.mjs +4 -0
- package/dist/chunk-3O47ZFW3.js +961 -0
- package/dist/chunk-3OY3VYNF.mjs +11 -0
- package/dist/chunk-3S6WPBZL.js +2936 -0
- package/dist/chunk-3TUOUP5T.js +399 -0
- package/dist/chunk-3VEH23I5.mjs +1380 -0
- package/dist/chunk-3ZYSAW2T.mjs +263 -0
- package/dist/chunk-4ANVF274.js +103 -0
- package/dist/chunk-4C7I3ELN.js +388 -0
- package/dist/chunk-4DYKAYFO.mjs +8 -0
- package/dist/chunk-4ZDR72SG.js +329 -0
- package/dist/chunk-52YS45RR.js +1066 -0
- package/dist/chunk-5325XSCH.js +107 -0
- package/dist/chunk-5AD5X6AV.js +13 -0
- package/dist/chunk-5BYDGGWO.mjs +197 -0
- package/dist/chunk-5C3C7VDM.mjs +55 -0
- package/dist/chunk-5HFMY3D7.js +660 -0
- package/dist/chunk-5LH2QN3T.js +1862 -0
- package/dist/chunk-5PJEXSOW.js +44 -0
- package/dist/chunk-5SXDH3Y7.js +90 -0
- package/dist/chunk-5YFBGGCK.mjs +502 -0
- package/dist/chunk-5YWN6H5Q.mjs +133 -0
- package/dist/chunk-66QP3SMN.js +402 -0
- package/dist/chunk-6DAEZKIG.mjs +385 -0
- package/dist/chunk-6DATW7TB.mjs +420 -0
- package/dist/{chunk-JRGK3NXR.mjs → chunk-6ETDAU62.mjs} +72 -212
- package/dist/chunk-6H254EVP.mjs +178 -0
- package/dist/chunk-6PFNJPBJ.mjs +820 -0
- package/dist/chunk-6PJWXIFX.mjs +357 -0
- package/dist/chunk-6SWKWCMS.js +80 -0
- package/dist/chunk-6VVXXX7S.js +808 -0
- package/dist/chunk-6WUBSMTX.js +1403 -0
- package/dist/chunk-73SGZLAQ.mjs +35 -0
- package/dist/chunk-76L2V6KD.mjs +4 -0
- package/dist/chunk-7AAIAVAA.js +1531 -0
- package/dist/chunk-7ARSJPV3.mjs +93 -0
- package/dist/chunk-7BHW5GTC.mjs +1234 -0
- package/dist/chunk-7DQSDKDU.js +6 -0
- package/dist/chunk-7IQQQENP.mjs +401 -0
- package/dist/chunk-7KFTYENS.js +11357 -0
- package/dist/chunk-7SM6XSPZ.js +3171 -0
- package/dist/chunk-7SXOHAIR.mjs +28 -0
- package/dist/chunk-A2MAX6S4.js +90 -0
- package/dist/chunk-A33OORT7.mjs +1530 -0
- package/dist/{chunk-U6ACF76H.mjs → chunk-A36JRXXH.mjs} +1075 -1845
- package/dist/chunk-A7BU3BK4.js +52 -0
- package/dist/chunk-A7MQSN2V.mjs +77 -0
- package/dist/chunk-A7V4L2IT.mjs +416 -0
- package/dist/chunk-AABEK6XU.js +226 -0
- package/dist/chunk-AGV33FWC.mjs +5005 -0
- package/dist/chunk-AHNR3BXI.js +108 -0
- package/dist/chunk-AQ5RLBU2.mjs +286 -0
- package/dist/chunk-AQOE6WCG.js +1270 -0
- package/dist/chunk-ATAWRACV.mjs +62 -0
- package/dist/chunk-ATCURNUV.js +14 -0
- package/dist/chunk-AWPV33OO.js +6 -0
- package/dist/chunk-AYJPHKYV.js +337 -0
- package/dist/chunk-AZ5BGWHB.js +162 -0
- package/dist/chunk-AZAXD44P.js +1373 -0
- package/dist/chunk-BBGKQIJJ.mjs +406 -0
- package/dist/chunk-BP4JLSUA.js +1453 -0
- package/dist/{chunk-SUCE7FWA.mjs → chunk-BTUSVHIE.mjs} +539 -978
- package/dist/chunk-BU6OK542.mjs +818 -0
- package/dist/chunk-CVSRWM6W.js +418 -0
- package/dist/chunk-CYBMFMJD.mjs +247 -0
- package/dist/chunk-DDJLDOUX.mjs +217 -0
- package/dist/{chunk-V32BCG7M.js → chunk-DFZWHNRG.js} +75 -215
- package/dist/chunk-DJ2C7AVG.js +644 -0
- package/dist/chunk-DS2VU4WW.mjs +102 -0
- package/dist/chunk-DSAG7T5P.js +7290 -0
- package/dist/chunk-E2QPPH7I.js +327 -0
- package/dist/chunk-E65WCTIG.mjs +1187 -0
- package/dist/{chunk-33VCYWVL.mjs → chunk-E6QQKDNE.mjs} +30 -42
- package/dist/chunk-ECDK6QBF.mjs +981 -0
- package/dist/chunk-EIB4OWVQ.mjs +620 -0
- package/dist/chunk-EQUZYCGO.js +250 -0
- package/dist/chunk-F3UJ6ZRM.mjs +313 -0
- package/dist/chunk-F63N2ZTQ.js +7023 -0
- package/dist/chunk-F6XRYEM3.mjs +26 -0
- package/dist/chunk-FE6VCE4K.js +5030 -0
- package/dist/chunk-FLWD6GRR.js +1372 -0
- package/dist/chunk-FQBFWJBS.mjs +110 -0
- package/dist/chunk-FXVJ2HFU.js +26 -0
- package/dist/chunk-FZMQMQBW.js +312 -0
- package/dist/chunk-G3EEC44R.js +53 -0
- package/dist/{chunk-KG3WT4PR.mjs → chunk-GCKWKLZF.mjs} +73 -104
- package/dist/chunk-GCX7TY4D.mjs +6826 -0
- package/dist/chunk-GDB6TCSD.js +450 -0
- package/dist/chunk-GDCV4IWO.mjs +21 -0
- package/dist/chunk-GDZT5LZ5.js +170 -0
- package/dist/chunk-GHPUYD4I.mjs +213 -0
- package/dist/chunk-GHS6MIL6.mjs +1432 -0
- package/dist/chunk-GPS2THCL.mjs +11 -0
- package/dist/{chunk-EV2EVOYS.js → chunk-GTJWQAGU.js} +31 -42
- package/dist/chunk-GVTI6UJQ.mjs +130 -0
- package/dist/chunk-GXKI64OT.mjs +1138 -0
- package/dist/chunk-GYDYF2WX.js +275 -0
- package/dist/chunk-GYLP6UG4.mjs +705 -0
- package/dist/chunk-H3OQKK6X.js +1158 -0
- package/dist/chunk-H5DFSCJ6.js +40 -0
- package/dist/chunk-HAGEIC2L.mjs +186 -0
- package/dist/chunk-HAJ4JRFO.js +293 -0
- package/dist/chunk-HDR72GB6.js +188 -0
- package/dist/chunk-HF5HPS4T.mjs +40 -0
- package/dist/chunk-HK6LOFDS.js +218 -0
- package/dist/chunk-HMWYTXCY.mjs +143 -0
- package/dist/chunk-HPCSRCMA.js +89 -0
- package/dist/chunk-HSEO6TPU.js +247 -0
- package/dist/chunk-I5FOHCLH.js +132 -0
- package/dist/chunk-IDLW4NWA.mjs +85 -0
- package/dist/chunk-IIDZ5WUX.js +61 -0
- package/dist/chunk-IR74FJHU.js +2332 -0
- package/dist/chunk-IRVFYAKP.mjs +100 -0
- package/dist/{chunk-XBL3TMPC.mjs → chunk-IZDWAL53.mjs} +1795 -3287
- package/dist/chunk-J2KZXIU3.js +51 -0
- package/dist/chunk-J2U6PJSO.js +91 -0
- package/dist/chunk-J5AJNY2N.js +283 -0
- package/dist/chunk-J6KQZ4FO.mjs +821 -0
- package/dist/{chunk-OWW5GUSB.js → chunk-JGBCIKJV.js} +7 -6
- package/dist/chunk-JKGTBMU7.mjs +25 -0
- package/dist/chunk-JR3TNEQC.js +422 -0
- package/dist/chunk-JURRXY2J.mjs +29 -0
- package/dist/chunk-K3HW5I2A.mjs +317 -0
- package/dist/chunk-K46SMZ66.mjs +103 -0
- package/dist/chunk-K4UDGE3Z.mjs +6 -0
- package/dist/chunk-KDQOR4QQ.mjs +350 -0
- package/dist/chunk-KDTVOLHI.mjs +288 -0
- package/dist/chunk-KGHJH5KJ.mjs +35 -0
- package/dist/chunk-KIZOA5LX.mjs +140 -0
- package/dist/chunk-KK6HYVBI.mjs +242 -0
- package/dist/chunk-KMKWGXMK.js +856 -0
- package/dist/chunk-KPA6K5IB.js +80 -0
- package/dist/chunk-KU7O4IXU.mjs +260 -0
- package/dist/chunk-KVFNRJOR.mjs +11142 -0
- package/dist/chunk-KZJRSXHK.js +2432 -0
- package/dist/chunk-LHWPRUJL.js +79 -0
- package/dist/chunk-LIV3KXJG.mjs +369 -0
- package/dist/chunk-LKV4LACG.js +21 -0
- package/dist/chunk-LUY45X3U.mjs +263 -0
- package/dist/chunk-LYEZZEEF.mjs +17 -0
- package/dist/chunk-M5EXQZYY.mjs +1519 -0
- package/dist/chunk-ME6HGG4I.mjs +1338 -0
- package/dist/chunk-MEXP6DA6.js +31 -0
- package/dist/chunk-MG52AW3H.js +902 -0
- package/dist/chunk-MIPO6F72.js +334 -0
- package/dist/{chunk-5QW7CQBA.js → chunk-MKIJQL5Q.js} +211 -321
- package/dist/chunk-MN3YETVN.mjs +17 -0
- package/dist/chunk-MOBSBXVE.mjs +2391 -0
- package/dist/chunk-MOMOZEUM.mjs +88 -0
- package/dist/chunk-MRFUNRAP.js +62 -0
- package/dist/chunk-MTIHEW2M.js +433 -0
- package/dist/chunk-N4RGGDEL.mjs +73 -0
- package/dist/chunk-NH654HAT.js +10 -0
- package/dist/chunk-NHJUGZUR.mjs +253 -0
- package/dist/chunk-NMQT4HG3.mjs +757 -0
- package/dist/chunk-NPSYB6DC.mjs +906 -0
- package/dist/chunk-NW2GPMSO.js +857 -0
- package/dist/chunk-NXKQOQ6L.js +76 -0
- package/dist/chunk-NXLAZIJZ.js +309 -0
- package/dist/chunk-NYWNA5CF.js +148 -0
- package/dist/chunk-NZTKLY2W.js +1442 -0
- package/dist/chunk-O2ICABUD.js +36 -0
- package/dist/chunk-OIVVQQ22.js +862 -0
- package/dist/chunk-OKC2B4O3.mjs +312 -0
- package/dist/chunk-OLWFPDBK.js +2220 -0
- package/dist/chunk-OMTVH334.js +3779 -0
- package/dist/chunk-OQRVEM56.mjs +362 -0
- package/dist/chunk-OXMIBOD4.js +337 -0
- package/dist/chunk-PBL6YL5L.mjs +288 -0
- package/dist/chunk-PDOELNNQ.js +97 -0
- package/dist/chunk-PDQJY2GZ.js +136 -0
- package/dist/chunk-PKOZXD2Q.js +1274 -0
- package/dist/chunk-PPF2BYFL.mjs +2191 -0
- package/dist/chunk-PQTQKNKD.js +539 -0
- package/dist/chunk-PRSR4FAV.mjs +81 -0
- package/dist/chunk-PTRNO5UD.js +95 -0
- package/dist/chunk-Q2Y3VMKH.js +2000 -0
- package/dist/chunk-QCZOE65N.js +96 -0
- package/dist/chunk-QDYFLATW.mjs +52 -0
- package/dist/chunk-QQABGCMM.js +22 -0
- package/dist/chunk-QS6TRHMR.js +345 -0
- package/dist/chunk-R56P64LB.mjs +208 -0
- package/dist/chunk-RCQ2MPBV.js +428 -0
- package/dist/chunk-RFVRPYR2.mjs +856 -0
- package/dist/chunk-RKBLPGPV.js +11521 -0
- package/dist/chunk-RM2V4IND.mjs +327 -0
- package/dist/chunk-RQXN5A34.mjs +613 -0
- package/dist/chunk-RUVGVNOF.mjs +2687 -0
- package/dist/chunk-SAFJIGYB.mjs +165 -0
- package/dist/chunk-SKQFLBDD.js +263 -0
- package/dist/chunk-SMK6JU2F.mjs +2092 -0
- package/dist/{chunk-UVRPC2P7.js → chunk-SNNEOS5Z.js} +1984 -3476
- package/dist/chunk-SPCRQ6NO.mjs +1246 -0
- package/dist/chunk-SWX4SALA.mjs +19 -0
- package/dist/{chunk-JVODCGFP.mjs → chunk-SYEO2WV4.mjs} +128 -238
- package/dist/chunk-T2QQMX2N.js +10 -0
- package/dist/chunk-T3AFF3L7.mjs +57 -0
- package/dist/chunk-T6Z2EXYL.js +712 -0
- package/dist/chunk-T7LOXGYX.js +118 -0
- package/dist/chunk-TJCAE7RC.mjs +1315 -0
- package/dist/chunk-TJI3K6RP.js +137 -0
- package/dist/chunk-TL2SVO4P.mjs +55 -0
- package/dist/chunk-TM63CYGN.mjs +399 -0
- package/dist/chunk-TU5RYTYU.mjs +13 -0
- package/dist/chunk-TVJZ4GPS.js +1553 -0
- package/dist/chunk-TWM6DLYF.js +371 -0
- package/dist/chunk-U63OC4TQ.js +30 -0
- package/dist/{chunk-L5GKVQVJ.js → chunk-U6BVSJZ6.js} +25 -57
- package/dist/chunk-U6UVWEAK.mjs +792 -0
- package/dist/chunk-UCEPNO6N.mjs +11048 -0
- package/dist/{chunk-ANT574FD.js → chunk-UCR5HRYM.js} +74 -105
- package/dist/chunk-UG5BTOTF.mjs +334 -0
- package/dist/chunk-UGH37BQW.mjs +157 -0
- package/dist/chunk-V7ZRH3PY.mjs +271 -0
- package/dist/chunk-VBGHBL3E.mjs +1394 -0
- package/dist/chunk-VRBDAS5I.js +920 -0
- package/dist/chunk-VVE3Y76O.js +230 -0
- package/dist/chunk-W65JIRI4.mjs +1182 -0
- package/dist/chunk-WHYKAT7G.js +62 -0
- package/dist/{chunk-YOIVZ6OA.mjs → chunk-WIZRUIZB.mjs} +25 -57
- package/dist/chunk-WKWTDZS7.js +385 -0
- package/dist/chunk-WLMINRC4.mjs +78 -0
- package/dist/chunk-WOF3AD3J.js +22 -0
- package/dist/chunk-WWKMOA76.js +1262 -0
- package/dist/chunk-X5A5FOWW.js +615 -0
- package/dist/chunk-X6CN6KQF.mjs +192 -0
- package/dist/chunk-XD2PMH46.mjs +517 -0
- package/dist/chunk-XJA2NGTI.mjs +88 -0
- package/dist/chunk-XJIHN3BY.mjs +8 -0
- package/dist/chunk-XK6UDWJS.js +203 -0
- package/dist/chunk-XPG3N5CF.mjs +415 -0
- package/dist/chunk-XVZ2NKSU.mjs +74 -0
- package/dist/chunk-XYP45OLE.js +117 -0
- package/dist/chunk-XZSDGZX6.mjs +301 -0
- package/dist/chunk-Y2EMGN4T.mjs +120 -0
- package/dist/chunk-Y3XWP5XW.mjs +298 -0
- package/dist/chunk-Y4K22JL6.js +228 -0
- package/dist/chunk-Y65LXQGA.mjs +3164 -0
- package/dist/chunk-Y66WVMO5.mjs +87 -0
- package/dist/chunk-Y7JWLB25.mjs +7280 -0
- package/dist/chunk-YCDXAJKU.js +175 -0
- package/dist/chunk-YRDQCCIS.js +152 -0
- package/dist/chunk-YV52DGSA.js +111 -0
- package/dist/chunk-YXGZQPUD.js +94 -0
- package/dist/chunk-Z3A3AFVU.mjs +102 -0
- package/dist/chunk-ZCY6YKKP.mjs +475 -0
- package/dist/chunk-ZEQHXVU5.js +215 -0
- package/dist/chunk-ZF7JCXCI.js +284 -0
- package/dist/chunk-ZJBRUH6V.js +29 -0
- package/dist/chunk-ZMIL4ZOA.js +365 -0
- package/dist/chunk-ZR5ULMN2.mjs +337 -0
- package/dist/chunk-ZXREOYOW.js +87 -0
- package/dist/{client-BSP9U1O1.d.mts → client-CX_WR0-J.d.mts} +2 -2
- package/dist/client-Dytx_ZTC.d.ts +230 -0
- package/dist/{client-B878xeAP.d.ts → client-dqOhP9Nc.d.ts} +2 -2
- package/dist/client-hTKbCuhG.d.mts +230 -0
- package/dist/clock-B-UAjkKa.d.mts +5 -0
- package/dist/clock-B-UAjkKa.d.ts +5 -0
- package/dist/config-BlXQluJR.d.mts +36 -0
- package/dist/config-BlXQluJR.d.ts +36 -0
- package/dist/courier-Cnn-edJ4.d.ts +95 -0
- package/dist/courier-FmGfkvIN.d.mts +95 -0
- package/dist/crowd-DdHFbqKK.d.ts +186 -0
- package/dist/crowd-hOVSAmA3.d.mts +186 -0
- package/dist/danfo-BEBapFlX.d.mts +146 -0
- package/dist/danfo-UQ_PTIIx.d.ts +146 -0
- package/dist/{elements-Bty6Qs_N.d.mts → elements-DdsRig-2.d.mts} +1548 -257
- package/dist/{elements-Bty6Qs_N.d.ts → elements-DdsRig-2.d.ts} +1548 -257
- package/dist/engines/godot.d.mts +56 -0
- package/dist/engines/godot.d.ts +56 -0
- package/dist/engines/godot.js +28 -0
- package/dist/engines/godot.mjs +3 -0
- package/dist/engines/wasm.d.mts +11 -0
- package/dist/engines/wasm.d.ts +11 -0
- package/dist/engines/wasm.js +178 -0
- package/dist/engines/wasm.mjs +176 -0
- package/dist/fallback-CrG_lTFk.d.mts +270 -0
- package/dist/fallback-CrG_lTFk.d.ts +270 -0
- package/dist/fallback-KDB4Y2CE.mjs +6 -0
- package/dist/fallback-Y26TQENE.js +19 -0
- package/dist/features-CZB4rmcD.d.mts +118 -0
- package/dist/features-CZB4rmcD.d.ts +118 -0
- package/dist/fit-BWiE7rgA.d.mts +44 -0
- package/dist/fit-DK0oT7zO.d.ts +44 -0
- package/dist/five-a-side-Bv1AOUy3.d.mts +115 -0
- package/dist/five-a-side-EC51SJY1.d.ts +115 -0
- package/dist/fluid-ARr0qUIL.d.ts +939 -0
- package/dist/fluid-DLlEj2cs.d.mts +939 -0
- package/dist/game/conformance.d.mts +84 -0
- package/dist/game/conformance.d.ts +84 -0
- package/dist/game/conformance.js +1025 -0
- package/dist/game/conformance.mjs +994 -0
- package/dist/game/heap.d.mts +40 -0
- package/dist/game/heap.d.ts +40 -0
- package/dist/game/heap.js +48 -0
- package/dist/game/heap.mjs +7 -0
- package/dist/game/kit/canvas.d.mts +240 -0
- package/dist/game/kit/canvas.d.ts +240 -0
- package/dist/game/kit/canvas.js +3566 -0
- package/dist/game/kit/canvas.mjs +1039 -0
- package/dist/game/kit/courier.d.mts +17 -0
- package/dist/game/kit/courier.d.ts +17 -0
- package/dist/game/kit/courier.js +66 -0
- package/dist/game/kit/courier.mjs +49 -0
- package/dist/game/kit/danfo.d.mts +11 -0
- package/dist/game/kit/danfo.d.ts +11 -0
- package/dist/game/kit/danfo.js +109 -0
- package/dist/game/kit/danfo.mjs +44 -0
- package/dist/game/kit/engine.d.mts +29 -0
- package/dist/game/kit/engine.d.ts +29 -0
- package/dist/game/kit/engine.js +183 -0
- package/dist/game/kit/engine.mjs +30 -0
- package/dist/game/kit/five-a-side.d.mts +11 -0
- package/dist/game/kit/five-a-side.d.ts +11 -0
- package/dist/game/kit/five-a-side.js +86 -0
- package/dist/game/kit/five-a-side.mjs +41 -0
- package/dist/game/kit/frontier.d.mts +344 -0
- package/dist/game/kit/frontier.d.ts +344 -0
- package/dist/game/kit/frontier.js +435 -0
- package/dist/game/kit/frontier.mjs +14 -0
- package/dist/game/kit/genesis.d.mts +752 -0
- package/dist/game/kit/genesis.d.ts +752 -0
- package/dist/game/kit/genesis.js +380 -0
- package/dist/game/kit/genesis.mjs +15 -0
- package/dist/game/kit/ludo.d.mts +15 -0
- package/dist/game/kit/ludo.d.ts +15 -0
- package/dist/game/kit/ludo.js +87 -0
- package/dist/game/kit/ludo.mjs +42 -0
- package/dist/game/kit/runner.d.mts +12 -0
- package/dist/game/kit/runner.d.ts +12 -0
- package/dist/game/kit/runner.js +83 -0
- package/dist/game/kit/runner.mjs +46 -0
- package/dist/game/kit/shootout.d.mts +13 -0
- package/dist/game/kit/shootout.d.ts +13 -0
- package/dist/game/kit/shootout.js +122 -0
- package/dist/game/kit/shootout.mjs +57 -0
- package/dist/game/kit/slots.d.mts +392 -0
- package/dist/game/kit/slots.d.ts +392 -0
- package/dist/game/kit/slots.js +215 -0
- package/dist/game/kit/slots.mjs +6 -0
- package/dist/game/kit/tycoon.d.mts +16 -0
- package/dist/game/kit/tycoon.d.ts +16 -0
- package/dist/game/kit/tycoon.js +145 -0
- package/dist/game/kit/tycoon.mjs +44 -0
- package/dist/game/kit/word.d.mts +11 -0
- package/dist/game/kit/word.d.ts +11 -0
- package/dist/game/kit/word.js +78 -0
- package/dist/game/kit/word.mjs +41 -0
- package/dist/game/kit/worlds.d.mts +18 -0
- package/dist/game/kit/worlds.d.ts +18 -0
- package/dist/game/kit/worlds.js +74 -0
- package/dist/game/kit/worlds.mjs +49 -0
- package/dist/game/kit.d.mts +53 -0
- package/dist/game/kit.d.ts +53 -0
- package/dist/game/kit.js +2610 -0
- package/dist/game/kit.mjs +101 -0
- package/dist/game/prepared.d.mts +14 -0
- package/dist/game/prepared.d.ts +14 -0
- package/dist/game/prepared.js +81 -0
- package/dist/game/prepared.mjs +32 -0
- package/dist/game-Bx8onkhX.d.mts +1451 -0
- package/dist/game-fgQy2YIm.d.ts +1451 -0
- package/dist/game-theme-CBTw1b_d.d.mts +35 -0
- package/dist/game-theme-Dg-ict5A.d.ts +35 -0
- package/dist/game.d.mts +3546 -0
- package/dist/game.d.ts +3546 -0
- package/dist/game.js +4455 -0
- package/dist/game.mjs +50 -0
- package/dist/graphics-C6YjWYvP.d.ts +5 -0
- package/dist/graphics-Dk2yQnYN.d.mts +5 -0
- package/dist/guest-DrsA00XD.d.mts +732 -0
- package/dist/guest-wIdfoT05.d.ts +732 -0
- package/dist/hit-stop-BKkVwTq7.d.mts +43 -0
- package/dist/hit-stop-D-8pPYnM.d.ts +43 -0
- package/dist/hot-Crn9XpHJ.d.ts +29 -0
- package/dist/hot-DH3nOhQD.d.mts +29 -0
- package/dist/{index-CQStGb3B.d.mts → index-6gkHMGAq.d.mts} +2 -2
- package/dist/index-B8ybCKJI.d.ts +41 -0
- package/dist/{index-DJwXmoaP.d.ts → index-B98Xac8e.d.ts} +2 -2
- package/dist/{index-B7oA_1XI.d.ts → index-B_ByTtIT.d.ts} +2 -2
- package/dist/index-DHjNHb1c.d.mts +41 -0
- package/dist/{index-DhUSTAhT.d.mts → index-DbAN_VQE.d.mts} +2 -2
- package/dist/index.d.mts +134 -24
- package/dist/index.d.ts +134 -24
- package/dist/index.js +407 -248
- package/dist/index.mjs +184 -58
- package/dist/interactives-authoring.d.mts +231 -0
- package/dist/interactives-authoring.d.ts +231 -0
- package/dist/interactives-authoring.js +1743 -0
- package/dist/interactives-authoring.mjs +1704 -0
- package/dist/interactives-canvas.global.js +148 -0
- package/dist/interactives-guest.d.mts +20 -0
- package/dist/interactives-guest.d.ts +20 -0
- package/dist/interactives-guest.js +63 -0
- package/dist/interactives-guest.json +1 -0
- package/dist/interactives-guest.mjs +61 -0
- package/dist/interactives-jsc.global.js +9357 -0
- package/dist/interactives-meters.d.mts +93 -0
- package/dist/interactives-meters.d.ts +93 -0
- package/dist/interactives-meters.js +252 -0
- package/dist/interactives-meters.mjs +68 -0
- package/dist/interactives-production.d.mts +430 -0
- package/dist/interactives-production.d.ts +430 -0
- package/dist/interactives-production.js +1231 -0
- package/dist/interactives-production.mjs +1170 -0
- package/dist/interactives-record.d.mts +112 -0
- package/dist/interactives-record.d.ts +112 -0
- package/dist/interactives-record.js +302 -0
- package/dist/interactives-record.mjs +295 -0
- package/dist/interactives-runtime.d.mts +61 -0
- package/dist/interactives-runtime.d.ts +61 -0
- package/dist/interactives-runtime.js +442 -0
- package/dist/interactives-runtime.mjs +25 -0
- package/dist/interactives-studio-kernel.global.js +1 -0
- package/dist/interactives-studio.d.mts +806 -0
- package/dist/interactives-studio.d.ts +806 -0
- package/dist/interactives-studio.js +5741 -0
- package/dist/interactives-studio.mjs +5651 -0
- package/dist/interactives-tick.d.mts +90 -0
- package/dist/interactives-tick.d.ts +90 -0
- package/dist/interactives-tick.js +203 -0
- package/dist/interactives-tick.mjs +6 -0
- package/dist/interactives-web.d.mts +762 -0
- package/dist/interactives-web.d.ts +762 -0
- package/dist/interactives-web.js +5000 -0
- package/dist/interactives-web.mjs +4628 -0
- package/dist/interactives.d.mts +2430 -0
- package/dist/interactives.d.ts +2430 -0
- package/dist/interactives.js +5723 -0
- package/dist/interactives.mjs +4333 -0
- package/dist/juice-CoHxlpKA.d.ts +42 -0
- package/dist/juice-DQztFS43.d.mts +42 -0
- package/dist/launch-T2f4_Di4.d.mts +151 -0
- package/dist/launch-d6oreMzR.d.ts +151 -0
- package/dist/library-DXYaMFhi.d.mts +69 -0
- package/dist/library-DXYaMFhi.d.ts +69 -0
- package/dist/link-BUTqGmyi.d.mts +38 -0
- package/dist/link-BUTqGmyi.d.ts +38 -0
- package/dist/lint.js +104 -204
- package/dist/lint.mjs +103 -203
- package/dist/local-D8_I6UeL.d.mts +6967 -0
- package/dist/local-VZkqsCzR.d.ts +6967 -0
- package/dist/lockstep-BLf6dglI.d.mts +321 -0
- package/dist/lockstep-D50Ia0JW.d.ts +321 -0
- package/dist/ludo-B8ClkDqr.d.ts +205 -0
- package/dist/ludo-BOuohQ-M.d.mts +205 -0
- package/dist/mock/cli.mjs +200 -56
- package/dist/mock/library.js +200 -56
- package/dist/mock/library.mjs +200 -56
- package/dist/mock/msw.js +200 -56
- package/dist/mock/msw.mjs +200 -56
- package/dist/native-BodxSh03.d.mts +16 -0
- package/dist/native-DUHMT8gA.d.ts +16 -0
- package/dist/network-ZXLD7l1b.d.mts +19 -0
- package/dist/network-ZXLD7l1b.d.ts +19 -0
- package/dist/online-XeymeM9s.d.ts +381 -0
- package/dist/online-d7W_Al9a.d.mts +381 -0
- package/dist/params-DxFb5G_U.d.mts +155 -0
- package/dist/params-DxFb5G_U.d.ts +155 -0
- package/dist/play-BRRlfLhX.d.ts +940 -0
- package/dist/play-ClrMd_e8.d.mts +940 -0
- package/dist/policy-CCw8tXLm.d.mts +3078 -0
- package/dist/policy-CMqOSQIu.d.ts +3078 -0
- package/dist/ports-B_0v_P3A.d.mts +13 -0
- package/dist/ports-CGU_3e_0.d.ts +13 -0
- package/dist/prefetch-BHnicOQj.d.ts +117 -0
- package/dist/prefetch-CBXgYacv.d.mts +117 -0
- package/dist/{price-CSztR02F.d.mts → price-BOzexBww.d.mts} +1 -1
- package/dist/{price-C_vasx9A.d.ts → price-C1h9sPxE.d.ts} +1 -1
- package/dist/protocol-C8qbpUbT.d.mts +242 -0
- package/dist/protocol-C8qbpUbT.d.ts +242 -0
- package/dist/rapier-AZHT4YI7.js +7886 -0
- package/dist/rapier-ODEPCQA6.mjs +7792 -0
- package/dist/react.d.mts +157 -15
- package/dist/react.d.ts +157 -15
- package/dist/react.js +5564 -5904
- package/dist/react.mjs +5451 -5808
- package/dist/runner-CQcLL7By.d.ts +189 -0
- package/dist/runner-D46Yj-wE.d.mts +189 -0
- package/dist/runtime-BRWfkf_q.d.mts +51 -0
- package/dist/runtime-DyuBMkKM.d.ts +51 -0
- package/dist/scheduling-D2ajXpMC.d.ts +224 -0
- package/dist/scheduling-DSRbbaZb.d.mts +224 -0
- package/dist/schema-BrWxzKp6.d.mts +63 -0
- package/dist/schema-BrWxzKp6.d.ts +63 -0
- package/dist/server/evict.js +34 -37
- package/dist/server/evict.mjs +34 -37
- package/dist/server/tanstack.d.mts +49 -3
- package/dist/server/tanstack.d.ts +49 -3
- package/dist/server/tanstack.js +169 -117
- package/dist/server/tanstack.mjs +166 -118
- package/dist/{server-Dckg4Vdr.d.ts → server-D29IIuDV.d.ts} +136 -130
- package/dist/{server-B6dW7-Lj.d.mts → server-DQMWPnc8.d.mts} +136 -130
- package/dist/server.d.mts +45 -5
- package/dist/server.d.ts +45 -5
- package/dist/server.js +171 -227
- package/dist/server.mjs +165 -225
- package/dist/session-grant-CJ27DwrT.d.mts +19 -0
- package/dist/session-grant-CJ27DwrT.d.ts +19 -0
- package/dist/shootout-BJZeX6FG.d.ts +140 -0
- package/dist/shootout-tcZd1Rxt.d.mts +140 -0
- package/dist/state-replica-stMtdkVD.d.mts +42 -0
- package/dist/state-replica-stMtdkVD.d.ts +42 -0
- package/dist/studio-CowqWqez.d.mts +14 -0
- package/dist/studio-CowqWqez.d.ts +14 -0
- package/dist/styles.css +1 -1
- package/dist/template-AhCdB1kW.d.mts +190 -0
- package/dist/template-BkEGVTQj.d.ts +190 -0
- package/dist/terrain-BMxEc6Oc.d.ts +429 -0
- package/dist/terrain-C-XC1Oui.d.mts +429 -0
- package/dist/testing/msw.d.mts +28 -4
- package/dist/testing/msw.d.ts +28 -4
- package/dist/testing/msw.js +15 -21
- package/dist/testing/msw.mjs +15 -21
- package/dist/testing/suite.d.mts +6 -5
- package/dist/testing/suite.d.ts +6 -5
- package/dist/testing/suite.js +89 -124
- package/dist/testing/suite.mjs +81 -116
- package/dist/testing.d.mts +27 -1227
- package/dist/testing.d.ts +27 -1227
- package/dist/testing.js +127 -131
- package/dist/testing.mjs +19 -23
- package/dist/tick-transport-C8QEh8Uw.d.mts +50 -0
- package/dist/tick-transport-UjHY3xK1.d.ts +50 -0
- package/dist/timeline-protocol-hp6e8zFB.d.mts +47 -0
- package/dist/timeline-protocol-hp6e8zFB.d.ts +47 -0
- package/dist/tokens-DhanQRQS.d.mts +21 -0
- package/dist/tokens-K8yxwd6G.d.ts +21 -0
- package/dist/tree-C-Io2Hbx.d.mts +35 -0
- package/dist/tree-CP_qSW4H.d.ts +35 -0
- package/dist/tycoon-B5KHk2Xx.d.mts +255 -0
- package/dist/tycoon-hmHo-3HX.d.ts +255 -0
- package/dist/types-BQkxPwZP.d.mts +219 -0
- package/dist/types-D_f6UUxM.d.ts +219 -0
- package/dist/ui-DwHicuFv.d.mts +563 -0
- package/dist/ui-hi7S2YcH.d.ts +563 -0
- package/dist/{sign-in-DQlIdqsi.d.mts → url-52ndUruG.d.mts} +15 -1
- package/dist/{sign-in-DQlIdqsi.d.ts → url-52ndUruG.d.ts} +15 -1
- package/dist/utils.d.mts +3 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +37 -37
- package/dist/utils.mjs +4 -4
- package/dist/vars-Dc_PrhBK.d.mts +511 -0
- package/dist/vars-Dc_PrhBK.d.ts +511 -0
- package/dist/vm-IUARFFAI.mjs +63 -0
- package/dist/vm-N7L6MGGH.js +65 -0
- package/dist/weave-delivery-CW-Kstut.d.mts +360 -0
- package/dist/weave-delivery-CW-Kstut.d.ts +360 -0
- package/dist/web-Dss74a7v.d.ts +883 -0
- package/dist/web-f9ZQPoyw.d.mts +883 -0
- package/dist/web-transport-C7MkBL0a.d.ts +19 -0
- package/dist/web-transport-aYEqXMd9.d.mts +19 -0
- package/dist/weight-CPGjsgjV.d.ts +92 -0
- package/dist/weight-tF1ODR1p.d.mts +92 -0
- package/dist/word-BcX9Jcmv.d.mts +70 -0
- package/dist/word-C7sVPLHm.d.ts +70 -0
- package/dist/world-PvILHDR1.d.ts +2285 -0
- package/dist/world-qekkXjJv.d.mts +2285 -0
- package/dist/worlds-Br2Pb0Cs.d.ts +109 -0
- package/dist/worlds-D5ydYr7d.d.mts +109 -0
- package/engines/c/cimplify.h +108 -0
- package/engines/c/cimplify.lib.js +11 -0
- package/engines/godot/addons/cimplify/cimplify.gd +97 -0
- package/engines/rust/interactives-ctx/Cargo.toml +9 -0
- package/engines/rust/interactives-ctx/src/lib.rs +189 -0
- package/package.json +189 -3
- package/vendor/rapier3d-compat/LICENSE +201 -0
- package/vendor/rapier3d-compat/PATCHES.md +61 -0
- package/dist/chunk-2P4KXFB6.js +0 -274
- package/dist/chunk-3G6RQLXK.mjs +0 -21
- package/dist/chunk-3V4DVXV3.mjs +0 -254
- package/dist/chunk-EDK3LNM6.js +0 -2436
- package/dist/chunk-F7J3HK27.js +0 -4549
- package/dist/chunk-U4MW6PYU.mjs +0 -23
- package/dist/chunk-XREIZ56K.js +0 -26
|
@@ -0,0 +1,1394 @@
|
|
|
1
|
+
import { replayFlags } from './chunk-DDJLDOUX.mjs';
|
|
2
|
+
import { luauVmRunsHere, verifyChunk, PartialChunk, LUAU_SCRIPTS_GROUP, DEFAULT_PART_ZONE, twinned, twinCaps, unmetEngineFeature, chunkRefMessage, fetchVerified, chunkMessage, SCRIPTS_CORE_GROUP } from './chunk-BU6OK542.mjs';
|
|
3
|
+
import { engineHeapFor, ENGINE_HEAP_REQUIREMENT } from './chunk-JURRXY2J.mjs';
|
|
4
|
+
import { threadsAvailable } from './chunk-Y66WVMO5.mjs';
|
|
5
|
+
import { TreeMirror, replayMessage, DEFAULT_CLIP_ARM } from './chunk-UGH37BQW.mjs';
|
|
6
|
+
import { METERS_OFF, StudioSender, StudioAssembler, STUDIO_GRANT_TOPIC } from './chunk-HAGEIC2L.mjs';
|
|
7
|
+
import { NETWORK_MESSAGE_BYTES, webNetworkHint, watchWebNetwork, writeNetworkHint } from './chunk-K46SMZ66.mjs';
|
|
8
|
+
import { GL_CORE_GROUP } from './chunk-DS2VU4WW.mjs';
|
|
9
|
+
import { sha256Into, SHA256_BYTES } from './chunk-5YWN6H5Q.mjs';
|
|
10
|
+
import './chunk-SPCRQ6NO.mjs';
|
|
11
|
+
import { ChunkPriority, MessageTag, ENGINE_CORE_UNIT, hex, unhex, CHUNK_FAILED_BYTES, prefetchSlots, forEachChunkEntry, CHUNK_REQUEST_ENTRY_BYTES, CHUNK_RELEASE_ENTRY_BYTES, PREFETCH_BUDGET_SHARE, writeChunkFailed, MessageWriter, readJson, ENGINE_CORE_THREADS_UNIT, TAG_BYTES, PING_BYTES, LIFECYCLE_BYTES, INSPECTOR_BYTES, CHUNK_REQUESTS_VERSION, INSPECTOR_SHOWN, INSPECTOR_HIDDEN, BRIDGE_LIMITS, readFrameMark, readSessionComplete, MILESTONE_BY_CODE, LifecycleCode } from './chunk-V7ZRH3PY.mjs';
|
|
12
|
+
import { encodeBase64, decodeBase64 } from './chunk-2IC4H6OV.mjs';
|
|
13
|
+
|
|
14
|
+
// src/interactives/content/origin.ts
|
|
15
|
+
var SHELL_PREFIX = "/g/", RUNTIME_PREFIX = "/r/", WASM_PREFIX = "/w/", JOINED_PREFIX = "/j/", JOINED_PARTS_PARAM = "p", JOINED_PART_SEPARATOR = ",", MAX_JOINED_PARTS = 16, RUNTIME_SUFFIX = ".js", WASM_SUFFIX = ".wasm", SRI_PREFIX = "sha256-", FORBIDDEN_PARENT = "cimplify.io", HOST_PAGE_ISOLATION_HEADERS = {
|
|
16
|
+
"cross-origin-opener-policy": "same-origin",
|
|
17
|
+
"cross-origin-embedder-policy": "require-corp",
|
|
18
|
+
"cross-origin-resource-policy": "same-origin"
|
|
19
|
+
}, LABEL_BYTES = 20, BASE32 = "abcdefghijklmnopqrstuvwxyz234567", BASE32_BITS = 5, BYTE_BITS = 8, BASE32_MASK = 31, HOST_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/, SECURE_SCHEME = "https:", LOCAL_SCHEME = "http:", LOCAL_SUFFIXES = [".test", ".localhost"], MIN_LABELS = 2, HEX_DIGEST = /^[0-9a-f]{64}$/;
|
|
20
|
+
function local(host) {
|
|
21
|
+
return LOCAL_SUFFIXES.some((suffix) => host.endsWith(suffix));
|
|
22
|
+
}
|
|
23
|
+
function parseContentOrigin(value) {
|
|
24
|
+
let url;
|
|
25
|
+
try {
|
|
26
|
+
url = new URL(value);
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
let scheme = url.protocol;
|
|
31
|
+
if (scheme !== SECURE_SCHEME && scheme !== LOCAL_SCHEME || url.username !== "" || url.password !== "" || url.search !== "" || url.hash !== "" || url.pathname !== "/" && url.pathname !== "") return null;
|
|
32
|
+
let host = url.hostname.toLowerCase(), labels = host.split(".");
|
|
33
|
+
return labels.length < (2) || !labels.every((label) => HOST_LABEL.test(label)) || host === FORBIDDEN_PARENT || host.endsWith(`.${FORBIDDEN_PARENT}`) || scheme === LOCAL_SCHEME && !local(host) ? null : { scheme, host, port: url.port };
|
|
34
|
+
}
|
|
35
|
+
function base32(bytes) {
|
|
36
|
+
let out = "", buffer = 0, bits = 0;
|
|
37
|
+
for (let i = 0; i < bytes.length; i++)
|
|
38
|
+
for (buffer = buffer << (8) | bytes[i], bits += (8); bits >= (5); )
|
|
39
|
+
bits -= (5), out += BASE32[buffer >>> bits & (31)];
|
|
40
|
+
return bits > 0 && (out += BASE32[buffer << (5) - bits & (31)]), out;
|
|
41
|
+
}
|
|
42
|
+
function interactiveLabel(interactiveId) {
|
|
43
|
+
let digest = new Uint8Array(SHA256_BYTES);
|
|
44
|
+
return sha256Into(new TextEncoder().encode(interactiveId), digest), base32(digest.subarray(0, (20)));
|
|
45
|
+
}
|
|
46
|
+
function guestOrigin(origin, interactiveId) {
|
|
47
|
+
let port = origin.port === "" ? "" : `:${origin.port}`;
|
|
48
|
+
return `${origin.scheme}//${interactiveLabel(interactiveId)}.${origin.host}${port}`;
|
|
49
|
+
}
|
|
50
|
+
function servesContent(origin, host) {
|
|
51
|
+
let name = host.toLowerCase().split(":")[0];
|
|
52
|
+
return name.endsWith(`.${origin.host}`) ? HOST_LABEL.test(name.slice(0, name.length - origin.host.length - 1)) : false;
|
|
53
|
+
}
|
|
54
|
+
function sha256Hex(bytes) {
|
|
55
|
+
let digest = new Uint8Array(SHA256_BYTES);
|
|
56
|
+
return sha256Into(bytes, digest), hex(digest);
|
|
57
|
+
}
|
|
58
|
+
function isDigestHex(value) {
|
|
59
|
+
return HEX_DIGEST.test(value);
|
|
60
|
+
}
|
|
61
|
+
function sri(digestHex) {
|
|
62
|
+
let bytes = new Uint8Array(SHA256_BYTES);
|
|
63
|
+
return !isDigestHex(digestHex) || !unhex(digestHex, bytes) ? null : SRI_PREFIX + encodeBase64(bytes);
|
|
64
|
+
}
|
|
65
|
+
function shellPath(runtimeDigest) {
|
|
66
|
+
return SHELL_PREFIX + runtimeDigest;
|
|
67
|
+
}
|
|
68
|
+
function runtimePath(runtimeDigest) {
|
|
69
|
+
return RUNTIME_PREFIX + runtimeDigest + RUNTIME_SUFFIX;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/interactives/hosts/lazy.ts
|
|
73
|
+
var DEFAULT_LAZY_BUDGET_BYTES = 64 * 1024 * 1024, DEFAULT_LAZY_CONCURRENCY = 4, DEFAULT_RUN_BYTES = 256 * 1024, PRIORITIES = ChunkPriority.prefetch + 1, LazyChunkServer = class {
|
|
74
|
+
constructor(refs, options, sink = null) {
|
|
75
|
+
this.options = options;
|
|
76
|
+
this.sink = sink;
|
|
77
|
+
this.known = /* @__PURE__ */ new Map();
|
|
78
|
+
this.queues = Array.from({ length: PRIORITIES }, () => []);
|
|
79
|
+
this.queued = /* @__PURE__ */ new Map();
|
|
80
|
+
this.flying = /* @__PURE__ */ new Map();
|
|
81
|
+
this.held = /* @__PURE__ */ new Map();
|
|
82
|
+
this.partials = /* @__PURE__ */ new Map();
|
|
83
|
+
this.failure = new Uint8Array(CHUNK_FAILED_BYTES);
|
|
84
|
+
this.heldBytes = 0;
|
|
85
|
+
this.generation = 0;
|
|
86
|
+
this.preemptions = 0;
|
|
87
|
+
this.runs = 0;
|
|
88
|
+
for (let ref of refs) this.known.set(ref.digest, ref);
|
|
89
|
+
this.budget = options.budget_bytes ?? DEFAULT_LAZY_BUDGET_BYTES, this.concurrency = Math.max(1, options.concurrency ?? (4)), this.prefetchSlots = prefetchSlots(this.concurrency);
|
|
90
|
+
}
|
|
91
|
+
get bytesHeld() {
|
|
92
|
+
return this.heldBytes;
|
|
93
|
+
}
|
|
94
|
+
get pending() {
|
|
95
|
+
return this.queued.size + this.flying.size;
|
|
96
|
+
}
|
|
97
|
+
get preempted() {
|
|
98
|
+
return this.preemptions;
|
|
99
|
+
}
|
|
100
|
+
get ranged() {
|
|
101
|
+
return this.runs;
|
|
102
|
+
}
|
|
103
|
+
priorityOf(digest) {
|
|
104
|
+
return this.queued.get(digest) ?? this.flying.get(digest)?.priority ?? null;
|
|
105
|
+
}
|
|
106
|
+
attach(sink) {
|
|
107
|
+
this.sink = sink, this.generation++;
|
|
108
|
+
for (let queue of this.queues) queue.length = 0;
|
|
109
|
+
this.queued.clear();
|
|
110
|
+
for (let flight of this.flying.values()) flight.controller?.abort();
|
|
111
|
+
this.flying.clear(), this.held.clear(), this.partials.clear(), this.heldBytes = 0;
|
|
112
|
+
}
|
|
113
|
+
request(bytes) {
|
|
114
|
+
forEachChunkEntry(bytes, CHUNK_REQUEST_ENTRY_BYTES, (digest, priority) => this.enqueue(digest, priority)), this.preempt(), this.pump();
|
|
115
|
+
}
|
|
116
|
+
requestOne(digest, priority) {
|
|
117
|
+
this.enqueue(digest, priority), this.preempt(), this.pump();
|
|
118
|
+
}
|
|
119
|
+
requestMany(entries) {
|
|
120
|
+
for (let [digest, priority] of entries) this.enqueue(digest, priority);
|
|
121
|
+
this.preempt(), this.pump();
|
|
122
|
+
}
|
|
123
|
+
enqueue(digest, requested) {
|
|
124
|
+
if (!this.known.has(digest)) {
|
|
125
|
+
this.fail(digest, "unknown");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
let priority = Math.min(Math.max(0, requested), PRIORITIES - 1), flight = this.flying.get(digest);
|
|
129
|
+
if (flight !== void 0) {
|
|
130
|
+
priority < flight.priority && (flight.priority = priority);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let queued = this.queued.get(digest);
|
|
134
|
+
if (queued !== void 0) {
|
|
135
|
+
if (priority >= queued) return;
|
|
136
|
+
this.unqueue(digest, queued);
|
|
137
|
+
}
|
|
138
|
+
this.queued.set(digest, priority), this.queues[priority].push(digest);
|
|
139
|
+
}
|
|
140
|
+
unqueue(digest, priority) {
|
|
141
|
+
let queue = this.queues[priority], at = queue.indexOf(digest);
|
|
142
|
+
at >= 0 && queue.splice(at, 1), this.queued.delete(digest);
|
|
143
|
+
}
|
|
144
|
+
release(bytes) {
|
|
145
|
+
forEachChunkEntry(bytes, CHUNK_RELEASE_ENTRY_BYTES, (digest) => {
|
|
146
|
+
let queued = this.queued.get(digest);
|
|
147
|
+
if (queued !== void 0) {
|
|
148
|
+
this.unqueue(digest, queued), this.partials.delete(digest);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let size = this.held.get(digest);
|
|
152
|
+
size !== void 0 && (this.held.delete(digest), this.heldBytes -= size);
|
|
153
|
+
}), this.pump();
|
|
154
|
+
}
|
|
155
|
+
top() {
|
|
156
|
+
let top = null;
|
|
157
|
+
for (let priority = 0; priority < PRIORITIES; priority++)
|
|
158
|
+
if (this.queues[priority].length > 0) {
|
|
159
|
+
top = priority;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
for (let flight of this.flying.values()) (top === null || flight.priority < top) && (top = flight.priority);
|
|
163
|
+
return top;
|
|
164
|
+
}
|
|
165
|
+
preempt() {
|
|
166
|
+
let top = this.top();
|
|
167
|
+
if (top === null) return;
|
|
168
|
+
let aborted = /* @__PURE__ */ new Set();
|
|
169
|
+
for (let flight of this.flying.values())
|
|
170
|
+
flight.priority <= top || flight.controller === null || aborted.add(flight.controller);
|
|
171
|
+
if (aborted.size !== 0) {
|
|
172
|
+
for (let [digest, flight] of this.flying)
|
|
173
|
+
flight.controller === null || !aborted.has(flight.controller) || (flight.preempted = true, this.flying.delete(digest), this.preemptions++, this.queued.set(digest, flight.priority), this.queues[flight.priority].unshift(digest));
|
|
174
|
+
for (let controller of aborted) controller.abort();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
next() {
|
|
178
|
+
let top = this.top();
|
|
179
|
+
if (top === null) return null;
|
|
180
|
+
let queue = this.queues[top];
|
|
181
|
+
return queue.length === 0 || top === ChunkPriority.prefetch && this.prefetchFlying() >= this.prefetchSlots ? null : queue.shift() ?? null;
|
|
182
|
+
}
|
|
183
|
+
requestsFlying(priority) {
|
|
184
|
+
let count = 0, counted = /* @__PURE__ */ new Set();
|
|
185
|
+
for (let flight of this.flying.values())
|
|
186
|
+
if (!(priority !== null && flight.priority !== priority)) {
|
|
187
|
+
if (flight.controller !== null) {
|
|
188
|
+
if (counted.has(flight.controller)) continue;
|
|
189
|
+
counted.add(flight.controller);
|
|
190
|
+
}
|
|
191
|
+
count++;
|
|
192
|
+
}
|
|
193
|
+
return count;
|
|
194
|
+
}
|
|
195
|
+
prefetchFlying() {
|
|
196
|
+
return this.requestsFlying(ChunkPriority.prefetch);
|
|
197
|
+
}
|
|
198
|
+
pump() {
|
|
199
|
+
for (; this.requestsFlying(null) < this.concurrency; ) {
|
|
200
|
+
let digest = this.next();
|
|
201
|
+
if (digest === null) return;
|
|
202
|
+
let priority = this.queued.get(digest) ?? ChunkPriority.now;
|
|
203
|
+
this.queued.delete(digest);
|
|
204
|
+
let controller = typeof AbortController == "function" ? new AbortController() : null, run = this.gather(digest, priority);
|
|
205
|
+
if (run.length > 1) {
|
|
206
|
+
let flights = run.map((member) => {
|
|
207
|
+
let flight2 = { priority, preempted: false, controller };
|
|
208
|
+
return this.flying.set(member, flight2), flight2;
|
|
209
|
+
});
|
|
210
|
+
this.runs++, this.serveRun(run, flights, this.generation);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
let flight = { priority, preempted: false, controller };
|
|
214
|
+
this.flying.set(digest, flight), this.serve(digest, flight, this.generation);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
gather(digest, priority) {
|
|
218
|
+
let spans = this.options.spans;
|
|
219
|
+
if (spans === void 0 || this.options.source.fetchRun === void 0 || this.partials.has(digest)) return [digest];
|
|
220
|
+
let run = [digest], bytes = spans.locate(digest)?.size ?? 0, limit = this.options.run_bytes ?? DEFAULT_RUN_BYTES;
|
|
221
|
+
for (let step of [1, -1]) {
|
|
222
|
+
let at = digest;
|
|
223
|
+
for (; bytes < limit; ) {
|
|
224
|
+
let next = spans.neighbour(at, step);
|
|
225
|
+
if (next === null || this.queued.get(next) !== priority || this.partials.has(next)) break;
|
|
226
|
+
this.unqueue(next, priority), step === 1 ? run.push(next) : run.unshift(next), bytes += spans.locate(next)?.size ?? 0, at = next;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return run;
|
|
230
|
+
}
|
|
231
|
+
async serveRun(run, flights, generation) {
|
|
232
|
+
let live = (k) => generation === this.generation && !flights[k].preempted, fetchRun = this.options.source.fetchRun;
|
|
233
|
+
try {
|
|
234
|
+
let wanted = [];
|
|
235
|
+
for (let k = 0; k < run.length; k++) {
|
|
236
|
+
let declared = this.known.get(run[k])?.size;
|
|
237
|
+
declared !== void 0 && !this.fits(run[k], declared, flights[k].priority) ? this.fail(run[k], "budget") : wanted.push(k);
|
|
238
|
+
}
|
|
239
|
+
if (wanted.length === 0 || fetchRun === void 0) return;
|
|
240
|
+
let bodies;
|
|
241
|
+
try {
|
|
242
|
+
bodies = await fetchRun(
|
|
243
|
+
wanted.map((k) => run[k]),
|
|
244
|
+
flights[0].controller?.signal
|
|
245
|
+
);
|
|
246
|
+
} catch {
|
|
247
|
+
for (let k of wanted) live(k) && this.fail(run[k], "network");
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
for (let m = 0; m < wanted.length; m++) {
|
|
251
|
+
let k = wanted[m];
|
|
252
|
+
if (!live(k)) continue;
|
|
253
|
+
let body = bodies[m] ?? null;
|
|
254
|
+
if (body === null || !await verifyChunk(run[k], body)) {
|
|
255
|
+
live(k) && this.fail(run[k], body === null ? "network" : "verify");
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (live(k)) {
|
|
259
|
+
if (!this.fits(run[k], body.length, flights[k].priority)) {
|
|
260
|
+
this.fail(run[k], "budget");
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
this.heldBytes += body.length - (this.held.get(run[k]) ?? 0), this.held.set(run[k], body.length), this.sink?.deliver(run[k], body);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} finally {
|
|
267
|
+
for (let k = 0; k < run.length; k++)
|
|
268
|
+
generation === this.generation && this.flying.get(run[k]) === flights[k] && this.flying.delete(run[k]);
|
|
269
|
+
generation === this.generation && this.pump();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
fits(digest, size, priority) {
|
|
273
|
+
let already = this.held.get(digest) ?? 0, limit = priority === ChunkPriority.prefetch ? Math.floor(this.budget * PREFETCH_BUDGET_SHARE) : this.budget;
|
|
274
|
+
return this.heldBytes - already + size <= limit;
|
|
275
|
+
}
|
|
276
|
+
async serve(digest, flight, generation) {
|
|
277
|
+
let live = () => generation === this.generation && !flight.preempted;
|
|
278
|
+
try {
|
|
279
|
+
let declared = this.known.get(digest)?.size;
|
|
280
|
+
if (declared !== void 0 && !this.fits(digest, declared, flight.priority)) {
|
|
281
|
+
this.fail(digest, "budget");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
let partial = this.partials.get(digest);
|
|
285
|
+
partial === void 0 && (partial = new PartialChunk(), this.partials.set(digest, partial));
|
|
286
|
+
let body;
|
|
287
|
+
try {
|
|
288
|
+
body = await this.options.source.fetch(digest, flight.controller?.signal, partial);
|
|
289
|
+
} catch {
|
|
290
|
+
live() && (this.partials.delete(digest), this.fail(digest, "network"));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (!live()) return;
|
|
294
|
+
if (this.partials.delete(digest), !await verifyChunk(digest, body)) {
|
|
295
|
+
live() && this.fail(digest, "verify");
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (!live()) return;
|
|
299
|
+
if (!this.fits(digest, body.length, flight.priority)) {
|
|
300
|
+
this.fail(digest, "budget");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.heldBytes += body.length - (this.held.get(digest) ?? 0), this.held.set(digest, body.length), this.sink?.deliver(digest, body);
|
|
304
|
+
} finally {
|
|
305
|
+
generation === this.generation && this.flying.get(digest) === flight && this.flying.delete(digest), generation === this.generation && this.pump();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
fail(digest, reason) {
|
|
309
|
+
let length = writeChunkFailed(this.failure, digest, reason);
|
|
310
|
+
this.sink?.send(this.failure, length);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// src/interactives/hosts/chrome/mediator.ts
|
|
315
|
+
var HOST_REQUEST_PREFIX = "host-", NO_ARGUMENTS = {};
|
|
316
|
+
function trackingOf(consents, interactive_id) {
|
|
317
|
+
let state = consents.state(interactive_id, "tracking");
|
|
318
|
+
return state === "granted" ? "authorized" : state === "denied" ? "denied" : "not_asked";
|
|
319
|
+
}
|
|
320
|
+
var HostMediator = class {
|
|
321
|
+
constructor(options) {
|
|
322
|
+
this.options = options;
|
|
323
|
+
this.writer = new MessageWriter();
|
|
324
|
+
this.offers = /* @__PURE__ */ new Map();
|
|
325
|
+
this.offerRequests = /* @__PURE__ */ new Set();
|
|
326
|
+
this.hostCalls = /* @__PURE__ */ new Map();
|
|
327
|
+
this.asking = /* @__PURE__ */ new Set();
|
|
328
|
+
this.outlet = null;
|
|
329
|
+
this.program = null;
|
|
330
|
+
this.stopConsents = null;
|
|
331
|
+
this.nextHostCall = 0;
|
|
332
|
+
}
|
|
333
|
+
start(program, outlet) {
|
|
334
|
+
this.program = program, this.outlet = outlet, this.stopConsents?.(), this.stopConsents = this.options.consents.subscribe((interactive_id) => {
|
|
335
|
+
interactive_id === this.options.interactive_id && this.sendConsents();
|
|
336
|
+
}), this.sendConsents();
|
|
337
|
+
}
|
|
338
|
+
stop() {
|
|
339
|
+
this.stopConsents?.(), this.stopConsents = null, this.outlet = null, this.hostCalls.clear();
|
|
340
|
+
}
|
|
341
|
+
send(length) {
|
|
342
|
+
this.outlet?.toSession(this.writer.bytes, length);
|
|
343
|
+
}
|
|
344
|
+
sendConsents() {
|
|
345
|
+
this.send(this.writer.json(MessageTag.consent, { granted: [...this.options.consents.granted(this.options.interactive_id)] }));
|
|
346
|
+
}
|
|
347
|
+
relay(bytes) {
|
|
348
|
+
this.outlet?.toSession(bytes, bytes.length);
|
|
349
|
+
}
|
|
350
|
+
fromGuest(bytes) {
|
|
351
|
+
if (bytes[0] !== MessageTag.request) return false;
|
|
352
|
+
let envelope = readJson(bytes);
|
|
353
|
+
switch (envelope.call.operation) {
|
|
354
|
+
case "wallet.offers":
|
|
355
|
+
return this.offerRequests.add(envelope.request_id), false;
|
|
356
|
+
case "wallet.spend":
|
|
357
|
+
return this.spend(bytes.slice(), envelope.call.arguments), true;
|
|
358
|
+
case "ads.placement":
|
|
359
|
+
return this.options.registry === null ? false : (this.placement(bytes.slice(), envelope.call.arguments, this.options.registry), true);
|
|
360
|
+
default:
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
fromSession(bytes) {
|
|
365
|
+
if (bytes[0] !== MessageTag.response) return false;
|
|
366
|
+
let envelope = readJson(bytes), hostCall = this.hostCalls.get(envelope.request_id);
|
|
367
|
+
if (hostCall !== void 0)
|
|
368
|
+
return this.hostCalls.delete(envelope.request_id), hostCall(envelope), true;
|
|
369
|
+
let outcome = envelope.outcome;
|
|
370
|
+
return this.offerRequests.delete(envelope.request_id) && outcome.status === "ok" && this.remember(outcome.response.result), outcome.status === "error" && this.consentRequired(outcome.error), false;
|
|
371
|
+
}
|
|
372
|
+
remember(offers) {
|
|
373
|
+
for (let offer of offers.offers) this.offers.set(offer.offer_id, { display_name: offer.display_name, price_cimples: offer.price_cimples });
|
|
374
|
+
}
|
|
375
|
+
consentRequired(error) {
|
|
376
|
+
if (error.code !== "consent_required") return;
|
|
377
|
+
let kind = error.consent;
|
|
378
|
+
this.asking.has(kind) || this.options.consents.state(this.options.interactive_id, kind) !== "undecided" || (this.asking.add(kind), this.options.controller.requestConsent(kind).then((granted) => {
|
|
379
|
+
this.asking.delete(kind), this.options.consents.decide(this.options.interactive_id, kind, granted);
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
/** Sends one ctx call on the host's own behalf, such as posting a clip the player saved from host chrome. */
|
|
383
|
+
hostCall(operation, args = NO_ARGUMENTS) {
|
|
384
|
+
let program = this.program;
|
|
385
|
+
if (program === null) return Promise.reject(new Error("the host session has not started"));
|
|
386
|
+
let request_id = `${HOST_REQUEST_PREFIX}${this.nextHostCall++}`, envelope = {
|
|
387
|
+
contract_version: 1,
|
|
388
|
+
request_id,
|
|
389
|
+
interactive_id: program.interactive_id,
|
|
390
|
+
revision: program.revision,
|
|
391
|
+
deadline_ms: null,
|
|
392
|
+
call: { operation, arguments: args }
|
|
393
|
+
};
|
|
394
|
+
return new Promise((resolve) => {
|
|
395
|
+
this.hostCalls.set(request_id, resolve), this.send(this.writer.json(MessageTag.request, envelope));
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
async offer(offer_id) {
|
|
399
|
+
let known = this.offers.get(offer_id);
|
|
400
|
+
if (known !== void 0) return known;
|
|
401
|
+
let envelope = await this.hostCall("wallet.offers");
|
|
402
|
+
return envelope.outcome.status === "ok" && this.remember(envelope.outcome.response.result), this.offers.get(offer_id) ?? null;
|
|
403
|
+
}
|
|
404
|
+
async spend(request, spend) {
|
|
405
|
+
let offer = await this.offer(spend.offer_id).catch(() => null), price_cimples = offer === null ? 0 : offer.price_cimples * spend.quantity, decision = offer === null ? "cancelled" : await this.options.controller.confirmSpend({
|
|
406
|
+
offer_id: spend.offer_id,
|
|
407
|
+
display_name: offer.display_name,
|
|
408
|
+
quantity: spend.quantity,
|
|
409
|
+
price_cimples
|
|
410
|
+
}), confirmation = {
|
|
411
|
+
request_key: spend.request_key,
|
|
412
|
+
offer_id: spend.offer_id,
|
|
413
|
+
quantity: spend.quantity,
|
|
414
|
+
price_cimples,
|
|
415
|
+
decision
|
|
416
|
+
};
|
|
417
|
+
this.send(this.writer.json(MessageTag.confirm, confirmation)), this.relay(request);
|
|
418
|
+
}
|
|
419
|
+
async placement(request, placement, registry) {
|
|
420
|
+
let interactive_id = this.options.interactive_id;
|
|
421
|
+
try {
|
|
422
|
+
let served = await registry.decideAd(interactive_id, {
|
|
423
|
+
request_key: placement.request_key,
|
|
424
|
+
format: placement.format,
|
|
425
|
+
slot: placement.slot,
|
|
426
|
+
tracking: trackingOf(this.options.consents, interactive_id)
|
|
427
|
+
});
|
|
428
|
+
served.status === "decided" && served.creative !== null && await this.options.controller.showAd(served.creative) === "completed" && await registry.completeAd(interactive_id, served.placement_id, !1);
|
|
429
|
+
} catch {
|
|
430
|
+
this.relay(request);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
this.relay(request);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// src/interactives/hosts/gpu.ts
|
|
438
|
+
var GPU_REQUIREMENT_NAMES = [
|
|
439
|
+
"sampled_textures_per_stage",
|
|
440
|
+
"samplers_per_stage",
|
|
441
|
+
"storage_buffers_per_stage",
|
|
442
|
+
"compute_workgroup_invocations",
|
|
443
|
+
"compute_workgroup_storage_bytes"
|
|
444
|
+
], WEBGPU_LIMITS = {
|
|
445
|
+
sampled_textures_per_stage: "maxSampledTexturesPerShaderStage",
|
|
446
|
+
samplers_per_stage: "maxSamplersPerShaderStage",
|
|
447
|
+
storage_buffers_per_stage: "maxStorageBuffersPerShaderStage",
|
|
448
|
+
compute_workgroup_invocations: "maxComputeInvocationsPerWorkgroup",
|
|
449
|
+
compute_workgroup_storage_bytes: "maxComputeWorkgroupStorageSize"
|
|
450
|
+
}, NO_GPU = {
|
|
451
|
+
sampled_textures_per_stage: 0,
|
|
452
|
+
samplers_per_stage: 0,
|
|
453
|
+
storage_buffers_per_stage: 0,
|
|
454
|
+
compute_workgroup_invocations: 0,
|
|
455
|
+
compute_workgroup_storage_bytes: 0
|
|
456
|
+
}, WEBGL2 = "webgl2", MAX_TEXTURE_IMAGE_UNITS = 34930, decoder = new TextDecoder();
|
|
457
|
+
function unmetGpuRequirement(requirements, limits) {
|
|
458
|
+
for (let name of GPU_REQUIREMENT_NAMES) {
|
|
459
|
+
let floor = requirements[name];
|
|
460
|
+
if (floor !== void 0 && floor > limits[name]) return name;
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
function manifestGpuRequirements(manifest) {
|
|
465
|
+
return JSON.parse(decoder.decode(manifest)).gpu?.requirements ?? {};
|
|
466
|
+
}
|
|
467
|
+
function webglLimits(scope) {
|
|
468
|
+
let gl = scope.document?.createElement("canvas").getContext(WEBGL2) ?? null;
|
|
469
|
+
if (gl === null) return NO_GPU;
|
|
470
|
+
let units = Number(gl.getParameter((34930))) || 0;
|
|
471
|
+
return { ...NO_GPU, sampled_textures_per_stage: units, samplers_per_stage: units };
|
|
472
|
+
}
|
|
473
|
+
async function deviceGpuLimits(scope = globalThis) {
|
|
474
|
+
let adapter = await scope.navigator?.gpu?.requestAdapter().catch(() => null);
|
|
475
|
+
if (adapter == null) return webglLimits(scope);
|
|
476
|
+
let limits = { ...NO_GPU };
|
|
477
|
+
for (let name of GPU_REQUIREMENT_NAMES) limits[name] = adapter.limits[WEBGPU_LIMITS[name]] ?? 0;
|
|
478
|
+
return limits;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/interactives/parts/brotli.ts
|
|
482
|
+
var BROTLI_FORMAT = "brotli";
|
|
483
|
+
function brotliStream() {
|
|
484
|
+
try {
|
|
485
|
+
return new DecompressionStream(BROTLI_FORMAT);
|
|
486
|
+
} catch {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
async function inflateCapped(body, inflate, cap) {
|
|
491
|
+
let reader = body.pipeThrough(inflate).getReader(), pieces = [], length = 0;
|
|
492
|
+
for (; ; ) {
|
|
493
|
+
let { done, value } = await reader.read();
|
|
494
|
+
if (done) break;
|
|
495
|
+
if (length += value.length, length > cap)
|
|
496
|
+
return await reader.cancel(), null;
|
|
497
|
+
pieces.push(value);
|
|
498
|
+
}
|
|
499
|
+
let out = new Uint8Array(length), at = 0;
|
|
500
|
+
for (let piece of pieces)
|
|
501
|
+
out.set(piece, at), at += piece.length;
|
|
502
|
+
return out;
|
|
503
|
+
}
|
|
504
|
+
async function fetchTwin(fetcher, url, cap, signal) {
|
|
505
|
+
let inflate = brotliStream();
|
|
506
|
+
if (inflate === null) return null;
|
|
507
|
+
try {
|
|
508
|
+
let response = await fetcher(`${url}.br`, { signal });
|
|
509
|
+
if (!response.ok || response.body === null) return null;
|
|
510
|
+
let wire = Number(response.headers.get("content-length") ?? 0), bytes = await inflateCapped(response.body, inflate, cap);
|
|
511
|
+
return bytes === null ? null : { bytes, wire };
|
|
512
|
+
} catch {
|
|
513
|
+
if (signal?.aborted === true) throw signal.reason;
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/interactives/hosts/session.ts
|
|
519
|
+
var SESSION_PATH_SUFFIX = "/session", OPEN = 1, NORMAL_CLOSE = 1e3;
|
|
520
|
+
function sessionUrl(target) {
|
|
521
|
+
let url = new URL(`/v1/interactives/${encodeURIComponent(target.interactive_id)}${SESSION_PATH_SUFFIX}`, target.base_url);
|
|
522
|
+
return url.protocol = url.protocol === "https:" ? "wss:" : url.protocol === "http:" ? "ws:" : url.protocol, url.searchParams.set("revision", target.revision), url.searchParams.set("channel", target.channel ?? "live"), url.href;
|
|
523
|
+
}
|
|
524
|
+
function bytesOf(data) {
|
|
525
|
+
return data instanceof ArrayBuffer ? new Uint8Array(data) : ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : null;
|
|
526
|
+
}
|
|
527
|
+
function openSession(target, connect) {
|
|
528
|
+
let socket = connect(sessionUrl(target));
|
|
529
|
+
socket.binaryType = "arraybuffer";
|
|
530
|
+
let listener = () => {
|
|
531
|
+
}, closers = [], closed = null, finish = (close) => {
|
|
532
|
+
if (closed === null) {
|
|
533
|
+
closed = close;
|
|
534
|
+
for (let closer of closers) closer(close);
|
|
535
|
+
}
|
|
536
|
+
}, transport = {
|
|
537
|
+
send(bytes, length) {
|
|
538
|
+
socket.readyState === (1) && socket.send(bytes.subarray(0, length));
|
|
539
|
+
},
|
|
540
|
+
on_message(next) {
|
|
541
|
+
listener = next;
|
|
542
|
+
},
|
|
543
|
+
on_close(next) {
|
|
544
|
+
closed !== null ? next(closed) : closers.push(next);
|
|
545
|
+
},
|
|
546
|
+
close() {
|
|
547
|
+
finish({ reason: "closed_by_host", detail: null }), socket.close((1e3));
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
return new Promise((resolve, reject) => {
|
|
551
|
+
socket.onmessage = (event) => {
|
|
552
|
+
let bytes = bytesOf(event.data);
|
|
553
|
+
if (!(bytes === null || bytes.length === 0)) {
|
|
554
|
+
if (bytes[0] === MessageTag.hello) {
|
|
555
|
+
let hello = readJson(bytes);
|
|
556
|
+
if (hello.protocol !== 1) {
|
|
557
|
+
reject(new Error(`session protocol ${hello.protocol} is not ${1}`)), socket.close((1e3));
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
resolve({ transport, hello });
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (bytes[0] === MessageTag.close) {
|
|
564
|
+
let close = readJson(bytes);
|
|
565
|
+
reject(new Error(close.detail ?? close.reason)), finish(close);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
listener(bytes);
|
|
569
|
+
}
|
|
570
|
+
}, socket.onclose = (event) => {
|
|
571
|
+
let close = { reason: "disconnected", detail: event.reason || String(event.code) };
|
|
572
|
+
reject(new Error(close.detail)), finish(close);
|
|
573
|
+
}, socket.onerror = () => {
|
|
574
|
+
};
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
var PARTIAL_CONTENT = 206;
|
|
578
|
+
function httpChunks(base, fetcher = fetch) {
|
|
579
|
+
return {
|
|
580
|
+
fetchTwin: async (digest, cap, signal) => (await fetchTwin(fetcher, new URL(digest, base).href, cap, signal))?.bytes ?? null,
|
|
581
|
+
async fetch(digest, signal, partial) {
|
|
582
|
+
let from = partial?.received ?? 0, init = { signal, headers: from > 0 ? { Range: `bytes=${from}-` } : void 0 }, response = await fetcher(new URL(digest, base).href, init);
|
|
583
|
+
if (!response.ok) throw new Error(`chunk ${digest} answered ${response.status}`);
|
|
584
|
+
if (partial === void 0 || response.body === null) {
|
|
585
|
+
partial?.reset();
|
|
586
|
+
let body = new Uint8Array(await response.arrayBuffer());
|
|
587
|
+
return partial?.append(body), body;
|
|
588
|
+
}
|
|
589
|
+
from > 0 && response.status !== (206) && partial.reset();
|
|
590
|
+
let reader = response.body.getReader();
|
|
591
|
+
for (; ; ) {
|
|
592
|
+
let { done, value } = await reader.read();
|
|
593
|
+
if (done) break;
|
|
594
|
+
partial.append(value);
|
|
595
|
+
}
|
|
596
|
+
return partial.join();
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// src/interactives/hosts/zones.ts
|
|
602
|
+
var PARTIAL_CONTENT2 = 206, ZoneSpans = class _ZoneSpans {
|
|
603
|
+
constructor() {
|
|
604
|
+
this.spans = /* @__PURE__ */ new Map();
|
|
605
|
+
this.members = /* @__PURE__ */ new Map();
|
|
606
|
+
}
|
|
607
|
+
static of(chunks, files) {
|
|
608
|
+
let spans = new _ZoneSpans();
|
|
609
|
+
for (let file of files) {
|
|
610
|
+
let members = chunks.filter((chunk) => chunk.asset_group === file.asset_group);
|
|
611
|
+
if (members.length !== file.parts || members.some((chunk) => chunk.size === void 0) || members.reduce((sum, chunk) => sum + (chunk.size ?? 0), 0) !== file.bytes) continue;
|
|
612
|
+
let offset = 0;
|
|
613
|
+
members.forEach((chunk, index) => {
|
|
614
|
+
let size = chunk.size ?? 0;
|
|
615
|
+
spans.spans.has(chunk.digest) || spans.spans.set(chunk.digest, { file: file.digest, offset, size, index }), offset += size;
|
|
616
|
+
}), spans.members.set(
|
|
617
|
+
file.digest,
|
|
618
|
+
members.map((chunk) => chunk.digest)
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
return spans;
|
|
622
|
+
}
|
|
623
|
+
get size() {
|
|
624
|
+
return this.spans.size;
|
|
625
|
+
}
|
|
626
|
+
locate(digest) {
|
|
627
|
+
return this.spans.get(digest);
|
|
628
|
+
}
|
|
629
|
+
neighbour(digest, step) {
|
|
630
|
+
let span = this.spans.get(digest);
|
|
631
|
+
return span === void 0 ? null : this.members.get(span.file)?.[span.index + step] ?? null;
|
|
632
|
+
}
|
|
633
|
+
runs(digests) {
|
|
634
|
+
let runs = [], current = [], last;
|
|
635
|
+
for (let k = 0; k < digests.length; k++) {
|
|
636
|
+
let span = this.spans.get(digests[k]);
|
|
637
|
+
!(span !== void 0 && last !== void 0 && span.file === last.file && span.index === last.index + 1) && current.length > 0 && (runs.push(current), current = []), current.push(k), last = span;
|
|
638
|
+
}
|
|
639
|
+
return current.length > 0 && runs.push(current), runs;
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
function rangedChunks(base, spans, fetcher = fetch) {
|
|
643
|
+
let single = httpChunks(base, fetcher), range = async (digests, signal) => {
|
|
644
|
+
let first = spans.locate(digests[0]), last = spans.locate(digests[digests.length - 1]);
|
|
645
|
+
if (first === void 0 || last === void 0) return Promise.all(digests.map((digest) => single.fetch(digest, signal).catch(() => null)));
|
|
646
|
+
let start = first.offset, end = last.offset + last.size, response = await fetcher(new URL(first.file, base).href, { signal, headers: { Range: `bytes=${start}-${end - 1}` } });
|
|
647
|
+
if (!response.ok) throw new Error(`zone file ${first.file} answered ${response.status}`);
|
|
648
|
+
let whole = new Uint8Array(await response.arrayBuffer()), at = response.status === (206) ? 0 : start;
|
|
649
|
+
if (whole.length < at + end - start) throw new Error(`zone file ${first.file} answered ${whole.length} bytes for ${end - start}`);
|
|
650
|
+
return digests.map((digest) => {
|
|
651
|
+
let span = spans.locate(digest);
|
|
652
|
+
if (span === void 0) return null;
|
|
653
|
+
let from = at + span.offset - start;
|
|
654
|
+
return whole.slice(from, from + span.size);
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
return {
|
|
658
|
+
fetch: single.fetch,
|
|
659
|
+
fetchTwin: single.fetchTwin,
|
|
660
|
+
async fetchRun(digests, signal) {
|
|
661
|
+
let out = new Array(digests.length).fill(null);
|
|
662
|
+
return await Promise.all(
|
|
663
|
+
spans.runs(digests).map(async (run) => {
|
|
664
|
+
let bodies = await range(
|
|
665
|
+
run.map((k) => digests[k]),
|
|
666
|
+
signal
|
|
667
|
+
).catch(() => run.map(() => null));
|
|
668
|
+
run.forEach((k, m) => {
|
|
669
|
+
out[k] = bodies[m];
|
|
670
|
+
});
|
|
671
|
+
})
|
|
672
|
+
), out;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// src/interactives/hosts/webgpu.ts
|
|
678
|
+
var probed = null, probing = null;
|
|
679
|
+
function gpuOf() {
|
|
680
|
+
let gpu = globalThis.navigator?.gpu;
|
|
681
|
+
return gpu !== void 0 && typeof gpu.requestAdapter == "function" ? gpu : null;
|
|
682
|
+
}
|
|
683
|
+
function probeHostWebGpu() {
|
|
684
|
+
if (probing !== null) return probing;
|
|
685
|
+
let gpu = gpuOf();
|
|
686
|
+
return probing = gpu === null ? Promise.resolve(false) : gpu.requestAdapter().then(
|
|
687
|
+
(adapter) => adapter != null,
|
|
688
|
+
() => false
|
|
689
|
+
), probing.then((found) => {
|
|
690
|
+
probed = found;
|
|
691
|
+
}), probing;
|
|
692
|
+
}
|
|
693
|
+
function hostWebGpu() {
|
|
694
|
+
return probed ?? gpuOf() !== null;
|
|
695
|
+
}
|
|
696
|
+
function forgetHostWebGpu() {
|
|
697
|
+
probed = null, probing = null;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/interactives/hosts/clips.ts
|
|
701
|
+
var CLIP_CAMERA = "clip_camera", REPLAY_MEDIA_TYPE = "application/vnd.cimplify.replay", CLIP_COMMANDS = /* @__PURE__ */ new Set(["clip_start", "clip_stop", "clip_cancel", "clip_keep", "replay_save"]);
|
|
702
|
+
function isClipCommand(command) {
|
|
703
|
+
return CLIP_COMMANDS.has(command.kind);
|
|
704
|
+
}
|
|
705
|
+
function clipArm(options) {
|
|
706
|
+
return {
|
|
707
|
+
window_ms: options.window_ms ?? DEFAULT_CLIP_ARM.window_ms,
|
|
708
|
+
fps: options.fps ?? DEFAULT_CLIP_ARM.fps,
|
|
709
|
+
video_bits_per_second: options.video_bits_per_second ?? DEFAULT_CLIP_ARM.video_bits_per_second,
|
|
710
|
+
audio: options.audio ?? DEFAULT_CLIP_ARM.audio,
|
|
711
|
+
max_long_edge: options.max_long_edge ?? DEFAULT_CLIP_ARM.max_long_edge
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function keptMs(window_ms, started, now, max_ms) {
|
|
715
|
+
return Math.max(0, Math.min(now - started, max_ms, window_ms));
|
|
716
|
+
}
|
|
717
|
+
function failure(code) {
|
|
718
|
+
return { error: code };
|
|
719
|
+
}
|
|
720
|
+
function replyOf(outcome) {
|
|
721
|
+
return "media" in outcome ? { media_id: outcome.media.media_id } : { error: { code: outcome.error } };
|
|
722
|
+
}
|
|
723
|
+
var HostClips = class {
|
|
724
|
+
constructor(options, interactive_id, consent, now) {
|
|
725
|
+
this.options = options;
|
|
726
|
+
this.interactive_id = interactive_id;
|
|
727
|
+
this.consent = consent;
|
|
728
|
+
this.now = now;
|
|
729
|
+
this.guest = null;
|
|
730
|
+
this.recordings = /* @__PURE__ */ new Map();
|
|
731
|
+
this.nextRecording = 1;
|
|
732
|
+
this.paused = false;
|
|
733
|
+
this.stopConsents = null;
|
|
734
|
+
this.asking = null;
|
|
735
|
+
this.arm = clipArm(options);
|
|
736
|
+
}
|
|
737
|
+
get available() {
|
|
738
|
+
return this.guest !== null;
|
|
739
|
+
}
|
|
740
|
+
attach(guest) {
|
|
741
|
+
if (this.detach(), this.guest = guest, guest === null) return;
|
|
742
|
+
this.paused = false, guest.arm(this.arm), guest.on_camera_live(() => this.update());
|
|
743
|
+
let consents = this.consent?.consents;
|
|
744
|
+
consents !== void 0 && (this.stopConsents = consents.subscribe((interactive_id) => {
|
|
745
|
+
interactive_id === this.interactive_id && this.update();
|
|
746
|
+
})), this.update();
|
|
747
|
+
}
|
|
748
|
+
detach() {
|
|
749
|
+
this.stopConsents?.(), this.stopConsents = null, this.guest?.arm(null), this.guest = null, this.recordings.clear();
|
|
750
|
+
}
|
|
751
|
+
cameraAllowed() {
|
|
752
|
+
return this.consent?.consents.state(this.interactive_id, CLIP_CAMERA) === "granted";
|
|
753
|
+
}
|
|
754
|
+
update() {
|
|
755
|
+
let guest = this.guest;
|
|
756
|
+
if (guest === null) return;
|
|
757
|
+
let paused = guest.camera_live && !this.cameraAllowed();
|
|
758
|
+
paused !== this.paused && (this.paused = paused, guest.pause(paused));
|
|
759
|
+
}
|
|
760
|
+
/** Asks for camera in clips from host chrome; the answer lifts the pause for later saves. */
|
|
761
|
+
askCamera() {
|
|
762
|
+
let consent = this.consent;
|
|
763
|
+
return consent === null ? Promise.resolve(false) : (this.asking ?? (this.asking = consent.controller.requestConsent(CLIP_CAMERA).then((granted) => (consent.consents.decide(this.interactive_id, CLIP_CAMERA, granted), this.asking = null, this.update(), granted))), this.asking);
|
|
764
|
+
}
|
|
765
|
+
async keep(keep_ms) {
|
|
766
|
+
let guest = this.guest;
|
|
767
|
+
if (guest === null) return failure("unavailable");
|
|
768
|
+
if (guest.camera_live && !this.cameraAllowed())
|
|
769
|
+
return this.consent?.consents.state(this.interactive_id, CLIP_CAMERA) === "undecided" && this.askCamera(), failure("camera_consent");
|
|
770
|
+
let saved = await guest.save(Math.min(Math.max(0, keep_ms), this.arm.window_ms));
|
|
771
|
+
return saved === null ? failure("nothing_recorded") : this.upload("video", saved);
|
|
772
|
+
}
|
|
773
|
+
async saveReplay(bytes) {
|
|
774
|
+
let blob = new Blob([bytes], { type: REPLAY_MEDIA_TYPE });
|
|
775
|
+
return this.upload("replay", { blob, type: REPLAY_MEDIA_TYPE, duration_ms: 0, width: 0, height: 0 });
|
|
776
|
+
}
|
|
777
|
+
async upload(kind, saved) {
|
|
778
|
+
try {
|
|
779
|
+
return { media: await this.options.upload({ kind, interactive_id: this.interactive_id, ...saved }) };
|
|
780
|
+
} catch {
|
|
781
|
+
return failure("failed");
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
async command(command) {
|
|
785
|
+
switch (command.kind) {
|
|
786
|
+
case "clip_start": {
|
|
787
|
+
let clip = this.nextRecording++;
|
|
788
|
+
return this.recordings.set(clip, { started: this.now(), max_ms: Math.min(Math.max(0, command.max_ms), this.arm.window_ms) }), { clip };
|
|
789
|
+
}
|
|
790
|
+
case "clip_stop": {
|
|
791
|
+
let recording = this.recordings.get(command.clip);
|
|
792
|
+
return recording === void 0 ? { error: { code: "unknown_clip" } } : (this.recordings.delete(command.clip), replyOf(await this.keep(keptMs(this.arm.window_ms, recording.started, this.now(), recording.max_ms))));
|
|
793
|
+
}
|
|
794
|
+
case "clip_cancel":
|
|
795
|
+
return this.recordings.delete(command.clip), null;
|
|
796
|
+
case "clip_keep":
|
|
797
|
+
return replyOf(await this.keep(command.ms));
|
|
798
|
+
case "replay_save":
|
|
799
|
+
return replyOf(await this.saveReplay(decodeBase64(command.replay)));
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
// src/interactives/hosts/web.ts
|
|
805
|
+
var FIRST_FRAME_MILESTONE = "first_frame_scheduled";
|
|
806
|
+
function referable(ref) {
|
|
807
|
+
return typeof ref.payload_digest == "string" && isDigestHex(ref.payload_digest);
|
|
808
|
+
}
|
|
809
|
+
function never() {
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
812
|
+
var ENGINE_GROUP_PREFIX = "engine:", SINGLE_THREAD_GROUP = "threads:single", ISOLATED_THREAD_GROUP = "threads:isolated", TIER_GROUP_PREFIX = "tier:", DEFAULT_HOST_TIER = "mid", ALTERNATIVE_RUNTIMES = { [ENGINE_CORE_THREADS_UNIT]: ENGINE_CORE_UNIT };
|
|
813
|
+
function standsInFor(chunk) {
|
|
814
|
+
let name = chunk.runtime?.name;
|
|
815
|
+
return name === void 0 ? null : chunk.asset_group === SCRIPTS_CORE_GROUP || chunk.asset_group === GL_CORE_GROUP ? name === ENGINE_CORE_UNIT ? ENGINE_CORE_UNIT : null : chunk.asset_group !== ISOLATED_THREAD_GROUP ? null : ALTERNATIVE_RUNTIMES[name] ?? null;
|
|
816
|
+
}
|
|
817
|
+
function chunksForHost(chunks, engine, isolated = false, tier = DEFAULT_HOST_TIER, threads = false, scripts = luauVmRunsHere, webgpu = hostWebGpu()) {
|
|
818
|
+
let skipped = isolated ? SINGLE_THREAD_GROUP : ISOLATED_THREAD_GROUP, tierGroup = `${TIER_GROUP_PREFIX}${tier}`, offers = (group) => chunks.some((chunk) => chunk.asset_group === group && standsInFor(chunk) !== null), scripted = offers(SCRIPTS_CORE_GROUP), glCore = !webgpu && offers(GL_CORE_GROUP) && (!scripted || scripts()), scriptsCore = !glCore && scripted && scripts(), chosen = (chunk) => chunk.asset_group === GL_CORE_GROUP ? glCore : chunk.asset_group === SCRIPTS_CORE_GROUP ? scriptsCore : threads && !scriptsCore && !glCore, replaced = /* @__PURE__ */ new Set();
|
|
819
|
+
for (let chunk of chunks) {
|
|
820
|
+
let unit = standsInFor(chunk);
|
|
821
|
+
unit !== null && chosen(chunk) && replaced.add(unit);
|
|
822
|
+
}
|
|
823
|
+
return chunks.filter((chunk) => {
|
|
824
|
+
if (standsInFor(chunk) !== null) return chosen(chunk);
|
|
825
|
+
let runtime = chunk.runtime?.name;
|
|
826
|
+
if (runtime !== void 0 && replaced.has(runtime)) return false;
|
|
827
|
+
let group = chunk.asset_group;
|
|
828
|
+
return group === void 0 ? true : group === skipped ? false : group.startsWith(TIER_GROUP_PREFIX) ? group === tierGroup : group === LUAU_SCRIPTS_GROUP ? luauVmRunsHere() : group.startsWith(ENGINE_GROUP_PREFIX) ? engine !== null && group === `${ENGINE_GROUP_PREFIX}${engine}` : true;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
var CODE_GROUP = "code";
|
|
832
|
+
function linksBeforeStart(chunk) {
|
|
833
|
+
if (!chunk.before_play) return false;
|
|
834
|
+
if (standsInFor(chunk) !== null) return true;
|
|
835
|
+
let group = chunk.asset_group;
|
|
836
|
+
return group === void 0 || group === CODE_GROUP || group.startsWith(ENGINE_GROUP_PREFIX);
|
|
837
|
+
}
|
|
838
|
+
function swappable(chunk) {
|
|
839
|
+
if (chunk.lazy === true || (chunk.runtime ?? null) !== null || standsInFor(chunk) !== null) return false;
|
|
840
|
+
let group = chunk.asset_group;
|
|
841
|
+
return group === void 0 || !(group.startsWith(ENGINE_GROUP_PREFIX) || group.startsWith(TIER_GROUP_PREFIX) || group === SINGLE_THREAD_GROUP || group === ISOLATED_THREAD_GROUP);
|
|
842
|
+
}
|
|
843
|
+
async function swapInPlace(host, build) {
|
|
844
|
+
if (host === null) return { swapped: false, reason: "the Interactive is not running" };
|
|
845
|
+
let next;
|
|
846
|
+
try {
|
|
847
|
+
next = await build();
|
|
848
|
+
} catch (error) {
|
|
849
|
+
return { swapped: false, reason: error instanceof Error ? error.message : String(error) };
|
|
850
|
+
}
|
|
851
|
+
return !next.ok || next.host !== true || next.chunks === void 0 || next.chunks === null ? { swapped: false, reason: "the new build cannot run here" } : host.hotSwap(next.chunks);
|
|
852
|
+
}
|
|
853
|
+
function hostIsolated() {
|
|
854
|
+
return globalThis.crossOriginIsolated === true;
|
|
855
|
+
}
|
|
856
|
+
function hostThreads() {
|
|
857
|
+
return hostIsolated() && threadsAvailable();
|
|
858
|
+
}
|
|
859
|
+
var DEFAULT_HOST_LIMITS = {
|
|
860
|
+
ping_ms: 250,
|
|
861
|
+
cpu_slice_ms: 2e3,
|
|
862
|
+
memory_bytes: 128 * 1024 * 1024,
|
|
863
|
+
boot_ms: 1e4,
|
|
864
|
+
restarts_per_window: 3,
|
|
865
|
+
restart_window_ms: 6e4
|
|
866
|
+
}, HostFaultError = class extends Error {
|
|
867
|
+
constructor(fault) {
|
|
868
|
+
super(fault.message);
|
|
869
|
+
this.fault = fault;
|
|
870
|
+
this.name = "HostFaultError";
|
|
871
|
+
}
|
|
872
|
+
}, RELAYED_FROM_GUEST = /* @__PURE__ */ new Set([MessageTag.request, MessageTag.frames]), RELAYED_FROM_SESSION = /* @__PURE__ */ new Set([MessageTag.response, MessageTag.event, MessageTag.frames]), PARTS_SUBSCRIPTION = "sub_host_parts";
|
|
873
|
+
function workerEngines(script) {
|
|
874
|
+
return {
|
|
875
|
+
spawn() {
|
|
876
|
+
let worker = new Worker(script, { type: "module" }), listener = () => {
|
|
877
|
+
};
|
|
878
|
+
return worker.onmessage = (event) => listener(new Uint8Array(event.data)), {
|
|
879
|
+
send(bytes, length) {
|
|
880
|
+
let copy = bytes.slice(0, length);
|
|
881
|
+
worker.postMessage(copy.buffer, [copy.buffer]);
|
|
882
|
+
},
|
|
883
|
+
on_message(next) {
|
|
884
|
+
listener = next;
|
|
885
|
+
},
|
|
886
|
+
on_crash(next) {
|
|
887
|
+
worker.onerror = (event) => {
|
|
888
|
+
event.preventDefault(), next(event.message || "the guest engine stopped");
|
|
889
|
+
};
|
|
890
|
+
},
|
|
891
|
+
terminate() {
|
|
892
|
+
worker.terminate();
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
var GuestPool = class {
|
|
899
|
+
constructor(factory, size) {
|
|
900
|
+
this.factory = factory;
|
|
901
|
+
this.size = size;
|
|
902
|
+
this.ready = [];
|
|
903
|
+
this.waiting = [];
|
|
904
|
+
for (let i = 0; i < size; i++) this.warm();
|
|
905
|
+
}
|
|
906
|
+
warm() {
|
|
907
|
+
let engine = this.factory.spawn();
|
|
908
|
+
engine.on_crash(() => {
|
|
909
|
+
engine.terminate(), this.warm();
|
|
910
|
+
}), engine.on_message((bytes) => {
|
|
911
|
+
if (bytes[0] !== MessageTag.ready) return;
|
|
912
|
+
engine.on_message(() => {
|
|
913
|
+
});
|
|
914
|
+
let next = this.waiting.shift();
|
|
915
|
+
next !== void 0 ? next(engine) : this.ready.push(engine);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
acquire() {
|
|
919
|
+
this.warm();
|
|
920
|
+
let engine = this.ready.shift();
|
|
921
|
+
return engine !== void 0 ? Promise.resolve(engine) : new Promise((resolve) => this.waiting.push(resolve));
|
|
922
|
+
}
|
|
923
|
+
drain() {
|
|
924
|
+
for (let engine of this.ready) engine.terminate();
|
|
925
|
+
this.ready.length = 0;
|
|
926
|
+
}
|
|
927
|
+
get warmed() {
|
|
928
|
+
return this.ready.length;
|
|
929
|
+
}
|
|
930
|
+
}, TreeStore = class {
|
|
931
|
+
constructor() {
|
|
932
|
+
this.mirror = new TreeMirror();
|
|
933
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
934
|
+
this.subscribe = (listener) => (this.listeners.add(listener), () => this.listeners.delete(listener));
|
|
935
|
+
this.snapshot = () => this.mirror.root;
|
|
936
|
+
}
|
|
937
|
+
apply(patches) {
|
|
938
|
+
this.mirror.apply(patches);
|
|
939
|
+
for (let listener of this.listeners) listener();
|
|
940
|
+
}
|
|
941
|
+
reset() {
|
|
942
|
+
this.mirror.apply([{ op: "root", node: null }]);
|
|
943
|
+
for (let listener of this.listeners) listener();
|
|
944
|
+
}
|
|
945
|
+
}, WebHost = class {
|
|
946
|
+
constructor(options) {
|
|
947
|
+
this.options = options;
|
|
948
|
+
this.tree = new TreeStore();
|
|
949
|
+
this.writer = new MessageWriter();
|
|
950
|
+
this.stepMessage = new Uint8Array(TAG_BYTES);
|
|
951
|
+
this.supplying = 0;
|
|
952
|
+
this.ping = new Uint8Array(PING_BYTES);
|
|
953
|
+
this.pingView = new DataView(this.ping.buffer);
|
|
954
|
+
this.lifecycleMessage = new Uint8Array(LIFECYCLE_BYTES);
|
|
955
|
+
this.partsSequence = 0;
|
|
956
|
+
this.engine = null;
|
|
957
|
+
this.watchdog = null;
|
|
958
|
+
this.pingSequence = 0;
|
|
959
|
+
this.pingSentAt = -1;
|
|
960
|
+
this.restarts = [];
|
|
961
|
+
this.started = null;
|
|
962
|
+
this.failed = null;
|
|
963
|
+
this.phase = "idle";
|
|
964
|
+
this.outlet = { toSession: (bytes, length) => this.options.transport.send(bytes, length) };
|
|
965
|
+
this.networkMessage = new Uint8Array(NETWORK_MESSAGE_BYTES);
|
|
966
|
+
this.unwatchNetwork = null;
|
|
967
|
+
this.inspectorMessage = new Uint8Array(INSPECTOR_BYTES);
|
|
968
|
+
this.inspectorShown = false;
|
|
969
|
+
this.meterRequest = METERS_OFF;
|
|
970
|
+
this.studioOut = new StudioSender(MessageTag.studio, (frame) => this.engine?.send(frame, frame.length));
|
|
971
|
+
this.hotDone = null;
|
|
972
|
+
options.webgpu === void 0 && probeHostWebGpu(), this.networkHint = options.network === void 0 ? webNetworkHint() : options.network, options.network === void 0 && (this.unwatchNetwork = watchWebNetwork((hint) => this.setNetwork(hint))), this.limits = { ...DEFAULT_HOST_LIMITS, ...options.limits }, this.studioIn = options.on_studio === void 0 ? null : new StudioAssembler();
|
|
973
|
+
let isolated = hostIsolated(), threads = options.threads ?? hostThreads(), webgpu = options.webgpu ?? hostWebGpu();
|
|
974
|
+
this.hosted = (chunks) => chunksForHost(chunks, null, isolated, options.device_tier ?? DEFAULT_HOST_TIER, threads, luauVmRunsHere, webgpu);
|
|
975
|
+
let hosted = this.hosted(options.package.chunks);
|
|
976
|
+
this.known = new Set(hosted.map((chunk) => chunk.digest)), this.chunks = hosted.filter((chunk) => chunk.lazy !== true), this.parts = options.part_store === void 0 ? null : options.part_store.session(
|
|
977
|
+
options.hello.program.interactive_id,
|
|
978
|
+
hosted.map((chunk) => ({ digest: chunk.digest, zone: chunk.asset_group ?? DEFAULT_PART_ZONE })),
|
|
979
|
+
{ keep_on_device: options.package.keep_on_device === true }
|
|
980
|
+
), this.parts?.on_evicted((eviction) => this.evicted(eviction));
|
|
981
|
+
let upstream = twinned(options.chunks, twinCaps(options.package.chunks));
|
|
982
|
+
this.source = this.parts === null ? upstream : this.parts.source(upstream);
|
|
983
|
+
let spans = ZoneSpans.of(options.package.chunks, options.package.zone_files ?? []);
|
|
984
|
+
this.afterFirstFrame = hosted.filter((chunk) => chunk.lazy === true && chunk.asset_group === LUAU_SCRIPTS_GROUP).map((chunk) => chunk.digest), this.lazyChunks = new LazyChunkServer(hosted.filter((chunk) => chunk.lazy === true), {
|
|
985
|
+
source: this.source,
|
|
986
|
+
budget_bytes: options.lazy_budget_bytes,
|
|
987
|
+
concurrency: options.lazy_concurrency,
|
|
988
|
+
spans: spans.size > 0 ? spans : void 0
|
|
989
|
+
}), this.mediator = options.chrome === void 0 ? null : new HostMediator(options.chrome), this.now = options.now ?? (() => Date.now());
|
|
990
|
+
let chrome = options.chrome;
|
|
991
|
+
this.clips = options.clips === void 0 ? null : new HostClips(options.clips, options.hello.program.interactive_id, chrome === void 0 ? null : { consents: chrome.consents, controller: chrome.controller }, this.now), this.ping[0] = MessageTag.ping, this.lifecycleMessage[0] = MessageTag.lifecycle, this.inspectorMessage[0] = MessageTag.inspector, options.transport.on_message((bytes) => this.fromSession(bytes)), options.transport.on_close((close) => this.fail({ source: "session", message: `${close.reason}${close.detail ? `: ${close.detail}` : ""}` }));
|
|
992
|
+
}
|
|
993
|
+
engineHeap() {
|
|
994
|
+
return engineHeapFor(this.options.package.engine_heap, this.options.device_tier ?? DEFAULT_HOST_TIER);
|
|
995
|
+
}
|
|
996
|
+
deviceRefusal() {
|
|
997
|
+
let gpu = this.options.gpu, unmet = gpu === void 0 ? null : unmetGpuRequirement(gpu.requirements, gpu.limits);
|
|
998
|
+
if (unmet !== null) return { source: "device", requirement: unmet, message: `this device's GPU is below the game's ${unmet} requirement` };
|
|
999
|
+
let features = this.options.engine_features, missing = features === void 0 ? null : unmetEngineFeature(features.required, features.available);
|
|
1000
|
+
if (missing !== null) return { source: "device", requirement: missing, message: `this device's engine does not provide ${missing}, which the game uses` };
|
|
1001
|
+
let heap = this.engineHeap();
|
|
1002
|
+
return "refused" in heap ? { source: "device", requirement: ENGINE_HEAP_REQUIREMENT, message: heap.refused } : null;
|
|
1003
|
+
}
|
|
1004
|
+
async start() {
|
|
1005
|
+
if (this.phase !== "idle" && this.phase !== "crashed") throw new Error(`the host is ${this.phase}`);
|
|
1006
|
+
let refused = this.deviceRefusal();
|
|
1007
|
+
if (refused !== null)
|
|
1008
|
+
throw this.options.on_fault?.(refused), new HostFaultError(refused);
|
|
1009
|
+
this.phase = "booting", this.mediator?.start(this.options.hello.program, this.outlet);
|
|
1010
|
+
let engines = this.options.engines, runtimes = this.options.runtimes, interactive = this.options.hello.program.interactive_id, warm = runtimes === void 0 ? null : await runtimes.take(this.chunks, interactive), pooled = warm !== null || engines instanceof GuestPool, engine = warm?.engine ?? (engines instanceof GuestPool ? await engines.acquire() : engines.spawn(interactive));
|
|
1011
|
+
this.engine = engine;
|
|
1012
|
+
let settled = new Promise((resolve, reject) => {
|
|
1013
|
+
this.started = resolve, this.failed = reject;
|
|
1014
|
+
}), booted = pooled ? Promise.resolve() : this.awaitReady(engine);
|
|
1015
|
+
engine.on_crash((message) => this.fail({ source: "crash", message }));
|
|
1016
|
+
let unstaged = warm === null ? this.chunks : this.chunks.filter((chunk) => !warm.staged.has(chunk.digest)), deferred = engine.may_fetch_wasm === true ? (ref) => referable(ref) && !this.holdsPart(ref.digest) : never, playable = unstaged.filter(linksBeforeStart), eager = playable.filter((ref) => !deferred(ref)), linked = playable.filter(deferred), chunks = this.fetchChunks(eager);
|
|
1017
|
+
chunks.catch(() => {
|
|
1018
|
+
});
|
|
1019
|
+
let following = unstaged.filter((chunk) => !linksBeforeStart(chunk)), followingBodies = following.map((ref) => deferred(ref) ? null : ref.before_play ? this.fetchChunks([ref]) : chunks.then(() => this.fetchChunks([ref])));
|
|
1020
|
+
for (let body of followingBodies) body?.catch(() => {
|
|
1021
|
+
});
|
|
1022
|
+
if (await Promise.race([booted, settled]), this.engine !== engine) return settled;
|
|
1023
|
+
engine.on_message((bytes) => this.fromGuest(bytes)), this.lazyChunks.attach({ deliver: (digest, body) => this.sendChunk(engine, digest, body), send: (bytes, length) => engine.send(bytes, length) }), this.boot(engine);
|
|
1024
|
+
try {
|
|
1025
|
+
let bodies = await Promise.race([chunks, settled.then(() => [])]);
|
|
1026
|
+
if (this.engine !== engine) return settled;
|
|
1027
|
+
for (let i = 0; i < bodies.length; i++) this.sendChunk(engine, eager[i].digest, bodies[i]);
|
|
1028
|
+
for (let ref of linked) await this.deliver(engine, ref);
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
return this.engine !== engine || this.fail({ source: "package", message: error instanceof Error ? error.message : String(error) }), settled;
|
|
1031
|
+
}
|
|
1032
|
+
return engine.send(this.writer.bytes, this.writer.tag(MessageTag.start)), this.clips?.attach(engine.clips ?? null), this.openReplay(engine), this.armWatchdog(), this.streamChunks(engine, following, followingBodies).then(() => this.keepRuntimes(engine, linked)), settled;
|
|
1033
|
+
}
|
|
1034
|
+
holdsPart(digest) {
|
|
1035
|
+
return this.parts !== null && this.options.part_store?.has(digest) === true;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Copies the runtime wasm the guest fetched itself into the shared part store once the start-time
|
|
1039
|
+
* chunks are in, so the next game on this device reads it from the store instead of the network.
|
|
1040
|
+
* Skipped on a metered or data-saver link, where the copy would cost the player a second download.
|
|
1041
|
+
*/
|
|
1042
|
+
async keepRuntimes(engine, refs) {
|
|
1043
|
+
let hint = this.networkHint;
|
|
1044
|
+
if (!(this.parts === null || hint !== null && (hint.metered || hint.saver)))
|
|
1045
|
+
for (let ref of refs) {
|
|
1046
|
+
if (this.engine !== engine) return;
|
|
1047
|
+
if (!(!referable(ref) || this.holdsPart(ref.digest)))
|
|
1048
|
+
try {
|
|
1049
|
+
await this.fetchChunks([ref]);
|
|
1050
|
+
} catch {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
async deliver(engine, ref) {
|
|
1056
|
+
if (engine.fetches_wasm === true && referable(ref) && !this.holdsPart(ref.digest)) {
|
|
1057
|
+
let message = chunkRefMessage(MessageTag.chunk_ref, ref.digest, ref.payload_digest);
|
|
1058
|
+
engine.send(message, message.length);
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
let [bytes] = await this.fetchChunks([ref]);
|
|
1062
|
+
this.engine === engine && this.sendChunk(engine, ref.digest, bytes);
|
|
1063
|
+
}
|
|
1064
|
+
async supply(engine, digest) {
|
|
1065
|
+
let ref = this.chunks.find((chunk) => chunk.digest === digest);
|
|
1066
|
+
if (ref !== void 0) {
|
|
1067
|
+
this.supplying++;
|
|
1068
|
+
try {
|
|
1069
|
+
let [bytes] = await this.fetchChunks([ref]);
|
|
1070
|
+
this.engine === engine && this.sendChunk(engine, digest, bytes);
|
|
1071
|
+
} catch (error) {
|
|
1072
|
+
if (this.engine !== engine) return;
|
|
1073
|
+
this.fail({ source: "package", message: error instanceof Error ? error.message : String(error) });
|
|
1074
|
+
} finally {
|
|
1075
|
+
this.supplying--;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
async stepWhenSettled(engine, settled) {
|
|
1080
|
+
for (; this.engine === engine && (this.supplying > 0 || this.lazyChunks.pending > 0); ) await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1081
|
+
this.engine === engine && (settled(), this.stepMessage[0] = MessageTag.frame_step, engine.send(this.stepMessage, TAG_BYTES));
|
|
1082
|
+
}
|
|
1083
|
+
async streamChunks(engine, refs, bodies) {
|
|
1084
|
+
for (let i = 0; i < refs.length; i++)
|
|
1085
|
+
try {
|
|
1086
|
+
let body = bodies[i];
|
|
1087
|
+
if (body === null) {
|
|
1088
|
+
await this.deliver(engine, refs[i]);
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
let [bytes] = await body;
|
|
1092
|
+
if (this.engine !== engine) return;
|
|
1093
|
+
this.sendChunk(engine, refs[i].digest, bytes);
|
|
1094
|
+
} catch (error) {
|
|
1095
|
+
if (this.engine !== engine) return;
|
|
1096
|
+
this.fail({ source: "package", message: error instanceof Error ? error.message : String(error) });
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
awaitReady(engine) {
|
|
1101
|
+
return new Promise((resolve) => {
|
|
1102
|
+
let timer = setTimeout(() => this.fail({ source: "watchdog", message: "the guest engine did not start in time" }), this.limits.boot_ms);
|
|
1103
|
+
engine.on_message((bytes) => {
|
|
1104
|
+
bytes[0] === MessageTag.ready && (clearTimeout(timer), resolve());
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
boot(engine) {
|
|
1109
|
+
let heap = this.engineHeap(), boot = {
|
|
1110
|
+
program: this.options.hello.program,
|
|
1111
|
+
locale: this.options.locale,
|
|
1112
|
+
clock_offset_ms: this.options.hello.server_time_ms - this.now(),
|
|
1113
|
+
deadline_ms: null,
|
|
1114
|
+
chunk_requests: CHUNK_REQUESTS_VERSION,
|
|
1115
|
+
..."bytes" in heap ? { engine_heap_bytes: heap.bytes } : {},
|
|
1116
|
+
...this.networkHint === null ? {} : { network: this.networkHint }
|
|
1117
|
+
};
|
|
1118
|
+
engine.send(this.writer.bytes, this.writer.json(MessageTag.boot, boot)), this.inspectorShown && this.sendInspector(engine), this.meterRequest.on && engine.send(this.writer.bytes, this.writer.json(MessageTag.meters, this.meterRequest)), this.studioIn !== null && (this.studioIn.reset(), this.studioOut.post({ topic: STUDIO_GRANT_TOPIC }));
|
|
1119
|
+
}
|
|
1120
|
+
get studio() {
|
|
1121
|
+
return this.studioIn !== null;
|
|
1122
|
+
}
|
|
1123
|
+
sendStudio(message) {
|
|
1124
|
+
if (this.studioIn === null) throw new Error("this host was not opened as a studio viewer");
|
|
1125
|
+
return this.engine === null || this.phase === "disposed" ? false : (this.studioOut.post(message), true);
|
|
1126
|
+
}
|
|
1127
|
+
studioReport(bytes) {
|
|
1128
|
+
let assembler = this.studioIn, deliver = this.options.on_studio;
|
|
1129
|
+
if (assembler === null || deliver === void 0) return;
|
|
1130
|
+
let message;
|
|
1131
|
+
try {
|
|
1132
|
+
message = assembler.accept(bytes);
|
|
1133
|
+
} catch (error) {
|
|
1134
|
+
this.fail({ source: "guest", phase: "run", message: error instanceof Error ? error.message : String(error), stack: null });
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
message !== null && deliver(message);
|
|
1138
|
+
}
|
|
1139
|
+
get inspector() {
|
|
1140
|
+
return this.inspectorShown;
|
|
1141
|
+
}
|
|
1142
|
+
get meters() {
|
|
1143
|
+
return this.meterRequest;
|
|
1144
|
+
}
|
|
1145
|
+
setMeters(request) {
|
|
1146
|
+
this.meterRequest = request;
|
|
1147
|
+
let engine = this.engine;
|
|
1148
|
+
engine === null || this.phase === "disposed" || engine.send(this.writer.bytes, this.writer.json(MessageTag.meters, request));
|
|
1149
|
+
}
|
|
1150
|
+
setInspector(shown) {
|
|
1151
|
+
this.inspectorShown = shown;
|
|
1152
|
+
let engine = this.engine;
|
|
1153
|
+
engine === null || this.phase === "disposed" || this.sendInspector(engine);
|
|
1154
|
+
}
|
|
1155
|
+
sendInspector(engine) {
|
|
1156
|
+
this.inspectorMessage[TAG_BYTES] = this.inspectorShown ? INSPECTOR_SHOWN : INSPECTOR_HIDDEN, engine.send(this.inspectorMessage, INSPECTOR_BYTES);
|
|
1157
|
+
}
|
|
1158
|
+
get network() {
|
|
1159
|
+
return this.networkHint;
|
|
1160
|
+
}
|
|
1161
|
+
setNetwork(hint) {
|
|
1162
|
+
this.networkHint = hint;
|
|
1163
|
+
let engine = this.engine;
|
|
1164
|
+
engine === null || this.phase === "disposed" || engine.send(this.networkMessage, writeNetworkHint(this.networkMessage, MessageTag.network, hint));
|
|
1165
|
+
}
|
|
1166
|
+
fetchChunks(refs) {
|
|
1167
|
+
return fetchVerified(this.source, refs.map((ref) => ref.digest));
|
|
1168
|
+
}
|
|
1169
|
+
sendChunk(engine, digest, body) {
|
|
1170
|
+
let message = chunkMessage(MessageTag.chunk, digest, body);
|
|
1171
|
+
engine.send(message, message.length);
|
|
1172
|
+
}
|
|
1173
|
+
armWatchdog() {
|
|
1174
|
+
this.disarmWatchdog(), this.pingSentAt = -1, this.watchdog = setInterval(() => this.tick(), this.limits.ping_ms);
|
|
1175
|
+
}
|
|
1176
|
+
disarmWatchdog() {
|
|
1177
|
+
this.watchdog !== null && clearInterval(this.watchdog), this.watchdog = null;
|
|
1178
|
+
}
|
|
1179
|
+
tick() {
|
|
1180
|
+
let engine = this.engine;
|
|
1181
|
+
if (engine === null) return;
|
|
1182
|
+
let now = this.now();
|
|
1183
|
+
if (this.pingSentAt >= 0) {
|
|
1184
|
+
now - this.pingSentAt > this.limits.cpu_slice_ms && this.fail({ source: "watchdog", message: `the guest ran longer than ${this.limits.cpu_slice_ms} ms without yielding` });
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
this.pingSequence = this.pingSequence + 1 >>> 0, this.pingView.setUint32(1, this.pingSequence, true), this.pingSentAt = now, engine.send(this.ping, PING_BYTES);
|
|
1188
|
+
}
|
|
1189
|
+
pong(bytes) {
|
|
1190
|
+
let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1191
|
+
if (view.getUint32(1, true) !== this.pingSequence) return;
|
|
1192
|
+
this.pingSentAt = -1;
|
|
1193
|
+
let heap = view.getFloat64(5, true);
|
|
1194
|
+
heap > this.limits.memory_bytes && this.fail({ source: "memory", message: `the guest heap reached ${heap} bytes, over its ${this.limits.memory_bytes} byte cap` });
|
|
1195
|
+
}
|
|
1196
|
+
fromGuest(bytes) {
|
|
1197
|
+
if (bytes.length > BRIDGE_LIMITS.max_message_bytes) {
|
|
1198
|
+
this.fail({ source: "guest", phase: "run", message: "the guest sent an oversized message", stack: null });
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
let tag = bytes[0];
|
|
1202
|
+
if (RELAYED_FROM_GUEST.has(tag)) {
|
|
1203
|
+
if (this.mediator?.fromGuest(bytes) === true) return;
|
|
1204
|
+
this.options.transport.send(bytes, bytes.length);
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
switch (tag) {
|
|
1208
|
+
case MessageTag.pong:
|
|
1209
|
+
this.pong(bytes);
|
|
1210
|
+
return;
|
|
1211
|
+
case MessageTag.render:
|
|
1212
|
+
if (bytes.length > BRIDGE_LIMITS.max_render_bytes) {
|
|
1213
|
+
this.fail({ source: "guest", phase: "render", message: "a tree update exceeded the render budget", stack: null });
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
this.tree.apply(readJson(bytes));
|
|
1217
|
+
return;
|
|
1218
|
+
case MessageTag.ui_command:
|
|
1219
|
+
this.command(readJson(bytes));
|
|
1220
|
+
return;
|
|
1221
|
+
case MessageTag.fault:
|
|
1222
|
+
this.fail({ source: "guest", ...readJson(bytes) });
|
|
1223
|
+
return;
|
|
1224
|
+
case MessageTag.hot_done:
|
|
1225
|
+
this.finishHot(readJson(bytes));
|
|
1226
|
+
return;
|
|
1227
|
+
case MessageTag.meter_report:
|
|
1228
|
+
this.meterRequest.on && this.options.on_meters?.(readJson(bytes));
|
|
1229
|
+
return;
|
|
1230
|
+
case MessageTag.studio_report:
|
|
1231
|
+
this.studioReport(bytes);
|
|
1232
|
+
return;
|
|
1233
|
+
case MessageTag.started:
|
|
1234
|
+
this.phase = "running", this.started?.(), this.started = null;
|
|
1235
|
+
return;
|
|
1236
|
+
case MessageTag.disposed:
|
|
1237
|
+
this.teardown("disposed");
|
|
1238
|
+
return;
|
|
1239
|
+
case MessageTag.chunk_request: {
|
|
1240
|
+
let engine = this.engine;
|
|
1241
|
+
if (engine === null) return;
|
|
1242
|
+
let lazy = [];
|
|
1243
|
+
forEachChunkEntry(bytes, CHUNK_REQUEST_ENTRY_BYTES, (digest, priority) => {
|
|
1244
|
+
this.chunks.some((chunk) => chunk.digest === digest) ? this.supply(engine, digest) : lazy.push([digest, priority]);
|
|
1245
|
+
}), lazy.length > 0 && this.lazyChunks.requestMany(lazy);
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
case MessageTag.chunk_release:
|
|
1249
|
+
this.lazyChunks.release(bytes), this.parts !== null && forEachChunkEntry(bytes, CHUNK_RELEASE_ENTRY_BYTES, (digest) => this.parts?.release(digest));
|
|
1250
|
+
return;
|
|
1251
|
+
case MessageTag.milestone: {
|
|
1252
|
+
let name = MILESTONE_BY_CODE[bytes[TAG_BYTES]] ?? null;
|
|
1253
|
+
if (name === FIRST_FRAME_MILESTONE) for (let digest of this.afterFirstFrame) this.lazyChunks.requestOne(digest, ChunkPriority.soon);
|
|
1254
|
+
name !== null && this.options.on_milestone?.(name, this.now());
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
case MessageTag.session_complete: {
|
|
1258
|
+
let completion = readSessionComplete(bytes);
|
|
1259
|
+
completion !== null && this.options.on_complete?.(completion, this.now());
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
case MessageTag.frame_mark: {
|
|
1263
|
+
let engine = this.engine, marked = this.options.on_frame_mark, mark = readFrameMark(bytes);
|
|
1264
|
+
if (engine === null || marked === void 0 || mark === null) return;
|
|
1265
|
+
this.stepWhenSettled(engine, () => marked(mark));
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
fromSession(bytes) {
|
|
1271
|
+
let engine = this.engine;
|
|
1272
|
+
this.mediator?.fromSession(bytes) !== true && (engine === null || !RELAYED_FROM_SESSION.has(bytes[0]) || engine.send(bytes, bytes.length));
|
|
1273
|
+
}
|
|
1274
|
+
openReplay(engine) {
|
|
1275
|
+
let opened = this.options.replay ?? null;
|
|
1276
|
+
if (opened === null) return;
|
|
1277
|
+
let flags = replayFlags(opened.bytes);
|
|
1278
|
+
if (flags === null) return;
|
|
1279
|
+
let mode = opened.mode === "play" && flags.play_from_here ? "play" : "watch", message = replayMessage(opened.bytes, mode);
|
|
1280
|
+
engine.send(message, message.length);
|
|
1281
|
+
}
|
|
1282
|
+
get clipsEnabled() {
|
|
1283
|
+
return this.clips !== null;
|
|
1284
|
+
}
|
|
1285
|
+
/** Saves the host's rolling window (the last 15 s by default) and uploads it, or says why it could not. */
|
|
1286
|
+
saveClip(keep_ms) {
|
|
1287
|
+
let clips = this.clips;
|
|
1288
|
+
return clips === null ? Promise.resolve({ error: "unavailable" }) : clips.keep(keep_ms ?? clips.arm.window_ms);
|
|
1289
|
+
}
|
|
1290
|
+
/** Asks the player, in host chrome, whether clips may include the camera while it is on. */
|
|
1291
|
+
askClipCamera() {
|
|
1292
|
+
return this.clips?.askCamera() ?? Promise.resolve(false);
|
|
1293
|
+
}
|
|
1294
|
+
/** Posts a saved clip as a Flick through the session, as the game's own `social.post` would. */
|
|
1295
|
+
async postClip(media, score = null) {
|
|
1296
|
+
let mediator = this.mediator;
|
|
1297
|
+
if (mediator === null) return null;
|
|
1298
|
+
let envelope = await mediator.hostCall("social.post", { kind: "clip", media, score });
|
|
1299
|
+
return envelope.outcome.status === "ok" ? envelope.outcome.response.result : null;
|
|
1300
|
+
}
|
|
1301
|
+
async shareClip(media) {
|
|
1302
|
+
let mediator = this.mediator;
|
|
1303
|
+
if (mediator === null) return null;
|
|
1304
|
+
let envelope = await mediator.hostCall("share.open", { target: { kind: "clip", media }, audience_hint: null });
|
|
1305
|
+
return envelope.outcome.status === "ok" ? envelope.outcome.response.result : null;
|
|
1306
|
+
}
|
|
1307
|
+
async command(message) {
|
|
1308
|
+
let command = message.command, clips = this.clips, value = clips !== null && isClipCommand(command) ? await clips.command(command) : await this.options.on_command?.(command);
|
|
1309
|
+
if (message.id === 0 || this.engine === null) return;
|
|
1310
|
+
let reply = { id: message.id, value: value ?? null };
|
|
1311
|
+
this.engine.send(this.writer.bytes, this.writer.json(MessageTag.ui_reply, reply));
|
|
1312
|
+
}
|
|
1313
|
+
grantConsents(granted) {
|
|
1314
|
+
let consent = { granted: [...new Set(granted)] };
|
|
1315
|
+
this.options.transport.send(this.writer.bytes, this.writer.json(MessageTag.consent, consent));
|
|
1316
|
+
}
|
|
1317
|
+
evicted(eviction) {
|
|
1318
|
+
if (this.engine === null) return;
|
|
1319
|
+
let envelope = {
|
|
1320
|
+
contract_version: 1,
|
|
1321
|
+
subscription_id: PARTS_SUBSCRIPTION,
|
|
1322
|
+
sequence: ++this.partsSequence,
|
|
1323
|
+
emitted_at: this.now(),
|
|
1324
|
+
event: { family: "parts", event: { kind: "evicted", zone: eviction.zone, parts: eviction.parts, bytes: eviction.bytes, reason: eviction.reason, kept: eviction.kept } }
|
|
1325
|
+
};
|
|
1326
|
+
this.engine.send(this.writer.bytes, this.writer.json(MessageTag.event, envelope));
|
|
1327
|
+
}
|
|
1328
|
+
dispatch(event) {
|
|
1329
|
+
this.engine?.send(this.writer.bytes, this.writer.json(MessageTag.ui_event, event));
|
|
1330
|
+
}
|
|
1331
|
+
lifecycle(name) {
|
|
1332
|
+
this.engine !== null && (this.lifecycleMessage[1] = LifecycleCode[name], this.engine.send(this.lifecycleMessage, LIFECYCLE_BYTES));
|
|
1333
|
+
}
|
|
1334
|
+
dispose() {
|
|
1335
|
+
if (this.phase === "disposed") return;
|
|
1336
|
+
if (this.engine === null) {
|
|
1337
|
+
this.teardown("disposed");
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
this.lifecycle("dispose");
|
|
1341
|
+
let engine = this.engine;
|
|
1342
|
+
setTimeout(() => {
|
|
1343
|
+
this.engine === engine && this.teardown("disposed");
|
|
1344
|
+
}, this.limits.ping_ms);
|
|
1345
|
+
}
|
|
1346
|
+
async hotSwap(chunks) {
|
|
1347
|
+
let engine = this.engine;
|
|
1348
|
+
if (engine === null || this.phase !== "running") return { swapped: false, reason: "the Interactive is not running" };
|
|
1349
|
+
if (this.hotDone !== null) return { swapped: false, reason: "a swap is already in progress" };
|
|
1350
|
+
let unseen = this.hosted(chunks).filter((chunk) => !this.known.has(chunk.digest)), fresh = unseen.filter((chunk) => swappable(chunk));
|
|
1351
|
+
if (fresh.length !== unseen.length) return { swapped: false, reason: "more than the code and assets changed" };
|
|
1352
|
+
if (fresh.length === 0) return { swapped: false, reason: "no code changed" };
|
|
1353
|
+
let bodies;
|
|
1354
|
+
try {
|
|
1355
|
+
bodies = await this.fetchChunks(fresh);
|
|
1356
|
+
} catch (error) {
|
|
1357
|
+
return { swapped: false, reason: error instanceof Error ? error.message : String(error) };
|
|
1358
|
+
}
|
|
1359
|
+
if (this.engine !== engine) return { swapped: false, reason: "the Interactive stopped" };
|
|
1360
|
+
for (let i = 0; i < fresh.length; i++)
|
|
1361
|
+
this.sendChunk(engine, fresh[i].digest, bodies[i]), this.chunks.push(fresh[i]), this.known.add(fresh[i].digest);
|
|
1362
|
+
let result = new Promise((resolve) => {
|
|
1363
|
+
this.hotDone = resolve;
|
|
1364
|
+
}), request = { chunks: fresh.map((chunk) => chunk.digest) };
|
|
1365
|
+
return engine.send(this.writer.bytes, this.writer.json(MessageTag.hot, request)), result;
|
|
1366
|
+
}
|
|
1367
|
+
finishHot(result) {
|
|
1368
|
+
let done = this.hotDone;
|
|
1369
|
+
this.hotDone = null, done?.(result);
|
|
1370
|
+
}
|
|
1371
|
+
async restart() {
|
|
1372
|
+
let now = this.now();
|
|
1373
|
+
if (this.restarts = this.restarts.filter((at) => now - at < this.limits.restart_window_ms), this.restarts.length >= this.limits.restarts_per_window)
|
|
1374
|
+
throw new Error("the Interactive crashed too often to restart");
|
|
1375
|
+
return this.restarts.push(now), this.tree.reset(), this.phase = "crashed", this.start();
|
|
1376
|
+
}
|
|
1377
|
+
fail(fault) {
|
|
1378
|
+
if (this.phase !== "disposed") {
|
|
1379
|
+
if (this.options.on_fault?.(fault), fault.source === "session")
|
|
1380
|
+
this.teardown("disposed");
|
|
1381
|
+
else {
|
|
1382
|
+
if (fault.source === "guest" && fault.phase === "run")
|
|
1383
|
+
return;
|
|
1384
|
+
this.teardown("crashed");
|
|
1385
|
+
}
|
|
1386
|
+
this.failed?.(new HostFaultError(fault)), this.failed = null, this.started = null;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
teardown(phase) {
|
|
1390
|
+
this.finishHot({ swapped: false, reason: "the Interactive stopped" }), this.lazyChunks.attach(null), this.parts?.close(), this.clips?.detach(), this.disarmWatchdog(), this.engine?.terminate(), this.engine = null, this.phase = phase, phase === "disposed" && (this.unwatchNetwork?.(), this.unwatchNetwork = null, this.options.runtimes?.warm(this.chunks), this.mediator?.stop(), this.options.chrome?.controller.dismissAll(), this.options.transport.close());
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
export { ALTERNATIVE_RUNTIMES, CLIP_CAMERA, DEFAULT_HOST_LIMITS, DEFAULT_HOST_TIER, DEFAULT_LAZY_BUDGET_BYTES, DEFAULT_LAZY_CONCURRENCY, ENGINE_GROUP_PREFIX, GPU_REQUIREMENT_NAMES, GuestPool, HOST_PAGE_ISOLATION_HEADERS, HostClips, HostFaultError, HostMediator, ISOLATED_THREAD_GROUP, JOINED_PARTS_PARAM, JOINED_PART_SEPARATOR, JOINED_PREFIX, LazyChunkServer, MAX_JOINED_PARTS, REPLAY_MEDIA_TYPE, RUNTIME_PREFIX, RUNTIME_SUFFIX, SHELL_PREFIX, SINGLE_THREAD_GROUP, TIER_GROUP_PREFIX, TreeStore, WASM_PREFIX, WASM_SUFFIX, WebHost, ZoneSpans, chunksForHost, deviceGpuLimits, fetchTwin, forgetHostWebGpu, guestOrigin, hostIsolated, hostThreads, hostWebGpu, httpChunks, interactiveLabel, isDigestHex, linksBeforeStart, manifestGpuRequirements, openSession, parseContentOrigin, probeHostWebGpu, rangedChunks, referable, runtimePath, servesContent, sessionUrl, sha256Hex, shellPath, sri, swapInPlace, swappable, unmetGpuRequirement, workerEngines };
|