@webspatial/core-sdk 0.1.10 → 0.1.13
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 +20 -0
- package/dist/iife/index.d.ts +730 -0
- package/dist/iife/index.global.js +11 -0
- package/dist/iife/index.global.js.map +1 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.js +845 -825
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
- package/src/core/Spatial.ts +6 -6
- package/src/core/SpatialHelper.ts +4 -0
- package/src/core/SpatialWindowContainer.ts +6 -0
- package/src/core/component/SpatialWindowComponent.ts +11 -3
- package/src/core/private/WebSpatial.ts +36 -9
- package/src/types/global.d.ts +12 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +29 -1
|
@@ -7,6 +7,33 @@ import {
|
|
|
7
7
|
sceneDataJSBShape,
|
|
8
8
|
} from '../types'
|
|
9
9
|
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
// Location for webspatial custom functions
|
|
13
|
+
__WebSpatialData: {
|
|
14
|
+
androidNativeMessage: Function
|
|
15
|
+
getNativeVersion: Function
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Location for webspatial internal callbacks (eg. completion events)
|
|
19
|
+
__SpatialWebEvent: Function
|
|
20
|
+
|
|
21
|
+
// Used to access webkit specific api
|
|
22
|
+
webkit: any
|
|
23
|
+
|
|
24
|
+
// Marks the page as unloaded so it doesn't send additional events
|
|
25
|
+
__WebSpatialUnloaded: boolean
|
|
26
|
+
|
|
27
|
+
// Internal id information mapping to internal state about the native window
|
|
28
|
+
_webSpatialID: string
|
|
29
|
+
_webSpatialGroupID: string
|
|
30
|
+
_webSpatialParentGroupID: string
|
|
31
|
+
|
|
32
|
+
// Will be removed in favor of __WebSpatialData
|
|
33
|
+
WebSpatailNativeVersion: string
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
10
37
|
export class WindowContainer {
|
|
11
38
|
id = ''
|
|
12
39
|
}
|
|
@@ -41,7 +68,7 @@ export class WebSpatial {
|
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
static init() {
|
|
44
|
-
|
|
71
|
+
window.__SpatialWebEvent = (e: any) => {
|
|
45
72
|
if (e.resourceId) {
|
|
46
73
|
var callback = WebSpatial.eventReceivers[e.resourceId]
|
|
47
74
|
callback(e.data)
|
|
@@ -77,7 +104,7 @@ export class WebSpatial {
|
|
|
77
104
|
}
|
|
78
105
|
|
|
79
106
|
static getBackend() {
|
|
80
|
-
if (
|
|
107
|
+
if (window.webkit) {
|
|
81
108
|
return 'AVP'
|
|
82
109
|
} else {
|
|
83
110
|
return 'UNKNOWN'
|
|
@@ -85,7 +112,7 @@ export class WebSpatial {
|
|
|
85
112
|
}
|
|
86
113
|
|
|
87
114
|
static async sendCommand(cmd: RemoteCommand) {
|
|
88
|
-
if (
|
|
115
|
+
if (window.__WebSpatialUnloaded) {
|
|
89
116
|
return
|
|
90
117
|
}
|
|
91
118
|
if (WebSpatial.transactionStarted) {
|
|
@@ -96,10 +123,10 @@ export class WebSpatial {
|
|
|
96
123
|
var msg = JSON.stringify(cmd)
|
|
97
124
|
|
|
98
125
|
if (WebSpatial.getBackend() == 'AVP') {
|
|
99
|
-
|
|
126
|
+
window.webkit.messageHandlers.bridge.postMessage(msg)
|
|
100
127
|
return
|
|
101
128
|
} else {
|
|
102
|
-
|
|
129
|
+
window.__WebSpatialData.androidNativeMessage(msg)
|
|
103
130
|
return
|
|
104
131
|
}
|
|
105
132
|
}
|
|
@@ -132,13 +159,13 @@ export class WebSpatial {
|
|
|
132
159
|
const { window: newWindow, ...sceneData } = cfg.sceneData
|
|
133
160
|
const jsbSceneData: sceneDataJSBShape = {
|
|
134
161
|
...sceneData,
|
|
135
|
-
windowID:
|
|
136
|
-
windowContainerID:
|
|
162
|
+
windowID: newWindow._webSpatialID,
|
|
163
|
+
windowContainerID: newWindow._webSpatialGroupID,
|
|
137
164
|
}
|
|
138
165
|
var cmd = new RemoteCommand('createScene', {
|
|
139
166
|
windowStyle: style,
|
|
140
167
|
sceneData: jsbSceneData,
|
|
141
|
-
windowContainerID:
|
|
168
|
+
windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID
|
|
142
169
|
})
|
|
143
170
|
|
|
144
171
|
try {
|
|
@@ -311,7 +338,7 @@ export class WebSpatial {
|
|
|
311
338
|
|
|
312
339
|
static async setLoading(method: LoadingMethodKind, style?: string) {
|
|
313
340
|
var cmd = new RemoteCommand('setLoading', {
|
|
314
|
-
windowContainerID:
|
|
341
|
+
windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID
|
|
315
342
|
loading: {
|
|
316
343
|
method,
|
|
317
344
|
style,
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
// tsup.config.ts
|
|
2
2
|
import { defineConfig, Options } from 'tsup'
|
|
3
|
-
|
|
3
|
+
import { version } from './package.json'
|
|
4
4
|
const baseConfig: Options = {
|
|
5
5
|
splitting: false,
|
|
6
6
|
sourcemap: true,
|
|
7
7
|
clean: true,
|
|
8
8
|
dts: true,
|
|
9
|
+
banner: {
|
|
10
|
+
js: `
|
|
11
|
+
(function(){
|
|
12
|
+
if(typeof window === 'undefined') return;
|
|
13
|
+
if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
|
|
14
|
+
window.__webspatialsdk__['core-sdk-version'] = ${JSON.stringify(version)}
|
|
15
|
+
})()
|
|
16
|
+
`,
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const versionDefine = {
|
|
21
|
+
__WEBSPATIAL_CORE_SDK_VERSION__: JSON.stringify(version),
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
export default defineConfig([
|
|
@@ -17,7 +30,22 @@ export default defineConfig([
|
|
|
17
30
|
esbuildOptions(options) {
|
|
18
31
|
options.define = {
|
|
19
32
|
...options.define,
|
|
33
|
+
...versionDefine,
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
...baseConfig,
|
|
39
|
+
entry: ['src/index.ts'],
|
|
40
|
+
format: ['iife'],
|
|
41
|
+
outDir: 'dist/iife',
|
|
42
|
+
globalName: 'webspatialCore',
|
|
43
|
+
esbuildOptions(options) {
|
|
44
|
+
options.define = {
|
|
45
|
+
...options.define,
|
|
46
|
+
...versionDefine,
|
|
20
47
|
}
|
|
21
48
|
},
|
|
49
|
+
minify: true,
|
|
22
50
|
},
|
|
23
51
|
])
|