@vfx-js/effects 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/lib/cjs/datamosh.d.ts +43 -0
- package/lib/cjs/datamosh.js +559 -0
- package/lib/cjs/datamosh.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +7 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/jpeg-glitch.d.ts +82 -0
- package/lib/cjs/jpeg-glitch.js +501 -0
- package/lib/cjs/jpeg-glitch.js.map +1 -0
- package/lib/cjs/package.json +4 -4
- package/lib/cjs/particle-explode.js +1 -14
- package/lib/cjs/particle-explode.js.map +1 -1
- package/lib/cjs/pixelsort.d.ts +37 -0
- package/lib/cjs/pixelsort.js +474 -0
- package/lib/cjs/pixelsort.js.map +1 -0
- package/lib/esm/datamosh.d.ts +43 -0
- package/lib/esm/datamosh.js +555 -0
- package/lib/esm/datamosh.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/jpeg-glitch.d.ts +82 -0
- package/lib/esm/jpeg-glitch.js +497 -0
- package/lib/esm/jpeg-glitch.js.map +1 -0
- package/lib/esm/package.json +4 -4
- package/lib/esm/particle-explode.js +1 -14
- package/lib/esm/particle-explode.js.map +1 -1
- package/lib/esm/pixelsort.d.ts +37 -0
- package/lib/esm/pixelsort.js +470 -0
- package/lib/esm/pixelsort.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Effect, EffectContext } from "@vfx-js/core";
|
|
2
|
+
export type DatamoshColorSpace = "rgb" | "ycbcr";
|
|
3
|
+
/** Stage routed to the canvas; non-`output` views are for debugging. */
|
|
4
|
+
export type DatamoshView = "output" | "motion" | "residual" | "current" | "previous";
|
|
5
|
+
export type DatamoshParams = {
|
|
6
|
+
/** Motion-estimation block size in px. */
|
|
7
|
+
blockSize: number;
|
|
8
|
+
/** Motion search radius, in steps. Coverage = searchRange * searchStep px. */
|
|
9
|
+
searchRange: number;
|
|
10
|
+
/** Pixels per search step. Widens coverage at a fixed candidate count. */
|
|
11
|
+
searchStep: number;
|
|
12
|
+
/** Add the residual during decode (off = pure motion). */
|
|
13
|
+
useResidual: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* P-frame duplication: re-apply the frame's motion this many extra
|
|
16
|
+
* times per frame, dragging the accumulator further along the field
|
|
17
|
+
* (the bloom/smear amplifier). 0 = one normal application.
|
|
18
|
+
*/
|
|
19
|
+
dup: number;
|
|
20
|
+
/** Color model. `"ycbcr"` is 4:2:0 (half-res chroma w/ truncated MV). */
|
|
21
|
+
colorSpace: DatamoshColorSpace;
|
|
22
|
+
/** Chroma saturation boost (YCbCr output). 1 = unchanged. */
|
|
23
|
+
chromaGain: number;
|
|
24
|
+
/** Stage shown on the canvas. */
|
|
25
|
+
view: DatamoshView;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Pseudo-datamosh via a faked H.264 block codec. Passes the input
|
|
29
|
+
* through until `enable()`, then holds a motion-compensated accumulator
|
|
30
|
+
* so motion smears stale texture around. Mutate `params` directly or via
|
|
31
|
+
* `setParams`; toggle the mosh with `enable()` / `disable()`.
|
|
32
|
+
*/
|
|
33
|
+
export declare class DatamoshEffect implements Effect {
|
|
34
|
+
#private;
|
|
35
|
+
params: DatamoshParams;
|
|
36
|
+
constructor(initial?: Partial<DatamoshParams>);
|
|
37
|
+
setParams(partial: Partial<DatamoshParams>): void;
|
|
38
|
+
enable(): void;
|
|
39
|
+
disable(): void;
|
|
40
|
+
get enabled(): boolean;
|
|
41
|
+
render(ctx: EffectContext): void;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _DatamoshEffect_instances, _DatamoshEffect_enabled, _DatamoshEffect_seed, _DatamoshEffect_curRT, _DatamoshEffect_prevRT, _DatamoshEffect_mvRT, _DatamoshEffect_resRT, _DatamoshEffect_accRT, _DatamoshEffect_chromaAccRT, _DatamoshEffect_chromaResRT, _DatamoshEffect_w, _DatamoshEffect_h, _DatamoshEffect_cw, _DatamoshEffect_ch, _DatamoshEffect_block, _DatamoshEffect_lastColorSpace, _DatamoshEffect_disposeTargets, _DatamoshEffect_ensureSize, _DatamoshEffect_display;
|
|
13
|
+
// Premultiplied copy of an internal RT to the canvas. `uvContent` maps
|
|
14
|
+
// the content rect into the target buffer.
|
|
15
|
+
const FRAG_DISPLAY = `#version 300 es
|
|
16
|
+
precision highp float;
|
|
17
|
+
in vec2 uvContent;
|
|
18
|
+
out vec4 outColor;
|
|
19
|
+
uniform sampler2D tex;
|
|
20
|
+
void main() {
|
|
21
|
+
vec4 c = texture(tex, uvContent);
|
|
22
|
+
outColor = vec4(c.rgb * c.a, c.a);
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
// Motion estimation: one fragment per block. SAD block-matching searches
|
|
26
|
+
// the reference over a +/-uSearch px window and writes the displacement
|
|
27
|
+
// (px) that best matches the current block, into .rg of a float RT.
|
|
28
|
+
// A small length bias breaks ties toward (0,0) so flat blocks don't latch
|
|
29
|
+
// onto spurious large vectors.
|
|
30
|
+
const FRAG_ME = `#version 300 es
|
|
31
|
+
precision highp float;
|
|
32
|
+
out vec4 outMV;
|
|
33
|
+
uniform sampler2D uCur, uRef;
|
|
34
|
+
uniform vec2 uResolution; // [w, h] in px
|
|
35
|
+
uniform float uBlock; // block size in px
|
|
36
|
+
uniform float uSearch; // search radius, in steps
|
|
37
|
+
uniform float uStep; // px per step (coverage = uSearch * uStep px)
|
|
38
|
+
void main() {
|
|
39
|
+
vec2 block = floor(gl_FragCoord.xy);
|
|
40
|
+
vec2 base = block * uBlock; // top-left pixel of this block
|
|
41
|
+
|
|
42
|
+
// Cache the current block's 3x3 samples and their (offset, px) within
|
|
43
|
+
// the block — the offsets are invariant across candidates.
|
|
44
|
+
vec3 cs[9];
|
|
45
|
+
vec2 off[9];
|
|
46
|
+
for (int i = 0; i < 3; i++) {
|
|
47
|
+
for (int j = 0; j < 3; j++) {
|
|
48
|
+
int k = i * 3 + j;
|
|
49
|
+
off[k] = vec2(1 + i * 2, 1 + j * 2) / 6.0 * uBlock;
|
|
50
|
+
cs[k] = texture(uCur, (base + off[k] + 0.5) / uResolution).rgb;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
vec2 move = vec2(0.0);
|
|
55
|
+
float bestSad = 1e9;
|
|
56
|
+
for (float by = -uSearch; by <= uSearch; by++) {
|
|
57
|
+
for (float bx = -uSearch; bx <= uSearch; bx++) {
|
|
58
|
+
vec2 cand = vec2(bx, by) * uStep; // candidate displacement, px
|
|
59
|
+
float sad = 0.0;
|
|
60
|
+
for (int k = 0; k < 9; k++) {
|
|
61
|
+
vec3 cRef = texture(uRef, (base + off[k] + cand + 0.5) / uResolution).rgb;
|
|
62
|
+
sad += dot(abs(cs[k] - cRef), vec3(1.0));
|
|
63
|
+
}
|
|
64
|
+
sad += length(cand) * 0.0025; // prefer small motion on ties
|
|
65
|
+
if (sad < bestSad) {
|
|
66
|
+
bestSad = sad;
|
|
67
|
+
move = cand;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
outMV = vec4(move, 0.0, 1.0);
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
// Residual = cur - motionComp(ref, mv). Signed -> needs a float RT.
|
|
76
|
+
const FRAG_RESIDUAL = `#version 300 es
|
|
77
|
+
precision highp float;
|
|
78
|
+
in vec2 uv;
|
|
79
|
+
out vec4 outColor;
|
|
80
|
+
uniform sampler2D uCur, uRef, uMV;
|
|
81
|
+
uniform vec2 uResolution;
|
|
82
|
+
void main() {
|
|
83
|
+
vec2 mv = texture(uMV, uv).rg; // px
|
|
84
|
+
vec3 cur = texture(uCur, uv).rgb;
|
|
85
|
+
vec3 pred = texture(uRef, uv + mv / uResolution).rgb;
|
|
86
|
+
outColor = vec4(cur - pred, 1.0);
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
// Decode. intra -> seed from the clean source. inter -> motion-comp the
|
|
90
|
+
// held accumulator and add the residual (this is where the mosh lives).
|
|
91
|
+
const FRAG_DECODE = `#version 300 es
|
|
92
|
+
precision highp float;
|
|
93
|
+
in vec2 uv;
|
|
94
|
+
out vec4 outColor;
|
|
95
|
+
uniform sampler2D uAccum, uMV, uVideo, uResidual;
|
|
96
|
+
uniform vec2 uResolution;
|
|
97
|
+
uniform bool uIntra;
|
|
98
|
+
uniform bool uUseResidual;
|
|
99
|
+
void main() {
|
|
100
|
+
if (uIntra) {
|
|
101
|
+
outColor = vec4(texture(uVideo, uv).rgb, 1.0);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
vec2 mv = texture(uMV, uv).rg; // px
|
|
105
|
+
vec3 pred = texture(uAccum, uv + mv / uResolution).rgb;
|
|
106
|
+
vec3 res = uUseResidual ? texture(uResidual, uv).rgb : vec3(0.0);
|
|
107
|
+
// Clamp like an 8-bit decoder so the feedback can't run away to white.
|
|
108
|
+
outColor = vec4(clamp(pred + res, 0.0, 1.0), 1.0);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
// Debug view: motion field as HSV (hue = direction, value = magnitude).
|
|
112
|
+
const FRAG_VIEW_MOTION = `#version 300 es
|
|
113
|
+
precision highp float;
|
|
114
|
+
in vec2 uvContent;
|
|
115
|
+
out vec4 outColor;
|
|
116
|
+
uniform sampler2D uMV;
|
|
117
|
+
uniform float uMvScale; // magnitude normalization, px
|
|
118
|
+
vec3 hsv(vec3 c) {
|
|
119
|
+
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
120
|
+
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
121
|
+
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
122
|
+
}
|
|
123
|
+
void main() {
|
|
124
|
+
vec2 mv = texture(uMV, uvContent).rg;
|
|
125
|
+
float ang = atan(mv.y, mv.x) / 6.28318 + 0.5;
|
|
126
|
+
float mag = clamp(length(mv) / max(uMvScale, 1.0), 0.0, 1.0);
|
|
127
|
+
outColor = vec4(hsv(vec3(ang, 0.9, 0.15 + 0.85 * mag)), 1.0);
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
// Debug view: signed residual remapped to gray (0.5 = zero).
|
|
131
|
+
const FRAG_VIEW_RESIDUAL = `#version 300 es
|
|
132
|
+
precision highp float;
|
|
133
|
+
in vec2 uvContent;
|
|
134
|
+
out vec4 outColor;
|
|
135
|
+
uniform sampler2D uResidual;
|
|
136
|
+
void main() {
|
|
137
|
+
vec3 r = texture(uResidual, uvContent).rgb;
|
|
138
|
+
outColor = vec4(clamp(r * 0.5 + 0.5, 0.0, 1.0), 1.0);
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
// BT.601 luma / chroma. Both are linear, so the residual planes are
|
|
142
|
+
// derived from the shared RGB residual: luma(res) and chroma(res) - 0.5.
|
|
143
|
+
const Y601 = `
|
|
144
|
+
float luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
|
|
145
|
+
vec2 chroma(vec3 c) {
|
|
146
|
+
return vec2(dot(c, vec3(-0.168736, -0.331264, 0.5)),
|
|
147
|
+
dot(c, vec3(0.5, -0.418688, -0.081312))) + 0.5;
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
// Chroma residual (half res), zero-centered (Cb,Cr). Built with the SAME
|
|
151
|
+
// truncated chroma MV as the decode prediction, so the two cancel when
|
|
152
|
+
// residual is on — leaving the truncation drift to show only in pure-motion.
|
|
153
|
+
const FRAG_RESIDUAL_C = `#version 300 es
|
|
154
|
+
precision highp float;
|
|
155
|
+
${Y601}
|
|
156
|
+
in vec2 uv;
|
|
157
|
+
out vec4 outColor;
|
|
158
|
+
uniform sampler2D uCur, uRef, uMV;
|
|
159
|
+
uniform vec2 uChromaRes;
|
|
160
|
+
void main() {
|
|
161
|
+
vec2 mvc = floor(texture(uMV, uv).rg * 0.5);
|
|
162
|
+
vec2 pred = chroma(texture(uRef, uv + mvc / uChromaRes).rgb);
|
|
163
|
+
outColor = vec4(chroma(texture(uCur, uv).rgb) - pred, 0.0, 1.0);
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
// Luma decode (full res). Writes Y into .r of the shared accumulator.
|
|
167
|
+
const FRAG_DECODE_Y = `#version 300 es
|
|
168
|
+
precision highp float;
|
|
169
|
+
${Y601}
|
|
170
|
+
in vec2 uv;
|
|
171
|
+
out vec4 outColor;
|
|
172
|
+
uniform sampler2D uAccum, uMV, uVideo, uResidual;
|
|
173
|
+
uniform vec2 uResolution;
|
|
174
|
+
uniform bool uIntra;
|
|
175
|
+
uniform bool uUseResidual;
|
|
176
|
+
void main() {
|
|
177
|
+
// I-frame: passthrough the input
|
|
178
|
+
if (uIntra) {
|
|
179
|
+
outColor = vec4(luma(texture(uVideo, uv).rgb), 0.0, 0.0, 1.0);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// P-frame: compose luma from acc + residual
|
|
184
|
+
vec2 mv = texture(uMV, uv).rg; // px
|
|
185
|
+
float pred = texture(uAccum, uv + mv / uResolution).r;
|
|
186
|
+
float res = uUseResidual ? luma(texture(uResidual, uv).rgb) : 0.0;
|
|
187
|
+
float Y = clamp(pred + res, 0.0, 1.0);
|
|
188
|
+
|
|
189
|
+
outColor = vec4(Y, 0.0, 0.0, 1.0);
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
192
|
+
// Chroma decode (half res). Writes (Cb,Cr) into .rg of the chroma plane.
|
|
193
|
+
// The truncated chroma MV (mvc = floor(mv * 0.5)) is the datamosh color
|
|
194
|
+
// drift: chroma is dragged by half the luma motion, rounded down, so color
|
|
195
|
+
// slides off the luma edges.
|
|
196
|
+
const FRAG_DECODE_C = `#version 300 es
|
|
197
|
+
precision highp float;
|
|
198
|
+
${Y601}
|
|
199
|
+
in vec2 uv;
|
|
200
|
+
out vec4 outColor;
|
|
201
|
+
uniform sampler2D uChromaAcc, uMV, uVideo, uResidualC;
|
|
202
|
+
uniform vec2 uChromaRes;
|
|
203
|
+
uniform bool uIntra;
|
|
204
|
+
uniform bool uUseResidual;
|
|
205
|
+
void main() {
|
|
206
|
+
// I-frame: passthrough the input
|
|
207
|
+
if (uIntra) {
|
|
208
|
+
outColor = vec4(chroma(texture(uVideo, uv).rgb), 0.0, 1.0);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// P-frame: compose chroma from acc + residual. uResidualC is the
|
|
213
|
+
// zero-centered chroma residual (built with the SAME truncated MV as
|
|
214
|
+
// the prediction below, so they cancel when residual is on).
|
|
215
|
+
vec2 mv = texture(uMV, uv).rg; // px (luma units)
|
|
216
|
+
vec2 mvc = floor(mv * 0.5);
|
|
217
|
+
vec2 pred = texture(uChromaAcc, uv + mvc / uChromaRes).rg;
|
|
218
|
+
vec2 res = uUseResidual ? texture(uResidualC, uv).rg : vec2(0);
|
|
219
|
+
vec2 C = clamp(pred + res, 0.0, 1.0);
|
|
220
|
+
|
|
221
|
+
outColor = vec4(C, 0.0, 1.0);
|
|
222
|
+
}
|
|
223
|
+
`;
|
|
224
|
+
// YCbCr 4:2:0 -> RGB. Luma full res, chroma upsampled (bilinear) from the
|
|
225
|
+
// half-res plane. `uChromaGain` boosts saturation. Premultiplied for the
|
|
226
|
+
// canvas.
|
|
227
|
+
const FRAG_DISPLAY_YCBCR = `#version 300 es
|
|
228
|
+
precision highp float;
|
|
229
|
+
in vec2 uvContent;
|
|
230
|
+
out vec4 outColor;
|
|
231
|
+
uniform sampler2D uLumaAcc;
|
|
232
|
+
uniform sampler2D uChromaAcc;
|
|
233
|
+
uniform float uChromaGain;
|
|
234
|
+
void main() {
|
|
235
|
+
float Y = texture(uLumaAcc, uvContent).r;
|
|
236
|
+
vec2 cbcr = (texture(uChromaAcc, uvContent).rg - 0.5) * uChromaGain;
|
|
237
|
+
vec3 rgb = vec3(
|
|
238
|
+
Y + 1.402 * cbcr.y,
|
|
239
|
+
Y - 0.344136 * cbcr.x - 0.714136 * cbcr.y,
|
|
240
|
+
Y + 1.772 * cbcr.x
|
|
241
|
+
);
|
|
242
|
+
outColor = vec4(clamp(rgb, 0.0, 1.0), 1.0);
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
const DEFAULT_PARAMS = {
|
|
246
|
+
blockSize: 16,
|
|
247
|
+
searchRange: 5,
|
|
248
|
+
searchStep: 2,
|
|
249
|
+
useResidual: true,
|
|
250
|
+
dup: 0,
|
|
251
|
+
colorSpace: "ycbcr",
|
|
252
|
+
chromaGain: 1,
|
|
253
|
+
view: "output",
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Pseudo-datamosh via a faked H.264 block codec. Passes the input
|
|
257
|
+
* through until `enable()`, then holds a motion-compensated accumulator
|
|
258
|
+
* so motion smears stale texture around. Mutate `params` directly or via
|
|
259
|
+
* `setParams`; toggle the mosh with `enable()` / `disable()`.
|
|
260
|
+
*/
|
|
261
|
+
export class DatamoshEffect {
|
|
262
|
+
constructor(initial = {}) {
|
|
263
|
+
_DatamoshEffect_instances.add(this);
|
|
264
|
+
_DatamoshEffect_enabled.set(this, false);
|
|
265
|
+
// Re-seed the accumulator from a clean frame on the next mosh frame.
|
|
266
|
+
_DatamoshEffect_seed.set(this, true);
|
|
267
|
+
_DatamoshEffect_curRT.set(this, null);
|
|
268
|
+
_DatamoshEffect_prevRT.set(this, null);
|
|
269
|
+
_DatamoshEffect_mvRT.set(this, null);
|
|
270
|
+
_DatamoshEffect_resRT.set(this, null);
|
|
271
|
+
_DatamoshEffect_accRT.set(this, null);
|
|
272
|
+
// Half-res chroma accumulator (YCbCr path). Luma reuses #accRT (.r).
|
|
273
|
+
_DatamoshEffect_chromaAccRT.set(this, null);
|
|
274
|
+
// Half-res chroma residual (YCbCr path). Luma reuses #resRT (.r).
|
|
275
|
+
_DatamoshEffect_chromaResRT.set(this, null);
|
|
276
|
+
_DatamoshEffect_w.set(this, 0);
|
|
277
|
+
_DatamoshEffect_h.set(this, 0);
|
|
278
|
+
_DatamoshEffect_cw.set(this, 0);
|
|
279
|
+
_DatamoshEffect_ch.set(this, 0);
|
|
280
|
+
_DatamoshEffect_block.set(this, 0);
|
|
281
|
+
// Re-seed when the color model flips (accumulators change meaning).
|
|
282
|
+
_DatamoshEffect_lastColorSpace.set(this, void 0);
|
|
283
|
+
this.params = { ...DEFAULT_PARAMS, ...initial };
|
|
284
|
+
__classPrivateFieldSet(this, _DatamoshEffect_lastColorSpace, this.params.colorSpace, "f");
|
|
285
|
+
}
|
|
286
|
+
setParams(partial) {
|
|
287
|
+
Object.assign(this.params, partial);
|
|
288
|
+
}
|
|
289
|
+
enable() {
|
|
290
|
+
__classPrivateFieldSet(this, _DatamoshEffect_enabled, true, "f");
|
|
291
|
+
}
|
|
292
|
+
disable() {
|
|
293
|
+
__classPrivateFieldSet(this, _DatamoshEffect_enabled, false, "f");
|
|
294
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, true, "f");
|
|
295
|
+
}
|
|
296
|
+
get enabled() {
|
|
297
|
+
return __classPrivateFieldGet(this, _DatamoshEffect_enabled, "f");
|
|
298
|
+
}
|
|
299
|
+
render(ctx) {
|
|
300
|
+
__classPrivateFieldGet(this, _DatamoshEffect_instances, "m", _DatamoshEffect_ensureSize).call(this, ctx);
|
|
301
|
+
const cur = __classPrivateFieldGet(this, _DatamoshEffect_curRT, "f");
|
|
302
|
+
const prev = __classPrivateFieldGet(this, _DatamoshEffect_prevRT, "f");
|
|
303
|
+
const mv = __classPrivateFieldGet(this, _DatamoshEffect_mvRT, "f");
|
|
304
|
+
const res = __classPrivateFieldGet(this, _DatamoshEffect_resRT, "f");
|
|
305
|
+
const acc = __classPrivateFieldGet(this, _DatamoshEffect_accRT, "f");
|
|
306
|
+
const chromaAcc = __classPrivateFieldGet(this, _DatamoshEffect_chromaAccRT, "f");
|
|
307
|
+
const chromaResidual = __classPrivateFieldGet(this, _DatamoshEffect_chromaResRT, "f");
|
|
308
|
+
if (!cur ||
|
|
309
|
+
!prev ||
|
|
310
|
+
!mv ||
|
|
311
|
+
!res ||
|
|
312
|
+
!acc ||
|
|
313
|
+
!chromaAcc ||
|
|
314
|
+
!chromaResidual) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
// Flipping the color model repurposes the accumulators, so re-seed.
|
|
318
|
+
if (this.params.colorSpace !== __classPrivateFieldGet(this, _DatamoshEffect_lastColorSpace, "f")) {
|
|
319
|
+
__classPrivateFieldSet(this, _DatamoshEffect_lastColorSpace, this.params.colorSpace, "f");
|
|
320
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, true, "f");
|
|
321
|
+
}
|
|
322
|
+
const resolution = [__classPrivateFieldGet(this, _DatamoshEffect_w, "f"), __classPrivateFieldGet(this, _DatamoshEffect_h, "f")];
|
|
323
|
+
// Capture the current frame into uv-space.
|
|
324
|
+
ctx.blit(ctx.src, cur);
|
|
325
|
+
// ME + residual feed both the decoder and the debug views, so run
|
|
326
|
+
// them whenever moshing OR inspecting an intermediate stage.
|
|
327
|
+
const debug = this.params.view !== "output";
|
|
328
|
+
if (__classPrivateFieldGet(this, _DatamoshEffect_enabled, "f") || debug) {
|
|
329
|
+
ctx.draw({
|
|
330
|
+
frag: FRAG_ME,
|
|
331
|
+
uniforms: {
|
|
332
|
+
uCur: cur,
|
|
333
|
+
uRef: prev,
|
|
334
|
+
uResolution: resolution,
|
|
335
|
+
uBlock: __classPrivateFieldGet(this, _DatamoshEffect_block, "f"),
|
|
336
|
+
uSearch: this.params.searchRange,
|
|
337
|
+
uStep: this.params.searchStep,
|
|
338
|
+
},
|
|
339
|
+
target: mv,
|
|
340
|
+
});
|
|
341
|
+
ctx.draw({
|
|
342
|
+
frag: FRAG_RESIDUAL,
|
|
343
|
+
uniforms: {
|
|
344
|
+
uCur: cur,
|
|
345
|
+
uRef: prev,
|
|
346
|
+
uMV: mv,
|
|
347
|
+
uResolution: resolution,
|
|
348
|
+
},
|
|
349
|
+
target: res,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (__classPrivateFieldGet(this, _DatamoshEffect_enabled, "f")) {
|
|
353
|
+
// Decode onto the held accumulator. First mosh frame seeds
|
|
354
|
+
// intra (1 pass); inter re-applies the motion 1 + dup times,
|
|
355
|
+
// chaining through the persistent RT's ping-pong to compound
|
|
356
|
+
// the smear. Residual lands on the first pass only.
|
|
357
|
+
const reps = __classPrivateFieldGet(this, _DatamoshEffect_seed, "f") ? 1 : 1 + this.params.dup;
|
|
358
|
+
const chromaRes = [__classPrivateFieldGet(this, _DatamoshEffect_cw, "f"), __classPrivateFieldGet(this, _DatamoshEffect_ch, "f")];
|
|
359
|
+
if (this.params.colorSpace === "ycbcr") {
|
|
360
|
+
// Chroma residual with the truncated MV (matches DECC's
|
|
361
|
+
// prediction so it cancels when residual is on).
|
|
362
|
+
ctx.draw({
|
|
363
|
+
frag: FRAG_RESIDUAL_C,
|
|
364
|
+
uniforms: {
|
|
365
|
+
uCur: cur,
|
|
366
|
+
uRef: prev,
|
|
367
|
+
uMV: mv,
|
|
368
|
+
uChromaRes: chromaRes,
|
|
369
|
+
},
|
|
370
|
+
target: chromaResidual,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
for (let r = 0; r < reps; r++) {
|
|
374
|
+
const useResidual = this.params.useResidual && r === 0;
|
|
375
|
+
if (this.params.colorSpace === "ycbcr") {
|
|
376
|
+
ctx.draw({
|
|
377
|
+
frag: FRAG_DECODE_Y,
|
|
378
|
+
uniforms: {
|
|
379
|
+
uAccum: acc,
|
|
380
|
+
uMV: mv,
|
|
381
|
+
uVideo: cur,
|
|
382
|
+
uResidual: res,
|
|
383
|
+
uResolution: resolution,
|
|
384
|
+
uIntra: __classPrivateFieldGet(this, _DatamoshEffect_seed, "f"),
|
|
385
|
+
uUseResidual: useResidual,
|
|
386
|
+
},
|
|
387
|
+
target: acc,
|
|
388
|
+
});
|
|
389
|
+
ctx.draw({
|
|
390
|
+
frag: FRAG_DECODE_C,
|
|
391
|
+
uniforms: {
|
|
392
|
+
uChromaAcc: chromaAcc,
|
|
393
|
+
uMV: mv,
|
|
394
|
+
uVideo: cur,
|
|
395
|
+
uResidualC: chromaResidual,
|
|
396
|
+
uChromaRes: chromaRes,
|
|
397
|
+
uIntra: __classPrivateFieldGet(this, _DatamoshEffect_seed, "f"),
|
|
398
|
+
uUseResidual: useResidual,
|
|
399
|
+
},
|
|
400
|
+
target: chromaAcc,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
ctx.draw({
|
|
405
|
+
frag: FRAG_DECODE,
|
|
406
|
+
uniforms: {
|
|
407
|
+
uAccum: acc,
|
|
408
|
+
uMV: mv,
|
|
409
|
+
uVideo: cur,
|
|
410
|
+
uResidual: res,
|
|
411
|
+
uResolution: resolution,
|
|
412
|
+
uIntra: __classPrivateFieldGet(this, _DatamoshEffect_seed, "f"),
|
|
413
|
+
uUseResidual: useResidual,
|
|
414
|
+
},
|
|
415
|
+
target: acc,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, false, "f");
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
// Never refresh acc while disabled; re-seed on the next mosh frame.
|
|
423
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, true, "f");
|
|
424
|
+
}
|
|
425
|
+
__classPrivateFieldGet(this, _DatamoshEffect_instances, "m", _DatamoshEffect_display).call(this, ctx, cur, prev, mv, res, acc, chromaAcc);
|
|
426
|
+
// Reference for next frame's motion estimation.
|
|
427
|
+
ctx.blit(ctx.src, prev);
|
|
428
|
+
}
|
|
429
|
+
dispose() {
|
|
430
|
+
__classPrivateFieldGet(this, _DatamoshEffect_instances, "m", _DatamoshEffect_disposeTargets).call(this);
|
|
431
|
+
__classPrivateFieldSet(this, _DatamoshEffect_w, 0, "f");
|
|
432
|
+
__classPrivateFieldSet(this, _DatamoshEffect_h, 0, "f");
|
|
433
|
+
__classPrivateFieldSet(this, _DatamoshEffect_cw, 0, "f");
|
|
434
|
+
__classPrivateFieldSet(this, _DatamoshEffect_ch, 0, "f");
|
|
435
|
+
__classPrivateFieldSet(this, _DatamoshEffect_block, 0, "f");
|
|
436
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, true, "f");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
_DatamoshEffect_enabled = new WeakMap(), _DatamoshEffect_seed = new WeakMap(), _DatamoshEffect_curRT = new WeakMap(), _DatamoshEffect_prevRT = new WeakMap(), _DatamoshEffect_mvRT = new WeakMap(), _DatamoshEffect_resRT = new WeakMap(), _DatamoshEffect_accRT = new WeakMap(), _DatamoshEffect_chromaAccRT = new WeakMap(), _DatamoshEffect_chromaResRT = new WeakMap(), _DatamoshEffect_w = new WeakMap(), _DatamoshEffect_h = new WeakMap(), _DatamoshEffect_cw = new WeakMap(), _DatamoshEffect_ch = new WeakMap(), _DatamoshEffect_block = new WeakMap(), _DatamoshEffect_lastColorSpace = new WeakMap(), _DatamoshEffect_instances = new WeakSet(), _DatamoshEffect_disposeTargets = function _DatamoshEffect_disposeTargets() {
|
|
440
|
+
__classPrivateFieldGet(this, _DatamoshEffect_curRT, "f")?.dispose();
|
|
441
|
+
__classPrivateFieldGet(this, _DatamoshEffect_prevRT, "f")?.dispose();
|
|
442
|
+
__classPrivateFieldGet(this, _DatamoshEffect_mvRT, "f")?.dispose();
|
|
443
|
+
__classPrivateFieldGet(this, _DatamoshEffect_resRT, "f")?.dispose();
|
|
444
|
+
__classPrivateFieldGet(this, _DatamoshEffect_accRT, "f")?.dispose();
|
|
445
|
+
__classPrivateFieldGet(this, _DatamoshEffect_chromaAccRT, "f")?.dispose();
|
|
446
|
+
__classPrivateFieldGet(this, _DatamoshEffect_chromaResRT, "f")?.dispose();
|
|
447
|
+
__classPrivateFieldSet(this, _DatamoshEffect_curRT, null, "f");
|
|
448
|
+
__classPrivateFieldSet(this, _DatamoshEffect_prevRT, null, "f");
|
|
449
|
+
__classPrivateFieldSet(this, _DatamoshEffect_mvRT, null, "f");
|
|
450
|
+
__classPrivateFieldSet(this, _DatamoshEffect_resRT, null, "f");
|
|
451
|
+
__classPrivateFieldSet(this, _DatamoshEffect_accRT, null, "f");
|
|
452
|
+
__classPrivateFieldSet(this, _DatamoshEffect_chromaAccRT, null, "f");
|
|
453
|
+
__classPrivateFieldSet(this, _DatamoshEffect_chromaResRT, null, "f");
|
|
454
|
+
}, _DatamoshEffect_ensureSize = function _DatamoshEffect_ensureSize(ctx) {
|
|
455
|
+
const [w, h] = ctx.dims.elementPixel;
|
|
456
|
+
const block = Math.max(2, this.params.blockSize);
|
|
457
|
+
if (__classPrivateFieldGet(this, _DatamoshEffect_w, "f") === w && __classPrivateFieldGet(this, _DatamoshEffect_h, "f") === h && __classPrivateFieldGet(this, _DatamoshEffect_block, "f") === block) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
__classPrivateFieldGet(this, _DatamoshEffect_instances, "m", _DatamoshEffect_disposeTargets).call(this);
|
|
461
|
+
__classPrivateFieldSet(this, _DatamoshEffect_w, w, "f");
|
|
462
|
+
__classPrivateFieldSet(this, _DatamoshEffect_h, h, "f");
|
|
463
|
+
__classPrivateFieldSet(this, _DatamoshEffect_cw, Math.ceil(w / 2), "f");
|
|
464
|
+
__classPrivateFieldSet(this, _DatamoshEffect_ch, Math.ceil(h / 2), "f");
|
|
465
|
+
__classPrivateFieldSet(this, _DatamoshEffect_block, block, "f");
|
|
466
|
+
__classPrivateFieldSet(this, _DatamoshEffect_seed, true, "f");
|
|
467
|
+
const cols = Math.ceil(w / block);
|
|
468
|
+
const rows = Math.ceil(h / block);
|
|
469
|
+
// Full-res content buffers; residual/accumulator are float to
|
|
470
|
+
// hold signed values and accumulation overflow.
|
|
471
|
+
__classPrivateFieldSet(this, _DatamoshEffect_curRT, ctx.createRenderTarget({ size: [w, h] }), "f");
|
|
472
|
+
__classPrivateFieldSet(this, _DatamoshEffect_prevRT, ctx.createRenderTarget({
|
|
473
|
+
size: [w, h],
|
|
474
|
+
persistent: true,
|
|
475
|
+
}), "f");
|
|
476
|
+
__classPrivateFieldSet(this, _DatamoshEffect_resRT, ctx.createRenderTarget({ size: [w, h], float: true }), "f");
|
|
477
|
+
__classPrivateFieldSet(this, _DatamoshEffect_accRT, ctx.createRenderTarget({
|
|
478
|
+
size: [w, h],
|
|
479
|
+
float: true,
|
|
480
|
+
persistent: true,
|
|
481
|
+
}), "f");
|
|
482
|
+
// Half-res chroma accumulator (4:2:0). RG = (Cb, Cr).
|
|
483
|
+
__classPrivateFieldSet(this, _DatamoshEffect_chromaAccRT, ctx.createRenderTarget({
|
|
484
|
+
size: [__classPrivateFieldGet(this, _DatamoshEffect_cw, "f"), __classPrivateFieldGet(this, _DatamoshEffect_ch, "f")],
|
|
485
|
+
float: true,
|
|
486
|
+
persistent: true,
|
|
487
|
+
}), "f");
|
|
488
|
+
// Half-res chroma residual (zero-centered, truncated-MV).
|
|
489
|
+
__classPrivateFieldSet(this, _DatamoshEffect_chromaResRT, ctx.createRenderTarget({
|
|
490
|
+
size: [__classPrivateFieldGet(this, _DatamoshEffect_cw, "f"), __classPrivateFieldGet(this, _DatamoshEffect_ch, "f")],
|
|
491
|
+
float: true,
|
|
492
|
+
}), "f");
|
|
493
|
+
// Motion field: one texel per block, nearest so reads snap to the
|
|
494
|
+
// block's vector.
|
|
495
|
+
__classPrivateFieldSet(this, _DatamoshEffect_mvRT, ctx.createRenderTarget({
|
|
496
|
+
size: [cols, rows],
|
|
497
|
+
float: true,
|
|
498
|
+
filter: "nearest",
|
|
499
|
+
}), "f");
|
|
500
|
+
}, _DatamoshEffect_display = function _DatamoshEffect_display(ctx, cur, prev, mv, res, acc, chromaAcc) {
|
|
501
|
+
switch (this.params.view) {
|
|
502
|
+
case "motion":
|
|
503
|
+
ctx.draw({
|
|
504
|
+
frag: FRAG_VIEW_MOTION,
|
|
505
|
+
uniforms: {
|
|
506
|
+
uMV: mv,
|
|
507
|
+
uMvScale: this.params.searchRange * this.params.searchStep,
|
|
508
|
+
},
|
|
509
|
+
target: ctx.target,
|
|
510
|
+
});
|
|
511
|
+
return;
|
|
512
|
+
case "residual":
|
|
513
|
+
ctx.draw({
|
|
514
|
+
frag: FRAG_VIEW_RESIDUAL,
|
|
515
|
+
uniforms: { uResidual: res },
|
|
516
|
+
target: ctx.target,
|
|
517
|
+
});
|
|
518
|
+
return;
|
|
519
|
+
case "current":
|
|
520
|
+
ctx.draw({
|
|
521
|
+
frag: FRAG_DISPLAY,
|
|
522
|
+
uniforms: { tex: cur },
|
|
523
|
+
target: ctx.target,
|
|
524
|
+
});
|
|
525
|
+
return;
|
|
526
|
+
case "previous":
|
|
527
|
+
ctx.draw({
|
|
528
|
+
frag: FRAG_DISPLAY,
|
|
529
|
+
uniforms: { tex: prev },
|
|
530
|
+
target: ctx.target,
|
|
531
|
+
});
|
|
532
|
+
return;
|
|
533
|
+
default:
|
|
534
|
+
// "output": decoded result while moshing, live frame otherwise.
|
|
535
|
+
if (__classPrivateFieldGet(this, _DatamoshEffect_enabled, "f") && this.params.colorSpace === "ycbcr") {
|
|
536
|
+
ctx.draw({
|
|
537
|
+
frag: FRAG_DISPLAY_YCBCR,
|
|
538
|
+
uniforms: {
|
|
539
|
+
uLumaAcc: acc,
|
|
540
|
+
uChromaAcc: chromaAcc,
|
|
541
|
+
uChromaGain: this.params.chromaGain,
|
|
542
|
+
},
|
|
543
|
+
target: ctx.target,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
ctx.draw({
|
|
548
|
+
frag: FRAG_DISPLAY,
|
|
549
|
+
uniforms: { tex: __classPrivateFieldGet(this, _DatamoshEffect_enabled, "f") ? acc : cur },
|
|
550
|
+
target: ctx.target,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
//# sourceMappingURL=datamosh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datamosh.js","sourceRoot":"","sources":["../../src/datamosh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,uEAAuE;AACvE,2CAA2C;AAC3C,MAAM,YAAY,GAAG;;;;;;;;;CASpB,CAAC;AAEF,yEAAyE;AACzE,wEAAwE;AACxE,oEAAoE;AACpE,0EAA0E;AAC1E,+BAA+B;AAC/B,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Cf,CAAC;AAEF,oEAAoE;AACpE,MAAM,aAAa,GAAG;;;;;;;;;;;;CAYrB,CAAC;AAEF,wEAAwE;AACxE,wEAAwE;AACxE,MAAM,WAAW,GAAG;;;;;;;;;;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,MAAM,EAAE,GAAG,CAAC,MAAM;aACrB,CAAC,CAAC;YACH,OAAO;QACX,KAAK,UAAU;YACX,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;gBACvB,MAAM,EAAE,GAAG,CAAC,MAAM;aACrB,CAAC,CAAC;YACH,OAAO;QACX;YACI,gEAAgE;YAChE,IAAI,uBAAA,IAAI,+BAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;gBACtD,GAAG,CAAC,IAAI,CAAC;oBACL,IAAI,EAAE,kBAAkB;oBACxB,QAAQ,EAAE;wBACN,QAAQ,EAAE,GAAG;wBACb,UAAU,EAAE,SAAS;wBACrB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;qBACtC;oBACD,MAAM,EAAE,GAAG,CAAC,MAAM;iBACrB,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,GAAG,CAAC,IAAI,CAAC;oBACL,IAAI,EAAE,YAAY;oBAClB,QAAQ,EAAE,EAAE,GAAG,EAAE,uBAAA,IAAI,+BAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE;oBAC5C,MAAM,EAAE,GAAG,CAAC,MAAM;iBACrB,CAAC,CAAC;YACP,CAAC;IACT,CAAC;AACL,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { BloomEffect } from "./bloom";
|
|
2
|
+
export { type DatamoshColorSpace, DatamoshEffect, type DatamoshParams, type DatamoshView, } from "./datamosh";
|
|
2
3
|
export { FluidEffect } from "./fluid";
|
|
3
4
|
export { HalftoneEffect, type HalftoneInkPresetName } from "./halftone";
|
|
5
|
+
export { JPEGGlitchEffect, type JPEGGlitchParams } from "./jpeg-glitch";
|
|
4
6
|
export { ParticleEffect } from "./particle";
|
|
5
7
|
export { ParticleExplodeEffect } from "./particle-explode";
|
|
6
8
|
export { PixelateEffect } from "./pixelate";
|
|
9
|
+
export { type PixelSortDirection, PixelSortEffect, type PixelSortKey, type PixelSortParams, } from "./pixelsort";
|
|
7
10
|
export { ScanlineEffect } from "./scanline";
|
|
8
11
|
export { VoronoiEffect } from "./voronoi";
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { BloomEffect } from "./bloom";
|
|
2
|
+
export { DatamoshEffect, } from "./datamosh";
|
|
2
3
|
export { FluidEffect } from "./fluid";
|
|
3
4
|
export { HalftoneEffect } from "./halftone";
|
|
5
|
+
export { JPEGGlitchEffect } from "./jpeg-glitch";
|
|
4
6
|
export { ParticleEffect } from "./particle";
|
|
5
7
|
export { ParticleExplodeEffect } from "./particle-explode";
|
|
6
8
|
export { PixelateEffect } from "./pixelate";
|
|
9
|
+
export { PixelSortEffect, } from "./pixelsort";
|
|
7
10
|
export { ScanlineEffect } from "./scanline";
|
|
8
11
|
export { VoronoiEffect } from "./voronoi";
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEH,cAAc,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEH,eAAe,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|