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