@netless/window-manager 0.4.0-canary.3 → 0.4.0-canary.7

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.
Files changed (66) hide show
  1. package/dist/index.es.js +1 -1
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +1 -1
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/src/App/Storage/StorageEvent.d.ts +8 -0
  6. package/dist/src/App/Storage/index.d.ts +26 -0
  7. package/dist/src/App/Storage/typings.d.ts +21 -0
  8. package/dist/src/App/Storage/utils.d.ts +5 -0
  9. package/dist/{AppContext.d.ts → src/AppContext.d.ts} +2 -0
  10. package/dist/{AppListener.d.ts → src/AppListener.d.ts} +0 -1
  11. package/dist/{AppManager.d.ts → src/AppManager.d.ts} +4 -5
  12. package/dist/{AppProxy.d.ts → src/AppProxy.d.ts} +2 -3
  13. package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +0 -0
  14. package/dist/{Base → src/Base}/Context.d.ts +0 -1
  15. package/dist/{Base → src/Base}/index.d.ts +0 -0
  16. package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +2 -1
  17. package/dist/src/BuiltinApps.d.ts +6 -0
  18. package/dist/src/ContainerResizeObserver.d.ts +10 -0
  19. package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
  20. package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
  21. package/dist/{Cursor → src/Cursor}/index.d.ts +0 -0
  22. package/dist/src/Helper.d.ts +6 -0
  23. package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +0 -1
  24. package/dist/{Register → src/Register}/index.d.ts +0 -0
  25. package/dist/{Register → src/Register}/loader.d.ts +0 -0
  26. package/dist/{Register → src/Register}/storage.d.ts +0 -0
  27. package/dist/{Utils → src/Utils}/Common.d.ts +3 -1
  28. package/dist/{Utils → src/Utils}/Reactive.d.ts +1 -1
  29. package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
  30. package/dist/{Utils → src/Utils}/error.d.ts +0 -0
  31. package/dist/{Utils → src/Utils}/log.d.ts +0 -0
  32. package/dist/{MainView.d.ts → src/View/MainView.d.ts} +2 -4
  33. package/dist/src/View/ViewManager.d.ts +13 -0
  34. package/dist/{constants.d.ts → src/constants.d.ts} +0 -5
  35. package/dist/{index.d.ts → src/index.d.ts} +4 -8
  36. package/dist/{typings.d.ts → src/typings.d.ts} +1 -0
  37. package/dist/style.css +1 -1
  38. package/package.json +3 -3
  39. package/src/App/Storage/StorageEvent.ts +21 -0
  40. package/src/App/Storage/index.ts +243 -0
  41. package/src/App/Storage/typings.ts +21 -0
  42. package/src/App/Storage/utils.ts +17 -0
  43. package/src/AppContext.ts +9 -1
  44. package/src/AppListener.ts +0 -8
  45. package/src/AppManager.ts +33 -28
  46. package/src/AppProxy.ts +14 -36
  47. package/src/Base/Context.ts +0 -4
  48. package/src/BoxManager.ts +9 -7
  49. package/src/BuiltinApps.ts +24 -0
  50. package/src/ContainerResizeObserver.ts +62 -0
  51. package/src/Helper.ts +30 -0
  52. package/src/ReconnectRefresher.ts +0 -5
  53. package/src/Utils/Common.ts +35 -13
  54. package/src/Utils/Reactive.ts +9 -3
  55. package/src/{MainView.ts → View/MainView.ts} +7 -25
  56. package/src/View/ViewManager.ts +53 -0
  57. package/src/constants.ts +0 -2
  58. package/src/index.ts +20 -69
  59. package/src/style.css +6 -0
  60. package/src/typings.ts +1 -0
  61. package/dist/Utils/CameraStore.d.ts +0 -15
  62. package/dist/ViewManager.d.ts +0 -29
  63. package/dist/sdk.d.ts +0 -14
  64. package/src/Utils/CameraStore.ts +0 -72
  65. package/src/sdk.ts +0 -39
  66. package/src/viewManager.ts +0 -177
