@netless/window-manager 1.0.0-canary.43 → 1.0.0-canary.46
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/index.cjs.js +12908 -115
- package/dist/index.es.js +2825 -3614
- package/dist/index.umd.js +12916 -127
- package/dist/src/View/ViewSync.d.ts +5 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/typings.d.ts +1 -0
- package/dist/style.css +795 -1
- package/package.json +3 -3
- package/pnpm-lock.yaml +8 -8
- package/src/View/ViewSync.ts +55 -35
- package/src/index.ts +26 -17
- package/src/typings.ts +1 -0
- package/vite.config.js +5 -4
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "1.0.0-canary.
|
3
|
+
"version": "1.0.0-canary.46",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.es.js",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
27
|
"@juggle/resize-observer": "^3.3.1",
|
28
|
-
"@netless/telebox-insider": "1.0.0-alpha.
|
28
|
+
"@netless/telebox-insider": "1.0.0-alpha.36",
|
29
29
|
"emittery": "^0.11.0",
|
30
30
|
"lodash": "^4.17.21",
|
31
31
|
"p-retry": "^4.6.2",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
"value-enhancer": "^1.3.2"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
|
-
"@netless/app-docs-viewer": "^0.3.
|
37
|
+
"@netless/app-docs-viewer": "^0.3.2",
|
38
38
|
"@netless/app-plyr": "0.2.0",
|
39
39
|
"@playwright/test": "^1.23.2",
|
40
40
|
"@rollup/plugin-commonjs": "^20.0.0",
|
package/pnpm-lock.yaml
CHANGED
@@ -2,9 +2,9 @@ lockfileVersion: 5.4
|
|
2
2
|
|
3
3
|
specifiers:
|
4
4
|
'@juggle/resize-observer': ^3.3.1
|
5
|
-
'@netless/app-docs-viewer': ^0.3.
|
5
|
+
'@netless/app-docs-viewer': ^0.3.2
|
6
6
|
'@netless/app-plyr': 0.2.0
|
7
|
-
'@netless/telebox-insider': 1.0.0-alpha.
|
7
|
+
'@netless/telebox-insider': 1.0.0-alpha.36
|
8
8
|
'@playwright/test': ^1.23.2
|
9
9
|
'@rollup/plugin-commonjs': ^20.0.0
|
10
10
|
'@rollup/plugin-node-resolve': ^13.0.4
|
@@ -45,7 +45,7 @@ specifiers:
|
|
45
45
|
|
46
46
|
dependencies:
|
47
47
|
'@juggle/resize-observer': 3.3.1
|
48
|
-
'@netless/telebox-insider': 1.0.0-alpha.
|
48
|
+
'@netless/telebox-insider': 1.0.0-alpha.36
|
49
49
|
emittery: 0.11.0
|
50
50
|
lodash: 4.17.21
|
51
51
|
p-retry: 4.6.2
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
value-enhancer: 1.3.2
|
55
55
|
|
56
56
|
devDependencies:
|
57
|
-
'@netless/app-docs-viewer': 0.3.
|
57
|
+
'@netless/app-docs-viewer': 0.3.2
|
58
58
|
'@netless/app-plyr': 0.2.0
|
59
59
|
'@playwright/test': 1.23.2
|
60
60
|
'@rollup/plugin-commonjs': 20.0.0
|
@@ -231,8 +231,8 @@ packages:
|
|
231
231
|
resolution: {integrity: sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==}
|
232
232
|
dev: true
|
233
233
|
|
234
|
-
/@netless/app-docs-viewer/0.3.
|
235
|
-
resolution: {integrity: sha512-
|
234
|
+
/@netless/app-docs-viewer/0.3.2:
|
235
|
+
resolution: {integrity: sha512-3gO8/AblCYQlu5kEnvI6+qJBu0VycSnIyVXfP6xu5obHHfF5aa+JGnDJ1/wZ+8DpvaydhWTuKvv+oVtuXDG0gg==}
|
236
236
|
dependencies:
|
237
237
|
remitter: 0.2.6
|
238
238
|
value-enhancer: 1.3.2
|
@@ -247,8 +247,8 @@ packages:
|
|
247
247
|
resolution: {integrity: sha512-7NzsJrba0R/mq/l10SkIZQwbrNVJyPxZYrjK6xL3Ts732iWAVuS2UB0u3s6iGeUVcqV39A679yva8APWRl4M0A==}
|
248
248
|
dev: true
|
249
249
|
|
250
|
-
/@netless/telebox-insider/1.0.0-alpha.
|
251
|
-
resolution: {integrity: sha512-
|
250
|
+
/@netless/telebox-insider/1.0.0-alpha.36:
|
251
|
+
resolution: {integrity: sha512-wW0/pmagLt1pzV7PfCWJAAsOm4+RED6GEh2mOSTGS/q6lIOV8Qjoe0MizaR3ild7d6rg/kIFj2II3IYF0d+OiA==}
|
252
252
|
dependencies:
|
253
253
|
'@juggle/resize-observer': 3.3.1
|
254
254
|
'@types/shallowequal': 1.1.1
|
package/src/View/ViewSync.ts
CHANGED
@@ -30,7 +30,25 @@ export class ViewSync {
|
|
30
30
|
private synchronizer: CameraSynchronizer;
|
31
31
|
|
32
32
|
constructor(private context: ViewSyncContext) {
|
33
|
-
this.synchronizer =
|
33
|
+
this.synchronizer = this.createSynchronizer();
|
34
|
+
this.bindView(this.context.view$.value);
|
35
|
+
this.sem.add(() => [
|
36
|
+
this.subscribeView(),
|
37
|
+
this.subscribeCamera(),
|
38
|
+
this.subscribeSize(),
|
39
|
+
this.subscribeStageRect(),
|
40
|
+
]);
|
41
|
+
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
42
|
+
camera$size$.reaction(([camera, size]) => {
|
43
|
+
if (camera && size) {
|
44
|
+
this.synchronizer.onRemoteUpdate(camera, size);
|
45
|
+
camera$size$.destroy();
|
46
|
+
}
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
private createSynchronizer = () => {
|
51
|
+
return new CameraSynchronizer((camera: ICamera) => {
|
34
52
|
this.context.camera$.setValue(camera, true);
|
35
53
|
const notStoreCamera =
|
36
54
|
this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
|
@@ -40,42 +58,44 @@ export class ViewSync {
|
|
40
58
|
this.context.storeCamera(camera);
|
41
59
|
}
|
42
60
|
});
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
this.context.size$.subscribe(size => {
|
64
|
-
if (size) {
|
65
|
-
this.synchronizer.onRemoteSizeUpdate(size);
|
66
|
-
}
|
67
|
-
}),
|
68
|
-
this.context.stageRect$.subscribe(rect => {
|
69
|
-
if (rect) {
|
70
|
-
this.synchronizer.setRect(rect);
|
71
|
-
}
|
72
|
-
})
|
73
|
-
]);
|
74
|
-
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
75
|
-
camera$size$.reaction(([camera, size]) => {
|
61
|
+
}
|
62
|
+
|
63
|
+
private subscribeView = () => {
|
64
|
+
return this.context.view$.subscribe(view => {
|
65
|
+
const currentCamera = this.context.camera$.value;
|
66
|
+
if (currentCamera && this.context.size$.value) {
|
67
|
+
view?.moveCamera({
|
68
|
+
scale: 1,
|
69
|
+
animationMode: AnimationMode.Immediately,
|
70
|
+
});
|
71
|
+
this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
|
72
|
+
}
|
73
|
+
this.bindView(view);
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
private subscribeCamera = () => {
|
78
|
+
return this.context.camera$.subscribe((camera, skipUpdate) => {
|
79
|
+
if (skipUpdate) return;
|
80
|
+
const size = this.context.size$.value;
|
76
81
|
if (camera && size) {
|
77
82
|
this.synchronizer.onRemoteUpdate(camera, size);
|
78
|
-
|
83
|
+
}
|
84
|
+
});
|
85
|
+
}
|
86
|
+
|
87
|
+
private subscribeSize = () => {
|
88
|
+
return this.context.size$.subscribe(size => {
|
89
|
+
if (size) {
|
90
|
+
this.synchronizer.onRemoteSizeUpdate(size);
|
91
|
+
}
|
92
|
+
});
|
93
|
+
}
|
94
|
+
|
95
|
+
private subscribeStageRect = () => {
|
96
|
+
return this.context.stageRect$.subscribe(rect => {
|
97
|
+
if (rect) {
|
98
|
+
this.synchronizer.setRect(rect);
|
79
99
|
}
|
80
100
|
});
|
81
101
|
}
|
package/src/index.ts
CHANGED
@@ -185,6 +185,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
185
185
|
private static params?: MountParams;
|
186
186
|
|
187
187
|
private cameraUpdating = 0;
|
188
|
+
private nextCamera: Camera | null = null;
|
188
189
|
|
189
190
|
public containerSizeRatio = WindowManager.containerSizeRatio;
|
190
191
|
|
@@ -261,6 +262,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
261
262
|
containerStyle: params.containerStyle,
|
262
263
|
stageStyle: params.stageStyle,
|
263
264
|
fullscreen: params.fullscreen,
|
265
|
+
theme: params.theme,
|
264
266
|
});
|
265
267
|
manager.appManager?.setBoxManager(manager.boxManager);
|
266
268
|
if (params.container) {
|
@@ -833,27 +835,34 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
833
835
|
this.mainView.moveCamera(camera);
|
834
836
|
}
|
835
837
|
this.appManager.dispatchInternalEvent(Events.MoveCamera, camera);
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
clearTimeout(this.cameraUpdating);
|
843
|
-
this.cameraUpdating = 0;
|
844
|
-
if (!this.appManager) return;
|
845
|
-
this.appManager.mainViewProxy.storeCamera({
|
846
|
-
id: this.appManager.uid,
|
847
|
-
...nextCamera
|
848
|
-
});
|
849
|
-
}, 50);
|
838
|
+
this.mainView.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
839
|
+
clearTimeout(this.cameraUpdating);
|
840
|
+
this.cameraUpdating = 0;
|
841
|
+
this.mainView.callbacks.on("onCameraUpdated", this.onCameraUpdated);
|
842
|
+
if (nextScale) {
|
843
|
+
this.nextCamera = { ...nextCamera, scale: nextScale };
|
850
844
|
}
|
851
|
-
this.mainView.callbacks.off("onCameraUpdated", onCameraUpdated);
|
852
|
-
this.mainView.callbacks.on("onCameraUpdated", onCameraUpdated);
|
853
|
-
|
854
845
|
}
|
855
846
|
};
|
856
847
|
|
848
|
+
private onCameraUpdated = () => {
|
849
|
+
if (this.cameraUpdating) {
|
850
|
+
clearTimeout(this.cameraUpdating);
|
851
|
+
this.cameraUpdating = 0;
|
852
|
+
}
|
853
|
+
this.cameraUpdating = setTimeout(() => {
|
854
|
+
this.mainView.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
855
|
+
clearTimeout(this.cameraUpdating);
|
856
|
+
this.cameraUpdating = 0;
|
857
|
+
if (!this.appManager || !this.nextCamera) return;
|
858
|
+
this.appManager.mainViewProxy.storeCamera({
|
859
|
+
id: this.appManager.uid,
|
860
|
+
...this.nextCamera
|
861
|
+
});
|
862
|
+
this.nextCamera = null;
|
863
|
+
}, 50);
|
864
|
+
}
|
865
|
+
|
857
866
|
public convertToPointInWorld(point: Point): Point {
|
858
867
|
return this.mainView.convertToPointInWorld(point);
|
859
868
|
}
|
package/src/typings.ts
CHANGED
@@ -94,3 +94,4 @@ export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } f
|
|
94
94
|
export * from "./Page";
|
95
95
|
export * from "./Utils/error";
|
96
96
|
export type { Member } from "./Helper";
|
97
|
+
export type { TeleBoxManager, TeleBoxManagerQueryConfig } from "@netless/telebox-insider";
|
package/vite.config.js
CHANGED
@@ -5,8 +5,8 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
5
5
|
import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
|
6
6
|
import { omit } from "lodash";
|
7
7
|
|
8
|
-
export default defineConfig((
|
9
|
-
const isProd = mode === "production";
|
8
|
+
export default defineConfig(() => {
|
9
|
+
// const isProd = mode === "production";
|
10
10
|
|
11
11
|
return {
|
12
12
|
test: {
|
@@ -40,7 +40,8 @@ export default defineConfig(({ mode }) => {
|
|
40
40
|
entry: path.resolve(__dirname, "src/index.ts"),
|
41
41
|
formats: ["es", "umd", "cjs"],
|
42
42
|
name: "WindowManager",
|
43
|
-
fileName: "index"
|
43
|
+
fileName: "index",
|
44
|
+
|
44
45
|
},
|
45
46
|
outDir: "dist",
|
46
47
|
rollupOptions: {
|
@@ -49,7 +50,7 @@ export default defineConfig(({ mode }) => {
|
|
49
50
|
...peerDependencies,
|
50
51
|
}),
|
51
52
|
},
|
52
|
-
minify:
|
53
|
+
minify: false
|
53
54
|
},
|
54
55
|
};
|
55
56
|
})
|