textmode.js 0.1.6-beta.1 → 0.1.6-beta.3

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.
@@ -1,9 +1,9 @@
1
1
  var iA = Object.defineProperty;
2
2
  var sA = (n, A, e) => A in n ? iA(n, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[A] = e;
3
3
  var a = (n, A, e) => sA(n, typeof A != "symbol" ? A + "" : A, e);
4
- class P extends Error {
4
+ class p extends Error {
5
5
  constructor(e, t, r = {}) {
6
- const i = P.createFormattedMessage(e, r);
6
+ const i = p.createFormattedMessage(e, r);
7
7
  super(i);
8
8
  a(this, "originalError");
9
9
  a(this, "context");
@@ -19,7 +19,7 @@ class P extends Error {
19
19
 
20
20
  📋 Context:`;
21
21
  for (const [i, s] of Object.entries(t)) {
22
- const o = P.formatValue(s);
22
+ const o = p.formatValue(s);
23
23
  r += `
24
24
  - ${i}: ${o}`;
25
25
  }
@@ -38,16 +38,16 @@ class P extends Error {
38
38
  if (typeof e == "string") return `"${e}"`;
39
39
  if (typeof e == "number" || typeof e == "boolean") return String(e);
40
40
  if (Array.isArray(e))
41
- return e.length === 0 ? "[]" : e.length <= 5 ? `[${e.map((t) => P.formatValue(t)).join(", ")}]` : `[${e.slice(0, 3).map((t) => P.formatValue(t)).join(", ")}, ... +${e.length - 3} more]`;
41
+ return e.length === 0 ? "[]" : e.length <= 5 ? `[${e.map((t) => p.formatValue(t)).join(", ")}]` : `[${e.slice(0, 3).map((t) => p.formatValue(t)).join(", ")}, ... +${e.length - 3} more]`;
42
42
  if (typeof e == "object") {
43
43
  const t = Object.keys(e);
44
- return t.length === 0 ? "{}" : t.length <= 3 ? `{ ${t.map((s) => `${s}: ${P.formatValue(e[s])}`).join(", ")} }` : `{ ${t.slice(0, 2).map((i) => `${i}: ${P.formatValue(e[i])}`).join(", ")}, ... +${t.length - 2} more }`;
44
+ return t.length === 0 ? "{}" : t.length <= 3 ? `{ ${t.map((s) => `${s}: ${p.formatValue(e[s])}`).join(", ")} }` : `{ ${t.slice(0, 2).map((i) => `${i}: ${p.formatValue(e[i])}`).join(", ")}, ... +${t.length - 2} more }`;
45
45
  }
46
46
  return String(e);
47
47
  }
48
48
  }
49
49
  var oA = /* @__PURE__ */ ((n) => (n[n.SILENT = 0] = "SILENT", n[n.WARNING = 1] = "WARNING", n[n.ERROR = 2] = "ERROR", n[n.THROW = 3] = "THROW", n))(oA || {});
50
- const v = class v {
50
+ const b = class b {
51
51
  constructor() {
52
52
  a(this, "_options", {
53
53
  globalLevel: 3
@@ -55,7 +55,7 @@ const v = class v {
55
55
  });
56
56
  }
57
57
  static getInstance() {
58
- return v._instance || (v._instance = new v()), v._instance;
58
+ return b._instance || (b._instance = new b()), b._instance;
59
59
  }
60
60
  /**
61
61
  * Handle an error based on the configured settings
@@ -71,15 +71,15 @@ const v = class v {
71
71
  return console.group(
72
72
  `%c${r} Oops! (╯°□°)╯︵ Something went wrong in your code.`,
73
73
  "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;"
74
- ), console.warn(P.createFormattedMessage(A, e)), console.groupEnd(), !1;
74
+ ), console.warn(p.createFormattedMessage(A, e)), console.groupEnd(), !1;
75
75
  case 2:
76
76
  return console.group(
77
77
  `%c${r} Oops! (╯°□°)╯︵ Something went wrong in your code.`,
78
78
  "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;"
79
- ), console.error(P.createFormattedMessage(A, e)), console.groupEnd(), !1;
79
+ ), console.error(p.createFormattedMessage(A, e)), console.groupEnd(), !1;
80
80
  case 3:
81
81
  default:
82
- const i = new P(A, t, e);
82
+ const i = new p(A, t, e);
83
83
  throw console.group(
84
84
  `%c${r} Oops! (╯°□°)╯︵ Something went wrong in your code.`,
85
85
  "color: #d32f2f; font-weight: bold; background: #ffcdd2; padding: 2px 6px; border-radius: 3px;"
@@ -103,9 +103,9 @@ const v = class v {
103
103
  this._options.globalLevel = A;
104
104
  }
105
105
  };
106
- a(v, "_instance", null);
107
- let V = v;
108
- const f = V.getInstance();
106
+ a(b, "_instance", null);
107
+ let k = b;
108
+ const f = k.getInstance();
109
109
  class aA {
110
110
  constructor(A, e, t = e, r = {}) {
111
111
  a(this, "gl");
@@ -244,11 +244,11 @@ class y {
244
244
  /** Bytes per vertex: depends on position format (vec2 vs vec3) */
245
245
  a(this, "bytesPerVertex");
246
246
  this.gl = A, this.bytesPerVertex = 16;
247
- const s = A.getParameter(A.VIEWPORT), o = s[2], g = s[3], B = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, E = e / o * 2 - 1, l = (e + r) / o * 2 - 1;
248
- let h, c;
249
- B ? (h = t / g * 2 - 1, c = (t + i) / g * 2 - 1) : (h = 1 - t / g * 2, c = 1 - (t + i) / g * 2);
247
+ const s = A.getParameter(A.VIEWPORT), o = s[2], g = s[3], B = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, E = e / o * 2 - 1, h = (e + r) / o * 2 - 1;
248
+ let l, c;
249
+ B ? (l = t / g * 2 - 1, c = (t + i) / g * 2 - 1) : (l = 1 - t / g * 2, c = 1 - (t + i) / g * 2);
250
250
  let d, u, m, D;
251
- d = E, m = l, u = h, D = c;
251
+ d = E, m = h, u = l, D = c;
252
252
  const C = this.generateVertices(d, u, m, D);
253
253
  this.vertexBuffer = A.createBuffer(), A.bindBuffer(A.ARRAY_BUFFER, this.vertexBuffer), A.bufferData(A.ARRAY_BUFFER, C, A.STATIC_DRAW);
254
254
  }
@@ -335,13 +335,13 @@ class gA {
335
335
  /** Bytes per vertex: vec2+vec2 = 16 bytes */
336
336
  a(this, "bytesPerVertex");
337
337
  this.gl = A, this.bytesPerVertex = 16;
338
- const o = A.getParameter(A.VIEWPORT), g = o[2], B = o[3], E = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, l = r - e, h = i - t, c = Math.sqrt(l * l + h * h);
338
+ const o = A.getParameter(A.VIEWPORT), g = o[2], B = o[3], E = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, h = r - e, l = i - t, c = Math.sqrt(h * h + l * l);
339
339
  if (c === 0) {
340
340
  const rA = this.generateVertices(0, 0, 0, 0);
341
341
  this.vertexBuffer = A.createBuffer(), A.bindBuffer(A.ARRAY_BUFFER, this.vertexBuffer), A.bufferData(A.ARRAY_BUFFER, rA, A.STATIC_DRAW);
342
342
  return;
343
343
  }
344
- const d = l / c, m = -(h / c), D = d, C = s / 2, p = e + m * C, F = t + D * C, b = e - m * C, _ = t - D * C, R = r + m * C, T = i + D * C, j = r - m * C, X = i - D * C, Z = p / g * 2 - 1, q = b / g * 2 - 1, AA = R / g * 2 - 1, eA = j / g * 2 - 1;
344
+ const d = h / c, m = -(l / c), D = d, C = s / 2, P = e + m * C, F = t + D * C, v = e - m * C, _ = t - D * C, R = r + m * C, T = i + D * C, j = r - m * C, X = i - D * C, Z = P / g * 2 - 1, q = v / g * 2 - 1, AA = R / g * 2 - 1, eA = j / g * 2 - 1;
345
345
  let G, M, U, Y;
346
346
  E ? (G = F / B * 2 - 1, M = _ / B * 2 - 1, U = T / B * 2 - 1, Y = X / B * 2 - 1) : (G = 1 - F / B * 2, M = 1 - _ / B * 2, U = 1 - T / B * 2, Y = 1 - X / B * 2);
347
347
  const tA = this.generateLineVertices(
@@ -465,7 +465,7 @@ class BA extends K {
465
465
  new gA(this.gl, this.x, this.y, this.x2, this.y2, e).render();
466
466
  }
467
467
  }
468
- class I {
468
+ class w {
469
469
  constructor(A, e, t) {
470
470
  a(this, "gl");
471
471
  a(this, "program");
@@ -612,8 +612,8 @@ class I {
612
612
  this.textureUnitCounter = 0;
613
613
  }
614
614
  }
615
- var w = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}", EA = "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}", lA = "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}";
616
- class hA {
615
+ var I = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}", EA = "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}", hA = "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}";
616
+ class lA {
617
617
  constructor(A) {
618
618
  a(this, "gl");
619
619
  a(this, "imageShader");
@@ -631,7 +631,7 @@ class hA {
631
631
  // in degrees
632
632
  // State stack for push/pop functionality
633
633
  a(this, "stateStack", []);
634
- this.gl = A, this.imageShader = new I(this.gl, w, EA), this.solidColorShader = new I(this.gl, w, lA), this.gl.enable(this.gl.BLEND), this.gl.blendEquation(this.gl.FUNC_ADD), this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
634
+ this.gl = A, this.imageShader = new w(this.gl, I, EA), this.solidColorShader = new w(this.gl, I, hA), this.gl.enable(this.gl.BLEND), this.gl.blendEquation(this.gl.FUNC_ADD), this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
635
635
  }
636
636
  /**
637
637
  * Set the current shader
@@ -732,10 +732,10 @@ class hA {
732
732
  this.currentShader = null, this.stateStack = [], this.currentRotation = 0, this.fillMode = !0, this.strokeMode = !0, this.currentFillColor = [1, 1, 1, 1], this.currentStrokeColor = [0, 0, 0, 1], this.currentStrokeWeight = 1;
733
733
  }
734
734
  createShader(A, e) {
735
- return new I(this.gl, A, e);
735
+ return new w(this.gl, A, e);
736
736
  }
737
737
  createFilterShader(A) {
738
- return new I(this.gl, w, A);
738
+ return new w(this.gl, I, A);
739
739
  }
740
740
  /**
741
741
  * Set a uniform value for the current shader
@@ -750,8 +750,8 @@ class hA {
750
750
  const i = new nA(this.gl, A, e, t, r);
751
751
  if (this.currentShader !== null) {
752
752
  if (this.currentRotation !== 0) {
753
- const { centerX: l, centerY: h, radians: c, aspectRatio: d } = this.calculateRotationParams(A, e, t, r);
754
- this.setUniform("u_rotation", c), this.setUniform("u_center", [l, h]), this.setUniform("u_aspectRatio", d);
753
+ const { centerX: h, centerY: l, radians: c, aspectRatio: d } = this.calculateRotationParams(A, e, t, r);
754
+ this.setUniform("u_rotation", c), this.setUniform("u_center", [h, l]), this.setUniform("u_aspectRatio", d);
755
755
  } else
756
756
  this.setUniform("u_rotation", 0), this.setUniform("u_center", [0, 0]), this.setUniform("u_aspectRatio", 1);
757
757
  i.renderFill(), this.currentShader = null;
@@ -773,25 +773,25 @@ class hA {
773
773
  const i = new BA(this.gl, A, e, t, r);
774
774
  if (this.currentShader !== null) {
775
775
  if (this.currentRotation !== 0) {
776
- const u = (A + t) / 2, m = (e + r) / 2, D = Math.abs(t - A), C = Math.abs(r - e), { centerX: p, centerY: F, radians: b, aspectRatio: _ } = this.calculateRotationParams(u - D / 2, m - C / 2, D, C);
777
- this.setUniform("u_rotation", b), this.setUniform("u_center", [p, F]), this.setUniform("u_aspectRatio", _);
776
+ const u = (A + t) / 2, m = (e + r) / 2, D = Math.abs(t - A), C = Math.abs(r - e), { centerX: P, centerY: F, radians: v, aspectRatio: _ } = this.calculateRotationParams(u - D / 2, m - C / 2, D, C);
777
+ this.setUniform("u_rotation", v), this.setUniform("u_center", [P, F]), this.setUniform("u_aspectRatio", _);
778
778
  } else
779
779
  this.setUniform("u_rotation", 0), this.setUniform("u_center", [0, 0]), this.setUniform("u_aspectRatio", 1);
780
780
  i.renderStroke(this.currentStrokeWeight), this.currentShader = null;
781
781
  return;
782
782
  }
783
- const s = this.solidColorShader, o = (A + t) / 2, g = (e + r) / 2, B = Math.abs(t - A), E = Math.abs(r - e), { centerX: l, centerY: h, radians: c, aspectRatio: d } = this.calculateRotationParams(o - B / 2, g - E / 2, B, E);
784
- this.shader(s), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [l, h]), this.setUniform("u_aspectRatio", d), i.renderStroke(this.currentStrokeWeight), this.currentShader = null;
783
+ const s = this.solidColorShader, o = (A + t) / 2, g = (e + r) / 2, B = Math.abs(t - A), E = Math.abs(r - e), { centerX: h, centerY: l, radians: c, aspectRatio: d } = this.calculateRotationParams(o - B / 2, g - E / 2, B, E);
784
+ this.shader(s), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [h, l]), this.setUniform("u_aspectRatio", d), i.renderStroke(this.currentStrokeWeight), this.currentShader = null;
785
785
  }
786
786
  /**
787
787
  * Calculate rotation parameters for built-in shaders (NDC coordinates)
788
788
  */
789
789
  calculateRotationParams(A, e, t, r) {
790
- const i = this.gl.getParameter(this.gl.VIEWPORT), s = i[2], o = i[3], g = s / o, B = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, E = A + t / 2, l = e + r / 2, h = E / s * 2 - 1;
790
+ const i = this.gl.getParameter(this.gl.VIEWPORT), s = i[2], o = i[3], g = s / o, B = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, E = A + t / 2, h = e + r / 2, l = E / s * 2 - 1;
791
791
  let c;
792
- B ? c = l / o * 2 - 1 : c = 1 - l / o * 2;
792
+ B ? c = h / o * 2 - 1 : c = 1 - h / o * 2;
793
793
  const d = this.currentRotation * Math.PI / 180;
794
- return { centerX: h, centerY: c, radians: d, aspectRatio: g };
794
+ return { centerX: l, centerY: c, radians: d, aspectRatio: g };
795
795
  }
796
796
  /**
797
797
  * Create a new framebuffer
@@ -855,15 +855,15 @@ Q.parse = function(n) {
855
855
  hmtx: B.hmtx,
856
856
  loca: B.loca,
857
857
  glyf: B.glyf
858
- }, l = { _data: i, _index: s, _offset: o };
859
- for (var h in E) {
860
- var c = Q.findTable(i, h, o);
858
+ }, h = { _data: i, _index: s, _offset: o };
859
+ for (var l in E) {
860
+ var c = Q.findTable(i, l, o);
861
861
  if (c) {
862
862
  var d = c[0], u = g[d];
863
- u == null && (u = E[h].parseTab(i, d, c[1], l)), l[h] = g[d] = u;
863
+ u == null && (u = E[l].parseTab(i, d, c[1], h)), h[l] = g[d] = u;
864
864
  }
865
865
  }
866
- return l;
866
+ return h;
867
867
  }, e = new Uint8Array(n), t = {}, r = A(e, 0, 0, t);
868
868
  return [r];
869
869
  };
@@ -921,17 +921,17 @@ Q.T.cmap = {
921
921
  for (var g = [], B = 0; B < o; B++) {
922
922
  var E = i(n, A);
923
923
  A += 2;
924
- var l = i(n, A);
924
+ var h = i(n, A);
925
925
  A += 2;
926
- var h = r.readUint(n, A);
926
+ var l = r.readUint(n, A);
927
927
  A += 4;
928
- var c = "p" + E + "e" + l, d = g.indexOf(h);
928
+ var c = "p" + E + "e" + h, d = g.indexOf(l);
929
929
  if (d == -1) {
930
930
  d = t.tables.length;
931
931
  var u = {};
932
- g.push(h);
933
- var m = u.format = i(n, h);
934
- m == 4 ? u = s.parse4(n, h, u) : m == 12 && (u = s.parse12(n, h, u)), t.tables.push(u);
932
+ g.push(l);
933
+ var m = u.format = i(n, l);
934
+ m == 4 ? u = s.parse4(n, l, u) : m == 12 && (u = s.parse12(n, l, u)), t.tables.push(u);
935
935
  }
936
936
  t.ids[c] != null && console.log("multiple tables for one platform+encoding: " + c), t.ids[c] = d;
937
937
  }
@@ -996,10 +996,10 @@ Q.T.hhea = {
996
996
  };
997
997
  Q.T.hmtx = {
998
998
  parseTab: function(n, A, e, t) {
999
- for (var r = Q.B, i = [], s = [], o = t.maxp.numGlyphs, g = t.hhea.numberOfHMetrics, B = 0, E = 0, l = 0; l < g; )
1000
- B = r.readUshort(n, A + (l << 2)), E = r.readShort(n, A + (l << 2) + 2), i.push(B), s.push(E), l++;
1001
- for (; l < o; )
1002
- i.push(B), s.push(E), l++;
999
+ for (var r = Q.B, i = [], s = [], o = t.maxp.numGlyphs, g = t.hhea.numberOfHMetrics, B = 0, E = 0, h = 0; h < g; )
1000
+ B = r.readUshort(n, A + (h << 2)), E = r.readShort(n, A + (h << 2) + 2), i.push(B), s.push(E), h++;
1001
+ for (; h < o; )
1002
+ i.push(B), s.push(E), h++;
1003
1003
  return { aWidth: i, lsBearing: s };
1004
1004
  }
1005
1005
  };
@@ -1039,9 +1039,9 @@ Q.T.glyf = {
1039
1039
  for (var o = 0; o < B; o++) {
1040
1040
  var E = t[i];
1041
1041
  if (i++, s.flags.push(E), E & 8) {
1042
- var l = t[i];
1042
+ var h = t[i];
1043
1043
  i++;
1044
- for (var h = 0; h < l; h++)
1044
+ for (var l = 0; l < h; l++)
1045
1045
  s.flags.push(E), o++;
1046
1046
  }
1047
1047
  }
@@ -1212,8 +1212,8 @@ class uA {
1212
1212
  */
1213
1213
  _renderCharactersToCanvas(A, e, t, r) {
1214
1214
  for (let i = 0; i < A.length; i++) {
1215
- const s = i % t, o = Math.floor(i / t), g = s * e.width + e.width * 0.5, B = o * e.height + e.height * 0.5, E = Math.round(g - e.width * 0.5), l = Math.round(B - r * 0.5);
1216
- this._textureContext.fillText(A[i].character, E, l);
1215
+ const s = i % t, o = Math.floor(i / t), g = s * e.width + e.width * 0.5, B = o * e.height + e.height * 0.5, E = Math.round(g - e.width * 0.5), h = Math.round(B - r * 0.5);
1216
+ this._textureContext.fillText(A[i].character, E, h);
1217
1217
  }
1218
1218
  }
1219
1219
  /**
@@ -1386,7 +1386,7 @@ class CA {
1386
1386
  if (A) {
1387
1387
  const t = await fetch(A);
1388
1388
  if (!t.ok)
1389
- throw new P(`Failed to load font file: ${t.status} ${t.statusText}`);
1389
+ throw new p(`Failed to load font file: ${t.status} ${t.statusText}`);
1390
1390
  e = await t.arrayBuffer();
1391
1391
  } else
1392
1392
  e = await (await fetch(QA)).arrayBuffer();
@@ -1422,7 +1422,7 @@ class CA {
1422
1422
  try {
1423
1423
  const e = await fetch(A);
1424
1424
  if (!e.ok)
1425
- throw new P(`Failed to load font file: ${e.status} ${e.statusText}`);
1425
+ throw new p(`Failed to load font file: ${e.status} ${e.statusText}`);
1426
1426
  const t = await e.arrayBuffer();
1427
1427
  await this._loadFontFace(t);
1428
1428
  const r = Q.parse(t);
@@ -1430,7 +1430,7 @@ class CA {
1430
1430
  throw new Error("Failed to parse font file");
1431
1431
  this._font = r[0], await this._initializeFont();
1432
1432
  } catch (e) {
1433
- throw new P(`Failed to load font: ${e instanceof Error ? e.message : "Unknown error"}`, e);
1433
+ throw new p(`Failed to load font: ${e instanceof Error ? e.message : "Unknown error"}`, e);
1434
1434
  }
1435
1435
  }
1436
1436
  /**
@@ -1564,9 +1564,8 @@ class mA {
1564
1564
  */
1565
1565
  reset() {
1566
1566
  if (!this._fixedDimensions) {
1567
- const A = this._canvas.getBoundingClientRect();
1568
- let e = Math.round(A.width), t = Math.round(A.height);
1569
- [this._cols, this._rows] = [Math.floor(e / this._cellWidth), Math.floor(t / this._cellHeight)];
1567
+ const A = this._canvas.width, e = this._canvas.height;
1568
+ [this._cols, this._rows] = [Math.floor(A / this._cellWidth), Math.floor(e / this._cellHeight)];
1570
1569
  }
1571
1570
  this._resizeGrid();
1572
1571
  }
@@ -1574,9 +1573,8 @@ class mA {
1574
1573
  * Reset the total grid width & height, and the offset to the outer canvas.
1575
1574
  */
1576
1575
  _resizeGrid() {
1577
- const A = this._canvas.getBoundingClientRect();
1578
- let e = Math.round(A.width), t = Math.round(A.height);
1579
- this._width = this._cols * this._cellWidth, this._height = this._rows * this._cellHeight, this._offsetX = Math.floor((e - this._width) / 2), this._offsetY = Math.floor((t - this._height) / 2);
1576
+ const A = this._canvas.width, e = this._canvas.height;
1577
+ this._width = this._cols * this._cellWidth, this._height = this._rows * this._cellHeight, this._offsetX = Math.floor((A - this._width) / 2), this._offsetY = Math.floor((e - this._height) / 2);
1580
1578
  }
1581
1579
  /**
1582
1580
  * Re-assign the grid cell dimensions and `reset()` the grid.
@@ -1669,7 +1667,9 @@ class DA {
1669
1667
  a(this, "_canvas");
1670
1668
  a(this, "captureSource");
1671
1669
  a(this, "_isStandalone");
1672
- this.captureSource = A, this._isStandalone = e, this._canvas = this.createCanvas(t.width, t.height);
1670
+ a(this, "resizeObserver");
1671
+ a(this, "onTransformChange");
1672
+ this.captureSource = A, this._isStandalone = e, this._canvas = this.createCanvas(t.width, t.height), e && this.setupTransformObserver();
1673
1673
  }
1674
1674
  createCanvas(A, e) {
1675
1675
  var r;
@@ -1726,15 +1726,40 @@ class DA {
1726
1726
  powerPreference: "high-performance"
1727
1727
  }, e = this._canvas.getContext("webgl2", A) || this._canvas.getContext("webgl", A);
1728
1728
  if (!e)
1729
- throw new P("WebGL context could not be created. Ensure your browser supports WebGL.");
1729
+ throw new p("WebGL context could not be created. Ensure your browser supports WebGL.");
1730
1730
  return e;
1731
1731
  }
1732
+ /**
1733
+ * Get the effective rendering dimensions accounting for CSS transforms
1734
+ */
1735
+ getEffectiveRenderingDimensions() {
1736
+ return this._canvas ? { width: this._canvas.width, height: this._canvas.height } : { width: 0, height: 0 };
1737
+ }
1738
+ /**
1739
+ * Check if the canvas is affected by CSS transforms
1740
+ */
1741
+ isTransformed() {
1742
+ if (!this._canvas || !this._isStandalone) return !1;
1743
+ const A = this._canvas.getBoundingClientRect(), e = Math.round(A.width), t = Math.round(A.height);
1744
+ return e !== this._canvas.width || t !== this._canvas.height;
1745
+ }
1746
+ /**
1747
+ * Set up ResizeObserver to monitor for CSS transform changes
1748
+ */
1749
+ setupTransformObserver() {
1750
+ typeof ResizeObserver > "u" || (this.resizeObserver = new ResizeObserver((A) => {
1751
+ for (const e of A) {
1752
+ const t = e.contentRect, r = Math.round(t.width), i = Math.round(t.height);
1753
+ this.onTransformChange && (r !== this._canvas.width || i !== this._canvas.height) && this.onTransformChange();
1754
+ }
1755
+ }), this.resizeObserver.observe(this._canvas));
1756
+ }
1732
1757
  /**
1733
1758
  * Dispose of this TextmodeCanvas and clean up all resources.
1734
1759
  * This method is idempotent and safe to call multiple times.
1735
1760
  */
1736
1761
  dispose() {
1737
- if (this._canvas) {
1762
+ if (this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = void 0), this._canvas) {
1738
1763
  const A = this._canvas.getContext("webgl") || this._canvas.getContext("webgl2");
1739
1764
  if (A) {
1740
1765
  const e = A.getExtension("WEBGL_lose_context");
@@ -1833,7 +1858,7 @@ class x {
1833
1858
  return this._options;
1834
1859
  }
1835
1860
  }
1836
- class PA {
1861
+ class pA {
1837
1862
  /**
1838
1863
  * Create a new color palette instance.
1839
1864
  * @param renderer The renderer instance.
@@ -1892,7 +1917,7 @@ class z extends x {
1892
1917
  constructor(e, t, r, i = {}) {
1893
1918
  super(e, t, r, i);
1894
1919
  a(this, "palette");
1895
- this.palette = new PA(this.renderer, this.fontManager.getCharacterColors(" .:-=+*%@#"));
1920
+ this.palette = new pA(this.renderer, this.fontManager.getCharacterColors(" .:-=+*%@#"));
1896
1921
  }
1897
1922
  /**
1898
1923
  * Sets the characters used for mapping.
@@ -2050,8 +2075,8 @@ class z extends x {
2050
2075
  return [t, r, i, 255];
2051
2076
  }
2052
2077
  }
2053
- var pA = "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}", IA = "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}", wA = "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}", _A = "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}", bA = "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}";
2054
- const vA = {
2078
+ var PA = "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}", wA = "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}", IA = "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}", _A = "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}", vA = "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}";
2079
+ const bA = {
2055
2080
  /** Enable/disable the renderer */
2056
2081
  enabled: !0,
2057
2082
  /** Characters used for brightness mapping (from darkest to brightest) */
@@ -2077,7 +2102,7 @@ const vA = {
2077
2102
  /** Range of brightness values to map to ASCII characters */
2078
2103
  brightnessRange: [0, 255]
2079
2104
  };
2080
- class O extends z {
2105
+ class V extends z {
2081
2106
  /**
2082
2107
  * Creates a new TextmodeBrightnessConverter instance.
2083
2108
  * @param renderer Renderer instance for texture creation
@@ -2086,14 +2111,14 @@ class O extends z {
2086
2111
  * @ignore
2087
2112
  */
2088
2113
  constructor(e, t, r) {
2089
- super(e, t, r, { ...vA });
2114
+ super(e, t, r, { ...bA });
2090
2115
  a(this, "sampleShader");
2091
2116
  a(this, "colorFillShader");
2092
2117
  a(this, "charMappingShader");
2093
2118
  a(this, "transformFillShader");
2094
2119
  a(this, "rotationFillShader");
2095
2120
  a(this, "sampleFramebuffer");
2096
- this.sampleShader = new I(e.context, w, pA), this.colorFillShader = new I(e.context, w, IA), this.transformFillShader = new I(e.context, w, wA), this.rotationFillShader = new I(e.context, w, _A), this.charMappingShader = new I(e.context, w, bA), this.sampleFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
2121
+ this.sampleShader = new w(e.context, I, PA), this.colorFillShader = new w(e.context, I, wA), this.transformFillShader = new w(e.context, I, IA), this.rotationFillShader = new w(e.context, I, _A), this.charMappingShader = new w(e.context, I, vA), this.sampleFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
2097
2122
  }
2098
2123
  convert(e) {
2099
2124
  this.sampleFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.sampleShader), this.renderer.setUniform("u_sketchTexture", e), this.renderer.setUniform("u_gridCellDimensions", [this.grid.cols, this.grid.rows]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this.sampleFramebuffer.end(), this._primaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.characterColor), this.renderer.setUniform("u_useFixedColor", this._options.characterColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._primaryColorFramebuffer.end(), this._secondaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.cellColor), this.renderer.setUniform("u_useFixedColor", this._options.cellColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._secondaryColorFramebuffer.end(), this._transformFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.transformFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_invert", this._options.invert), this.renderer.setUniform("u_flipHorizontally", this._options.flipHorizontally), this.renderer.setUniform("u_flipVertically", this._options.flipVertically), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._transformFramebuffer.end(), this._rotationFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.rotationFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_rotationColor", this._options.rotation), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._rotationFramebuffer.end(), this._characterFramebuffer.begin(), this.renderer.clear(0, 0, 0, 0), this.renderer.shader(this.charMappingShader), this.renderer.setUniform("u_colorSampleFramebuffer", this.sampleFramebuffer.texture), this.renderer.setUniform("u_charPaletteTexture", this.palette.texture), this.renderer.setUniform("u_charPaletteSize", [this.palette.colors.length, 1]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._characterFramebuffer.end();
@@ -2118,7 +2143,7 @@ class O extends z {
2118
2143
  }
2119
2144
  const LA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2120
2145
  __proto__: null,
2121
- TextmodeBrightnessConverter: O,
2146
+ TextmodeBrightnessConverter: V,
2122
2147
  TextmodeConverter: x,
2123
2148
  TextmodeFeatureConverter: z
2124
2149
  }, Symbol.toStringTag, { value: "Module" }));
@@ -2143,8 +2168,8 @@ class FA {
2143
2168
  a(this, "_secondaryColorFramebuffer");
2144
2169
  a(this, "_rotationFramebuffer");
2145
2170
  a(this, "_transformFramebuffer");
2146
- this.renderer = A, this.font = e, this.grid = t, this._asciiShader = this.renderer.createShader(w, xA), this.converters = [
2147
- { name: "brightness", converter: new O(A, e, t) },
2171
+ this.renderer = A, this.font = e, this.grid = t, this._asciiShader = this.renderer.createShader(I, xA), this.converters = [
2172
+ { name: "brightness", converter: new V(A, e, t) },
2148
2173
  { name: "custom", converter: new x(A, e, t) }
2149
2174
  ], this._characterFramebuffer = this.renderer.createFramebuffer(t.cols, t.rows), this._primaryColorFramebuffer = this.renderer.createFramebuffer(t.cols, t.rows), this._secondaryColorFramebuffer = this.renderer.createFramebuffer(t.cols, t.rows), this._rotationFramebuffer = this.renderer.createFramebuffer(t.cols, t.rows), this._transformFramebuffer = this.renderer.createFramebuffer(t.cols, t.rows), this._resultFramebuffer = this.renderer.createFramebuffer(this.grid.width, this.grid.height);
2150
2175
  }
@@ -2206,7 +2231,7 @@ class FA {
2206
2231
  ))
2207
2232
  return;
2208
2233
  let t;
2209
- return e === "brightness" ? t = new O(this.renderer, this.font, this.grid) : t = new x(this.renderer, this.font, this.grid), this.converters.push({ name: A, converter: t }), t;
2234
+ return e === "brightness" ? t = new V(this.renderer, this.font, this.grid) : t = new x(this.renderer, this.font, this.grid), this.converters.push({ name: A, converter: t }), t;
2210
2235
  }
2211
2236
  /**
2212
2237
  * Removes a converter from the pipeline by name or instance.
@@ -2410,7 +2435,7 @@ class yA extends L {
2410
2435
  * @returns Transform data object
2411
2436
  */
2412
2437
  extractTransformData(A, e, t) {
2413
- const r = A[t], i = A[t + 1], s = A[t + 2], o = r === 255, g = i === 255, B = s === 255, E = e[t], l = e[t + 1], h = E + l / 255, c = Math.round(h * 360 / 255 * 100) / 100;
2438
+ const r = A[t], i = A[t + 1], s = A[t + 2], o = r === 255, g = i === 255, B = s === 255, E = e[t], h = e[t + 1], l = E + h / 255, c = Math.round(l * 360 / 255 * 100) / 100;
2414
2439
  return {
2415
2440
  isInverted: o,
2416
2441
  flipHorizontal: g,
@@ -2450,22 +2475,22 @@ class yA extends L {
2450
2475
  o
2451
2476
  );
2452
2477
  let B = this.pixelsToRGBA(A.primaryColorPixels, o), E = this.pixelsToRGBA(A.secondaryColorPixels, o);
2453
- const l = this.extractTransformData(
2478
+ const h = this.extractTransformData(
2454
2479
  A.transformPixels,
2455
2480
  A.rotationPixels,
2456
2481
  o
2457
2482
  );
2458
- if (l.isInverted) {
2483
+ if (h.isInverted) {
2459
2484
  const c = B;
2460
2485
  B = E, E = c;
2461
2486
  }
2462
- const h = this.calculateCellPosition(s, i, e);
2487
+ const l = this.calculateCellPosition(s, i, e);
2463
2488
  t.push({
2464
2489
  charIndex: g,
2465
2490
  primaryColor: B,
2466
2491
  secondaryColor: E,
2467
- transform: l,
2468
- position: h
2492
+ transform: h,
2493
+ position: l
2469
2494
  }), r++;
2470
2495
  }
2471
2496
  return t;
@@ -2545,31 +2570,31 @@ class TA {
2545
2570
  const { xs: i, ys: s, endPts: o, flags: g } = A;
2546
2571
  if (!i || !s || !o || !g) return "";
2547
2572
  let B = "", E = 0;
2548
- for (let l = 0; l < o.length; l++) {
2549
- const h = o[l];
2550
- if (!(h < E)) {
2551
- if (h >= E) {
2573
+ for (let h = 0; h < o.length; h++) {
2574
+ const l = o[h];
2575
+ if (!(l < E)) {
2576
+ if (l >= E) {
2552
2577
  const c = e + i[E] * r, d = t - s[E] * r;
2553
2578
  B += `M${c.toFixed(2)},${d.toFixed(2)}`;
2554
2579
  let u = E + 1;
2555
- for (; u <= h; )
2580
+ for (; u <= l; )
2556
2581
  if ((g[u] & 1) !== 0) {
2557
2582
  const D = e + i[u] * r, C = t - s[u] * r;
2558
2583
  B += `L${D.toFixed(2)},${C.toFixed(2)}`, u++;
2559
2584
  } else {
2560
2585
  const D = e + i[u] * r, C = t - s[u] * r;
2561
- let p = u + 1 > h ? E : u + 1;
2562
- if ((g[p] & 1) !== 0) {
2563
- const b = e + i[p] * r, _ = t - s[p] * r;
2564
- B += `Q${D.toFixed(2)},${C.toFixed(2)} ${b.toFixed(2)},${_.toFixed(2)}`, u = p + 1;
2586
+ let P = u + 1 > l ? E : u + 1;
2587
+ if ((g[P] & 1) !== 0) {
2588
+ const v = e + i[P] * r, _ = t - s[P] * r;
2589
+ B += `Q${D.toFixed(2)},${C.toFixed(2)} ${v.toFixed(2)},${_.toFixed(2)}`, u = P + 1;
2565
2590
  } else {
2566
- const b = e + i[p] * r, _ = t - s[p] * r, R = (D + b) / 2, T = (C + _) / 2;
2567
- B += `Q${D.toFixed(2)},${C.toFixed(2)} ${R.toFixed(2)},${T.toFixed(2)}`, u = p;
2591
+ const v = e + i[P] * r, _ = t - s[P] * r, R = (D + v) / 2, T = (C + _) / 2;
2592
+ B += `Q${D.toFixed(2)},${C.toFixed(2)} ${R.toFixed(2)},${T.toFixed(2)}`, u = P;
2568
2593
  }
2569
2594
  }
2570
2595
  B += "Z";
2571
2596
  }
2572
- E = h + 1;
2597
+ E = l + 1;
2573
2598
  }
2574
2599
  }
2575
2600
  return B;
@@ -2613,8 +2638,8 @@ class TA {
2613
2638
  */
2614
2639
  generatePositionedCharacterPath(A, e, t, r, i, s, o, g) {
2615
2640
  try {
2616
- const B = o / e.head.unitsPerEm, E = g * B, l = t + (i - E) / 2, h = r + (s + o * 0.7) / 2;
2617
- return this.generateCharacterPath(A, e, l, h, o).toSVG() || null;
2641
+ const B = o / e.head.unitsPerEm, E = g * B, h = t + (i - E) / 2, l = r + (s + o * 0.7) / 2;
2642
+ return this.generateCharacterPath(A, e, h, l, o).toSVG() || null;
2618
2643
  } catch (B) {
2619
2644
  return console.warn(`Failed to generate positioned character path for "${A}":`, B), null;
2620
2645
  }
@@ -2866,10 +2891,10 @@ class GA extends L {
2866
2891
  for (let g = 0; g < e.rows; g++) {
2867
2892
  const B = [];
2868
2893
  for (let E = 0; E < e.cols; E++) {
2869
- const l = s * 4, h = this.getCharacterIndex(
2894
+ const h = s * 4, l = this.getCharacterIndex(
2870
2895
  A.characterPixels,
2871
- l
2872
- ), c = ((o = t.characters[h]) == null ? void 0 : o.character) || r;
2896
+ h
2897
+ ), c = ((o = t.characters[l]) == null ? void 0 : o.character) || r;
2873
2898
  B.push(c), s++;
2874
2899
  }
2875
2900
  i.push(B);
@@ -2997,7 +3022,7 @@ class YA extends L {
2997
3022
  ), i;
2998
3023
  }
2999
3024
  }
3000
- class kA {
3025
+ class OA {
3001
3026
  /**
3002
3027
  * Generates image data from canvas
3003
3028
  * @param canvas The canvas containing the image data
@@ -3044,12 +3069,12 @@ const J = {
3044
3069
  png: "image/png",
3045
3070
  jpg: "image/jpeg",
3046
3071
  webp: "image/webp"
3047
- }, k = {
3072
+ }, O = {
3048
3073
  png: ".png",
3049
3074
  jpg: ".jpg",
3050
3075
  webp: ".webp"
3051
3076
  };
3052
- class VA extends H {
3077
+ class kA extends H {
3053
3078
  /**
3054
3079
  * Saves image content as a downloadable file
3055
3080
  * @param content The image content (data URL or blob)
@@ -3058,7 +3083,7 @@ class VA extends H {
3058
3083
  */
3059
3084
  saveImage(A, e, t) {
3060
3085
  try {
3061
- const r = k[t];
3086
+ const r = O[t];
3062
3087
  typeof A == "string" ? this.saveImageFromDataURL(A, this.sanitizeFilename(e) + r) : this.saveImageFromBlob(A, this.sanitizeFilename(e) + r);
3063
3088
  } catch (r) {
3064
3089
  throw console.error(`Failed to save ${t.toUpperCase()} image:`, r), new Error(`Image save failed: ${r instanceof Error ? r.message : "Unknown error"}`);
@@ -3093,7 +3118,7 @@ class VA extends H {
3093
3118
  * @returns True if the format is supported for saving
3094
3119
  */
3095
3120
  validateSaveSupport(A) {
3096
- return A in J && A in k;
3121
+ return A in J && A in O;
3097
3122
  }
3098
3123
  /**
3099
3124
  * Gets the MIME type for the specified image format
@@ -3109,15 +3134,15 @@ class VA extends H {
3109
3134
  * @returns The file extension (including the dot)
3110
3135
  */
3111
3136
  getFileExtension(A) {
3112
- return k[A];
3137
+ return O[A];
3113
3138
  }
3114
3139
  }
3115
- class OA {
3140
+ class VA {
3116
3141
  constructor() {
3117
3142
  a(this, "dataExtractor");
3118
3143
  a(this, "contentGenerator");
3119
3144
  a(this, "fileHandler");
3120
- this.dataExtractor = new YA(), this.contentGenerator = new kA(), this.fileHandler = new VA();
3145
+ this.dataExtractor = new YA(), this.contentGenerator = new OA(), this.fileHandler = new kA();
3121
3146
  }
3122
3147
  /**
3123
3148
  * Applies default values to image export options
@@ -3245,7 +3270,7 @@ class S {
3245
3270
  */
3246
3271
  static async create(A = null, e = {}) {
3247
3272
  const t = new S(A, e), r = t._standalone ? e : void 0;
3248
- t.textmodeCanvas = new DA(t.captureSource, t._standalone, r), t._renderer = new hA(t.textmodeCanvas.getWebGLContext());
3273
+ t.textmodeCanvas = new DA(t.captureSource, t._standalone, r), t._renderer = new lA(t.textmodeCanvas.getWebGLContext());
3249
3274
  let i, s;
3250
3275
  t._standalone ? (i = e.width || 800, s = e.height || 600) : (i = t.textmodeCanvas.width || 800, s = t.textmodeCanvas.height || 600), t._canvasFramebuffer = t._renderer.createFramebuffer(i, s), t._font = new CA(t._renderer, e.fontSize ?? 16), await t._font.initialize(e.fontSource);
3251
3276
  const o = t._font.maxGlyphDimensions;
@@ -3406,7 +3431,7 @@ class S {
3406
3431
  * ```
3407
3432
  */
3408
3433
  async saveCanvas(A, e = "png", t = {}) {
3409
- await new OA().saveImage(this.textmodeCanvas, {
3434
+ await new VA().saveImage(this.textmodeCanvas, {
3410
3435
  ...t,
3411
3436
  filename: A,
3412
3437
  format: e
@@ -4406,7 +4431,7 @@ class N {
4406
4431
  * ```
4407
4432
  */
4408
4433
  static get version() {
4409
- return "0.1.6-beta.1";
4434
+ return "0.1.6-beta.3";
4410
4435
  }
4411
4436
  constructor() {
4412
4437
  throw new Error("Textmode is a static class and cannot be instantiated.");