@@ -0,0 +1,62 @@
1
+ import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
2
+ import { WindowManager } from "./index";
3
+ import type { EmitterType} from "./index";
4
+
5
+ const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
6
+
7
+ export class ContainerResizeObserver {
8
+ private containerResizeObserver?: ResizeObserver;
9
+
10
+ constructor(private emitter: EmitterType) {}
11
+
12
+ public static create(
13
+ container: HTMLElement,
14
+ sizer: HTMLElement,
15
+ wrapper: HTMLDivElement,
16
+ emitter: EmitterType,
17
+ ) {
18
+ const containerResizeObserver = new ContainerResizeObserver(emitter);
19
+ containerResizeObserver.observePlaygroundSize(container, sizer, wrapper);
20
+ return containerResizeObserver;
21
+ }
22
+
23
+ public observePlaygroundSize(
24
+ container: HTMLElement,
25
+ sizer: HTMLElement,
26
+ wrapper: HTMLDivElement
27
+ ) {
28
+ this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
29
+
30
+ this.containerResizeObserver = new ResizeObserver(entries => {
31
+ const containerRect = entries[0]?.contentRect;
32
+ if (containerRect) {
33
+ this.updateSizer(containerRect, sizer, wrapper);
34
+ this.emitter.emit("playgroundSizeChange", containerRect)
35
+ }
36
+ });
37
+
38
+ this.containerResizeObserver.observe(container);
39
+ }
40
+
41
+ private updateSizer(
42
+ { width, height }: DOMRectReadOnly,
43
+ sizer: HTMLElement,
44
+ wrapper: HTMLDivElement
45
+ ) {
46
+ if (width && height) {
47
+ if (height / width > WindowManager.containerSizeRatio) {
48
+ height = width * WindowManager.containerSizeRatio;
49
+ sizer.classList.toggle("netless-window-manager-sizer-horizontal", true);
50
+ } else {
51
+ width = height / WindowManager.containerSizeRatio;
52
+ sizer.classList.toggle("netless-window-manager-sizer-horizontal", false);
53
+ }
54
+ wrapper.style.width = `${width}px`;
55
+ wrapper.style.height = `${height}px`;
56
+ }
57
+ }
58
+
59
+ public disconnect() {
60
+ this.containerResizeObserver?.disconnect();
61
+ }
62
+ }
package/src/Helper.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { WindowManager } from "./index";
2
+
3
+ export const setupWrapper = (
4
+ root: HTMLElement
5
+ ): {
6
+ playground: HTMLDivElement;
7
+ wrapper: HTMLDivElement;
8
+ sizer: HTMLDivElement;
9
+ mainViewElement: HTMLDivElement;
10
+ } => {
11
+ const playground = document.createElement("div");
12
+ playground.className = "netless-window-manager-playground";
13
+
14
+ const sizer = document.createElement("div");
15
+ sizer.className = "netless-window-manager-sizer";
16
+
17
+ const wrapper = document.createElement("div");
18
+ wrapper.className = "netless-window-manager-wrapper";
19
+
20
+ const mainViewElement = document.createElement("div");
21
+ mainViewElement.className = "netless-window-manager-main-view";
22
+
23
+ playground.appendChild(sizer);
24
+ sizer.appendChild(wrapper);
25
+ wrapper.appendChild(mainViewElement);
26
+ root.appendChild(playground);
27
+ WindowManager.wrapper = wrapper;
28
+
29
+ return { playground, wrapper, sizer, mainViewElement };
30
+ };
@@ -1,5 +1,4 @@
1
1
  import { debounce, isFunction } from "lodash";
2
- import { emitter } from "./index";
3
2
  import { log } from "./Utils/log";
4
3
  import { RoomPhase } from "white-web-sdk";
5
4
  import type { Room } from "white-web-sdk";
@@ -85,7 +84,3 @@ export class ReconnectRefresher {
85
84
  this.releaseDisposers();
86
85
  }
87
86
  }
88
-
89
- export const reconnectRefresher = new ReconnectRefresher({
90
- emitter: emitter,
91
- });
@@ -1,7 +1,7 @@
1
- import { appRegister } from '../Register';
2
- import { debounce } from 'lodash';
3
- import { emitter } from '../index';
4
- import { v4 } from 'uuid';
1
+ import { appRegister } from "../Register";
2
+ import { debounce } from "lodash";
3
+ import { emitter } from "../index";
4
+ import { v4 } from "uuid";
5
5
  import type { PublicEvent } from "../index";
