@oidoid/void 0.1.0-7 → 0.1.0-8
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/dist/package.json +7 -8
- package/dist/public/index.js +1 -1
- package/dist/public/index.js.map +1 -1
- package/dist/public/{void-v0.1.0-6+20251020.7cdf98d.html → void-v0.1.0-8+20251022.b364155.html} +2 -2
- package/package.json +7 -8
- package/dist/meta.json +0 -1
- package/dist/public/favicon/favicon16.png +0 -0
- package/dist/public/favicon/favicon192.png +0 -0
- package/dist/public/favicon/favicon32.png +0 -0
- package/dist/public/favicon/favicon48.png +0 -0
- package/dist/public/favicon/favicon64.png +0 -0
- package/dist/public/preload-atlas.png +0 -0
- package/dist/public/void-v0.1.0-6+20251020.e4e9eef.html +0 -111
- package/dist/public/void-v0.1.0-7+20251021.7cdf98d.html +0 -111
- package/schema/config-file.test.ts +0 -55
- package/schema/config-file.ts +0 -69
- package/schema/config-file.v0.json +0 -68
- package/tools/atlas-pack/aseprite.ts +0 -60
- package/tools/atlas-pack/atlas-json-parser.test.ts +0 -780
- package/tools/atlas-pack/atlas-json-parser.ts +0 -159
- package/tools/atlas-pack/atlas-pack.ts +0 -51
- package/tools/bundle/bundle.ts +0 -64
- package/tools/bundle/html-plugin.ts +0 -135
- package/tools/types/config.ts +0 -65
- package/tools/types/package-json.ts +0 -4
- package/tools/utils/argv.test.ts +0 -41
- package/tools/utils/argv.ts +0 -29
- package/tools/utils/exec.ts +0 -22
- package/tools/utils/file-util.ts +0 -11
- package/tools/utils/html-parser.ts +0 -9
- package/tools/void.ts +0 -55
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang=en><head>
|
|
3
|
-
<meta charset=utf-8>
|
|
4
|
-
<title>void</title>
|
|
5
|
-
<link href="data:image/webp;base64,UklGRmYAAABXRUJQVlA4TFoAAAAvD8ADEA4HbRsJEqYD+jSfyMzuUohaKRIIJDRh7G8yh0AgUUp5uTn6PwEc/5/kIwBZf6VNA+lu1ZBea67ULpla6waQpPYGYn2ofbA+1G5H63JpH6whNzVArgE=" rel=icon sizes=16x16 type=image/webp>
|
|
6
|
-
<link rel=manifest href=data:application/json,%7B%22author%22%3A%22oidoid%22%2C%22background_color%22%3A%22%23ffffb1%22%2C%22description%22%3A%22void%202D%20game%20library%20demo.%22%2C%22display%22%3A%22standalone%22%2C%22homepage_url%22%3A%22https%3A%2F%2Foidoid.com%2F%22%2C%22icons%22%3A%5B%7B%22src%22%3A%22data%3Aimage%2Fwebp%3Bbase64%2CUklGRmYAAABXRUJQVlA4TFoAAAAvD8ADEA4HbRsJEqYD%2BjSfyMzuUohaKRIIJDRh7G8yh0AgUUp5uTn6PwEc%2F5%2FkIwBZf6VNA%2Blu1ZBea67ULpla6waQpPYGYn2ofbA%2B1G5H63JpH6whNzVArgE%3D%22%2C%22sizes%22%3A%2216x16%22%2C%22type%22%3A%22image%2Fwebp%22%7D%2C%7B%22src%22%3A%22data%3Aimage%2Fwebp%3Bbase64%2CUklGRoIAAABXRUJQVlA4THYAAAAvH8AHEA4HbSNJEqYFejSPyHy7PQRaFSkSCCQ0YexvModAIFFKebk5%2Bj8Bffz%2F5QNJv%2FpOtn81hQSSGgmHCk5rJLyumtziFCplUxUUtFYvMwWFO8ZEQW8ChZsU9CZQqHWqoJXeVLhJQSt0J%2B%2BAJt0VuvN6L78B%22%2C%22sizes%22%3A%2232x32%22%2C%22type%22%3A%22image%2Fwebp%22%7D%2C%7B%22src%22%3A%22data%3Aimage%2Fwebp%3Bbase64%2CUklGRowAAABXRUJQVlA4TIAAAAAvL8ALEFUwbttGUk1T6LY5hVya04N9OoBAIMmfZrgBBAJJEPur3n9Gbts4km6asn0f4WkzaPqITIQbVYgJv%2BotBYIK9TTmbAucsARd2SKEB8APVI7JV4sfqBZLHxcEXYZLIb8Bznfy75bNyVmLpb8T5GcAWQLbGwIXCWzHFm0rYA%3D%3D%22%2C%22sizes%22%3A%2248x48%22%2C%22type%22%3A%22image%2Fwebp%22%7D%2C%7B%22src%22%3A%22data%3Aimage%2Fwebp%3Bbase64%2CUklGRnYAAABXRUJQVlA4TGkAAAAvP8APEB8gECD8WdCvSSBAyHDjf0SHQIDQ58a0jvkPwN%2BUgYM2khypSTbJIlmXPjaBiP5PQF62Lc2b%2F9RHldKF8izqQnlbO6Uy0rsiriRJW2QpqTiGjIljyMpLceRNGRMH0newGUjfzgAA%22%2C%22sizes%22%3A%2264x64%22%2C%22type%22%3A%22image%2Fwebp%22%7D%2C%7B%22src%22%3A%22data%3Aimage%2Fwebp%3Bbase64%2CUklGRp4AAABXRUJQVlA4TJEAAAAvv8AvEB8gECD8WdCvSSBAyHDjf0SHQIDQ58a0jvkPwN%2BUAZNIkiSNyTJZJovcz25QRP8nYB7nsgrMy38fD3auAiqwFQCfrdTOtwLgJzvkcFt0rq4H7naoVmq1IeYy52qlbotjoFKrtaFW6tqo1GptqJW6IR6u1Go9vFqpa6NSq5UwM8BbagXM4T6YGT45lzcBAA%3D%3D%22%2C%22sizes%22%3A%22192x192%22%2C%22type%22%3A%22image%2Fwebp%22%7D%5D%2C%22manifest_version%22%3A3%2C%22name%22%3A%22void%22%2C%22orientation%22%3A%22any%22%2C%22short_name%22%3A%22void%22%2C%22start_url%22%3A%22https%3A%2F%2Foidoid.com%2F%22%2C%22theme_color%22%3A%22%23ffffb1%22%2C%22version%22%3A%220.1.0-7%22%7D>
|
|
7
|
-
</head>
|
|
8
|
-
<body style=background-color:#ffffb1>
|
|
9
|
-
<img alt="" id=preload-atlas style=display:none src=data:image/webp;base64,UklGRuIDAABXRUJQVlA4TNYDAAAvT8AQELVIamzbtpXXo40FHFwBBIWvjw6CGAQQHCCAc9acc+37ELA6O5l8F9/uOmoiWa1ehzh0YAAPCMEBNujTpYyB32szo6iRpKj3kLDi1sp6QA4ueKIH5hD/riVJCpqF3INibu6QTb6h+LhRq7oS4+3MU7PCMTVDExA9Vu2+UT+AXd2CNwL1rHBMv1/nx88uluBGxfHpcwB+0s8wKe8zeY8xaY6MblQxzgVhUt7nwZf79zUrHNeZoCCB0nmzf4bJeB+rXudY4pi9pzHBIdbX4+YRwmS8va9rX0sc3tsNCYLoY2cIU/PnOWQYpRDipHVfl2l/5+RonsXeAwmyobsPAe+EfYYsdP9HcGGCVOj+WcgVuItyBlVIILgwQSZ0RdWuyDuYgPDWQJYJxQNXV+VCoabgGNIEwNPNEtjnWkiQCVXnDNzACwyVZqlwjyQQx/IIoFWfEVglXKrlDFyMX/qMrAu/5jvNoj7AhfzrCeJb0t9lFtW3TSV9JqXrmtn5LMDFuLXPJOq6rt09k85CuJBf+0yiLh/as5LFQZXhnmxd13Xiz0KW69pbhAn+Aj6TC42Zdqey+NQu5le192YJMnXVnAq8wC/6dAKP9p2M/1CfKgTELL03ZuFczXynRYKNHKS+cpUNddaQLISL+Qsw5BIQrgACKNAgkqUiUBN/sRNeQ5mUIXVTdYNcqfEAlsM3AYFduK6QoIw2R/oJIA9A1RS/TuiDEJ/CG0sVnTCZ/Px3f+ekNhV/FCgyBPWu5y88/ySBi65fEO+7bSY8/5CArRekZNqZTXYRvUoOnlPiS0sj3MvL9ik4p9SXSHMZpEkew7qQRrJUvfD9622sA36F/sK+3dkdRKpEh0DgV+BLAXlFvEq2nui19f9wTDf4kpKTQVUphT62w2HYW+yMS7z8VIWykP1G7+AB8aC6uu43xHrG4vpbzQ5qN3tLBLMJLgCJ9fY96lVLqcKtJG5+Vy32yLIb7MSn7NCVkHxfKm9Gpg7qTHBqffay4IiQbKl8J3UD7+AifMHdh67RalcTVKJhiXWkZ7F16Sqzu5BbJ1pAgLR5SKDyilRQHdJinVNPZZT1YqGyE1vo1TfCar2mSmEsvbFiLQvaD2zBkpdrBQhgE+c+t5f6KWb4ApmQhmCtfPniQFAlXJnwyYOoi2Y7a9F/GhKd8NKvPsmVN/GF8suKgK7DwNupqMQrj40UuyW/MAGpCZzeHrE8YihrlqXicxZ/ilKB0ZsVmA+H7nNZ/IStXX4Cd78PLaVSjp7/7a77feRuhY1/yp8nq1Bw+QlmhsOiuieYn1u4V/EF>
|
|
10
|
-
<script type=module async>var o={published:"20251021",version:"0.1.0-7"};var _=o;var Q={id:"mem-prop-5x6",name:"mem 5x6",cellWidth:5,cellHeight:6,leading:1,lineHeight:7,baseline:1,kerning:{" 0":0," 1":0," 2":0," 3":0," 4":0," 5":0," 6":0," 7":0," 8":0," 9":0,"##":-1,"#_":0,"',":0,"'.":0,"'/":0,"'J":0,"'S":0,"'_":0,"'j":0,"'s":0,"(+":0,"(-":0,"(<":0,"(f":0,"({":0,"(~":0,")_":0,"*,":0,"*.":0,"*/":0,"*S":0,"*_":0,"*j":0,"*s":0,"+)":0,"+,":0,"+.":0,"+/":0,"+>":0,"+?":0,"+I":0,"+S":0,"+T":0,"+Z":0,"+]":0,"+_":0,"+`":0,"+j":0,"+s":0,"+}":0,",'":0,",*":0,",+":0,",-":0,",<":0,",?":0,",T":0,",Y":0,",Z":0,',"':0,",\\":0,",^":0,",`":0,",f":0,",t":0,",z":0,",{":0,",~":0,"-)":0,"-,":0,"--":0,"-.":0,"-/":0,"->":0,"-?":0,"-I":0,"-S":0,"-T":0,"-Z":0,"-]":0,"-_":0,"-`":0,"-j":0,"-s":0,"-}":0,".'":0,".*":0,".+":0,".-":0,".<":0,".?":0,".T":0,".Y":0,".Z":0,'."':0,".\\":0,".^":0,".`":0,".f":0,".t":0,".z":0,".{":0,".~":0,"/,":0,"/.":0,"//":0,"/J":0,"/S":0,"/_":0,"/j":0,"/s":0,"0 ":0,"1 ":0,"1T":0,"1Y":0,"1Z":0,"1f":0,"1t":0,"1z":0,"2 ":0,"3 ":0,"4 ":0,"5 ":0,"6 ":0,"7 ":0,"8 ":0,"9 ":0,":?":0,":T":0,":Z":0,":`":0,";?":0,";T":0,";Z":0,"<+":0,"<-":0,"<<":0,"<f":0,"<{":0,"<~":0,"==":0,"=_":0,">)":0,">,":0,">.":0,">/":0,">>":0,">?":0,">I":0,">S":0,">T":0,">Z":0,">]":0,">_":0,">`":0,">j":0,">s":0,">}":0,"?,":0,"?.":0,"?/":0,"?S":0,"?_":0,"?j":0,"?s":0,"@_":0,"C+":0,"C-":0,"C<":0,Cf:0,"C{":0,"C~":0,D_:0,"E+":0,"E-":0,"E<":0,Ef:0,"E{":0,"E~":0,"F&":0,"F+":0,"F,":0,"F-":0,"F.":0,"F/":0,"F:":0,"F;":0,"F<":0,FJ:0,FS:0,F_:0,Fa:0,Fe:0,Ff:0,Fg:0,Fj:0,Fq:0,Fs:0,"F{":0,"F~":0,"I+":0,"I-":0,"I<":0,If:0,"I{":0,"I~":0,"L'":0,"L*":0,"L+":0,"L-":0,L4:0,L7:0,"L<":0,"L?":0,LT:0,LY:0,LZ:0,'L"':0,"L\\":0,"L^":0,"L`":0,Lf:0,Lt:0,Lz:0,"L{":0,"L~":0,"P,":0,"P.":0,"P/":0,PS:0,P_:0,Pj:0,Ps:0,"S&":0,"S+":0,"S,":0,"S-":0,"S.":0,"S/":0,"S:":0,"S;":0,"S<":0,SJ:0,SS:0,S_:0,Sa:0,Se:0,Sf:0,Sg:0,Sj:0,Sq:0,Ss:0,"S{":0,"S~":0,"T&":0,"T+":0,"T,":0,"T-":0,"T.":0,"T/":0,"T:":0,"T;":0,"T<":0,TJ:0,TS:0,T_:0,Ta:0,Te:0,Tf:0,Tg:0,Tj:0,Tq:0,Ts:0,"T{":0,"T~":0,V_:0,"Y,":0,"Y.":0,"Y/":0,YS:0,Y_:0,Yj:0,Ys:0,"Z'":0,"Z*":0,"Z+":0,"Z-":0,Z4:0,Z7:0,"Z<":0,"Z?":0,ZT:0,ZY:0,ZZ:0,'Z"':0,"Z\\":0,"Z^":0,"Z`":0,Zf:0,Zt:0,Zz:0,"Z{":0,"Z~":0,"[+":0,"[-":0,"[<":0,"[f":0,"[{":0,"[~":0,'",':0,'".':0,'"/':0,'"J':0,'"S':0,'"_':0,'"j':0,'"s':0,"\\'":0,"\\*":0,"\\+":0,"\\-":0,"\\<":0,"\\?":0,"\\T":0,"\\Y":0,"\\Z":0,'\\"':0,"\\\\":0,"\\^":0,"\\`":0,"\\f":0,"\\t":0,"\\z":0,"\\{":0,"\\~":0,"^,":0,"^.":0,"^/":0,"^J":0,"^S":0,"^_":0,"^j":0,"^s":0,"_#":0,"_%":0,"_'":0,"_(":0,"_*":0,"_+":0,"_-":0,"_<":0,"_=":0,"_?":0,"_@":0,_T:0,_V:0,_Y:0,_Z:0,'_"':0,"_\\":0,"_^":0,__:0,"_`":0,_a:0,_e:0,_f:0,_t:0,_v:0,_z:0,"_{":0,"_~":0,"`,":0,"`.":0,"`/":0,"`J":0,"`S":0,"`_":0,"`j":0,"`s":0,"f,":0,"f.":0,"f/":0,fS:0,f_:0,fj:0,fs:0,"q#":0,q$:0,"q%":0,"q&":0,"q'":0,"q(":0,"q*":0,"q+":0,"q-":0,q0:0,q1:0,q2:0,q3:0,q4:0,q5:0,q6:0,q7:0,q8:0,q9:0,"q<":0,"q=":0,"q?":0,"q@":0,qA:0,qB:0,qC:0,qD:0,qE:0,qF:0,qG:0,qH:0,qI:0,qJ:0,qK:0,qL:0,qM:0,qN:0,qO:0,qP:0,qQ:0,qR:0,qS:0,qT:0,qU:0,qV:0,qW:0,qX:0,qY:0,qZ:0,"q[":0,'q"':0,"q\\":0,"q]":0,"q^":0,"q`":0,qa:0,qb:0,qc:0,qd:0,qe:0,qf:0,qh:0,qk:0,qm:0,qn:0,qo:0,qq:0,qr:0,qs:0,qt:0,qu:0,qv:0,qw:0,qx:0,qz:0,"q{":0,"q}":0,"q~":0,"r,":0,"r.":0,"r/":0,rS:0,r_:0,rj:-1,rs:0,"s,":0,"s.":0,"s/":0,sJ:0,sS:0,s_:0,sj:0,ss:0,"z'":0,"z*":0,"z+":0,"z-":0,z4:0,z7:0,"z<":0,"z?":0,zT:0,zY:0,zZ:0,'z"':0,"z\\":0,"z^":0,"z`":0,zf:0,zt:0,zz:0,"z{":0,"z~":0,"{+":0,"{-":0,"{<":0,"{f":0,"{{":0,"{~":0,"})":0,"},":0,"}.":0,"}/":0,"}>":0,"}?":0,"}I":0,"}S":0,"}T":0,"}Z":0,"}]":0,"}_":0,"}`":0,"}j":0,"}s":0,"}}":0,"~'":0,"~?":0,"~T":0,"~Z":0,'~"':0,"~\\":0,"~^":0,"~_":0,"~`":0,"~t":0,"~z":0},defaultKerning:1,defaultWhitespaceKerning:-1,endOfLineKerning:0,charWidth:{" ":4,"!":1,"#":5,"&":4,"'":1,"(":2,")":2,",":1,".":1,":":1,";":1,"@":5,M:5,W:5,"[":2,"\n":0,"]":2,"`":2,i:1,l:1,m:5,q:4,w:5,"|":1},defaultCharWidth:3};var C=Q;var h={Top:0,UIA:1,UIB:2,UIC:3,UID:4,UIE:5,UIF:6,UIG:7,A:8,B:9,C:10,D:11,E:12,F:13,Bottom:14,Hidden:15};function B(i,e){return Math.max(h.Top,Math.min(h.Bottom,i+e))}function x(i,e){let t={w:e.w??1,h:e.h??1};if(!i.w||!i.h||!t.w||!t.h)return!1;let r={x:i.x??0,y:i.y??0};return r.x<e.x+t.w&&r.x+i.w>e.x&&r.y<e.y+t.h&&r.y+i.h>e.y}function ee(i,e){i.w=e.w,i.h=e.h}function g(i,e){return i.w===e.w&&i.h===e.h}function te(i,e){return{x:i.x+e.x,y:i.y+e.y}}function ie(i,e){i.x=e.x,i.y=e.y}function re(i,e){return _e($(i,e))}function f(i,e){return i.x===e.x&&i.y===e.y}function _e(i){return Math.hypot(i.x,i.y)}function ne(i,e){return{x:Math.max(i.x,e.x),y:Math.max(i.y,e.y)}}function se(i,e){return{x:Math.min(i.x,e.x),y:Math.min(i.y,e.y)}}function $(i,e){return{x:i.x-e.x,y:i.y-e.y}}var b=class{#e;#t;#i=!0;constructor(e,t){this.#e={w:e.sprites.alloc(),nw:e.sprites.alloc(),n:e.sprites.alloc(),ne:e.sprites.alloc(),e:e.sprites.alloc(),se:e.sprites.alloc(),s:e.sprites.alloc(),sw:e.sprites.alloc(),origin:e.sprites.alloc()},this.#e.w.tag=t.w?.tag??t.e?.tag??t.n.tag,this.#e.n.tag=t.n.tag,this.#e.e.tag=t.e?.tag??this.#e.w.tag,this.#e.s.tag=t.s?.tag??this.#e.n.tag,this.#e.nw.tag=t.nw?.tag??t.se?.tag??t.n.tag,this.#e.ne.tag=t.ne?.tag??t.sw?.tag??t.nw?.tag??t.n.tag,this.#e.se.tag=t.se?.tag??this.#e.nw.tag,this.#e.sw.tag=t.sw?.tag??this.#e.ne.tag,this.#e.origin.tag=t.origin.tag,this.#e.w.z=this.#e.nw.z=this.#e.n.z=this.#e.ne.z=this.#e.e.z=this.#e.se.z=this.#e.s.z=this.#e.sw.z=this.#e.origin.z=t.z??0,this.#e.w.stretch=t.w?.stretch??t.e?.stretch??!1,this.#e.n.stretch=t.n.stretch??t.s?.stretch??!1,this.#e.e.stretch=t.e?.stretch??this.#e.w.stretch,this.#e.s.stretch=t.s?.stretch??this.#e.n.stretch,this.#e.nw.stretch=t.nw?.stretch??t.se?.stretch??!1,this.#e.ne.stretch=t.ne?.stretch??t.sw?.stretch??!1,this.#e.se.stretch=t.se?.stretch??this.#e.nw.stretch,this.#e.sw.stretch=t.sw?.stretch??this.#e.ne.stretch,this.#e.origin.stretch=t.origin.stretch??!1,this.#e.w.flipX=t.w?.flip?.x??!t.e?.flip?.x,this.#e.w.flipY=t.w?.flip?.y??!!t.e?.flip?.y,this.#e.n.flipX=t.n.flip?.x??!!t.s?.flip?.x,this.#e.n.flipY=t.n.flip?.y??!t.s?.flip?.y,this.#e.e.flipX=t.e?.flip?.x??!this.#e.w.flipX,this.#e.e.flipY=t.e?.flip?.y??this.#e.w.flipY,this.#e.s.flipX=t.s?.flip?.x??this.#e.n.flipX,this.#e.s.flipY=t.s?.flip?.y??!this.#e.n.flipY,this.#e.origin.flipX=!!t.origin.flip?.x,this.#e.origin.flipY=!!t.origin.flip?.y,this.#e.n.h=t.border?.n??t.border?.s??this.#e.n.h,this.#e.w.w=t.border?.w??t.border?.e??this.#e.n.h,this.#e.e.w=t.border?.e??this.#e.w.w,this.#e.s.h=t.border?.s??this.#e.n.h,this.#e.nw.w=this.#e.w.w,this.#e.nw.h=this.#e.n.h,this.#e.ne.w=this.#e.e.w,this.#e.ne.h=this.#e.n.h,this.#e.se.w=this.#e.e.w,this.#e.se.h=this.#e.s.h,this.#e.sw.w=this.#e.w.w,this.#e.sw.h=this.#e.s.h,this.#t={w:t.margin?.w??0,h:t.margin?.h??0};let r=t.wh?.w==null?this.#e.w.w+this.#e.n.w+this.#e.e.w:t.wh.w;this.#e.n.w=r-1,this.wh={w:r,h:t.wh?.h==null?this.#e.n.h+this.#e.e.h+this.#e.s.h:t.wh.h},this.#e.nw.x=(t.x??0)-1,this.xy={x:t.x??0,y:t.y??0}}free(e){e.sprites.free(this.#e.w,this.#e.nw,this.#e.n,this.#e.ne,this.#e.e,this.#e.se,this.#e.s,this.#e.sw,this.#e.origin)}update(){if(this.#i)return this.#i=!1,!0}get wh(){return{w:this.#e.w.w+this.#e.n.w+this.#e.e.w+this.#t.w,h:this.#e.n.h+this.#e.w.h+this.#e.s.h+this.#t.h}}set wh(e){g(e,this.wh)||(this.#e.w.h=e.h-this.#e.n.h-this.#e.s.h-this.#t.h,this.#e.n.w=e.w-this.#e.w.w-this.#e.e.w-this.#t.w,this.#e.s.w=this.#e.n.w,this.#e.e.h=this.#e.w.h,this.#e.origin.w=this.#e.n.w,this.#e.origin.h=this.#e.e.h,this.#r(),this.#i=!0)}get xy(){return{x:this.#e.nw.x-this.#t.w/2,y:this.#e.nw.y-this.#t.h/2}}set xy(e){f(e,this.xy)||(this.#e.nw.x=e.x+this.#t.w/2,this.#e.nw.y=e.y+this.#t.h/2,this.#e.w.x=this.#e.nw.x,this.#e.w.y=this.#e.nw.y+this.#e.nw.h,this.#e.n.x=this.#e.nw.x+this.#e.nw.w,this.#e.n.y=this.#e.nw.y,this.#e.origin.x=this.#e.n.x,this.#e.origin.y=this.#e.nw.y+this.#e.ne.h,this.#r(),this.#i=!0)}#r(){this.#e.ne.x=this.#e.n.x+this.#e.n.w,this.#e.ne.y=this.#e.nw.y,this.#e.e.x=this.#e.ne.x,this.#e.e.y=this.#e.nw.y+this.#e.ne.h,this.#e.se.x=this.#e.e.x,this.#e.se.y=this.#e.e.y+this.#e.e.h,this.#e.s.x=this.#e.n.x,this.#e.s.y=this.#e.se.y,this.#e.sw.x=this.#e.nw.x,this.#e.sw.y=this.#e.se.y}};function oe(i,e){let t=e.codePointAt(0);return(t==null||t>255)&&(t=63),`${i.id}--${t.toString(16).padStart(2,"0")}`}function ae(i,e,t){return t==null?i.endOfLineKerning:i.kerning[e+t]!=null?i.kerning[e+t]:/^\s?$/.test(e)||/^\s?$/.test(t)?i.defaultWhitespaceKerning:i.defaultKerning}function j(i,e){return i.charWidth[e]??i.defaultCharWidth}function le(i){let e=[],t=i.scale??1,r=i.start??{x:0,y:0},n=i.maxW??1/0,s={x:r.x,y:r.y},a=0;for(;e.length<i.str.length;){let d=e.length,m=i.str[d],u;m===`
|
|
11
|
-
`?u=Be(i.font,s,r.x,t):/^\s*$/.test(m)?u=Ye(i.font,s,n,de(i.font,m,i.str[d+1],t),r.x,t):(u=he(i.font,s,n,i.str,d,r.x,t),s.x>0&&u.cursor.y===w(i.font,r.x,s.y,t).y&&n-s.x+u.cursor.x<=n&&(s=w(i.font,r.x,s.y,t),u=he(i.font,s,n,i.str,d,r.x,t))),e.push(...u.chars),s.x=u.cursor.x,s.y=u.cursor.y,a=Math.max(a,u.cursor.x-r.x)}return{chars:e,cursor:s,wh:{w:a,h:w(i.font,r.x,s.y,t).y-r.y}}}function he(i,e,t,r,n,s,a){let d=[],{x:m,y:u}=e;for(;;n++){let p=r[n];if(!p||/^\s*$/.test(p))break;let S=de(i,p,r[n+1],a);m>s&&m+S>s+t&&({x:m,y:u}=w(i,s,u,a)),d.push({x:m,y:u,w:j(i,p),h:i.cellHeight}),m+=S}return{chars:d,cursor:{x:m,y:u}}}function w(i,e,t,r){return{x:e,y:t+i.lineHeight*r}}function Be(i,e,t,r){return{chars:[void 0],cursor:w(i,t,e.y,r)}}function Ye(i,e,t,r,n,s){let a=e.x>0&&e.x+r>=t?w(i,n,e.y,s):{x:e.x+r,y:e.y};return{chars:[void 0],cursor:a}}function de(i,e,t,r){return r*(j(i,e)+ae(i,e,t))}var y=class{#e=1/0;#t="Outdated";#i=h.UIA;#r=1;#s=[];#n="";#o={w:0,h:0};#a={x:0,y:0};free(e){e.sprites.free(...this.#s)}layout(e){if(this.#t!=="Outdated")return!1;let t=0,r=le({font:C,maxW:this.#e,scale:this.#r,start:this.#a,str:this.#n});this.#o={w:r.wh.w,h:r.wh.h};for(let[n,s]of r.chars.entries()){if(s==null)continue;let a=this.#s[t]??=e.sprites.alloc();a.x=s.x,a.y=s.y,a.tag=oe(C,this.#n[n]),a.stretch=!0,a.w*=this.#r,a.h*=this.#r,a.z=this.#i,t++}for(;this.#s.length>t;)e.sprites.free(this.#s.pop());return this.#t="Updated",!0}get maxW(){return this.#e}set maxW(e){e!==this.#e&&(this.#e=e,this.#t="Outdated")}get scale(){return this.#r}set scale(e){e!==this.#r&&(this.#r=e,this.#t="Outdated")}get text(){return this.#n}set text(e){e!==this.#n&&(this.#n=e,this.#t="Outdated")}update(e){if(this.#t!=="Rendered")return this.#t==="Outdated"&&this.layout(e),this.#t="Rendered",!0}get scaledLeading(){return C.leading*this.#r}get wh(){return this.#o}get xy(){return this.#a}set xy(e){f(e,this.#a)||(this.#a.x=e.x,this.#a.y=e.y,this.#t="Outdated")}get z(){return this.#i}set z(e){e!==this.#i&&(this.#i=e,this.#t="Outdated")}};var Y=class{#e;#t=!0;#i;#r;#s=!1;#n=!1;#o=new y;#a={x:0,y:0};constructor(e,t){let r=t.button.z??h.UID;this.#e=new b(e,{...t.button,x:t.x,y:t.y,z:r,wh:{w:t.w,h:t.h}}),this.#i={sprite:e.sprites.alloc(),z:t.pressed.z??B(r,2)},this.#r={sprite:e.sprites.alloc(),z:t.selected.z??B(this.#i.z,-1)},this.#i.sprite.tag=t.pressed.tag,this.#i.sprite.x=t.x??0,this.#i.sprite.y=t.y??0,this.#i.sprite.w=t.w??this.#e.wh.w,this.#i.sprite.h=t.h??this.#e.wh.h,this.#i.sprite.z=h.Hidden,this.#r.sprite.tag=t.selected.tag,this.#r.sprite.x=t.x??0,this.#r.sprite.y=t.y??0,this.#r.sprite.w=t.w??this.#e.wh.w,this.#r.sprite.h=t.h??this.#e.wh.h,this.#r.sprite.z=h.Hidden,this.#o.text=t.text?.text??"",this.#o.scale=t.text?.scale??1,this.#o.layout(e),this.#l(e),this.#o.maxW=t.w??this.#e.wh.w,this.#o.z=t.text?.z??B(r,-1),this.#n=t.toggle??!1}get selected(){return this.#r.z!==h.Hidden}free(e){this.#e.free(e),this.#o.free(e),e.sprites.free(this.#r.sprite,this.#i.sprite)}get on(){return this.#i.sprite.z!==h.Hidden}set on(e){this.#i.sprite.z=e?this.#i.z:h.Hidden}get onStart(){return this.on&&this.#s}set text(e){this.#o.text=e}update(e){let t=this.#t;this.#e.update()&&(t=!0),this.#o.update(e)&&(t=!0);let r=!e.input.handled&&!!e.zoo.cursor?.hits(e,this.#r.sprite,"UI"),s=r&&e.input.isOnStart("Click")||e.zoo.cursor?.keyboard&&e.input.isOnStart("A")?this.#n?!this.on:!0:this.#n?this.on:e.input.isOn("Click")||!!e.zoo.cursor?.keyboard&&e.input.isOn("A");return this.#s=this.on!==s,this.#s&&(this.on=s,t=!0),r&&(e.input.point?.click||e.input.point?.type==="Mouse")?(t||=this.#r.sprite.z!==this.#r.z,this.#r.sprite.z=this.#r.z):(t||=this.#r.sprite.z!==h.Hidden,this.#r.sprite.z=h.Hidden),e.input.handled||=r,this.#t=!1,t}setXY(e,t){f(t,this.#a)||(this.#a.x=t.x,this.#a.y=t.y,this.#e.xy=t,this.#l(e),this.#i.sprite.xy=t,this.#r.sprite.xy=t,this.#t=!0)}#l(e){this.#o.layout(e),this.#o.xy={x:this.#e.xy.x+this.#e.wh.w/2-this.#o.wh.w/2,y:this.#e.xy.y+this.#e.wh.h/2-(this.#o.wh.h-this.#o.scaledLeading)/2}}};var v=class{keyboard=!1;#e;#t;#i;constructor(e,t,r){this.#i=t,this.#t=r??this.#i,this.#e=e.sprites.alloc(),this.#e.tag=t,this.#e.z=h.Hidden}free(e){e.sprites.free(this.#e)}hitbox(e,t){let r=t==="Level",n=this.#e.hitbox;if(!n)throw Error("cursor has no hitbox");return{x:(r?e.cam.x:0)+n.x,y:(r?e.cam.y:0)+n.y,w:n.w,h:n.h}}hits(e,t,r){return this.visible&&x(this.hitbox(e,r),t)}update(e){if(e.input.point?.invalid)return this.#e.tag=e.input.point.click?this.#t:this.#i,this.#e.xy=e.input.point.local,this.#e.z=e.input.point?.type==="Mouse"?h.Top:h.Hidden,!0;if(this.keyboard&&e.input.isAnyOn("L","R","U","D"))return e.input.isOn("L")&&(this.#e.x-=1),e.input.isOn("R")&&(this.#e.x+=1),e.input.isOn("U")&&(this.#e.y-=1),e.input.isOn("D")&&(this.#e.y+=1),this.#e.z=h.Top,!0}get visible(){return this.#e.z!==h.Hidden}};var A=class{#e;#t=!0;#i={w:0,h:0};#r={x:0,y:0};#s;#n;constructor(e,t,r){this.#n=e.sprites.alloc(),this.#n.tag=t,this.#s=r}get fill(){return this.#e}set fill(e){this.#e!==e&&(this.#e=e,this.#t=!0)}free(e){e.sprites.free(this.#n)}get h(){return this.#n.h}set h(e){this.#n.h!==e&&(this.#n.h=e,this.#t=!0)}get margin(){return this.#i}set margin(e){g(e,this.#i)||(ee(this.#i,e),this.#t=!0)}get modulo(){return this.#r}set modulo(e){f(e,this.#r)||(ie(this.#r,e),this.#t=!0)}get pivot(){return this.#s}set pivot(e){this.#s!==e&&(this.#s=e,this.#t=!0)}update(e){if(!this.#t&&!e.cam.invalid)return;let t=e.cam.follow({w:this.#n.w,h:this.#n.h},this.#n.z,this.#s,{fill:this.#e,modulo:this.#r,margin:this.#i});return this.#n.x=t.x,this.#n.y=t.y,this.#t=!1,!0}get w(){return this.#n.w}set w(e){this.#n.w!==e&&(this.#n.w=e,this.#t=!0)}get z(){return this.#n.z}set z(e){this.#n.z=e}};var l=Ae(globalThis.location?.href);function Ae(i){if(!i)return;let e=[...new URL(i).searchParams].find(([s])=>s.toLowerCase()==="debug")?.[1];if(e==null)return;let t=Object.fromEntries(e.split(",").filter(Boolean).map(s=>s.split("="))),r={};for(let s in t)r[s.toLowerCase()]=t[s]||"true";let n={cam:void 0,input:void 0,mem:void 0,render:void 0};return new Proxy(r,{get(s,a){if(typeof a!="string"||(a=a.toLowerCase(),s[a]))return s[a];if(!e||"all"in t||a in n&&"void"in t)return"true"}})}var M=class{#e;#t=new Set;#i=!1;add(...e){for(let t of e)this.#t.add(t),t instanceof v&&(this.#e=t)}clear(){this.#e=void 0,this.#t.clear()}get cursor(){return this.#e}get invalid(){return this.#i}remove(...e){for(let t of e)this.#t.delete(t),t===this.#e&&(this.#e=void 0)}update(e){this.#i=!1;for(let t of this.#t)t.update?.(e)&&(!this.#i&&l?.invalid&&console.debug("ent update invalid",t),this.#i=!0)}};function me(i){return{anim:i.anim,celXYWH:Me(i),tags:Object.keys(i.anim)}}function Me(i){let e=[],t=0;for(let r of Object.values(i.anim))e.push(...Xe(r,i.celXY,t)),t+=r.cels*2;return e}function Xe(i,e,t){let r=[];for(let n=0;n<16;n++){let s=t+2*(n%i.cels);r.push(e[s],e[s+1],i.w,i.h)}return r}var X=class{#e=0;#t=1;#i=!0;#r=1;#s={w:1/0,h:1/0};#n="Int";#o=1;#a=1;#l={w:1,h:1};#h=0;#u=0;#d=0;center(e){this.x=Math.floor(e.x-this.w/2),this.y=Math.floor(e.y-this.h/2)}clientToXY(e){let t=this.clientToXYLocal(e);return{x:this.#h+t.x,y:this.#u+t.y}}clientToXYLocal(e){return{x:e.x/this.#l.w*this.#a,y:e.y/this.#l.h*this.#t}}follow(e,t,r,n){let s=n?.margin?.w??0,a=t>h.UIG?Math.trunc(this.x):0;switch(r){case"SW":case"W":case"NW":a+=s;break;case"SE":case"E":case"NE":a+=this.w-(e.w+s);break;case"N":case"S":case"Origin":a+=Math.trunc(this.w/2)-Math.trunc(e.w/2);break}a-=a%((n?.modulo?.x??a)||1);let d=n?.margin?.h??0,m=t>h.UIG?Math.trunc(this.y):0;switch(r){case"N":case"NE":case"NW":m+=d;break;case"SE":case"S":case"SW":m+=this.h-(e.h+d);break;case"E":case"W":case"Origin":m+=Math.trunc(this.h/2)-Math.trunc(e.h/2);break}m-=m%((n?.modulo?.y??m)||1);let u=n?.fill==="X"||n?.fill==="XY"?this.w-2*s:e.w,p=n?.fill==="Y"||n?.fill==="XY"?this.h-2*d:e.h;return{x:a,y:m,w:u,h:p}}get h(){return this.#t}isVisible(e){return x(this,e)}get invalid(){return this.#i}get minScale(){return this.#r}set minScale(e){this.#o!==e&&(this.#o=e,this.#m())}get minWH(){return this.#s}set minWH(e){this.#s.w===e.w&&this.#s.h===e.h||(this.#s.w=e.w,this.#s.h=e.h,this.#m())}get mode(){return this.#n}set mode(e){this.#n!==e&&(this.#n=e,this.#m())}get portrait(){return this.h>this.w}postupdate(){this.#i=!1}get scale(){return this.#o}toString(){return`Cam{(${this.x} ${this.y}) ${this.w}\xD7${this.h}}`}update(e){if(!e.parentElement)throw Error("canvas has no parent");let{clientWidth:t,clientHeight:r}=e.parentElement;this.#i||=this.#l.w!==t||this.#l.h!==r||this.#e!==devicePixelRatio,this.#i&&(this.#e=devicePixelRatio,this.#l.w=t,this.#l.h=r,this.#m(),e.width=this.#a,e.height=this.#t,e.style.width=`${this.#a*this.#o/devicePixelRatio}px`,e.style.height=`${this.#t*this.#o/devicePixelRatio}px`)}get w(){return this.#a}get whClient(){return this.#l}get x(){return this.#h}set x(e){this.#i||=this.x!==e,this.#h=e}get y(){return this.#u}set y(e){this.#i||=this.y!==e,this.#u=e}get zoomOut(){return this.#d}set zoomOut(e){e=Math.max(0,e),this.#d!==e&&(this.#d=e,this.#m())}#m(){!this.#i&&l?.invalid&&console.debug("cam invalid"),this.#i=!0;let e={w:this.#l.w*devicePixelRatio,h:this.#l.h*devicePixelRatio},t=Math.max(this.#r,Math.min(e.w/this.#s.w,e.h/this.#s.h)-(this.#n==="Int"?Math.trunc(this.#d):this.#d));this.#o=this.#n==="Int"?Math.trunc(t):t,this.#a=Math.ceil(e.w/this.#o),this.#t=Math.ceil(e.h/this.#o)}};function ue(i,e){return(i%e+e)%e}var c=12,Zt=1/64,K={w:4095,h:4095},Z=class{i;#e;constructor(e,t){this.#e=e,this.i=t}above(e){return(this.z===e.z?(e.zend?e.y+e.h:e.y)-(this.zend?this.y+this.h:this.y):this.z-e.z)<0}get cel(){return this.#e.view.getUint8(this.i+10)&31}set cel(e){let t=this.#e.view.getUint8(this.i+10);this.#e.view.setUint8(this.i+10,t&-32|e&31)}clips(e){return x(this,e)}get flipX(){return!!(this.#e.view.getUint8(this.i+6)&64)}set flipX(e){let t=this.#e.view.getUint8(this.i+6);this.#e.view.setUint8(this.i+6,t&-65|-e&64)}get flipY(){return!!(this.#e.view.getUint8(this.i+6)&32)}set flipY(e){let t=this.#e.view.getUint8(this.i+6);this.#e.view.setUint8(this.i+6,t&-33|-e&32)}get h(){return this.#e.view.getUint16(this.i+8,!0)>>>4}set h(e){let t=this.#e.view.getUint16(this.i+8,!0);this.#e.view.setUint16(this.i+8,t&-65521|(e&4095)<<4,!0)}get id(){return this.#e.view.getUint16(this.i+10,!0)>>>5&2047}set id(e){let t=this.#e.view.getUint16(this.i+10,!0);this.#e.view.setUint16(this.i+10,t&-65505|(e&2047)<<5,!0)}get stretch(){return!!(this.#e.view.getUint8(this.i+6)&128)}set stretch(e){let t=this.#e.view.getUint8(this.i+6);this.#e.view.setUint8(this.i+6,t&-129|-e&128)}get w(){return this.#e.view.getUint16(this.i+7,!0)&4095}set w(e){let t=this.#e.view.getUint16(this.i+7,!0);this.#e.view.setUint16(this.i+7,t&-4096|e&4095,!0)}get x(){return(this.#e.view.getUint32(this.i+0,!0)<<8>>8)/64}set x(e){let t=this.#e.view.getUint32(this.i+0,!0);this.#e.view.setUint32(this.i+0,t&-16777216|e*64&16777215,!0)}get xy(){return{x:this.x,y:this.y}}set xy(e){this.x=e.x,this.y=e.y}get y(){return(this.#e.view.getUint32(this.i+3,!0)<<8>>8)/64}set y(e){let t=this.#e.view.getUint32(this.i+3,!0);this.#e.view.setUint32(this.i+3,t&-16777216|e*64&16777215,!0)}get z(){return this.#e.view.getUint8(this.i+6)&15}set z(e){let t=this.#e.view.getUint8(this.i+6);this.#e.view.setUint8(this.i+6,t&-16|e&15)}get zend(){return!!(this.#e.view.getUint8(this.i+6)&16)}set zend(e){let t=this.#e.view.getUint8(this.i+6);this.#e.view.setUint8(this.i+6,t&-17|-e&16)}},T=class i extends Z{#e;#t;#i;#r;constructor(e,t,r,n){super(e,t),this.#e=r,this.#r=n}get anim(){return this.#e.anim[this.tag]}get flipX(){return super.flipX}set flipX(e){this.flipX!==e&&(super.flipX=e,this.#t=void 0,this.#i=void 0)}get flipY(){return super.flipY}set flipY(e){this.flipY!==e&&(super.flipY=e,this.#t=void 0,this.#i=void 0)}get h(){return super.h}set h(e){this.h!==e&&(super.h=e,this.#t=void 0,this.#i=void 0)}get hitbox(){if(this.#t)return this.#t;let{hitbox:e}=this.anim;if(e)return this.#t??={x:this.x+(this.flipX?this.w-e.w-e.x:e.x),y:this.y+(this.flipY?this.h-e.h-e.y:e.y),w:e.w,h:e.h}}hits(e){let t=this.hitbox;if(!t)return!1;let r=e instanceof i?e.hurtbox:e;return!!r&&x(t,r)}get hurtbox(){if(this.#i)return this.#i;let{hurtbox:e}=this.anim;if(e)return this.#i??={x:this.x+(this.flipX?this.w-e.w-e.x:e.x),y:this.y+(this.flipY?this.h-e.h-e.y:e.y),w:e.w,h:e.h}}get id(){return super.id}set id(e){this.id!==e&&(super.id=e,this.#t=void 0,this.#i=void 0)}get looped(){return ue(this.#s-this.cel,32)>=this.anim.cels}reset(){this.cel=this.#s}get tag(){return this.#e.tags[this.id]}set tag(e){let t=this.#e.anim[e];this.w=t.w,this.h=t.h,this.id=t.id,this.reset()}toString(){return`Sprite{${this.tag} (${this.x} ${this.y} ${this.z}) ${this.w}\xD7${this.h}}`}get w(){return super.w}set w(e){this.w!==e&&(super.w=e,this.#t=void 0,this.#i=void 0)}get x(){return super.x}set x(e){this.x!==e&&(super.x=e,this.#t=void 0,this.#i=void 0)}get y(){return super.y}set y(e){this.y!==e&&(super.y=e,this.#t=void 0,this.#i=void 0)}get#s(){return this.#r.age/62.5%(this.anim.cels*2)}};var P=class{enable=!1;#e;constructor(e){this.#e=e}register(e){let t=this.#e[`${e}EventListener`].bind(this.#e);return t("contextmenu",this.#t),t("touchstart",this.#t,{passive:!1}),this}[Symbol.dispose](){this.register("remove")}#t=e=>{!e.isTrusted||e.metaKey||e.altKey||e.ctrlKey||this.enable||e.preventDefault()}};var z=class{bits=0;bitByAxis={};bitByButton={};onEvent=()=>{};#e;constructor(e){this.#e=e}get connected(){return isSecureContext&&navigator.getGamepads().filter(Boolean).length>0}register(e){let t=this.#e[`${e}EventListener`].bind(this.#e);return t("gamepadconnected",this.onEvent),t("gamepaddisconnected",this.onEvent),this}reset(){this.bits=0}[Symbol.dispose](){this.register("remove")}update(){if(isSecureContext)for(let e of navigator.getGamepads()){for(let[t,r]of e?.axes.entries()??[]){let n=this.bitByAxis[t];if(!n)continue;let s=r<0?n[0]:r===0?0:n[1];this.bits|=Math.abs(r)>=.5?s:0}for(let[t,r]of e?.buttons.entries()??[]){let n=this.bitByButton[t];n!=null&&(this.bits|=r.pressed?n:0)}}}};var W=class{bitByCode={};invalid=!1;onEvent=()=>{};#e={};#t;constructor(e){this.#t=e}get bits(){let e=0;for(let t in this.bitByCode)e|=this.#e[t]?this.bitByCode[t]:0;return e}postupdate(){this.invalid=!1}register(e){let t=this.#t[`${e}EventListener`].bind(this.#t);for(let r of["keydown","keyup"])t(r,this.#i);return this}reset(){this.invalid=!1,this.#e={}}[Symbol.dispose](){this.register("remove")}#i=e=>{!e.isTrusted||this.bitByCode[e.code]==null||e.type==="keydown"&&(e.metaKey||e.altKey||e.ctrlKey)||(this.invalid=!0,this.#e[e.code]=e.type==="keydown",e.preventDefault(),this.onEvent())}};var Pe={mouse:"Mouse",pen:"Pen",touch:"Touch"},ze=["pointercancel","pointerdown","pointermove","pointerup"],k=class{bitByButton={};dragMinClient=5;invalid=!1;onEvent=()=>{};primary;secondary={};#e;#t;constructor(e){this.#t=e}get boundsClient(){if(!this.primary?.bits&&!Object.keys(this.secondary).length)return;let e={x:1/0,y:1/0},t={x:-1/0,y:-1/0};for(let r of[this.primary,...Object.values(this.secondary)])r?.bits&&(e=se(e,r.xyClient),t=ne(t,r.xyClient));return{x:e.x,y:e.y,w:t.x-e.x,h:t.y-e.y}}get centerClient(){let e=this.boundsClient;return e?te(e,{x:e.w/2,y:e.h/2}):this.primary?.xyClient}get locked(){return this.#t.ownerDocument.pointerLockElement===this.#t}get pinchClient(){if(!this.#e)return;let e=this.#s;return e?$(e,this.#e):void 0}postupdate(){this.invalid=!1}register(e){let t=this.#t[`${e}EventListener`].bind(this.#t);for(let r of ze)t(r,this.#r);return this}reset(){this.invalid=!1,this.primary=void 0;for(let e in this.secondary)delete this.secondary[e];this.#e=void 0}update(){((this.primary?.bits?1:0)+Object.values(this.secondary).length<2||!this.#e)&&(this.#e=this.#s)}[Symbol.dispose](){this.register("remove")}#i(e){let t=0;for(let r=1;r<=e;r<<=1)(r&e)===r&&(t|=this.bitByButton[r]??0);return t}#r=e=>{if(!e.isTrusted)return;this.invalid=!0;let t=e.metaKey||e.altKey||e.ctrlKey?0:this.#i(e.buttons);t&&e.preventDefault();let r=this.locked;if(e.type==="pointerdown"&&!r)try{this.#t.setPointerCapture(e.pointerId)}catch{}let n=e.isPrimary?this.primary:this.secondary[e.pointerId],s;if(r){let S=1/devicePixelRatio;s={x:Math.min(Math.max(0,(n?.xyClient.x??e.offsetX)+e.movementX*S),this.#t.clientWidth),y:Math.min(Math.max(0,(n?.xyClient.y??e.offsetY)+e.movementY*S),this.#t.clientHeight)}}else s={x:e.offsetX,y:e.offsetY};let a=e.type,d=Pe[e.pointerType],m;e.type==="pointerdown"?m={x:s.x,y:s.y}:e.type==="pointermove"&&(m=n?.clickClient);let u=!!t&&(n?.drag||!!m&&re(m,s)>=this.dragMinClient),p={clickClient:m,bits:t,drag:u,ev:a,id:e.pointerId,primary:e.isPrimary,type:d,xyClient:s};e.isPrimary?this.primary=p:t?this.secondary[e.pointerId]=p:delete this.secondary[e.pointerId],this.onEvent()};get#s(){if((this.primary?.bits?1:0)+Object.values(this.secondary).length<2)return;let e=this.boundsClient;return e?{x:e.w,y:e.h}:void 0}};var H=class{deltaClient;onEvent=()=>{};#e;constructor(e){this.#e=e}postupdate(){this.deltaClient=void 0}register(e){return this.#e[`${e}EventListener`].bind(this.#e)("wheel",this.#t,{passive:!0}),this}reset(){this.deltaClient=void 0}[Symbol.dispose](){this.register("remove")}#t=e=>{!e.isTrusted||e.metaKey||e.altKey||e.ctrlKey||(this.deltaClient={x:e.deltaX,y:e.deltaY,z:e.deltaZ},this.onEvent())}};var O=class{comboMaxIntervalMillis=300;gestured=!1;handled=!1;invalid=!1;minHeldMillis=300;#e={};#t={};#i=0;#r;#s=[];#n;#o;#a=0;#l;#h;#u;#d=0;#m;#f;constructor(e,t){this.#r=e,this.#n=new P(t),this.#o=new z(globalThis),this.#l=new W(t.ownerDocument),this.#h=new k(t),this.#m=new H(t)}get anyOn(){return this.#i!==0}get combo(){let e=[];for(let t of this.#s){let r=[];for(let n=1;n<=t;n<<=1)(n&t)===n&&this.#t[n]&&r.push(this.#t[n]);r.sort(),e.push(r)}return e}get contextMenu(){return this.#n}get gamepad(){return this.#o.connected?{}:void 0}get held(){return!this.handled&&this.#a>=this.minHeldMillis}isAnyOn(...e){return!this.handled&&!!(this.#i&this.#c(e))}isAnyOnStart(...e){return this.started&&this.isAnyOn(...e)}isCombo(...e){return e.length===this.#s.length&&this.isComboEndsWith(...e)}isComboEndsWith(...e){for(let[t,r]of e.entries()){let n=this.#c(r);if(this.#s.at(-e.length+t)!==n)return!1}return!this.handled&&(this.#s.at(-1)===this.#i||!this.#i)}isComboEndsWithStart(...e){return this.isOnStart(...e.at(-1))&&this.isComboEndsWith(...e)}isComboStart(...e){return this.isOnStart(...e.at(-1))&&this.isCombo(...e)}isOff(...e){return!this.handled&&!this.isOn(...e)}isOffStart(...e){let t=this.#c(e);return(this.#d&t)===t&&this.started&&this.isOff(...e)}isOn(...e){let t=this.#c(e);return!this.handled&&(this.#i&t)===t}isOnStart(...e){return this.started&&this.isOn(...e)}get key(){return{invalid:this.#l.invalid}}mapDefault(){let e=this;return e.mapKeyboardCode("L","ArrowLeft"),e.mapKeyboardCode("R","ArrowRight"),e.mapKeyboardCode("U","ArrowUp"),e.mapKeyboardCode("D","ArrowDown"),e.mapKeyboardCode("C","KeyC"),e.mapKeyboardCode("A","KeyX"),e.mapKeyboardCode("B","KeyZ"),e.mapKeyboardCode("Menu","Enter"),e.mapKeyboardCode("Back","Escape"),e.mapGamepadAxis("L","R",0,2),e.mapGamepadAxis("U","D",1,3),e.mapGamepadButton("L",14),e.mapGamepadButton("R",15),e.mapGamepadButton("U",12),e.mapGamepadButton("D",13),e.mapGamepadButton("C",2),e.mapGamepadButton("B",0),e.mapGamepadButton("A",1),e.mapGamepadButton("Menu",9),e.mapGamepadButton("Back",8),e.mapPointerClick("Click",1),e.mapPointerClick("Click2",2),e.mapPointerClick("ClickMiddle",4),e}mapGamepadAxis(e,t,...r){for(let n of r)this.#o.bitByAxis[n]=[this.#p(e),this.#p(t)]}mapGamepadButton(e,...t){for(let r of t)this.#o.bitByButton[r]=this.#p(e)}mapKeyboardCode(e,...t){for(let r of t)this.#l.bitByCode[r]=this.#p(e)}mapPointerClick(e,...t){for(let r of t)this.#h.bitByButton[r]=this.#p(e)}get on(){let e=[];for(let t in this.#e)this.isOn(t)&&e.push(t);return e.sort()}set onEvent(e){this.#o.onEvent=e,this.#l.onEvent=e,this.#h.onEvent=e,this.#m.onEvent=e}get point(){return this.#u}get pointer(){return this.#h}register(e){return globalThis[`${e}EventListener`]("blur",this.reset),this.#n.register(e),this.#o.register(e),this.#l.register(e),this.#h.register(e),this.#m.register(e),this}reset=()=>{this.#i=0,this.#d=0,this.handled=!1,this.#a=0,this.#s.length=0,this.#o.reset(),this.#l.reset(),this.#h.reset(),this.#u=void 0,this.#m.reset(),this.#f=void 0};get started(){return!this.handled&&this.#i!==this.#d}update(e){if(this.handled=!1,this.#o.update(),this.#h.update(),this.#d=this.#i,this.#i=this.#o.bits|this.#l.bits|(this.#h.primary?.bits??0),this.invalid=this.#i!==this.#d||this.#h.invalid||!!this.#m.deltaClient,this.gestured||=!!this.#i,(e>this.comboMaxIntervalMillis&&this.#i!==this.#d||this.#a+e>this.comboMaxIntervalMillis&&!this.#i)&&(this.#s.length=0),this.#i===this.#d?this.#a=this.#a+e:this.#a=e,this.#i&&this.#i!==this.#d&&(this.#d&&(this.#s.length=0),this.#s.push(this.#i)),this.#h.primary){let t=this.#h.pinchClient,r=this.#h.primary.drag&&!Object.values(this.#h.secondary).length,n=[];for(let d of Object.values(this.#h.secondary))n.push({type:d.type,click:d.clickClient?{client:d.clickClient,local:this.#r.clientToXYLocal(d.clickClient),...this.#r.clientToXY(d.clickClient)}:void 0,...this.#r.clientToXY(d.xyClient),client:d.xyClient,local:this.#r.clientToXYLocal(d.xyClient)});let s=this.#h.centerClient,a={client:s,local:this.#r.clientToXYLocal(s),...this.#r.clientToXY(s)};this.#u={center:a,click:this.#h.primary.clickClient?{client:this.#h.primary.clickClient,local:this.#r.clientToXYLocal(this.#h.primary.clickClient),...this.#r.clientToXY(this.#h.primary.clickClient)}:void 0,drag:{on:r,start:!this.#u?.drag.on&&r,end:!!this.#u?.drag.on&&!r},invalid:this.#h.invalid,pinch:t?{client:t,xy:this.#r.clientToXY(t)}:void 0,secondary:n,type:this.#h.primary.type,...this.#r.clientToXY(this.#h.primary.xyClient),client:this.#h.primary.xyClient,local:this.#r.clientToXYLocal(this.#h.primary.xyClient)}}else this.#u=void 0;this.#f=this.#m.deltaClient?{delta:{client:this.#m.deltaClient,xy:this.#r.clientToXY(this.#m.deltaClient)}}:void 0,this.#l.postupdate(),this.#h.postupdate(),this.#m.postupdate()}[Symbol.dispose](){this.register("remove")}get wheel(){return this.#f}#c(e){let t=0;for(let r of e)t|=this.#e[r]??0;return t}#p(e){let t=this.#e[e]??=1<<Object.keys(this.#e).length;return this.#t[t]=e,t}};var E=class{#e;#t;#i=0;#r;#s;constructor(e){if(e.allocBytes<=0)throw Error("byte allocation must be > 0");if(e.pageBlocks<=0)throw Error("page blocks must be > 0");this.#t={...e,minPages:e.minPages??1};let t=this.#t.minPages*e.pageBlocks;this.#e=new Array(t),this.#r=new Uint8Array,this.#a(t,"Init")}alloc(){this.#i>=this.#n&&this.#a(this.#n+this.#t.pageBlocks,"Call");let e=this.#e[this.#i];return e.i=this.#i*this.#t.allocBytes,this.#i++,e}clear(){this.#i=0;let e=this.#t.minPages*this.#t.pageBlocks;this.#n>e&&this.#a(e,"Call")}free(...e){for(let t of e)this.#o(t)}get size(){return this.#i}get view(){return this.#s}toDebugString(){let e="";for(let t=0;t<this.#r.buffer.byteLength;t++)t&&!(t%this.#t.allocBytes)&&(e+=" "),e+=this.#r[t].toString(16).padStart(2,"0");return e}get#n(){return this.#r.buffer.byteLength/this.#t.allocBytes}#o(e){if(!this.#i)throw Error("pool underflow");this.#i--;let t=this.#i*this.#t.allocBytes;this.#r.copyWithin(e.i,t,t+this.#t.allocBytes),this.#e[this.#i].i=e.i,[this.#e[e.i],this.#e[this.#i]]=[this.#e[this.#i],this.#e[e.i]];let r=Math.floor((this.#n-this.#i)/this.#t.pageBlocks);r&&this.#n/this.#t.pageBlocks-r>=this.#t.minPages&&this.#a(this.#n-r*this.#t.pageBlocks,"Call")}#a(e,t){t==="Call"&&l?.mem&&console.debug(`[mem] ${e<this.#n?"shrinking":"growing"} pool to ${e}`),this.#e.length=e;for(let s=this.#n;s<e;s++)this.#e[s]=this.#t.alloc(this);let r=new ArrayBuffer(e*this.#t.allocBytes),n=new Uint8Array(r);n.set(this.#r.subarray(0,e*this.#t.allocBytes)),this.#r=n,this.#s=new DataView(r)}};function pe(i){return`#${i.toString(16).padStart(8,"0")}`}function ce(i,e){i.parentNode===document.body&&(document.body.style.margin="0",document.body.style.width="100dvw",document.body.style.height="100dvh",document.body.style.overflow="hidden",document.body.style.background=pe(e))}function fe(){if(document.querySelector('meta[name="viewport"]'))return;let i=document.createElement("meta");i.name="viewport",i.content="width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no",document.head.appendChild(i)}function ye(i,e){return i??=document.createElement("canvas"),i.width=0,i.style.cursor="none",i.style.display="block",i.style.outline="none",i.style.cursor="none",e==="Int"&&(i.style.imageRendering="pixelated"),i.style.touchAction="none",i.tabIndex=0,i.focus(),i.parentNode||document.body.append(i),i}async function xe(i){let e=new Promise((t,r)=>{i.onload=()=>t(i),i.onerror=()=>r(Error(`image load error for ${i.src}`))});return i.complete?i:await e}function be(i,e,t,r){let n=ke(i,e,t);return i.useProgram(n),{buffer:i.createBuffer(),program:n,textures:r,uniform:We(i,n),vao:i.createVertexArray()}}function We(i,e){let t=e?i.getProgramParameter(e,i.ACTIVE_UNIFORMS):0,r=l?.render?new Proxy({},{get(n,s){if(n[s]==null)throw Error(`no shader uniform "${s}"`);return n[s]}}):{};for(let n=0;n<t;++n){let s=i.getActiveUniform(e,n);if(!s)throw Error(`no shader uniform at index ${n}`);let a=i.getUniformLocation(e,s.name);if(!a)throw Error(`no shader uniform "${s.name}"`);let d=s.name.replace("[0]","");r[d]=a}return r}function ke(i,e,t){let r=i.createProgram();if(!r)return null;let n=ge(i,"VERTEX_SHADER",e),s=ge(i,"FRAGMENT_SHADER",t);if(!n||!s)return null;if(i.attachShader(r,n),i.attachShader(r,s),i.linkProgram(r),l?.render&&!i.getProgramParameter(r,i.LINK_STATUS)){let a=i.getProgramInfoLog(r)?.slice(0,-1);throw Error(`shader link failure; ${a}`)}return i.detachShader(r,s),i.detachShader(r,n),i.deleteShader(s),i.deleteShader(n),r}function ge(i,e,t){let r=i.createShader(i[e]);if(!r)return r;if(i.shaderSource(r,t.trim()),i.compileShader(r),l?.render&&!i.getShaderParameter(r,i.COMPILE_STATUS)){let n=i.getShaderInfoLog(r)?.slice(0,-1);throw Error(`shader compile failure; ${n}`)}return r}var we=`#version 300 es
|
|
12
|
-
#pragma debug(${l?.render?"on":"off"})
|
|
13
|
-
#pragma optimize(${l?.render?"off":"on"})
|
|
14
|
-
|
|
15
|
-
precision highp int;
|
|
16
|
-
precision highp float;
|
|
17
|
-
precision highp usampler2D;
|
|
18
|
-
|
|
19
|
-
uniform sampler2D uTex;
|
|
20
|
-
uniform uvec2 uTexWH;
|
|
21
|
-
|
|
22
|
-
flat in uint vStretch;
|
|
23
|
-
flat in ivec4 vTexXYWH;
|
|
24
|
-
flat in int vZ;
|
|
25
|
-
in vec2 vDstWH;
|
|
26
|
-
flat in ivec2 vDstWHFixed;
|
|
27
|
-
|
|
28
|
-
out vec4 oRGBA;
|
|
29
|
-
|
|
30
|
-
void main() {
|
|
31
|
-
if (vZ == ${h.Hidden} || vDstWHFixed.x == 0 || vDstWHFixed.y == 0)
|
|
32
|
-
discard;
|
|
33
|
-
|
|
34
|
-
vec2 px = vec2(vTexXYWH.xy) + (
|
|
35
|
-
vStretch == 1u ? (vDstWH * vec2(vTexXYWH.zw) / vec2(vDstWHFixed))
|
|
36
|
-
: mod(vDstWH, vec2(vTexXYWH.zw))
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
oRGBA = texture(uTex, px / vec2(uTexWH));
|
|
40
|
-
if(oRGBA.a < .001) discard;
|
|
41
|
-
}
|
|
42
|
-
`;var ve=`#version 300 es
|
|
43
|
-
#pragma debug(${l?.render?"on":"off"})
|
|
44
|
-
#pragma optimize(${l?.render?"off":"on"})
|
|
45
|
-
|
|
46
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#essl300_minimum_requirements_webgl_2
|
|
47
|
-
precision highp int;
|
|
48
|
-
precision highp float;
|
|
49
|
-
precision highp usampler2D;
|
|
50
|
-
|
|
51
|
-
uniform ivec4 uCam;
|
|
52
|
-
uniform usampler2D uCels;
|
|
53
|
-
uniform float uAge;
|
|
54
|
-
|
|
55
|
-
layout (location=0) in ivec2 iUV;
|
|
56
|
-
layout (location=1) in uint iy8_x24;
|
|
57
|
-
layout (location=2) in uint iw8_sxyz_llll_y16;
|
|
58
|
-
layout (location=3) in uint ii11_c5_h12_w4;
|
|
59
|
-
|
|
60
|
-
const int maxY = 0x20000;
|
|
61
|
-
const int layers = 16;
|
|
62
|
-
const int maxDepth = maxY * layers;
|
|
63
|
-
|
|
64
|
-
flat out uint vStretch;
|
|
65
|
-
flat out ivec4 vTexXYWH;
|
|
66
|
-
flat out int vZ;
|
|
67
|
-
out vec2 vDstWH;
|
|
68
|
-
flat out ivec2 vDstWHFixed;
|
|
69
|
-
|
|
70
|
-
void main() {
|
|
71
|
-
int x = (int((iy8_x24 & 0xffffffu) << 8) >> 8) / 64;
|
|
72
|
-
int y = (int(iy8_x24 >> 24) | (int(iw8_sxyz_llll_y16 & 0xffffu) << 16 >> 8)) / 64;
|
|
73
|
-
int z = int((iw8_sxyz_llll_y16 >> 16) & 0xfu);
|
|
74
|
-
bool zend = bool(iw8_sxyz_llll_y16 & 0x100000u);
|
|
75
|
-
bool flipY = bool(iw8_sxyz_llll_y16 & 0x200000u);
|
|
76
|
-
bool flipX = bool(iw8_sxyz_llll_y16 & 0x400000u);
|
|
77
|
-
bool stretch = bool(iw8_sxyz_llll_y16 & 0x800000u);
|
|
78
|
-
int id = int((ii11_c5_h12_w4 >> 17) & 0x7ff0u); // ignore cel.
|
|
79
|
-
int cel = int((ii11_c5_h12_w4 >> 16) & 0xfu); // ignore the MSB.
|
|
80
|
-
int w = int(((ii11_c5_h12_w4 & 0xfu) << 8) | (iw8_sxyz_llll_y16 >> 24));
|
|
81
|
-
int h = int((ii11_c5_h12_w4 >> 4) & 0xfffu);
|
|
82
|
-
|
|
83
|
-
// https://www.patternsgameprog.com/opengl-2d-facade-25-get-the-z-of-a-pixel
|
|
84
|
-
float depth = float((z + 1) * maxY - (y + (zend ? 0 : h))) / float(maxDepth);
|
|
85
|
-
|
|
86
|
-
ivec2 targetWH = iUV * ivec2(w, h);
|
|
87
|
-
|
|
88
|
-
vec2 end = vec2(x + targetWH.x, y + targetWH.y);
|
|
89
|
-
// UI layers are always given in screen coordinates.
|
|
90
|
-
// to-do: how to handle non-int mode?
|
|
91
|
-
vec2 camXY = z < ${h.A} ? vec2(0, 0) : vec2(uCam.xy);
|
|
92
|
-
vec2 clip = ((-2. * camXY + 2. * end) / vec2(uCam.zw) - 1.) * vec2(1, -1);
|
|
93
|
-
gl_Position = vec4(clip, depth, 1);
|
|
94
|
-
|
|
95
|
-
int frame = (((int(uAge / ${62.5}) & 0x1f) - cel) + ${16}) & 0xf;
|
|
96
|
-
uvec4 texXYWH = texelFetch(uCels, ivec2(0, id + frame), 0);
|
|
97
|
-
vTexXYWH = ivec4(texXYWH);
|
|
98
|
-
vZ = z;
|
|
99
|
-
|
|
100
|
-
vDstWH = vec2(targetWH * ivec2(flipX ? -1 : 1, flipY ? -1 : 1));
|
|
101
|
-
vDstWHFixed = ivec2(w, h) * ivec2(flipX ? -1 : 1, flipY ? -1 : 1);
|
|
102
|
-
|
|
103
|
-
vStretch = stretch ? 1u : 0u;
|
|
104
|
-
}
|
|
105
|
-
`;var Te=new Int8Array([1,1,0,1,1,0,0,0]),D=class{always=l?.render==="always";clears=0;invalid=!1;loseContext;#e;#t=0;#i=!0;#r;#s;#n;#o;constructor(e,t,r){this.#n=e,this.#e=t,this.#s=r}clear(e){if(!this.#r)return;let{gl:t}=this.#r;this.#t!==e&&(this.#t=e,t.clearColor((e>>>24&255)/255,(e>>>16&255)/255,(e>>>8&255)/255,(e>>>0&255)/255)),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),this.clears++}draw(e){if(!this.#o||!this.#r)return;let{gl:t,spriteShader:r}=this.#r;t.bindBuffer(t.ARRAY_BUFFER,r.buffer),t.bufferData(t.ARRAY_BUFFER,e.view,t.DYNAMIC_DRAW,0,e.size*c),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindVertexArray(r.vao),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,Te.length/2,e.size),t.bindVertexArray(null),this.invalid=!1}get hasContext(){return this.#r!=null}load(e){this.#o=e,this.#r=this._Context()}predraw(e){if(!this.#r)return;let{gl:t,spriteShader:r,viewport:n}=this.#r;g(n,e)||(t.viewport(0,0,e.w,e.h),n.w=e.w,n.h=e.h),t.useProgram(r.program),t.uniform4i(r.uniform.uCam,e.x,e.y,e.w,e.h),t.uniform1f(r.uniform.uAge,this.#s.age);for(let[s,a]of r.textures.entries())t.activeTexture(t.TEXTURE0+s),t.bindTexture(t.TEXTURE_2D,a)}register(e){return this.#e[`${e}EventListener`]("webglcontextlost",this.#a),this.#e[`${e}EventListener`]("webglcontextrestored",this.#l),this}setDepth(e){this.#i=e,this.#r&&(e?this.#r.gl.enable(this.#r.gl.DEPTH_TEST):this.#r.gl.disable(this.#r.gl.DEPTH_TEST))}[Symbol.dispose](){this.register("remove")}_Context(){let e=this.#r?.gl??He(this.#e);if(!e)return;let t=be(e,ve,we,[e.createTexture(),e.createTexture()]);return e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),this.setDepth(this.#i),e.depthRange(0,1),e.clearDepth(1),e.depthFunc(e.LESS),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,!1),e.bindVertexArray(t.vao),e.bindBuffer(e.ARRAY_BUFFER,e.createBuffer()),e.bufferData(e.ARRAY_BUFFER,Te,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribIPointer(0,2,e.BYTE,0,0),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ARRAY_BUFFER,t.buffer),e.enableVertexAttribArray(1),e.vertexAttribIPointer(1,1,e.UNSIGNED_INT,c,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribIPointer(2,1,e.UNSIGNED_INT,c,4),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribIPointer(3,1,e.UNSIGNED_INT,c,8),e.vertexAttribDivisor(3,1),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindTexture(e.TEXTURE_2D,t.textures[0]),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),this.#o&&e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.#o),e.bindTexture(e.TEXTURE_2D,null),e.bindTexture(e.TEXTURE_2D,t.textures[1]),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA16UI,1,this.#n.celXYWH.length/4,0,e.RGBA_INTEGER,e.UNSIGNED_SHORT,new Uint16Array(this.#n.celXYWH)),e.bindTexture(e.TEXTURE_2D,null),e.bindVertexArray(null),e.uniform1i(t.uniform.uTex,0),e.uniform1i(t.uniform.uCels,1),this.#o&&e.uniform2ui(t.uniform.uTexWH,this.#o.naturalWidth,this.#o.naturalHeight),!this.invalid&&l?.invalid&&console.debug("renderer invalid"),this.invalid=!0,this.loseContext=e.getExtension("WEBGL_lose_context")??void 0,this.#r={gl:e,spriteShader:t,viewport:{w:0,h:0}}}#a=e=>{e.preventDefault(),console.debug("[render] WebGL context lost"),this.#r=void 0};#l=()=>{console.debug("[render] WebGL context restored"),this.#r=this._Context()}};function He(i){let e=i.getContext("webgl2",{antialias:!1,powerPreference:"low-power",preserveDrawingBuffer:!0,...!l?.render&&{desynchronized:!0}});if(!e){console.debug("[render] no GL context");return}return l?.render&&!e.getContextAttributes()?.desynchronized&&console.debug("[render] no WebGL DOM desynchronization"),e}var F=class{age=0;onFrame;#e=0;#t=!1;register(e){let t=`${e}EventListener`;return document[t]("visibilitychange",this.#s),e==="remove"&&this.#i(),this.#t=e==="add",this}requestFrame(){this.#e||document.hidden||!this.#t||(this.#e=requestAnimationFrame(this.#r))}[Symbol.dispose](){this.register("remove")}#i(){this.#e&&cancelAnimationFrame(this.#e),this.#e=0}#r=e=>{let t=e-(this.age||e);this.age=e,this.#e=0,this.onFrame?.(t)};#s=e=>{e.isTrusted&&(document.hidden?this.#i():this.requestFrame())}};var I=class{#e;#t;#i=0;#r;#s=0;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}register(e){return e==="add"?this.#s=setTimeout(()=>{this.#r(),this.#i=setInterval(this.#r,this.#t)},this.#e()):(clearTimeout(this.#s),clearInterval(this.#i)),this}[Symbol.dispose](){this.register("remove")}};var U=class{cam=new X;canvas;input;preload;renderer;sprites;zoo=new M;looper=new F;#e;#t;#i=new ResizeObserver(()=>this.onResize());constructor(e){e.poll!=null&&(this.#e=new I(e.poll.delay??(()=>0),e.poll.period,()=>this.onPoll())),fe(),this.canvas=ye(e.canvas,e.mode??"Int"),ce(this.canvas,e.backgroundRGBA??255),e.minWH&&(this.cam.minWH=e.minWH),this.cam.mode=e.mode??"Int",this.cam.update(this.canvas),this.input=new O(this.cam,this.canvas),e.input!=="Custom"&&this.input.mapDefault(),this.input.onEvent=()=>this.onEvent(),e.preloadAtlas&&(this.#t=e.preloadAtlas.image),this.preload=e.preloadAtlas?me(e.preloadAtlas.json):{anim:{},celXYWH:[],tags:[]},this.renderer=new D(this.preload??{},this.canvas,this.looper),this.sprites=new E({alloc:t=>this.onAllocSprite(t),allocBytes:c,minPages:e.sprites?.minPages??3,pageBlocks:e.sprites?.pageBlocks??1e3}),this.looper.onFrame=t=>this.onFrame(t)}onAllocSprite(e){return new T(e,0,this.preload,this.looper)}onEvent(){this.requestFrame("Force")}onFrame(e){document.hidden||(this.input.update(e),this.requestFrame(),this.onLoop(e),this.cam.postupdate())}onLoop(e){}onPoll(){this.requestFrame("Force")}onResize(){this.requestFrame("Force")}async register(e){if(this.input.register(e),this.renderer.register(e),this.looper.register(e),!this.canvas.parentElement)throw Error("no canvas parent");e==="add"?this.#i.observe(this.canvas.parentElement):this.#i.unobserve(this.canvas.parentElement),e==="add"&&this.looper.requestFrame(),this.#e?.register(e),this.#t&&await xe(this.#t),this.renderer.load(this.#t)}requestFrame(e){(e||this.renderer.always||this.input.anyOn||this.input.gamepad)&&this.looper.requestFrame()}async[Symbol.asyncDispose](){await this.register("remove")}};var Ee=_?`${_.version}+${_.published}`:"?";var Se={anim:{"background--OrangeCheckerboard":{cels:1,h:2,id:0,w:2},"background--GreyCheckerboard":{cels:1,h:2,id:1,w:2},"background--Kiwi":{cels:1,h:2,id:2,w:2},"background--Strawberry":{cels:1,h:2,id:3,w:2},"background--Grape":{cels:1,h:2,id:4,w:2},"background--Blueberry":{cels:1,h:2,id:5,w:2},"background--Bubblegum":{cels:1,h:2,id:6,w:2},"background--Transparent":{cels:1,h:2,id:7,w:2},"background--Black":{cels:1,h:2,id:8,w:2},"backpacker--WalkRight":{cels:16,h:13,hitbox:{x:2,y:0,w:4,h:4},id:9,w:8},"backpacker--WalkDown":{cels:16,h:13,hitbox:{x:2,y:0,w:4,h:4},id:10,w:8},"backpacker--WalkUp":{cels:16,h:13,hitbox:{x:2,y:0,w:4,h:4},id:11,w:8},"cursor--Pointer":{cels:1,h:14,hitbox:{x:0,y:0,w:2,h:2},hurtbox:{x:0,y:0,w:2,h:2},id:12,w:8},"mem-prop-5x6--00":{cels:1,h:6,id:13,w:5},"mem-prop-5x6--01":{cels:1,h:6,id:14,w:5},"mem-prop-5x6--02":{cels:1,h:6,id:15,w:5},"mem-prop-5x6--03":{cels:1,h:6,id:16,w:5},"mem-prop-5x6--04":{cels:1,h:6,id:17,w:5},"mem-prop-5x6--05":{cels:1,h:6,id:18,w:5},"mem-prop-5x6--06":{cels:1,h:6,id:19,w:5},"mem-prop-5x6--07":{cels:1,h:6,id:20,w:5},"mem-prop-5x6--08":{cels:1,h:6,id:21,w:5},"mem-prop-5x6--09":{cels:1,h:6,id:22,w:5},"mem-prop-5x6--0a":{cels:1,h:6,id:23,w:5},"mem-prop-5x6--0b":{cels:1,h:6,id:24,w:5},"mem-prop-5x6--0c":{cels:1,h:6,id:25,w:5},"mem-prop-5x6--0d":{cels:1,h:6,id:26,w:5},"mem-prop-5x6--0e":{cels:1,h:6,id:27,w:5},"mem-prop-5x6--0f":{cels:1,h:6,id:28,w:5},"mem-prop-5x6--10":{cels:1,h:6,id:29,w:5},"mem-prop-5x6--11":{cels:1,h:6,id:30,w:5},"mem-prop-5x6--12":{cels:1,h:6,id:31,w:5},"mem-prop-5x6--13":{cels:1,h:6,id:32,w:5},"mem-prop-5x6--14":{cels:1,h:6,id:33,w:5},"mem-prop-5x6--15":{cels:1,h:6,id:34,w:5},"mem-prop-5x6--16":{cels:1,h:6,id:35,w:5},"mem-prop-5x6--17":{cels:1,h:6,id:36,w:5},"mem-prop-5x6--18":{cels:1,h:6,id:37,w:5},"mem-prop-5x6--19":{cels:1,h:6,id:38,w:5},"mem-prop-5x6--1a":{cels:1,h:6,id:39,w:5},"mem-prop-5x6--1b":{cels:1,h:6,id:40,w:5},"mem-prop-5x6--1c":{cels:1,h:6,id:41,w:5},"mem-prop-5x6--1d":{cels:1,h:6,id:42,w:5},"mem-prop-5x6--1e":{cels:1,h:6,id:43,w:5},"mem-prop-5x6--1f":{cels:1,h:6,id:44,w:5},"mem-prop-5x6--20":{cels:1,h:6,id:45,w:5},"mem-prop-5x6--21":{cels:1,h:6,id:46,w:5},"mem-prop-5x6--22":{cels:1,h:6,id:47,w:5},"mem-prop-5x6--23":{cels:1,h:6,id:48,w:5},"mem-prop-5x6--24":{cels:1,h:6,id:49,w:5},"mem-prop-5x6--25":{cels:1,h:6,id:50,w:5},"mem-prop-5x6--26":{cels:1,h:6,id:51,w:5},"mem-prop-5x6--27":{cels:1,h:6,id:52,w:5},"mem-prop-5x6--28":{cels:1,h:6,id:53,w:5},"mem-prop-5x6--29":{cels:1,h:6,id:54,w:5},"mem-prop-5x6--2a":{cels:1,h:6,id:55,w:5},"mem-prop-5x6--2b":{cels:1,h:6,id:56,w:5},"mem-prop-5x6--2c":{cels:1,h:6,id:57,w:5},"mem-prop-5x6--2d":{cels:1,h:6,id:58,w:5},"mem-prop-5x6--2e":{cels:1,h:6,id:59,w:5},"mem-prop-5x6--2f":{cels:1,h:6,id:60,w:5},"mem-prop-5x6--30":{cels:1,h:6,id:61,w:5},"mem-prop-5x6--31":{cels:1,h:6,id:62,w:5},"mem-prop-5x6--32":{cels:1,h:6,id:63,w:5},"mem-prop-5x6--33":{cels:1,h:6,id:64,w:5},"mem-prop-5x6--34":{cels:1,h:6,id:65,w:5},"mem-prop-5x6--35":{cels:1,h:6,id:66,w:5},"mem-prop-5x6--36":{cels:1,h:6,id:67,w:5},"mem-prop-5x6--37":{cels:1,h:6,id:68,w:5},"mem-prop-5x6--38":{cels:1,h:6,id:69,w:5},"mem-prop-5x6--39":{cels:1,h:6,id:70,w:5},"mem-prop-5x6--3a":{cels:1,h:6,id:71,w:5},"mem-prop-5x6--3b":{cels:1,h:6,id:72,w:5},"mem-prop-5x6--3c":{cels:1,h:6,id:73,w:5},"mem-prop-5x6--3d":{cels:1,h:6,id:74,w:5},"mem-prop-5x6--3e":{cels:1,h:6,id:75,w:5},"mem-prop-5x6--3f":{cels:1,h:6,id:76,w:5},"mem-prop-5x6--40":{cels:1,h:6,id:77,w:5},"mem-prop-5x6--41":{cels:1,h:6,id:78,w:5},"mem-prop-5x6--42":{cels:1,h:6,id:79,w:5},"mem-prop-5x6--43":{cels:1,h:6,id:80,w:5},"mem-prop-5x6--44":{cels:1,h:6,id:81,w:5},"mem-prop-5x6--45":{cels:1,h:6,id:82,w:5},"mem-prop-5x6--46":{cels:1,h:6,id:83,w:5},"mem-prop-5x6--47":{cels:1,h:6,id:84,w:5},"mem-prop-5x6--48":{cels:1,h:6,id:85,w:5},"mem-prop-5x6--49":{cels:1,h:6,id:86,w:5},"mem-prop-5x6--4a":{cels:1,h:6,id:87,w:5},"mem-prop-5x6--4b":{cels:1,h:6,id:88,w:5},"mem-prop-5x6--4c":{cels:1,h:6,id:89,w:5},"mem-prop-5x6--4d":{cels:1,h:6,id:90,w:5},"mem-prop-5x6--4e":{cels:1,h:6,id:91,w:5},"mem-prop-5x6--4f":{cels:1,h:6,id:92,w:5},"mem-prop-5x6--50":{cels:1,h:6,id:93,w:5},"mem-prop-5x6--51":{cels:1,h:6,id:94,w:5},"mem-prop-5x6--52":{cels:1,h:6,id:95,w:5},"mem-prop-5x6--53":{cels:1,h:6,id:96,w:5},"mem-prop-5x6--54":{cels:1,h:6,id:97,w:5},"mem-prop-5x6--55":{cels:1,h:6,id:98,w:5},"mem-prop-5x6--56":{cels:1,h:6,id:99,w:5},"mem-prop-5x6--57":{cels:1,h:6,id:100,w:5},"mem-prop-5x6--58":{cels:1,h:6,id:101,w:5},"mem-prop-5x6--59":{cels:1,h:6,id:102,w:5},"mem-prop-5x6--5a":{cels:1,h:6,id:103,w:5},"mem-prop-5x6--5b":{cels:1,h:6,id:104,w:5},"mem-prop-5x6--5c":{cels:1,h:6,id:105,w:5},"mem-prop-5x6--5d":{cels:1,h:6,id:106,w:5},"mem-prop-5x6--5e":{cels:1,h:6,id:107,w:5},"mem-prop-5x6--5f":{cels:1,h:6,id:108,w:5},"mem-prop-5x6--60":{cels:1,h:6,id:109,w:5},"mem-prop-5x6--61":{cels:1,h:6,id:110,w:5},"mem-prop-5x6--62":{cels:1,h:6,id:111,w:5},"mem-prop-5x6--63":{cels:1,h:6,id:112,w:5},"mem-prop-5x6--64":{cels:1,h:6,id:113,w:5},"mem-prop-5x6--65":{cels:1,h:6,id:114,w:5},"mem-prop-5x6--66":{cels:1,h:6,id:115,w:5},"mem-prop-5x6--67":{cels:1,h:6,id:116,w:5},"mem-prop-5x6--68":{cels:1,h:6,id:117,w:5},"mem-prop-5x6--69":{cels:1,h:6,id:118,w:5},"mem-prop-5x6--6a":{cels:1,h:6,id:119,w:5},"mem-prop-5x6--6b":{cels:1,h:6,id:120,w:5},"mem-prop-5x6--6c":{cels:1,h:6,id:121,w:5},"mem-prop-5x6--6d":{cels:1,h:6,id:122,w:5},"mem-prop-5x6--6e":{cels:1,h:6,id:123,w:5},"mem-prop-5x6--6f":{cels:1,h:6,id:124,w:5},"mem-prop-5x6--70":{cels:1,h:6,id:125,w:5},"mem-prop-5x6--71":{cels:1,h:6,id:126,w:5},"mem-prop-5x6--72":{cels:1,h:6,id:127,w:5},"mem-prop-5x6--73":{cels:1,h:6,id:128,w:5},"mem-prop-5x6--74":{cels:1,h:6,id:129,w:5},"mem-prop-5x6--75":{cels:1,h:6,id:130,w:5},"mem-prop-5x6--76":{cels:1,h:6,id:131,w:5},"mem-prop-5x6--77":{cels:1,h:6,id:132,w:5},"mem-prop-5x6--78":{cels:1,h:6,id:133,w:5},"mem-prop-5x6--79":{cels:1,h:6,id:134,w:5},"mem-prop-5x6--7a":{cels:1,h:6,id:135,w:5},"mem-prop-5x6--7b":{cels:1,h:6,id:136,w:5},"mem-prop-5x6--7c":{cels:1,h:6,id:137,w:5},"mem-prop-5x6--7d":{cels:1,h:6,id:138,w:5},"mem-prop-5x6--7e":{cels:1,h:6,id:139,w:5},"mem-prop-5x6--7f":{cels:1,h:6,id:140,w:5},"oidoid--Default":{cels:1,h:16,id:141,w:16}},celXY:[22,37,21,27,21,29,21,31,20,33,22,33,20,35,22,35,20,37,24,26,24,26,8,16,8,16,0,16,0,16,16,14,16,14,72,13,72,13,32,26,32,26,0,16,0,16,64,13,64,13,56,13,56,13,48,13,48,13,40,13,40,13,32,13,32,13,56,13,56,13,24,13,24,13,72,0,72,0,64,0,64,0,24,0,24,0,56,0,56,0,48,0,48,0,48,0,48,0,24,0,24,0,40,0,40,0,32,0,32,0,32,0,32,0,16,0,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,45,56,40,56,10,53,5,53,0,53,35,51,30,51,25,51,20,51,15,51,35,45,70,50,65,50,60,50,55,50,50,50,45,50,40,50,10,47,5,47,0,47,70,62,50,56,65,62,60,62,55,62,50,62,45,62,40,62,10,59,5,59,0,59,35,57,70,32,30,57,25,57,20,57,15,57,75,56,70,56,65,56,60,56,75,50,55,56,10,35,75,32,15,33,0,35,5,35,40,38,45,38,65,32,60,32,55,32,50,32,45,32,40,26,50,26,55,26,60,26,65,26,70,26,75,26,16,27,0,29,5,29,10,29,40,32,45,26,10,41,30,45,25,45,20,45,15,45,75,44,70,44,65,44,60,44,55,44,50,44,45,44,40,44,50,38,5,41,0,41,35,39,30,39,25,39,20,39,15,39,75,38,70,38,65,38,60,38,55,38,45,56,0,0]};var V=class{#e=new y;constructor(){this.#e.scale=3,this.#e.z=h.A}free(e){this.#e.free(e)}update(e){let t=new Date;return this.#e.text=De(t),(this.#e.layout(e)||e.cam.invalid)&&(this.#e.xy=e.cam.follow({w:this.#e.wh.w,h:this.#e.wh.h-this.#e.scaledLeading},this.#e.z,"N",{margin:{h:8}})),this.#e.update(e)}};function De(i){let e=`${i.getHours()%12||12}`.padStart(2," "),t=`${i.getMinutes()}`.padStart(2,"0"),r=`${i.getSeconds()}`.padStart(2,"0");return`${e}:${t}:${r}`}var q=class{#e;constructor(e){this.#e=new Y(e,{button:{w:{tag:"background--Strawberry"},nw:{tag:"background--Transparent"},n:{tag:"background--Bubblegum"},e:{tag:"background--Blueberry"},s:{tag:"background--Kiwi"},origin:{tag:"background--Grape"},border:{n:1},margin:{w:2,h:2}},selected:{tag:"background--OrangeCheckerboard"},toggle:!0,text:{text:"render",scale:2},w:64,h:22,x:50,y:25,pressed:{tag:"background--Bubblegum"}})}get on(){return this.#e.on}set on(e){this.#e.on=e}free(e){this.#e.free(e)}update(e){return this.#e.update(e)}};var G=class{#e=new y;#t=0;constructor(){this.#e.z=h.A}free(e){this.#e.free(e)}update(e){this.#t++,this.#e.text=`${this.#t} updates
|
|
106
|
-
${e.renderer.clears+1} renders`,this.#e.layout(e),this.#e.xy=e.cam.follow({w:this.#e.wh.w,h:this.#e.wh.h-this.#e.scaledLeading},this.#e.z,"NE",{margin:{w:8,h:8}}),this.#e.update(e)}};var N=class extends U{#e;#t;#i;constructor(){super({preloadAtlas:{image:document.querySelector("#preload-atlas"),json:Se},backgroundRGBA:4294947327,minWH:{w:320,h:240},poll:{delay:()=>Fe(new Date,l?.seconds),period:(l?.seconds?1:60)*1e3}}),this.#e=new E({alloc:e=>new T(e,0,this.preload,this.looper),allocBytes:c,pageBlocks:10}),this.#t=new q(this),this.#t.on=this.renderer.always,this.#i=new G,this.#r()}onLoop(e){l?.input&&this.#s(),this.renderer.always=this.#t.on;let t=this.#n();this.zoo.update(this),t||=this.zoo.invalid||this.cam.invalid||this.renderer.invalid||this.renderer.always,t&&(this.renderer.clear(4294947327),this.renderer.predraw(this.cam),this.renderer.setDepth(!0),this.renderer.draw(this.sprites),this.renderer.setDepth(!1),this.renderer.draw(this.#e))}#r(){let e=new b(this,{n:{tag:"background--Black"},origin:{tag:"background--Transparent"},border:{n:1},z:h.UIA});this.zoo.add(e);let t=this.cam.follow({w:0,h:0},h.UIA,"NW",{fill:"XY"});e.xy=t,e.wh=t;let r=this.sprites.alloc();r.tag="backpacker--WalkRight",r.x=7,r.y=7,r.z=h.C,r.stretch=!0,r.w*=5,r.h*=5;let n=new A(this,"oidoid--Default","SW");n.z=h.UIG,n.margin={w:4,h:4},this.zoo.add(new v(this,"cursor--Pointer"),this.#t,new V,this.#i,n);let s=this.#e.alloc();s.tag="background--GreyCheckerboard",s.w=K.w,s.h=K.h,s.z=h.UIA}#s(){if(this.input.started){let e=!!this.input.on.length;console.debug(e?`[input] buttons on: ${this.input.on.join(" ")}.`:"[input] buttons off.");let t=this.input.combo;t.length>1&&e&&console.debug(`[input] combo: ${t.map(r=>r.join("+")).join(" ")}.`)}this.input.point?.invalid&&this.input.point?.click&&!this.input.point.pinch&&console.debug(`[input] ${this.input.point.drag.on?"drag":"click"} xy: ${this.input.point.x} ${this.input.point.y}.`),this.input.point?.pinch&&console.debug(`[input] pinch xy: ${this.input.point.pinch.xy.x} ${this.input.point.pinch.xy.y}.`),this.input.wheel&&console.debug(`[input] wheel xy: ${this.input.wheel.delta.xy.x} ${this.input.wheel.delta.xy.y}.`)}#n(){let e=this.input.isAnyOn("L","R","U","D");this.input.isAnyOnStart("L","R","U","D")&&(this.cam.x=Math.trunc(this.cam.x),this.cam.y=Math.trunc(this.cam.y));let t=1/4;return this.input.isOn("L")&&(this.cam.x-=t),this.input.isOn("R")&&(this.cam.x+=t),this.input.isOn("U")&&(this.cam.y-=t),this.input.isOn("D")&&(this.cam.y+=t),this.input.wheel?.delta.xy.y&&(e=!0,this.cam.zoomOut-=this.input.wheel.delta.client.y*.01),this.cam.update(this.canvas),e}};function Fe(i,e){return((e?0:(59-i.getSeconds()%60)*1e3)+1e3-i.getMilliseconds()%1e3)%(e?1e3:6e4)}console.debug(`void v${Ee} \u2500\u2500\u2500oidoid>\xB0\u2500\u2500`);var Ce=new N;await Ce.register("add");l&&(globalThis.v=Ce);
|
|
107
|
-
//# sourceMappingURL=index.js.map
|
|
108
|
-
</script>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
</body></html>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import {test} from 'node:test'
|
|
3
|
-
import {type ConfigFile, type ConfigFileSchema, parse} from './config-file.ts'
|
|
4
|
-
|
|
5
|
-
test('defaults', () => {
|
|
6
|
-
const config: ConfigFileSchema = {}
|
|
7
|
-
assert.deepEqual<ConfigFile>(
|
|
8
|
-
parse('dirname/filename', JSON.stringify(config)),
|
|
9
|
-
{
|
|
10
|
-
$schema:
|
|
11
|
-
'https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json',
|
|
12
|
-
entry: 'dirname/src/assets/index.html',
|
|
13
|
-
meta: 'dirname/dist/meta.json',
|
|
14
|
-
out: {dir: 'dirname/dist/public/', name: undefined},
|
|
15
|
-
preloadAtlas: undefined,
|
|
16
|
-
|
|
17
|
-
dirname: 'dirname',
|
|
18
|
-
filename: 'dirname/filename'
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('overrides', () => {
|
|
24
|
-
const config: Required<ConfigFileSchema> = {
|
|
25
|
-
$schema: '$schema',
|
|
26
|
-
entry: 'entry',
|
|
27
|
-
meta: 'meta',
|
|
28
|
-
out: {dir: 'outDir', name: 'name'},
|
|
29
|
-
preloadAtlas: {dir: 'dir/', image: 'image.webp', json: 'json.json'}
|
|
30
|
-
}
|
|
31
|
-
assert.deepEqual<ConfigFile>(
|
|
32
|
-
parse('dirname/filename', JSON.stringify(config)),
|
|
33
|
-
{
|
|
34
|
-
$schema: '$schema',
|
|
35
|
-
entry: 'dirname/entry',
|
|
36
|
-
meta: 'dirname/meta',
|
|
37
|
-
out: {dir: 'dirname/outDir', name: 'name'},
|
|
38
|
-
preloadAtlas: {
|
|
39
|
-
dir: 'dirname/dir/',
|
|
40
|
-
image: 'dirname/image.webp',
|
|
41
|
-
json: 'dirname/json.json'
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
dirname: 'dirname',
|
|
45
|
-
filename: 'dirname/filename'
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('overrides', () => {
|
|
51
|
-
assert.throws(
|
|
52
|
-
() => parse('dirname/filename', ''),
|
|
53
|
-
Error('config dirname/filename unparsable')
|
|
54
|
-
)
|
|
55
|
-
})
|
package/schema/config-file.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {readFile} from 'node:fs/promises'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import schema from './config-file.v0.json' with {type: 'json'}
|
|
4
|
-
|
|
5
|
-
export type AtlasConfig = {dir: string; image: string; json: string}
|
|
6
|
-
|
|
7
|
-
export type ConfigFile = {
|
|
8
|
-
$schema: string
|
|
9
|
-
entry: string
|
|
10
|
-
meta: string | undefined
|
|
11
|
-
out: {dir: string; name: string | undefined}
|
|
12
|
-
preloadAtlas: AtlasConfig | undefined
|
|
13
|
-
|
|
14
|
-
/** config directory name. */
|
|
15
|
-
dirname: string
|
|
16
|
-
/** config filename. */
|
|
17
|
-
filename: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ConfigFileSchema = {
|
|
21
|
-
$schema?: string | undefined
|
|
22
|
-
entry?: string | undefined
|
|
23
|
-
meta?: string | undefined
|
|
24
|
-
out?: {dir?: string | undefined; name?: string | undefined} | undefined
|
|
25
|
-
preloadAtlas?: AtlasConfig | undefined
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function parseConfigFile(filename: string): Promise<ConfigFile> {
|
|
29
|
-
let str
|
|
30
|
-
try {
|
|
31
|
-
str = await readFile(filename, 'utf8')
|
|
32
|
-
} catch (err) {
|
|
33
|
-
throw Error(`config ${filename} unreadable`, {cause: err})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return parse(filename, str)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** @internal */
|
|
40
|
-
export function parse(filename: string, str: string): ConfigFile {
|
|
41
|
-
const dirname = path.dirname(filename)
|
|
42
|
-
let json: ConfigFileSchema
|
|
43
|
-
try {
|
|
44
|
-
json = JSON.parse(str)
|
|
45
|
-
} catch (err) {
|
|
46
|
-
throw Error(`config ${filename} unparsable`, {cause: err})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
$schema: json.$schema ?? schema.properties.$schema.default,
|
|
51
|
-
entry: path.join(dirname, json.entry ?? schema.properties.entry.default),
|
|
52
|
-
meta: path.join(dirname, json.meta ?? schema.properties.meta.default),
|
|
53
|
-
out: {
|
|
54
|
-
dir: path.join(
|
|
55
|
-
dirname,
|
|
56
|
-
json.out?.dir ?? schema.properties.out.properties.dir.default
|
|
57
|
-
),
|
|
58
|
-
name: json.out?.name
|
|
59
|
-
},
|
|
60
|
-
preloadAtlas: json.preloadAtlas && {
|
|
61
|
-
dir: path.join(dirname, json.preloadAtlas.dir),
|
|
62
|
-
image: path.join(dirname, json.preloadAtlas.image),
|
|
63
|
-
json: path.join(dirname, json.preloadAtlas.json)
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
dirname,
|
|
67
|
-
filename
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json",
|
|
4
|
-
"title": "void Config File Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"description": "a JSON representation of a void config file.",
|
|
7
|
-
"$defs": {
|
|
8
|
-
"Atlas": {
|
|
9
|
-
"type": "object",
|
|
10
|
-
"description": "sprite sheet config.",
|
|
11
|
-
"additionalProperties": false,
|
|
12
|
-
"required": ["dir", "image", "json"],
|
|
13
|
-
"properties": {
|
|
14
|
-
"dir": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "Aseprite asset root directory. all `**.aseprite` files are input.",
|
|
17
|
-
"examples": ["src/assets/atlas/", "./"]
|
|
18
|
-
},
|
|
19
|
-
"image": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"description": "sprite sheet image output.",
|
|
22
|
-
"examples": ["dist/public/atlas.webp", "atlas.png"]
|
|
23
|
-
},
|
|
24
|
-
"json": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "sprite sheet JSON output.",
|
|
27
|
-
"examples": ["src/assets/atlas.json", "atlas.json"]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"additionalProperties": false,
|
|
33
|
-
"properties": {
|
|
34
|
-
"$schema": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"description": "the configuration schema URI.",
|
|
37
|
-
"default": "https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json"
|
|
38
|
-
},
|
|
39
|
-
"entry": {
|
|
40
|
-
"type": "string",
|
|
41
|
-
"default": "src/assets/index.html",
|
|
42
|
-
"description": "HTML entrypoint input. the file should include a script tag sourcing the TypeScript / JavaScript entrypoint."
|
|
43
|
-
},
|
|
44
|
-
"meta": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"default": "dist/meta.json",
|
|
47
|
-
"description": "esbuild bundle metadata file output."
|
|
48
|
-
},
|
|
49
|
-
"out": {
|
|
50
|
-
"type": "object",
|
|
51
|
-
"description": "output config.",
|
|
52
|
-
"additionalProperties": false,
|
|
53
|
-
"properties": {
|
|
54
|
-
"dir": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"description": "HTML and JavaScript output directory.",
|
|
57
|
-
"default": "dist/public/"
|
|
58
|
-
},
|
|
59
|
-
"name": {
|
|
60
|
-
"type": "string",
|
|
61
|
-
"description": "HTML output file stem when watch is disabled. defaults to entry.",
|
|
62
|
-
"examples": ["index", "super-patience"]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"preloadAtlas": {"$ref": "#/$defs/Atlas"}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type {TagFormat} from '../../src/graphics/atlas.ts'
|
|
2
|
-
import type {Box, WH} from '../../src/types/geo.ts'
|
|
3
|
-
|
|
4
|
-
/** https://github.com/aseprite/aseprite/blob/master/docs/ase-file-specs.md */
|
|
5
|
-
export type Aseprite = {meta: AsepriteMeta; frames: AsepriteFrameMap}
|
|
6
|
-
|
|
7
|
-
export type AsepriteFrameMap = {[tag: AsepriteFrameTag]: AsepriteFrame}
|
|
8
|
-
|
|
9
|
-
export type AsepriteMeta = {
|
|
10
|
-
/** `--list-tags`. */
|
|
11
|
-
frameTags: AsepriteTagSpan[]
|
|
12
|
-
size: WH
|
|
13
|
-
/** `--list-slices`. */
|
|
14
|
-
slices: AsepriteSlice[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** `--filename-format='{title}--{tag}--{frame}'`. */
|
|
18
|
-
export type AsepriteFrameTag = `${TagFormat}--${bigint}`
|
|
19
|
-
|
|
20
|
-
export type AsepriteFrame = {
|
|
21
|
-
/** positive animation length in milliseconds. */
|
|
22
|
-
duration: number
|
|
23
|
-
/** bounds including padding. */
|
|
24
|
-
frame: Box
|
|
25
|
-
/** WH without padding. */
|
|
26
|
-
sourceSize: WH
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type AsepriteTagSpan = {
|
|
30
|
-
direction: AsepriteDirection | string
|
|
31
|
-
name: TagFormat | string
|
|
32
|
-
from: number
|
|
33
|
-
/** inclusive ending index, possibly equal to from. */
|
|
34
|
-
to: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type AsepriteSlice = {
|
|
38
|
-
/** '#ff0000ff' is hitbox, '#00ff00ff' is hurtbox, '#0000ffff is both. */
|
|
39
|
-
color: string
|
|
40
|
-
name: TagFormat | string
|
|
41
|
-
keys: {bounds: Box}[]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type AsepriteDirection =
|
|
45
|
-
(typeof AsepriteDirection)[keyof typeof AsepriteDirection]
|
|
46
|
-
export const AsepriteDirection = {
|
|
47
|
-
/** animate from start to end; when looping, return to start. */
|
|
48
|
-
Forward: 'forward',
|
|
49
|
-
/** animate from end to start; when looping, return to end. */
|
|
50
|
-
Reverse: 'reverse',
|
|
51
|
-
/**
|
|
52
|
-
* animate from start to end - 1 or start, whichever is greater; when
|
|
53
|
-
* looping, change direction (initially, end to start + 1 or end, whichever
|
|
54
|
-
* is lesser. a traversal from start to end - 1 then end to start + 1 is
|
|
55
|
-
* considered a complete loop.
|
|
56
|
-
*/
|
|
57
|
-
PingPong: 'pingpong',
|
|
58
|
-
/** like pingpong but start from end - 1 or start, whichever is greater. */
|
|
59
|
-
PingPongReverse: 'pingpong_reverse'
|
|
60
|
-
} as const
|