textmode.export.js 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -166
- package/dist/textmode.export.esm.js +522 -483
- package/dist/textmode.export.umd.js +2 -2
- package/dist/types/exporters/base/DataExtractor.d.ts +2 -1
- package/dist/types/exporters/base/DataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/base/FileHandler.d.ts +3 -0
- package/dist/types/exporters/base/FileHandler.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFExporter.d.ts +6 -2
- package/dist/types/exporters/gif/GIFExporter.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFRecorder.d.ts +3 -3
- 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/image/ImageExporter.d.ts +7 -2
- package/dist/types/exporters/image/ImageExporter.d.ts.map +1 -1
- package/dist/types/exporters/image/index.d.ts +1 -1
- package/dist/types/exporters/image/index.d.ts.map +1 -1
- package/dist/types/exporters/image/types.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts +10 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGDataExtractor.d.ts +3 -1
- package/dist/types/exporters/svg/SVGDataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGExporter.d.ts +3 -0
- package/dist/types/exporters/svg/SVGExporter.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts +8 -4
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/index.d.ts +1 -1
- package/dist/types/exporters/svg/index.d.ts.map +1 -1
- package/dist/types/exporters/svg/types.d.ts.map +1 -1
- package/dist/types/exporters/txt/TXTExporter.d.ts +4 -0
- package/dist/types/exporters/txt/TXTExporter.d.ts.map +1 -1
- package/dist/types/exporters/txt/index.d.ts.map +1 -1
- package/dist/types/exporters/txt/types.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoExporter.d.ts +6 -2
- package/dist/types/exporters/video/VideoExporter.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoRecorder.d.ts +3 -3
- package/dist/types/exporters/video/VideoRecorder.d.ts.map +1 -1
- package/dist/types/exporters/video/index.d.ts +1 -1
- package/dist/types/exporters/video/index.d.ts.map +1 -1
- package/dist/types/exporters/video/types.d.ts +2 -2
- package/dist/types/exporters/video/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +82 -20
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/overlay/blades/Blade.d.ts +6 -1
- package/dist/types/overlay/blades/Blade.d.ts.map +1 -1
- package/dist/types/overlay/blades/GIFBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/ImageBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/SVGBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/TextBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/VideoBlade.d.ts.map +1 -1
- package/dist/types/overlay/components/actions/Button.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Component.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Container.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Field.d.ts.map +1 -1
- package/dist/types/overlay/components/display/Header.d.ts.map +1 -1
- package/dist/types/overlay/components/display/StatusDisplay.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/CheckboxInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/NumberInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/RangeInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/SelectInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/TextInput.d.ts.map +1 -1
- package/dist/types/overlay/core/EventBus.d.ts +1 -0
- package/dist/types/overlay/core/EventBus.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/overlay/core/StateManager.d.ts.map +1 -1
- package/dist/types/overlay/formatRegistry.d.ts.map +1 -1
- package/dist/types/overlay/index.d.ts +1 -0
- package/dist/types/overlay/index.d.ts.map +1 -1
- package/dist/types/overlay/models/FormatDefinition.d.ts +3 -3
- package/dist/types/overlay/models/FormatDefinition.d.ts.map +1 -1
- package/dist/types/overlay/models/OverlayEvents.d.ts.map +1 -1
- package/dist/types/overlay/models/OverlayState.d.ts.map +1 -1
- package/dist/types/overlay/services/ClipboardService.d.ts +7 -2
- package/dist/types/overlay/services/ClipboardService.d.ts.map +1 -1
- package/dist/types/overlay/services/ExportService.d.ts.map +1 -1
- package/dist/types/overlay/services/PositionService.d.ts.map +1 -1
- package/dist/types/overlay/types.d.ts.map +1 -1
- package/dist/types/types.d.ts +99 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/pixels.d.ts +1 -0
- package/dist/types/utils/pixels.d.ts.map +1 -1
- package/package.json +115 -72
|
@@ -24,13 +24,13 @@ class Q {
|
|
|
24
24
|
return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function ft(
|
|
28
|
-
return { r:
|
|
27
|
+
function ft(n, t) {
|
|
28
|
+
return { r: n[t], g: n[t + 1], b: n[t + 2], a: n[t + 3] };
|
|
29
29
|
}
|
|
30
|
-
class
|
|
30
|
+
class qt extends At {
|
|
31
31
|
_extractTransformData(t, e) {
|
|
32
|
-
const r = t[e + 2], a = !!(1 & r), i = !!(2 & r),
|
|
33
|
-
return { isInverted: a, flipHorizontal: i, flipVertical:
|
|
32
|
+
const r = t[e + 2], a = !!(1 & r), i = !!(2 & r), s = !!(4 & r), l = t[e + 3] / 255;
|
|
33
|
+
return { isInverted: a, flipHorizontal: i, flipVertical: s, rotation: Math.round(360 * l * 100) / 100 };
|
|
34
34
|
}
|
|
35
35
|
_calculateCellPosition(t, e, r) {
|
|
36
36
|
return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
|
|
@@ -38,50 +38,49 @@ class Wt extends At {
|
|
|
38
38
|
$extractSVGCellData(t, e) {
|
|
39
39
|
const r = [];
|
|
40
40
|
let a = 0;
|
|
41
|
-
for (let i = 0; i < e.rows; i++) for (let
|
|
42
|
-
const
|
|
43
|
-
let p = ft(t.primaryColorPixels,
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
41
|
+
for (let i = 0; i < e.rows; i++) for (let s = 0; s < e.cols; s++) {
|
|
42
|
+
const l = 4 * a, d = this.$getCharacterIndex(t.characterPixels, l);
|
|
43
|
+
let p = ft(t.primaryColorPixels, l), o = ft(t.secondaryColorPixels, l);
|
|
44
|
+
const c = this._extractTransformData(t.characterPixels, l);
|
|
45
|
+
if (c.isInverted) {
|
|
46
46
|
const m = p;
|
|
47
47
|
p = o, o = m;
|
|
48
48
|
}
|
|
49
|
-
const u = this._calculateCellPosition(
|
|
50
|
-
r.push({ charIndex:
|
|
49
|
+
const u = this._calculateCellPosition(s, i, e);
|
|
50
|
+
r.push({ charIndex: d, primaryColor: p, secondaryColor: o, transform: c, position: u }), a++;
|
|
51
51
|
}
|
|
52
52
|
return r;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
class
|
|
55
|
+
class Ht {
|
|
56
56
|
_createGlyphPath(t, e, r, a, i) {
|
|
57
|
-
const
|
|
58
|
-
return { getBoundingBox: () => ({ x1: r + e.xMin *
|
|
57
|
+
const s = i / t.head.unitsPerEm;
|
|
58
|
+
return { getBoundingBox: () => ({ x1: r + e.xMin * s, y1: a + -e.yMax * s, x2: r + e.xMax * s, y2: a + -e.yMin * s }), toSVG: () => this._glyphToSVGPath(e, r, a, s) };
|
|
59
59
|
}
|
|
60
60
|
_glyphToSVGPath(t, e, r, a) {
|
|
61
61
|
if (!t || !t.xs) return "";
|
|
62
|
-
const { xs: i, ys:
|
|
63
|
-
if (!(i &&
|
|
62
|
+
const { xs: i, ys: s, endPts: l, flags: d } = t;
|
|
63
|
+
if (!(i && s && l && d)) return "";
|
|
64
64
|
let p = "", o = 0;
|
|
65
|
-
for (let
|
|
66
|
-
const u = c
|
|
65
|
+
for (let c = 0; c < l.length; c++) {
|
|
66
|
+
const u = l[c];
|
|
67
67
|
if (!(u < o)) {
|
|
68
68
|
if (u >= o) {
|
|
69
|
-
const m = e + i[o] * a, x = r -
|
|
69
|
+
const m = e + i[o] * a, x = r - s[o] * a;
|
|
70
70
|
p += `M${m.toFixed(2)},${x.toFixed(2)}`;
|
|
71
71
|
let h = o + 1;
|
|
72
72
|
for (; h <= u; )
|
|
73
|
-
if (1 &
|
|
74
|
-
const
|
|
75
|
-
p += `L${
|
|
73
|
+
if (1 & d[h]) {
|
|
74
|
+
const g = e + i[h] * a, _ = r - s[h] * a;
|
|
75
|
+
p += `L${g.toFixed(2)},${_.toFixed(2)}`, h++;
|
|
76
76
|
} else {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
p += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
|
|
77
|
+
const g = e + i[h] * a, _ = r - s[h] * a, v = h + 1 > u ? o : h + 1;
|
|
78
|
+
if (1 & d[v]) {
|
|
79
|
+
const f = e + i[v] * a, C = r - s[v] * a;
|
|
80
|
+
p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
|
|
82
81
|
} else {
|
|
83
|
-
const
|
|
84
|
-
p += `Q${
|
|
82
|
+
const f = (g + (e + i[v] * a)) / 2, C = (_ + (r - s[v] * a)) / 2;
|
|
83
|
+
p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
p += "Z";
|
|
@@ -92,19 +91,19 @@ class qt {
|
|
|
92
91
|
return p;
|
|
93
92
|
}
|
|
94
93
|
_generateCharacterPath(t, e, r, a, i) {
|
|
95
|
-
const
|
|
96
|
-
return
|
|
94
|
+
const s = e.characterMap.get(t)?.glyphData;
|
|
95
|
+
return s ? this._createGlyphPath(e.font, s, r, a, i) : null;
|
|
97
96
|
}
|
|
98
|
-
$generatePositionedCharacterPath(t, e, r, a, i,
|
|
99
|
-
if (!
|
|
100
|
-
const p =
|
|
97
|
+
$generatePositionedCharacterPath(t, e, r, a, i, s, l, d) {
|
|
98
|
+
if (!d) return null;
|
|
99
|
+
const p = l / e.font.head.unitsPerEm, o = r + (i - d.advanceWidth * p) / 2, c = a + (s + 0.7 * l) / 2, u = this._generateCharacterPath(t, e, o, c, l);
|
|
101
100
|
return u && u.toSVG() || null;
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
|
-
class
|
|
103
|
+
class jt {
|
|
105
104
|
_pathGenerator;
|
|
106
105
|
constructor() {
|
|
107
|
-
this._pathGenerator = new
|
|
106
|
+
this._pathGenerator = new Ht();
|
|
108
107
|
}
|
|
109
108
|
$generateSVGHeader(t) {
|
|
110
109
|
const { width: e, height: r } = t;
|
|
@@ -116,43 +115,43 @@ class Ht {
|
|
|
116
115
|
_generateTransformAttribute(t, e) {
|
|
117
116
|
const { transform: r, position: a } = t;
|
|
118
117
|
if (!r.flipHorizontal && !r.flipVertical && !r.rotation) return "";
|
|
119
|
-
const i = a.cellX + e.cellWidth / 2,
|
|
118
|
+
const i = a.cellX + e.cellWidth / 2, s = a.cellY + e.cellHeight / 2, l = [];
|
|
120
119
|
if (r.flipHorizontal || r.flipVertical) {
|
|
121
|
-
const
|
|
122
|
-
|
|
120
|
+
const d = r.flipHorizontal ? -1 : 1, p = r.flipVertical ? -1 : 1;
|
|
121
|
+
l.push(`translate(${i} ${s})scale(${d} ${p})translate(${-i} ${-s})`);
|
|
123
122
|
}
|
|
124
|
-
return r.rotation &&
|
|
123
|
+
return r.rotation && l.push(`rotate(${r.rotation} ${i} ${s})`), ` transform="${l.join(" ")}"`;
|
|
125
124
|
}
|
|
126
125
|
_generateCellBackground(t, e, r) {
|
|
127
126
|
if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
128
|
-
const { position: a } = t, { r: i, g:
|
|
127
|
+
const { position: a } = t, { r: i, g: s, b: l, a: d } = t.secondaryColor, p = `rgba(${i},${s},${l},${d / 255})`;
|
|
129
128
|
return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${p}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${p}"/>`;
|
|
130
129
|
}
|
|
131
130
|
_generateCharacterPath(t, e, r, a) {
|
|
132
131
|
const i = r.characters[t.charIndex];
|
|
133
132
|
if (!i) return "";
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
const { r:
|
|
137
|
-
return a.drawMode === "stroke" ? `<path d="${
|
|
133
|
+
const s = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.glyphData);
|
|
134
|
+
if (!s) return "";
|
|
135
|
+
const { r: l, g: d, b: p, a: o } = t.primaryColor, c = `rgba(${l},${d},${p},${o / 255})`;
|
|
136
|
+
return a.drawMode === "stroke" ? `<path d="${s}" stroke="${c}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${s}" fill="${c}"/>`;
|
|
138
137
|
}
|
|
139
138
|
$generateCellContent(t, e, r, a) {
|
|
140
|
-
const i = [],
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
i.push(
|
|
139
|
+
const i = [], s = this._generateCellBackground(t, e, a);
|
|
140
|
+
s && i.push(s);
|
|
141
|
+
const l = this._generateCharacterPath(t, e, r, a);
|
|
142
|
+
if (l) {
|
|
143
|
+
const d = this._generateTransformAttribute(t, e);
|
|
144
|
+
i.push(d ? `<g${d}>${l}</g>` : l);
|
|
146
145
|
}
|
|
147
146
|
return i.join("");
|
|
148
147
|
}
|
|
149
148
|
$generateSVGContent(t, e, r, a) {
|
|
150
149
|
const i = [this.$generateSVGHeader(e), '<g id="ascii-cells">'];
|
|
151
|
-
for (const
|
|
150
|
+
for (const s of t) i.push(this.$generateCellContent(s, e, r, a));
|
|
152
151
|
return i.push(this.$generateSVGFooter()), i.join("");
|
|
153
152
|
}
|
|
154
153
|
$optimizeSVGContent(t) {
|
|
155
|
-
return t.replace(
|
|
154
|
+
return t.replace(/\s+/g, " ").replace(/> </g, "><");
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
class gt {
|
|
@@ -160,8 +159,8 @@ class gt {
|
|
|
160
159
|
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, filename: t.filename };
|
|
161
160
|
}
|
|
162
161
|
$generateSVG(t, e = {}) {
|
|
163
|
-
const r = new
|
|
164
|
-
return a.$optimizeSVGContent(
|
|
162
|
+
const r = new qt(), a = new jt(), i = r.$extractSVGCellData(r.$extractFramebufferData(t.layers.base.drawFramebuffer), t.grid), s = a.$generateSVGContent(i, t.grid, t.font, this._applyDefaultOptions(e));
|
|
163
|
+
return a.$optimizeSVGContent(s);
|
|
165
164
|
}
|
|
166
165
|
$saveSVG(t, e = {}) {
|
|
167
166
|
new Q().$downloadFile(new Blob([this.$generateSVG(t, e)], { type: "image/svg+xml;charset=utf-8" }), e.filename);
|
|
@@ -176,10 +175,10 @@ class bt {
|
|
|
176
175
|
if (!(t.format in st)) throw new Error(`Saving '${t.format}' files is not supported`);
|
|
177
176
|
}
|
|
178
177
|
async $generateImageBlob(t, e) {
|
|
179
|
-
const r = t, a = document.createElement("canvas"), i = a.getContext("2d"),
|
|
180
|
-
return a.width =
|
|
178
|
+
const r = t, a = document.createElement("canvas"), i = a.getContext("2d"), s = Math.round(r.width * e.scale), l = Math.round(r.height * e.scale);
|
|
179
|
+
return a.width = s, a.height = l, i.imageSmoothingEnabled = !1, i.clearRect(0, 0, s, l), i.drawImage(r, 0, 0, r.width, r.height, 0, 0, s, l), await new Promise((d, p) => {
|
|
181
180
|
a.toBlob((o) => {
|
|
182
|
-
o ?
|
|
181
|
+
o ? d(o) : p(new Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
183
182
|
}, st[e.format]);
|
|
184
183
|
});
|
|
185
184
|
}
|
|
@@ -202,25 +201,17 @@ class vt {
|
|
|
202
201
|
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename };
|
|
203
202
|
}
|
|
204
203
|
_createTXTContent(t, e) {
|
|
205
|
-
const r = new At();
|
|
206
|
-
|
|
207
|
-
let
|
|
208
|
-
|
|
209
|
-
let n = 0;
|
|
210
|
-
for (let l = 0; l < t.grid.rows; l++) {
|
|
211
|
-
const p = [];
|
|
204
|
+
const r = new At(), a = t.layers.base.drawFramebuffer, i = r.$extractFramebufferData(a), s = [];
|
|
205
|
+
let l = 0;
|
|
206
|
+
for (let d = 0; d < t.grid.rows; d++) {
|
|
207
|
+
let p = "";
|
|
212
208
|
for (let o = 0; o < t.grid.cols; o++) {
|
|
213
|
-
const
|
|
214
|
-
p.
|
|
209
|
+
const c = 4 * l, u = r.$getCharacterIndex(i.characterPixels, c);
|
|
210
|
+
p += t.font.characters[u]?.character || e.emptyCharacter, l++;
|
|
215
211
|
}
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
const c = [];
|
|
219
|
-
for (const l of i) {
|
|
220
|
-
let p = l.join("");
|
|
221
|
-
e.preserveTrailingSpaces || (p = p.replace(/\s+$/, "")), c.push(p);
|
|
212
|
+
e.preserveTrailingSpaces || (p = p.trimEnd()), s.push(p);
|
|
222
213
|
}
|
|
223
|
-
return
|
|
214
|
+
return s.join(`
|
|
224
215
|
`);
|
|
225
216
|
}
|
|
226
217
|
$generateTXT(t, e = {}) {
|
|
@@ -231,133 +222,133 @@ class vt {
|
|
|
231
222
|
new Q().$downloadFile(i, r.filename);
|
|
232
223
|
}
|
|
233
224
|
}
|
|
234
|
-
class
|
|
225
|
+
class Qt {
|
|
235
226
|
_canvas;
|
|
236
227
|
_ctx;
|
|
237
228
|
async $record(t, e, r, a) {
|
|
238
|
-
const i = Math.max(1, Math.round(e.frameRate)),
|
|
239
|
-
return await new Promise((
|
|
229
|
+
const i = Math.max(1, Math.round(e.frameRate)), s = Math.round(1e3 / i), l = Math.max(1, Math.round(e.frameCount));
|
|
230
|
+
return await new Promise((d, p) => {
|
|
240
231
|
const o = [];
|
|
241
|
-
let
|
|
232
|
+
let c, u = 0, m = !1;
|
|
242
233
|
const x = () => {
|
|
243
|
-
|
|
234
|
+
c && (c(), c = void 0);
|
|
244
235
|
}, h = (_) => {
|
|
245
|
-
m || (m = !0, x(),
|
|
246
|
-
},
|
|
247
|
-
if (u >=
|
|
236
|
+
m || (m = !0, x(), d(_));
|
|
237
|
+
}, g = () => {
|
|
238
|
+
if (u >= l) h(o);
|
|
248
239
|
else try {
|
|
249
|
-
const _ = e.scale, v = Math.max(1, Math.round(t.width * _)),
|
|
250
|
-
this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height ===
|
|
240
|
+
const _ = e.scale, v = Math.max(1, Math.round(t.width * _)), f = Math.max(1, Math.round(t.height * _));
|
|
241
|
+
this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height === f || (this._canvas.width = v, this._canvas.height = f), this._ctx || (this._ctx = this._canvas.getContext("2d"));
|
|
251
242
|
const C = this._ctx;
|
|
252
|
-
C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v,
|
|
253
|
-
const S = { imageData: C.getImageData(0, 0, v,
|
|
254
|
-
o.push(S), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames:
|
|
243
|
+
C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v, f), C.drawImage(t, 0, 0, t.width, t.height, 0, 0, v, f);
|
|
244
|
+
const S = { imageData: C.getImageData(0, 0, v, f), width: v, height: f, delayMs: s };
|
|
245
|
+
o.push(S), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: l }), u >= l && h(o);
|
|
255
246
|
} catch (_) {
|
|
256
247
|
((v) => {
|
|
257
248
|
if (m) return;
|
|
258
249
|
m = !0, x();
|
|
259
|
-
const
|
|
260
|
-
a?.({ state: "error", message:
|
|
250
|
+
const f = v instanceof Error ? v.message : "GIF recording failed";
|
|
251
|
+
a?.({ state: "error", message: f }), p(v instanceof Error ? v : new Error(String(v)));
|
|
261
252
|
})(_);
|
|
262
253
|
}
|
|
263
254
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}), a?.({ state: "recording", frameIndex: 0, totalFrames:
|
|
255
|
+
c = r(() => {
|
|
256
|
+
g();
|
|
257
|
+
}), a?.({ state: "recording", frameIndex: 0, totalFrames: l });
|
|
267
258
|
});
|
|
268
259
|
}
|
|
269
260
|
}
|
|
270
|
-
var Pt = Object.defineProperty,
|
|
271
|
-
for (var e in t) Pt(
|
|
272
|
-
},
|
|
273
|
-
function t(
|
|
274
|
-
return 0.29889531 *
|
|
261
|
+
var Pt = Object.defineProperty, Xt = (n) => Pt(n, "__esModule", { value: !0 }), Yt = (n, t) => () => (t || n((t = { exports: {} }).exports, t), t.exports), Jt = (n, t) => {
|
|
262
|
+
for (var e in t) Pt(n, e, { get: t[e], enumerable: !0 });
|
|
263
|
+
}, Kt = Yt((n) => {
|
|
264
|
+
function t(c, u, m) {
|
|
265
|
+
return 0.29889531 * c + 0.58662247 * u + 0.11448223 * m;
|
|
275
266
|
}
|
|
276
|
-
function e(
|
|
277
|
-
return 0.59597799 *
|
|
267
|
+
function e(c, u, m) {
|
|
268
|
+
return 0.59597799 * c - 0.2741761 * u - 0.32180189 * m;
|
|
278
269
|
}
|
|
279
|
-
function r(
|
|
280
|
-
return 0.21147017 *
|
|
270
|
+
function r(c, u, m) {
|
|
271
|
+
return 0.21147017 * c - 0.52261711 * u + 0.31114694 * m;
|
|
281
272
|
}
|
|
282
|
-
function a(
|
|
283
|
-
let m =
|
|
284
|
-
return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 +
|
|
273
|
+
function a(c, u) {
|
|
274
|
+
let m = c[0] - u[0], x = c[1] - u[1], h = c[2] - u[2], g = i(c) - i(u);
|
|
275
|
+
return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 + g * g;
|
|
285
276
|
}
|
|
286
|
-
function i(
|
|
287
|
-
return
|
|
277
|
+
function i(c) {
|
|
278
|
+
return c[3] != null ? c[3] : 255;
|
|
288
279
|
}
|
|
289
|
-
function
|
|
290
|
-
return Math.sqrt(a(
|
|
280
|
+
function s(c, u) {
|
|
281
|
+
return Math.sqrt(a(c, u));
|
|
291
282
|
}
|
|
292
|
-
function c
|
|
293
|
-
let [m, x, h] =
|
|
294
|
-
return
|
|
283
|
+
function l(c, u) {
|
|
284
|
+
let [m, x, h] = c, [g, _, v] = u, f = t(m, x, h) - t(g, _, v), C = e(m, x, h) - e(g, _, v), S = r(m, x, h) - r(g, _, v), E = i(c) - i(u);
|
|
285
|
+
return f * f * 0.5053 + C * C * 0.299 + S * S * 0.1957 + E * E;
|
|
295
286
|
}
|
|
296
|
-
function
|
|
297
|
-
return Math.sqrt(c
|
|
287
|
+
function d(c, u) {
|
|
288
|
+
return Math.sqrt(l(c, u));
|
|
298
289
|
}
|
|
299
|
-
function p(
|
|
290
|
+
function p(c, u) {
|
|
300
291
|
var m, x = 0;
|
|
301
|
-
for (m = 0; m <
|
|
302
|
-
let h =
|
|
292
|
+
for (m = 0; m < c.length; m++) {
|
|
293
|
+
let h = c[m] - u[m];
|
|
303
294
|
x += h * h;
|
|
304
295
|
}
|
|
305
296
|
return x;
|
|
306
297
|
}
|
|
307
|
-
function o(
|
|
308
|
-
return Math.sqrt(p(
|
|
298
|
+
function o(c, u) {
|
|
299
|
+
return Math.sqrt(p(c, u));
|
|
309
300
|
}
|
|
310
|
-
|
|
311
|
-
}),
|
|
312
|
-
function Dt(
|
|
313
|
-
let t = 0, e = new Uint8Array(
|
|
301
|
+
Xt(n), Jt(n, { colorDifferenceRGBToYIQ: () => d, colorDifferenceRGBToYIQSquared: () => l, colorDifferenceYIQ: () => s, colorDifferenceYIQSquared: () => a, euclideanDistance: () => o, euclideanDistanceSquared: () => p });
|
|
302
|
+
}), Zt = { trailer: 59 };
|
|
303
|
+
function Dt(n = 256) {
|
|
304
|
+
let t = 0, e = new Uint8Array(n);
|
|
314
305
|
return { get buffer() {
|
|
315
306
|
return e.buffer;
|
|
316
307
|
}, reset() {
|
|
317
308
|
t = 0;
|
|
318
309
|
}, bytesView: () => e.subarray(0, t), bytes: () => e.slice(0, t), writeByte(a) {
|
|
319
310
|
r(t + 1), e[t] = a, t++;
|
|
320
|
-
}, writeBytes(a, i = 0,
|
|
321
|
-
r(t +
|
|
322
|
-
for (let
|
|
323
|
-
}, writeBytesView(a, i = 0,
|
|
324
|
-
r(t +
|
|
311
|
+
}, writeBytes(a, i = 0, s = a.length) {
|
|
312
|
+
r(t + s);
|
|
313
|
+
for (let l = 0; l < s; l++) e[t++] = a[l + i];
|
|
314
|
+
}, writeBytesView(a, i = 0, s = a.byteLength) {
|
|
315
|
+
r(t + s), e.set(a.subarray(i, i + s), t), t += s;
|
|
325
316
|
} };
|
|
326
317
|
function r(a) {
|
|
327
318
|
var i = e.length;
|
|
328
319
|
if (i >= a) return;
|
|
329
320
|
a = Math.max(a, i * (i < 1048576 ? 2 : 1.125) >>> 0), i != 0 && (a = Math.max(a, 256));
|
|
330
|
-
let
|
|
331
|
-
e = new Uint8Array(a), t > 0 && e.set(
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
var Z = 12, xt = 5003,
|
|
335
|
-
function
|
|
336
|
-
a = a || Dt(512), i = i || new Uint8Array(256),
|
|
337
|
-
let
|
|
338
|
-
i.fill(0),
|
|
339
|
-
let o = 0,
|
|
340
|
-
for (let k =
|
|
341
|
-
E = 8 - E, a.writeByte(p),
|
|
321
|
+
let s = e;
|
|
322
|
+
e = new Uint8Array(a), t > 0 && e.set(s.subarray(0, t), 0);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
var Z = 12, xt = 5003, te = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
|
|
326
|
+
function ee(n, t, e, r, a, i, s, l) {
|
|
327
|
+
a = a || Dt(512), i = i || new Uint8Array(256), s = s || new Int32Array(xt), l = l || new Int32Array(xt);
|
|
328
|
+
let d = s.length, p = Math.max(2, r);
|
|
329
|
+
i.fill(0), l.fill(0), L();
|
|
330
|
+
let o = 0, c = 0, u = p + 1, m = u, x = !1, h = m, g = D(h), _ = 1 << u - 1, v = _ + 1, f = _ + 2, C = 0, S = e[0], E = 0;
|
|
331
|
+
for (let k = d; k < 65536; k *= 2) ++E;
|
|
332
|
+
E = 8 - E, a.writeByte(p), T(_);
|
|
342
333
|
for (let k = 1; k < e.length; k++) V(e[k]);
|
|
343
|
-
return
|
|
334
|
+
return T(S), T(v), a.writeByte(0), a.bytesView();
|
|
344
335
|
function A(k) {
|
|
345
336
|
i[C++] = k, C >= 254 && B();
|
|
346
337
|
}
|
|
347
338
|
function L() {
|
|
348
|
-
|
|
339
|
+
s.fill(-1);
|
|
349
340
|
}
|
|
350
341
|
function V(k) {
|
|
351
342
|
let R = (k << Z) + S, y = k << E ^ S;
|
|
352
|
-
if (
|
|
343
|
+
if (s[y] === R) S = l[y];
|
|
353
344
|
else {
|
|
354
|
-
if (
|
|
355
|
-
let w = y === 0 ? 1 :
|
|
345
|
+
if (s[y] >= 0) {
|
|
346
|
+
let w = y === 0 ? 1 : d - y;
|
|
356
347
|
do
|
|
357
|
-
if (y -= w, y < 0 && (y +=
|
|
358
|
-
while (
|
|
348
|
+
if (y -= w, y < 0 && (y += d), s[y] === R) return void (S = l[y]);
|
|
349
|
+
while (s[y] >= 0);
|
|
359
350
|
}
|
|
360
|
-
|
|
351
|
+
T(S), S = k, f < 1 << Z ? (l[y] = f++, s[y] = R) : (L(), f = _ + 2, x = !0, T(_));
|
|
361
352
|
}
|
|
362
353
|
}
|
|
363
354
|
function B() {
|
|
@@ -366,36 +357,36 @@ function te(s, t, e, r, a, i, n, c) {
|
|
|
366
357
|
function D(k) {
|
|
367
358
|
return (1 << k) - 1;
|
|
368
359
|
}
|
|
369
|
-
function
|
|
370
|
-
for (o &=
|
|
371
|
-
if ((
|
|
372
|
-
for (;
|
|
360
|
+
function T(k) {
|
|
361
|
+
for (o &= te[c], c > 0 ? o |= k << c : o = k, c += h; c >= 8; ) A(255 & o), o >>= 8, c -= 8;
|
|
362
|
+
if ((f > g || x) && (x ? (h = m, g = D(h), x = !1) : (++h, g = h == Z ? 1 << Z : D(h))), k == v) {
|
|
363
|
+
for (; c > 0; ) A(255 & o), o >>= 8, c -= 8;
|
|
373
364
|
B();
|
|
374
365
|
}
|
|
375
366
|
}
|
|
376
367
|
}
|
|
377
|
-
var
|
|
378
|
-
function Vt(
|
|
379
|
-
return
|
|
368
|
+
var re = ee;
|
|
369
|
+
function Vt(n, t, e) {
|
|
370
|
+
return n << 8 & 63488 | t << 2 & 992 | e >> 3 & 31;
|
|
380
371
|
}
|
|
381
|
-
function
|
|
382
|
-
return
|
|
372
|
+
function Ot(n, t, e, r) {
|
|
373
|
+
return n >> 4 | 240 & t | (240 & e) << 4 | (240 & r) << 8;
|
|
383
374
|
}
|
|
384
|
-
function
|
|
385
|
-
return
|
|
375
|
+
function Tt(n, t, e) {
|
|
376
|
+
return n >> 4 << 8 | t >> 4 << 4 | e >> 4;
|
|
386
377
|
}
|
|
387
|
-
function tt(
|
|
388
|
-
return
|
|
378
|
+
function tt(n, t, e) {
|
|
379
|
+
return n < t ? t : n > e ? e : n;
|
|
389
380
|
}
|
|
390
|
-
function at(
|
|
391
|
-
return
|
|
381
|
+
function at(n) {
|
|
382
|
+
return n * n;
|
|
392
383
|
}
|
|
393
|
-
function yt(
|
|
394
|
-
for (var r = 0, a = 1e100, i =
|
|
395
|
-
var
|
|
384
|
+
function yt(n, t, e) {
|
|
385
|
+
for (var r = 0, a = 1e100, i = n[t], s = i.cnt, l = (i.ac, i.rc), d = i.gc, p = i.bc, o = i.fw; o != 0; o = n[o].fw) {
|
|
386
|
+
var c = n[o].cnt, u = s * c / (s + c);
|
|
396
387
|
if (!(u >= a)) {
|
|
397
388
|
var m = 0;
|
|
398
|
-
!((m += u * at(
|
|
389
|
+
!((m += u * at(n[o].rc - l)) >= a) && !((m += u * at(n[o].gc - d)) >= a) && !((m += u * at(n[o].bc - p)) >= a) && (a = m, r = o);
|
|
399
390
|
}
|
|
400
391
|
}
|
|
401
392
|
i.err = a, i.nn = r;
|
|
@@ -403,37 +394,37 @@ function yt(s, t, e) {
|
|
|
403
394
|
function dt() {
|
|
404
395
|
return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
|
|
405
396
|
}
|
|
406
|
-
function
|
|
407
|
-
let e = new Array(t === "rgb444" ? 4096 : 65536), r =
|
|
397
|
+
function ae(n, t) {
|
|
398
|
+
let e = new Array(t === "rgb444" ? 4096 : 65536), r = n.length;
|
|
408
399
|
if (t === "rgba4444") for (let a = 0; a < r; ++a) {
|
|
409
|
-
let i =
|
|
410
|
-
|
|
400
|
+
let i = n[a], s = i >> 24 & 255, l = i >> 16 & 255, d = i >> 8 & 255, p = 255 & i, o = Ot(p, d, l, s), c = o in e ? e[o] : e[o] = dt();
|
|
401
|
+
c.rc += p, c.gc += d, c.bc += l, c.ac += s, c.cnt++;
|
|
411
402
|
}
|
|
412
403
|
else if (t === "rgb444") for (let a = 0; a < r; ++a) {
|
|
413
|
-
let i =
|
|
414
|
-
o.rc +=
|
|
404
|
+
let i = n[a], s = i >> 16 & 255, l = i >> 8 & 255, d = 255 & i, p = Tt(d, l, s), o = p in e ? e[p] : e[p] = dt();
|
|
405
|
+
o.rc += d, o.gc += l, o.bc += s, o.cnt++;
|
|
415
406
|
}
|
|
416
407
|
else for (let a = 0; a < r; ++a) {
|
|
417
|
-
let i =
|
|
418
|
-
o.rc +=
|
|
408
|
+
let i = n[a], s = i >> 16 & 255, l = i >> 8 & 255, d = 255 & i, p = Vt(d, l, s), o = p in e ? e[p] : e[p] = dt();
|
|
409
|
+
o.rc += d, o.gc += l, o.bc += s, o.cnt++;
|
|
419
410
|
}
|
|
420
411
|
return e;
|
|
421
412
|
}
|
|
422
|
-
function
|
|
423
|
-
let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold:
|
|
413
|
+
function ie(n, t, e) {
|
|
414
|
+
let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: s = 0, oneBitAlpha: l = !1 } = e || {}, d = e.useSqrt !== !1, p = r === "rgba4444", o = ae(n, r), c = o.length, u = c - 1, m = new Uint32Array(c + 1);
|
|
424
415
|
for (var x = 0, h = 0; h < o.length; ++h) {
|
|
425
416
|
let k = o[h];
|
|
426
417
|
if (k != null) {
|
|
427
|
-
var
|
|
428
|
-
p && (k.ac *=
|
|
418
|
+
var g = 1 / k.cnt;
|
|
419
|
+
p && (k.ac *= g), k.rc *= g, k.gc *= g, k.bc *= g, o[x++] = k;
|
|
429
420
|
}
|
|
430
421
|
}
|
|
431
|
-
for (at(t) / x < 0.022 && (
|
|
432
|
-
var _, v,
|
|
433
|
-
for (
|
|
422
|
+
for (at(t) / x < 0.022 && (d = !1), h = 0; h < x - 1; ++h) o[h].fw = h + 1, o[h + 1].bk = h, d && (o[h].cnt = Math.sqrt(o[h].cnt));
|
|
423
|
+
var _, v, f;
|
|
424
|
+
for (d && (o[h].cnt = Math.sqrt(o[h].cnt)), h = 0; h < x; ++h) {
|
|
434
425
|
yt(o, h);
|
|
435
426
|
var C = o[h].err;
|
|
436
|
-
for (v = ++m[0]; v > 1 && !(o[_ = m[
|
|
427
|
+
for (v = ++m[0]; v > 1 && !(o[_ = m[f = v >> 1]].err <= C); v = f) m[v] = _;
|
|
437
428
|
m[v] = h;
|
|
438
429
|
}
|
|
439
430
|
var S = x - t;
|
|
@@ -441,138 +432,139 @@ function ae(s, t, e) {
|
|
|
441
432
|
for (var E; ; ) {
|
|
442
433
|
var A = m[1];
|
|
443
434
|
if ((E = o[A]).tm >= E.mtm && o[E.nn].mtm <= E.tm) break;
|
|
444
|
-
for (E.mtm == u ? A = m[1] = m[m[0]--] : (yt(o, A), E.tm = h), C = o[A].err, v = 1; (
|
|
435
|
+
for (E.mtm == u ? A = m[1] = m[m[0]--] : (yt(o, A), E.tm = h), C = o[A].err, v = 1; (f = v + v) <= m[0] && (f < m[0] && o[m[f]].err > o[m[f + 1]].err && f++, !(C <= o[_ = m[f]].err)); v = f) m[v] = _;
|
|
445
436
|
m[v] = A;
|
|
446
437
|
}
|
|
447
438
|
var L = o[E.nn], V = E.cnt, B = L.cnt;
|
|
448
|
-
|
|
439
|
+
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, o[L.bk].fw = L.fw, o[L.fw].bk = L.bk, L.mtm = u;
|
|
449
440
|
}
|
|
450
441
|
let D = [];
|
|
451
|
-
var
|
|
452
|
-
for (h = 0; ; ++
|
|
442
|
+
var T = 0;
|
|
443
|
+
for (h = 0; ; ++T) {
|
|
453
444
|
let k = tt(Math.round(o[h].rc), 0, 255), R = tt(Math.round(o[h].gc), 0, 255), y = tt(Math.round(o[h].bc), 0, 255), w = 255;
|
|
454
|
-
p && (w = tt(Math.round(o[h].ac), 0, 255),
|
|
445
|
+
p && (w = tt(Math.round(o[h].ac), 0, 255), l && (w = w <= (typeof l == "number" ? l : 127) ? 0 : 255), a && w <= s && (k = R = y = i, w = 0));
|
|
455
446
|
let F = p ? [k, R, y, w] : [k, R, y];
|
|
456
|
-
if (
|
|
447
|
+
if (oe(D, F) || D.push(F), (h = o[h].fw) == 0) break;
|
|
457
448
|
}
|
|
458
449
|
return D;
|
|
459
450
|
}
|
|
460
|
-
function
|
|
461
|
-
for (let e = 0; e <
|
|
462
|
-
let r =
|
|
451
|
+
function oe(n, t) {
|
|
452
|
+
for (let e = 0; e < n.length; e++) {
|
|
453
|
+
let r = n[e], a = r[0] === t[0] && r[1] === t[1] && r[2] === t[2], i = !(r.length >= 4 && t.length >= 4) || r[3] === t[3];
|
|
463
454
|
if (a && i) return !0;
|
|
464
455
|
}
|
|
465
456
|
return !1;
|
|
466
457
|
}
|
|
467
|
-
function
|
|
468
|
-
let r = (e = e || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(
|
|
469
|
-
if (e === "rgba4444") for (let
|
|
470
|
-
let
|
|
471
|
-
i[m] != null ?
|
|
458
|
+
function ne(n, t, e) {
|
|
459
|
+
let r = (e = e || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(n.length), i = new Array(r);
|
|
460
|
+
if (e === "rgba4444") for (let s = 0; s < n.length; s++) {
|
|
461
|
+
let l, d = n[s], p = d >> 24 & 255, o = d >> 16 & 255, c = d >> 8 & 255, u = 255 & d, m = Ot(u, c, o, p);
|
|
462
|
+
i[m] != null ? l = i[m] : (l = se(u, c, o, p, t), i[m] = l), a[s] = l;
|
|
472
463
|
}
|
|
473
|
-
else for (let
|
|
474
|
-
let
|
|
475
|
-
i[u] != null ?
|
|
464
|
+
else for (let s = 0; s < n.length; s++) {
|
|
465
|
+
let l, d = n[s], p = d >> 16 & 255, o = d >> 8 & 255, c = 255 & d, u = e === "rgb444" ? Tt(c, o, p) : Vt(c, o, p);
|
|
466
|
+
i[u] != null ? l = i[u] : (l = le(c, o, p, t), i[u] = l), a[s] = l;
|
|
476
467
|
}
|
|
477
468
|
return a;
|
|
478
469
|
}
|
|
479
|
-
function
|
|
480
|
-
let i = 0,
|
|
481
|
-
for (let
|
|
482
|
-
let
|
|
483
|
-
u >
|
|
470
|
+
function se(n, t, e, r, a) {
|
|
471
|
+
let i = 0, s = 1e100;
|
|
472
|
+
for (let l = 0; l < a.length; l++) {
|
|
473
|
+
let d = a[l], p = d[0], o = d[1], c = d[2], u = W(d[3] - r);
|
|
474
|
+
u > s || (u += W(p - n), !(u > s) && (u += W(o - t), !(u > s) && (u += W(c - e), !(u > s) && (s = u, i = l))));
|
|
484
475
|
}
|
|
485
476
|
return i;
|
|
486
477
|
}
|
|
487
|
-
function
|
|
478
|
+
function le(n, t, e, r) {
|
|
488
479
|
let a = 0, i = 1e100;
|
|
489
|
-
for (let
|
|
490
|
-
let
|
|
491
|
-
|
|
480
|
+
for (let s = 0; s < r.length; s++) {
|
|
481
|
+
let l = r[s], d = l[0], p = l[1], o = l[2], c = W(d - n);
|
|
482
|
+
c > i || (c += W(p - t), !(c > i) && (c += W(o - e), !(c > i) && (i = c, a = s)));
|
|
492
483
|
}
|
|
493
484
|
return a;
|
|
494
485
|
}
|
|
495
|
-
function W(
|
|
496
|
-
return
|
|
486
|
+
function W(n) {
|
|
487
|
+
return n * n;
|
|
497
488
|
}
|
|
498
|
-
function
|
|
499
|
-
let { initialCapacity: t = 4096, auto: e = !0 } =
|
|
489
|
+
function de(n = {}) {
|
|
490
|
+
let { initialCapacity: t = 4096, auto: e = !0 } = n, r = Dt(t), a = new Uint8Array(256), i = new Int32Array(5003), s = new Int32Array(5003), l = !1;
|
|
500
491
|
return { reset() {
|
|
501
|
-
r.reset(),
|
|
492
|
+
r.reset(), l = !1;
|
|
502
493
|
}, finish() {
|
|
503
|
-
r.writeByte(
|
|
494
|
+
r.writeByte(Zt.trailer);
|
|
504
495
|
}, bytes: () => r.bytes(), bytesView: () => r.bytesView(), get buffer() {
|
|
505
496
|
return r.buffer;
|
|
506
497
|
}, get stream() {
|
|
507
498
|
return r;
|
|
508
|
-
}, writeHeader:
|
|
509
|
-
let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette:
|
|
510
|
-
if (e ?
|
|
511
|
-
if (!
|
|
512
|
-
|
|
499
|
+
}, writeHeader: d, writeFrame(p, o, c, u = {}) {
|
|
500
|
+
let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette: g = null, repeat: _ = 0, colorDepth: v = 8, dispose: f = -1 } = u, C = !1;
|
|
501
|
+
if (e ? l || (C = !0, d(), l = !0) : C = !!u.first, o = Math.max(0, Math.floor(o)), c = Math.max(0, Math.floor(c)), C) {
|
|
502
|
+
if (!g) throw new Error("First frame must include a { palette } option");
|
|
503
|
+
ue(r, o, c, g, v), _t(r, g), _ >= 0 && pe(r, _);
|
|
513
504
|
}
|
|
514
505
|
let S = Math.round(h / 10);
|
|
515
|
-
|
|
516
|
-
let E = !!
|
|
517
|
-
|
|
506
|
+
ce(r, f, S, m, x);
|
|
507
|
+
let E = !!g && !C;
|
|
508
|
+
he(r, o, c, E ? g : null), E && _t(r, g), me(r, p, o, c, v, a, i, s);
|
|
518
509
|
} };
|
|
519
|
-
function
|
|
510
|
+
function d() {
|
|
520
511
|
Rt(r, "GIF89a");
|
|
521
512
|
}
|
|
522
513
|
}
|
|
523
|
-
function
|
|
524
|
-
var i,
|
|
525
|
-
|
|
514
|
+
function ce(n, t, e, r, a) {
|
|
515
|
+
var i, s;
|
|
516
|
+
n.writeByte(33), n.writeByte(249), n.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, s = 2) : (i = 0, s = 0), t >= 0 && (s = 7 & t), s <<= 2, n.writeByte(0 | s | i), N(n, e), n.writeByte(a || 0), n.writeByte(0);
|
|
526
517
|
}
|
|
527
|
-
function
|
|
518
|
+
function ue(n, t, e, r, a = 8) {
|
|
528
519
|
let i = 128 | a - 1 << 4 | ht(r.length) - 1;
|
|
529
|
-
N(
|
|
520
|
+
N(n, t), N(n, e), n.writeBytes([i, 0, 0]);
|
|
530
521
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
522
|
+
function pe(n, t) {
|
|
523
|
+
n.writeByte(33), n.writeByte(255), n.writeByte(11), Rt(n, "NETSCAPE2.0"), n.writeByte(3), n.writeByte(1), N(n, t), n.writeByte(0);
|
|
533
524
|
}
|
|
534
|
-
function _t(
|
|
525
|
+
function _t(n, t) {
|
|
535
526
|
let e = 1 << ht(t.length);
|
|
536
527
|
for (let r = 0; r < e; r++) {
|
|
537
528
|
let a = [0, 0, 0];
|
|
538
|
-
r < t.length && (a = t[r]),
|
|
529
|
+
r < t.length && (a = t[r]), n.writeByte(a[0]), n.writeByte(a[1]), n.writeByte(a[2]);
|
|
539
530
|
}
|
|
540
531
|
}
|
|
541
|
-
function
|
|
542
|
-
if (
|
|
543
|
-
let a = 0, i = 0,
|
|
544
|
-
|
|
545
|
-
} else
|
|
532
|
+
function he(n, t, e, r) {
|
|
533
|
+
if (n.writeByte(44), N(n, 0), N(n, 0), N(n, t), N(n, e), r) {
|
|
534
|
+
let a = 0, i = 0, s = ht(r.length) - 1;
|
|
535
|
+
n.writeByte(128 | a | i | s);
|
|
536
|
+
} else n.writeByte(0);
|
|
546
537
|
}
|
|
547
|
-
function
|
|
548
|
-
|
|
538
|
+
function me(n, t, e, r, a = 8, i, s, l) {
|
|
539
|
+
re(e, r, t, a, n, i, s, l);
|
|
549
540
|
}
|
|
550
|
-
function N(
|
|
551
|
-
|
|
541
|
+
function N(n, t) {
|
|
542
|
+
n.writeByte(255 & t), n.writeByte(t >> 8 & 255);
|
|
552
543
|
}
|
|
553
|
-
function Rt(
|
|
554
|
-
for (var e = 0; e < t.length; e++)
|
|
544
|
+
function Rt(n, t) {
|
|
545
|
+
for (var e = 0; e < t.length; e++) n.writeByte(t.charCodeAt(e));
|
|
555
546
|
}
|
|
556
|
-
function ht(
|
|
557
|
-
return Math.max(Math.ceil(Math.log2(
|
|
547
|
+
function ht(n) {
|
|
548
|
+
return Math.max(Math.ceil(Math.log2(n)), 1);
|
|
558
549
|
}
|
|
559
|
-
|
|
560
|
-
class
|
|
550
|
+
Kt();
|
|
551
|
+
class fe {
|
|
561
552
|
_recorder;
|
|
562
553
|
_textmodifier;
|
|
563
554
|
_registerPostDrawHook;
|
|
564
555
|
constructor(t, e) {
|
|
565
|
-
this._recorder = new
|
|
556
|
+
this._recorder = new Qt(), this._textmodifier = t, this._registerPostDrawHook = e;
|
|
566
557
|
}
|
|
567
558
|
async $saveGIF(t = {}) {
|
|
568
559
|
const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t), a = t.onProgress;
|
|
569
560
|
try {
|
|
570
|
-
const i = await this._recorder.$record(e, r, this._registerPostDrawHook, a),
|
|
571
|
-
i.
|
|
572
|
-
const { width: u, height: m, imageData: x, delayMs: h } =
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
561
|
+
const i = await this._recorder.$record(e, r, this._registerPostDrawHook, a), s = de(), { repeat: l } = t;
|
|
562
|
+
for (let o = 0; o < i.length; o++) {
|
|
563
|
+
const c = i[o], { width: u, height: m, imageData: x, delayMs: h } = c, g = new Uint32Array(x.data.buffer), _ = ie(g, 256, {}), v = ne(g, _);
|
|
564
|
+
s.writeFrame(v, u, m, { palette: _, delay: h, repeat: o === 0 ? l : -1 }), o % 2 != 0 && o !== i.length - 1 || (a?.({ state: "encoding", frameIndex: o + 1, totalFrames: i.length }), await new Promise((f) => setTimeout(f, 0)));
|
|
565
|
+
}
|
|
566
|
+
s.finish();
|
|
567
|
+
const d = s.bytes(), p = d.buffer.slice(d.byteOffset, d.byteOffset + d.byteLength);
|
|
576
568
|
new Q().$downloadFile(new Blob([p], { type: "image/gif" }), r.filename), a?.({ state: "completed", totalFrames: r.frameCount });
|
|
577
569
|
} catch (i) {
|
|
578
570
|
throw a?.({ state: "error", message: i instanceof Error ? i.message : "GIF export failed" }), i;
|
|
@@ -583,69 +575,69 @@ class me {
|
|
|
583
575
|
return { filename: t.filename, frameCount: e, frameRate: r, scale: a, repeat: i };
|
|
584
576
|
}
|
|
585
577
|
}
|
|
586
|
-
function
|
|
587
|
-
return
|
|
578
|
+
function ge(n) {
|
|
579
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
588
580
|
}
|
|
589
581
|
var wt, Ct = { exports: {} };
|
|
590
|
-
function
|
|
591
|
-
return wt || (wt = 1,
|
|
592
|
-
function t(
|
|
582
|
+
function be() {
|
|
583
|
+
return wt || (wt = 1, n = Ct, (function() {
|
|
584
|
+
function t(d, p) {
|
|
593
585
|
return (function(o) {
|
|
594
586
|
if (typeof o != "string" || !o.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
|
|
595
587
|
return window.atob(o.substring(23));
|
|
596
|
-
})(typeof
|
|
588
|
+
})(typeof d == "string" && /^data:image\/webp/.test(d) ? d : d.toDataURL("image/webp", p));
|
|
597
589
|
}
|
|
598
|
-
function e(
|
|
599
|
-
return (
|
|
590
|
+
function e(d) {
|
|
591
|
+
return (d.charCodeAt(0) | d.charCodeAt(1) << 8 | d.charCodeAt(2) << 16 | d.charCodeAt(3) << 24) >>> 0;
|
|
600
592
|
}
|
|
601
|
-
function r(
|
|
602
|
-
let p =
|
|
593
|
+
function r(d) {
|
|
594
|
+
let p = d.indexOf("VP8", 12);
|
|
603
595
|
if (p === -1) throw new Error("Bad image format, does this browser support WebP?");
|
|
604
596
|
let o = !1;
|
|
605
|
-
for (; p <
|
|
606
|
-
let
|
|
607
|
-
switch (u =
|
|
597
|
+
for (; p < d.length - 8; ) {
|
|
598
|
+
let c, u;
|
|
599
|
+
switch (u = d.substring(p, p + 4), p += 4, c = e(d.substring(p, p + 4)), p += 4, u) {
|
|
608
600
|
case "VP8 ":
|
|
609
|
-
return { frame:
|
|
601
|
+
return { frame: d.substring(p, p + c), hasAlpha: o };
|
|
610
602
|
case "ALPH":
|
|
611
603
|
o = !0;
|
|
612
604
|
}
|
|
613
|
-
p +=
|
|
605
|
+
p += c, 1 & c && p++;
|
|
614
606
|
}
|
|
615
607
|
throw new Error("Failed to find VP8 keyframe in WebP image, is this image mistakenly encoded in the Lossless WebP format?");
|
|
616
608
|
}
|
|
617
|
-
function a(
|
|
618
|
-
this.value =
|
|
609
|
+
function a(d) {
|
|
610
|
+
this.value = d;
|
|
619
611
|
}
|
|
620
|
-
function i(
|
|
621
|
-
this.value =
|
|
612
|
+
function i(d) {
|
|
613
|
+
this.value = d;
|
|
622
614
|
}
|
|
623
|
-
function
|
|
624
|
-
if (Array.isArray(o)) for (let
|
|
625
|
-
else if (typeof o == "string")
|
|
626
|
-
else if (o instanceof Uint8Array)
|
|
615
|
+
function s(d, p, o) {
|
|
616
|
+
if (Array.isArray(o)) for (let c = 0; c < o.length; c++) s(d, p, o[c]);
|
|
617
|
+
else if (typeof o == "string") d.writeString(o);
|
|
618
|
+
else if (o instanceof Uint8Array) d.writeBytes(o);
|
|
627
619
|
else {
|
|
628
620
|
if (!o.id) throw new Error("Bad EBML datatype " + typeof o.data);
|
|
629
|
-
if (o.offset =
|
|
630
|
-
let
|
|
631
|
-
o.size === -1 ?
|
|
632
|
-
} else if (typeof o.data == "string")
|
|
633
|
-
else if (typeof o.data == "number") o.size || (o.size =
|
|
634
|
-
else if (o.data instanceof i)
|
|
635
|
-
else if (o.data instanceof a)
|
|
621
|
+
if (o.offset = d.pos + p, d.writeUnsignedIntBE(o.id), Array.isArray(o.data)) {
|
|
622
|
+
let c, u, m;
|
|
623
|
+
o.size === -1 ? d.writeByte(255) : o.size === -2 ? (c = d.pos, d.writeBytes([15, 255, 255, 255, 255])) : (c = d.pos, d.writeBytes([0, 0, 0, 0])), u = d.pos, o.dataOffset = u + p, s(d, p, o.data), o.size !== -1 && o.size !== -2 && (m = d.pos, o.size = m - u, d.seek(c), d.writeEBMLVarIntWidth(o.size, 4), d.seek(m));
|
|
624
|
+
} else if (typeof o.data == "string") d.writeEBMLVarInt(o.data.length), o.dataOffset = d.pos + p, d.writeString(o.data);
|
|
625
|
+
else if (typeof o.data == "number") o.size || (o.size = d.measureUnsignedInt(o.data)), d.writeEBMLVarInt(o.size), o.dataOffset = d.pos + p, d.writeUnsignedIntBE(o.data, o.size);
|
|
626
|
+
else if (o.data instanceof i) d.writeEBMLVarInt(8), o.dataOffset = d.pos + p, d.writeDoubleBE(o.data.value);
|
|
627
|
+
else if (o.data instanceof a) d.writeEBMLVarInt(4), o.dataOffset = d.pos + p, d.writeFloatBE(o.data.value);
|
|
636
628
|
else {
|
|
637
629
|
if (!(o.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof o.data);
|
|
638
|
-
|
|
630
|
+
d.writeEBMLVarInt(o.data.byteLength), o.dataOffset = d.pos + p, d.writeBytes(o.data);
|
|
639
631
|
}
|
|
640
632
|
}
|
|
641
633
|
}
|
|
642
|
-
let
|
|
634
|
+
let l = function(d, p) {
|
|
643
635
|
return function(o) {
|
|
644
|
-
let
|
|
636
|
+
let c, u, m = !1, x = 0, h = 0, g = null, _ = null, v = null, f = [], C = 0, S = 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(o.fileWriter || o.fd);
|
|
645
637
|
function D(y) {
|
|
646
|
-
return y -
|
|
638
|
+
return y - c.dataOffset;
|
|
647
639
|
}
|
|
648
|
-
function
|
|
640
|
+
function T() {
|
|
649
641
|
u = (function() {
|
|
650
642
|
let M = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
|
|
651
643
|
for (let I in A) {
|
|
@@ -657,59 +649,59 @@ function ge() {
|
|
|
657
649
|
let y = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" }, L] }, w = [{ id: 176, data: x }, { id: 186, data: h }];
|
|
658
650
|
o.transparent && w.push({ id: 21440, data: 1 });
|
|
659
651
|
let F = { 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 }] }] };
|
|
660
|
-
|
|
661
|
-
let $ = new
|
|
662
|
-
|
|
652
|
+
c = { id: 408125543, size: -2, data: [u, y, F] };
|
|
653
|
+
let $ = new d(256);
|
|
654
|
+
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 }] }, c]), B.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(y.offset), A.Tracks.positionEBML.data = D(F.offset), m = !0;
|
|
663
655
|
}
|
|
664
656
|
function k(y) {
|
|
665
657
|
return y.alpha ? (function(w) {
|
|
666
|
-
let F, $, M = new
|
|
658
|
+
let F, $, M = new d(4);
|
|
667
659
|
if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
|
|
668
660
|
return M.writeEBMLVarInt(w.trackNumber), M.writeU16BE(w.timecode), M.writeByte(0), F = { 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: [F, $] };
|
|
669
661
|
})(y) : (function(w) {
|
|
670
|
-
let F = new
|
|
662
|
+
let F = new d(4);
|
|
671
663
|
if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
|
|
672
664
|
return F.writeEBMLVarInt(w.trackNumber), F.writeU16BE(w.timecode), F.writeByte(128), { id: 163, data: [F.getAsDataArray(), w.frame] };
|
|
673
665
|
})(y);
|
|
674
666
|
}
|
|
675
667
|
function R() {
|
|
676
|
-
if (
|
|
668
|
+
if (f.length === 0) return;
|
|
677
669
|
let y = 0;
|
|
678
|
-
for (let I = 0; I <
|
|
679
|
-
let w = new
|
|
670
|
+
for (let I = 0; I < f.length; I++) y += f[I].frame.length + (f[I].alpha ? f[I].alpha.length : 0);
|
|
671
|
+
let w = new d(y + 64 * f.length), F = (function(I) {
|
|
680
672
|
return { id: 524531317, data: [{ id: 231, data: Math.round(I.timecode) }] };
|
|
681
673
|
})({ timecode: Math.round(C) });
|
|
682
|
-
for (let I = 0; I <
|
|
674
|
+
for (let I = 0; I < f.length; I++) F.data.push(k(f[I]));
|
|
683
675
|
var $, M, U;
|
|
684
|
-
|
|
676
|
+
s(w, B.pos, F), B.write(w.getAsDataArray()), $ = 1, M = Math.round(C), U = F.offset, V.push({ id: 187, data: [{ id: 179, data: M }, { id: 183, data: [{ id: 247, data: $ }, { id: 241, data: D(U) }] }] }), f = [], C += S, S = 0;
|
|
685
677
|
}
|
|
686
678
|
this.addFrame = function(y, w, F) {
|
|
687
|
-
m || (x = y.width || 0, h = y.height || 0,
|
|
679
|
+
m || (x = y.width || 0, h = y.height || 0, T());
|
|
688
680
|
let $, M = r(t(y, o.quality)), U = null;
|
|
689
681
|
$ = F || (typeof w == "number" ? w : o.frameDuration), o.transparent && (w instanceof HTMLCanvasElement || typeof w == "string" ? U = w : M.hasAlpha && (U = (function(I) {
|
|
690
|
-
|
|
691
|
-
let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0,
|
|
692
|
-
for (let ot = 3; ot <
|
|
682
|
+
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));
|
|
683
|
+
let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0, Wt = I.width * I.height * 4;
|
|
684
|
+
for (let ot = 3; ot < Wt; ot += 4) {
|
|
693
685
|
let nt = q[ot];
|
|
694
686
|
J[K++] = nt, J[K++] = nt, J[K++] = nt, J[K++] = 255;
|
|
695
687
|
}
|
|
696
|
-
return _.putImageData(v, 0, 0),
|
|
688
|
+
return _.putImageData(v, 0, 0), g;
|
|
697
689
|
})(y))), (function(I) {
|
|
698
|
-
I.trackNumber = 1, I.timecode = Math.round(S),
|
|
690
|
+
I.trackNumber = 1, I.timecode = Math.round(S), f.push(I), S += I.duration, S >= 5e3 && R();
|
|
699
691
|
})({ frame: M.frame, duration: $, alpha: U ? r(t(U, o.alphaQuality)).frame : null });
|
|
700
692
|
}, this.complete = function() {
|
|
701
|
-
return m ||
|
|
702
|
-
let y = { id: 475249515, data: V }, w = new
|
|
703
|
-
|
|
693
|
+
return m || T(), R(), (function() {
|
|
694
|
+
let y = { id: 475249515, data: V }, w = new d(16 + 32 * V.length);
|
|
695
|
+
s(w, B.pos, y), B.write(w.getAsDataArray()), A.Cues.positionEBML.data = D(y.offset);
|
|
704
696
|
})(), (function() {
|
|
705
|
-
let y = new
|
|
706
|
-
|
|
697
|
+
let y = new d(u.size), w = B.pos;
|
|
698
|
+
s(y, u.dataOffset, u.data), B.seek(u.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
|
|
707
699
|
})(), (function() {
|
|
708
|
-
let y = new
|
|
700
|
+
let y = new d(8), w = B.pos;
|
|
709
701
|
y.writeDoubleBE(C), B.seek(L.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
|
|
710
702
|
})(), (function() {
|
|
711
|
-
let y = new
|
|
712
|
-
y.writeUnsignedIntBE(
|
|
703
|
+
let y = new d(10), w = B.pos;
|
|
704
|
+
y.writeUnsignedIntBE(c.id), y.writeEBMLVarIntWidth(B.pos - c.dataOffset, 5), B.seek(c.offset), B.write(y.getAsDataArray()), B.seek(w);
|
|
713
705
|
})(), B.complete("video/webm");
|
|
714
706
|
}, this.getWrittenSize = function() {
|
|
715
707
|
return B.length;
|
|
@@ -727,13 +719,13 @@ function ge() {
|
|
|
727
719
|
})();
|
|
728
720
|
};
|
|
729
721
|
};
|
|
730
|
-
|
|
722
|
+
n.exports = l;
|
|
731
723
|
})()), Ct.exports;
|
|
732
|
-
var
|
|
724
|
+
var n;
|
|
733
725
|
}
|
|
734
726
|
var Et, kt = { exports: {} };
|
|
735
|
-
function
|
|
736
|
-
return Et || (Et = 1,
|
|
727
|
+
function ve() {
|
|
728
|
+
return Et || (Et = 1, n = kt, (function() {
|
|
737
729
|
let t = function(e) {
|
|
738
730
|
this.data = new Uint8Array(e), this.pos = 0;
|
|
739
731
|
};
|
|
@@ -804,138 +796,138 @@ function be() {
|
|
|
804
796
|
if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
|
|
805
797
|
if (this.pos == this.data.byteLength) return this.data;
|
|
806
798
|
throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
|
|
807
|
-
},
|
|
799
|
+
}, n.exports = t;
|
|
808
800
|
})()), kt.exports;
|
|
809
|
-
var
|
|
801
|
+
var n;
|
|
810
802
|
}
|
|
811
803
|
var Bt, It, St, Ft = { exports: {} };
|
|
812
|
-
function
|
|
813
|
-
return Bt || (Bt = 1,
|
|
804
|
+
function xe() {
|
|
805
|
+
return Bt || (Bt = 1, n = Ft, (function() {
|
|
814
806
|
let t = function(e) {
|
|
815
807
|
return function(r) {
|
|
816
|
-
let a = [], i = Promise.resolve(),
|
|
817
|
-
function
|
|
808
|
+
let a = [], i = Promise.resolve(), s = null, l = null;
|
|
809
|
+
function d(c) {
|
|
818
810
|
return new Promise(function(u, m) {
|
|
819
811
|
let x = new FileReader();
|
|
820
812
|
x.addEventListener("loadend", function() {
|
|
821
813
|
u(x.result);
|
|
822
|
-
}), x.readAsArrayBuffer(
|
|
814
|
+
}), x.readAsArrayBuffer(c);
|
|
823
815
|
});
|
|
824
816
|
}
|
|
825
|
-
function p(
|
|
817
|
+
function p(c) {
|
|
826
818
|
return new Promise(function(u, m) {
|
|
827
|
-
|
|
819
|
+
c instanceof Uint8Array ? u(c) : c instanceof ArrayBuffer || ArrayBuffer.isView(c) ? u(new Uint8Array(c)) : c instanceof Blob ? u(d(c).then(function(x) {
|
|
828
820
|
return new Uint8Array(x);
|
|
829
|
-
})) : u(
|
|
821
|
+
})) : u(d(new Blob([c])).then(function(x) {
|
|
830
822
|
return new Uint8Array(x);
|
|
831
823
|
}));
|
|
832
824
|
});
|
|
833
825
|
}
|
|
834
|
-
function o(
|
|
835
|
-
let u =
|
|
826
|
+
function o(c) {
|
|
827
|
+
let u = c.byteLength || c.length || c.size;
|
|
836
828
|
if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
|
|
837
829
|
return u;
|
|
838
830
|
}
|
|
839
|
-
r && r.constructor.name === "FileWriter" ?
|
|
840
|
-
if (
|
|
841
|
-
if (isNaN(
|
|
842
|
-
if (
|
|
843
|
-
this.pos =
|
|
844
|
-
}, this.write = function(
|
|
845
|
-
let u = { offset: this.pos, data:
|
|
831
|
+
r && r.constructor.name === "FileWriter" ? s = r : e && r && (l = r), this.pos = 0, this.length = 0, this.seek = function(c) {
|
|
832
|
+
if (c < 0) throw new Error("Offset may not be negative");
|
|
833
|
+
if (isNaN(c)) throw new Error("Offset may not be NaN");
|
|
834
|
+
if (c > this.length) throw new Error("Seeking beyond the end of file is not allowed");
|
|
835
|
+
this.pos = c;
|
|
836
|
+
}, this.write = function(c) {
|
|
837
|
+
let u = { offset: this.pos, data: c, length: o(c) }, m = u.offset >= this.length;
|
|
846
838
|
this.pos += u.length, this.length = Math.max(this.length, this.pos), i = i.then(function() {
|
|
847
|
-
if (
|
|
848
|
-
p(u.data).then(function(
|
|
849
|
-
let _ = 0, v = Buffer.from(
|
|
850
|
-
_ += S, _ >= E.length ? x() : e.write(
|
|
839
|
+
if (l) return new Promise(function(x, h) {
|
|
840
|
+
p(u.data).then(function(g) {
|
|
841
|
+
let _ = 0, v = Buffer.from(g.buffer), f = function(C, S, E) {
|
|
842
|
+
_ += S, _ >= E.length ? x() : e.write(l, E, _, E.length - _, u.offset + _, f);
|
|
851
843
|
};
|
|
852
|
-
e.write(
|
|
844
|
+
e.write(l, v, 0, v.length, u.offset, f);
|
|
853
845
|
});
|
|
854
846
|
});
|
|
855
|
-
if (
|
|
856
|
-
|
|
847
|
+
if (s) return new Promise(function(x, h) {
|
|
848
|
+
s.onwriteend = x, s.seek(u.offset), s.write(new Blob([u.data]));
|
|
857
849
|
});
|
|
858
850
|
if (!m) for (let x = 0; x < a.length; x++) {
|
|
859
851
|
let h = a[x];
|
|
860
852
|
if (!(u.offset + u.length <= h.offset || u.offset >= h.offset + h.length)) {
|
|
861
853
|
if (u.offset < h.offset || u.offset + u.length > h.offset + h.length) throw new Error("Overwrite crosses blob boundaries");
|
|
862
|
-
return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(
|
|
863
|
-
return h.data =
|
|
864
|
-
}).then(function(
|
|
865
|
-
u.data =
|
|
854
|
+
return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(g) {
|
|
855
|
+
return h.data = g, p(u.data);
|
|
856
|
+
}).then(function(g) {
|
|
857
|
+
u.data = g, h.data.set(u.data, u.offset - h.offset);
|
|
866
858
|
});
|
|
867
859
|
}
|
|
868
860
|
}
|
|
869
861
|
a.push(u);
|
|
870
862
|
});
|
|
871
|
-
}, this.complete = function(
|
|
872
|
-
return i =
|
|
863
|
+
}, this.complete = function(c) {
|
|
864
|
+
return i = l || s ? i.then(function() {
|
|
873
865
|
return null;
|
|
874
866
|
}) : i.then(function() {
|
|
875
867
|
let u = [];
|
|
876
868
|
for (let m = 0; m < a.length; m++) u.push(a[m].data);
|
|
877
|
-
return new Blob(u, { type:
|
|
869
|
+
return new Blob(u, { type: c });
|
|
878
870
|
}), i;
|
|
879
871
|
};
|
|
880
872
|
};
|
|
881
873
|
};
|
|
882
|
-
|
|
874
|
+
n.exports = t;
|
|
883
875
|
})()), Ft.exports;
|
|
884
|
-
var
|
|
876
|
+
var n;
|
|
885
877
|
}
|
|
886
|
-
function
|
|
887
|
-
return St ? It : (St = 1, It =
|
|
878
|
+
function ye() {
|
|
879
|
+
return St ? It : (St = 1, It = be()(ve(), xe()(null)));
|
|
888
880
|
}
|
|
889
|
-
var
|
|
890
|
-
const
|
|
891
|
-
class
|
|
881
|
+
var _e = ye();
|
|
882
|
+
const we = ge(_e);
|
|
883
|
+
class Ce {
|
|
892
884
|
async $record(t, e, r, a) {
|
|
893
|
-
const i = Math.max(1, Math.round(e.frameRate)),
|
|
885
|
+
const i = Math.max(1, Math.round(e.frameRate)), s = Math.max(1, Math.round(e.frameCount)), l = new we({ quality: e.quality, alphaQuality: e.transparent ? e.quality : void 0, transparent: e.transparent, frameRate: i }), d = this._createSnapshotSurface();
|
|
894
886
|
return await new Promise((p, o) => {
|
|
895
|
-
let
|
|
887
|
+
let c, u = "capturing", m = !1, x = 0;
|
|
896
888
|
const h = () => {
|
|
897
|
-
|
|
898
|
-
},
|
|
899
|
-
a?.({ state: "recording", frameIndex: x, totalFrames:
|
|
900
|
-
}, _ = (
|
|
889
|
+
c && (c(), c = void 0);
|
|
890
|
+
}, g = () => {
|
|
891
|
+
a?.({ state: "recording", frameIndex: x, totalFrames: s });
|
|
892
|
+
}, _ = (f) => {
|
|
901
893
|
if (m) return;
|
|
902
894
|
m = !0, h();
|
|
903
|
-
const C =
|
|
904
|
-
a?.({ state: "error", message: C }), o(
|
|
895
|
+
const C = f instanceof Error ? f.message : "WEBM export failed";
|
|
896
|
+
a?.({ state: "error", message: C }), o(f instanceof Error ? f : new Error(String(f)));
|
|
905
897
|
}, v = () => {
|
|
906
|
-
u !== "capturing" || m || (u = "encoding", h(),
|
|
898
|
+
u !== "capturing" || m || (u = "encoding", h(), l.complete().then((f) => {
|
|
907
899
|
((C) => {
|
|
908
|
-
m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(
|
|
909
|
-
})(
|
|
900
|
+
m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(s, x), totalFrames: s }), p(C));
|
|
901
|
+
})(f);
|
|
910
902
|
}).catch(_));
|
|
911
903
|
};
|
|
912
|
-
|
|
904
|
+
c = r(() => {
|
|
913
905
|
(() => {
|
|
914
|
-
if (u === "capturing") if (x >=
|
|
906
|
+
if (u === "capturing") if (x >= s) v();
|
|
915
907
|
else try {
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
} catch (
|
|
919
|
-
_(
|
|
908
|
+
const f = d(t);
|
|
909
|
+
l.addFrame(f), x += 1, g(), x >= s && v();
|
|
910
|
+
} catch (f) {
|
|
911
|
+
_(f);
|
|
920
912
|
}
|
|
921
913
|
})();
|
|
922
|
-
}),
|
|
914
|
+
}), g();
|
|
923
915
|
});
|
|
924
916
|
}
|
|
925
917
|
_createSnapshotSurface() {
|
|
926
918
|
let t = null, e = null;
|
|
927
919
|
return (r) => {
|
|
928
|
-
const a = Math.max(1, r.width), i = Math.max(1, r.height),
|
|
929
|
-
return
|
|
920
|
+
const a = Math.max(1, r.width), i = Math.max(1, r.height), s = ((l, d) => (t || (t = document.createElement("canvas")), t.width !== l || t.height !== d ? (t.width = l, t.height = d, e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)) : e || (e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)), e ? t : null))(a, i);
|
|
921
|
+
return s && e ? (e.clearRect(0, 0, a, i), e.drawImage(r, 0, 0, a, i), s) : r;
|
|
930
922
|
};
|
|
931
923
|
}
|
|
932
924
|
}
|
|
933
|
-
class
|
|
925
|
+
class Ee {
|
|
934
926
|
_recorder;
|
|
935
927
|
_textmodifier;
|
|
936
928
|
_registerPostDrawHook;
|
|
937
929
|
constructor(t, e) {
|
|
938
|
-
this._recorder = new
|
|
930
|
+
this._recorder = new Ce(), this._textmodifier = t, this._registerPostDrawHook = e;
|
|
939
931
|
}
|
|
940
932
|
async $saveWEBM(t = {}) {
|
|
941
933
|
const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t);
|
|
@@ -951,7 +943,7 @@ class Ce {
|
|
|
951
943
|
}
|
|
952
944
|
}
|
|
953
945
|
const b = { root: "textmode-export-overlay", stack: "textmode-export-overlay__stack", stackDense: "textmode-export-overlay__stack--dense", stackCompact: "textmode-export-overlay__stack--compact", section: "textmode-export-overlay__section", header: "textmode-export-overlay__header", headerTitleRow: "textmode-export-overlay__header-title-row", headerLinks: "textmode-export-overlay__header-links", row: "textmode-export-overlay__row", label: "textmode-export-overlay__label", field: "textmode-export-overlay__field", fieldCompact: "textmode-export-overlay__field--compact", fieldDense: "textmode-export-overlay__field--dense", fieldFull: "textmode-export-overlay__field--full", fieldChannel: "textmode-export-overlay__field--channel", input: "textmode-export-overlay__input", checkbox: "textmode-export-overlay__checkbox", muted: "textmode-export-overlay__muted", status: "textmode-export-overlay__status", statusGif: "textmode-export-overlay__status--gif", statusVideo: "textmode-export-overlay__status--video", statusTitle: "textmode-export-overlay__status-title", statusValue: "textmode-export-overlay__status-value", divider: "textmode-export-overlay__divider", title: "textmode-export-overlay__title", button: "textmode-export-overlay__button", buttonPrimary: "textmode-export-overlay__button--primary", buttonSecondary: "textmode-export-overlay__button--secondary", buttonFull: "textmode-export-overlay__button--full", supportLink: "textmode-export-overlay__support-link", supportIcon: "textmode-export-overlay__support-icon", linkIcon: "textmode-export-overlay__link-icon" };
|
|
954
|
-
class
|
|
946
|
+
class O {
|
|
955
947
|
element;
|
|
956
948
|
mounted = !1;
|
|
957
949
|
destroyed = !1;
|
|
@@ -986,7 +978,7 @@ class T {
|
|
|
986
978
|
return this.mounted;
|
|
987
979
|
}
|
|
988
980
|
}
|
|
989
|
-
class H extends
|
|
981
|
+
class H extends O {
|
|
990
982
|
static _iconNamespace = "http://www.w3.org/2000/svg";
|
|
991
983
|
render() {
|
|
992
984
|
const t = document.createElement("div");
|
|
@@ -997,10 +989,10 @@ class H extends T {
|
|
|
997
989
|
r.textContent = "textmode.export.js", r.classList.add(b.title);
|
|
998
990
|
const a = document.createElement("div");
|
|
999
991
|
a.classList.add(b.headerLinks);
|
|
1000
|
-
const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]),
|
|
1001
|
-
a.appendChild(i), a.appendChild(
|
|
1002
|
-
const
|
|
1003
|
-
return
|
|
992
|
+
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/docs/support", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
|
|
993
|
+
a.appendChild(i), a.appendChild(s), e.appendChild(r), e.appendChild(a);
|
|
994
|
+
const l = document.createElement("div");
|
|
995
|
+
return l.classList.add(b.divider), t.appendChild(e), t.appendChild(l), t;
|
|
1004
996
|
}
|
|
1005
997
|
_createLink(t, e, r, a) {
|
|
1006
998
|
const i = document.createElement("a");
|
|
@@ -1011,13 +1003,13 @@ class H extends T {
|
|
|
1011
1003
|
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(t);
|
|
1012
1004
|
for (const a of e) {
|
|
1013
1005
|
const i = document.createElementNS(H._iconNamespace, "path");
|
|
1014
|
-
for (const [
|
|
1006
|
+
for (const [s, l] of Object.entries(a)) i.setAttribute(s, l);
|
|
1015
1007
|
r.appendChild(i);
|
|
1016
1008
|
}
|
|
1017
1009
|
return r;
|
|
1018
1010
|
}
|
|
1019
1011
|
}
|
|
1020
|
-
class P extends
|
|
1012
|
+
class P extends O {
|
|
1021
1013
|
props;
|
|
1022
1014
|
constructor(t) {
|
|
1023
1015
|
super(), this.props = t;
|
|
@@ -1064,7 +1056,7 @@ class P extends T {
|
|
|
1064
1056
|
}
|
|
1065
1057
|
}
|
|
1066
1058
|
}
|
|
1067
|
-
class mt extends
|
|
1059
|
+
class mt extends O {
|
|
1068
1060
|
props;
|
|
1069
1061
|
select;
|
|
1070
1062
|
handleChange = () => {
|
|
@@ -1105,7 +1097,7 @@ class mt extends T {
|
|
|
1105
1097
|
}
|
|
1106
1098
|
}
|
|
1107
1099
|
}
|
|
1108
|
-
class Lt extends
|
|
1100
|
+
class Lt extends O {
|
|
1109
1101
|
props;
|
|
1110
1102
|
button;
|
|
1111
1103
|
constructor(t) {
|
|
@@ -1127,7 +1119,7 @@ class Lt extends T {
|
|
|
1127
1119
|
this.props = t, this.button.textContent = t.label, this.button.disabled = !!t.disabled, t.variant === "secondary" ? (this.button.classList.add(b.buttonSecondary), this.button.classList.remove(b.buttonPrimary)) : (this.button.classList.add(b.buttonPrimary), this.button.classList.remove(b.buttonSecondary)), this.button.classList.toggle(b.buttonFull, !!t.fullWidth);
|
|
1128
1120
|
}
|
|
1129
1121
|
}
|
|
1130
|
-
class
|
|
1122
|
+
class ke {
|
|
1131
1123
|
api;
|
|
1132
1124
|
constructor(t) {
|
|
1133
1125
|
this.api = t;
|
|
@@ -1152,7 +1144,7 @@ class Ee {
|
|
|
1152
1144
|
}
|
|
1153
1145
|
}
|
|
1154
1146
|
}
|
|
1155
|
-
class
|
|
1147
|
+
class Be {
|
|
1156
1148
|
api;
|
|
1157
1149
|
events;
|
|
1158
1150
|
constructor(t, e) {
|
|
@@ -1190,7 +1182,7 @@ class ke {
|
|
|
1190
1182
|
}
|
|
1191
1183
|
}
|
|
1192
1184
|
}
|
|
1193
|
-
class
|
|
1185
|
+
class Ie {
|
|
1194
1186
|
modifier;
|
|
1195
1187
|
overlay;
|
|
1196
1188
|
animationFrameId = null;
|
|
@@ -1214,13 +1206,13 @@ class Be {
|
|
|
1214
1206
|
this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.bound && (window.removeEventListener("resize", this.handleUpdate), window.removeEventListener("scroll", this.handleUpdate, !0), this.bound = !1);
|
|
1215
1207
|
}
|
|
1216
1208
|
}
|
|
1217
|
-
const X = "textmode-export-number-input",
|
|
1218
|
-
|
|
1219
|
-
}, Mt = (
|
|
1209
|
+
const X = "textmode-export-number-input", Se = `${X}__field`, Fe = `${X}__controls`, Le = `${X}__control`, Ut = `${X}__display`, et = `${Ut}--visible`, Me = (n) => {
|
|
1210
|
+
n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1211
|
+
}, Mt = (n) => {
|
|
1220
1212
|
const t = document.createElement("button");
|
|
1221
|
-
return t.type = "button", t.className =
|
|
1213
|
+
return t.type = "button", t.className = Le, t.textContent = n > 0 ? "▲" : "▼", t;
|
|
1222
1214
|
};
|
|
1223
|
-
class G extends
|
|
1215
|
+
class G extends O {
|
|
1224
1216
|
props;
|
|
1225
1217
|
input;
|
|
1226
1218
|
display;
|
|
@@ -1236,9 +1228,9 @@ class G extends T {
|
|
|
1236
1228
|
}
|
|
1237
1229
|
render() {
|
|
1238
1230
|
const t = document.createElement("div");
|
|
1239
|
-
t.className = X, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className =
|
|
1231
|
+
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 = Se, this.display = document.createElement("div"), this.display.className = Ut;
|
|
1240
1232
|
const e = document.createElement("div");
|
|
1241
|
-
return e.className =
|
|
1233
|
+
return e.className = Fe, this.incrementButton = Mt(1), this.decrementButton = Mt(-1), e.appendChild(this.incrementButton), e.appendChild(this.decrementButton), t.appendChild(this.input), t.appendChild(this.display), t.appendChild(e), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(t), this.updateDisplay(), t;
|
|
1242
1234
|
}
|
|
1243
1235
|
get inputElement() {
|
|
1244
1236
|
return this.input;
|
|
@@ -1258,27 +1250,27 @@ class G extends T {
|
|
|
1258
1250
|
bindStepControls() {
|
|
1259
1251
|
const t = (i) => () => {
|
|
1260
1252
|
if (this.input.disabled) return;
|
|
1261
|
-
const
|
|
1262
|
-
if (
|
|
1253
|
+
const s = this.input.value, l = this.input.getAttribute("step");
|
|
1254
|
+
if (l && l !== "any") i > 0 ? this.input.stepUp() : this.input.stepDown();
|
|
1263
1255
|
else {
|
|
1264
|
-
const
|
|
1256
|
+
const d = i > 0 ? 1 : -1, p = Number.parseFloat(this.input.value || "0"), o = Number.isFinite(p) ? p + d : d;
|
|
1265
1257
|
this.input.value = String(o);
|
|
1266
1258
|
}
|
|
1267
|
-
this.input.value !==
|
|
1268
|
-
}, e = t(1), r = t(-1), a = (i,
|
|
1269
|
-
if (this.suppressClickAfterPointer.get(i)) return this.suppressClickAfterPointer.set(i, !1), void
|
|
1270
|
-
|
|
1259
|
+
this.input.value !== s && Me(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
|
|
1260
|
+
}, e = t(1), r = t(-1), a = (i, s) => (l) => {
|
|
1261
|
+
if (this.suppressClickAfterPointer.get(i)) return this.suppressClickAfterPointer.set(i, !1), void l.preventDefault();
|
|
1262
|
+
s();
|
|
1271
1263
|
};
|
|
1272
1264
|
this.incrementButton.addEventListener("click", a(this.incrementButton, e)), this.decrementButton.addEventListener("click", a(this.decrementButton, r));
|
|
1273
1265
|
}
|
|
1274
1266
|
bindHoldBehavior() {
|
|
1275
1267
|
const t = (e, r) => {
|
|
1276
1268
|
const a = r > 0 ? () => this.incrementButton.click() : () => this.decrementButton.click();
|
|
1277
|
-
e.addEventListener("pointerdown", (
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1269
|
+
e.addEventListener("pointerdown", (l) => {
|
|
1270
|
+
if (l.button === 0) {
|
|
1271
|
+
l.preventDefault(), this.suppressClickAfterPointer.set(e, !0), this.activePointerId = l.pointerId;
|
|
1280
1272
|
try {
|
|
1281
|
-
e.setPointerCapture(
|
|
1273
|
+
e.setPointerCapture(l.pointerId);
|
|
1282
1274
|
} catch {
|
|
1283
1275
|
}
|
|
1284
1276
|
a(), this.holdTimeoutId = window.setTimeout(() => {
|
|
@@ -1294,10 +1286,10 @@ class G extends T {
|
|
|
1294
1286
|
}
|
|
1295
1287
|
this.activePointerId = void 0;
|
|
1296
1288
|
}
|
|
1297
|
-
},
|
|
1289
|
+
}, s = () => {
|
|
1298
1290
|
this.clearHoldTimers(), i();
|
|
1299
1291
|
};
|
|
1300
|
-
e.addEventListener("pointerup",
|
|
1292
|
+
e.addEventListener("pointerup", s), e.addEventListener("pointerleave", s), e.addEventListener("pointercancel", s);
|
|
1301
1293
|
};
|
|
1302
1294
|
t(this.incrementButton, 1), t(this.decrementButton, -1);
|
|
1303
1295
|
}
|
|
@@ -1324,7 +1316,7 @@ class G extends T {
|
|
|
1324
1316
|
this.holdTimeoutId !== void 0 && (window.clearTimeout(this.holdTimeoutId), this.holdTimeoutId = void 0), this.holdIntervalId !== void 0 && (window.clearInterval(this.holdIntervalId), this.holdIntervalId = void 0);
|
|
1325
1317
|
}
|
|
1326
1318
|
}
|
|
1327
|
-
class j extends
|
|
1319
|
+
class j extends O {
|
|
1328
1320
|
variant;
|
|
1329
1321
|
additionalClasses;
|
|
1330
1322
|
constructor(t = "stack", e = []) {
|
|
@@ -1336,7 +1328,7 @@ class j extends T {
|
|
|
1336
1328
|
}
|
|
1337
1329
|
}
|
|
1338
1330
|
const $t = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
|
|
1339
|
-
class Nt extends
|
|
1331
|
+
class Nt extends O {
|
|
1340
1332
|
props;
|
|
1341
1333
|
container;
|
|
1342
1334
|
messageElement;
|
|
@@ -1358,7 +1350,7 @@ class Nt extends T {
|
|
|
1358
1350
|
this.messageElement.classList.remove(...Object.values($t)), this.messageElement.classList.add($t[t]);
|
|
1359
1351
|
}
|
|
1360
1352
|
}
|
|
1361
|
-
class Y extends
|
|
1353
|
+
class Y extends O {
|
|
1362
1354
|
_config;
|
|
1363
1355
|
_managedComponents = /* @__PURE__ */ new Set();
|
|
1364
1356
|
constructor(t) {
|
|
@@ -1397,10 +1389,10 @@ class ut extends Y {
|
|
|
1397
1389
|
a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
|
|
1398
1390
|
const i = new j("row");
|
|
1399
1391
|
i.mount(t);
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1392
|
+
const s = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
|
|
1393
|
+
s.mount(i.root), this.scaleInput.mount(s.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
|
|
1394
|
+
const l = new P({ label: "loop count", labelFor: "textmode-export-gif-repeat", variant: "dense" });
|
|
1395
|
+
return l.mount(i.root), this.repeatInput.mount(l.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(t), t;
|
|
1404
1396
|
}
|
|
1405
1397
|
getOptions() {
|
|
1406
1398
|
const t = this._config.defaultOptions ?? {};
|
|
@@ -1414,11 +1406,11 @@ class ut extends Y {
|
|
|
1414
1406
|
return Number.isFinite(t) && t > 0 && Number.isFinite(e) && e > 0 && Number.isFinite(r) && r > 0;
|
|
1415
1407
|
}
|
|
1416
1408
|
isRecording() {
|
|
1417
|
-
return this.recordingState === "recording";
|
|
1409
|
+
return this.recordingState === "recording" || this.recordingState === "encoding";
|
|
1418
1410
|
}
|
|
1419
1411
|
setRecordingState(t, e) {
|
|
1420
1412
|
this.recordingState = t;
|
|
1421
|
-
const r = t === "recording";
|
|
1413
|
+
const r = t === "recording" || t === "encoding";
|
|
1422
1414
|
switch (this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.scaleInput.inputElement.disabled = r, this.repeatInput.inputElement.disabled = r, t) {
|
|
1423
1415
|
case "recording":
|
|
1424
1416
|
if (e?.totalFrames) {
|
|
@@ -1426,6 +1418,12 @@ class ut extends Y {
|
|
|
1426
1418
|
this.status.setMessage(`recording ${a}/${e.totalFrames}`, "active");
|
|
1427
1419
|
} else this.status.setMessage("recording…", "active");
|
|
1428
1420
|
break;
|
|
1421
|
+
case "encoding":
|
|
1422
|
+
if (e?.totalFrames) {
|
|
1423
|
+
const a = e.frameIndex ?? 0;
|
|
1424
|
+
this.status.setMessage(`encoding ${a}/${e.totalFrames}`, "active");
|
|
1425
|
+
} else this.status.setMessage("encoding…", "active");
|
|
1426
|
+
break;
|
|
1429
1427
|
case "completed":
|
|
1430
1428
|
this.status.setMessage("GIF saved successfully", "active");
|
|
1431
1429
|
break;
|
|
@@ -1437,7 +1435,11 @@ class ut extends Y {
|
|
|
1437
1435
|
}
|
|
1438
1436
|
}
|
|
1439
1437
|
handleProgress(t) {
|
|
1440
|
-
t.state
|
|
1438
|
+
if (t.state !== "recording" && t.state !== "encoding" || !t.totalFrames) t.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : t.state === "error" && this.status.setMessage(t.message ?? "failed to export GIF", "alert");
|
|
1439
|
+
else {
|
|
1440
|
+
const e = t.state === "recording" ? "recording" : "encoding";
|
|
1441
|
+
this.status.setMessage(`${e} ${t.frameIndex ?? 0}/${t.totalFrames}`, "active");
|
|
1442
|
+
}
|
|
1441
1443
|
}
|
|
1442
1444
|
applyDefaults() {
|
|
1443
1445
|
const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? z.frameCount, r = t.frameRate ?? z.frameRate, a = t.scale ?? z.scale, i = t.repeat ?? z.repeat;
|
|
@@ -1452,12 +1454,12 @@ class ut extends Y {
|
|
|
1452
1454
|
return Number.isFinite(r) ? r : e;
|
|
1453
1455
|
}
|
|
1454
1456
|
}
|
|
1455
|
-
const it = "textmode-export-range-input",
|
|
1456
|
-
if (typeof
|
|
1457
|
-
const e = Number.parseFloat(
|
|
1457
|
+
const it = "textmode-export-range-input", $e = `${it}__field`, Ae = `${it}__tooltip`, ct = `${it}__tooltip--visible`, rt = (n, t) => {
|
|
1458
|
+
if (typeof n != "string" || n.length === 0) return t;
|
|
1459
|
+
const e = Number.parseFloat(n);
|
|
1458
1460
|
return Number.isFinite(e) ? e : t;
|
|
1459
|
-
},
|
|
1460
|
-
class
|
|
1461
|
+
}, Pe = (n, t, e) => Math.min(e, Math.max(t, n));
|
|
1462
|
+
class De extends O {
|
|
1461
1463
|
props;
|
|
1462
1464
|
input;
|
|
1463
1465
|
tooltip;
|
|
@@ -1473,7 +1475,7 @@ class Pe extends T {
|
|
|
1473
1475
|
}
|
|
1474
1476
|
render() {
|
|
1475
1477
|
const t = document.createElement("div");
|
|
1476
|
-
return t.className = it, 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 =
|
|
1478
|
+
return t.className = it, 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 = $e, this.tooltip = document.createElement("div"), this.tooltip.className = Ae, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
|
|
1477
1479
|
}
|
|
1478
1480
|
get inputElement() {
|
|
1479
1481
|
return this.input;
|
|
@@ -1549,7 +1551,7 @@ class Pe extends T {
|
|
|
1549
1551
|
this.tooltip.textContent = t(e, this.input);
|
|
1550
1552
|
}
|
|
1551
1553
|
updateTooltipPosition() {
|
|
1552
|
-
const t = this.getMin(), e = this.getMax(), r =
|
|
1554
|
+
const t = this.getMin(), e = this.getMax(), r = Pe(this.getCurrentValue(), t, e), a = e - t, i = a === 0 ? 0 : (r - t) / a;
|
|
1553
1555
|
this.tooltip.style.left = 100 * i + "%";
|
|
1554
1556
|
}
|
|
1555
1557
|
getMin() {
|
|
@@ -1562,18 +1564,18 @@ class Pe extends T {
|
|
|
1562
1564
|
return rt(this.input.value, rt(this.props.defaultValue, 0));
|
|
1563
1565
|
}
|
|
1564
1566
|
}
|
|
1565
|
-
function
|
|
1566
|
-
if (!Number.isFinite(
|
|
1567
|
-
const t = Math.max(0, Math.min(1,
|
|
1567
|
+
function Ve(n) {
|
|
1568
|
+
if (!Number.isFinite(n)) return "default quality";
|
|
1569
|
+
const t = Math.max(0, Math.min(1, n));
|
|
1568
1570
|
return t >= 0.995 ? "near-lossless" : t >= 0.98 ? "maximum detail" : t >= 0.88 ? "ultra quality" : t >= 0.7 ? "high quality" : t >= 0.5 ? "balanced" : t >= 0.25 ? "compact" : t >= 0.1 ? "lightweight" : "draft";
|
|
1569
1571
|
}
|
|
1570
|
-
function
|
|
1571
|
-
return `${
|
|
1572
|
+
function Oe(n) {
|
|
1573
|
+
return `${Ve(n)} (quality ≈ ${n.toFixed(3)})`;
|
|
1572
1574
|
}
|
|
1573
1575
|
class pt extends Y {
|
|
1574
1576
|
frameRateInput = this._manageComponent(new G({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (t) => Number.isFinite(t) ? `${t} fps` : null }));
|
|
1575
1577
|
frameCountInput = this._manageComponent(new G({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } }));
|
|
1576
|
-
qualityInput = this._manageComponent(new
|
|
1578
|
+
qualityInput = this._manageComponent(new De({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => Oe(t) }));
|
|
1577
1579
|
status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "video" }));
|
|
1578
1580
|
recordingState = "idle";
|
|
1579
1581
|
constructor(t) {
|
|
@@ -1643,7 +1645,7 @@ class pt extends Y {
|
|
|
1643
1645
|
}
|
|
1644
1646
|
}
|
|
1645
1647
|
const Te = `@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}}`;
|
|
1646
|
-
class
|
|
1648
|
+
class Re {
|
|
1647
1649
|
_textmodifier;
|
|
1648
1650
|
_state;
|
|
1649
1651
|
_events;
|
|
@@ -1679,10 +1681,22 @@ class Oe {
|
|
|
1679
1681
|
});
|
|
1680
1682
|
};
|
|
1681
1683
|
constructor(t, e, r, a, i) {
|
|
1682
|
-
this._textmodifier = t, this._state = r, this._events = a, this._exportService = new
|
|
1684
|
+
this._textmodifier = t, this._state = r, this._events = a, this._exportService = new Be(e, a), this._clipboardService = new ke(e), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
|
|
1683
1685
|
}
|
|
1684
1686
|
$mount() {
|
|
1685
|
-
this._createOverlay(), this._renderStaticContent(), this._positionService = new
|
|
1687
|
+
this._createOverlay(), this._renderStaticContent(), this._positionService = new Ie(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
|
|
1688
|
+
}
|
|
1689
|
+
show() {
|
|
1690
|
+
this._shadowHost && (this._shadowHost.style.display = "");
|
|
1691
|
+
}
|
|
1692
|
+
hide() {
|
|
1693
|
+
this._shadowHost && (this._shadowHost.style.display = "none");
|
|
1694
|
+
}
|
|
1695
|
+
toggle() {
|
|
1696
|
+
this.isVisible() ? this.hide() : this.show();
|
|
1697
|
+
}
|
|
1698
|
+
isVisible() {
|
|
1699
|
+
return !!this._shadowHost && this._shadowHost.style.display !== "none";
|
|
1686
1700
|
}
|
|
1687
1701
|
$dispose() {
|
|
1688
1702
|
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);
|
|
@@ -1793,7 +1807,20 @@ class Oe {
|
|
|
1793
1807
|
const t = this._currentBlade.definition.format, e = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
|
|
1794
1808
|
this._copyButton.setDisabled(!0), this._copyButton.setLabel("copying…");
|
|
1795
1809
|
try {
|
|
1796
|
-
|
|
1810
|
+
switch (t) {
|
|
1811
|
+
case "txt":
|
|
1812
|
+
await this._clipboardService.$copy("txt", e);
|
|
1813
|
+
break;
|
|
1814
|
+
case "svg":
|
|
1815
|
+
await this._clipboardService.$copy("svg", e);
|
|
1816
|
+
break;
|
|
1817
|
+
case "image":
|
|
1818
|
+
await this._clipboardService.$copy("image", e);
|
|
1819
|
+
break;
|
|
1820
|
+
default:
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
this._copyButton.setLabel("copied!");
|
|
1797
1824
|
} catch (a) {
|
|
1798
1825
|
console.error("[textmode-export] Failed to copy to clipboard", a), this._copyButton.setLabel("copy failed!");
|
|
1799
1826
|
} finally {
|
|
@@ -1808,9 +1835,12 @@ class Oe {
|
|
|
1808
1835
|
if (t === "gif" && this._currentBlade.blade instanceof ut) {
|
|
1809
1836
|
const r = this._currentBlade.blade, a = this._state.snapshot.gifProgress;
|
|
1810
1837
|
if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
|
|
1811
|
-
const i = a.frameIndex ?? 0;
|
|
1812
|
-
this._exportButton.setLabel(
|
|
1813
|
-
} else
|
|
1838
|
+
const i = a.frameIndex ?? 0, s = a.state === "encoding" ? "encoding" : "recording";
|
|
1839
|
+
this._exportButton.setLabel(`${s} ${i}/${a.totalFrames}`);
|
|
1840
|
+
} else {
|
|
1841
|
+
const i = a?.state === "encoding" ? "encoding" : "recording";
|
|
1842
|
+
this._exportButton.setLabel(`${i}…`);
|
|
1843
|
+
}
|
|
1814
1844
|
else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
|
|
1815
1845
|
return;
|
|
1816
1846
|
}
|
|
@@ -1827,17 +1857,22 @@ class Oe {
|
|
|
1827
1857
|
this._exportButton.setDisabled(e), this._exportButton.setLabel(e ? "exporting…" : "download file");
|
|
1828
1858
|
}
|
|
1829
1859
|
}
|
|
1830
|
-
class
|
|
1831
|
-
_listeners =
|
|
1860
|
+
class Ue {
|
|
1861
|
+
_listeners = {};
|
|
1862
|
+
_getPool(t) {
|
|
1863
|
+
const e = this._listeners[t];
|
|
1864
|
+
if (e) return e;
|
|
1865
|
+
const r = /* @__PURE__ */ new Set();
|
|
1866
|
+
return this._listeners[t] = r, r;
|
|
1867
|
+
}
|
|
1832
1868
|
$on(t, e) {
|
|
1833
|
-
|
|
1834
|
-
const r = this._listeners.get(t);
|
|
1869
|
+
const r = this._getPool(t);
|
|
1835
1870
|
return r.add(e), () => {
|
|
1836
|
-
r.delete(e), r.size === 0 && this._listeners
|
|
1871
|
+
r.delete(e), r.size === 0 && delete this._listeners[t];
|
|
1837
1872
|
};
|
|
1838
1873
|
}
|
|
1839
1874
|
$emit(t, e) {
|
|
1840
|
-
const r = this._listeners
|
|
1875
|
+
const r = this._listeners[t];
|
|
1841
1876
|
if (r) for (const a of [...r]) try {
|
|
1842
1877
|
a(e);
|
|
1843
1878
|
} catch (i) {
|
|
@@ -1845,10 +1880,10 @@ class Re {
|
|
|
1845
1880
|
}
|
|
1846
1881
|
}
|
|
1847
1882
|
$clear() {
|
|
1848
|
-
this._listeners.
|
|
1883
|
+
for (const t of Object.keys(this._listeners)) delete this._listeners[t];
|
|
1849
1884
|
}
|
|
1850
1885
|
}
|
|
1851
|
-
class
|
|
1886
|
+
class Ne {
|
|
1852
1887
|
_state;
|
|
1853
1888
|
_listeners = /* @__PURE__ */ new Set();
|
|
1854
1889
|
constructor(t) {
|
|
@@ -1877,8 +1912,8 @@ class Ue {
|
|
|
1877
1912
|
for (const r of [...this._listeners]) r(e);
|
|
1878
1913
|
}
|
|
1879
1914
|
}
|
|
1880
|
-
const
|
|
1881
|
-
class Gt extends
|
|
1915
|
+
const Ge = (n) => ({ format: n, isBusy: !1 });
|
|
1916
|
+
class Gt extends O {
|
|
1882
1917
|
props;
|
|
1883
1918
|
checkbox;
|
|
1884
1919
|
labelElement;
|
|
@@ -1909,7 +1944,7 @@ class Gt extends T {
|
|
|
1909
1944
|
this.props = t, t.id && (this.checkbox.id = t.id, this.labelElement.htmlFor = t.id), this.checkbox.checked = !!t.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = t.label);
|
|
1910
1945
|
}
|
|
1911
1946
|
}
|
|
1912
|
-
class
|
|
1947
|
+
class ze extends O {
|
|
1913
1948
|
props;
|
|
1914
1949
|
input;
|
|
1915
1950
|
handleInput = () => {
|
|
@@ -1937,9 +1972,9 @@ class Ge extends T {
|
|
|
1937
1972
|
this.props = t, t.id && (this.input.id = t.id), t.maxLength !== void 0 && (this.input.maxLength = t.maxLength), t.defaultValue !== void 0 && (this.input.value = t.defaultValue);
|
|
1938
1973
|
}
|
|
1939
1974
|
}
|
|
1940
|
-
class
|
|
1975
|
+
class We extends Y {
|
|
1941
1976
|
trailingSpaces = this._manageComponent(new Gt({ label: "preserve trailing spaces", defaultChecked: !1 }));
|
|
1942
|
-
emptyCharacter = this._manageComponent(new
|
|
1977
|
+
emptyCharacter = this._manageComponent(new ze({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
|
|
1943
1978
|
constructor(t) {
|
|
1944
1979
|
super(t);
|
|
1945
1980
|
}
|
|
@@ -1964,7 +1999,7 @@ class ze extends Y {
|
|
|
1964
1999
|
this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
|
|
1965
2000
|
}
|
|
1966
2001
|
}
|
|
1967
|
-
class
|
|
2002
|
+
class qe extends Y {
|
|
1968
2003
|
formatSelect = this._manageComponent(new mt({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${lt.png})` }, { value: "jpg", label: `JPG (${lt.jpg})` }, { value: "webp", label: `WEBP (${lt.webp})` }], defaultValue: "png" }));
|
|
1969
2004
|
scaleInput = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0.1", step: "0.1" } }));
|
|
1970
2005
|
constructor(t) {
|
|
@@ -1998,7 +2033,7 @@ class We extends Y {
|
|
|
1998
2033
|
this.scaleInput.value = String(e);
|
|
1999
2034
|
}
|
|
2000
2035
|
}
|
|
2001
|
-
class
|
|
2036
|
+
class He extends Y {
|
|
2002
2037
|
includeBackground = this._manageComponent(new Gt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 }));
|
|
2003
2038
|
drawMode = this._manageComponent(new mt({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" }));
|
|
2004
2039
|
strokeWidth = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0", step: "0.1" } }));
|
|
@@ -2036,31 +2071,35 @@ class qe extends Y {
|
|
|
2036
2071
|
this.strokeWidth.value = String(e), this.strokeWidth.refresh();
|
|
2037
2072
|
}
|
|
2038
2073
|
}
|
|
2039
|
-
const
|
|
2040
|
-
function
|
|
2041
|
-
return
|
|
2042
|
-
}
|
|
2043
|
-
function
|
|
2044
|
-
const e =
|
|
2045
|
-
return
|
|
2046
|
-
}
|
|
2047
|
-
const
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2074
|
+
const je = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new We({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new qe({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new He({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new ut({ 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 pt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
|
|
2075
|
+
function Qe() {
|
|
2076
|
+
return je;
|
|
2077
|
+
}
|
|
2078
|
+
function Xe(n, t) {
|
|
2079
|
+
const e = Qe(), r = e[0]?.format, a = new Ne(Ge(r)), i = new Ue(), s = new Re(n, t, a, i, e);
|
|
2080
|
+
return s.$mount(), s;
|
|
2081
|
+
}
|
|
2082
|
+
const zt = { name: "textmode.export", version: "1.2.1", async install(n, t) {
|
|
2083
|
+
const e = { saveCanvas: async (l = {}) => new bt().$saveImage(n.canvas, l), copyCanvas: async (l = {}) => new bt().$copyImageToClipboard(n.canvas, l), saveSVG: (l = {}) => {
|
|
2084
|
+
new gt().$saveSVG(n, l);
|
|
2085
|
+
}, saveStrings: (l = {}) => {
|
|
2086
|
+
new vt().$saveTXT(n, l);
|
|
2087
|
+
}, toSVG: (l = {}) => new gt().$generateSVG(n, l), toString: (l = {}) => new vt().$generateTXT(n, l), saveGIF: async (l = {}) => new fe(n, t.registerPostDrawHook).$saveGIF(l), saveWEBM: async (l = {}) => new Ee(n, t.registerPostDrawHook).$saveWEBM(l) }, r = Xe(n, e), a = { show: () => r.show(), hide: () => r.hide(), toggle: () => r.toggle(), isVisible: () => r.isVisible() }, i = { ...e, exportOverlay: a }, s = n;
|
|
2088
|
+
Object.assign(s, i), s._exportOverlayController = r;
|
|
2089
|
+
}, async uninstall(n) {
|
|
2090
|
+
const t = n;
|
|
2091
|
+
t._exportOverlayController?.$dispose(), delete t._exportOverlayController;
|
|
2092
|
+
const r = ["exportOverlay", "saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
|
|
2093
|
+
for (const a of r) delete t[a];
|
|
2094
|
+
} }, Ye = (n = {}) => {
|
|
2095
|
+
const t = n.overlay ?? !0, e = { ...zt }, r = e.install;
|
|
2096
|
+
return e.install = async (a, i) => {
|
|
2097
|
+
const s = a;
|
|
2098
|
+
await r.call(e, s, i), t || s.exportOverlay?.hide();
|
|
2099
|
+
}, e;
|
|
2062
2100
|
};
|
|
2063
|
-
typeof window < "u" && (window.createTextmodeExportPlugin =
|
|
2101
|
+
typeof window < "u" && (window.ExportPlugin = zt, window.createTextmodeExportPlugin = Ye);
|
|
2064
2102
|
export {
|
|
2065
|
-
|
|
2103
|
+
zt as ExportPlugin,
|
|
2104
|
+
Ye as createTextmodeExportPlugin
|
|
2066
2105
|
};
|