6
6
  import type { Displayer, ViewVisionMode, Room, View } from "white-web-sdk";
7
7
  import type Emittery from "emittery";
@@ -26,7 +26,21 @@ export const setScenePath = (room: Room | undefined, scenePath: string) => {
26
26
  room.setScenePath(scenePath);
27
27
  }
28
28
  }
29
- }
29
+ };
30
+
31
+ export const getScenePath = (
32
+ room: Room | undefined,
33
+ dir: string | undefined,
34
+ index: number
35
+ ): string | undefined => {
36
+ if (room && dir) {
37
+ const scenes = entireScenes(room);
38
+ const scene = scenes[dir]?.[index];
39
+ if (scene) {
40
+ return `${dir}/${scene.name}`;
41
+ }
42
+ }
43
+ };
30
44
 
31
45
  export const setViewMode = (view: View, mode: ViewVisionMode) => {
32
46
  if (!(view as any).didRelease && view.mode !== mode) {
@@ -44,7 +58,7 @@ export const emitError = (error: Error) => {
44
58
 
45
59
  export const addEmitterOnceListener = (event: any, listener: any) => {
46
60
  emitter.once(event).then(listener);
47
- }
61
+ };
48
62
 
49
63
  export const notifyMainViewModeChange = debounce(
50
64
  (callbacks: Emittery<PublicEvent>, mode: ViewVisionMode) => {
@@ -53,9 +67,10 @@ export const notifyMainViewModeChange = debounce(
53
67
  200
54
68
  );
55
69
 
56
- export const makeValidScenePath = (displayer: Displayer, scenePath: string) => {
57
- const scenes = displayer.entireScenes()[scenePath];
58
- const firstSceneName = scenes[0].name;
70
+ export const makeValidScenePath = (displayer: Displayer, scenePath: string, index = 0) => {
71
+ const scenes = entireScenes(displayer)[scenePath];
72
+ if (!scenes) return;
73
+ const firstSceneName = scenes[index].name;
59
74
  if (scenePath === "/") {
60
75
  return `/${firstSceneName}`;
61
76
  } else {
@@ -63,9 +78,13 @@ export const makeValidScenePath = (displayer: Displayer, scenePath: string) => {
63
78
  }
64
79
  };
65
80
 
81
+ export const entireScenes = (displayer: Displayer) => {
82
+ return displayer.entireScenes();
83
+ };
84
+
66
85
  export const isValidScenePath = (scenePath: string) => {
67
86
  return scenePath.startsWith("/");
68
- }
87
+ };
69
88
 
70
89
  export const ensureValidScenePath = (scenePath: string) => {
71
90
  if (scenePath.endsWith("/")) {
@@ -73,11 +92,14 @@ export const ensureValidScenePath = (scenePath: string) => {
73
92
  } else {
74
93
  return scenePath;
75
94
  }
76
- }
95
+ };
77
96
 
78
97
  export const getVersionNumber = (version: string) => {
79
- const versionString = version.split(".").map(s => s.padStart(2, "0")).join("");
98
+ const versionString = version
99
+ .split(".")
100
+ .map(s => s.padStart(2, "0"))
101
+ .join("");
80
102
  return parseInt(versionString);
81
103
  };
82
104
 
83
- export const wait = (time: number) => new Promise((resolve) => setTimeout(resolve, time));
105
+ export const wait = (time: number) => new Promise(resolve => setTimeout(resolve, time));
@@ -1,5 +1,6 @@
1
1
  import { listenUpdated, unlistenUpdated, reaction, UpdateEventKind } from "white-web-sdk";
2
2
  import type { AkkoObjectUpdatedProperty , AkkoObjectUpdatedListener } from "white-web-sdk";
3
+ import { isObject } from "lodash";
3
4
 
4
5
  // 兼容 13 和 14 版本 SDK
5
6
  export const onObjectByEvent = (event: UpdateEventKind) => {
@@ -30,7 +31,8 @@ export const onObjectByEvent = (event: UpdateEventKind) => {
30
31
 
31
32
  export const safeListenPropsUpdated = <T>(
32
33
  getProps: () => T,
33
- callback: AkkoObjectUpdatedListener<T>
34
+ callback: AkkoObjectUpdatedListener<T>,
35
+ onDestroyed?: (props: unknown) => void
34
36
  ) => {
35
37
  let disposeListenUpdated: (() => void) | null = null;
36
38
  const disposeReaction = reaction(
@@ -41,8 +43,12 @@ export const safeListenPropsUpdated = <T>(
41
43
  disposeListenUpdated = null;
42
44
  }
43
45
  const props = getProps();
44
- disposeListenUpdated = () => unlistenUpdated(props, callback);
45
- listenUpdated(props, callback);
46
+ if (isObject(props)) {
47
+ disposeListenUpdated = () => unlistenUpdated(props, callback);
48
+ listenUpdated(props, callback);
49
+ } else {
50
+ onDestroyed?.(props);
51
+ }
46
52
  },
47
53
  { fireImmediately: true }
48
54
  );
@@ -1,17 +1,16 @@
1
- import { AnimationMode, reaction, ViewVisionMode } from "white-web-sdk";
2
- import { Base } from "./Base";
3
- import { callbacks, emitter } from "./index";
1
+ import { AnimationMode, reaction } from "white-web-sdk";
2
+ import { Base } from "../Base";
3
+ import { callbacks, emitter } from "../index";
4
4
  import { createView } from "./ViewManager";
5
5
  import { debounce, isEmpty, isEqual } from "lodash";
6
- import { Fields } from "./AttributesDelegate";
7
- import { notifyMainViewModeChange, setViewFocusScenePath, setViewMode } from "./Utils/Common";
6
+ import { Fields } from "../AttributesDelegate";
7
+ import { setViewFocusScenePath } from "../Utils/Common";
8
8
  import { SideEffectManager } from "side-effect-manager";
9
9
  import type { Camera, Size, View } from "white-web-sdk";
10
- import type { AppManager } from "./AppManager";
10
+ import type { AppManager } from "../AppManager";
11
11
 
12
12
  export class MainViewProxy extends Base {
13
13
  private scale?: number;
14
- private cameraStore = this.manager.cameraStore;
15
14
  private started = false;
16
15
  private mainViewIsAddListener = false;
17
16
  private mainView: View;
@@ -23,7 +22,6 @@ export class MainViewProxy extends Base {
23
22
  super(manager);
24
23
  this.mainView = this.createMainView();
25
24
  this.moveCameraSizeByAttributes();
26
- this.cameraStore.register(this.viewId, this.mainView);
27
25
  emitter.once("mainViewMounted").then(() => {
28
26
  setTimeout(() => {
29
27
  this.start();
@@ -34,7 +32,7 @@ export class MainViewProxy extends Base {
34
32
  });
35
33
  const playgroundSizeChangeListener = () => {
36
34
  this.sizeChangeHandler(this.mainViewSize);
37
- }
35
+ };
38
36
  this.sideEffectManager.add(() => {
39
37
  emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
40
38
  return () => emitter.off("playgroundSizeChange", playgroundSizeChangeListener);
@@ -103,9 +101,6 @@ export class MainViewProxy extends Base {
103
101
  if (mainViewScenePath) {
104
102
  setViewFocusScenePath(mainView, mainViewScenePath);
105
103
  }
106
- if (!this.store.focus) {
107
- this.switchViewModeToWriter();
108
- }
109
104
  return mainView;
110
105
  }
111
106
 
@@ -138,7 +133,6 @@ export class MainViewProxy extends Base {
138
133
 
139
134
  public async mainViewClickHandler(): Promise<void> {
140
135
  if (!this.manager.canOperate) return;
141
- if (this.view.mode === ViewVisionMode.Writable) return;
142
136
  this.store.cleanFocus();
143
137
  this.context.blurFocusBox();
144
138
  }
@@ -163,17 +157,6 @@ export class MainViewProxy extends Base {
163
157
  callbacks.emit("cameraStateChange", this.cameraState);
164
158
  };
165
159
 
166
- public switchViewModeToWriter(): void {
167
- if (!this.manager.canOperate) return;
168
- if (this.view) {
169
- if (this.view.mode === ViewVisionMode.Writable) return;
170
- this.cameraStore.switchView(this.viewId, this.mainView, () => {
171
- notifyMainViewModeChange(callbacks, ViewVisionMode.Writable);
172
- setViewMode(this.view, ViewVisionMode.Writable);
173
- });
174
- }
175
- }
176
-
177
160
  public moveCameraToContian(size: Size): void {
178
161
  if (!isEmpty(size)) {
179
162
  this.view.moveCameraToContain({
@@ -210,7 +193,6 @@ export class MainViewProxy extends Base {
210
193
 
211
194
  public destroy() {
212
195
  this.stop();
213
- this.cameraStore.unregister(this.viewId, this.mainView);
214
196
  this.sideEffectManager.flushAll();
215
197
  }
216
198
  }
@@ -0,0 +1,53 @@
1
+ import type { View , Displayer} from "white-web-sdk";
2
+
3
+ export class ViewManager {
4
+ public views: Map<string, View> = new Map();
5
+
6
+ constructor(private displayer: Displayer) {}
7
+
8
+ public createView(id: string): View {
9
+ const view = createView(this.displayer);
10
+ this.views.set(id, view);
11
+ return view;
12
+ }
13
+
14
+ public getView(id: string): View | undefined {
15
+ return this.views.get(id);
16
+ }
17
+
18
+ public destroyView(id: string): void {
19
+ const view = this.views.get(id);
20
+ if (view) {
21
+ view.release();
22
+ this.views.delete(id);
23
+ }
24
+ }
25
+
26
+ public setViewScenePath(id: string, scenePath: string): void {
27
+ const view = this.views.get(id);
28
+ if (view) {
29
+ view.focusScenePath = scenePath;
30
+ }
31
+ }
32
+
33
+ public destroy() {
34
+ this.views.forEach(view => {
35
+ view.release();
36
+ });
37
+ this.views.clear();
38
+ }
39
+ }
40
+
41
+
42
+ export const createView = (displayer: Displayer): View => {
43
+ const view = displayer.views.createView();
44
+ setDefaultCameraBound(view);
45
+ return view;
46
+ };
47
+
48
+ export const setDefaultCameraBound = (view: View) => {
49
+ view.setCameraBound({
50
+ maxContentMode: () => 10,
51
+ minContentMode: () => 0.1,
52
+ });
53
+ };
package/src/constants.ts CHANGED
@@ -44,6 +44,4 @@ export const MIN_HEIGHT = 340 / 720;
44
44
 
45
45
  export const SET_SCENEPATH_DELAY = 100; // 设置 scenePath 的延迟事件
46
46
 
47
- export const DEFAULT_COLLECTOR_STYLE = { right: "10px", bottom: "15px", position: "absolute" };
48
-
49
47
  export const DEFAULT_CONTAINER_RATIO = 9 / 16;
package/src/index.ts CHANGED
@@ -1,9 +1,8 @@
1
- import AppDocsViewer from "@netless/app-docs-viewer";
2
- import AppMediaPlayer, { setOptions } from "@netless/app-media-player";
3
1
  import Emittery from "emittery";
4
2
  import pRetry from "p-retry";
5
3
  import { AppManager } from "./AppManager";
6
4
  import { appRegister } from "./Register";
5
+ import { ContainerResizeObserver } from "./ContainerResizeObserver";
7
6
  import { createBoxManager } from "./BoxManager";
8
7
  import { CursorManager } from "./Cursor";
9
8
  import { DEFAULT_CONTAINER_RATIO, Events, REQUIRE_VERSION } from "./constants";
@@ -11,9 +10,11 @@ import { Fields } from "./AttributesDelegate";
11
10
  import { initDb } from "./Register/storage";
12
11
  import { isNull, isObject } from "lodash";
13
12
  import { log } from "./Utils/log";
13
+ import { ReconnectRefresher } from "./ReconnectRefresher";
14
14
  import { replaceRoomFunction } from "./Utils/RoomHacker";
15
- import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
16
- import { setupWrapper } from "./ViewManager";
15
+ import { setupBuiltin } from "./BuiltinApps";
16
+ import { setupWrapper } from "./Helper";
17
+ import { version } from "../package.json";
17
18
  import "./style.css";
18
19
  import "@netless/telebox-insider/dist/style.css";
19
20
  import {
@@ -59,8 +60,6 @@ import type { NetlessApp, RegisterParams } from "./typings";
59
60
  import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
60
61
  import type { AppProxy } from "./AppProxy";
61
62
 
62
- const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
63
-
64
63
  export type WindowMangerAttributes = {
65
64
  modelValue?: string;
66
65
  boxState: TELE_BOX_STATE;
@@ -172,6 +171,8 @@ export type MountParams = {
172
171
  export type CallbacksType = Emittery<PublicEvent>;
173
172
  export const callbacks: CallbacksType = new Emittery();
174
173
 
174
+ export const reconnectRefresher = new ReconnectRefresher({ emitter });
175
+
175
176
  export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
176
177
  public static kind = "WindowManager";
177
178
  public static displayer: Displayer;
@@ -182,7 +183,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
182
183
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
183
184
  private static isCreated = false;
184
185
 
185
- public version = "0.4.0-canary.3";
186
+ public version = version;
186
187
 
187
188
  public appListeners?: AppListeners;
188
189
 
@@ -196,6 +197,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
196
197
  private boxManager?: BoxManager;
197
198
  private static params?: MountParams;
198
199
 
200
+ private containerResizeObserver?: ContainerResizeObserver;
201
+
199
202
  constructor(context: InvisiblePluginContext) {
200
203
  super(context);
201
204
  WindowManager.displayer = context.displayer;
@@ -221,9 +224,6 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
221
224
  }
222
225
  let manager = await this.initManager(room);
223
226
  this.debug = Boolean(debug);
224
- if (this.debug) {
225
- setOptions({ verbose: true });
226
- }
227
227
  log("Already insert room", manager);
228
228
 
229
229
  if (isRoom(this.displayer)) {
@@ -317,7 +317,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
317
317
  style.textContent = overwriteStyles;
318
318
  playground.appendChild(style);
319
319
  }
320
- manager.observePlaygroundSize(playground, sizer, wrapper);
320
+ manager.containerResizeObserver = ContainerResizeObserver.create(
321
+ playground,
322
+ sizer,
323
+ wrapper,
324
+ emitter
325
+ );
321
326
  WindowManager.wrapper = wrapper;
322
327
  return mainViewElement;
323
328
  }
@@ -475,10 +480,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
475
480
  * 设置所有 app 的 readonly 模式
476
481
  */
477
482
  public setReadonly(readonly: boolean): void {
478
- if (this.room?.isWritable) {
479
- this.readonly = readonly;
480
- this.appManager?.boxManager?.setReadonly(readonly);
481
- }
483
+ this.readonly = readonly;
484
+ this.boxManager?.setReadonly(readonly);
482
485
  }
483
486
 
484
487
  /**
@@ -698,62 +701,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
698
701
  }
699
702
  }
700
703
  }
701
-
702
- private containerResizeObserver?: ResizeObserver;
703
-
704
- private observePlaygroundSize(
705
- container: HTMLElement,
706
- sizer: HTMLElement,
707
- wrapper: HTMLDivElement
708
- ) {
709
- this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
710
-
711
- this.containerResizeObserver = new ResizeObserver(entries => {
712
- const containerRect = entries[0]?.contentRect;
713
- if (containerRect) {
714
- this.updateSizer(containerRect, sizer, wrapper);
715
- this.cursorManager?.updateContainerRect();
716
- this.boxManager?.updateManagerRect();
717
- emitter.emit("playgroundSizeChange", containerRect);
718
- }
719
- });
720
-
721
- this.containerResizeObserver.observe(container);
722
- }
723
-
724
- private updateSizer(
725
- { width, height }: DOMRectReadOnly,
726
- sizer: HTMLElement,
727
- wrapper: HTMLDivElement
728
- ) {
729
- if (width && height) {
730
- if (height / width > WindowManager.containerSizeRatio) {
731
- height = width * WindowManager.containerSizeRatio;
732
- sizer.classList.toggle("netless-window-manager-sizer-horizontal", true);
733
- } else {
734
- width = height / WindowManager.containerSizeRatio;
735
- sizer.classList.toggle("netless-window-manager-sizer-horizontal", false);
736
- }
737
- wrapper.style.width = `${width}px`;
738
- wrapper.style.height = `${height}px`;
739
- }
740
- }
741
704
  }
742
705
 
743
- WindowManager.register({
744
- kind: AppDocsViewer.kind,
745
- src: AppDocsViewer,
746
- });
747
- WindowManager.register({
748
- kind: AppMediaPlayer.kind,
749
- src: AppMediaPlayer,
750
- });
751
-
752
- export const BuiltinApps = {
753
- DocsViewer: AppDocsViewer.kind as string,
754
- MediaPlayer: AppMediaPlayer.kind as string,
755
- };
706
+ setupBuiltin();
756
707
 
757
708
  export * from "./typings";
758
709
 
759
- export { WhiteWindowSDK } from "./sdk";
710
+ export { BuiltinApps } from "./BuiltinApps";
package/src/style.css CHANGED
@@ -167,3 +167,9 @@
167
167
  display: flex;
168
168
  justify-content: center;
169
169
  }
170
+
171
+ .telebox-collector {
172
+ position: absolute;
173
+ right: 10px;
174
+ bottom: 15px;
175
+ }
package/src/typings.ts CHANGED
@@ -76,3 +76,4 @@ export type AppListenerKeys = keyof AppEmitterEvent;
76
76
  export type { AppContext } from "./AppContext";
77
77
  export type { ReadonlyTeleBox, TeleBoxRect };
78
78
  export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room, Player };
79
+ export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
@@ -1,15 +0,0 @@
1
- import type { Camera, View } from "white-web-sdk";
2
- export declare class CameraStore {
3
- private cameras;
4
- private listeners;
5
- setCamera(id: string, camera: Camera): void;
6
- getCamera(id: string): Camera | undefined;
7
- deleteCamera(id: string): void;
8
- recoverCamera(id: string, view?: View): void;
9
- register(id: string, view: View): void;
10
- unregister(id: string, view?: View): void;
11
- private onListener;
12
- private offListener;
13
- switchView(id: string, view: View | undefined, callback: () => void): Promise<void>;
14
- private getOrCreateListener;
15
- }
@@ -1,29 +0,0 @@
1
- import { Base } from "./Base";
2
- import type { View, Displayer } from "white-web-sdk";
3
- import type { AppManager } from "./AppManager";
4
- export declare class ViewManager extends Base {
5
- private views;
6
- private timer?;
7
- private appTimer?;
8
- private mainViewProxy;
9
- private displayer;
10
- constructor(manager: AppManager);
11
- get currentScenePath(): string;
12
- get mainView(): View;
13
- createView(appId: string): View;
14
- destroyView(appId: string): void;
15
- private releaseView;
16
- getView(appId: string): View | undefined;
17
- switchMainViewToWriter(): Promise<boolean> | undefined;
18
- freedomAllViews(): void;
19
- switchAppToWriter(id: string): void;
20
- destroy(): void;
21
- }
22
- export declare const createView: (displayer: Displayer) => View;
23
- export declare const setDefaultCameraBound: (view: View) => void;
24
- export declare const setupWrapper: (root: HTMLElement) => {
25
- playground: HTMLDivElement;
26
- wrapper: HTMLDivElement;
27
- sizer: HTMLDivElement;
28
- mainViewElement: HTMLDivElement;
29
- };
package/dist/sdk.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { WindowManager } from './index';
2
- import type { MountParams } from "./index";
3
- import type { WhiteWebSdkConfiguration, JoinRoomParams } from "white-web-sdk";
4
- declare type WhiteWindowSDKConfiguration = Omit<WhiteWebSdkConfiguration, "useMobXState">;
5
- declare type WindowJoinRoomParams = {
6
- joinRoomParams: Omit<JoinRoomParams, "useMultiViews" | "disableMagixEventDispatchLimit">;
7
- mountParams: Omit<MountParams, "room">;
8
- };
9
- export declare class WhiteWindowSDK {
10
- private sdk;
11
- constructor(params: WhiteWindowSDKConfiguration);
12
- mount(params: WindowJoinRoomParams): Promise<WindowManager>;
13
- }
14
- export {};