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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  var se = Object.defineProperty;
2
- var ae = (h, e, t) => e in h ? se(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
- var o = (h, e, t) => ae(h, typeof e != "symbol" ? e + "" : e, t);
2
+ var ne = (h, e, t) => e in h ? se(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
+ var o = (h, e, t) => ne(h, typeof e != "symbol" ? e + "" : e, t);
4
4
  class F extends Error {
5
5
  constructor(t, r, i = {}) {
6
6
  const s = F.createFormattedMessage(t, i);
@@ -18,10 +18,10 @@ class F extends Error {
18
18
  i += `
19
19
 
20
20
  📋 Context:`;
21
- for (const [s, a] of Object.entries(r)) {
22
- const n = F.formatValue(a);
21
+ for (const [s, n] of Object.entries(r)) {
22
+ const a = F.formatValue(n);
23
23
  i += `
24
- - ${s}: ${n}`;
24
+ - ${s}: ${a}`;
25
25
  }
26
26
  }
27
27
  return i += `
@@ -41,12 +41,12 @@ class F extends Error {
41
41
  return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((r) => F.formatValue(r)).join(", ")}]` : `[${t.slice(0, 3).map((r) => F.formatValue(r)).join(", ")}, ... +${t.length - 3} more]`;
42
42
  if (typeof t == "object") {
43
43
  const r = Object.keys(t);
44
- return r.length === 0 ? "{}" : r.length <= 3 ? `{ ${r.map((a) => `${a}: ${F.formatValue(t[a])}`).join(", ")} }` : `{ ${r.slice(0, 2).map((s) => `${s}: ${F.formatValue(t[s])}`).join(", ")}, ... +${r.length - 2} more }`;
44
+ return r.length === 0 ? "{}" : r.length <= 3 ? `{ ${r.map((n) => `${n}: ${F.formatValue(t[n])}`).join(", ")} }` : `{ ${r.slice(0, 2).map((s) => `${s}: ${F.formatValue(t[s])}`).join(", ")}, ... +${r.length - 2} more }`;
45
45
  }
46
46
  return String(t);
47
47
  }
48
48
  }
49
- var ne = /* @__PURE__ */ ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ne || {});
49
+ var ae = /* @__PURE__ */ ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ae || {});
50
50
  const E = class E {
51
51
  constructor() {
52
52
  o(this, "_options", {
@@ -105,7 +105,7 @@ const E = class E {
105
105
  };
106
106
  o(E, "_instance", null);
107
107
  let $ = E;
108
- const x = $.getInstance();
108
+ const v = $.getInstance();
109
109
  class oe {
110
110
  constructor(e, t, r = t, i = {}) {
111
111
  o(this, "gl");
@@ -189,16 +189,16 @@ class oe {
189
189
  get(e, t, r, i) {
190
190
  const { gl: s } = this;
191
191
  if (e === void 0 && t === void 0) {
192
- const a = new Uint8Array(this._width * this._height * 4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
193
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(0, 0, this._width, this._height, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), a;
192
+ const n = new Uint8Array(this._width * this._height * 4), a = s.getParameter(s.FRAMEBUFFER_BINDING);
193
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(0, 0, this._width, this._height, s.RGBA, s.UNSIGNED_BYTE, n), s.bindFramebuffer(s.FRAMEBUFFER, a), n;
194
194
  } else if (r === void 0 && i === void 0) {
195
195
  (e < 0 || t < 0 || e >= this._width || t >= this._height) && (console.warn("The x and y values passed to Framebuffer.get are outside of its range and will be clamped."), e = Math.max(0, Math.min(e, this._width - 1)), t = Math.max(0, Math.min(t, this._height - 1)));
196
- const a = new Uint8Array(4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
197
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, 1, 1, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), [a[0], a[1], a[2], a[3]];
196
+ const n = new Uint8Array(4), a = s.getParameter(s.FRAMEBUFFER_BINDING);
197
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, 1, 1, s.RGBA, s.UNSIGNED_BYTE, n), s.bindFramebuffer(s.FRAMEBUFFER, a), [n[0], n[1], n[2], n[3]];
198
198
  } else {
199
199
  e = Math.max(0, Math.min(e, this._width - 1)), t = Math.max(0, Math.min(t, this._height - 1)), r = Math.max(1, Math.min(r, this._width - e)), i = Math.max(1, Math.min(i, this._height - t));
200
- const a = new Uint8Array(r * i * 4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
201
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, r, i, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), a;
200
+ const n = new Uint8Array(r * i * 4), a = s.getParameter(s.FRAMEBUFFER_BINDING);
201
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, r, i, s.RGBA, s.UNSIGNED_BYTE, n), s.bindFramebuffer(s.FRAMEBUFFER, a), n;
202
202
  }
203
203
  }
204
204
  /**
@@ -244,13 +244,13 @@ class M {
244
244
  /** Bytes per vertex: depends on position format (vec2 vs vec3) */
245
245
  o(this, "bytesPerVertex");
246
246
  this.gl = e, this.bytesPerVertex = 16;
247
- const a = e.getParameter(e.VIEWPORT), n = a[2], l = a[3], c = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, u = t / n * 2 - 1, d = (t + i) / n * 2 - 1;
247
+ const n = e.getParameter(e.VIEWPORT), a = n[2], l = n[3], c = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, u = t / a * 2 - 1, d = (t + i) / a * 2 - 1;
248
248
  let f, g;
249
249
  c ? (f = r / l * 2 - 1, g = (r + s) / l * 2 - 1) : (f = 1 - r / l * 2, g = 1 - (r + s) / l * 2);
250
250
  let _, p, b, C;
251
251
  _ = u, b = d, p = f, C = g;
252
- const v = this.generateVertices(_, p, b, C);
253
- this.vertexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, v, e.STATIC_DRAW);
252
+ const x = this.generateVertices(_, p, b, C);
253
+ this.vertexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, x, e.STATIC_DRAW);
254
254
  }
255
255
  /**
256
256
  * Generate vertex data for the rectangle with texture coordinates
@@ -301,11 +301,11 @@ class M {
301
301
  }
302
302
  }
303
303
  class he extends Q {
304
- constructor(t, r, i, s, a) {
304
+ constructor(t, r, i, s, n) {
305
305
  super(t, r, i);
306
306
  o(this, "width");
307
307
  o(this, "height");
308
- this.width = s, this.height = a;
308
+ this.width = s, this.height = n;
309
309
  }
310
310
  /**
311
311
  * Render the filled rectangle using the existing Rectangle geometry.
@@ -320,12 +320,12 @@ class he extends Q {
320
320
  */
321
321
  renderStroke(t) {
322
322
  if (t <= 0) return;
323
- const r = new M(this.gl, this.x, this.y, this.width, t), i = new M(this.gl, this.x + this.width - t, this.y, t, this.height), s = new M(this.gl, this.x, this.y + this.height - t, this.width, t), a = new M(this.gl, this.x, this.y, t, this.height);
324
- r.render(), i.render(), s.render(), a.render();
323
+ const r = new M(this.gl, this.x, this.y, this.width, t), i = new M(this.gl, this.x + this.width - t, this.y, t, this.height), s = new M(this.gl, this.x, this.y + this.height - t, this.width, t), n = new M(this.gl, this.x, this.y, t, this.height);
324
+ r.render(), i.render(), s.render(), n.render();
325
325
  }
326
326
  }
327
327
  class le {
328
- constructor(e, t, r, i, s, a) {
328
+ constructor(e, t, r, i, s, n) {
329
329
  /** The WebGL rendering context */
330
330
  o(this, "gl");
331
331
  /** The vertex buffer containing position and texture coordinates */
@@ -335,13 +335,13 @@ class le {
335
335
  /** Bytes per vertex: vec2+vec2 = 16 bytes */
336
336
  o(this, "bytesPerVertex");
337
337
  this.gl = e, this.bytesPerVertex = 16;
338
- const n = e.getParameter(e.VIEWPORT), l = n[2], c = n[3], u = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, d = i - t, f = s - r, g = Math.sqrt(d * d + f * f);
338
+ const a = e.getParameter(e.VIEWPORT), l = a[2], c = a[3], u = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, d = i - t, f = s - r, g = Math.sqrt(d * d + f * f);
339
339
  if (g === 0) {
340
340
  const ie = this.generateVertices(0, 0, 0, 0);
341
341
  this.vertexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, ie, e.STATIC_DRAW);
342
342
  return;
343
343
  }
344
- const _ = d / g, b = -(f / g), C = _, v = a / 2, w = t + b * v, A = r + C * v, R = t - b * v, S = r - C * v, P = i + b * v, D = s + C * v, Z = i - b * v, W = s - C * v, J = w / l * 2 - 1, K = R / l * 2 - 1, ee = P / l * 2 - 1, te = Z / l * 2 - 1;
344
+ const _ = d / g, b = -(f / g), C = _, x = n / 2, w = t + b * x, A = r + C * x, R = t - b * x, S = r - C * x, P = i + b * x, D = s + C * x, Z = i - b * x, W = s - C * x, J = w / l * 2 - 1, K = R / l * 2 - 1, ee = P / l * 2 - 1, te = Z / l * 2 - 1;
345
345
  let B, G, V, k;
346
346
  u ? (B = A / c * 2 - 1, G = S / c * 2 - 1, V = D / c * 2 - 1, k = W / c * 2 - 1) : (B = 1 - A / c * 2, G = 1 - S / c * 2, V = 1 - D / c * 2, k = 1 - W / c * 2);
347
347
  const re = this.generateLineVertices(
@@ -399,7 +399,7 @@ class le {
399
399
  * Uses the four corners calculated based on line direction and thickness
400
400
  * @private
401
401
  */
402
- generateLineVertices(e, t, r, i, s, a, n, l) {
402
+ generateLineVertices(e, t, r, i, s, n, a, l) {
403
403
  return new Float32Array([
404
404
  e,
405
405
  t,
@@ -412,7 +412,7 @@ class le {
412
412
  1,
413
413
  // corner2 (start - perpendicular)
414
414
  s,
415
- a,
415
+ n,
416
416
  1,
417
417
  0,
418
418
  // corner3 (end + perpendicular)
@@ -421,13 +421,13 @@ class le {
421
421
  0,
422
422
  1,
423
423
  // corner2 (start - perpendicular)
424
- n,
424
+ a,
425
425
  l,
426
426
  1,
427
427
  1,
428
428
  // corner4 (end - perpendicular)
429
429
  s,
430
- a,
430
+ n,
431
431
  1,
432
432
  0
433
433
  // corner3 (end + perpendicular)
@@ -444,11 +444,11 @@ class le {
444
444
  }
445
445
  }
446
446
  class ce extends Q {
447
- constructor(t, r, i, s, a) {
447
+ constructor(t, r, i, s, n) {
448
448
  super(t, r, i);
449
449
  o(this, "x2");
450
450
  o(this, "y2");
451
- this.x2 = s, this.y2 = a;
451
+ this.x2 = s, this.y2 = n;
452
452
  }
453
453
  /**
454
454
  * Lines don't support fill rendering - this method does nothing.
@@ -477,8 +477,8 @@ class y {
477
477
  createProgram(e, t) {
478
478
  const r = this.createShader(this.gl.VERTEX_SHADER, e), i = this.createShader(this.gl.FRAGMENT_SHADER, t), s = this.gl.createProgram();
479
479
  if (this.gl.attachShader(s, r), this.gl.attachShader(s, i), this.gl.linkProgram(s), !this.gl.getProgramParameter(s, this.gl.LINK_STATUS)) {
480
- const a = this.gl.getProgramInfoLog(s);
481
- throw new Error(`Shader program link error: ${a}`);
480
+ const n = this.gl.getProgramInfoLog(s);
481
+ throw new Error(`Shader program link error: ${n}`);
482
482
  }
483
483
  return this.gl.deleteShader(r), this.gl.deleteShader(i), s;
484
484
  }
@@ -528,7 +528,7 @@ class y {
528
528
  this.gl.uniform1i(r, t ? 1 : 0);
529
529
  else if (Array.isArray(t))
530
530
  if (i && (i.type === this.gl.INT_VEC2 || i.type === this.gl.INT_VEC3 || i.type === this.gl.INT_VEC4)) {
531
- const s = t.map((a) => Math.floor(a));
531
+ const s = t.map((n) => Math.floor(n));
532
532
  switch (s.length) {
533
533
  case 2:
534
534
  this.gl.uniform2iv(r, s);
@@ -757,8 +757,8 @@ class fe {
757
757
  s.renderFill(), this.currentShader = null;
758
758
  return;
759
759
  }
760
- const a = this.solidColorShader, { centerX: n, centerY: l, radians: c, aspectRatio: u } = this.calculateRotationParams(e, t, r, i);
761
- this.fillMode && (this.shader(a), this.setUniform("u_color", this.currentFillColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [n, l]), this.setUniform("u_aspectRatio", u), s.renderFill()), this.strokeMode && (this.shader(a), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [n, l]), this.setUniform("u_aspectRatio", u), s.renderStroke(this.currentStrokeWeight)), this.currentShader = null;
760
+ const n = this.solidColorShader, { centerX: a, centerY: l, radians: c, aspectRatio: u } = this.calculateRotationParams(e, t, r, i);
761
+ this.fillMode && (this.shader(n), this.setUniform("u_color", this.currentFillColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [a, l]), this.setUniform("u_aspectRatio", u), s.renderFill()), this.strokeMode && (this.shader(n), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [a, l]), this.setUniform("u_aspectRatio", u), s.renderStroke(this.currentStrokeWeight)), this.currentShader = null;
762
762
  }
763
763
  /**
764
764
  * Draw a line from (x1, y1) to (x2, y2) with the current stroke settings.
@@ -773,23 +773,23 @@ class fe {
773
773
  const s = new ce(this.gl, e, t, r, i);
774
774
  if (this.currentShader !== null) {
775
775
  if (this.currentRotation !== 0) {
776
- const p = (e + r) / 2, b = (t + i) / 2, C = Math.abs(r - e), v = Math.abs(i - t), { centerX: w, centerY: A, radians: R, aspectRatio: S } = this.calculateRotationParams(p - C / 2, b - v / 2, C, v);
776
+ const p = (e + r) / 2, b = (t + i) / 2, C = Math.abs(r - e), x = Math.abs(i - t), { centerX: w, centerY: A, radians: R, aspectRatio: S } = this.calculateRotationParams(p - C / 2, b - x / 2, C, x);
777
777
  this.setUniform("u_rotation", R), this.setUniform("u_center", [w, A]), this.setUniform("u_aspectRatio", S);
778
778
  } else
779
779
  this.setUniform("u_rotation", 0), this.setUniform("u_center", [0, 0]), this.setUniform("u_aspectRatio", 1);
780
780
  s.renderStroke(this.currentStrokeWeight), this.currentShader = null;
781
781
  return;
782
782
  }
783
- const a = this.solidColorShader, n = (e + r) / 2, l = (t + i) / 2, c = Math.abs(r - e), u = Math.abs(i - t), { centerX: d, centerY: f, radians: g, aspectRatio: _ } = this.calculateRotationParams(n - c / 2, l - u / 2, c, u);
784
- this.shader(a), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", g), this.setUniform("u_center", [d, f]), this.setUniform("u_aspectRatio", _), s.renderStroke(this.currentStrokeWeight), this.currentShader = null;
783
+ const n = this.solidColorShader, a = (e + r) / 2, l = (t + i) / 2, c = Math.abs(r - e), u = Math.abs(i - t), { centerX: d, centerY: f, radians: g, aspectRatio: _ } = this.calculateRotationParams(a - c / 2, l - u / 2, c, u);
784
+ this.shader(n), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", g), this.setUniform("u_center", [d, f]), this.setUniform("u_aspectRatio", _), s.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(e, t, r, i) {
790
- const s = this.gl.getParameter(this.gl.VIEWPORT), a = s[2], n = s[3], l = a / n, c = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, u = e + r / 2, d = t + i / 2, f = u / a * 2 - 1;
790
+ const s = this.gl.getParameter(this.gl.VIEWPORT), n = s[2], a = s[3], l = n / a, c = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, u = e + r / 2, d = t + i / 2, f = u / n * 2 - 1;
791
791
  let g;
792
- c ? g = d / n * 2 - 1 : g = 1 - d / n * 2;
792
+ c ? g = d / a * 2 - 1 : g = 1 - d / a * 2;
793
793
  const _ = this.currentRotation * Math.PI / 180;
794
794
  return { centerX: f, centerY: g, radians: _, aspectRatio: l };
795
795
  }
@@ -812,10 +812,11 @@ class fe {
812
812
  this.gl.clearColor(e, t, r, i), this.gl.clear(this.gl.COLOR_BUFFER_BIT);
813
813
  }
814
814
  /**
815
- * Ensure viewport matches canvas dimensions
815
+ * Ensure viewport matches canvas dimensions, optionally using custom dimensions for CSS transforms
816
816
  */
817
- resetViewport() {
818
- this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
817
+ resetViewport(e, t) {
818
+ const r = e || this.gl.canvas.width, i = t || this.gl.canvas.height;
819
+ this.gl.viewport(0, 0, r, i);
819
820
  }
820
821
  /**
821
822
  * Get the WebGL context
@@ -835,18 +836,18 @@ class fe {
835
836
  */
836
837
  image(e, t, r, i, s) {
837
838
  this.shader(this.imageShader), this.setUniform("u_texture", e.texture);
838
- const { centerX: a, centerY: n, radians: l, aspectRatio: c } = this.calculateRotationParams(
839
+ const { centerX: n, centerY: a, radians: l, aspectRatio: c } = this.calculateRotationParams(
839
840
  t,
840
841
  r,
841
842
  i ?? e.width,
842
843
  s ?? e.height
843
844
  );
844
- this.setUniform("u_rotation", l), this.setUniform("u_center", [a, n]), this.setUniform("u_aspectRatio", c), this.rect(t, r, i ?? e.width, s ?? e.height);
845
+ this.setUniform("u_rotation", l), this.setUniform("u_center", [n, a]), this.setUniform("u_aspectRatio", c), this.rect(t, r, i ?? e.width, s ?? e.height);
845
846
  }
846
847
  }
847
848
  var m = {};
848
849
  m.parse = function(h) {
849
- var e = function(s, a, n, l) {
850
+ var e = function(s, n, a, l) {
850
851
  var c = m.T, u = {
851
852
  cmap: c.cmap,
852
853
  head: c.head,
@@ -855,9 +856,9 @@ m.parse = function(h) {
855
856
  hmtx: c.hmtx,
856
857
  loca: c.loca,
857
858
  glyf: c.glyf
858
- }, d = { _data: s, _index: a, _offset: n };
859
+ }, d = { _data: s, _index: n, _offset: a };
859
860
  for (var f in u) {
860
- var g = m.findTable(s, f, n);
861
+ var g = m.findTable(s, f, a);
861
862
  if (g) {
862
863
  var _ = g[0], p = l[_];
863
864
  p == null && (p = u[f].parseTab(s, _, g[1], d)), d[f] = l[_] = p;
@@ -868,11 +869,11 @@ m.parse = function(h) {
868
869
  return [i];
869
870
  };
870
871
  m.findTable = function(h, e, t) {
871
- for (var r = m.B, i = r.readUshort(h, t + 4), s = t + 12, a = 0; a < i; a++) {
872
- var n = r.readASCII(h, s, 4);
872
+ for (var r = m.B, i = r.readUshort(h, t + 4), s = t + 12, n = 0; n < i; n++) {
873
+ var a = r.readASCII(h, s, 4);
873
874
  r.readUint(h, s + 4);
874
875
  var l = r.readUint(h, s + 8), c = r.readUint(h, s + 12);
875
- if (n == e) return [l, c];
876
+ if (a == e) return [l, c];
876
877
  s += 16;
877
878
  }
878
879
  return null;
@@ -914,11 +915,11 @@ m.T.cmap = {
914
915
  parseTab: function(h, e, t) {
915
916
  var r = { tables: [], ids: {}, off: e };
916
917
  h = new Uint8Array(h.buffer, e, t), e = 0;
917
- var i = m.B, s = i.readUshort, a = m.T.cmap;
918
+ var i = m.B, s = i.readUshort, n = m.T.cmap;
918
919
  s(h, e), e += 2;
919
- var n = s(h, e);
920
+ var a = s(h, e);
920
921
  e += 2;
921
- for (var l = [], c = 0; c < n; c++) {
922
+ for (var l = [], c = 0; c < a; c++) {
922
923
  var u = s(h, e);
923
924
  e += 2;
924
925
  var d = s(h, e);
@@ -931,16 +932,16 @@ m.T.cmap = {
931
932
  var p = {};
932
933
  l.push(f);
933
934
  var b = p.format = s(h, f);
934
- b == 4 ? p = a.parse4(h, f, p) : b == 12 && (p = a.parse12(h, f, p)), r.tables.push(p);
935
+ b == 4 ? p = n.parse4(h, f, p) : b == 12 && (p = n.parse12(h, f, p)), r.tables.push(p);
935
936
  }
936
937
  r.ids[g] != null && console.log("multiple tables for one platform+encoding: " + g), r.ids[g] = _;
937
938
  }
938
939
  return r;
939
940
  },
940
941
  parse4: function(h, e, t) {
941
- var r = m.B, i = r.readUshort, s = r.readUshorts, a = e;
942
+ var r = m.B, i = r.readUshort, s = r.readUshorts, n = e;
942
943
  e += 2;
943
- var n = i(h, e);
944
+ var a = i(h, e);
944
945
  e += 2, i(h, e), e += 2;
945
946
  var l = i(h, e);
946
947
  e += 2;
@@ -948,15 +949,15 @@ m.T.cmap = {
948
949
  t.searchRange = i(h, e), e += 2, t.entrySelector = i(h, e), e += 2, t.rangeShift = i(h, e), e += 2, t.endCount = s(h, e, c), e += c * 2, e += 2, t.startCount = s(h, e, c), e += c * 2, t.idDelta = [];
949
950
  for (var u = 0; u < c; u++)
950
951
  t.idDelta.push(r.readShort(h, e)), e += 2;
951
- return t.idRangeOffset = s(h, e, c), e += c * 2, t.glyphIdArray = s(h, e, a + n - e >> 1), t;
952
+ return t.idRangeOffset = s(h, e, c), e += c * 2, t.glyphIdArray = s(h, e, n + a - e >> 1), t;
952
953
  },
953
954
  parse12: function(h, e, t) {
954
955
  var r = m.B, i = r.readUint;
955
956
  e += 4, i(h, e), e += 4, i(h, e), e += 4;
956
957
  var s = i(h, e) * 3;
957
958
  e += 4;
958
- for (var a = t.groups = new Uint32Array(s), n = 0; n < s; n += 3)
959
- a[n] = i(h, e + (n << 2)), a[n + 1] = i(h, e + (n << 2) + 4), a[n + 2] = i(h, e + (n << 2) + 8);
959
+ for (var n = t.groups = new Uint32Array(s), a = 0; a < s; a += 3)
960
+ n[a] = i(h, e + (a << 2)), n[a + 1] = i(h, e + (a << 2) + 4), n[a + 2] = i(h, e + (a << 2) + 8);
960
961
  return t;
961
962
  }
962
963
  };
@@ -987,20 +988,20 @@ m.T.hhea = {
987
988
  "res3",
988
989
  "metricDataFormat",
989
990
  "numberOfHMetrics"
990
- ], a = 0; a < s.length; a++) {
991
- var n = s[a], l = n == "advanceWidthMax" || n == "numberOfHMetrics" ? r.readUshort : r.readShort;
992
- i[n] = l(h, e + a * 2);
991
+ ], n = 0; n < s.length; n++) {
992
+ var a = s[n], l = a == "advanceWidthMax" || a == "numberOfHMetrics" ? r.readUshort : r.readShort;
993
+ i[a] = l(h, e + n * 2);
993
994
  }
994
995
  return i;
995
996
  }
996
997
  };
997
998
  m.T.hmtx = {
998
999
  parseTab: function(h, e, t, r) {
999
- for (var i = m.B, s = [], a = [], n = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics, c = 0, u = 0, d = 0; d < l; )
1000
- c = i.readUshort(h, e + (d << 2)), u = i.readShort(h, e + (d << 2) + 2), s.push(c), a.push(u), d++;
1001
- for (; d < n; )
1002
- s.push(c), a.push(u), d++;
1003
- return { aWidth: s, lsBearing: a };
1000
+ for (var i = m.B, s = [], n = [], a = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics, c = 0, u = 0, d = 0; d < l; )
1001
+ c = i.readUshort(h, e + (d << 2)), u = i.readShort(h, e + (d << 2) + 2), s.push(c), n.push(u), d++;
1002
+ for (; d < a; )
1003
+ s.push(c), n.push(u), d++;
1004
+ return { aWidth: s, lsBearing: n };
1004
1005
  }
1005
1006
  };
1006
1007
  m.T.maxp = {
@@ -1011,55 +1012,55 @@ m.T.maxp = {
1011
1012
  };
1012
1013
  m.T.loca = {
1013
1014
  parseTab: function(h, e, t, r) {
1014
- var i = m.B, s = [], a = r.head.indexToLocFormat, n = r.maxp.numGlyphs + 1;
1015
- if (a == 0) for (var l = 0; l < n; l++) s.push(i.readUshort(h, e + (l << 1)) << 1);
1016
- if (a == 1) for (var l = 0; l < n; l++) s.push(i.readUint(h, e + (l << 2)));
1015
+ var i = m.B, s = [], n = r.head.indexToLocFormat, a = r.maxp.numGlyphs + 1;
1016
+ if (n == 0) for (var l = 0; l < a; l++) s.push(i.readUshort(h, e + (l << 1)) << 1);
1017
+ if (n == 1) for (var l = 0; l < a; l++) s.push(i.readUint(h, e + (l << 2)));
1017
1018
  return s;
1018
1019
  }
1019
1020
  };
1020
1021
  m.T.glyf = {
1021
1022
  parseTab: function(h, e, t, r) {
1022
- for (var i = [], s = r.maxp.numGlyphs, a = 0; a < s; a++) i.push(null);
1023
+ for (var i = [], s = r.maxp.numGlyphs, n = 0; n < s; n++) i.push(null);
1023
1024
  return i;
1024
1025
  },
1025
1026
  _parseGlyf: function(h, e) {
1026
1027
  var t = m.B, r = h._data, i = h.loca;
1027
1028
  if (i[e] == i[e + 1]) return null;
1028
- var s = m.findTable(r, "glyf", h._offset)[0] + i[e], a = {};
1029
- if (a.noc = t.readShort(r, s), s += 2, a.xMin = t.readShort(r, s), s += 2, a.yMin = t.readShort(r, s), s += 2, a.xMax = t.readShort(r, s), s += 2, a.yMax = t.readShort(r, s), s += 2, a.xMin >= a.xMax || a.yMin >= a.yMax) return null;
1030
- if (a.noc > 0) {
1031
- a.endPts = [];
1032
- for (var n = 0; n < a.noc; n++)
1033
- a.endPts.push(t.readUshort(r, s)), s += 2;
1029
+ var s = m.findTable(r, "glyf", h._offset)[0] + i[e], n = {};
1030
+ if (n.noc = t.readShort(r, s), s += 2, n.xMin = t.readShort(r, s), s += 2, n.yMin = t.readShort(r, s), s += 2, n.xMax = t.readShort(r, s), s += 2, n.yMax = t.readShort(r, s), s += 2, n.xMin >= n.xMax || n.yMin >= n.yMax) return null;
1031
+ if (n.noc > 0) {
1032
+ n.endPts = [];
1033
+ for (var a = 0; a < n.noc; a++)
1034
+ n.endPts.push(t.readUshort(r, s)), s += 2;
1034
1035
  var l = t.readUshort(r, s);
1035
1036
  if (s += 2, r.length - s < l) return null;
1036
1037
  s += l;
1037
- var c = a.endPts[a.noc - 1] + 1;
1038
- a.flags = [];
1039
- for (var n = 0; n < c; n++) {
1038
+ var c = n.endPts[n.noc - 1] + 1;
1039
+ n.flags = [];
1040
+ for (var a = 0; a < c; a++) {
1040
1041
  var u = r[s];
1041
- if (s++, a.flags.push(u), u & 8) {
1042
+ if (s++, n.flags.push(u), u & 8) {
1042
1043
  var d = r[s];
1043
1044
  s++;
1044
1045
  for (var f = 0; f < d; f++)
1045
- a.flags.push(u), n++;
1046
+ n.flags.push(u), a++;
1046
1047
  }
1047
1048
  }
1048
- a.xs = [];
1049
- for (var n = 0; n < c; n++) {
1050
- var g = (a.flags[n] & 2) != 0, _ = (a.flags[n] & 16) != 0;
1051
- g ? (a.xs.push(_ ? r[s] : -r[s]), s++) : _ ? a.xs.push(0) : (a.xs.push(t.readShort(r, s)), s += 2);
1049
+ n.xs = [];
1050
+ for (var a = 0; a < c; a++) {
1051
+ var g = (n.flags[a] & 2) != 0, _ = (n.flags[a] & 16) != 0;
1052
+ g ? (n.xs.push(_ ? r[s] : -r[s]), s++) : _ ? n.xs.push(0) : (n.xs.push(t.readShort(r, s)), s += 2);
1052
1053
  }
1053
- a.ys = [];
1054
- for (var n = 0; n < c; n++) {
1055
- var g = (a.flags[n] & 4) != 0, _ = (a.flags[n] & 32) != 0;
1056
- g ? (a.ys.push(_ ? r[s] : -r[s]), s++) : _ ? a.ys.push(0) : (a.ys.push(t.readShort(r, s)), s += 2);
1054
+ n.ys = [];
1055
+ for (var a = 0; a < c; a++) {
1056
+ var g = (n.flags[a] & 4) != 0, _ = (n.flags[a] & 32) != 0;
1057
+ g ? (n.ys.push(_ ? r[s] : -r[s]), s++) : _ ? n.ys.push(0) : (n.ys.push(t.readShort(r, s)), s += 2);
1057
1058
  }
1058
- for (var p = 0, b = 0, n = 0; n < c; n++)
1059
- p += a.xs[n], b += a.ys[n], a.xs[n] = p, a.ys[n] = b;
1059
+ for (var p = 0, b = 0, a = 0; a < c; a++)
1060
+ p += n.xs[a], b += n.ys[a], n.xs[a] = p, n.ys[a] = b;
1060
1061
  } else
1061
- a.parts = [];
1062
- return a;
1062
+ n.parts = [];
1063
+ return n;
1063
1064
  }
1064
1065
  };
1065
1066
  typeof module < "u" && module.exports ? module.exports = m : typeof window < "u" && (window.Typr = m);
@@ -1094,9 +1095,9 @@ class me {
1094
1095
  for (let r = 0; r < e.startCount.length; r++) {
1095
1096
  const i = e.startCount[r], s = e.endCount[r];
1096
1097
  if (!(i === 65535 && s === 65535)) {
1097
- for (let a = i; a <= s; a++)
1098
- if (this._calculateGlyphIndexFormat4(e, a, r) > 0) {
1099
- const l = String.fromCodePoint(a);
1098
+ for (let n = i; n <= s; n++)
1099
+ if (this._calculateGlyphIndexFormat4(e, n, r) > 0) {
1100
+ const l = String.fromCodePoint(n);
1100
1101
  t.push(l);
1101
1102
  }
1102
1103
  }
@@ -1113,10 +1114,10 @@ class me {
1113
1114
  if (!e.groups)
1114
1115
  return t;
1115
1116
  for (let r = 0; r < e.groups.length; r += 3) {
1116
- const i = e.groups[r], s = e.groups[r + 1], a = e.groups[r + 2];
1117
- for (let n = i; n <= s; n++)
1118
- if (a + (n - i) > 0) {
1119
- const c = String.fromCodePoint(n);
1117
+ const i = e.groups[r], s = e.groups[r + 1], n = e.groups[r + 2];
1118
+ for (let a = i; a <= s; a++)
1119
+ if (n + (a - i) > 0) {
1120
+ const c = String.fromCodePoint(a);
1120
1121
  t.push(c);
1121
1122
  }
1122
1123
  }
@@ -1180,13 +1181,13 @@ class ge {
1180
1181
  * @returns Object containing framebuffer, columns, and rows
1181
1182
  */
1182
1183
  createTextureAtlas(e, t, r, i) {
1183
- const s = e.length, a = Math.ceil(Math.sqrt(s)), n = Math.ceil(s / a), l = t.width * a, c = t.height * n;
1184
- this._setupCanvas(l, c, r, i), this._renderCharactersToCanvas(e, t, a, r), this._applyBlackWhiteThreshold();
1184
+ const s = e.length, n = Math.ceil(Math.sqrt(s)), a = Math.ceil(s / n), l = t.width * n, c = t.height * a;
1185
+ this._setupCanvas(l, c, r, i), this._renderCharactersToCanvas(e, t, n, r), this._applyBlackWhiteThreshold();
1185
1186
  const u = this._renderer.createFramebuffer(l, c, { filter: "nearest" });
1186
1187
  return u.update(this._textureCanvas), {
1187
1188
  framebuffer: u,
1188
- columns: a,
1189
- rows: n
1189
+ columns: n,
1190
+ rows: a
1190
1191
  };
1191
1192
  }
1192
1193
  /**
@@ -1210,7 +1211,7 @@ class ge {
1210
1211
  */
1211
1212
  _renderCharactersToCanvas(e, t, r, i) {
1212
1213
  for (let s = 0; s < e.length; s++) {
1213
- const a = s % r, n = Math.floor(s / r), l = a * t.width + t.width * 0.5, c = n * t.height + t.height * 0.5, u = Math.round(l - t.width * 0.5), d = Math.round(c - i * 0.5);
1214
+ const n = s % r, a = Math.floor(s / r), l = n * t.width + t.width * 0.5, c = a * t.height + t.height * 0.5, u = Math.round(l - t.width * 0.5), d = Math.round(c - i * 0.5);
1214
1215
  this._textureContext.fillText(e[s].character, u, d);
1215
1216
  }
1216
1217
  }
@@ -1223,8 +1224,8 @@ class ge {
1223
1224
  _applyBlackWhiteThreshold(e = 128) {
1224
1225
  const t = this._textureContext.getImageData(0, 0, this._textureCanvas.width, this._textureCanvas.height), r = t.data;
1225
1226
  for (let i = 0; i < r.length; i += 4) {
1226
- const s = 0.299 * r[i] + 0.587 * r[i + 1] + 0.114 * r[i + 2], a = e + 32, n = s > a ? 255 : 0;
1227
- r[i] = n, r[i + 1] = n, r[i + 2] = n;
1227
+ const s = 0.299 * r[i] + 0.587 * r[i + 1] + 0.114 * r[i + 2], n = e + 32, a = s > n ? 255 : 0;
1228
+ r[i] = a, r[i + 1] = a, r[i + 2] = a;
1228
1229
  }
1229
1230
  this._textureContext.putImageData(t, 0, 0);
1230
1231
  }
@@ -1249,8 +1250,8 @@ class pe {
1249
1250
  calculateMaxGlyphDimensions(e, t, r) {
1250
1251
  this._tempContext.font = `${t}px ${r}`;
1251
1252
  let i = 0, s = 0;
1252
- for (const a of e) {
1253
- const n = this._tempContext.measureText(a), l = n.width, c = n.actualBoundingBoxAscent + n.actualBoundingBoxDescent;
1253
+ for (const n of e) {
1254
+ const a = this._tempContext.measureText(n), l = a.width, c = a.actualBoundingBoxAscent + a.actualBoundingBoxDescent;
1254
1255
  l > 0 && (i = Math.max(i, l), s = Math.max(s, c));
1255
1256
  }
1256
1257
  return {
@@ -1268,17 +1269,17 @@ class _e {
1268
1269
  */
1269
1270
  createCharacterObjects(e, t) {
1270
1271
  return e.map((r, i) => {
1271
- const s = r.codePointAt(0) || 0, a = this._generateCharacterColor(i);
1272
- let n = 0;
1272
+ const s = r.codePointAt(0) || 0, n = this._generateCharacterColor(i);
1273
+ let a = 0;
1273
1274
  if (t.hmtx && t.hmtx.aWidth) {
1274
1275
  const l = this._getGlyphIndex(t, s);
1275
- l > 0 && t.hmtx.aWidth[l] !== void 0 && (n = t.hmtx.aWidth[l]);
1276
+ l > 0 && t.hmtx.aWidth[l] !== void 0 && (a = t.hmtx.aWidth[l]);
1276
1277
  }
1277
1278
  return {
1278
1279
  character: r,
1279
1280
  unicode: s,
1280
- color: a,
1281
- advanceWidth: n
1281
+ color: n,
1282
+ advanceWidth: a
1282
1283
  };
1283
1284
  });
1284
1285
  }
@@ -1299,11 +1300,11 @@ class _e {
1299
1300
  if (i.idRangeOffset[s] === 0)
1300
1301
  return t + i.idDelta[s] & 65535;
1301
1302
  {
1302
- const a = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
1303
- if (a >= 0 && a < i.glyphIdArray.length) {
1304
- const n = i.glyphIdArray[a];
1305
- if (n !== 0)
1306
- return n + i.idDelta[s] & 65535;
1303
+ const n = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
1304
+ if (n >= 0 && n < i.glyphIdArray.length) {
1305
+ const a = i.glyphIdArray[n];
1306
+ if (a !== 0)
1307
+ return a + i.idDelta[s] & 65535;
1307
1308
  }
1308
1309
  }
1309
1310
  }
@@ -1326,7 +1327,7 @@ class _e {
1326
1327
  * @returns RGB color as a tuple [r, g, b], or [0, 0, 0] if not found
1327
1328
  */
1328
1329
  getCharacterColor(e, t) {
1329
- if (!x.validate(
1330
+ if (!v.validate(
1330
1331
  typeof e == "string" && e.length === 1,
1331
1332
  "Character must be a single character string.",
1332
1333
  { method: "getCharacterColor", providedValue: e }
@@ -1342,14 +1343,14 @@ class _e {
1342
1343
  * @returns Array of RGB colors for each character
1343
1344
  */
1344
1345
  getCharacterColors(e, t) {
1345
- return x.validate(
1346
+ return v.validate(
1346
1347
  typeof e == "string" && e.length > 0,
1347
1348
  "Characters must be a string with at least one character.",
1348
1349
  { method: "getCharacterColors", providedValue: e }
1349
1350
  ) ? e.split("").map((r) => this.getCharacterColor(r, t) || [0, 0, 0]) : [[0, 0, 0]];
1350
1351
  }
1351
1352
  }
1352
- class xe {
1353
+ class ve {
1353
1354
  /**
1354
1355
  * Creates a new TextmodeFont instance.
1355
1356
  * @param renderer Renderer instance for texture creation
@@ -1525,7 +1526,7 @@ class xe {
1525
1526
  return this._font;
1526
1527
  }
1527
1528
  }
1528
- class ve {
1529
+ class xe {
1529
1530
  /**
1530
1531
  * Create a new grid instance.
1531
1532
  * @param canvas The canvas element used to determine the grid dimensions.
@@ -1667,7 +1668,9 @@ class be {
1667
1668
  o(this, "_canvas");
1668
1669
  o(this, "captureSource");
1669
1670
  o(this, "_isStandalone");
1670
- this.captureSource = e, this._isStandalone = t, this._canvas = this.createCanvas(r.width, r.height);
1671
+ o(this, "resizeObserver");
1672
+ o(this, "onTransformChange");
1673
+ this.captureSource = e, this._isStandalone = t, this._canvas = this.createCanvas(r.width, r.height), t && this.setupTransformObserver();
1671
1674
  }
1672
1675
  createCanvas(e, t) {
1673
1676
  var i;
@@ -1676,12 +1679,12 @@ class be {
1676
1679
  r.width = e || 800, r.height = t || 600, document.body.appendChild(r);
1677
1680
  else {
1678
1681
  const s = this.captureSource.getBoundingClientRect();
1679
- let a = Math.round(s.width), n = Math.round(s.height);
1682
+ let n = Math.round(s.width), a = Math.round(s.height);
1680
1683
  if (this.captureSource instanceof HTMLVideoElement) {
1681
1684
  const u = this.captureSource;
1682
- (a === 0 || n === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (a = u.videoWidth, n = u.videoHeight);
1685
+ (n === 0 || a === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (n = u.videoWidth, a = u.videoHeight);
1683
1686
  }
1684
- r.width = a, r.height = n, r.style.position = "absolute", r.style.pointerEvents = "none";
1687
+ r.width = n, r.height = a, r.style.position = "absolute", r.style.pointerEvents = "none";
1685
1688
  const l = window.getComputedStyle(this.captureSource);
1686
1689
  let c = parseInt(l.zIndex || "0", 10);
1687
1690
  isNaN(c) && (c = 0), r.style.zIndex = (c + 1).toString(), this.positionOverlayCanvas(r), (i = this.captureSource.parentNode) == null || i.insertBefore(r, this.captureSource.nextSibling);
@@ -1704,8 +1707,8 @@ class be {
1704
1707
  const r = this.captureSource.getBoundingClientRect();
1705
1708
  let i = Math.round(r.width), s = Math.round(r.height);
1706
1709
  if (this.captureSource instanceof HTMLVideoElement) {
1707
- const a = this.captureSource;
1708
- (i === 0 || s === 0) && a.videoWidth > 0 && a.videoHeight > 0 && (i = a.videoWidth, s = a.videoHeight);
1710
+ const n = this.captureSource;
1711
+ (i === 0 || s === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (i = n.videoWidth, s = n.videoHeight);
1709
1712
  }
1710
1713
  this._canvas.width = i, this._canvas.height = s, this.positionOverlayCanvas(this._canvas);
1711
1714
  }
@@ -1727,12 +1730,45 @@ class be {
1727
1730
  throw new F("WebGL context could not be created. Ensure your browser supports WebGL.");
1728
1731
  return t;
1729
1732
  }
1733
+ /**
1734
+ * Get the effective rendering dimensions accounting for CSS transforms
1735
+ */
1736
+ getEffectiveRenderingDimensions() {
1737
+ if (!this._canvas)
1738
+ return { width: 0, height: 0 };
1739
+ const e = this._canvas.getBoundingClientRect(), t = Math.round(e.width), r = Math.round(e.height);
1740
+ if (this._isStandalone) {
1741
+ const i = this._canvas.width, s = this._canvas.height;
1742
+ if (t !== i || r !== s)
1743
+ return { width: t, height: r };
1744
+ }
1745
+ return { width: this._canvas.width, height: this._canvas.height };
1746
+ }
1747
+ /**
1748
+ * Check if the canvas is affected by CSS transforms
1749
+ */
1750
+ isTransformed() {
1751
+ if (!this._canvas || !this._isStandalone) return !1;
1752
+ const e = this._canvas.getBoundingClientRect(), t = Math.round(e.width), r = Math.round(e.height);
1753
+ return t !== this._canvas.width || r !== this._canvas.height;
1754
+ }
1755
+ /**
1756
+ * Set up ResizeObserver to monitor for CSS transform changes
1757
+ */
1758
+ setupTransformObserver() {
1759
+ typeof ResizeObserver > "u" || (this.resizeObserver = new ResizeObserver((e) => {
1760
+ for (const t of e) {
1761
+ const r = t.contentRect, i = Math.round(r.width), s = Math.round(r.height);
1762
+ this.onTransformChange && (i !== this._canvas.width || s !== this._canvas.height) && this.onTransformChange();
1763
+ }
1764
+ }), this.resizeObserver.observe(this._canvas));
1765
+ }
1730
1766
  /**
1731
1767
  * Dispose of this TextmodeCanvas and clean up all resources.
1732
1768
  * This method is idempotent and safe to call multiple times.
1733
1769
  */
1734
1770
  dispose() {
1735
- if (this._canvas) {
1771
+ if (this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = void 0), this._canvas) {
1736
1772
  const e = this._canvas.getContext("webgl") || this._canvas.getContext("webgl2");
1737
1773
  if (e) {
1738
1774
  const t = e.getExtension("WEBGL_lose_context");
@@ -1855,8 +1891,8 @@ class Ce {
1855
1891
  this._framebuffer.width !== e && this._framebuffer.resize(e, t);
1856
1892
  const r = new Uint8Array(e * t * 4);
1857
1893
  for (let i = 0; i < e; i++) {
1858
- const s = i < this._colors.length ? this._colors[i] : [0, 0, 0], a = i * 4;
1859
- r[a] = s[0], r[a + 1] = s[1], r[a + 2] = s[2], r[a + 3] = 255;
1894
+ const s = i < this._colors.length ? this._colors[i] : [0, 0, 0], n = i * 4;
1895
+ r[n] = s[0], r[n + 1] = s[1], r[n + 2] = s[2], r[n + 3] = 255;
1860
1896
  }
1861
1897
  this._framebuffer.updatePixels(r, e, t);
1862
1898
  }
@@ -1886,7 +1922,7 @@ class Ce {
1886
1922
  return this._framebuffer.texture;
1887
1923
  }
1888
1924
  }
1889
- class H extends U {
1925
+ class O extends U {
1890
1926
  constructor(t, r, i, s = {}) {
1891
1927
  super(t, r, i, s);
1892
1928
  o(this, "palette");
@@ -1897,7 +1933,7 @@ class H extends U {
1897
1933
  * @param characters The characters to use for mapping, usually ordered from darkest to brightest.
1898
1934
  */
1899
1935
  characters(t) {
1900
- x.validate(
1936
+ v.validate(
1901
1937
  this.fontManager.hasAllCharacters(t),
1902
1938
  "One or more characters do not exist in the current font.",
1903
1939
  { method: "characters", providedValue: t }
@@ -1912,25 +1948,25 @@ class H extends U {
1912
1948
  * @param a Alpha component (0-255).
1913
1949
  */
1914
1950
  characterColor(t, r, i, s = 255) {
1915
- let a, n, l, c;
1951
+ let n, a, l, c;
1916
1952
  if (typeof t == "string") {
1917
1953
  const u = this.parseHexColor(t);
1918
1954
  if (!u) {
1919
- x.validate(
1955
+ v.validate(
1920
1956
  !1,
1921
1957
  "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.",
1922
1958
  { method: "characterColor", providedValue: t }
1923
1959
  );
1924
1960
  return;
1925
1961
  }
1926
- [a, n, l, c] = u;
1927
- } else if (a = t, n = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !x.validate(
1928
- [a, n, l, c].every((u) => u >= 0 && u <= 255),
1962
+ [n, a, l, c] = u;
1963
+ } else if (n = t, a = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !v.validate(
1964
+ [n, a, l, c].every((u) => u >= 0 && u <= 255),
1929
1965
  "Character color values must be between 0 and 255",
1930
- { method: "characterColor", providedValues: { r: a, g: n, b: l, a: c } }
1966
+ { method: "characterColor", providedValues: { r: n, g: a, b: l, a: c } }
1931
1967
  ))
1932
1968
  return;
1933
- this._options.characterColor = [a / 255, n / 255, l / 255, c / 255];
1969
+ this._options.characterColor = [n / 255, a / 255, l / 255, c / 255];
1934
1970
  }
1935
1971
  /**
1936
1972
  * Sets the character color mode.
@@ -1939,7 +1975,7 @@ class H extends U {
1939
1975
  * @param mode The color mode to use for characters.
1940
1976
  */
1941
1977
  characterColorMode(t) {
1942
- x.validate(
1978
+ v.validate(
1943
1979
  ["sampled", "fixed"].includes(t),
1944
1980
  "Invalid character color mode. Must be 'sampled' or 'fixed'.",
1945
1981
  { method: "characterColorMode", providedValue: t }
@@ -1954,25 +1990,25 @@ class H extends U {
1954
1990
  * @param a Alpha component (0-255).
1955
1991
  */
1956
1992
  cellColor(t, r, i, s = 255) {
1957
- let a, n, l, c;
1993
+ let n, a, l, c;
1958
1994
  if (typeof t == "string") {
1959
1995
  const u = this.parseHexColor(t);
1960
1996
  if (!u) {
1961
- x.validate(
1997
+ v.validate(
1962
1998
  !1,
1963
1999
  "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.",
1964
2000
  { method: "cellColor", providedValue: t }
1965
2001
  );
1966
2002
  return;
1967
2003
  }
1968
- [a, n, l, c] = u;
1969
- } else if (a = t, n = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !x.validate(
1970
- [a, n, l, c].every((u) => u >= 0 && u <= 255),
2004
+ [n, a, l, c] = u;
2005
+ } else if (n = t, a = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !v.validate(
2006
+ [n, a, l, c].every((u) => u >= 0 && u <= 255),
1971
2007
  "Cell color values must be between 0 and 255",
1972
- { method: "cellColor", providedValues: { r: a, g: n, b: l, a: c } }
2008
+ { method: "cellColor", providedValues: { r: n, g: a, b: l, a: c } }
1973
2009
  ))
1974
2010
  return;
1975
- this._options.cellColor = [a / 255, n / 255, l / 255, c / 255];
2011
+ this._options.cellColor = [n / 255, a / 255, l / 255, c / 255];
1976
2012
  }
1977
2013
  /**
1978
2014
  * Sets the cell color mode.
@@ -1981,7 +2017,7 @@ class H extends U {
1981
2017
  * @param mode The color mode to use for background cells.
1982
2018
  */
1983
2019
  cellColorMode(t) {
1984
- x.validate(
2020
+ v.validate(
1985
2021
  ["sampled", "fixed"].includes(t),
1986
2022
  "Invalid cell color mode. Must be 'sampled' or 'fixed'.",
1987
2023
  { method: "cellColorMode", providedValue: t }
@@ -1992,7 +2028,7 @@ class H extends U {
1992
2028
  * @param invert If `true`, the character color becomes the cell color and vice versa.
1993
2029
  */
1994
2030
  invert(t) {
1995
- x.validate(
2031
+ v.validate(
1996
2032
  typeof t == "boolean" || typeof t == "number" && Number.isInteger(t),
1997
2033
  "Invert must be a boolean value or an integer (0 for false, any other number for true).",
1998
2034
  { method: "invert", providedValue: t }
@@ -2003,7 +2039,7 @@ class H extends U {
2003
2039
  * @param angle The rotation angle in degrees.
2004
2040
  */
2005
2041
  rotation(t) {
2006
- if (!x.validate(
2042
+ if (!v.validate(
2007
2043
  typeof t == "number",
2008
2044
  "Rotation angle must be a number.",
2009
2045
  { method: "rotation", providedValue: t }
@@ -2018,7 +2054,7 @@ class H extends U {
2018
2054
  * @param flip If `true`, characters are flipped horizontally. If `false`, no flip is applied.
2019
2055
  */
2020
2056
  flipHorizontally(t) {
2021
- x.validate(
2057
+ v.validate(
2022
2058
  typeof t == "boolean" || typeof t == "number" && Number.isInteger(t),
2023
2059
  "Flip horizontally must be a boolean value or an integer (0 for false, any other number for true).",
2024
2060
  { method: "flipHorizontally", providedValue: t }
@@ -2029,7 +2065,7 @@ class H extends U {
2029
2065
  * @param flip If `true`, characters are flipped vertically. If `false`, no flip is applied.
2030
2066
  */
2031
2067
  flipVertically(t) {
2032
- x.validate(
2068
+ v.validate(
2033
2069
  typeof t == "boolean" || typeof t == "number" && Number.isInteger(t),
2034
2070
  "Flip vertically must be a boolean value or an integer (0 for false, any other number for true).",
2035
2071
  { method: "flipVertically", providedValue: t }
@@ -2043,7 +2079,7 @@ class H extends U {
2043
2079
  parseHexColor(t) {
2044
2080
  if (t = t.replace(/^#/, ""), !/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t))
2045
2081
  return null;
2046
- t.length === 3 && (t = t.split("").map((a) => a + a).join(""));
2082
+ t.length === 3 && (t = t.split("").map((n) => n + n).join(""));
2047
2083
  const r = parseInt(t.slice(0, 2), 16), i = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16);
2048
2084
  return [r, i, s, 255];
2049
2085
  }
@@ -2075,7 +2111,7 @@ const Re = {
2075
2111
  /** Range of brightness values to map to ASCII characters */
2076
2112
  brightnessRange: [0, 255]
2077
2113
  };
2078
- class L extends H {
2114
+ class L extends O {
2079
2115
  /**
2080
2116
  * Creates a new TextmodeBrightnessConverter instance.
2081
2117
  * @param renderer Renderer instance for texture creation
@@ -2107,18 +2143,18 @@ class L extends H {
2107
2143
  * @param range Array of two numbers `[min, max]`, where `min` is darkest and `max` is brightest.
2108
2144
  */
2109
2145
  brightnessRange(t) {
2110
- x.validate(
2146
+ v.validate(
2111
2147
  Array.isArray(t) && t.length === 2 && t.every((r) => typeof r == "number" && r >= 0 && r <= 255),
2112
2148
  "Brightness range must be an array of two numbers between 0 and 255.",
2113
2149
  { method: "brightnessRange", providedValue: t }
2114
2150
  ) && (this._options.brightnessRange = t);
2115
2151
  }
2116
2152
  }
2117
- const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2153
+ const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2118
2154
  __proto__: null,
2119
2155
  TextmodeBrightnessConverter: L,
2120
2156
  TextmodeConverter: U,
2121
- TextmodeFeatureConverter: H
2157
+ TextmodeFeatureConverter: O
2122
2158
  }, Symbol.toStringTag, { value: "Module" }));
2123
2159
  var Ee = "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform sampler2D u_captureTexture;uniform vec2 u_captureDimensions;uniform int u_backgroundMode;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=gl_FragCoord.xy/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);if(encodedIndexVec.a<0.01){gl_FragColor=(u_backgroundMode==0)? vec4(0.0):texture2D(u_captureTexture,gl_FragCoord.xy/u_captureDimensions);return;}int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);vec2 charCoord=vec2(charCol,charRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}";
2124
2160
  class Ue {
@@ -2154,13 +2190,13 @@ class Ue {
2154
2190
  render(e) {
2155
2191
  for (const r of this.converters) {
2156
2192
  const i = r.converter;
2157
- i.options.enabled && i instanceof H && i.convert(e);
2193
+ i.options.enabled && i instanceof O && i.convert(e);
2158
2194
  }
2159
2195
  const t = (r, i) => {
2160
2196
  r.begin(), this.renderer.clear();
2161
2197
  for (const s of this.converters) {
2162
- const a = s.converter;
2163
- a.options.enabled && this.renderer.image(i(a), 0, 0);
2198
+ const n = s.converter;
2199
+ n.options.enabled && this.renderer.image(i(n), 0, 0);
2164
2200
  }
2165
2201
  r.end();
2166
2202
  };
@@ -2172,14 +2208,14 @@ class Ue {
2172
2208
  * @returns The requested `TextmodeConverter` instance.
2173
2209
  */
2174
2210
  get(e) {
2175
- if (!x.validate(
2211
+ if (!v.validate(
2176
2212
  typeof e == "string" && e.length > 0,
2177
2213
  "Converter name must be a non-empty string.",
2178
2214
  { method: "converter", providedValue: e }
2179
2215
  ))
2180
2216
  return;
2181
2217
  const t = this.converters.find((i) => i.name === e), r = t == null ? void 0 : t.converter;
2182
- if (x.validate(
2218
+ if (v.validate(
2183
2219
  r instanceof U,
2184
2220
  `Converter "${e}" is not a valid TextmodeConverter.`,
2185
2221
  { method: "converter", providedValue: e, converterInstance: r }
@@ -2193,11 +2229,11 @@ class Ue {
2193
2229
  * @returns The newly created {@link TextmodeConverter} instance or `void` if the addition failed.
2194
2230
  */
2195
2231
  add(e, t) {
2196
- if (!x.validate(
2232
+ if (!v.validate(
2197
2233
  typeof e == "string" && e.length > 0,
2198
2234
  "Converter name must be a non-empty string.",
2199
2235
  { method: "add", providedValue: e }
2200
- ) || !x.validate(
2236
+ ) || !v.validate(
2201
2237
  t === "brightness" || t === "custom",
2202
2238
  `Converter type must be either "brightness" or "custom". Provided: ${t}`,
2203
2239
  { method: "add", providedValue: t }
@@ -2211,7 +2247,7 @@ class Ue {
2211
2247
  * @param nameOrInstance The unique name of the converter or the converter instance to remove.
2212
2248
  */
2213
2249
  remove(e) {
2214
- if (!x.validate(
2250
+ if (!v.validate(
2215
2251
  typeof e == "string" || e instanceof U,
2216
2252
  "Parameter must be either a string (converter name) or a TextmodeConverter instance.",
2217
2253
  { method: "remove", providedValue: e }
@@ -2219,7 +2255,7 @@ class Ue {
2219
2255
  return;
2220
2256
  let t = -1;
2221
2257
  if (typeof e == "string") {
2222
- if (!x.validate(
2258
+ if (!v.validate(
2223
2259
  e.length > 0,
2224
2260
  "Converter name must be a non-empty string.",
2225
2261
  { method: "remove", providedValue: e }
@@ -2228,7 +2264,7 @@ class Ue {
2228
2264
  t = this.converters.findIndex((r) => r.name === e);
2229
2265
  } else
2230
2266
  t = this.converters.findIndex((r) => r.converter === e);
2231
- x.validate(
2267
+ v.validate(
2232
2268
  t !== -1,
2233
2269
  typeof e == "string" ? `Converter with name "${e}" not found in pipeline.` : "Converter instance not found in pipeline.",
2234
2270
  { method: "remove", providedValue: e, convertersCount: this.converters.length }
@@ -2300,20 +2336,20 @@ class Ue {
2300
2336
  return this._transformFramebuffer;
2301
2337
  }
2302
2338
  }
2303
- class X {
2339
+ class H {
2304
2340
  /**
2305
2341
  * Extracts pixel data from all framebuffers needed for export
2306
2342
  * @param pipeline The conversion pipeline containing framebuffers
2307
2343
  * @returns Object containing all pixel data arrays
2308
2344
  */
2309
2345
  extractFramebufferData(e) {
2310
- const t = e.get("brightness"), r = t == null ? void 0 : t.characterFramebuffer, i = t == null ? void 0 : t.primaryColorFramebuffer, s = t == null ? void 0 : t.secondaryColorFramebuffer, a = t == null ? void 0 : t.transformFramebuffer, n = t == null ? void 0 : t.rotationFramebuffer;
2311
- return r == null || r.loadPixels(), i == null || i.loadPixels(), s == null || s.loadPixels(), a == null || a.loadPixels(), n == null || n.loadPixels(), {
2346
+ const t = e.get("brightness"), r = t == null ? void 0 : t.characterFramebuffer, i = t == null ? void 0 : t.primaryColorFramebuffer, s = t == null ? void 0 : t.secondaryColorFramebuffer, n = t == null ? void 0 : t.transformFramebuffer, a = t == null ? void 0 : t.rotationFramebuffer;
2347
+ return r == null || r.loadPixels(), i == null || i.loadPixels(), s == null || s.loadPixels(), n == null || n.loadPixels(), a == null || a.loadPixels(), {
2312
2348
  characterPixels: (r == null ? void 0 : r.pixels) || new Uint8Array(0),
2313
2349
  primaryColorPixels: (i == null ? void 0 : i.pixels) || new Uint8Array(0),
2314
2350
  secondaryColorPixels: (s == null ? void 0 : s.pixels) || new Uint8Array(0),
2315
- transformPixels: (a == null ? void 0 : a.pixels) || new Uint8Array(0),
2316
- rotationPixels: (n == null ? void 0 : n.pixels) || new Uint8Array(0)
2351
+ transformPixels: (n == null ? void 0 : n.pixels) || new Uint8Array(0),
2352
+ rotationPixels: (a == null ? void 0 : a.pixels) || new Uint8Array(0)
2317
2353
  };
2318
2354
  }
2319
2355
  /**
@@ -2342,7 +2378,7 @@ class X {
2342
2378
  };
2343
2379
  }
2344
2380
  }
2345
- class N {
2381
+ class X {
2346
2382
  /**
2347
2383
  * Creates a downloadable blob from content
2348
2384
  * @param content The content to include in the blob
@@ -2360,8 +2396,8 @@ class N {
2360
2396
  */
2361
2397
  downloadFile(e, t, r) {
2362
2398
  try {
2363
- const i = this.createBlob(e, r), s = URL.createObjectURL(i), a = document.createElement("a");
2364
- a.href = s, a.download = t, a.style.display = "none", a.rel = "noopener", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(s);
2399
+ const i = this.createBlob(e, r), s = URL.createObjectURL(i), n = document.createElement("a");
2400
+ n.href = s, n.download = t, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(s);
2365
2401
  } catch (i) {
2366
2402
  throw console.error("Failed to download file:", i), new Error(`File download failed: ${i instanceof Error ? i.message : "Unknown error"}`);
2367
2403
  }
@@ -2399,7 +2435,7 @@ class N {
2399
2435
  return `'textmode-export'-${this.generateTimestamp()}`;
2400
2436
  }
2401
2437
  }
2402
- class Ae extends X {
2438
+ class Ae extends H {
2403
2439
  /**
2404
2440
  * Extracts transform data from transform pixels
2405
2441
  * @param transformPixels Transform framebuffer pixels
@@ -2408,9 +2444,9 @@ class Ae extends X {
2408
2444
  * @returns Transform data object
2409
2445
  */
2410
2446
  extractTransformData(e, t, r) {
2411
- const i = e[r], s = e[r + 1], a = e[r + 2], n = i === 255, l = s === 255, c = a === 255, u = t[r], d = t[r + 1], f = u + d / 255, g = Math.round(f * 360 / 255 * 100) / 100;
2447
+ const i = e[r], s = e[r + 1], n = e[r + 2], a = i === 255, l = s === 255, c = n === 255, u = t[r], d = t[r + 1], f = u + d / 255, g = Math.round(f * 360 / 255 * 100) / 100;
2412
2448
  return {
2413
- isInverted: n,
2449
+ isInverted: a,
2414
2450
  flipHorizontal: l,
2415
2451
  flipVertical: c,
2416
2452
  rotation: g
@@ -2442,22 +2478,22 @@ class Ae extends X {
2442
2478
  const r = [];
2443
2479
  let i = 0;
2444
2480
  for (let s = 0; s < t.rows; s++)
2445
- for (let a = 0; a < t.cols; a++) {
2446
- const n = i * 4, l = this.getCharacterIndex(
2481
+ for (let n = 0; n < t.cols; n++) {
2482
+ const a = i * 4, l = this.getCharacterIndex(
2447
2483
  e.characterPixels,
2448
- n
2484
+ a
2449
2485
  );
2450
- let c = this.pixelsToRGBA(e.primaryColorPixels, n), u = this.pixelsToRGBA(e.secondaryColorPixels, n);
2486
+ let c = this.pixelsToRGBA(e.primaryColorPixels, a), u = this.pixelsToRGBA(e.secondaryColorPixels, a);
2451
2487
  const d = this.extractTransformData(
2452
2488
  e.transformPixels,
2453
2489
  e.rotationPixels,
2454
- n
2490
+ a
2455
2491
  );
2456
2492
  if (d.isInverted) {
2457
2493
  const g = c;
2458
2494
  c = u, u = g;
2459
2495
  }
2460
- const f = this.calculateCellPosition(a, s, t);
2496
+ const f = this.calculateCellPosition(n, s, t);
2461
2497
  r.push({
2462
2498
  charIndex: l,
2463
2499
  primaryColor: c,
@@ -2486,11 +2522,11 @@ class Me {
2486
2522
  if (i.idRangeOffset[s] === 0)
2487
2523
  return t + i.idDelta[s] & 65535;
2488
2524
  {
2489
- const a = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
2490
- if (a >= 0 && a < i.glyphIdArray.length) {
2491
- const n = i.glyphIdArray[a];
2492
- if (n !== 0)
2493
- return n + i.idDelta[s] & 65535;
2525
+ const n = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
2526
+ if (n >= 0 && n < i.glyphIdArray.length) {
2527
+ const a = i.glyphIdArray[n];
2528
+ if (a !== 0)
2529
+ return a + i.idDelta[s] & 65535;
2494
2530
  }
2495
2531
  }
2496
2532
  }
@@ -2519,15 +2555,15 @@ class Me {
2519
2555
  createGlyphPath(e, t, r, i, s) {
2520
2556
  if (!t || !t.xs || t.xs.length === 0)
2521
2557
  return this.createEmptyPath();
2522
- const a = s / e.head.unitsPerEm;
2558
+ const n = s / e.head.unitsPerEm;
2523
2559
  return {
2524
2560
  getBoundingBox: () => ({
2525
- x1: r + t.xMin * a,
2526
- y1: i + -t.yMax * a,
2527
- x2: r + t.xMax * a,
2528
- y2: i + -t.yMin * a
2561
+ x1: r + t.xMin * n,
2562
+ y1: i + -t.yMax * n,
2563
+ x2: r + t.xMax * n,
2564
+ y2: i + -t.yMin * n
2529
2565
  }),
2530
- toSVG: () => this.glyphToSVGPath(t, r, i, a)
2566
+ toSVG: () => this.glyphToSVGPath(t, r, i, n)
2531
2567
  };
2532
2568
  }
2533
2569
  /**
@@ -2540,29 +2576,29 @@ class Me {
2540
2576
  */
2541
2577
  glyphToSVGPath(e, t, r, i) {
2542
2578
  if (!e || !e.xs) return "";
2543
- const { xs: s, ys: a, endPts: n, flags: l } = e;
2544
- if (!s || !a || !n || !l) return "";
2579
+ const { xs: s, ys: n, endPts: a, flags: l } = e;
2580
+ if (!s || !n || !a || !l) return "";
2545
2581
  let c = "", u = 0;
2546
- for (let d = 0; d < n.length; d++) {
2547
- const f = n[d];
2582
+ for (let d = 0; d < a.length; d++) {
2583
+ const f = a[d];
2548
2584
  if (!(f < u)) {
2549
2585
  if (f >= u) {
2550
- const g = t + s[u] * i, _ = r - a[u] * i;
2586
+ const g = t + s[u] * i, _ = r - n[u] * i;
2551
2587
  c += `M${g.toFixed(2)},${_.toFixed(2)}`;
2552
2588
  let p = u + 1;
2553
2589
  for (; p <= f; )
2554
2590
  if ((l[p] & 1) !== 0) {
2555
- const C = t + s[p] * i, v = r - a[p] * i;
2556
- c += `L${C.toFixed(2)},${v.toFixed(2)}`, p++;
2591
+ const C = t + s[p] * i, x = r - n[p] * i;
2592
+ c += `L${C.toFixed(2)},${x.toFixed(2)}`, p++;
2557
2593
  } else {
2558
- const C = t + s[p] * i, v = r - a[p] * i;
2594
+ const C = t + s[p] * i, x = r - n[p] * i;
2559
2595
  let w = p + 1 > f ? u : p + 1;
2560
2596
  if ((l[w] & 1) !== 0) {
2561
- const R = t + s[w] * i, S = r - a[w] * i;
2562
- c += `Q${C.toFixed(2)},${v.toFixed(2)} ${R.toFixed(2)},${S.toFixed(2)}`, p = w + 1;
2597
+ const R = t + s[w] * i, S = r - n[w] * i;
2598
+ c += `Q${C.toFixed(2)},${x.toFixed(2)} ${R.toFixed(2)},${S.toFixed(2)}`, p = w + 1;
2563
2599
  } else {
2564
- const R = t + s[w] * i, S = r - a[w] * i, P = (C + R) / 2, D = (v + S) / 2;
2565
- c += `Q${C.toFixed(2)},${v.toFixed(2)} ${P.toFixed(2)},${D.toFixed(2)}`, p = w;
2600
+ const R = t + s[w] * i, S = r - n[w] * i, P = (C + R) / 2, D = (x + S) / 2;
2601
+ c += `Q${C.toFixed(2)},${x.toFixed(2)} ${P.toFixed(2)},${D.toFixed(2)}`, p = w;
2566
2602
  }
2567
2603
  }
2568
2604
  c += "Z";
@@ -2583,18 +2619,18 @@ class Me {
2583
2619
  */
2584
2620
  generateCharacterPath(e, t, r, i, s) {
2585
2621
  try {
2586
- const a = e.codePointAt(0) || 0, n = this.getGlyphIndex(t, a);
2587
- if (n === 0)
2622
+ const n = e.codePointAt(0) || 0, a = this.getGlyphIndex(t, n);
2623
+ if (a === 0)
2588
2624
  return this.createEmptyPath();
2589
2625
  let l = null;
2590
2626
  try {
2591
- t.glyf && t.glyf[n] !== null ? l = t.glyf[n] : m && m.T && m.T.glyf && m.T.glyf._parseGlyf && (l = m.T.glyf._parseGlyf(t, n), t.glyf && l && (t.glyf[n] = l));
2627
+ t.glyf && t.glyf[a] !== null ? l = t.glyf[a] : m && m.T && m.T.glyf && m.T.glyf._parseGlyf && (l = m.T.glyf._parseGlyf(t, a), t.glyf && l && (t.glyf[a] = l));
2592
2628
  } catch (c) {
2593
- console.warn(`Failed to parse glyph ${n}:`, c);
2629
+ console.warn(`Failed to parse glyph ${a}:`, c);
2594
2630
  }
2595
2631
  return l ? this.createGlyphPath(t, l, r, i, s) : this.createEmptyPath();
2596
- } catch (a) {
2597
- return console.warn(`Failed to generate path for character "${e}":`, a), this.createEmptyPath();
2632
+ } catch (n) {
2633
+ return console.warn(`Failed to generate path for character "${e}":`, n), this.createEmptyPath();
2598
2634
  }
2599
2635
  }
2600
2636
  /**
@@ -2609,10 +2645,10 @@ class Me {
2609
2645
  * @param advanceWidth Character advance width
2610
2646
  * @returns SVG path data string or null if generation fails
2611
2647
  */
2612
- generatePositionedCharacterPath(e, t, r, i, s, a, n, l) {
2648
+ generatePositionedCharacterPath(e, t, r, i, s, n, a, l) {
2613
2649
  try {
2614
- const c = n / t.head.unitsPerEm, u = l * c, d = r + (s - u) / 2, f = i + (a + n * 0.7) / 2;
2615
- return this.generateCharacterPath(e, t, d, f, n).toSVG() || null;
2650
+ const c = a / t.head.unitsPerEm, u = l * c, d = r + (s - u) / 2, f = i + (n + a * 0.7) / 2;
2651
+ return this.generateCharacterPath(e, t, d, f, a).toSVG() || null;
2616
2652
  } catch (c) {
2617
2653
  return console.warn(`Failed to generate positioned character path for "${e}":`, c), null;
2618
2654
  }
@@ -2673,12 +2709,12 @@ class De {
2673
2709
  * @returns Transform attribute string or empty string
2674
2710
  */
2675
2711
  generateTransformAttribute(e, t) {
2676
- const { transform: r, position: i } = e, s = i.cellX + t.cellWidth / 2, a = i.cellY + t.cellHeight / 2, n = [];
2712
+ const { transform: r, position: i } = e, s = i.cellX + t.cellWidth / 2, n = i.cellY + t.cellHeight / 2, a = [];
2677
2713
  if (r.flipHorizontal || r.flipVertical) {
2678
2714
  const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
2679
- n.push(`translate(${s} ${a})`), n.push(`scale(${l} ${c})`), n.push(`translate(${-s} ${-a})`);
2715
+ a.push(`translate(${s} ${n})`), a.push(`scale(${l} ${c})`), a.push(`translate(${-s} ${-n})`);
2680
2716
  }
2681
- return r.rotation && n.push(`rotate(${r.rotation} ${s} ${a})`), n.length ? ` transform="${n.join(" ")}"` : "";
2717
+ return r.rotation && a.push(`rotate(${r.rotation} ${s} ${n})`), a.length ? ` transform="${a.join(" ")}"` : "";
2682
2718
  }
2683
2719
  /**
2684
2720
  * Generates background rectangle for a cell
@@ -2707,7 +2743,7 @@ class De {
2707
2743
  const s = r.characters[e.charIndex];
2708
2744
  if (!s)
2709
2745
  return "";
2710
- const a = this.pathGenerator.generatePositionedCharacterPath(
2746
+ const n = this.pathGenerator.generatePositionedCharacterPath(
2711
2747
  s.character,
2712
2748
  r.font,
2713
2749
  e.position.cellX,
@@ -2717,12 +2753,12 @@ class De {
2717
2753
  r.fontSize,
2718
2754
  s.advanceWidth
2719
2755
  );
2720
- if (!a)
2756
+ if (!n)
2721
2757
  return "";
2722
- const n = this.rgbaToColorString(e.primaryColor);
2758
+ const a = this.rgbaToColorString(e.primaryColor);
2723
2759
  return i.drawMode === "stroke" ? `
2724
- <path id="${`path-${e.charIndex}-${e.position.cellX}-${e.position.cellY}`.replace(/\./g, "-")}" d="${a}" stroke="${n}" stroke-width="${i.strokeWidth}" fill="none" />` : `
2725
- <path d="${a}" fill="${n}" />`;
2760
+ <path id="${`path-${e.charIndex}-${e.position.cellX}-${e.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${a}" stroke-width="${i.strokeWidth}" fill="none" />` : `
2761
+ <path d="${n}" fill="${a}" />`;
2726
2762
  }
2727
2763
  /**
2728
2764
  * Generates complete SVG content for a single cell
@@ -2735,10 +2771,10 @@ class De {
2735
2771
  generateCellContent(e, t, r, i) {
2736
2772
  let s = "";
2737
2773
  s += this.generateCellBackground(e, t, i);
2738
- const a = this.generateTransformAttribute(e, t), n = this.generateCharacterPath(e, t, r, i);
2739
- return n && (a ? (s += `
2740
- <g${a}>`, s += n, s += `
2741
- </g>`) : s += n), s;
2774
+ const n = this.generateTransformAttribute(e, t), a = this.generateCharacterPath(e, t, r, i);
2775
+ return a && (n ? (s += `
2776
+ <g${n}>`, s += a, s += `
2777
+ </g>`) : s += a), s;
2742
2778
  }
2743
2779
  /**
2744
2780
  * Generates the complete SVG content from cell data
@@ -2752,8 +2788,8 @@ class De {
2752
2788
  let s = this.generateSVGHeader(t);
2753
2789
  s += this.generateBackground(t, i), s += `
2754
2790
  <g id="ascii-cells">`;
2755
- for (const a of e)
2756
- s += this.generateCellContent(a, t, r, i);
2791
+ for (const n of e)
2792
+ s += this.generateCellContent(n, t, r, i);
2757
2793
  return s += this.generateSVGFooter(), s;
2758
2794
  }
2759
2795
  /**
@@ -2766,7 +2802,7 @@ class De {
2766
2802
  `).replace(/[ \t]+$/gm, "");
2767
2803
  }
2768
2804
  }
2769
- class Ie extends N {
2805
+ class Ie extends X {
2770
2806
  /**
2771
2807
  * Creates a downloadable blob from SVG content
2772
2808
  * @param svgContent The SVG content string
@@ -2826,13 +2862,13 @@ class Y {
2826
2862
  const r = this.applyDefaultOptions(t), i = this.dataExtractor.extractFramebufferData(e.pipeline), s = this.dataExtractor.extractSVGCellData(
2827
2863
  i,
2828
2864
  e.grid
2829
- ), a = this.contentGenerator.generateSVGContent(
2865
+ ), n = this.contentGenerator.generateSVGContent(
2830
2866
  s,
2831
2867
  e.grid,
2832
2868
  e.font,
2833
2869
  r
2834
2870
  );
2835
- return this.contentGenerator.optimizeSVGContent(a);
2871
+ return this.contentGenerator.optimizeSVGContent(n);
2836
2872
  }
2837
2873
  /**
2838
2874
  * Exports SVG content to a downloadable file
@@ -2848,7 +2884,7 @@ class Y {
2848
2884
  }
2849
2885
  }
2850
2886
  }
2851
- class Pe extends X {
2887
+ class Pe extends H {
2852
2888
  /**
2853
2889
  * Extracts character data for TXT generation
2854
2890
  * @param framebufferData Framebuffer pixel data
@@ -2858,17 +2894,17 @@ class Pe extends X {
2858
2894
  * @returns 2D array of characters (rows x columns)
2859
2895
  */
2860
2896
  extractCharacterGrid(e, t, r, i = " ") {
2861
- var n;
2897
+ var a;
2862
2898
  const s = [];
2863
- let a = 0;
2899
+ let n = 0;
2864
2900
  for (let l = 0; l < t.rows; l++) {
2865
2901
  const c = [];
2866
2902
  for (let u = 0; u < t.cols; u++) {
2867
- const d = a * 4, f = this.getCharacterIndex(
2903
+ const d = n * 4, f = this.getCharacterIndex(
2868
2904
  e.characterPixels,
2869
2905
  d
2870
- ), g = ((n = r.characters[f]) == null ? void 0 : n.character) || i;
2871
- c.push(g), a++;
2906
+ ), g = ((a = r.characters[f]) == null ? void 0 : a.character) || i;
2907
+ c.push(g), n++;
2872
2908
  }
2873
2909
  s.push(c);
2874
2910
  }
@@ -2885,8 +2921,8 @@ class Be {
2885
2921
  generateTXTContent(e, t) {
2886
2922
  const r = [];
2887
2923
  for (const s of e) {
2888
- let a = s.join("");
2889
- t.preserveTrailingSpaces || (a = a.replace(/\s+$/, "")), r.push(a);
2924
+ let n = s.join("");
2925
+ t.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), r.push(n);
2890
2926
  }
2891
2927
  const i = t.lineEnding === "crlf" ? `\r
2892
2928
  ` : `
@@ -2894,7 +2930,7 @@ class Be {
2894
2930
  return r.join(i);
2895
2931
  }
2896
2932
  }
2897
- class Ge extends N {
2933
+ class Ge extends X {
2898
2934
  /**
2899
2935
  * Saves TXT content as a downloadable file
2900
2936
  * @param content The TXT content to save
@@ -2969,7 +3005,7 @@ class j {
2969
3005
  }
2970
3006
  }
2971
3007
  }
2972
- class Ve extends X {
3008
+ class Ve extends H {
2973
3009
  /**
2974
3010
  * Captures the current state of the textmode canvas as image data
2975
3011
  * @param canvas The canvas data containing the rendered textmode graphics
@@ -2981,8 +3017,8 @@ class Ve extends X {
2981
3017
  const i = e.canvas;
2982
3018
  if (t === 1 && r === "transparent")
2983
3019
  return i;
2984
- const s = document.createElement("canvas"), a = s.getContext("2d"), n = Math.round(i.width * t), l = Math.round(i.height * t);
2985
- return s.width = n, s.height = l, r !== "transparent" && (a.fillStyle = r, a.fillRect(0, 0, n, l)), a.imageSmoothingEnabled = !1, a.drawImage(
3020
+ const s = document.createElement("canvas"), n = s.getContext("2d"), a = Math.round(i.width * t), l = Math.round(i.height * t);
3021
+ return s.width = a, s.height = l, r !== "transparent" && (n.fillStyle = r, n.fillRect(0, 0, a, l)), n.imageSmoothingEnabled = !1, n.drawImage(
2986
3022
  i,
2987
3023
  0,
2988
3024
  0,
@@ -2990,7 +3026,7 @@ class Ve extends X {
2990
3026
  i.height,
2991
3027
  0,
2992
3028
  0,
2993
- n,
3029
+ a,
2994
3030
  l
2995
3031
  ), s;
2996
3032
  }
@@ -3014,10 +3050,10 @@ class ke {
3014
3050
  */
3015
3051
  async generateImageBlob(e, t) {
3016
3052
  return new Promise((r, i) => {
3017
- const s = this.getMimeType(t.format), a = (n) => {
3018
- n ? r(n) : i(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
3053
+ const s = this.getMimeType(t.format), n = (a) => {
3054
+ a ? r(a) : i(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
3019
3055
  };
3020
- t.format === "png" ? e.toBlob(a, s) : e.toBlob(a, s, t.quality);
3056
+ t.format === "png" ? e.toBlob(n, s) : e.toBlob(n, s, t.quality);
3021
3057
  });
3022
3058
  }
3023
3059
  /**
@@ -3047,7 +3083,7 @@ const q = {
3047
3083
  jpg: ".jpg",
3048
3084
  webp: ".webp"
3049
3085
  };
3050
- class ze extends N {
3086
+ class ze extends X {
3051
3087
  /**
3052
3088
  * Saves image content as a downloadable file
3053
3089
  * @param content The image content (data URL or blob)
@@ -3244,10 +3280,13 @@ class I {
3244
3280
  static async create(e = null, t = {}) {
3245
3281
  const r = new I(e, t), i = r._standalone ? t : void 0;
3246
3282
  r.textmodeCanvas = new be(r.captureSource, r._standalone, i), r._renderer = new fe(r.textmodeCanvas.getWebGLContext());
3247
- let s, a;
3248
- r._standalone ? (s = t.width || 800, a = t.height || 600) : (s = r.textmodeCanvas.width || 800, a = r.textmodeCanvas.height || 600), r._canvasFramebuffer = r._renderer.createFramebuffer(s, a), r._font = new xe(r._renderer, t.fontSize ?? 16), await r._font.initialize(t.fontSource);
3249
- const n = r._font.maxGlyphDimensions;
3250
- return r._grid = new ve(r.textmodeCanvas.canvas, n.width, n.height), r._pipeline = new Ue(r._renderer, r._font, r._grid), r.setupEventListeners(), r.startAutoRendering(), r;
3283
+ let s, n;
3284
+ r._standalone ? (s = t.width || 800, n = t.height || 600) : (s = r.textmodeCanvas.width || 800, n = r.textmodeCanvas.height || 600), r._canvasFramebuffer = r._renderer.createFramebuffer(s, n), r._font = new ve(r._renderer, t.fontSize ?? 16), await r._font.initialize(t.fontSource);
3285
+ const a = r._font.maxGlyphDimensions;
3286
+ return r._grid = new xe(r.textmodeCanvas.canvas, a.width, a.height), r._pipeline = new Ue(r._renderer, r._font, r._grid), r.setupEventListeners(), r._standalone && (r.textmodeCanvas.onTransformChange = () => {
3287
+ const l = r.textmodeCanvas.getEffectiveRenderingDimensions();
3288
+ r._renderer.resetViewport(l.width, l.height), r._mode === "auto" && r.render();
3289
+ }), r.startAutoRendering(), r;
3251
3290
  }
3252
3291
  setupEventListeners() {
3253
3292
  this._windowResizeListener = () => {
@@ -3488,7 +3527,12 @@ class I {
3488
3527
  }
3489
3528
  }
3490
3529
  resize() {
3491
- this.textmodeCanvas.resize(), this._canvasFramebuffer.resize(this.textmodeCanvas.width, this.textmodeCanvas.height), this._grid.resize(), this._pipeline.resize(), this._renderer.resetViewport(), this._mode !== "manual" && this.render();
3530
+ if (this.textmodeCanvas.resize(), this._canvasFramebuffer.resize(this.textmodeCanvas.width, this.textmodeCanvas.height), this._grid.resize(), this._pipeline.resize(), this._standalone) {
3531
+ const e = this.textmodeCanvas.getEffectiveRenderingDimensions();
3532
+ this._renderer.resetViewport(e.width, e.height);
3533
+ } else
3534
+ this._renderer.resetViewport();
3535
+ this._mode !== "manual" && this.render();
3492
3536
  }
3493
3537
  /**
3494
3538
  * Start automatic rendering
@@ -3666,7 +3710,7 @@ class I {
3666
3710
  * ```
3667
3711
  */
3668
3712
  redraw(e = 1) {
3669
- if (x.validate(
3713
+ if (v.validate(
3670
3714
  typeof e == "number" && e > 0 && Number.isInteger(e),
3671
3715
  "Redraw count must be a positive integer.",
3672
3716
  { method: "redraw", providedValue: e }
@@ -3722,11 +3766,16 @@ class I {
3722
3766
  * ```
3723
3767
  */
3724
3768
  fontSize(e) {
3725
- x.validate(
3769
+ if (v.validate(
3726
3770
  typeof e == "number" && e > 0,
3727
3771
  "Font size must be a positive number greater than 0.",
3728
3772
  { method: "fontSize", providedValue: e }
3729
- ) && this._font.fontSize !== e && (this._font.setFontSize(e), this._grid.resizeCellPixelDimensions(this._font.maxGlyphDimensions.width, this._font.maxGlyphDimensions.height), this._pipeline.resize(), this._renderer.resetViewport());
3773
+ ) && this._font.fontSize !== e)
3774
+ if (this._font.setFontSize(e), this._grid.resizeCellPixelDimensions(this._font.maxGlyphDimensions.width, this._font.maxGlyphDimensions.height), this._pipeline.resize(), this._standalone) {
3775
+ const t = this.textmodeCanvas.getEffectiveRenderingDimensions();
3776
+ this._renderer.resetViewport(t.width, t.height);
3777
+ } else
3778
+ this._renderer.resetViewport();
3730
3779
  }
3731
3780
  /**
3732
3781
  * Set a draw callback function that will be executed before each render.
@@ -3793,7 +3842,12 @@ class I {
3793
3842
  * @param height The new height of the canvas.
3794
3843
  */
3795
3844
  resizeCanvas(e, t) {
3796
- this.textmodeCanvas.resize(e, t), this._canvasFramebuffer.resize(this.textmodeCanvas.width, this.textmodeCanvas.height), this._grid.resize(), this._pipeline.resize(), this._renderer.resetViewport(), this._mode !== "manual" && this.render();
3845
+ if (this.textmodeCanvas.resize(e, t), this._canvasFramebuffer.resize(this.textmodeCanvas.width, this.textmodeCanvas.height), this._grid.resize(), this._pipeline.resize(), this._standalone) {
3846
+ const r = this.textmodeCanvas.getEffectiveRenderingDimensions();
3847
+ this._renderer.resetViewport(r.width, r.height);
3848
+ } else
3849
+ this._renderer.resetViewport();
3850
+ this._mode !== "manual" && this.render();
3797
3851
  }
3798
3852
  /**
3799
3853
  * @inheritDoc TextmodeConversionPipeline.get
@@ -4314,7 +4368,7 @@ class I {
4314
4368
  return this._isDisposed;
4315
4369
  }
4316
4370
  }
4317
- class O {
4371
+ class N {
4318
4372
  /**
4319
4373
  * Create a {@link Textmodifier} instance for textmode rendering.
4320
4374
  *
@@ -4393,7 +4447,7 @@ class O {
4393
4447
  * ```
4394
4448
  */
4395
4449
  static setErrorLevel(e) {
4396
- x.setGlobalLevel(e);
4450
+ v.setGlobalLevel(e);
4397
4451
  }
4398
4452
  /**
4399
4453
  * Returns the current version of the `textmode.js` library.
@@ -4404,27 +4458,27 @@ class O {
4404
4458
  * ```
4405
4459
  */
4406
4460
  static get version() {
4407
- return "0.1.6-beta.1";
4461
+ return "0.1.6-beta.2";
4408
4462
  }
4409
4463
  constructor() {
4410
4464
  throw new Error("Textmode is a static class and cannot be instantiated.");
4411
4465
  }
4412
4466
  }
4413
- const Xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4414
4468
  __proto__: null
4415
- }, Symbol.toStringTag, { value: "Module" })), Ne = O.create, Oe = O.setErrorLevel, We = O.version;
4469
+ }, Symbol.toStringTag, { value: "Module" })), Xe = N.create, Ne = N.setErrorLevel, We = N.version;
4416
4470
  export {
4417
4471
  be as TextmodeCanvas,
4418
4472
  Ue as TextmodeConversionPipeline,
4419
- ne as TextmodeErrorLevel,
4420
- xe as TextmodeFont,
4421
- ve as TextmodeGrid,
4473
+ ae as TextmodeErrorLevel,
4474
+ ve as TextmodeFont,
4475
+ xe as TextmodeGrid,
4422
4476
  I as Textmodifier,
4423
- He as converters,
4424
- Ne as create,
4425
- O as default,
4426
- Xe as export,
4427
- Oe as setErrorLevel,
4428
- O as textmode,
4477
+ Oe as converters,
4478
+ Xe as create,
4479
+ N as default,
4480
+ He as export,
4481
+ Ne as setErrorLevel,
4482
+ N as textmode,
4429
4483
  We as version
4430
4484
  };