@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,5 +1,5 @@
1
1
  import * as p from "three";
2
- import { B as e, X as S } from "./index-MzlPbe9t.js";
2
+ import { B as e, X as S } from "./index-BmeB_V6I.js";
3
3
  const b = [
4
4
  [e.leftShoulder, e.rightShoulder],
5
5
  [e.leftHip, e.rightHip],
@@ -0,0 +1,212 @@
1
+ var w = Object.defineProperty;
2
+ var m = (n, e, s) => e in n ? w(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s;
3
+ var a = (n, e, s) => m(n, typeof e != "symbol" ? e + "" : e, s);
4
+ import { useMemo as g, useCallback as f } from "react";
5
+ import { u as v, r as p, a as S, l as A, b as k, E } from "./index-BmeB_V6I.js";
6
+ import { u as B, a as _ } from "./selectors-kj5g3uv2.js";
7
+ const X = (n) => {
8
+ const { session: e } = v(), s = B(), i = _(), o = JSON.stringify(n ?? null), t = g(
9
+ () => n ? p(n) : i ?? p(),
10
+ [o, i]
11
+ // eslint-disable-line react-hooks/exhaustive-deps
12
+ ), r = t.tiers, l = f(
13
+ (u) => {
14
+ const h = e.store.getSnapshot().quality;
15
+ h && e._setQuality(S(h, t, u, performance.now()));
16
+ },
17
+ [e, t]
18
+ ), d = f(
19
+ (u) => {
20
+ const h = e.store.getSnapshot().quality;
21
+ h && e._setQuality(A(h, t, u, performance.now()));
22
+ },
23
+ [e, t]
24
+ ), y = f(() => {
25
+ const u = e.store.getSnapshot().quality;
26
+ e._setQuality(
27
+ k(t, (u == null ? void 0 : u.signals) ?? E, performance.now())
28
+ );
29
+ }, [e, t]);
30
+ return g(
31
+ () => ({
32
+ tier: (s == null ? void 0 : s.decision.tier) ?? null,
33
+ index: (s == null ? void 0 : s.index) ?? -1,
34
+ tiers: r,
35
+ decision: (s == null ? void 0 : s.decision) ?? null,
36
+ history: (s == null ? void 0 : s.history) ?? [],
37
+ signals: (s == null ? void 0 : s.signals) ?? null,
38
+ locked: (s == null ? void 0 : s.locked) ?? !1,
39
+ setTier: l,
40
+ lock: () => d(!0),
41
+ unlock: () => d(!1),
42
+ reset: y,
43
+ state: s
44
+ }),
45
+ [s, r, l, d, y]
46
+ );
47
+ }, C = 256 * 1024 * 1024;
48
+ class Q {
49
+ constructor(e = {}) {
50
+ a(this, "entries", /* @__PURE__ */ new Map());
51
+ a(this, "listeners", /* @__PURE__ */ new Set());
52
+ a(this, "budget");
53
+ a(this, "now");
54
+ a(this, "evictions", 0);
55
+ a(this, "hits", 0);
56
+ a(this, "misses", 0);
57
+ /** Memoised `getStats()` result; cleared on every change so `useSyncExternalStore` sees a stable snapshot. */
58
+ a(this, "statsSnapshot", null);
59
+ this.budget = e.budgetBytes ?? C, this.now = e.now ?? (() => typeof performance < "u" ? performance.now() : Date.now());
60
+ }
61
+ /** Acquire `asset` on behalf of `ownerId`; shares an in-flight or loaded value. */
62
+ acquire(e, s) {
63
+ let i = this.entries.get(e.key);
64
+ if (i && i.status === "error" && (this.entries.delete(e.key), i = void 0), !i) {
65
+ this.misses += 1;
66
+ const o = typeof AbortController < "u" ? new AbortController() : null, t = {
67
+ definition: e,
68
+ status: "loading",
69
+ value: void 0,
70
+ bytes: 0,
71
+ owners: /* @__PURE__ */ new Set([s]),
72
+ promise: null,
73
+ controller: o,
74
+ error: null,
75
+ lastUsed: this.now(),
76
+ disposed: !1
77
+ };
78
+ return t.promise = e.load((o == null ? void 0 : o.signal) ?? new AbortController().signal).then((r) => {
79
+ var l, d;
80
+ if (t.disposed || this.entries.get(e.key) !== t)
81
+ throw (l = e.dispose) == null || l.call(e, r), new Error(`Asset "${e.key}" was released before it loaded`);
82
+ return t.value = r, t.bytes = Math.max(0, Math.round(((d = e.bytes) == null ? void 0 : d.call(e, r)) ?? 0)), t.status = "ready", t.promise = null, this.notify(), this.enforceBudget(), r;
83
+ }).catch((r) => {
84
+ const l = r instanceof Error ? r : new Error(String(r));
85
+ throw this.entries.get(e.key) === t && !t.disposed && (t.status = "error", t.error = l, t.promise = null, this.notify()), l;
86
+ }), this.entries.set(e.key, t), this.notify(), t.promise;
87
+ }
88
+ return this.hits += 1, i.owners.add(s), i.lastUsed = this.now(), this.notify(), i.status === "ready" ? Promise.resolve(i.value) : i.promise;
89
+ }
90
+ /** Start loading without holding a reference (warm the cache). */
91
+ preload(e) {
92
+ const s = "__preload__";
93
+ return this.acquire(e, s).finally(() => this.release(e.key, s));
94
+ }
95
+ /** Drop `ownerId`'s reference. The value stays cached until evicted or disposed. */
96
+ release(e, s) {
97
+ var o;
98
+ const i = this.entries.get(e);
99
+ !i || !i.owners.delete(s) || (i.lastUsed = this.now(), i.owners.size === 0 && i.status === "loading" && ((o = i.controller) == null || o.abort(), i.disposed = !0, this.entries.delete(e)), this.notify(), this.enforceBudget());
100
+ }
101
+ /** Synchronous read of a loaded value (or `undefined`). Does not take a reference. */
102
+ get(e) {
103
+ const s = this.entries.get(e);
104
+ return (s == null ? void 0 : s.status) === "ready" ? s.value : void 0;
105
+ }
106
+ has(e) {
107
+ return this.entries.has(e);
108
+ }
109
+ entry(e) {
110
+ const s = this.entries.get(e);
111
+ return s ? b(e, s) : void 0;
112
+ }
113
+ list() {
114
+ return Array.from(this.entries, ([e, s]) => b(e, s));
115
+ }
116
+ setBudget(e) {
117
+ this.budget = e, this.enforceBudget(), this.notify();
118
+ }
119
+ /**
120
+ * Dispose unreferenced values, least recently used first, until usage is
121
+ * within the budget (or `bytesToFree` is reclaimed). Referenced values are
122
+ * never touched. Returns the bytes reclaimed.
123
+ */
124
+ evict(e) {
125
+ const s = e ?? Math.max(0, this.usage() - (Number.isFinite(this.budget) ? this.budget : 1 / 0));
126
+ if (s <= 0) return 0;
127
+ const i = Array.from(this.entries).filter(([, t]) => t.owners.size === 0 && t.status === "ready").sort((t, r) => t[1].lastUsed - r[1].lastUsed);
128
+ let o = 0;
129
+ for (const [t, r] of i) {
130
+ if (o >= s) break;
131
+ o += r.bytes, this.disposeEntry(t, r), this.evictions += 1;
132
+ }
133
+ return o > 0 && this.notify(), o;
134
+ }
135
+ /** Dispose every unreferenced value (route change, scene teardown). Returns the bytes freed. */
136
+ disposeUnreferenced() {
137
+ let e = 0;
138
+ for (const [s, i] of Array.from(this.entries))
139
+ i.owners.size === 0 && (e += i.bytes, this.disposeEntry(s, i));
140
+ return e > 0 && this.notify(), e;
141
+ }
142
+ /** Dispose everything, referenced or not (app / session shutdown). Owners are forgotten. */
143
+ disposeAll() {
144
+ for (const [e, s] of Array.from(this.entries)) this.disposeEntry(e, s);
145
+ this.notify();
146
+ }
147
+ /** Current statistics. The object is reused until the cache changes, so it is safe as a store snapshot. */
148
+ getStats() {
149
+ if (this.statsSnapshot) return this.statsSnapshot;
150
+ let e = 0, s = 0, i = 0, o = 0, t = 0;
151
+ for (const r of this.entries.values())
152
+ r.owners.size > 0 && (e += 1), r.status === "loading" && (s += 1), r.status === "error" && (i += 1), r.status === "ready" && (o += r.bytes, r.owners.size === 0 && (t += r.bytes));
153
+ return this.statsSnapshot = {
154
+ assets: this.entries.size,
155
+ referencedAssets: e,
156
+ loadingAssets: s,
157
+ erroredAssets: i,
158
+ usageBytes: o,
159
+ reclaimableBytes: t,
160
+ budgetBytes: this.budget,
161
+ overBudget: o > this.budget,
162
+ evictions: this.evictions,
163
+ hits: this.hits,
164
+ misses: this.misses
165
+ }, this.statsSnapshot;
166
+ }
167
+ subscribe(e) {
168
+ return this.listeners.add(e), () => {
169
+ this.listeners.delete(e);
170
+ };
171
+ }
172
+ usage() {
173
+ let e = 0;
174
+ for (const s of this.entries.values()) s.status === "ready" && (e += s.bytes);
175
+ return e;
176
+ }
177
+ enforceBudget() {
178
+ Number.isFinite(this.budget) && this.usage() > this.budget && this.evict();
179
+ }
180
+ disposeEntry(e, s) {
181
+ var i, o, t;
182
+ if (!s.disposed) {
183
+ if (s.disposed = !0, (i = s.controller) == null || i.abort(), s.status === "ready" && s.value !== void 0)
184
+ try {
185
+ (t = (o = s.definition).dispose) == null || t.call(o, s.value);
186
+ } catch (r) {
187
+ console.warn(`[xr-sdk assets] dispose threw for ${e}`, r);
188
+ }
189
+ this.entries.delete(e);
190
+ }
191
+ }
192
+ notify() {
193
+ this.statsSnapshot = null, this.listeners.forEach((e) => e());
194
+ }
195
+ }
196
+ const b = (n, e) => ({
197
+ key: n,
198
+ status: e.status,
199
+ bytes: e.bytes,
200
+ owners: e.owners.size,
201
+ lastUsed: e.lastUsed,
202
+ error: e.error
203
+ }), U = (n) => new Q(n);
204
+ let c;
205
+ const q = () => (c || (c = U()), c);
206
+ export {
207
+ C as D,
208
+ Q as X,
209
+ U as c,
210
+ q as g,
211
+ X as u
212
+ };
@@ -0,0 +1 @@
1
+ "use strict";var S=Object.defineProperty;var v=(o,e,t)=>e in o?S(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var l=(o,e,t)=>v(o,typeof e!="symbol"?e+"":e,t);const f=require("react"),d=require("./index-J3Qy6hi3.cjs"),p=require("./selectors-Bq6tSgOY.cjs"),k=o=>{const{session:e}=d.useXRContext(),t=p.useXRQualityState(),i=p.useXRQualityConfig(),n=JSON.stringify(o??null),s=f.useMemo(()=>o?d.resolveQualityConfig(o):i??d.resolveQualityConfig(),[n,i]),r=s.tiers,a=f.useCallback(u=>{const c=e.store.getSnapshot().quality;c&&e._setQuality(d.setQualityTier(c,s,u,performance.now()))},[e,s]),h=f.useCallback(u=>{const c=e.store.getSnapshot().quality;c&&e._setQuality(d.lockQuality(c,s,u,performance.now()))},[e,s]),g=f.useCallback(()=>{const u=e.store.getSnapshot().quality;e._setQuality(d.resetQuality(s,(u==null?void 0:u.signals)??d.EMPTY_QUALITY_SIGNALS,performance.now()))},[e,s]);return f.useMemo(()=>({tier:(t==null?void 0:t.decision.tier)??null,index:(t==null?void 0:t.index)??-1,tiers:r,decision:(t==null?void 0:t.decision)??null,history:(t==null?void 0:t.history)??[],signals:(t==null?void 0:t.signals)??null,locked:(t==null?void 0:t.locked)??!1,setTier:a,lock:()=>h(!0),unlock:()=>h(!1),reset:g,state:t}),[t,r,a,h,g])},w=256*1024*1024;class m{constructor(e={}){l(this,"entries",new Map);l(this,"listeners",new Set);l(this,"budget");l(this,"now");l(this,"evictions",0);l(this,"hits",0);l(this,"misses",0);l(this,"statsSnapshot",null);this.budget=e.budgetBytes??w,this.now=e.now??(()=>typeof performance<"u"?performance.now():Date.now())}acquire(e,t){let i=this.entries.get(e.key);if(i&&i.status==="error"&&(this.entries.delete(e.key),i=void 0),!i){this.misses+=1;const n=typeof AbortController<"u"?new AbortController:null,s={definition:e,status:"loading",value:void 0,bytes:0,owners:new Set([t]),promise:null,controller:n,error:null,lastUsed:this.now(),disposed:!1};return s.promise=e.load((n==null?void 0:n.signal)??new AbortController().signal).then(r=>{var a,h;if(s.disposed||this.entries.get(e.key)!==s)throw(a=e.dispose)==null||a.call(e,r),new Error(`Asset "${e.key}" was released before it loaded`);return s.value=r,s.bytes=Math.max(0,Math.round(((h=e.bytes)==null?void 0:h.call(e,r))??0)),s.status="ready",s.promise=null,this.notify(),this.enforceBudget(),r}).catch(r=>{const a=r instanceof Error?r:new Error(String(r));throw this.entries.get(e.key)===s&&!s.disposed&&(s.status="error",s.error=a,s.promise=null,this.notify()),a}),this.entries.set(e.key,s),this.notify(),s.promise}return this.hits+=1,i.owners.add(t),i.lastUsed=this.now(),this.notify(),i.status==="ready"?Promise.resolve(i.value):i.promise}preload(e){const t="__preload__";return this.acquire(e,t).finally(()=>this.release(e.key,t))}release(e,t){var n;const i=this.entries.get(e);!i||!i.owners.delete(t)||(i.lastUsed=this.now(),i.owners.size===0&&i.status==="loading"&&((n=i.controller)==null||n.abort(),i.disposed=!0,this.entries.delete(e)),this.notify(),this.enforceBudget())}get(e){const t=this.entries.get(e);return(t==null?void 0:t.status)==="ready"?t.value:void 0}has(e){return this.entries.has(e)}entry(e){const t=this.entries.get(e);return t?b(e,t):void 0}list(){return Array.from(this.entries,([e,t])=>b(e,t))}setBudget(e){this.budget=e,this.enforceBudget(),this.notify()}evict(e){const t=e??Math.max(0,this.usage()-(Number.isFinite(this.budget)?this.budget:1/0));if(t<=0)return 0;const i=Array.from(this.entries).filter(([,s])=>s.owners.size===0&&s.status==="ready").sort((s,r)=>s[1].lastUsed-r[1].lastUsed);let n=0;for(const[s,r]of i){if(n>=t)break;n+=r.bytes,this.disposeEntry(s,r),this.evictions+=1}return n>0&&this.notify(),n}disposeUnreferenced(){let e=0;for(const[t,i]of Array.from(this.entries))i.owners.size===0&&(e+=i.bytes,this.disposeEntry(t,i));return e>0&&this.notify(),e}disposeAll(){for(const[e,t]of Array.from(this.entries))this.disposeEntry(e,t);this.notify()}getStats(){if(this.statsSnapshot)return this.statsSnapshot;let e=0,t=0,i=0,n=0,s=0;for(const r of this.entries.values())r.owners.size>0&&(e+=1),r.status==="loading"&&(t+=1),r.status==="error"&&(i+=1),r.status==="ready"&&(n+=r.bytes,r.owners.size===0&&(s+=r.bytes));return this.statsSnapshot={assets:this.entries.size,referencedAssets:e,loadingAssets:t,erroredAssets:i,usageBytes:n,reclaimableBytes:s,budgetBytes:this.budget,overBudget:n>this.budget,evictions:this.evictions,hits:this.hits,misses:this.misses},this.statsSnapshot}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}usage(){let e=0;for(const t of this.entries.values())t.status==="ready"&&(e+=t.bytes);return e}enforceBudget(){Number.isFinite(this.budget)&&this.usage()>this.budget&&this.evict()}disposeEntry(e,t){var i,n,s;if(!t.disposed){if(t.disposed=!0,(i=t.controller)==null||i.abort(),t.status==="ready"&&t.value!==void 0)try{(s=(n=t.definition).dispose)==null||s.call(n,t.value)}catch(r){console.warn(`[xr-sdk assets] dispose threw for ${e}`,r)}this.entries.delete(e)}}notify(){this.statsSnapshot=null,this.listeners.forEach(e=>e())}}const b=(o,e)=>({key:o,status:e.status,bytes:e.bytes,owners:e.owners.size,lastUsed:e.lastUsed,error:e.error}),A=o=>new m(o);let y;const C=()=>(y||(y=A()),y);exports.DEFAULT_ASSET_BUDGET_BYTES=w;exports.XRAssetCache=m;exports.createAssetCache=A;exports.getDefaultAssetCache=C;exports.useXRQuality=k;
@@ -0,0 +1,27 @@
1
+ import { KnownComponentProps } from '../../editor-defs/types';
2
+ export type CaptureShareScreenProps = KnownComponentProps & {
3
+ /** Text of the save button. Default "Save". */
4
+ saveLabel?: string;
5
+ /** Text of the share button. Default "Share". */
6
+ shareLabel?: string;
7
+ /** Text of the retake button. Default "Retake". */
8
+ retakeLabel?: string;
9
+ /** Caption in the share sheet (up to 280 characters). */
10
+ shareText?: string;
11
+ /** An https link added to the share. Anything else is ignored. */
12
+ shareLink?: string;
13
+ /** Line shown under the photo. */
14
+ caption?: string;
15
+ /** Background colour, `#rrggbb`. */
16
+ background?: string;
17
+ /** Text and button colour, `#rrggbb`. */
18
+ color?: string;
19
+ className?: string;
20
+ };
21
+ /**
22
+ * A page screen (DOM, outside the canvas) that shows the viewer's latest capture with save, share
23
+ * and retake buttons. It appears once the viewer has taken a photo with `useCapture` (a Button's
24
+ * tap); the editor shows it with a placeholder image. Save and share run only from the viewer's
25
+ * tap, and share falls back to a download where the browser cannot share files.
26
+ */
27
+ export declare function CaptureShareScreen(rawProps: CaptureShareScreenProps): import("react/jsx-runtime").JSX.Element | null;
@@ -5,4 +5,4 @@ export type HtmlRegionProps = KnownComponentProps & {
5
5
  /** Markup only. The editor lists its text pieces. */
6
6
  children?: ReactNode;
7
7
  };
8
- export declare function HtmlRegion({ className, children, name: _name, locked: _locked, }: HtmlRegionProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function HtmlRegion(props: HtmlRegionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { KnownComponentProps } from '../../editor-defs/types';
2
+ export type IntroScreenProps = KnownComponentProps & {
3
+ /** Main line (up to 80 characters). */
4
+ title?: string;
5
+ /** Instructions under the title (up to 500 characters). */
6
+ body?: string;
7
+ /** Project image path (`/images/steps.png`) shown above the title. Anything else is ignored. */
8
+ image?: string;
9
+ /** Text of the continue button (up to 40 characters). Default "Continue". */
10
+ buttonLabel?: string;
11
+ /**
12
+ * Runs from the viewer's tap, synchronously in the click handler, so the browser counts it as a
13
+ * user gesture (the camera permission prompt needs one). Wire it to the session start. The editor
14
+ * shows it read-only; an IntroScreen without it reads "Not wired yet".
15
+ */
16
+ onContinue?: () => void;
17
+ /** Background colour: `#rrggbb`, `rgb()`, `rgba()`, `hsl()` or `hsla()`. */
18
+ background?: string;
19
+ /** Text colour, same formats as `background`. */
20
+ color?: string;
21
+ /** Editor only: keeps the screen visible in Edit. Never changes the published app. */
22
+ pinVisible?: boolean;
23
+ className?: string;
24
+ };
25
+ /**
26
+ * An instructions and camera permission screen (DOM, outside the canvas): image, title, body and
27
+ * one button. The button calls `onContinue` straight from the tap and then hides the screen. In
28
+ * Edit the screen is shown only with `pinVisible`, which does nothing in a published app. The
29
+ * editor never lists `onContinue` as editable, so it cannot change what the button runs.
30
+ */
31
+ export declare function IntroScreen(rawProps: IntroScreenProps): import("react/jsx-runtime").JSX.Element | null;
@@ -2,6 +2,14 @@ import { ScreenShapeProps, ScreenShapeSettings, ScreenShapeSettingsInput } from
2
2
  export type { ScreenShapeKind, ScreenShapeProps, ScreenShapeSettings, ScreenShapeSettingsInput, } from './types';
3
3
  export declare const DEFAULT_SCREEN_SHAPE_SETTINGS: ScreenShapeSettings;
4
4
  export declare const mergeScreenShapeSettings: (settings?: ScreenShapeSettingsInput) => ScreenShapeSettings;
5
+ /** Props the visual editor can show live while a change is unsaved (edit builds only). */
6
+ export declare const SCREEN_SHAPE_LIVE_EDITABLE: readonly ["transform.position", "transform.size", "transform.rotation", "settings.fillColor"];
7
+ export declare const SCREEN_SHAPE_LIVE_ACCEPT: {
8
+ "transform.position": (v: unknown) => boolean;
9
+ "transform.size": (v: unknown) => boolean;
10
+ "transform.rotation": (v: unknown) => v is number;
11
+ "settings.fillColor": (v: unknown) => v is string;
12
+ };
5
13
  /**
6
14
  * @editorElement screenShape transform.position transform.size transform.rotation settings.fillColor
7
15
  */
@@ -0,0 +1,38 @@
1
+ import { ReactNode } from 'react';
2
+ import { KnownComponentProps } from '../../editor-defs/types';
3
+ export type SplashScreenProps = KnownComponentProps & {
4
+ /** Project image path (`/images/logo.png`) shown above the title. Anything else is ignored. */
5
+ logo?: string;
6
+ /** Main line (up to 80 characters). */
7
+ title?: string;
8
+ /** Line under the title (up to 160 characters). */
9
+ subtitle?: string;
10
+ /** Background colour: `#rrggbb`, `rgb()`, `rgba()`, `hsl()` or `hsla()`. */
11
+ background?: string;
12
+ /** Text colour, same formats as `background`. */
13
+ color?: string;
14
+ /** Least time, in milliseconds, the splash stays up once passed as `loadingComponent`. Default 0. */
15
+ minimumShowTime?: number;
16
+ /** Editor only: keeps the splash visible in Edit. Never changes the published app. */
17
+ pinVisible?: boolean;
18
+ className?: string;
19
+ };
20
+ /** A splash can hold the page for at most this long, whatever the prop says. */
21
+ export declare const SPLASH_MAX_HOLD_MS = 10000;
22
+ /** A hex, rgb(a) or hsl(a) colour; anything else (urls, var(), expressions) is not a colour. */
23
+ export declare const isSplashColour: (v: unknown) => v is string;
24
+ /** A project-relative path only: the file control's `/path`, never a host, scheme or `//`. */
25
+ export declare const isSplashLogo: (v: unknown) => v is string;
26
+ /** Milliseconds a valid minimum show time holds the splash: 0 for anything that is not a number >= 0. */
27
+ export declare const splashHoldMs: (v: unknown) => number;
28
+ /** How long `XRScene` waits after ready before removing the loading overlay. */
29
+ export declare const loadingRemoveDelay: (transitionMs: number | undefined, holdForMs: number, elapsedMs: number) => number;
30
+ /** The minimum show time of a `<SplashScreen>` passed as `loadingComponent`; 0 for any other node. */
31
+ export declare function loadingHoldMs(node: ReactNode): number;
32
+ /**
33
+ * A loading screen (DOM, outside the canvas) with a logo, title and subtitle. Pass it as
34
+ * `<XRScene loadingComponent={<SplashScreen title="Welcome" minimumShowTime={1500} />} />`; `XRScene`
35
+ * keeps it up for at least `minimumShowTime`. It exists only while loading, so the editor shows it
36
+ * only when `pinVisible` is set, and `pinVisible` does nothing in a published app.
37
+ */
38
+ export declare function SplashScreen(rawProps: SplashScreenProps): import("react/jsx-runtime").JSX.Element | null;
@@ -2,4 +2,7 @@ import { TextLabelProps } from './types';
2
2
  export type { TextLabelProps } from './types';
3
3
  export { resolveTextLabelDrawX, resolveTextLabelPanelX, resolveTextLabelStartY } from './alignment';
4
4
  export type { TextAlign, TextBackgroundFillMode, TextBackgroundFit, TextBackgroundTextureFit, TextBendPreset, TextGlow, TextGradientStop, TextInnerShadow, TextOverflowMode, TextShadowLayer, TextStrokeLayer, TextVerticalAlign, } from './types';
5
+ export declare const TEXT_LABEL_LIVE_ACCEPT: {
6
+ color: (v: unknown) => v is string;
7
+ };
5
8
  export declare function TextLabel(rawProps: TextLabelProps): import("react/jsx-runtime").JSX.Element;
@@ -32,6 +32,9 @@ export * from './Object3D';
32
32
  export * from './PaintedFace';
33
33
  export * from './ThemeProvider';
34
34
  export * from './Button';
35
+ export * from './CaptureShareScreen';
36
+ export * from './SplashScreen';
37
+ export * from './IntroScreen';
35
38
  export * from './Light';
36
39
  export * from './LightObject';
37
40
  export * from './LookAt';
@@ -0,0 +1 @@
1
+ "use strict";var Fe=Object.defineProperty;var Ce=(e,t,n)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var O=(e,t,n)=>Ce(e,typeof t!="symbol"?t+"":t,n);const L=require("react/jsx-runtime"),oe=require("@react-three/fiber"),T=require("react"),ke=require("three"),xe=require("./uv-BMFt19bg.cjs"),K=require("./selectors-Bq6tSgOY.cjs"),pe=require("./index-J3Qy6hi3.cjs"),Ie=require("./live.generated-n5ZV_2Gt.cjs"),Le=require("./useEditOverrides-DMAMGzlF.cjs"),Xe=require("./useLiveProps-Bz9wifGN.cjs"),le=require("./context-hA0Rb2Xa.cjs");function De(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=De(ke),ve={display:"flex",alignItems:"center",justifyContent:"center",height:"100%",background:"#363636",color:"white",fontFamily:"monospace"},Be=()=>L.jsx("div",{style:ve,children:"Loading..."}),Ge=e=>L.jsx("div",{style:ve,children:e.error}),je=80,Ue=160,$e=1e4,qe=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,We=/^(?:rgba?|hsla?)\(\s*[0-9.%\s,/-]+\)$/i,ae=e=>typeof e=="string"&&e.length<=64&&(qe.test(e)||We.test(e)),ge=e=>Ie.isLiveFileRef(e)&&e.startsWith("/"),ce=(e,t)=>typeof e=="string"?[...e].slice(0,t).join(""):"",Ne=e=>typeof e=="number"&&Number.isFinite(e)&&e>0?Math.min(e,$e):0,Pe=(e,t,n)=>Math.max(e??0,t-n,0);function He(e){return!T.isValidElement(e)||e.type!==me?0:Ne(e.props.minimumShowTime)}function me(e){const t=Xe.useLiveProps("SplashScreen",e);if(Le.editStore()!==void 0&&t.pinVisible!==!0)return null;const n=ae(t.background)?t.background:"#111827",o=ae(t.color)?t.color:"#ffffff",r=ge(t.logo)?t.logo:void 0,a=ce(t.title,je),c=ce(t.subtitle,Ue),i={width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"0.75em",padding:"1em",boxSizing:"border-box",textAlign:"center",background:n,color:o};return L.jsxs("div",{className:t.className,style:i,children:[r?L.jsx("img",{src:r,alt:"",style:{maxWidth:"40%",maxHeight:"30%",objectFit:"contain"}}):null,a?L.jsx("div",{style:{fontSize:"1.25em",fontWeight:600},children:a}):null,c?L.jsx("div",{style:{opacity:.75},children:c}):null]})}const Ve=(e,t,{sceneDepth:n=!1}={})=>{const o=new U.WebGLRenderTarget(e,t,{colorSpace:U.SRGBColorSpace,depthBuffer:!0,stencilBuffer:!0});return n&&(o.depthTexture=new U.DepthTexture(e,t),o.depthTexture.format=U.DepthStencilFormat,o.depthTexture.type=U.UnsignedInt248Type),o},Ye=e=>typeof e=="number"?e:Array.isArray(e)?e[1]:3,de={position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:10},he={sceneColorTexture:null,sceneDepthTexture:null},ze=e=>{const t=K.useXRQualityState(),o=K.useXRQualityConfig()?(t==null?void 0:t.decision.tier.renderScale)??1:1,r=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(.5,Math.min(r,e)*o)},Oe=({onRenderOutputs:e,renderOutputs:t,size:n})=>{const{gl:o,scene:r,size:a}=oe.useThree(),{session:c}=pe.useXRContext(),i=Math.max(1,Math.round((n==null?void 0:n.width)??a.width)),h=Math.max(1,Math.round((n==null?void 0:n.height)??a.height)),f=!!(t.sceneColor||t.sceneDepth),s=T.useMemo(()=>f?Ve(i,h,{sceneDepth:!!t.sceneDepth}):null,[f,h,t.sceneDepth,i]);return T.useEffect(()=>{if(!s){e==null||e(he);return}return e==null||e({sceneColorTexture:t.sceneColor?s.texture:null,sceneDepthTexture:t.sceneDepth&&s.depthTexture?s.depthTexture:null}),()=>{var l;s.dispose(),(l=s.depthTexture)==null||l.dispose(),e==null||e(he)}},[e,t.sceneColor,t.sceneDepth,s]),oe.useFrame(()=>{if(!s)return;const l=[];t.excludeScreenUI!==!1&&r.traverse(u=>{u.visible&&u.renderOrder>=xe.RENDER_LAYERS.SCREEN_UI&&(l.push(u),u.visible=!1)});const v=o.getRenderTarget(),w=o.xr.enabled;o.xr.enabled=!1,o.setRenderTarget(s),o.clear(),c._renderFrame(),o.setRenderTarget(v),o.xr.enabled=w,l.forEach(u=>{u.visible=!0})},-100),null},Qe=({style:e,canvasProps:t,children:n,loadingComponent:o,loadingTransitionDuration:r,errorComponent:a,renderTargetSize:c,renderOutputs:i={},onRenderOutputs:h})=>{const f=T.useRef(null),s=T.useRef(null),l=T.useRef(null),v=T.useRef(!1),w=ze(Ye(t==null?void 0:t.dpr)),{session:u}=pe.useXRContext(),x=K.useXRReady(),d=K.useXRError(),[g,R]=T.useState(!0),m=T.useRef(Date.now()),M=He(o);return T.useEffect(()=>{if(c){u._setRenderSize(Math.round(c.width),Math.round(c.height));return}const p=(A,C)=>{A<=0||C<=0||u._setRenderSize(Math.round(A),Math.round(C))},_=()=>{!s.current||v.current||(v.current=!0,u._setRenderTarget(s.current))},k=(A,C)=>{l.current!==null&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{l.current=null,p(A,C)})},B=new ResizeObserver(A=>{const C=A[0];if(!C)return;const{width:S,height:E}=C.contentRect;_(),k(S,E)});return f.current&&B.observe(f.current),_(),()=>{B.disconnect(),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),v.current=!1}},[c,u]),T.useEffect(()=>{if(x){const p=Pe(r,M,Date.now()-m.current);p>0?setTimeout(()=>{R(!1)},p):R(!1)}},[x,r,M]),L.jsxs("div",{id:"vincentt-xr-container",ref:f,style:{width:"100%",height:"100%",...e,position:"relative"},children:[g&&L.jsx("div",{style:de,children:o||L.jsx(Be,{})}),d&&L.jsx("div",{style:de,children:a||L.jsx(Ge,{error:d.message})}),L.jsxs(oe.Canvas,{id:"vincentt-xr-canvas",ref:s,gl:{alpha:!0,preserveDrawingBuffer:!1,antialias:!0,stencil:!0,premultipliedAlpha:!1,toneMapping:U.NoToneMapping},...t,dpr:w,onCreated:p=>{c?u._setRenderSize(Math.round(c.width),Math.round(c.height)):u._setRenderTarget(s.current),u._setR3FState({renderer:p.gl,scene:p.scene,camera:p.camera}),p.gl.outputColorSpace=U.SRGBColorSpace,t!=null&&t.onCreated&&t.onCreated(p)},children:[L.jsx(Oe,{onRenderOutputs:h,renderOutputs:i,size:c}),n]})]})},we=(e,t,n,o,r)=>{const a=e/2,c=t/2,i=n.left*a+o.left,h=n.right*a-o.right,f=n.bottom*c+o.bottom,s=n.top*c-o.top,l=h-i,v=s-f,w=(i+h)/2,u=(f+s)/2,x=r[0]*l/2,d=r[1]*v/2;return{centerX:w,centerY:u,width:l,height:v,pivotX:x,pivotY:d}},Ze={left:0,right:0,top:0,bottom:0},Ke={left:0,right:0,top:0,bottom:0},Je=[0,0],be=({anchors:e,offsets:t,pivot:n=Je,children:o})=>{const{width:r,height:a}=le.useScreenSpace(),c=T.useMemo(()=>({anchors:{...Ze,...e??{}},offsets:{...Ke,...t??{}}}),[e,t]),i=T.useMemo(()=>we(r,a,c.anchors,c.offsets,n),[r,a,c,n]);T.useEffect(()=>{const l=c.anchors;l.left>l.right&&console.warn(`[ScreenTransform] inverted X axis: anchors.left (${l.left}) > anchors.right (${l.right})`),l.bottom>l.top&&console.warn(`[ScreenTransform] inverted Y axis: anchors.bottom (${l.bottom}) > anchors.top (${l.top})`),i.width<=0&&console.warn(`[ScreenTransform] zero or negative width (${i.width.toFixed(3)}) — anchors + offsets collapse the X extent`),i.height<=0&&console.warn(`[ScreenTransform] zero or negative height (${i.height.toFixed(3)}) — anchors + offsets collapse the Y extent`)},[c,i.width,i.height]);const h=n[0]!==0||n[1]!==0,f=h?[1,1,1]:[i.width,i.height,1],s=!h&&i.width>0&&i.height>0?i.width/i.height:null;return L.jsx("group",{position:[i.centerX-i.pivotX,i.centerY-i.pivotY,0],scale:f,renderOrder:xe.RENDER_LAYERS.SCREEN_UI,children:L.jsx(le.ScreenRectAspectContext.Provider,{value:s,children:o})})};class Se{constructor(t,n){O(this,"capabilities");O(this,"snapshot");O(this,"listeners",new Set);O(this,"eventListeners",new Map);this.capabilities=t,this.snapshot={state:"idle",frame:0,time:0,playMode:"forward",loop:!0,loopCount:0,...n}}play(){const t=this.snapshot.state==="paused";this.update({state:"playing"}),this.emit(t?"Resume":"PlayBegin")}pause(){this.update({state:"paused"}),this.emit("Pause")}restart(){this.update({state:"playing",frame:0,time:0}),this.emit("PlayBegin")}setPlayMode(t){!this.capabilities.canReverse&&(t==="reverse"||t==="ping-pong"||t==="random")||this.update({playMode:t})}setLoop(t,n=0){this.update({loop:t,loopCount:n})}seek(t){this.capabilities.canSeek&&this.update({frame:Math.max(0,Math.floor(t)),time:Math.max(0,t)})}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}on(t,n){const o=this.eventListeners.get(t)??new Set;return o.add(n),this.eventListeners.set(t,o),()=>this.off(t,n)}off(t,n){var o;(o=this.eventListeners.get(t))==null||o.delete(n)}getSnapshot(){return this.snapshot}dispose(){this.listeners.clear(),this.eventListeners.clear(),this.snapshot={...this.snapshot,state:"idle"}}updateSnapshot(t){this.update(t)}emit(t){var n;(n=this.eventListeners.get(t))==null||n.forEach(o=>o({type:t,snapshot:this.snapshot}))}update(t){this.snapshot={...this.snapshot,...t},this.listeners.forEach(n=>n(this.snapshot))}}const ye=(e,t,n,o,r)=>{const a=Math.max(1,Math.floor(t)),c=Math.max(0,Math.floor(e)),i=n==="ping-pong"&&a>1?a*2-2:a,h=Math.floor(c/i),f=r>0?h>=r:!o&&c>=i,s=f?i-1:c%i;return{frame:n==="reverse"?a-1-s%a:n==="random"?s*7919%a:n==="ping-pong"&&s>=a?i-s:s,ended:f,loop:h}},et=(e,t,n)=>{const o=Math.max(1,Math.floor(n));return Math.floor(Math.max(0,e)*Math.max(0,t))%o};var fe={},_e,tt;function rt(e,t,n,a){var r=0,a=a===void 0?{}:a,c=a.loop===void 0?null:a.loop,i=a.palette===void 0?null:a.palette;if(t<=0||n<=0||t>65535||n>65535)throw new Error("Width/Height invalid.");function h(d){var g=d.length;if(g<2||g>256||g&g-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return g}e[r++]=71,e[r++]=73,e[r++]=70,e[r++]=56,e[r++]=57,e[r++]=97;var f=0,s=0;if(i!==null){for(var l=h(i);l>>=1;)++f;if(l=1<<f,--f,a.background!==void 0){if(s=a.background,s>=l)throw new Error("Background index out of range.");if(s===0)throw new Error("Background index explicitly passed as 0.")}}if(e[r++]=t&255,e[r++]=t>>8&255,e[r++]=n&255,e[r++]=n>>8&255,e[r++]=(i!==null?128:0)|f,e[r++]=s,e[r++]=0,i!==null)for(var v=0,w=i.length;v<w;++v){var u=i[v];e[r++]=u>>16&255,e[r++]=u>>8&255,e[r++]=u&255}if(c!==null){if(c<0||c>65535)throw new Error("Loop count invalid.");e[r++]=33,e[r++]=255,e[r++]=11,e[r++]=78,e[r++]=69,e[r++]=84,e[r++]=83,e[r++]=67,e[r++]=65,e[r++]=80,e[r++]=69,e[r++]=50,e[r++]=46,e[r++]=48,e[r++]=3,e[r++]=1,e[r++]=c&255,e[r++]=c>>8&255,e[r++]=0}var x=!1;this.addFrame=function(d,g,R,m,M,p){if(x===!0&&(--r,x=!1),p=p===void 0?{}:p,d<0||g<0||d>65535||g>65535)throw new Error("x/y invalid.");if(R<=0||m<=0||R>65535||m>65535)throw new Error("Width/Height invalid.");if(M.length<R*m)throw new Error("Not enough pixels for the frame size.");var _=!0,k=p.palette;if(k==null&&(_=!1,k=i),k==null)throw new Error("Must supply either a local or global palette.");for(var B=h(k),A=0;B>>=1;)++A;B=1<<A;var C=p.delay===void 0?0:p.delay,S=p.disposal===void 0?0:p.disposal;if(S<0||S>3)throw new Error("Disposal out of range.");var E=!1,X=0;if(p.transparent!==void 0&&p.transparent!==null&&(E=!0,X=p.transparent,X<0||X>=B))throw new Error("Transparent color index.");if((S!==0||E||C!==0)&&(e[r++]=33,e[r++]=249,e[r++]=4,e[r++]=S<<2|(E===!0?1:0),e[r++]=C&255,e[r++]=C>>8&255,e[r++]=X,e[r++]=0),e[r++]=44,e[r++]=d&255,e[r++]=d>>8&255,e[r++]=g&255,e[r++]=g>>8&255,e[r++]=R&255,e[r++]=R>>8&255,e[r++]=m&255,e[r++]=m>>8&255,e[r++]=_===!0?128|A-1:0,_===!0)for(var $=0,D=k.length;$<D;++$){var I=k[$];e[r++]=I>>16&255,e[r++]=I>>8&255,e[r++]=I&255}return r=nt(e,r,A<2?2:A,M),r},this.end=function(){return x===!1&&(e[r++]=59,x=!0),r},this.getOutputBuffer=function(){return e},this.setOutputBuffer=function(d){e=d},this.getOutputBufferPosition=function(){return r},this.setOutputBufferPosition=function(d){r=d}}function nt(e,t,n,o){e[t++]=n;var r=t++,a=1<<n,c=a-1,i=a+1,h=i+1,f=n+1,s=0,l=0;function v(p){for(;s>=p;)e[t++]=l&255,l>>=8,s-=8,t===r+256&&(e[r]=255,r=t++)}function w(p){l|=p<<s,s+=f,v(8)}var u=o[0]&c,x={};w(a);for(var d=1,g=o.length;d<g;++d){var R=o[d]&c,m=u<<8|R,M=x[m];if(M===void 0){for(l|=u<<s,s+=f;s>=8;)e[t++]=l&255,l>>=8,s-=8,t===r+256&&(e[r]=255,r=t++);h===4096?(w(a),h=i+1,f=n+1,x={}):(h>=1<<f&&++f,x[m]=h++),u=R}else u=M}return w(u),w(i),v(1),r+1===t?e[r]=0:(e[r]=t-r-1,e[t++]=0),t}function ot(e){var t=0;if(e[t++]!==71||e[t++]!==73||e[t++]!==70||e[t++]!==56||(e[t++]+1&253)!==56||e[t++]!==97)throw new Error("Invalid GIF 87a/89a header.");var n=e[t++]|e[t++]<<8,o=e[t++]|e[t++]<<8,r=e[t++],a=r>>7,c=r&7,i=1<<c+1;e[t++],e[t++];var h=null,f=null;a&&(h=t,f=i,t+=i*3);var s=!0,l=[],v=0,w=null,u=0,x=null;for(this.width=n,this.height=o;s&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(e[t]!==11||e[t+1]==78&&e[t+2]==69&&e[t+3]==84&&e[t+4]==83&&e[t+5]==67&&e[t+6]==65&&e[t+7]==80&&e[t+8]==69&&e[t+9]==50&&e[t+10]==46&&e[t+11]==48&&e[t+12]==3&&e[t+13]==1&&e[t+16]==0)t+=14,x=e[t++]|e[t++]<<8,t++;else for(t+=12;;){var d=e[t++];if(!(d>=0))throw Error("Invalid block size");if(d===0)break;t+=d}break;case 249:if(e[t++]!==4||e[t+4]!==0)throw new Error("Invalid graphics extension block.");var g=e[t++];v=e[t++]|e[t++]<<8,w=e[t++],g&1||(w=null),u=g>>2&7,t++;break;case 254:for(;;){var d=e[t++];if(!(d>=0))throw Error("Invalid block size");if(d===0)break;t+=d}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var R=e[t++]|e[t++]<<8,m=e[t++]|e[t++]<<8,M=e[t++]|e[t++]<<8,p=e[t++]|e[t++]<<8,_=e[t++],k=_>>7,B=_>>6&1,A=_&7,C=1<<A+1,S=h,E=f,X=!1;if(k){var X=!0;S=t,E=C,t+=C*3}var $=t;for(t++;;){var d=e[t++];if(!(d>=0))throw Error("Invalid block size");if(d===0)break;t+=d}l.push({x:R,y:m,width:M,height:p,has_local_palette:X,palette_offset:S,palette_size:E,data_offset:$,data_length:t-$,transparent_index:w,interlaced:!!B,delay:v,disposal:u});break;case 59:s=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return l.length},this.loopCount=function(){return x},this.frameInfo=function(D){if(D<0||D>=l.length)throw new Error("Frame index out of range.");return l[D]},this.decodeAndBlitFrameBGRA=function(D,I){var y=this.frameInfo(D),Q=y.width*y.height,q=new Uint8Array(Q);ue(e,y.data_offset,q,Q);var W=y.palette_offset,N=y.transparent_index;N===null&&(N=256);var G=y.width,P=n-G,H=G,Z=(y.y*n+y.x)*4,b=((y.y+y.height)*n+y.x)*4,F=Z,V=P*4;y.interlaced===!0&&(V+=n*4*7);for(var Y=8,z=0,ee=q.length;z<ee;++z){var j=q[z];if(H===0&&(F+=V,H=G,F>=b&&(V=P*4+n*4*(Y-1),F=Z+(G+P)*(Y<<1),Y>>=1)),j===N)F+=4;else{var te=e[W+j*3],re=e[W+j*3+1],ne=e[W+j*3+2];I[F++]=ne,I[F++]=re,I[F++]=te,I[F++]=255}--H}},this.decodeAndBlitFrameRGBA=function(D,I){var y=this.frameInfo(D),Q=y.width*y.height,q=new Uint8Array(Q);ue(e,y.data_offset,q,Q);var W=y.palette_offset,N=y.transparent_index;N===null&&(N=256);var G=y.width,P=n-G,H=G,Z=(y.y*n+y.x)*4,b=((y.y+y.height)*n+y.x)*4,F=Z,V=P*4;y.interlaced===!0&&(V+=n*4*7);for(var Y=8,z=0,ee=q.length;z<ee;++z){var j=q[z];if(H===0&&(F+=V,H=G,F>=b&&(V=P*4+n*4*(Y-1),F=Z+(G+P)*(Y<<1),Y>>=1)),j===N)F+=4;else{var te=e[W+j*3],re=e[W+j*3+1],ne=e[W+j*3+2];I[F++]=te,I[F++]=re,I[F++]=ne,I[F++]=255}--H}}}function ue(e,t,n,o){for(var r=e[t++],a=1<<r,c=a+1,i=c+1,h=r+1,f=(1<<h)-1,s=0,l=0,v=0,w=e[t++],u=new Int32Array(4096),x=null;;){for(;s<16&&w!==0;)l|=e[t++]<<s,s+=8,w===1?w=e[t++]:--w;if(s<h)break;var d=l&f;if(l>>=h,s-=h,d===a){i=c+1,h=r+1,f=(1<<h)-1,x=null;continue}else if(d===c)break;for(var g=d<i?d:x,R=0,m=g;m>a;)m=u[m]>>8,++R;var M=m,p=v+R+(g!==d?1:0);if(p>o){console.log("Warning, gif stream longer than expected.");return}n[v++]=M,v+=R;var _=v;for(g!==d&&(n[v++]=M),m=g;R--;)m=u[m],n[--_]=m&255,m>>=8;x!==null&&i<4096&&(u[i++]=x<<8|M,i>=f+1&&h<12&&(++h,f=f<<1|1)),x=d}return v!==o&&console.log("Warning, gif stream shorter than expected."),n}try{tt=fe.GifWriter=rt,_e=fe.GifReader=ot}catch{}const at=_e;function it(e){return async(t,n)=>{const o=e.find(r=>r.canResolve(t));if(!o)throw new Re("No texture provider matched source",t);return Ee(o.resolve.bind(o),t,n)}}class Re extends Error{constructor(n,o){super(n);O(this,"source");this.name="TextureSourceLoadError",this.source=o}}function J(e){if(e.aborted)throw new DOMException("Texture source load aborted","AbortError")}async function Ee(e,t,n){J(n);const o=await e(t,n);return n.aborted&&(o.dispose(),J(n)),o}function st(e){e==null||e.dispose()}const Te=5*1024*1024,ie=1e6,se=180,lt=(e,t,n)=>{for(let o=n.y;o<n.y+n.height;o+=1)e.fill(0,(o*t+n.x)*4,(o*t+n.x+n.width)*4)},ct=(e,t,n,o,r)=>t.byteLength>Te?`file is ${(t.byteLength/1024/1024).toFixed(1)} MB; max is 5 MB`:n*o>ie?`canvas is ${n}x${o}; max area is ${ie}`:r>se?`frame count is ${r}; max is ${se}`:r===0?"frame count is 0":e?null:"source URL is empty",dt=e=>typeof e=="string"?e:e.src,ht={canResolve:e=>typeof e=="string"?/\.gif(?:[?#].*)?$/i.test(e):e.kind==="gif",async resolve(e,t){const n=dt(e),o=await fetch(n,{signal:t});if(!o.ok)throw new Error(`GIF request failed with ${o.status}`);const r=new Uint8Array(await o.arrayBuffer());J(t);const a=new at(r),c=a.numFrames(),i=ct(n,r,a.width,a.height,c);if(i)throw console.warn(`[xr-sdk] GIF ScreenImage source rejected: ${i}`,n),new Error(`GIF source rejected: ${i}`);const h=document.createElement("canvas");h.width=a.width,h.height=a.height;const f=h.getContext("2d");if(!f)throw new Error("Could not create GIF canvas context");const s=new U.CanvasTexture(h);s.colorSpace=U.SRGBColorSpace;const l=new Uint8Array(a.width*a.height*4),v=new ImageData(new Uint8ClampedArray(l.buffer),a.width,a.height),w=Array.from({length:c},(S,E)=>a.frameInfo(E)),u=w.reduce((S,E)=>S+Math.max(20,E.delay*10),0)/1e3,x=new Se({canSeek:!1,canReverse:!1,supportsLoopCount:!0},{state:"ready",duration:u,frameCount:c});let d=0,g=0,R=!1,m=!1,M=0,p=0,_=null;const k=(S,E=!1)=>{E&&(l.fill(0),_=null),(_==null?void 0:_.info.disposal)===2?lt(l,a.width,_.info):_!=null&&_.restorePixels&&l.set(_.restorePixels);const X=w[S],$=X.disposal===3?new Uint8Array(l):null;return a.decodeAndBlitFrameRGBA(S,l),f.putImageData(v,0,0),s.needsUpdate=!0,_={info:X,restorePixels:$},m=!0,x.updateSnapshot({frame:S,time:w.slice(0,S).reduce((D,I)=>D+Math.max(20,I.delay*10),0)/1e3}),m=!1,x.emit("KeyFrameInSecond"),Math.max(20,X.delay*10)},B=S=>{g=window.setTimeout(()=>{d=requestAnimationFrame(A)},S)},A=()=>{if(R||x.getSnapshot().state!=="playing")return;const S=x.getSnapshot(),E=ye(M,c,S.playMode,S.loop,S.loopCount);if(E.ended){x.updateSnapshot({state:"ended",frame:E.frame,time:u}),x.emit("PlayEnd");return}const X=E.loop!==p;p=E.loop,M+=1,B(k(E.frame,X))},C=x.subscribe(S=>{m||(clearTimeout(g),cancelAnimationFrame(d),S.state==="playing"&&(d=requestAnimationFrame(A)))});return k(0),x.play(),{texture:s,controller:x,metadata:{width:a.width,height:a.height,duration:u,frameCount:c},dispose(){R=!0,C(),clearTimeout(g),cancelAnimationFrame(d),x.dispose(),s.dispose()}}}},Me=T.createContext(null),Ae=T.createContext(null),ft=()=>T.useContext(Me),ut=()=>T.useContext(Ae);exports.BasicAnimatedTextureController=Se;exports.MAX_GIF_BYTES=Te;exports.MAX_GIF_FRAMES=se;exports.MAX_GIF_PIXELS=ie;exports.ScreenTransform=be;exports.SplashScreen=me;exports.TextureSourceLoadError=Re;exports.XRScene=Qe;exports.XRViewportRenderOutputsContext=Ae;exports.XRViewportStateContext=Me;exports.computeScreenTransform=we;exports.createTextureSourceResolver=it;exports.disposeResolvedTextureSource=st;exports.getPlaybackFrame=ye;exports.getSequenceFrame=et;exports.gifTextureSourceProvider=ht;exports.isSplashColour=ae;exports.isSplashLogo=ge;exports.resolveTextureSource=Ee;exports.throwIfAborted=J;exports.useXRViewportRenderOutputs=ut;exports.useXRViewportState=ft;