@vincentt-xr/sdk 2.0.0-alpha.22 → 2.0.0-alpha.23

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.
Files changed (90) hide show
  1. package/GROUNDING.md +138 -2
  2. package/components.json +61 -1
  3. package/dist/{CanonicalHeadFrame-S3Jk9F1P.js → CanonicalHeadFrame-ZSfpHH_w.js} +15 -15
  4. package/dist/{DebuggerUI-B8bheFk-.js → DebuggerUI-C_c1B-2p.js} +1 -1
  5. package/dist/{FaceRetouch-DW_9g5EA.js → FaceRetouch-4tV3RYa-.js} +4 -4
  6. package/dist/{TextLabel-C-AibH5A.cjs → TextLabel-DWBSNwRA.cjs} +2 -2
  7. package/dist/{TextLabel-fEF1o3wE.js → TextLabel-XSfkeWDJ.js} +172 -172
  8. package/dist/{bodyMaskMaterial-CUlzyXnJ.js → bodyMaskMaterial-BF6Gm6hz.js} +1 -1
  9. package/dist/cache-CbX-0Rgn.js +212 -0
  10. package/dist/cache-DFqZYsHC.cjs +1 -0
  11. package/dist/components/CaptureShareScreen/index.d.ts +27 -0
  12. package/dist/components/HtmlRegion/index.d.ts +1 -1
  13. package/dist/components/IntroScreen/index.d.ts +31 -0
  14. package/dist/components/ScreenShape/index.d.ts +8 -0
  15. package/dist/components/SplashScreen/index.d.ts +38 -0
  16. package/dist/components/TextLabel/TextLabel.d.ts +3 -0
  17. package/dist/components/index.d.ts +3 -0
  18. package/dist/contexts-awO81p6d.cjs +1 -0
  19. package/dist/contexts-hhxufDg2.js +714 -0
  20. package/dist/debug-ui/media-source.js +1 -1
  21. package/dist/debug-ui.cjs +1 -1
  22. package/dist/debug-ui.js +11 -11
  23. package/dist/{drawNormalizedCrop-D48Layv4.js → drawNormalizedCrop-8RzfrVNS.js} +14 -14
  24. package/dist/editor-defs/live.d.ts +10 -0
  25. package/dist/editor-defs/types.d.ts +1 -1
  26. package/dist/editor-scenes.cjs +1 -1
  27. package/dist/editor-scenes.js +419 -40
  28. package/dist/entries/core.d.ts +10 -0
  29. package/dist/entries/editor-scenes.d.ts +1 -6
  30. package/dist/face-effects.cjs +78 -78
  31. package/dist/face-effects.js +277 -276
  32. package/dist/{getFaceInfo-e9XzHPLC.js → getFaceInfo-B1pPvyh9.js} +1 -1
  33. package/dist/hooks/captureStore.d.ts +25 -0
  34. package/dist/hooks/useCapture.d.ts +28 -0
  35. package/dist/hooks/useShare.d.ts +37 -0
  36. package/dist/{index-Dk1UOe-H.js → index-BTVIMj8H.js} +10 -10
  37. package/dist/{index-MzlPbe9t.js → index-BmeB_V6I.js} +57 -57
  38. package/dist/{index-B9ph9k5I.js → index-CW4yk2jC.js} +272 -263
  39. package/dist/{index-em1AaMkI.js → index-Cw6HeUjE.js} +1 -1
  40. package/dist/{index-BKZPBg1D.js → index-DSrRFuRp.js} +1 -1
  41. package/dist/{index-DCjFgbB8.js → index-DTkbQ5OA.js} +24 -24
  42. package/dist/{index-B34w-TyW.js → index-Dmhh2RjM.js} +1 -1
  43. package/dist/index-hEANh5cP.cjs +21 -0
  44. package/dist/{index-DSMv6GWI.cjs → index-rCxTueDx.cjs} +1 -1
  45. package/dist/instructions.cjs +1 -1
  46. package/dist/instructions.js +8 -8
  47. package/dist/{internal-kwJxojDs.js → internal-DDcTDvPS.js} +3 -3
  48. package/dist/internal.js +2 -2
  49. package/dist/{landmarks-BgLF-yfd.js → landmarks-BB8jyfJA.js} +6 -6
  50. package/dist/live.generated-Do4jgrUN.js +116 -0
  51. package/dist/live.generated-n5ZV_2Gt.cjs +1 -0
  52. package/dist/low-level.cjs +1 -1
  53. package/dist/low-level.js +17 -17
  54. package/dist/main.cjs +1 -1
  55. package/dist/main.js +1074 -878
  56. package/dist/overlay/consumer.d.ts +36 -0
  57. package/dist/overlay/grammar.d.ts +74 -0
  58. package/dist/overlay/region.d.ts +23 -0
  59. package/dist/particles.js +5 -5
  60. package/dist/product.js +2 -2
  61. package/dist/{providers-Bo1gfoXg.js → providers-Q4H0Ii-y.js} +3 -3
  62. package/dist/{renderGroups-Cul4eOG8.js → renderGroups-LVQ0Af0t.js} +1 -1
  63. package/dist/{renderPasses-CLOTeP38.js → renderPasses-DYc2-EBT.js} +43 -43
  64. package/dist/scene-object.cjs +1 -1
  65. package/dist/scene-object.js +2 -2
  66. package/dist/{segmentation-Q1eXSt_x.js → segmentation-BWHRt2hE.js} +1 -1
  67. package/dist/{selectors-CiawE6Ox.js → selectors-kj5g3uv2.js} +6 -6
  68. package/dist/{session-CmpigDxI.js → session-CMz1ao3i.js} +9 -9
  69. package/dist/tracking.js +127 -127
  70. package/dist/{trigger-BHKfnvtB.js → trigger-8fpI9g9S.js} +7 -7
  71. package/dist/{useBodies-DzRzQg88.js → useBodies-CH4ZUECn.js} +7 -7
  72. package/dist/useEditOverrides-BmvpLYPU.js +85 -0
  73. package/dist/useEditOverrides-DMAMGzlF.cjs +1 -0
  74. package/dist/{useFaceInfo-DUxqnPek.js → useFaceInfo-BV77B-r4.js} +10 -10
  75. package/dist/{useFaceResultReader-DSnUjQcw.js → useFaceResultReader-DgOPK1Z6.js} +1 -1
  76. package/dist/{useIrisTracking-Bfp1Fv66.js → useIrisTracking-D6mv7coz.js} +10 -10
  77. package/dist/useLiveProps-Bz9wifGN.cjs +1 -0
  78. package/dist/useLiveProps-CMkyV6Dt.js +28 -0
  79. package/dist/{useXRCapabilities-BhN_CKwJ.js → useXRCapabilities-FAY2ve86.js} +1 -1
  80. package/dist/utils/useEditOverlay.d.ts +33 -0
  81. package/dist/utils/useEditOverrides.d.ts +6 -0
  82. package/package.json +1 -1
  83. package/settings.json +1 -1
  84. package/dist/cache-CsH3zPDX.js +0 -307
  85. package/dist/cache-DrEDi7qn.cjs +0 -1
  86. package/dist/contexts-CSz9stBV.cjs +0 -1
  87. package/dist/contexts-C_l5hzI8.js +0 -667
  88. package/dist/index-BkjRuUdW.cjs +0 -21
  89. package/dist/useEditOverrides-BBkK8cN2.js +0 -41
  90. package/dist/useEditOverrides-CgapHJzA.cjs +0 -1
