@netless/window-manager 1.0.13-beta.0 → 1.0.13-test.1
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.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App/AppProxy.ts +3 -1
- package/src/AppListener.ts +1 -0
- package/src/AppManager.ts +16 -3
- package/src/AttributesDelegate.ts +5 -0
- package/src/Utils/Common.ts +1 -0
- package/src/View/MainView.ts +5 -0
- package/src/index.ts +27 -2
package/package.json
CHANGED
package/src/App/AppProxy.ts
CHANGED
|
@@ -216,7 +216,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
216
216
|
}
|
|
217
217
|
setTimeout(async () => {
|
|
218
218
|
// 延迟执行 setup, 防止初始化的属性没有更新成功
|
|
219
|
-
|
|
219
|
+
this.Logger?.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
|
|
220
220
|
const result = await app.setup(context);
|
|
221
221
|
this.appResult = result;
|
|
222
222
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
|
@@ -538,6 +538,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
538
538
|
await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
|
|
539
539
|
await this.appEmitter.emit("destroy", { error });
|
|
540
540
|
} catch (error) {
|
|
541
|
+
this.Logger?.error(`[WindowManager]: notifyApp error: ${error.message}`);
|
|
541
542
|
console.error("[WindowManager]: notifyApp error", error.message, error.stack);
|
|
542
543
|
}
|
|
543
544
|
this.appEmitter.clearListeners();
|
|
@@ -560,6 +561,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
560
561
|
this.manager.refresher.remove(this.stateKey);
|
|
561
562
|
this.manager.refresher.remove(`${this.id}-fullPath`);
|
|
562
563
|
this._prevFullPath = undefined;
|
|
564
|
+
this.Logger?.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
|
|
563
565
|
}
|
|
564
566
|
|
|
565
567
|
public close(): Promise<void> {
|
package/src/AppListener.ts
CHANGED
package/src/AppManager.ts
CHANGED
|
@@ -51,6 +51,7 @@ import type {
|
|
|
51
51
|
} from "./BoxEmitter";
|
|
52
52
|
import { getExtendClass } from "./Utils/extendClass";
|
|
53
53
|
import type { TeleBoxState } from "@netless/telebox-insider";
|
|
54
|
+
import { getAttribute } from "video.js/dist/types/utils/dom";
|
|
54
55
|
|
|
55
56
|
export class AppManager {
|
|
56
57
|
static readonly kind = "AppManager";
|
|
@@ -133,6 +134,7 @@ export class AppManager {
|
|
|
133
134
|
this.createRootDirScenesCallback();
|
|
134
135
|
|
|
135
136
|
appRegister.setSyncRegisterApp(payload => {
|
|
137
|
+
this.Logger?.info(`[WindowManager] syncRegisterApp ${JSON.stringify(payload)}`);
|
|
136
138
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
|
137
139
|
});
|
|
138
140
|
}
|
|
@@ -602,7 +604,9 @@ export class AppManager {
|
|
|
602
604
|
try {
|
|
603
605
|
const appAttributes = this.attributes[id];
|
|
604
606
|
if (!appAttributes) {
|
|
605
|
-
this.Logger?.error(
|
|
607
|
+
this.Logger?.error(
|
|
608
|
+
`[WindowManager]: appAttributes is undefined, appId: ${id}`
|
|
609
|
+
);
|
|
606
610
|
throw new Error("appAttributes is undefined");
|
|
607
611
|
}
|
|
608
612
|
|
|
@@ -725,7 +729,9 @@ export class AppManager {
|
|
|
725
729
|
|
|
726
730
|
public async addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined> {
|
|
727
731
|
log("addApp", params);
|
|
728
|
-
this.windowManger.Logger?.info(
|
|
732
|
+
this.windowManger.Logger?.info(
|
|
733
|
+
`[WindowManager]: addApp ${params.kind}, isDynamicPPT: ${isDynamicPPT}`
|
|
734
|
+
);
|
|
729
735
|
const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
|
|
730
736
|
const appProxy = await this.baseInsertApp(params, appId, true, needFocus);
|
|
731
737
|
this.afterAddApp(appProxy);
|
|
@@ -774,7 +780,9 @@ export class AppManager {
|
|
|
774
780
|
focus?: boolean
|
|
775
781
|
) {
|
|
776
782
|
if (this.appProxies.has(appId)) {
|
|
777
|
-
this.windowManger.Logger?.warn(
|
|
783
|
+
this.windowManger.Logger?.warn(
|
|
784
|
+
`[WindowManager]: app duplicate exists and cannot be created again, appId: ${appId}`
|
|
785
|
+
);
|
|
778
786
|
return;
|
|
779
787
|
}
|
|
780
788
|
const AppProxyClass = getExtendClass(AppProxy, WindowManager.extendClass);
|
|
@@ -833,6 +841,7 @@ export class AppManager {
|
|
|
833
841
|
throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
|
|
834
842
|
} else if (scenePathType === ScenePathType.Page) {
|
|
835
843
|
await this._setMainViewScenePath(scenePath);
|
|
844
|
+
|
|
836
845
|
} else if (scenePathType === ScenePathType.Dir) {
|
|
837
846
|
const validScenePath = makeValidScenePath(this.displayer, scenePath);
|
|
838
847
|
if (validScenePath) {
|
|
@@ -845,6 +854,7 @@ export class AppManager {
|
|
|
845
854
|
private async _setMainViewScenePath(scenePath: string) {
|
|
846
855
|
const success = this.setMainViewFocusPath(scenePath);
|
|
847
856
|
if (success) {
|
|
857
|
+
console.log("[window-manager] _setMainViewScenePath====>", scenePath);
|
|
848
858
|
this.safeSetAttributes({ _mainScenePath: scenePath });
|
|
849
859
|
this.store.setMainViewFocusPath(this.mainView);
|
|
850
860
|
this.updateSceneIndex();
|
|
@@ -861,6 +871,7 @@ export class AppManager {
|
|
|
861
871
|
const pageName = scenePath.replace(sceneDir, "").replace("/", "");
|
|
862
872
|
const index = scenes.findIndex(scene => scene.name === pageName);
|
|
863
873
|
if (isInteger(index) && index >= 0) {
|
|
874
|
+
console.log("[window-manager] updateSceneIndex====>", index);
|
|
864
875
|
this.safeSetAttributes({ _mainSceneIndex: index });
|
|
865
876
|
}
|
|
866
877
|
}
|
|
@@ -886,6 +897,7 @@ export class AppManager {
|
|
|
886
897
|
}
|
|
887
898
|
|
|
888
899
|
private dispatchSetMainViewScenePath(scenePath: string): void {
|
|
900
|
+
console.log("[window-manager] dispatchSetMainViewScenePath====>", scenePath);
|
|
889
901
|
this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
|
|
890
902
|
callbacks.emit("mainViewScenePathChange", scenePath);
|
|
891
903
|
// 兼容 15 的 SDK, 需要 room 的当前 ScenePath
|
|
@@ -966,3 +978,4 @@ export class AppManager {
|
|
|
966
978
|
this._resolveTimer = undefined;
|
|
967
979
|
}
|
|
968
980
|
}
|
|
981
|
+
|
|
@@ -194,10 +194,12 @@ export class AttributesDelegate {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
public setMainViewScenePath(scenePath: string) {
|
|
197
|
+
console.log("[window-manager] setMainViewScenePath====>", scenePath);
|
|
197
198
|
this.context.safeSetAttributes({ _mainScenePath: scenePath });
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
public setMainViewSceneIndex(index: number) {
|
|
202
|
+
console.log("[window-manager] setMainViewSceneIndex====>", index);
|
|
201
203
|
this.context.safeSetAttributes({ _mainSceneIndex: index });
|
|
202
204
|
}
|
|
203
205
|
|
|
@@ -210,16 +212,19 @@ export class AttributesDelegate {
|
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
public setMainViewCamera(camera: ICamera) {
|
|
215
|
+
console.log("[window-manager] setMainViewCamera", camera);
|
|
213
216
|
this.context.safeSetAttributes({ [Fields.MainViewCamera]: { ...camera } });
|
|
214
217
|
}
|
|
215
218
|
|
|
216
219
|
public setMainViewSize(size: ISize) {
|
|
217
220
|
if (size.width === 0 || size.height === 0) return;
|
|
221
|
+
console.log("[window-manager] setMainViewSize", size);
|
|
218
222
|
this.context.safeSetAttributes({ [Fields.MainViewSize]: { ...size } });
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
public setMainViewCameraAndSize(camera: ICamera, size: ISize) {
|
|
222
226
|
if (size.width === 0 || size.height === 0) return;
|
|
227
|
+
console.log("[window-manager] setMainViewCameraAndSize", camera, size);
|
|
223
228
|
this.context.safeSetAttributes({
|
|
224
229
|
[Fields.MainViewCamera]: { ...camera },
|
|
225
230
|
[Fields.MainViewSize]: { ...size },
|
package/src/Utils/Common.ts
CHANGED
|
@@ -34,6 +34,7 @@ export const setScenePath = (room: Room | undefined, scenePath: string) => {
|
|
|
34
34
|
if (room && room.isWritable) {
|
|
35
35
|
if (room.state.sceneState.scenePath !== scenePath) {
|
|
36
36
|
const nextScenePath = scenePath === "/" ? "" : scenePath;
|
|
37
|
+
console.log("[window-manager] real setScenePath for current room====>", nextScenePath);
|
|
37
38
|
room.setScenePath(nextScenePath);
|
|
38
39
|
}
|
|
39
40
|
}
|
package/src/View/MainView.ts
CHANGED
|
@@ -33,6 +33,7 @@ export class MainViewProxy {
|
|
|
33
33
|
this.startListenWritableChange();
|
|
34
34
|
});
|
|
35
35
|
const playgroundSizeChangeListener = () => {
|
|
36
|
+
console.log("[window-manager] playgroundSizeChangeListener====>", this.mainViewSize);
|
|
36
37
|
this.sizeChangeHandler(this.mainViewSize);
|
|
37
38
|
};
|
|
38
39
|
this.sideEffectManager.add(() => {
|
|
@@ -97,6 +98,7 @@ export class MainViewProxy {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
public start() {
|
|
101
|
+
console.log("[window-manager] start====>", this.mainViewSize);
|
|
100
102
|
this.sizeChangeHandler(this.mainViewSize);
|
|
101
103
|
if (this.started) return;
|
|
102
104
|
this.addCameraListener();
|
|
@@ -120,6 +122,7 @@ export class MainViewProxy {
|
|
|
120
122
|
() => this.mainViewCamera,
|
|
121
123
|
camera => {
|
|
122
124
|
if (camera && camera.id !== this.manager.uid) {
|
|
125
|
+
console.log("[window-manager] cameraReaction====>", camera, this.mainViewSize);
|
|
123
126
|
this.moveCameraToContian(this.mainViewSize);
|
|
124
127
|
this.moveCamera(camera);
|
|
125
128
|
}
|
|
@@ -130,6 +133,7 @@ export class MainViewProxy {
|
|
|
130
133
|
|
|
131
134
|
public sizeChangeHandler = debounce((size: Size) => {
|
|
132
135
|
if (size) {
|
|
136
|
+
console.log("[window-manager] sizeChangeHandler====>", size, this.mainViewCamera);
|
|
133
137
|
this.moveCameraToContian(size);
|
|
134
138
|
this.moveCamera(this.mainViewCamera);
|
|
135
139
|
}
|
|
@@ -138,6 +142,7 @@ export class MainViewProxy {
|
|
|
138
142
|
|
|
139
143
|
public onUpdateContainerSizeRatio = () => {
|
|
140
144
|
const size = this.store.getMainViewSize();
|
|
145
|
+
console.log("[window-manager] onUpdateContainerSizeRatio====>", size);
|
|
141
146
|
this.sizeChangeHandler(size);
|
|
142
147
|
};
|
|
143
148
|
|
package/src/index.ts
CHANGED
|
@@ -286,8 +286,14 @@ export class WindowManager
|
|
|
286
286
|
manager = await this.initManager(room);
|
|
287
287
|
if (manager) {
|
|
288
288
|
manager._roomLogger = (room as unknown as { logger: Logger }).logger;
|
|
289
|
+
if (WindowManager.registered.size > 0) {
|
|
290
|
+
manager._roomLogger.info(
|
|
291
|
+
`[WindowManager] registered apps: ${JSON.stringify(
|
|
292
|
+
Array.from(WindowManager.registered.keys())
|
|
293
|
+
)}`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
289
296
|
}
|
|
290
|
-
|
|
291
297
|
}
|
|
292
298
|
if (WindowManager.isCreated) {
|
|
293
299
|
throw new Error("[WindowManager]: Already created cannot be created again");
|
|
@@ -297,7 +303,13 @@ export class WindowManager
|
|
|
297
303
|
if (this.debug) {
|
|
298
304
|
setOptions({ verbose: true });
|
|
299
305
|
}
|
|
300
|
-
|
|
306
|
+
if (manager?._roomLogger) {
|
|
307
|
+
manager._roomLogger.info(
|
|
308
|
+
`[WindowManager] Already insert room version: ${manager.version}`
|
|
309
|
+
);
|
|
310
|
+
} else {
|
|
311
|
+
log("Already insert room", manager);
|
|
312
|
+
}
|
|
301
313
|
|
|
302
314
|
if (isRoom(this.displayer)) {
|
|
303
315
|
if (!manager) {
|
|
@@ -356,12 +368,25 @@ export class WindowManager
|
|
|
356
368
|
replaceRoomFunction(room, manager);
|
|
357
369
|
internalEmitter.emit("onCreated");
|
|
358
370
|
WindowManager.isCreated = true;
|
|
371
|
+
if (
|
|
372
|
+
manager._roomLogger &&
|
|
373
|
+
manager.attributes.registered &&
|
|
374
|
+
Object.keys(manager.attributes.registered).length > 0
|
|
375
|
+
) {
|
|
376
|
+
manager._roomLogger.info(
|
|
377
|
+
`[WindowManager] attributes registered apps: ${JSON.stringify(
|
|
378
|
+
Array.from(Object.keys(manager.attributes.registered))
|
|
379
|
+
)}`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
359
382
|
try {
|
|
360
383
|
await initDb();
|
|
361
384
|
} catch (error) {
|
|
385
|
+
manager._roomLogger?.warn(`[WindowManager] indexedDB open failed: ${error.message}`);
|
|
362
386
|
console.warn("[WindowManager]: indexedDB open failed");
|
|
363
387
|
console.log(error);
|
|
364
388
|
}
|
|
389
|
+
|
|
365
390
|
return manager;
|
|
366
391
|
}
|
|
367
392
|
|