@netless/window-manager 1.0.0-canary.8 → 1.0.0
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/LICENSE.txt +21 -0
- package/README.md +90 -64
- package/README.zh-cn.md +224 -0
- package/dist/index.d.ts +1133 -39
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/{index.es.js → index.mjs} +8393 -5913
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +1 -1
- package/docs/advanced.md +55 -55
- package/docs/api.md +124 -113
- package/docs/app-context.md +248 -209
- package/docs/basic.md +25 -26
- package/docs/camera.md +19 -20
- package/docs/cn/advanced.md +137 -0
- package/docs/cn/api.md +309 -0
- package/docs/cn/app-context.md +369 -0
- package/docs/cn/basic.md +64 -0
- package/docs/cn/camera.md +53 -0
- package/docs/cn/concept.md +9 -0
- package/docs/cn/custom-max-bar.md +31 -0
- package/docs/cn/develop-app.md +94 -0
- package/docs/cn/export-pdf.md +48 -0
- package/docs/cn/migrate.md +60 -0
- package/docs/cn/replay.md +40 -0
- package/docs/concept.md +6 -5
- package/docs/custom-max-bar.md +31 -0
- package/docs/develop-app.md +22 -19
- package/docs/export-pdf.md +48 -0
- package/docs/migrate.md +25 -27
- package/docs/quickstart.md +50 -0
- package/docs/replay.md +20 -20
- package/package.json +32 -22
- package/src/App/AppContext.ts +104 -71
- package/src/App/AppPageStateImpl.ts +6 -25
- package/src/App/AppProxy.ts +42 -147
- package/src/App/MagixEvent/index.ts +38 -38
- package/src/App/Storage/StorageEvent.ts +13 -13
- package/src/App/Storage/index.ts +269 -245
- package/src/App/Storage/typings.ts +4 -2
- package/src/App/Storage/utils.ts +3 -3
- package/src/App/index.ts +0 -1
- package/src/AppListener.ts +8 -8
- package/src/AppManager.ts +84 -75
- package/src/AttributesDelegate.ts +42 -22
- package/src/BoxEmitter.ts +12 -6
- package/src/BoxManager.ts +122 -106
- package/src/ContainerResizeObserver.ts +75 -0
- package/src/Cursor/Cursor.svelte +16 -5
- package/src/Cursor/Cursor.svelte.d.ts +21 -0
- package/src/Cursor/Cursor.ts +77 -13
- package/src/Cursor/icons.ts +6 -0
- package/src/Cursor/icons2.ts +66 -0
- package/src/Cursor/index.ts +127 -26
- package/src/Helper.ts +94 -14
- package/src/InternalEmitter.ts +2 -7
- package/src/Page/PageController.ts +1 -0
- package/src/Page/index.ts +1 -1
- package/src/PageState.ts +6 -5
- package/src/ReconnectRefresher.ts +9 -4
- package/src/RedoUndo.ts +3 -3
- package/src/Register/index.ts +22 -17
- package/src/Register/loader.ts +26 -22
- package/src/Register/storage.ts +13 -13
- package/src/Utils/Common.ts +18 -14
- package/src/Utils/Reactive.ts +26 -25
- package/src/Utils/RoomHacker.ts +4 -4
- package/src/Utils/error.ts +0 -1
- package/src/View/IframeBridge.ts +680 -0
- package/src/View/MainView.ts +114 -53
- package/src/callback.ts +21 -1
- package/src/constants.ts +0 -2
- package/src/image/pencil-eraser-1.svg +3 -0
- package/src/image/pencil-eraser-2.svg +3 -0
- package/src/image/pencil-eraser-3.svg +3 -0
- package/src/index.ts +224 -74
- package/src/style.css +27 -10
- package/src/typings.ts +20 -10
- package/.prettierignore +0 -7
- package/.prettierrc.json +0 -9
- package/CHANGELOG.md +0 -196
- package/__mocks__/white-web-sdk.ts +0 -50
- package/dist/App/AppContext.d.ts +0 -76
- package/dist/App/AppPageStateImpl.d.ts +0 -21
- package/dist/App/AppProxy.d.ts +0 -81
- package/dist/App/AppViewSync.d.ts +0 -11
- package/dist/App/MagixEvent/index.d.ts +0 -29
- package/dist/App/Storage/StorageEvent.d.ts +0 -8
- package/dist/App/Storage/index.d.ts +0 -39
- package/dist/App/Storage/typings.d.ts +0 -22
- package/dist/App/Storage/utils.d.ts +0 -5
- package/dist/App/WhiteboardView.d.ts +0 -22
- package/dist/App/index.d.ts +0 -3
- package/dist/AppListener.d.ts +0 -21
- package/dist/AppManager.d.ts +0 -107
- package/dist/AttributesDelegate.d.ts +0 -80
- package/dist/BoxEmitter.d.ts +0 -34
- package/dist/BoxManager.d.ts +0 -100
- package/dist/BuiltinApps.d.ts +0 -5
- package/dist/Cursor/Cursor.d.ts +0 -39
- package/dist/Cursor/icons.d.ts +0 -3
- package/dist/Cursor/index.d.ts +0 -46
- package/dist/Helper.d.ts +0 -17
- package/dist/InternalEmitter.d.ts +0 -39
- package/dist/Page/PageController.d.ts +0 -20
- package/dist/Page/index.d.ts +0 -3
- package/dist/PageState.d.ts +0 -9
- package/dist/ReconnectRefresher.d.ts +0 -24
- package/dist/RedoUndo.d.ts +0 -18
- package/dist/Register/index.d.ts +0 -28
- package/dist/Register/loader.d.ts +0 -4
- package/dist/Register/storage.d.ts +0 -8
- package/dist/Utils/AppCreateQueue.d.ts +0 -15
- package/dist/Utils/Common.d.ts +0 -23
- package/dist/Utils/Reactive.d.ts +0 -6
- package/dist/Utils/RoomHacker.d.ts +0 -3
- package/dist/Utils/error.d.ts +0 -27
- package/dist/Utils/log.d.ts +0 -1
- package/dist/View/CameraSynchronizer.d.ts +0 -17
- package/dist/View/MainView.d.ts +0 -48
- package/dist/View/ViewManager.d.ts +0 -13
- package/dist/View/ViewSync.d.ts +0 -7
- package/dist/callback.d.ts +0 -24
- package/dist/constants.d.ts +0 -49
- package/dist/index.cjs.js +0 -46
- package/dist/index.umd.js +0 -46
- package/dist/typings.d.ts +0 -82
- package/jest.config.js +0 -27
- package/pnpm-lock.yaml +0 -6302
- package/src/App/AppViewSync.ts +0 -68
- package/src/App/WhiteboardView.ts +0 -83
- package/src/View/CameraSynchronizer.ts +0 -73
- package/src/View/ViewSync.ts +0 -10
- package/vite.config.js +0 -51
- /package/docs/{qickstart.md → cn/quickstart.md} +0 -0
package/src/App/AppProxy.ts
CHANGED
@@ -3,22 +3,15 @@ import { AppAttributes, AppEvents, Events, SETUP_APP_DELAY } from "../constants"
|
|
3
3
|
import { AppContext } from "./AppContext";
|
4
4
|
import { AppPageStateImpl } from "./AppPageStateImpl";
|
5
5
|
import { appRegister } from "../Register";
|
6
|
-
import {
|
7
|
-
import { autorun, reaction, toJS } from "white-web-sdk";
|
8
|
-
import { boxEmitter } from "../BoxEmitter";
|
6
|
+
import { autorun } from "white-web-sdk";
|
9
7
|
import { BoxManagerNotFoundError } from "../Utils/error";
|
10
|
-
import { calculateNextIndex } from "../Page";
|
11
|
-
import { combine, Val } from "value-enhancer";
|
12
8
|
import { debounce, get } from "lodash";
|
13
|
-
import {
|
9
|
+
import { internalEmitter } from "../InternalEmitter";
|
14
10
|
import { Fields } from "../AttributesDelegate";
|
15
11
|
import { log } from "../Utils/log";
|
16
|
-
import { SideEffectManager } from "side-effect-manager";
|
17
|
-
import type { ICamera, ISize } from "../AttributesDelegate";
|
18
12
|
import {
|
19
13
|
entireScenes,
|
20
14
|
getScenePath,
|
21
|
-
putScenes,
|
22
15
|
removeScenes,
|
23
16
|
setScenePath,
|
24
17
|
setViewFocusScenePath,
|
@@ -30,11 +23,14 @@ import type {
|
|
30
23
|
setAppOptions,
|
31
24
|
AppListenerKeys,
|
32
25
|
} from "../index";
|
33
|
-
import type { SceneState, View, SceneDefinition
|
26
|
+
import type { SceneState, View, SceneDefinition } from "white-web-sdk";
|
34
27
|
import type { AppManager } from "../AppManager";
|
35
28
|
import type { NetlessApp } from "../typings";
|
36
29
|
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
37
30
|
import type { PageRemoveService, PageState } from "../Page";
|
31
|
+
import { calculateNextIndex } from "../Page";
|
32
|
+
import { boxEmitter } from "../BoxEmitter";
|
33
|
+
import { callbacks } from "../callback";
|
38
34
|
|
39
35
|
export type AppEmitter = Emittery<AppEmitterEvent>;
|
40
36
|
|
@@ -42,7 +38,6 @@ export class AppProxy implements PageRemoveService {
|
|
42
38
|
public kind: string;
|
43
39
|
public id: string;
|
44
40
|
public scenePath?: string;
|
45
|
-
private appScenePath: string;
|
46
41
|
public appEmitter: AppEmitter;
|
47
42
|
public scenes?: SceneDefinition[];
|
48
43
|
|
@@ -51,27 +46,16 @@ export class AppProxy implements PageRemoveService {
|
|
51
46
|
private appProxies = this.manager.appProxies;
|
52
47
|
private viewManager = this.manager.viewManager;
|
53
48
|
private store = this.manager.store;
|
54
|
-
public uid = this.manager.uid;
|
55
49
|
|
56
50
|
public isAddApp: boolean;
|
57
|
-
|
51
|
+
private status: "normal" | "destroyed" = "normal";
|
58
52
|
private stateKey: string;
|
59
|
-
|
53
|
+
private _pageState: AppPageStateImpl;
|
60
54
|
private _prevFullPath: string | undefined;
|
61
55
|
|
62
56
|
public appResult?: NetlessApp<any>;
|
63
57
|
public appContext?: AppContext<any, any>;
|
64
58
|
|
65
|
-
private sideEffectManager = new SideEffectManager();
|
66
|
-
|
67
|
-
public camera$ = new Val<ICamera | undefined>(undefined);
|
68
|
-
public size$ = new Val<ISize | undefined>(undefined);
|
69
|
-
|
70
|
-
private appViewSync?: AppViewSync;
|
71
|
-
|
72
|
-
public box$ = new Val<ReadonlyTeleBox | undefined>(undefined);
|
73
|
-
public view$ = new Val<View | undefined>(undefined);
|
74
|
-
|
75
59
|
constructor(
|
76
60
|
private params: BaseInsertParams,
|
77
61
|
private manager: AppManager,
|
@@ -80,7 +64,6 @@ export class AppProxy implements PageRemoveService {
|
|
80
64
|
) {
|
81
65
|
this.kind = params.kind;
|
82
66
|
this.id = appId;
|
83
|
-
this.appScenePath = `/${this.id}-app-dir`;
|
84
67
|
this.stateKey = `${this.id}_state`;
|
85
68
|
this.appProxies.set(this.id, this);
|
86
69
|
this.appEmitter = new Emittery();
|
@@ -93,94 +76,12 @@ export class AppProxy implements PageRemoveService {
|
|
93
76
|
// 只有传入了 scenePath 的 App 才会创建 View
|
94
77
|
this.createView();
|
95
78
|
}
|
96
|
-
if (!this.scenePath) {
|
97
|
-
this.scenePath = this.appScenePath;
|
98
|
-
}
|
99
79
|
this._pageState = new AppPageStateImpl({
|
100
80
|
displayer: this.manager.displayer,
|
101
81
|
scenePath: this.scenePath,
|
102
82
|
view: this.view,
|
103
83
|
notifyPageStateChange: this.notifyPageStateChange,
|
104
84
|
});
|
105
|
-
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
106
|
-
this.sideEffectManager.add(() =>
|
107
|
-
emitter.on("roomMembersChange", members => {
|
108
|
-
this.appEmitter.emit("roomMembersChange", members);
|
109
|
-
})
|
110
|
-
);
|
111
|
-
this.camera$.setValue(toJS(this.appAttributes.camera));
|
112
|
-
this.size$.setValue(toJS(this.appAttributes.size));
|
113
|
-
this.sideEffectManager.add(() => {
|
114
|
-
return this.manager.refresher.add(`${this.id}-camera`, () => {
|
115
|
-
return reaction(
|
116
|
-
() => this.appAttributes?.camera,
|
117
|
-
camera => {
|
118
|
-
if (camera && camera.id !== this.uid) {
|
119
|
-
this.camera$.setValue(toJS(camera));
|
120
|
-
}
|
121
|
-
}
|
122
|
-
);
|
123
|
-
});
|
124
|
-
});
|
125
|
-
this.sideEffectManager.add(() => {
|
126
|
-
return this.manager.refresher.add(`${this.id}-size`, () => {
|
127
|
-
return reaction(
|
128
|
-
() => this.appAttributes?.size,
|
129
|
-
size => {
|
130
|
-
if (size && size.id !== this.uid) {
|
131
|
-
this.size$.setValue(toJS(size));
|
132
|
-
}
|
133
|
-
}
|
134
|
-
);
|
135
|
-
});
|
136
|
-
});
|
137
|
-
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
138
|
-
if (box && view) {
|
139
|
-
if (!this.camera$.value) {
|
140
|
-
this.storeCamera({
|
141
|
-
centerX: 0, centerY: 0, scale: 1, id: this.uid,
|
142
|
-
});
|
143
|
-
this.camera$.setValue(toJS(this.appAttributes.camera));
|
144
|
-
}
|
145
|
-
if (!this.size$.value && box.contentStageRect) {
|
146
|
-
this.storeSize({
|
147
|
-
id: this.uid,
|
148
|
-
width: box.contentStageRect?.width,
|
149
|
-
height: box.contentStageRect?.height,
|
150
|
-
});
|
151
|
-
this.size$.setValue(toJS(this.appAttributes.size));
|
152
|
-
}
|
153
|
-
this.appViewSync = new AppViewSync(this);
|
154
|
-
this.sideEffectManager.add(() => () => this.appViewSync?.destroy());
|
155
|
-
}
|
156
|
-
});
|
157
|
-
this.sideEffectManager.add(() => emitter.on("memberStateChange", memberState => {
|
158
|
-
// clicker 教具把事件穿透给下层
|
159
|
-
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
160
|
-
if (needPointerEventsNone) {
|
161
|
-
if (this.appContext?._viewWrapper) {
|
162
|
-
this.appContext._viewWrapper.style.pointerEvents = "none";
|
163
|
-
}
|
164
|
-
} else {
|
165
|
-
if (this.appContext?._viewWrapper) {
|
166
|
-
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}));
|
170
|
-
}
|
171
|
-
|
172
|
-
public createAppDir() {
|
173
|
-
const scenePath = this.scenePath || this.appScenePath;
|
174
|
-
const sceneNode = this._pageState.createSceneNode(scenePath);
|
175
|
-
if (!sceneNode) {
|
176
|
-
putScenes(this.manager.room, scenePath, [{ name: "1" }]);
|
177
|
-
this._pageState.createSceneNode(scenePath);
|
178
|
-
this.setSceneIndex(0);
|
179
|
-
}
|
180
|
-
this.scenes = entireScenes(this.manager.displayer)[scenePath];
|
181
|
-
const view = this.createView();
|
182
|
-
this._pageState.setView(view);
|
183
|
-
return view;
|
184
85
|
}
|
185
86
|
|
186
87
|
private initScenes() {
|
@@ -231,7 +132,7 @@ export class AppProxy implements PageRemoveService {
|
|
231
132
|
}
|
232
133
|
|
233
134
|
public setFullPath(path: string) {
|
234
|
-
this.
|
135
|
+
this.manager.safeUpdateAttributes(["apps", this.id, Fields.FullPath], path);
|
235
136
|
}
|
236
137
|
|
237
138
|
public async baseInsertApp(skipUpdate = false): Promise<{ appId: string; app: NetlessApp }> {
|
@@ -252,7 +153,7 @@ export class AppProxy implements PageRemoveService {
|
|
252
153
|
} else {
|
253
154
|
throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
254
155
|
}
|
255
|
-
|
156
|
+
internalEmitter.emit("updateManagerRect");
|
256
157
|
return {
|
257
158
|
appId: this.id,
|
258
159
|
app: appImpl,
|
@@ -260,7 +161,7 @@ export class AppProxy implements PageRemoveService {
|
|
260
161
|
}
|
261
162
|
|
262
163
|
public get box(): ReadonlyTeleBox | undefined {
|
263
|
-
return this.
|
164
|
+
return this.boxManager?.getBox(this.id);
|
264
165
|
}
|
265
166
|
|
266
167
|
private async setupApp(
|
@@ -277,7 +178,7 @@ export class AppProxy implements PageRemoveService {
|
|
277
178
|
const context = new AppContext(this.manager, this.boxManager, appId, this, appOptions);
|
278
179
|
this.appContext = context;
|
279
180
|
try {
|
280
|
-
|
181
|
+
internalEmitter.once(`${appId}${Events.WindowCreated}` as any).then(async () => {
|
281
182
|
let boxInitState: AppInitState | undefined;
|
282
183
|
if (!skipUpdate) {
|
283
184
|
boxInitState = this.getAppInitState(appId);
|
@@ -288,22 +189,28 @@ export class AppProxy implements PageRemoveService {
|
|
288
189
|
this.setViewFocusScenePath();
|
289
190
|
setTimeout(async () => {
|
290
191
|
// 延迟执行 setup, 防止初始化的属性没有更新成功
|
192
|
+
console.log("setup app", app);
|
291
193
|
const result = await app.setup(context);
|
292
194
|
this.appResult = result;
|
293
195
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
196
|
+
this.afterSetupApp(boxInitState);
|
294
197
|
this.fixMobileSize();
|
198
|
+
callbacks.emit("onAppSetup", appId);
|
295
199
|
}, SETUP_APP_DELAY);
|
296
200
|
});
|
297
|
-
|
201
|
+
this.boxManager?.createBox({
|
298
202
|
appId: appId,
|
299
203
|
app,
|
300
204
|
options,
|
301
205
|
canOperate: this.manager.canOperate,
|
302
206
|
smartPosition: this.isAddApp,
|
303
207
|
});
|
304
|
-
this.box$.setValue(box);
|
305
208
|
if (this.isAddApp && this.box) {
|
306
209
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
210
|
+
this.store.updateAppState(appId, AppAttributes.Size, {
|
211
|
+
width: this.box.intrinsicWidth,
|
212
|
+
height: this.box.intrinsicHeight,
|
213
|
+
});
|
307
214
|
this.boxManager.focusBox({ appId }, false);
|
308
215
|
}
|
309
216
|
} catch (error: any) {
|
@@ -325,6 +232,14 @@ export class AppProxy implements PageRemoveService {
|
|
325
232
|
}
|
326
233
|
}
|
327
234
|
|
235
|
+
private afterSetupApp(boxInitState: AppInitState | undefined): void {
|
236
|
+
if (boxInitState) {
|
237
|
+
if (!boxInitState?.x || !boxInitState.y) {
|
238
|
+
this.boxManager?.setBoxInitState(this.id);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
328
243
|
public async onSeek(time: number) {
|
329
244
|
this.appEmitter.emit("seek", time).catch(err => {
|
330
245
|
console.log(`[WindowManager]: emit seek error: ${err.message}`);
|
@@ -446,7 +361,7 @@ export class AppProxy implements PageRemoveService {
|
|
446
361
|
}
|
447
362
|
|
448
363
|
private appAttributesUpdateListener = (appId: string) => {
|
449
|
-
this.manager.refresher
|
364
|
+
this.manager.refresher.add(appId, () => {
|
450
365
|
return autorun(() => {
|
451
366
|
const attrs = this.manager.attributes[appId];
|
452
367
|
if (attrs) {
|
@@ -454,15 +369,16 @@ export class AppProxy implements PageRemoveService {
|
|
454
369
|
}
|
455
370
|
});
|
456
371
|
});
|
457
|
-
this.manager.refresher
|
372
|
+
this.manager.refresher.add(this.stateKey, () => {
|
458
373
|
return autorun(() => {
|
459
374
|
const appState = this.appAttributes?.state;
|
460
375
|
if (appState?.zIndex > 0 && appState.zIndex !== this.box?.zIndex) {
|
461
376
|
this.boxManager?.setZIndex(appId, appState.zIndex);
|
377
|
+
this.boxManager?.focusBox({ appId });
|
462
378
|
}
|
463
379
|
});
|
464
380
|
});
|
465
|
-
this.manager.refresher
|
381
|
+
this.manager.refresher.add(`${appId}-fullPath`, () => {
|
466
382
|
return autorun(() => {
|
467
383
|
const fullPath = this.appAttributes?.fullPath;
|
468
384
|
this.setFocusScenePathHandler(fullPath);
|
@@ -477,6 +393,7 @@ export class AppProxy implements PageRemoveService {
|
|
477
393
|
private setFocusScenePathHandler = debounce((fullPath: string | undefined) => {
|
478
394
|
if (this.view && fullPath && fullPath !== this.view?.focusScenePath) {
|
479
395
|
setViewFocusScenePath(this.view, fullPath);
|
396
|
+
callbacks.emit("onAppScenePathChange", { appId: this.id, view: this.view });
|
480
397
|
}
|
481
398
|
}, 50);
|
482
399
|
|
@@ -496,17 +413,14 @@ export class AppProxy implements PageRemoveService {
|
|
496
413
|
return fullPath;
|
497
414
|
}
|
498
415
|
|
499
|
-
private createView(): View {
|
500
|
-
const view = this.viewManager.createView(this.id);
|
501
|
-
this.view$.setValue(view);
|
416
|
+
private async createView(): Promise<View> {
|
417
|
+
const view = await this.viewManager.createView(this.id);
|
502
418
|
this.setViewFocusScenePath();
|
503
419
|
return view;
|
504
420
|
}
|
505
421
|
|
506
422
|
public notifyPageStateChange = debounce(() => {
|
507
|
-
|
508
|
-
this.appEmitter.emit("pageStateChange", this.pageState);
|
509
|
-
}
|
423
|
+
this.appEmitter.emit("pageStateChange", this.pageState);
|
510
424
|
}, 50);
|
511
425
|
|
512
426
|
public get pageState(): PageState {
|
@@ -516,7 +430,7 @@ export class AppProxy implements PageRemoveService {
|
|
516
430
|
// PageRemoveService
|
517
431
|
public async removeSceneByIndex(index: number) {
|
518
432
|
const scenePath = this._pageState.getFullPath(index);
|
519
|
-
if (scenePath
|
433
|
+
if (scenePath) {
|
520
434
|
const nextIndex = calculateNextIndex(index, this.pageState);
|
521
435
|
// 只修改 focus path 不修改 FullPath
|
522
436
|
this.setSceneIndexWithoutSync(nextIndex);
|
@@ -552,22 +466,6 @@ export class AppProxy implements PageRemoveService {
|
|
552
466
|
}
|
553
467
|
}
|
554
468
|
|
555
|
-
public storeCamera = (camera: ICamera) => {
|
556
|
-
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
557
|
-
};
|
558
|
-
|
559
|
-
public storeSize = (size: ISize) => {
|
560
|
-
this.store.updateAppAttributes(this.id, Fields.Size, size);
|
561
|
-
};
|
562
|
-
|
563
|
-
public moveCamera = (camera: Camera) => {
|
564
|
-
if (!this.camera$.value) {
|
565
|
-
return;
|
566
|
-
}
|
567
|
-
const nextCamera = { ...this.camera$.value, ...camera };
|
568
|
-
this.storeCamera(nextCamera);
|
569
|
-
};
|
570
|
-
|
571
469
|
public async destroy(
|
572
470
|
needCloseBox: boolean,
|
573
471
|
cleanAttrs: boolean,
|
@@ -583,8 +481,7 @@ export class AppProxy implements PageRemoveService {
|
|
583
481
|
console.error("[WindowManager]: notifyApp error", error.message, error.stack);
|
584
482
|
}
|
585
483
|
this.appEmitter.clearListeners();
|
586
|
-
this.
|
587
|
-
emitter.emit(`destroy-${this.id}` as any, { error });
|
484
|
+
internalEmitter.emit(`destroy-${this.id}` as any, { error });
|
588
485
|
if (needCloseBox) {
|
589
486
|
this.boxManager?.closeBox(this.id, skipUpdate);
|
590
487
|
}
|
@@ -595,16 +492,14 @@ export class AppProxy implements PageRemoveService {
|
|
595
492
|
}
|
596
493
|
}
|
597
494
|
this.appProxies.delete(this.id);
|
495
|
+
this._pageState.destroy();
|
598
496
|
|
599
497
|
this.viewManager.destroyView(this.id);
|
600
498
|
this.manager.appStatus.delete(this.id);
|
601
|
-
this.manager.refresher
|
602
|
-
this.manager.refresher
|
603
|
-
this.manager.refresher
|
499
|
+
this.manager.refresher.remove(this.id);
|
500
|
+
this.manager.refresher.remove(this.stateKey);
|
501
|
+
this.manager.refresher.remove(`${this.id}-fullPath`);
|
604
502
|
this._prevFullPath = undefined;
|
605
|
-
this.camera$.destroy();
|
606
|
-
this.size$.destroy();
|
607
|
-
this.box$.destroy();
|
608
503
|
}
|
609
504
|
|
610
505
|
public close(): Promise<void> {
|
@@ -1,68 +1,68 @@
|
|
1
1
|
import type {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
MagixEventListenerOptions as WhiteMagixListenerOptions,
|
3
|
+
Event as WhiteEvent,
|
4
|
+
EventPhase as WhiteEventPhase,
|
5
|
+
Scope as WhiteScope,
|
6
6
|
} from "white-web-sdk";
|
7
7
|
|
8
8
|
export interface MagixEventListenerOptions extends WhiteMagixListenerOptions {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
/**
|
10
|
+
* Rapid emitted callbacks will be slowed down to this interval (in ms).
|
11
|
+
*/
|
12
|
+
fireInterval?: number;
|
13
|
+
/**
|
14
|
+
* If `true`, sent events will reach self-listeners after committed to server.
|
15
|
+
* Otherwise the events will reach self-listeners immediately.
|
16
|
+
*/
|
17
|
+
fireSelfEventAfterCommit?: boolean;
|
18
18
|
}
|
19
19
|
|
20
20
|
export interface MagixEventMessage<
|
21
|
-
|
22
|
-
|
21
|
+
TPayloads = any,
|
22
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
23
23
|
> extends Omit<WhiteEvent, "scope" | "phase"> {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
/** Event name */
|
25
|
+
event: TEvent;
|
26
|
+
/** Event Payload */
|
27
|
+
payload: TPayloads[TEvent];
|
28
|
+
/** Whiteboard ID of the client who dispatched the event. It will be AdminObserverId for system events. */
|
29
|
+
authorId: number;
|
30
|
+
scope: `${WhiteScope}`;
|
31
|
+
phase: `${WhiteEventPhase}`;
|
32
32
|
}
|
33
33
|
|
34
34
|
export type MagixEventTypes<TPayloads = any> = Extract<keyof TPayloads, string>;
|
35
35
|
|
36
36
|
export type MagixEventPayload<
|
37
|
-
|
38
|
-
|
37
|
+
TPayloads = any,
|
38
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
39
39
|
> = TPayloads[TEvent];
|
40
40
|
|
41
41
|
export type MagixEventDispatcher<TPayloads = any> = <
|
42
|
-
|
42
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
43
43
|
>(
|
44
|
-
|
45
|
-
|
44
|
+
event: TEvent,
|
45
|
+
payload: TPayloads[TEvent]
|
46
46
|
) => void;
|
47
47
|
|
48
48
|
export type MagixEventHandler<
|
49
|
-
|
50
|
-
|
49
|
+
TPayloads = any,
|
50
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
51
51
|
> = (message: MagixEventMessage<TPayloads, TEvent>) => void;
|
52
52
|
|
53
|
-
export type MagixEventListenerDisposer = () => void
|
53
|
+
export type MagixEventListenerDisposer = () => void;
|
54
54
|
|
55
55
|
export type MagixEventAddListener<TPayloads = any> = <
|
56
|
-
|
56
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
57
57
|
>(
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
event: TEvent,
|
59
|
+
handler: MagixEventHandler<TPayloads, TEvent>,
|
60
|
+
options?: MagixEventListenerOptions | undefined
|
61
61
|
) => MagixEventListenerDisposer;
|
62
62
|
|
63
63
|
export type MagixEventRemoveListener<TPayloads = any> = <
|
64
|
-
|
64
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
65
65
|
>(
|
66
|
-
|
67
|
-
|
66
|
+
event: TEvent,
|
67
|
+
handler?: MagixEventHandler<TPayloads, TEvent>
|
68
68
|
) => void;
|
@@ -1,21 +1,21 @@
|
|
1
1
|
export type StorageEventListener<T> = (event: T) => void;
|
2
2
|
|
3
3
|
export class StorageEvent<TMessage> {
|
4
|
-
|
4
|
+
listeners = new Set<StorageEventListener<TMessage>>();
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
get length(): number {
|
7
|
+
return this.listeners.size;
|
8
|
+
}
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
dispatch(message: TMessage): void {
|
11
|
+
this.listeners.forEach(callback => callback(message));
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
addListener(listener: StorageEventListener<TMessage>): void {
|
15
|
+
this.listeners.add(listener);
|
16
|
+
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
removeListener(listener: StorageEventListener<TMessage>): void {
|
19
|
+
this.listeners.delete(listener);
|
20
|
+
}
|
21
21
|
}
|