@@ -1,7 +1,7 @@
1
1
  import { useFrame as S } from "@react-three/fiber";
2
- import { useState as E, useRef as f, useCallback as M, useId as g, useEffect as h } from "react";
3
- import { E as p, b as j, e as C, X as m, f as I } from "./index-MzlPbe9t.js";
4
- import { u as v } from "./landmarks-BgLF-yfd.js";
2
+ import { useState as g, useRef as f, useCallback as M, useId as h, useEffect as j } from "react";
3
+ import { f as p, g as C, h as E, X as m, j as I } from "./index-BmeB_V6I.js";
4
+ import { u as v } from "./landmarks-BB8jyfJA.js";
5
5
  const X = (t, o) => {
6
6
  var r;
7
7
  for (let n = 0; n < m.body.max; n += 1)
@@ -13,7 +13,7 @@ const X = (t, o) => {
13
13
  if (r !== void 0)
14
14
  return { body: i(s.find((e) => e.id === r)), memory: u };
15
15
  if (n) {
16
- const e = j(C(s), n, u);
16
+ const e = C(E(s), n, u);
17
17
  return {
18
18
  body: e.index === null ? null : i(s[e.index]),
19
19
  memory: e.memory
@@ -24,7 +24,7 @@ const X = (t, o) => {
24
24
  const l = s.find((e) => e.pose === c);
25
25
  return { body: { pose: c, id: (l == null ? void 0 : l.id) ?? null, held: !1, index: o }, memory: u };
26
26
  }, R = (t, o = !0, r) => {
27
- const n = g(), { ready: u, node: s } = v(
27
+ const n = h(), { ready: u, node: s } = v(
28
28
  I.BODY_TRACKER,
29
29
  r,
30
30
  o
@@ -32,7 +32,7 @@ const X = (t, o) => {
32
32
  m.body.max,
33
33
  Math.max(1, Number.isFinite(t) ? Math.round(t) : 1)
34
34
  );
35
- return h(() => {
35
+ return j(() => {
36
36
  var c;
37
37
  return (c = s == null ? void 0 : s.requestBodies) == null ? void 0 : c.call(s, n, i);
38
38
  }, [s, n, i]), { ready: u, node: s };
@@ -40,7 +40,7 @@ const X = (t, o) => {
40
40
  numBodies: t = m.body.max,
41
41
  active: o = !0
42
42
  } = {}) => {
43
- const { node: r } = R(t, o), [n, u] = E([]), s = f("");
43
+ const { node: r } = R(t, o), [n, u] = g([]), s = f("");
44
44
  return S(() => {
45
45
  var l;
46
46
  const i = (((l = r == null ? void 0 : r.getBodies) == null ? void 0 : l.call(r)) ?? []).map((d) => d.id), c = i.join(",");
@@ -0,0 +1,85 @@
1
+ import { useSyncExternalStore as b } from "react";
2
+ let s;
3
+ function P(t) {
4
+ s = t;
5
+ }
6
+ const y = () => () => {
7
+ }, l = () => {
8
+ }, d = () => 0;
9
+ function g(t, o, n) {
10
+ const e = s;
11
+ return b(
12
+ e ? e.subscribe : y,
13
+ e ? () => e.slice(t) : l,
14
+ l
15
+ ), e == null ? void 0 : e.resolve(t, o, n);
16
+ }
17
+ function R(t, o) {
18
+ var e;
19
+ const n = s;
20
+ return b(
21
+ n ? n.subscribe : y,
22
+ n ? () => n.slice(t) : l,
23
+ l
24
+ ), (e = n == null ? void 0 : n.region) == null ? void 0 : e.call(n, t, o);
25
+ }
26
+ function A() {
27
+ const t = s;
28
+ return b(t ? t.subscribe : y, t ? t.version : d, d);
29
+ }
30
+ function D(t, o, n) {
31
+ return s == null ? void 0 : s.resolve(t, o, n);
32
+ }
33
+ const v = "__VCT_EDIT_OVERRIDES__";
34
+ function S() {
35
+ const t = globalThis[v];
36
+ return t && typeof t.subscribe == "function" && typeof t.version == "function" && typeof t.get == "function" ? t : void 0;
37
+ }
38
+ const I = (t) => typeof t == "number" && Number.isFinite(t), L = (t) => typeof t == "string" && /^#[0-9a-fA-F]{6}$/.test(t), _ = () => () => {
39
+ }, E = () => 0, j = (t) => typeof t == "object" && t !== null && !Array.isArray(t) && (Object.getPrototypeOf(t) === Object.prototype || Object.getPrototypeOf(t) === null);
40
+ function V(t, o, n) {
41
+ let e = t;
42
+ for (let r = 0; r < o.length - 1; r += 1) {
43
+ const c = e[o[r]];
44
+ if (!j(c)) return !1;
45
+ const i = { ...c };
46
+ e[o[r]] = i, e = i;
47
+ }
48
+ return e[o[o.length - 1]] = n, !0;
49
+ }
50
+ function T(t, o, n) {
51
+ const e = S();
52
+ b(
53
+ e ? e.subscribe : _,
54
+ e ? e.version : E,
55
+ E
56
+ );
57
+ const r = g(
58
+ t,
59
+ o,
60
+ n
61
+ ), c = e == null ? void 0 : e.get(t);
62
+ if (!r && !c) return t;
63
+ let i = null;
64
+ for (const f of [r, c])
65
+ if (f)
66
+ for (const u of o) {
67
+ if (!Object.prototype.hasOwnProperty.call(f, u)) continue;
68
+ const a = n == null ? void 0 : n[u];
69
+ if (a && !a(f[u])) continue;
70
+ const O = i ?? { ...t };
71
+ V(O, u.split("."), f[u]) && (i = O);
72
+ }
73
+ return i ?? t;
74
+ }
75
+ export {
76
+ P as a,
77
+ A as b,
78
+ I as c,
79
+ R as d,
80
+ S as e,
81
+ L as i,
82
+ D as r,
83
+ V as s,
84
+ T as u
85
+ };
@@ -0,0 +1 @@
1
+ "use strict";const y=require("react");let i;function g(e){i=e}const b=()=>()=>{},f=()=>{},a=()=>0;function _(e,o,n){const t=i;return y.useSyncExternalStore(t?t.subscribe:b,t?()=>t.slice(e):f,f),t==null?void 0:t.resolve(e,o,n)}function R(e,o){var t;const n=i;return y.useSyncExternalStore(n?n.subscribe:b,n?()=>n.slice(e):f,f),(t=n==null?void 0:n.region)==null?void 0:t.call(n,e,o)}function V(){const e=i;return y.useSyncExternalStore(e?e.subscribe:b,e?e.version:a,a)}function j(e,o,n){return i==null?void 0:i.resolve(e,o,n)}const L="__VCT_EDIT_OVERRIDES__";function d(){const e=globalThis[L];return e&&typeof e.subscribe=="function"&&typeof e.version=="function"&&typeof e.get=="function"?e:void 0}const P=e=>typeof e=="number"&&Number.isFinite(e),x=e=>typeof e=="string"&&/^#[0-9a-fA-F]{6}$/.test(e),h=()=>()=>{},v=()=>0,m=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function S(e,o,n){let t=e;for(let r=0;r<o.length-1;r+=1){const u=t[o[r]];if(!m(u))return!1;const s={...u};t[o[r]]=s,t=s}return t[o[o.length-1]]=n,!0}function A(e,o,n){const t=d();y.useSyncExternalStore(t?t.subscribe:h,t?t.version:v,v);const r=_(e,o,n),u=t==null?void 0:t.get(e);if(!r&&!u)return e;let s=null;for(const l of[r,u])if(l)for(const c of o){if(!Object.prototype.hasOwnProperty.call(l,c))continue;const O=n==null?void 0:n[c];if(O&&!O(l[c]))continue;const E=s??{...e};S(E,c.split("."),l[c])&&(s=E)}return s??e}exports.editStore=d;exports.isLiveColour=x;exports.isLiveNumber=P;exports.resolveEditOverlay=j;exports.setOverlaySlot=g;exports.setPath=S;exports.useEditOverlayVersion=V;exports.useEditOverrides=A;exports.useEditRegion=R;
@@ -1,9 +1,9 @@
1
- import { useMemo as x, useEffect as h, useCallback as p, useRef as E } from "react";
2
- import { X as R, f as b, E as C, b as N } from "./index-MzlPbe9t.js";
3
- import { useThree as _ } from "@react-three/fiber";
4
- import { g as y } from "./getFaceInfo-e9XzHPLC.js";
5
- import { u as T } from "./useFaceResultReader-DSnUjQcw.js";
6
- import { u as S } from "./landmarks-BgLF-yfd.js";
1
+ import { useMemo as x, useEffect as h, useCallback as p, useRef as R } from "react";
2
+ import { X as E, j as C, f as N, g as _ } from "./index-BmeB_V6I.js";
3
+ import { useThree as b } from "@react-three/fiber";
4
+ import { g as y } from "./getFaceInfo-B1pPvyh9.js";
5
+ import { u as T } from "./useFaceResultReader-DgOPK1Z6.js";
6
+ import { u as S } from "./landmarks-BB8jyfJA.js";
7
7
  const X = ({
8
8
  active: i = !0,
9
9
  holdMs: l = 250,
@@ -11,14 +11,14 @@ const X = ({
11
11
  targetFps: s,
12
12
  throttleMs: o = 16
13
13
  } = {}) => {
14
- const { camera: t } = _(), u = Number.isFinite(r) ? Math.min(R.face.max, Math.max(1, Math.round(r))) : 1, m = s !== void 0 && Number.isFinite(s) && s > 0 ? s : void 0, e = x(
14
+ const { camera: t } = b(), u = Number.isFinite(r) ? Math.min(E.face.max, Math.max(1, Math.round(r))) : 1, m = s !== void 0 && Number.isFinite(s) && s > 0 ? s : void 0, e = x(
15
15
  () => ({
16
16
  numFaces: u,
17
17
  ...m ? { targetFps: m } : {}
18
18
  }),
19
19
  [u, m]
20
20
  ), { node: n, ready: c } = S(
21
- b.FACE_TRACKER,
21
+ C.FACE_TRACKER,
22
22
  e,
23
23
  i
24
24
  );
@@ -55,14 +55,14 @@ const X = ({
55
55
  const o = Number.isFinite(i) ? Math.max(0, Math.round(i)) : 0, t = X({
56
56
  ...s,
57
57
  numFaces: Math.max(l ?? (r ? A : o + 1), o + 1)
58
- }), u = E(C), m = JSON.stringify(r ?? null), e = x(() => {
58
+ }), u = R(N), m = JSON.stringify(r ?? null), e = x(() => {
59
59
  if (!r) return null;
60
60
  const n = t.map((c, d) => ({
61
61
  index: d,
62
62
  center: { x: c.bounds.centerX, y: c.bounds.centerY },
63
63
  size: c.bounds.width
64
64
  }));
65
- return N(n, r, u.current);
65
+ return _(n, r, u.current);
66
66
  }, [t, m]);
67
67
  return h(() => {
68
68
  e && (u.current = e.memory);
@@ -1,5 +1,5 @@
1
1
  import { useState as E, useEffect as N } from "react";
2
- import { c as P } from "./getFaceInfo-e9XzHPLC.js";
2
+ import { c as P } from "./getFaceInfo-B1pPvyh9.js";
3
3
  const S = (t, i) => t.map((e) => ({
4
4
  landmarks: e,
5
5
  bounds: P(e)
@@ -2,25 +2,25 @@ var Gt = Object.defineProperty;
2
2
  var Xt = (t, e, s) => e in t ? Gt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
3
  var m = (t, e, s) => Xt(t, typeof e != "symbol" ? e + "" : e, s);
4
4
  import * as o from "three";
5
- import { t as $, g as kt, n as Te, J as ie, f as Tt, u as Kt, I as Yt, i as Qt, C as Ze } from "./index-MzlPbe9t.js";
6
- import { C as _, b as He, c as $t, d as Zt, a as Jt, e as e0, u as t0 } from "./CanonicalHeadFrame-S3Jk9F1P.js";
7
- import { b as s0, a as r0, d as n0, e as a0, t as Ee, c as o0, s as Je } from "./index-B34w-TyW.js";
8
- import { a as i0, g as l0, d as P } from "./getFaceInfo-e9XzHPLC.js";
5
+ import { t as $, k as kt, n as Te, J as ie, j as Tt, u as Kt, I as Yt, i as Qt, C as Ze } from "./index-BmeB_V6I.js";
6
+ import { C as _, b as He, c as $t, d as Zt, a as Jt, e as e0, u as t0 } from "./CanonicalHeadFrame-ZSfpHH_w.js";
7
+ import { b as s0, a as r0, d as n0, e as a0, t as Ee, c as o0, s as Je } from "./index-Dmhh2RjM.js";
8
+ import { a as i0, g as l0, d as P } from "./getFaceInfo-B1pPvyh9.js";
9
9
  import { s as et, a as c0, L as u0, u as d0 } from "./useLandmarkPoseFit-Bmb3h6Mw.js";
10
10
  import { s as h0 } from "./similarityFit-Bbz-R8AY.js";
11
11
  import { C as z } from "./canonicalFace-BHwyCx1c.js";
12
12
  import { b as he, r as f0, a as p0, M as be } from "./renderState-CJNmj5jz.js";
13
13
  import { jsx as k, jsxs as m0, Fragment as g0 } from "react/jsx-runtime";
14
14
  import { useRef as T, useCallback as Nt, useMemo as oe, useState as Oe, useEffect as q, useContext as S0 } from "react";
15
- import { c as Ke } from "./segmentation-Q1eXSt_x.js";
15
+ import { c as Ke } from "./segmentation-BWHRt2hE.js";
16
16
  import { useThree as Ce, useFrame as Ut } from "@react-three/fiber";
17
17
  import { c as w0 } from "./SkeletonUtils-C2r90MtN.js";
18
- import { T as A0, u as Dt } from "./index-Dk1UOe-H.js";
18
+ import { T as A0, u as Dt } from "./index-BTVIMj8H.js";
19
19
  import { R as y0 } from "./uv-DJU_XfmN.js";
20
- import { f as v0, u as R0 } from "./selectors-CiawE6Ox.js";
21
- import { u as M0 } from "./useBodies-DzRzQg88.js";
22
- import { c as E0, I as b0, u as tt } from "./providers-Bo1gfoXg.js";
23
- import { u as C0 } from "./landmarks-BgLF-yfd.js";
20
+ import { e as v0, b as R0 } from "./selectors-kj5g3uv2.js";
21
+ import { u as M0 } from "./useBodies-CH4ZUECn.js";
22
+ import { c as E0, I as b0, u as tt } from "./providers-Q4H0Ii-y.js";
23
+ import { u as C0 } from "./landmarks-BB8jyfJA.js";
24
24
  const x0 = {
25
25
  "body.head": 0,
26
26
  "body.leftShoulder": 11,
@@ -0,0 +1 @@
1
+ "use strict";const u=require("./live.generated-n5ZV_2Gt.cjs"),v=require("./useEditOverrides-DMAMGzlF.cjs"),p=new Map;function d(e,s){const c=p.get(e);if(c&&s.length===0)return c;const i=u.LIVE_TABLE[e]??{},t={};for(const[f,r]of Object.entries(i)){const o=l=>u.liveAccepts(r,l);r.c==="file"&&(o.fileRef=!0),t[f]=o}const n={keys:[...Object.keys(i),...s],accept:t};return s.length===0&&p.set(e,n),n}function h(e,s,c=[],i={}){const t=d(e,c);return v.useEditOverrides(s,t.keys,{...t.accept,...i})}exports.useLiveProps=h;
@@ -0,0 +1,28 @@
1
+ import { L as l, l as h } from "./live.generated-Do4jgrUN.js";
2
+ import { u as k } from "./useEditOverrides-BmvpLYPU.js";
3
+ const p = /* @__PURE__ */ new Map();
4
+ function a(e, t) {
5
+ const s = p.get(e);
6
+ if (s && t.length === 0) return s;
7
+ const o = l[e] ?? {}, c = {};
8
+ for (const [f, r] of Object.entries(o)) {
9
+ const i = (u) => h(r, u);
10
+ r.c === "file" && (i.fileRef = !0), c[f] = i;
11
+ }
12
+ const n = { keys: [...Object.keys(o), ...t], accept: c };
13
+ return t.length === 0 && p.set(e, n), n;
14
+ }
15
+ function O(e, t, s = [], o = {}) {
16
+ const c = a(e, s);
17
+ return k(
18
+ t,
19
+ c.keys,
20
+ {
21
+ ...c.accept,
22
+ ...o
23
+ }
24
+ );
25
+ }
26
+ export {
27
+ O as u
28
+ };
@@ -1,5 +1,5 @@
1
1
  import { useRef as m, useState as u, useCallback as E, useEffect as R } from "react";
2
- import { d as g } from "./index-MzlPbe9t.js";
2
+ import { d as g } from "./index-BmeB_V6I.js";
3
3
  const k = (t = {}) => {
4
4
  const { enabled: c = !0, timeoutMs: o, queryPermission: l } = t, f = (t.models ?? []).join("|"), i = m(t.models);
5
5
  i.current = t.models;
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * The seam between the core components and the editor's overlay consumer. Everything that decides
4
+ * what an overlay entry means (grammar, caps, reports to the bridge) lives in `lib/overlay/`, which
5
+ * only the edit entry imports. Core carries this slot, empty unless that entry registered into it,
6
+ * so a published or preview build has nothing to apply and `useEditOverlay` returns `undefined`.
7
+ */
8
+ export interface OverlaySlot {
9
+ subscribe(listener: () => void): () => void;
10
+ /** Stable per element until the entries for its stamp change; the render trigger. */
11
+ slice(props: object): unknown;
12
+ /** Changes whenever any element's entries change. */
13
+ version(): number;
14
+ /** The values the entries give this element, already checked against its own keys. */
15
+ resolve(props: object, keys: readonly string[], accept?: Partial<Record<string, (value: unknown) => boolean>>): Readonly<Record<string, unknown>> | undefined;
16
+ /** What an HTML region renders in place of its children, or `undefined` for its own children. */
17
+ region?(props: object, children: ReactNode): ReactNode | undefined;
18
+ }
19
+ /** Called once by the edit entry's consumer. */
20
+ export declare function setOverlaySlot(next: OverlaySlot): void;
21
+ /**
22
+ * Overlay values for the element whose props object this is, or `undefined` for none (always,
23
+ * outside an edit build). Call it with the component's own props object, before destructuring.
24
+ */
25
+ export declare function useEditOverlay(props: object, keys: readonly string[], accept?: Partial<Record<string, (value: unknown) => boolean>>): Readonly<Record<string, unknown>> | undefined;
26
+ /**
27
+ * The node an HTML region shows in place of its children while the overlay holds a plan for it,
28
+ * or `undefined` (always, outside an edit build, and whenever the plan is taken out).
29
+ */
30
+ export declare function useEditRegion(props: object, children: ReactNode): ReactNode | undefined;
31
+ /** For a parent that reads the overlay for several children at once (the edit `Scenes`). */
32
+ export declare function useEditOverlayVersion(): number;
33
+ export declare function resolveEditOverlay(props: object, keys: readonly string[], accept?: Partial<Record<string, (value: unknown) => boolean>>): Readonly<Record<string, unknown>> | undefined;
@@ -29,6 +29,12 @@ export declare const isLiveColour: (v: unknown) => v is string;
29
29
  * editor bridge (0.3.0 and later) writes into the store.
30
30
  */
31
31
  export type EditOverrideKey<P> = (keyof P & string) | `${keyof P & string}.${string}`;
32
+ /**
33
+ * Sets `path` in `out`, copying each object on the way so `out` never shares a changed object
34
+ * with the original props. Leaves `out` unchanged when an object on the path is missing or is
35
+ * not a plain object: the editor only shows a setting whose parent is written in source.
36
+ */
37
+ export declare function setPath(out: Record<string, unknown>, path: string[], value: unknown): boolean;
32
38
  /**
33
39
  * `props` with the editor's live overrides for the listed `keys` merged in, or `props` itself
34
40
  * when there are none (always, outside an edit build). A dotted key replaces only that leaf;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentt-xr/sdk",
3
- "version": "2.0.0-alpha.22",
3
+ "version": "2.0.0-alpha.23",
4
4
  "description": "XR SDK by Vincentt",
5
5
  "repository": {
6
6
  "type": "git",
package/settings.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": "vincentt.settings-decl/1",
3
3
  "package": "@vincentt-xr/sdk",
4
- "version": "2.0.0-alpha.22",
4
+ "version": "2.0.0-alpha.23",
5
5
  "components": {
6
6
  "AudioPlayer": {
7
7
  "element": "sound",
@@ -1,307 +0,0 @@
1
- var x = Object.defineProperty;
2
- var A = (s, e, t) => e in s ? x(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var a = (s, e, t) => A(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { u as k } from "./useEditOverrides-BBkK8cN2.js";
5
- import { useMemo as g, useCallback as d } from "react";
6
- import { u as S, r as m, h as E, l as L, j as T, k as B } from "./index-MzlPbe9t.js";
7
- import { a as _, b as v } from "./selectors-CiawE6Ox.js";
8
- const C = {
9
- AudioPlayer: {
10
- src: { c: "file" },
11
- volume: { c: "number", min: 0, max: 100 },
12
- playMode: { c: "choice", options: ["once", "loop", "infinite"] }
13
- },
14
- Button: {
15
- label: { c: "shortText", maxLength: 40 },
16
- action: { c: "choice", options: ["link", "scene"] },
17
- link: { c: "link", maxLength: 2048 },
18
- target: { c: "choice" },
19
- color: { c: "colour" },
20
- visible: { c: "switch" }
21
- },
22
- Light: {
23
- type: { c: "choice", options: ["ambient", "directional", "point", "spot"] },
24
- color: { c: "colour" },
25
- intensity: { c: "number", min: 0 },
26
- enabled: { c: "switch" },
27
- castShadow: { c: "switch" },
28
- distance: { c: "number", min: 0 },
29
- decay: { c: "number", min: 0 },
30
- angle: { c: "number", min: 0, max: 1.57 },
31
- penumbra: { c: "number", min: 0, max: 1 }
32
- },
33
- Model: { src: { c: "file" } },
34
- Object3D: {
35
- colour: { c: "colour" },
36
- texture: { c: "file" },
37
- size: { c: "number", min: 0 },
38
- visible: { c: "switch" }
39
- },
40
- PaintedFace: {
41
- src: { c: "file" },
42
- amount: { c: "number", min: 0, max: 1 },
43
- layout: { c: "choice", options: ["asIs", "flip", "upsideDown"] },
44
- ownEyes: { c: "switch" },
45
- ownMouth: { c: "switch" },
46
- visible: { c: "switch" }
47
- },
48
- Scene: {
49
- label: { c: "shortText", maxLength: 60 },
50
- overlay: { c: "switch" },
51
- open: { c: "switch" },
52
- over: { c: "shortText", maxLength: 64 }
53
- },
54
- ScreenImage: { src: { c: "file" } },
55
- ScreenText: {
56
- text: { c: "longText", maxLength: 500 },
57
- color: { c: "colour" },
58
- fontSize: { c: "number", min: 1 },
59
- textAlign: { c: "choice", options: ["left", "center", "right"] }
60
- }
61
- }, M = /^#[0-9a-fA-F]{6}$/, w = 4096, Q = (s) => typeof s == "string" && s.length <= w && (s.startsWith("https://") || s.startsWith("/") && s.length > 1 && s[1] !== "/" && s[1] !== "\\" && s.charCodeAt(1) > 32);
62
- function U(s, e) {
63
- switch (s.c) {
64
- case "colour":
65
- return typeof e == "string" && M.test(e);
66
- case "number":
67
- return typeof e == "number" && Number.isFinite(e) && (s.min === void 0 || e >= s.min) && (s.max === void 0 || e <= s.max);
68
- case "switch":
69
- return typeof e == "boolean";
70
- case "choice":
71
- return typeof e == "string" && (s.options === void 0 || s.options.includes(e));
72
- case "shortText":
73
- case "longText":
74
- return typeof e == "string" && [...e].length <= (s.maxLength ?? 2e3);
75
- case "link":
76
- return typeof e == "string" && e.length <= w;
77
- case "file":
78
- return Q(e);
79
- }
80
- }
81
- const p = /* @__PURE__ */ new Map();
82
- function z(s, e) {
83
- const t = p.get(s);
84
- if (t && e.length === 0) return t;
85
- const r = C[s] ?? {}, o = {};
86
- for (const [n, c] of Object.entries(r)) o[n] = (l) => U(c, l);
87
- const i = { keys: [...Object.keys(r), ...e], accept: o };
88
- return e.length === 0 && p.set(s, i), i;
89
- }
90
- function P(s, e, t = [], r = {}) {
91
- const o = z(s, t);
92
- return k(
93
- e,
94
- o.keys,
95
- {
96
- ...o.accept,
97
- ...r
98
- }
99
- );
100
- }
101
- const j = (s) => {
102
- const { session: e } = S(), t = _(), r = v(), o = JSON.stringify(s ?? null), i = g(
103
- () => s ? m(s) : r ?? m(),
104
- [o, r]
105
- // eslint-disable-line react-hooks/exhaustive-deps
106
- ), n = i.tiers, c = d(
107
- (u) => {
108
- const h = e.store.getSnapshot().quality;
109
- h && e._setQuality(E(h, i, u, performance.now()));
110
- },
111
- [e, i]
112
- ), l = d(
113
- (u) => {
114
- const h = e.store.getSnapshot().quality;
115
- h && e._setQuality(L(h, i, u, performance.now()));
116
- },
117
- [e, i]
118
- ), y = d(() => {
119
- const u = e.store.getSnapshot().quality;
120
- e._setQuality(
121
- T(i, (u == null ? void 0 : u.signals) ?? B, performance.now())
122
- );
123
- }, [e, i]);
124
- return g(
125
- () => ({
126
- tier: (t == null ? void 0 : t.decision.tier) ?? null,
127
- index: (t == null ? void 0 : t.index) ?? -1,
128
- tiers: n,
129
- decision: (t == null ? void 0 : t.decision) ?? null,
130
- history: (t == null ? void 0 : t.history) ?? [],
131
- signals: (t == null ? void 0 : t.signals) ?? null,
132
- locked: (t == null ? void 0 : t.locked) ?? !1,
133
- setTier: c,
134
- lock: () => l(!0),
135
- unlock: () => l(!1),
136
- reset: y,
137
- state: t
138
- }),
139
- [t, n, c, l, y]
140
- );
141
- }, F = 256 * 1024 * 1024;
142
- class X {
143
- constructor(e = {}) {
144
- a(this, "entries", /* @__PURE__ */ new Map());
145
- a(this, "listeners", /* @__PURE__ */ new Set());
146
- a(this, "budget");
147
- a(this, "now");
148
- a(this, "evictions", 0);
149
- a(this, "hits", 0);
150
- a(this, "misses", 0);
151
- /** Memoised `getStats()` result; cleared on every change so `useSyncExternalStore` sees a stable snapshot. */
152
- a(this, "statsSnapshot", null);
153
- this.budget = e.budgetBytes ?? F, this.now = e.now ?? (() => typeof performance < "u" ? performance.now() : Date.now());
154
- }
155
- /** Acquire `asset` on behalf of `ownerId`; shares an in-flight or loaded value. */
156
- acquire(e, t) {
157
- let r = this.entries.get(e.key);
158
- if (r && r.status === "error" && (this.entries.delete(e.key), r = void 0), !r) {
159
- this.misses += 1;
160
- const o = typeof AbortController < "u" ? new AbortController() : null, i = {
161
- definition: e,
162
- status: "loading",
163
- value: void 0,
164
- bytes: 0,
165
- owners: /* @__PURE__ */ new Set([t]),
166
- promise: null,
167
- controller: o,
168
- error: null,
169
- lastUsed: this.now(),
170
- disposed: !1
171
- };
172
- return i.promise = e.load((o == null ? void 0 : o.signal) ?? new AbortController().signal).then((n) => {
173
- var c, l;
174
- if (i.disposed || this.entries.get(e.key) !== i)
175
- throw (c = e.dispose) == null || c.call(e, n), new Error(`Asset "${e.key}" was released before it loaded`);
176
- return i.value = n, i.bytes = Math.max(0, Math.round(((l = e.bytes) == null ? void 0 : l.call(e, n)) ?? 0)), i.status = "ready", i.promise = null, this.notify(), this.enforceBudget(), n;
177
- }).catch((n) => {
178
- const c = n instanceof Error ? n : new Error(String(n));
179
- throw this.entries.get(e.key) === i && !i.disposed && (i.status = "error", i.error = c, i.promise = null, this.notify()), c;
180
- }), this.entries.set(e.key, i), this.notify(), i.promise;
181
- }
182
- return this.hits += 1, r.owners.add(t), r.lastUsed = this.now(), this.notify(), r.status === "ready" ? Promise.resolve(r.value) : r.promise;
183
- }
184
- /** Start loading without holding a reference (warm the cache). */
185
- preload(e) {
186
- const t = "__preload__";
187
- return this.acquire(e, t).finally(() => this.release(e.key, t));
188
- }
189
- /** Drop `ownerId`'s reference. The value stays cached until evicted or disposed. */
190
- release(e, t) {
191
- var o;
192
- const r = this.entries.get(e);
193
- !r || !r.owners.delete(t) || (r.lastUsed = this.now(), r.owners.size === 0 && r.status === "loading" && ((o = r.controller) == null || o.abort(), r.disposed = !0, this.entries.delete(e)), this.notify(), this.enforceBudget());
194
- }
195
- /** Synchronous read of a loaded value (or `undefined`). Does not take a reference. */
196
- get(e) {
197
- const t = this.entries.get(e);
198
- return (t == null ? void 0 : t.status) === "ready" ? t.value : void 0;
199
- }
200
- has(e) {
201
- return this.entries.has(e);
202
- }
203
- entry(e) {
204
- const t = this.entries.get(e);
205
- return t ? b(e, t) : void 0;
206
- }
207
- list() {
208
- return Array.from(this.entries, ([e, t]) => b(e, t));
209
- }
210
- setBudget(e) {
211
- this.budget = e, this.enforceBudget(), this.notify();
212
- }
213
- /**
214
- * Dispose unreferenced values, least recently used first, until usage is
215
- * within the budget (or `bytesToFree` is reclaimed). Referenced values are
216
- * never touched. Returns the bytes reclaimed.
217
- */
218
- evict(e) {
219
- const t = e ?? Math.max(0, this.usage() - (Number.isFinite(this.budget) ? this.budget : 1 / 0));
220
- if (t <= 0) return 0;
221
- const r = Array.from(this.entries).filter(([, i]) => i.owners.size === 0 && i.status === "ready").sort((i, n) => i[1].lastUsed - n[1].lastUsed);
222
- let o = 0;
223
- for (const [i, n] of r) {
224
- if (o >= t) break;
225
- o += n.bytes, this.disposeEntry(i, n), this.evictions += 1;
226
- }
227
- return o > 0 && this.notify(), o;
228
- }
229
- /** Dispose every unreferenced value (route change, scene teardown). Returns the bytes freed. */
230
- disposeUnreferenced() {
231
- let e = 0;
232
- for (const [t, r] of Array.from(this.entries))
233
- r.owners.size === 0 && (e += r.bytes, this.disposeEntry(t, r));
234
- return e > 0 && this.notify(), e;
235
- }
236
- /** Dispose everything, referenced or not (app / session shutdown). Owners are forgotten. */
237
- disposeAll() {
238
- for (const [e, t] of Array.from(this.entries)) this.disposeEntry(e, t);
239
- this.notify();
240
- }
241
- /** Current statistics. The object is reused until the cache changes, so it is safe as a store snapshot. */
242
- getStats() {
243
- if (this.statsSnapshot) return this.statsSnapshot;
244
- let e = 0, t = 0, r = 0, o = 0, i = 0;
245
- for (const n of this.entries.values())
246
- n.owners.size > 0 && (e += 1), n.status === "loading" && (t += 1), n.status === "error" && (r += 1), n.status === "ready" && (o += n.bytes, n.owners.size === 0 && (i += n.bytes));
247
- return this.statsSnapshot = {
248
- assets: this.entries.size,
249
- referencedAssets: e,
250
- loadingAssets: t,
251
- erroredAssets: r,
252
- usageBytes: o,
253
- reclaimableBytes: i,
254
- budgetBytes: this.budget,
255
- overBudget: o > this.budget,
256
- evictions: this.evictions,
257
- hits: this.hits,
258
- misses: this.misses
259
- }, this.statsSnapshot;
260
- }
261
- subscribe(e) {
262
- return this.listeners.add(e), () => {
263
- this.listeners.delete(e);
264
- };
265
- }
266
- usage() {
267
- let e = 0;
268
- for (const t of this.entries.values()) t.status === "ready" && (e += t.bytes);
269
- return e;
270
- }
271
- enforceBudget() {
272
- Number.isFinite(this.budget) && this.usage() > this.budget && this.evict();
273
- }
274
- disposeEntry(e, t) {
275
- var r, o, i;
276
- if (!t.disposed) {
277
- if (t.disposed = !0, (r = t.controller) == null || r.abort(), t.status === "ready" && t.value !== void 0)
278
- try {
279
- (i = (o = t.definition).dispose) == null || i.call(o, t.value);
280
- } catch (n) {
281
- console.warn(`[xr-sdk assets] dispose threw for ${e}`, n);
282
- }
283
- this.entries.delete(e);
284
- }
285
- }
286
- notify() {
287
- this.statsSnapshot = null, this.listeners.forEach((e) => e());
288
- }
289
- }
290
- const b = (s, e) => ({
291
- key: s,
292
- status: e.status,
293
- bytes: e.bytes,
294
- owners: e.owners.size,
295
- lastUsed: e.lastUsed,
296
- error: e.error
297
- }), D = (s) => new X(s);
298
- let f;
299
- const Y = () => (f || (f = D()), f);
300
- export {
301
- F as D,
302
- X,
303
- j as a,
304
- D as c,
305
- Y as g,
306
- P as u
307
- };