@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,2191 @@
|
|
|
1
|
+
import { tokens, UiTheme, mergeThemes, varDefault, UiVar, UiSlot } from './chunk-WLMINRC4.mjs';
|
|
2
|
+
import { DIRECTION, JUSTIFY, ALIGN, TEXT_ALIGN, VERTICAL, SHAPE, AXES, TEXT_WRAP_STYLE, UiProp, UiUnit, UI_MAX_EXCLUSIONS, UiFlag, UiEventKind, UiStyleError, parseColor, StyleCache, writeStyle, UiNumberFormat, UiVectorData, UiExclusionShape, UiTransition, UiEasing, UiRole, UiTrait, UiAction, PatchWriter, UiTextOption, UiKind, UiAnchor, readEvent, eventStride, GRADIENT_KIND } from './chunk-RFVRPYR2.mjs';
|
|
3
|
+
import { suggest, didYouMean } from './chunk-F6XRYEM3.mjs';
|
|
4
|
+
import { TextLayout, defaultLayoutStyle, breakDictionaries } from './chunk-GYLP6UG4.mjs';
|
|
5
|
+
import { fontTable } from './chunk-XJA2NGTI.mjs';
|
|
6
|
+
|
|
7
|
+
// src/interactives/game-ui/styling/keys.ts
|
|
8
|
+
var ValueType = {
|
|
9
|
+
length: 0,
|
|
10
|
+
float: 1,
|
|
11
|
+
int: 2,
|
|
12
|
+
color: 3,
|
|
13
|
+
enumeration: 4,
|
|
14
|
+
bool: 5,
|
|
15
|
+
edges: 6,
|
|
16
|
+
pair: 7,
|
|
17
|
+
colors: 8,
|
|
18
|
+
quad: 9,
|
|
19
|
+
shadow: 10,
|
|
20
|
+
gradient: 11
|
|
21
|
+
}, GRADIENT_STOPS = 4, SHADOW_WORDS = 5, GRADIENT_WORDS = 1 + (4) * 2 + 4, GRADIENT_FIRST_FLOAT = 1 + (4), VALUE_WORDS = [1, 1, 1, 1, 1, 1, 4, 2, 4, 4, (5), GRADIENT_WORDS];
|
|
22
|
+
function isFloatWord(type, word) {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case ValueType.length:
|
|
25
|
+
case ValueType.float:
|
|
26
|
+
case ValueType.edges:
|
|
27
|
+
case ValueType.pair:
|
|
28
|
+
case ValueType.quad:
|
|
29
|
+
return true;
|
|
30
|
+
case ValueType.shadow:
|
|
31
|
+
return word > 0;
|
|
32
|
+
case ValueType.gradient:
|
|
33
|
+
return word >= GRADIENT_FIRST_FLOAT;
|
|
34
|
+
default:
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function isColorWord(type, word) {
|
|
39
|
+
return type === ValueType.color || type === ValueType.colors ? true : type === ValueType.shadow ? word === 0 : type === ValueType.gradient ? word > 0 && word < GRADIENT_FIRST_FLOAT : false;
|
|
40
|
+
}
|
|
41
|
+
var Tier = { shorthandOfShorthands: 1e3, shorthandOfLonghands: 2e3, plain: 3e3, longhand: 4e3 }, DISPLAY = { flex: 0, none: 1 }, POSITION = { relative: 0, absolute: 1 }, POINTER = { auto: 0, none: 1 }, T = ValueType, S1 = Tier.shorthandOfShorthands, S2 = Tier.shorthandOfLonghands, P = Tier.plain, L = Tier.longhand, SPECS = [
|
|
42
|
+
{ name: "width", type: T.length, tier: P },
|
|
43
|
+
{ name: "height", type: T.length, tier: P },
|
|
44
|
+
{ name: "minWidth", type: T.length, tier: P },
|
|
45
|
+
{ name: "minHeight", type: T.length, tier: P },
|
|
46
|
+
{ name: "maxWidth", type: T.length, tier: P },
|
|
47
|
+
{ name: "maxHeight", type: T.length, tier: P },
|
|
48
|
+
{ name: "basis", type: T.length, tier: P },
|
|
49
|
+
{ name: "inset", type: T.length, tier: S1 },
|
|
50
|
+
{ name: "insetInline", type: T.length, tier: S2 },
|
|
51
|
+
{ name: "insetBlock", type: T.length, tier: S2 },
|
|
52
|
+
{ name: "top", type: T.length, tier: L },
|
|
53
|
+
{ name: "right", type: T.length, tier: L },
|
|
54
|
+
{ name: "bottom", type: T.length, tier: L },
|
|
55
|
+
{ name: "left", type: T.length, tier: L },
|
|
56
|
+
{ name: "padding", type: T.edges, tier: S1 },
|
|
57
|
+
{ name: "paddingInline", type: T.float, tier: S2 },
|
|
58
|
+
{ name: "paddingBlock", type: T.float, tier: S2 },
|
|
59
|
+
{ name: "paddingTop", type: T.float, tier: L },
|
|
60
|
+
{ name: "paddingRight", type: T.float, tier: L },
|
|
61
|
+
{ name: "paddingBottom", type: T.float, tier: L },
|
|
62
|
+
{ name: "paddingLeft", type: T.float, tier: L },
|
|
63
|
+
{ name: "margin", type: T.edges, tier: S1 },
|
|
64
|
+
{ name: "marginInline", type: T.float, tier: S2 },
|
|
65
|
+
{ name: "marginBlock", type: T.float, tier: S2 },
|
|
66
|
+
{ name: "marginTop", type: T.float, tier: L },
|
|
67
|
+
{ name: "marginRight", type: T.float, tier: L },
|
|
68
|
+
{ name: "marginBottom", type: T.float, tier: L },
|
|
69
|
+
{ name: "marginLeft", type: T.float, tier: L },
|
|
70
|
+
{ name: "borderWidth", type: T.edges, tier: S1 },
|
|
71
|
+
{ name: "borderInlineWidth", type: T.float, tier: S2 },
|
|
72
|
+
{ name: "borderBlockWidth", type: T.float, tier: S2 },
|
|
73
|
+
{ name: "borderTopWidth", type: T.float, tier: L },
|
|
74
|
+
{ name: "borderRightWidth", type: T.float, tier: L },
|
|
75
|
+
{ name: "borderBottomWidth", type: T.float, tier: L },
|
|
76
|
+
{ name: "borderLeftWidth", type: T.float, tier: L },
|
|
77
|
+
{ name: "gap", type: T.pair, tier: S2 },
|
|
78
|
+
{ name: "columnGap", type: T.float, tier: L },
|
|
79
|
+
{ name: "rowGap", type: T.float, tier: L },
|
|
80
|
+
{ name: "grow", type: T.float, tier: P },
|
|
81
|
+
{ name: "shrink", type: T.float, tier: P },
|
|
82
|
+
{ name: "aspect", type: T.float, tier: P },
|
|
83
|
+
{ name: "direction", type: T.enumeration, tier: P, table: DIRECTION },
|
|
84
|
+
{ name: "justify", type: T.enumeration, tier: P, table: JUSTIFY },
|
|
85
|
+
{ name: "alignItems", type: T.enumeration, tier: P, table: ALIGN },
|
|
86
|
+
{ name: "alignSelf", type: T.enumeration, tier: P, table: ALIGN },
|
|
87
|
+
{ name: "alignContent", type: T.enumeration, tier: P, table: ALIGN },
|
|
88
|
+
{ name: "position", type: T.enumeration, tier: P, table: POSITION },
|
|
89
|
+
{ name: "wrap", type: T.bool, tier: P },
|
|
90
|
+
{ name: "display", type: T.enumeration, tier: P, table: DISPLAY },
|
|
91
|
+
{ name: "fill", type: T.color, tier: P },
|
|
92
|
+
{ name: "borderColor", type: T.colors, tier: S1 },
|
|
93
|
+
{ name: "borderInlineColor", type: T.color, tier: S2 },
|
|
94
|
+
{ name: "borderBlockColor", type: T.color, tier: S2 },
|
|
95
|
+
{ name: "borderTopColor", type: T.color, tier: L },
|
|
96
|
+
{ name: "borderRightColor", type: T.color, tier: L },
|
|
97
|
+
{ name: "borderBottomColor", type: T.color, tier: L },
|
|
98
|
+
{ name: "borderLeftColor", type: T.color, tier: L },
|
|
99
|
+
{ name: "radius", type: T.edges, tier: S2 },
|
|
100
|
+
{ name: "radiusTopLeft", type: T.float, tier: L },
|
|
101
|
+
{ name: "radiusTopRight", type: T.float, tier: L },
|
|
102
|
+
{ name: "radiusBottomRight", type: T.float, tier: L },
|
|
103
|
+
{ name: "radiusBottomLeft", type: T.float, tier: L },
|
|
104
|
+
{ name: "opacity", type: T.float, tier: P },
|
|
105
|
+
{ name: "translate", type: T.pair, tier: S2 },
|
|
106
|
+
{ name: "translateX", type: T.float, tier: L },
|
|
107
|
+
{ name: "translateY", type: T.float, tier: L },
|
|
108
|
+
{ name: "scale", type: T.pair, tier: S2 },
|
|
109
|
+
{ name: "scaleX", type: T.float, tier: L },
|
|
110
|
+
{ name: "scaleY", type: T.float, tier: L },
|
|
111
|
+
{ name: "rotate", type: T.float, tier: P },
|
|
112
|
+
{ name: "origin", type: T.pair, tier: P },
|
|
113
|
+
{ name: "zIndex", type: T.int, tier: P },
|
|
114
|
+
{ name: "hidden", type: T.bool, tier: P },
|
|
115
|
+
{ name: "clip", type: T.bool, tier: P },
|
|
116
|
+
{ name: "pointerEvents", type: T.enumeration, tier: P, table: POINTER },
|
|
117
|
+
{ name: "layer", type: T.bool, tier: P },
|
|
118
|
+
{ name: "shadow", type: T.shadow, tier: P },
|
|
119
|
+
{ name: "gradient", type: T.gradient, tier: P },
|
|
120
|
+
{ name: "fontFamily", type: T.int, tier: P },
|
|
121
|
+
{ name: "fontWeight", type: T.int, tier: P },
|
|
122
|
+
{ name: "fontSize", type: T.float, tier: P },
|
|
123
|
+
{ name: "lineHeight", type: T.float, tier: P },
|
|
124
|
+
{ name: "letterSpacing", type: T.float, tier: P },
|
|
125
|
+
{ name: "textAlign", type: T.enumeration, tier: P, table: TEXT_ALIGN },
|
|
126
|
+
{ name: "textColor", type: T.color, tier: P },
|
|
127
|
+
{ name: "textWrap", type: T.bool, tier: P },
|
|
128
|
+
{ name: "verticalAlign", type: T.enumeration, tier: P, table: VERTICAL },
|
|
129
|
+
{ name: "placeholderColor", type: T.color, tier: P },
|
|
130
|
+
{ name: "tint", type: T.color, tier: P },
|
|
131
|
+
{ name: "uv", type: T.quad, tier: P },
|
|
132
|
+
{ name: "nineSlice", type: T.edges, tier: P },
|
|
133
|
+
{ name: "nineSliceUv", type: T.edges, tier: P },
|
|
134
|
+
{ name: "shape", type: T.enumeration, tier: P, table: SHAPE },
|
|
135
|
+
{ name: "stroke", type: T.color, tier: P },
|
|
136
|
+
{ name: "strokeWidth", type: T.float, tier: P },
|
|
137
|
+
{ name: "scrollAxes", type: T.enumeration, tier: P, table: AXES },
|
|
138
|
+
{ name: "textWrapStyle", type: T.enumeration, tier: P, table: TEXT_WRAP_STYLE }
|
|
139
|
+
], KEY_COUNT = SPECS.length, KEY_NAMES = SPECS.map((s) => s.name), KEY_TYPES = Uint8Array.from(SPECS, (s) => s.type), KEY_TIERS = Uint16Array.from(SPECS, (s) => s.tier), KEY_TABLES = SPECS.map((s) => s.table ?? null), ALIASES = {
|
|
140
|
+
borderRadius: "radius",
|
|
141
|
+
borderTopLeftRadius: "radiusTopLeft",
|
|
142
|
+
borderTopRightRadius: "radiusTopRight",
|
|
143
|
+
borderBottomRightRadius: "radiusBottomRight",
|
|
144
|
+
borderBottomLeftRadius: "radiusBottomLeft",
|
|
145
|
+
paddingHorizontal: "paddingInline",
|
|
146
|
+
paddingVertical: "paddingBlock",
|
|
147
|
+
marginHorizontal: "marginInline",
|
|
148
|
+
marginVertical: "marginBlock",
|
|
149
|
+
flexGrow: "grow",
|
|
150
|
+
flexShrink: "shrink",
|
|
151
|
+
flexBasis: "basis",
|
|
152
|
+
flexDirection: "direction",
|
|
153
|
+
justifyContent: "justify",
|
|
154
|
+
backgroundColor: "fill",
|
|
155
|
+
color: "textColor",
|
|
156
|
+
aspectRatio: "aspect"
|
|
157
|
+
}, KEY_IDS = /* @__PURE__ */ new Map();
|
|
158
|
+
SPECS.forEach((s, i) => KEY_IDS.set(s.name, i));
|
|
159
|
+
for (let [alias, target] of Object.entries(ALIASES)) KEY_IDS.set(alias, KEY_IDS.get(target));
|
|
160
|
+
function keyId(name) {
|
|
161
|
+
return KEY_IDS.get(name) ?? -1;
|
|
162
|
+
}
|
|
163
|
+
var STYLE_PROPERTY_NAMES = [...KEY_IDS.keys()], Condition = {
|
|
164
|
+
pressed: 1,
|
|
165
|
+
focus: 2,
|
|
166
|
+
disabled: 4,
|
|
167
|
+
landscape: 8,
|
|
168
|
+
portrait: 16,
|
|
169
|
+
safe: 32,
|
|
170
|
+
sm: 64,
|
|
171
|
+
lg: 128
|
|
172
|
+
}, STATE_CONDITIONS = Condition.pressed | Condition.focus | Condition.disabled, CONTEXT_CONDITIONS = Condition.landscape | Condition.portrait | Condition.safe | Condition.sm | Condition.lg, CONDITION_KEYS = {
|
|
173
|
+
":pressed": Condition.pressed,
|
|
174
|
+
":active": Condition.pressed,
|
|
175
|
+
":focus": Condition.focus,
|
|
176
|
+
":disabled": Condition.disabled,
|
|
177
|
+
"@landscape": Condition.landscape,
|
|
178
|
+
"@portrait": Condition.portrait,
|
|
179
|
+
"@safe": Condition.safe,
|
|
180
|
+
"@sm": Condition.sm,
|
|
181
|
+
"@lg": Condition.lg
|
|
182
|
+
}, PSEUDO_ACTIVE = 170, PSEUDO_FOCUS = 150, PSEUDO_DISABLED = 92, AT_MEDIA = 200, CONDITION_BITS = 8, CONDITION_PRIORITY = [(170), (150), (92), (200), (200), (200), (200), (200)];
|
|
183
|
+
function conditionPriority(mask) {
|
|
184
|
+
let total = 0;
|
|
185
|
+
for (let bit = 0; bit < (8); bit++) mask & 1 << bit && (total += CONDITION_PRIORITY[bit]);
|
|
186
|
+
return total;
|
|
187
|
+
}
|
|
188
|
+
var WireEmit = { length: 0, float: 1, word: 2, floats: 3, words: 4, shadow: 5, gradient: 6, flag: 7 }, BLACK = 0, WHITE = 4294967295, PLACEHOLDER = 4294967168, DEFAULT_WEIGHT = 400, DEFAULT_FONT = 16, CENTER = 0.5;
|
|
189
|
+
function length(prop, chain) {
|
|
190
|
+
return { prop, emit: WireEmit.length, components: [chain], defaults: [0, UiUnit.auto] };
|
|
191
|
+
}
|
|
192
|
+
function single(prop, emit, key, fallback) {
|
|
193
|
+
return { prop, emit, components: [[[key, 0]]], defaults: [fallback] };
|
|
194
|
+
}
|
|
195
|
+
function sides(prop, all, inline, block, top, right, bottom, left) {
|
|
196
|
+
return {
|
|
197
|
+
prop,
|
|
198
|
+
emit: WireEmit.floats,
|
|
199
|
+
components: [
|
|
200
|
+
[[all, 0], [block, 0], [top, 0]],
|
|
201
|
+
[[all, 1], [inline, 0], [right, 0]],
|
|
202
|
+
[[all, 2], [block, 0], [bottom, 0]],
|
|
203
|
+
[[all, 3], [inline, 0], [left, 0]]
|
|
204
|
+
],
|
|
205
|
+
defaults: [0, 0, 0, 0]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function pair(prop, all, first, second, fallback) {
|
|
209
|
+
return {
|
|
210
|
+
prop,
|
|
211
|
+
emit: WireEmit.floats,
|
|
212
|
+
components: [first === null ? [[all, 0]] : [[all, 0], [first, 0]], second === null ? [[all, 1]] : [[all, 1], [second, 0]]],
|
|
213
|
+
defaults: [fallback, fallback]
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function whole(prop, emit, key, defaults2) {
|
|
217
|
+
return { prop, emit, components: defaults2.map((_, i) => [[key, i]]), defaults: defaults2 };
|
|
218
|
+
}
|
|
219
|
+
var WIRE_SPECS = [
|
|
220
|
+
length(UiProp.width, [["width", 0]]),
|
|
221
|
+
length(UiProp.height, [["height", 0]]),
|
|
222
|
+
length(UiProp.min_width, [["minWidth", 0]]),
|
|
223
|
+
length(UiProp.min_height, [["minHeight", 0]]),
|
|
224
|
+
length(UiProp.max_width, [["maxWidth", 0]]),
|
|
225
|
+
length(UiProp.max_height, [["maxHeight", 0]]),
|
|
226
|
+
length(UiProp.basis, [["basis", 0]]),
|
|
227
|
+
length(UiProp.inset_top, [["inset", 0], ["insetBlock", 0], ["top", 0]]),
|
|
228
|
+
length(UiProp.inset_right, [["inset", 0], ["insetInline", 0], ["right", 0]]),
|
|
229
|
+
length(UiProp.inset_bottom, [["inset", 0], ["insetBlock", 0], ["bottom", 0]]),
|
|
230
|
+
length(UiProp.inset_left, [["inset", 0], ["insetInline", 0], ["left", 0]]),
|
|
231
|
+
sides(UiProp.padding, "padding", "paddingInline", "paddingBlock", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft"),
|
|
232
|
+
sides(UiProp.margin, "margin", "marginInline", "marginBlock", "marginTop", "marginRight", "marginBottom", "marginLeft"),
|
|
233
|
+
sides(UiProp.border_width, "borderWidth", "borderInlineWidth", "borderBlockWidth", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"),
|
|
234
|
+
pair(UiProp.gap, "gap", "columnGap", "rowGap", 0),
|
|
235
|
+
single(UiProp.grow, WireEmit.float, "grow", 0),
|
|
236
|
+
single(UiProp.shrink, WireEmit.float, "shrink", 1),
|
|
237
|
+
single(UiProp.aspect, WireEmit.float, "aspect", 0),
|
|
238
|
+
single(UiProp.direction, WireEmit.word, "direction", DIRECTION.column),
|
|
239
|
+
single(UiProp.justify, WireEmit.word, "justify", JUSTIFY.start),
|
|
240
|
+
single(UiProp.align_items, WireEmit.word, "alignItems", ALIGN.stretch),
|
|
241
|
+
single(UiProp.align_self, WireEmit.word, "alignSelf", ALIGN.auto),
|
|
242
|
+
single(UiProp.align_content, WireEmit.word, "alignContent", ALIGN.stretch),
|
|
243
|
+
single(UiProp.position, WireEmit.word, "position", POSITION.relative),
|
|
244
|
+
single(UiProp.wrap, WireEmit.word, "wrap", 0),
|
|
245
|
+
single(UiProp.display_none, WireEmit.word, "display", DISPLAY.flex),
|
|
246
|
+
single(UiProp.fill, WireEmit.word, "fill", (0)),
|
|
247
|
+
{
|
|
248
|
+
prop: UiProp.border_color,
|
|
249
|
+
emit: WireEmit.words,
|
|
250
|
+
components: [
|
|
251
|
+
[["borderColor", 0], ["borderBlockColor", 0], ["borderTopColor", 0]],
|
|
252
|
+
[["borderColor", 1], ["borderInlineColor", 0], ["borderRightColor", 0]],
|
|
253
|
+
[["borderColor", 2], ["borderBlockColor", 0], ["borderBottomColor", 0]],
|
|
254
|
+
[["borderColor", 3], ["borderInlineColor", 0], ["borderLeftColor", 0]]
|
|
255
|
+
],
|
|
256
|
+
defaults: [(0), (0), (0), (0)]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
prop: UiProp.radii,
|
|
260
|
+
emit: WireEmit.floats,
|
|
261
|
+
components: [
|
|
262
|
+
[["radius", 0], ["radiusTopLeft", 0]],
|
|
263
|
+
[["radius", 1], ["radiusTopRight", 0]],
|
|
264
|
+
[["radius", 2], ["radiusBottomRight", 0]],
|
|
265
|
+
[["radius", 3], ["radiusBottomLeft", 0]]
|
|
266
|
+
],
|
|
267
|
+
defaults: [0, 0, 0, 0]
|
|
268
|
+
},
|
|
269
|
+
single(UiProp.opacity, WireEmit.float, "opacity", 1),
|
|
270
|
+
pair(UiProp.translate, "translate", "translateX", "translateY", 0),
|
|
271
|
+
pair(UiProp.scale, "scale", "scaleX", "scaleY", 1),
|
|
272
|
+
single(UiProp.rotate, WireEmit.float, "rotate", 0),
|
|
273
|
+
pair(UiProp.origin, "origin", null, null, (0.5)),
|
|
274
|
+
single(UiProp.z_index, WireEmit.word, "zIndex", 0),
|
|
275
|
+
single(UiProp.hidden, WireEmit.word, "hidden", 0),
|
|
276
|
+
single(UiProp.clip, WireEmit.word, "clip", 0),
|
|
277
|
+
single(UiProp.pointer_events_none, WireEmit.word, "pointerEvents", POINTER.auto),
|
|
278
|
+
single(UiProp.flags, WireEmit.flag, "layer", 0),
|
|
279
|
+
whole(UiProp.shadow, WireEmit.shadow, "shadow", [0, 0, 0, 0, 0]),
|
|
280
|
+
whole(UiProp.gradient, WireEmit.gradient, "gradient", new Array(GRADIENT_WORDS).fill(0)),
|
|
281
|
+
single(UiProp.font_family, WireEmit.word, "fontFamily", 0),
|
|
282
|
+
single(UiProp.font_weight, WireEmit.word, "fontWeight", (400)),
|
|
283
|
+
single(UiProp.font_size, WireEmit.float, "fontSize", (16)),
|
|
284
|
+
single(UiProp.line_height, WireEmit.float, "lineHeight", 0),
|
|
285
|
+
single(UiProp.letter_spacing, WireEmit.float, "letterSpacing", 0),
|
|
286
|
+
single(UiProp.text_align, WireEmit.word, "textAlign", TEXT_ALIGN.start),
|
|
287
|
+
single(UiProp.text_color, WireEmit.word, "textColor", (4294967295)),
|
|
288
|
+
single(UiProp.text_wrap, WireEmit.word, "textWrap", 0),
|
|
289
|
+
single(UiProp.vertical_align, WireEmit.word, "verticalAlign", VERTICAL.top),
|
|
290
|
+
single(UiProp.placeholder_color, WireEmit.word, "placeholderColor", (4294967168)),
|
|
291
|
+
single(UiProp.image_tint, WireEmit.word, "tint", (4294967295)),
|
|
292
|
+
whole(UiProp.image_uv, WireEmit.floats, "uv", [0, 0, 1, 1]),
|
|
293
|
+
whole(UiProp.nine_slice, WireEmit.floats, "nineSlice", [0, 0, 0, 0]),
|
|
294
|
+
whole(UiProp.nine_slice_uv, WireEmit.floats, "nineSliceUv", [0, 0, 0, 0]),
|
|
295
|
+
single(UiProp.shape_kind, WireEmit.word, "shape", SHAPE.rect),
|
|
296
|
+
single(UiProp.stroke_color, WireEmit.word, "stroke", (0)),
|
|
297
|
+
single(UiProp.stroke_width, WireEmit.float, "strokeWidth", 0),
|
|
298
|
+
single(UiProp.scroll_axes, WireEmit.word, "scrollAxes", AXES.none),
|
|
299
|
+
single(UiProp.text_wrap_style, WireEmit.word, "textWrapStyle", TEXT_WRAP_STYLE.greedy)
|
|
300
|
+
], WIRE_COUNT = WIRE_SPECS.length, WIRE_PROPS = Uint8Array.from(WIRE_SPECS, (w) => w.prop), WIRE_EMITS = Uint8Array.from(WIRE_SPECS, (w) => w.emit), WIRE_COMPONENT_START = new Uint16Array(WIRE_COUNT), WIRE_COMPONENT_COUNT = new Uint8Array(WIRE_COUNT), WIRE_DEFAULT_UNIT = new Uint8Array(WIRE_COUNT), components = [], defaults = [], chainStart = [], chainCount = [], chainKeys = [], chainWords = [], keyWires = Array.from({ length: KEY_COUNT }, () => []);
|
|
301
|
+
WIRE_SPECS.forEach((wire, w) => {
|
|
302
|
+
WIRE_COMPONENT_START[w] = components.length, WIRE_COMPONENT_COUNT[w] = wire.components.length, WIRE_DEFAULT_UNIT[w] = wire.emit === WireEmit.length ? wire.defaults[1] : 0, wire.components.forEach((chain, c) => {
|
|
303
|
+
components.push(components.length), defaults.push(wire.defaults[c]), chainStart.push(chainKeys.length), chainCount.push(chain.length);
|
|
304
|
+
for (let [name, word] of chain) {
|
|
305
|
+
let id = keyId(name);
|
|
306
|
+
if (id < 0) throw new Error(`wire chain names unknown key ${name}`);
|
|
307
|
+
chainKeys.push(id), chainWords.push(word), keyWires[id].indexOf(w) < 0 && keyWires[id].push(w);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
var descendants = Array.from({ length: KEY_COUNT }, () => /* @__PURE__ */ new Set());
|
|
312
|
+
for (let wire of WIRE_SPECS)
|
|
313
|
+
for (let chain of wire.components)
|
|
314
|
+
for (let i = 0; i < chain.length; i++)
|
|
315
|
+
for (let j = i + 1; j < chain.length; j++) descendants[keyId(chain[i][0])].add(keyId(chain[j][0]));
|
|
316
|
+
var KEY_DESCENDANTS = descendants.map((set) => [...set].sort((a, b) => a - b)), COMPONENT_DEFAULTS = Float64Array.from(defaults), COMPONENT_CHAIN_START = Uint16Array.from(chainStart), COMPONENT_CHAIN_COUNT = Uint8Array.from(chainCount), CHAIN_KEYS = Uint8Array.from(chainKeys), CHAIN_WORDS = Uint8Array.from(chainWords), KEY_WIRES = keyWires.map((list) => Uint8Array.from(list)), MAX_COMPONENTS = GRADIENT_WORDS;
|
|
317
|
+
|
|
318
|
+
// src/interactives/game-ui/styling/compile.ts
|
|
319
|
+
var STYLE_BLOCK_MAGIC = 827937875, STYLE_BLOCK_VERSION = 1, STYLE_BLOCK_HEADER_WORDS = 2, VariantKind = { literal: 0, null: 1, referenced: 2 }, SLOT_REFERENCE = 2147483648, BYTE = 255, COUNT_SHIFT = 8, PAYLOAD_SHIFT = 8, KIND_SHIFT = 16, UNIT_SHIFT = 20, NIBBLE = 15, VERSION_SHIFT = 16, COUNT_MASK = 65535, PERCENT = "%", AUTO = "auto", DEFAULT = "default", UiStyleCompileError = class extends UiStyleError {
|
|
320
|
+
constructor(message, kind, subject, suggestion) {
|
|
321
|
+
super(message);
|
|
322
|
+
this.kind = kind;
|
|
323
|
+
this.subject = subject;
|
|
324
|
+
this.suggestion = suggestion;
|
|
325
|
+
this.name = "UiStyleCompileError";
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
function propertyError(name) {
|
|
329
|
+
let hit = suggest(name, STYLE_PROPERTY_NAMES);
|
|
330
|
+
return new UiStyleCompileError(`unknown style property "${name}"${hit === null ? "" : `; did you mean "${hit}"?`}`, "property", name, hit);
|
|
331
|
+
}
|
|
332
|
+
function valueError(key, detail) {
|
|
333
|
+
return new UiStyleCompileError(`${key}: ${detail}`, "value", key, null);
|
|
334
|
+
}
|
|
335
|
+
var f32 = new Float32Array(1), u32 = new Uint32Array(f32.buffer);
|
|
336
|
+
function floatBits(value) {
|
|
337
|
+
return f32[0] = value, u32[0];
|
|
338
|
+
}
|
|
339
|
+
function bitsFloat(word) {
|
|
340
|
+
return u32[0] = word, f32[0];
|
|
341
|
+
}
|
|
342
|
+
function isReference(value) {
|
|
343
|
+
return value instanceof UiVar || value instanceof UiSlot;
|
|
344
|
+
}
|
|
345
|
+
function referenceWord(value) {
|
|
346
|
+
return value instanceof UiSlot ? ((2147483648) | value.index) >>> 0 : value.id;
|
|
347
|
+
}
|
|
348
|
+
function isPlainObject(value) {
|
|
349
|
+
if (typeof value != "object" || value === null || Array.isArray(value) || isReference(value)) return false;
|
|
350
|
+
let proto = Object.getPrototypeOf(value);
|
|
351
|
+
return proto === Object.prototype || proto === null;
|
|
352
|
+
}
|
|
353
|
+
function isConditional(value) {
|
|
354
|
+
if (!isPlainObject(value)) return false;
|
|
355
|
+
for (let key of Object.keys(value)) if (key === DEFAULT || key.startsWith(":") || key.startsWith("@")) return true;
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
function flatten(key, value, mask, out) {
|
|
359
|
+
if (!isConditional(value)) {
|
|
360
|
+
out.delete(mask), out.set(mask, value);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
for (let [name, nested] of Object.entries(value)) {
|
|
364
|
+
if (name === DEFAULT) {
|
|
365
|
+
flatten(key, nested, mask, out);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
let bit = CONDITION_KEYS[name];
|
|
369
|
+
if (bit === void 0) {
|
|
370
|
+
let hit = suggest(name, Object.keys(CONDITION_KEYS));
|
|
371
|
+
throw new UiStyleCompileError(`${key}: unknown condition "${name}"${hit === null ? "" : `; did you mean "${hit}"?`}`, "condition", name, hit);
|
|
372
|
+
}
|
|
373
|
+
flatten(key, nested, mask | bit, out);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
var Encoder = class {
|
|
377
|
+
constructor(key) {
|
|
378
|
+
this.key = key;
|
|
379
|
+
this.words = [];
|
|
380
|
+
this.refs = 0;
|
|
381
|
+
this.unit = 0;
|
|
382
|
+
}
|
|
383
|
+
reference(value) {
|
|
384
|
+
this.refs |= 1 << this.words.length, this.words.push(referenceWord(value));
|
|
385
|
+
}
|
|
386
|
+
float(value) {
|
|
387
|
+
if (isReference(value)) return this.reference(value);
|
|
388
|
+
if (typeof value != "number" || !Number.isFinite(value)) throw valueError(this.key, `${String(value)} must be a finite number`);
|
|
389
|
+
this.words.push(floatBits(value));
|
|
390
|
+
}
|
|
391
|
+
color(value) {
|
|
392
|
+
if (isReference(value)) return this.reference(value);
|
|
393
|
+
if (typeof value != "number" && typeof value != "string") throw valueError(this.key, `${String(value)} must be a colour`);
|
|
394
|
+
try {
|
|
395
|
+
this.words.push(parseColor(value));
|
|
396
|
+
} catch (error) {
|
|
397
|
+
throw valueError(this.key, error.message);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
length(value) {
|
|
401
|
+
if (isReference(value))
|
|
402
|
+
return this.unit = value instanceof UiSlot && value.percent ? UiUnit.percent : UiUnit.points, this.reference(value);
|
|
403
|
+
if (typeof value == "number" && Number.isFinite(value)) {
|
|
404
|
+
this.unit = UiUnit.points, this.words.push(floatBits(value));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (value === AUTO) {
|
|
408
|
+
this.unit = UiUnit.auto, this.words.push(0);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (typeof value == "string" && value.endsWith(PERCENT)) {
|
|
412
|
+
let amount = Number(value.slice(0, -PERCENT.length));
|
|
413
|
+
if (Number.isFinite(amount)) {
|
|
414
|
+
this.unit = UiUnit.percent, this.words.push(floatBits(amount));
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
throw valueError(this.key, `length ${String(value)} must be a number, a percentage or auto`);
|
|
419
|
+
}
|
|
420
|
+
enumeration(value, table) {
|
|
421
|
+
if (isReference(value)) return this.reference(value);
|
|
422
|
+
let code = typeof value == "string" ? table[value] : void 0;
|
|
423
|
+
if (code === void 0) throw valueError(this.key, `${String(value)} is not one of ${Object.keys(table).join(", ")}${didYouMean(String(value), Object.keys(table))}`);
|
|
424
|
+
this.words.push(code);
|
|
425
|
+
}
|
|
426
|
+
bool(value) {
|
|
427
|
+
if (isReference(value)) return this.reference(value);
|
|
428
|
+
if (typeof value != "boolean") throw valueError(this.key, `${String(value)} must be true or false`);
|
|
429
|
+
this.words.push(value ? 1 : 0);
|
|
430
|
+
}
|
|
431
|
+
int(value) {
|
|
432
|
+
if (isReference(value)) return this.reference(value);
|
|
433
|
+
if (typeof value != "number" || !Number.isInteger(value)) throw valueError(this.key, `${String(value)} must be an integer`);
|
|
434
|
+
this.words.push((value | 0) >>> 0);
|
|
435
|
+
}
|
|
436
|
+
repeat(value, count, write, what) {
|
|
437
|
+
if (Array.isArray(value)) {
|
|
438
|
+
if (value.length !== count) throw valueError(this.key, `${what} takes one value or ${count} values`);
|
|
439
|
+
for (let item of value) write(item);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
for (let i = 0; i < count; i++) write(value);
|
|
443
|
+
}
|
|
444
|
+
shadow(value) {
|
|
445
|
+
if (!isPlainObject(value)) throw valueError(this.key, "a shadow is { color, x, y, blur, spread }");
|
|
446
|
+
let known = ["color", "x", "y", "blur", "spread"];
|
|
447
|
+
for (let name of Object.keys(value)) if (known.indexOf(name) < 0) throw valueError(this.key, `shadow has no ${name}${didYouMean(name, known)}`);
|
|
448
|
+
this.color(value.color), this.float(value.x ?? 0), this.float(value.y ?? 0), this.float(value.blur ?? 0), this.float(value.spread ?? 0);
|
|
449
|
+
}
|
|
450
|
+
gradient(value) {
|
|
451
|
+
if (!isPlainObject(value)) throw valueError(this.key, "a gradient is { kind, stops, from, to }");
|
|
452
|
+
let known = ["kind", "stops", "from", "to"];
|
|
453
|
+
for (let name of Object.keys(value)) if (known.indexOf(name) < 0) throw valueError(this.key, `gradient has no ${name}${didYouMean(name, known)}`);
|
|
454
|
+
let stops = value.stops;
|
|
455
|
+
if (!Array.isArray(stops) || stops.length === 0 || stops.length > (4)) throw valueError(this.key, `a gradient needs between 1 and ${(4)} stops`);
|
|
456
|
+
this.enumeration(value.kind ?? "linear", GRADIENT_KIND);
|
|
457
|
+
let pick = (i) => {
|
|
458
|
+
let stop = stops[Math.min(i, stops.length - 1)];
|
|
459
|
+
if (!Array.isArray(stop) || stop.length !== 2) throw valueError(this.key, "each gradient stop is [colour, offset]");
|
|
460
|
+
return stop;
|
|
461
|
+
};
|
|
462
|
+
for (let i = 0; i < (4); i++) this.color(pick(i)[0]);
|
|
463
|
+
for (let i = 0; i < (4); i++) this.float(pick(i)[1]);
|
|
464
|
+
let from = value.from ?? [0, 0], to = value.to ?? [0, 1];
|
|
465
|
+
if (!Array.isArray(from) || from.length !== 2 || !Array.isArray(to) || to.length !== 2) throw valueError(this.key, "gradient from and to are [x, y] points");
|
|
466
|
+
this.float(from[0]), this.float(from[1]), this.float(to[0]), this.float(to[1]);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
function encodeLeaf(key, type, table, value) {
|
|
470
|
+
let e = new Encoder(key), whole2 = isReference(value);
|
|
471
|
+
if (whole2 && (type === ValueType.shadow || type === ValueType.gradient)) throw valueError(key, "a variable can fill a colour or a number inside a shadow or gradient, not the whole value");
|
|
472
|
+
switch (type) {
|
|
473
|
+
case ValueType.length:
|
|
474
|
+
e.length(value);
|
|
475
|
+
break;
|
|
476
|
+
case ValueType.float:
|
|
477
|
+
e.float(value);
|
|
478
|
+
break;
|
|
479
|
+
case ValueType.int:
|
|
480
|
+
e.int(value);
|
|
481
|
+
break;
|
|
482
|
+
case ValueType.color:
|
|
483
|
+
e.color(value);
|
|
484
|
+
break;
|
|
485
|
+
case ValueType.enumeration:
|
|
486
|
+
e.enumeration(value, table);
|
|
487
|
+
break;
|
|
488
|
+
case ValueType.bool:
|
|
489
|
+
e.bool(value);
|
|
490
|
+
break;
|
|
491
|
+
case ValueType.edges:
|
|
492
|
+
e.repeat(value, 4, (v) => e.float(v), "an edge value");
|
|
493
|
+
break;
|
|
494
|
+
case ValueType.pair:
|
|
495
|
+
e.repeat(value, 2, (v) => e.float(v), "a pair");
|
|
496
|
+
break;
|
|
497
|
+
case ValueType.colors:
|
|
498
|
+
e.repeat(value, 4, (v) => e.color(v), "a border colour");
|
|
499
|
+
break;
|
|
500
|
+
case ValueType.quad:
|
|
501
|
+
if (!Array.isArray(value) && !whole2) throw valueError(key, "takes four numbers");
|
|
502
|
+
e.repeat(value, 4, (v) => e.float(v), "a quad");
|
|
503
|
+
break;
|
|
504
|
+
case ValueType.shadow:
|
|
505
|
+
e.shadow(value);
|
|
506
|
+
break;
|
|
507
|
+
case ValueType.gradient:
|
|
508
|
+
e.gradient(value);
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
if (e.words.length !== VALUE_WORDS[type]) throw valueError(key, "encoded to the wrong width");
|
|
512
|
+
return e;
|
|
513
|
+
}
|
|
514
|
+
function compileStyle(definition) {
|
|
515
|
+
if (!isPlainObject(definition)) throw new UiStyleCompileError("a style is an object of style properties", "value", "style", null);
|
|
516
|
+
let byKey = /* @__PURE__ */ new Map();
|
|
517
|
+
for (let [name, value] of Object.entries(definition)) {
|
|
518
|
+
if (value === void 0) continue;
|
|
519
|
+
let id = keyId(name);
|
|
520
|
+
if (id < 0) throw propertyError(name);
|
|
521
|
+
let variants = /* @__PURE__ */ new Map();
|
|
522
|
+
flatten(name, value, 0, variants), byKey.delete(id), byKey.set(id, variants);
|
|
523
|
+
for (let child of KEY_DESCENDANTS[id])
|
|
524
|
+
byKey.delete(child), byKey.set(child, /* @__PURE__ */ new Map([[0, null]]));
|
|
525
|
+
}
|
|
526
|
+
let ids = [...byKey.keys()].sort((a, b) => a - b), out = [(827937875), ids.length | (1) << (16)];
|
|
527
|
+
for (let id of ids) {
|
|
528
|
+
let variants = byKey.get(id), masks = [...variants.keys()].sort((a, b) => a - b);
|
|
529
|
+
out.push(id | masks.length << (8));
|
|
530
|
+
let type = KEY_TYPES[id];
|
|
531
|
+
for (let mask of masks) {
|
|
532
|
+
let leaf = variants.get(mask);
|
|
533
|
+
if (leaf === null) {
|
|
534
|
+
out.push(mask | VariantKind.null << (16));
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
let encoded = encodeLeaf(KEY_NAMES[id], type, KEY_TABLES[id], leaf), kind = encoded.refs === 0 ? VariantKind.literal : VariantKind.referenced;
|
|
538
|
+
out.push((mask | encoded.words.length << (8) | kind << (16) | encoded.unit << (20)) >>> 0), kind === VariantKind.referenced && out.push(encoded.refs);
|
|
539
|
+
for (let word of encoded.words) out.push(word >>> 0);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return Uint32Array.from(out);
|
|
543
|
+
}
|
|
544
|
+
function readBlock(words) {
|
|
545
|
+
if (words.length < (2) || words[0] >>> 0 !== (827937875)) throw new UiStyleError("compiled style data is not a style block");
|
|
546
|
+
let version = words[1] >>> (16);
|
|
547
|
+
if (version !== (1)) throw new UiStyleError(`compiled style block version ${version} is not supported; rebuild with this SDK`);
|
|
548
|
+
let keys = words[1] & (65535), out = [], at = (2);
|
|
549
|
+
for (let k = 0; k < keys; k++) {
|
|
550
|
+
let head = words[at++], key = head & (255), count = head >>> (8) & (255);
|
|
551
|
+
for (let v = 0; v < count; v++) {
|
|
552
|
+
let word = words[at++], kind = word >>> (16) & (15), size2 = word >>> (8) & (255), refs = kind === VariantKind.referenced ? words[at++] : 0, payload = [];
|
|
553
|
+
for (let i = 0; i < size2; i++) payload.push(words[at++] >>> 0);
|
|
554
|
+
out.push({ key, mask: word & (255), kind, unit: word >>> (20) & (15), refs, payload });
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (at !== words.length) throw new UiStyleError("compiled style block has trailing words");
|
|
558
|
+
return out;
|
|
559
|
+
}
|
|
560
|
+
function payloadNumber(type, word, bits) {
|
|
561
|
+
return isFloatWord(type, word) ? bitsFloat(bits) : type === ValueType.int ? bits | 0 : bits >>> 0;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/interactives/game-ui/styling/tailwind.ts
|
|
565
|
+
var SPACING_UNIT = 4, SPACING_STEPS = ["0", "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14", "16", "20", "24", "28", "32", "36", "40", "44", "48", "52", "56", "60", "64", "72", "80", "96"], SPACING = new Set(SPACING_STEPS), FRACTIONS = ["1/2", "1/3", "2/3", "1/4", "2/4", "3/4", "1/5", "2/5", "3/5", "4/5", "1/6", "5/6"], PERCENT2 = 100, FULL = "100%", AUTO2 = "auto", PX = "px", RADIUS = { none: 0, sm: 2, "": 4, md: 6, lg: 8, xl: 12, "2xl": 16, "3xl": 24, full: 9999 }, BORDER_WIDTHS = { "": 1, 0: 0, 2: 2, 4: 4, 8: 8 }, OPACITY_STEP = 5, Z = ["0", "10", "20", "30", "40", "50", "auto"], SCALES = ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150"], ROTATIONS = ["0", "1", "2", "3", "6", "12", "45", "90", "180"], DEGREES = Math.PI / 180, FONT_SIZES = { xs: 12, sm: 14, base: 16, lg: 18, xl: 20, "2xl": 24, "3xl": 30, "4xl": 36, "5xl": 48, "6xl": 60, "7xl": 72 }, FONT_WEIGHTS = { thin: 100, extralight: 200, light: 300, normal: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900 }, LEADING = { none: 1, tight: 1.25, snug: 1.375, normal: 1.5, relaxed: 1.625, loose: 2 }, SHADOW_INK = "#0000001a", SHADOWS = {
|
|
566
|
+
sm: { color: "#0000000d", x: 0, y: 1, blur: 2, spread: 0 },
|
|
567
|
+
"": { color: SHADOW_INK, x: 0, y: 1, blur: 3, spread: 0 },
|
|
568
|
+
md: { color: SHADOW_INK, x: 0, y: 4, blur: 6, spread: -1 },
|
|
569
|
+
lg: { color: SHADOW_INK, x: 0, y: 10, blur: 15, spread: -3 },
|
|
570
|
+
xl: { color: SHADOW_INK, x: 0, y: 20, blur: 25, spread: -5 },
|
|
571
|
+
"2xl": { color: "#00000040", x: 0, y: 25, blur: 50, spread: -12 },
|
|
572
|
+
none: null
|
|
573
|
+
}, ORIGINS = {
|
|
574
|
+
center: [0.5, 0.5],
|
|
575
|
+
top: [0.5, 0],
|
|
576
|
+
"top-right": [1, 0],
|
|
577
|
+
right: [1, 0.5],
|
|
578
|
+
"bottom-right": [1, 1],
|
|
579
|
+
bottom: [0.5, 1],
|
|
580
|
+
"bottom-left": [0, 1],
|
|
581
|
+
left: [0, 0.5],
|
|
582
|
+
"top-left": [0, 0]
|
|
583
|
+
}, GRADIENT_DIRECTIONS = {
|
|
584
|
+
t: [0.5, 1, 0.5, 0],
|
|
585
|
+
tr: [0, 1, 1, 0],
|
|
586
|
+
r: [0, 0.5, 1, 0.5],
|
|
587
|
+
br: [0, 0, 1, 1],
|
|
588
|
+
b: [0.5, 0, 0.5, 1],
|
|
589
|
+
bl: [1, 0, 0, 1],
|
|
590
|
+
l: [1, 0.5, 0, 0.5],
|
|
591
|
+
tl: [1, 1, 0, 0]
|
|
592
|
+
}, RADIAL_GEOMETRY = [0.5, 0.5, 0.5, 0], VIA_OFFSET = 0.5, LITERAL_COLOURS = { white: "#ffffffff", black: "#000000ff", transparent: "#00000000" }, TRANSPARENT = LITERAL_COLOURS.transparent, VARIANTS = {
|
|
593
|
+
pressed: Condition.pressed,
|
|
594
|
+
active: Condition.pressed,
|
|
595
|
+
focus: Condition.focus,
|
|
596
|
+
disabled: Condition.disabled,
|
|
597
|
+
landscape: Condition.landscape,
|
|
598
|
+
portrait: Condition.portrait,
|
|
599
|
+
safe: Condition.safe,
|
|
600
|
+
sm: Condition.sm,
|
|
601
|
+
lg: Condition.lg
|
|
602
|
+
}, CONDITION_NAMES = [":pressed", ":focus", ":disabled", "@landscape", "@portrait", "@safe", "@sm", "@lg"];
|
|
603
|
+
function kebab(name) {
|
|
604
|
+
return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
605
|
+
}
|
|
606
|
+
var TOKEN_COLOURS = /* @__PURE__ */ new Map();
|
|
607
|
+
for (let [name, variable] of Object.entries(tokens)) TOKEN_COLOURS.set(kebab(name), variable);
|
|
608
|
+
var COLOUR_NAMES = [...TOKEN_COLOURS.keys(), ...Object.keys(LITERAL_COLOURS)];
|
|
609
|
+
function arbitrary(token) {
|
|
610
|
+
return token.length > 2 && token.startsWith("[") && token.endsWith("]") ? token.slice(1, -1) : null;
|
|
611
|
+
}
|
|
612
|
+
function arbitraryNumber(token) {
|
|
613
|
+
let raw = arbitrary(token);
|
|
614
|
+
if (raw === null) return null;
|
|
615
|
+
let body = raw.endsWith(PX) ? raw.slice(0, -PX.length) : raw, value = Number(body);
|
|
616
|
+
return body.length > 0 && Number.isFinite(value) ? value : null;
|
|
617
|
+
}
|
|
618
|
+
function spacing(token) {
|
|
619
|
+
return token === PX ? 1 : SPACING.has(token) ? Number(token) * (4) : arbitraryNumber(token);
|
|
620
|
+
}
|
|
621
|
+
function size(token) {
|
|
622
|
+
if (token === "full") return FULL;
|
|
623
|
+
if (token === AUTO2) return AUTO2;
|
|
624
|
+
let slash = token.indexOf("/");
|
|
625
|
+
if (slash > 0 && FRACTIONS.indexOf(token) >= 0) return `${Number(token.slice(0, slash)) / Number(token.slice(slash + 1)) * (100)}%`;
|
|
626
|
+
let raw = arbitrary(token);
|
|
627
|
+
return raw !== null && raw.endsWith("%") && Number.isFinite(Number(raw.slice(0, -1))) ? raw : spacing(token);
|
|
628
|
+
}
|
|
629
|
+
function colour(token) {
|
|
630
|
+
let variable = TOKEN_COLOURS.get(token);
|
|
631
|
+
if (variable !== void 0) return variable;
|
|
632
|
+
let literal = LITERAL_COLOURS[token];
|
|
633
|
+
if (literal !== void 0) return literal;
|
|
634
|
+
let raw = arbitrary(token);
|
|
635
|
+
return raw !== null && raw.startsWith("#") ? raw : null;
|
|
636
|
+
}
|
|
637
|
+
function percentScale(token) {
|
|
638
|
+
return SCALES.indexOf(token) >= 0 ? Number(token) / (100) : arbitraryNumber(token);
|
|
639
|
+
}
|
|
640
|
+
var sign = (negative, value) => negative ? -value : value, spacingValues = () => [PX, ...SPACING_STEPS], sizeValues = () => [...spacingValues(), ...FRACTIONS, "full", AUTO2];
|
|
641
|
+
function keyword(prefix, apply) {
|
|
642
|
+
return {
|
|
643
|
+
prefix,
|
|
644
|
+
values: () => [""],
|
|
645
|
+
apply: (token, context) => token !== "" ? false : (apply(context), true)
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function choice(prefix, table, apply) {
|
|
649
|
+
return {
|
|
650
|
+
prefix,
|
|
651
|
+
values: () => Object.keys(table),
|
|
652
|
+
apply: (token, context) => Object.prototype.hasOwnProperty.call(table, token) ? (apply(table[token], context), true) : false
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function spaced(prefix, props3, negative) {
|
|
656
|
+
return {
|
|
657
|
+
prefix,
|
|
658
|
+
negative,
|
|
659
|
+
values: spacingValues,
|
|
660
|
+
apply: (token, context, minus) => {
|
|
661
|
+
let value = spacing(token);
|
|
662
|
+
if (value === null) return false;
|
|
663
|
+
for (let prop of props3) context.set(prop, sign(minus, value));
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function sized(prefix, props3, negative) {
|
|
669
|
+
return {
|
|
670
|
+
prefix,
|
|
671
|
+
negative,
|
|
672
|
+
values: sizeValues,
|
|
673
|
+
apply: (token, context, minus) => {
|
|
674
|
+
let value = size(token);
|
|
675
|
+
if (value === null || minus && value === AUTO2) return false;
|
|
676
|
+
let signed = typeof value == "number" ? sign(minus, value) : minus ? `-${value}` : value;
|
|
677
|
+
for (let prop of props3) context.set(prop, signed);
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function coloured(prefix, props3) {
|
|
683
|
+
return {
|
|
684
|
+
prefix,
|
|
685
|
+
values: () => COLOUR_NAMES,
|
|
686
|
+
apply: (token, context) => {
|
|
687
|
+
let value = colour(token);
|
|
688
|
+
if (value === null) return false;
|
|
689
|
+
for (let prop of props3) context.set(prop, value);
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function widths(prefix, prop) {
|
|
695
|
+
return {
|
|
696
|
+
prefix,
|
|
697
|
+
values: () => Object.keys(BORDER_WIDTHS),
|
|
698
|
+
apply: (token, context) => {
|
|
699
|
+
let value = Object.prototype.hasOwnProperty.call(BORDER_WIDTHS, token) ? BORDER_WIDTHS[token] : arbitraryNumber(token);
|
|
700
|
+
return value === null ? false : (context.set(prop, value), true);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
function radius(prefix, props3) {
|
|
705
|
+
return {
|
|
706
|
+
prefix,
|
|
707
|
+
values: () => Object.keys(RADIUS),
|
|
708
|
+
apply: (token, context) => {
|
|
709
|
+
let value = Object.prototype.hasOwnProperty.call(RADIUS, token) ? RADIUS[token] : arbitraryNumber(token);
|
|
710
|
+
if (value === null) return false;
|
|
711
|
+
for (let prop of props3) context.set(prop, value);
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
function scaled(prefix, props3) {
|
|
717
|
+
return {
|
|
718
|
+
prefix,
|
|
719
|
+
values: () => SCALES,
|
|
720
|
+
apply: (token, context) => {
|
|
721
|
+
let value = percentScale(token);
|
|
722
|
+
if (value === null) return false;
|
|
723
|
+
for (let prop of props3) context.set(prop, value);
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
var FAMILIES = [
|
|
729
|
+
keyword("flex", (c) => c.set("display", "flex")),
|
|
730
|
+
keyword("hidden", (c) => c.set("display", "none")),
|
|
731
|
+
keyword("invisible", (c) => c.set("hidden", true)),
|
|
732
|
+
keyword("visible", (c) => c.set("hidden", false)),
|
|
733
|
+
choice("flex", { row: "row", col: "column", "row-reverse": "row-reverse", "col-reverse": "column-reverse" }, (v, c) => c.set("direction", v)),
|
|
734
|
+
choice("flex", { wrap: true, nowrap: false }, (v, c) => c.set("wrap", v)),
|
|
735
|
+
choice("flex", { 1: [1, 1, "0%"], auto: [1, 1, AUTO2], initial: [0, 1, AUTO2], none: [0, 0, AUTO2] }, (v, c) => {
|
|
736
|
+
c.set("grow", v[0]), c.set("shrink", v[1]), c.set("basis", v[2]);
|
|
737
|
+
}),
|
|
738
|
+
keyword("grow", (c) => c.set("grow", 1)),
|
|
739
|
+
choice("grow", { 0: 0 }, (v, c) => c.set("grow", v)),
|
|
740
|
+
keyword("shrink", (c) => c.set("shrink", 1)),
|
|
741
|
+
choice("shrink", { 0: 0 }, (v, c) => c.set("shrink", v)),
|
|
742
|
+
sized("basis", ["basis"], false),
|
|
743
|
+
choice("justify", { start: "start", end: "end", center: "center", between: "space-between", around: "space-around", evenly: "space-evenly" }, (v, c) => c.set("justify", v)),
|
|
744
|
+
choice("items", { start: "start", end: "end", center: "center", stretch: "stretch" }, (v, c) => c.set("alignItems", v)),
|
|
745
|
+
choice("self", { auto: "auto", start: "start", end: "end", center: "center", stretch: "stretch" }, (v, c) => c.set("alignSelf", v)),
|
|
746
|
+
choice("content", { start: "start", end: "end", center: "center", stretch: "stretch" }, (v, c) => c.set("alignContent", v)),
|
|
747
|
+
keyword("absolute", (c) => c.set("position", "absolute")),
|
|
748
|
+
keyword("relative", (c) => c.set("position", "relative")),
|
|
749
|
+
choice("overflow", { hidden: true, visible: false, clip: true }, (v, c) => c.set("clip", v)),
|
|
750
|
+
choice("overflow", { scroll: "both", auto: "both" }, (v, c) => c.set("scrollAxes", v)),
|
|
751
|
+
choice("overflow-x", { scroll: "x", auto: "x" }, (v, c) => c.set("scrollAxes", v)),
|
|
752
|
+
choice("overflow-y", { scroll: "y", auto: "y" }, (v, c) => c.set("scrollAxes", v)),
|
|
753
|
+
choice("pointer-events", { none: "none", auto: "auto" }, (v, c) => c.set("pointerEvents", v)),
|
|
754
|
+
{
|
|
755
|
+
prefix: "aspect",
|
|
756
|
+
values: () => ["square", "video"],
|
|
757
|
+
apply: (token, c) => {
|
|
758
|
+
let value = token === "square" ? 1 : token === "video" ? 1.7777777777777777 : arbitraryNumber(token);
|
|
759
|
+
return value === null ? false : (c.set("aspect", value), true);
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
prefix: "z",
|
|
764
|
+
negative: true,
|
|
765
|
+
values: () => Z,
|
|
766
|
+
apply: (token, c, minus) => {
|
|
767
|
+
let value = token === AUTO2 ? 0 : Z.indexOf(token) >= 0 ? Number(token) : arbitraryNumber(token);
|
|
768
|
+
return value === null || !Number.isInteger(value) ? false : (c.set("zIndex", sign(minus, value)), true);
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
prefix: "opacity",
|
|
773
|
+
values: () => Array.from({ length: (100) / (5) + 1 }, (_, i) => String(i * (5))),
|
|
774
|
+
apply: (token, c) => {
|
|
775
|
+
let step2 = Number(token), value = token.length > 0 && Number.isInteger(step2) && step2 >= 0 && step2 <= (100) && step2 % (5) === 0 ? step2 / (100) : arbitraryNumber(token);
|
|
776
|
+
return value === null ? false : (c.set("opacity", value), true);
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
spaced("p", ["padding"], false),
|
|
780
|
+
spaced("px", ["paddingInline"], false),
|
|
781
|
+
spaced("py", ["paddingBlock"], false),
|
|
782
|
+
spaced("pt", ["paddingTop"], false),
|
|
783
|
+
spaced("pr", ["paddingRight"], false),
|
|
784
|
+
spaced("pb", ["paddingBottom"], false),
|
|
785
|
+
spaced("pl", ["paddingLeft"], false),
|
|
786
|
+
spaced("m", ["margin"], true),
|
|
787
|
+
spaced("mx", ["marginInline"], true),
|
|
788
|
+
spaced("my", ["marginBlock"], true),
|
|
789
|
+
spaced("mt", ["marginTop"], true),
|
|
790
|
+
spaced("mr", ["marginRight"], true),
|
|
791
|
+
spaced("mb", ["marginBottom"], true),
|
|
792
|
+
spaced("ml", ["marginLeft"], true),
|
|
793
|
+
spaced("gap", ["gap"], false),
|
|
794
|
+
spaced("gap-x", ["columnGap"], false),
|
|
795
|
+
spaced("gap-y", ["rowGap"], false),
|
|
796
|
+
sized("w", ["width"], false),
|
|
797
|
+
sized("h", ["height"], false),
|
|
798
|
+
sized("min-w", ["minWidth"], false),
|
|
799
|
+
sized("min-h", ["minHeight"], false),
|
|
800
|
+
sized("max-w", ["maxWidth"], false),
|
|
801
|
+
sized("max-h", ["maxHeight"], false),
|
|
802
|
+
sized("size", ["width", "height"], false),
|
|
803
|
+
sized("inset", ["inset"], true),
|
|
804
|
+
sized("inset-x", ["insetInline"], true),
|
|
805
|
+
sized("inset-y", ["insetBlock"], true),
|
|
806
|
+
sized("top", ["top"], true),
|
|
807
|
+
sized("right", ["right"], true),
|
|
808
|
+
sized("bottom", ["bottom"], true),
|
|
809
|
+
sized("left", ["left"], true),
|
|
810
|
+
radius("rounded", ["radius"]),
|
|
811
|
+
radius("rounded-t", ["radiusTopLeft", "radiusTopRight"]),
|
|
812
|
+
radius("rounded-r", ["radiusTopRight", "radiusBottomRight"]),
|
|
813
|
+
radius("rounded-b", ["radiusBottomRight", "radiusBottomLeft"]),
|
|
814
|
+
radius("rounded-l", ["radiusTopLeft", "radiusBottomLeft"]),
|
|
815
|
+
radius("rounded-tl", ["radiusTopLeft"]),
|
|
816
|
+
radius("rounded-tr", ["radiusTopRight"]),
|
|
817
|
+
radius("rounded-br", ["radiusBottomRight"]),
|
|
818
|
+
radius("rounded-bl", ["radiusBottomLeft"]),
|
|
819
|
+
widths("border", "borderWidth"),
|
|
820
|
+
widths("border-x", "borderInlineWidth"),
|
|
821
|
+
widths("border-y", "borderBlockWidth"),
|
|
822
|
+
widths("border-t", "borderTopWidth"),
|
|
823
|
+
widths("border-r", "borderRightWidth"),
|
|
824
|
+
widths("border-b", "borderBottomWidth"),
|
|
825
|
+
widths("border-l", "borderLeftWidth"),
|
|
826
|
+
coloured("border", ["borderColor"]),
|
|
827
|
+
coloured("border-x", ["borderInlineColor"]),
|
|
828
|
+
coloured("border-y", ["borderBlockColor"]),
|
|
829
|
+
coloured("border-t", ["borderTopColor"]),
|
|
830
|
+
coloured("border-r", ["borderRightColor"]),
|
|
831
|
+
coloured("border-b", ["borderBottomColor"]),
|
|
832
|
+
coloured("border-l", ["borderLeftColor"]),
|
|
833
|
+
coloured("bg", ["fill"]),
|
|
834
|
+
coloured("fill", ["fill"]),
|
|
835
|
+
coloured("tint", ["tint"]),
|
|
836
|
+
coloured("stroke", ["stroke"]),
|
|
837
|
+
choice("stroke", { 0: 0, 1: 1, 2: 2 }, (v, c) => c.set("strokeWidth", v)),
|
|
838
|
+
coloured("placeholder", ["placeholderColor"]),
|
|
839
|
+
coloured("text", ["textColor"]),
|
|
840
|
+
choice("text", FONT_SIZES, (v, c) => c.set("fontSize", v)),
|
|
841
|
+
{
|
|
842
|
+
prefix: "text",
|
|
843
|
+
values: () => [],
|
|
844
|
+
apply: (token, c) => {
|
|
845
|
+
let value = arbitraryNumber(token);
|
|
846
|
+
return value === null ? false : (c.set("fontSize", value), true);
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
choice("text", { left: "left", center: "center", right: "right", start: "start", end: "end" }, (v, c) => c.set("textAlign", v)),
|
|
850
|
+
choice("text", { wrap: true, nowrap: false }, (v, c) => c.set("textWrap", v)),
|
|
851
|
+
choice("text", { balance: "balance", pretty: "pretty" }, (v, c) => {
|
|
852
|
+
c.set("textWrap", true), c.set("textWrapStyle", v);
|
|
853
|
+
}),
|
|
854
|
+
choice("font", FONT_WEIGHTS, (v, c) => c.set("fontWeight", v)),
|
|
855
|
+
{
|
|
856
|
+
prefix: "leading",
|
|
857
|
+
values: () => Object.keys(LEADING),
|
|
858
|
+
apply: (token, c) => {
|
|
859
|
+
let value = Object.prototype.hasOwnProperty.call(LEADING, token) ? LEADING[token] : arbitraryNumber(token);
|
|
860
|
+
return value === null ? false : (c.set("lineHeight", value), true);
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
prefix: "tracking",
|
|
865
|
+
negative: true,
|
|
866
|
+
values: () => [],
|
|
867
|
+
apply: (token, c, minus) => {
|
|
868
|
+
let value = arbitraryNumber(token);
|
|
869
|
+
return value === null ? false : (c.set("letterSpacing", sign(minus, value)), true);
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
choice("align", { top: "top", middle: "center", bottom: "bottom" }, (v, c) => c.set("verticalAlign", v)),
|
|
873
|
+
scaled("scale", ["scale"]),
|
|
874
|
+
scaled("scale-x", ["scaleX"]),
|
|
875
|
+
scaled("scale-y", ["scaleY"]),
|
|
876
|
+
{
|
|
877
|
+
prefix: "rotate",
|
|
878
|
+
negative: true,
|
|
879
|
+
values: () => ROTATIONS,
|
|
880
|
+
apply: (token, c, minus) => {
|
|
881
|
+
let degrees = ROTATIONS.indexOf(token) >= 0 ? Number(token) : arbitraryNumber(token);
|
|
882
|
+
return degrees === null ? false : (c.set("rotate", sign(minus, degrees) * DEGREES), true);
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
spaced("translate-x", ["translateX"], true),
|
|
886
|
+
spaced("translate-y", ["translateY"], true),
|
|
887
|
+
choice("origin", ORIGINS, (v, c) => c.set("origin", v)),
|
|
888
|
+
choice("shadow", SHADOWS, (v, c) => c.set("shadow", v)),
|
|
889
|
+
choice("bg-gradient-to", GRADIENT_DIRECTIONS, (v, c) => {
|
|
890
|
+
c.gradient.kind = "linear", c.gradient.geometry = v;
|
|
891
|
+
}),
|
|
892
|
+
choice("bg-linear-to", GRADIENT_DIRECTIONS, (v, c) => {
|
|
893
|
+
c.gradient.kind = "linear", c.gradient.geometry = v;
|
|
894
|
+
}),
|
|
895
|
+
keyword("bg-radial", (c) => {
|
|
896
|
+
c.gradient.kind = "radial", c.gradient.geometry = RADIAL_GEOMETRY;
|
|
897
|
+
}),
|
|
898
|
+
{
|
|
899
|
+
prefix: "from",
|
|
900
|
+
values: () => COLOUR_NAMES,
|
|
901
|
+
apply: (token, c) => {
|
|
902
|
+
let value = colour(token);
|
|
903
|
+
return value === null ? false : (c.gradient.from = value, true);
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
prefix: "via",
|
|
908
|
+
values: () => COLOUR_NAMES,
|
|
909
|
+
apply: (token, c) => {
|
|
910
|
+
let value = colour(token);
|
|
911
|
+
return value === null ? false : (c.gradient.via = value, true);
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
prefix: "to",
|
|
916
|
+
values: () => COLOUR_NAMES,
|
|
917
|
+
apply: (token, c) => {
|
|
918
|
+
let value = colour(token);
|
|
919
|
+
return value === null ? false : (c.gradient.to = value, true);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
], ORDERED = [...FAMILIES].sort((a, b) => b.prefix.length - a.prefix.length), vocabulary = null;
|
|
923
|
+
function tailwindVocabulary() {
|
|
924
|
+
if (vocabulary !== null) return vocabulary;
|
|
925
|
+
let out = /* @__PURE__ */ new Set();
|
|
926
|
+
for (let family of FAMILIES)
|
|
927
|
+
for (let value of family.values()) {
|
|
928
|
+
let name = value === "" ? family.prefix : `${family.prefix}-${value}`;
|
|
929
|
+
out.add(name), family.negative === true && value !== "" && value !== "0" && value !== AUTO2 && out.add(`-${name}`);
|
|
930
|
+
}
|
|
931
|
+
for (let variant of Object.keys(VARIANTS)) out.add(`${variant}:`);
|
|
932
|
+
return vocabulary = [...out], vocabulary;
|
|
933
|
+
}
|
|
934
|
+
function splitVariants(name) {
|
|
935
|
+
let parts = [], depth = 0, start = 0;
|
|
936
|
+
for (let i = 0; i < name.length; i++) {
|
|
937
|
+
let c = name[i];
|
|
938
|
+
c === "[" ? depth++ : c === "]" ? depth-- : c === ":" && depth === 0 && (parts.push(name.slice(start, i)), start = i + 1);
|
|
939
|
+
}
|
|
940
|
+
return parts.push(name.slice(start)), parts;
|
|
941
|
+
}
|
|
942
|
+
function applyUtility(body, context) {
|
|
943
|
+
let negative = body.startsWith("-"), bare = negative ? body.slice(1) : body;
|
|
944
|
+
for (let family of ORDERED) {
|
|
945
|
+
if (negative && family.negative !== true) continue;
|
|
946
|
+
let token = null;
|
|
947
|
+
if (bare === family.prefix ? token = "" : bare.startsWith(`${family.prefix}-`) && (token = bare.slice(family.prefix.length + 1)), token !== null && family.apply(token, context, negative))
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
function insert(target, bits, value) {
|
|
953
|
+
if (bits.length === 0) {
|
|
954
|
+
target.default = value;
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
let name = CONDITION_NAMES[bits[0]], nested = target[name] ?? {};
|
|
958
|
+
target[name] = nested, insert(nested, bits.slice(1), value);
|
|
959
|
+
}
|
|
960
|
+
function maskBits(mask) {
|
|
961
|
+
let bits = [];
|
|
962
|
+
for (let bit = 0; bit < CONDITION_NAMES.length; bit++) mask & 1 << bit && bits.push(bit);
|
|
963
|
+
return bits;
|
|
964
|
+
}
|
|
965
|
+
function gradientValue(parts) {
|
|
966
|
+
let geometry = parts.geometry ?? GRADIENT_DIRECTIONS.b, from = parts.from ?? TRANSPARENT, to = parts.to ?? TRANSPARENT, stops = parts.via === void 0 ? [[from, 0], [to, 1]] : [[from, 0], [parts.via, (0.5)], [to, 1]];
|
|
967
|
+
return { kind: parts.kind ?? "linear", stops, from: [geometry[0], geometry[1]], to: [geometry[2], geometry[3]] };
|
|
968
|
+
}
|
|
969
|
+
function tailwindStyle(classes) {
|
|
970
|
+
let values = /* @__PURE__ */ new Map(), gradients = /* @__PURE__ */ new Map(), set = (mask) => (prop, value) => {
|
|
971
|
+
let byMask = values.get(prop);
|
|
972
|
+
byMask === void 0 && (byMask = /* @__PURE__ */ new Map(), values.set(prop, byMask)), byMask.delete(mask), byMask.set(mask, value);
|
|
973
|
+
};
|
|
974
|
+
for (let name of classes.split(/\s+/)) {
|
|
975
|
+
if (name.length === 0) continue;
|
|
976
|
+
let parts = splitVariants(name), body = parts[parts.length - 1], mask = 0;
|
|
977
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
978
|
+
let bit = VARIANTS[parts[i]];
|
|
979
|
+
if (bit === void 0) {
|
|
980
|
+
let hit = suggest(parts[i], Object.keys(VARIANTS));
|
|
981
|
+
throw new UiStyleCompileError(`unknown variant "${parts[i]}:" in "${name}"${hit === null ? "" : `; did you mean "${hit}:"?`}`, "class", name, hit === null ? null : `${hit}:${body}`);
|
|
982
|
+
}
|
|
983
|
+
mask |= bit;
|
|
984
|
+
}
|
|
985
|
+
if (body.length === 0) throw new UiStyleCompileError(`class "${name}" has no utility after its variants`, "class", name, null);
|
|
986
|
+
let gradient = gradients.get(mask);
|
|
987
|
+
if (gradient === void 0 && (gradient = {}, gradients.set(mask, gradient)), !applyUtility(body, { set: set(mask), gradient })) {
|
|
988
|
+
let hit = suggest(body, tailwindVocabulary()), prefix = parts.slice(0, -1).map((p) => `${p}:`).join("");
|
|
989
|
+
throw new UiStyleCompileError(`unknown class "${name}"${hit === null ? "" : `; did you mean "${prefix}${hit}"?`}`, "class", name, hit === null ? null : `${prefix}${hit}`);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
for (let [mask, parts] of gradients)
|
|
993
|
+
parts.kind === void 0 && parts.from === void 0 && parts.via === void 0 && parts.to === void 0 || set(mask)("gradient", gradientValue(parts));
|
|
994
|
+
let style = {}, ordered = [...values].sort((a, b) => KEY_TIERS[keyId(a[0])] - KEY_TIERS[keyId(b[0])]);
|
|
995
|
+
for (let [prop, byMask] of ordered) {
|
|
996
|
+
if (byMask.size === 1 && byMask.has(0)) {
|
|
997
|
+
style[prop] = byMask.get(0);
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
1000
|
+
let nested = {};
|
|
1001
|
+
for (let mask of [...byMask.keys()].sort((a, b) => a - b)) insert(nested, maskBits(mask), byMask.get(mask));
|
|
1002
|
+
style[prop] = nested;
|
|
1003
|
+
}
|
|
1004
|
+
return style;
|
|
1005
|
+
}
|
|
1006
|
+
function compileClasses(classes) {
|
|
1007
|
+
return compileStyle(tailwindStyle(classes));
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// src/interactives/game-ui/styling/runtime.ts
|
|
1011
|
+
var NO_VARIANT = -1, REF_VAR = 1, REF_SLOT = 2, SLOT_INDEX = 65535, PERCENT3 = "%", SLOT_FLOAT = 0, SLOT_INT = 1, SLOT_WORD = 2, slotFloats = new Float32Array(1), slotWords = new Uint32Array(slotFloats.buffer), AUTO3 = "auto", CompiledStyle = class {
|
|
1012
|
+
constructor(words) {
|
|
1013
|
+
this.first = new Int16Array(KEY_COUNT).fill((-1));
|
|
1014
|
+
this.count = new Uint8Array(KEY_COUNT);
|
|
1015
|
+
this.variantKey = new Uint8Array(0);
|
|
1016
|
+
this.mask = new Uint8Array(0);
|
|
1017
|
+
this.priority = new Uint16Array(0);
|
|
1018
|
+
this.empty = new Uint8Array(0);
|
|
1019
|
+
this.unit = new Uint8Array(0);
|
|
1020
|
+
this.start = new Uint16Array(0);
|
|
1021
|
+
this.values = new Float64Array(0);
|
|
1022
|
+
this.refKind = new Uint8Array(0);
|
|
1023
|
+
this.refId = new Int32Array(0);
|
|
1024
|
+
this.stateMask = 0;
|
|
1025
|
+
this.contextMask = 0;
|
|
1026
|
+
this.usesVars = false;
|
|
1027
|
+
this.slots = 0;
|
|
1028
|
+
this.version = 0;
|
|
1029
|
+
this.slotPos = new Int32Array(0);
|
|
1030
|
+
this.slotFloat = new Uint8Array(0);
|
|
1031
|
+
this.slotRefPos = new Int32Array(0);
|
|
1032
|
+
this.slotRefSlot = new Int32Array(0);
|
|
1033
|
+
this.slotRefMode = new Uint8Array(0);
|
|
1034
|
+
this.load(words);
|
|
1035
|
+
}
|
|
1036
|
+
slotBits(slot) {
|
|
1037
|
+
let value = this.values[this.slotPos[slot]];
|
|
1038
|
+
return this.slotFloat[slot] === 1 ? floatBits(value) : value >>> 0;
|
|
1039
|
+
}
|
|
1040
|
+
load(words) {
|
|
1041
|
+
let variants = readBlock(words), n = variants.length, total = 0;
|
|
1042
|
+
for (let v of variants) total += v.payload.length;
|
|
1043
|
+
this.first.fill((-1)), this.count.fill(0), this.variantKey = new Uint8Array(n), this.mask = new Uint8Array(n), this.priority = new Uint16Array(n), this.empty = new Uint8Array(n), this.unit = new Uint8Array(n), this.start = new Uint16Array(n), this.values = new Float64Array(total), this.refKind = new Uint8Array(total), this.refId = new Int32Array(total), this.stateMask = 0, this.contextMask = 0, this.usesVars = false, this.slots = 0;
|
|
1044
|
+
let at = 0;
|
|
1045
|
+
variants.forEach((v, i) => {
|
|
1046
|
+
this.first[v.key] === (-1) && (this.first[v.key] = i), this.count[v.key]++, this.variantKey[i] = v.key, this.mask[i] = v.mask, this.priority[i] = KEY_TIERS[v.key] + conditionPriority(v.mask), this.empty[i] = v.kind === VariantKind.null ? 1 : 0, this.unit[i] = v.unit, this.start[i] = at, this.stateMask |= v.mask & STATE_CONDITIONS, this.contextMask |= v.mask & CONTEXT_CONDITIONS;
|
|
1047
|
+
let type = KEY_TYPES[v.key];
|
|
1048
|
+
v.payload.forEach((bits, word) => {
|
|
1049
|
+
let pos = at + word;
|
|
1050
|
+
if (v.refs & 1 << word) {
|
|
1051
|
+
bits & (2147483648) ? (this.refKind[pos] = (2), this.refId[pos] = bits & (65535), this.slots = Math.max(this.slots, (bits & (65535)) + 1)) : (this.refKind[pos] = (1), this.refId[pos] = bits, this.usesVars = true);
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
this.values[pos] = payloadNumber(type, word, bits);
|
|
1055
|
+
}), at += v.payload.length;
|
|
1056
|
+
}), this.slotPos = new Int32Array(this.slots).fill(-1), this.slotFloat = new Uint8Array(this.slots);
|
|
1057
|
+
for (let v = 0; v < n; v++) {
|
|
1058
|
+
let begin = this.start[v], end = v + 1 < n ? this.start[v + 1] : total;
|
|
1059
|
+
for (let pos = begin; pos < end; pos++) {
|
|
1060
|
+
if (this.refKind[pos] !== (2) || this.slotPos[this.refId[pos]] >= 0) continue;
|
|
1061
|
+
let type = KEY_TYPES[this.variantKey[v]];
|
|
1062
|
+
this.slotPos[this.refId[pos]] = pos, this.slotFloat[this.refId[pos]] = isFloatWord(type, pos - begin) ? 1 : 0;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
let refPos = [], refSlot = [], refMode = [];
|
|
1066
|
+
for (let v = 0; v < n; v++) {
|
|
1067
|
+
let begin = this.start[v], end = v + 1 < n ? this.start[v + 1] : total, type = KEY_TYPES[this.variantKey[v]];
|
|
1068
|
+
for (let pos = begin; pos < end; pos++) {
|
|
1069
|
+
if (this.refKind[pos] !== (2)) continue;
|
|
1070
|
+
let word = pos - begin;
|
|
1071
|
+
refPos.push(pos), refSlot.push(this.refId[pos]), refMode.push(isColorWord(type, word) ? (2) : isFloatWord(type, word) ? (0) : type === ValueType.int ? (1) : (2));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
this.slotRefPos = Int32Array.from(refPos), this.slotRefSlot = Int32Array.from(refSlot), this.slotRefMode = Uint8Array.from(refMode), this.version++;
|
|
1075
|
+
}
|
|
1076
|
+
keySignature() {
|
|
1077
|
+
let out = "";
|
|
1078
|
+
for (let k = 0; k < KEY_COUNT; k++) this.first[k] !== (-1) && (out += `${k},`);
|
|
1079
|
+
return out;
|
|
1080
|
+
}
|
|
1081
|
+
setSlotsFrom(source, offset = 0) {
|
|
1082
|
+
let positions = this.slotRefPos, slots = this.slotRefSlot, modes = this.slotRefMode, values = this.values;
|
|
1083
|
+
for (let i = 0; i < positions.length; i++) {
|
|
1084
|
+
let mode = modes[i], value = source[offset + slots[i]];
|
|
1085
|
+
values[positions[i]] = mode === (0) ? value : mode === (1) ? value | 0 : value >>> 0;
|
|
1086
|
+
}
|
|
1087
|
+
return this;
|
|
1088
|
+
}
|
|
1089
|
+
slotBitsTo(slot, out, at) {
|
|
1090
|
+
let value = this.values[this.slotPos[slot]];
|
|
1091
|
+
this.slotFloat[slot] === 1 ? (slotFloats[0] = value, out[at] = slotWords[0]) : out[at] = value >>> 0;
|
|
1092
|
+
}
|
|
1093
|
+
setSlot(slot, raw) {
|
|
1094
|
+
let total = this.values.length;
|
|
1095
|
+
for (let v = 0; v < this.variantKey.length; v++) {
|
|
1096
|
+
let begin = this.start[v], end = v + 1 < this.variantKey.length ? this.start[v + 1] : total;
|
|
1097
|
+
for (let pos = begin; pos < end; pos++) {
|
|
1098
|
+
if (this.refKind[pos] !== (2) || this.refId[pos] !== slot) continue;
|
|
1099
|
+
let key = this.variantKey[v];
|
|
1100
|
+
convert(key, pos - begin, raw), this.values[pos] = converted[0], KEY_TYPES[key] === ValueType.length && typeof raw == "string" && this.unit[v] !== convertedUnit && (this.unit[v] = convertedUnit, this.version++);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}, converted = new Float64Array(1), convertedUnit = UiUnit.points;
|
|
1105
|
+
function convert(key, word, raw) {
|
|
1106
|
+
let type = KEY_TYPES[key];
|
|
1107
|
+
if (convertedUnit = UiUnit.points, isColorWord(type, word)) {
|
|
1108
|
+
converted[0] = typeof raw == "number" ? raw >>> 0 : parseColor(raw);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
if (typeof raw == "number") {
|
|
1112
|
+
converted[0] = isFloatWord(type, word) ? raw : type === ValueType.int ? raw | 0 : raw >>> 0;
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
if (typeof raw == "boolean") {
|
|
1116
|
+
converted[0] = raw ? 1 : 0;
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
if (type === ValueType.enumeration) {
|
|
1120
|
+
let code = KEY_TABLES[key][raw];
|
|
1121
|
+
if (code === void 0) throw new UiStyleError(`style variable value ${raw} is not valid here`);
|
|
1122
|
+
converted[0] = code;
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (type === ValueType.length && raw === AUTO3) {
|
|
1126
|
+
convertedUnit = UiUnit.auto, converted[0] = 0;
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
type === ValueType.length && raw.endsWith(PERCENT3) && (convertedUnit = UiUnit.percent);
|
|
1130
|
+
let value = Number.parseFloat(raw);
|
|
1131
|
+
converted[0] = isFloatWord(type, word) ? value : type === ValueType.int ? value | 0 : value >>> 0;
|
|
1132
|
+
}
|
|
1133
|
+
var UiProps = class _UiProps {
|
|
1134
|
+
constructor(parts) {
|
|
1135
|
+
this.owner = new Array(KEY_COUNT).fill(null);
|
|
1136
|
+
this.wireSet = new Uint8Array(WIRE_COUNT);
|
|
1137
|
+
this.encoded = null;
|
|
1138
|
+
this.encodedVersion = -1;
|
|
1139
|
+
let themes = [];
|
|
1140
|
+
for (let part of parts) {
|
|
1141
|
+
if (part instanceof UiTheme) {
|
|
1142
|
+
themes.push(part);
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (part instanceof _UiProps) {
|
|
1146
|
+
part.theme !== null && themes.push(part.theme);
|
|
1147
|
+
for (let k = 0; k < KEY_COUNT; k++) part.owner[k] !== null && (this.owner[k] = part.owner[k]);
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
for (let k = 0; k < KEY_COUNT; k++) part.first[k] !== (-1) && (this.owner[k] = part);
|
|
1151
|
+
}
|
|
1152
|
+
let wires = /* @__PURE__ */ new Set(), state = 0, context = 0, vars = false;
|
|
1153
|
+
for (let k = 0; k < KEY_COUNT; k++) {
|
|
1154
|
+
let style = this.owner[k];
|
|
1155
|
+
if (style === null) continue;
|
|
1156
|
+
for (let w of KEY_WIRES[k]) wires.add(w);
|
|
1157
|
+
let first = style.first[k];
|
|
1158
|
+
for (let v = first; v < first + style.count[k]; v++)
|
|
1159
|
+
state |= style.mask[v] & STATE_CONDITIONS, context |= style.mask[v] & CONTEXT_CONDITIONS;
|
|
1160
|
+
vars || (vars = style.usesVars);
|
|
1161
|
+
}
|
|
1162
|
+
this.wires = Uint8Array.from([...wires].sort((a, b) => a - b));
|
|
1163
|
+
for (let w of this.wires) this.wireSet[w] = 1;
|
|
1164
|
+
let distinct = [];
|
|
1165
|
+
for (let k = 0; k < KEY_COUNT; k++) {
|
|
1166
|
+
let style = this.owner[k];
|
|
1167
|
+
style !== null && distinct.indexOf(style) < 0 && distinct.push(style);
|
|
1168
|
+
}
|
|
1169
|
+
this.styles = distinct, this.dynamics = distinct.filter((style) => style.slots > 0), this.slotOffsets = new Int32Array(this.dynamics.length);
|
|
1170
|
+
let slots = 0;
|
|
1171
|
+
this.dynamics.forEach((style, i) => {
|
|
1172
|
+
this.slotOffsets[i] = slots, slots += style.slots;
|
|
1173
|
+
}), this.slotCount = slots, this.stateMask = state, this.contextMask = context, this.usesVars = vars, this.theme = themes.length === 0 ? null : themes.length === 1 ? themes[0] : mergeThemes(themes);
|
|
1174
|
+
}
|
|
1175
|
+
version() {
|
|
1176
|
+
let total = 0;
|
|
1177
|
+
for (let i = 0; i < this.styles.length; i++) total += this.styles[i].version;
|
|
1178
|
+
return total;
|
|
1179
|
+
}
|
|
1180
|
+
slotOffset(style) {
|
|
1181
|
+
for (let i = 0; i < this.dynamics.length; i++) if (this.dynamics[i] === style) return this.slotOffsets[i];
|
|
1182
|
+
return 0;
|
|
1183
|
+
}
|
|
1184
|
+
}, classCache = /* @__PURE__ */ new Map(), objectCache = /* @__PURE__ */ new WeakMap();
|
|
1185
|
+
function isWords(value) {
|
|
1186
|
+
return value instanceof Uint32Array || Array.isArray(value) && typeof value[0] == "number";
|
|
1187
|
+
}
|
|
1188
|
+
function styleOf(arg) {
|
|
1189
|
+
if (arg instanceof CompiledStyle || arg instanceof UiProps || arg instanceof UiTheme) return arg;
|
|
1190
|
+
if (typeof arg == "string") {
|
|
1191
|
+
let style2 = classCache.get(arg);
|
|
1192
|
+
return style2 === void 0 && (style2 = new CompiledStyle(compileClasses(arg)), classCache.set(arg, style2)), style2;
|
|
1193
|
+
}
|
|
1194
|
+
let style = objectCache.get(arg);
|
|
1195
|
+
return style === void 0 && (style = new CompiledStyle(isWords(arg) ? arg : compileStyle(arg)), objectCache.set(arg, style)), style;
|
|
1196
|
+
}
|
|
1197
|
+
var PropsNode = class {
|
|
1198
|
+
constructor() {
|
|
1199
|
+
this.next = null;
|
|
1200
|
+
this.result = null;
|
|
1201
|
+
}
|
|
1202
|
+
}, root = new PropsNode(), EMPTY_PROPS = new UiProps([]);
|
|
1203
|
+
root.result = EMPTY_PROPS;
|
|
1204
|
+
function isList(arg) {
|
|
1205
|
+
return Array.isArray(arg) && !isWords(arg);
|
|
1206
|
+
}
|
|
1207
|
+
function step(node, arg) {
|
|
1208
|
+
if (arg === false || arg === null || arg === void 0) return node;
|
|
1209
|
+
if (isList(arg)) {
|
|
1210
|
+
let at = node;
|
|
1211
|
+
for (let i = 0; i < arg.length; i++) at = step(at, arg[i]);
|
|
1212
|
+
return at;
|
|
1213
|
+
}
|
|
1214
|
+
let key = typeof arg == "string" || arg instanceof CompiledStyle || arg instanceof UiProps || arg instanceof UiTheme ? arg : styleOf(arg), next = node.next;
|
|
1215
|
+
next === null && (next = /* @__PURE__ */ new Map(), node.next = next);
|
|
1216
|
+
let child = next.get(key);
|
|
1217
|
+
return child === void 0 && (child = new PropsNode(), next.set(key, child)), child;
|
|
1218
|
+
}
|
|
1219
|
+
function collect(arg, out) {
|
|
1220
|
+
if (!(arg === false || arg === null || arg === void 0)) {
|
|
1221
|
+
if (isList(arg)) {
|
|
1222
|
+
for (let item of arg) collect(item, out);
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
out.push(styleOf(arg));
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
function props(a, b, c, d, e, f2, g, h) {
|
|
1229
|
+
let node = step(root, a);
|
|
1230
|
+
if (node = step(node, b), node = step(node, c), node = step(node, d), node = step(node, e), node = step(node, f2), node = step(node, g), node = step(node, h), node.result !== null) return node.result;
|
|
1231
|
+
let parts = [];
|
|
1232
|
+
return collect([a, b, c, d, e, f2, g, h], parts), node.result = parts.length === 1 && parts[0] instanceof UiProps ? parts[0] : new UiProps(parts), node.result;
|
|
1233
|
+
}
|
|
1234
|
+
function contextual(name, error) {
|
|
1235
|
+
throw error instanceof UiStyleCompileError ? new UiStyleCompileError(`styles.${name}: ${error.message}`, error.kind, error.subject, error.suggestion) : error;
|
|
1236
|
+
}
|
|
1237
|
+
function compiledDynamic(entry) {
|
|
1238
|
+
let style = new CompiledStyle(entry[0]), fns = entry[1];
|
|
1239
|
+
return (a, b, c, d) => {
|
|
1240
|
+
for (let i = 0; i < fns.length; i++) style.setSlot(i, fns[i](a, b, c, d));
|
|
1241
|
+
return style;
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
function fallbackDynamic(name, fn) {
|
|
1245
|
+
let style = null, signature = "";
|
|
1246
|
+
return (a, b, c, d) => {
|
|
1247
|
+
let words;
|
|
1248
|
+
try {
|
|
1249
|
+
words = compileStyle(fn(a, b, c, d));
|
|
1250
|
+
} catch (error) {
|
|
1251
|
+
contextual(name, error);
|
|
1252
|
+
}
|
|
1253
|
+
if (style === null)
|
|
1254
|
+
return style = new CompiledStyle(words), signature = style.keySignature(), style;
|
|
1255
|
+
if (style.load(words), style.keySignature() !== signature) throw new UiStyleError(`styles.${name}: a dynamic style must return the same properties on every call`);
|
|
1256
|
+
return style;
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function styles(definition, compiled) {
|
|
1260
|
+
let out = {}, names = /* @__PURE__ */ new Set([...Object.keys(definition), ...Object.keys(compiled ?? {})]);
|
|
1261
|
+
for (let name of names) {
|
|
1262
|
+
let entry = compiled?.[name], value = definition[name];
|
|
1263
|
+
if (entry !== void 0 && !isWords(entry) && typeof entry[1] == "function") {
|
|
1264
|
+
let style = new CompiledStyle(entry[0]);
|
|
1265
|
+
out[name] = entry[1](style, new Float64Array(Math.max(1, style.slots)));
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
if (entry !== void 0 && !isWords(entry)) {
|
|
1269
|
+
out[name] = compiledDynamic(entry);
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
if (entry !== void 0) {
|
|
1273
|
+
out[name] = new CompiledStyle(entry);
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
if (typeof value == "function") {
|
|
1277
|
+
out[name] = fallbackDynamic(name, value);
|
|
1278
|
+
continue;
|
|
1279
|
+
}
|
|
1280
|
+
try {
|
|
1281
|
+
out[name] = new CompiledStyle(compileStyle(value));
|
|
1282
|
+
} catch (error) {
|
|
1283
|
+
contextual(name, error);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
return out;
|
|
1287
|
+
}
|
|
1288
|
+
var TokenKind = { color: 1, float: 2 };
|
|
1289
|
+
var varKinds = /* @__PURE__ */ new Map(), collectedIds = [], collectedKinds = [], encodingProps = null, literalVars = false, insets = null;
|
|
1290
|
+
function tokenKind(type, word) {
|
|
1291
|
+
return isColorWord(type, word) ? TokenKind.color : type !== ValueType.length && isFloatWord(type, word) ? TokenKind.float : 0;
|
|
1292
|
+
}
|
|
1293
|
+
function claimToken(id, kind) {
|
|
1294
|
+
if (kind === 0) return false;
|
|
1295
|
+
let known = varKinds.get(id);
|
|
1296
|
+
if (known === void 0) varKinds.set(id, kind);
|
|
1297
|
+
else if (known !== kind) return false;
|
|
1298
|
+
return collectedIds.indexOf(id) < 0 && (collectedIds.push(id), collectedKinds.push(kind)), true;
|
|
1299
|
+
}
|
|
1300
|
+
function tokenBits(kind, raw) {
|
|
1301
|
+
return kind === TokenKind.color ? typeof raw == "number" ? raw >>> 0 : parseColor(raw) : floatBits(typeof raw == "number" ? raw : Number.parseFloat(raw));
|
|
1302
|
+
}
|
|
1303
|
+
var component = new Float64Array(MAX_COMPONENTS), floats2 = new Float64Array(2), floats4 = new Float64Array(4), words1 = new Float64Array(1), words4 = new Float64Array(4), NO_WORDS = new Float64Array(0), lengthUnit = 0, keepRefs = false, componentRefs = 0, componentSafe = 0;
|
|
1304
|
+
var SHADOW_FLOATS = 4, GRADIENT_HEAD = 5;
|
|
1305
|
+
function read(style, variant, word, target, slot) {
|
|
1306
|
+
let pos = style.start[variant] + word;
|
|
1307
|
+
lengthUnit = style.unit[variant];
|
|
1308
|
+
let kind = style.refKind[pos];
|
|
1309
|
+
if (kind === (2) && keepRefs && encodingProps !== null) {
|
|
1310
|
+
component[slot] = ((2147483648) | encodingProps.slotOffset(style) + style.refId[pos]) >>> 0, componentRefs |= 1 << slot;
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
if (kind !== (1)) {
|
|
1314
|
+
component[slot] = style.values[pos];
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
let id = style.refId[pos];
|
|
1318
|
+
if (keepRefs) {
|
|
1319
|
+
if (target.scopedVar(id) === void 0 && claimToken(id, tokenKind(KEY_TYPES[style.variantKey[variant]], word))) {
|
|
1320
|
+
component[slot] = id, componentRefs |= 1 << slot;
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
literalVars = true;
|
|
1324
|
+
}
|
|
1325
|
+
let raw = target.resolveVar(id) ?? varDefault(id);
|
|
1326
|
+
if (raw === void 0) throw new UiStyleError(`style variable ${id} has no value; define it with defineVars`);
|
|
1327
|
+
convert(style.variantKey[variant], word, raw), component[slot] = converted[0], lengthUnit = convertedUnit;
|
|
1328
|
+
}
|
|
1329
|
+
function safeEdge(prop, component2) {
|
|
1330
|
+
return prop === UiProp.padding || prop === UiProp.margin ? component2 : prop >= UiProp.inset_top && prop <= UiProp.inset_left ? prop - UiProp.inset_top : -1;
|
|
1331
|
+
}
|
|
1332
|
+
function resolveWire(owner, wire, active, target) {
|
|
1333
|
+
let first = WIRE_COMPONENT_START[wire], count = WIRE_COMPONENT_COUNT[wire], any = false;
|
|
1334
|
+
componentRefs = 0, componentSafe = 0, lengthUnit = WIRE_DEFAULT_UNIT[wire];
|
|
1335
|
+
let unit = lengthUnit;
|
|
1336
|
+
for (let c = 0; c < count; c++) {
|
|
1337
|
+
let index = first + c, chainStart2 = COMPONENT_CHAIN_START[index], chainEnd = chainStart2 + COMPONENT_CHAIN_COUNT[index], best = -1, bestStyle = null, bestVariant = (-1), bestWord = 0;
|
|
1338
|
+
for (let link = chainStart2; link < chainEnd; link++) {
|
|
1339
|
+
let key = CHAIN_KEYS[link], style = owner[key];
|
|
1340
|
+
if (style === null) continue;
|
|
1341
|
+
let begin = style.first[key], end = begin + style.count[key];
|
|
1342
|
+
for (let v = begin; v < end; v++)
|
|
1343
|
+
style.empty[v] === 1 || (style.mask[v] & ~active) !== 0 || style.priority[v] >= best && (best = style.priority[v], bestStyle = style, bestVariant = v, bestWord = CHAIN_WORDS[link]);
|
|
1344
|
+
}
|
|
1345
|
+
if (bestStyle === null) {
|
|
1346
|
+
component[c] = COMPONENT_DEFAULTS[index];
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
if (any = true, read(bestStyle, bestVariant, bestWord, target, c), (bestStyle.mask[bestVariant] & Condition.safe) !== 0) {
|
|
1350
|
+
let edge = safeEdge(WIRE_PROPS[wire], c);
|
|
1351
|
+
edge >= 0 && (WIRE_EMITS[wire] !== WireEmit.length || lengthUnit === UiUnit.points) && (keepRefs ? componentSafe |= 1 << c : insets !== null);
|
|
1352
|
+
}
|
|
1353
|
+
unit = lengthUnit;
|
|
1354
|
+
}
|
|
1355
|
+
return lengthUnit = unit, any;
|
|
1356
|
+
}
|
|
1357
|
+
function fillFrom(values, offset, count) {
|
|
1358
|
+
for (let i = 0; i < count; i++) values[i] = component[offset + i];
|
|
1359
|
+
return values;
|
|
1360
|
+
}
|
|
1361
|
+
function resetWire(target, wire) {
|
|
1362
|
+
let kind = WIRE_EMITS[wire];
|
|
1363
|
+
if (kind === WireEmit.flag) return;
|
|
1364
|
+
resolveWire(EMPTY_PROPS.owner, wire, 0, target);
|
|
1365
|
+
let prop = WIRE_PROPS[wire], { writer, id } = target;
|
|
1366
|
+
switch (target.cache.forget(prop), kind) {
|
|
1367
|
+
case WireEmit.length:
|
|
1368
|
+
writer.propFloatAt(id, prop, component, 0, lengthUnit);
|
|
1369
|
+
return;
|
|
1370
|
+
case WireEmit.float:
|
|
1371
|
+
writer.propFloatAt(id, prop, component, 0);
|
|
1372
|
+
return;
|
|
1373
|
+
case WireEmit.word:
|
|
1374
|
+
writer.propWordAt(id, prop, component, 0);
|
|
1375
|
+
return;
|
|
1376
|
+
case WireEmit.floats: {
|
|
1377
|
+
let n = WIRE_COMPONENT_COUNT[wire];
|
|
1378
|
+
writer.propFloats(id, prop, fillFrom(n === 2 ? floats2 : floats4, 0, n));
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
case WireEmit.words:
|
|
1382
|
+
writer.propWords(id, prop, fillFrom(words4, 0, 4));
|
|
1383
|
+
return;
|
|
1384
|
+
case WireEmit.shadow:
|
|
1385
|
+
words1[0] = component[0], writer.propMixed(id, prop, words1, fillFrom(floats4, 1, (4)));
|
|
1386
|
+
return;
|
|
1387
|
+
case WireEmit.gradient:
|
|
1388
|
+
writer.propWords(id, prop, NO_WORDS);
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
var STYLE_RECORD_REFERENCED = 1 << 24, STYLE_RECORD_SAFE_EDGES = 1 << 25, RECORD_UNIT_SHIFT = 8, RECORD_WORDS_SHIFT = 16, MAX_STYLE_VARIANTS = 64, DETACHED = {
|
|
1393
|
+
writer: null,
|
|
1394
|
+
cache: null,
|
|
1395
|
+
id: 0,
|
|
1396
|
+
resolveVar: () => {
|
|
1397
|
+
},
|
|
1398
|
+
scopedVar: () => {
|
|
1399
|
+
},
|
|
1400
|
+
setLayer: () => {
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
function wireClosure(owner, wire) {
|
|
1404
|
+
let closure = [0], first = WIRE_COMPONENT_START[wire];
|
|
1405
|
+
for (let index = first; index < first + WIRE_COMPONENT_COUNT[wire]; index++) {
|
|
1406
|
+
let chainStart2 = COMPONENT_CHAIN_START[index];
|
|
1407
|
+
for (let link = chainStart2; link < chainStart2 + COMPONENT_CHAIN_COUNT[index]; link++) {
|
|
1408
|
+
let key = CHAIN_KEYS[link], style = owner[key];
|
|
1409
|
+
if (style !== null)
|
|
1410
|
+
for (let v = style.first[key]; v < style.first[key] + style.count[key]; v++) {
|
|
1411
|
+
let mask = style.mask[v];
|
|
1412
|
+
if (style.empty[v] === 1 || mask === 0 || closure.indexOf(mask) >= 0) continue;
|
|
1413
|
+
let known = closure.length;
|
|
1414
|
+
for (let i = 0; i < known; i++) closure.indexOf(closure[i] | mask) < 0 && closure.push(closure[i] | mask);
|
|
1415
|
+
if (closure.length > (64)) throw new UiStyleError(`a style property combines more than ${(64)} condition sets; split it across elements`);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
return closure;
|
|
1420
|
+
}
|
|
1421
|
+
function isFloatComponent(emit, index) {
|
|
1422
|
+
return emit === WireEmit.length || emit === WireEmit.float || emit === WireEmit.floats ? true : emit === WireEmit.shadow ? index > 0 : emit === WireEmit.gradient ? index >= (5) : false;
|
|
1423
|
+
}
|
|
1424
|
+
function encodeEntry(out, wire) {
|
|
1425
|
+
let emit = WIRE_EMITS[wire], count = WIRE_COMPONENT_COUNT[wire], referenced = componentRefs !== 0, safe = componentSafe !== 0, unit = emit === WireEmit.length ? lengthUnit : 0;
|
|
1426
|
+
out.push((WIRE_PROPS[wire] | unit << (8) | count << (16) | (referenced ? STYLE_RECORD_REFERENCED : 0) | (safe ? STYLE_RECORD_SAFE_EDGES : 0)) >>> 0), referenced && out.push(componentRefs >>> 0), safe && out.push(componentSafe >>> 0);
|
|
1427
|
+
for (let i = 0; i < count; i++) {
|
|
1428
|
+
let value = component[i];
|
|
1429
|
+
out.push((componentRefs & 1 << i) !== 0 ? value >>> 0 : isFloatComponent(emit, i) ? floatBits(value) : value >>> 0);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
function encode(props3, target) {
|
|
1433
|
+
let records = [], wires = new Uint8Array(WIRE_COUNT);
|
|
1434
|
+
keepRefs = true, encodingProps = props3, literalVars = false, collectedIds.length = 0, collectedKinds.length = 0;
|
|
1435
|
+
try {
|
|
1436
|
+
let list = Array.from(props3.wires).filter((wire) => WIRE_EMITS[wire] !== WireEmit.flag), closures = list.map((wire) => wireClosure(props3.owner, wire)), masks = [...new Set(closures.flat())].sort((a, b) => conditionPriority(a) - conditionPriority(b) || a - b);
|
|
1437
|
+
for (let union of masks) {
|
|
1438
|
+
let words = [];
|
|
1439
|
+
for (let i = 0; i < list.length; i++) {
|
|
1440
|
+
let wire = list[i];
|
|
1441
|
+
closures[i].indexOf(union) < 0 || !resolveWire(props3.owner, wire, union, target) || (encodeEntry(words, wire), wires[wire] = 1);
|
|
1442
|
+
}
|
|
1443
|
+
union !== 0 && words.length === 0 || records.push({ mask: union, words: Uint32Array.from(words) });
|
|
1444
|
+
}
|
|
1445
|
+
return { records, wires, tokenIds: Uint32Array.from(collectedIds), tokenKinds: Uint8Array.from(collectedKinds), literal: literalVars };
|
|
1446
|
+
} finally {
|
|
1447
|
+
keepRefs = false, encodingProps = null, componentRefs = 0, componentSafe = 0;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function encodeStyleRecords(props3) {
|
|
1451
|
+
return [...engineRecords(props3, DETACHED, false).records];
|
|
1452
|
+
}
|
|
1453
|
+
function engineRecords(props3, target, scoped) {
|
|
1454
|
+
let version = props3.version(), cached = props3.encoded;
|
|
1455
|
+
return (cached === null || props3.encodedVersion !== version) && (cached = encode(props3, DETACHED), props3.encoded = cached, props3.encodedVersion = version), scoped || cached.literal ? encode(props3, target) : cached;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// src/interactives/game-ui/styling/index.ts
|
|
1459
|
+
function styles2(definition, compiled) {
|
|
1460
|
+
return styles(definition, compiled);
|
|
1461
|
+
}
|
|
1462
|
+
var props2 = props;
|
|
1463
|
+
|
|
1464
|
+
// src/interactives/game-ui/measure.ts
|
|
1465
|
+
var MEASURE_CAPACITY = 2048, DEFAULT_FONT_SIZE = 16, WRAP_SLACK = 0.01, MEMO_LIMIT = 16384, f = Math.fround, TextMeasurer = class {
|
|
1466
|
+
constructor() {
|
|
1467
|
+
this.layout = new TextLayout((2048));
|
|
1468
|
+
this.style = defaultLayoutStyle();
|
|
1469
|
+
this.result = { lines: 0, rows: 0, width: 0, height: 0 };
|
|
1470
|
+
this.memo = /* @__PURE__ */ new Map();
|
|
1471
|
+
this.hits = 0;
|
|
1472
|
+
this.misses = 0;
|
|
1473
|
+
this.dictionaries = null;
|
|
1474
|
+
}
|
|
1475
|
+
measure(table, text, style, width, out) {
|
|
1476
|
+
let size2 = style.fontSize ?? (16), lineHeight = style.lineHeight ?? 0, letterSpacing = style.letterSpacing ?? 0, wrap = style.textWrapStyle ?? "greedy", limit = width > 0 && Number.isFinite(width) ? width : Number.POSITIVE_INFINITY, dictionaries = breakDictionaries();
|
|
1477
|
+
dictionaries !== this.dictionaries && (this.dictionaries = dictionaries, this.memo.clear());
|
|
1478
|
+
let known = this.memo.get(text);
|
|
1479
|
+
if (known !== void 0 && known.table === table && known.size === size2 && known.lineHeight === lineHeight && known.letterSpacing === letterSpacing && known.wrap === wrap && known.limit === limit)
|
|
1480
|
+
return this.hits++, out.lines = known.lines, out.width = known.width, out.height = known.height, out;
|
|
1481
|
+
this.misses++;
|
|
1482
|
+
let shaped = f(Math.max(size2, 11920929e-14)), s = this.style;
|
|
1483
|
+
s.size = shaped, s.lineHeight = f(lineHeight), s.letterSpacing = f(f(letterSpacing) / shaped), s.maxWidth = Number.isFinite(limit) ? f(f(limit) + f((0.01))) : 0, s.wrap = wrap;
|
|
1484
|
+
let result = this.layout.measure(table, text, s, this.result);
|
|
1485
|
+
return out.lines = result.lines, out.width = result.width, out.height = result.height, known !== void 0 ? (known.table = table, known.size = size2, known.lineHeight = lineHeight, known.letterSpacing = letterSpacing, known.wrap = wrap, known.limit = limit, known.lines = result.lines, known.width = result.width, known.height = result.height) : (this.memo.size >= (16384) && this.memo.clear(), this.memo.set(text, { table, size: size2, lineHeight, letterSpacing, wrap, limit, lines: result.lines, width: result.width, height: result.height })), out;
|
|
1486
|
+
}
|
|
1487
|
+
clear() {
|
|
1488
|
+
this.memo.clear();
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
// src/interactives/game-ui/ui.ts
|
|
1493
|
+
var MIN_POLYGON_POINTS = 3, POLYGON_WORDS = 2, EXCLUSION_RECORDS = Array.from({ length: UI_MAX_EXCLUSIONS }, () => ({
|
|
1494
|
+
shape: 0,
|
|
1495
|
+
sibling: 0,
|
|
1496
|
+
margin: 0,
|
|
1497
|
+
x: 0,
|
|
1498
|
+
y: 0,
|
|
1499
|
+
width: 0,
|
|
1500
|
+
height: 0,
|
|
1501
|
+
points: null
|
|
1502
|
+
})), BREAKPOINT_SM = 640, BREAKPOINT_LG = 1024, LEGACY_KEYS = /* @__PURE__ */ new Set([
|
|
1503
|
+
"width",
|
|
1504
|
+
"height",
|
|
1505
|
+
"minWidth",
|
|
1506
|
+
"minHeight",
|
|
1507
|
+
"maxWidth",
|
|
1508
|
+
"maxHeight",
|
|
1509
|
+
"basis",
|
|
1510
|
+
"top",
|
|
1511
|
+
"right",
|
|
1512
|
+
"bottom",
|
|
1513
|
+
"left",
|
|
1514
|
+
"padding",
|
|
1515
|
+
"margin",
|
|
1516
|
+
"borderWidth",
|
|
1517
|
+
"gap",
|
|
1518
|
+
"grow",
|
|
1519
|
+
"shrink",
|
|
1520
|
+
"aspect",
|
|
1521
|
+
"direction",
|
|
1522
|
+
"justify",
|
|
1523
|
+
"alignItems",
|
|
1524
|
+
"alignSelf",
|
|
1525
|
+
"alignContent",
|
|
1526
|
+
"position",
|
|
1527
|
+
"wrap",
|
|
1528
|
+
"display",
|
|
1529
|
+
"fill",
|
|
1530
|
+
"borderColor",
|
|
1531
|
+
"radius",
|
|
1532
|
+
"opacity",
|
|
1533
|
+
"translate",
|
|
1534
|
+
"scale",
|
|
1535
|
+
"rotate",
|
|
1536
|
+
"origin",
|
|
1537
|
+
"zIndex",
|
|
1538
|
+
"hidden",
|
|
1539
|
+
"clip",
|
|
1540
|
+
"pointerEvents",
|
|
1541
|
+
"layer",
|
|
1542
|
+
"shadow",
|
|
1543
|
+
"gradient",
|
|
1544
|
+
"fontFamily",
|
|
1545
|
+
"fontWeight",
|
|
1546
|
+
"fontSize",
|
|
1547
|
+
"lineHeight",
|
|
1548
|
+
"letterSpacing",
|
|
1549
|
+
"textAlign",
|
|
1550
|
+
"textColor",
|
|
1551
|
+
"textWrap",
|
|
1552
|
+
"verticalAlign",
|
|
1553
|
+
"placeholderColor",
|
|
1554
|
+
"tint",
|
|
1555
|
+
"uv",
|
|
1556
|
+
"nineSlice",
|
|
1557
|
+
"nineSliceUv",
|
|
1558
|
+
"shape",
|
|
1559
|
+
"stroke",
|
|
1560
|
+
"strokeWidth",
|
|
1561
|
+
"scrollAxes",
|
|
1562
|
+
"textWrapStyle"
|
|
1563
|
+
]);
|
|
1564
|
+
function conditional(value) {
|
|
1565
|
+
if (typeof value != "object" || value === null || Array.isArray(value)) return false;
|
|
1566
|
+
for (let key in value) if (key === "default" || key.startsWith(":") || key.startsWith("@")) return true;
|
|
1567
|
+
return false;
|
|
1568
|
+
}
|
|
1569
|
+
function isLegacyStyle(style) {
|
|
1570
|
+
if (typeof style != "object" || style === null || Array.isArray(style) || ArrayBuffer.isView(style) || style instanceof CompiledStyle || style instanceof UiProps || style instanceof UiTheme) return false;
|
|
1571
|
+
for (let key in style) {
|
|
1572
|
+
if (!LEGACY_KEYS.has(key)) return false;
|
|
1573
|
+
let value = style[key];
|
|
1574
|
+
if (value instanceof UiVar || conditional(value)) return false;
|
|
1575
|
+
}
|
|
1576
|
+
return true;
|
|
1577
|
+
}
|
|
1578
|
+
function holds(encoded, mask) {
|
|
1579
|
+
let records = encoded.records;
|
|
1580
|
+
for (let i = 0; i < records.length; i++) if (records[i].mask === mask) return true;
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
var GameUiError = class extends Error {
|
|
1584
|
+
constructor(message) {
|
|
1585
|
+
super(message), this.name = "GameUiError";
|
|
1586
|
+
}
|
|
1587
|
+
}, DEFAULT_MAX_NODES = 4096, DEFAULT_MAX_SLOTS = 4096, NO_SLOTS = -1, EMPTY_RECORD = new Uint32Array(0), SLOT_SCRATCH = new Uint32Array(1), ROOT_THEME = {}, DEFAULT_WEIGHT2 = 400, PIVOT_BOTTOM_CENTER = [0.5, 1], ZERO_PAIR = [0, 0], DEFAULT_MIN_SCALE = 0.25, DEFAULT_MAX_SCALE = 2, DEFAULT_OCCLUDED_OPACITY = 0.35, NO_SEPARATOR = 0, COMMA = 44, EVENT_FLAGS = {
|
|
1588
|
+
press: UiFlag.press,
|
|
1589
|
+
release: UiFlag.press,
|
|
1590
|
+
tap: UiFlag.tap,
|
|
1591
|
+
long_press: UiFlag.long_press,
|
|
1592
|
+
drag_start: UiFlag.drag,
|
|
1593
|
+
drag_move: UiFlag.drag,
|
|
1594
|
+
drag_end: UiFlag.drag,
|
|
1595
|
+
scroll: 0,
|
|
1596
|
+
focus: 0,
|
|
1597
|
+
action: UiFlag.tap,
|
|
1598
|
+
passthrough: 0,
|
|
1599
|
+
change: 0,
|
|
1600
|
+
blur: 0,
|
|
1601
|
+
vector: 0
|
|
1602
|
+
}, VECTOR_TRUE = 1, VECTOR_FALSE = 0, vectorNameEncoder = new TextEncoder(), vectorNames = /* @__PURE__ */ new Map();
|
|
1603
|
+
function vectorName(name) {
|
|
1604
|
+
let bytes = vectorNames.get(name);
|
|
1605
|
+
return bytes === void 0 && (bytes = vectorNameEncoder.encode(name), vectorNames.set(name, bytes)), bytes;
|
|
1606
|
+
}
|
|
1607
|
+
var decoder = new TextDecoder(), EVENT_NAMES = (() => {
|
|
1608
|
+
let names = [];
|
|
1609
|
+
for (let [name, code] of Object.entries(UiEventKind)) names[code] = name;
|
|
1610
|
+
return names;
|
|
1611
|
+
})(), UiElement = class {
|
|
1612
|
+
constructor(ui, id, kind) {
|
|
1613
|
+
this.ui = ui;
|
|
1614
|
+
this.id = id;
|
|
1615
|
+
this.kind = kind;
|
|
1616
|
+
this.cache = new StyleCache();
|
|
1617
|
+
this.flags = 0;
|
|
1618
|
+
this.listeners = null;
|
|
1619
|
+
this.alive = true;
|
|
1620
|
+
this.edited = "";
|
|
1621
|
+
this.parentElement = null;
|
|
1622
|
+
this.kids = [];
|
|
1623
|
+
this.current = null;
|
|
1624
|
+
this.sent = null;
|
|
1625
|
+
this.sentVersion = -1;
|
|
1626
|
+
this.forced = false;
|
|
1627
|
+
this.focusable = false;
|
|
1628
|
+
this.slotBase = (-1);
|
|
1629
|
+
this.slotSize = 0;
|
|
1630
|
+
this.slotFresh = false;
|
|
1631
|
+
this.slotBits = null;
|
|
1632
|
+
this.stateBits = 0;
|
|
1633
|
+
this.scope = null;
|
|
1634
|
+
}
|
|
1635
|
+
get writer() {
|
|
1636
|
+
return this.ui.writer;
|
|
1637
|
+
}
|
|
1638
|
+
get props() {
|
|
1639
|
+
return this.current;
|
|
1640
|
+
}
|
|
1641
|
+
get state() {
|
|
1642
|
+
return this.stateBits;
|
|
1643
|
+
}
|
|
1644
|
+
resolveVar(id) {
|
|
1645
|
+
let cursor = this;
|
|
1646
|
+
for (; cursor !== null; ) {
|
|
1647
|
+
let scope = cursor.scope;
|
|
1648
|
+
if (scope !== null) {
|
|
1649
|
+
let value = scope.values.get(id);
|
|
1650
|
+
if (value !== void 0) return value;
|
|
1651
|
+
}
|
|
1652
|
+
cursor = cursor.parentElement;
|
|
1653
|
+
}
|
|
1654
|
+
let root2 = this.ui.rootTheme;
|
|
1655
|
+
if (root2 !== null) {
|
|
1656
|
+
let value = root2.values.get(id);
|
|
1657
|
+
if (value !== void 0) return value;
|
|
1658
|
+
}
|
|
1659
|
+
return varDefault(id);
|
|
1660
|
+
}
|
|
1661
|
+
scopedVar(id) {
|
|
1662
|
+
let cursor = this;
|
|
1663
|
+
for (; cursor !== null; ) {
|
|
1664
|
+
let scope = cursor.scope;
|
|
1665
|
+
if (scope !== null) {
|
|
1666
|
+
let value = scope.values.get(id);
|
|
1667
|
+
if (value !== void 0) return value;
|
|
1668
|
+
}
|
|
1669
|
+
cursor = cursor.parentElement;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
scoped() {
|
|
1673
|
+
let cursor = this;
|
|
1674
|
+
for (; cursor !== null; ) {
|
|
1675
|
+
if (cursor.scope !== null) return true;
|
|
1676
|
+
cursor = cursor.parentElement;
|
|
1677
|
+
}
|
|
1678
|
+
return false;
|
|
1679
|
+
}
|
|
1680
|
+
get perElement() {
|
|
1681
|
+
return this.sent !== null && (this.sent.literal || this.sent !== this.current?.encoded);
|
|
1682
|
+
}
|
|
1683
|
+
setLayer(on) {
|
|
1684
|
+
this.setFlag(UiFlag.layer, on);
|
|
1685
|
+
}
|
|
1686
|
+
applyProps(next) {
|
|
1687
|
+
let previous = this.scope, old = this.current;
|
|
1688
|
+
if (this.current = next, this.scope = next.theme, (next.stateMask & Condition.pressed) !== 0 && this.setFlag(UiFlag.press, true), (next.stateMask & Condition.focus) !== 0 && !this.focusable && (this.focusable = true, this.ui.writer.propWord(this.id, UiProp.focusable, 1)), this.send(old, next), previous !== this.scope) for (let i = 0; i < this.kids.length; i++) this.kids[i].restyleVars();
|
|
1689
|
+
}
|
|
1690
|
+
send(old, next) {
|
|
1691
|
+
let version = next.version();
|
|
1692
|
+
if (next !== old || this.sent === null || this.forced || version !== this.sentVersion) {
|
|
1693
|
+
let encoded = engineRecords(next, this, this.scoped());
|
|
1694
|
+
next.slotCount > this.slotSize && this.allocateSlots(next.slotCount), this.ui.ensureTokens(encoded.tokenIds, encoded.tokenKinds);
|
|
1695
|
+
let writer = this.ui.writer, previous = this.sent;
|
|
1696
|
+
if (previous !== null && previous !== encoded) {
|
|
1697
|
+
let records2 = previous.records;
|
|
1698
|
+
for (let i = 0; i < records2.length; i++) {
|
|
1699
|
+
let mask = records2[i].mask;
|
|
1700
|
+
mask !== 0 && !holds(encoded, mask) && writer.style(this.id, mask, EMPTY_RECORD);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
let records = encoded.records, base = this.slotBase < 0 ? 0 : this.slotBase;
|
|
1704
|
+
for (let i = 0; i < records.length; i++) writer.style(this.id, records[i].mask, records[i].words, base);
|
|
1705
|
+
if (previous !== null && previous !== encoded) {
|
|
1706
|
+
let before = previous.wires, after = encoded.wires;
|
|
1707
|
+
for (let wire = 0; wire < before.length; wire++) before[wire] === 1 && after[wire] === 0 && resetWire(this, wire);
|
|
1708
|
+
}
|
|
1709
|
+
this.sent = encoded, this.sentVersion = version, this.forced = false;
|
|
1710
|
+
}
|
|
1711
|
+
this.writeSlots(next);
|
|
1712
|
+
}
|
|
1713
|
+
allocateSlots(count) {
|
|
1714
|
+
this.slotBase !== (-1) && this.ui.freeSlots(this.slotBase, this.slotSize), this.slotBase = this.ui.allocateSlots(count), this.slotSize = count, this.slotBits = new Uint32Array(count), this.slotFresh = true;
|
|
1715
|
+
}
|
|
1716
|
+
writeSlots(props3) {
|
|
1717
|
+
let bits = this.slotBits;
|
|
1718
|
+
if (bits === null || props3.slotCount === 0) return;
|
|
1719
|
+
let dynamics = props3.dynamics;
|
|
1720
|
+
for (let d = 0; d < dynamics.length; d++) {
|
|
1721
|
+
let style = dynamics[d], offset = props3.slotOffsets[d];
|
|
1722
|
+
for (let s = 0; s < style.slots; s++) {
|
|
1723
|
+
style.slotBitsTo(s, SLOT_SCRATCH, 0);
|
|
1724
|
+
let local = offset + s;
|
|
1725
|
+
!this.slotFresh && bits[local] === SLOT_SCRATCH[0] || (bits[local] = SLOT_SCRATCH[0], this.ui.writer.slotAt(this.slotBase + local, SLOT_SCRATCH, 0));
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
this.slotFresh = false;
|
|
1729
|
+
}
|
|
1730
|
+
active() {
|
|
1731
|
+
let bits = 0, cursor = this;
|
|
1732
|
+
for (; cursor !== null; )
|
|
1733
|
+
bits |= cursor.stateBits, cursor = cursor.parentElement;
|
|
1734
|
+
return (bits & Condition.disabled) !== 0 && (bits &= ~(Condition.pressed | Condition.focus)), bits | this.ui.context;
|
|
1735
|
+
}
|
|
1736
|
+
restyle() {
|
|
1737
|
+
this.current === null || !this.alive || (this.forced = true, this.send(this.current, this.current), this.ui.touched());
|
|
1738
|
+
}
|
|
1739
|
+
restyleVars() {
|
|
1740
|
+
this.current !== null && this.current.usesVars && this.restyle();
|
|
1741
|
+
for (let i = 0; i < this.kids.length; i++) this.kids[i].restyleVars();
|
|
1742
|
+
}
|
|
1743
|
+
setState(state, on) {
|
|
1744
|
+
let bit = Condition[state], next = on ? this.stateBits | bit : this.stateBits & ~bit;
|
|
1745
|
+
return next === this.stateBits ? this : (this.stateBits = next, state === "disabled" && this.alive && (this.ui.writer.propWord(this.id, UiProp.disabled, on ? 1 : 0), this.ui.touched()), this);
|
|
1746
|
+
}
|
|
1747
|
+
get parent() {
|
|
1748
|
+
return this.parentElement;
|
|
1749
|
+
}
|
|
1750
|
+
get children() {
|
|
1751
|
+
return this.kids;
|
|
1752
|
+
}
|
|
1753
|
+
contains(element) {
|
|
1754
|
+
let cursor = element.parentElement;
|
|
1755
|
+
for (; cursor !== null; ) {
|
|
1756
|
+
if (cursor === this) return true;
|
|
1757
|
+
cursor = cursor.parentElement;
|
|
1758
|
+
}
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1761
|
+
detach() {
|
|
1762
|
+
let parent = this.parentElement;
|
|
1763
|
+
if (parent === null) return;
|
|
1764
|
+
let at = parent.kids.indexOf(this);
|
|
1765
|
+
at >= 0 && parent.kids.splice(at, 1), this.parentElement = null;
|
|
1766
|
+
}
|
|
1767
|
+
adopt(child, before) {
|
|
1768
|
+
if (child === this || child.contains(this))
|
|
1769
|
+
throw new GameUiError(`inserting ui element ${child.id} would create a cycle`);
|
|
1770
|
+
child.parentElement !== null && child.detach();
|
|
1771
|
+
let at = before === null ? -1 : this.kids.indexOf(before);
|
|
1772
|
+
at < 0 ? this.kids.push(child) : this.kids.splice(at, 0, child), child.parentElement = this;
|
|
1773
|
+
}
|
|
1774
|
+
get destroyed() {
|
|
1775
|
+
return !this.alive;
|
|
1776
|
+
}
|
|
1777
|
+
style(style) {
|
|
1778
|
+
return this.ui.check(this), isLegacyStyle(style) ? (style.layer !== void 0 && this.setFlag(UiFlag.layer, style.layer), writeStyle(this.ui.writer, this.cache, this.id, style)) : this.applyProps(style instanceof UiProps ? style : props2(style)), this.ui.touched(), this;
|
|
1779
|
+
}
|
|
1780
|
+
append(child) {
|
|
1781
|
+
return this.ui.check(this), this.ui.check(child), this.adopt(child, null), this.ui.writer.insert(child.id, this.id, 4294967295), this.ui.touched(), this;
|
|
1782
|
+
}
|
|
1783
|
+
insertBefore(child, before) {
|
|
1784
|
+
if (this.ui.check(this), this.ui.check(child), before.parentElement !== this) throw new GameUiError(`ui element ${before.id} is not a child of ${this.id}`);
|
|
1785
|
+
return this.adopt(child, before), this.ui.writer.insert(child.id, this.id, before.id), this.ui.touched(), this;
|
|
1786
|
+
}
|
|
1787
|
+
remove() {
|
|
1788
|
+
return this.ui.check(this), this.detach(), this.ui.writer.remove(this.id), this.ui.touched(), this;
|
|
1789
|
+
}
|
|
1790
|
+
destroy() {
|
|
1791
|
+
this.alive && (this.ui.release(this), this.alive = false);
|
|
1792
|
+
}
|
|
1793
|
+
get value() {
|
|
1794
|
+
return this.edited;
|
|
1795
|
+
}
|
|
1796
|
+
accept(value) {
|
|
1797
|
+
this.edited = value;
|
|
1798
|
+
}
|
|
1799
|
+
text(value) {
|
|
1800
|
+
return this.ui.check(this), this.kind === "input" && (this.edited = value), this.ui.writer.text(this.id, value), this.ui.touched(), this;
|
|
1801
|
+
}
|
|
1802
|
+
textPrefix(value, length2) {
|
|
1803
|
+
return this.ui.check(this), this.ui.writer.textPrefix(this.id, value, length2), this.ui.touched(), this;
|
|
1804
|
+
}
|
|
1805
|
+
textRef(id) {
|
|
1806
|
+
return this.ui.check(this), this.ui.writer.textRef(this.id, id), this.ui.touched(), this;
|
|
1807
|
+
}
|
|
1808
|
+
number(value, options = {}) {
|
|
1809
|
+
this.ui.check(this);
|
|
1810
|
+
let separator = options.separator === void 0 ? (44) : options.separator.length === 0 ? (0) : options.separator.charCodeAt(0);
|
|
1811
|
+
return this.ui.writer.number(this.id, value, UiNumberFormat[options.format ?? "integer"], options.decimals ?? 0, separator), this.ui.touched(), this;
|
|
1812
|
+
}
|
|
1813
|
+
placeholder(value) {
|
|
1814
|
+
return this.ui.check(this), this.ui.writer.placeholder(this.id, value), this.ui.touched(), this;
|
|
1815
|
+
}
|
|
1816
|
+
image(asset, width, height) {
|
|
1817
|
+
return this.ui.check(this), this.ui.writer.image(this.id, asset, width, height), this.ui.touched(), this;
|
|
1818
|
+
}
|
|
1819
|
+
path(points) {
|
|
1820
|
+
return this.ui.check(this), this.ui.writer.path(this.id, points), this.ui.touched(), this;
|
|
1821
|
+
}
|
|
1822
|
+
vector(asset, artboard = 0) {
|
|
1823
|
+
return this.requireVector(), this.ui.writer.vector(this.id, asset, artboard), this.ui.touched(), this;
|
|
1824
|
+
}
|
|
1825
|
+
play(kind, index) {
|
|
1826
|
+
return this.requireVector(), this.ui.writer.vectorPlay(this.id, kind, index), this.ui.touched(), this;
|
|
1827
|
+
}
|
|
1828
|
+
seek(kind, index, seconds) {
|
|
1829
|
+
return this.requireVector(), this.ui.writer.vectorSeek(this.id, kind, index, seconds), this.ui.touched(), this;
|
|
1830
|
+
}
|
|
1831
|
+
setInput(input, value) {
|
|
1832
|
+
this.requireVector();
|
|
1833
|
+
let numeric = typeof value == "boolean" ? value ? (1) : (0) : value;
|
|
1834
|
+
return typeof input == "number" ? this.ui.writer.vectorInput(this.id, input, numeric) : this.ui.writer.vectorInputName(this.id, vectorName(input), numeric), this.ui.touched(), this;
|
|
1835
|
+
}
|
|
1836
|
+
setData(path, value) {
|
|
1837
|
+
return this.requireVector(), typeof value == "boolean" ? this.ui.writer.vectorData(this.id, UiVectorData.bool, vectorName(path), value ? (1) : (0), 0) : this.ui.writer.vectorData(this.id, UiVectorData.number, vectorName(path), value, 0), this.ui.touched(), this;
|
|
1838
|
+
}
|
|
1839
|
+
setDataColor(path, argb) {
|
|
1840
|
+
return this.requireVector(), this.ui.writer.vectorData(this.id, UiVectorData.color, vectorName(path), 0, argb >>> 0), this.ui.touched(), this;
|
|
1841
|
+
}
|
|
1842
|
+
fireData(path) {
|
|
1843
|
+
return this.requireVector(), this.ui.writer.vectorData(this.id, UiVectorData.fire, vectorName(path), 0, 0), this.ui.touched(), this;
|
|
1844
|
+
}
|
|
1845
|
+
detachVector() {
|
|
1846
|
+
return this.requireVector(), this.ui.writer.vectorDetach(this.id), this.ui.touched(), this;
|
|
1847
|
+
}
|
|
1848
|
+
requireVector() {
|
|
1849
|
+
if (this.ui.check(this), this.kind !== "vector") throw new GameUiError(`ui ${this.kind} ${this.id} is not a vector element; create it with ui.vector`);
|
|
1850
|
+
}
|
|
1851
|
+
flowAround(exclusions) {
|
|
1852
|
+
if (this.ui.check(this), this.kind === "image" || this.kind === "shape") throw new GameUiError(`ui ${this.kind} ${this.id} cannot flow around shapes; use text, input, box or scroll`);
|
|
1853
|
+
let count = exclusions === null ? 0 : exclusions.length;
|
|
1854
|
+
if (count > UI_MAX_EXCLUSIONS) throw new GameUiError(`ui element ${this.id} flows around at most ${UI_MAX_EXCLUSIONS} shapes`);
|
|
1855
|
+
for (let i = 0; i < count; i++) this.exclusionRecord(exclusions[i], EXCLUSION_RECORDS[i]);
|
|
1856
|
+
this.ui.writer.exclusions(this.id, EXCLUSION_RECORDS, count);
|
|
1857
|
+
for (let i = 0; i < count; i++) EXCLUSION_RECORDS[i].points = null;
|
|
1858
|
+
return this.ui.touched(), this;
|
|
1859
|
+
}
|
|
1860
|
+
exclusionRecord(exclusion, out) {
|
|
1861
|
+
if (out.margin = exclusion.margin ?? 0, out.sibling = 4294967295, out.x = 0, out.y = 0, out.width = 0, out.height = 0, out.points = null, "rect" in exclusion)
|
|
1862
|
+
out.shape = UiExclusionShape.rect, out.x = exclusion.rect[0], out.y = exclusion.rect[1], out.width = exclusion.rect[2], out.height = exclusion.rect[3];
|
|
1863
|
+
else if ("circle" in exclusion) {
|
|
1864
|
+
let [cx, cy, r] = exclusion.circle;
|
|
1865
|
+
out.shape = UiExclusionShape.ellipse, out.x = cx - r, out.y = cy - r, out.width = r * 2, out.height = r * 2;
|
|
1866
|
+
} else if ("polygon" in exclusion) {
|
|
1867
|
+
if (exclusion.polygon.length < (3) * (2)) throw new GameUiError("an exclusion polygon needs at least three points");
|
|
1868
|
+
out.shape = UiExclusionShape.polygon, out.points = exclusion.polygon, exclusion.element !== void 0 && (out.sibling = this.exclusionTarget(exclusion.element));
|
|
1869
|
+
} else
|
|
1870
|
+
out.shape = exclusion.shape === "circle" ? UiExclusionShape.ellipse : UiExclusionShape.rect, out.sibling = this.exclusionTarget(exclusion.element);
|
|
1871
|
+
}
|
|
1872
|
+
exclusionTarget(element) {
|
|
1873
|
+
if (this.ui.check(element), element === this) throw new GameUiError(`ui element ${this.id} cannot flow around itself`);
|
|
1874
|
+
return element.id;
|
|
1875
|
+
}
|
|
1876
|
+
transition(props3, options) {
|
|
1877
|
+
this.ui.check(this);
|
|
1878
|
+
let mask = 0;
|
|
1879
|
+
for (let prop of props3) mask |= UiTransition[prop];
|
|
1880
|
+
let easing = options.spring !== void 0 ? "spring" : options.bezier !== void 0 ? "bezier" : options.easing ?? "ease", params = options.spring !== void 0 ? [options.spring.damping, options.spring.cycles, 0, 0] : options.bezier ?? null;
|
|
1881
|
+
return this.ui.writer.transition(this.id, mask, options.duration, UiEasing[easing], params), this.ui.touched(), this;
|
|
1882
|
+
}
|
|
1883
|
+
accessibility(options) {
|
|
1884
|
+
this.ui.check(this);
|
|
1885
|
+
let writer = this.ui.writer;
|
|
1886
|
+
options.role !== void 0 && writer.propWord(this.id, UiProp.role, UiRole[options.role]), options.label !== void 0 && writer.label(this.id, options.label), options.value !== void 0 && writer.value(this.id, options.value);
|
|
1887
|
+
let traits = (options.selected ? UiTrait.selected : 0) | (options.disabled ? UiTrait.disabled : 0) | (options.hidden ? UiTrait.hidden : 0) | (options.live ? UiTrait.live : 0) | (options.modal ? UiTrait.modal : 0);
|
|
1888
|
+
if (writer.propWord(this.id, UiProp.traits, traits), this.setState("disabled", options.disabled === true), options.actions !== void 0) {
|
|
1889
|
+
let actions = 0;
|
|
1890
|
+
for (let action of options.actions) actions |= UiAction[action];
|
|
1891
|
+
writer.propWord(this.id, UiProp.actions, actions);
|
|
1892
|
+
}
|
|
1893
|
+
return this.ui.touched(), this;
|
|
1894
|
+
}
|
|
1895
|
+
scrollTo(x, y) {
|
|
1896
|
+
return this.ui.check(this), this.ui.writer.scrollTo(this.id, x, y), this.ui.touched(), this;
|
|
1897
|
+
}
|
|
1898
|
+
focus() {
|
|
1899
|
+
return this.ui.check(this), this.ui.writer.focus(this.id), this.ui.touched(), this;
|
|
1900
|
+
}
|
|
1901
|
+
blur() {
|
|
1902
|
+
return this.ui.check(this), this.ui.writer.blur(this.id), this.ui.touched(), this;
|
|
1903
|
+
}
|
|
1904
|
+
on(event, listener) {
|
|
1905
|
+
this.ui.check(this), this.listeners === null && (this.listeners = /* @__PURE__ */ new Map());
|
|
1906
|
+
let list = this.listeners.get(event);
|
|
1907
|
+
return list === void 0 && (list = [], this.listeners.set(event, list)), list.push(listener), this.setFlag(EVENT_FLAGS[event], true), () => {
|
|
1908
|
+
let at = list.indexOf(listener);
|
|
1909
|
+
at >= 0 && list.splice(at, 1);
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
emit(name, event) {
|
|
1913
|
+
name === "press" ? this.setState("pressed", true) : name === "release" ? this.setState("pressed", false) : name === "focus" ? this.setState("focus", true) : name === "blur" && this.setState("focus", false);
|
|
1914
|
+
let list = this.listeners?.get(name);
|
|
1915
|
+
if (list === void 0 || list.length === 0) return false;
|
|
1916
|
+
for (let i = 0; i < list.length; i++) list[i](event, this);
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
setFlag(flag, on) {
|
|
1920
|
+
if (flag === 0) return;
|
|
1921
|
+
let next = on ? this.flags | flag : this.flags & ~flag;
|
|
1922
|
+
next !== this.flags && (this.flags = next, this.ui.writer.propWord(this.id, UiProp.flags, next), this.ui.touched());
|
|
1923
|
+
}
|
|
1924
|
+
dispose() {
|
|
1925
|
+
this.alive = false, this.listeners = null, this.current = null, this.sent = null, this.scope = null, this.slotBase !== (-1) && this.ui.freeSlots(this.slotBase, this.slotSize), this.slotBase = (-1), this.slotSize = 0, this.slotBits = null;
|
|
1926
|
+
}
|
|
1927
|
+
}, GameUi = class {
|
|
1928
|
+
constructor(sink, options = {}) {
|
|
1929
|
+
this.sink = sink;
|
|
1930
|
+
this.elements = [];
|
|
1931
|
+
this.free = [];
|
|
1932
|
+
this.next = 0;
|
|
1933
|
+
this.strings = /* @__PURE__ */ new Map();
|
|
1934
|
+
this.families = /* @__PURE__ */ new Map();
|
|
1935
|
+
this.fontFamilies = [];
|
|
1936
|
+
this.fontWeights = [];
|
|
1937
|
+
this.fontIds = [];
|
|
1938
|
+
this.measurer = new TextMeasurer();
|
|
1939
|
+
this.passthrough = [];
|
|
1940
|
+
this.event = { kind: 0, phase: 0, pointer: 0, node: 0, x: 0, y: 0, dx: 0, dy: 0, value: 0, time_ms: 0 };
|
|
1941
|
+
this.scheduled = false;
|
|
1942
|
+
this.contextBits = Condition.portrait | Condition.safe;
|
|
1943
|
+
this.themeRoot = null;
|
|
1944
|
+
this.tokenIds = [];
|
|
1945
|
+
this.tokenKinds = [];
|
|
1946
|
+
this.tokenSent = /* @__PURE__ */ new Set();
|
|
1947
|
+
this.themeBits = /* @__PURE__ */ new WeakMap();
|
|
1948
|
+
this.slotTop = 0;
|
|
1949
|
+
this.freeSlotBlocks = /* @__PURE__ */ new Map();
|
|
1950
|
+
this.flushTask = () => {
|
|
1951
|
+
this.flush();
|
|
1952
|
+
};
|
|
1953
|
+
this.maxNodes = options.max_nodes ?? (4096), this.maxSlots = options.max_slots ?? (4096), this.autoFlush = options.auto_flush ?? true, this.writer = new PatchWriter(options.capacity, options.reserve ?? 0), options.dictionaries === true && this.textDictionaries(true);
|
|
1954
|
+
}
|
|
1955
|
+
get context() {
|
|
1956
|
+
return this.contextBits;
|
|
1957
|
+
}
|
|
1958
|
+
get rootTheme() {
|
|
1959
|
+
return this.themeRoot;
|
|
1960
|
+
}
|
|
1961
|
+
styles(definition, compiled) {
|
|
1962
|
+
return styles2(definition, compiled);
|
|
1963
|
+
}
|
|
1964
|
+
props(a, b, c, d, e, f2, g, h) {
|
|
1965
|
+
return props2(a, b, c, d, e, f2, g, h);
|
|
1966
|
+
}
|
|
1967
|
+
environment(environment) {
|
|
1968
|
+
let width = environment.width;
|
|
1969
|
+
this.contextBits = (width > environment.height ? Condition.landscape : Condition.portrait) | Condition.safe | (width >= (640) ? Condition.sm : 0) | (width >= (1024) ? Condition.lg : 0);
|
|
1970
|
+
}
|
|
1971
|
+
tokenValue(theme, id, kind) {
|
|
1972
|
+
let key = theme ?? ROOT_THEME, caches = this.themeBits.get(key);
|
|
1973
|
+
caches === void 0 && (caches = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()], this.themeBits.set(key, caches));
|
|
1974
|
+
let cache = caches[kind], bits = cache.get(id);
|
|
1975
|
+
if (bits === void 0) {
|
|
1976
|
+
let raw = theme?.values.get(id) ?? varDefault(id);
|
|
1977
|
+
if (raw === void 0) throw new GameUiError(`style variable ${id} has no value; define it with defineVars`);
|
|
1978
|
+
bits = tokenBits(kind, raw), cache.set(id, bits);
|
|
1979
|
+
}
|
|
1980
|
+
return bits;
|
|
1981
|
+
}
|
|
1982
|
+
ensureTokens(ids, kinds) {
|
|
1983
|
+
let missing = 0;
|
|
1984
|
+
for (let i = 0; i < ids.length; i++) this.tokenSent.has(ids[i]) || missing++;
|
|
1985
|
+
if (missing !== 0) {
|
|
1986
|
+
this.writer.tokens(false, missing);
|
|
1987
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1988
|
+
let id = ids[i];
|
|
1989
|
+
this.tokenSent.has(id) || (this.tokenSent.add(id), this.tokenIds.push(id), this.tokenKinds.push(kinds[i]), this.writer.pair(id, this.tokenValue(this.themeRoot, id, kinds[i])));
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
theme(theme) {
|
|
1994
|
+
if (theme === this.themeRoot) return;
|
|
1995
|
+
this.themeRoot = theme;
|
|
1996
|
+
let count = this.tokenIds.length;
|
|
1997
|
+
if (count > 0) {
|
|
1998
|
+
this.writer.tokens(true, count);
|
|
1999
|
+
for (let i = 0; i < count; i++) this.writer.pair(this.tokenIds[i], this.tokenValue(theme, this.tokenIds[i], this.tokenKinds[i]));
|
|
2000
|
+
}
|
|
2001
|
+
for (let i = 0; i < this.elements.length; i++) {
|
|
2002
|
+
let element = this.elements[i];
|
|
2003
|
+
element !== void 0 && element.perElement && element.restyle();
|
|
2004
|
+
}
|
|
2005
|
+
this.touched();
|
|
2006
|
+
}
|
|
2007
|
+
allocateSlots(count) {
|
|
2008
|
+
let free = this.freeSlotBlocks.get(count);
|
|
2009
|
+
if (free !== void 0 && free.length > 0) return free.pop();
|
|
2010
|
+
let base = this.slotTop;
|
|
2011
|
+
if (base + count > this.maxSlots) throw new GameUiError(`a game ui holds at most ${this.maxSlots} dynamic style slots`);
|
|
2012
|
+
return this.slotTop = base + count, base;
|
|
2013
|
+
}
|
|
2014
|
+
freeSlots(base, count) {
|
|
2015
|
+
let free = this.freeSlotBlocks.get(count);
|
|
2016
|
+
free === void 0 && (free = [], this.freeSlotBlocks.set(count, free)), free.push(base);
|
|
2017
|
+
}
|
|
2018
|
+
textDictionaries(on) {
|
|
2019
|
+
this.writer.textOptions(on ? UiTextOption.dictionaries : 0), this.touched();
|
|
2020
|
+
}
|
|
2021
|
+
check(element) {
|
|
2022
|
+
if (element.ui !== this) throw new GameUiError("this element belongs to another game ui");
|
|
2023
|
+
if (element.destroyed) throw new GameUiError(`ui element ${element.id} was destroyed`);
|
|
2024
|
+
}
|
|
2025
|
+
touched() {
|
|
2026
|
+
!this.autoFlush || this.scheduled || (this.scheduled = true, queueMicrotask(this.flushTask));
|
|
2027
|
+
}
|
|
2028
|
+
allocate(kind) {
|
|
2029
|
+
let id = this.free.length > 0 ? this.free.pop() : this.next++;
|
|
2030
|
+
if (id >= this.maxNodes) throw new GameUiError(`a game ui holds at most ${this.maxNodes} nodes`);
|
|
2031
|
+
let element = new UiElement(this, id, kind);
|
|
2032
|
+
return this.elements[id] = element, this.writer.create(id, UiKind[kind]), this.touched(), element;
|
|
2033
|
+
}
|
|
2034
|
+
release(element) {
|
|
2035
|
+
this.check(element), this.writer.destroy(element.id), this.touched(), this.forget(element);
|
|
2036
|
+
}
|
|
2037
|
+
forget(element) {
|
|
2038
|
+
element.detach();
|
|
2039
|
+
let kids = element.children.slice();
|
|
2040
|
+
for (let i = 0; i < kids.length; i++) this.forget(kids[i]);
|
|
2041
|
+
this.elements[element.id] = void 0, this.free.push(element.id), element.dispose();
|
|
2042
|
+
}
|
|
2043
|
+
element(id) {
|
|
2044
|
+
return this.elements[id];
|
|
2045
|
+
}
|
|
2046
|
+
box(style) {
|
|
2047
|
+
let element = this.allocate("box");
|
|
2048
|
+
return style !== void 0 && element.style(style), element;
|
|
2049
|
+
}
|
|
2050
|
+
text(content, style, options) {
|
|
2051
|
+
let element = this.allocate("text");
|
|
2052
|
+
return style !== void 0 && element.style(style), content.length > 0 && element.text(content), options?.flowAround !== void 0 && element.flowAround(options.flowAround), element;
|
|
2053
|
+
}
|
|
2054
|
+
fontFor(family, weight = (400)) {
|
|
2055
|
+
let id = typeof family == "number" ? family : this.family(family), best = id, distance = Number.POSITIVE_INFINITY;
|
|
2056
|
+
for (let i = 0; i < this.fontFamilies.length; i++) {
|
|
2057
|
+
if (this.fontFamilies[i] !== id) continue;
|
|
2058
|
+
let gap = Math.abs(this.fontWeights[i] - weight);
|
|
2059
|
+
gap < distance && (distance = gap, best = this.fontIds[i]);
|
|
2060
|
+
}
|
|
2061
|
+
return best;
|
|
2062
|
+
}
|
|
2063
|
+
measureText(text, style = {}, width = 0, out) {
|
|
2064
|
+
let font = this.fontFor(style.fontFamily ?? 0, style.fontWeight ?? (400)), table = fontTable(font);
|
|
2065
|
+
if (table === void 0)
|
|
2066
|
+
throw new GameUiError(`measureText needs the table of render font ${font}; load it with graphics.loadFont before measuring`);
|
|
2067
|
+
return this.measurer.measure(table, text, style, width, out ?? { lines: 0, width: 0, height: 0 });
|
|
2068
|
+
}
|
|
2069
|
+
get measureStats() {
|
|
2070
|
+
return { hits: this.measurer.hits, misses: this.measurer.misses };
|
|
2071
|
+
}
|
|
2072
|
+
image(asset, natural, style) {
|
|
2073
|
+
let element = this.allocate("image");
|
|
2074
|
+
return element.image(asset, natural[0], natural[1]), style !== void 0 && element.style(style), element;
|
|
2075
|
+
}
|
|
2076
|
+
loadVector(asset, bytes) {
|
|
2077
|
+
this.writer.vectorLoad(asset, bytes), this.touched();
|
|
2078
|
+
}
|
|
2079
|
+
unloadVector(asset) {
|
|
2080
|
+
this.writer.vectorUnload(asset), this.touched();
|
|
2081
|
+
}
|
|
2082
|
+
vector(asset, artboard = 0, style) {
|
|
2083
|
+
let element = this.allocate("vector");
|
|
2084
|
+
return element.vector(asset, artboard), style !== void 0 && element.style(style), element;
|
|
2085
|
+
}
|
|
2086
|
+
shape(style, path) {
|
|
2087
|
+
let element = this.allocate("shape");
|
|
2088
|
+
return style !== void 0 && element.style(style), path !== void 0 && element.path(path), element;
|
|
2089
|
+
}
|
|
2090
|
+
scroll(style) {
|
|
2091
|
+
let element = this.allocate("scroll");
|
|
2092
|
+
return style !== void 0 && element.style(style), element;
|
|
2093
|
+
}
|
|
2094
|
+
input(placeholder, style) {
|
|
2095
|
+
let element = this.allocate("input");
|
|
2096
|
+
return style !== void 0 && element.style(style), placeholder.length > 0 && element.placeholder(placeholder), element;
|
|
2097
|
+
}
|
|
2098
|
+
root(element, options = {}) {
|
|
2099
|
+
this.check(element);
|
|
2100
|
+
let offset = options.offset ?? ZERO_PAIR;
|
|
2101
|
+
return this.writer.root(element.id, UiAnchor[options.anchor ?? "top_left"], options.safe_area ?? true, offset[0], offset[1], options.z ?? 0), this.touched(), element;
|
|
2102
|
+
}
|
|
2103
|
+
worldRoot(element, anchor) {
|
|
2104
|
+
return this.check(element), this.writer.worldRoot(element.id, {
|
|
2105
|
+
position: anchor.position,
|
|
2106
|
+
pivot: anchor.pivot ?? PIVOT_BOTTOM_CENTER,
|
|
2107
|
+
offset: anchor.offset ?? ZERO_PAIR,
|
|
2108
|
+
reference_distance: anchor.reference_distance ?? 0,
|
|
2109
|
+
min_scale: anchor.min_scale ?? (0.25),
|
|
2110
|
+
max_scale: anchor.max_scale ?? (2),
|
|
2111
|
+
hide_when_occluded: anchor.hide_when_occluded ?? false,
|
|
2112
|
+
occluded_opacity: anchor.occluded_opacity ?? (0.35),
|
|
2113
|
+
z: anchor.z ?? 0
|
|
2114
|
+
}), this.touched(), element;
|
|
2115
|
+
}
|
|
2116
|
+
unroot(element) {
|
|
2117
|
+
this.check(element), this.writer.unroot(element.id), this.touched();
|
|
2118
|
+
}
|
|
2119
|
+
move(element, x, y, z) {
|
|
2120
|
+
this.check(element), this.writer.anchor(element.id, x, y, z), this.touched();
|
|
2121
|
+
}
|
|
2122
|
+
moveFrom(element, values, offset) {
|
|
2123
|
+
this.check(element), this.writer.anchorFrom(element.id, values, offset), this.touched();
|
|
2124
|
+
}
|
|
2125
|
+
occlude(element, occluded) {
|
|
2126
|
+
this.check(element), this.writer.occluded(element.id, occluded), this.touched();
|
|
2127
|
+
}
|
|
2128
|
+
intern(text) {
|
|
2129
|
+
let known = this.strings.get(text);
|
|
2130
|
+
if (known !== void 0) return known;
|
|
2131
|
+
let id = this.strings.size;
|
|
2132
|
+
return this.strings.set(text, id), this.writer.string(id, text), this.touched(), id;
|
|
2133
|
+
}
|
|
2134
|
+
family(name) {
|
|
2135
|
+
let known = this.families.get(name);
|
|
2136
|
+
if (known !== void 0) return known;
|
|
2137
|
+
let id = this.families.size;
|
|
2138
|
+
return this.families.set(name, id), id;
|
|
2139
|
+
}
|
|
2140
|
+
registerFont(family, font, weight = (400)) {
|
|
2141
|
+
let id = this.family(family), at = -1;
|
|
2142
|
+
for (let i = 0; i < this.fontFamilies.length; i++) this.fontFamilies[i] === id && this.fontWeights[i] === weight && (at = i);
|
|
2143
|
+
return at < 0 ? (this.fontFamilies.push(id), this.fontWeights.push(weight), this.fontIds.push(font)) : this.fontIds[at] = font, this.writer.font(id, weight, font), this.touched(), id;
|
|
2144
|
+
}
|
|
2145
|
+
onPassthrough(listener) {
|
|
2146
|
+
return this.passthrough.push(listener), () => {
|
|
2147
|
+
let at = this.passthrough.indexOf(listener);
|
|
2148
|
+
at >= 0 && this.passthrough.splice(at, 1);
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
flush() {
|
|
2152
|
+
if (this.scheduled = false, this.writer.empty) return 0;
|
|
2153
|
+
let length2 = this.writer.finish();
|
|
2154
|
+
return this.sink.submit(this.writer.bytes, length2), this.writer.reset(), length2;
|
|
2155
|
+
}
|
|
2156
|
+
dispatch(bytes, offset = 0) {
|
|
2157
|
+
let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), handled = 0, stride = 32;
|
|
2158
|
+
for (let at = offset; at + 32 <= bytes.byteLength; at += stride) {
|
|
2159
|
+
readEvent(view, at, this.event), stride = eventStride(this.event.kind, view, at), this.event.text = void 0;
|
|
2160
|
+
let name = EVENT_NAMES[this.event.kind];
|
|
2161
|
+
if (name == null) continue;
|
|
2162
|
+
if (name === "change") {
|
|
2163
|
+
let start = at + 32, end = Math.min(start + this.event.value, bytes.byteLength), text = decoder.decode(bytes.subarray(start, end));
|
|
2164
|
+
this.event.text = text;
|
|
2165
|
+
let target = this.elements[this.event.node];
|
|
2166
|
+
if (target === void 0) continue;
|
|
2167
|
+
target.accept(text), target.emit(name, this.event) && handled++;
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
if (name === "passthrough") {
|
|
2171
|
+
for (let i = 0; i < this.passthrough.length; i++) this.passthrough[i](this.event);
|
|
2172
|
+
handled++;
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
let element = this.elements[this.event.node];
|
|
2176
|
+
element !== void 0 && element.emit(name, this.event) && handled++;
|
|
2177
|
+
}
|
|
2178
|
+
return handled;
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
function collectingSink() {
|
|
2182
|
+
let buffers = [];
|
|
2183
|
+
return {
|
|
2184
|
+
buffers,
|
|
2185
|
+
submit(bytes, length2) {
|
|
2186
|
+
buffers.push(bytes.slice(0, length2));
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
export { BREAKPOINT_LG, BREAKPOINT_SM, CompiledStyle, Condition, GameUi, GameUiError, KEY_NAMES, SLOT_REFERENCE, STYLE_BLOCK_MAGIC, STYLE_BLOCK_VERSION, STYLE_PROPERTY_NAMES, STYLE_RECORD_REFERENCED, STYLE_RECORD_SAFE_EDGES, TextMeasurer, UiElement, UiProps, UiStyleCompileError, VariantKind, collectingSink, compileClasses, compileStyle, conditionPriority, encodeStyleRecords, props2 as props, readBlock, styles2 as styles, tailwindStyle, tailwindVocabulary };
|