@sekyro/web 0.1.0-rc.6 → 0.1.0-rc.7
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/CHANGELOG.md +27 -0
- package/LICENSE +3 -3
- package/README.md +4 -4
- package/dist/chunk-B45J4KC3.js +1 -0
- package/dist/chunk-BMA36W2W.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-IYUOYINS.js +1 -0
- package/dist/chunk-P7ECRN47.js +1 -0
- package/dist/chunk-SXZCL5NO.js +1 -0
- package/dist/chunk-YOB4ZTYN.js +1 -0
- package/dist/chunk-YQBK6OIM.js +1 -0
- package/dist/client/index.cjs +1 -357
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -15
- package/dist/core/index.cjs +1 -1639
- package/dist/core/index.js +1 -139
- package/dist/core/v3/detect-worker.cjs +1 -392
- package/dist/core/v3/detect-worker.js +1 -13
- package/dist/{create-verification-BKc9NFQj.d.cts → create-verification-C2JhOO6Y.d.cts} +94 -16
- package/dist/{create-verification-DjcMZHAQ.d.ts → create-verification-CGazwtAh.d.ts} +94 -16
- package/dist/detector-scanic-VQFFXKTL.js +1 -0
- package/dist/{hosted-client-DJXq_CB9.d.ts → hosted-client-kBeq-mnJ.d.cts} +164 -11
- package/dist/{hosted-client-DJXq_CB9.d.cts → hosted-client-kBeq-mnJ.d.ts} +164 -11
- package/dist/index.cjs +1 -3030
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -85
- package/dist/internal/index.cjs +1 -4439
- package/dist/internal/index.d.cts +10 -7
- package/dist/internal/index.d.ts +10 -7
- package/dist/internal/index.js +1 -657
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.js +1 -11
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/package.json +5 -8
- package/sbom.cdx.json +195 -0
- package/dist/chunk-MWNFSNMP.js +0 -52
- package/dist/chunk-MWNFSNMP.js.map +0 -1
- package/dist/chunk-NILNKLK6.js +0 -50
- package/dist/chunk-NILNKLK6.js.map +0 -1
- package/dist/chunk-NWF46H7K.js +0 -359
- package/dist/chunk-NWF46H7K.js.map +0 -1
- package/dist/chunk-R3SJQHYU.js +0 -1173
- package/dist/chunk-R3SJQHYU.js.map +0 -1
- package/dist/chunk-TG5IE552.js +0 -1128
- package/dist/chunk-TG5IE552.js.map +0 -1
- package/dist/chunk-WY6U7AIK.js +0 -193
- package/dist/chunk-WY6U7AIK.js.map +0 -1
- package/dist/chunk-YVFF4Q4G.js +0 -327
- package/dist/chunk-YVFF4Q4G.js.map +0 -1
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/v3/detect-worker.cjs.map +0 -1
- package/dist/core/v3/detect-worker.js.map +0 -1
- package/dist/detector-scanic-4C6IEW2K.js +0 -787
- package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.js.map +0 -1
- package/dist/popup/index.cjs.map +0 -1
- package/dist/popup/index.js.map +0 -1
- package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
- package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
package/dist/core/index.js
CHANGED
|
@@ -1,139 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CENTERED_FACTOR,
|
|
3
|
-
CIRCLE_RADIUS_FACTOR,
|
|
4
|
-
CLIP_MS,
|
|
5
|
-
CaptureSessionV3,
|
|
6
|
-
ClipError,
|
|
7
|
-
ClipRecorder,
|
|
8
|
-
DEFAULT_CLIP_MIME,
|
|
9
|
-
DEVICE_PROFILES,
|
|
10
|
-
DetectScheduler,
|
|
11
|
-
DeviceProfiler,
|
|
12
|
-
FaceGateV3,
|
|
13
|
-
IN_CIRCLE_FACTOR,
|
|
14
|
-
KEYFRAME_CANDIDATES,
|
|
15
|
-
KEYFRAME_WINDOW_MS,
|
|
16
|
-
MAX_CLIP_BYTES,
|
|
17
|
-
MIME_CANDIDATES,
|
|
18
|
-
STOP_GRACE_MS,
|
|
19
|
-
TIMESLICE_MS,
|
|
20
|
-
V3_GATE_DEFAULTS,
|
|
21
|
-
VIDEO_BPS,
|
|
22
|
-
buildCaptureConstraints,
|
|
23
|
-
buildLivenessV2FormData,
|
|
24
|
-
cameraPreflight,
|
|
25
|
-
captureMirroredKeyframe,
|
|
26
|
-
classifyDevice,
|
|
27
|
-
detectIsMobile,
|
|
28
|
-
extForMime,
|
|
29
|
-
isClipTooLarge,
|
|
30
|
-
isMediaRecorderSupported,
|
|
31
|
-
mapGetUserMediaError,
|
|
32
|
-
pickMimeType,
|
|
33
|
-
probeDevice
|
|
34
|
-
} from "../chunk-TG5IE552.js";
|
|
35
|
-
import {
|
|
36
|
-
DEFAULT_TIER_ORDER,
|
|
37
|
-
DEFAULT_V3_ASSET_BASE_URL,
|
|
38
|
-
DetectorLadderError,
|
|
39
|
-
createDetector,
|
|
40
|
-
intrinsicSize,
|
|
41
|
-
toStreamPixels
|
|
42
|
-
} from "../chunk-NWF46H7K.js";
|
|
43
|
-
import {
|
|
44
|
-
EXPOSURE_BAND,
|
|
45
|
-
SHARP_REF,
|
|
46
|
-
exposure,
|
|
47
|
-
meanLuma,
|
|
48
|
-
sharpness
|
|
49
|
-
} from "../chunk-MWNFSNMP.js";
|
|
50
|
-
|
|
51
|
-
// src/core/messages.ts
|
|
52
|
-
var errorCopy = {
|
|
53
|
-
permission: {
|
|
54
|
-
key: "fcv2.err.permission",
|
|
55
|
-
fr: "Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."
|
|
56
|
-
},
|
|
57
|
-
notfound: {
|
|
58
|
-
key: "fcv2.err.notfound",
|
|
59
|
-
fr: "Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."
|
|
60
|
-
},
|
|
61
|
-
inuse: {
|
|
62
|
-
key: "fcv2.err.inuse",
|
|
63
|
-
fr: "La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."
|
|
64
|
-
},
|
|
65
|
-
overconstrained: {
|
|
66
|
-
key: "fcv2.err.overconstrained",
|
|
67
|
-
fr: "La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"
|
|
68
|
-
},
|
|
69
|
-
insecure: {
|
|
70
|
-
key: "fcv2.err.insecure",
|
|
71
|
-
fr: "La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."
|
|
72
|
-
},
|
|
73
|
-
unsupported: {
|
|
74
|
-
key: "fcv2.err.unsupported",
|
|
75
|
-
fr: "Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."
|
|
76
|
-
},
|
|
77
|
-
generic: {
|
|
78
|
-
key: "fcv2.err.generic",
|
|
79
|
-
fr: "Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var uiCopy = {
|
|
83
|
-
recording: { key: "fcv2.recording", fr: "Enregistrement en cours\u2026" },
|
|
84
|
-
uploading: { key: "fcv2.uploading", fr: "Envoi en cours\u2026" },
|
|
85
|
-
clipTooLarge: {
|
|
86
|
-
key: "fcv2.err.cliptoolarge",
|
|
87
|
-
fr: "La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."
|
|
88
|
-
},
|
|
89
|
-
retry: { key: "fcv2.retry", fr: "R\xE9essayer" },
|
|
90
|
-
listen: { key: "fcv2.listen", fr: "\xC9couter" }
|
|
91
|
-
};
|
|
92
|
-
export {
|
|
93
|
-
CENTERED_FACTOR,
|
|
94
|
-
CIRCLE_RADIUS_FACTOR,
|
|
95
|
-
CLIP_MS,
|
|
96
|
-
CaptureSessionV3,
|
|
97
|
-
ClipError,
|
|
98
|
-
ClipRecorder,
|
|
99
|
-
DEFAULT_CLIP_MIME,
|
|
100
|
-
DEFAULT_TIER_ORDER,
|
|
101
|
-
DEFAULT_V3_ASSET_BASE_URL,
|
|
102
|
-
DEVICE_PROFILES,
|
|
103
|
-
DetectScheduler,
|
|
104
|
-
DetectorLadderError,
|
|
105
|
-
DeviceProfiler,
|
|
106
|
-
EXPOSURE_BAND,
|
|
107
|
-
FaceGateV3,
|
|
108
|
-
IN_CIRCLE_FACTOR,
|
|
109
|
-
KEYFRAME_CANDIDATES,
|
|
110
|
-
KEYFRAME_WINDOW_MS,
|
|
111
|
-
MAX_CLIP_BYTES,
|
|
112
|
-
MIME_CANDIDATES,
|
|
113
|
-
SHARP_REF,
|
|
114
|
-
STOP_GRACE_MS,
|
|
115
|
-
TIMESLICE_MS,
|
|
116
|
-
V3_GATE_DEFAULTS,
|
|
117
|
-
VIDEO_BPS,
|
|
118
|
-
buildCaptureConstraints,
|
|
119
|
-
buildLivenessV2FormData,
|
|
120
|
-
cameraPreflight,
|
|
121
|
-
captureMirroredKeyframe,
|
|
122
|
-
classifyDevice,
|
|
123
|
-
createDetector,
|
|
124
|
-
detectIsMobile,
|
|
125
|
-
errorCopy,
|
|
126
|
-
exposure,
|
|
127
|
-
extForMime,
|
|
128
|
-
intrinsicSize,
|
|
129
|
-
isClipTooLarge,
|
|
130
|
-
isMediaRecorderSupported,
|
|
131
|
-
mapGetUserMediaError,
|
|
132
|
-
meanLuma,
|
|
133
|
-
pickMimeType,
|
|
134
|
-
probeDevice,
|
|
135
|
-
sharpness,
|
|
136
|
-
toStreamPixels,
|
|
137
|
-
uiCopy
|
|
138
|
-
};
|
|
139
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{A as S,B as V,C as j,D as q,E as w,F as D,a as e,b as r,c as o,d as n,e as a,f as s,g as i,h as t,i as c,j as p,k as u,l as f,m,n as d,o as l,p as v,q as y,r as g,s as x,t as k,u as z,v as C,w as A,x as H,y as K,z as P}from"../chunk-YQBK6OIM.js";import"../chunk-IYUOYINS.js";import{a as L,b as T,c as E,d as R,e as h,f as b}from"../chunk-BMA36W2W.js";import{a as B,b as F,c as N,d as O,e as U}from"../chunk-FPXL63KZ.js";var G={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},I={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};export{a as CENTERED_FACTOR,o as CIRCLE_RADIUS_FACTOR,v as CLIP_MS,D as CaptureSessionV3,k as ClipError,z as ClipRecorder,t as DEFAULT_CLIP_MIME,T as DEFAULT_TIER_ORDER,L as DEFAULT_V3_ASSET_BASE_URL,A as DEVICE_PROFILES,S as DetectScheduler,E as DetectorLadderError,P as DeviceProfiler,F as EXPOSURE_BAND,j as FaceGateV3,n as IN_CIRCLE_FACTOR,q as KEYFRAME_CANDIDATES,w as KEYFRAME_WINDOW_MS,f as MAX_CLIP_BYTES,s as MIME_CANDIDATES,B as SHARP_REF,g as STOP_GRACE_MS,y as TIMESLICE_MS,V as V3_GATE_DEFAULTS,x as VIDEO_BPS,e as buildCaptureConstraints,l as buildLivenessV2FormData,p as cameraPreflight,C as captureMirroredKeyframe,K as classifyDevice,b as createDetector,r as detectIsMobile,G as errorCopy,U as exposure,d as extForMime,R as intrinsicSize,m as isClipTooLarge,u as isMediaRecorderSupported,c as mapGetUserMediaError,N as meanLuma,i as pickMimeType,H as probeDevice,O as sharpness,h as toStreamPixels,I as uiCopy};
|
|
@@ -1,392 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/core/v3/detect-worker.ts
|
|
31
|
-
var detect_worker_exports = {};
|
|
32
|
-
__export(detect_worker_exports, {
|
|
33
|
-
WORKER_PROTOCOL_VERSION: () => WORKER_PROTOCOL_VERSION,
|
|
34
|
-
WorkerDetectorProxy: () => WorkerDetectorProxy,
|
|
35
|
-
installWorkerDetectorHost: () => installWorkerDetectorHost,
|
|
36
|
-
workerOffloadSupported: () => workerOffloadSupported
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(detect_worker_exports);
|
|
39
|
-
|
|
40
|
-
// src/core/v3/detector-blaze.ts
|
|
41
|
-
var BLAZE_INIT_TIMEOUT_MS = 1e4;
|
|
42
|
-
var BlazeDetector = class _BlazeDetector {
|
|
43
|
-
constructor(inner, fallbackReason) {
|
|
44
|
-
this.tier = "blaze";
|
|
45
|
-
this.inner = inner;
|
|
46
|
-
if (fallbackReason !== void 0) this.fallbackReason = fallbackReason;
|
|
47
|
-
}
|
|
48
|
-
static async create(assetBaseUrl, fallbackReason) {
|
|
49
|
-
const vision = await import("@mediapipe/tasks-vision");
|
|
50
|
-
const fileset = await vision.FilesetResolver.forVisionTasks(assetBaseUrl);
|
|
51
|
-
const inner = await vision.FaceDetector.createFromOptions(fileset, {
|
|
52
|
-
baseOptions: {
|
|
53
|
-
modelAssetPath: `${assetBaseUrl}/blaze_face_short_range.tflite`,
|
|
54
|
-
// CPU delegate — the iOS-Safari-safe path (see header). NEVER 'GPU'.
|
|
55
|
-
delegate: "CPU"
|
|
56
|
-
},
|
|
57
|
-
runningMode: "IMAGE"
|
|
58
|
-
});
|
|
59
|
-
return new _BlazeDetector(inner, fallbackReason);
|
|
60
|
-
}
|
|
61
|
-
async detect(source, sourceWidth, sourceHeight) {
|
|
62
|
-
let detections;
|
|
63
|
-
try {
|
|
64
|
-
detections = this.inner.detect(source).detections;
|
|
65
|
-
} catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const best = pickMostConfident(detections);
|
|
69
|
-
if (best?.boundingBox === void 0) return null;
|
|
70
|
-
const size = intrinsicSize(source);
|
|
71
|
-
const eyes = extractEyes(best.keypoints, size);
|
|
72
|
-
const observation = {
|
|
73
|
-
box: {
|
|
74
|
-
x: best.boundingBox.originX,
|
|
75
|
-
y: best.boundingBox.originY,
|
|
76
|
-
width: best.boundingBox.width,
|
|
77
|
-
height: best.boundingBox.height
|
|
78
|
-
},
|
|
79
|
-
...eyes !== void 0 ? { eyes } : {},
|
|
80
|
-
score: best.categories[0]?.score ?? 0
|
|
81
|
-
};
|
|
82
|
-
return toStreamPixels(observation, source, sourceWidth, sourceHeight);
|
|
83
|
-
}
|
|
84
|
-
destroy() {
|
|
85
|
-
try {
|
|
86
|
-
this.inner.close();
|
|
87
|
-
} catch {
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
function pickMostConfident(detections) {
|
|
92
|
-
let best;
|
|
93
|
-
let bestScore = -1;
|
|
94
|
-
for (const detection of detections) {
|
|
95
|
-
const score = detection.categories[0]?.score ?? 0;
|
|
96
|
-
if (score > bestScore) {
|
|
97
|
-
best = detection;
|
|
98
|
-
bestScore = score;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return best;
|
|
102
|
-
}
|
|
103
|
-
function extractEyes(keypoints, size) {
|
|
104
|
-
const a = keypoints?.[0];
|
|
105
|
-
const b = keypoints?.[1];
|
|
106
|
-
if (a === void 0 || b === void 0) return void 0;
|
|
107
|
-
const toSource = (p) => ({ x: p.x * size.width, y: p.y * size.height });
|
|
108
|
-
const [pa, pb] = [toSource(a), toSource(b)];
|
|
109
|
-
return pa.x <= pb.x ? { left: pa, right: pb } : { left: pb, right: pa };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/core/v3/detector-native.ts
|
|
113
|
-
function smokeSource() {
|
|
114
|
-
if (typeof OffscreenCanvas === "function") return new OffscreenCanvas(2, 2);
|
|
115
|
-
const canvas = document.createElement("canvas");
|
|
116
|
-
canvas.width = 2;
|
|
117
|
-
canvas.height = 2;
|
|
118
|
-
return canvas;
|
|
119
|
-
}
|
|
120
|
-
async function probeNativeDetector() {
|
|
121
|
-
const ctor = globalThis.FaceDetector;
|
|
122
|
-
if (typeof ctor !== "function") return { ok: false, reason: "unsupported" };
|
|
123
|
-
try {
|
|
124
|
-
const instance = new ctor({ fastMode: true, maxDetectedFaces: 1 });
|
|
125
|
-
await instance.detect(smokeSource());
|
|
126
|
-
return { ok: true, instance };
|
|
127
|
-
} catch (err) {
|
|
128
|
-
return { ok: false, reason: `smoke_failed:${err instanceof Error ? err.message : String(err)}` };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
var NativeDetector = class {
|
|
132
|
-
constructor(inner, fallbackReason) {
|
|
133
|
-
this.tier = "native";
|
|
134
|
-
this.inner = inner;
|
|
135
|
-
if (fallbackReason !== void 0) this.fallbackReason = fallbackReason;
|
|
136
|
-
}
|
|
137
|
-
async detect(source, sourceWidth, sourceHeight) {
|
|
138
|
-
let faces;
|
|
139
|
-
try {
|
|
140
|
-
faces = await this.inner.detect(source);
|
|
141
|
-
} catch {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
const face = faces[0];
|
|
145
|
-
if (face === void 0) return null;
|
|
146
|
-
const eyes = extractEyes2(face.landmarks);
|
|
147
|
-
const observation = {
|
|
148
|
-
box: {
|
|
149
|
-
x: face.boundingBox.x,
|
|
150
|
-
y: face.boundingBox.y,
|
|
151
|
-
width: face.boundingBox.width,
|
|
152
|
-
height: face.boundingBox.height
|
|
153
|
-
},
|
|
154
|
-
...eyes !== void 0 ? { eyes } : {},
|
|
155
|
-
// The Shape Detection API exposes no confidence — the smoke-tested
|
|
156
|
-
// native tier treats any detection as confident.
|
|
157
|
-
score: 1
|
|
158
|
-
};
|
|
159
|
-
return toStreamPixels(observation, source, sourceWidth, sourceHeight);
|
|
160
|
-
}
|
|
161
|
-
destroy() {
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
function extractEyes2(landmarks) {
|
|
165
|
-
if (landmarks === void 0) return void 0;
|
|
166
|
-
const eyePoints = landmarks.filter((landmark) => landmark.type === "eye").map((landmark) => landmark.locations[0]).filter((point) => point !== void 0);
|
|
167
|
-
const [a, b] = eyePoints;
|
|
168
|
-
if (a === void 0 || b === void 0) return void 0;
|
|
169
|
-
return a.x <= b.x ? { left: a, right: b } : { left: b, right: a };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// src/core/v3/detector.ts
|
|
173
|
-
var DEFAULT_V3_ASSET_BASE_URL = "/models-v3";
|
|
174
|
-
var DEFAULT_TIER_ORDER = ["native", "blaze"];
|
|
175
|
-
var DetectorLadderError = class extends Error {
|
|
176
|
-
constructor(fallbackReason) {
|
|
177
|
-
super(`no detector tier available (${fallbackReason})`);
|
|
178
|
-
this.name = "DetectorLadderError";
|
|
179
|
-
this.fallbackReason = fallbackReason;
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
function intrinsicSize(source) {
|
|
183
|
-
const candidate = source;
|
|
184
|
-
if (typeof candidate.videoWidth === "number" && candidate.videoWidth > 0) {
|
|
185
|
-
return { width: candidate.videoWidth, height: candidate.videoHeight ?? 0 };
|
|
186
|
-
}
|
|
187
|
-
if (typeof candidate.naturalWidth === "number" && candidate.naturalWidth > 0) {
|
|
188
|
-
return { width: candidate.naturalWidth, height: candidate.naturalHeight ?? 0 };
|
|
189
|
-
}
|
|
190
|
-
const width = typeof candidate.width === "number" ? candidate.width : 0;
|
|
191
|
-
const height = typeof candidate.height === "number" ? candidate.height : 0;
|
|
192
|
-
return { width, height };
|
|
193
|
-
}
|
|
194
|
-
function toStreamPixels(observation, source, streamWidth, streamHeight) {
|
|
195
|
-
const size = intrinsicSize(source);
|
|
196
|
-
const scaleX = size.width > 0 ? streamWidth / size.width : 1;
|
|
197
|
-
const scaleY = size.height > 0 ? streamHeight / size.height : 1;
|
|
198
|
-
const scalePoint = (p) => ({ x: p.x * scaleX, y: p.y * scaleY });
|
|
199
|
-
return {
|
|
200
|
-
box: {
|
|
201
|
-
x: observation.box.x * scaleX,
|
|
202
|
-
y: observation.box.y * scaleY,
|
|
203
|
-
width: observation.box.width * scaleX,
|
|
204
|
-
height: observation.box.height * scaleY
|
|
205
|
-
},
|
|
206
|
-
...observation.eyes !== void 0 ? { eyes: { left: scalePoint(observation.eyes.left), right: scalePoint(observation.eyes.right) } } : {},
|
|
207
|
-
score: observation.score
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function describeError(err) {
|
|
211
|
-
return err instanceof Error ? err.message : String(err);
|
|
212
|
-
}
|
|
213
|
-
async function createDetector(options) {
|
|
214
|
-
const order = options.preferred ?? DEFAULT_TIER_ORDER;
|
|
215
|
-
const reasons = [];
|
|
216
|
-
for (const tier of order) {
|
|
217
|
-
if (tier === "native") {
|
|
218
|
-
const probed = await probeNativeDetector();
|
|
219
|
-
if (probed.ok) {
|
|
220
|
-
return new NativeDetector(probed.instance, reasonOf(reasons));
|
|
221
|
-
}
|
|
222
|
-
reasons.push(`native:${probed.reason}`);
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
try {
|
|
226
|
-
return await withTimeout(
|
|
227
|
-
BlazeDetector.create(
|
|
228
|
-
options.v3AssetBaseUrl ?? DEFAULT_V3_ASSET_BASE_URL,
|
|
229
|
-
reasonOf(reasons)
|
|
230
|
-
),
|
|
231
|
-
options.blazeInitTimeoutMs ?? BLAZE_INIT_TIMEOUT_MS
|
|
232
|
-
);
|
|
233
|
-
} catch (err) {
|
|
234
|
-
reasons.push(
|
|
235
|
-
err instanceof InitTimeoutError ? "blaze:blaze_init_timeout" : `blaze:${describeError(err)}`
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
throw new DetectorLadderError(reasonOf(reasons) ?? "no_tier_available");
|
|
240
|
-
}
|
|
241
|
-
function reasonOf(reasons) {
|
|
242
|
-
return reasons.length > 0 ? reasons.join("; ") : void 0;
|
|
243
|
-
}
|
|
244
|
-
var InitTimeoutError = class extends Error {
|
|
245
|
-
};
|
|
246
|
-
function withTimeout(promise, deadlineMs) {
|
|
247
|
-
return new Promise((resolvePromise, rejectPromise) => {
|
|
248
|
-
const timer = setTimeout(() => {
|
|
249
|
-
rejectPromise(new InitTimeoutError(`init exceeded ${deadlineMs}ms`));
|
|
250
|
-
promise.then(
|
|
251
|
-
(value) => value.destroy(),
|
|
252
|
-
() => void 0
|
|
253
|
-
);
|
|
254
|
-
}, deadlineMs);
|
|
255
|
-
promise.then(
|
|
256
|
-
(value) => {
|
|
257
|
-
clearTimeout(timer);
|
|
258
|
-
resolvePromise(value);
|
|
259
|
-
},
|
|
260
|
-
(err) => {
|
|
261
|
-
clearTimeout(timer);
|
|
262
|
-
rejectPromise(err);
|
|
263
|
-
}
|
|
264
|
-
);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// src/core/v3/detect-worker.ts
|
|
269
|
-
var WORKER_PROTOCOL_VERSION = 1;
|
|
270
|
-
function workerOffloadSupported() {
|
|
271
|
-
return typeof OffscreenCanvas === "function" && typeof createImageBitmap === "function" && typeof Worker === "function";
|
|
272
|
-
}
|
|
273
|
-
function installWorkerDetectorHost(scope, deps = {}) {
|
|
274
|
-
const create = deps.createDetector ?? createDetector;
|
|
275
|
-
let detector = null;
|
|
276
|
-
scope.onmessage = (event) => {
|
|
277
|
-
const message = event.data;
|
|
278
|
-
if (message.v !== WORKER_PROTOCOL_VERSION) {
|
|
279
|
-
message.bitmap?.close?.();
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (message.type === "init") {
|
|
283
|
-
void create(message.options).then((created) => {
|
|
284
|
-
detector = created;
|
|
285
|
-
const ready = {
|
|
286
|
-
v: WORKER_PROTOCOL_VERSION,
|
|
287
|
-
type: "ready",
|
|
288
|
-
tier: created.tier,
|
|
289
|
-
...created.fallbackReason !== void 0 ? { fallbackReason: created.fallbackReason } : {}
|
|
290
|
-
};
|
|
291
|
-
scope.postMessage(ready);
|
|
292
|
-
});
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (message.type === "detect") {
|
|
296
|
-
const respond = (observation) => {
|
|
297
|
-
const result = {
|
|
298
|
-
v: WORKER_PROTOCOL_VERSION,
|
|
299
|
-
type: "result",
|
|
300
|
-
id: message.id,
|
|
301
|
-
observation
|
|
302
|
-
};
|
|
303
|
-
scope.postMessage(result);
|
|
304
|
-
message.bitmap.close?.();
|
|
305
|
-
};
|
|
306
|
-
if (detector === null) {
|
|
307
|
-
respond(null);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
void detector.detect(message.bitmap, message.streamWidth, message.streamHeight).then(respond, () => respond(null));
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
if (typeof self !== "undefined" && typeof self.importScripts === "function") {
|
|
315
|
-
installWorkerDetectorHost(self);
|
|
316
|
-
}
|
|
317
|
-
var WorkerDetectorProxy = class _WorkerDetectorProxy {
|
|
318
|
-
constructor(worker, ready) {
|
|
319
|
-
this.pending = /* @__PURE__ */ new Map();
|
|
320
|
-
this.nextId = 1;
|
|
321
|
-
this.worker = worker;
|
|
322
|
-
this.tier = ready.tier;
|
|
323
|
-
if (ready.fallbackReason !== void 0) this.fallbackReason = ready.fallbackReason;
|
|
324
|
-
worker.addEventListener("message", (event) => {
|
|
325
|
-
const message = event.data;
|
|
326
|
-
if (message.v !== WORKER_PROTOCOL_VERSION || message.type !== "result") return;
|
|
327
|
-
const resolve = this.pending.get(message.id);
|
|
328
|
-
this.pending.delete(message.id);
|
|
329
|
-
resolve?.(message.observation);
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
static create(worker, options, readyTimeoutMs = 1e4) {
|
|
333
|
-
return new Promise((resolve, reject) => {
|
|
334
|
-
const timer = setTimeout(() => {
|
|
335
|
-
worker.removeEventListener("message", onReady);
|
|
336
|
-
worker.terminate();
|
|
337
|
-
reject(new Error(`worker detector not ready within ${readyTimeoutMs}ms`));
|
|
338
|
-
}, readyTimeoutMs);
|
|
339
|
-
const onReady = (event) => {
|
|
340
|
-
const message = event.data;
|
|
341
|
-
if (message.v !== WORKER_PROTOCOL_VERSION || message.type !== "ready") return;
|
|
342
|
-
clearTimeout(timer);
|
|
343
|
-
worker.removeEventListener("message", onReady);
|
|
344
|
-
resolve(new _WorkerDetectorProxy(worker, message));
|
|
345
|
-
};
|
|
346
|
-
worker.addEventListener("message", onReady);
|
|
347
|
-
const init = { v: WORKER_PROTOCOL_VERSION, type: "init", options };
|
|
348
|
-
worker.postMessage(init);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
async detect(source, sourceWidth, sourceHeight) {
|
|
352
|
-
let bitmap;
|
|
353
|
-
try {
|
|
354
|
-
if (typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap) {
|
|
355
|
-
bitmap = source;
|
|
356
|
-
} else if (typeof createImageBitmap === "function") {
|
|
357
|
-
bitmap = await createImageBitmap(source);
|
|
358
|
-
} else {
|
|
359
|
-
bitmap = source;
|
|
360
|
-
}
|
|
361
|
-
} catch {
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
const id = this.nextId;
|
|
365
|
-
this.nextId += 1;
|
|
366
|
-
return new Promise((resolve) => {
|
|
367
|
-
this.pending.set(id, resolve);
|
|
368
|
-
const message = {
|
|
369
|
-
v: WORKER_PROTOCOL_VERSION,
|
|
370
|
-
type: "detect",
|
|
371
|
-
id,
|
|
372
|
-
bitmap,
|
|
373
|
-
streamWidth: sourceWidth,
|
|
374
|
-
streamHeight: sourceHeight
|
|
375
|
-
};
|
|
376
|
-
this.worker.postMessage(message, [bitmap]);
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
destroy() {
|
|
380
|
-
for (const resolve of this.pending.values()) resolve(null);
|
|
381
|
-
this.pending.clear();
|
|
382
|
-
this.worker.terminate();
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
386
|
-
0 && (module.exports = {
|
|
387
|
-
WORKER_PROTOCOL_VERSION,
|
|
388
|
-
WorkerDetectorProxy,
|
|
389
|
-
installWorkerDetectorHost,
|
|
390
|
-
workerOffloadSupported
|
|
391
|
-
});
|
|
392
|
-
//# sourceMappingURL=detect-worker.cjs.map
|
|
1
|
+
"use strict";var T=Object.create;var d=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},x=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of I(e))!S.call(t,n)&&n!==r&&d(t,n,{get:()=>e[n],enumerable:!(o=F(e,n))||o.enumerable});return t};var L=(t,e,r)=>(r=t!=null?T(E(t)):{},x(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),_=t=>x(d({},"__esModule",{value:!0}),t);var U={};M(U,{WORKER_PROTOCOL_VERSION:()=>u,WorkerDetectorProxy:()=>v,installWorkerDetectorHost:()=>w,workerOffloadSupported:()=>H});module.exports=_(U);var k=1e4,l=class t{constructor(e,r){this.tier="blaze";this.inner=e,r!==void 0&&(this.fallbackReason=r)}static async create(e,r){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),i=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(i,r)}async detect(e,r,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let i=W(n);if(i?.boundingBox===void 0)return null;let a=g(e),s=P(i.keypoints,a),c={box:{x:i.boundingBox.originX,y:i.boundingBox.originY,width:i.boundingBox.width,height:i.boundingBox.height},...s!==void 0?{eyes:s}:{},score:i.categories[0]?.score??0};return m(c,e,r,o)}destroy(){try{this.inner.close()}catch{}}};function W(t){let e,r=-1;for(let o of t){let n=o.categories[0]?.score??0;n>r&&(e=o,r=n)}return e}function P(t,e){let r=t?.[0],o=t?.[1];if(r===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[i,a]=[n(r),n(o)];return i.x<=a.x?{left:i,right:a}:{left:a,right:i}}function B(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function D(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(B()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var f=class{constructor(e,r){this.tier="native";this.inner=e,r!==void 0&&(this.fallbackReason=r)}async detect(e,r,o){let n;try{n=await this.inner.detect(e)}catch{return null}let i=n[0];if(i===void 0)return null;let a=C(i.landmarks),s={box:{x:i.boundingBox.x,y:i.boundingBox.y,width:i.boundingBox.width,height:i.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return m(s,e,r,o)}destroy(){}};function C(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[r,o]=e;if(!(r===void 0||o===void 0))return r.x<=o.x?{left:r,right:o}:{left:o,right:r}}var N="/models-v3",V=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let r=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:r,height:o}}function m(t,e,r,o){let n=g(e),i=n.width>0?r/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*i,y:c.y*a});return{box:{x:t.box.x*i,y:t.box.y*a,width:t.box.width*i,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},score:t.score}}function A(t){return t instanceof Error?t.message:String(t)}async function O(t){let e=t.preferred??V,r=[];for(let o of e){if(o==="native"){let n=await D();if(n.ok)return new f(n.instance,h(r));r.push(`native:${n.reason}`);continue}try{return await z(l.create(t.v3AssetBaseUrl??N,h(r)),t.blazeInitTimeoutMs??k)}catch(n){r.push(n instanceof b?"blaze:blaze_init_timeout":`blaze:${A(n)}`)}}throw new y(h(r)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var b=class extends Error{};function z(t,e){return new Promise((r,o)=>{let n=setTimeout(()=>{o(new b(`init exceeded ${e}ms`)),t.then(i=>i.destroy(),()=>{})},e);t.then(i=>{clearTimeout(n),r(i)},i=>{clearTimeout(n),o(i)})})}var u=1;function H(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function w(t,e={}){let r=e.createDetector??O,o=null;t.onmessage=n=>{let i=n.data;if(i.v!==u){i.bitmap?.close?.();return}if(i.type==="init"){r(i.options).then(a=>{o=a;let s={v:u,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(i.type==="detect"){let a=s=>{let c={v:u,type:"result",id:i.id,observation:s};t.postMessage(c),i.bitmap.close?.()};if(o===null){a(null);return}o.detect(i.bitmap,i.streamWidth,i.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&w(self);var v=class t{constructor(e,r){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=r.tier,r.fallbackReason!==void 0&&(this.fallbackReason=r.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==u||n.type!=="result")return;let i=this.pending.get(n.id);this.pending.delete(n.id),i?.(n.observation)})}static create(e,r,o=1e4){return new Promise((n,i)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),i(new Error(`worker detector not ready within ${o}ms`))},o),s=R=>{let p=R.data;p.v!==u||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:u,type:"init",options:r};e.postMessage(c)})}async detect(e,r,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let i=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(i,a);let s={v:u,type:"detect",id:i,bitmap:n,streamWidth:r,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};0&&(module.exports={WORKER_PROTOCOL_VERSION,WorkerDetectorProxy,installWorkerDetectorHost,workerOffloadSupported});
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WORKER_PROTOCOL_VERSION,
|
|
3
|
-
WorkerDetectorProxy,
|
|
4
|
-
installWorkerDetectorHost,
|
|
5
|
-
workerOffloadSupported
|
|
6
|
-
} from "../../chunk-NWF46H7K.js";
|
|
7
|
-
export {
|
|
8
|
-
WORKER_PROTOCOL_VERSION,
|
|
9
|
-
WorkerDetectorProxy,
|
|
10
|
-
installWorkerDetectorHost,
|
|
11
|
-
workerOffloadSupported
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=detect-worker.js.map
|
|
1
|
+
import{g as a,h as b,i as c,j as d}from"../../chunk-BMA36W2W.js";export{a as WORKER_PROTOCOL_VERSION,d as WorkerDetectorProxy,c as installWorkerDetectorHost,b as workerOffloadSupported};
|