textmode.js 0.3.2-beta.3 → 0.4.1-beta.1

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.
@@ -28,12 +28,12 @@ ${"↓".repeat(24)}
28
28
  }
29
29
  }
30
30
  var ct = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(ct || {});
31
- const S = class S {
31
+ const I = class I {
32
32
  constructor() {
33
33
  h(this, "u", { globalLevel: 3 });
34
34
  }
35
35
  static _() {
36
- return S.l || (S.l = new S()), S.l;
36
+ return I.l || (I.l = new I()), I.l;
37
37
  }
38
38
  m(t, e) {
39
39
  const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
@@ -55,8 +55,8 @@ const S = class S {
55
55
  this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- h(S, "l", null);
59
- let K = S;
58
+ h(I, "l", null);
59
+ let K = I;
60
60
  const k = K._(), et = /* @__PURE__ */ new WeakMap();
61
61
  function X(a, t) {
62
62
  et.set(a, t);
@@ -362,8 +362,8 @@ class G {
362
362
  this.gt.deleteProgram(this.Lt);
363
363
  }
364
364
  }
365
- const z = `#version 300 es
366
- in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uy;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uy)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, st = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
365
+ const N = `#version 300 es
366
+ in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, st = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
367
  class lt {
368
368
  constructor(t) {
369
369
  h(this, "gt");
@@ -371,9 +371,9 @@ class lt {
371
371
  h(this, "Qt");
372
372
  h(this, "ts");
373
373
  h(this, "ss");
374
- this.gt = t, this.Qt = new G(this.gt, z, `#version 300 es
375
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Jt = new G(this.gt, z, `#version 300 es
376
- precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new G(this.gt, st, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.ss = new G(this.gt, z, `#version 300 es
374
+ this.gt = t, this.Qt = new G(this.gt, N, `#version 300 es
375
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Jt = new G(this.gt, N, `#version 300 es
376
+ precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new G(this.gt, st, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.ss = new G(this.gt, N, `#version 300 es
377
377
  precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`);
378
378
  }
379
379
  es() {
@@ -389,7 +389,7 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform
389
389
  return this.ss;
390
390
  }
391
391
  hs(t) {
392
- return new G(this.gt, z, t);
392
+ return new G(this.gt, N, t);
393
393
  }
394
394
  cs(t, e) {
395
395
  return new G(this.gt, t, e);
@@ -437,7 +437,7 @@ class ft {
437
437
  }
438
438
  bs(t, e, i) {
439
439
  const { shader: s } = t, r = Y(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
440
- s.Xt({ U9: r[2] / r[3], Uy: [r[2], r[3]] });
440
+ s.Xt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
441
441
  const n = (l) => {
442
442
  if (!l || !l.$s()) return;
443
443
  const f = l.unitGeometry, u = l.unitBuffer;
@@ -468,7 +468,7 @@ class ft {
468
468
  Ps(t, e, i, s, r, n, o, c) {
469
469
  e.Ht(), e.Xt(i);
470
470
  const l = this.gt.getParameter(this.gt.VIEWPORT);
471
- if (e.Xt({ U9: l[2] / l[3], Uy: [l[2], l[3]] }), t.As(), t.ks({ x: s, y: r, width: n, height: o }, c), t.$s()) {
471
+ if (e.Xt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.As(), t.ks({ x: s, y: r, width: n, height: o }, c), t.$s()) {
472
472
  const f = t.unitGeometry, u = t.unitBuffer;
473
473
  try {
474
474
  this.gs.us(e.Zt, t.type + "", f, u), t.batch.Ms(e), t.batch.Rs(f.Fs, f.Ss);
@@ -928,7 +928,7 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
928
928
  function W(a) {
929
929
  return a + 3 & -4;
930
930
  }
931
- function V(a, t, e) {
931
+ function $(a, t, e) {
932
932
  const i = t + e;
933
933
  let s = 0;
934
934
  const r = R.t;
@@ -978,7 +978,7 @@ function O(a) {
978
978
  }
979
979
  return { min: t, max: e, table: n };
980
980
  }
981
- function $(a, t) {
981
+ function V(a, t) {
982
982
  let e = 0;
983
983
  for (let i = 1; i <= t.max; i++) {
984
984
  e |= a.readBits(1) << i - 1;
@@ -1030,19 +1030,19 @@ function Pt(a) {
1030
1030
  for (let U = 0; U < p; U++) x[w[U]] = r.readBits(3);
1031
1031
  const _ = O(x), A = [];
1032
1032
  for (; A.length < d + y; ) {
1033
- const U = $(r, _);
1033
+ const U = V(r, _);
1034
1034
  if (U <= 15) A.push(U);
1035
1035
  else if (U === 16) {
1036
- const B = r.readBits(2) + 3, I = A[A.length - 1] || 0;
1037
- for (let Z = 0; Z < B; Z++) A.push(I);
1036
+ const B = r.readBits(2) + 3, S = A[A.length - 1] || 0;
1037
+ for (let Z = 0; Z < B; Z++) A.push(S);
1038
1038
  } else if (U === 17) {
1039
1039
  const B = r.readBits(3) + 3;
1040
- for (let I = 0; I < B; I++) A.push(0);
1040
+ for (let S = 0; S < B; S++) A.push(0);
1041
1041
  } else {
1042
1042
  if (U !== 18) throw Error("Invalid code length symbol");
1043
1043
  {
1044
1044
  const B = r.readBits(7) + 11;
1045
- for (let I = 0; I < B; I++) A.push(0);
1045
+ for (let S = 0; S < B; S++) A.push(0);
1046
1046
  }
1047
1047
  }
1048
1048
  }
@@ -1050,7 +1050,7 @@ function Pt(a) {
1050
1050
  v = O(T), g = O(F);
1051
1051
  }
1052
1052
  for (; ; ) {
1053
- const d = $(r, v);
1053
+ const d = V(r, v);
1054
1054
  if (d < 256) n.push(d);
1055
1055
  else {
1056
1056
  if (d === 256) break;
@@ -1059,7 +1059,7 @@ function Pt(a) {
1059
1059
  let p = o[y];
1060
1060
  const w = c[y];
1061
1061
  w && (p += r.readBits(w));
1062
- const x = $(r, g);
1062
+ const x = V(r, g);
1063
1063
  if (x >= 30) throw Error("Invalid distance symbol");
1064
1064
  let _ = l[x];
1065
1065
  const A = f[x];
@@ -1108,10 +1108,10 @@ function Lt(a) {
1108
1108
  if (p.tag === "head" && w.length >= 12) {
1109
1109
  const x = new Uint8Array(w);
1110
1110
  t.writeUint(x, 8, 0);
1111
- const _ = V(x, 0, W(x.length));
1111
+ const _ = $(x, 0, W(x.length));
1112
1112
  t.writeUint(d, y, _), y += 4;
1113
1113
  } else {
1114
- const x = V(w, 0, W(w.length));
1114
+ const x = $(w, 0, W(w.length));
1115
1115
  t.writeUint(d, y, x), y += 4;
1116
1116
  }
1117
1117
  t.writeUint(d, y, g[p.tag]), y += 4, t.writeUint(d, y, p.data.length), y += 4;
@@ -1124,14 +1124,14 @@ function Lt(a) {
1124
1124
  const p = g.head, w = function(x, _) {
1125
1125
  const A = R, T = _ + 8, F = [x[T], x[T + 1], x[T + 2], x[T + 3]];
1126
1126
  A.writeUint(x, T, 0);
1127
- const U = 2981146554 - (V(x, 0, W(x.length)) >>> 0) >>> 0;
1127
+ const U = 2981146554 - ($(x, 0, W(x.length)) >>> 0) >>> 0;
1128
1128
  return x[T] = F[0], x[T + 1] = F[1], x[T + 2] = F[2], x[T + 3] = F[3], U >>> 0;
1129
1129
  }(d, p);
1130
1130
  t.writeUint(d, p + 8, w);
1131
1131
  }
1132
1132
  return d.buffer;
1133
1133
  }
1134
- const It = { parseTab(a, t, e) {
1134
+ const St = { parseTab(a, t, e) {
1135
1135
  const i = { tables: [], ids: {}, off: t };
1136
1136
  a = new Uint8Array(a.buffer, t, e), t = 0;
1137
1137
  const s = R, r = s.readUshort, n = r(a, t += 2);
@@ -1168,7 +1168,7 @@ const It = { parseTab(a, t, e) {
1168
1168
  const s = new Uint32Array(3 * i);
1169
1169
  for (let r = 0; r < 3 * i; r += 3) s[r] = e(a, t + (r << 2)), s[r + 1] = e(a, t + (r << 2) + 4), s[r + 2] = e(a, t + (r << 2) + 8);
1170
1170
  return { format: 12, groups: s };
1171
- } }, St = { parseTab(a, t, e) {
1171
+ } }, It = { parseTab(a, t, e) {
1172
1172
  const i = R;
1173
1173
  t += 18;
1174
1174
  const s = i.readUshort(a, t);
@@ -1196,7 +1196,7 @@ const It = { parseTab(a, t, e) {
1196
1196
  for (; u < c; ) l = s.readUshort(a, t + (u << 2)), f = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(f), u++;
1197
1197
  for (; u < o; ) r.push(l), n.push(f), u++;
1198
1198
  return { aWidth: r, lsBearing: n };
1199
- } }, tt = { cmap: It, head: St, hhea: Mt, maxp: { parseTab(a, t, e) {
1199
+ } }, tt = { cmap: St, head: It, hhea: Mt, maxp: { parseTab(a, t, e) {
1200
1200
  const i = R;
1201
1201
  return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
1202
1202
  } }, hmtx: Gt, loca: { parseTab(a, t, e, i) {
@@ -1520,7 +1520,7 @@ class kt {
1520
1520
  return k.v(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Ai(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1521
1521
  }
1522
1522
  }
1523
- class Nt {
1523
+ class zt {
1524
1524
  constructor(t, e = 16) {
1525
1525
  h(this, "ki");
1526
1526
  h(this, "Ei", []);
@@ -1641,7 +1641,7 @@ class Nt {
1641
1641
  return this.ki;
1642
1642
  }
1643
1643
  }
1644
- class zt {
1644
+ class Nt {
1645
1645
  constructor(t, e, i) {
1646
1646
  h(this, "Ji");
1647
1647
  h(this, "Qi");
@@ -1767,7 +1767,7 @@ class Wt {
1767
1767
  return this.er.height;
1768
1768
  }
1769
1769
  }
1770
- class N {
1770
+ class z {
1771
1771
  constructor(t, e, i, s) {
1772
1772
  h(this, "yr");
1773
1773
  h(this, "dt");
@@ -1830,7 +1830,7 @@ class N {
1830
1830
  static Fr(t, e, i) {
1831
1831
  const s = t.context, r = s.createTexture();
1832
1832
  s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
1833
- const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new N(s, r, n, o);
1833
+ const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new z(s, r, n, o);
1834
1834
  return c.Mr = i, c;
1835
1835
  }
1836
1836
  get texture() {
@@ -2326,7 +2326,7 @@ class ot {
2326
2326
  return 180 * Math.atan2(e.clientY - t.clientY, e.clientX - t.clientX) / Math.PI;
2327
2327
  }
2328
2328
  }
2329
- const Vt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), $t = (a) => class extends a {
2329
+ const $t = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), Vt = (a) => class extends a {
2330
2330
  rotate(t = 0, e = 0, i = 0) {
2331
2331
  this.xt.state.st(t), this.xt.state.et(e), this.xt.state.it(i);
2332
2332
  }
@@ -2421,12 +2421,12 @@ const Vt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2421
2421
  }
2422
2422
  }
2423
2423
  async loadImage(t) {
2424
- if (typeof t != "string") return N.Fr(this.xt, t, (s) => this.ki.zi(s));
2424
+ if (typeof t != "string") return z.Fr(this.xt, t, (s) => this.ki.zi(s));
2425
2425
  const e = t, i = await new Promise((s, r) => {
2426
2426
  const n = new Image();
2427
2427
  n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2428
2428
  });
2429
- return N.Fr(this.xt, i, (s) => this.ki.zi(s));
2429
+ return z.Fr(this.xt, i, (s) => this.ki.zi(s));
2430
2430
  }
2431
2431
  }, Kt = (a) => class extends a {
2432
2432
  async loadFont(t) {
@@ -2566,57 +2566,53 @@ class Qt {
2566
2566
  h(this, "rh", /* @__PURE__ */ new Map());
2567
2567
  this.th = t;
2568
2568
  }
2569
- async installMany(t) {
2570
- for (const e of t) await this.use(e);
2571
- }
2572
- async use(t) {
2573
- if (this.sh.has(t.name)) return void console.warn(`[textmode.js] Plugin "${t.name}" is already installed.`);
2574
- const e = this.nh(t.name);
2575
- try {
2576
- await t.install(this.th, e);
2577
- } catch (i) {
2578
- throw this.oh(t.name), i;
2569
+ async nh(t) {
2570
+ for (const e of t) {
2571
+ if (this.sh.has(e.name)) return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);
2572
+ const i = this.oh(e.name);
2573
+ try {
2574
+ await e.install(this.th, i);
2575
+ } catch (s) {
2576
+ throw this.hh(e.name), s;
2577
+ }
2578
+ this.sh.set(e.name, e), this.eh.push(e.name);
2579
2579
  }
2580
- this.sh.set(t.name, t), this.eh.push(t.name);
2581
2580
  }
2582
- async unuse(t) {
2581
+ async ah(t) {
2583
2582
  const e = this.sh.get(t);
2584
2583
  if (!e) return;
2585
- const i = this.nh(t);
2584
+ const i = this.oh(t);
2586
2585
  if (e.uninstall) try {
2587
2586
  await e.uninstall(this.th, i);
2588
2587
  } catch (s) {
2589
2588
  console.error(`[textmode.js] Error while uninstalling plugin "${t}":`, s);
2590
2589
  }
2591
- this.sh.delete(t), this.eh.splice(this.eh.indexOf(t), 1), this.oh(t);
2592
- }
2593
- has(t) {
2594
- return this.sh.has(t);
2590
+ this.sh.delete(t), this.eh.splice(this.eh.indexOf(t), 1), this.hh(t);
2595
2591
  }
2596
2592
  runPreDrawHooks() {
2597
- this.hh(this.ih, "preDraw");
2593
+ this.uh(this.ih, "preDraw");
2598
2594
  }
2599
2595
  runPostDrawHooks() {
2600
- this.hh(this.rh, "postDraw");
2596
+ this.uh(this.rh, "postDraw");
2601
2597
  }
2602
- async disposeAll() {
2598
+ async fh() {
2603
2599
  const t = [...this.sh.keys()];
2604
- for (const e of t) await this.unuse(e);
2600
+ for (const e of t) await this.ah(e);
2605
2601
  }
2606
- nh(t) {
2607
- return { ...this.th.ah(), registerPreDrawHook: (e) => this.uh(this.ih, t, e), registerPostDrawHook: (e) => this.uh(this.rh, t, e) };
2602
+ oh(t) {
2603
+ return { ...this.th.dh(), registerPreDrawHook: (e) => this._h(this.ih, t, e), registerPostDrawHook: (e) => this._h(this.rh, t, e) };
2608
2604
  }
2609
- uh(t, e, i) {
2605
+ _h(t, e, i) {
2610
2606
  const s = t.get(e) ?? /* @__PURE__ */ new Set();
2611
2607
  return s.add(i), t.set(e, s), () => {
2612
2608
  const r = t.get(e);
2613
2609
  r && (r.delete(i), r.size === 0 && t.delete(e));
2614
2610
  };
2615
2611
  }
2616
- oh(t) {
2612
+ hh(t) {
2617
2613
  this.ih.delete(t), this.rh.delete(t);
2618
2614
  }
2619
- hh(t, e) {
2615
+ uh(t, e) {
2620
2616
  for (const i of this.eh) {
2621
2617
  const s = t.get(i);
2622
2618
  if (s) for (const r of s) try {
@@ -2637,91 +2633,90 @@ class te {
2637
2633
  h(this, "In");
2638
2634
  h(this, "Jo");
2639
2635
  h(this, "Qo");
2640
- h(this, "fh");
2641
- h(this, "Vo");
2642
- h(this, "dh");
2643
- h(this, "_h");
2644
2636
  h(this, "ph");
2637
+ h(this, "Vo");
2638
+ h(this, "mh");
2639
+ h(this, "gh");
2640
+ h(this, "yh");
2645
2641
  }
2646
2642
  Zo() {
2647
2643
  }
2648
2644
  }
2649
2645
  class ee extends function(e, ...i) {
2650
2646
  return i.reduce((s, r) => r(s), e);
2651
- }(te, $t, Kt, qt, jt, Jt, Zt) {
2647
+ }(te, Vt, Kt, qt, jt, Jt, Zt) {
2652
2648
  constructor(e = {}) {
2653
- var i;
2654
2649
  super();
2655
- h(this, "mh");
2656
- h(this, "gh");
2657
- h(this, "yh", !1);
2658
- h(this, "Ch", !1);
2659
- h(this, "wh", () => {
2650
+ h(this, "Ch");
2651
+ h(this, "wh", !1);
2652
+ h(this, "bh", !1);
2653
+ h(this, "$h", !1);
2654
+ h(this, "xh", () => {
2660
2655
  });
2661
- h(this, "bh", () => {
2656
+ h(this, "Mh", () => {
2662
2657
  });
2663
- h(this, "$h", () => {
2658
+ h(this, "Rh", () => {
2664
2659
  });
2665
- h(this, "xh");
2660
+ h(this, "Fh");
2666
2661
  h(this, "lr");
2667
2662
  h(this, "cr", !1);
2668
- h(this, "Mh");
2669
- this.mh = new Qt(this), this.gh = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.cr = e.overlay ?? !1, this.er = new Wt(e), this.xt = new _t(this.er.gr()), this.ki = new Nt(this.xt, e.fontSize ?? 16), this.qo = new Xt(e.frameRate ?? 60), this.In = new rt(this.er), this.Jo = new ot(this.er, this.In), this.Qo = new nt(), this.fh = this.xt.At(), this.dh = this.xt.rs(), this.Rh(e);
2663
+ h(this, "Sh");
2664
+ this.Ch = new Qt(this), this.cr = e.overlay ?? !1, this.er = new Wt(e), this.xt = new _t(this.er.gr()), this.ki = new zt(this.xt, e.fontSize ?? 16), this.qo = new Xt(e.frameRate ?? 60), this.In = new rt(this.er), this.Jo = new ot(this.er, this.In), this.Qo = new nt(), this.ph = this.xt.At(), this.mh = this.xt.rs(), this.Th(e);
2670
2665
  }
2671
- async Rh(e) {
2666
+ async Th(e) {
2672
2667
  await this.ki.Ni(e.fontSource);
2673
2668
  const i = this.ki.maxGlyphDimensions;
2674
- this.Gr = new zt(this.er.canvas, i.width, i.height), this.In.Ni(this.Gr), this.Jo.Ni(this.Gr), this.Vo = this.xt.Ye(this.Gr.cols, this.Gr.rows, 5), this._h = this.xt.Ye(this.Gr.width, this.Gr.height, 1), this.cr && (this.Mh = N.Fr(this.xt, this.er.targetCanvas, (s) => this.ki.zi(s))), this.ph = this.xt.cs(st, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.Fh(), await this.mh.installMany(this.gh), this.gh = [], this.yh = !0, this.wh(), this.qo.start(() => this.Zo());
2675
- }
2676
- async use(e) {
2677
- return this.yh ? await this.mh.use(e) : this.gh.push(e), this;
2678
- }
2679
- async unuse(e) {
2680
- return this.yh ? (await this.mh.unuse(e), this) : (this.gh = this.gh.filter((i) => i.name !== e), this);
2669
+ this.Gr = new Nt(this.er.canvas, i.width, i.height), this.In.Ni(this.Gr), this.Jo.Ni(this.Gr), this.Vo = this.xt.Ye(this.Gr.cols, this.Gr.rows, 5), this.gh = this.xt.Ye(this.Gr.width, this.Gr.height, 1), this.cr && (this.Sh = z.Fr(this.xt, this.er.targetCanvas, (s) => this.ki.zi(s))), this.yh = this.xt.cs(st, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.Ah(), await this.Ch.nh(e.plugins ?? []), this.xh(), this.qo.start(() => this.Zo());
2681
2670
  }
2682
- hasPlugin(e) {
2683
- return this.yh ? this.mh.has(e) : this.gh.some((i) => i.name === e);
2684
- }
2685
- ah() {
2686
- return { renderer: this.xt, font: this.ki, grid: this.Gr, canvas: this.er, drawFramebuffer: this.Vo, asciiFramebuffer: this._h, flushDrawCommands: () => {
2687
- this.xt.zt(this.fh);
2671
+ dh() {
2672
+ return { renderer: this.xt, font: this.ki, grid: this.Gr, canvas: this.er, drawFramebuffer: this.Vo, asciiFramebuffer: this.gh, flushDrawCommands: () => {
2673
+ this.xt.zt(this.ph);
2688
2674
  } };
2689
2675
  }
2690
- Fh() {
2691
- this.xh = () => {
2692
- this.cr && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.$h();
2693
- }, window.addEventListener("resize", this.xh), this.In.an(), this.Jo.an(), this.Qo.an(), window.addEventListener("blur", () => {
2676
+ Ah() {
2677
+ this.Fh = () => {
2678
+ this.cr && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.Rh();
2679
+ }, window.addEventListener("resize", this.Fh), this.In.an(), this.Jo.an(), this.Qo.an(), window.addEventListener("blur", () => {
2694
2680
  this.Qo.Gn();
2695
2681
  }), window.ResizeObserver && this.cr && (this.lr = new ResizeObserver(() => {
2696
2682
  this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height);
2697
2683
  }), this.lr.observe(this.er.targetCanvas));
2698
2684
  }
2699
2685
  Zo() {
2700
- if (this.qo.measureFrameRate(), this.qo.incrementFrame(), this.Ch) return;
2701
- if (this.cr) {
2702
- const i = this.xt.context;
2703
- i.bindTexture(i.TEXTURE_2D, this.Mh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.er.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2686
+ this.bh = !0;
2687
+ try {
2688
+ if (this.qo.measureFrameRate(), this.qo.incrementFrame(), this.cr) {
2689
+ const i = this.xt.context;
2690
+ i.bindTexture(i.TEXTURE_2D, this.Sh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.er.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2691
+ }
2692
+ this.Ch.runPreDrawHooks(), this.Vo.begin(), this.xt.Le(this.ph), this.Mh(), this.xt.zt(this.ph), this.Vo.end(), this.gh.begin(), this.xt.Le(this.mh), this.mh.Xt({ U0: this.ki.fontFramebuffer, U1: [this.ki.textureColumns, this.ki.textureRows], U2: this.Vo.textures[0], U3: this.Vo.textures[1], U4: this.Vo.textures[2], U5: this.Vo.textures[4], U6: this.Vo.textures[3], U7: [this.Gr.cols, this.Gr.rows], U8: [this.gh.width, this.gh.height], U9: this.gh.width / this.gh.height }), this.xt.We(0, 0, this.er.width, this.er.height), this.gh.end();
2693
+ const e = this.xt.state.canvasBackgroundColor;
2694
+ this.xt.Ys(e[0], e[1], e[2], e[3]), this.xt.Le(this.yh), this.yh.Xt({ Ua: this.gh.textures[0], Ub: [this.gh.width, this.gh.height], Uc: [this.Gr.offsetX, this.Gr.offsetY], Ud: [this.Gr.width, this.Gr.height] }), this.xt.We(this.Gr.offsetX, this.Gr.offsetY, this.Gr.width, this.Gr.height), this.Ch.runPostDrawHooks();
2695
+ } catch (e) {
2696
+ console.error("[textmode.js] Error during render:", e);
2697
+ } finally {
2698
+ this.bh = !1, this.wh && !this.$h && this.zh();
2704
2699
  }
2705
- this.mh.runPreDrawHooks(), this.Vo.begin(), this.xt.Le(this.fh), this.bh(), this.xt.zt(this.fh), this.Vo.end(), this._h.begin(), this.xt.Le(this.dh), this.dh.Xt({ U0: this.ki.fontFramebuffer, U1: [this.ki.textureColumns, this.ki.textureRows], U2: this.Vo.textures[0], U3: this.Vo.textures[1], U4: this.Vo.textures[2], U5: this.Vo.textures[4], U6: this.Vo.textures[3], U7: [this.Gr.cols, this.Gr.rows], U8: [this._h.width, this._h.height], U9: this._h.width / this._h.height }), this.xt.We(0, 0, this.er.width, this.er.height), this._h.end();
2706
- const e = this.xt.state.canvasBackgroundColor;
2707
- this.xt.Ys(e[0], e[1], e[2], e[3]), this.xt.Le(this.ph), this.ph.Xt({ Ua: this._h.textures[0], Ub: [this._h.width, this._h.height], Uc: [this.Gr.offsetX, this.Gr.offsetY], Ud: [this.Gr.width, this.Gr.height] }), this.xt.We(this.Gr.offsetX, this.Gr.offsetY, this.Gr.width, this.Gr.height), this.mh.runPostDrawHooks();
2708
2700
  }
2709
2701
  setup(e) {
2710
- this.wh = e;
2702
+ this.xh = e;
2711
2703
  }
2712
2704
  draw(e) {
2713
- this.bh = e;
2705
+ this.Mh = e;
2714
2706
  }
2715
2707
  windowResized(e) {
2716
- this.$h = e;
2708
+ this.Rh = e;
2717
2709
  }
2718
2710
  resizeCanvas(e, i) {
2719
- this.er.vr(e, i), this.Gr.nr(), this.Vo.resize(this.Gr.cols, this.Gr.rows), this._h.resize(this.Gr.width, this.Gr.height), this.xt.Ze(), this.In.hn(), this.Jo.wo(), this.Zo();
2711
+ this.er.vr(e, i), this.Gr.nr(), this.Vo.resize(this.Gr.cols, this.Gr.rows), this.gh.resize(this.Gr.width, this.Gr.height), this.xt.Ze(), this.In.hn(), this.Jo.wo(), this.Zo();
2720
2712
  }
2721
2713
  destroy() {
2722
- this.Ch || (this.qo.stop(), this.mh.disposeAll().catch((e) => {
2714
+ this.$h || this.wh || (this.wh = !0, this.qo.stop(), this.noLoop(), this.bh || this.zh());
2715
+ }
2716
+ zh() {
2717
+ this.$h || (this.wh = !1, this.Ch.fh().catch((e) => {
2723
2718
  console.error("[textmode.js] Error while disposing plugins:", e);
2724
- }), window.removeEventListener("resize", this.xh), this.In.pn(), this.Jo.pn(), this.Qo.pn(), this.ki.Pt(), this.xt.Pt(), this._h.Pt(), this.ph.Pt(), this.Mh && this.Mh.Pt(), this.Ch = !0);
2719
+ }), window.removeEventListener("resize", this.Fh), this.In.pn(), this.Jo.pn(), this.Qo.pn(), this.ki.Pt(), this.xt.Pt(), this.gh.Pt(), this.yh.Pt(), this.er.Pt(), this.Sh && this.Sh.Pt(), this.$h = !0);
2725
2720
  }
2726
2721
  get grid() {
2727
2722
  return this.Gr;
@@ -2742,10 +2737,10 @@ class ee extends function(e, ...i) {
2742
2737
  return this.Vo;
2743
2738
  }
2744
2739
  get isDisposed() {
2745
- return this.Ch;
2740
+ return this.$h;
2746
2741
  }
2747
2742
  get overlay() {
2748
- return this.Mh;
2743
+ return this.Sh;
2749
2744
  }
2750
2745
  }
2751
2746
  class J {
@@ -2758,23 +2753,21 @@ class J {
2758
2753
  k.C(t);
2759
2754
  }
2760
2755
  static get version() {
2761
- return "0.3.2-beta.3";
2756
+ return "0.4.1-beta.1";
2762
2757
  }
2763
2758
  }
2764
- const se = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), re = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: Ht, mouse: Yt, touch: Vt }, Symbol.toStringTag, { value: "Module" })), ne = J.create, oe = J.setErrorLevel, he = J.version;
2759
+ const se = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: Ht, mouse: Yt, touch: $t }, Symbol.toStringTag, { value: "Module" })), re = J.create, ne = J.setErrorLevel, oe = J.version;
2765
2760
  export {
2766
- Qt as PluginManager,
2767
2761
  Wt as TextmodeCanvas,
2768
2762
  ct as TextmodeErrorLevel,
2769
- Nt as TextmodeFont,
2763
+ zt as TextmodeFont,
2770
2764
  q as TextmodeFramebuffer,
2771
- zt as TextmodeGrid,
2772
- N as TextmodeImage,
2765
+ Nt as TextmodeGrid,
2766
+ z as TextmodeImage,
2773
2767
  ee as Textmodifier,
2774
- ne as create,
2775
- se as export,
2776
- re as input,
2777
- oe as setErrorLevel,
2768
+ re as create,
2769
+ se as input,
2770
+ ne as setErrorLevel,
2778
2771
  J as textmode,
2779
- he as version
2772
+ oe as version
2780
2773
  };