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