textmode.export.js 1.3.0-beta.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/textmode.export.esm.js +1003 -871
- package/dist/textmode.export.umd.js +2 -2
- package/dist/types/exporters/base/CharacterResolver.d.ts +29 -0
- package/dist/types/exporters/base/CharacterResolver.d.ts.map +1 -0
- package/dist/types/exporters/base/DataExtractor.d.ts +10 -2
- package/dist/types/exporters/base/DataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/base/LayerTarget.d.ts +46 -0
- package/dist/types/exporters/base/LayerTarget.d.ts.map +1 -0
- package/dist/types/exporters/base/index.d.ts +3 -0
- package/dist/types/exporters/base/index.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFExporter.d.ts +1 -1
- package/dist/types/exporters/gif/GIFExporter.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFRecorder.d.ts +1 -1
- package/dist/types/exporters/gif/GIFRecorder.d.ts.map +1 -1
- package/dist/types/exporters/json/JSONDataExtractor.d.ts +3 -4
- package/dist/types/exporters/json/JSONDataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/json/JSONExporter.d.ts +12 -7
- package/dist/types/exporters/json/JSONExporter.d.ts.map +1 -1
- package/dist/types/exporters/json/index.d.ts +1 -1
- package/dist/types/exporters/json/index.d.ts.map +1 -1
- package/dist/types/exporters/json/types.d.ts +78 -15
- package/dist/types/exporters/json/types.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts +1 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGExporter.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGExporter.test.d.ts +2 -0
- package/dist/types/exporters/svg/SVGExporter.test.d.ts.map +1 -0
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts +7 -15
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/types.d.ts +4 -2
- package/dist/types/exporters/svg/types.d.ts.map +1 -1
- package/dist/types/exporters/txt/TXTExporter.d.ts.map +1 -1
- package/dist/types/exporters/txt/TXTExporter.test.d.ts +2 -0
- package/dist/types/exporters/txt/TXTExporter.test.d.ts.map +1 -0
- package/dist/types/exporters/txt/types.d.ts +3 -1
- package/dist/types/exporters/txt/types.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoExporter.d.ts +1 -1
- package/dist/types/exporters/video/VideoExporter.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoRecorder.d.ts +1 -1
- package/dist/types/exporters/video/VideoRecorder.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/overlay/blades/Blade.d.ts +2 -0
- package/dist/types/overlay/blades/Blade.d.ts.map +1 -1
- package/dist/types/overlay/blades/JSONBlade.d.ts +5 -0
- package/dist/types/overlay/blades/JSONBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/SVGBlade.d.ts +2 -0
- package/dist/types/overlay/blades/SVGBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/TextBlade.d.ts +2 -0
- package/dist/types/overlay/blades/TextBlade.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/LayerTargetSelect.d.ts +20 -0
- package/dist/types/overlay/components/inputs/LayerTargetSelect.d.ts.map +1 -0
- package/dist/types/overlay/core/OverlayController.d.ts +1 -0
- package/dist/types/overlay/core/OverlayController.d.ts.map +1 -1
- package/dist/types/overlay/formatRegistry.d.ts +2 -1
- package/dist/types/overlay/formatRegistry.d.ts.map +1 -1
- package/dist/types/overlay/formatRegistry.test.d.ts +2 -0
- package/dist/types/overlay/formatRegistry.test.d.ts.map +1 -0
- package/dist/types/overlay/index.d.ts +3 -1
- package/dist/types/overlay/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +21 -18
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -1,613 +1,654 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (i,
|
|
1
|
+
var te = Object.defineProperty;
|
|
2
|
+
var ee = (i, e, t) => e in i ? te(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var p = (i, e, t) => ee(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
class xt {
|
|
5
|
-
$extractFramebufferData(
|
|
6
|
-
return { characterPixels:
|
|
5
|
+
$extractFramebufferData(e) {
|
|
6
|
+
return { characterPixels: e.readPixels(0), primaryColorPixels: e.readPixels(1), secondaryColorPixels: e.readPixels(2) };
|
|
7
7
|
}
|
|
8
|
-
$
|
|
9
|
-
return
|
|
8
|
+
$getEncodedCharacterValue(e, t) {
|
|
9
|
+
return e[t] + (e[t + 1] << 8);
|
|
10
10
|
}
|
|
11
|
-
$
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
$getCharacterIndex(e, t) {
|
|
12
|
+
return this.$getEncodedCharacterValue(e, t);
|
|
13
|
+
}
|
|
14
|
+
$extractCellTransform(e, t) {
|
|
15
|
+
const r = e[t + 2], a = e[t + 3] / 255;
|
|
16
|
+
return { isInverted: !!(1 & r), flipHorizontal: !!(2 & r), flipVertical: !!(4 & r), rotation: Math.round(360 * a * 100) / 100 };
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
|
-
class
|
|
17
|
-
$downloadFile(
|
|
19
|
+
class X {
|
|
20
|
+
$downloadFile(e, t) {
|
|
18
21
|
try {
|
|
19
|
-
const
|
|
20
|
-
o.href = a, o.download =
|
|
21
|
-
} catch (
|
|
22
|
-
console.error("[textmode-export] Failed to download file:",
|
|
22
|
+
const r = this._sanitizeFilename(t), a = URL.createObjectURL(e), o = document.createElement("a");
|
|
23
|
+
o.href = a, o.download = r, o.style.display = "none", o.rel = "noopener", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a);
|
|
24
|
+
} catch (r) {
|
|
25
|
+
console.error("[textmode-export] Failed to download file:", r);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
_sanitizeFilename(
|
|
26
|
-
if (!
|
|
27
|
-
const t =
|
|
28
|
+
_sanitizeFilename(e) {
|
|
29
|
+
if (!e) return this._generateDefaultFilename();
|
|
30
|
+
const t = e.trim();
|
|
28
31
|
return t ? t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
|
|
29
32
|
}
|
|
30
33
|
_generateDefaultFilename() {
|
|
31
34
|
return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const Et = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
function re(i) {
|
|
39
|
+
return Math.round(255 * i[0]) + (Math.round(255 * i[1]) << 8);
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
function _t(i, e) {
|
|
42
|
+
let t = Et.get(i);
|
|
43
|
+
if (!t) {
|
|
44
|
+
t = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const r of i.characters) t.set(re(r.color), r);
|
|
46
|
+
Et.set(i, t);
|
|
40
47
|
}
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
return t.get(e);
|
|
49
|
+
}
|
|
50
|
+
function zt(i, e) {
|
|
51
|
+
const t = i === "base" ? "Base layer" : `Layer ${Number.parseInt(i.replace("layer-", ""), 10)}`;
|
|
52
|
+
return e._visible === !1 ? `${t} (hidden)` : t;
|
|
53
|
+
}
|
|
54
|
+
function kt(i) {
|
|
55
|
+
return [{ id: "base", layer: i.layers.base }, ...i.layers.all.map((e, t) => ({ id: `layer-${t + 1}`, layer: e }))].map(({ id: e, layer: t }) => ({ id: e, label: zt(e, t), layer: t }));
|
|
56
|
+
}
|
|
57
|
+
function ae(i) {
|
|
58
|
+
return { getOptions: () => kt(i), getLayerById: (e) => {
|
|
59
|
+
var t;
|
|
60
|
+
return (t = kt(i).find((r) => r.id === e)) == null ? void 0 : t.layer;
|
|
61
|
+
}, getDefaultId: () => "base" };
|
|
62
|
+
}
|
|
63
|
+
function oe(i, e) {
|
|
64
|
+
if (e === i.layers.base) return "base";
|
|
65
|
+
const t = i.layers.all.indexOf(e);
|
|
66
|
+
if (t >= 0) return `layer-${t + 1}`;
|
|
67
|
+
throw new Error("[textmode-export] Cannot export a layer that is not managed by this Textmodifier instance.");
|
|
68
|
+
}
|
|
69
|
+
function lt(i, e) {
|
|
70
|
+
const t = e ?? i.layers.base, r = oe(i, t), a = t.grid, o = t.font, n = t.drawFramebuffer;
|
|
71
|
+
if (!a || !n) throw new Error("[textmode-export] Cannot export an uninitialized layer.");
|
|
72
|
+
return { id: r, label: zt(r, t), layer: t, grid: a, font: o, drawFramebuffer: n };
|
|
73
|
+
}
|
|
74
|
+
function ie(i) {
|
|
75
|
+
return [i.layers.base, ...i.layers.all].map((e) => {
|
|
76
|
+
const t = e;
|
|
77
|
+
return { ...lt(i, e), visible: t._visible ?? !0, opacity: t._opacity ?? 1, blendMode: t._blendMode ?? "normal", offsetX: t._offsetX ?? 0, offsetY: t._offsetY ?? 0, rotationZ: t._rotation ?? 0 };
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function st(i, e) {
|
|
81
|
+
return { r: i[e], g: i[e + 1], b: i[e + 2], a: i[e + 3] };
|
|
82
|
+
}
|
|
83
|
+
class se extends xt {
|
|
84
|
+
_calculateCellPosition(e, t, r) {
|
|
85
|
+
return { x: e, y: t, cellX: e * r.cellWidth, cellY: t * r.cellHeight };
|
|
86
|
+
}
|
|
87
|
+
$extractSVGCellData(e, t) {
|
|
88
|
+
const r = [];
|
|
43
89
|
let a = 0;
|
|
44
|
-
for (let o = 0; o < t.rows; o++) for (let
|
|
45
|
-
const d = 4 * a, l = this.$
|
|
46
|
-
let h =
|
|
47
|
-
const c = this.$extractCellTransform(
|
|
90
|
+
for (let o = 0; o < t.rows; o++) for (let n = 0; n < t.cols; n++) {
|
|
91
|
+
const d = 4 * a, l = this.$getEncodedCharacterValue(e.characterPixels, d);
|
|
92
|
+
let h = st(e.primaryColorPixels, d), s = st(e.secondaryColorPixels, d);
|
|
93
|
+
const c = this.$extractCellTransform(e.characterPixels, d);
|
|
48
94
|
if (c.isInverted) {
|
|
49
95
|
const f = h;
|
|
50
|
-
h =
|
|
96
|
+
h = s, s = f;
|
|
51
97
|
}
|
|
52
|
-
const u = this._calculateCellPosition(
|
|
53
|
-
|
|
98
|
+
const u = this._calculateCellPosition(n, o, t);
|
|
99
|
+
r.push({ encodedGlyphSlot: l, primaryColor: h, secondaryColor: s, transform: c, position: u }), a++;
|
|
54
100
|
}
|
|
55
|
-
return
|
|
101
|
+
return r;
|
|
56
102
|
}
|
|
57
103
|
}
|
|
58
|
-
class
|
|
59
|
-
_createGlyphPath(
|
|
60
|
-
const
|
|
61
|
-
return { getBoundingBox: () => ({ x1:
|
|
104
|
+
class ne {
|
|
105
|
+
_createGlyphPath(e, t, r, a, o) {
|
|
106
|
+
const n = o / e.head.unitsPerEm;
|
|
107
|
+
return { getBoundingBox: () => ({ x1: r + t.xMin * n, y1: a + -t.yMax * n, x2: r + t.xMax * n, y2: a + -t.yMin * n }), toSVG: () => this._glyphToSVGPath(t, r, a, n) };
|
|
62
108
|
}
|
|
63
|
-
_glyphToSVGPath(
|
|
64
|
-
if (!
|
|
65
|
-
const { xs: o, ys:
|
|
66
|
-
if (!(o &&
|
|
67
|
-
let h = "",
|
|
109
|
+
_glyphToSVGPath(e, t, r, a) {
|
|
110
|
+
if (!e || !e.xs) return "";
|
|
111
|
+
const { xs: o, ys: n, endPts: d, flags: l } = e;
|
|
112
|
+
if (!(o && n && d && l)) return "";
|
|
113
|
+
let h = "", s = 0;
|
|
68
114
|
for (let c = 0; c < d.length; c++) {
|
|
69
115
|
const u = d[c];
|
|
70
|
-
if (!(u <
|
|
71
|
-
if (u >=
|
|
72
|
-
const f = t + o[
|
|
73
|
-
h += `M${f.toFixed(2)},${
|
|
74
|
-
let m =
|
|
116
|
+
if (!(u < s)) {
|
|
117
|
+
if (u >= s) {
|
|
118
|
+
const f = t + o[s] * a, x = r - n[s] * a;
|
|
119
|
+
h += `M${f.toFixed(2)},${x.toFixed(2)}`;
|
|
120
|
+
let m = s + 1;
|
|
75
121
|
for (; m <= u; )
|
|
76
122
|
if (1 & l[m]) {
|
|
77
|
-
const v = t + o[m] * a, w =
|
|
123
|
+
const v = t + o[m] * a, w = r - n[m] * a;
|
|
78
124
|
h += `L${v.toFixed(2)},${w.toFixed(2)}`, m++;
|
|
79
125
|
} else {
|
|
80
|
-
const v = t + o[m] * a, w =
|
|
81
|
-
if (1 & l[
|
|
82
|
-
const g = t + o[
|
|
83
|
-
h += `Q${v.toFixed(2)},${w.toFixed(2)} ${g.toFixed(2)},${E.toFixed(2)}`, m =
|
|
126
|
+
const v = t + o[m] * a, w = r - n[m] * a, y = m + 1 > u ? s : m + 1;
|
|
127
|
+
if (1 & l[y]) {
|
|
128
|
+
const g = t + o[y] * a, E = r - n[y] * a;
|
|
129
|
+
h += `Q${v.toFixed(2)},${w.toFixed(2)} ${g.toFixed(2)},${E.toFixed(2)}`, m = y + 1;
|
|
84
130
|
} else {
|
|
85
|
-
const g = (v + (t + o[
|
|
86
|
-
h += `Q${v.toFixed(2)},${w.toFixed(2)} ${g.toFixed(2)},${E.toFixed(2)}`, m =
|
|
131
|
+
const g = (v + (t + o[y] * a)) / 2, E = (w + (r - n[y] * a)) / 2;
|
|
132
|
+
h += `Q${v.toFixed(2)},${w.toFixed(2)} ${g.toFixed(2)},${E.toFixed(2)}`, m = y;
|
|
87
133
|
}
|
|
88
134
|
}
|
|
89
135
|
h += "Z";
|
|
90
136
|
}
|
|
91
|
-
|
|
137
|
+
s = u + 1;
|
|
92
138
|
}
|
|
93
139
|
}
|
|
94
140
|
return h;
|
|
95
141
|
}
|
|
96
|
-
|
|
97
|
-
var d;
|
|
98
|
-
const s = (d = t.characterMap.get(r)) == null ? void 0 : d.glyphData;
|
|
99
|
-
return s ? this._createGlyphPath(t.font, s, e, a, o) : null;
|
|
100
|
-
}
|
|
101
|
-
$generatePositionedCharacterPath(r, t, e, a, o, s, d, l) {
|
|
142
|
+
$generatePositionedCharacterPath(e, t, r, a, o, n, d, l) {
|
|
102
143
|
if (!l) return null;
|
|
103
|
-
const h = d /
|
|
104
|
-
return
|
|
144
|
+
const h = t.font, s = d / h.head.unitsPerEm, c = r + (o - l.advanceWidth * s) / 2, u = a + h.hhea.ascender * s;
|
|
145
|
+
return this._createGlyphPath(h, l, c, u, d).toSVG() || null;
|
|
105
146
|
}
|
|
106
147
|
}
|
|
107
|
-
class
|
|
148
|
+
class le {
|
|
108
149
|
constructor() {
|
|
109
150
|
p(this, "_pathGenerator");
|
|
110
|
-
this._pathGenerator = new
|
|
151
|
+
this._pathGenerator = new ne();
|
|
111
152
|
}
|
|
112
|
-
$generateSVGHeader(
|
|
113
|
-
const { width: t, height:
|
|
114
|
-
return `<?xml version="1.0" encoding="UTF-8"?><svg width="${t}" height="${
|
|
153
|
+
$generateSVGHeader(e) {
|
|
154
|
+
const { width: t, height: r } = e;
|
|
155
|
+
return `<?xml version="1.0" encoding="UTF-8"?><svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
|
|
115
156
|
}
|
|
116
157
|
$generateSVGFooter() {
|
|
117
158
|
return "</g></svg>";
|
|
118
159
|
}
|
|
119
|
-
_generateTransformAttribute(
|
|
120
|
-
const { transform:
|
|
121
|
-
if (!
|
|
122
|
-
const o = a.cellX + t.cellWidth / 2,
|
|
123
|
-
if (
|
|
124
|
-
const l =
|
|
125
|
-
d.push(`translate(${o} ${
|
|
160
|
+
_generateTransformAttribute(e, t) {
|
|
161
|
+
const { transform: r, position: a } = e;
|
|
162
|
+
if (!r.flipHorizontal && !r.flipVertical && !r.rotation) return "";
|
|
163
|
+
const o = a.cellX + t.cellWidth / 2, n = a.cellY + t.cellHeight / 2, d = [];
|
|
164
|
+
if (r.flipHorizontal || r.flipVertical) {
|
|
165
|
+
const l = r.flipHorizontal ? -1 : 1, h = r.flipVertical ? -1 : 1;
|
|
166
|
+
d.push(`translate(${o} ${n})scale(${l} ${h})translate(${-o} ${-n})`);
|
|
126
167
|
}
|
|
127
|
-
return
|
|
168
|
+
return r.rotation && d.push(`rotate(${r.rotation} ${o} ${n})`), ` transform="${d.join(" ")}"`;
|
|
128
169
|
}
|
|
129
|
-
_generateCellBackground(
|
|
130
|
-
if (!
|
|
131
|
-
const { position: a } =
|
|
132
|
-
return
|
|
170
|
+
_generateCellBackground(e, t, r) {
|
|
171
|
+
if (!r.includeBackgroundRectangles || e.secondaryColor.a === 0) return "";
|
|
172
|
+
const { position: a } = e, { r: o, g: n, b: d, a: l } = e.secondaryColor, h = `rgba(${o},${n},${d},${l / 255})`;
|
|
173
|
+
return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" stroke="${h}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" fill="${h}"/>`;
|
|
133
174
|
}
|
|
134
|
-
_generateCharacterPath(
|
|
135
|
-
const o = e.
|
|
175
|
+
_generateCharacterPath(e, t, r, a) {
|
|
176
|
+
const o = _t(r, e.encodedGlyphSlot);
|
|
136
177
|
if (!o) return "";
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
139
|
-
const { r: d, g: l, b: h, a:
|
|
140
|
-
return a.drawMode === "stroke" ? `<path d="${
|
|
141
|
-
}
|
|
142
|
-
$generateCellContent(
|
|
143
|
-
const o = [],
|
|
144
|
-
|
|
145
|
-
const d = this._generateCharacterPath(
|
|
178
|
+
const n = this._pathGenerator.$generatePositionedCharacterPath(o.character, r, e.position.cellX, e.position.cellY, t.cellWidth, t.cellHeight, r.fontSize, o.glyphData);
|
|
179
|
+
if (!n) return "";
|
|
180
|
+
const { r: d, g: l, b: h, a: s } = e.primaryColor, c = `rgba(${d},${l},${h},${s / 255})`;
|
|
181
|
+
return a.drawMode === "stroke" ? `<path d="${n}" stroke="${c}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${c}"/>`;
|
|
182
|
+
}
|
|
183
|
+
$generateCellContent(e, t, r, a) {
|
|
184
|
+
const o = [], n = this._generateCellBackground(e, t, a);
|
|
185
|
+
n && o.push(n);
|
|
186
|
+
const d = this._generateCharacterPath(e, t, r, a);
|
|
146
187
|
if (d) {
|
|
147
|
-
const l = this._generateTransformAttribute(
|
|
188
|
+
const l = this._generateTransformAttribute(e, t);
|
|
148
189
|
o.push(l ? `<g${l}>${d}</g>` : d);
|
|
149
190
|
}
|
|
150
191
|
return o.join("");
|
|
151
192
|
}
|
|
152
|
-
$generateSVGContent(
|
|
193
|
+
$generateSVGContent(e, t, r, a) {
|
|
153
194
|
const o = [this.$generateSVGHeader(t), '<g id="ascii-cells">'];
|
|
154
|
-
for (const
|
|
195
|
+
for (const n of e) o.push(this.$generateCellContent(n, t, r, a));
|
|
155
196
|
return o.push(this.$generateSVGFooter()), o.join("");
|
|
156
197
|
}
|
|
157
|
-
$optimizeSVGContent(
|
|
158
|
-
return
|
|
198
|
+
$optimizeSVGContent(e) {
|
|
199
|
+
return e.replace(/\s+/g, " ").replace(/> </g, "><");
|
|
159
200
|
}
|
|
160
201
|
}
|
|
161
|
-
class
|
|
162
|
-
_applyDefaultOptions(
|
|
163
|
-
return { includeBackgroundRectangles:
|
|
202
|
+
class Bt {
|
|
203
|
+
_applyDefaultOptions(e) {
|
|
204
|
+
return { includeBackgroundRectangles: e.includeBackgroundRectangles ?? !0, drawMode: e.drawMode ?? "fill", strokeWidth: e.strokeWidth ?? 1, filename: e.filename, layer: e.layer };
|
|
164
205
|
}
|
|
165
|
-
$generateSVG(
|
|
166
|
-
const
|
|
167
|
-
return a.$optimizeSVGContent(
|
|
206
|
+
$generateSVG(e, t = {}) {
|
|
207
|
+
const r = new se(), a = new le(), o = this._applyDefaultOptions(t), n = lt(e, o.layer), d = r.$extractSVGCellData(r.$extractFramebufferData(n.drawFramebuffer), n.grid), l = a.$generateSVGContent(d, n.grid, n.font, o);
|
|
208
|
+
return a.$optimizeSVGContent(l);
|
|
168
209
|
}
|
|
169
|
-
$saveSVG(
|
|
170
|
-
new
|
|
210
|
+
$saveSVG(e, t = {}) {
|
|
211
|
+
new X().$downloadFile(new Blob([this.$generateSVG(e, t)], { type: "image/svg+xml;charset=utf-8" }), t.filename);
|
|
171
212
|
}
|
|
172
213
|
}
|
|
173
|
-
const
|
|
174
|
-
class
|
|
175
|
-
_applyDefaultOptions(
|
|
176
|
-
return { format:
|
|
214
|
+
const pt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, ht = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
215
|
+
class St {
|
|
216
|
+
_applyDefaultOptions(e) {
|
|
217
|
+
return { format: e.format ?? "png", scale: Math.abs(e.scale ?? 1), filename: e.filename };
|
|
177
218
|
}
|
|
178
|
-
_validateOptions(
|
|
179
|
-
if (!(
|
|
219
|
+
_validateOptions(e) {
|
|
220
|
+
if (!(e.format in pt)) throw new Error(`Saving '${e.format}' files is not supported`);
|
|
180
221
|
}
|
|
181
|
-
async $generateImageBlob(
|
|
182
|
-
const
|
|
183
|
-
return a.width =
|
|
184
|
-
a.toBlob((
|
|
185
|
-
|
|
186
|
-
},
|
|
222
|
+
async $generateImageBlob(e, t) {
|
|
223
|
+
const r = e, a = document.createElement("canvas"), o = a.getContext("2d"), n = Math.round(r.width * t.scale), d = Math.round(r.height * t.scale);
|
|
224
|
+
return a.width = n, a.height = d, o.imageSmoothingEnabled = !1, o.clearRect(0, 0, n, d), o.drawImage(r, 0, 0, r.width, r.height, 0, 0, n, d), await new Promise((l, h) => {
|
|
225
|
+
a.toBlob((s) => {
|
|
226
|
+
s ? l(s) : h(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
|
|
227
|
+
}, pt[t.format]);
|
|
187
228
|
});
|
|
188
229
|
}
|
|
189
|
-
async $saveImage(
|
|
190
|
-
const
|
|
191
|
-
this._validateOptions(
|
|
192
|
-
const a = await this.$generateImageBlob(
|
|
193
|
-
new
|
|
230
|
+
async $saveImage(e, t = {}) {
|
|
231
|
+
const r = this._applyDefaultOptions(t);
|
|
232
|
+
this._validateOptions(r);
|
|
233
|
+
const a = await this.$generateImageBlob(e, r);
|
|
234
|
+
new X().$downloadFile(a, r.filename);
|
|
194
235
|
}
|
|
195
|
-
async $copyImageToClipboard(
|
|
236
|
+
async $copyImageToClipboard(e, t = {}) {
|
|
196
237
|
if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.write != "function") throw new Error("Clipboard API is not available in this environment");
|
|
197
|
-
const
|
|
198
|
-
this._validateOptions(
|
|
199
|
-
const a = await this.$generateImageBlob(
|
|
238
|
+
const r = this._applyDefaultOptions(t);
|
|
239
|
+
this._validateOptions(r);
|
|
240
|
+
const a = await this.$generateImageBlob(e, r), o = new ClipboardItem({ [pt[r.format]]: a });
|
|
200
241
|
await navigator.clipboard.write([o]);
|
|
201
242
|
}
|
|
202
243
|
}
|
|
203
|
-
class
|
|
204
|
-
_applyDefaultOptions(
|
|
205
|
-
return { preserveTrailingSpaces:
|
|
244
|
+
class It {
|
|
245
|
+
_applyDefaultOptions(e) {
|
|
246
|
+
return { preserveTrailingSpaces: e.preserveTrailingSpaces ?? !1, emptyCharacter: e.emptyCharacter ?? " ", filename: e.filename, layer: e.layer };
|
|
206
247
|
}
|
|
207
|
-
_createTXTContent(
|
|
248
|
+
_createTXTContent(e, t) {
|
|
208
249
|
var l;
|
|
209
|
-
const
|
|
250
|
+
const r = new xt(), a = lt(e, t.layer), o = r.$extractFramebufferData(a.drawFramebuffer), n = [];
|
|
210
251
|
let d = 0;
|
|
211
|
-
for (let h = 0; h <
|
|
212
|
-
let
|
|
213
|
-
for (let c = 0; c <
|
|
214
|
-
const u = 4 * d, f =
|
|
215
|
-
|
|
252
|
+
for (let h = 0; h < a.grid.rows; h++) {
|
|
253
|
+
let s = "";
|
|
254
|
+
for (let c = 0; c < a.grid.cols; c++) {
|
|
255
|
+
const u = 4 * d, f = r.$getEncodedCharacterValue(o.characterPixels, u);
|
|
256
|
+
s += ((l = _t(a.font, f)) == null ? void 0 : l.character) || t.emptyCharacter, d++;
|
|
216
257
|
}
|
|
217
|
-
t.preserveTrailingSpaces || (
|
|
258
|
+
t.preserveTrailingSpaces || (s = s.trimEnd()), n.push(s);
|
|
218
259
|
}
|
|
219
|
-
return
|
|
260
|
+
return n.join(`
|
|
220
261
|
`);
|
|
221
262
|
}
|
|
222
|
-
$generateTXT(
|
|
223
|
-
return this._createTXTContent(
|
|
263
|
+
$generateTXT(e, t = {}) {
|
|
264
|
+
return this._createTXTContent(e, this._applyDefaultOptions(t));
|
|
224
265
|
}
|
|
225
|
-
$saveTXT(
|
|
226
|
-
const
|
|
227
|
-
new
|
|
266
|
+
$saveTXT(e, t = {}) {
|
|
267
|
+
const r = this._applyDefaultOptions(t), a = this._createTXTContent(e, r), o = new Blob([a], { type: "text/plain;charset=utf-8" });
|
|
268
|
+
new X().$downloadFile(o, r.filename);
|
|
228
269
|
}
|
|
229
270
|
}
|
|
230
|
-
class
|
|
271
|
+
class de {
|
|
231
272
|
constructor() {
|
|
232
273
|
p(this, "_canvas");
|
|
233
274
|
p(this, "_ctx");
|
|
234
275
|
}
|
|
235
|
-
async $record(
|
|
236
|
-
const o = Math.max(1, Math.round(t.frameRate)),
|
|
276
|
+
async $record(e, t, r, a) {
|
|
277
|
+
const o = Math.max(1, Math.round(t.frameRate)), n = Math.round(1e3 / o), d = Math.max(1, Math.round(t.frameCount));
|
|
237
278
|
return await new Promise((l, h) => {
|
|
238
|
-
const
|
|
279
|
+
const s = [];
|
|
239
280
|
let c, u = 0, f = !1;
|
|
240
|
-
const
|
|
281
|
+
const x = () => {
|
|
241
282
|
c && (c(), c = void 0);
|
|
242
283
|
}, m = (w) => {
|
|
243
|
-
f || (f = !0,
|
|
284
|
+
f || (f = !0, x(), l(w));
|
|
244
285
|
}, v = () => {
|
|
245
|
-
if (u >= d) m(
|
|
286
|
+
if (u >= d) m(s);
|
|
246
287
|
else try {
|
|
247
|
-
const w = t.scale,
|
|
248
|
-
this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width ===
|
|
288
|
+
const w = t.scale, y = Math.max(1, Math.round(e.width * w)), g = Math.max(1, Math.round(e.height * w));
|
|
289
|
+
this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === y && this._canvas.height === g || (this._canvas.width = y, this._canvas.height = g), this._ctx || (this._ctx = this._canvas.getContext("2d"));
|
|
249
290
|
const E = this._ctx;
|
|
250
|
-
E.imageSmoothingEnabled = !1, E.clearRect(0, 0,
|
|
251
|
-
const
|
|
252
|
-
|
|
291
|
+
E.imageSmoothingEnabled = !1, E.clearRect(0, 0, y, g), E.drawImage(e, 0, 0, e.width, e.height, 0, 0, y, g);
|
|
292
|
+
const L = { imageData: E.getImageData(0, 0, y, g), width: y, height: g, delayMs: n };
|
|
293
|
+
s.push(L), u += 1, a == null || a({ state: "recording", frameIndex: u, totalFrames: d }), u >= d && m(s);
|
|
253
294
|
} catch (w) {
|
|
254
|
-
((
|
|
295
|
+
((y) => {
|
|
255
296
|
if (f) return;
|
|
256
|
-
f = !0,
|
|
257
|
-
const g =
|
|
258
|
-
a == null || a({ state: "error", message: g }), h(
|
|
297
|
+
f = !0, x();
|
|
298
|
+
const g = y instanceof Error ? y.message : "GIF recording failed";
|
|
299
|
+
a == null || a({ state: "error", message: g }), h(y instanceof Error ? y : new Error(String(y)));
|
|
259
300
|
})(w);
|
|
260
301
|
}
|
|
261
302
|
};
|
|
262
|
-
c =
|
|
303
|
+
c = r(() => {
|
|
263
304
|
v();
|
|
264
305
|
}), a == null || a({ state: "recording", frameIndex: 0, totalFrames: d });
|
|
265
306
|
});
|
|
266
307
|
}
|
|
267
308
|
}
|
|
268
|
-
var
|
|
269
|
-
for (var t in
|
|
270
|
-
},
|
|
271
|
-
function
|
|
309
|
+
var jt = Object.defineProperty, ce = (i) => jt(i, "__esModule", { value: !0 }), ue = (i, e) => () => (e || i((e = { exports: {} }).exports, e), e.exports), pe = (i, e) => {
|
|
310
|
+
for (var t in e) jt(i, t, { get: e[t], enumerable: !0 });
|
|
311
|
+
}, he = ue((i) => {
|
|
312
|
+
function e(c, u, f) {
|
|
272
313
|
return 0.29889531 * c + 0.58662247 * u + 0.11448223 * f;
|
|
273
314
|
}
|
|
274
315
|
function t(c, u, f) {
|
|
275
316
|
return 0.59597799 * c - 0.2741761 * u - 0.32180189 * f;
|
|
276
317
|
}
|
|
277
|
-
function
|
|
318
|
+
function r(c, u, f) {
|
|
278
319
|
return 0.21147017 * c - 0.52261711 * u + 0.31114694 * f;
|
|
279
320
|
}
|
|
280
321
|
function a(c, u) {
|
|
281
|
-
let f = c[0] - u[0],
|
|
282
|
-
return f * f * 0.5053 +
|
|
322
|
+
let f = c[0] - u[0], x = c[1] - u[1], m = c[2] - u[2], v = o(c) - o(u);
|
|
323
|
+
return f * f * 0.5053 + x * x * 0.299 + m * m * 0.1957 + v * v;
|
|
283
324
|
}
|
|
284
325
|
function o(c) {
|
|
285
326
|
return c[3] != null ? c[3] : 255;
|
|
286
327
|
}
|
|
287
|
-
function
|
|
328
|
+
function n(c, u) {
|
|
288
329
|
return Math.sqrt(a(c, u));
|
|
289
330
|
}
|
|
290
331
|
function d(c, u) {
|
|
291
|
-
let [f,
|
|
292
|
-
return g * g * 0.5053 + E * E * 0.299 +
|
|
332
|
+
let [f, x, m] = c, [v, w, y] = u, g = e(f, x, m) - e(v, w, y), E = t(f, x, m) - t(v, w, y), L = r(f, x, m) - r(v, w, y), k = o(c) - o(u);
|
|
333
|
+
return g * g * 0.5053 + E * E * 0.299 + L * L * 0.1957 + k * k;
|
|
293
334
|
}
|
|
294
335
|
function l(c, u) {
|
|
295
336
|
return Math.sqrt(d(c, u));
|
|
296
337
|
}
|
|
297
338
|
function h(c, u) {
|
|
298
|
-
var f,
|
|
339
|
+
var f, x = 0;
|
|
299
340
|
for (f = 0; f < c.length; f++) {
|
|
300
341
|
let m = c[f] - u[f];
|
|
301
|
-
|
|
342
|
+
x += m * m;
|
|
302
343
|
}
|
|
303
|
-
return
|
|
344
|
+
return x;
|
|
304
345
|
}
|
|
305
|
-
function
|
|
346
|
+
function s(c, u) {
|
|
306
347
|
return Math.sqrt(h(c, u));
|
|
307
348
|
}
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
function
|
|
311
|
-
let
|
|
349
|
+
ce(i), pe(i, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => d, colorDifferenceYIQ: () => n, colorDifferenceYIQSquared: () => a, euclideanDistance: () => s, euclideanDistanceSquared: () => h });
|
|
350
|
+
}), me = { trailer: 59 };
|
|
351
|
+
function Wt(i = 256) {
|
|
352
|
+
let e = 0, t = new Uint8Array(i);
|
|
312
353
|
return { get buffer() {
|
|
313
354
|
return t.buffer;
|
|
314
355
|
}, reset() {
|
|
315
|
-
|
|
316
|
-
}, bytesView: () => t.subarray(0,
|
|
317
|
-
e
|
|
318
|
-
}, writeBytes(a, o = 0,
|
|
319
|
-
e
|
|
320
|
-
for (let d = 0; d <
|
|
321
|
-
}, writeBytesView(a, o = 0,
|
|
322
|
-
e
|
|
356
|
+
e = 0;
|
|
357
|
+
}, bytesView: () => t.subarray(0, e), bytes: () => t.slice(0, e), writeByte(a) {
|
|
358
|
+
r(e + 1), t[e] = a, e++;
|
|
359
|
+
}, writeBytes(a, o = 0, n = a.length) {
|
|
360
|
+
r(e + n);
|
|
361
|
+
for (let d = 0; d < n; d++) t[e++] = a[d + o];
|
|
362
|
+
}, writeBytesView(a, o = 0, n = a.byteLength) {
|
|
363
|
+
r(e + n), t.set(a.subarray(o, o + n), e), e += n;
|
|
323
364
|
} };
|
|
324
|
-
function
|
|
365
|
+
function r(a) {
|
|
325
366
|
var o = t.length;
|
|
326
367
|
if (o >= a) return;
|
|
327
368
|
a = Math.max(a, o * (o < 1048576 ? 2 : 1.125) >>> 0), o != 0 && (a = Math.max(a, 256));
|
|
328
|
-
let
|
|
329
|
-
t = new Uint8Array(a),
|
|
369
|
+
let n = t;
|
|
370
|
+
t = new Uint8Array(a), e > 0 && t.set(n.subarray(0, e), 0);
|
|
330
371
|
}
|
|
331
372
|
}
|
|
332
|
-
var
|
|
333
|
-
function
|
|
334
|
-
a = a ||
|
|
335
|
-
let l =
|
|
336
|
-
o.fill(0), d.fill(0),
|
|
337
|
-
let
|
|
373
|
+
var et = 12, Lt = 5003, fe = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
|
|
374
|
+
function ge(i, e, t, r, a, o, n, d) {
|
|
375
|
+
a = a || Wt(512), o = o || new Uint8Array(256), n = n || new Int32Array(Lt), d = d || new Int32Array(Lt);
|
|
376
|
+
let l = n.length, h = Math.max(2, r);
|
|
377
|
+
o.fill(0), d.fill(0), F();
|
|
378
|
+
let s = 0, c = 0, u = h + 1, f = u, x = !1, m = f, v = A(m), w = 1 << u - 1, y = w + 1, g = w + 2, E = 0, L = t[0], k = 0;
|
|
338
379
|
for (let B = l; B < 65536; B *= 2) ++k;
|
|
339
380
|
k = 8 - k, a.writeByte(h), R(w);
|
|
340
381
|
for (let B = 1; B < t.length; B++) V(t[B]);
|
|
341
|
-
return R(
|
|
342
|
-
function
|
|
382
|
+
return R(L), R(y), a.writeByte(0), a.bytesView();
|
|
383
|
+
function O(B) {
|
|
343
384
|
o[E++] = B, E >= 254 && S();
|
|
344
385
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
386
|
+
function F() {
|
|
387
|
+
n.fill(-1);
|
|
347
388
|
}
|
|
348
389
|
function V(B) {
|
|
349
|
-
let N = (B <<
|
|
350
|
-
if (
|
|
390
|
+
let N = (B << et) + L, _ = B << k ^ L;
|
|
391
|
+
if (n[_] === N) L = d[_];
|
|
351
392
|
else {
|
|
352
|
-
if (
|
|
393
|
+
if (n[_] >= 0) {
|
|
353
394
|
let C = _ === 0 ? 1 : l - _;
|
|
354
395
|
do
|
|
355
|
-
if (_ -= C, _ < 0 && (_ += l),
|
|
356
|
-
while (
|
|
396
|
+
if (_ -= C, _ < 0 && (_ += l), n[_] === N) return void (L = d[_]);
|
|
397
|
+
while (n[_] >= 0);
|
|
357
398
|
}
|
|
358
|
-
R(
|
|
399
|
+
R(L), L = B, g < 1 << et ? (d[_] = g++, n[_] = N) : (F(), g = w + 2, x = !0, R(w));
|
|
359
400
|
}
|
|
360
401
|
}
|
|
361
402
|
function S() {
|
|
362
403
|
E > 0 && (a.writeByte(E), a.writeBytesView(o, 0, E), E = 0);
|
|
363
404
|
}
|
|
364
|
-
function
|
|
405
|
+
function A(B) {
|
|
365
406
|
return (1 << B) - 1;
|
|
366
407
|
}
|
|
367
408
|
function R(B) {
|
|
368
|
-
for (
|
|
369
|
-
if ((g > v ||
|
|
370
|
-
for (; c > 0; )
|
|
409
|
+
for (s &= fe[c], c > 0 ? s |= B << c : s = B, c += m; c >= 8; ) O(255 & s), s >>= 8, c -= 8;
|
|
410
|
+
if ((g > v || x) && (x ? (m = f, v = A(m), x = !1) : (++m, v = m == et ? 1 << et : A(m))), B == y) {
|
|
411
|
+
for (; c > 0; ) O(255 & s), s >>= 8, c -= 8;
|
|
371
412
|
S();
|
|
372
413
|
}
|
|
373
414
|
}
|
|
374
415
|
}
|
|
375
|
-
var
|
|
376
|
-
function
|
|
377
|
-
return i << 8 & 63488 |
|
|
416
|
+
var be = ge;
|
|
417
|
+
function qt(i, e, t) {
|
|
418
|
+
return i << 8 & 63488 | e << 2 & 992 | t >> 3 & 31;
|
|
378
419
|
}
|
|
379
|
-
function
|
|
380
|
-
return i >> 4 | 240 &
|
|
420
|
+
function Ht(i, e, t, r) {
|
|
421
|
+
return i >> 4 | 240 & e | (240 & t) << 4 | (240 & r) << 8;
|
|
381
422
|
}
|
|
382
|
-
function
|
|
383
|
-
return i >> 4 << 8 |
|
|
423
|
+
function Xt(i, e, t) {
|
|
424
|
+
return i >> 4 << 8 | e >> 4 << 4 | t >> 4;
|
|
384
425
|
}
|
|
385
|
-
function
|
|
386
|
-
return i <
|
|
426
|
+
function rt(i, e, t) {
|
|
427
|
+
return i < e ? e : i > t ? t : i;
|
|
387
428
|
}
|
|
388
|
-
function
|
|
429
|
+
function it(i) {
|
|
389
430
|
return i * i;
|
|
390
431
|
}
|
|
391
|
-
function
|
|
392
|
-
for (var
|
|
393
|
-
var c = i[
|
|
432
|
+
function Mt(i, e, t) {
|
|
433
|
+
for (var r = 0, a = 1e100, o = i[e], n = o.cnt, d = (o.ac, o.rc), l = o.gc, h = o.bc, s = o.fw; s != 0; s = i[s].fw) {
|
|
434
|
+
var c = i[s].cnt, u = n * c / (n + c);
|
|
394
435
|
if (!(u >= a)) {
|
|
395
436
|
var f = 0;
|
|
396
|
-
!((f += u *
|
|
437
|
+
!((f += u * it(i[s].rc - d)) >= a) && !((f += u * it(i[s].gc - l)) >= a) && !((f += u * it(i[s].bc - h)) >= a) && (a = f, r = s);
|
|
397
438
|
}
|
|
398
439
|
}
|
|
399
|
-
o.err = a, o.nn =
|
|
440
|
+
o.err = a, o.nn = r;
|
|
400
441
|
}
|
|
401
|
-
function
|
|
442
|
+
function mt() {
|
|
402
443
|
return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
|
|
403
444
|
}
|
|
404
|
-
function
|
|
405
|
-
let t = new Array(
|
|
406
|
-
if (
|
|
407
|
-
let o = i[a],
|
|
408
|
-
c.rc += h, c.gc += l, c.bc += d, c.ac +=
|
|
445
|
+
function ve(i, e) {
|
|
446
|
+
let t = new Array(e === "rgb444" ? 4096 : 65536), r = i.length;
|
|
447
|
+
if (e === "rgba4444") for (let a = 0; a < r; ++a) {
|
|
448
|
+
let o = i[a], n = o >> 24 & 255, d = o >> 16 & 255, l = o >> 8 & 255, h = 255 & o, s = Ht(h, l, d, n), c = s in t ? t[s] : t[s] = mt();
|
|
449
|
+
c.rc += h, c.gc += l, c.bc += d, c.ac += n, c.cnt++;
|
|
409
450
|
}
|
|
410
|
-
else if (
|
|
411
|
-
let o = i[a],
|
|
412
|
-
|
|
451
|
+
else if (e === "rgb444") for (let a = 0; a < r; ++a) {
|
|
452
|
+
let o = i[a], n = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = Xt(l, d, n), s = h in t ? t[h] : t[h] = mt();
|
|
453
|
+
s.rc += l, s.gc += d, s.bc += n, s.cnt++;
|
|
413
454
|
}
|
|
414
|
-
else for (let a = 0; a <
|
|
415
|
-
let o = i[a],
|
|
416
|
-
|
|
455
|
+
else for (let a = 0; a < r; ++a) {
|
|
456
|
+
let o = i[a], n = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = qt(l, d, n), s = h in t ? t[h] : t[h] = mt();
|
|
457
|
+
s.rc += l, s.gc += d, s.bc += n, s.cnt++;
|
|
417
458
|
}
|
|
418
459
|
return t;
|
|
419
460
|
}
|
|
420
|
-
function
|
|
421
|
-
let { format:
|
|
422
|
-
for (var
|
|
423
|
-
let B =
|
|
461
|
+
function ye(i, e, t) {
|
|
462
|
+
let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: o = 0, clearAlphaThreshold: n = 0, oneBitAlpha: d = !1 } = t || {}, l = t.useSqrt !== !1, h = r === "rgba4444", s = ve(i, r), c = s.length, u = c - 1, f = new Uint32Array(c + 1);
|
|
463
|
+
for (var x = 0, m = 0; m < s.length; ++m) {
|
|
464
|
+
let B = s[m];
|
|
424
465
|
if (B != null) {
|
|
425
466
|
var v = 1 / B.cnt;
|
|
426
|
-
h && (B.ac *= v), B.rc *= v, B.gc *= v, B.bc *= v,
|
|
467
|
+
h && (B.ac *= v), B.rc *= v, B.gc *= v, B.bc *= v, s[x++] = B;
|
|
427
468
|
}
|
|
428
469
|
}
|
|
429
|
-
for (
|
|
430
|
-
var w,
|
|
431
|
-
for (l && (
|
|
432
|
-
|
|
433
|
-
var E =
|
|
434
|
-
for (
|
|
435
|
-
f[
|
|
470
|
+
for (it(e) / x < 0.022 && (l = !1), m = 0; m < x - 1; ++m) s[m].fw = m + 1, s[m + 1].bk = m, l && (s[m].cnt = Math.sqrt(s[m].cnt));
|
|
471
|
+
var w, y, g;
|
|
472
|
+
for (l && (s[m].cnt = Math.sqrt(s[m].cnt)), m = 0; m < x; ++m) {
|
|
473
|
+
Mt(s, m);
|
|
474
|
+
var E = s[m].err;
|
|
475
|
+
for (y = ++f[0]; y > 1 && !(s[w = f[g = y >> 1]].err <= E); y = g) f[y] = w;
|
|
476
|
+
f[y] = m;
|
|
436
477
|
}
|
|
437
|
-
var
|
|
438
|
-
for (m = 0; m <
|
|
478
|
+
var L = x - e;
|
|
479
|
+
for (m = 0; m < L; ) {
|
|
439
480
|
for (var k; ; ) {
|
|
440
|
-
var
|
|
441
|
-
if ((k =
|
|
442
|
-
for (k.mtm == u ?
|
|
443
|
-
f[
|
|
481
|
+
var O = f[1];
|
|
482
|
+
if ((k = s[O]).tm >= k.mtm && s[k.nn].mtm <= k.tm) break;
|
|
483
|
+
for (k.mtm == u ? O = f[1] = f[f[0]--] : (Mt(s, O), k.tm = m), E = s[O].err, y = 1; (g = y + y) <= f[0] && (g < f[0] && s[f[g]].err > s[f[g + 1]].err && g++, !(E <= s[w = f[g]].err)); y = g) f[y] = w;
|
|
484
|
+
f[y] = O;
|
|
444
485
|
}
|
|
445
|
-
var
|
|
446
|
-
v = 1 / (V + S), h && (k.ac = v * (V * k.ac + S *
|
|
486
|
+
var F = s[k.nn], V = k.cnt, S = F.cnt;
|
|
487
|
+
v = 1 / (V + S), h && (k.ac = v * (V * k.ac + S * F.ac)), k.rc = v * (V * k.rc + S * F.rc), k.gc = v * (V * k.gc + S * F.gc), k.bc = v * (V * k.bc + S * F.bc), k.cnt += F.cnt, k.mtm = ++m, s[F.bk].fw = F.fw, s[F.fw].bk = F.bk, F.mtm = u;
|
|
447
488
|
}
|
|
448
|
-
let
|
|
489
|
+
let A = [];
|
|
449
490
|
var R = 0;
|
|
450
491
|
for (m = 0; ; ++R) {
|
|
451
|
-
let B =
|
|
452
|
-
h && (C =
|
|
492
|
+
let B = rt(Math.round(s[m].rc), 0, 255), N = rt(Math.round(s[m].gc), 0, 255), _ = rt(Math.round(s[m].bc), 0, 255), C = 255;
|
|
493
|
+
h && (C = rt(Math.round(s[m].ac), 0, 255), d && (C = C <= (typeof d == "number" ? d : 127) ? 0 : 255), a && C <= n && (B = N = _ = o, C = 0));
|
|
453
494
|
let M = h ? [B, N, _, C] : [B, N, _];
|
|
454
|
-
if (
|
|
495
|
+
if (xe(A, M) || A.push(M), (m = s[m].fw) == 0) break;
|
|
455
496
|
}
|
|
456
|
-
return
|
|
497
|
+
return A;
|
|
457
498
|
}
|
|
458
|
-
function
|
|
499
|
+
function xe(i, e) {
|
|
459
500
|
for (let t = 0; t < i.length; t++) {
|
|
460
|
-
let
|
|
501
|
+
let r = i[t], a = r[0] === e[0] && r[1] === e[1] && r[2] === e[2], o = !(r.length >= 4 && e.length >= 4) || r[3] === e[3];
|
|
461
502
|
if (a && o) return !0;
|
|
462
503
|
}
|
|
463
504
|
return !1;
|
|
464
505
|
}
|
|
465
|
-
function
|
|
466
|
-
let
|
|
467
|
-
if (t === "rgba4444") for (let
|
|
468
|
-
let d, l = i[
|
|
469
|
-
o[f] != null ? d = o[f] : (d =
|
|
506
|
+
function _e(i, e, t) {
|
|
507
|
+
let r = (t = t || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(i.length), o = new Array(r);
|
|
508
|
+
if (t === "rgba4444") for (let n = 0; n < i.length; n++) {
|
|
509
|
+
let d, l = i[n], h = l >> 24 & 255, s = l >> 16 & 255, c = l >> 8 & 255, u = 255 & l, f = Ht(u, c, s, h);
|
|
510
|
+
o[f] != null ? d = o[f] : (d = we(u, c, s, h, e), o[f] = d), a[n] = d;
|
|
470
511
|
}
|
|
471
|
-
else for (let
|
|
472
|
-
let d, l = i[
|
|
473
|
-
o[u] != null ? d = o[u] : (d =
|
|
512
|
+
else for (let n = 0; n < i.length; n++) {
|
|
513
|
+
let d, l = i[n], h = l >> 16 & 255, s = l >> 8 & 255, c = 255 & l, u = t === "rgb444" ? Xt(c, s, h) : qt(c, s, h);
|
|
514
|
+
o[u] != null ? d = o[u] : (d = Ce(c, s, h, e), o[u] = d), a[n] = d;
|
|
474
515
|
}
|
|
475
516
|
return a;
|
|
476
517
|
}
|
|
477
|
-
function
|
|
478
|
-
let o = 0,
|
|
518
|
+
function we(i, e, t, r, a) {
|
|
519
|
+
let o = 0, n = 1e100;
|
|
479
520
|
for (let d = 0; d < a.length; d++) {
|
|
480
|
-
let l = a[d], h = l[0],
|
|
481
|
-
u >
|
|
521
|
+
let l = a[d], h = l[0], s = l[1], c = l[2], u = W(l[3] - r);
|
|
522
|
+
u > n || (u += W(h - i), !(u > n) && (u += W(s - e), !(u > n) && (u += W(c - t), !(u > n) && (n = u, o = d))));
|
|
482
523
|
}
|
|
483
524
|
return o;
|
|
484
525
|
}
|
|
485
|
-
function
|
|
526
|
+
function Ce(i, e, t, r) {
|
|
486
527
|
let a = 0, o = 1e100;
|
|
487
|
-
for (let
|
|
488
|
-
let d =
|
|
489
|
-
c > o || (c += W(h -
|
|
528
|
+
for (let n = 0; n < r.length; n++) {
|
|
529
|
+
let d = r[n], l = d[0], h = d[1], s = d[2], c = W(l - i);
|
|
530
|
+
c > o || (c += W(h - e), !(c > o) && (c += W(s - t), !(c > o) && (o = c, a = n)));
|
|
490
531
|
}
|
|
491
532
|
return a;
|
|
492
533
|
}
|
|
493
534
|
function W(i) {
|
|
494
535
|
return i * i;
|
|
495
536
|
}
|
|
496
|
-
function
|
|
497
|
-
let { initialCapacity:
|
|
537
|
+
function Ee(i = {}) {
|
|
538
|
+
let { initialCapacity: e = 4096, auto: t = !0 } = i, r = Wt(e), a = new Uint8Array(256), o = new Int32Array(5003), n = new Int32Array(5003), d = !1;
|
|
498
539
|
return { reset() {
|
|
499
|
-
|
|
540
|
+
r.reset(), d = !1;
|
|
500
541
|
}, finish() {
|
|
501
|
-
|
|
502
|
-
}, bytes: () =>
|
|
503
|
-
return
|
|
542
|
+
r.writeByte(me.trailer);
|
|
543
|
+
}, bytes: () => r.bytes(), bytesView: () => r.bytesView(), get buffer() {
|
|
544
|
+
return r.buffer;
|
|
504
545
|
}, get stream() {
|
|
505
|
-
return
|
|
506
|
-
}, writeHeader: l, writeFrame(h,
|
|
507
|
-
let { transparent: f = !1, transparentIndex:
|
|
508
|
-
if (t ? d || (E = !0, l(), d = !0) : E = !!u.first,
|
|
546
|
+
return r;
|
|
547
|
+
}, writeHeader: l, writeFrame(h, s, c, u = {}) {
|
|
548
|
+
let { transparent: f = !1, transparentIndex: x = 0, delay: m = 0, palette: v = null, repeat: w = 0, colorDepth: y = 8, dispose: g = -1 } = u, E = !1;
|
|
549
|
+
if (t ? d || (E = !0, l(), d = !0) : E = !!u.first, s = Math.max(0, Math.floor(s)), c = Math.max(0, Math.floor(c)), E) {
|
|
509
550
|
if (!v) throw new Error("First frame must include a { palette } option");
|
|
510
|
-
|
|
551
|
+
Be(r, s, c, v, y), Ft(r, v), w >= 0 && Se(r, w);
|
|
511
552
|
}
|
|
512
|
-
let
|
|
513
|
-
|
|
553
|
+
let L = Math.round(m / 10);
|
|
554
|
+
ke(r, g, L, f, x);
|
|
514
555
|
let k = !!v && !E;
|
|
515
|
-
|
|
556
|
+
Ie(r, s, c, k ? v : null), k && Ft(r, v), Le(r, h, s, c, y, a, o, n);
|
|
516
557
|
} };
|
|
517
558
|
function l() {
|
|
518
|
-
|
|
559
|
+
Jt(r, "GIF89a");
|
|
519
560
|
}
|
|
520
561
|
}
|
|
521
|
-
function
|
|
522
|
-
var o,
|
|
523
|
-
i.writeByte(33), i.writeByte(249), i.writeByte(4), a < 0 && (a = 0,
|
|
562
|
+
function ke(i, e, t, r, a) {
|
|
563
|
+
var o, n;
|
|
564
|
+
i.writeByte(33), i.writeByte(249), i.writeByte(4), a < 0 && (a = 0, r = !1), r ? (o = 1, n = 2) : (o = 0, n = 0), e >= 0 && (n = 7 & e), n <<= 2, i.writeByte(0 | n | o), G(i, t), i.writeByte(a || 0), i.writeByte(0);
|
|
524
565
|
}
|
|
525
|
-
function
|
|
526
|
-
let o = 128 | a - 1 << 4 |
|
|
527
|
-
G(i,
|
|
566
|
+
function Be(i, e, t, r, a = 8) {
|
|
567
|
+
let o = 128 | a - 1 << 4 | wt(r.length) - 1;
|
|
568
|
+
G(i, e), G(i, t), i.writeBytes([o, 0, 0]);
|
|
528
569
|
}
|
|
529
|
-
function
|
|
530
|
-
i.writeByte(33), i.writeByte(255), i.writeByte(11),
|
|
570
|
+
function Se(i, e) {
|
|
571
|
+
i.writeByte(33), i.writeByte(255), i.writeByte(11), Jt(i, "NETSCAPE2.0"), i.writeByte(3), i.writeByte(1), G(i, e), i.writeByte(0);
|
|
531
572
|
}
|
|
532
|
-
function
|
|
533
|
-
let t = 1 <<
|
|
534
|
-
for (let
|
|
573
|
+
function Ft(i, e) {
|
|
574
|
+
let t = 1 << wt(e.length);
|
|
575
|
+
for (let r = 0; r < t; r++) {
|
|
535
576
|
let a = [0, 0, 0];
|
|
536
|
-
|
|
577
|
+
r < e.length && (a = e[r]), i.writeByte(a[0]), i.writeByte(a[1]), i.writeByte(a[2]);
|
|
537
578
|
}
|
|
538
579
|
}
|
|
539
|
-
function
|
|
540
|
-
if (i.writeByte(44), G(i, 0), G(i, 0), G(i,
|
|
541
|
-
let a = 0, o = 0,
|
|
542
|
-
i.writeByte(128 | a | o |
|
|
580
|
+
function Ie(i, e, t, r) {
|
|
581
|
+
if (i.writeByte(44), G(i, 0), G(i, 0), G(i, e), G(i, t), r) {
|
|
582
|
+
let a = 0, o = 0, n = wt(r.length) - 1;
|
|
583
|
+
i.writeByte(128 | a | o | n);
|
|
543
584
|
} else i.writeByte(0);
|
|
544
585
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
586
|
+
function Le(i, e, t, r, a = 8, o, n, d) {
|
|
587
|
+
be(t, r, e, a, i, o, n, d);
|
|
547
588
|
}
|
|
548
|
-
function G(i,
|
|
549
|
-
i.writeByte(255 &
|
|
589
|
+
function G(i, e) {
|
|
590
|
+
i.writeByte(255 & e), i.writeByte(e >> 8 & 255);
|
|
550
591
|
}
|
|
551
|
-
function
|
|
552
|
-
for (var t = 0; t <
|
|
592
|
+
function Jt(i, e) {
|
|
593
|
+
for (var t = 0; t < e.length; t++) i.writeByte(e.charCodeAt(t));
|
|
553
594
|
}
|
|
554
|
-
function
|
|
595
|
+
function wt(i) {
|
|
555
596
|
return Math.max(Math.ceil(Math.log2(i)), 1);
|
|
556
597
|
}
|
|
557
|
-
|
|
558
|
-
class
|
|
559
|
-
constructor(
|
|
598
|
+
he();
|
|
599
|
+
class Me {
|
|
600
|
+
constructor(e, t) {
|
|
560
601
|
p(this, "_recorder");
|
|
561
602
|
p(this, "_textmodifier");
|
|
562
603
|
p(this, "_registerPostDrawHook");
|
|
563
|
-
this._recorder = new
|
|
604
|
+
this._recorder = new de(), this._textmodifier = e, this._registerPostDrawHook = t;
|
|
564
605
|
}
|
|
565
|
-
async $saveGIF(
|
|
566
|
-
const t = this._textmodifier.canvas,
|
|
606
|
+
async $saveGIF(e = {}) {
|
|
607
|
+
const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e), a = e.onProgress;
|
|
567
608
|
try {
|
|
568
|
-
const o = await this._recorder.$record(t,
|
|
569
|
-
for (let
|
|
570
|
-
const c = o[
|
|
571
|
-
|
|
609
|
+
const o = await this._recorder.$record(t, r, this._registerPostDrawHook, a), n = Ee(), { repeat: d } = e;
|
|
610
|
+
for (let s = 0; s < o.length; s++) {
|
|
611
|
+
const c = o[s], { width: u, height: f, imageData: x, delayMs: m } = c, v = new Uint32Array(x.data.buffer), w = ye(v, 256, {}), y = _e(v, w);
|
|
612
|
+
n.writeFrame(y, u, f, { palette: w, delay: m, repeat: s === 0 ? d : -1 }), s % 2 != 0 && s !== o.length - 1 || (a == null || a({ state: "encoding", frameIndex: s + 1, totalFrames: o.length }), await new Promise((g) => setTimeout(g, 0)));
|
|
572
613
|
}
|
|
573
|
-
|
|
574
|
-
const l =
|
|
575
|
-
new
|
|
614
|
+
n.finish();
|
|
615
|
+
const l = n.bytes(), h = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
|
|
616
|
+
new X().$downloadFile(new Blob([h], { type: "image/gif" }), r.filename), a == null || a({ state: "completed", totalFrames: r.frameCount });
|
|
576
617
|
} catch (o) {
|
|
577
618
|
throw a == null || a({ state: "error", message: o instanceof Error ? o.message : "GIF export failed" }), o;
|
|
578
619
|
}
|
|
579
620
|
}
|
|
580
|
-
_applyDefaultOptions(
|
|
581
|
-
const t = Math.abs(Math.round(
|
|
582
|
-
return { filename:
|
|
621
|
+
_applyDefaultOptions(e) {
|
|
622
|
+
const t = Math.abs(Math.round(e.frameCount ?? 300)), r = Math.abs(e.frameRate ?? 60), a = Math.abs(e.scale ?? 1), o = Math.max(-1, Math.round(e.repeat ?? 0));
|
|
623
|
+
return { filename: e.filename, frameCount: t, frameRate: r, scale: a, repeat: o };
|
|
583
624
|
}
|
|
584
625
|
}
|
|
585
|
-
function
|
|
626
|
+
function Fe(i) {
|
|
586
627
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
587
628
|
}
|
|
588
|
-
var
|
|
589
|
-
function
|
|
590
|
-
return
|
|
591
|
-
function
|
|
592
|
-
return (function(
|
|
593
|
-
if (typeof
|
|
594
|
-
return window.atob(
|
|
629
|
+
var $t, Tt = { exports: {} };
|
|
630
|
+
function $e() {
|
|
631
|
+
return $t || ($t = 1, i = Tt, (function() {
|
|
632
|
+
function e(l, h) {
|
|
633
|
+
return (function(s) {
|
|
634
|
+
if (typeof s != "string" || !s.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
|
|
635
|
+
return window.atob(s.substring(23));
|
|
595
636
|
})(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", h));
|
|
596
637
|
}
|
|
597
638
|
function t(l) {
|
|
598
639
|
return (l.charCodeAt(0) | l.charCodeAt(1) << 8 | l.charCodeAt(2) << 16 | l.charCodeAt(3) << 24) >>> 0;
|
|
599
640
|
}
|
|
600
|
-
function
|
|
641
|
+
function r(l) {
|
|
601
642
|
let h = l.indexOf("VP8", 12);
|
|
602
643
|
if (h === -1) throw new Error("Bad image format, does this browser support WebP?");
|
|
603
|
-
let
|
|
644
|
+
let s = !1;
|
|
604
645
|
for (; h < l.length - 8; ) {
|
|
605
646
|
let c, u;
|
|
606
647
|
switch (u = l.substring(h, h + 4), h += 4, c = t(l.substring(h, h + 4)), h += 4, u) {
|
|
607
648
|
case "VP8 ":
|
|
608
|
-
return { frame: l.substring(h, h + c), hasAlpha:
|
|
649
|
+
return { frame: l.substring(h, h + c), hasAlpha: s };
|
|
609
650
|
case "ALPH":
|
|
610
|
-
|
|
651
|
+
s = !0;
|
|
611
652
|
}
|
|
612
653
|
h += c, 1 & c && h++;
|
|
613
654
|
}
|
|
@@ -619,46 +660,46 @@ function we() {
|
|
|
619
660
|
function o(l) {
|
|
620
661
|
this.value = l;
|
|
621
662
|
}
|
|
622
|
-
function
|
|
623
|
-
if (Array.isArray(
|
|
624
|
-
else if (typeof
|
|
625
|
-
else if (
|
|
663
|
+
function n(l, h, s) {
|
|
664
|
+
if (Array.isArray(s)) for (let c = 0; c < s.length; c++) n(l, h, s[c]);
|
|
665
|
+
else if (typeof s == "string") l.writeString(s);
|
|
666
|
+
else if (s instanceof Uint8Array) l.writeBytes(s);
|
|
626
667
|
else {
|
|
627
|
-
if (!
|
|
628
|
-
if (
|
|
668
|
+
if (!s.id) throw new Error("Bad EBML datatype " + typeof s.data);
|
|
669
|
+
if (s.offset = l.pos + h, l.writeUnsignedIntBE(s.id), Array.isArray(s.data)) {
|
|
629
670
|
let c, u, f;
|
|
630
|
-
|
|
631
|
-
} else if (typeof
|
|
632
|
-
else if (typeof
|
|
633
|
-
else if (
|
|
634
|
-
else if (
|
|
671
|
+
s.size === -1 ? l.writeByte(255) : s.size === -2 ? (c = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (c = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, s.dataOffset = u + h, n(l, h, s.data), s.size !== -1 && s.size !== -2 && (f = l.pos, s.size = f - u, l.seek(c), l.writeEBMLVarIntWidth(s.size, 4), l.seek(f));
|
|
672
|
+
} else if (typeof s.data == "string") l.writeEBMLVarInt(s.data.length), s.dataOffset = l.pos + h, l.writeString(s.data);
|
|
673
|
+
else if (typeof s.data == "number") s.size || (s.size = l.measureUnsignedInt(s.data)), l.writeEBMLVarInt(s.size), s.dataOffset = l.pos + h, l.writeUnsignedIntBE(s.data, s.size);
|
|
674
|
+
else if (s.data instanceof o) l.writeEBMLVarInt(8), s.dataOffset = l.pos + h, l.writeDoubleBE(s.data.value);
|
|
675
|
+
else if (s.data instanceof a) l.writeEBMLVarInt(4), s.dataOffset = l.pos + h, l.writeFloatBE(s.data.value);
|
|
635
676
|
else {
|
|
636
|
-
if (!(
|
|
637
|
-
l.writeEBMLVarInt(
|
|
677
|
+
if (!(s.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof s.data);
|
|
678
|
+
l.writeEBMLVarInt(s.data.byteLength), s.dataOffset = l.pos + h, l.writeBytes(s.data);
|
|
638
679
|
}
|
|
639
680
|
}
|
|
640
681
|
}
|
|
641
682
|
let d = function(l, h) {
|
|
642
|
-
return function(
|
|
643
|
-
let c, u, f = !1,
|
|
644
|
-
function
|
|
683
|
+
return function(s) {
|
|
684
|
+
let c, u, f = !1, x = 0, m = 0, v = null, w = null, y = null, g = [], E = 0, L = 0, k = { quality: 0.95, transparent: !1, alphaQuality: void 0, fileWriter: null, fd: null, frameDuration: null, frameRate: null }, O = { Cues: { id: new Uint8Array([28, 83, 187, 107]), positionEBML: null }, SegmentInfo: { id: new Uint8Array([21, 73, 169, 102]), positionEBML: null }, Tracks: { id: new Uint8Array([22, 84, 174, 107]), positionEBML: null } }, F = { id: 17545, data: new o(0) }, V = [], S = new h(s.fileWriter || s.fd);
|
|
685
|
+
function A(_) {
|
|
645
686
|
return _ - c.dataOffset;
|
|
646
687
|
}
|
|
647
688
|
function R() {
|
|
648
689
|
u = (function() {
|
|
649
690
|
let $ = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
|
|
650
|
-
for (let I in
|
|
651
|
-
let
|
|
652
|
-
|
|
691
|
+
for (let I in O) {
|
|
692
|
+
let Y = O[I];
|
|
693
|
+
Y.positionEBML = Object.create($), U.data.push({ id: 19899, data: [{ id: 21419, data: Y.id }, Y.positionEBML] });
|
|
653
694
|
}
|
|
654
695
|
return U;
|
|
655
696
|
})();
|
|
656
|
-
let _ = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" },
|
|
657
|
-
|
|
697
|
+
let _ = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" }, F] }, C = [{ id: 176, data: x }, { id: 186, data: m }];
|
|
698
|
+
s.transparent && C.push({ id: 21440, data: 1 });
|
|
658
699
|
let M = { id: 374648427, data: [{ id: 174, data: [{ id: 215, data: 1 }, { id: 29637, data: 1 }, { id: 156, data: 0 }, { id: 2274716, data: "und" }, { id: 134, data: "V_VP8" }, { id: 2459272, data: "VP8" }, { id: 131, data: 1 }, { id: 224, data: C }] }] };
|
|
659
700
|
c = { id: 408125543, size: -2, data: [u, _, M] };
|
|
660
701
|
let P = new l(256);
|
|
661
|
-
|
|
702
|
+
n(P, S.pos, [{ id: 440786851, data: [{ id: 17030, data: 1 }, { id: 17143, data: 1 }, { id: 17138, data: 4 }, { id: 17139, data: 8 }, { id: 17026, data: "webm" }, { id: 17031, data: 2 }, { id: 17029, data: 2 }] }, c]), S.write(P.getAsDataArray()), O.SegmentInfo.positionEBML.data = A(_.offset), O.Tracks.positionEBML.data = A(M.offset), f = !0;
|
|
662
703
|
}
|
|
663
704
|
function B(_) {
|
|
664
705
|
return _.alpha ? (function(C) {
|
|
@@ -680,80 +721,80 @@ function we() {
|
|
|
680
721
|
})({ timecode: Math.round(E) });
|
|
681
722
|
for (let I = 0; I < g.length; I++) M.data.push(B(g[I]));
|
|
682
723
|
var P, $, U;
|
|
683
|
-
|
|
724
|
+
n(C, S.pos, M), S.write(C.getAsDataArray()), P = 1, $ = Math.round(E), U = M.offset, V.push({ id: 187, data: [{ id: 179, data: $ }, { id: 183, data: [{ id: 247, data: P }, { id: 241, data: A(U) }] }] }), g = [], E += L, L = 0;
|
|
684
725
|
}
|
|
685
726
|
this.addFrame = function(_, C, M) {
|
|
686
|
-
f || (
|
|
687
|
-
let P, $ = e(
|
|
688
|
-
P = M || (typeof C == "number" ? C :
|
|
689
|
-
v !== null && v.width === I.width && v.height === I.height || (v = document.createElement("canvas"), v.width = I.width, v.height = I.height, w = v.getContext("2d"),
|
|
690
|
-
let
|
|
691
|
-
for (let
|
|
692
|
-
let
|
|
693
|
-
K[
|
|
727
|
+
f || (x = _.width || 0, m = _.height || 0, R());
|
|
728
|
+
let P, $ = r(e(_, s.quality)), U = null;
|
|
729
|
+
P = M || (typeof C == "number" ? C : s.frameDuration), s.transparent && (C instanceof HTMLCanvasElement || typeof C == "string" ? U = C : $.hasAlpha && (U = (function(I) {
|
|
730
|
+
v !== null && v.width === I.width && v.height === I.height || (v = document.createElement("canvas"), v.width = I.width, v.height = I.height, w = v.getContext("2d"), y = w.createImageData(v.width, v.height));
|
|
731
|
+
let Y = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, K = y.data, tt = 0, Kt = I.width * I.height * 4;
|
|
732
|
+
for (let ct = 3; ct < Kt; ct += 4) {
|
|
733
|
+
let ut = Y[ct];
|
|
734
|
+
K[tt++] = ut, K[tt++] = ut, K[tt++] = ut, K[tt++] = 255;
|
|
694
735
|
}
|
|
695
|
-
return w.putImageData(
|
|
736
|
+
return w.putImageData(y, 0, 0), v;
|
|
696
737
|
})(_))), (function(I) {
|
|
697
|
-
I.trackNumber = 1, I.timecode = Math.round(
|
|
698
|
-
})({ frame: $.frame, duration: P, alpha: U ? e(
|
|
738
|
+
I.trackNumber = 1, I.timecode = Math.round(L), g.push(I), L += I.duration, L >= 5e3 && N();
|
|
739
|
+
})({ frame: $.frame, duration: P, alpha: U ? r(e(U, s.alphaQuality)).frame : null });
|
|
699
740
|
}, this.complete = function() {
|
|
700
741
|
return f || R(), N(), (function() {
|
|
701
742
|
let _ = { id: 475249515, data: V }, C = new l(16 + 32 * V.length);
|
|
702
|
-
|
|
743
|
+
n(C, S.pos, _), S.write(C.getAsDataArray()), O.Cues.positionEBML.data = A(_.offset);
|
|
703
744
|
})(), (function() {
|
|
704
745
|
let _ = new l(u.size), C = S.pos;
|
|
705
|
-
|
|
746
|
+
n(_, u.dataOffset, u.data), S.seek(u.dataOffset), S.write(_.getAsDataArray()), S.seek(C);
|
|
706
747
|
})(), (function() {
|
|
707
748
|
let _ = new l(8), C = S.pos;
|
|
708
|
-
_.writeDoubleBE(E), S.seek(
|
|
749
|
+
_.writeDoubleBE(E), S.seek(F.dataOffset), S.write(_.getAsDataArray()), S.seek(C);
|
|
709
750
|
})(), (function() {
|
|
710
751
|
let _ = new l(10), C = S.pos;
|
|
711
752
|
_.writeUnsignedIntBE(c.id), _.writeEBMLVarIntWidth(S.pos - c.dataOffset, 5), S.seek(c.offset), S.write(_.getAsDataArray()), S.seek(C);
|
|
712
753
|
})(), S.complete("video/webm");
|
|
713
754
|
}, this.getWrittenSize = function() {
|
|
714
755
|
return S.length;
|
|
715
|
-
},
|
|
756
|
+
}, s = (function(_, C) {
|
|
716
757
|
let M = {};
|
|
717
758
|
return [_, C].forEach(function(P) {
|
|
718
759
|
for (let $ in P) Object.prototype.hasOwnProperty.call(P, $) && (M[$] = P[$]);
|
|
719
760
|
}), M;
|
|
720
|
-
})(k,
|
|
721
|
-
if (!
|
|
722
|
-
if (!
|
|
723
|
-
|
|
761
|
+
})(k, s || {}), (function() {
|
|
762
|
+
if (!s.frameDuration) {
|
|
763
|
+
if (!s.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
|
|
764
|
+
s.frameDuration = 1e3 / s.frameRate;
|
|
724
765
|
}
|
|
725
|
-
|
|
766
|
+
s.quality = Math.max(Math.min(s.quality, 0.99999), 0), s.alphaQuality === void 0 ? s.alphaQuality = s.quality : s.alphaQuality = Math.max(Math.min(s.alphaQuality, 0.99999), 0);
|
|
726
767
|
})();
|
|
727
768
|
};
|
|
728
769
|
};
|
|
729
770
|
i.exports = d;
|
|
730
|
-
})()),
|
|
771
|
+
})()), Tt.exports;
|
|
731
772
|
var i;
|
|
732
773
|
}
|
|
733
|
-
var
|
|
734
|
-
function
|
|
735
|
-
return
|
|
736
|
-
let
|
|
774
|
+
var Pt, Ot = { exports: {} };
|
|
775
|
+
function Te() {
|
|
776
|
+
return Pt || (Pt = 1, i = Ot, (function() {
|
|
777
|
+
let e = function(t) {
|
|
737
778
|
this.data = new Uint8Array(t), this.pos = 0;
|
|
738
779
|
};
|
|
739
|
-
|
|
780
|
+
e.prototype.seek = function(t) {
|
|
740
781
|
this.pos = t;
|
|
741
|
-
},
|
|
742
|
-
for (let
|
|
743
|
-
},
|
|
782
|
+
}, e.prototype.writeBytes = function(t) {
|
|
783
|
+
for (let r = 0; r < t.length; r++) this.data[this.pos++] = t[r];
|
|
784
|
+
}, e.prototype.writeByte = function(t) {
|
|
744
785
|
this.data[this.pos++] = t;
|
|
745
|
-
},
|
|
786
|
+
}, e.prototype.writeU8 = e.prototype.writeByte, e.prototype.writeU16BE = function(t) {
|
|
746
787
|
this.data[this.pos++] = t >> 8, this.data[this.pos++] = t;
|
|
747
|
-
},
|
|
748
|
-
let
|
|
749
|
-
for (let a =
|
|
750
|
-
},
|
|
751
|
-
let
|
|
752
|
-
for (let a =
|
|
753
|
-
},
|
|
754
|
-
for (let
|
|
755
|
-
},
|
|
756
|
-
switch (
|
|
788
|
+
}, e.prototype.writeDoubleBE = function(t) {
|
|
789
|
+
let r = new Uint8Array(new Float64Array([t]).buffer);
|
|
790
|
+
for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
|
|
791
|
+
}, e.prototype.writeFloatBE = function(t) {
|
|
792
|
+
let r = new Uint8Array(new Float32Array([t]).buffer);
|
|
793
|
+
for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
|
|
794
|
+
}, e.prototype.writeString = function(t) {
|
|
795
|
+
for (let r = 0; r < t.length; r++) this.data[this.pos++] = t.charCodeAt(r);
|
|
796
|
+
}, e.prototype.writeEBMLVarIntWidth = function(t, r) {
|
|
797
|
+
switch (r) {
|
|
757
798
|
case 1:
|
|
758
799
|
this.writeU8(128 | t);
|
|
759
800
|
break;
|
|
@@ -770,19 +811,19 @@ function Ce() {
|
|
|
770
811
|
this.writeU8(8 | t / 4294967296 & 7), this.writeU8(t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
|
|
771
812
|
break;
|
|
772
813
|
default:
|
|
773
|
-
throw new Error("Bad EBML VINT size " +
|
|
814
|
+
throw new Error("Bad EBML VINT size " + r);
|
|
774
815
|
}
|
|
775
|
-
},
|
|
816
|
+
}, e.prototype.measureEBMLVarInt = function(t) {
|
|
776
817
|
if (t < 127) return 1;
|
|
777
818
|
if (t < 16383) return 2;
|
|
778
819
|
if (t < 2097151) return 3;
|
|
779
820
|
if (t < 268435455) return 4;
|
|
780
821
|
if (t < 34359738367) return 5;
|
|
781
822
|
throw new Error("EBML VINT size not supported " + t);
|
|
782
|
-
},
|
|
823
|
+
}, e.prototype.writeEBMLVarInt = function(t) {
|
|
783
824
|
this.writeEBMLVarIntWidth(t, this.measureEBMLVarInt(t));
|
|
784
|
-
},
|
|
785
|
-
switch (
|
|
825
|
+
}, e.prototype.writeUnsignedIntBE = function(t, r) {
|
|
826
|
+
switch (r === void 0 && (r = this.measureUnsignedInt(t)), r) {
|
|
786
827
|
case 5:
|
|
787
828
|
this.writeU8(Math.floor(t / 4294967296));
|
|
788
829
|
case 4:
|
|
@@ -795,67 +836,67 @@ function Ce() {
|
|
|
795
836
|
this.writeU8(t);
|
|
796
837
|
break;
|
|
797
838
|
default:
|
|
798
|
-
throw new Error("Bad UINT size " +
|
|
839
|
+
throw new Error("Bad UINT size " + r);
|
|
799
840
|
}
|
|
800
|
-
},
|
|
841
|
+
}, e.prototype.measureUnsignedInt = function(t) {
|
|
801
842
|
return t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 4294967296 ? 4 : 5;
|
|
802
|
-
},
|
|
843
|
+
}, e.prototype.getAsDataArray = function() {
|
|
803
844
|
if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
|
|
804
845
|
if (this.pos == this.data.byteLength) return this.data;
|
|
805
846
|
throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
|
|
806
|
-
}, i.exports =
|
|
807
|
-
})()),
|
|
847
|
+
}, i.exports = e;
|
|
848
|
+
})()), Ot.exports;
|
|
808
849
|
var i;
|
|
809
850
|
}
|
|
810
|
-
var
|
|
811
|
-
function
|
|
812
|
-
return
|
|
813
|
-
let
|
|
814
|
-
return function(
|
|
815
|
-
let a = [], o = Promise.resolve(),
|
|
851
|
+
var At, Dt, Vt, Rt = { exports: {} };
|
|
852
|
+
function Pe() {
|
|
853
|
+
return At || (At = 1, i = Rt, (function() {
|
|
854
|
+
let e = function(t) {
|
|
855
|
+
return function(r) {
|
|
856
|
+
let a = [], o = Promise.resolve(), n = null, d = null;
|
|
816
857
|
function l(c) {
|
|
817
858
|
return new Promise(function(u, f) {
|
|
818
|
-
let
|
|
819
|
-
|
|
820
|
-
u(
|
|
821
|
-
}),
|
|
859
|
+
let x = new FileReader();
|
|
860
|
+
x.addEventListener("loadend", function() {
|
|
861
|
+
u(x.result);
|
|
862
|
+
}), x.readAsArrayBuffer(c);
|
|
822
863
|
});
|
|
823
864
|
}
|
|
824
865
|
function h(c) {
|
|
825
866
|
return new Promise(function(u, f) {
|
|
826
|
-
c instanceof Uint8Array ? u(c) : c instanceof ArrayBuffer || ArrayBuffer.isView(c) ? u(new Uint8Array(c)) : c instanceof Blob ? u(l(c).then(function(
|
|
827
|
-
return new Uint8Array(
|
|
828
|
-
})) : u(l(new Blob([c])).then(function(
|
|
829
|
-
return new Uint8Array(
|
|
867
|
+
c instanceof Uint8Array ? u(c) : c instanceof ArrayBuffer || ArrayBuffer.isView(c) ? u(new Uint8Array(c)) : c instanceof Blob ? u(l(c).then(function(x) {
|
|
868
|
+
return new Uint8Array(x);
|
|
869
|
+
})) : u(l(new Blob([c])).then(function(x) {
|
|
870
|
+
return new Uint8Array(x);
|
|
830
871
|
}));
|
|
831
872
|
});
|
|
832
873
|
}
|
|
833
|
-
function
|
|
874
|
+
function s(c) {
|
|
834
875
|
let u = c.byteLength || c.length || c.size;
|
|
835
876
|
if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
|
|
836
877
|
return u;
|
|
837
878
|
}
|
|
838
|
-
|
|
879
|
+
r && r.constructor.name === "FileWriter" ? n = r : t && r && (d = r), this.pos = 0, this.length = 0, this.seek = function(c) {
|
|
839
880
|
if (c < 0) throw new Error("Offset may not be negative");
|
|
840
881
|
if (isNaN(c)) throw new Error("Offset may not be NaN");
|
|
841
882
|
if (c > this.length) throw new Error("Seeking beyond the end of file is not allowed");
|
|
842
883
|
this.pos = c;
|
|
843
884
|
}, this.write = function(c) {
|
|
844
|
-
let u = { offset: this.pos, data: c, length:
|
|
885
|
+
let u = { offset: this.pos, data: c, length: s(c) }, f = u.offset >= this.length;
|
|
845
886
|
this.pos += u.length, this.length = Math.max(this.length, this.pos), o = o.then(function() {
|
|
846
|
-
if (d) return new Promise(function(
|
|
887
|
+
if (d) return new Promise(function(x, m) {
|
|
847
888
|
h(u.data).then(function(v) {
|
|
848
|
-
let w = 0,
|
|
849
|
-
w +=
|
|
889
|
+
let w = 0, y = Buffer.from(v.buffer), g = function(E, L, k) {
|
|
890
|
+
w += L, w >= k.length ? x() : t.write(d, k, w, k.length - w, u.offset + w, g);
|
|
850
891
|
};
|
|
851
|
-
t.write(d,
|
|
892
|
+
t.write(d, y, 0, y.length, u.offset, g);
|
|
852
893
|
});
|
|
853
894
|
});
|
|
854
|
-
if (
|
|
855
|
-
|
|
895
|
+
if (n) return new Promise(function(x, m) {
|
|
896
|
+
n.onwriteend = x, n.seek(u.offset), n.write(new Blob([u.data]));
|
|
856
897
|
});
|
|
857
|
-
if (!f) for (let
|
|
858
|
-
let m = a[
|
|
898
|
+
if (!f) for (let x = 0; x < a.length; x++) {
|
|
899
|
+
let m = a[x];
|
|
859
900
|
if (!(u.offset + u.length <= m.offset || u.offset >= m.offset + m.length)) {
|
|
860
901
|
if (u.offset < m.offset || u.offset + u.length > m.offset + m.length) throw new Error("Overwrite crosses blob boundaries");
|
|
861
902
|
return u.offset == m.offset && u.length == m.length ? void (m.data = u.data) : h(m.data).then(function(v) {
|
|
@@ -868,7 +909,7 @@ function Ee() {
|
|
|
868
909
|
a.push(u);
|
|
869
910
|
});
|
|
870
911
|
}, this.complete = function(c) {
|
|
871
|
-
return o = d ||
|
|
912
|
+
return o = d || n ? o.then(function() {
|
|
872
913
|
return null;
|
|
873
914
|
}) : o.then(function() {
|
|
874
915
|
let u = [];
|
|
@@ -878,42 +919,42 @@ function Ee() {
|
|
|
878
919
|
};
|
|
879
920
|
};
|
|
880
921
|
};
|
|
881
|
-
i.exports =
|
|
882
|
-
})()),
|
|
922
|
+
i.exports = e;
|
|
923
|
+
})()), Rt.exports;
|
|
883
924
|
var i;
|
|
884
925
|
}
|
|
885
|
-
function
|
|
886
|
-
return
|
|
926
|
+
function Oe() {
|
|
927
|
+
return Vt ? Dt : (Vt = 1, Dt = $e()(Te(), Pe()(null)));
|
|
887
928
|
}
|
|
888
|
-
var
|
|
889
|
-
const
|
|
890
|
-
class
|
|
891
|
-
async $record(
|
|
892
|
-
const o = Math.max(1, Math.round(t.frameRate)),
|
|
893
|
-
return await new Promise((h,
|
|
894
|
-
let c, u = "capturing", f = !1,
|
|
929
|
+
var Ae = Oe();
|
|
930
|
+
const De = Fe(Ae);
|
|
931
|
+
class Ve {
|
|
932
|
+
async $record(e, t, r, a) {
|
|
933
|
+
const o = Math.max(1, Math.round(t.frameRate)), n = Math.max(1, Math.round(t.frameCount)), d = new De({ quality: t.quality, alphaQuality: t.transparent ? t.quality : void 0, transparent: t.transparent, frameRate: o }), l = this._createSnapshotSurface();
|
|
934
|
+
return await new Promise((h, s) => {
|
|
935
|
+
let c, u = "capturing", f = !1, x = 0;
|
|
895
936
|
const m = () => {
|
|
896
937
|
c && (c(), c = void 0);
|
|
897
938
|
}, v = () => {
|
|
898
|
-
a == null || a({ state: "recording", frameIndex:
|
|
939
|
+
a == null || a({ state: "recording", frameIndex: x, totalFrames: n });
|
|
899
940
|
}, w = (g) => {
|
|
900
941
|
if (f) return;
|
|
901
942
|
f = !0, m();
|
|
902
943
|
const E = g instanceof Error ? g.message : "WEBM export failed";
|
|
903
|
-
a == null || a({ state: "error", message: E }),
|
|
904
|
-
},
|
|
944
|
+
a == null || a({ state: "error", message: E }), s(g instanceof Error ? g : new Error(String(g)));
|
|
945
|
+
}, y = () => {
|
|
905
946
|
u !== "capturing" || f || (u = "encoding", m(), d.complete().then((g) => {
|
|
906
947
|
((E) => {
|
|
907
|
-
f || (f = !0, a == null || a({ state: "completed", frameIndex: Math.min(
|
|
948
|
+
f || (f = !0, a == null || a({ state: "completed", frameIndex: Math.min(n, x), totalFrames: n }), h(E));
|
|
908
949
|
})(g);
|
|
909
950
|
}).catch(w));
|
|
910
951
|
};
|
|
911
|
-
c =
|
|
952
|
+
c = r(() => {
|
|
912
953
|
(() => {
|
|
913
|
-
if (u === "capturing") if (
|
|
954
|
+
if (u === "capturing") if (x >= n) y();
|
|
914
955
|
else try {
|
|
915
|
-
const g = l(
|
|
916
|
-
d.addFrame(g),
|
|
956
|
+
const g = l(e);
|
|
957
|
+
d.addFrame(g), x += 1, v(), x >= n && y();
|
|
917
958
|
} catch (g) {
|
|
918
959
|
w(g);
|
|
919
960
|
}
|
|
@@ -922,87 +963,104 @@ class Ie {
|
|
|
922
963
|
});
|
|
923
964
|
}
|
|
924
965
|
_createSnapshotSurface() {
|
|
925
|
-
let
|
|
926
|
-
return (
|
|
927
|
-
const a = Math.max(1,
|
|
928
|
-
return
|
|
966
|
+
let e = null, t = null;
|
|
967
|
+
return (r) => {
|
|
968
|
+
const a = Math.max(1, r.width), o = Math.max(1, r.height), n = ((d, l) => (e || (e = document.createElement("canvas")), e.width !== d || e.height !== l ? (e.width = d, e.height = l, t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)) : t || (t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)), t ? e : null))(a, o);
|
|
969
|
+
return n && t ? (t.clearRect(0, 0, a, o), t.drawImage(r, 0, 0, a, o), n) : r;
|
|
929
970
|
};
|
|
930
971
|
}
|
|
931
972
|
}
|
|
932
|
-
class
|
|
933
|
-
constructor(
|
|
973
|
+
class Re {
|
|
974
|
+
constructor(e, t) {
|
|
934
975
|
p(this, "_recorder");
|
|
935
976
|
p(this, "_textmodifier");
|
|
936
977
|
p(this, "_registerPostDrawHook");
|
|
937
|
-
this._recorder = new
|
|
978
|
+
this._recorder = new Ve(), this._textmodifier = e, this._registerPostDrawHook = t;
|
|
938
979
|
}
|
|
939
|
-
async $saveWEBM(
|
|
980
|
+
async $saveWEBM(e = {}) {
|
|
940
981
|
var a;
|
|
941
|
-
const t = this._textmodifier.canvas,
|
|
982
|
+
const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e);
|
|
942
983
|
try {
|
|
943
|
-
const o = await this._recorder.$record(t,
|
|
944
|
-
new
|
|
984
|
+
const o = await this._recorder.$record(t, r, this._registerPostDrawHook, e.onProgress);
|
|
985
|
+
new X().$downloadFile(o, r.filename);
|
|
945
986
|
} catch (o) {
|
|
946
|
-
throw (a =
|
|
987
|
+
throw (a = e.onProgress) == null || a.call(e, { state: "error", message: o instanceof Error ? o.message : "WEBM export failed" }), o;
|
|
947
988
|
}
|
|
948
989
|
}
|
|
949
|
-
_applyDefaultOptions(
|
|
950
|
-
return { filename:
|
|
990
|
+
_applyDefaultOptions(e) {
|
|
991
|
+
return { filename: e.filename, frameRate: Math.abs(Math.round(e.frameRate ?? 60)), frameCount: Math.abs(Math.round(e.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(e.quality ?? 1, 0), 1)), transparent: !!e.transparent, debugLogging: !!e.debugLogging };
|
|
951
992
|
}
|
|
952
993
|
}
|
|
953
|
-
class
|
|
954
|
-
$extractCellData(
|
|
955
|
-
var
|
|
956
|
-
const t =
|
|
957
|
-
let
|
|
958
|
-
for (let
|
|
959
|
-
const
|
|
960
|
-
|
|
994
|
+
class Ne extends xt {
|
|
995
|
+
$extractCellData(e) {
|
|
996
|
+
var d;
|
|
997
|
+
const t = this.$extractFramebufferData(e.drawFramebuffer), r = [], a = e.grid, o = e.font;
|
|
998
|
+
let n = 0;
|
|
999
|
+
for (let l = 0; l < a.rows; l++) for (let h = 0; h < a.cols; h++) {
|
|
1000
|
+
const s = 4 * n, c = this.$getEncodedCharacterValue(t.characterPixels, s), u = this.$extractCellTransform(t.characterPixels, s), f = ((d = _t(o, c)) == null ? void 0 : d.character) ?? " ";
|
|
1001
|
+
r.push({ x: h, y: l, character: f, foreground: st(t.primaryColorPixels, s), background: st(t.secondaryColorPixels, s), transform: { invert: u.isInverted, flipX: u.flipHorizontal, flipY: u.flipVertical, rotation: u.rotation } }), n++;
|
|
961
1002
|
}
|
|
962
|
-
return
|
|
1003
|
+
return r;
|
|
963
1004
|
}
|
|
964
1005
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1006
|
+
class ft {
|
|
1007
|
+
_applyDefaultOptions(e) {
|
|
1008
|
+
return { target: e.target ?? "selected", pretty: e.pretty ?? !0, colorMode: e.colorMode ?? "hex", includeMetadata: e.includeMetadata ?? !0, filename: e.filename, layer: e.layer };
|
|
1009
|
+
}
|
|
1010
|
+
_createMetadata(e) {
|
|
1011
|
+
return e.includeMetadata ? { createdAt: (/* @__PURE__ */ new Date()).toISOString(), generator: { name: "textmode.export.js", version: "1.2.1" } } : void 0;
|
|
969
1012
|
}
|
|
970
|
-
_formatColor(
|
|
971
|
-
return t === "rgba" ? { ...
|
|
1013
|
+
_formatColor(e, t) {
|
|
1014
|
+
return t === "rgba" ? { ...e } : `#${[e.r, e.g, e.b, e.a].map((r) => r.toString(16).padStart(2, "0")).join("")}`;
|
|
972
1015
|
}
|
|
973
|
-
_createObjectRowsCells(
|
|
974
|
-
const
|
|
975
|
-
for (let
|
|
976
|
-
const
|
|
977
|
-
|
|
1016
|
+
_createObjectRowsCells(e, t, r, a) {
|
|
1017
|
+
const o = [];
|
|
1018
|
+
for (let n = 0; n < r; n++) {
|
|
1019
|
+
const d = n * t, l = e.slice(d, d + t).map((h) => ({ x: h.x, y: h.y, character: h.character, foreground: this._formatColor(h.foreground, a), background: this._formatColor(h.background, a), transform: { ...h.transform } }));
|
|
1020
|
+
o.push(l);
|
|
978
1021
|
}
|
|
979
|
-
return { encoding: "object-rows-v1", rows:
|
|
1022
|
+
return { encoding: "object-rows-v1", rows: o };
|
|
980
1023
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1024
|
+
_createLayerGrid(e) {
|
|
1025
|
+
return { cols: e.grid.cols, rows: e.grid.rows, cellWidth: e.grid.cellWidth, cellHeight: e.grid.cellHeight };
|
|
1026
|
+
}
|
|
1027
|
+
_createLayerCells(e, t) {
|
|
1028
|
+
const r = new Ne().$extractCellData(e);
|
|
1029
|
+
return this._createObjectRowsCells(r, e.grid.cols, e.grid.rows, t.colorMode);
|
|
1030
|
+
}
|
|
1031
|
+
_createStackLayer(e, t) {
|
|
1032
|
+
return { id: e.id, visible: e.visible, opacity: e.opacity, blendMode: e.blendMode, offsetX: e.offsetX, offsetY: e.offsetY, rotationZ: e.rotationZ, grid: this._createLayerGrid(e), cells: this._createLayerCells(e, t) };
|
|
1033
|
+
}
|
|
1034
|
+
$generateJSONData(e, t = {}) {
|
|
1035
|
+
const r = this._applyDefaultOptions(t), a = this._createMetadata(r);
|
|
1036
|
+
if (r.target === "all") {
|
|
1037
|
+
const n = ie(e), d = n[0].grid;
|
|
1038
|
+
return { format: "textmode.document", formatVersion: "2.0.0", target: "all", ...a ? { metadata: a } : {}, canvas: { width: d.width, height: d.height }, layers: n.map((l) => this._createStackLayer(l, r)) };
|
|
1039
|
+
}
|
|
1040
|
+
const o = lt(e, r.layer);
|
|
1041
|
+
return { format: "textmode.document", formatVersion: "2.0.0", target: "selected", ...a ? { metadata: a } : {}, canvas: { width: o.grid.width, height: o.grid.height }, grid: this._createLayerGrid(o), layer: { id: o.id, cells: this._createLayerCells(o, r) } };
|
|
984
1042
|
}
|
|
985
|
-
$generateJSONString(
|
|
986
|
-
const
|
|
1043
|
+
$generateJSONString(e, t = {}) {
|
|
1044
|
+
const r = this._applyDefaultOptions(t), a = this.$generateJSONData(e, r), o = typeof r.pretty == "number" ? r.pretty : r.pretty ? 2 : 0;
|
|
987
1045
|
return JSON.stringify(a, null, o);
|
|
988
1046
|
}
|
|
989
|
-
$saveJSON(
|
|
990
|
-
const
|
|
991
|
-
new
|
|
1047
|
+
$saveJSON(e, t = {}) {
|
|
1048
|
+
const r = this._applyDefaultOptions(t);
|
|
1049
|
+
new X().$downloadFile(new Blob([this.$generateJSONString(e, r)], { type: "application/json;charset=utf-8" }), r.filename);
|
|
992
1050
|
}
|
|
993
1051
|
}
|
|
994
1052
|
const b = { root: "textmode-export-overlay", stack: "textmode-export-overlay__stack", stackDense: "textmode-export-overlay__stack--dense", stackCompact: "textmode-export-overlay__stack--compact", section: "textmode-export-overlay__section", header: "textmode-export-overlay__header", headerTitleRow: "textmode-export-overlay__header-title-row", headerLinks: "textmode-export-overlay__header-links", row: "textmode-export-overlay__row", label: "textmode-export-overlay__label", field: "textmode-export-overlay__field", fieldCompact: "textmode-export-overlay__field--compact", fieldDense: "textmode-export-overlay__field--dense", fieldFull: "textmode-export-overlay__field--full", fieldChannel: "textmode-export-overlay__field--channel", input: "textmode-export-overlay__input", checkbox: "textmode-export-overlay__checkbox", muted: "textmode-export-overlay__muted", status: "textmode-export-overlay__status", statusGif: "textmode-export-overlay__status--gif", statusVideo: "textmode-export-overlay__status--video", statusTitle: "textmode-export-overlay__status-title", statusValue: "textmode-export-overlay__status-value", divider: "textmode-export-overlay__divider", title: "textmode-export-overlay__title", button: "textmode-export-overlay__button", buttonPrimary: "textmode-export-overlay__button--primary", buttonSecondary: "textmode-export-overlay__button--secondary", buttonFull: "textmode-export-overlay__button--full", supportLink: "textmode-export-overlay__support-link", supportIcon: "textmode-export-overlay__support-icon", linkIcon: "textmode-export-overlay__link-icon" };
|
|
995
|
-
class
|
|
1053
|
+
class D {
|
|
996
1054
|
constructor() {
|
|
997
1055
|
p(this, "element");
|
|
998
1056
|
p(this, "mounted", !1);
|
|
999
1057
|
p(this, "destroyed", !1);
|
|
1000
1058
|
}
|
|
1001
|
-
mount(
|
|
1059
|
+
mount(e) {
|
|
1002
1060
|
if (this.destroyed) throw new Error("Cannot mount a destroyed component");
|
|
1003
1061
|
if (this.mounted) return;
|
|
1004
1062
|
const t = this.render();
|
|
1005
|
-
|
|
1063
|
+
e.appendChild(t), this.element = t, this.onMount(), this.mounted = !0;
|
|
1006
1064
|
}
|
|
1007
1065
|
unmount() {
|
|
1008
1066
|
this.mounted && this.element && (this._onUnmount(), this.element.remove(), this.element = void 0, this.mounted = !1);
|
|
@@ -1010,8 +1068,8 @@ class T {
|
|
|
1010
1068
|
destroy() {
|
|
1011
1069
|
this.destroyed || (this.unmount(), this._onDestroy(), this.destroyed = !0);
|
|
1012
1070
|
}
|
|
1013
|
-
update(
|
|
1014
|
-
this.mounted && this.onUpdate(
|
|
1071
|
+
update(e) {
|
|
1072
|
+
this.mounted && this.onUpdate(e);
|
|
1015
1073
|
}
|
|
1016
1074
|
onMount() {
|
|
1017
1075
|
}
|
|
@@ -1019,7 +1077,7 @@ class T {
|
|
|
1019
1077
|
}
|
|
1020
1078
|
_onDestroy() {
|
|
1021
1079
|
}
|
|
1022
|
-
onUpdate(
|
|
1080
|
+
onUpdate(e) {
|
|
1023
1081
|
}
|
|
1024
1082
|
get root() {
|
|
1025
1083
|
if (!this.element) throw new Error("Component is not mounted yet");
|
|
@@ -1029,39 +1087,39 @@ class T {
|
|
|
1029
1087
|
return this.mounted;
|
|
1030
1088
|
}
|
|
1031
1089
|
}
|
|
1032
|
-
const q = class q extends
|
|
1090
|
+
const q = class q extends D {
|
|
1033
1091
|
render() {
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1092
|
+
const e = document.createElement("div");
|
|
1093
|
+
e.classList.add(b.stack, b.stackDense, b.header);
|
|
1036
1094
|
const t = document.createElement("div");
|
|
1037
1095
|
t.classList.add(b.headerTitleRow);
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1096
|
+
const r = document.createElement("strong");
|
|
1097
|
+
r.textContent = "textmode.export.js", r.classList.add(b.title);
|
|
1040
1098
|
const a = document.createElement("div");
|
|
1041
1099
|
a.classList.add(b.headerLinks);
|
|
1042
|
-
const o = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]),
|
|
1043
|
-
a.appendChild(o), a.appendChild(
|
|
1100
|
+
const o = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]), n = this._createLink("https://code.textmode.art/docs/support", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
|
|
1101
|
+
a.appendChild(o), a.appendChild(n), t.appendChild(r), t.appendChild(a);
|
|
1044
1102
|
const d = document.createElement("div");
|
|
1045
|
-
return d.classList.add(b.divider),
|
|
1103
|
+
return d.classList.add(b.divider), e.appendChild(t), e.appendChild(d), e;
|
|
1046
1104
|
}
|
|
1047
|
-
_createLink(
|
|
1105
|
+
_createLink(e, t, r, a) {
|
|
1048
1106
|
const o = document.createElement("a");
|
|
1049
|
-
return o.href =
|
|
1107
|
+
return o.href = e, o.target = "_blank", o.rel = "noopener noreferrer", o.classList.add(b.supportLink), o.setAttribute("aria-label", t), o.appendChild(this._createIcon(r, a)), o;
|
|
1050
1108
|
}
|
|
1051
|
-
_createIcon(
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1109
|
+
_createIcon(e, t) {
|
|
1110
|
+
const r = document.createElementNS(q._iconNamespace, "svg");
|
|
1111
|
+
r.setAttribute("xmlns", q._iconNamespace), r.setAttribute("width", "18"), r.setAttribute("height", "18"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), r.classList.add(e);
|
|
1054
1112
|
for (const a of t) {
|
|
1055
1113
|
const o = document.createElementNS(q._iconNamespace, "path");
|
|
1056
|
-
for (const [
|
|
1057
|
-
|
|
1114
|
+
for (const [n, d] of Object.entries(a)) o.setAttribute(n, d);
|
|
1115
|
+
r.appendChild(o);
|
|
1058
1116
|
}
|
|
1059
|
-
return
|
|
1117
|
+
return r;
|
|
1060
1118
|
}
|
|
1061
1119
|
};
|
|
1062
1120
|
p(q, "_iconNamespace", "http://www.w3.org/2000/svg");
|
|
1063
|
-
let
|
|
1064
|
-
class
|
|
1121
|
+
let bt = q;
|
|
1122
|
+
class T extends D {
|
|
1065
1123
|
constructor(t) {
|
|
1066
1124
|
super();
|
|
1067
1125
|
p(this, "props");
|
|
@@ -1070,8 +1128,8 @@ class O extends T {
|
|
|
1070
1128
|
render() {
|
|
1071
1129
|
const t = document.createElement("div");
|
|
1072
1130
|
t.classList.add(b.field), this.applyVariant(t, this.props.variant);
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1131
|
+
const r = document.createElement("label");
|
|
1132
|
+
if (r.classList.add(b.label), r.textContent = this.props.label, this.props.labelFor && (r.htmlFor = this.props.labelFor), t.appendChild(r), this.props.description) {
|
|
1075
1133
|
const a = document.createElement("span");
|
|
1076
1134
|
a.classList.add(b.muted), a.textContent = this.props.description, t.appendChild(a);
|
|
1077
1135
|
}
|
|
@@ -1084,17 +1142,17 @@ class O extends T {
|
|
|
1084
1142
|
this.props = t, super.update(t);
|
|
1085
1143
|
}
|
|
1086
1144
|
onUpdate(t) {
|
|
1087
|
-
const
|
|
1088
|
-
for (;
|
|
1089
|
-
this.props = t,
|
|
1145
|
+
const r = this.root;
|
|
1146
|
+
for (; r.firstChild; ) r.removeChild(r.firstChild);
|
|
1147
|
+
this.props = t, r.classList.add(b.field), this.applyVariant(r, t.variant);
|
|
1090
1148
|
const a = document.createElement("label");
|
|
1091
|
-
if (a.classList.add(b.label), a.textContent = t.label, t.labelFor && (a.htmlFor = t.labelFor),
|
|
1149
|
+
if (a.classList.add(b.label), a.textContent = t.label, t.labelFor && (a.htmlFor = t.labelFor), r.appendChild(a), t.description) {
|
|
1092
1150
|
const o = document.createElement("span");
|
|
1093
|
-
o.classList.add(b.muted), o.textContent = t.description,
|
|
1151
|
+
o.classList.add(b.muted), o.textContent = t.description, r.appendChild(o);
|
|
1094
1152
|
}
|
|
1095
1153
|
}
|
|
1096
|
-
applyVariant(t,
|
|
1097
|
-
switch (t.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel),
|
|
1154
|
+
applyVariant(t, r) {
|
|
1155
|
+
switch (t.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), r) {
|
|
1098
1156
|
case "compact":
|
|
1099
1157
|
t.classList.add(b.fieldCompact);
|
|
1100
1158
|
break;
|
|
@@ -1109,7 +1167,7 @@ class O extends T {
|
|
|
1109
1167
|
}
|
|
1110
1168
|
}
|
|
1111
1169
|
}
|
|
1112
|
-
class
|
|
1170
|
+
class H extends D {
|
|
1113
1171
|
constructor(t) {
|
|
1114
1172
|
super();
|
|
1115
1173
|
p(this, "props");
|
|
@@ -1144,14 +1202,14 @@ class st extends T {
|
|
|
1144
1202
|
if (this.select) {
|
|
1145
1203
|
this.select.innerHTML = "";
|
|
1146
1204
|
for (const t of this.props.options) {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1205
|
+
const r = document.createElement("option");
|
|
1206
|
+
r.value = t.value, r.textContent = t.label, this.select.appendChild(r);
|
|
1149
1207
|
}
|
|
1150
1208
|
this.props.defaultValue && (this.select.value = this.props.defaultValue);
|
|
1151
1209
|
}
|
|
1152
1210
|
}
|
|
1153
1211
|
}
|
|
1154
|
-
class
|
|
1212
|
+
class Nt extends D {
|
|
1155
1213
|
constructor(t) {
|
|
1156
1214
|
super();
|
|
1157
1215
|
p(this, "props");
|
|
@@ -1174,59 +1232,59 @@ class Ot extends T {
|
|
|
1174
1232
|
this.props = t, this.button.textContent = t.label, this.button.disabled = !!t.disabled, t.variant === "secondary" ? (this.button.classList.add(b.buttonSecondary), this.button.classList.remove(b.buttonPrimary)) : (this.button.classList.add(b.buttonPrimary), this.button.classList.remove(b.buttonSecondary)), this.button.classList.toggle(b.buttonFull, !!t.fullWidth);
|
|
1175
1233
|
}
|
|
1176
1234
|
}
|
|
1177
|
-
class
|
|
1178
|
-
constructor(
|
|
1235
|
+
class Ue {
|
|
1236
|
+
constructor(e) {
|
|
1179
1237
|
p(this, "api");
|
|
1180
|
-
this.api =
|
|
1238
|
+
this.api = e;
|
|
1181
1239
|
}
|
|
1182
|
-
async $copy(
|
|
1183
|
-
switch (
|
|
1240
|
+
async $copy(e, t) {
|
|
1241
|
+
switch (e) {
|
|
1184
1242
|
case "txt": {
|
|
1185
|
-
const
|
|
1186
|
-
await navigator.clipboard.writeText(
|
|
1243
|
+
const r = this.api.toString(t);
|
|
1244
|
+
await navigator.clipboard.writeText(r);
|
|
1187
1245
|
break;
|
|
1188
1246
|
}
|
|
1189
1247
|
case "json": {
|
|
1190
|
-
const
|
|
1191
|
-
await navigator.clipboard.writeText(
|
|
1248
|
+
const r = this.api.toJSONString(t);
|
|
1249
|
+
await navigator.clipboard.writeText(r);
|
|
1192
1250
|
break;
|
|
1193
1251
|
}
|
|
1194
1252
|
case "svg": {
|
|
1195
|
-
const
|
|
1196
|
-
await navigator.clipboard.writeText(
|
|
1253
|
+
const r = this.api.toSVG(t);
|
|
1254
|
+
await navigator.clipboard.writeText(r);
|
|
1197
1255
|
break;
|
|
1198
1256
|
}
|
|
1199
1257
|
case "image":
|
|
1200
1258
|
await this.api.copyCanvas(t);
|
|
1201
1259
|
break;
|
|
1202
1260
|
default:
|
|
1203
|
-
throw new Error(`Clipboard not supported for ${
|
|
1261
|
+
throw new Error(`Clipboard not supported for ${e}`);
|
|
1204
1262
|
}
|
|
1205
1263
|
}
|
|
1206
1264
|
}
|
|
1207
|
-
class
|
|
1208
|
-
constructor(
|
|
1265
|
+
class Ge {
|
|
1266
|
+
constructor(e, t) {
|
|
1209
1267
|
p(this, "api");
|
|
1210
1268
|
p(this, "events");
|
|
1211
|
-
this.api =
|
|
1269
|
+
this.api = e, this.events = t;
|
|
1212
1270
|
}
|
|
1213
|
-
async $requestExport(
|
|
1214
|
-
this.events.$emit("export:request", { format:
|
|
1271
|
+
async $requestExport(e, t, r = {}) {
|
|
1272
|
+
this.events.$emit("export:request", { format: e });
|
|
1215
1273
|
try {
|
|
1216
|
-
const a = { onGIFProgress:
|
|
1217
|
-
var
|
|
1218
|
-
(
|
|
1219
|
-
} :
|
|
1220
|
-
var
|
|
1221
|
-
(
|
|
1222
|
-
} :
|
|
1223
|
-
await this._execute(
|
|
1274
|
+
const a = { onGIFProgress: r.onGIFProgress ? (o) => {
|
|
1275
|
+
var n;
|
|
1276
|
+
(n = r.onGIFProgress) == null || n.call(r, o), this.events.$emit("export:progress", { format: e, progress: o });
|
|
1277
|
+
} : e === "gif" ? (o) => this.events.$emit("export:progress", { format: e, progress: o }) : void 0, onVideoProgress: r.onVideoProgress ? (o) => {
|
|
1278
|
+
var n;
|
|
1279
|
+
(n = r.onVideoProgress) == null || n.call(r, o), this.events.$emit("export:progress", { format: e, progress: o });
|
|
1280
|
+
} : e === "video" ? (o) => this.events.$emit("export:progress", { format: e, progress: o }) : void 0 };
|
|
1281
|
+
await this._execute(e, t, a), this.events.$emit("export:success", { format: e });
|
|
1224
1282
|
} catch (a) {
|
|
1225
|
-
throw this.events.$emit("export:error", { format:
|
|
1283
|
+
throw this.events.$emit("export:error", { format: e, error: a }), a;
|
|
1226
1284
|
}
|
|
1227
1285
|
}
|
|
1228
|
-
_execute(
|
|
1229
|
-
switch (
|
|
1286
|
+
_execute(e, t, r) {
|
|
1287
|
+
switch (e) {
|
|
1230
1288
|
case "txt":
|
|
1231
1289
|
return Promise.resolve(this.api.saveStrings(t));
|
|
1232
1290
|
case "json":
|
|
@@ -1236,24 +1294,24 @@ class Pe {
|
|
|
1236
1294
|
case "svg":
|
|
1237
1295
|
return Promise.resolve(this.api.saveSVG(t));
|
|
1238
1296
|
case "gif": {
|
|
1239
|
-
const a = { ...t, onProgress:
|
|
1297
|
+
const a = { ...t, onProgress: r.onGIFProgress };
|
|
1240
1298
|
return this.api.saveGIF(a);
|
|
1241
1299
|
}
|
|
1242
1300
|
case "video": {
|
|
1243
|
-
const a = { ...t, onProgress:
|
|
1301
|
+
const a = { ...t, onProgress: r.onVideoProgress };
|
|
1244
1302
|
return this.api.saveWEBM(a);
|
|
1245
1303
|
}
|
|
1246
1304
|
}
|
|
1247
1305
|
}
|
|
1248
1306
|
}
|
|
1249
|
-
class
|
|
1250
|
-
constructor(
|
|
1307
|
+
class ze {
|
|
1308
|
+
constructor(e, t) {
|
|
1251
1309
|
p(this, "modifier");
|
|
1252
1310
|
p(this, "overlay");
|
|
1253
1311
|
p(this, "animationFrameId", null);
|
|
1254
1312
|
p(this, "handleUpdate");
|
|
1255
1313
|
p(this, "bound", !1);
|
|
1256
|
-
this.modifier =
|
|
1314
|
+
this.modifier = e, this.overlay = t, this.handleUpdate = () => this.scheduleUpdate();
|
|
1257
1315
|
}
|
|
1258
1316
|
scheduleUpdate() {
|
|
1259
1317
|
this.animationFrameId !== null && cancelAnimationFrame(this.animationFrameId), this.animationFrameId = requestAnimationFrame(() => this.update());
|
|
@@ -1263,20 +1321,20 @@ class Ae {
|
|
|
1263
1321
|
}
|
|
1264
1322
|
update() {
|
|
1265
1323
|
this.animationFrameId = null;
|
|
1266
|
-
const
|
|
1267
|
-
this.overlay.style.top = `${
|
|
1324
|
+
const e = this.modifier.canvas.getBoundingClientRect();
|
|
1325
|
+
this.overlay.style.top = `${e.top + window.scrollY + 8}px`, this.overlay.style.left = `${e.left + window.scrollX + 8}px`;
|
|
1268
1326
|
}
|
|
1269
1327
|
dispose() {
|
|
1270
1328
|
this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.bound && (window.removeEventListener("resize", this.handleUpdate), window.removeEventListener("scroll", this.handleUpdate, !0), this.bound = !1);
|
|
1271
1329
|
}
|
|
1272
1330
|
}
|
|
1273
|
-
const
|
|
1331
|
+
const Z = "textmode-export-number-input", je = `${Z}__field`, We = `${Z}__controls`, qe = `${Z}__control`, Yt = `${Z}__display`, at = `${Yt}--visible`, He = (i) => {
|
|
1274
1332
|
i.dispatchEvent(new Event("input", { bubbles: !0 })), i.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1275
|
-
},
|
|
1276
|
-
const
|
|
1277
|
-
return
|
|
1333
|
+
}, Ut = (i) => {
|
|
1334
|
+
const e = document.createElement("button");
|
|
1335
|
+
return e.type = "button", e.className = qe, e.textContent = i > 0 ? "▲" : "▼", e;
|
|
1278
1336
|
};
|
|
1279
|
-
class z extends
|
|
1337
|
+
class z extends D {
|
|
1280
1338
|
constructor(t) {
|
|
1281
1339
|
super();
|
|
1282
1340
|
p(this, "props");
|
|
@@ -1293,9 +1351,9 @@ class z extends T {
|
|
|
1293
1351
|
}
|
|
1294
1352
|
render() {
|
|
1295
1353
|
const t = document.createElement("div");
|
|
1296
|
-
t.className =
|
|
1297
|
-
const
|
|
1298
|
-
return
|
|
1354
|
+
t.className = Z, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = je, this.display = document.createElement("div"), this.display.className = Yt;
|
|
1355
|
+
const r = document.createElement("div");
|
|
1356
|
+
return r.className = We, this.incrementButton = Ut(1), this.decrementButton = Ut(-1), r.appendChild(this.incrementButton), r.appendChild(this.decrementButton), t.appendChild(this.input), t.appendChild(this.display), t.appendChild(r), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(t), this.updateDisplay(), t;
|
|
1299
1357
|
}
|
|
1300
1358
|
get inputElement() {
|
|
1301
1359
|
return this.input;
|
|
@@ -1314,29 +1372,29 @@ class z extends T {
|
|
|
1314
1372
|
this.clearHoldTimers(), (t = this.disabledObserver) == null || t.disconnect();
|
|
1315
1373
|
}
|
|
1316
1374
|
bindStepControls() {
|
|
1317
|
-
const t = (
|
|
1375
|
+
const t = (n) => () => {
|
|
1318
1376
|
if (this.input.disabled) return;
|
|
1319
1377
|
const d = this.input.value, l = this.input.getAttribute("step");
|
|
1320
|
-
if (l && l !== "any")
|
|
1378
|
+
if (l && l !== "any") n > 0 ? this.input.stepUp() : this.input.stepDown();
|
|
1321
1379
|
else {
|
|
1322
|
-
const h =
|
|
1380
|
+
const h = n > 0 ? 1 : -1, s = Number.parseFloat(this.input.value || "0"), c = Number.isFinite(s) ? s + h : h;
|
|
1323
1381
|
this.input.value = String(c);
|
|
1324
1382
|
}
|
|
1325
|
-
this.input.value !== d &&
|
|
1326
|
-
},
|
|
1327
|
-
if (this.suppressClickAfterPointer.get(
|
|
1383
|
+
this.input.value !== d && He(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
|
|
1384
|
+
}, r = t(1), a = t(-1), o = (n, d) => (l) => {
|
|
1385
|
+
if (this.suppressClickAfterPointer.get(n)) return this.suppressClickAfterPointer.set(n, !1), void l.preventDefault();
|
|
1328
1386
|
d();
|
|
1329
1387
|
};
|
|
1330
|
-
this.incrementButton.addEventListener("click", o(this.incrementButton,
|
|
1388
|
+
this.incrementButton.addEventListener("click", o(this.incrementButton, r)), this.decrementButton.addEventListener("click", o(this.decrementButton, a));
|
|
1331
1389
|
}
|
|
1332
1390
|
bindHoldBehavior() {
|
|
1333
|
-
const t = (
|
|
1391
|
+
const t = (r, a) => {
|
|
1334
1392
|
const o = a > 0 ? () => this.incrementButton.click() : () => this.decrementButton.click();
|
|
1335
|
-
|
|
1393
|
+
r.addEventListener("pointerdown", (l) => {
|
|
1336
1394
|
if (l.button === 0) {
|
|
1337
|
-
l.preventDefault(), this.suppressClickAfterPointer.set(
|
|
1395
|
+
l.preventDefault(), this.suppressClickAfterPointer.set(r, !0), this.activePointerId = l.pointerId;
|
|
1338
1396
|
try {
|
|
1339
|
-
|
|
1397
|
+
r.setPointerCapture(l.pointerId);
|
|
1340
1398
|
} catch {
|
|
1341
1399
|
}
|
|
1342
1400
|
o(), this.holdTimeoutId = window.setTimeout(() => {
|
|
@@ -1344,18 +1402,18 @@ class z extends T {
|
|
|
1344
1402
|
}, 380);
|
|
1345
1403
|
}
|
|
1346
1404
|
});
|
|
1347
|
-
const
|
|
1405
|
+
const n = () => {
|
|
1348
1406
|
if (this.activePointerId !== void 0) {
|
|
1349
1407
|
try {
|
|
1350
|
-
|
|
1408
|
+
r.releasePointerCapture(this.activePointerId);
|
|
1351
1409
|
} catch {
|
|
1352
1410
|
}
|
|
1353
1411
|
this.activePointerId = void 0;
|
|
1354
1412
|
}
|
|
1355
1413
|
}, d = () => {
|
|
1356
|
-
this.clearHoldTimers(),
|
|
1414
|
+
this.clearHoldTimers(), n();
|
|
1357
1415
|
};
|
|
1358
|
-
|
|
1416
|
+
r.addEventListener("pointerup", d), r.addEventListener("pointerleave", d), r.addEventListener("pointercancel", d);
|
|
1359
1417
|
};
|
|
1360
1418
|
t(this.incrementButton, 1), t(this.decrementButton, -1);
|
|
1361
1419
|
}
|
|
@@ -1366,36 +1424,36 @@ class z extends T {
|
|
|
1366
1424
|
this.input.addEventListener("input", t), this.input.addEventListener("change", t);
|
|
1367
1425
|
}
|
|
1368
1426
|
observeDisabledState(t) {
|
|
1369
|
-
const
|
|
1427
|
+
const r = () => {
|
|
1370
1428
|
const a = this.input.disabled;
|
|
1371
|
-
this.incrementButton.disabled = a, this.decrementButton.disabled = a, t.classList.toggle("is-disabled", a), a ? (this.display.classList.remove(
|
|
1429
|
+
this.incrementButton.disabled = a, this.decrementButton.disabled = a, t.classList.toggle("is-disabled", a), a ? (this.display.classList.remove(at), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor")) : this.updateDisplay();
|
|
1372
1430
|
};
|
|
1373
|
-
typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(
|
|
1431
|
+
typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(r), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), r();
|
|
1374
1432
|
}
|
|
1375
1433
|
updateDisplay() {
|
|
1376
1434
|
const t = this.props.formatDisplay;
|
|
1377
|
-
if (!t) return this.display.textContent = "", this.display.classList.remove(
|
|
1378
|
-
const
|
|
1379
|
-
o ? (this.display.textContent = o, this.display.classList.add(
|
|
1435
|
+
if (!t) return this.display.textContent = "", this.display.classList.remove(at), this.input.style.removeProperty("color"), void this.input.style.removeProperty("caretColor");
|
|
1436
|
+
const r = this.input.value, a = Number.parseFloat(r), o = t(Number.isFinite(a) ? a : Number.NaN, r, this.input);
|
|
1437
|
+
o ? (this.display.textContent = o, this.display.classList.add(at), this.input.style.color = "transparent", this.input.style.caretColor = "#f8fafc") : (this.display.textContent = "", this.display.classList.remove(at), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor"));
|
|
1380
1438
|
}
|
|
1381
1439
|
clearHoldTimers() {
|
|
1382
1440
|
this.holdTimeoutId !== void 0 && (window.clearTimeout(this.holdTimeoutId), this.holdTimeoutId = void 0), this.holdIntervalId !== void 0 && (window.clearInterval(this.holdIntervalId), this.holdIntervalId = void 0);
|
|
1383
1441
|
}
|
|
1384
1442
|
}
|
|
1385
|
-
class
|
|
1386
|
-
constructor(t = "stack",
|
|
1443
|
+
class Q extends D {
|
|
1444
|
+
constructor(t = "stack", r = []) {
|
|
1387
1445
|
super();
|
|
1388
1446
|
p(this, "variant");
|
|
1389
1447
|
p(this, "additionalClasses");
|
|
1390
|
-
this.variant = t, this.additionalClasses =
|
|
1448
|
+
this.variant = t, this.additionalClasses = r;
|
|
1391
1449
|
}
|
|
1392
1450
|
render() {
|
|
1393
|
-
const t = document.createElement("div"),
|
|
1394
|
-
return t.classList.add(...
|
|
1451
|
+
const t = document.createElement("div"), r = [this.variant === "stack" ? b.stack : void 0, this.variant === "stackDense" ? b.stackDense : void 0, this.variant === "stackCompact" ? b.stackCompact : void 0, this.variant === "row" ? b.row : void 0, this.variant === "section" ? b.section : void 0, ...this.additionalClasses].filter(Boolean);
|
|
1452
|
+
return t.classList.add(...r), t;
|
|
1395
1453
|
}
|
|
1396
1454
|
}
|
|
1397
|
-
const
|
|
1398
|
-
class
|
|
1455
|
+
const Gt = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
|
|
1456
|
+
class Qt extends D {
|
|
1399
1457
|
constructor(t) {
|
|
1400
1458
|
super();
|
|
1401
1459
|
p(this, "props");
|
|
@@ -1408,17 +1466,17 @@ class Wt extends T {
|
|
|
1408
1466
|
const t = document.createElement("span");
|
|
1409
1467
|
return t.classList.add(b.statusTitle), t.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(b.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(t), this.container.appendChild(this.messageElement), this.container;
|
|
1410
1468
|
}
|
|
1411
|
-
setMessage(t,
|
|
1412
|
-
this.messageElement.textContent = t, this.applyVariant(
|
|
1469
|
+
setMessage(t, r = "neutral") {
|
|
1470
|
+
this.messageElement.textContent = t, this.applyVariant(r);
|
|
1413
1471
|
}
|
|
1414
1472
|
onUpdate(t) {
|
|
1415
1473
|
this.props = t, this.setMessage(t.message, t.variant ?? "neutral");
|
|
1416
1474
|
}
|
|
1417
1475
|
applyVariant(t) {
|
|
1418
|
-
this.messageElement.classList.remove(...Object.values(
|
|
1476
|
+
this.messageElement.classList.remove(...Object.values(Gt)), this.messageElement.classList.add(Gt[t]);
|
|
1419
1477
|
}
|
|
1420
1478
|
}
|
|
1421
|
-
class J extends
|
|
1479
|
+
class J extends D {
|
|
1422
1480
|
constructor(t) {
|
|
1423
1481
|
super();
|
|
1424
1482
|
p(this, "_config");
|
|
@@ -1437,31 +1495,31 @@ class J extends T {
|
|
|
1437
1495
|
}
|
|
1438
1496
|
}
|
|
1439
1497
|
const j = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
|
|
1440
|
-
class
|
|
1498
|
+
class vt extends J {
|
|
1441
1499
|
constructor(t) {
|
|
1442
1500
|
super(t);
|
|
1443
1501
|
p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(j.frameCount), attributes: { min: "1", max: "600", step: "1" } })));
|
|
1444
1502
|
p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(j.frameRate), attributes: { min: "1", max: "60", step: "1" } })));
|
|
1445
1503
|
p(this, "scaleInput", this._manageComponent(new z({ defaultValue: String(j.scale), attributes: { min: "0.1", max: "8", step: "0.1" } })));
|
|
1446
|
-
p(this, "repeatInput", this._manageComponent(new z({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t,
|
|
1447
|
-
p(this, "status", this._manageComponent(new
|
|
1504
|
+
p(this, "repeatInput", this._manageComponent(new z({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t, r) => Number.isFinite(t) ? t === 0 ? "∞" : null : r.trim() === "" ? null : r })));
|
|
1505
|
+
p(this, "status", this._manageComponent(new Qt({ title: "status", message: "ready to record", variant: "neutral", context: "gif" })));
|
|
1448
1506
|
p(this, "recordingState", "idle");
|
|
1449
1507
|
}
|
|
1450
1508
|
render() {
|
|
1451
1509
|
const t = document.createElement("div");
|
|
1452
1510
|
t.classList.add(b.stack);
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1455
|
-
const a = new
|
|
1456
|
-
a.mount(
|
|
1457
|
-
const o = new
|
|
1458
|
-
o.mount(
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
const d = new
|
|
1462
|
-
d.mount(
|
|
1463
|
-
const l = new
|
|
1464
|
-
return l.mount(
|
|
1511
|
+
const r = new Q("row");
|
|
1512
|
+
r.mount(t);
|
|
1513
|
+
const a = new T({ label: "number of frames", labelFor: "textmode-export-gif-frame-count", variant: "dense" });
|
|
1514
|
+
a.mount(r.root), this.frameCountInput.mount(a.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
|
|
1515
|
+
const o = new T({ label: "frame rate (fps)", labelFor: "textmode-export-gif-frame-rate", variant: "dense" });
|
|
1516
|
+
o.mount(r.root), this.frameRateInput.mount(o.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
|
|
1517
|
+
const n = new Q("row");
|
|
1518
|
+
n.mount(t);
|
|
1519
|
+
const d = new T({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
|
|
1520
|
+
d.mount(n.root), this.scaleInput.mount(d.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
|
|
1521
|
+
const l = new T({ label: "loop count", labelFor: "textmode-export-gif-repeat", variant: "dense" });
|
|
1522
|
+
return l.mount(n.root), this.repeatInput.mount(l.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(t), t;
|
|
1465
1523
|
}
|
|
1466
1524
|
getOptions() {
|
|
1467
1525
|
const t = this._config.defaultOptions ?? {};
|
|
@@ -1471,33 +1529,33 @@ class bt extends J {
|
|
|
1471
1529
|
this.recordingState = "idle", this.applyDefaults(), this.setRecordingState("idle");
|
|
1472
1530
|
}
|
|
1473
1531
|
validate() {
|
|
1474
|
-
const t = Number.parseInt(this.frameCountInput.value, 10),
|
|
1475
|
-
return Number.isFinite(t) && t > 0 && Number.isFinite(
|
|
1532
|
+
const t = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseInt(this.frameRateInput.value, 10), a = Number.parseFloat(this.scaleInput.value);
|
|
1533
|
+
return Number.isFinite(t) && t > 0 && Number.isFinite(r) && r > 0 && Number.isFinite(a) && a > 0;
|
|
1476
1534
|
}
|
|
1477
1535
|
isRecording() {
|
|
1478
1536
|
return this.recordingState === "recording" || this.recordingState === "encoding";
|
|
1479
1537
|
}
|
|
1480
|
-
setRecordingState(t,
|
|
1538
|
+
setRecordingState(t, r) {
|
|
1481
1539
|
this.recordingState = t;
|
|
1482
1540
|
const a = t === "recording" || t === "encoding";
|
|
1483
1541
|
switch (this.frameCountInput.inputElement.disabled = a, this.frameRateInput.inputElement.disabled = a, this.scaleInput.inputElement.disabled = a, this.repeatInput.inputElement.disabled = a, t) {
|
|
1484
1542
|
case "recording":
|
|
1485
|
-
if (
|
|
1486
|
-
const o =
|
|
1487
|
-
this.status.setMessage(`recording ${o}/${
|
|
1543
|
+
if (r != null && r.totalFrames) {
|
|
1544
|
+
const o = r.frameIndex ?? 0;
|
|
1545
|
+
this.status.setMessage(`recording ${o}/${r.totalFrames}`, "active");
|
|
1488
1546
|
} else this.status.setMessage("recording…", "active");
|
|
1489
1547
|
break;
|
|
1490
1548
|
case "encoding":
|
|
1491
|
-
if (
|
|
1492
|
-
const o =
|
|
1493
|
-
this.status.setMessage(`encoding ${o}/${
|
|
1549
|
+
if (r != null && r.totalFrames) {
|
|
1550
|
+
const o = r.frameIndex ?? 0;
|
|
1551
|
+
this.status.setMessage(`encoding ${o}/${r.totalFrames}`, "active");
|
|
1494
1552
|
} else this.status.setMessage("encoding…", "active");
|
|
1495
1553
|
break;
|
|
1496
1554
|
case "completed":
|
|
1497
1555
|
this.status.setMessage("GIF saved successfully", "active");
|
|
1498
1556
|
break;
|
|
1499
1557
|
case "error":
|
|
1500
|
-
this.status.setMessage((
|
|
1558
|
+
this.status.setMessage((r == null ? void 0 : r.message) ?? "failed to export GIF", "alert");
|
|
1501
1559
|
break;
|
|
1502
1560
|
default:
|
|
1503
1561
|
this.status.setMessage("ready to record", "neutral");
|
|
@@ -1506,29 +1564,29 @@ class bt extends J {
|
|
|
1506
1564
|
handleProgress(t) {
|
|
1507
1565
|
if (t.state !== "recording" && t.state !== "encoding" || !t.totalFrames) t.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : t.state === "error" && this.status.setMessage(t.message ?? "failed to export GIF", "alert");
|
|
1508
1566
|
else {
|
|
1509
|
-
const
|
|
1510
|
-
this.status.setMessage(`${
|
|
1567
|
+
const r = t.state === "recording" ? "recording" : "encoding";
|
|
1568
|
+
this.status.setMessage(`${r} ${t.frameIndex ?? 0}/${t.totalFrames}`, "active");
|
|
1511
1569
|
}
|
|
1512
1570
|
}
|
|
1513
1571
|
applyDefaults() {
|
|
1514
|
-
const t = this._config.defaultOptions ?? {},
|
|
1515
|
-
this.frameCountInput.value = String(
|
|
1572
|
+
const t = this._config.defaultOptions ?? {}, r = t.frameCount ?? j.frameCount, a = t.frameRate ?? j.frameRate, o = t.scale ?? j.scale, n = t.repeat ?? j.repeat;
|
|
1573
|
+
this.frameCountInput.value = String(r), this.frameRateInput.value = String(a), this.scaleInput.value = String(o), this.repeatInput.value = String(n), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
|
|
1516
1574
|
}
|
|
1517
|
-
safeParseInt(t,
|
|
1575
|
+
safeParseInt(t, r) {
|
|
1518
1576
|
const a = Number.parseInt(t, 10);
|
|
1519
|
-
return Number.isFinite(a) ? a :
|
|
1577
|
+
return Number.isFinite(a) ? a : r;
|
|
1520
1578
|
}
|
|
1521
|
-
safeParseFloat(t,
|
|
1579
|
+
safeParseFloat(t, r) {
|
|
1522
1580
|
const a = Number.parseFloat(t);
|
|
1523
|
-
return Number.isFinite(a) ? a :
|
|
1581
|
+
return Number.isFinite(a) ? a : r;
|
|
1524
1582
|
}
|
|
1525
1583
|
}
|
|
1526
|
-
const
|
|
1527
|
-
if (typeof i != "string" || i.length === 0) return
|
|
1584
|
+
const dt = "textmode-export-range-input", Xe = `${dt}__field`, Je = `${dt}__tooltip`, gt = `${dt}__tooltip--visible`, ot = (i, e) => {
|
|
1585
|
+
if (typeof i != "string" || i.length === 0) return e;
|
|
1528
1586
|
const t = Number.parseFloat(i);
|
|
1529
|
-
return Number.isFinite(t) ? t :
|
|
1530
|
-
},
|
|
1531
|
-
class
|
|
1587
|
+
return Number.isFinite(t) ? t : e;
|
|
1588
|
+
}, Ye = (i, e, t) => Math.min(t, Math.max(e, i));
|
|
1589
|
+
class Qe extends D {
|
|
1532
1590
|
constructor(t) {
|
|
1533
1591
|
super();
|
|
1534
1592
|
p(this, "props");
|
|
@@ -1545,7 +1603,7 @@ class Ge extends T {
|
|
|
1545
1603
|
}
|
|
1546
1604
|
render() {
|
|
1547
1605
|
const t = document.createElement("div");
|
|
1548
|
-
return t.className =
|
|
1606
|
+
return t.className = dt, this.input = document.createElement("input"), this.input.type = "range", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Xe, this.tooltip = document.createElement("div"), this.tooltip.className = Je, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
|
|
1549
1607
|
}
|
|
1550
1608
|
get inputElement() {
|
|
1551
1609
|
return this.input;
|
|
@@ -1557,8 +1615,8 @@ class Ge extends T {
|
|
|
1557
1615
|
this.input.value = t, this.updateTooltip();
|
|
1558
1616
|
}
|
|
1559
1617
|
_onDestroy() {
|
|
1560
|
-
var t,
|
|
1561
|
-
(t = this.disabledObserver) == null || t.disconnect(), (
|
|
1618
|
+
var t, r;
|
|
1619
|
+
(t = this.disabledObserver) == null || t.disconnect(), (r = this.resizeObserver) == null || r.disconnect();
|
|
1562
1620
|
}
|
|
1563
1621
|
bindEvents(t) {
|
|
1564
1622
|
this.input.addEventListener("pointerenter", () => {
|
|
@@ -1583,27 +1641,27 @@ class Ge extends T {
|
|
|
1583
1641
|
this.activePointerId = void 0;
|
|
1584
1642
|
}
|
|
1585
1643
|
});
|
|
1586
|
-
const
|
|
1644
|
+
const r = () => {
|
|
1587
1645
|
this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.hoverActive = this.input.matches(":hover"), this.releasePointerCapture(), this.refreshTooltipVisibility();
|
|
1588
1646
|
};
|
|
1589
|
-
this.input.addEventListener("pointerup",
|
|
1647
|
+
this.input.addEventListener("pointerup", r), this.input.addEventListener("pointercancel", r), this.input.addEventListener("lostpointercapture", r), this.input.addEventListener("input", () => {
|
|
1590
1648
|
(this.hoverActive || this.focusActive || this.pointerActive) && this.updateTooltip(), this.props.defaultValue = this.input.value;
|
|
1591
1649
|
}), this.input.addEventListener("change", () => {
|
|
1592
1650
|
this.pointerActive || this.updateTooltip(), this.props.defaultValue = this.input.value;
|
|
1593
1651
|
}), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
|
|
1594
|
-
this.tooltip.classList.contains(
|
|
1652
|
+
this.tooltip.classList.contains(gt) && this.updateTooltipPosition();
|
|
1595
1653
|
}), this.resizeObserver.observe(t));
|
|
1596
1654
|
}
|
|
1597
1655
|
refreshTooltipVisibility() {
|
|
1598
1656
|
const t = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
|
|
1599
|
-
t && this.updateTooltip(), this.tooltip.classList.toggle(
|
|
1657
|
+
t && this.updateTooltip(), this.tooltip.classList.toggle(gt, t);
|
|
1600
1658
|
}
|
|
1601
1659
|
syncDisabledState(t) {
|
|
1602
|
-
const
|
|
1660
|
+
const r = () => {
|
|
1603
1661
|
const a = this.input.disabled;
|
|
1604
|
-
t.classList.toggle("is-disabled", a), a && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(
|
|
1662
|
+
t.classList.toggle("is-disabled", a), a && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(gt));
|
|
1605
1663
|
};
|
|
1606
|
-
typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(
|
|
1664
|
+
typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(r), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), r();
|
|
1607
1665
|
}
|
|
1608
1666
|
releasePointerCapture() {
|
|
1609
1667
|
if (this.activePointerId !== void 0) {
|
|
@@ -1618,81 +1676,81 @@ class Ge extends T {
|
|
|
1618
1676
|
this.updateTooltipContent(), this.updateTooltipPosition();
|
|
1619
1677
|
}
|
|
1620
1678
|
updateTooltipContent() {
|
|
1621
|
-
const t = this.props.formatValue ?? ((a) => `${a}`),
|
|
1622
|
-
this.tooltip.textContent = t(
|
|
1679
|
+
const t = this.props.formatValue ?? ((a) => `${a}`), r = this.getCurrentValue();
|
|
1680
|
+
this.tooltip.textContent = t(r, this.input);
|
|
1623
1681
|
}
|
|
1624
1682
|
updateTooltipPosition() {
|
|
1625
|
-
const t = this.getMin(),
|
|
1626
|
-
this.tooltip.style.left = 100 *
|
|
1683
|
+
const t = this.getMin(), r = this.getMax(), a = Ye(this.getCurrentValue(), t, r), o = r - t, n = o === 0 ? 0 : (a - t) / o;
|
|
1684
|
+
this.tooltip.style.left = 100 * n + "%";
|
|
1627
1685
|
}
|
|
1628
1686
|
getMin() {
|
|
1629
|
-
return
|
|
1687
|
+
return ot(this.input.min, 0);
|
|
1630
1688
|
}
|
|
1631
1689
|
getMax() {
|
|
1632
|
-
return
|
|
1690
|
+
return ot(this.input.max, 100);
|
|
1633
1691
|
}
|
|
1634
1692
|
getCurrentValue() {
|
|
1635
|
-
return
|
|
1693
|
+
return ot(this.input.value, ot(this.props.defaultValue, 0));
|
|
1636
1694
|
}
|
|
1637
1695
|
}
|
|
1638
|
-
function
|
|
1696
|
+
function Ze(i) {
|
|
1639
1697
|
if (!Number.isFinite(i)) return "default quality";
|
|
1640
|
-
const
|
|
1641
|
-
return
|
|
1698
|
+
const e = Math.max(0, Math.min(1, i));
|
|
1699
|
+
return e >= 0.995 ? "near-lossless" : e >= 0.98 ? "maximum detail" : e >= 0.88 ? "ultra quality" : e >= 0.7 ? "high quality" : e >= 0.5 ? "balanced" : e >= 0.25 ? "compact" : e >= 0.1 ? "lightweight" : "draft";
|
|
1642
1700
|
}
|
|
1643
|
-
function
|
|
1644
|
-
return `${
|
|
1701
|
+
function Ke(i) {
|
|
1702
|
+
return `${Ze(i)} (quality ≈ ${i.toFixed(3)})`;
|
|
1645
1703
|
}
|
|
1646
|
-
class
|
|
1704
|
+
class yt extends J {
|
|
1647
1705
|
constructor(t) {
|
|
1648
1706
|
super(t);
|
|
1649
1707
|
p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (t) => Number.isFinite(t) ? `${t} fps` : null })));
|
|
1650
1708
|
p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } })));
|
|
1651
|
-
p(this, "qualityInput", this._manageComponent(new
|
|
1652
|
-
p(this, "status", this._manageComponent(new
|
|
1709
|
+
p(this, "qualityInput", this._manageComponent(new Qe({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => Ke(t) })));
|
|
1710
|
+
p(this, "status", this._manageComponent(new Qt({ title: "status", message: "ready to record", variant: "neutral", context: "video" })));
|
|
1653
1711
|
p(this, "recordingState", "idle");
|
|
1654
1712
|
}
|
|
1655
1713
|
render() {
|
|
1656
1714
|
const t = document.createElement("div");
|
|
1657
1715
|
t.classList.add(b.stack);
|
|
1658
|
-
const
|
|
1659
|
-
|
|
1660
|
-
const a = new
|
|
1661
|
-
a.mount(
|
|
1662
|
-
const o = new
|
|
1663
|
-
o.mount(
|
|
1664
|
-
const
|
|
1665
|
-
return
|
|
1716
|
+
const r = new Q("row");
|
|
1717
|
+
r.mount(t);
|
|
1718
|
+
const a = new T({ label: "number of frames", labelFor: "textmode-export-video-frame-count", variant: "compact" });
|
|
1719
|
+
a.mount(r.root), this.frameCountInput.mount(a.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
|
|
1720
|
+
const o = new T({ label: "frame rate (fps)", labelFor: "textmode-export-video-frame-rate", variant: "compact" });
|
|
1721
|
+
o.mount(r.root), this.frameRateInput.mount(o.root), this.frameRateInput.inputElement.id = "textmode-export-video-frame-rate";
|
|
1722
|
+
const n = new T({ label: "quality", labelFor: "textmode-export-video-quality", variant: "full" });
|
|
1723
|
+
return n.mount(t), this.qualityInput.mount(n.root), this.qualityInput.inputElement.id = "textmode-export-video-quality", this.status.mount(t), t;
|
|
1666
1724
|
}
|
|
1667
1725
|
getOptions() {
|
|
1668
|
-
const t = this._config.defaultOptions ?? {},
|
|
1669
|
-
return { frameCount: Number.isFinite(
|
|
1726
|
+
const t = this._config.defaultOptions ?? {}, r = Number.parseInt(this.frameCountInput.value, 10), a = Number.parseFloat(this.frameRateInput.value), o = Number.parseFloat(this.qualityInput.value);
|
|
1727
|
+
return { frameCount: Number.isFinite(r) ? r : t.frameCount ?? 480, frameRate: Number.isFinite(a) ? a : t.frameRate ?? 60, quality: Number.isFinite(o) ? o : t.quality ?? 0.7 };
|
|
1670
1728
|
}
|
|
1671
1729
|
reset() {
|
|
1672
1730
|
this.recordingState = "idle", this.applyDefaults(), this.status.setMessage("ready to record", "neutral");
|
|
1673
1731
|
}
|
|
1674
1732
|
validate() {
|
|
1675
|
-
const t = Number.parseInt(this.frameCountInput.value, 10),
|
|
1676
|
-
return Number.isFinite(t) && t >= 1 && Number.isFinite(
|
|
1733
|
+
const t = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseFloat(this.frameRateInput.value);
|
|
1734
|
+
return Number.isFinite(t) && t >= 1 && Number.isFinite(r) && r >= 1;
|
|
1677
1735
|
}
|
|
1678
1736
|
isRecording() {
|
|
1679
1737
|
return this.recordingState === "recording";
|
|
1680
1738
|
}
|
|
1681
|
-
setRecordingState(t,
|
|
1739
|
+
setRecordingState(t, r) {
|
|
1682
1740
|
this.recordingState = t;
|
|
1683
1741
|
const a = t === "recording";
|
|
1684
|
-
this.frameCountInput.inputElement.disabled = a, this.frameRateInput.inputElement.disabled = a, this.qualityInput.inputElement.disabled = a, this.syncStatus(t,
|
|
1742
|
+
this.frameCountInput.inputElement.disabled = a, this.frameRateInput.inputElement.disabled = a, this.qualityInput.inputElement.disabled = a, this.syncStatus(t, r);
|
|
1685
1743
|
}
|
|
1686
1744
|
handleProgress(t) {
|
|
1687
1745
|
this.syncStatus(t.state, t);
|
|
1688
1746
|
}
|
|
1689
|
-
syncStatus(t,
|
|
1747
|
+
syncStatus(t, r) {
|
|
1690
1748
|
switch (t) {
|
|
1691
1749
|
case "recording": {
|
|
1692
|
-
const a = (
|
|
1750
|
+
const a = (r == null ? void 0 : r.frameIndex) ?? 0, o = (r == null ? void 0 : r.totalFrames) ?? this.resolvePlannedFrameCount();
|
|
1693
1751
|
if (o) {
|
|
1694
|
-
const
|
|
1695
|
-
this.status.setMessage(`recording ${
|
|
1752
|
+
const n = Math.min(Math.max(0, Math.round(a)), o);
|
|
1753
|
+
this.status.setMessage(`recording ${n}/${o} frames`, "active");
|
|
1696
1754
|
} else this.status.setMessage(`recording ${Math.max(0, Math.round(a))} frames`, "active");
|
|
1697
1755
|
break;
|
|
1698
1756
|
}
|
|
@@ -1700,7 +1758,7 @@ class vt extends J {
|
|
|
1700
1758
|
this.status.setMessage("saved to disk", "active");
|
|
1701
1759
|
break;
|
|
1702
1760
|
case "error":
|
|
1703
|
-
this.status.setMessage(
|
|
1761
|
+
this.status.setMessage(r != null && r.message ? `error: ${r.message}` : "recording failed", "alert");
|
|
1704
1762
|
break;
|
|
1705
1763
|
default:
|
|
1706
1764
|
this.status.setMessage("ready to record", "neutral");
|
|
@@ -1711,13 +1769,16 @@ class vt extends J {
|
|
|
1711
1769
|
return Number.isFinite(t) && t > 0 ? Math.round(t) : void 0;
|
|
1712
1770
|
}
|
|
1713
1771
|
applyDefaults() {
|
|
1714
|
-
const t = this._config.defaultOptions ?? {},
|
|
1715
|
-
this.frameCountInput.value = String(
|
|
1772
|
+
const t = this._config.defaultOptions ?? {}, r = t.frameCount ?? 480, a = t.frameRate ?? 60, o = t.quality ?? 0.7;
|
|
1773
|
+
this.frameCountInput.value = String(r), this.frameRateInput.value = String(a), this.qualityInput.value = String(o), this.frameCountInput.refresh(), this.frameRateInput.refresh();
|
|
1716
1774
|
}
|
|
1717
1775
|
}
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1720
|
-
|
|
1776
|
+
const tr = `@layer textmode-export-overlay{.textmode-export-overlay{--overlay-bg: rgba(20, 20, 20, .8);--overlay-surface: rgba(40, 40, 40, .9);--overlay-border: rgba(255, 255, 255, .14);--overlay-border-strong: rgba(255, 255, 255, .2);--overlay-border-focus: rgba(160, 160, 160, .6);--overlay-focus-shadow: 0 0 0 1px rgba(140, 140, 140, .28);--overlay-text: #ffffff;--overlay-muted: rgba(200, 200, 200, .74);--overlay-radius: .75rem;--overlay-stack-gap: .55rem;position:absolute;top:0;left:0;display:flex;flex-direction:column;gap:var(--overlay-stack-gap);min-width:236px;max-width:236px;padding:.65rem .8rem;background:var(--overlay-bg);color:var(--overlay-text);border-radius:var(--overlay-radius);border:1px solid var(--overlay-border);box-shadow:0 12px 28px #0000004d;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:.82rem;line-height:1.35;pointer-events:auto;z-index:2147483647}.textmode-export-overlay *{box-sizing:border-box}.textmode-export-overlay__header{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__header-title-row{display:flex;align-items:center;justify-content:space-between;gap:.4rem}.textmode-export-overlay__header-links{display:inline-flex;align-items:center;gap:.3rem}.textmode-export-overlay__support-link{display:inline-flex;align-items:center;justify-content:center;padding:.2rem;border-radius:.45rem;border:1px solid transparent;color:#d7d7d7d1;background:transparent;text-decoration:none;line-height:0;transition:background .18s ease,color .18s ease,transform .18s ease,border-color .18s ease}.textmode-export-overlay__support-link:hover{color:#fff;background:#5a5a5a4d;border-color:#c8c8c824}.textmode-export-overlay__support-link:focus-visible{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-overlay__support-icon,.textmode-export-overlay__link-icon{display:block;width:1rem;height:1rem}.textmode-export-overlay__stack{display:flex;flex-direction:column;gap:var(--overlay-stack-gap)}.textmode-export-overlay__stack--dense{gap:.3rem}.textmode-export-overlay__stack--compact{gap:.45rem}.textmode-export-overlay__section{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__title{font-size:.92rem;font-weight:600}.textmode-export-overlay__divider{width:100%;height:1px;background:#ffffff29;margin-top:.25rem}.textmode-export-overlay__label{font-weight:500;opacity:.9}.textmode-export-overlay__checkbox{display:flex;align-items:center;gap:.5rem}.textmode-export-overlay__checkbox input[type=checkbox]{width:1rem;height:1rem;accent-color:rgba(100,100,100,.9)}.textmode-export-overlay__row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:flex-start;width:100%}.textmode-export-overlay__field{display:flex;flex-direction:column;gap:.3rem;flex:1 1 120px;min-width:120px}.textmode-export-overlay__field--compact{flex:1 1 100px;min-width:100px}.textmode-export-overlay__field--dense{flex:1 1 90px;min-width:90px}.textmode-export-overlay__field--channel{flex:1 1 0;min-width:0}.textmode-export-overlay__field--full{width:100%;flex:1 1 100%}.textmode-export-overlay__input,.textmode-export-overlay select.textmode-export-overlay__input,.textmode-export-overlay input.textmode-export-overlay__input{width:100%;padding:.35rem .5rem;border-radius:.4rem;border:1px solid var(--overlay-border-strong);background:var(--overlay-surface);color:var(--overlay-text);font:inherit;line-height:1.35;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.textmode-export-overlay select.textmode-export-overlay__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(200, 200, 200, 0.74)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .5rem center;background-size:1rem;padding-right:2rem}.textmode-export-overlay__input:focus{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow);background:#2d2f42eb}.textmode-export-overlay__input::placeholder{color:var(--overlay-muted);opacity:.7}.textmode-export-overlay__muted{font-size:.75rem;opacity:.7;display:block}.textmode-export-overlay__button{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;border-radius:.45rem;border:none;font-weight:600;padding:.45rem .7rem;cursor:pointer;transition:background .2s ease,transform .2s ease,box-shadow .2s ease}.textmode-export-overlay__button--primary{background:#505050;color:#fff}.textmode-export-overlay__button--secondary{background:#606060;color:#fff}.textmode-export-overlay__button--full{width:100%}.textmode-export-overlay__button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 18px #00000073}.textmode-export-overlay__button--primary:hover:not(:disabled){background:#404040}.textmode-export-overlay__button--secondary:hover:not(:disabled){background:#4a4a4a}.textmode-export-overlay__button:disabled{cursor:default;opacity:.55;transform:none;box-shadow:none}.textmode-export-overlay__status{display:flex;flex-direction:column;gap:.25rem;padding:.45rem .55rem;border-radius:.45rem;border:1px solid rgba(110,110,110,.22);background:#4646462e}.textmode-export-overlay__status--gif{background:#5050501f;border-color:#78787840}.textmode-export-overlay__status--video{background:#4646461f;border-color:#6e6e6e40}.textmode-export-overlay__status-title{font-weight:600;font-size:.75rem;opacity:.85;text-transform:uppercase;letter-spacing:.04em}.textmode-export-overlay__status-value{font-size:.82rem;color:#dedede;transition:color .18s ease}.textmode-export-overlay__status-value--neutral{color:#cfcfcf}.textmode-export-overlay__status-value--active{color:#f5f5f5}.textmode-export-overlay__status-value--alert{color:#b8b8b8}.textmode-export-number-input,.textmode-export-overlay .textmode-export-number-input{display:flex;align-items:stretch;width:100%;background:var(--overlay-surface);border:1px solid var(--overlay-border-strong);border-radius:.4rem;overflow:hidden;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;position:relative}.textmode-export-number-input:focus-within{border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-number-input.is-disabled{opacity:.55}.textmode-export-number-input__field{flex:1 1 auto;min-width:0;border:none;background:transparent;color:var(--overlay-text);font:inherit;padding:.35rem .5rem;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.textmode-export-number-input__field::-webkit-outer-spin-button,.textmode-export-number-input__field::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.textmode-export-number-input__field:focus{outline:none}.textmode-export-number-input__controls{display:flex;flex-direction:column;border-left:1px solid rgba(255,255,255,.12);min-width:1.6rem}.textmode-export-number-input__control{display:flex;align-items:center;justify-content:center;width:100%;flex:1;border:none;background:#32323299;color:#d0d0d0;font-size:.68rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease;padding:0}.textmode-export-number-input__control:hover:not(:disabled){background:#5a5a5ad9;color:#fff}.textmode-export-number-input__control:disabled{cursor:default;opacity:.4;background:#28282880;color:#c8c8c866}.textmode-export-number-input:focus-within .textmode-export-number-input__control{background:#3c3c3cbf;color:#e8e8e8}.textmode-export-number-input__display{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:.4rem .55rem;pointer-events:none;color:#f8fafc;opacity:0;transition:opacity .14s ease}.textmode-export-number-input__display--visible{opacity:1}.textmode-export-range-input{position:relative;width:100%}.textmode-export-range-input.is-disabled{opacity:.55}.textmode-export-range-input__field{width:100%;height:1.4rem;padding:0;margin:0;background:transparent;cursor:pointer;-moz-appearance:none;appearance:none;-webkit-appearance:none}.textmode-export-range-input__field::-webkit-slider-thumb{width:12px;height:12px;margin-top:-3.5px;-webkit-appearance:none;border-radius:50%;background:#a0a0a0;border:2px solid #303030;box-shadow:0 0 0 2px #00000059}.textmode-export-range-input__field::-webkit-slider-runnable-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__field::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:#a0a0a0;border:2px solid #303030;margin-top:-3.5px}.textmode-export-range-input__field::-moz-range-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__tooltip{position:absolute;top:-1.5rem;left:0;transform:translate(-50%);padding:.2rem .35rem;border-radius:.35rem;background:#1e1e1ee0;color:#f8fafc;font-size:.68rem;line-height:1;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease}.textmode-export-range-input__tooltip--visible{opacity:1}}`;
|
|
1777
|
+
function er(i) {
|
|
1778
|
+
return typeof i.refreshLayerTargets == "function";
|
|
1779
|
+
}
|
|
1780
|
+
class rr {
|
|
1781
|
+
constructor(e, t, r, a, o) {
|
|
1721
1782
|
p(this, "_textmodifier");
|
|
1722
1783
|
p(this, "_state");
|
|
1723
1784
|
p(this, "_events");
|
|
@@ -1732,33 +1793,33 @@ class qe {
|
|
|
1732
1793
|
p(this, "_optionsContainer");
|
|
1733
1794
|
p(this, "_copyButtonContainer");
|
|
1734
1795
|
p(this, "_positionService");
|
|
1735
|
-
p(this, "_header", new
|
|
1736
|
-
p(this, "_formatField", new
|
|
1737
|
-
p(this, "_formatSelect", new
|
|
1738
|
-
p(this, "_exportButton", new
|
|
1739
|
-
p(this, "_copyButton", new
|
|
1796
|
+
p(this, "_header", new bt());
|
|
1797
|
+
p(this, "_formatField", new T({ label: "export format", labelFor: "textmode-export-format", variant: "full" }));
|
|
1798
|
+
p(this, "_formatSelect", new H({ id: "textmode-export-format", options: [] }));
|
|
1799
|
+
p(this, "_exportButton", new Nt({ label: "download file", fullWidth: !0, variant: "primary" }));
|
|
1800
|
+
p(this, "_copyButton", new Nt({ label: "copy to clipboard", fullWidth: !0, variant: "primary" }));
|
|
1740
1801
|
p(this, "_currentFormat");
|
|
1741
1802
|
p(this, "_currentBlade");
|
|
1742
1803
|
p(this, "_handleFormatSelectChange", () => {
|
|
1743
1804
|
this._handleFormatChange(this._formatSelect.value);
|
|
1744
1805
|
});
|
|
1745
1806
|
p(this, "_handleExportClickSafe", () => {
|
|
1746
|
-
this._handleExportClick().catch((
|
|
1747
|
-
console.error("[textmode-export] Export failed",
|
|
1807
|
+
this._handleExportClick().catch((e) => {
|
|
1808
|
+
console.error("[textmode-export] Export failed", e);
|
|
1748
1809
|
});
|
|
1749
1810
|
});
|
|
1750
1811
|
p(this, "_handleCopyClickSafe", () => {
|
|
1751
|
-
this._handleCopyClick().catch((
|
|
1752
|
-
console.error("[textmode-export] Copy failed",
|
|
1812
|
+
this._handleCopyClick().catch((e) => {
|
|
1813
|
+
console.error("[textmode-export] Copy failed", e);
|
|
1753
1814
|
});
|
|
1754
1815
|
});
|
|
1755
|
-
this._textmodifier =
|
|
1816
|
+
this._textmodifier = e, this._state = r, this._events = a, this._exportService = new Ge(t, a), this._clipboardService = new Ue(t), this._definitions = o, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
|
|
1756
1817
|
}
|
|
1757
1818
|
$mount() {
|
|
1758
|
-
this._createOverlay(), this._renderStaticContent(), this._positionService = new
|
|
1819
|
+
this._createOverlay(), this._renderStaticContent(), this._positionService = new ze(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
|
|
1759
1820
|
}
|
|
1760
1821
|
show() {
|
|
1761
|
-
this._shadowHost && (this._shadowHost.style.display = "");
|
|
1822
|
+
this._shadowHost && (this.refreshLayerTargets(), this._shadowHost.style.display = "");
|
|
1762
1823
|
}
|
|
1763
1824
|
hide() {
|
|
1764
1825
|
this._shadowHost && (this._shadowHost.style.display = "none");
|
|
@@ -1769,51 +1830,54 @@ class qe {
|
|
|
1769
1830
|
isVisible() {
|
|
1770
1831
|
return !!this._shadowHost && this._shadowHost.style.display !== "none";
|
|
1771
1832
|
}
|
|
1833
|
+
refreshLayerTargets() {
|
|
1834
|
+
this._currentBlade && er(this._currentBlade.blade) && this._currentBlade.blade.refreshLayerTargets();
|
|
1835
|
+
}
|
|
1772
1836
|
$dispose() {
|
|
1773
|
-
var
|
|
1837
|
+
var e, t;
|
|
1774
1838
|
this._formatSelect.isMounted() && this._formatSelect.selectElement.removeEventListener("change", this._handleFormatSelectChange), this._exportButton.isMounted() && this._exportButton.buttonElement.removeEventListener("click", this._handleExportClickSafe), this._copyButton.isMounted() && this._copyButton.buttonElement.removeEventListener("click", this._handleCopyClickSafe);
|
|
1775
|
-
for (const
|
|
1839
|
+
for (const r of this._eventUnsubscribers) r();
|
|
1776
1840
|
this._eventUnsubscribers.length = 0, this._events.$clear();
|
|
1777
|
-
for (const
|
|
1778
|
-
this._formats.clear(), this._currentBlade = void 0, (
|
|
1841
|
+
for (const r of this._formats.values()) r.blade.destroy();
|
|
1842
|
+
this._formats.clear(), this._currentBlade = void 0, (e = this._shadowHost) != null && e.isConnected && this._shadowHost.remove(), (t = this._positionService) == null || t.dispose();
|
|
1779
1843
|
}
|
|
1780
1844
|
_initializeFormatMap() {
|
|
1781
|
-
for (const
|
|
1782
|
-
const t =
|
|
1783
|
-
this._formats.set(
|
|
1845
|
+
for (const e of this._definitions) {
|
|
1846
|
+
const t = e.createBlade();
|
|
1847
|
+
this._formats.set(e.format, { definition: e, blade: t, initialized: !1 });
|
|
1784
1848
|
}
|
|
1785
1849
|
}
|
|
1786
1850
|
_createOverlay() {
|
|
1787
1851
|
this._shadowHost = document.createElement("div"), this._shadowHost.dataset.plugin = "textmode-export-overlay-host", this._shadowHost.style.cssText = "position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2147483647;", this._shadowRoot = this._shadowHost.attachShadow({ mode: "open" });
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1852
|
+
const e = document.createElement("style");
|
|
1853
|
+
e.textContent = tr, this._shadowRoot.appendChild(e), this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(b.root, b.stack), this._shadowRoot.appendChild(this._overlayElement), document.body.appendChild(this._shadowHost);
|
|
1790
1854
|
}
|
|
1791
1855
|
_renderStaticContent() {
|
|
1792
1856
|
this._header.mount(this._overlayElement);
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1857
|
+
const e = document.createElement("div");
|
|
1858
|
+
e.classList.add(b.section), this._overlayElement.appendChild(e), this._formatField.mount(e), this._prepareFormatOptions(), this._formatSelect.mount(this._formatField.root), this._formatSelect.selectElement.addEventListener("change", this._handleFormatSelectChange), this._optionsContainer = document.createElement("div"), this._optionsContainer.classList.add(b.stack, b.stackCompact), this._overlayElement.appendChild(this._optionsContainer), this._exportButton.mount(this._overlayElement), this._exportButton.buttonElement.addEventListener("click", this._handleExportClickSafe), this._copyButtonContainer = document.createElement("div"), this._copyButtonContainer.classList.add(b.stack, b.stackDense), this._overlayElement.appendChild(this._copyButtonContainer), this._copyButton.mount(this._copyButtonContainer), this._copyButton.buttonElement.dataset.defaultLabel = "copy to clipboard", this._copyButton.buttonElement.addEventListener("click", this._handleCopyClickSafe);
|
|
1795
1859
|
}
|
|
1796
1860
|
_prepareFormatOptions() {
|
|
1797
|
-
const
|
|
1798
|
-
this._formatSelect.update({ options:
|
|
1861
|
+
const e = this._definitions.map((t) => ({ value: t.format, label: t.label }));
|
|
1862
|
+
this._formatSelect.update({ options: e, defaultValue: this._currentFormat });
|
|
1799
1863
|
}
|
|
1800
1864
|
_registerEventHandlers() {
|
|
1801
|
-
this._eventUnsubscribers.push(this._events.$on("export:request", ({ format:
|
|
1802
|
-
|
|
1803
|
-
}), this._events.$on("export:success", ({ format:
|
|
1804
|
-
if (
|
|
1865
|
+
this._eventUnsubscribers.push(this._events.$on("export:request", ({ format: e }) => {
|
|
1866
|
+
e === this._currentFormat && (this._state.$set({ isBusy: !0, error: void 0 }), this._updateExportButton());
|
|
1867
|
+
}), this._events.$on("export:success", ({ format: e }) => {
|
|
1868
|
+
if (e === this._currentFormat) {
|
|
1805
1869
|
const t = { isBusy: !1 };
|
|
1806
|
-
|
|
1870
|
+
e === "gif" && (t.gifProgress = void 0), e === "video" && (t.videoProgress = void 0), this._state.$set(t), this._updateExportButton();
|
|
1807
1871
|
}
|
|
1808
|
-
}), this._events.$on("export:error", ({ format:
|
|
1809
|
-
|
|
1810
|
-
}), this._events.$on("export:progress", ({ format:
|
|
1811
|
-
var
|
|
1872
|
+
}), this._events.$on("export:error", ({ format: e, error: t }) => {
|
|
1873
|
+
e === this._currentFormat && (this._state.$set({ isBusy: !1, error: t }), this._updateExportButton());
|
|
1874
|
+
}), this._events.$on("export:progress", ({ format: e, progress: t }) => {
|
|
1875
|
+
var r, a;
|
|
1812
1876
|
if (t) {
|
|
1813
|
-
if (
|
|
1877
|
+
if (e === "gif" && ((r = this._currentBlade) == null ? void 0 : r.blade) instanceof vt) {
|
|
1814
1878
|
const o = t;
|
|
1815
1879
|
this._state.$set({ gifProgress: o }), this._currentBlade.blade.handleProgress(o);
|
|
1816
|
-
} else if (
|
|
1880
|
+
} else if (e === "video" && ((a = this._currentBlade) == null ? void 0 : a.blade) instanceof yt) {
|
|
1817
1881
|
const o = t;
|
|
1818
1882
|
this._state.$set({ videoProgress: o }), this._currentBlade.blade.handleProgress(o);
|
|
1819
1883
|
}
|
|
@@ -1821,57 +1885,57 @@ class qe {
|
|
|
1821
1885
|
}
|
|
1822
1886
|
}));
|
|
1823
1887
|
}
|
|
1824
|
-
_handleFormatChange(
|
|
1825
|
-
this._currentFormat =
|
|
1888
|
+
_handleFormatChange(e) {
|
|
1889
|
+
this._currentFormat = e, this._state.$set({ format: e }), this._switchFormat(e), this._events.$emit("format:change", { format: e });
|
|
1826
1890
|
}
|
|
1827
|
-
_switchFormat(
|
|
1828
|
-
var
|
|
1829
|
-
const t = this._formats.get(
|
|
1830
|
-
if (!t) throw new Error(`Unknown export format: ${
|
|
1831
|
-
this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", t.blade.mount(this._optionsContainer), t.initialized || (t.blade.reset(), t.initialized = !0), this._currentBlade = t, this._formatSelect.value =
|
|
1891
|
+
_switchFormat(e) {
|
|
1892
|
+
var r;
|
|
1893
|
+
const t = this._formats.get(e);
|
|
1894
|
+
if (!t) throw new Error(`Unknown export format: ${e}`);
|
|
1895
|
+
this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", t.blade.mount(this._optionsContainer), t.initialized || (t.blade.reset(), t.initialized = !0), this._currentBlade = t, this._formatSelect.value = e, this.refreshLayerTargets(), this._updateCopyButtonState(), this._updateExportButton(), (r = this._positionService) == null || r.scheduleUpdate();
|
|
1832
1896
|
}
|
|
1833
1897
|
_updateCopyButtonState() {
|
|
1834
1898
|
var t;
|
|
1835
|
-
const
|
|
1836
|
-
this._copyButtonContainer.style.display =
|
|
1899
|
+
const e = ((t = this._currentBlade) == null ? void 0 : t.definition.supportsClipboard) ?? !1;
|
|
1900
|
+
this._copyButtonContainer.style.display = e ? "flex" : "none", this._copyButton.setDisabled(!e);
|
|
1837
1901
|
}
|
|
1838
1902
|
async _handleExportClick() {
|
|
1839
1903
|
if (!this._currentBlade) return;
|
|
1840
|
-
const
|
|
1904
|
+
const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions();
|
|
1841
1905
|
if (this._currentBlade.blade.validate()) {
|
|
1842
|
-
if (
|
|
1843
|
-
const
|
|
1844
|
-
if (
|
|
1845
|
-
|
|
1906
|
+
if (e === "gif") {
|
|
1907
|
+
const r = this._currentBlade.blade;
|
|
1908
|
+
if (r.isRecording()) return;
|
|
1909
|
+
r.setRecordingState("recording");
|
|
1846
1910
|
try {
|
|
1847
1911
|
await this._exportService.$requestExport("gif", t, { onGIFProgress: (a) => {
|
|
1848
|
-
|
|
1912
|
+
r.setRecordingState(a.state, a);
|
|
1849
1913
|
} });
|
|
1850
1914
|
} catch (a) {
|
|
1851
|
-
throw
|
|
1915
|
+
throw r.setRecordingState("error"), a;
|
|
1852
1916
|
}
|
|
1853
1917
|
return void window.setTimeout(() => {
|
|
1854
|
-
|
|
1918
|
+
r.setRecordingState("idle"), this._updateExportButton();
|
|
1855
1919
|
}, 1600);
|
|
1856
1920
|
}
|
|
1857
|
-
if (
|
|
1858
|
-
const
|
|
1859
|
-
if (
|
|
1860
|
-
|
|
1921
|
+
if (e === "video") {
|
|
1922
|
+
const r = this._currentBlade.blade;
|
|
1923
|
+
if (r.isRecording()) return;
|
|
1924
|
+
r.setRecordingState("recording");
|
|
1861
1925
|
try {
|
|
1862
1926
|
await this._exportService.$requestExport("video", t, { onVideoProgress: (a) => {
|
|
1863
|
-
|
|
1927
|
+
r.setRecordingState(a.state, a);
|
|
1864
1928
|
} });
|
|
1865
1929
|
} catch (a) {
|
|
1866
|
-
throw
|
|
1930
|
+
throw r.setRecordingState("error"), a;
|
|
1867
1931
|
}
|
|
1868
1932
|
return void window.setTimeout(() => {
|
|
1869
|
-
|
|
1933
|
+
r.setRecordingState("idle"), this._updateExportButton();
|
|
1870
1934
|
}, 1600);
|
|
1871
1935
|
}
|
|
1872
1936
|
this._exportButton.setDisabled(!0), this._exportButton.setLabel("exporting…");
|
|
1873
1937
|
try {
|
|
1874
|
-
await this._exportService.$requestExport(
|
|
1938
|
+
await this._exportService.$requestExport(e, t);
|
|
1875
1939
|
} finally {
|
|
1876
1940
|
this._exportButton.setDisabled(!1), this._exportButton.setLabel("download file");
|
|
1877
1941
|
}
|
|
@@ -1879,10 +1943,10 @@ class qe {
|
|
|
1879
1943
|
}
|
|
1880
1944
|
async _handleCopyClick() {
|
|
1881
1945
|
if (!this._currentBlade || !this._currentBlade.definition.supportsClipboard) return;
|
|
1882
|
-
const
|
|
1946
|
+
const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
|
|
1883
1947
|
this._copyButton.setDisabled(!0), this._copyButton.setLabel("copying…");
|
|
1884
1948
|
try {
|
|
1885
|
-
switch (
|
|
1949
|
+
switch (e) {
|
|
1886
1950
|
case "txt":
|
|
1887
1951
|
await this._clipboardService.$copy("txt", t);
|
|
1888
1952
|
break;
|
|
@@ -1903,18 +1967,18 @@ class qe {
|
|
|
1903
1967
|
console.error("[textmode-export] Failed to copy to clipboard", a), this._copyButton.setLabel("copy failed!");
|
|
1904
1968
|
} finally {
|
|
1905
1969
|
window.setTimeout(() => {
|
|
1906
|
-
this._copyButton.setLabel(
|
|
1970
|
+
this._copyButton.setLabel(r), this._copyButton.setDisabled(!1);
|
|
1907
1971
|
}, 1200);
|
|
1908
1972
|
}
|
|
1909
1973
|
}
|
|
1910
1974
|
_updateExportButton() {
|
|
1911
1975
|
if (!this._currentBlade) return;
|
|
1912
|
-
const
|
|
1913
|
-
if (
|
|
1914
|
-
const
|
|
1915
|
-
if (
|
|
1916
|
-
const o = a.frameIndex ?? 0,
|
|
1917
|
-
this._exportButton.setLabel(`${
|
|
1976
|
+
const e = this._currentBlade.definition.format;
|
|
1977
|
+
if (e === "gif" && this._currentBlade.blade instanceof vt) {
|
|
1978
|
+
const r = this._currentBlade.blade, a = this._state.snapshot.gifProgress;
|
|
1979
|
+
if (r.isRecording()) if (this._exportButton.setDisabled(!0), a == null ? void 0 : a.totalFrames) {
|
|
1980
|
+
const o = a.frameIndex ?? 0, n = a.state === "encoding" ? "encoding" : "recording";
|
|
1981
|
+
this._exportButton.setLabel(`${n} ${o}/${a.totalFrames}`);
|
|
1918
1982
|
} else {
|
|
1919
1983
|
const o = (a == null ? void 0 : a.state) === "encoding" ? "encoding" : "recording";
|
|
1920
1984
|
this._exportButton.setLabel(`${o}…`);
|
|
@@ -1922,9 +1986,9 @@ class qe {
|
|
|
1922
1986
|
else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
|
|
1923
1987
|
return;
|
|
1924
1988
|
}
|
|
1925
|
-
if (
|
|
1926
|
-
const
|
|
1927
|
-
if (
|
|
1989
|
+
if (e === "video" && this._currentBlade.blade instanceof yt) {
|
|
1990
|
+
const r = this._currentBlade.blade, a = this._state.snapshot.videoProgress;
|
|
1991
|
+
if (r.isRecording()) if (this._exportButton.setDisabled(!0), a == null ? void 0 : a.totalFrames) {
|
|
1928
1992
|
const o = a.frameIndex ?? 0;
|
|
1929
1993
|
this._exportButton.setLabel(`recording ${o}/${a.totalFrames} frames`);
|
|
1930
1994
|
} else this._exportButton.setLabel("recording…");
|
|
@@ -1935,65 +1999,65 @@ class qe {
|
|
|
1935
1999
|
this._exportButton.setDisabled(t), this._exportButton.setLabel(t ? "exporting…" : "download file");
|
|
1936
2000
|
}
|
|
1937
2001
|
}
|
|
1938
|
-
class
|
|
2002
|
+
class ar {
|
|
1939
2003
|
constructor() {
|
|
1940
2004
|
p(this, "_listeners", {});
|
|
1941
2005
|
}
|
|
1942
|
-
_getPool(
|
|
1943
|
-
const t = this._listeners[
|
|
2006
|
+
_getPool(e) {
|
|
2007
|
+
const t = this._listeners[e];
|
|
1944
2008
|
if (t) return t;
|
|
1945
|
-
const
|
|
1946
|
-
return this._listeners[
|
|
2009
|
+
const r = /* @__PURE__ */ new Set();
|
|
2010
|
+
return this._listeners[e] = r, r;
|
|
1947
2011
|
}
|
|
1948
|
-
$on(
|
|
1949
|
-
const
|
|
1950
|
-
return
|
|
1951
|
-
|
|
2012
|
+
$on(e, t) {
|
|
2013
|
+
const r = this._getPool(e);
|
|
2014
|
+
return r.add(t), () => {
|
|
2015
|
+
r.delete(t), r.size === 0 && delete this._listeners[e];
|
|
1952
2016
|
};
|
|
1953
2017
|
}
|
|
1954
|
-
$emit(
|
|
1955
|
-
const
|
|
1956
|
-
if (
|
|
2018
|
+
$emit(e, t) {
|
|
2019
|
+
const r = this._listeners[e];
|
|
2020
|
+
if (r) for (const a of [...r]) try {
|
|
1957
2021
|
a(t);
|
|
1958
2022
|
} catch (o) {
|
|
1959
2023
|
console.error("[textmode-export] Event handler failed", o);
|
|
1960
2024
|
}
|
|
1961
2025
|
}
|
|
1962
2026
|
$clear() {
|
|
1963
|
-
for (const
|
|
2027
|
+
for (const e of Object.keys(this._listeners)) delete this._listeners[e];
|
|
1964
2028
|
}
|
|
1965
2029
|
}
|
|
1966
|
-
class
|
|
1967
|
-
constructor(
|
|
2030
|
+
class or {
|
|
2031
|
+
constructor(e) {
|
|
1968
2032
|
p(this, "_state");
|
|
1969
2033
|
p(this, "_listeners", /* @__PURE__ */ new Set());
|
|
1970
|
-
this._state =
|
|
2034
|
+
this._state = e;
|
|
1971
2035
|
}
|
|
1972
2036
|
get snapshot() {
|
|
1973
2037
|
return Object.freeze({ ...this._state });
|
|
1974
2038
|
}
|
|
1975
|
-
$set(
|
|
1976
|
-
this._state = Object.assign({}, this._state,
|
|
2039
|
+
$set(e) {
|
|
2040
|
+
this._state = Object.assign({}, this._state, e);
|
|
1977
2041
|
const t = this.snapshot;
|
|
1978
|
-
for (const
|
|
1979
|
-
|
|
2042
|
+
for (const r of [...this._listeners]) try {
|
|
2043
|
+
r(t);
|
|
1980
2044
|
} catch (a) {
|
|
1981
2045
|
console.error("[textmode-export] State listener failed", a);
|
|
1982
2046
|
}
|
|
1983
2047
|
}
|
|
1984
|
-
$subscribe(
|
|
1985
|
-
return this._listeners.add(
|
|
1986
|
-
this._listeners.delete(
|
|
2048
|
+
$subscribe(e) {
|
|
2049
|
+
return this._listeners.add(e), e(this.snapshot), () => {
|
|
2050
|
+
this._listeners.delete(e);
|
|
1987
2051
|
};
|
|
1988
2052
|
}
|
|
1989
|
-
$reset(
|
|
1990
|
-
this._state =
|
|
2053
|
+
$reset(e) {
|
|
2054
|
+
this._state = e;
|
|
1991
2055
|
const t = this.snapshot;
|
|
1992
|
-
for (const
|
|
2056
|
+
for (const r of [...this._listeners]) r(t);
|
|
1993
2057
|
}
|
|
1994
2058
|
}
|
|
1995
|
-
const
|
|
1996
|
-
class nt extends
|
|
2059
|
+
const ir = (i) => ({ format: i, isBusy: !1 });
|
|
2060
|
+
class nt extends D {
|
|
1997
2061
|
constructor(t) {
|
|
1998
2062
|
super();
|
|
1999
2063
|
p(this, "props");
|
|
@@ -2025,7 +2089,7 @@ class nt extends T {
|
|
|
2025
2089
|
this.props = t, t.id && (this.checkbox.id = t.id, this.labelElement.htmlFor = t.id), this.checkbox.checked = !!t.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = t.label);
|
|
2026
2090
|
}
|
|
2027
2091
|
}
|
|
2028
|
-
class
|
|
2092
|
+
class sr extends D {
|
|
2029
2093
|
constructor(t) {
|
|
2030
2094
|
super();
|
|
2031
2095
|
p(this, "props");
|
|
@@ -2054,21 +2118,57 @@ class Ye extends T {
|
|
|
2054
2118
|
this.props = t, t.id && (this.input.id = t.id), t.maxLength !== void 0 && (this.input.maxLength = t.maxLength), t.defaultValue !== void 0 && (this.input.value = t.defaultValue);
|
|
2055
2119
|
}
|
|
2056
2120
|
}
|
|
2057
|
-
class
|
|
2121
|
+
class Ct extends D {
|
|
2122
|
+
constructor(t) {
|
|
2123
|
+
super();
|
|
2124
|
+
p(this, "provider");
|
|
2125
|
+
p(this, "field");
|
|
2126
|
+
p(this, "select");
|
|
2127
|
+
this.provider = t.provider, this.field = new T({ label: "layer", labelFor: t.id, variant: "full" }), this.select = new H({ id: t.id, options: [], defaultValue: t.provider.getDefaultId() });
|
|
2128
|
+
}
|
|
2129
|
+
render() {
|
|
2130
|
+
const t = document.createElement("div");
|
|
2131
|
+
return this.field.mount(t), this.refresh(), this.select.mount(this.field.root), t;
|
|
2132
|
+
}
|
|
2133
|
+
get layer() {
|
|
2134
|
+
const t = this.provider.getLayerById(this.select.value);
|
|
2135
|
+
if (t) return t;
|
|
2136
|
+
const r = this.provider.getDefaultId();
|
|
2137
|
+
return this.select.value = r, this.provider.getLayerById(r);
|
|
2138
|
+
}
|
|
2139
|
+
setDisabled(t) {
|
|
2140
|
+
this.select.selectElement.disabled = t;
|
|
2141
|
+
}
|
|
2142
|
+
refresh() {
|
|
2143
|
+
const t = this.provider.getOptions(), r = this.select.isMounted() ? this.select.value : this.provider.getDefaultId(), a = t.some((o) => o.id === r) ? r : this.provider.getDefaultId();
|
|
2144
|
+
this.select.update({ options: t.map((o) => ({ value: o.id, label: o.label })), defaultValue: a }), this.select.value = a;
|
|
2145
|
+
}
|
|
2146
|
+
_onUnmount() {
|
|
2147
|
+
this.select.unmount(), this.field.unmount();
|
|
2148
|
+
}
|
|
2149
|
+
_onDestroy() {
|
|
2150
|
+
this.select.destroy(), this.field.destroy();
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
class nr extends J {
|
|
2058
2154
|
constructor(t) {
|
|
2059
2155
|
super(t);
|
|
2156
|
+
p(this, "layerTarget");
|
|
2060
2157
|
p(this, "trailingSpaces", this._manageComponent(new nt({ label: "preserve trailing spaces", defaultChecked: !1 })));
|
|
2061
|
-
p(this, "emptyCharacter", this._manageComponent(new
|
|
2158
|
+
p(this, "emptyCharacter", this._manageComponent(new sr({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 })));
|
|
2159
|
+
t.layerTargetProvider && (this.layerTarget = this._manageComponent(new Ct({ id: "textmode-export-txt-layer", provider: t.layerTargetProvider })));
|
|
2062
2160
|
}
|
|
2063
2161
|
render() {
|
|
2162
|
+
var a;
|
|
2064
2163
|
const t = document.createElement("div");
|
|
2065
|
-
t.classList.add(b.stack), this.trailingSpaces.mount(t);
|
|
2066
|
-
const
|
|
2067
|
-
return
|
|
2164
|
+
t.classList.add(b.stack), (a = this.layerTarget) == null || a.mount(t), this.trailingSpaces.mount(t);
|
|
2165
|
+
const r = new T({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
|
|
2166
|
+
return r.mount(t), this.emptyCharacter.mount(r.root), t;
|
|
2068
2167
|
}
|
|
2069
2168
|
getOptions() {
|
|
2070
|
-
|
|
2071
|
-
|
|
2169
|
+
var a;
|
|
2170
|
+
const t = this._config.defaultOptions ?? {}, r = this.emptyCharacter.value || t.emptyCharacter || " ";
|
|
2171
|
+
return { layer: (a = this.layerTarget) == null ? void 0 : a.layer, preserveTrailingSpaces: this.trailingSpaces.checked, emptyCharacter: r };
|
|
2072
2172
|
}
|
|
2073
2173
|
reset() {
|
|
2074
2174
|
this.applyDefaults();
|
|
@@ -2076,26 +2176,38 @@ class Qe extends J {
|
|
|
2076
2176
|
validate() {
|
|
2077
2177
|
return this.emptyCharacter.value.length <= 1;
|
|
2078
2178
|
}
|
|
2179
|
+
refreshLayerTargets() {
|
|
2180
|
+
var t;
|
|
2181
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2182
|
+
}
|
|
2079
2183
|
applyDefaults() {
|
|
2080
2184
|
const t = this._config.defaultOptions ?? {};
|
|
2081
2185
|
this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
|
|
2082
2186
|
}
|
|
2083
2187
|
}
|
|
2084
|
-
class
|
|
2188
|
+
class lr extends J {
|
|
2085
2189
|
constructor(t) {
|
|
2086
2190
|
super(t);
|
|
2191
|
+
p(this, "layerTarget");
|
|
2192
|
+
p(this, "layerTargetContainer");
|
|
2193
|
+
p(this, "target", this._manageComponent(new H({ id: "textmode-export-json-target", options: [{ value: "selected", label: "selected layer" }, { value: "all", label: "all layers" }], defaultValue: "selected" })));
|
|
2087
2194
|
p(this, "prettyPrint", this._manageComponent(new nt({ id: "textmode-export-json-pretty", label: "pretty print", defaultChecked: !0 })));
|
|
2088
2195
|
p(this, "includeMetadata", this._manageComponent(new nt({ id: "textmode-export-json-metadata", label: "include metadata", defaultChecked: !0 })));
|
|
2089
|
-
p(this, "colorMode", this._manageComponent(new
|
|
2196
|
+
p(this, "colorMode", this._manageComponent(new H({ id: "textmode-export-json-color-mode", options: [{ value: "hex", label: "hex" }, { value: "rgba", label: "rgba" }], defaultValue: "hex" })));
|
|
2197
|
+
t.layerTargetProvider && (this.layerTarget = this._manageComponent(new Ct({ id: "textmode-export-json-layer", provider: t.layerTargetProvider })));
|
|
2090
2198
|
}
|
|
2091
2199
|
render() {
|
|
2092
2200
|
const t = document.createElement("div");
|
|
2093
|
-
t.classList.add(b.stack)
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2201
|
+
t.classList.add(b.stack);
|
|
2202
|
+
const r = new T({ label: "target", labelFor: "textmode-export-json-target", variant: "full" });
|
|
2203
|
+
r.mount(t), this.target.mount(r.root), this.target.selectElement.addEventListener("change", () => this.updateLayerTargetVisibility()), this.layerTarget && (this.layerTargetContainer = document.createElement("div"), this.layerTarget.mount(this.layerTargetContainer), t.appendChild(this.layerTargetContainer)), this.prettyPrint.mount(t), this.includeMetadata.mount(t);
|
|
2204
|
+
const a = new T({ label: "color mode", labelFor: "textmode-export-json-color-mode", variant: "full" });
|
|
2205
|
+
return a.mount(t), this.colorMode.mount(a.root), this.updateLayerTargetVisibility(), t;
|
|
2096
2206
|
}
|
|
2097
2207
|
getOptions() {
|
|
2098
|
-
|
|
2208
|
+
var r;
|
|
2209
|
+
const t = this.target.value;
|
|
2210
|
+
return { target: t, layer: t === "selected" ? (r = this.layerTarget) == null ? void 0 : r.layer : void 0, pretty: this.prettyPrint.checked, includeMetadata: this.includeMetadata.checked, colorMode: this.colorMode.value };
|
|
2099
2211
|
}
|
|
2100
2212
|
reset() {
|
|
2101
2213
|
this.applyDefaults();
|
|
@@ -2103,31 +2215,40 @@ class Ke extends J {
|
|
|
2103
2215
|
validate() {
|
|
2104
2216
|
return !0;
|
|
2105
2217
|
}
|
|
2218
|
+
refreshLayerTargets() {
|
|
2219
|
+
var t;
|
|
2220
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2221
|
+
}
|
|
2106
2222
|
applyDefaults() {
|
|
2107
2223
|
const t = this._config.defaultOptions ?? {};
|
|
2108
|
-
this.prettyPrint.checked = typeof t.pretty == "number" ? t.pretty > 0 : t.pretty ?? !0, this.includeMetadata.checked = t.includeMetadata ?? !0, this.colorMode.value = t.colorMode ?? "hex";
|
|
2224
|
+
this.target.value = t.target ?? "selected", this.prettyPrint.checked = typeof t.pretty == "number" ? t.pretty > 0 : t.pretty ?? !0, this.includeMetadata.checked = t.includeMetadata ?? !0, this.colorMode.value = t.colorMode ?? "hex", this.updateLayerTargetVisibility();
|
|
2225
|
+
}
|
|
2226
|
+
updateLayerTargetVisibility() {
|
|
2227
|
+
var r;
|
|
2228
|
+
const t = this.target.value === "selected";
|
|
2229
|
+
this.layerTargetContainer && (this.layerTargetContainer.style.display = t ? "" : "none"), (r = this.layerTarget) == null || r.setDisabled(!t);
|
|
2109
2230
|
}
|
|
2110
2231
|
}
|
|
2111
|
-
class
|
|
2232
|
+
class dr extends J {
|
|
2112
2233
|
constructor(t) {
|
|
2113
2234
|
super(t);
|
|
2114
|
-
p(this, "formatSelect", this._manageComponent(new
|
|
2235
|
+
p(this, "formatSelect", this._manageComponent(new H({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${ht.png})` }, { value: "jpg", label: `JPG (${ht.jpg})` }, { value: "webp", label: `WEBP (${ht.webp})` }], defaultValue: "png" })));
|
|
2115
2236
|
p(this, "scaleInput", this._manageComponent(new z({ defaultValue: "1", attributes: { min: "0.1", step: "0.1" } })));
|
|
2116
2237
|
}
|
|
2117
2238
|
render() {
|
|
2118
2239
|
const t = document.createElement("div");
|
|
2119
2240
|
t.classList.add(b.stack);
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2122
|
-
const a = new
|
|
2123
|
-
a.mount(
|
|
2124
|
-
const o = new
|
|
2125
|
-
return o.mount(
|
|
2241
|
+
const r = new Q("row");
|
|
2242
|
+
r.mount(t);
|
|
2243
|
+
const a = new T({ label: "image format", labelFor: "textmode-export-image-format", variant: "compact" });
|
|
2244
|
+
a.mount(r.root), this.formatSelect.mount(a.root);
|
|
2245
|
+
const o = new T({ label: "scale", labelFor: "textmode-export-image-scale", variant: "dense" });
|
|
2246
|
+
return o.mount(r.root), this.scaleInput.mount(o.root), this.scaleInput.inputElement.id = "textmode-export-image-scale", t;
|
|
2126
2247
|
}
|
|
2127
2248
|
getOptions() {
|
|
2128
|
-
var
|
|
2249
|
+
var r;
|
|
2129
2250
|
const t = Number.parseFloat(this.scaleInput.value);
|
|
2130
|
-
return { format: this.formatSelect.value, scale: Number.isFinite(t) ? t : ((
|
|
2251
|
+
return { format: this.formatSelect.value, scale: Number.isFinite(t) ? t : ((r = this._config.defaultOptions) == null ? void 0 : r.scale) ?? 1 };
|
|
2131
2252
|
}
|
|
2132
2253
|
reset() {
|
|
2133
2254
|
this.applyDefaults(), this.scaleInput.refresh();
|
|
@@ -2139,29 +2260,33 @@ class Ze extends J {
|
|
|
2139
2260
|
applyDefaults() {
|
|
2140
2261
|
const t = this._config.defaultOptions ?? {};
|
|
2141
2262
|
this.formatSelect.value = t.format ?? "png";
|
|
2142
|
-
const
|
|
2143
|
-
this.scaleInput.value = String(
|
|
2263
|
+
const r = t.scale ?? 1;
|
|
2264
|
+
this.scaleInput.value = String(r);
|
|
2144
2265
|
}
|
|
2145
2266
|
}
|
|
2146
|
-
class
|
|
2267
|
+
class cr extends J {
|
|
2147
2268
|
constructor(t) {
|
|
2148
2269
|
super(t);
|
|
2270
|
+
p(this, "layerTarget");
|
|
2149
2271
|
p(this, "includeBackground", this._manageComponent(new nt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 })));
|
|
2150
|
-
p(this, "drawMode", this._manageComponent(new
|
|
2272
|
+
p(this, "drawMode", this._manageComponent(new H({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" })));
|
|
2151
2273
|
p(this, "strokeWidth", this._manageComponent(new z({ defaultValue: "1", attributes: { min: "0", step: "0.1" } })));
|
|
2274
|
+
t.layerTargetProvider && (this.layerTarget = this._manageComponent(new Ct({ id: "textmode-export-svg-layer", provider: t.layerTargetProvider })));
|
|
2152
2275
|
}
|
|
2153
2276
|
render() {
|
|
2277
|
+
var n;
|
|
2154
2278
|
const t = document.createElement("div");
|
|
2155
|
-
t.classList.add(b.stack), this.includeBackground.mount(t);
|
|
2156
|
-
const
|
|
2157
|
-
|
|
2158
|
-
const a = new
|
|
2159
|
-
a.mount(
|
|
2160
|
-
const o = new
|
|
2161
|
-
return o.mount(
|
|
2279
|
+
t.classList.add(b.stack), (n = this.layerTarget) == null || n.mount(t), this.includeBackground.mount(t);
|
|
2280
|
+
const r = new Q("row");
|
|
2281
|
+
r.mount(t);
|
|
2282
|
+
const a = new T({ label: "draw mode", labelFor: "textmode-export-svg-draw-mode", variant: "compact" });
|
|
2283
|
+
a.mount(r.root), this.drawMode.mount(a.root);
|
|
2284
|
+
const o = new T({ label: "stroke width", labelFor: "textmode-export-svg-stroke-width", variant: "compact" });
|
|
2285
|
+
return o.mount(r.root), this.strokeWidth.mount(o.root), this.strokeWidth.inputElement.id = "textmode-export-svg-stroke-width", this.drawMode.selectElement.addEventListener("change", () => this.updateStrokeControls()), this.updateStrokeControls(), t;
|
|
2162
2286
|
}
|
|
2163
2287
|
getOptions() {
|
|
2164
|
-
|
|
2288
|
+
var t;
|
|
2289
|
+
return { layer: (t = this.layerTarget) == null ? void 0 : t.layer, includeBackgroundRectangles: this.includeBackground.checked, drawMode: this.drawMode.value, strokeWidth: Number.parseFloat(this.strokeWidth.value) };
|
|
2165
2290
|
}
|
|
2166
2291
|
reset() {
|
|
2167
2292
|
this.applyDefaults(), this.updateStrokeControls();
|
|
@@ -2170,6 +2295,10 @@ class tr extends J {
|
|
|
2170
2295
|
const t = Number.parseFloat(this.strokeWidth.value);
|
|
2171
2296
|
return this.drawMode.value !== "stroke" || Number.isFinite(t) && t >= 0;
|
|
2172
2297
|
}
|
|
2298
|
+
refreshLayerTargets() {
|
|
2299
|
+
var t;
|
|
2300
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2301
|
+
}
|
|
2173
2302
|
updateStrokeControls() {
|
|
2174
2303
|
const t = this.drawMode.value === "stroke";
|
|
2175
2304
|
this.strokeWidth.inputElement.disabled = !t, this.strokeWidth.refresh();
|
|
@@ -2177,43 +2306,46 @@ class tr extends J {
|
|
|
2177
2306
|
applyDefaults() {
|
|
2178
2307
|
const t = this._config.defaultOptions ?? {};
|
|
2179
2308
|
this.includeBackground.checked = t.includeBackgroundRectangles ?? !0, this.drawMode.value = t.drawMode ?? "fill";
|
|
2180
|
-
const
|
|
2181
|
-
this.strokeWidth.value = String(
|
|
2309
|
+
const r = t.strokeWidth ?? 1;
|
|
2310
|
+
this.strokeWidth.value = String(r), this.strokeWidth.refresh();
|
|
2182
2311
|
}
|
|
2183
2312
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
return er;
|
|
2313
|
+
function ur(i) {
|
|
2314
|
+
return [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new nr({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " }, layerTargetProvider: i }) }, { format: "json", label: "document data (.json)", supportsClipboard: !0, createBlade: () => new lr({ format: "json", label: "document data (.json)", supportsClipboard: !0, defaultOptions: { target: "selected", pretty: !0, includeMetadata: !0, colorMode: "hex" }, layerTargetProvider: i }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new dr({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new cr({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 }, layerTargetProvider: i }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new vt({ format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, defaultOptions: { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 } }) }, { format: "video", label: "video (.webm)", supportsClipboard: !1, createBlade: () => new yt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
|
|
2187
2315
|
}
|
|
2188
|
-
function
|
|
2189
|
-
var
|
|
2190
|
-
const
|
|
2191
|
-
return
|
|
2316
|
+
function pr(i, e, t) {
|
|
2317
|
+
var l;
|
|
2318
|
+
const r = ur(t), a = (l = r[0]) == null ? void 0 : l.format, o = new or(ir(a)), n = new ar(), d = new rr(i, e, o, n, r);
|
|
2319
|
+
return d.$mount(), d;
|
|
2192
2320
|
}
|
|
2193
|
-
const
|
|
2194
|
-
const t = { saveCanvas: async (d = {}) => new
|
|
2195
|
-
new
|
|
2321
|
+
const Zt = { name: "textmode.export", version: "1.2.1", async install(i, e) {
|
|
2322
|
+
const t = { saveCanvas: async (d = {}) => new St().$saveImage(i.canvas, d), copyCanvas: async (d = {}) => new St().$copyImageToClipboard(i.canvas, d), saveSVG: (d = {}) => {
|
|
2323
|
+
new Bt().$saveSVG(i, d);
|
|
2196
2324
|
}, saveStrings: (d = {}) => {
|
|
2197
|
-
new
|
|
2198
|
-
}, toSVG: (d = {}) => new
|
|
2199
|
-
new
|
|
2200
|
-
}, saveGIF: async (d = {}) => new
|
|
2201
|
-
|
|
2325
|
+
new It().$saveTXT(i, d);
|
|
2326
|
+
}, toSVG: (d = {}) => new Bt().$generateSVG(i, d), toString: (d = {}) => new It().$generateTXT(i, d), toJSON: (d = {}) => new ft().$generateJSONData(i, d), toJSONString: (d = {}) => new ft().$generateJSONString(i, d), saveJSON: (d = {}) => {
|
|
2327
|
+
new ft().$saveJSON(i, d);
|
|
2328
|
+
}, saveGIF: async (d = {}) => new Me(i, e.registerPostDrawHook).$saveGIF(d), saveWEBM: async (d = {}) => new Re(i, e.registerPostDrawHook).$saveWEBM(d) }, r = pr(i, t, ae(i));
|
|
2329
|
+
e.registerPostDrawHook(() => {
|
|
2330
|
+
r.isVisible() && r.refreshLayerTargets();
|
|
2331
|
+
});
|
|
2332
|
+
const a = { show: () => r.show(), hide: () => r.hide(), toggle: () => r.toggle(), isVisible: () => r.isVisible() }, o = { ...t, exportOverlay: a }, n = i;
|
|
2333
|
+
Object.assign(n, o), n._exportOverlayController = r;
|
|
2202
2334
|
}, async uninstall(i) {
|
|
2203
|
-
const
|
|
2204
|
-
t == null || t.$dispose(), delete
|
|
2205
|
-
const
|
|
2206
|
-
for (const a of
|
|
2207
|
-
} },
|
|
2208
|
-
const
|
|
2335
|
+
const e = i, t = e._exportOverlayController;
|
|
2336
|
+
t == null || t.$dispose(), delete e._exportOverlayController;
|
|
2337
|
+
const r = ["exportOverlay", "saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "toJSON", "toJSONString", "saveJSON", "saveGIF", "saveWEBM"];
|
|
2338
|
+
for (const a of r) delete e[a];
|
|
2339
|
+
} }, hr = (i = {}) => {
|
|
2340
|
+
const e = i.overlay ?? !0, t = { ...Zt }, r = t.install;
|
|
2209
2341
|
return t.install = async (a, o) => {
|
|
2210
2342
|
var d;
|
|
2211
|
-
const
|
|
2212
|
-
await
|
|
2343
|
+
const n = a;
|
|
2344
|
+
await r.call(t, n, o), e || ((d = n.exportOverlay) == null || d.hide());
|
|
2213
2345
|
}, t;
|
|
2214
2346
|
};
|
|
2215
|
-
typeof window < "u" && (window.ExportPlugin =
|
|
2347
|
+
typeof window < "u" && (window.ExportPlugin = Zt, window.createTextmodeExportPlugin = hr);
|
|
2216
2348
|
export {
|
|
2217
|
-
|
|
2218
|
-
|
|
2349
|
+
Zt as ExportPlugin,
|
|
2350
|
+
hr as createTextmodeExportPlugin
|
|
2219
2351
|
};
|