@tradalab/mediakit 1.1.0 → 1.3.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-BMIOUOT3.js +152 -0
- package/dist/chunk-BMIOUOT3.js.map +1 -0
- package/dist/chunk-WRKQ2NFI.js +183 -0
- package/dist/chunk-WRKQ2NFI.js.map +1 -0
- package/dist/index.d.ts +215 -7
- package/dist/index.js +1667 -36
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +164 -0
- package/dist/layout.js +17 -0
- package/dist/layout.js.map +1 -0
- package/dist/mediakit.wasm +0 -0
- package/dist/recipe.d.ts +119 -1
- package/dist/recipe.js +13 -1
- package/dist/whiten_pink.png +0 -0
- package/dist/worker.js +212 -26
- package/dist/worker.js.map +1 -1
- package/package.json +6 -2
- package/dist/chunk-XLLQ74JA.js +0 -112
- package/dist/chunk-XLLQ74JA.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradalab/mediakit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Tradalab realtime camera processing",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"types": "./dist/recipe.d.ts",
|
|
18
18
|
"import": "./dist/recipe.js"
|
|
19
19
|
},
|
|
20
|
+
"./layout": {
|
|
21
|
+
"types": "./dist/layout.d.ts",
|
|
22
|
+
"import": "./dist/layout.js"
|
|
23
|
+
},
|
|
20
24
|
"./package.json": "./package.json"
|
|
21
25
|
},
|
|
22
26
|
"files": [
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"typescript": "^5"
|
|
40
44
|
},
|
|
41
45
|
"scripts": {
|
|
42
|
-
"build": "node -e \"const fs=require('fs');if(fs.existsSync('dist'))for(const f of fs.readdirSync('dist'))if(f.startsWith('chunk-'))fs.rmSync('dist/'+f)\" && tsup",
|
|
46
|
+
"build": "node -e \"const fs=require('fs');if(fs.existsSync('dist'))for(const f of fs.readdirSync('dist'))if(f.startsWith('chunk-'))fs.rmSync('dist/'+f)\" && tsup && node -e \"const fs=require('fs');for(const f of ['whiten_pink.png','NOTICE'])fs.copyFileSync('assets/'+f,'dist/'+f)\"",
|
|
43
47
|
"dev": "tsup --watch",
|
|
44
48
|
"typecheck": "tsc --noEmit",
|
|
45
49
|
"login": "npm login --registry https://registry.npmjs.org/",
|
package/dist/chunk-XLLQ74JA.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// src/recipe.ts
|
|
2
|
-
var NO_EFFECTS = {
|
|
3
|
-
beautify: 0,
|
|
4
|
-
exposure: 0,
|
|
5
|
-
contrast: 0,
|
|
6
|
-
saturation: 0,
|
|
7
|
-
warmth: 0,
|
|
8
|
-
autoframe: false,
|
|
9
|
-
teeth: 0,
|
|
10
|
-
eyeBright: 0,
|
|
11
|
-
underEye: 0,
|
|
12
|
-
smileLines: 0,
|
|
13
|
-
lips: 0,
|
|
14
|
-
lipColor: [0.55, 0.18, 0.24],
|
|
15
|
-
blush: 0,
|
|
16
|
-
blushColor: [0.9, 0.5, 0.42],
|
|
17
|
-
iris: 0,
|
|
18
|
-
irisColor: [0.3, 0.5, 0.75],
|
|
19
|
-
lut: "",
|
|
20
|
-
grade: 0,
|
|
21
|
-
autoLight: false,
|
|
22
|
-
slimFace: 0,
|
|
23
|
-
enlargeEyes: 0,
|
|
24
|
-
noseSlim: 0,
|
|
25
|
-
chin: 0
|
|
26
|
-
};
|
|
27
|
-
function touchUp(amount) {
|
|
28
|
-
const a = Math.min(1, Math.max(0, amount));
|
|
29
|
-
return {
|
|
30
|
-
beautify: a * TOUCH_UP.beautify,
|
|
31
|
-
eyeBright: a * TOUCH_UP.eyeBright,
|
|
32
|
-
underEye: a * TOUCH_UP.underEye,
|
|
33
|
-
smileLines: a * TOUCH_UP.smileLines,
|
|
34
|
-
teeth: a * TOUCH_UP.teeth
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
var TOUCH_UP = {
|
|
38
|
-
beautify: 0.6,
|
|
39
|
-
eyeBright: 0.5,
|
|
40
|
-
underEye: 0.45,
|
|
41
|
-
smileLines: 0.5,
|
|
42
|
-
teeth: 0.4
|
|
43
|
-
};
|
|
44
|
-
function touchUpAmount(e) {
|
|
45
|
-
let a = 0;
|
|
46
|
-
for (const k of Object.keys(TOUCH_UP)) {
|
|
47
|
-
a = Math.max(a, (e[k] ?? 0) / TOUCH_UP[k]);
|
|
48
|
-
}
|
|
49
|
-
return Math.min(1, a);
|
|
50
|
-
}
|
|
51
|
-
var MODE_NONE = 0;
|
|
52
|
-
var MODE_BLUR = 1;
|
|
53
|
-
var MODE_IMAGE = 2;
|
|
54
|
-
function backgroundMode(f) {
|
|
55
|
-
switch (f.kind) {
|
|
56
|
-
case "blur":
|
|
57
|
-
return MODE_BLUR;
|
|
58
|
-
case "image":
|
|
59
|
-
return MODE_IMAGE;
|
|
60
|
-
default:
|
|
61
|
-
return MODE_NONE;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function needsMask(f, e) {
|
|
65
|
-
return f.kind !== "none" || e.beautify > 0 || e.autoframe;
|
|
66
|
-
}
|
|
67
|
-
function needsFace(e) {
|
|
68
|
-
return e.teeth > 0 || e.eyeBright > 0 || e.underEye > 0 || e.smileLines > 0 || e.lips > 0 || e.blush > 0 || e.iris > 0 || e.slimFace > 0 || e.enlargeEyes > 0 || e.noseSlim > 0 || e.chin !== 0;
|
|
69
|
-
}
|
|
70
|
-
function coreRecipe(f, e) {
|
|
71
|
-
return {
|
|
72
|
-
background: backgroundMode(f),
|
|
73
|
-
blurRadius: f.kind === "blur" ? f.blurRadius : 0,
|
|
74
|
-
beautify: e.beautify,
|
|
75
|
-
exposure: e.exposure,
|
|
76
|
-
contrast: e.contrast,
|
|
77
|
-
saturation: e.saturation,
|
|
78
|
-
warmth: e.warmth,
|
|
79
|
-
autoframe: e.autoframe,
|
|
80
|
-
teeth: e.teeth,
|
|
81
|
-
eyeBright: e.eyeBright,
|
|
82
|
-
underEye: e.underEye,
|
|
83
|
-
smileLines: e.smileLines,
|
|
84
|
-
lips: e.lips,
|
|
85
|
-
lipColor: e.lipColor,
|
|
86
|
-
blush: e.blush,
|
|
87
|
-
blushColor: e.blushColor,
|
|
88
|
-
iris: e.iris,
|
|
89
|
-
irisColor: e.irisColor,
|
|
90
|
-
grade: e.grade,
|
|
91
|
-
autoLight: e.autoLight,
|
|
92
|
-
slimFace: e.slimFace,
|
|
93
|
-
enlargeEyes: e.enlargeEyes,
|
|
94
|
-
noseSlim: e.noseSlim,
|
|
95
|
-
chin: e.chin
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export {
|
|
100
|
-
NO_EFFECTS,
|
|
101
|
-
touchUp,
|
|
102
|
-
TOUCH_UP,
|
|
103
|
-
touchUpAmount,
|
|
104
|
-
MODE_NONE,
|
|
105
|
-
MODE_BLUR,
|
|
106
|
-
MODE_IMAGE,
|
|
107
|
-
backgroundMode,
|
|
108
|
-
needsMask,
|
|
109
|
-
needsFace,
|
|
110
|
-
coreRecipe
|
|
111
|
-
};
|
|
112
|
-
//# sourceMappingURL=chunk-XLLQ74JA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/recipe.ts"],"sourcesContent":["/**\n * The bridge between what the user picked and the recipe the Go core takes.\n *\n * Both halves live here because both map onto `core.Recipe` field for field: BgFilter carries\n * the background mode and its one parameter, Effects carries everything else. They are two\n * types rather than one because the UI edits them from two different places - a preset picker\n * and a slider panel - not because they belong to different layers.\n */\n\n/**\n * What replaces the background.\n *\n * `imagePath` is a URL the consuming app serves: a path under its own public root, or a data\n * URL for something the user uploaded. The Engine fetches it and cover-crops it to the frame\n * aspect, so any shape is safe to pass.\n */\nexport type BgFilter =\n | { kind: \"none\" }\n | { kind: \"blur\"; blurRadius: number }\n | { kind: \"image\"; imagePath: string }\n\n/** A colour as red, green, blue, each 0..1. */\nexport type Rgb = [number, number, number]\n\nexport interface Effects {\n /** Skin smoothing, 0..1. Needs the person mask, so it pulls in the segmentation cost. */\n beautify: number\n /** Exposure, -1..1. Positive lifts the shadows more than the highlights. */\n exposure: number\n /** Contrast, -1..1. */\n contrast: number\n /** Saturation, -1..1. */\n saturation: number\n /** Warm (positive) or cool (negative), -1..1. */\n warmth: number\n /** Keep the person framed. Needs the person mask. */\n autoframe: boolean\n\n // ── Need FACE landmarks ──────────────────────────────────────────────────────────\n /** Teeth whitening, 0..1. */\n teeth: number\n /** Brighten the whites of the eyes, 0..1. */\n eyeBright: number\n /** Reduce under-eye shadow, 0..1. */\n underEye: number\n /** Soften the nasolabial folds, 0..1. */\n smileLines: number\n\n /**\n * Makeup, 0..1 each, in its colour. Drawn against the full landmark mesh, so the lip tint\n * follows the lip line rather than an ellipse. Not offered in meet, like reshaping.\n */\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n /** Iris colour: the ring only, clipped by the eyelids, the pupil left black. */\n iris: number\n irisColor: Rgb\n\n /**\n * A colour LUT: `lut` is a URL the host serves (a 512x512 \"lookup\" PNG, 64 levels, 8x8 tiles,\n * row 0 at the top), `grade` how strongly it applies. \"\" means none.\n */\n lut: string\n grade: number\n\n /**\n * Lift exposure when the room is dark, on top of `exposure`. Only ever brightens. Needs no\n * detector: it reads the frame's own brightness.\n */\n autoLight: boolean\n\n /**\n * Jawline slimming, 0..1.\n *\n * Deliberately NOT offered in meet: Zoom, Google Meet and Teams all ship without face\n * reshaping, and in a work setting it reads as unserious. The field is here because the\n * second consumer of mediakit is slate, where reshaping is ordinary.\n */\n slimFace: number\n /** Eye enlargement, 0..1. Withheld from meet for the same reason as slimFace. */\n enlargeEyes: number\n /** Nose narrowing, 0..1. Withheld from meet like slimFace. */\n noseSlim: number\n /** Chin length, -1 (shorter) .. 1 (longer). Withheld from meet like slimFace. */\n chin: number\n}\n\nexport const NO_EFFECTS: Effects = {\n beautify: 0,\n exposure: 0,\n contrast: 0,\n saturation: 0,\n warmth: 0,\n autoframe: false,\n teeth: 0,\n eyeBright: 0,\n underEye: 0,\n smileLines: 0,\n lips: 0,\n lipColor: [0.55, 0.18, 0.24],\n blush: 0,\n blushColor: [0.9, 0.5, 0.42],\n iris: 0,\n irisColor: [0.3, 0.5, 0.75],\n lut: \"\",\n grade: 0,\n autoLight: false,\n slimFace: 0,\n enlargeEyes: 0,\n noseSlim: 0,\n chin: 0,\n}\n\n/**\n * One knob for \"look a little fresher\": skin, eyes, under-eyes, smile lines and teeth, moved\n * together in proportions tuned to read as rested rather than filtered at 1.\n *\n * A host that shows this instead of five sliders gets the shape Zoom and TikTok ship - people\n * reach for one control, not five, and five half-understood knobs mostly get set too high. The\n * ratios live here, next to the fields they drive, so every host means the same thing by it.\n */\nexport function touchUp(amount: number): Pick<Effects, \"beautify\" | \"eyeBright\" | \"underEye\" | \"smileLines\" | \"teeth\"> {\n const a = Math.min(1, Math.max(0, amount))\n return {\n beautify: a * TOUCH_UP.beautify,\n eyeBright: a * TOUCH_UP.eyeBright,\n underEye: a * TOUCH_UP.underEye,\n smileLines: a * TOUCH_UP.smileLines,\n teeth: a * TOUCH_UP.teeth,\n }\n}\n\n/** What `touchUp(1)` sets. Exported so a host can read a stored recipe back into one knob. */\nexport const TOUCH_UP = {\n beautify: 0.6,\n eyeBright: 0.5,\n underEye: 0.45,\n smileLines: 0.5,\n teeth: 0.4,\n} as const\n\n/**\n * The touch-up position a recipe corresponds to: the LARGEST of its five fields relative to\n * `touchUp(1)`. A recipe whose fields were set one by one has no single answer, and reading one\n * field only would show 0 for a recipe still whitening teeth - a knob at 0 that cannot turn off\n * what is running. Taking the largest, any effect still on shows, and moving the knob rewrites\n * all five consistently.\n */\nexport function touchUpAmount(e: Effects): number {\n let a = 0\n for (const k of Object.keys(TOUCH_UP) as (keyof typeof TOUCH_UP)[]) {\n a = Math.max(a, (e[k] ?? 0) / TOUCH_UP[k])\n }\n return Math.min(1, a)\n}\n\n/** Go-side `BackgroundMode`. Must match `core/recipe.go`. */\nexport const MODE_NONE = 0\nexport const MODE_BLUR = 1\nexport const MODE_IMAGE = 2\n\nexport function backgroundMode(f: BgFilter): number {\n switch (f.kind) {\n case \"blur\":\n return MODE_BLUR\n case \"image\":\n return MODE_IMAGE\n default:\n return MODE_NONE\n }\n}\n\n/**\n * Whether this recipe needs the person mask.\n *\n * Must match `Recipe.NeedsMask` on the Go side. This is the single biggest saving in the\n * module: a colour-only recipe skips MediaPipe entirely - the most expensive part of a frame,\n * and 9 MB of wasm the user then never downloads.\n *\n * The Go version is authoritative; this one exists so the JS side knows whether to load the\n * segmenter at all, BEFORE it can ask Go.\n */\nexport function needsMask(f: BgFilter, e: Effects): boolean {\n return f.kind !== \"none\" || e.beautify > 0 || e.autoframe\n}\n\n/**\n * Whether this recipe needs face landmarks.\n *\n * Must match `Recipe.NeedsFace` on the Go side. Split from {@link needsMask} because the two\n * detectors are independent costs, and the landmark model is 15 times the size of the\n * segmentation one - making someone who only wants a blurred background download it is waste\n * that shows up on the first load.\n */\nexport function needsFace(e: Effects): boolean {\n return (\n e.teeth > 0 ||\n e.eyeBright > 0 ||\n e.underEye > 0 ||\n e.smileLines > 0 ||\n e.lips > 0 ||\n e.blush > 0 ||\n e.iris > 0 ||\n e.slimFace > 0 ||\n e.enlargeEyes > 0 ||\n e.noseSlim > 0 ||\n e.chin !== 0\n )\n}\n\n/** The recipe in the shape the Go core takes. Field names must match `setRecipe` in wasmjs/main.go. */\nexport interface CoreRecipe {\n background: number\n blurRadius: number\n beautify: number\n exposure: number\n contrast: number\n saturation: number\n warmth: number\n autoframe: boolean\n teeth: number\n eyeBright: number\n underEye: number\n smileLines: number\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n iris: number\n irisColor: Rgb\n grade: number\n autoLight: boolean\n slimFace: number\n enlargeEyes: number\n noseSlim: number\n chin: number\n}\n\nexport function coreRecipe(f: BgFilter, e: Effects): CoreRecipe {\n return {\n background: backgroundMode(f),\n blurRadius: f.kind === \"blur\" ? f.blurRadius : 0,\n beautify: e.beautify,\n exposure: e.exposure,\n contrast: e.contrast,\n saturation: e.saturation,\n warmth: e.warmth,\n autoframe: e.autoframe,\n teeth: e.teeth,\n eyeBright: e.eyeBright,\n underEye: e.underEye,\n smileLines: e.smileLines,\n lips: e.lips,\n lipColor: e.lipColor,\n blush: e.blush,\n blushColor: e.blushColor,\n iris: e.iris,\n irisColor: e.irisColor,\n grade: e.grade,\n autoLight: e.autoLight,\n slimFace: e.slimFace,\n enlargeEyes: e.enlargeEyes,\n noseSlim: e.noseSlim,\n chin: e.chin,\n }\n}\n"],"mappings":";AAyFO,IAAM,aAAsB;AAAA,EAC/B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,UAAU,CAAC,MAAM,MAAM,IAAI;AAAA,EAC3B,OAAO;AAAA,EACP,YAAY,CAAC,KAAK,KAAK,IAAI;AAAA,EAC3B,MAAM;AAAA,EACN,WAAW,CAAC,KAAK,KAAK,IAAI;AAAA,EAC1B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb,UAAU;AAAA,EACV,MAAM;AACV;AAUO,SAAS,QAAQ,QAA+F;AACnH,QAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC;AACzC,SAAO;AAAA,IACH,UAAU,IAAI,SAAS;AAAA,IACvB,WAAW,IAAI,SAAS;AAAA,IACxB,UAAU,IAAI,SAAS;AAAA,IACvB,YAAY,IAAI,SAAS;AAAA,IACzB,OAAO,IAAI,SAAS;AAAA,EACxB;AAC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