@netless/window-manager 1.0.0-canary.45 → 1.0.0-canary.48

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.
@@ -51,7 +51,7 @@ export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TA
51
51
  get box(): ReadonlyTeleBox;
52
52
  get room(): Room | undefined;
53
53
  get members(): Member[];
54
- get currentMember(): Member;
54
+ get currentMember(): Member | undefined;
55
55
  /** @deprecated Use context.storage.setState instead. */
56
56
  setAttributes: (attributes: TAttributes) => void;
57
57
  /** @deprecated Use context.storage.setState instead. */
@@ -1,7 +1,7 @@
1
1
  import type { SceneDefinition } from "white-web-sdk";
2
2
  export declare type AddPageParams = {
3
3
  after?: boolean;
4
- scene?: SceneDefinition;
4
+ scene?: SceneDefinition | SceneDefinition[];
5
5
  };
6
6
  export declare type PageState = {
7
7
  index: number;
@@ -18,6 +18,11 @@ export declare class ViewSync {
18
18
  private sem;
19
19
  private synchronizer;
20
20
  constructor(context: ViewSyncContext);
21
+ private createSynchronizer;
22
+ private subscribeView;
23
+ private subscribeCamera;
24
+ private subscribeSize;
25
+ private subscribeStageRect;
21
26
  bindView: (view?: View | undefined) => void;
22
27
  private onCameraUpdatedByDevice;
23
28
  destroy(): void;
@@ -86,3 +86,4 @@ export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } f
86
86
  export * from "./Page";
87
87
  export * from "./Utils/error";
88
88
  export type { Member } from "./Helper";
89
+ export type { TeleBoxManager, TeleBoxManagerQueryConfig } from "@netless/telebox-insider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.45",
3
+ "version": "1.0.0-canary.48",
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.35",
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,8 +34,8 @@
34
34
  "value-enhancer": "^1.3.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@netless/app-docs-viewer": "^0.3.2",
38
- "@netless/app-plyr": "0.2.0",
37
+ "@netless/app-docs-viewer": "^0.3.3",
38
+ "@netless/app-plyr": "0.2.2",
39
39
  "@playwright/test": "^1.23.2",
40
40
  "@rollup/plugin-commonjs": "^20.0.0",
41
41
  "@rollup/plugin-node-resolve": "^13.0.4",
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.2
6
- '@netless/app-plyr': 0.2.0
7
- '@netless/telebox-insider': 1.0.0-alpha.35
5
+ '@netless/app-docs-viewer': ^0.3.3
6
+ '@netless/app-plyr': 0.2.2
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.35
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,8 +54,8 @@ dependencies:
54
54
  value-enhancer: 1.3.2
55
55
 
56
56
  devDependencies:
57
- '@netless/app-docs-viewer': 0.3.2
58
- '@netless/app-plyr': 0.2.0
57
+ '@netless/app-docs-viewer': 0.3.3
58
+ '@netless/app-plyr': 0.2.2
59
59
  '@playwright/test': 1.23.2
60
60
  '@rollup/plugin-commonjs': 20.0.0
61
61
  '@rollup/plugin-node-resolve': 13.1.3
@@ -231,24 +231,24 @@ packages:
231
231
  resolution: {integrity: sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==}
232
232
  dev: true
233
233
 
234
- /@netless/app-docs-viewer/0.3.2:
235
- resolution: {integrity: sha512-3gO8/AblCYQlu5kEnvI6+qJBu0VycSnIyVXfP6xu5obHHfF5aa+JGnDJ1/wZ+8DpvaydhWTuKvv+oVtuXDG0gg==}
234
+ /@netless/app-docs-viewer/0.3.3:
235
+ resolution: {integrity: sha512-yrc79e4oPKSNRackRjupkNp3Qvhrk9rETCf03FL1GlnrSE+GKtoZStRF4D7L6/214Gh930qjaEAOSF9BvkabLg==}
236
236
  dependencies:
237
237
  remitter: 0.2.6
238
238
  value-enhancer: 1.3.2
239
239
  vanilla-lazyload: 17.8.2
240
240
  dev: true
241
241
 
242
- /@netless/app-plyr/0.2.0:
243
- resolution: {integrity: sha512-noeWWwcI1Qlkw9Zf/MJispYsH+WsTjETO8tUx/o6qJLHkf2wH+B0AZeL+/wy+bqzSOITg6yDnxWvNdxFuhDNUQ==}
242
+ /@netless/app-plyr/0.2.2:
243
+ resolution: {integrity: sha512-bB/xQMMb7bUcr3SH7Sb7/orYyzoeWgADX8vQWNskvQuiX7uIvFHZSZSG2ld+Idmjiqjo7zU6L1bUMAMshLu5/g==}
244
244
  dev: true
245
245
 
246
246
  /@netless/canvas-polyfill/0.0.4:
247
247
  resolution: {integrity: sha512-7NzsJrba0R/mq/l10SkIZQwbrNVJyPxZYrjK6xL3Ts732iWAVuS2UB0u3s6iGeUVcqV39A679yva8APWRl4M0A==}
248
248
  dev: true
249
249
 
250
- /@netless/telebox-insider/1.0.0-alpha.35:
251
- resolution: {integrity: sha512-uX/PUEoG/+CoaigeoWH+U07io93n+T89VjJDl5FRnd3gc/QfYf3ASSDQ9+7GjbOBUDUFwYHqVIxEhU67mGXCbw==}
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
@@ -180,10 +180,11 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
180
180
  return this.manager.members$.value;
181
181
  }
