@webspatial/react-sdk 1.5.0 → 1.6.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/default/index.d.ts +14 -0
- package/dist/default/index.js +367 -231
- package/dist/default/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.web.js +1 -1
- package/dist/web/index.d.ts +14 -0
- package/dist/web/index.js +371 -235
- package/dist/web/index.js.map +1 -1
- package/package.json +5 -4
package/dist/default/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
(function(){
|
|
3
3
|
if(typeof window === 'undefined') return;
|
|
4
4
|
if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
|
|
5
|
-
window.__webspatialsdk__['react-sdk-version'] = "1.
|
|
5
|
+
window.__webspatialsdk__['react-sdk-version'] = "1.6.0"
|
|
6
6
|
window.__webspatialsdk__['XR_ENV'] = "avp"
|
|
7
7
|
})()
|
|
8
8
|
|
|
@@ -145,11 +145,20 @@ function joinToCSSText(cssKV) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// src/spatialized-container/hooks/useDomProxy.ts
|
|
148
|
-
function makeOriginalKey(key) {
|
|
149
|
-
return `__original_${key}`;
|
|
150
|
-
}
|
|
151
148
|
var SpatialContainerRefProxy = class {
|
|
152
149
|
transformVisibilityTaskContainerDom = null;
|
|
150
|
+
/** Raw Standard host element (styled root). Used to mirror class onto the transform probe. */
|
|
151
|
+
standardRawDom = null;
|
|
152
|
+
standardClassObserver = null;
|
|
153
|
+
/**
|
|
154
|
+
* When set, Standard's DOM className is forwarded here so TransformVisibilityTaskContainer
|
|
155
|
+
* can render it from React state (avoids React clobbering imperative class updates).
|
|
156
|
+
*/
|
|
157
|
+
mirrorClassNotify = null;
|
|
158
|
+
/** Last class string applied to the probe + used to skip redundant syncs. */
|
|
159
|
+
lastMirroredClassName = null;
|
|
160
|
+
/** Coalesce multiple class sync triggers in the same turn (Observer + classList, etc.). */
|
|
161
|
+
classSyncMicrotaskQueued = false;
|
|
153
162
|
ref;
|
|
154
163
|
domProxy;
|
|
155
164
|
styleProxy;
|
|
@@ -159,211 +168,263 @@ var SpatialContainerRefProxy = class {
|
|
|
159
168
|
this.ref = ref;
|
|
160
169
|
this.extraRefProps = extraRefProps;
|
|
161
170
|
}
|
|
171
|
+
setMirrorClassNotify(fn) {
|
|
172
|
+
this.mirrorClassNotify = fn;
|
|
173
|
+
if (fn && this.standardRawDom) {
|
|
174
|
+
this.flushSyncTransformClassFromStandard(true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
disconnectStandardClassObserver() {
|
|
178
|
+
this.standardClassObserver?.disconnect();
|
|
179
|
+
this.standardClassObserver = null;
|
|
180
|
+
}
|
|
181
|
+
attachStandardClassObserver() {
|
|
182
|
+
this.disconnectStandardClassObserver();
|
|
183
|
+
if (!this.standardRawDom) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.standardClassObserver = new MutationObserver(() => {
|
|
187
|
+
this.scheduleSyncTransformClassFromStandard();
|
|
188
|
+
});
|
|
189
|
+
this.standardClassObserver.observe(this.standardRawDom, {
|
|
190
|
+
attributes: true,
|
|
191
|
+
attributeFilter: ["class"]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Merge multiple sync requests (e.g. classList hook + MutationObserver) into one microtask.
|
|
196
|
+
*/
|
|
197
|
+
scheduleSyncTransformClassFromStandard() {
|
|
198
|
+
if (this.classSyncMicrotaskQueued) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.classSyncMicrotaskQueued = true;
|
|
202
|
+
queueMicrotask(() => {
|
|
203
|
+
this.classSyncMicrotaskQueued = false;
|
|
204
|
+
this.flushSyncTransformClassFromStandard(false);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Source of truth: Standard host DOM (incl. styled-components runtime class changes).
|
|
209
|
+
* @param force when true, skip same-string short-circuit (e.g. mirror notify just registered).
|
|
210
|
+
*/
|
|
211
|
+
flushSyncTransformClassFromStandard(force) {
|
|
212
|
+
if (!this.standardRawDom) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const name = this.standardRawDom.className;
|
|
216
|
+
const probe = this.transformVisibilityTaskContainerDom;
|
|
217
|
+
if (!force && probe && probe.className === name && this.lastMirroredClassName === name) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.lastMirroredClassName = name;
|
|
221
|
+
if (probe) {
|
|
222
|
+
probe.className = name;
|
|
223
|
+
}
|
|
224
|
+
this.mirrorClassNotify?.(name);
|
|
225
|
+
}
|
|
162
226
|
updateStandardSpatializedContainerDom(dom) {
|
|
163
227
|
const self = this;
|
|
164
|
-
if (dom) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} else {
|
|
211
|
-
|
|
228
|
+
if (!dom) {
|
|
229
|
+
this.disconnectStandardClassObserver();
|
|
230
|
+
this.standardRawDom = null;
|
|
231
|
+
this.lastMirroredClassName = null;
|
|
232
|
+
this.domProxy = void 0;
|
|
233
|
+
this.styleProxy = void 0;
|
|
234
|
+
this.updateDomProxyToRef();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.standardRawDom = dom;
|
|
238
|
+
let cacheExtraRefProps;
|
|
239
|
+
const domProxy = new Proxy(
|
|
240
|
+
dom,
|
|
241
|
+
{
|
|
242
|
+
get(target, prop) {
|
|
243
|
+
if (prop === "__raw") {
|
|
244
|
+
return target;
|
|
245
|
+
}
|
|
246
|
+
if (prop === "xrClientDepth") {
|
|
247
|
+
return target.style.getPropertyValue(SpatialCustomStyleVars.depth);
|
|
248
|
+
}
|
|
249
|
+
if (prop === "xrOffsetBack") {
|
|
250
|
+
return target.style.getPropertyValue(SpatialCustomStyleVars.back);
|
|
251
|
+
}
|
|
252
|
+
if (prop === "style") {
|
|
253
|
+
if (!self.styleProxy) {
|
|
254
|
+
self.styleProxy = new Proxy(target.style, {
|
|
255
|
+
get(target2, prop2) {
|
|
256
|
+
if (prop2 === "visibility" || prop2 === "transform") {
|
|
257
|
+
return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(
|
|
258
|
+
prop2
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
const value2 = Reflect.get(target2, prop2);
|
|
262
|
+
if (typeof value2 === "function") {
|
|
263
|
+
if (prop2 === "setProperty" || prop2 === "removeProperty" || prop2 === "getPropertyValue") {
|
|
264
|
+
return function(...args) {
|
|
265
|
+
const validProperties = ["visibility", "transform"];
|
|
266
|
+
const [property] = args;
|
|
267
|
+
if (validProperties.includes(property)) {
|
|
268
|
+
if (prop2 === "setProperty") {
|
|
269
|
+
const [, kValue] = args;
|
|
270
|
+
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
271
|
+
property,
|
|
272
|
+
kValue
|
|
273
|
+
);
|
|
274
|
+
} else if (prop2 === "removeProperty") {
|
|
275
|
+
self.transformVisibilityTaskContainerDom?.style.removeProperty(
|
|
276
|
+
property
|
|
277
|
+
);
|
|
278
|
+
} else if (prop2 === "getPropertyValue") {
|
|
279
|
+
return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(
|
|
280
|
+
property
|
|
281
|
+
);
|
|
212
282
|
}
|
|
213
|
-
}.bind(target2);
|
|
214
|
-
} else {
|
|
215
|
-
return value2.bind(target2);
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
return value2;
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
set(target2, prop2, value2) {
|
|
222
|
-
if (prop2 === "visibility") {
|
|
223
|
-
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
224
|
-
"visibility",
|
|
225
|
-
value2
|
|
226
|
-
);
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
if (prop2 === "transform") {
|
|
230
|
-
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
231
|
-
"transform",
|
|
232
|
-
value2
|
|
233
|
-
);
|
|
234
|
-
return true;
|
|
235
|
-
}
|
|
236
|
-
if (prop2 === SpatialCustomStyleVars.backgroundMaterial) {
|
|
237
|
-
target2.setProperty(
|
|
238
|
-
SpatialCustomStyleVars.backgroundMaterial,
|
|
239
|
-
value2
|
|
240
|
-
);
|
|
241
|
-
} else if (prop2 === SpatialCustomStyleVars.back) {
|
|
242
|
-
target2.setProperty(
|
|
243
|
-
SpatialCustomStyleVars.back,
|
|
244
|
-
value2
|
|
245
|
-
);
|
|
246
|
-
} else if (prop2 === SpatialCustomStyleVars.xrZIndex) {
|
|
247
|
-
target2.setProperty(
|
|
248
|
-
SpatialCustomStyleVars.xrZIndex,
|
|
249
|
-
value2
|
|
250
|
-
);
|
|
251
|
-
} else if (prop2 === SpatialCustomStyleVars.depth) {
|
|
252
|
-
target2.setProperty(
|
|
253
|
-
SpatialCustomStyleVars.depth,
|
|
254
|
-
value2
|
|
255
|
-
);
|
|
256
|
-
} else if (prop2 === "cssText") {
|
|
257
|
-
const toFilteredCSSProperties = [
|
|
258
|
-
"transform",
|
|
259
|
-
"visibility"
|
|
260
|
-
];
|
|
261
|
-
const { extractedValues, filteredCssText } = extractAndRemoveCustomProperties(
|
|
262
|
-
value2,
|
|
263
|
-
toFilteredCSSProperties
|
|
264
|
-
);
|
|
265
|
-
toFilteredCSSProperties.forEach((key) => {
|
|
266
|
-
if (extractedValues[key]) {
|
|
267
|
-
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
268
|
-
key,
|
|
269
|
-
extractedValues[key]
|
|
270
|
-
);
|
|
271
283
|
} else {
|
|
272
|
-
|
|
284
|
+
return value2.apply(this, args);
|
|
273
285
|
}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
visibility: "hidden"
|
|
278
|
-
});
|
|
279
|
-
return Reflect.set(
|
|
280
|
-
target2,
|
|
281
|
-
prop2,
|
|
282
|
-
[appendedCSSText, filteredCssText].join(";")
|
|
283
|
-
);
|
|
286
|
+
}.bind(target2);
|
|
287
|
+
} else {
|
|
288
|
+
return value2.bind(target2);
|
|
284
289
|
}
|
|
285
|
-
|
|
290
|
+
} else {
|
|
291
|
+
return value2;
|
|
286
292
|
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
const extraProps = cacheExtraRefProps;
|
|
296
|
-
if (extraProps.hasOwnProperty(prop)) {
|
|
297
|
-
return extraProps[prop];
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const value = Reflect.get(target, prop);
|
|
301
|
-
if (typeof value === "function") {
|
|
302
|
-
if ("removeAttribute" === prop) {
|
|
303
|
-
return function(...args) {
|
|
304
|
-
const [property] = args;
|
|
305
|
-
if (property === "style") {
|
|
306
|
-
dom.style.cssText = "visibility: hidden; transition: none; transform: none;";
|
|
307
|
-
if (self.transformVisibilityTaskContainerDom) {
|
|
308
|
-
self.transformVisibilityTaskContainerDom.style.visibility = "";
|
|
309
|
-
self.transformVisibilityTaskContainerDom.style.transform = "";
|
|
310
|
-
}
|
|
293
|
+
},
|
|
294
|
+
set(target2, prop2, value2) {
|
|
295
|
+
if (prop2 === "visibility") {
|
|
296
|
+
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
297
|
+
"visibility",
|
|
298
|
+
value2
|
|
299
|
+
);
|
|
311
300
|
return true;
|
|
312
301
|
}
|
|
313
|
-
if (
|
|
314
|
-
|
|
302
|
+
if (prop2 === "transform") {
|
|
303
|
+
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
304
|
+
"transform",
|
|
305
|
+
value2
|
|
306
|
+
);
|
|
315
307
|
return true;
|
|
316
308
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
309
|
+
if (prop2 === SpatialCustomStyleVars.backgroundMaterial) {
|
|
310
|
+
target2.setProperty(
|
|
311
|
+
SpatialCustomStyleVars.backgroundMaterial,
|
|
312
|
+
value2
|
|
313
|
+
);
|
|
314
|
+
} else if (prop2 === SpatialCustomStyleVars.back) {
|
|
315
|
+
target2.setProperty(
|
|
316
|
+
SpatialCustomStyleVars.back,
|
|
317
|
+
value2
|
|
318
|
+
);
|
|
319
|
+
} else if (prop2 === SpatialCustomStyleVars.xrZIndex) {
|
|
320
|
+
target2.setProperty(
|
|
321
|
+
SpatialCustomStyleVars.xrZIndex,
|
|
322
|
+
value2
|
|
323
|
+
);
|
|
324
|
+
} else if (prop2 === SpatialCustomStyleVars.depth) {
|
|
325
|
+
target2.setProperty(
|
|
326
|
+
SpatialCustomStyleVars.depth,
|
|
327
|
+
value2
|
|
328
|
+
);
|
|
329
|
+
} else if (prop2 === "cssText") {
|
|
330
|
+
const toFilteredCSSProperties = ["transform", "visibility"];
|
|
331
|
+
const { extractedValues, filteredCssText } = extractAndRemoveCustomProperties(
|
|
332
|
+
value2,
|
|
333
|
+
toFilteredCSSProperties
|
|
334
|
+
);
|
|
335
|
+
toFilteredCSSProperties.forEach((key) => {
|
|
336
|
+
if (extractedValues[key]) {
|
|
337
|
+
self.transformVisibilityTaskContainerDom?.style.setProperty(
|
|
338
|
+
key,
|
|
339
|
+
extractedValues[key]
|
|
340
|
+
);
|
|
341
|
+
} else {
|
|
342
|
+
target2.removeProperty(key);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
const appendedCSSText = joinToCSSText({
|
|
346
|
+
transform: "none",
|
|
347
|
+
visibility: "hidden"
|
|
348
|
+
});
|
|
349
|
+
return Reflect.set(
|
|
350
|
+
target2,
|
|
351
|
+
prop2,
|
|
352
|
+
[appendedCSSText, filteredCssText].join(";")
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
return Reflect.set(target2, prop2, value2);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
320
358
|
}
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
value = value + " xr-spatial-default";
|
|
327
|
-
}
|
|
328
|
-
if (self.transformVisibilityTaskContainerDom) {
|
|
329
|
-
self.transformVisibilityTaskContainerDom.className = value;
|
|
330
|
-
}
|
|
359
|
+
return self.styleProxy;
|
|
360
|
+
}
|
|
361
|
+
if (typeof prop === "string" && self.extraRefProps) {
|
|
362
|
+
if (!cacheExtraRefProps) {
|
|
363
|
+
cacheExtraRefProps = self.extraRefProps(domProxy);
|
|
331
364
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
cacheExtraRefProps[prop] = value;
|
|
365
|
+
const extraProps = cacheExtraRefProps;
|
|
366
|
+
if (extraProps.hasOwnProperty(prop)) {
|
|
367
|
+
return extraProps[prop];
|
|
337
368
|
}
|
|
338
|
-
return Reflect.set(target, prop, value);
|
|
339
369
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
370
|
+
const value = Reflect.get(target, prop);
|
|
371
|
+
if (typeof value === "function") {
|
|
372
|
+
if ("removeAttribute" === prop) {
|
|
373
|
+
return function(...args) {
|
|
374
|
+
const [property] = args;
|
|
375
|
+
if (property === "style") {
|
|
376
|
+
dom.style.cssText = "visibility: hidden; transition: none; transform: none;";
|
|
377
|
+
if (self.transformVisibilityTaskContainerDom) {
|
|
378
|
+
self.transformVisibilityTaskContainerDom.style.visibility = "";
|
|
379
|
+
self.transformVisibilityTaskContainerDom.style.transform = "";
|
|
380
|
+
}
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
if (property === "class") {
|
|
384
|
+
domProxy.className = "xr-spatial-default";
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
return value.bind(target);
|
|
354
390
|
}
|
|
355
|
-
return
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
391
|
+
return value;
|
|
392
|
+
},
|
|
393
|
+
set(target, prop, value) {
|
|
394
|
+
if (prop === "className") {
|
|
395
|
+
if (value && String(value).indexOf("xr-spatial-default") === -1) {
|
|
396
|
+
value = value + " xr-spatial-default";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (typeof prop === "string" && self.extraRefProps) {
|
|
400
|
+
if (!cacheExtraRefProps) {
|
|
401
|
+
cacheExtraRefProps = self.extraRefProps(domProxy);
|
|
402
|
+
}
|
|
403
|
+
cacheExtraRefProps[prop] = value;
|
|
404
|
+
}
|
|
405
|
+
const ok = Reflect.set(target, prop, value);
|
|
406
|
+
if (ok && prop === "className") {
|
|
407
|
+
self.scheduleSyncTransformClassFromStandard();
|
|
408
|
+
}
|
|
409
|
+
return ok;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
this.domProxy = domProxy;
|
|
414
|
+
this.styleProxy = void 0;
|
|
415
|
+
this.updateDomProxyToRef();
|
|
416
|
+
Object.assign(dom, {
|
|
417
|
+
__targetProxy: domProxy
|
|
418
|
+
});
|
|
419
|
+
this.attachStandardClassObserver();
|
|
420
|
+
this.scheduleSyncTransformClassFromStandard();
|
|
364
421
|
}
|
|
365
422
|
updateTransformVisibilityTaskContainerDom(dom) {
|
|
366
423
|
this.transformVisibilityTaskContainerDom = dom;
|
|
424
|
+
if (!dom) {
|
|
425
|
+
this.lastMirroredClassName = null;
|
|
426
|
+
}
|
|
427
|
+
this.scheduleSyncTransformClassFromStandard();
|
|
367
428
|
this.updateDomProxyToRef();
|
|
368
429
|
}
|
|
369
430
|
updateDomProxyToRef() {
|
|
@@ -843,7 +904,14 @@ var TransformVisibilityTaskContainer = forwardRef2(
|
|
|
843
904
|
);
|
|
844
905
|
|
|
845
906
|
// src/spatialized-container/SpatializedContainer.tsx
|
|
846
|
-
import {
|
|
907
|
+
import {
|
|
908
|
+
forwardRef as forwardRef4,
|
|
909
|
+
useCallback as useCallback6,
|
|
910
|
+
useContext as useContext7,
|
|
911
|
+
useEffect as useEffect10,
|
|
912
|
+
useMemo as useMemo2,
|
|
913
|
+
useState as useState6
|
|
914
|
+
} from "react";
|
|
847
915
|
|
|
848
916
|
// src/utils/getSession.ts
|
|
849
917
|
import { isSSREnv, Spatial } from "@webspatial/core-sdk";
|
|
@@ -1148,7 +1216,7 @@ function renderPlaceholderInSubPortal(portalInstanceObject, El) {
|
|
|
1148
1216
|
return /* @__PURE__ */ jsx3(Fragment, {});
|
|
1149
1217
|
}
|
|
1150
1218
|
const { width, height } = portalInstanceObject.domRect;
|
|
1151
|
-
const display = portalInstanceObject.computedStyle.
|
|
1219
|
+
const display = portalInstanceObject.computedStyle.getPropertyValue("display");
|
|
1152
1220
|
const spatialIdProps = { [SpatialID]: spatialId };
|
|
1153
1221
|
return /* @__PURE__ */ jsx3(
|
|
1154
1222
|
El,
|
|
@@ -1593,6 +1661,20 @@ function SpatializedContainerBase(inprops, ref) {
|
|
|
1593
1661
|
standardSpatializedContainerCallback,
|
|
1594
1662
|
spatialContainerRefProxy
|
|
1595
1663
|
} = useDomProxy(ref, extraRefProps);
|
|
1664
|
+
const [probeClassName, setProbeClassName] = useState6(
|
|
1665
|
+
() => props.className ?? ""
|
|
1666
|
+
);
|
|
1667
|
+
const notifyProbeClass = useCallback6((name) => {
|
|
1668
|
+
setProbeClassName((prev) => prev === name ? prev : name);
|
|
1669
|
+
}, []);
|
|
1670
|
+
useEffect10(() => {
|
|
1671
|
+
spatialContainerRefProxy.current.setMirrorClassNotify?.(
|
|
1672
|
+
notifyProbeClass
|
|
1673
|
+
);
|
|
1674
|
+
return () => {
|
|
1675
|
+
spatialContainerRefProxy.current.setMirrorClassNotify?.(null);
|
|
1676
|
+
};
|
|
1677
|
+
}, [spatialContainerRefProxy, notifyProbeClass]);
|
|
1596
1678
|
useEffect10(() => {
|
|
1597
1679
|
rootSpatializedContainerObject.updateSpatialContainerRefProxyInfo(
|
|
1598
1680
|
spatialId,
|
|
@@ -1621,7 +1703,7 @@ function SpatializedContainerBase(inprops, ref) {
|
|
|
1621
1703
|
{
|
|
1622
1704
|
ref: transformVisibilityTaskContainerCallback,
|
|
1623
1705
|
...spatialIdProps,
|
|
1624
|
-
className:
|
|
1706
|
+
className: probeClassName,
|
|
1625
1707
|
style: props.style
|
|
1626
1708
|
}
|
|
1627
1709
|
)
|
|
@@ -1633,6 +1715,18 @@ function SpatializedContainerBase(inprops, ref) {
|
|
|
1633
1715
|
standardSpatializedContainerCallback,
|
|
1634
1716
|
spatialContainerRefProxy
|
|
1635
1717
|
} = useDomProxy(ref, extraRefProps);
|
|
1718
|
+
const [probeClassName, setProbeClassName] = useState6(
|
|
1719
|
+
() => props.className ?? ""
|
|
1720
|
+
);
|
|
1721
|
+
const notifyProbeClass = useCallback6((name) => {
|
|
1722
|
+
setProbeClassName((prev) => prev === name ? prev : name);
|
|
1723
|
+
}, []);
|
|
1724
|
+
useEffect10(() => {
|
|
1725
|
+
spatialContainerRefProxy.current.setMirrorClassNotify?.(notifyProbeClass);
|
|
1726
|
+
return () => {
|
|
1727
|
+
spatialContainerRefProxy.current.setMirrorClassNotify?.(null);
|
|
1728
|
+
};
|
|
1729
|
+
}, [spatialContainerRefProxy, notifyProbeClass]);
|
|
1636
1730
|
const spatialEvents = useSpatialEvents(
|
|
1637
1731
|
{
|
|
1638
1732
|
onSpatialTap,
|
|
@@ -1684,7 +1778,7 @@ function SpatializedContainerBase(inprops, ref) {
|
|
|
1684
1778
|
{
|
|
1685
1779
|
ref: transformVisibilityTaskContainerCallback,
|
|
1686
1780
|
...spatialIdProps,
|
|
1687
|
-
className:
|
|
1781
|
+
className: probeClassName,
|
|
1688
1782
|
style: props.style
|
|
1689
1783
|
}
|
|
1690
1784
|
)
|
|
@@ -1964,8 +2058,10 @@ var Spatialized2DElementContainer = forwardRef5(
|
|
|
1964
2058
|
|
|
1965
2059
|
// src/spatialized-container/SpatializedStatic3DElementContainer.tsx
|
|
1966
2060
|
import {
|
|
2061
|
+
Children,
|
|
1967
2062
|
forwardRef as forwardRef6,
|
|
1968
|
-
|
|
2063
|
+
isValidElement,
|
|
2064
|
+
useCallback as useCallback7,
|
|
1969
2065
|
useContext as useContext9,
|
|
1970
2066
|
useEffect as useEffect13,
|
|
1971
2067
|
useMemo as useMemo3,
|
|
@@ -1973,9 +2069,7 @@ import {
|
|
|
1973
2069
|
} from "react";
|
|
1974
2070
|
import { Fragment as Fragment2, jsx as jsx8 } from "react/jsx-runtime";
|
|
1975
2071
|
function getAbsoluteURL(url) {
|
|
1976
|
-
if (!url)
|
|
1977
|
-
return "";
|
|
1978
|
-
}
|
|
2072
|
+
if (!url) return url;
|
|
1979
2073
|
try {
|
|
1980
2074
|
return new URL(url, document.baseURI).toString();
|
|
1981
2075
|
} catch {
|
|
@@ -2003,21 +2097,34 @@ function createLoadFailureEvent(targetGetter) {
|
|
|
2003
2097
|
function createLoadSuccessEvent(targetGetter) {
|
|
2004
2098
|
return createLoadEvent("modelloaded", targetGetter);
|
|
2005
2099
|
}
|
|
2100
|
+
function collectSources(children) {
|
|
2101
|
+
const sources = [];
|
|
2102
|
+
Children.forEach(children, (child) => {
|
|
2103
|
+
if (isValidElement(child) && child.type === "source") {
|
|
2104
|
+
const { src, type } = child.props;
|
|
2105
|
+
if (src) {
|
|
2106
|
+
sources.push({ src: getAbsoluteURL(src), type });
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
return sources;
|
|
2111
|
+
}
|
|
2006
2112
|
function SpatializedContent2(props) {
|
|
2007
|
-
const { src, spatializedElement, onLoad, onError } = props;
|
|
2008
|
-
const
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2011
|
-
);
|
|
2012
|
-
const currentSrc = useMemo3(() => getAbsoluteURL(src), [src]);
|
|
2113
|
+
const { src, children, spatializedElement, onLoad, onError, autoPlay, loop } = props;
|
|
2114
|
+
const portalInstanceObject = useContext9(PortalInstanceContext);
|
|
2115
|
+
const modelURL = useMemo3(() => getAbsoluteURL(src), [src]);
|
|
2116
|
+
const sources = useMemo3(() => collectSources(children), [children]);
|
|
2013
2117
|
useEffect13(() => {
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2118
|
+
spatializedElement.updateProperties({
|
|
2119
|
+
modelURL: modelURL ?? "",
|
|
2120
|
+
sources,
|
|
2121
|
+
autoplay: autoPlay,
|
|
2122
|
+
loop
|
|
2123
|
+
});
|
|
2124
|
+
}, [modelURL, JSON.stringify(sources), autoPlay, loop]);
|
|
2018
2125
|
useEffect13(() => {
|
|
2019
2126
|
if (onLoad) {
|
|
2020
|
-
|
|
2127
|
+
spatializedElement.onLoadCallback = () => {
|
|
2021
2128
|
onLoad(
|
|
2022
2129
|
createLoadSuccessEvent(
|
|
2023
2130
|
() => portalInstanceObject.dom.__targetProxy
|
|
@@ -2025,12 +2132,12 @@ function SpatializedContent2(props) {
|
|
|
2025
2132
|
);
|
|
2026
2133
|
};
|
|
2027
2134
|
} else {
|
|
2028
|
-
|
|
2135
|
+
spatializedElement.onLoadCallback = void 0;
|
|
2029
2136
|
}
|
|
2030
2137
|
}, [onLoad]);
|
|
2031
2138
|
useEffect13(() => {
|
|
2032
2139
|
if (onError) {
|
|
2033
|
-
|
|
2140
|
+
spatializedElement.onLoadFailureCallback = () => {
|
|
2034
2141
|
onError(
|
|
2035
2142
|
createLoadFailureEvent(
|
|
2036
2143
|
() => portalInstanceObject.dom.__targetProxy
|
|
@@ -2038,24 +2145,27 @@ function SpatializedContent2(props) {
|
|
|
2038
2145
|
);
|
|
2039
2146
|
};
|
|
2040
2147
|
} else {
|
|
2041
|
-
|
|
2148
|
+
spatializedElement.onLoadFailureCallback = void 0;
|
|
2042
2149
|
}
|
|
2043
2150
|
}, [onError]);
|
|
2044
2151
|
return /* @__PURE__ */ jsx8(Fragment2, {});
|
|
2045
2152
|
}
|
|
2046
2153
|
function SpatializedStatic3DElementContainerBase(props, ref) {
|
|
2047
2154
|
const promiseRef = useRef5(null);
|
|
2048
|
-
const createSpatializedElement2 =
|
|
2049
|
-
|
|
2050
|
-
|
|
2155
|
+
const createSpatializedElement2 = useCallback7(() => {
|
|
2156
|
+
promiseRef.current = getSession().createSpatializedStatic3DElement(
|
|
2157
|
+
getAbsoluteURL(props.src),
|
|
2158
|
+
collectSources(props.children)
|
|
2159
|
+
);
|
|
2051
2160
|
return promiseRef.current;
|
|
2052
2161
|
}, []);
|
|
2053
|
-
const extraRefProps =
|
|
2162
|
+
const extraRefProps = useCallback7(
|
|
2054
2163
|
(domProxy) => {
|
|
2055
2164
|
let modelTransform = new DOMMatrixReadOnly();
|
|
2056
2165
|
return {
|
|
2057
2166
|
get currentSrc() {
|
|
2058
|
-
|
|
2167
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2168
|
+
return spatializedElement?.currentSrc ?? "";
|
|
2059
2169
|
},
|
|
2060
2170
|
get ready() {
|
|
2061
2171
|
return promiseRef.current.then((spatializedElement) => spatializedElement.ready).then((success) => {
|
|
@@ -2070,6 +2180,32 @@ function SpatializedStatic3DElementContainerBase(props, ref) {
|
|
|
2070
2180
|
modelTransform = value;
|
|
2071
2181
|
const spatializedElement = domProxy.__spatializedElement;
|
|
2072
2182
|
spatializedElement?.updateModelTransform(modelTransform);
|
|
2183
|
+
},
|
|
2184
|
+
async play() {
|
|
2185
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2186
|
+
await spatializedElement?.play();
|
|
2187
|
+
},
|
|
2188
|
+
async pause() {
|
|
2189
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2190
|
+
await spatializedElement?.pause();
|
|
2191
|
+
},
|
|
2192
|
+
get paused() {
|
|
2193
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2194
|
+
return spatializedElement?.paused ?? true;
|
|
2195
|
+
},
|
|
2196
|
+
get duration() {
|
|
2197
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2198
|
+
return spatializedElement?.duration ?? 0;
|
|
2199
|
+
},
|
|
2200
|
+
get playbackRate() {
|
|
2201
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2202
|
+
return spatializedElement?.playbackRate ?? 1;
|
|
2203
|
+
},
|
|
2204
|
+
set playbackRate(value) {
|
|
2205
|
+
const spatializedElement = domProxy.__spatializedElement;
|
|
2206
|
+
if (spatializedElement) {
|
|
2207
|
+
spatializedElement.playbackRate = value;
|
|
2208
|
+
}
|
|
2073
2209
|
}
|
|
2074
2210
|
};
|
|
2075
2211
|
},
|
|
@@ -2882,10 +3018,10 @@ var useEntity = ({
|
|
|
2882
3018
|
};
|
|
2883
3019
|
|
|
2884
3020
|
// src/reality/hooks/useForceUpdate.tsx
|
|
2885
|
-
import { useCallback as
|
|
3021
|
+
import { useCallback as useCallback8, useState as useState7 } from "react";
|
|
2886
3022
|
var useForceUpdate2 = () => {
|
|
2887
|
-
const [, setTick] =
|
|
2888
|
-
return
|
|
3023
|
+
const [, setTick] = useState7(0);
|
|
3024
|
+
return useCallback8(() => setTick((tick) => tick + 1), []);
|
|
2889
3025
|
};
|
|
2890
3026
|
|
|
2891
3027
|
// src/reality/components/BaseEntity.tsx
|
|
@@ -3308,10 +3444,10 @@ var ModelEntity = forwardRef18(
|
|
|
3308
3444
|
// src/reality/components/Reality.tsx
|
|
3309
3445
|
import {
|
|
3310
3446
|
forwardRef as forwardRef19,
|
|
3311
|
-
useCallback as
|
|
3447
|
+
useCallback as useCallback9,
|
|
3312
3448
|
useEffect as useEffect26,
|
|
3313
3449
|
useRef as useRef16,
|
|
3314
|
-
useState as
|
|
3450
|
+
useState as useState8
|
|
3315
3451
|
} from "react";
|
|
3316
3452
|
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3317
3453
|
var Reality = forwardRef19(
|
|
@@ -3336,8 +3472,8 @@ var Reality = forwardRef19(
|
|
|
3336
3472
|
} = inProps;
|
|
3337
3473
|
const ctxRef = useRef16(null);
|
|
3338
3474
|
const creationId = useRef16(0);
|
|
3339
|
-
const [isReady, setIsReady] =
|
|
3340
|
-
const cleanupReality =
|
|
3475
|
+
const [isReady, setIsReady] = useState8(false);
|
|
3476
|
+
const cleanupReality = useCallback9(() => {
|
|
3341
3477
|
ctxRef.current?.attachmentRegistry.destroy();
|
|
3342
3478
|
ctxRef.current?.resourceRegistry.destroy();
|
|
3343
3479
|
ctxRef.current?.reality.destroy();
|
|
@@ -3350,7 +3486,7 @@ var Reality = forwardRef19(
|
|
|
3350
3486
|
cleanupReality();
|
|
3351
3487
|
};
|
|
3352
3488
|
}, [cleanupReality]);
|
|
3353
|
-
const createReality =
|
|
3489
|
+
const createReality = useCallback9(async () => {
|
|
3354
3490
|
const id = ++creationId.current;
|
|
3355
3491
|
const resourceRegistry = new ResourceRegistry();
|
|
3356
3492
|
const attachmentRegistry = new AttachmentRegistry();
|
|
@@ -3393,7 +3529,7 @@ var Reality = forwardRef19(
|
|
|
3393
3529
|
return null;
|
|
3394
3530
|
}
|
|
3395
3531
|
}, [cleanupReality]);
|
|
3396
|
-
const content =
|
|
3532
|
+
const content = useCallback9(() => /* @__PURE__ */ jsx22(Fragment3, {}), []);
|
|
3397
3533
|
useRealityEvents({
|
|
3398
3534
|
instance: ctxRef.current?.reality ?? null,
|
|
3399
3535
|
onSpatialTap,
|
|
@@ -3422,7 +3558,7 @@ var Reality = forwardRef19(
|
|
|
3422
3558
|
);
|
|
3423
3559
|
|
|
3424
3560
|
// src/reality/components/AttachmentAsset.tsx
|
|
3425
|
-
import { useEffect as useEffect27, useState as
|
|
3561
|
+
import { useEffect as useEffect27, useState as useState9 } from "react";
|
|
3426
3562
|
import { createPortal as createPortal3 } from "react-dom";
|
|
3427
3563
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3428
3564
|
var AttachmentAsset = ({
|
|
@@ -3430,7 +3566,7 @@ var AttachmentAsset = ({
|
|
|
3430
3566
|
children
|
|
3431
3567
|
}) => {
|
|
3432
3568
|
const ctx = useRealityContext();
|
|
3433
|
-
const [containers, setContainers] =
|
|
3569
|
+
const [containers, setContainers] = useState9([]);
|
|
3434
3570
|
useEffect27(() => {
|
|
3435
3571
|
if (!ctx) return;
|
|
3436
3572
|
return ctx.attachmentRegistry.onContainersChange(name, setContainers);
|
|
@@ -3442,7 +3578,7 @@ var AttachmentAsset = ({
|
|
|
3442
3578
|
};
|
|
3443
3579
|
|
|
3444
3580
|
// src/reality/components/AttachmentEntity.tsx
|
|
3445
|
-
import { useEffect as useEffect28, useRef as useRef17, useState as
|
|
3581
|
+
import { useEffect as useEffect28, useRef as useRef17, useState as useState10 } from "react";
|
|
3446
3582
|
var instanceCounter = 0;
|
|
3447
3583
|
var AttachmentEntity = ({
|
|
3448
3584
|
attachment: attachmentName,
|
|
@@ -3455,7 +3591,7 @@ var AttachmentEntity = ({
|
|
|
3455
3591
|
const parentIdRef = useRef17(null);
|
|
3456
3592
|
const instanceIdRef = useRef17(`att_${++instanceCounter}`);
|
|
3457
3593
|
const attachmentNameRef = useRef17(attachmentName);
|
|
3458
|
-
const [childWindow, setChildWindow] =
|
|
3594
|
+
const [childWindow, setChildWindow] = useState10(null);
|
|
3459
3595
|
useEffect28(() => {
|
|
3460
3596
|
if (!ctx || !parent) return;
|
|
3461
3597
|
if (attachmentRef.current) return;
|
|
@@ -3671,7 +3807,7 @@ async function convertCoordinate(position, { from, to }) {
|
|
|
3671
3807
|
}
|
|
3672
3808
|
|
|
3673
3809
|
// src/index.ts
|
|
3674
|
-
var version = "1.
|
|
3810
|
+
var version = "1.6.0";
|
|
3675
3811
|
if (typeof window !== "undefined") {
|
|
3676
3812
|
initPolyfill();
|
|
3677
3813
|
}
|