textmode.export.js 1.3.0 → 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 +1001 -880
- package/dist/textmode.export.umd.js +2 -2
- 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 +2 -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/SVGPathGenerator.d.ts +1 -1
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/types.d.ts +3 -1
- 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,624 +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
|
-
$getEncodedCharacterValue(
|
|
9
|
-
return
|
|
8
|
+
$getEncodedCharacterValue(e, t) {
|
|
9
|
+
return e[t] + (e[t + 1] << 8);
|
|
10
10
|
}
|
|
11
|
-
$getCharacterIndex(
|
|
12
|
-
return this.$getEncodedCharacterValue(
|
|
11
|
+
$getCharacterIndex(e, t) {
|
|
12
|
+
return this.$getEncodedCharacterValue(e, t);
|
|
13
13
|
}
|
|
14
|
-
$extractCellTransform(
|
|
15
|
-
const
|
|
16
|
-
return { isInverted: !!(1 &
|
|
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 };
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
class
|
|
20
|
-
$downloadFile(
|
|
19
|
+
class X {
|
|
20
|
+
$downloadFile(e, t) {
|
|
21
21
|
try {
|
|
22
|
-
const
|
|
23
|
-
o.href = a, o.download =
|
|
24
|
-
} catch (
|
|
25
|
-
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);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
_sanitizeFilename(
|
|
29
|
-
if (!
|
|
30
|
-
const t =
|
|
28
|
+
_sanitizeFilename(e) {
|
|
29
|
+
if (!e) return this._generateDefaultFilename();
|
|
30
|
+
const t = e.trim();
|
|
31
31
|
return t ? t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
|
|
32
32
|
}
|
|
33
33
|
_generateDefaultFilename() {
|
|
34
34
|
return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
function
|
|
37
|
+
const Et = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
function re(i) {
|
|
39
39
|
return Math.round(255 * i[0]) + (Math.round(255 * i[1]) << 8);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
let t =
|
|
41
|
+
function _t(i, e) {
|
|
42
|
+
let t = Et.get(i);
|
|
43
43
|
if (!t) {
|
|
44
44
|
t = /* @__PURE__ */ new Map();
|
|
45
|
-
for (const
|
|
46
|
-
|
|
45
|
+
for (const r of i.characters) t.set(re(r.color), r);
|
|
46
|
+
Et.set(i, t);
|
|
47
47
|
}
|
|
48
|
-
return t.get(
|
|
48
|
+
return t.get(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
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;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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 = [];
|
|
59
89
|
let a = 0;
|
|
60
|
-
for (let o = 0; o < t.rows; o++) for (let
|
|
61
|
-
const d = 4 * a, l = this.$getEncodedCharacterValue(
|
|
62
|
-
let h =
|
|
63
|
-
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);
|
|
64
94
|
if (c.isInverted) {
|
|
65
95
|
const f = h;
|
|
66
|
-
h =
|
|
96
|
+
h = s, s = f;
|
|
67
97
|
}
|
|
68
|
-
const u = this._calculateCellPosition(
|
|
69
|
-
|
|
98
|
+
const u = this._calculateCellPosition(n, o, t);
|
|
99
|
+
r.push({ encodedGlyphSlot: l, primaryColor: h, secondaryColor: s, transform: c, position: u }), a++;
|
|
70
100
|
}
|
|
71
|
-
return
|
|
101
|
+
return r;
|
|
72
102
|
}
|
|
73
103
|
}
|
|
74
|
-
class
|
|
75
|
-
_createGlyphPath(
|
|
76
|
-
const
|
|
77
|
-
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) };
|
|
78
108
|
}
|
|
79
|
-
_glyphToSVGPath(
|
|
80
|
-
if (!
|
|
81
|
-
const { xs: o, ys:
|
|
82
|
-
if (!(o &&
|
|
83
|
-
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;
|
|
84
114
|
for (let c = 0; c < d.length; c++) {
|
|
85
115
|
const u = d[c];
|
|
86
|
-
if (!(u <
|
|
87
|
-
if (u >=
|
|
88
|
-
const f = t + o[
|
|
89
|
-
h += `M${f.toFixed(2)},${
|
|
90
|
-
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;
|
|
91
121
|
for (; m <= u; )
|
|
92
122
|
if (1 & l[m]) {
|
|
93
|
-
const v = t + o[m] * a, w =
|
|
123
|
+
const v = t + o[m] * a, w = r - n[m] * a;
|
|
94
124
|
h += `L${v.toFixed(2)},${w.toFixed(2)}`, m++;
|
|
95
125
|
} else {
|
|
96
|
-
const v = t + o[m] * a, w =
|
|
97
|
-
if (1 & l[
|
|
98
|
-
const g = t + o[
|
|
99
|
-
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;
|
|
100
130
|
} else {
|
|
101
|
-
const g = (v + (t + o[
|
|
102
|
-
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;
|
|
103
133
|
}
|
|
104
134
|
}
|
|
105
135
|
h += "Z";
|
|
106
136
|
}
|
|
107
|
-
|
|
137
|
+
s = u + 1;
|
|
108
138
|
}
|
|
109
139
|
}
|
|
110
140
|
return h;
|
|
111
141
|
}
|
|
112
|
-
$generatePositionedCharacterPath(
|
|
142
|
+
$generatePositionedCharacterPath(e, t, r, a, o, n, d, l) {
|
|
113
143
|
if (!l) return null;
|
|
114
|
-
const h = t.font,
|
|
144
|
+
const h = t.font, s = d / h.head.unitsPerEm, c = r + (o - l.advanceWidth * s) / 2, u = a + h.hhea.ascender * s;
|
|
115
145
|
return this._createGlyphPath(h, l, c, u, d).toSVG() || null;
|
|
116
146
|
}
|
|
117
147
|
}
|
|
118
|
-
class
|
|
148
|
+
class le {
|
|
119
149
|
constructor() {
|
|
120
150
|
p(this, "_pathGenerator");
|
|
121
|
-
this._pathGenerator = new
|
|
151
|
+
this._pathGenerator = new ne();
|
|
122
152
|
}
|
|
123
|
-
$generateSVGHeader(
|
|
124
|
-
const { width: t, height:
|
|
125
|
-
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>`;
|
|
126
156
|
}
|
|
127
157
|
$generateSVGFooter() {
|
|
128
158
|
return "</g></svg>";
|
|
129
159
|
}
|
|
130
|
-
_generateTransformAttribute(
|
|
131
|
-
const { transform:
|
|
132
|
-
if (!
|
|
133
|
-
const o = a.cellX + t.cellWidth / 2,
|
|
134
|
-
if (
|
|
135
|
-
const l =
|
|
136
|
-
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})`);
|
|
137
167
|
}
|
|
138
|
-
return
|
|
168
|
+
return r.rotation && d.push(`rotate(${r.rotation} ${o} ${n})`), ` transform="${d.join(" ")}"`;
|
|
139
169
|
}
|
|
140
|
-
_generateCellBackground(
|
|
141
|
-
if (!
|
|
142
|
-
const { position: a } =
|
|
143
|
-
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}"/>`;
|
|
144
174
|
}
|
|
145
|
-
_generateCharacterPath(
|
|
146
|
-
const o =
|
|
175
|
+
_generateCharacterPath(e, t, r, a) {
|
|
176
|
+
const o = _t(r, e.encodedGlyphSlot);
|
|
147
177
|
if (!o) return "";
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
150
|
-
const { r: d, g: l, b: h, a:
|
|
151
|
-
return a.drawMode === "stroke" ? `<path d="${
|
|
152
|
-
}
|
|
153
|
-
$generateCellContent(
|
|
154
|
-
const o = [],
|
|
155
|
-
|
|
156
|
-
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);
|
|
157
187
|
if (d) {
|
|
158
|
-
const l = this._generateTransformAttribute(
|
|
188
|
+
const l = this._generateTransformAttribute(e, t);
|
|
159
189
|
o.push(l ? `<g${l}>${d}</g>` : d);
|
|
160
190
|
}
|
|
161
191
|
return o.join("");
|
|
162
192
|
}
|
|
163
|
-
$generateSVGContent(
|
|
193
|
+
$generateSVGContent(e, t, r, a) {
|
|
164
194
|
const o = [this.$generateSVGHeader(t), '<g id="ascii-cells">'];
|
|
165
|
-
for (const
|
|
195
|
+
for (const n of e) o.push(this.$generateCellContent(n, t, r, a));
|
|
166
196
|
return o.push(this.$generateSVGFooter()), o.join("");
|
|
167
197
|
}
|
|
168
|
-
$optimizeSVGContent(
|
|
169
|
-
return
|
|
198
|
+
$optimizeSVGContent(e) {
|
|
199
|
+
return e.replace(/\s+/g, " ").replace(/> </g, "><");
|
|
170
200
|
}
|
|
171
201
|
}
|
|
172
|
-
class
|
|
173
|
-
_applyDefaultOptions(
|
|
174
|
-
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 };
|
|
175
205
|
}
|
|
176
|
-
$generateSVG(
|
|
177
|
-
const
|
|
178
|
-
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);
|
|
179
209
|
}
|
|
180
|
-
$saveSVG(
|
|
181
|
-
new
|
|
210
|
+
$saveSVG(e, t = {}) {
|
|
211
|
+
new X().$downloadFile(new Blob([this.$generateSVG(e, t)], { type: "image/svg+xml;charset=utf-8" }), t.filename);
|
|
182
212
|
}
|
|
183
213
|
}
|
|
184
|
-
const
|
|
185
|
-
class
|
|
186
|
-
_applyDefaultOptions(
|
|
187
|
-
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 };
|
|
188
218
|
}
|
|
189
|
-
_validateOptions(
|
|
190
|
-
if (!(
|
|
219
|
+
_validateOptions(e) {
|
|
220
|
+
if (!(e.format in pt)) throw new Error(`Saving '${e.format}' files is not supported`);
|
|
191
221
|
}
|
|
192
|
-
async $generateImageBlob(
|
|
193
|
-
const
|
|
194
|
-
return a.width =
|
|
195
|
-
a.toBlob((
|
|
196
|
-
|
|
197
|
-
},
|
|
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]);
|
|
198
228
|
});
|
|
199
229
|
}
|
|
200
|
-
async $saveImage(
|
|
201
|
-
const
|
|
202
|
-
this._validateOptions(
|
|
203
|
-
const a = await this.$generateImageBlob(
|
|
204
|
-
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);
|
|
205
235
|
}
|
|
206
|
-
async $copyImageToClipboard(
|
|
236
|
+
async $copyImageToClipboard(e, t = {}) {
|
|
207
237
|
if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.write != "function") throw new Error("Clipboard API is not available in this environment");
|
|
208
|
-
const
|
|
209
|
-
this._validateOptions(
|
|
210
|
-
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 });
|
|
211
241
|
await navigator.clipboard.write([o]);
|
|
212
242
|
}
|
|
213
243
|
}
|
|
214
|
-
class
|
|
215
|
-
_applyDefaultOptions(
|
|
216
|
-
return { preserveTrailingSpaces:
|
|
244
|
+
class It {
|
|
245
|
+
_applyDefaultOptions(e) {
|
|
246
|
+
return { preserveTrailingSpaces: e.preserveTrailingSpaces ?? !1, emptyCharacter: e.emptyCharacter ?? " ", filename: e.filename, layer: e.layer };
|
|
217
247
|
}
|
|
218
|
-
_createTXTContent(
|
|
248
|
+
_createTXTContent(e, t) {
|
|
219
249
|
var l;
|
|
220
|
-
const
|
|
250
|
+
const r = new xt(), a = lt(e, t.layer), o = r.$extractFramebufferData(a.drawFramebuffer), n = [];
|
|
221
251
|
let d = 0;
|
|
222
|
-
for (let h = 0; h <
|
|
223
|
-
let
|
|
224
|
-
for (let c = 0; c <
|
|
225
|
-
const u = 4 * d, f =
|
|
226
|
-
|
|
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++;
|
|
227
257
|
}
|
|
228
|
-
t.preserveTrailingSpaces || (
|
|
258
|
+
t.preserveTrailingSpaces || (s = s.trimEnd()), n.push(s);
|
|
229
259
|
}
|
|
230
|
-
return
|
|
260
|
+
return n.join(`
|
|
231
261
|
`);
|
|
232
262
|
}
|
|
233
|
-
$generateTXT(
|
|
234
|
-
return this._createTXTContent(
|
|
263
|
+
$generateTXT(e, t = {}) {
|
|
264
|
+
return this._createTXTContent(e, this._applyDefaultOptions(t));
|
|
235
265
|
}
|
|
236
|
-
$saveTXT(
|
|
237
|
-
const
|
|
238
|
-
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);
|
|
239
269
|
}
|
|
240
270
|
}
|
|
241
|
-
class
|
|
271
|
+
class de {
|
|
242
272
|
constructor() {
|
|
243
273
|
p(this, "_canvas");
|
|
244
274
|
p(this, "_ctx");
|
|
245
275
|
}
|
|
246
|
-
async $record(
|
|
247
|
-
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));
|
|
248
278
|
return await new Promise((l, h) => {
|
|
249
|
-
const
|
|
279
|
+
const s = [];
|
|
250
280
|
let c, u = 0, f = !1;
|
|
251
|
-
const
|
|
281
|
+
const x = () => {
|
|
252
282
|
c && (c(), c = void 0);
|
|
253
283
|
}, m = (w) => {
|
|
254
|
-
f || (f = !0,
|
|
284
|
+
f || (f = !0, x(), l(w));
|
|
255
285
|
}, v = () => {
|
|
256
|
-
if (u >= d) m(
|
|
286
|
+
if (u >= d) m(s);
|
|
257
287
|
else try {
|
|
258
|
-
const w = t.scale,
|
|
259
|
-
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"));
|
|
260
290
|
const E = this._ctx;
|
|
261
|
-
E.imageSmoothingEnabled = !1, E.clearRect(0, 0,
|
|
262
|
-
const
|
|
263
|
-
|
|
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);
|
|
264
294
|
} catch (w) {
|
|
265
|
-
((
|
|
295
|
+
((y) => {
|
|
266
296
|
if (f) return;
|
|
267
|
-
f = !0,
|
|
268
|
-
const g =
|
|
269
|
-
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)));
|
|
270
300
|
})(w);
|
|
271
301
|
}
|
|
272
302
|
};
|
|
273
|
-
c =
|
|
303
|
+
c = r(() => {
|
|
274
304
|
v();
|
|
275
305
|
}), a == null || a({ state: "recording", frameIndex: 0, totalFrames: d });
|
|
276
306
|
});
|
|
277
307
|
}
|
|
278
308
|
}
|
|
279
|
-
var
|
|
280
|
-
for (var t in
|
|
281
|
-
},
|
|
282
|
-
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) {
|
|
283
313
|
return 0.29889531 * c + 0.58662247 * u + 0.11448223 * f;
|
|
284
314
|
}
|
|
285
315
|
function t(c, u, f) {
|
|
286
316
|
return 0.59597799 * c - 0.2741761 * u - 0.32180189 * f;
|
|
287
317
|
}
|
|
288
|
-
function
|
|
318
|
+
function r(c, u, f) {
|
|
289
319
|
return 0.21147017 * c - 0.52261711 * u + 0.31114694 * f;
|
|
290
320
|
}
|
|
291
321
|
function a(c, u) {
|
|
292
|
-
let f = c[0] - u[0],
|
|
293
|
-
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;
|
|
294
324
|
}
|
|
295
325
|
function o(c) {
|
|
296
326
|
return c[3] != null ? c[3] : 255;
|
|
297
327
|
}
|
|
298
|
-
function
|
|
328
|
+
function n(c, u) {
|
|
299
329
|
return Math.sqrt(a(c, u));
|
|
300
330
|
}
|
|
301
331
|
function d(c, u) {
|
|
302
|
-
let [f,
|
|
303
|
-
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;
|
|
304
334
|
}
|
|
305
335
|
function l(c, u) {
|
|
306
336
|
return Math.sqrt(d(c, u));
|
|
307
337
|
}
|
|
308
338
|
function h(c, u) {
|
|
309
|
-
var f,
|
|
339
|
+
var f, x = 0;
|
|
310
340
|
for (f = 0; f < c.length; f++) {
|
|
311
341
|
let m = c[f] - u[f];
|
|
312
|
-
|
|
342
|
+
x += m * m;
|
|
313
343
|
}
|
|
314
|
-
return
|
|
344
|
+
return x;
|
|
315
345
|
}
|
|
316
|
-
function
|
|
346
|
+
function s(c, u) {
|
|
317
347
|
return Math.sqrt(h(c, u));
|
|
318
348
|
}
|
|
319
|
-
|
|
320
|
-
}),
|
|
321
|
-
function
|
|
322
|
-
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);
|
|
323
353
|
return { get buffer() {
|
|
324
354
|
return t.buffer;
|
|
325
355
|
}, reset() {
|
|
326
|
-
|
|
327
|
-
}, bytesView: () => t.subarray(0,
|
|
328
|
-
e
|
|
329
|
-
}, writeBytes(a, o = 0,
|
|
330
|
-
e
|
|
331
|
-
for (let d = 0; d <
|
|
332
|
-
}, writeBytesView(a, o = 0,
|
|
333
|
-
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;
|
|
334
364
|
} };
|
|
335
|
-
function
|
|
365
|
+
function r(a) {
|
|
336
366
|
var o = t.length;
|
|
337
367
|
if (o >= a) return;
|
|
338
368
|
a = Math.max(a, o * (o < 1048576 ? 2 : 1.125) >>> 0), o != 0 && (a = Math.max(a, 256));
|
|
339
|
-
let
|
|
340
|
-
t = new Uint8Array(a),
|
|
369
|
+
let n = t;
|
|
370
|
+
t = new Uint8Array(a), e > 0 && t.set(n.subarray(0, e), 0);
|
|
341
371
|
}
|
|
342
372
|
}
|
|
343
|
-
var
|
|
344
|
-
function
|
|
345
|
-
a = a ||
|
|
346
|
-
let l =
|
|
347
|
-
o.fill(0), d.fill(0),
|
|
348
|
-
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;
|
|
349
379
|
for (let B = l; B < 65536; B *= 2) ++k;
|
|
350
380
|
k = 8 - k, a.writeByte(h), R(w);
|
|
351
381
|
for (let B = 1; B < t.length; B++) V(t[B]);
|
|
352
|
-
return R(
|
|
353
|
-
function
|
|
382
|
+
return R(L), R(y), a.writeByte(0), a.bytesView();
|
|
383
|
+
function O(B) {
|
|
354
384
|
o[E++] = B, E >= 254 && S();
|
|
355
385
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
386
|
+
function F() {
|
|
387
|
+
n.fill(-1);
|
|
358
388
|
}
|
|
359
389
|
function V(B) {
|
|
360
|
-
let N = (B <<
|
|
361
|
-
if (
|
|
390
|
+
let N = (B << et) + L, _ = B << k ^ L;
|
|
391
|
+
if (n[_] === N) L = d[_];
|
|
362
392
|
else {
|
|
363
|
-
if (
|
|
393
|
+
if (n[_] >= 0) {
|
|
364
394
|
let C = _ === 0 ? 1 : l - _;
|
|
365
395
|
do
|
|
366
|
-
if (_ -= C, _ < 0 && (_ += l),
|
|
367
|
-
while (
|
|
396
|
+
if (_ -= C, _ < 0 && (_ += l), n[_] === N) return void (L = d[_]);
|
|
397
|
+
while (n[_] >= 0);
|
|
368
398
|
}
|
|
369
|
-
R(
|
|
399
|
+
R(L), L = B, g < 1 << et ? (d[_] = g++, n[_] = N) : (F(), g = w + 2, x = !0, R(w));
|
|
370
400
|
}
|
|
371
401
|
}
|
|
372
402
|
function S() {
|
|
373
403
|
E > 0 && (a.writeByte(E), a.writeBytesView(o, 0, E), E = 0);
|
|
374
404
|
}
|
|
375
|
-
function
|
|
405
|
+
function A(B) {
|
|
376
406
|
return (1 << B) - 1;
|
|
377
407
|
}
|
|
378
408
|
function R(B) {
|
|
379
|
-
for (
|
|
380
|
-
if ((g > v ||
|
|
381
|
-
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;
|
|
382
412
|
S();
|
|
383
413
|
}
|
|
384
414
|
}
|
|
385
415
|
}
|
|
386
|
-
var
|
|
387
|
-
function
|
|
388
|
-
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;
|
|
389
419
|
}
|
|
390
|
-
function
|
|
391
|
-
return i >> 4 | 240 &
|
|
420
|
+
function Ht(i, e, t, r) {
|
|
421
|
+
return i >> 4 | 240 & e | (240 & t) << 4 | (240 & r) << 8;
|
|
392
422
|
}
|
|
393
|
-
function
|
|
394
|
-
return i >> 4 << 8 |
|
|
423
|
+
function Xt(i, e, t) {
|
|
424
|
+
return i >> 4 << 8 | e >> 4 << 4 | t >> 4;
|
|
395
425
|
}
|
|
396
|
-
function
|
|
397
|
-
return i <
|
|
426
|
+
function rt(i, e, t) {
|
|
427
|
+
return i < e ? e : i > t ? t : i;
|
|
398
428
|
}
|
|
399
|
-
function
|
|
429
|
+
function it(i) {
|
|
400
430
|
return i * i;
|
|
401
431
|
}
|
|
402
|
-
function
|
|
403
|
-
for (var
|
|
404
|
-
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);
|
|
405
435
|
if (!(u >= a)) {
|
|
406
436
|
var f = 0;
|
|
407
|
-
!((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);
|
|
408
438
|
}
|
|
409
439
|
}
|
|
410
|
-
o.err = a, o.nn =
|
|
440
|
+
o.err = a, o.nn = r;
|
|
411
441
|
}
|
|
412
|
-
function
|
|
442
|
+
function mt() {
|
|
413
443
|
return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
|
|
414
444
|
}
|
|
415
|
-
function
|
|
416
|
-
let t = new Array(
|
|
417
|
-
if (
|
|
418
|
-
let o = i[a],
|
|
419
|
-
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++;
|
|
420
450
|
}
|
|
421
|
-
else if (
|
|
422
|
-
let o = i[a],
|
|
423
|
-
|
|
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++;
|
|
424
454
|
}
|
|
425
|
-
else for (let a = 0; a <
|
|
426
|
-
let o = i[a],
|
|
427
|
-
|
|
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++;
|
|
428
458
|
}
|
|
429
459
|
return t;
|
|
430
460
|
}
|
|
431
|
-
function
|
|
432
|
-
let { format:
|
|
433
|
-
for (var
|
|
434
|
-
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];
|
|
435
465
|
if (B != null) {
|
|
436
466
|
var v = 1 / B.cnt;
|
|
437
|
-
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;
|
|
438
468
|
}
|
|
439
469
|
}
|
|
440
|
-
for (
|
|
441
|
-
var w,
|
|
442
|
-
for (l && (
|
|
443
|
-
|
|
444
|
-
var E =
|
|
445
|
-
for (
|
|
446
|
-
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;
|
|
447
477
|
}
|
|
448
|
-
var
|
|
449
|
-
for (m = 0; m <
|
|
478
|
+
var L = x - e;
|
|
479
|
+
for (m = 0; m < L; ) {
|
|
450
480
|
for (var k; ; ) {
|
|
451
|
-
var
|
|
452
|
-
if ((k =
|
|
453
|
-
for (k.mtm == u ?
|
|
454
|
-
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;
|
|
455
485
|
}
|
|
456
|
-
var
|
|
457
|
-
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;
|
|
458
488
|
}
|
|
459
|
-
let
|
|
489
|
+
let A = [];
|
|
460
490
|
var R = 0;
|
|
461
491
|
for (m = 0; ; ++R) {
|
|
462
|
-
let B =
|
|
463
|
-
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));
|
|
464
494
|
let M = h ? [B, N, _, C] : [B, N, _];
|
|
465
|
-
if (
|
|
495
|
+
if (xe(A, M) || A.push(M), (m = s[m].fw) == 0) break;
|
|
466
496
|
}
|
|
467
|
-
return
|
|
497
|
+
return A;
|
|
468
498
|
}
|
|
469
|
-
function
|
|
499
|
+
function xe(i, e) {
|
|
470
500
|
for (let t = 0; t < i.length; t++) {
|
|
471
|
-
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];
|
|
472
502
|
if (a && o) return !0;
|
|
473
503
|
}
|
|
474
504
|
return !1;
|
|
475
505
|
}
|
|
476
|
-
function
|
|
477
|
-
let
|
|
478
|
-
if (t === "rgba4444") for (let
|
|
479
|
-
let d, l = i[
|
|
480
|
-
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;
|
|
481
511
|
}
|
|
482
|
-
else for (let
|
|
483
|
-
let d, l = i[
|
|
484
|
-
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;
|
|
485
515
|
}
|
|
486
516
|
return a;
|
|
487
517
|
}
|
|
488
|
-
function
|
|
489
|
-
let o = 0,
|
|
518
|
+
function we(i, e, t, r, a) {
|
|
519
|
+
let o = 0, n = 1e100;
|
|
490
520
|
for (let d = 0; d < a.length; d++) {
|
|
491
|
-
let l = a[d], h = l[0],
|
|
492
|
-
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))));
|
|
493
523
|
}
|
|
494
524
|
return o;
|
|
495
525
|
}
|
|
496
|
-
function
|
|
526
|
+
function Ce(i, e, t, r) {
|
|
497
527
|
let a = 0, o = 1e100;
|
|
498
|
-
for (let
|
|
499
|
-
let d =
|
|
500
|
-
c > o || (c +=
|
|
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)));
|
|
501
531
|
}
|
|
502
532
|
return a;
|
|
503
533
|
}
|
|
504
|
-
function
|
|
534
|
+
function W(i) {
|
|
505
535
|
return i * i;
|
|
506
536
|
}
|
|
507
|
-
function
|
|
508
|
-
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;
|
|
509
539
|
return { reset() {
|
|
510
|
-
|
|
540
|
+
r.reset(), d = !1;
|
|
511
541
|
}, finish() {
|
|
512
|
-
|
|
513
|
-
}, bytes: () =>
|
|
514
|
-
return
|
|
542
|
+
r.writeByte(me.trailer);
|
|
543
|
+
}, bytes: () => r.bytes(), bytesView: () => r.bytesView(), get buffer() {
|
|
544
|
+
return r.buffer;
|
|
515
545
|
}, get stream() {
|
|
516
|
-
return
|
|
517
|
-
}, writeHeader: l, writeFrame(h,
|
|
518
|
-
let { transparent: f = !1, transparentIndex:
|
|
519
|
-
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) {
|
|
520
550
|
if (!v) throw new Error("First frame must include a { palette } option");
|
|
521
|
-
|
|
551
|
+
Be(r, s, c, v, y), Ft(r, v), w >= 0 && Se(r, w);
|
|
522
552
|
}
|
|
523
|
-
let
|
|
524
|
-
|
|
553
|
+
let L = Math.round(m / 10);
|
|
554
|
+
ke(r, g, L, f, x);
|
|
525
555
|
let k = !!v && !E;
|
|
526
|
-
|
|
556
|
+
Ie(r, s, c, k ? v : null), k && Ft(r, v), Le(r, h, s, c, y, a, o, n);
|
|
527
557
|
} };
|
|
528
558
|
function l() {
|
|
529
|
-
|
|
559
|
+
Jt(r, "GIF89a");
|
|
530
560
|
}
|
|
531
561
|
}
|
|
532
|
-
function
|
|
533
|
-
var o,
|
|
534
|
-
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);
|
|
535
565
|
}
|
|
536
|
-
function
|
|
537
|
-
let o = 128 | a - 1 << 4 |
|
|
538
|
-
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]);
|
|
539
569
|
}
|
|
540
|
-
function
|
|
541
|
-
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);
|
|
542
572
|
}
|
|
543
|
-
function
|
|
544
|
-
let t = 1 <<
|
|
545
|
-
for (let
|
|
573
|
+
function Ft(i, e) {
|
|
574
|
+
let t = 1 << wt(e.length);
|
|
575
|
+
for (let r = 0; r < t; r++) {
|
|
546
576
|
let a = [0, 0, 0];
|
|
547
|
-
|
|
577
|
+
r < e.length && (a = e[r]), i.writeByte(a[0]), i.writeByte(a[1]), i.writeByte(a[2]);
|
|
548
578
|
}
|
|
549
579
|
}
|
|
550
|
-
function
|
|
551
|
-
if (i.writeByte(44), G(i, 0), G(i, 0), G(i,
|
|
552
|
-
let a = 0, o = 0,
|
|
553
|
-
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);
|
|
554
584
|
} else i.writeByte(0);
|
|
555
585
|
}
|
|
556
|
-
function
|
|
557
|
-
|
|
586
|
+
function Le(i, e, t, r, a = 8, o, n, d) {
|
|
587
|
+
be(t, r, e, a, i, o, n, d);
|
|
558
588
|
}
|
|
559
|
-
function G(i,
|
|
560
|
-
i.writeByte(255 &
|
|
589
|
+
function G(i, e) {
|
|
590
|
+
i.writeByte(255 & e), i.writeByte(e >> 8 & 255);
|
|
561
591
|
}
|
|
562
|
-
function
|
|
563
|
-
for (var t = 0; t <
|
|
592
|
+
function Jt(i, e) {
|
|
593
|
+
for (var t = 0; t < e.length; t++) i.writeByte(e.charCodeAt(t));
|
|
564
594
|
}
|
|
565
|
-
function
|
|
595
|
+
function wt(i) {
|
|
566
596
|
return Math.max(Math.ceil(Math.log2(i)), 1);
|
|
567
597
|
}
|
|
568
|
-
|
|
569
|
-
class
|
|
570
|
-
constructor(
|
|
598
|
+
he();
|
|
599
|
+
class Me {
|
|
600
|
+
constructor(e, t) {
|
|
571
601
|
p(this, "_recorder");
|
|
572
602
|
p(this, "_textmodifier");
|
|
573
603
|
p(this, "_registerPostDrawHook");
|
|
574
|
-
this._recorder = new
|
|
604
|
+
this._recorder = new de(), this._textmodifier = e, this._registerPostDrawHook = t;
|
|
575
605
|
}
|
|
576
|
-
async $saveGIF(
|
|
577
|
-
const t = this._textmodifier.canvas,
|
|
606
|
+
async $saveGIF(e = {}) {
|
|
607
|
+
const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e), a = e.onProgress;
|
|
578
608
|
try {
|
|
579
|
-
const o = await this._recorder.$record(t,
|
|
580
|
-
for (let
|
|
581
|
-
const c = o[
|
|
582
|
-
|
|
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)));
|
|
583
613
|
}
|
|
584
|
-
|
|
585
|
-
const l =
|
|
586
|
-
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 });
|
|
587
617
|
} catch (o) {
|
|
588
618
|
throw a == null || a({ state: "error", message: o instanceof Error ? o.message : "GIF export failed" }), o;
|
|
589
619
|
}
|
|
590
620
|
}
|
|
591
|
-
_applyDefaultOptions(
|
|
592
|
-
const t = Math.abs(Math.round(
|
|
593
|
-
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 };
|
|
594
624
|
}
|
|
595
625
|
}
|
|
596
|
-
function
|
|
626
|
+
function Fe(i) {
|
|
597
627
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
598
628
|
}
|
|
599
|
-
var
|
|
600
|
-
function
|
|
601
|
-
return
|
|
602
|
-
function
|
|
603
|
-
return (function(
|
|
604
|
-
if (typeof
|
|
605
|
-
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));
|
|
606
636
|
})(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", h));
|
|
607
637
|
}
|
|
608
638
|
function t(l) {
|
|
609
639
|
return (l.charCodeAt(0) | l.charCodeAt(1) << 8 | l.charCodeAt(2) << 16 | l.charCodeAt(3) << 24) >>> 0;
|
|
610
640
|
}
|
|
611
|
-
function
|
|
641
|
+
function r(l) {
|
|
612
642
|
let h = l.indexOf("VP8", 12);
|
|
613
643
|
if (h === -1) throw new Error("Bad image format, does this browser support WebP?");
|
|
614
|
-
let
|
|
644
|
+
let s = !1;
|
|
615
645
|
for (; h < l.length - 8; ) {
|
|
616
646
|
let c, u;
|
|
617
647
|
switch (u = l.substring(h, h + 4), h += 4, c = t(l.substring(h, h + 4)), h += 4, u) {
|
|
618
648
|
case "VP8 ":
|
|
619
|
-
return { frame: l.substring(h, h + c), hasAlpha:
|
|
649
|
+
return { frame: l.substring(h, h + c), hasAlpha: s };
|
|
620
650
|
case "ALPH":
|
|
621
|
-
|
|
651
|
+
s = !0;
|
|
622
652
|
}
|
|
623
653
|
h += c, 1 & c && h++;
|
|
624
654
|
}
|
|
@@ -630,46 +660,46 @@ function ke() {
|
|
|
630
660
|
function o(l) {
|
|
631
661
|
this.value = l;
|
|
632
662
|
}
|
|
633
|
-
function
|
|
634
|
-
if (Array.isArray(
|
|
635
|
-
else if (typeof
|
|
636
|
-
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);
|
|
637
667
|
else {
|
|
638
|
-
if (!
|
|
639
|
-
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)) {
|
|
640
670
|
let c, u, f;
|
|
641
|
-
|
|
642
|
-
} else if (typeof
|
|
643
|
-
else if (typeof
|
|
644
|
-
else if (
|
|
645
|
-
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);
|
|
646
676
|
else {
|
|
647
|
-
if (!(
|
|
648
|
-
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);
|
|
649
679
|
}
|
|
650
680
|
}
|
|
651
681
|
}
|
|
652
682
|
let d = function(l, h) {
|
|
653
|
-
return function(
|
|
654
|
-
let c, u, f = !1,
|
|
655
|
-
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(_) {
|
|
656
686
|
return _ - c.dataOffset;
|
|
657
687
|
}
|
|
658
688
|
function R() {
|
|
659
689
|
u = (function() {
|
|
660
690
|
let $ = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
|
|
661
|
-
for (let I in
|
|
662
|
-
let
|
|
663
|
-
|
|
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] });
|
|
664
694
|
}
|
|
665
695
|
return U;
|
|
666
696
|
})();
|
|
667
|
-
let _ = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" },
|
|
668
|
-
|
|
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 });
|
|
669
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 }] }] };
|
|
670
700
|
c = { id: 408125543, size: -2, data: [u, _, M] };
|
|
671
701
|
let P = new l(256);
|
|
672
|
-
|
|
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;
|
|
673
703
|
}
|
|
674
704
|
function B(_) {
|
|
675
705
|
return _.alpha ? (function(C) {
|
|
@@ -691,80 +721,80 @@ function ke() {
|
|
|
691
721
|
})({ timecode: Math.round(E) });
|
|
692
722
|
for (let I = 0; I < g.length; I++) M.data.push(B(g[I]));
|
|
693
723
|
var P, $, U;
|
|
694
|
-
|
|
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;
|
|
695
725
|
}
|
|
696
726
|
this.addFrame = function(_, C, M) {
|
|
697
|
-
f || (
|
|
698
|
-
let P, $ = e(
|
|
699
|
-
P = M || (typeof C == "number" ? C :
|
|
700
|
-
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"),
|
|
701
|
-
let
|
|
702
|
-
for (let
|
|
703
|
-
let
|
|
704
|
-
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;
|
|
705
735
|
}
|
|
706
|
-
return w.putImageData(
|
|
736
|
+
return w.putImageData(y, 0, 0), v;
|
|
707
737
|
})(_))), (function(I) {
|
|
708
|
-
I.trackNumber = 1, I.timecode = Math.round(
|
|
709
|
-
})({ 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 });
|
|
710
740
|
}, this.complete = function() {
|
|
711
741
|
return f || R(), N(), (function() {
|
|
712
742
|
let _ = { id: 475249515, data: V }, C = new l(16 + 32 * V.length);
|
|
713
|
-
|
|
743
|
+
n(C, S.pos, _), S.write(C.getAsDataArray()), O.Cues.positionEBML.data = A(_.offset);
|
|
714
744
|
})(), (function() {
|
|
715
745
|
let _ = new l(u.size), C = S.pos;
|
|
716
|
-
|
|
746
|
+
n(_, u.dataOffset, u.data), S.seek(u.dataOffset), S.write(_.getAsDataArray()), S.seek(C);
|
|
717
747
|
})(), (function() {
|
|
718
748
|
let _ = new l(8), C = S.pos;
|
|
719
|
-
_.writeDoubleBE(E), S.seek(
|
|
749
|
+
_.writeDoubleBE(E), S.seek(F.dataOffset), S.write(_.getAsDataArray()), S.seek(C);
|
|
720
750
|
})(), (function() {
|
|
721
751
|
let _ = new l(10), C = S.pos;
|
|
722
752
|
_.writeUnsignedIntBE(c.id), _.writeEBMLVarIntWidth(S.pos - c.dataOffset, 5), S.seek(c.offset), S.write(_.getAsDataArray()), S.seek(C);
|
|
723
753
|
})(), S.complete("video/webm");
|
|
724
754
|
}, this.getWrittenSize = function() {
|
|
725
755
|
return S.length;
|
|
726
|
-
},
|
|
756
|
+
}, s = (function(_, C) {
|
|
727
757
|
let M = {};
|
|
728
758
|
return [_, C].forEach(function(P) {
|
|
729
759
|
for (let $ in P) Object.prototype.hasOwnProperty.call(P, $) && (M[$] = P[$]);
|
|
730
760
|
}), M;
|
|
731
|
-
})(k,
|
|
732
|
-
if (!
|
|
733
|
-
if (!
|
|
734
|
-
|
|
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;
|
|
735
765
|
}
|
|
736
|
-
|
|
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);
|
|
737
767
|
})();
|
|
738
768
|
};
|
|
739
769
|
};
|
|
740
770
|
i.exports = d;
|
|
741
|
-
})()),
|
|
771
|
+
})()), Tt.exports;
|
|
742
772
|
var i;
|
|
743
773
|
}
|
|
744
|
-
var
|
|
745
|
-
function
|
|
746
|
-
return
|
|
747
|
-
let
|
|
774
|
+
var Pt, Ot = { exports: {} };
|
|
775
|
+
function Te() {
|
|
776
|
+
return Pt || (Pt = 1, i = Ot, (function() {
|
|
777
|
+
let e = function(t) {
|
|
748
778
|
this.data = new Uint8Array(t), this.pos = 0;
|
|
749
779
|
};
|
|
750
|
-
|
|
780
|
+
e.prototype.seek = function(t) {
|
|
751
781
|
this.pos = t;
|
|
752
|
-
},
|
|
753
|
-
for (let
|
|
754
|
-
},
|
|
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) {
|
|
755
785
|
this.data[this.pos++] = t;
|
|
756
|
-
},
|
|
786
|
+
}, e.prototype.writeU8 = e.prototype.writeByte, e.prototype.writeU16BE = function(t) {
|
|
757
787
|
this.data[this.pos++] = t >> 8, this.data[this.pos++] = t;
|
|
758
|
-
},
|
|
759
|
-
let
|
|
760
|
-
for (let a =
|
|
761
|
-
},
|
|
762
|
-
let
|
|
763
|
-
for (let a =
|
|
764
|
-
},
|
|
765
|
-
for (let
|
|
766
|
-
},
|
|
767
|
-
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) {
|
|
768
798
|
case 1:
|
|
769
799
|
this.writeU8(128 | t);
|
|
770
800
|
break;
|
|
@@ -781,19 +811,19 @@ function Be() {
|
|
|
781
811
|
this.writeU8(8 | t / 4294967296 & 7), this.writeU8(t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
|
|
782
812
|
break;
|
|
783
813
|
default:
|
|
784
|
-
throw new Error("Bad EBML VINT size " +
|
|
814
|
+
throw new Error("Bad EBML VINT size " + r);
|
|
785
815
|
}
|
|
786
|
-
},
|
|
816
|
+
}, e.prototype.measureEBMLVarInt = function(t) {
|
|
787
817
|
if (t < 127) return 1;
|
|
788
818
|
if (t < 16383) return 2;
|
|
789
819
|
if (t < 2097151) return 3;
|
|
790
820
|
if (t < 268435455) return 4;
|
|
791
821
|
if (t < 34359738367) return 5;
|
|
792
822
|
throw new Error("EBML VINT size not supported " + t);
|
|
793
|
-
},
|
|
823
|
+
}, e.prototype.writeEBMLVarInt = function(t) {
|
|
794
824
|
this.writeEBMLVarIntWidth(t, this.measureEBMLVarInt(t));
|
|
795
|
-
},
|
|
796
|
-
switch (
|
|
825
|
+
}, e.prototype.writeUnsignedIntBE = function(t, r) {
|
|
826
|
+
switch (r === void 0 && (r = this.measureUnsignedInt(t)), r) {
|
|
797
827
|
case 5:
|
|
798
828
|
this.writeU8(Math.floor(t / 4294967296));
|
|
799
829
|
case 4:
|
|
@@ -806,67 +836,67 @@ function Be() {
|
|
|
806
836
|
this.writeU8(t);
|
|
807
837
|
break;
|
|
808
838
|
default:
|
|
809
|
-
throw new Error("Bad UINT size " +
|
|
839
|
+
throw new Error("Bad UINT size " + r);
|
|
810
840
|
}
|
|
811
|
-
},
|
|
841
|
+
}, e.prototype.measureUnsignedInt = function(t) {
|
|
812
842
|
return t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 4294967296 ? 4 : 5;
|
|
813
|
-
},
|
|
843
|
+
}, e.prototype.getAsDataArray = function() {
|
|
814
844
|
if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
|
|
815
845
|
if (this.pos == this.data.byteLength) return this.data;
|
|
816
846
|
throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
|
|
817
|
-
}, i.exports =
|
|
818
|
-
})()),
|
|
847
|
+
}, i.exports = e;
|
|
848
|
+
})()), Ot.exports;
|
|
819
849
|
var i;
|
|
820
850
|
}
|
|
821
|
-
var
|
|
822
|
-
function
|
|
823
|
-
return
|
|
824
|
-
let
|
|
825
|
-
return function(
|
|
826
|
-
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;
|
|
827
857
|
function l(c) {
|
|
828
858
|
return new Promise(function(u, f) {
|
|
829
|
-
let
|
|
830
|
-
|
|
831
|
-
u(
|
|
832
|
-
}),
|
|
859
|
+
let x = new FileReader();
|
|
860
|
+
x.addEventListener("loadend", function() {
|
|
861
|
+
u(x.result);
|
|
862
|
+
}), x.readAsArrayBuffer(c);
|
|
833
863
|
});
|
|
834
864
|
}
|
|
835
865
|
function h(c) {
|
|
836
866
|
return new Promise(function(u, f) {
|
|
837
|
-
c instanceof Uint8Array ? u(c) : c instanceof ArrayBuffer || ArrayBuffer.isView(c) ? u(new Uint8Array(c)) : c instanceof Blob ? u(l(c).then(function(
|
|
838
|
-
return new Uint8Array(
|
|
839
|
-
})) : u(l(new Blob([c])).then(function(
|
|
840
|
-
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);
|
|
841
871
|
}));
|
|
842
872
|
});
|
|
843
873
|
}
|
|
844
|
-
function
|
|
874
|
+
function s(c) {
|
|
845
875
|
let u = c.byteLength || c.length || c.size;
|
|
846
876
|
if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
|
|
847
877
|
return u;
|
|
848
878
|
}
|
|
849
|
-
|
|
879
|
+
r && r.constructor.name === "FileWriter" ? n = r : t && r && (d = r), this.pos = 0, this.length = 0, this.seek = function(c) {
|
|
850
880
|
if (c < 0) throw new Error("Offset may not be negative");
|
|
851
881
|
if (isNaN(c)) throw new Error("Offset may not be NaN");
|
|
852
882
|
if (c > this.length) throw new Error("Seeking beyond the end of file is not allowed");
|
|
853
883
|
this.pos = c;
|
|
854
884
|
}, this.write = function(c) {
|
|
855
|
-
let u = { offset: this.pos, data: c, length:
|
|
885
|
+
let u = { offset: this.pos, data: c, length: s(c) }, f = u.offset >= this.length;
|
|
856
886
|
this.pos += u.length, this.length = Math.max(this.length, this.pos), o = o.then(function() {
|
|
857
|
-
if (d) return new Promise(function(
|
|
887
|
+
if (d) return new Promise(function(x, m) {
|
|
858
888
|
h(u.data).then(function(v) {
|
|
859
|
-
let w = 0,
|
|
860
|
-
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);
|
|
861
891
|
};
|
|
862
|
-
t.write(d,
|
|
892
|
+
t.write(d, y, 0, y.length, u.offset, g);
|
|
863
893
|
});
|
|
864
894
|
});
|
|
865
|
-
if (
|
|
866
|
-
|
|
895
|
+
if (n) return new Promise(function(x, m) {
|
|
896
|
+
n.onwriteend = x, n.seek(u.offset), n.write(new Blob([u.data]));
|
|
867
897
|
});
|
|
868
|
-
if (!f) for (let
|
|
869
|
-
let m = a[
|
|
898
|
+
if (!f) for (let x = 0; x < a.length; x++) {
|
|
899
|
+
let m = a[x];
|
|
870
900
|
if (!(u.offset + u.length <= m.offset || u.offset >= m.offset + m.length)) {
|
|
871
901
|
if (u.offset < m.offset || u.offset + u.length > m.offset + m.length) throw new Error("Overwrite crosses blob boundaries");
|
|
872
902
|
return u.offset == m.offset && u.length == m.length ? void (m.data = u.data) : h(m.data).then(function(v) {
|
|
@@ -879,7 +909,7 @@ function Se() {
|
|
|
879
909
|
a.push(u);
|
|
880
910
|
});
|
|
881
911
|
}, this.complete = function(c) {
|
|
882
|
-
return o = d ||
|
|
912
|
+
return o = d || n ? o.then(function() {
|
|
883
913
|
return null;
|
|
884
914
|
}) : o.then(function() {
|
|
885
915
|
let u = [];
|
|
@@ -889,42 +919,42 @@ function Se() {
|
|
|
889
919
|
};
|
|
890
920
|
};
|
|
891
921
|
};
|
|
892
|
-
i.exports =
|
|
893
|
-
})()),
|
|
922
|
+
i.exports = e;
|
|
923
|
+
})()), Rt.exports;
|
|
894
924
|
var i;
|
|
895
925
|
}
|
|
896
|
-
function
|
|
897
|
-
return
|
|
926
|
+
function Oe() {
|
|
927
|
+
return Vt ? Dt : (Vt = 1, Dt = $e()(Te(), Pe()(null)));
|
|
898
928
|
}
|
|
899
|
-
var
|
|
900
|
-
const
|
|
901
|
-
class
|
|
902
|
-
async $record(
|
|
903
|
-
const o = Math.max(1, Math.round(t.frameRate)),
|
|
904
|
-
return await new Promise((h,
|
|
905
|
-
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;
|
|
906
936
|
const m = () => {
|
|
907
937
|
c && (c(), c = void 0);
|
|
908
938
|
}, v = () => {
|
|
909
|
-
a == null || a({ state: "recording", frameIndex:
|
|
939
|
+
a == null || a({ state: "recording", frameIndex: x, totalFrames: n });
|
|
910
940
|
}, w = (g) => {
|
|
911
941
|
if (f) return;
|
|
912
942
|
f = !0, m();
|
|
913
943
|
const E = g instanceof Error ? g.message : "WEBM export failed";
|
|
914
|
-
a == null || a({ state: "error", message: E }),
|
|
915
|
-
},
|
|
944
|
+
a == null || a({ state: "error", message: E }), s(g instanceof Error ? g : new Error(String(g)));
|
|
945
|
+
}, y = () => {
|
|
916
946
|
u !== "capturing" || f || (u = "encoding", m(), d.complete().then((g) => {
|
|
917
947
|
((E) => {
|
|
918
|
-
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));
|
|
919
949
|
})(g);
|
|
920
950
|
}).catch(w));
|
|
921
951
|
};
|
|
922
|
-
c =
|
|
952
|
+
c = r(() => {
|
|
923
953
|
(() => {
|
|
924
|
-
if (u === "capturing") if (
|
|
954
|
+
if (u === "capturing") if (x >= n) y();
|
|
925
955
|
else try {
|
|
926
|
-
const g = l(
|
|
927
|
-
d.addFrame(g),
|
|
956
|
+
const g = l(e);
|
|
957
|
+
d.addFrame(g), x += 1, v(), x >= n && y();
|
|
928
958
|
} catch (g) {
|
|
929
959
|
w(g);
|
|
930
960
|
}
|
|
@@ -933,87 +963,104 @@ class Le {
|
|
|
933
963
|
});
|
|
934
964
|
}
|
|
935
965
|
_createSnapshotSurface() {
|
|
936
|
-
let
|
|
937
|
-
return (
|
|
938
|
-
const a = Math.max(1,
|
|
939
|
-
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;
|
|
940
970
|
};
|
|
941
971
|
}
|
|
942
972
|
}
|
|
943
|
-
class
|
|
944
|
-
constructor(
|
|
973
|
+
class Re {
|
|
974
|
+
constructor(e, t) {
|
|
945
975
|
p(this, "_recorder");
|
|
946
976
|
p(this, "_textmodifier");
|
|
947
977
|
p(this, "_registerPostDrawHook");
|
|
948
|
-
this._recorder = new
|
|
978
|
+
this._recorder = new Ve(), this._textmodifier = e, this._registerPostDrawHook = t;
|
|
949
979
|
}
|
|
950
|
-
async $saveWEBM(
|
|
980
|
+
async $saveWEBM(e = {}) {
|
|
951
981
|
var a;
|
|
952
|
-
const t = this._textmodifier.canvas,
|
|
982
|
+
const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e);
|
|
953
983
|
try {
|
|
954
|
-
const o = await this._recorder.$record(t,
|
|
955
|
-
new
|
|
984
|
+
const o = await this._recorder.$record(t, r, this._registerPostDrawHook, e.onProgress);
|
|
985
|
+
new X().$downloadFile(o, r.filename);
|
|
956
986
|
} catch (o) {
|
|
957
|
-
throw (a =
|
|
987
|
+
throw (a = e.onProgress) == null || a.call(e, { state: "error", message: o instanceof Error ? o.message : "WEBM export failed" }), o;
|
|
958
988
|
}
|
|
959
989
|
}
|
|
960
|
-
_applyDefaultOptions(
|
|
961
|
-
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 };
|
|
962
992
|
}
|
|
963
993
|
}
|
|
964
|
-
class
|
|
965
|
-
$extractCellData(
|
|
966
|
-
var
|
|
967
|
-
const t =
|
|
968
|
-
let
|
|
969
|
-
for (let
|
|
970
|
-
const
|
|
971
|
-
|
|
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++;
|
|
972
1002
|
}
|
|
973
|
-
return
|
|
1003
|
+
return r;
|
|
974
1004
|
}
|
|
975
1005
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
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;
|
|
980
1012
|
}
|
|
981
|
-
_formatColor(
|
|
982
|
-
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("")}`;
|
|
983
1015
|
}
|
|
984
|
-
_createObjectRowsCells(
|
|
985
|
-
const
|
|
986
|
-
for (let
|
|
987
|
-
const
|
|
988
|
-
|
|
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);
|
|
989
1021
|
}
|
|
990
|
-
return { encoding: "object-rows-v1", rows:
|
|
1022
|
+
return { encoding: "object-rows-v1", rows: o };
|
|
1023
|
+
}
|
|
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);
|
|
991
1030
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
return { $schema: Ae, format: "textmode.layer", formatVersion: "1.0.0", ...e.includeMetadata ? { metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString(), generator: { name: "textmode.export.js", version: "1.2.1" } } } : {}, canvas: { width: r.grid.width, height: r.grid.height }, grid: { cols: r.grid.cols, rows: r.grid.rows, cellWidth: r.grid.cellWidth, cellHeight: r.grid.cellHeight }, layer: { id: "base", cells: o } };
|
|
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) };
|
|
995
1033
|
}
|
|
996
|
-
$
|
|
997
|
-
const
|
|
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) } };
|
|
1042
|
+
}
|
|
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;
|
|
998
1045
|
return JSON.stringify(a, null, o);
|
|
999
1046
|
}
|
|
1000
|
-
$saveJSON(
|
|
1001
|
-
const
|
|
1002
|
-
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);
|
|
1003
1050
|
}
|
|
1004
1051
|
}
|
|
1005
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" };
|
|
1006
|
-
class
|
|
1053
|
+
class D {
|
|
1007
1054
|
constructor() {
|
|
1008
1055
|
p(this, "element");
|
|
1009
1056
|
p(this, "mounted", !1);
|
|
1010
1057
|
p(this, "destroyed", !1);
|
|
1011
1058
|
}
|
|
1012
|
-
mount(
|
|
1059
|
+
mount(e) {
|
|
1013
1060
|
if (this.destroyed) throw new Error("Cannot mount a destroyed component");
|
|
1014
1061
|
if (this.mounted) return;
|
|
1015
1062
|
const t = this.render();
|
|
1016
|
-
|
|
1063
|
+
e.appendChild(t), this.element = t, this.onMount(), this.mounted = !0;
|
|
1017
1064
|
}
|
|
1018
1065
|
unmount() {
|
|
1019
1066
|
this.mounted && this.element && (this._onUnmount(), this.element.remove(), this.element = void 0, this.mounted = !1);
|
|
@@ -1021,8 +1068,8 @@ class T {
|
|
|
1021
1068
|
destroy() {
|
|
1022
1069
|
this.destroyed || (this.unmount(), this._onDestroy(), this.destroyed = !0);
|
|
1023
1070
|
}
|
|
1024
|
-
update(
|
|
1025
|
-
this.mounted && this.onUpdate(
|
|
1071
|
+
update(e) {
|
|
1072
|
+
this.mounted && this.onUpdate(e);
|
|
1026
1073
|
}
|
|
1027
1074
|
onMount() {
|
|
1028
1075
|
}
|
|
@@ -1030,7 +1077,7 @@ class T {
|
|
|
1030
1077
|
}
|
|
1031
1078
|
_onDestroy() {
|
|
1032
1079
|
}
|
|
1033
|
-
onUpdate(
|
|
1080
|
+
onUpdate(e) {
|
|
1034
1081
|
}
|
|
1035
1082
|
get root() {
|
|
1036
1083
|
if (!this.element) throw new Error("Component is not mounted yet");
|
|
@@ -1040,39 +1087,39 @@ class T {
|
|
|
1040
1087
|
return this.mounted;
|
|
1041
1088
|
}
|
|
1042
1089
|
}
|
|
1043
|
-
const q = class q extends
|
|
1090
|
+
const q = class q extends D {
|
|
1044
1091
|
render() {
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1092
|
+
const e = document.createElement("div");
|
|
1093
|
+
e.classList.add(b.stack, b.stackDense, b.header);
|
|
1047
1094
|
const t = document.createElement("div");
|
|
1048
1095
|
t.classList.add(b.headerTitleRow);
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1096
|
+
const r = document.createElement("strong");
|
|
1097
|
+
r.textContent = "textmode.export.js", r.classList.add(b.title);
|
|
1051
1098
|
const a = document.createElement("div");
|
|
1052
1099
|
a.classList.add(b.headerLinks);
|
|
1053
|
-
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" }]),
|
|
1054
|
-
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);
|
|
1055
1102
|
const d = document.createElement("div");
|
|
1056
|
-
return d.classList.add(b.divider),
|
|
1103
|
+
return d.classList.add(b.divider), e.appendChild(t), e.appendChild(d), e;
|
|
1057
1104
|
}
|
|
1058
|
-
_createLink(
|
|
1105
|
+
_createLink(e, t, r, a) {
|
|
1059
1106
|
const o = document.createElement("a");
|
|
1060
|
-
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;
|
|
1061
1108
|
}
|
|
1062
|
-
_createIcon(
|
|
1063
|
-
const
|
|
1064
|
-
|
|
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);
|
|
1065
1112
|
for (const a of t) {
|
|
1066
1113
|
const o = document.createElementNS(q._iconNamespace, "path");
|
|
1067
|
-
for (const [
|
|
1068
|
-
|
|
1114
|
+
for (const [n, d] of Object.entries(a)) o.setAttribute(n, d);
|
|
1115
|
+
r.appendChild(o);
|
|
1069
1116
|
}
|
|
1070
|
-
return
|
|
1117
|
+
return r;
|
|
1071
1118
|
}
|
|
1072
1119
|
};
|
|
1073
1120
|
p(q, "_iconNamespace", "http://www.w3.org/2000/svg");
|
|
1074
|
-
let
|
|
1075
|
-
class
|
|
1121
|
+
let bt = q;
|
|
1122
|
+
class T extends D {
|
|
1076
1123
|
constructor(t) {
|
|
1077
1124
|
super();
|
|
1078
1125
|
p(this, "props");
|
|
@@ -1081,8 +1128,8 @@ class O extends T {
|
|
|
1081
1128
|
render() {
|
|
1082
1129
|
const t = document.createElement("div");
|
|
1083
1130
|
t.classList.add(b.field), this.applyVariant(t, this.props.variant);
|
|
1084
|
-
const
|
|
1085
|
-
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) {
|
|
1086
1133
|
const a = document.createElement("span");
|
|
1087
1134
|
a.classList.add(b.muted), a.textContent = this.props.description, t.appendChild(a);
|
|
1088
1135
|
}
|
|
@@ -1095,17 +1142,17 @@ class O extends T {
|
|
|
1095
1142
|
this.props = t, super.update(t);
|
|
1096
1143
|
}
|
|
1097
1144
|
onUpdate(t) {
|
|
1098
|
-
const
|
|
1099
|
-
for (;
|
|
1100
|
-
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);
|
|
1101
1148
|
const a = document.createElement("label");
|
|
1102
|
-
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) {
|
|
1103
1150
|
const o = document.createElement("span");
|
|
1104
|
-
o.classList.add(b.muted), o.textContent = t.description,
|
|
1151
|
+
o.classList.add(b.muted), o.textContent = t.description, r.appendChild(o);
|
|
1105
1152
|
}
|
|
1106
1153
|
}
|
|
1107
|
-
applyVariant(t,
|
|
1108
|
-
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) {
|
|
1109
1156
|
case "compact":
|
|
1110
1157
|
t.classList.add(b.fieldCompact);
|
|
1111
1158
|
break;
|
|
@@ -1120,7 +1167,7 @@ class O extends T {
|
|
|
1120
1167
|
}
|
|
1121
1168
|
}
|
|
1122
1169
|
}
|
|
1123
|
-
class
|
|
1170
|
+
class H extends D {
|
|
1124
1171
|
constructor(t) {
|
|
1125
1172
|
super();
|
|
1126
1173
|
p(this, "props");
|
|
@@ -1155,14 +1202,14 @@ class st extends T {
|
|
|
1155
1202
|
if (this.select) {
|
|
1156
1203
|
this.select.innerHTML = "";
|
|
1157
1204
|
for (const t of this.props.options) {
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1205
|
+
const r = document.createElement("option");
|
|
1206
|
+
r.value = t.value, r.textContent = t.label, this.select.appendChild(r);
|
|
1160
1207
|
}
|
|
1161
1208
|
this.props.defaultValue && (this.select.value = this.props.defaultValue);
|
|
1162
1209
|
}
|
|
1163
1210
|
}
|
|
1164
1211
|
}
|
|
1165
|
-
class
|
|
1212
|
+
class Nt extends D {
|
|
1166
1213
|
constructor(t) {
|
|
1167
1214
|
super();
|
|
1168
1215
|
p(this, "props");
|
|
@@ -1185,59 +1232,59 @@ class Vt extends T {
|
|
|
1185
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);
|
|
1186
1233
|
}
|
|
1187
1234
|
}
|
|
1188
|
-
class
|
|
1189
|
-
constructor(
|
|
1235
|
+
class Ue {
|
|
1236
|
+
constructor(e) {
|
|
1190
1237
|
p(this, "api");
|
|
1191
|
-
this.api =
|
|
1238
|
+
this.api = e;
|
|
1192
1239
|
}
|
|
1193
|
-
async $copy(
|
|
1194
|
-
switch (
|
|
1240
|
+
async $copy(e, t) {
|
|
1241
|
+
switch (e) {
|
|
1195
1242
|
case "txt": {
|
|
1196
|
-
const
|
|
1197
|
-
await navigator.clipboard.writeText(
|
|
1243
|
+
const r = this.api.toString(t);
|
|
1244
|
+
await navigator.clipboard.writeText(r);
|
|
1198
1245
|
break;
|
|
1199
1246
|
}
|
|
1200
1247
|
case "json": {
|
|
1201
|
-
const
|
|
1202
|
-
await navigator.clipboard.writeText(
|
|
1248
|
+
const r = this.api.toJSONString(t);
|
|
1249
|
+
await navigator.clipboard.writeText(r);
|
|
1203
1250
|
break;
|
|
1204
1251
|
}
|
|
1205
1252
|
case "svg": {
|
|
1206
|
-
const
|
|
1207
|
-
await navigator.clipboard.writeText(
|
|
1253
|
+
const r = this.api.toSVG(t);
|
|
1254
|
+
await navigator.clipboard.writeText(r);
|
|
1208
1255
|
break;
|
|
1209
1256
|
}
|
|
1210
1257
|
case "image":
|
|
1211
1258
|
await this.api.copyCanvas(t);
|
|
1212
1259
|
break;
|
|
1213
1260
|
default:
|
|
1214
|
-
throw new Error(`Clipboard not supported for ${
|
|
1261
|
+
throw new Error(`Clipboard not supported for ${e}`);
|
|
1215
1262
|
}
|
|
1216
1263
|
}
|
|
1217
1264
|
}
|
|
1218
|
-
class
|
|
1219
|
-
constructor(
|
|
1265
|
+
class Ge {
|
|
1266
|
+
constructor(e, t) {
|
|
1220
1267
|
p(this, "api");
|
|
1221
1268
|
p(this, "events");
|
|
1222
|
-
this.api =
|
|
1269
|
+
this.api = e, this.events = t;
|
|
1223
1270
|
}
|
|
1224
|
-
async $requestExport(
|
|
1225
|
-
this.events.$emit("export:request", { format:
|
|
1271
|
+
async $requestExport(e, t, r = {}) {
|
|
1272
|
+
this.events.$emit("export:request", { format: e });
|
|
1226
1273
|
try {
|
|
1227
|
-
const a = { onGIFProgress:
|
|
1228
|
-
var
|
|
1229
|
-
(
|
|
1230
|
-
} :
|
|
1231
|
-
var
|
|
1232
|
-
(
|
|
1233
|
-
} :
|
|
1234
|
-
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 });
|
|
1235
1282
|
} catch (a) {
|
|
1236
|
-
throw this.events.$emit("export:error", { format:
|
|
1283
|
+
throw this.events.$emit("export:error", { format: e, error: a }), a;
|
|
1237
1284
|
}
|
|
1238
1285
|
}
|
|
1239
|
-
_execute(
|
|
1240
|
-
switch (
|
|
1286
|
+
_execute(e, t, r) {
|
|
1287
|
+
switch (e) {
|
|
1241
1288
|
case "txt":
|
|
1242
1289
|
return Promise.resolve(this.api.saveStrings(t));
|
|
1243
1290
|
case "json":
|
|
@@ -1247,24 +1294,24 @@ class De {
|
|
|
1247
1294
|
case "svg":
|
|
1248
1295
|
return Promise.resolve(this.api.saveSVG(t));
|
|
1249
1296
|
case "gif": {
|
|
1250
|
-
const a = { ...t, onProgress:
|
|
1297
|
+
const a = { ...t, onProgress: r.onGIFProgress };
|
|
1251
1298
|
return this.api.saveGIF(a);
|
|
1252
1299
|
}
|
|
1253
1300
|
case "video": {
|
|
1254
|
-
const a = { ...t, onProgress:
|
|
1301
|
+
const a = { ...t, onProgress: r.onVideoProgress };
|
|
1255
1302
|
return this.api.saveWEBM(a);
|
|
1256
1303
|
}
|
|
1257
1304
|
}
|
|
1258
1305
|
}
|
|
1259
1306
|
}
|
|
1260
|
-
class
|
|
1261
|
-
constructor(
|
|
1307
|
+
class ze {
|
|
1308
|
+
constructor(e, t) {
|
|
1262
1309
|
p(this, "modifier");
|
|
1263
1310
|
p(this, "overlay");
|
|
1264
1311
|
p(this, "animationFrameId", null);
|
|
1265
1312
|
p(this, "handleUpdate");
|
|
1266
1313
|
p(this, "bound", !1);
|
|
1267
|
-
this.modifier =
|
|
1314
|
+
this.modifier = e, this.overlay = t, this.handleUpdate = () => this.scheduleUpdate();
|
|
1268
1315
|
}
|
|
1269
1316
|
scheduleUpdate() {
|
|
1270
1317
|
this.animationFrameId !== null && cancelAnimationFrame(this.animationFrameId), this.animationFrameId = requestAnimationFrame(() => this.update());
|
|
@@ -1274,20 +1321,20 @@ class Ve {
|
|
|
1274
1321
|
}
|
|
1275
1322
|
update() {
|
|
1276
1323
|
this.animationFrameId = null;
|
|
1277
|
-
const
|
|
1278
|
-
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`;
|
|
1279
1326
|
}
|
|
1280
1327
|
dispose() {
|
|
1281
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);
|
|
1282
1329
|
}
|
|
1283
1330
|
}
|
|
1284
|
-
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) => {
|
|
1285
1332
|
i.dispatchEvent(new Event("input", { bubbles: !0 })), i.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1286
|
-
},
|
|
1287
|
-
const
|
|
1288
|
-
return
|
|
1333
|
+
}, Ut = (i) => {
|
|
1334
|
+
const e = document.createElement("button");
|
|
1335
|
+
return e.type = "button", e.className = qe, e.textContent = i > 0 ? "▲" : "▼", e;
|
|
1289
1336
|
};
|
|
1290
|
-
class z extends
|
|
1337
|
+
class z extends D {
|
|
1291
1338
|
constructor(t) {
|
|
1292
1339
|
super();
|
|
1293
1340
|
p(this, "props");
|
|
@@ -1304,9 +1351,9 @@ class z extends T {
|
|
|
1304
1351
|
}
|
|
1305
1352
|
render() {
|
|
1306
1353
|
const t = document.createElement("div");
|
|
1307
|
-
t.className =
|
|
1308
|
-
const
|
|
1309
|
-
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;
|
|
1310
1357
|
}
|
|
1311
1358
|
get inputElement() {
|
|
1312
1359
|
return this.input;
|
|
@@ -1325,29 +1372,29 @@ class z extends T {
|
|
|
1325
1372
|
this.clearHoldTimers(), (t = this.disabledObserver) == null || t.disconnect();
|
|
1326
1373
|
}
|
|
1327
1374
|
bindStepControls() {
|
|
1328
|
-
const t = (
|
|
1375
|
+
const t = (n) => () => {
|
|
1329
1376
|
if (this.input.disabled) return;
|
|
1330
1377
|
const d = this.input.value, l = this.input.getAttribute("step");
|
|
1331
|
-
if (l && l !== "any")
|
|
1378
|
+
if (l && l !== "any") n > 0 ? this.input.stepUp() : this.input.stepDown();
|
|
1332
1379
|
else {
|
|
1333
|
-
const h =
|
|
1380
|
+
const h = n > 0 ? 1 : -1, s = Number.parseFloat(this.input.value || "0"), c = Number.isFinite(s) ? s + h : h;
|
|
1334
1381
|
this.input.value = String(c);
|
|
1335
1382
|
}
|
|
1336
|
-
this.input.value !== d &&
|
|
1337
|
-
},
|
|
1338
|
-
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();
|
|
1339
1386
|
d();
|
|
1340
1387
|
};
|
|
1341
|
-
this.incrementButton.addEventListener("click", o(this.incrementButton,
|
|
1388
|
+
this.incrementButton.addEventListener("click", o(this.incrementButton, r)), this.decrementButton.addEventListener("click", o(this.decrementButton, a));
|
|
1342
1389
|
}
|
|
1343
1390
|
bindHoldBehavior() {
|
|
1344
|
-
const t = (
|
|
1391
|
+
const t = (r, a) => {
|
|
1345
1392
|
const o = a > 0 ? () => this.incrementButton.click() : () => this.decrementButton.click();
|
|
1346
|
-
|
|
1393
|
+
r.addEventListener("pointerdown", (l) => {
|
|
1347
1394
|
if (l.button === 0) {
|
|
1348
|
-
l.preventDefault(), this.suppressClickAfterPointer.set(
|
|
1395
|
+
l.preventDefault(), this.suppressClickAfterPointer.set(r, !0), this.activePointerId = l.pointerId;
|
|
1349
1396
|
try {
|
|
1350
|
-
|
|
1397
|
+
r.setPointerCapture(l.pointerId);
|
|
1351
1398
|
} catch {
|
|
1352
1399
|
}
|
|
1353
1400
|
o(), this.holdTimeoutId = window.setTimeout(() => {
|
|
@@ -1355,18 +1402,18 @@ class z extends T {
|
|
|
1355
1402
|
}, 380);
|
|
1356
1403
|
}
|
|
1357
1404
|
});
|
|
1358
|
-
const
|
|
1405
|
+
const n = () => {
|
|
1359
1406
|
if (this.activePointerId !== void 0) {
|
|
1360
1407
|
try {
|
|
1361
|
-
|
|
1408
|
+
r.releasePointerCapture(this.activePointerId);
|
|
1362
1409
|
} catch {
|
|
1363
1410
|
}
|
|
1364
1411
|
this.activePointerId = void 0;
|
|
1365
1412
|
}
|
|
1366
1413
|
}, d = () => {
|
|
1367
|
-
this.clearHoldTimers(),
|
|
1414
|
+
this.clearHoldTimers(), n();
|
|
1368
1415
|
};
|
|
1369
|
-
|
|
1416
|
+
r.addEventListener("pointerup", d), r.addEventListener("pointerleave", d), r.addEventListener("pointercancel", d);
|
|
1370
1417
|
};
|
|
1371
1418
|
t(this.incrementButton, 1), t(this.decrementButton, -1);
|
|
1372
1419
|
}
|
|
@@ -1377,36 +1424,36 @@ class z extends T {
|
|
|
1377
1424
|
this.input.addEventListener("input", t), this.input.addEventListener("change", t);
|
|
1378
1425
|
}
|
|
1379
1426
|
observeDisabledState(t) {
|
|
1380
|
-
const
|
|
1427
|
+
const r = () => {
|
|
1381
1428
|
const a = this.input.disabled;
|
|
1382
|
-
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();
|
|
1383
1430
|
};
|
|
1384
|
-
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();
|
|
1385
1432
|
}
|
|
1386
1433
|
updateDisplay() {
|
|
1387
1434
|
const t = this.props.formatDisplay;
|
|
1388
|
-
if (!t) return this.display.textContent = "", this.display.classList.remove(
|
|
1389
|
-
const
|
|
1390
|
-
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"));
|
|
1391
1438
|
}
|
|
1392
1439
|
clearHoldTimers() {
|
|
1393
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);
|
|
1394
1441
|
}
|
|
1395
1442
|
}
|
|
1396
|
-
class
|
|
1397
|
-
constructor(t = "stack",
|
|
1443
|
+
class Q extends D {
|
|
1444
|
+
constructor(t = "stack", r = []) {
|
|
1398
1445
|
super();
|
|
1399
1446
|
p(this, "variant");
|
|
1400
1447
|
p(this, "additionalClasses");
|
|
1401
|
-
this.variant = t, this.additionalClasses =
|
|
1448
|
+
this.variant = t, this.additionalClasses = r;
|
|
1402
1449
|
}
|
|
1403
1450
|
render() {
|
|
1404
|
-
const t = document.createElement("div"),
|
|
1405
|
-
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;
|
|
1406
1453
|
}
|
|
1407
1454
|
}
|
|
1408
|
-
const
|
|
1409
|
-
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 {
|
|
1410
1457
|
constructor(t) {
|
|
1411
1458
|
super();
|
|
1412
1459
|
p(this, "props");
|
|
@@ -1419,17 +1466,17 @@ class Ht extends T {
|
|
|
1419
1466
|
const t = document.createElement("span");
|
|
1420
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;
|
|
1421
1468
|
}
|
|
1422
|
-
setMessage(t,
|
|
1423
|
-
this.messageElement.textContent = t, this.applyVariant(
|
|
1469
|
+
setMessage(t, r = "neutral") {
|
|
1470
|
+
this.messageElement.textContent = t, this.applyVariant(r);
|
|
1424
1471
|
}
|
|
1425
1472
|
onUpdate(t) {
|
|
1426
1473
|
this.props = t, this.setMessage(t.message, t.variant ?? "neutral");
|
|
1427
1474
|
}
|
|
1428
1475
|
applyVariant(t) {
|
|
1429
|
-
this.messageElement.classList.remove(...Object.values(
|
|
1476
|
+
this.messageElement.classList.remove(...Object.values(Gt)), this.messageElement.classList.add(Gt[t]);
|
|
1430
1477
|
}
|
|
1431
1478
|
}
|
|
1432
|
-
class J extends
|
|
1479
|
+
class J extends D {
|
|
1433
1480
|
constructor(t) {
|
|
1434
1481
|
super();
|
|
1435
1482
|
p(this, "_config");
|
|
@@ -1447,32 +1494,32 @@ class J extends T {
|
|
|
1447
1494
|
this._managedComponents.clear();
|
|
1448
1495
|
}
|
|
1449
1496
|
}
|
|
1450
|
-
const
|
|
1451
|
-
class
|
|
1497
|
+
const j = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
|
|
1498
|
+
class vt extends J {
|
|
1452
1499
|
constructor(t) {
|
|
1453
1500
|
super(t);
|
|
1454
|
-
p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(
|
|
1455
|
-
p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(
|
|
1456
|
-
p(this, "scaleInput", this._manageComponent(new z({ defaultValue: String(
|
|
1457
|
-
p(this, "repeatInput", this._manageComponent(new z({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t,
|
|
1458
|
-
p(this, "status", this._manageComponent(new
|
|
1501
|
+
p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(j.frameCount), attributes: { min: "1", max: "600", step: "1" } })));
|
|
1502
|
+
p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(j.frameRate), attributes: { min: "1", max: "60", step: "1" } })));
|
|
1503
|
+
p(this, "scaleInput", this._manageComponent(new z({ defaultValue: String(j.scale), attributes: { min: "0.1", max: "8", step: "0.1" } })));
|
|
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" })));
|
|
1459
1506
|
p(this, "recordingState", "idle");
|
|
1460
1507
|
}
|
|
1461
1508
|
render() {
|
|
1462
1509
|
const t = document.createElement("div");
|
|
1463
1510
|
t.classList.add(b.stack);
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1466
|
-
const a = new
|
|
1467
|
-
a.mount(
|
|
1468
|
-
const o = new
|
|
1469
|
-
o.mount(
|
|
1470
|
-
const
|
|
1471
|
-
|
|
1472
|
-
const d = new
|
|
1473
|
-
d.mount(
|
|
1474
|
-
const l = new
|
|
1475
|
-
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;
|
|
1476
1523
|
}
|
|
1477
1524
|
getOptions() {
|
|
1478
1525
|
const t = this._config.defaultOptions ?? {};
|
|
@@ -1482,33 +1529,33 @@ class bt extends J {
|
|
|
1482
1529
|
this.recordingState = "idle", this.applyDefaults(), this.setRecordingState("idle");
|
|
1483
1530
|
}
|
|
1484
1531
|
validate() {
|
|
1485
|
-
const t = Number.parseInt(this.frameCountInput.value, 10),
|
|
1486
|
-
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;
|
|
1487
1534
|
}
|
|
1488
1535
|
isRecording() {
|
|
1489
1536
|
return this.recordingState === "recording" || this.recordingState === "encoding";
|
|
1490
1537
|
}
|
|
1491
|
-
setRecordingState(t,
|
|
1538
|
+
setRecordingState(t, r) {
|
|
1492
1539
|
this.recordingState = t;
|
|
1493
1540
|
const a = t === "recording" || t === "encoding";
|
|
1494
1541
|
switch (this.frameCountInput.inputElement.disabled = a, this.frameRateInput.inputElement.disabled = a, this.scaleInput.inputElement.disabled = a, this.repeatInput.inputElement.disabled = a, t) {
|
|
1495
1542
|
case "recording":
|
|
1496
|
-
if (
|
|
1497
|
-
const o =
|
|
1498
|
-
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");
|
|
1499
1546
|
} else this.status.setMessage("recording…", "active");
|
|
1500
1547
|
break;
|
|
1501
1548
|
case "encoding":
|
|
1502
|
-
if (
|
|
1503
|
-
const o =
|
|
1504
|
-
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");
|
|
1505
1552
|
} else this.status.setMessage("encoding…", "active");
|
|
1506
1553
|
break;
|
|
1507
1554
|
case "completed":
|
|
1508
1555
|
this.status.setMessage("GIF saved successfully", "active");
|
|
1509
1556
|
break;
|
|
1510
1557
|
case "error":
|
|
1511
|
-
this.status.setMessage((
|
|
1558
|
+
this.status.setMessage((r == null ? void 0 : r.message) ?? "failed to export GIF", "alert");
|
|
1512
1559
|
break;
|
|
1513
1560
|
default:
|
|
1514
1561
|
this.status.setMessage("ready to record", "neutral");
|
|
@@ -1517,29 +1564,29 @@ class bt extends J {
|
|
|
1517
1564
|
handleProgress(t) {
|
|
1518
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");
|
|
1519
1566
|
else {
|
|
1520
|
-
const
|
|
1521
|
-
this.status.setMessage(`${
|
|
1567
|
+
const r = t.state === "recording" ? "recording" : "encoding";
|
|
1568
|
+
this.status.setMessage(`${r} ${t.frameIndex ?? 0}/${t.totalFrames}`, "active");
|
|
1522
1569
|
}
|
|
1523
1570
|
}
|
|
1524
1571
|
applyDefaults() {
|
|
1525
|
-
const t = this._config.defaultOptions ?? {},
|
|
1526
|
-
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();
|
|
1527
1574
|
}
|
|
1528
|
-
safeParseInt(t,
|
|
1575
|
+
safeParseInt(t, r) {
|
|
1529
1576
|
const a = Number.parseInt(t, 10);
|
|
1530
|
-
return Number.isFinite(a) ? a :
|
|
1577
|
+
return Number.isFinite(a) ? a : r;
|
|
1531
1578
|
}
|
|
1532
|
-
safeParseFloat(t,
|
|
1579
|
+
safeParseFloat(t, r) {
|
|
1533
1580
|
const a = Number.parseFloat(t);
|
|
1534
|
-
return Number.isFinite(a) ? a :
|
|
1581
|
+
return Number.isFinite(a) ? a : r;
|
|
1535
1582
|
}
|
|
1536
1583
|
}
|
|
1537
|
-
const
|
|
1538
|
-
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;
|
|
1539
1586
|
const t = Number.parseFloat(i);
|
|
1540
|
-
return Number.isFinite(t) ? t :
|
|
1541
|
-
},
|
|
1542
|
-
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 {
|
|
1543
1590
|
constructor(t) {
|
|
1544
1591
|
super();
|
|
1545
1592
|
p(this, "props");
|
|
@@ -1556,7 +1603,7 @@ class je extends T {
|
|
|
1556
1603
|
}
|
|
1557
1604
|
render() {
|
|
1558
1605
|
const t = document.createElement("div");
|
|
1559
|
-
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;
|
|
1560
1607
|
}
|
|
1561
1608
|
get inputElement() {
|
|
1562
1609
|
return this.input;
|
|
@@ -1568,8 +1615,8 @@ class je extends T {
|
|
|
1568
1615
|
this.input.value = t, this.updateTooltip();
|
|
1569
1616
|
}
|
|
1570
1617
|
_onDestroy() {
|
|
1571
|
-
var t,
|
|
1572
|
-
(t = this.disabledObserver) == null || t.disconnect(), (
|
|
1618
|
+
var t, r;
|
|
1619
|
+
(t = this.disabledObserver) == null || t.disconnect(), (r = this.resizeObserver) == null || r.disconnect();
|
|
1573
1620
|
}
|
|
1574
1621
|
bindEvents(t) {
|
|
1575
1622
|
this.input.addEventListener("pointerenter", () => {
|
|
@@ -1594,27 +1641,27 @@ class je extends T {
|
|
|
1594
1641
|
this.activePointerId = void 0;
|
|
1595
1642
|
}
|
|
1596
1643
|
});
|
|
1597
|
-
const
|
|
1644
|
+
const r = () => {
|
|
1598
1645
|
this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.hoverActive = this.input.matches(":hover"), this.releasePointerCapture(), this.refreshTooltipVisibility();
|
|
1599
1646
|
};
|
|
1600
|
-
this.input.addEventListener("pointerup",
|
|
1647
|
+
this.input.addEventListener("pointerup", r), this.input.addEventListener("pointercancel", r), this.input.addEventListener("lostpointercapture", r), this.input.addEventListener("input", () => {
|
|
1601
1648
|
(this.hoverActive || this.focusActive || this.pointerActive) && this.updateTooltip(), this.props.defaultValue = this.input.value;
|
|
1602
1649
|
}), this.input.addEventListener("change", () => {
|
|
1603
1650
|
this.pointerActive || this.updateTooltip(), this.props.defaultValue = this.input.value;
|
|
1604
1651
|
}), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
|
|
1605
|
-
this.tooltip.classList.contains(
|
|
1652
|
+
this.tooltip.classList.contains(gt) && this.updateTooltipPosition();
|
|
1606
1653
|
}), this.resizeObserver.observe(t));
|
|
1607
1654
|
}
|
|
1608
1655
|
refreshTooltipVisibility() {
|
|
1609
1656
|
const t = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
|
|
1610
|
-
t && this.updateTooltip(), this.tooltip.classList.toggle(
|
|
1657
|
+
t && this.updateTooltip(), this.tooltip.classList.toggle(gt, t);
|
|
1611
1658
|
}
|
|
1612
1659
|
syncDisabledState(t) {
|
|
1613
|
-
const
|
|
1660
|
+
const r = () => {
|
|
1614
1661
|
const a = this.input.disabled;
|
|
1615
|
-
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));
|
|
1616
1663
|
};
|
|
1617
|
-
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();
|
|
1618
1665
|
}
|
|
1619
1666
|
releasePointerCapture() {
|
|
1620
1667
|
if (this.activePointerId !== void 0) {
|
|
@@ -1629,81 +1676,81 @@ class je extends T {
|
|
|
1629
1676
|
this.updateTooltipContent(), this.updateTooltipPosition();
|
|
1630
1677
|
}
|
|
1631
1678
|
updateTooltipContent() {
|
|
1632
|
-
const t = this.props.formatValue ?? ((a) => `${a}`),
|
|
1633
|
-
this.tooltip.textContent = t(
|
|
1679
|
+
const t = this.props.formatValue ?? ((a) => `${a}`), r = this.getCurrentValue();
|
|
1680
|
+
this.tooltip.textContent = t(r, this.input);
|
|
1634
1681
|
}
|
|
1635
1682
|
updateTooltipPosition() {
|
|
1636
|
-
const t = this.getMin(),
|
|
1637
|
-
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 + "%";
|
|
1638
1685
|
}
|
|
1639
1686
|
getMin() {
|
|
1640
|
-
return
|
|
1687
|
+
return ot(this.input.min, 0);
|
|
1641
1688
|
}
|
|
1642
1689
|
getMax() {
|
|
1643
|
-
return
|
|
1690
|
+
return ot(this.input.max, 100);
|
|
1644
1691
|
}
|
|
1645
1692
|
getCurrentValue() {
|
|
1646
|
-
return
|
|
1693
|
+
return ot(this.input.value, ot(this.props.defaultValue, 0));
|
|
1647
1694
|
}
|
|
1648
1695
|
}
|
|
1649
|
-
function
|
|
1696
|
+
function Ze(i) {
|
|
1650
1697
|
if (!Number.isFinite(i)) return "default quality";
|
|
1651
|
-
const
|
|
1652
|
-
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";
|
|
1653
1700
|
}
|
|
1654
|
-
function
|
|
1655
|
-
return `${
|
|
1701
|
+
function Ke(i) {
|
|
1702
|
+
return `${Ze(i)} (quality ≈ ${i.toFixed(3)})`;
|
|
1656
1703
|
}
|
|
1657
|
-
class
|
|
1704
|
+
class yt extends J {
|
|
1658
1705
|
constructor(t) {
|
|
1659
1706
|
super(t);
|
|
1660
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 })));
|
|
1661
1708
|
p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } })));
|
|
1662
|
-
p(this, "qualityInput", this._manageComponent(new
|
|
1663
|
-
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" })));
|
|
1664
1711
|
p(this, "recordingState", "idle");
|
|
1665
1712
|
}
|
|
1666
1713
|
render() {
|
|
1667
1714
|
const t = document.createElement("div");
|
|
1668
1715
|
t.classList.add(b.stack);
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1671
|
-
const a = new
|
|
1672
|
-
a.mount(
|
|
1673
|
-
const o = new
|
|
1674
|
-
o.mount(
|
|
1675
|
-
const
|
|
1676
|
-
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;
|
|
1677
1724
|
}
|
|
1678
1725
|
getOptions() {
|
|
1679
|
-
const t = this._config.defaultOptions ?? {},
|
|
1680
|
-
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 };
|
|
1681
1728
|
}
|
|
1682
1729
|
reset() {
|
|
1683
1730
|
this.recordingState = "idle", this.applyDefaults(), this.status.setMessage("ready to record", "neutral");
|
|
1684
1731
|
}
|
|
1685
1732
|
validate() {
|
|
1686
|
-
const t = Number.parseInt(this.frameCountInput.value, 10),
|
|
1687
|
-
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;
|
|
1688
1735
|
}
|
|
1689
1736
|
isRecording() {
|
|
1690
1737
|
return this.recordingState === "recording";
|
|
1691
1738
|
}
|
|
1692
|
-
setRecordingState(t,
|
|
1739
|
+
setRecordingState(t, r) {
|
|
1693
1740
|
this.recordingState = t;
|
|
1694
1741
|
const a = t === "recording";
|
|
1695
|
-
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);
|
|
1696
1743
|
}
|
|
1697
1744
|
handleProgress(t) {
|
|
1698
1745
|
this.syncStatus(t.state, t);
|
|
1699
1746
|
}
|
|
1700
|
-
syncStatus(t,
|
|
1747
|
+
syncStatus(t, r) {
|
|
1701
1748
|
switch (t) {
|
|
1702
1749
|
case "recording": {
|
|
1703
|
-
const a = (
|
|
1750
|
+
const a = (r == null ? void 0 : r.frameIndex) ?? 0, o = (r == null ? void 0 : r.totalFrames) ?? this.resolvePlannedFrameCount();
|
|
1704
1751
|
if (o) {
|
|
1705
|
-
const
|
|
1706
|
-
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");
|
|
1707
1754
|
} else this.status.setMessage(`recording ${Math.max(0, Math.round(a))} frames`, "active");
|
|
1708
1755
|
break;
|
|
1709
1756
|
}
|
|
@@ -1711,7 +1758,7 @@ class vt extends J {
|
|
|
1711
1758
|
this.status.setMessage("saved to disk", "active");
|
|
1712
1759
|
break;
|
|
1713
1760
|
case "error":
|
|
1714
|
-
this.status.setMessage(
|
|
1761
|
+
this.status.setMessage(r != null && r.message ? `error: ${r.message}` : "recording failed", "alert");
|
|
1715
1762
|
break;
|
|
1716
1763
|
default:
|
|
1717
1764
|
this.status.setMessage("ready to record", "neutral");
|
|
@@ -1722,13 +1769,16 @@ class vt extends J {
|
|
|
1722
1769
|
return Number.isFinite(t) && t > 0 ? Math.round(t) : void 0;
|
|
1723
1770
|
}
|
|
1724
1771
|
applyDefaults() {
|
|
1725
|
-
const t = this._config.defaultOptions ?? {},
|
|
1726
|
-
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();
|
|
1727
1774
|
}
|
|
1728
1775
|
}
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
|
|
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) {
|
|
1732
1782
|
p(this, "_textmodifier");
|
|
1733
1783
|
p(this, "_state");
|
|
1734
1784
|
p(this, "_events");
|
|
@@ -1743,33 +1793,33 @@ class Xe {
|
|
|
1743
1793
|
p(this, "_optionsContainer");
|
|
1744
1794
|
p(this, "_copyButtonContainer");
|
|
1745
1795
|
p(this, "_positionService");
|
|
1746
|
-
p(this, "_header", new
|
|
1747
|
-
p(this, "_formatField", new
|
|
1748
|
-
p(this, "_formatSelect", new
|
|
1749
|
-
p(this, "_exportButton", new
|
|
1750
|
-
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" }));
|
|
1751
1801
|
p(this, "_currentFormat");
|
|
1752
1802
|
p(this, "_currentBlade");
|
|
1753
1803
|
p(this, "_handleFormatSelectChange", () => {
|
|
1754
1804
|
this._handleFormatChange(this._formatSelect.value);
|
|
1755
1805
|
});
|
|
1756
1806
|
p(this, "_handleExportClickSafe", () => {
|
|
1757
|
-
this._handleExportClick().catch((
|
|
1758
|
-
console.error("[textmode-export] Export failed",
|
|
1807
|
+
this._handleExportClick().catch((e) => {
|
|
1808
|
+
console.error("[textmode-export] Export failed", e);
|
|
1759
1809
|
});
|
|
1760
1810
|
});
|
|
1761
1811
|
p(this, "_handleCopyClickSafe", () => {
|
|
1762
|
-
this._handleCopyClick().catch((
|
|
1763
|
-
console.error("[textmode-export] Copy failed",
|
|
1812
|
+
this._handleCopyClick().catch((e) => {
|
|
1813
|
+
console.error("[textmode-export] Copy failed", e);
|
|
1764
1814
|
});
|
|
1765
1815
|
});
|
|
1766
|
-
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();
|
|
1767
1817
|
}
|
|
1768
1818
|
$mount() {
|
|
1769
|
-
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);
|
|
1770
1820
|
}
|
|
1771
1821
|
show() {
|
|
1772
|
-
this._shadowHost && (this._shadowHost.style.display = "");
|
|
1822
|
+
this._shadowHost && (this.refreshLayerTargets(), this._shadowHost.style.display = "");
|
|
1773
1823
|
}
|
|
1774
1824
|
hide() {
|
|
1775
1825
|
this._shadowHost && (this._shadowHost.style.display = "none");
|
|
@@ -1780,51 +1830,54 @@ class Xe {
|
|
|
1780
1830
|
isVisible() {
|
|
1781
1831
|
return !!this._shadowHost && this._shadowHost.style.display !== "none";
|
|
1782
1832
|
}
|
|
1833
|
+
refreshLayerTargets() {
|
|
1834
|
+
this._currentBlade && er(this._currentBlade.blade) && this._currentBlade.blade.refreshLayerTargets();
|
|
1835
|
+
}
|
|
1783
1836
|
$dispose() {
|
|
1784
|
-
var
|
|
1837
|
+
var e, t;
|
|
1785
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);
|
|
1786
|
-
for (const
|
|
1839
|
+
for (const r of this._eventUnsubscribers) r();
|
|
1787
1840
|
this._eventUnsubscribers.length = 0, this._events.$clear();
|
|
1788
|
-
for (const
|
|
1789
|
-
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();
|
|
1790
1843
|
}
|
|
1791
1844
|
_initializeFormatMap() {
|
|
1792
|
-
for (const
|
|
1793
|
-
const t =
|
|
1794
|
-
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 });
|
|
1795
1848
|
}
|
|
1796
1849
|
}
|
|
1797
1850
|
_createOverlay() {
|
|
1798
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" });
|
|
1799
|
-
const
|
|
1800
|
-
|
|
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);
|
|
1801
1854
|
}
|
|
1802
1855
|
_renderStaticContent() {
|
|
1803
1856
|
this._header.mount(this._overlayElement);
|
|
1804
|
-
const
|
|
1805
|
-
|
|
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);
|
|
1806
1859
|
}
|
|
1807
1860
|
_prepareFormatOptions() {
|
|
1808
|
-
const
|
|
1809
|
-
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 });
|
|
1810
1863
|
}
|
|
1811
1864
|
_registerEventHandlers() {
|
|
1812
|
-
this._eventUnsubscribers.push(this._events.$on("export:request", ({ format:
|
|
1813
|
-
|
|
1814
|
-
}), this._events.$on("export:success", ({ format:
|
|
1815
|
-
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) {
|
|
1816
1869
|
const t = { isBusy: !1 };
|
|
1817
|
-
|
|
1870
|
+
e === "gif" && (t.gifProgress = void 0), e === "video" && (t.videoProgress = void 0), this._state.$set(t), this._updateExportButton();
|
|
1818
1871
|
}
|
|
1819
|
-
}), this._events.$on("export:error", ({ format:
|
|
1820
|
-
|
|
1821
|
-
}), this._events.$on("export:progress", ({ format:
|
|
1822
|
-
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;
|
|
1823
1876
|
if (t) {
|
|
1824
|
-
if (
|
|
1877
|
+
if (e === "gif" && ((r = this._currentBlade) == null ? void 0 : r.blade) instanceof vt) {
|
|
1825
1878
|
const o = t;
|
|
1826
1879
|
this._state.$set({ gifProgress: o }), this._currentBlade.blade.handleProgress(o);
|
|
1827
|
-
} else if (
|
|
1880
|
+
} else if (e === "video" && ((a = this._currentBlade) == null ? void 0 : a.blade) instanceof yt) {
|
|
1828
1881
|
const o = t;
|
|
1829
1882
|
this._state.$set({ videoProgress: o }), this._currentBlade.blade.handleProgress(o);
|
|
1830
1883
|
}
|
|
@@ -1832,57 +1885,57 @@ class Xe {
|
|
|
1832
1885
|
}
|
|
1833
1886
|
}));
|
|
1834
1887
|
}
|
|
1835
|
-
_handleFormatChange(
|
|
1836
|
-
this._currentFormat =
|
|
1888
|
+
_handleFormatChange(e) {
|
|
1889
|
+
this._currentFormat = e, this._state.$set({ format: e }), this._switchFormat(e), this._events.$emit("format:change", { format: e });
|
|
1837
1890
|
}
|
|
1838
|
-
_switchFormat(
|
|
1839
|
-
var
|
|
1840
|
-
const t = this._formats.get(
|
|
1841
|
-
if (!t) throw new Error(`Unknown export format: ${
|
|
1842
|
-
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();
|
|
1843
1896
|
}
|
|
1844
1897
|
_updateCopyButtonState() {
|
|
1845
1898
|
var t;
|
|
1846
|
-
const
|
|
1847
|
-
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);
|
|
1848
1901
|
}
|
|
1849
1902
|
async _handleExportClick() {
|
|
1850
1903
|
if (!this._currentBlade) return;
|
|
1851
|
-
const
|
|
1904
|
+
const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions();
|
|
1852
1905
|
if (this._currentBlade.blade.validate()) {
|
|
1853
|
-
if (
|
|
1854
|
-
const
|
|
1855
|
-
if (
|
|
1856
|
-
|
|
1906
|
+
if (e === "gif") {
|
|
1907
|
+
const r = this._currentBlade.blade;
|
|
1908
|
+
if (r.isRecording()) return;
|
|
1909
|
+
r.setRecordingState("recording");
|
|
1857
1910
|
try {
|
|
1858
1911
|
await this._exportService.$requestExport("gif", t, { onGIFProgress: (a) => {
|
|
1859
|
-
|
|
1912
|
+
r.setRecordingState(a.state, a);
|
|
1860
1913
|
} });
|
|
1861
1914
|
} catch (a) {
|
|
1862
|
-
throw
|
|
1915
|
+
throw r.setRecordingState("error"), a;
|
|
1863
1916
|
}
|
|
1864
1917
|
return void window.setTimeout(() => {
|
|
1865
|
-
|
|
1918
|
+
r.setRecordingState("idle"), this._updateExportButton();
|
|
1866
1919
|
}, 1600);
|
|
1867
1920
|
}
|
|
1868
|
-
if (
|
|
1869
|
-
const
|
|
1870
|
-
if (
|
|
1871
|
-
|
|
1921
|
+
if (e === "video") {
|
|
1922
|
+
const r = this._currentBlade.blade;
|
|
1923
|
+
if (r.isRecording()) return;
|
|
1924
|
+
r.setRecordingState("recording");
|
|
1872
1925
|
try {
|
|
1873
1926
|
await this._exportService.$requestExport("video", t, { onVideoProgress: (a) => {
|
|
1874
|
-
|
|
1927
|
+
r.setRecordingState(a.state, a);
|
|
1875
1928
|
} });
|
|
1876
1929
|
} catch (a) {
|
|
1877
|
-
throw
|
|
1930
|
+
throw r.setRecordingState("error"), a;
|
|
1878
1931
|
}
|
|
1879
1932
|
return void window.setTimeout(() => {
|
|
1880
|
-
|
|
1933
|
+
r.setRecordingState("idle"), this._updateExportButton();
|
|
1881
1934
|
}, 1600);
|
|
1882
1935
|
}
|
|
1883
1936
|
this._exportButton.setDisabled(!0), this._exportButton.setLabel("exporting…");
|
|
1884
1937
|
try {
|
|
1885
|
-
await this._exportService.$requestExport(
|
|
1938
|
+
await this._exportService.$requestExport(e, t);
|
|
1886
1939
|
} finally {
|
|
1887
1940
|
this._exportButton.setDisabled(!1), this._exportButton.setLabel("download file");
|
|
1888
1941
|
}
|
|
@@ -1890,10 +1943,10 @@ class Xe {
|
|
|
1890
1943
|
}
|
|
1891
1944
|
async _handleCopyClick() {
|
|
1892
1945
|
if (!this._currentBlade || !this._currentBlade.definition.supportsClipboard) return;
|
|
1893
|
-
const
|
|
1946
|
+
const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
|
|
1894
1947
|
this._copyButton.setDisabled(!0), this._copyButton.setLabel("copying…");
|
|
1895
1948
|
try {
|
|
1896
|
-
switch (
|
|
1949
|
+
switch (e) {
|
|
1897
1950
|
case "txt":
|
|
1898
1951
|
await this._clipboardService.$copy("txt", t);
|
|
1899
1952
|
break;
|
|
@@ -1914,18 +1967,18 @@ class Xe {
|
|
|
1914
1967
|
console.error("[textmode-export] Failed to copy to clipboard", a), this._copyButton.setLabel("copy failed!");
|
|
1915
1968
|
} finally {
|
|
1916
1969
|
window.setTimeout(() => {
|
|
1917
|
-
this._copyButton.setLabel(
|
|
1970
|
+
this._copyButton.setLabel(r), this._copyButton.setDisabled(!1);
|
|
1918
1971
|
}, 1200);
|
|
1919
1972
|
}
|
|
1920
1973
|
}
|
|
1921
1974
|
_updateExportButton() {
|
|
1922
1975
|
if (!this._currentBlade) return;
|
|
1923
|
-
const
|
|
1924
|
-
if (
|
|
1925
|
-
const
|
|
1926
|
-
if (
|
|
1927
|
-
const o = a.frameIndex ?? 0,
|
|
1928
|
-
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}`);
|
|
1929
1982
|
} else {
|
|
1930
1983
|
const o = (a == null ? void 0 : a.state) === "encoding" ? "encoding" : "recording";
|
|
1931
1984
|
this._exportButton.setLabel(`${o}…`);
|
|
@@ -1933,9 +1986,9 @@ class Xe {
|
|
|
1933
1986
|
else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
|
|
1934
1987
|
return;
|
|
1935
1988
|
}
|
|
1936
|
-
if (
|
|
1937
|
-
const
|
|
1938
|
-
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) {
|
|
1939
1992
|
const o = a.frameIndex ?? 0;
|
|
1940
1993
|
this._exportButton.setLabel(`recording ${o}/${a.totalFrames} frames`);
|
|
1941
1994
|
} else this._exportButton.setLabel("recording…");
|
|
@@ -1946,65 +1999,65 @@ class Xe {
|
|
|
1946
1999
|
this._exportButton.setDisabled(t), this._exportButton.setLabel(t ? "exporting…" : "download file");
|
|
1947
2000
|
}
|
|
1948
2001
|
}
|
|
1949
|
-
class
|
|
2002
|
+
class ar {
|
|
1950
2003
|
constructor() {
|
|
1951
2004
|
p(this, "_listeners", {});
|
|
1952
2005
|
}
|
|
1953
|
-
_getPool(
|
|
1954
|
-
const t = this._listeners[
|
|
2006
|
+
_getPool(e) {
|
|
2007
|
+
const t = this._listeners[e];
|
|
1955
2008
|
if (t) return t;
|
|
1956
|
-
const
|
|
1957
|
-
return this._listeners[
|
|
2009
|
+
const r = /* @__PURE__ */ new Set();
|
|
2010
|
+
return this._listeners[e] = r, r;
|
|
1958
2011
|
}
|
|
1959
|
-
$on(
|
|
1960
|
-
const
|
|
1961
|
-
return
|
|
1962
|
-
|
|
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];
|
|
1963
2016
|
};
|
|
1964
2017
|
}
|
|
1965
|
-
$emit(
|
|
1966
|
-
const
|
|
1967
|
-
if (
|
|
2018
|
+
$emit(e, t) {
|
|
2019
|
+
const r = this._listeners[e];
|
|
2020
|
+
if (r) for (const a of [...r]) try {
|
|
1968
2021
|
a(t);
|
|
1969
2022
|
} catch (o) {
|
|
1970
2023
|
console.error("[textmode-export] Event handler failed", o);
|
|
1971
2024
|
}
|
|
1972
2025
|
}
|
|
1973
2026
|
$clear() {
|
|
1974
|
-
for (const
|
|
2027
|
+
for (const e of Object.keys(this._listeners)) delete this._listeners[e];
|
|
1975
2028
|
}
|
|
1976
2029
|
}
|
|
1977
|
-
class
|
|
1978
|
-
constructor(
|
|
2030
|
+
class or {
|
|
2031
|
+
constructor(e) {
|
|
1979
2032
|
p(this, "_state");
|
|
1980
2033
|
p(this, "_listeners", /* @__PURE__ */ new Set());
|
|
1981
|
-
this._state =
|
|
2034
|
+
this._state = e;
|
|
1982
2035
|
}
|
|
1983
2036
|
get snapshot() {
|
|
1984
2037
|
return Object.freeze({ ...this._state });
|
|
1985
2038
|
}
|
|
1986
|
-
$set(
|
|
1987
|
-
this._state = Object.assign({}, this._state,
|
|
2039
|
+
$set(e) {
|
|
2040
|
+
this._state = Object.assign({}, this._state, e);
|
|
1988
2041
|
const t = this.snapshot;
|
|
1989
|
-
for (const
|
|
1990
|
-
|
|
2042
|
+
for (const r of [...this._listeners]) try {
|
|
2043
|
+
r(t);
|
|
1991
2044
|
} catch (a) {
|
|
1992
2045
|
console.error("[textmode-export] State listener failed", a);
|
|
1993
2046
|
}
|
|
1994
2047
|
}
|
|
1995
|
-
$subscribe(
|
|
1996
|
-
return this._listeners.add(
|
|
1997
|
-
this._listeners.delete(
|
|
2048
|
+
$subscribe(e) {
|
|
2049
|
+
return this._listeners.add(e), e(this.snapshot), () => {
|
|
2050
|
+
this._listeners.delete(e);
|
|
1998
2051
|
};
|
|
1999
2052
|
}
|
|
2000
|
-
$reset(
|
|
2001
|
-
this._state =
|
|
2053
|
+
$reset(e) {
|
|
2054
|
+
this._state = e;
|
|
2002
2055
|
const t = this.snapshot;
|
|
2003
|
-
for (const
|
|
2056
|
+
for (const r of [...this._listeners]) r(t);
|
|
2004
2057
|
}
|
|
2005
2058
|
}
|
|
2006
|
-
const
|
|
2007
|
-
class nt extends
|
|
2059
|
+
const ir = (i) => ({ format: i, isBusy: !1 });
|
|
2060
|
+
class nt extends D {
|
|
2008
2061
|
constructor(t) {
|
|
2009
2062
|
super();
|
|
2010
2063
|
p(this, "props");
|
|
@@ -2036,7 +2089,7 @@ class nt extends T {
|
|
|
2036
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);
|
|
2037
2090
|
}
|
|
2038
2091
|
}
|
|
2039
|
-
class
|
|
2092
|
+
class sr extends D {
|
|
2040
2093
|
constructor(t) {
|
|
2041
2094
|
super();
|
|
2042
2095
|
p(this, "props");
|
|
@@ -2065,21 +2118,57 @@ class Ze extends T {
|
|
|
2065
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);
|
|
2066
2119
|
}
|
|
2067
2120
|
}
|
|
2068
|
-
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 {
|
|
2069
2154
|
constructor(t) {
|
|
2070
2155
|
super(t);
|
|
2156
|
+
p(this, "layerTarget");
|
|
2071
2157
|
p(this, "trailingSpaces", this._manageComponent(new nt({ label: "preserve trailing spaces", defaultChecked: !1 })));
|
|
2072
|
-
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 })));
|
|
2073
2160
|
}
|
|
2074
2161
|
render() {
|
|
2162
|
+
var a;
|
|
2075
2163
|
const t = document.createElement("div");
|
|
2076
|
-
t.classList.add(b.stack), this.trailingSpaces.mount(t);
|
|
2077
|
-
const
|
|
2078
|
-
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;
|
|
2079
2167
|
}
|
|
2080
2168
|
getOptions() {
|
|
2081
|
-
|
|
2082
|
-
|
|
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 };
|
|
2083
2172
|
}
|
|
2084
2173
|
reset() {
|
|
2085
2174
|
this.applyDefaults();
|
|
@@ -2087,26 +2176,38 @@ class tr extends J {
|
|
|
2087
2176
|
validate() {
|
|
2088
2177
|
return this.emptyCharacter.value.length <= 1;
|
|
2089
2178
|
}
|
|
2179
|
+
refreshLayerTargets() {
|
|
2180
|
+
var t;
|
|
2181
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2182
|
+
}
|
|
2090
2183
|
applyDefaults() {
|
|
2091
2184
|
const t = this._config.defaultOptions ?? {};
|
|
2092
2185
|
this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
|
|
2093
2186
|
}
|
|
2094
2187
|
}
|
|
2095
|
-
class
|
|
2188
|
+
class lr extends J {
|
|
2096
2189
|
constructor(t) {
|
|
2097
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" })));
|
|
2098
2194
|
p(this, "prettyPrint", this._manageComponent(new nt({ id: "textmode-export-json-pretty", label: "pretty print", defaultChecked: !0 })));
|
|
2099
2195
|
p(this, "includeMetadata", this._manageComponent(new nt({ id: "textmode-export-json-metadata", label: "include metadata", defaultChecked: !0 })));
|
|
2100
|
-
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 })));
|
|
2101
2198
|
}
|
|
2102
2199
|
render() {
|
|
2103
2200
|
const t = document.createElement("div");
|
|
2104
|
-
t.classList.add(b.stack)
|
|
2105
|
-
const
|
|
2106
|
-
|
|
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;
|
|
2107
2206
|
}
|
|
2108
2207
|
getOptions() {
|
|
2109
|
-
|
|
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 };
|
|
2110
2211
|
}
|
|
2111
2212
|
reset() {
|
|
2112
2213
|
this.applyDefaults();
|
|
@@ -2114,31 +2215,40 @@ class er extends J {
|
|
|
2114
2215
|
validate() {
|
|
2115
2216
|
return !0;
|
|
2116
2217
|
}
|
|
2218
|
+
refreshLayerTargets() {
|
|
2219
|
+
var t;
|
|
2220
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2221
|
+
}
|
|
2117
2222
|
applyDefaults() {
|
|
2118
2223
|
const t = this._config.defaultOptions ?? {};
|
|
2119
|
-
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);
|
|
2120
2230
|
}
|
|
2121
2231
|
}
|
|
2122
|
-
class
|
|
2232
|
+
class dr extends J {
|
|
2123
2233
|
constructor(t) {
|
|
2124
2234
|
super(t);
|
|
2125
|
-
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" })));
|
|
2126
2236
|
p(this, "scaleInput", this._manageComponent(new z({ defaultValue: "1", attributes: { min: "0.1", step: "0.1" } })));
|
|
2127
2237
|
}
|
|
2128
2238
|
render() {
|
|
2129
2239
|
const t = document.createElement("div");
|
|
2130
2240
|
t.classList.add(b.stack);
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
const a = new
|
|
2134
|
-
a.mount(
|
|
2135
|
-
const o = new
|
|
2136
|
-
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;
|
|
2137
2247
|
}
|
|
2138
2248
|
getOptions() {
|
|
2139
|
-
var
|
|
2249
|
+
var r;
|
|
2140
2250
|
const t = Number.parseFloat(this.scaleInput.value);
|
|
2141
|
-
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 };
|
|
2142
2252
|
}
|
|
2143
2253
|
reset() {
|
|
2144
2254
|
this.applyDefaults(), this.scaleInput.refresh();
|
|
@@ -2150,29 +2260,33 @@ class rr extends J {
|
|
|
2150
2260
|
applyDefaults() {
|
|
2151
2261
|
const t = this._config.defaultOptions ?? {};
|
|
2152
2262
|
this.formatSelect.value = t.format ?? "png";
|
|
2153
|
-
const
|
|
2154
|
-
this.scaleInput.value = String(
|
|
2263
|
+
const r = t.scale ?? 1;
|
|
2264
|
+
this.scaleInput.value = String(r);
|
|
2155
2265
|
}
|
|
2156
2266
|
}
|
|
2157
|
-
class
|
|
2267
|
+
class cr extends J {
|
|
2158
2268
|
constructor(t) {
|
|
2159
2269
|
super(t);
|
|
2270
|
+
p(this, "layerTarget");
|
|
2160
2271
|
p(this, "includeBackground", this._manageComponent(new nt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 })));
|
|
2161
|
-
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" })));
|
|
2162
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 })));
|
|
2163
2275
|
}
|
|
2164
2276
|
render() {
|
|
2277
|
+
var n;
|
|
2165
2278
|
const t = document.createElement("div");
|
|
2166
|
-
t.classList.add(b.stack), this.includeBackground.mount(t);
|
|
2167
|
-
const
|
|
2168
|
-
|
|
2169
|
-
const a = new
|
|
2170
|
-
a.mount(
|
|
2171
|
-
const o = new
|
|
2172
|
-
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;
|
|
2173
2286
|
}
|
|
2174
2287
|
getOptions() {
|
|
2175
|
-
|
|
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) };
|
|
2176
2290
|
}
|
|
2177
2291
|
reset() {
|
|
2178
2292
|
this.applyDefaults(), this.updateStrokeControls();
|
|
@@ -2181,6 +2295,10 @@ class ar extends J {
|
|
|
2181
2295
|
const t = Number.parseFloat(this.strokeWidth.value);
|
|
2182
2296
|
return this.drawMode.value !== "stroke" || Number.isFinite(t) && t >= 0;
|
|
2183
2297
|
}
|
|
2298
|
+
refreshLayerTargets() {
|
|
2299
|
+
var t;
|
|
2300
|
+
(t = this.layerTarget) == null || t.refresh();
|
|
2301
|
+
}
|
|
2184
2302
|
updateStrokeControls() {
|
|
2185
2303
|
const t = this.drawMode.value === "stroke";
|
|
2186
2304
|
this.strokeWidth.inputElement.disabled = !t, this.strokeWidth.refresh();
|
|
@@ -2188,43 +2306,46 @@ class ar extends J {
|
|
|
2188
2306
|
applyDefaults() {
|
|
2189
2307
|
const t = this._config.defaultOptions ?? {};
|
|
2190
2308
|
this.includeBackground.checked = t.includeBackgroundRectangles ?? !0, this.drawMode.value = t.drawMode ?? "fill";
|
|
2191
|
-
const
|
|
2192
|
-
this.strokeWidth.value = String(
|
|
2309
|
+
const r = t.strokeWidth ?? 1;
|
|
2310
|
+
this.strokeWidth.value = String(r), this.strokeWidth.refresh();
|
|
2193
2311
|
}
|
|
2194
2312
|
}
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
return or;
|
|
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 } }) }];
|
|
2198
2315
|
}
|
|
2199
|
-
function
|
|
2200
|
-
var
|
|
2201
|
-
const
|
|
2202
|
-
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;
|
|
2203
2320
|
}
|
|
2204
|
-
const
|
|
2205
|
-
const t = { saveCanvas: async (d = {}) => new
|
|
2206
|
-
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);
|
|
2207
2324
|
}, saveStrings: (d = {}) => {
|
|
2208
|
-
new
|
|
2209
|
-
}, toSVG: (d = {}) => new
|
|
2210
|
-
new
|
|
2211
|
-
}, saveGIF: async (d = {}) => new
|
|
2212
|
-
|
|
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;
|
|
2213
2334
|
}, async uninstall(i) {
|
|
2214
|
-
const
|
|
2215
|
-
t == null || t.$dispose(), delete
|
|
2216
|
-
const
|
|
2217
|
-
for (const a of
|
|
2218
|
-
} },
|
|
2219
|
-
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;
|
|
2220
2341
|
return t.install = async (a, o) => {
|
|
2221
2342
|
var d;
|
|
2222
|
-
const
|
|
2223
|
-
await
|
|
2343
|
+
const n = a;
|
|
2344
|
+
await r.call(t, n, o), e || ((d = n.exportOverlay) == null || d.hide());
|
|
2224
2345
|
}, t;
|
|
2225
2346
|
};
|
|
2226
|
-
typeof window < "u" && (window.ExportPlugin =
|
|
2347
|
+
typeof window < "u" && (window.ExportPlugin = Zt, window.createTextmodeExportPlugin = hr);
|
|
2227
2348
|
export {
|
|
2228
|
-
|
|
2229
|
-
|
|
2349
|
+
Zt as ExportPlugin,
|
|
2350
|
+
hr as createTextmodeExportPlugin
|
|
2230
2351
|
};
|