@netless/window-manager 1.0.0-canary.4 → 1.0.0-canary.40

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 (90) hide show
  1. package/dist/index.cjs.js +115 -34
  2. package/dist/index.es.js +7269 -9721
  3. package/dist/index.umd.js +115 -34
  4. package/dist/{App → src/App}/AppContext.d.ts +12 -7
  5. package/dist/{App → src/App}/AppPageStateImpl.d.ts +0 -0
  6. package/dist/{App → src/App}/AppProxy.d.ts +29 -11
  7. package/dist/{App → src/App}/MagixEvent/index.d.ts +0 -0
  8. package/dist/{App → src/App}/Storage/StorageEvent.d.ts +0 -0
  9. package/dist/{App → src/App}/Storage/index.d.ts +0 -0
  10. package/dist/{App → src/App}/Storage/typings.d.ts +0 -0
  11. package/dist/{App → src/App}/Storage/utils.d.ts +0 -0
  12. package/dist/src/App/WhiteboardView.d.ts +27 -0
  13. package/dist/{App → src/App}/index.d.ts +1 -0
  14. package/dist/src/App/type.d.ts +21 -0
  15. package/dist/{AppListener.d.ts → src/AppListener.d.ts} +2 -2
  16. package/dist/{AppManager.d.ts → src/AppManager.d.ts} +6 -5
  17. package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +5 -2
  18. package/dist/{BoxEmitter.d.ts → src/BoxEmitter.d.ts} +0 -0
  19. package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +12 -6
  20. package/dist/{BuiltinApps.d.ts → src/BuiltinApps.d.ts} +3 -0
  21. package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
  22. package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
  23. package/dist/{Cursor → src/Cursor}/index.d.ts +3 -3
  24. package/dist/{Helper.d.ts → src/Helper.d.ts} +4 -8
  25. package/dist/{InternalEmitter.d.ts → src/InternalEmitter.d.ts} +3 -4
  26. package/dist/{Page → src/Page}/PageController.d.ts +1 -0
  27. package/dist/{Page → src/Page}/index.d.ts +0 -0
  28. package/dist/{PageState.d.ts → src/PageState.d.ts} +0 -0
  29. package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +0 -0
  30. package/dist/{RedoUndo.d.ts → src/RedoUndo.d.ts} +0 -0
  31. package/dist/{Register → src/Register}/index.d.ts +0 -0
  32. package/dist/{Register → src/Register}/loader.d.ts +0 -0
  33. package/dist/{Register → src/Register}/storage.d.ts +0 -0
  34. package/dist/{Utils → src/Utils}/AppCreateQueue.d.ts +0 -0
  35. package/dist/{Utils → src/Utils}/Common.d.ts +0 -0
  36. package/dist/{Utils → src/Utils}/Reactive.d.ts +0 -0
  37. package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
  38. package/dist/{Utils → src/Utils}/error.d.ts +1 -1
  39. package/dist/{Utils → src/Utils}/log.d.ts +0 -0
  40. package/dist/src/View/CameraSynchronizer.d.ts +19 -0
  41. package/dist/{View → src/View}/MainView.d.ts +18 -7
  42. package/dist/{View → src/View}/ViewManager.d.ts +0 -0
  43. package/dist/src/View/ViewSync.d.ts +24 -0
  44. package/dist/{callback.d.ts → src/callback.d.ts} +10 -1
  45. package/dist/{constants.d.ts → src/constants.d.ts} +10 -5
  46. package/dist/src/image.d.ts +19 -0
  47. package/dist/{index.d.ts → src/index.d.ts} +44 -13
  48. package/dist/src/shim.d.ts +11 -0
  49. package/dist/{typings.d.ts → src/typings.d.ts} +8 -2
  50. package/dist/style.css +1 -1
  51. package/docs/app-context.md +155 -27
  52. package/docs/mirgrate-to-1.0.md +39 -0
  53. package/package.json +23 -19
  54. package/playwright.config.ts +29 -0
  55. package/pnpm-lock.yaml +3078 -4412
  56. package/src/App/AppContext.ts +60 -28
  57. package/src/App/AppProxy.ts +235 -113
  58. package/src/App/WhiteboardView.ts +34 -12
  59. package/src/App/index.ts +1 -0
  60. package/src/App/type.ts +22 -0
  61. package/src/AppListener.ts +30 -21
  62. package/src/AppManager.ts +65 -43
  63. package/src/AttributesDelegate.ts +6 -3
  64. package/src/BoxManager.ts +76 -38
  65. package/src/BuiltinApps.ts +9 -8
  66. package/src/Cursor/Cursor.ts +7 -3
  67. package/src/Cursor/index.ts +7 -8
  68. package/src/Helper.ts +25 -7
  69. package/src/InternalEmitter.ts +3 -4
  70. package/src/Page/PageController.ts +1 -0
  71. package/src/PageState.ts +1 -1
  72. package/src/ReconnectRefresher.ts +6 -2
  73. package/src/Utils/Common.ts +3 -0
  74. package/src/Utils/Reactive.ts +27 -26
  75. package/src/Utils/RoomHacker.ts +3 -0
  76. package/src/Utils/error.ts +2 -2
  77. package/src/View/CameraSynchronizer.ts +41 -39
  78. package/src/View/MainView.ts +116 -75
  79. package/src/View/ViewSync.ts +103 -6
  80. package/src/callback.ts +6 -1
  81. package/src/constants.ts +8 -3
  82. package/src/index.ts +173 -58
  83. package/src/style.css +3 -46
  84. package/src/typings.ts +8 -2
  85. package/vite.config.js +8 -4
  86. package/dist/App/AppViewSync.d.ts +0 -11
  87. package/dist/App/WhiteboardView.d.ts +0 -21
  88. package/dist/View/CameraSynchronizer.d.ts +0 -17
  89. package/dist/View/ViewSync.d.ts +0 -7
  90. package/src/App/AppViewSync.ts +0 -69
