@tradalab/mediakit 1.0.0 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradalab/mediakit",
3
- "version": "1.0.0",
3
+ "version": "1.2.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": "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",
43
47
  "dev": "tsup --watch",
44
48
  "typecheck": "tsc --noEmit",
45
49
  "login": "npm login --registry https://registry.npmjs.org/",
@@ -1,62 +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
- slimFace: 0,
13
- enlargeEyes: 0
14
- };
15
- var MODE_NONE = 0;
16
- var MODE_BLUR = 1;
17
- var MODE_IMAGE = 2;
18
- function backgroundMode(f) {
19
- switch (f.kind) {
20
- case "blur":
21
- return MODE_BLUR;
22
- case "image":
23
- return MODE_IMAGE;
24
- default:
25
- return MODE_NONE;
26
- }
27
- }
28
- function needsMask(f, e) {
29
- return f.kind !== "none" || e.beautify > 0 || e.autoframe;
30
- }
31
- function needsFace(e) {
32
- return e.teeth > 0 || e.eyeBright > 0 || e.underEye > 0 || e.slimFace > 0 || e.enlargeEyes > 0;
33
- }
34
- function coreRecipe(f, e) {
35
- return {
36
- background: backgroundMode(f),
37
- blurRadius: f.kind === "blur" ? f.blurRadius : 0,
38
- beautify: e.beautify,
39
- exposure: e.exposure,
40
- contrast: e.contrast,
41
- saturation: e.saturation,
42
- warmth: e.warmth,
43
- autoframe: e.autoframe,
44
- teeth: e.teeth,
45
- eyeBright: e.eyeBright,
46
- underEye: e.underEye,
47
- slimFace: e.slimFace,
48
- enlargeEyes: e.enlargeEyes
49
- };
50
- }
51
-
52
- export {
53
- NO_EFFECTS,
54
- MODE_NONE,
55
- MODE_BLUR,
56
- MODE_IMAGE,
57
- backgroundMode,
58
- needsMask,
59
- needsFace,
60
- coreRecipe
61
- };
62
- //# sourceMappingURL=chunk-5KXLFDFV.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\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\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}\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 slimFace: 0,\n enlargeEyes: 0,\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 || e.eyeBright > 0 || e.underEye > 0 || e.slimFace > 0 || e.enlargeEyes > 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 slimFace: number\n enlargeEyes: 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 slimFace: e.slimFace,\n enlargeEyes: e.enlargeEyes,\n }\n}\n"],"mappings":";AAuDO,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,UAAU;AAAA,EACV,aAAa;AACjB;AAGO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,aAAa;AAEnB,SAAS,eAAe,GAAqB;AAChD,UAAQ,EAAE,MAAM;AAAA,IACZ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EACf;AACJ;AAYO,SAAS,UAAU,GAAa,GAAqB;AACxD,SAAO,EAAE,SAAS,UAAU,EAAE,WAAW,KAAK,EAAE;AACpD;AAUO,SAAS,UAAU,GAAqB;AAC3C,SACI,EAAE,QAAQ,KAAK,EAAE,YAAY,KAAK,EAAE,WAAW,KAAK,EAAE,WAAW,KAAK,EAAE,cAAc;AAE9F;AAmBO,SAAS,WAAW,GAAa,GAAwB;AAC5D,SAAO;AAAA,IACH,YAAY,eAAe,CAAC;AAAA,IAC5B,YAAY,EAAE,SAAS,SAAS,EAAE,aAAa;AAAA,IAC/C,UAAU,EAAE;AAAA,IACZ,UAAU,EAAE;AAAA,IACZ,UAAU,EAAE;AAAA,IACZ,YAAY,EAAE;AAAA,IACd,QAAQ,EAAE;AAAA,IACV,WAAW,EAAE;AAAA,IACb,OAAO,EAAE;AAAA,IACT,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IACZ,UAAU,EAAE;AAAA,IACZ,aAAa,EAAE;AAAA,EACnB;AACJ;","names":[]}