@tradalab/mediakit 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NOTICE +22 -0
- package/dist/chunk-TBMYRKXR.js +278 -0
- package/dist/chunk-TBMYRKXR.js.map +1 -0
- package/dist/index.d.ts +65 -5
- package/dist/index.js +1243 -32
- package/dist/index.js.map +1 -1
- package/dist/lut.d.ts +38 -0
- package/dist/lut.js +176 -0
- package/dist/lut.js.map +1 -0
- package/dist/mediakit.wasm +0 -0
- package/dist/recipe.d.ts +131 -1
- package/dist/recipe.js +13 -1
- package/dist/whiten_pink.png +0 -0
- package/dist/worker.js +196 -22
- package/dist/worker.js.map +1 -1
- package/package.json +6 -2
- package/dist/chunk-V47SDU4L.js +0 -128
- package/dist/chunk-V47SDU4L.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EFFECTS_SCHEMA,
|
|
2
3
|
NO_EFFECTS,
|
|
3
4
|
TOUCH_UP,
|
|
4
5
|
coreRecipe,
|
|
5
6
|
needsFace,
|
|
6
7
|
needsMask,
|
|
7
8
|
needsSegmentation,
|
|
9
|
+
needsSkinClasses,
|
|
10
|
+
normalizeEffects,
|
|
8
11
|
touchUp,
|
|
9
12
|
touchUpAmount
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TBMYRKXR.js";
|
|
11
14
|
import {
|
|
12
15
|
BLEND_MODES,
|
|
13
16
|
TRANSITIONS,
|
|
@@ -20,12 +23,15 @@ import {
|
|
|
20
23
|
// src/segmenter.ts
|
|
21
24
|
import { FilesetResolver, ImageSegmenter } from "@mediapipe/tasks-vision";
|
|
22
25
|
var WASM_DIR = "/mediakit/mp";
|
|
23
|
-
var MODEL_URL =
|
|
24
|
-
|
|
26
|
+
var MODEL_URL = {
|
|
27
|
+
person: "/mediakit/selfie_segmenter.tflite",
|
|
28
|
+
classes: "/mediakit/selfie_multiclass_256x256.tflite"
|
|
29
|
+
};
|
|
30
|
+
async function createSegmenter(canvas, model = "person") {
|
|
25
31
|
const fileset = await FilesetResolver.forVisionTasks(WASM_DIR);
|
|
26
32
|
const segmenter = await ImageSegmenter.createFromOptions(fileset, {
|
|
27
33
|
baseOptions: {
|
|
28
|
-
modelAssetPath: MODEL_URL,
|
|
34
|
+
modelAssetPath: MODEL_URL[model],
|
|
29
35
|
// MediaPipe's GPU delegate runs on WebGL2, which Chrome, Safari and Firefox all
|
|
30
36
|
// have. That is why mediakit picked MediaPipe over ONNX Runtime Web at P1: ORT's
|
|
31
37
|
// fast path is WebGPU, which Firefox only has on Windows.
|
|
@@ -205,6 +211,10 @@ var Engine = class _Engine {
|
|
|
205
211
|
backgroundPath = null;
|
|
206
212
|
/** The LUT the core holds, by path, so a slider drag does not decode it again. */
|
|
207
213
|
lutPath = "";
|
|
214
|
+
/** The makeup texture the core holds, by path - see setRecipe. */
|
|
215
|
+
makeupPath = "";
|
|
216
|
+
/** Whether the core holds the pink whitening table. */
|
|
217
|
+
skinLutState = "none";
|
|
208
218
|
closed = false;
|
|
209
219
|
/**
|
|
210
220
|
* The segmenter loads LAZILY - only once a recipe actually needs a person mask.
|
|
@@ -214,6 +224,11 @@ var Engine = class _Engine {
|
|
|
214
224
|
*/
|
|
215
225
|
segmenter = null;
|
|
216
226
|
segmenterLoading = null;
|
|
227
|
+
/** The multiclass segmenter, for recipes that tell skin from clothes (`needsSkinClasses`). */
|
|
228
|
+
classSegmenter = null;
|
|
229
|
+
classLoading = null;
|
|
230
|
+
/** The segmenter whose result this frame borrowed, to give it back after process(). */
|
|
231
|
+
used = null;
|
|
217
232
|
/**
|
|
218
233
|
* The landmark detector, also lazy and independent of the segmenter.
|
|
219
234
|
*
|
|
@@ -236,11 +251,11 @@ var Engine = class _Engine {
|
|
|
236
251
|
this.core = core;
|
|
237
252
|
}
|
|
238
253
|
/** Main thread: makes its own canvas. A worker calls `on` with an OffscreenCanvas. */
|
|
239
|
-
static async create(width, height, filter, effects = NO_EFFECTS) {
|
|
254
|
+
static async create(width, height, filter, effects = NO_EFFECTS, alpha = false) {
|
|
240
255
|
const canvas = document.createElement("canvas");
|
|
241
256
|
canvas.width = width;
|
|
242
257
|
canvas.height = height;
|
|
243
|
-
return _Engine.on(canvas, filter, effects);
|
|
258
|
+
return _Engine.on(canvas, filter, effects, void 0, alpha);
|
|
244
259
|
}
|
|
245
260
|
/**
|
|
246
261
|
* `background`: see {@link Engine.setRecipe}. `alpha` keeps the output's alpha channel, which
|
|
@@ -279,6 +294,9 @@ var Engine = class _Engine {
|
|
|
279
294
|
throw err;
|
|
280
295
|
}
|
|
281
296
|
}
|
|
297
|
+
get loading() {
|
|
298
|
+
return this.segmenterLoading !== null || this.classLoading !== null || this.faceLoading !== null;
|
|
299
|
+
}
|
|
282
300
|
get outputCanvas() {
|
|
283
301
|
return this.canvas;
|
|
284
302
|
}
|
|
@@ -324,8 +342,44 @@ var Engine = class _Engine {
|
|
|
324
342
|
}
|
|
325
343
|
this.lutPath = effects.lut;
|
|
326
344
|
}
|
|
345
|
+
if (effects.whitenStyle === "pink" && this.skinLutState === "none") {
|
|
346
|
+
this.skinLutState = "loading";
|
|
347
|
+
decodeImage("/mediakit/whiten_pink.png", { colorSpaceConversion: "none", premultiplyAlpha: "none" }).then((bmp) => {
|
|
348
|
+
if (this.closed) {
|
|
349
|
+
bmp.close();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.core.setSkinLut(bmp);
|
|
353
|
+
bmp.close();
|
|
354
|
+
this.skinLutState = "ready";
|
|
355
|
+
}).catch((err) => {
|
|
356
|
+
console.error("mediakit: pink whitening table failed to load", err);
|
|
357
|
+
this.skinLutState = "failed";
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
const makeupTexture = effects.makeupTexture ?? "";
|
|
361
|
+
if (makeupTexture !== this.makeupPath) {
|
|
362
|
+
if (makeupTexture) {
|
|
363
|
+
let bmp = null;
|
|
364
|
+
try {
|
|
365
|
+
bmp = await decodeImage(makeupTexture, { premultiplyAlpha: "none" });
|
|
366
|
+
} catch (e) {
|
|
367
|
+
console.error("mediakit: makeup texture failed to load", e);
|
|
368
|
+
}
|
|
369
|
+
if (this.closed || this.filter !== filter || this.effects !== effects) {
|
|
370
|
+
bmp?.close();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.core.setMakeup(bmp);
|
|
374
|
+
bmp?.close();
|
|
375
|
+
} else {
|
|
376
|
+
this.core.setMakeup(null);
|
|
377
|
+
}
|
|
378
|
+
this.makeupPath = makeupTexture;
|
|
379
|
+
}
|
|
327
380
|
this.core.setRecipe(coreRecipe(filter, effects));
|
|
328
381
|
if (needsSegmentation(filter, effects)) void this.ensureSegmenter();
|
|
382
|
+
if (needsSkinClasses(filter, effects)) void this.ensureClassSegmenter();
|
|
329
383
|
if (needsFace(effects)) void this.ensureFace();
|
|
330
384
|
}
|
|
331
385
|
ensureFace() {
|
|
@@ -347,6 +401,22 @@ var Engine = class _Engine {
|
|
|
347
401
|
});
|
|
348
402
|
return this.faceLoading;
|
|
349
403
|
}
|
|
404
|
+
ensureClassSegmenter() {
|
|
405
|
+
if (this.classSegmenter || this.closed) return Promise.resolve();
|
|
406
|
+
if (this.classLoading) return this.classLoading;
|
|
407
|
+
this.classLoading = createSegmenter(this.canvas, "classes").then((s) => {
|
|
408
|
+
if (this.closed) {
|
|
409
|
+
s.close();
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
this.classSegmenter = s;
|
|
413
|
+
}).catch((e) => {
|
|
414
|
+
console.error("mediakit: multiclass segmenter failed to load", e);
|
|
415
|
+
}).finally(() => {
|
|
416
|
+
this.classLoading = null;
|
|
417
|
+
});
|
|
418
|
+
return this.classLoading;
|
|
419
|
+
}
|
|
350
420
|
ensureSegmenter() {
|
|
351
421
|
if (this.segmenter || this.closed) return Promise.resolve();
|
|
352
422
|
if (this.segmenterLoading) return this.segmenterLoading;
|
|
@@ -382,14 +452,20 @@ var Engine = class _Engine {
|
|
|
382
452
|
const [lo, hi] = splitMicros(timestampUs);
|
|
383
453
|
const needSeg = this.core.decide(lo, hi, this.prevTotalMs, this.prevSegMs) === 1;
|
|
384
454
|
let mask = null;
|
|
455
|
+
let maskKind = 0;
|
|
385
456
|
let segMs = 0;
|
|
457
|
+
this.used = null;
|
|
386
458
|
if (needSeg) {
|
|
387
|
-
|
|
459
|
+
const classes = this.classSegmenter !== null && needsSkinClasses(this.filter, this.effects);
|
|
460
|
+
const seg = classes ? this.classSegmenter : this.segmenter;
|
|
461
|
+
if (!seg) {
|
|
388
462
|
void this.ensureSegmenter();
|
|
389
463
|
} else {
|
|
390
464
|
const s0 = performance.now();
|
|
391
|
-
mask =
|
|
465
|
+
mask = seg.segment(source, timestampUs / 1e3);
|
|
392
466
|
segMs = performance.now() - s0;
|
|
467
|
+
this.used = seg;
|
|
468
|
+
maskKind = classes ? 1 : 0;
|
|
393
469
|
}
|
|
394
470
|
}
|
|
395
471
|
if (this.core.decideFace() === 1) {
|
|
@@ -400,8 +476,9 @@ var Engine = class _Engine {
|
|
|
400
476
|
this.core.setFace(lo, hi, n);
|
|
401
477
|
}
|
|
402
478
|
}
|
|
403
|
-
const glCalls = this.core.process(source, mask, this.background);
|
|
404
|
-
if (mask) this.
|
|
479
|
+
const glCalls = this.core.process(source, mask, this.background, maskKind);
|
|
480
|
+
if (mask) this.used?.release();
|
|
481
|
+
this.used = null;
|
|
405
482
|
this.prevSegMs = segMs;
|
|
406
483
|
this.prevTotalMs = performance.now() - t0;
|
|
407
484
|
const s = this.core.stats();
|
|
@@ -433,14 +510,16 @@ var Engine = class _Engine {
|
|
|
433
510
|
* for the governor and the graph to decide with. See the ToMicros comment in
|
|
434
511
|
* `core/clock.go`.
|
|
435
512
|
*/
|
|
436
|
-
capture(timestampUs) {
|
|
437
|
-
return new VideoFrame(this.canvas, { timestamp: timestampUs, alpha: "discard" });
|
|
513
|
+
capture(timestampUs, keepAlpha = false) {
|
|
514
|
+
return new VideoFrame(this.canvas, { timestamp: timestampUs, alpha: keepAlpha ? "keep" : "discard" });
|
|
438
515
|
}
|
|
439
516
|
close() {
|
|
440
517
|
if (this.closed) return;
|
|
441
518
|
this.closed = true;
|
|
442
519
|
this.segmenter?.close();
|
|
443
520
|
this.segmenter = null;
|
|
521
|
+
this.classSegmenter?.close();
|
|
522
|
+
this.classSegmenter = null;
|
|
444
523
|
this.face?.close();
|
|
445
524
|
this.face = null;
|
|
446
525
|
this.lmBuf = null;
|
|
@@ -449,6 +528,7 @@ var Engine = class _Engine {
|
|
|
449
528
|
this.background = null;
|
|
450
529
|
this.backgroundPath = null;
|
|
451
530
|
this.lutPath = "";
|
|
531
|
+
this.makeupPath = "";
|
|
452
532
|
this.gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
453
533
|
}
|
|
454
534
|
};
|
|
@@ -504,6 +584,9 @@ async function coverCrop(src, w, h) {
|
|
|
504
584
|
|
|
505
585
|
// src/pipeline.ts
|
|
506
586
|
var WORKER_READY_MS = 8e3;
|
|
587
|
+
var STALL_MS = 2e3;
|
|
588
|
+
var LOADING_STALL_MS = 2e4;
|
|
589
|
+
var WORKER_DEAD_MS = 8e3;
|
|
507
590
|
function hasInsertableStreams() {
|
|
508
591
|
return typeof window !== "undefined" && "MediaStreamTrackProcessor" in window && "MediaStreamTrackGenerator" in window;
|
|
509
592
|
}
|
|
@@ -518,6 +601,19 @@ var VideoPipeline = class {
|
|
|
518
601
|
processedTrack;
|
|
519
602
|
filter;
|
|
520
603
|
effects;
|
|
604
|
+
opts;
|
|
605
|
+
// Health: a beat per frame out.
|
|
606
|
+
source = null;
|
|
607
|
+
size = { width: 1280, height: 720, fps: 30 };
|
|
608
|
+
lastBeat = 0;
|
|
609
|
+
frames = 0;
|
|
610
|
+
stalled = false;
|
|
611
|
+
watchdog = null;
|
|
612
|
+
movedOff = false;
|
|
613
|
+
/** What the worker last said about loading detectors. */
|
|
614
|
+
workerLoading = false;
|
|
615
|
+
// Frames handed out alongside the track - see subscribeFrames.
|
|
616
|
+
frameSubs = /* @__PURE__ */ new Set();
|
|
521
617
|
engine = null;
|
|
522
618
|
transport = "insertable";
|
|
523
619
|
// insertable path
|
|
@@ -531,9 +627,93 @@ var VideoPipeline = class {
|
|
|
531
627
|
video = null;
|
|
532
628
|
rvfcHandle = 0;
|
|
533
629
|
stopped = false;
|
|
534
|
-
constructor(filter, effects = NO_EFFECTS) {
|
|
630
|
+
constructor(filter, effects = NO_EFFECTS, opts = {}) {
|
|
535
631
|
this.filter = filter;
|
|
536
632
|
this.effects = effects;
|
|
633
|
+
this.opts = opts;
|
|
634
|
+
}
|
|
635
|
+
/** Whether frames are coming out, and how long since the last one. */
|
|
636
|
+
get health() {
|
|
637
|
+
return {
|
|
638
|
+
transport: this.transport,
|
|
639
|
+
frames: this.frames,
|
|
640
|
+
sinceMs: this.lastBeat ? performance.now() - this.lastBeat : 0,
|
|
641
|
+
stalled: this.stalled
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
/** Every processed frame. */
|
|
645
|
+
subscribeFrames(cb) {
|
|
646
|
+
this.frameSubs.add(cb);
|
|
647
|
+
if (this.frameSubs.size === 1) this.send({ t: "frames", on: true });
|
|
648
|
+
return () => {
|
|
649
|
+
this.frameSubs.delete(cb);
|
|
650
|
+
if (this.frameSubs.size === 0) this.send({ t: "frames", on: false });
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
deliver(frame) {
|
|
654
|
+
const subs = [...this.frameSubs];
|
|
655
|
+
if (subs.length === 0) {
|
|
656
|
+
frame.close();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
subs.forEach((cb, i) => {
|
|
660
|
+
try {
|
|
661
|
+
cb(i === subs.length - 1 ? frame : frame.clone());
|
|
662
|
+
} catch (e) {
|
|
663
|
+
console.error("mediakit: frame subscriber threw", e);
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
beat() {
|
|
668
|
+
this.lastBeat = performance.now();
|
|
669
|
+
this.frames++;
|
|
670
|
+
this.stalled = false;
|
|
671
|
+
}
|
|
672
|
+
startWatchdog() {
|
|
673
|
+
this.stopWatchdog();
|
|
674
|
+
this.lastBeat = performance.now();
|
|
675
|
+
this.watchdog = setInterval(() => {
|
|
676
|
+
if (this.stopped || !this.source) return;
|
|
677
|
+
if (this.source.readyState !== "live" || this.source.muted) {
|
|
678
|
+
this.lastBeat = performance.now();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (this.transport === "canvas" && typeof document !== "undefined" && document.visibilityState !== "visible") {
|
|
682
|
+
this.lastBeat = performance.now();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
const since = performance.now() - this.lastBeat;
|
|
686
|
+
const loading = this.transport === "worker" ? this.workerLoading : this.engine?.loading ?? false;
|
|
687
|
+
const transport = this.transport;
|
|
688
|
+
if (since >= (loading ? LOADING_STALL_MS : STALL_MS) && !this.stalled) {
|
|
689
|
+
this.stalled = true;
|
|
690
|
+
console.warn(`mediakit: no frame out for ${Math.round(since)}ms on the ${transport} transport`);
|
|
691
|
+
this.opts.onStall?.({ transport, sinceMs: since });
|
|
692
|
+
}
|
|
693
|
+
if (transport === "worker" && since >= (loading ? LOADING_STALL_MS : WORKER_DEAD_MS)) {
|
|
694
|
+
void this.moveOffWorker("silent");
|
|
695
|
+
}
|
|
696
|
+
}, 1e3);
|
|
697
|
+
}
|
|
698
|
+
stopWatchdog() {
|
|
699
|
+
if (this.watchdog) clearInterval(this.watchdog);
|
|
700
|
+
this.watchdog = null;
|
|
701
|
+
}
|
|
702
|
+
/** The worker failed or stalled AFTER the host published its track. */
|
|
703
|
+
async moveOffWorker(reason) {
|
|
704
|
+
if (this.movedOff || this.stopped || !this.source) return;
|
|
705
|
+
this.movedOff = true;
|
|
706
|
+
console.warn(`mediakit: worker ${reason} after start, moving to the main thread`);
|
|
707
|
+
const previous = this.processedTrack;
|
|
708
|
+
this.teardownWorker();
|
|
709
|
+
try {
|
|
710
|
+
await this.startMain(this.source);
|
|
711
|
+
} catch (e) {
|
|
712
|
+
console.error("mediakit: main-thread fallback failed", e);
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
previous?.stop();
|
|
716
|
+
if (this.processedTrack) this.opts.onTrackReplaced?.(this.processedTrack, previous);
|
|
537
717
|
}
|
|
538
718
|
get stats() {
|
|
539
719
|
return this.transport === "worker" ? this.workerStats : this.engine?.last ?? null;
|
|
@@ -547,6 +727,10 @@ var VideoPipeline = class {
|
|
|
547
727
|
const width = settings.width ?? 1280;
|
|
548
728
|
const height = settings.height ?? 720;
|
|
549
729
|
this.stopped = false;
|
|
730
|
+
this.source = source;
|
|
731
|
+
this.size = { width, height, fps: settings.frameRate ?? 30 };
|
|
732
|
+
this.frames = 0;
|
|
733
|
+
this.startWatchdog();
|
|
550
734
|
if (hasInsertableStreams() && typeof Worker !== "undefined" && typeof OffscreenCanvas !== "undefined") {
|
|
551
735
|
try {
|
|
552
736
|
await this.startWorker(source, width, height, await this.backgroundForWorker(this.filter));
|
|
@@ -556,13 +740,29 @@ var VideoPipeline = class {
|
|
|
556
740
|
this.teardownWorker();
|
|
557
741
|
console.warn("mediakit: worker unusable, falling back to the main thread", e);
|
|
558
742
|
}
|
|
743
|
+
} else if (typeof Worker !== "undefined" && typeof OffscreenCanvas !== "undefined") {
|
|
744
|
+
try {
|
|
745
|
+
await this.startWorkerWithTrack(source, width, height, await this.backgroundForWorker(this.filter));
|
|
746
|
+
this.transport = "worker";
|
|
747
|
+
return;
|
|
748
|
+
} catch (e) {
|
|
749
|
+
this.teardownWorker();
|
|
750
|
+
console.warn("mediakit: no worker transport in this browser, staying on the main thread", e);
|
|
751
|
+
}
|
|
559
752
|
}
|
|
560
|
-
|
|
753
|
+
await this.startMain(source);
|
|
754
|
+
}
|
|
755
|
+
async startMain(source) {
|
|
756
|
+
const { width, height, fps } = this.size;
|
|
757
|
+
this.engine = await Engine.create(width, height, this.filter, this.effects, this.opts.alpha ?? false);
|
|
561
758
|
this.transport = hasInsertableStreams() ? "insertable" : "canvas";
|
|
759
|
+
this.frames = 0;
|
|
760
|
+
this.lastBeat = performance.now();
|
|
761
|
+
this.stalled = false;
|
|
562
762
|
if (this.transport === "insertable") {
|
|
563
763
|
this.startInsertable(source);
|
|
564
764
|
} else {
|
|
565
|
-
await this.startCanvas(source,
|
|
765
|
+
await this.startCanvas(source, fps);
|
|
566
766
|
}
|
|
567
767
|
}
|
|
568
768
|
/** Swap the background in place - no pipeline rebuild, so the picture does not flash. */
|
|
@@ -586,6 +786,8 @@ var VideoPipeline = class {
|
|
|
586
786
|
}
|
|
587
787
|
async stop() {
|
|
588
788
|
this.stopped = true;
|
|
789
|
+
this.stopWatchdog();
|
|
790
|
+
this.source = null;
|
|
589
791
|
this.abort?.abort();
|
|
590
792
|
this.abort = null;
|
|
591
793
|
if (this.rvfcHandle && this.video) {
|
|
@@ -625,6 +827,7 @@ var VideoPipeline = class {
|
|
|
625
827
|
this.worker.terminate();
|
|
626
828
|
this.worker = null;
|
|
627
829
|
this.workerStats = null;
|
|
830
|
+
this.workerLoading = false;
|
|
628
831
|
this.workerBackgroundPath = null;
|
|
629
832
|
}
|
|
630
833
|
/**
|
|
@@ -660,6 +863,53 @@ var VideoPipeline = class {
|
|
|
660
863
|
kind: "video",
|
|
661
864
|
signalTarget: source
|
|
662
865
|
});
|
|
866
|
+
return this.attachWorker(
|
|
867
|
+
(ready) => {
|
|
868
|
+
this.processedTrack = ready.track ?? generator;
|
|
869
|
+
},
|
|
870
|
+
() => generator.stop(),
|
|
871
|
+
() => this.send(
|
|
872
|
+
{
|
|
873
|
+
t: "start",
|
|
874
|
+
readable: processor.readable,
|
|
875
|
+
writable: generator.writable,
|
|
876
|
+
width,
|
|
877
|
+
height,
|
|
878
|
+
filter: this.filter,
|
|
879
|
+
effects: this.effects,
|
|
880
|
+
background,
|
|
881
|
+
alpha: this.opts.alpha
|
|
882
|
+
},
|
|
883
|
+
background ? [processor.readable, generator.writable, background] : [processor.readable, generator.writable]
|
|
884
|
+
)
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
/** Safari's dialect (see `startTrack` in worker/entry.ts). */
|
|
888
|
+
startWorkerWithTrack(source, width, height, background) {
|
|
889
|
+
const clone = source.clone();
|
|
890
|
+
return this.attachWorker(
|
|
891
|
+
(ready) => {
|
|
892
|
+
if (!ready.track) throw new Error("mediakit: the worker sent no track");
|
|
893
|
+
this.processedTrack = ready.track;
|
|
894
|
+
},
|
|
895
|
+
() => clone.stop(),
|
|
896
|
+
() => this.send(
|
|
897
|
+
{
|
|
898
|
+
t: "startTrack",
|
|
899
|
+
track: clone,
|
|
900
|
+
width,
|
|
901
|
+
height,
|
|
902
|
+
filter: this.filter,
|
|
903
|
+
effects: this.effects,
|
|
904
|
+
background,
|
|
905
|
+
alpha: this.opts.alpha
|
|
906
|
+
},
|
|
907
|
+
background ? [clone, background] : [clone]
|
|
908
|
+
)
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
/** Starts the worker and waits for its "ready". */
|
|
912
|
+
attachWorker(onReady, cleanup, post) {
|
|
663
913
|
const worker = new Worker("/mediakit/worker.js");
|
|
664
914
|
this.worker = worker;
|
|
665
915
|
return new Promise((resolve, reject) => {
|
|
@@ -668,47 +918,57 @@ var VideoPipeline = class {
|
|
|
668
918
|
if (settled) return;
|
|
669
919
|
settled = true;
|
|
670
920
|
clearTimeout(timer);
|
|
671
|
-
|
|
921
|
+
cleanup();
|
|
672
922
|
reject(err);
|
|
673
923
|
};
|
|
674
924
|
const timer = setTimeout(
|
|
675
925
|
() => fail(new Error(`mediakit: worker silent for more than ${WORKER_READY_MS}ms`)),
|
|
676
926
|
WORKER_READY_MS
|
|
677
927
|
);
|
|
678
|
-
worker.onerror = (e) =>
|
|
928
|
+
worker.onerror = (e) => {
|
|
929
|
+
if (settled) {
|
|
930
|
+
void this.moveOffWorker(e.message || "crashed");
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
fail(new Error(e.message || "mediakit: worker failed to load"));
|
|
934
|
+
};
|
|
679
935
|
worker.onmessage = (e) => {
|
|
680
936
|
const m = e.data;
|
|
681
937
|
if (m.t === "stats") {
|
|
682
938
|
this.workerStats = m.stats;
|
|
939
|
+
this.lastBeat = performance.now();
|
|
940
|
+
if (m.frames >= 0) this.frames = m.frames;
|
|
941
|
+
this.workerLoading = m.loading;
|
|
942
|
+
this.stalled = false;
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
if (m.t === "frame") {
|
|
946
|
+
this.deliver(m.frame);
|
|
683
947
|
return;
|
|
684
948
|
}
|
|
685
949
|
if (m.t === "error") {
|
|
686
950
|
if (settled) {
|
|
687
951
|
console.error("mediakit: worker failed after start", m.message);
|
|
952
|
+
void this.moveOffWorker("failed");
|
|
688
953
|
return;
|
|
689
954
|
}
|
|
690
955
|
fail(new Error(m.message));
|
|
691
956
|
return;
|
|
692
957
|
}
|
|
958
|
+
this.workerLoading = m.loading;
|
|
959
|
+
try {
|
|
960
|
+
onReady(m);
|
|
961
|
+
} catch (err) {
|
|
962
|
+
fail(err instanceof Error ? err : new Error(String(err)));
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
693
965
|
settled = true;
|
|
694
966
|
clearTimeout(timer);
|
|
695
|
-
this.
|
|
967
|
+
if (this.frameSubs.size > 0) this.send({ t: "frames", on: true });
|
|
696
968
|
resolve();
|
|
697
969
|
};
|
|
698
970
|
try {
|
|
699
|
-
|
|
700
|
-
{
|
|
701
|
-
t: "start",
|
|
702
|
-
readable: processor.readable,
|
|
703
|
-
writable: generator.writable,
|
|
704
|
-
width,
|
|
705
|
-
height,
|
|
706
|
-
filter: this.filter,
|
|
707
|
-
effects: this.effects,
|
|
708
|
-
background
|
|
709
|
-
},
|
|
710
|
-
background ? [processor.readable, generator.writable, background] : [processor.readable, generator.writable]
|
|
711
|
-
);
|
|
971
|
+
post();
|
|
712
972
|
} catch (err) {
|
|
713
973
|
fail(err instanceof Error ? err : new Error(String(err)));
|
|
714
974
|
}
|
|
@@ -726,10 +986,13 @@ var VideoPipeline = class {
|
|
|
726
986
|
});
|
|
727
987
|
const transform = new TransformStream({
|
|
728
988
|
transform: (frame, controller) => {
|
|
989
|
+
this.beat();
|
|
729
990
|
try {
|
|
730
991
|
if (engine.render(frame, frame.timestamp)) {
|
|
731
992
|
controller.enqueue(engine.capture(frame.timestamp));
|
|
993
|
+
if (this.frameSubs.size > 0) this.deliver(engine.capture(frame.timestamp, true));
|
|
732
994
|
} else {
|
|
995
|
+
if (this.frameSubs.size > 0) this.deliver(frame.clone());
|
|
733
996
|
controller.enqueue(frame);
|
|
734
997
|
return;
|
|
735
998
|
}
|
|
@@ -771,8 +1034,13 @@ var VideoPipeline = class {
|
|
|
771
1034
|
this.processedTrack = stream.getVideoTracks()[0];
|
|
772
1035
|
const pump = (_now, meta) => {
|
|
773
1036
|
if (this.stopped || !this.engine) return;
|
|
1037
|
+
this.beat();
|
|
774
1038
|
try {
|
|
775
|
-
|
|
1039
|
+
const ts = Math.round(meta.mediaTime * 1e6);
|
|
1040
|
+
const drew = this.engine.render(video, ts);
|
|
1041
|
+
if (this.frameSubs.size > 0) {
|
|
1042
|
+
this.deliver(drew ? this.engine.capture(ts, true) : new VideoFrame(video, { timestamp: ts }));
|
|
1043
|
+
}
|
|
776
1044
|
} catch (e) {
|
|
777
1045
|
console.error("mediakit: frame processing failed", e);
|
|
778
1046
|
}
|
|
@@ -1189,9 +1457,951 @@ function css(c) {
|
|
|
1189
1457
|
const [r, g, b, a] = parseColor(c);
|
|
1190
1458
|
return `rgba(${Math.round(r * 255)},${Math.round(g * 255)},${Math.round(b * 255)},${a})`;
|
|
1191
1459
|
}
|
|
1460
|
+
|
|
1461
|
+
// src/facemesh.ts
|
|
1462
|
+
var FACE_UV = new Float32Array([
|
|
1463
|
+
0.49998,
|
|
1464
|
+
0.65253,
|
|
1465
|
+
0.50003,
|
|
1466
|
+
0.54749,
|
|
1467
|
+
0.49997,
|
|
1468
|
+
0.60237,
|
|
1469
|
+
0.48211,
|
|
1470
|
+
0.47198,
|
|
1471
|
+
0.50015,
|
|
1472
|
+
0.52716,
|
|
1473
|
+
0.49991,
|
|
1474
|
+
0.49825,
|
|
1475
|
+
0.49952,
|
|
1476
|
+
0.40106,
|
|
1477
|
+
0.28971,
|
|
1478
|
+
0.38076,
|
|
1479
|
+
0.49995,
|
|
1480
|
+
0.3124,
|
|
1481
|
+
0.49999,
|
|
1482
|
+
0.26992,
|
|
1483
|
+
0.50002,
|
|
1484
|
+
0.10705,
|
|
1485
|
+
0.50002,
|
|
1486
|
+
0.66623,
|
|
1487
|
+
0.50002,
|
|
1488
|
+
0.67922,
|
|
1489
|
+
0.50002,
|
|
1490
|
+
0.69235,
|
|
1491
|
+
0.49998,
|
|
1492
|
+
0.69528,
|
|
1493
|
+
0.49998,
|
|
1494
|
+
0.70593,
|
|
1495
|
+
0.49998,
|
|
1496
|
+
0.71938,
|
|
1497
|
+
0.49998,
|
|
1498
|
+
0.73702,
|
|
1499
|
+
0.49997,
|
|
1500
|
+
0.78137,
|
|
1501
|
+
0.49982,
|
|
1502
|
+
0.56298,
|
|
1503
|
+
0.47377,
|
|
1504
|
+
0.57391,
|
|
1505
|
+
0.10491,
|
|
1506
|
+
0.25414,
|
|
1507
|
+
0.36593,
|
|
1508
|
+
0.40958,
|
|
1509
|
+
0.33876,
|
|
1510
|
+
0.41302,
|
|
1511
|
+
0.31112,
|
|
1512
|
+
0.40946,
|
|
1513
|
+
0.27466,
|
|
1514
|
+
0.38913,
|
|
1515
|
+
0.39336,
|
|
1516
|
+
0.40371,
|
|
1517
|
+
0.34523,
|
|
1518
|
+
0.34401,
|
|
1519
|
+
0.37009,
|
|
1520
|
+
0.34608,
|
|
1521
|
+
0.31932,
|
|
1522
|
+
0.34727,
|
|
1523
|
+
0.2979,
|
|
1524
|
+
0.35359,
|
|
1525
|
+
0.24779,
|
|
1526
|
+
0.41081,
|
|
1527
|
+
0.39689,
|
|
1528
|
+
0.84276,
|
|
1529
|
+
0.2801,
|
|
1530
|
+
0.3756,
|
|
1531
|
+
0.10631,
|
|
1532
|
+
0.39996,
|
|
1533
|
+
0.20993,
|
|
1534
|
+
0.39135,
|
|
1535
|
+
0.35581,
|
|
1536
|
+
0.53441,
|
|
1537
|
+
0.47175,
|
|
1538
|
+
0.6504,
|
|
1539
|
+
0.47415,
|
|
1540
|
+
0.68019,
|
|
1541
|
+
0.43978,
|
|
1542
|
+
0.65723,
|
|
1543
|
+
0.41462,
|
|
1544
|
+
0.66654,
|
|
1545
|
+
0.45037,
|
|
1546
|
+
0.68086,
|
|
1547
|
+
0.42877,
|
|
1548
|
+
0.68269,
|
|
1549
|
+
0.37497,
|
|
1550
|
+
0.72781,
|
|
1551
|
+
0.48672,
|
|
1552
|
+
0.54763,
|
|
1553
|
+
0.4853,
|
|
1554
|
+
0.5274,
|
|
1555
|
+
0.25777,
|
|
1556
|
+
0.31449,
|
|
1557
|
+
0.40122,
|
|
1558
|
+
0.45517,
|
|
1559
|
+
0.42982,
|
|
1560
|
+
0.54862,
|
|
1561
|
+
0.42135,
|
|
1562
|
+
0.53374,
|
|
1563
|
+
0.2769,
|
|
1564
|
+
0.53206,
|
|
1565
|
+
0.48337,
|
|
1566
|
+
0.49959,
|
|
1567
|
+
0.33721,
|
|
1568
|
+
0.28288,
|
|
1569
|
+
0.29639,
|
|
1570
|
+
0.29324,
|
|
1571
|
+
0.1693,
|
|
1572
|
+
0.19381,
|
|
1573
|
+
0.44758,
|
|
1574
|
+
0.30261,
|
|
1575
|
+
0.39239,
|
|
1576
|
+
0.35389,
|
|
1577
|
+
0.35449,
|
|
1578
|
+
0.69678,
|
|
1579
|
+
0.06731,
|
|
1580
|
+
0.73011,
|
|
1581
|
+
0.44274,
|
|
1582
|
+
0.57283,
|
|
1583
|
+
0.4571,
|
|
1584
|
+
0.58479,
|
|
1585
|
+
0.38197,
|
|
1586
|
+
0.69471,
|
|
1587
|
+
0.39239,
|
|
1588
|
+
0.6942,
|
|
1589
|
+
0.27708,
|
|
1590
|
+
0.27193,
|
|
1591
|
+
0.42255,
|
|
1592
|
+
0.56323,
|
|
1593
|
+
0.38592,
|
|
1594
|
+
0.28136,
|
|
1595
|
+
0.3831,
|
|
1596
|
+
0.25584,
|
|
1597
|
+
0.33143,
|
|
1598
|
+
0.11971,
|
|
1599
|
+
0.22992,
|
|
1600
|
+
0.232,
|
|
1601
|
+
0.3645,
|
|
1602
|
+
0.18911,
|
|
1603
|
+
0.22962,
|
|
1604
|
+
0.29954,
|
|
1605
|
+
0.17329,
|
|
1606
|
+
0.27875,
|
|
1607
|
+
0.47288,
|
|
1608
|
+
0.6662,
|
|
1609
|
+
0.44683,
|
|
1610
|
+
0.66853,
|
|
1611
|
+
0.42276,
|
|
1612
|
+
0.67389,
|
|
1613
|
+
0.44531,
|
|
1614
|
+
0.58007,
|
|
1615
|
+
0.3881,
|
|
1616
|
+
0.69396,
|
|
1617
|
+
0.40304,
|
|
1618
|
+
0.70654,
|
|
1619
|
+
0.40363,
|
|
1620
|
+
0.69395,
|
|
1621
|
+
0.46004,
|
|
1622
|
+
0.55714,
|
|
1623
|
+
0.43116,
|
|
1624
|
+
0.69237,
|
|
1625
|
+
0.45218,
|
|
1626
|
+
0.69237,
|
|
1627
|
+
0.47539,
|
|
1628
|
+
0.69237,
|
|
1629
|
+
0.46583,
|
|
1630
|
+
0.77919,
|
|
1631
|
+
0.47233,
|
|
1632
|
+
0.73623,
|
|
1633
|
+
0.47309,
|
|
1634
|
+
0.71786,
|
|
1635
|
+
0.47312,
|
|
1636
|
+
0.70463,
|
|
1637
|
+
0.47303,
|
|
1638
|
+
0.69528,
|
|
1639
|
+
0.42794,
|
|
1640
|
+
0.69528,
|
|
1641
|
+
0.42648,
|
|
1642
|
+
0.70354,
|
|
1643
|
+
0.42316,
|
|
1644
|
+
0.71185,
|
|
1645
|
+
0.41831,
|
|
1646
|
+
0.72006,
|
|
1647
|
+
0.3901,
|
|
1648
|
+
0.63957,
|
|
1649
|
+
0.01395,
|
|
1650
|
+
0.56003,
|
|
1651
|
+
0.49991,
|
|
1652
|
+
0.58015,
|
|
1653
|
+
0.4132,
|
|
1654
|
+
0.6954,
|
|
1655
|
+
0.40963,
|
|
1656
|
+
0.70182,
|
|
1657
|
+
0.46808,
|
|
1658
|
+
0.60153,
|
|
1659
|
+
0.42273,
|
|
1660
|
+
0.58598,
|
|
1661
|
+
0.46308,
|
|
1662
|
+
0.59378,
|
|
1663
|
+
0.37212,
|
|
1664
|
+
0.47341,
|
|
1665
|
+
0.33456,
|
|
1666
|
+
0.49607,
|
|
1667
|
+
0.41167,
|
|
1668
|
+
0.54696,
|
|
1669
|
+
0.24218,
|
|
1670
|
+
0.14768,
|
|
1671
|
+
0.29078,
|
|
1672
|
+
0.20145,
|
|
1673
|
+
0.32734,
|
|
1674
|
+
0.25653,
|
|
1675
|
+
0.39951,
|
|
1676
|
+
0.74892,
|
|
1677
|
+
0.44173,
|
|
1678
|
+
0.26168,
|
|
1679
|
+
0.42977,
|
|
1680
|
+
0.18783,
|
|
1681
|
+
0.4122,
|
|
1682
|
+
0.1089,
|
|
1683
|
+
0.28896,
|
|
1684
|
+
0.39895,
|
|
1685
|
+
0.21894,
|
|
1686
|
+
0.43541,
|
|
1687
|
+
0.41278,
|
|
1688
|
+
0.39897,
|
|
1689
|
+
0.25714,
|
|
1690
|
+
0.35544,
|
|
1691
|
+
0.42768,
|
|
1692
|
+
0.43796,
|
|
1693
|
+
0.44834,
|
|
1694
|
+
0.53694,
|
|
1695
|
+
0.17856,
|
|
1696
|
+
0.45755,
|
|
1697
|
+
0.24731,
|
|
1698
|
+
0.45719,
|
|
1699
|
+
0.28627,
|
|
1700
|
+
0.46767,
|
|
1701
|
+
0.33283,
|
|
1702
|
+
0.46071,
|
|
1703
|
+
0.36876,
|
|
1704
|
+
0.44721,
|
|
1705
|
+
0.39896,
|
|
1706
|
+
0.43266,
|
|
1707
|
+
0.47641,
|
|
1708
|
+
0.40581,
|
|
1709
|
+
0.18924,
|
|
1710
|
+
0.52392,
|
|
1711
|
+
0.22896,
|
|
1712
|
+
0.34895,
|
|
1713
|
+
0.49073,
|
|
1714
|
+
0.5624,
|
|
1715
|
+
0.40467,
|
|
1716
|
+
0.48513,
|
|
1717
|
+
0.01947,
|
|
1718
|
+
0.40156,
|
|
1719
|
+
0.42624,
|
|
1720
|
+
0.42043,
|
|
1721
|
+
0.39699,
|
|
1722
|
+
0.5488,
|
|
1723
|
+
0.26647,
|
|
1724
|
+
0.37698,
|
|
1725
|
+
0.43912,
|
|
1726
|
+
0.51896,
|
|
1727
|
+
0.03231,
|
|
1728
|
+
0.64436,
|
|
1729
|
+
0.41905,
|
|
1730
|
+
0.38716,
|
|
1731
|
+
0.46278,
|
|
1732
|
+
0.50575,
|
|
1733
|
+
0.23898,
|
|
1734
|
+
0.77975,
|
|
1735
|
+
0.19822,
|
|
1736
|
+
0.83194,
|
|
1737
|
+
0.10755,
|
|
1738
|
+
0.54075,
|
|
1739
|
+
0.18361,
|
|
1740
|
+
0.74026,
|
|
1741
|
+
0.13441,
|
|
1742
|
+
0.33368,
|
|
1743
|
+
0.38576,
|
|
1744
|
+
0.88315,
|
|
1745
|
+
0.49097,
|
|
1746
|
+
0.57938,
|
|
1747
|
+
0.38238,
|
|
1748
|
+
0.50857,
|
|
1749
|
+
0.1744,
|
|
1750
|
+
0.39767,
|
|
1751
|
+
0.31878,
|
|
1752
|
+
0.39624,
|
|
1753
|
+
0.34336,
|
|
1754
|
+
0.4006,
|
|
1755
|
+
0.3961,
|
|
1756
|
+
0.71022,
|
|
1757
|
+
0.18788,
|
|
1758
|
+
0.58854,
|
|
1759
|
+
0.43099,
|
|
1760
|
+
0.94407,
|
|
1761
|
+
0.31899,
|
|
1762
|
+
0.89829,
|
|
1763
|
+
0.26625,
|
|
1764
|
+
0.8697,
|
|
1765
|
+
0.50002,
|
|
1766
|
+
0.19058,
|
|
1767
|
+
0.49998,
|
|
1768
|
+
0.95445,
|
|
1769
|
+
0.36617,
|
|
1770
|
+
0.39882,
|
|
1771
|
+
0.39321,
|
|
1772
|
+
0.39554,
|
|
1773
|
+
0.41037,
|
|
1774
|
+
0.39108,
|
|
1775
|
+
0.19499,
|
|
1776
|
+
0.3421,
|
|
1777
|
+
0.38866,
|
|
1778
|
+
0.36228,
|
|
1779
|
+
0.36596,
|
|
1780
|
+
0.35597,
|
|
1781
|
+
0.34336,
|
|
1782
|
+
0.35536,
|
|
1783
|
+
0.31878,
|
|
1784
|
+
0.35834,
|
|
1785
|
+
0.30141,
|
|
1786
|
+
0.36316,
|
|
1787
|
+
0.05813,
|
|
1788
|
+
0.31908,
|
|
1789
|
+
0.30141,
|
|
1790
|
+
0.38745,
|
|
1791
|
+
0.49999,
|
|
1792
|
+
0.61843,
|
|
1793
|
+
0.41584,
|
|
1794
|
+
0.6242,
|
|
1795
|
+
0.44568,
|
|
1796
|
+
0.56608,
|
|
1797
|
+
0.46584,
|
|
1798
|
+
0.62064,
|
|
1799
|
+
0.49992,
|
|
1800
|
+
0.35152,
|
|
1801
|
+
0.28872,
|
|
1802
|
+
0.81995,
|
|
1803
|
+
0.33528,
|
|
1804
|
+
0.85282,
|
|
1805
|
+
0.44051,
|
|
1806
|
+
0.90242,
|
|
1807
|
+
0.12829,
|
|
1808
|
+
0.79194,
|
|
1809
|
+
0.40877,
|
|
1810
|
+
0.37389,
|
|
1811
|
+
0.45561,
|
|
1812
|
+
0.4518,
|
|
1813
|
+
0.49988,
|
|
1814
|
+
0.90899,
|
|
1815
|
+
0.37544,
|
|
1816
|
+
0.92419,
|
|
1817
|
+
0.11421,
|
|
1818
|
+
0.61502,
|
|
1819
|
+
0.44866,
|
|
1820
|
+
0.69528,
|
|
1821
|
+
0.44802,
|
|
1822
|
+
0.70463,
|
|
1823
|
+
0.44711,
|
|
1824
|
+
0.71581,
|
|
1825
|
+
0.44483,
|
|
1826
|
+
0.73079,
|
|
1827
|
+
0.43001,
|
|
1828
|
+
0.76681,
|
|
1829
|
+
0.40679,
|
|
1830
|
+
0.68567,
|
|
1831
|
+
0.40074,
|
|
1832
|
+
0.68107,
|
|
1833
|
+
0.3924,
|
|
1834
|
+
0.6777,
|
|
1835
|
+
0.36786,
|
|
1836
|
+
0.66392,
|
|
1837
|
+
0.24792,
|
|
1838
|
+
0.60133,
|
|
1839
|
+
0.45277,
|
|
1840
|
+
0.42085,
|
|
1841
|
+
0.43639,
|
|
1842
|
+
0.35989,
|
|
1843
|
+
0.41616,
|
|
1844
|
+
0.36871,
|
|
1845
|
+
0.41339,
|
|
1846
|
+
0.69237,
|
|
1847
|
+
0.22802,
|
|
1848
|
+
0.68357,
|
|
1849
|
+
0.46827,
|
|
1850
|
+
0.35267,
|
|
1851
|
+
0.41136,
|
|
1852
|
+
0.80433,
|
|
1853
|
+
0.49999,
|
|
1854
|
+
0.46983,
|
|
1855
|
+
0.47915,
|
|
1856
|
+
0.44265,
|
|
1857
|
+
0.49997,
|
|
1858
|
+
0.43964,
|
|
1859
|
+
0.43211,
|
|
1860
|
+
0.49359,
|
|
1861
|
+
0.49989,
|
|
1862
|
+
0.86692,
|
|
1863
|
+
0.49991,
|
|
1864
|
+
0.82173,
|
|
1865
|
+
0.45655,
|
|
1866
|
+
0.8192,
|
|
1867
|
+
0.34455,
|
|
1868
|
+
0.74544,
|
|
1869
|
+
0.37891,
|
|
1870
|
+
0.57401,
|
|
1871
|
+
0.37429,
|
|
1872
|
+
0.78019,
|
|
1873
|
+
0.31969,
|
|
1874
|
+
0.57074,
|
|
1875
|
+
0.35716,
|
|
1876
|
+
0.60427,
|
|
1877
|
+
0.29528,
|
|
1878
|
+
0.62158,
|
|
1879
|
+
0.44775,
|
|
1880
|
+
0.86248,
|
|
1881
|
+
0.41099,
|
|
1882
|
+
0.50872,
|
|
1883
|
+
0.31395,
|
|
1884
|
+
0.77531,
|
|
1885
|
+
0.35413,
|
|
1886
|
+
0.81255,
|
|
1887
|
+
0.32455,
|
|
1888
|
+
0.70399,
|
|
1889
|
+
0.1891,
|
|
1890
|
+
0.6463,
|
|
1891
|
+
0.27978,
|
|
1892
|
+
0.71466,
|
|
1893
|
+
0.13382,
|
|
1894
|
+
0.6827,
|
|
1895
|
+
0.33677,
|
|
1896
|
+
0.64473,
|
|
1897
|
+
0.42988,
|
|
1898
|
+
0.46652,
|
|
1899
|
+
0.45553,
|
|
1900
|
+
0.54862,
|
|
1901
|
+
0.43711,
|
|
1902
|
+
0.5589,
|
|
1903
|
+
0.46729,
|
|
1904
|
+
0.52992,
|
|
1905
|
+
0.41471,
|
|
1906
|
+
0.33522,
|
|
1907
|
+
0.37705,
|
|
1908
|
+
0.32278,
|
|
1909
|
+
0.34411,
|
|
1910
|
+
0.32015,
|
|
1911
|
+
0.31288,
|
|
1912
|
+
0.32233,
|
|
1913
|
+
0.28353,
|
|
1914
|
+
0.33319,
|
|
1915
|
+
0.24125,
|
|
1916
|
+
0.38279,
|
|
1917
|
+
0.10299,
|
|
1918
|
+
0.46876,
|
|
1919
|
+
0.26761,
|
|
1920
|
+
0.42456,
|
|
1921
|
+
0.29788,
|
|
1922
|
+
0.43318,
|
|
1923
|
+
0.33343,
|
|
1924
|
+
0.43388,
|
|
1925
|
+
0.36643,
|
|
1926
|
+
0.42612,
|
|
1927
|
+
0.39601,
|
|
1928
|
+
0.4167,
|
|
1929
|
+
0.42012,
|
|
1930
|
+
0.41023,
|
|
1931
|
+
756e-5,
|
|
1932
|
+
0.48078,
|
|
1933
|
+
0.43295,
|
|
1934
|
+
0.56952,
|
|
1935
|
+
0.45864,
|
|
1936
|
+
0.47909,
|
|
1937
|
+
0.47347,
|
|
1938
|
+
0.54574,
|
|
1939
|
+
0.47609,
|
|
1940
|
+
0.56383,
|
|
1941
|
+
0.46847,
|
|
1942
|
+
0.55506,
|
|
1943
|
+
0.43399,
|
|
1944
|
+
0.58236,
|
|
1945
|
+
0.48352,
|
|
1946
|
+
0.56298,
|
|
1947
|
+
0.48248,
|
|
1948
|
+
0.57785,
|
|
1949
|
+
0.42645,
|
|
1950
|
+
0.3898,
|
|
1951
|
+
0.439,
|
|
1952
|
+
0.3965,
|
|
1953
|
+
0.45007,
|
|
1954
|
+
0.40043,
|
|
1955
|
+
0.28971,
|
|
1956
|
+
0.36825,
|
|
1957
|
+
0.27667,
|
|
1958
|
+
0.36337,
|
|
1959
|
+
0.51786,
|
|
1960
|
+
0.47195,
|
|
1961
|
+
0.71029,
|
|
1962
|
+
0.38076,
|
|
1963
|
+
0.52623,
|
|
1964
|
+
0.57391,
|
|
1965
|
+
0.89509,
|
|
1966
|
+
0.25414,
|
|
1967
|
+
0.63407,
|
|
1968
|
+
0.40958,
|
|
1969
|
+
0.66124,
|
|
1970
|
+
0.41302,
|
|
1971
|
+
0.68888,
|
|
1972
|
+
0.40946,
|
|
1973
|
+
0.72534,
|
|
1974
|
+
0.38913,
|
|
1975
|
+
0.60663,
|
|
1976
|
+
0.4037,
|
|
1977
|
+
0.65477,
|
|
1978
|
+
0.34401,
|
|
1979
|
+
0.62991,
|
|
1980
|
+
0.34608,
|
|
1981
|
+
0.68068,
|
|
1982
|
+
0.34727,
|
|
1983
|
+
0.7021,
|
|
1984
|
+
0.35359,
|
|
1985
|
+
0.75221,
|
|
1986
|
+
0.4108,
|
|
1987
|
+
0.60292,
|
|
1988
|
+
0.84286,
|
|
1989
|
+
0.7199,
|
|
1990
|
+
0.3756,
|
|
1991
|
+
0.89369,
|
|
1992
|
+
0.39996,
|
|
1993
|
+
0.79008,
|
|
1994
|
+
0.39135,
|
|
1995
|
+
0.644,
|
|
1996
|
+
0.53449,
|
|
1997
|
+
0.52825,
|
|
1998
|
+
0.6504,
|
|
1999
|
+
0.52585,
|
|
2000
|
+
0.68019,
|
|
2001
|
+
0.56022,
|
|
2002
|
+
0.65723,
|
|
2003
|
+
0.58538,
|
|
2004
|
+
0.66654,
|
|
2005
|
+
0.54963,
|
|
2006
|
+
0.68086,
|
|
2007
|
+
0.57123,
|
|
2008
|
+
0.68269,
|
|
2009
|
+
0.62485,
|
|
2010
|
+
0.7281,
|
|
2011
|
+
0.51305,
|
|
2012
|
+
0.54728,
|
|
2013
|
+
0.5151,
|
|
2014
|
+
0.52725,
|
|
2015
|
+
0.74225,
|
|
2016
|
+
0.31451,
|
|
2017
|
+
0.59863,
|
|
2018
|
+
0.45498,
|
|
2019
|
+
0.57034,
|
|
2020
|
+
0.54858,
|
|
2021
|
+
0.57863,
|
|
2022
|
+
0.53362,
|
|
2023
|
+
0.72309,
|
|
2024
|
+
0.53205,
|
|
2025
|
+
0.51645,
|
|
2026
|
+
0.49964,
|
|
2027
|
+
0.6628,
|
|
2028
|
+
0.28292,
|
|
2029
|
+
0.70362,
|
|
2030
|
+
0.29327,
|
|
2031
|
+
0.83071,
|
|
2032
|
+
0.19381,
|
|
2033
|
+
0.55239,
|
|
2034
|
+
0.30257,
|
|
2035
|
+
0.60761,
|
|
2036
|
+
0.35389,
|
|
2037
|
+
0.64543,
|
|
2038
|
+
0.69671,
|
|
2039
|
+
0.9327,
|
|
2040
|
+
0.73011,
|
|
2041
|
+
0.55726,
|
|
2042
|
+
0.57283,
|
|
2043
|
+
0.5429,
|
|
2044
|
+
0.58479,
|
|
2045
|
+
0.61803,
|
|
2046
|
+
0.69471,
|
|
2047
|
+
0.60759,
|
|
2048
|
+
0.6942,
|
|
2049
|
+
0.72294,
|
|
2050
|
+
0.27196,
|
|
2051
|
+
0.57741,
|
|
2052
|
+
0.56317,
|
|
2053
|
+
0.61408,
|
|
2054
|
+
0.28139,
|
|
2055
|
+
0.61691,
|
|
2056
|
+
0.25589,
|
|
2057
|
+
0.66851,
|
|
2058
|
+
0.11991,
|
|
2059
|
+
0.77009,
|
|
2060
|
+
0.23202,
|
|
2061
|
+
0.63554,
|
|
2062
|
+
0.18925,
|
|
2063
|
+
0.77039,
|
|
2064
|
+
0.29956,
|
|
2065
|
+
0.82672,
|
|
2066
|
+
0.27875,
|
|
2067
|
+
0.52712,
|
|
2068
|
+
0.6662,
|
|
2069
|
+
0.55317,
|
|
2070
|
+
0.66853,
|
|
2071
|
+
0.57724,
|
|
2072
|
+
0.67389,
|
|
2073
|
+
0.55469,
|
|
2074
|
+
0.58007,
|
|
2075
|
+
0.6119,
|
|
2076
|
+
0.69396,
|
|
2077
|
+
0.59696,
|
|
2078
|
+
0.70654,
|
|
2079
|
+
0.59637,
|
|
2080
|
+
0.69395,
|
|
2081
|
+
0.53996,
|
|
2082
|
+
0.55714,
|
|
2083
|
+
0.56884,
|
|
2084
|
+
0.69237,
|
|
2085
|
+
0.54782,
|
|
2086
|
+
0.69237,
|
|
2087
|
+
0.52461,
|
|
2088
|
+
0.69237,
|
|
2089
|
+
0.53409,
|
|
2090
|
+
0.77914,
|
|
2091
|
+
0.52767,
|
|
2092
|
+
0.73623,
|
|
2093
|
+
0.52691,
|
|
2094
|
+
0.71786,
|
|
2095
|
+
0.52688,
|
|
2096
|
+
0.70463,
|
|
2097
|
+
0.52697,
|
|
2098
|
+
0.69528,
|
|
2099
|
+
0.57206,
|
|
2100
|
+
0.69528,
|
|
2101
|
+
0.57352,
|
|
2102
|
+
0.70354,
|
|
2103
|
+
0.57684,
|
|
2104
|
+
0.71185,
|
|
2105
|
+
0.58169,
|
|
2106
|
+
0.72006,
|
|
2107
|
+
0.60994,
|
|
2108
|
+
0.63991,
|
|
2109
|
+
0.98605,
|
|
2110
|
+
0.56003,
|
|
2111
|
+
0.5868,
|
|
2112
|
+
0.6954,
|
|
2113
|
+
0.59037,
|
|
2114
|
+
0.70182,
|
|
2115
|
+
0.53192,
|
|
2116
|
+
0.60154,
|
|
2117
|
+
0.57727,
|
|
2118
|
+
0.58593,
|
|
2119
|
+
0.53692,
|
|
2120
|
+
0.59379,
|
|
2121
|
+
0.62754,
|
|
2122
|
+
0.47335,
|
|
2123
|
+
0.66559,
|
|
2124
|
+
0.49595,
|
|
2125
|
+
0.58835,
|
|
2126
|
+
0.54686,
|
|
2127
|
+
0.75782,
|
|
2128
|
+
0.14768,
|
|
2129
|
+
0.70925,
|
|
2130
|
+
0.20151,
|
|
2131
|
+
0.67268,
|
|
2132
|
+
0.25658,
|
|
2133
|
+
0.60041,
|
|
2134
|
+
0.749,
|
|
2135
|
+
0.55827,
|
|
2136
|
+
0.26167,
|
|
2137
|
+
0.5703,
|
|
2138
|
+
0.18787,
|
|
2139
|
+
0.58817,
|
|
2140
|
+
0.10904,
|
|
2141
|
+
0.71105,
|
|
2142
|
+
0.39895,
|
|
2143
|
+
0.78107,
|
|
2144
|
+
0.43541,
|
|
2145
|
+
0.58725,
|
|
2146
|
+
0.39893,
|
|
2147
|
+
0.74287,
|
|
2148
|
+
0.35545,
|
|
2149
|
+
0.57216,
|
|
2150
|
+
0.43765,
|
|
2151
|
+
0.55187,
|
|
2152
|
+
0.53657,
|
|
2153
|
+
0.82144,
|
|
2154
|
+
0.45756,
|
|
2155
|
+
0.7527,
|
|
2156
|
+
0.45718,
|
|
2157
|
+
0.71376,
|
|
2158
|
+
0.46763,
|
|
2159
|
+
0.66711,
|
|
2160
|
+
0.46067,
|
|
2161
|
+
0.6311,
|
|
2162
|
+
0.44715,
|
|
2163
|
+
0.60086,
|
|
2164
|
+
0.43247,
|
|
2165
|
+
0.52348,
|
|
2166
|
+
0.40563,
|
|
2167
|
+
0.81075,
|
|
2168
|
+
0.52393,
|
|
2169
|
+
0.77105,
|
|
2170
|
+
0.34896,
|
|
2171
|
+
0.50913,
|
|
2172
|
+
0.56272,
|
|
2173
|
+
0.59529,
|
|
2174
|
+
0.48502,
|
|
2175
|
+
0.98053,
|
|
2176
|
+
0.40156,
|
|
2177
|
+
0.5735,
|
|
2178
|
+
0.42,
|
|
2179
|
+
0.60299,
|
|
2180
|
+
0.54869,
|
|
2181
|
+
0.73353,
|
|
2182
|
+
0.37698,
|
|
2183
|
+
0.56061,
|
|
2184
|
+
0.51902,
|
|
2185
|
+
0.96769,
|
|
2186
|
+
0.64436,
|
|
2187
|
+
0.58098,
|
|
2188
|
+
0.38716,
|
|
2189
|
+
0.53773,
|
|
2190
|
+
0.50538,
|
|
2191
|
+
0.76097,
|
|
2192
|
+
0.77975,
|
|
2193
|
+
0.80178,
|
|
2194
|
+
0.83194,
|
|
2195
|
+
0.89244,
|
|
2196
|
+
0.54076,
|
|
2197
|
+
0.81635,
|
|
2198
|
+
0.74026,
|
|
2199
|
+
0.8656,
|
|
2200
|
+
0.33369,
|
|
2201
|
+
0.61407,
|
|
2202
|
+
0.88325,
|
|
2203
|
+
0.50895,
|
|
2204
|
+
0.57944,
|
|
2205
|
+
0.61794,
|
|
2206
|
+
0.50832,
|
|
2207
|
+
0.82561,
|
|
2208
|
+
0.39768,
|
|
2209
|
+
0.68122,
|
|
2210
|
+
0.39624,
|
|
2211
|
+
0.65664,
|
|
2212
|
+
0.4006,
|
|
2213
|
+
0.6039,
|
|
2214
|
+
0.71022,
|
|
2215
|
+
0.81209,
|
|
2216
|
+
0.58854,
|
|
2217
|
+
0.56801,
|
|
2218
|
+
0.94456,
|
|
2219
|
+
0.68101,
|
|
2220
|
+
0.89829,
|
|
2221
|
+
0.73375,
|
|
2222
|
+
0.8697,
|
|
2223
|
+
0.63383,
|
|
2224
|
+
0.39882,
|
|
2225
|
+
0.60679,
|
|
2226
|
+
0.39554,
|
|
2227
|
+
0.58966,
|
|
2228
|
+
0.39106,
|
|
2229
|
+
0.80502,
|
|
2230
|
+
0.34211,
|
|
2231
|
+
0.61133,
|
|
2232
|
+
0.36228,
|
|
2233
|
+
0.63404,
|
|
2234
|
+
0.35597,
|
|
2235
|
+
0.65664,
|
|
2236
|
+
0.35536,
|
|
2237
|
+
0.68122,
|
|
2238
|
+
0.35834,
|
|
2239
|
+
0.69859,
|
|
2240
|
+
0.36316,
|
|
2241
|
+
0.94187,
|
|
2242
|
+
0.31908,
|
|
2243
|
+
0.69859,
|
|
2244
|
+
0.38745,
|
|
2245
|
+
0.58418,
|
|
2246
|
+
0.62411,
|
|
2247
|
+
0.55432,
|
|
2248
|
+
0.56608,
|
|
2249
|
+
0.53415,
|
|
2250
|
+
0.62064,
|
|
2251
|
+
0.71122,
|
|
2252
|
+
0.81998,
|
|
2253
|
+
0.66463,
|
|
2254
|
+
0.85287,
|
|
2255
|
+
0.5591,
|
|
2256
|
+
0.90263,
|
|
2257
|
+
0.87171,
|
|
2258
|
+
0.79194,
|
|
2259
|
+
0.59123,
|
|
2260
|
+
0.37389,
|
|
2261
|
+
0.54434,
|
|
2262
|
+
0.45158,
|
|
2263
|
+
0.62456,
|
|
2264
|
+
0.92419,
|
|
2265
|
+
0.88577,
|
|
2266
|
+
0.61503,
|
|
2267
|
+
0.55134,
|
|
2268
|
+
0.69528,
|
|
2269
|
+
0.55198,
|
|
2270
|
+
0.70463,
|
|
2271
|
+
0.55289,
|
|
2272
|
+
0.71581,
|
|
2273
|
+
0.55517,
|
|
2274
|
+
0.73079,
|
|
2275
|
+
0.56994,
|
|
2276
|
+
0.76704,
|
|
2277
|
+
0.5932,
|
|
2278
|
+
0.68568,
|
|
2279
|
+
0.59926,
|
|
2280
|
+
0.68107,
|
|
2281
|
+
0.6076,
|
|
2282
|
+
0.6777,
|
|
2283
|
+
0.63194,
|
|
2284
|
+
0.6635,
|
|
2285
|
+
0.75203,
|
|
2286
|
+
0.60132,
|
|
2287
|
+
0.54723,
|
|
2288
|
+
0.42039,
|
|
2289
|
+
0.56354,
|
|
2290
|
+
0.35983,
|
|
2291
|
+
0.58384,
|
|
2292
|
+
0.36871,
|
|
2293
|
+
0.58661,
|
|
2294
|
+
0.69237,
|
|
2295
|
+
0.77192,
|
|
2296
|
+
0.68358,
|
|
2297
|
+
0.5316,
|
|
2298
|
+
0.35248,
|
|
2299
|
+
0.58837,
|
|
2300
|
+
0.80444,
|
|
2301
|
+
0.5208,
|
|
2302
|
+
0.44256,
|
|
2303
|
+
0.56798,
|
|
2304
|
+
0.49348,
|
|
2305
|
+
0.54328,
|
|
2306
|
+
0.81926,
|
|
2307
|
+
0.65532,
|
|
2308
|
+
0.74551,
|
|
2309
|
+
0.62101,
|
|
2310
|
+
0.57402,
|
|
2311
|
+
0.62556,
|
|
2312
|
+
0.78031,
|
|
2313
|
+
0.6802,
|
|
2314
|
+
0.57072,
|
|
2315
|
+
0.64276,
|
|
2316
|
+
0.60434,
|
|
2317
|
+
0.70466,
|
|
2318
|
+
0.62153,
|
|
2319
|
+
0.55201,
|
|
2320
|
+
0.86259,
|
|
2321
|
+
0.58907,
|
|
2322
|
+
0.50864,
|
|
2323
|
+
0.68595,
|
|
2324
|
+
0.77536,
|
|
2325
|
+
0.64573,
|
|
2326
|
+
0.81264,
|
|
2327
|
+
0.67534,
|
|
2328
|
+
0.70398,
|
|
2329
|
+
0.81086,
|
|
2330
|
+
0.64631,
|
|
2331
|
+
0.72012,
|
|
2332
|
+
0.71467,
|
|
2333
|
+
0.86615,
|
|
2334
|
+
0.68271,
|
|
2335
|
+
0.66319,
|
|
2336
|
+
0.6446,
|
|
2337
|
+
0.57008,
|
|
2338
|
+
0.46633,
|
|
2339
|
+
0.54456,
|
|
2340
|
+
0.54838,
|
|
2341
|
+
0.56276,
|
|
2342
|
+
0.55878,
|
|
2343
|
+
0.53199,
|
|
2344
|
+
0.53014,
|
|
2345
|
+
0.58527,
|
|
2346
|
+
0.33518,
|
|
2347
|
+
0.62295,
|
|
2348
|
+
0.32278,
|
|
2349
|
+
0.6559,
|
|
2350
|
+
0.32016,
|
|
2351
|
+
0.68713,
|
|
2352
|
+
0.32235,
|
|
2353
|
+
0.71648,
|
|
2354
|
+
0.3332,
|
|
2355
|
+
0.75876,
|
|
2356
|
+
0.38279,
|
|
2357
|
+
0.89701,
|
|
2358
|
+
0.46877,
|
|
2359
|
+
0.73239,
|
|
2360
|
+
0.42455,
|
|
2361
|
+
0.70211,
|
|
2362
|
+
0.43316,
|
|
2363
|
+
0.66653,
|
|
2364
|
+
0.43387,
|
|
2365
|
+
0.6335,
|
|
2366
|
+
0.42609,
|
|
2367
|
+
0.60388,
|
|
2368
|
+
0.41659,
|
|
2369
|
+
0.57966,
|
|
2370
|
+
0.40995,
|
|
2371
|
+
0.99244,
|
|
2372
|
+
0.48078,
|
|
2373
|
+
0.56719,
|
|
2374
|
+
0.56942,
|
|
2375
|
+
0.54137,
|
|
2376
|
+
0.4789,
|
|
2377
|
+
0.52656,
|
|
2378
|
+
0.54612,
|
|
2379
|
+
0.52391,
|
|
2380
|
+
0.56383,
|
|
2381
|
+
0.53153,
|
|
2382
|
+
0.55506,
|
|
2383
|
+
0.56604,
|
|
2384
|
+
0.58233,
|
|
2385
|
+
0.51631,
|
|
2386
|
+
0.56305,
|
|
2387
|
+
0.51747,
|
|
2388
|
+
0.57788,
|
|
2389
|
+
0.57359,
|
|
2390
|
+
0.38981,
|
|
2391
|
+
0.5607,
|
|
2392
|
+
0.39533,
|
|
2393
|
+
0.54976,
|
|
2394
|
+
0.39975,
|
|
2395
|
+
0.71029,
|
|
2396
|
+
0.36825,
|
|
2397
|
+
0.72333,
|
|
2398
|
+
0.36337
|
|
2399
|
+
]);
|
|
1192
2400
|
export {
|
|
1193
2401
|
BLEND_MODES,
|
|
2402
|
+
EFFECTS_SCHEMA,
|
|
1194
2403
|
Engine,
|
|
2404
|
+
FACE_UV,
|
|
1195
2405
|
NO_EFFECTS,
|
|
1196
2406
|
Scene,
|
|
1197
2407
|
TOUCH_UP,
|
|
@@ -1203,6 +2413,7 @@ export {
|
|
|
1203
2413
|
needsFace,
|
|
1204
2414
|
needsMask,
|
|
1205
2415
|
needsSegmentation,
|
|
2416
|
+
normalizeEffects,
|
|
1206
2417
|
parseColor,
|
|
1207
2418
|
renderText,
|
|
1208
2419
|
touchUp,
|