@@ -1,69 +0,0 @@
1
- import { CameraSynchronizer } from "../View/CameraSynchronizer";
2
- import { SideEffectManager } from "side-effect-manager";
3
- import type { Camera, View } from "white-web-sdk";
4
- import type { AppProxy } from "./AppProxy";
5
- import { isEqual } from "lodash";
6
-
7
- export class AppViewSync {
8
- private sem = new SideEffectManager();
9
- private synchronizer: CameraSynchronizer;
10
-
11
- constructor(private appProxy: AppProxy) {
12
- this.synchronizer = new CameraSynchronizer((camera: Camera) => {
13
- this.appProxy.storeCamera({
14
- id: this.appProxy.uid,
15
- ...camera,
16
- });
17
- });
18
- this.bindView(appProxy.view);
19
- this.sem.add(() => this.appProxy.camera$.subscribe(camera => {
20
- const size = this.appProxy.size$.value;
21
- if (camera && size) {
22
- this.synchronizer.onRemoteUpdate(camera, size);
23
- }
24
- }));
25
- const box = this.appProxy.box;
26
- if (box && box.contentStageRect) {
27
- this.synchronizer.setRect(box.contentStageRect);
28
- this.sem.add(() =>
29
- box._contentStageRect$.subscribe(rect => {
30
- if (rect) {
31
- this.synchronizer.setRect(rect);
32
- }
33
- }),
34
- );
35
- if (!this.appProxy.size$.value) {
36
- this.appProxy.storeSize({
37
- id: this.appProxy.uid,
38
- width: box.contentStageRect.width,
39
- height: box.contentStageRect.height,
40
- });
41
- }
42
- }
43
- }
44
-
45
- public bindView = (view?: View) => {
46
- if (!view) return;
47
- this.synchronizer.setView(view);
48
- this.sem.add(() => {
49
- view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
50
- return () =>
51
- view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
52
- });
53
- };
54
-
55
- private onCameraUpdatedByDevice = (camera: Camera) => {
56
- this.synchronizer.onLocalCameraUpdate(camera);
57
- const stage = this.appProxy.box?.contentStageRect;
58
- if (stage) {
59
- const size = { width: stage.width, height: stage.height, id: this.appProxy.uid };
60
- if (!isEqual(size, this.appProxy.size$.value)) {
61
- this.appProxy.storeSize(size);
62
- }
63
- }
64
- };
65
-
66
- public destroy() {
67
- this.sem.flushAll();
68
- }
69
- }