182
182
 
183
- public get currentMember(): Member {
183
+ //** currentMember is undefined in read-only and replay mode. */
184
+ public get currentMember(): Member | undefined {
184
185
  const self = findMemberByUid(this.room, this.manager.uid);
185
186
  if (!self) {
186
- throw new Error(`Member ${this.manager.uid} not found.`);
187
+ return undefined;
187
188
  }
188
189
  return {
189
190
  uid: this.manager.uid,
package/src/AppManager.ts CHANGED
@@ -473,7 +473,8 @@ export class AppManager {
473
473
  this.appCreateQueue.emitReady();
474
474
  }
475
475
  let appsWithCreatedAt = appIds.map(appId => {
476
- if (apps[appId].setup) {
476
+ // 兼容 1.0 之前创建的应用
477
+ if (apps[appId].setup === true || apps[appId].setup === undefined) {
477
478
  return {
478
479
  id: appId,
479
480
  createdAt: apps[appId].createdAt,
@@ -2,7 +2,7 @@ import type { SceneDefinition } from "white-web-sdk";
2
2
 
3
3
  export type AddPageParams = {
4
4
  after?: boolean;
5
- scene?: SceneDefinition;
5
+ scene?: SceneDefinition | SceneDefinition[];
6
6
  };
7
7
 
8
8
  export type PageState = {
@@ -30,7 +30,25 @@ export class ViewSync {
30
30
  private synchronizer: CameraSynchronizer;
31
31
 
32
32
  constructor(private context: ViewSyncContext) {
33
- this.synchronizer = new CameraSynchronizer((camera: ICamera) => {
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
- this.bindView(this.context.view$.value);
44
- this.sem.add(() => [
45
- this.context.view$.subscribe(view => {
46
- const currentCamera = this.context.camera$.value;
47
- if (currentCamera && this.context.size$.value) {
48
- view?.moveCamera({
49
- scale: 1,
50
- animationMode: AnimationMode.Immediately,
51
- });
52
- this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
53
- }
54
-
55
- this.bindView(view);
56
- }),
57
- this.context.camera$.subscribe((camera, skipUpdate) => {
58
- const size = this.context.size$.value;
59
- if (camera && size && !skipUpdate) {
60
- this.synchronizer.onRemoteUpdate(camera, size);
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
- camera$size$.destroy();
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
@@ -539,12 +539,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
539
539
  public async addPage(params?: AddPageParams): Promise<void> {
540
540
  if (this.appManager) {
541
541
  const after = params?.after;
542
- const scene = params?.scene;
542
+ const scene = params?.scene || {};
543
+ const scenes = Array.isArray(scene) ? scene : [scene];
543
544
  if (after) {
544
545
  const nextIndex = this.mainViewSceneIndex + 1;
545
- this.room.putScenes(ROOT_DIR, [scene || {}], nextIndex);
546
+ this.room.putScenes(ROOT_DIR, scenes, nextIndex);
546
547
  } else {
547
- this.room.putScenes(ROOT_DIR, [scene || {}]);
548
+ this.room.putScenes(ROOT_DIR, scenes);
548
549
  }
549
550
  }
550
551
  }
@@ -839,7 +840,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
839
840
  clearTimeout(this.cameraUpdating);
840
841
  this.cameraUpdating = 0;
841
842
  this.mainView.callbacks.on("onCameraUpdated", this.onCameraUpdated);
842
- this.nextCamera = nextCamera;
843
+ if (nextScale) {
844
+ this.nextCamera = { ...nextCamera, scale: nextScale };
845
+ }
843
846
  }
844
847
  };
845
848
 
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";