@webspatial/core-sdk 1.0.5 → 1.1.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/CHANGELOG.md +6 -0
- package/dist/iife/index.global.js +3 -3
- package/dist/iife/index.global.js.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/platform-adapter/android/AndroidPlatform.ts +2 -2
- package/src/reality/entity/SpatialEntity.ts +4 -0
- package/src/scene-polyfill.ts +25 -5
package/package.json
CHANGED
|
@@ -91,10 +91,10 @@ export class AndroidPlatform implements PlatformAbility {
|
|
|
91
91
|
// Make the page renderable through window.open
|
|
92
92
|
windowProxy?.open('about:blank', '_self')
|
|
93
93
|
// Polling to check if SpatialId injection is successful
|
|
94
|
-
while (!windowProxy?.
|
|
94
|
+
while (!windowProxy?.__SpatialId) {
|
|
95
95
|
await new Promise(resolve => setTimeout(resolve, 16))
|
|
96
96
|
}
|
|
97
|
-
let spatialId = windowProxy?.
|
|
97
|
+
let spatialId = windowProxy?.__SpatialId
|
|
98
98
|
creatingElementCount--
|
|
99
99
|
return Promise.resolve(
|
|
100
100
|
CommandResultSuccess({ windowProxy: windowProxy, id: spatialId }),
|
|
@@ -206,6 +206,10 @@ export class SpatialEntity extends SpatialObject {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
dispatchEvent(evt: CustomEvent) {
|
|
209
|
+
// Set origin once at the first dispatch in the bubbling chain
|
|
210
|
+
if (!(evt as any).__origin) {
|
|
211
|
+
Object.defineProperty(evt, '__origin', { value: this, enumerable: false })
|
|
212
|
+
}
|
|
209
213
|
this.events[evt.type]?.(evt)
|
|
210
214
|
if (evt.bubbles && !evt.cancelBubble) {
|
|
211
215
|
if (this.parent && this.parent instanceof SpatialEntity) {
|
package/src/scene-polyfill.ts
CHANGED
|
@@ -50,17 +50,37 @@ class SceneManager {
|
|
|
50
50
|
return this.configMap[name]
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Ensure URL is absolute; only convert when a relative path is provided
|
|
54
|
+
// - Keep external and special schemes untouched (http, https, data, blob, about, file, mailto, etc.)
|
|
55
|
+
// - Handle protocol-relative URLs (//example.com/path)
|
|
56
|
+
// - Resolve relative paths against document.baseURI (respects <base href>)
|
|
57
|
+
private ensureAbsoluteUrl(raw?: string): string | undefined {
|
|
58
|
+
if (!raw) return raw
|
|
59
|
+
// Already has a scheme (includes internal webspatial:// which is handled earlier)
|
|
60
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw)) {
|
|
61
|
+
return raw
|
|
62
|
+
}
|
|
63
|
+
// Protocol-relative URL
|
|
64
|
+
if (raw.startsWith('//')) {
|
|
65
|
+
return `${window.location.protocol}${raw}`
|
|
66
|
+
}
|
|
67
|
+
// Resolve against base URI
|
|
68
|
+
try {
|
|
69
|
+
return new URL(raw, document.baseURI).toString()
|
|
70
|
+
} catch {
|
|
71
|
+
// Fallback: leave unchanged
|
|
72
|
+
return raw
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
53
76
|
private open = (url?: string, target?: string, features?: string) => {
|
|
54
77
|
// bypass internal
|
|
55
78
|
if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {
|
|
56
79
|
return this.originalOpen(url, target, features)
|
|
57
80
|
}
|
|
58
81
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
if (!url?.startsWith(prefix)) {
|
|
62
|
-
url = prefix + url
|
|
63
|
-
}
|
|
82
|
+
// Normalize only relative URLs to absolute for platform handling
|
|
83
|
+
url = this.ensureAbsoluteUrl(url)
|
|
64
84
|
|
|
65
85
|
// if target is special
|
|
66
86
|
if (target === '_self' || target === '_parent' || target === '_top') {
|