@netless/window-manager 1.0.12 → 1.0.13-beta.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.d.ts +5 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/App/AppProxy.ts +10 -2
- package/src/AppManager.ts +18 -6
- package/src/index.ts +37 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/window-manager",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13-beta.1",
|
|
4
4
|
"description": "Multi-window mode for Netless Whiteboard",
|
|
5
5
|
"author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"jspdf": "2.5.1",
|
|
26
|
-
"white-web-sdk": "^2.16.
|
|
26
|
+
"white-web-sdk": "^2.16.53"
|
|
27
27
|
},
|
|
28
28
|
"peerDependenciesMeta": {
|
|
29
29
|
"jspdf": {
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"typescript": "^4.5.5",
|
|
73
73
|
"vite": "^2.9.9",
|
|
74
74
|
"vitest": "^0.14.1",
|
|
75
|
-
"white-web-sdk": "^2.16.
|
|
75
|
+
"white-web-sdk": "^2.16.53"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/src/App/AppProxy.ts
CHANGED
|
@@ -120,6 +120,10 @@ export class AppProxy implements PageRemoveService {
|
|
|
120
120
|
return this.store.getAppAttributes(this.id);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
public get Logger() {
|
|
124
|
+
return this.manager.windowManger.Logger;
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
public getFullScenePath(): string | undefined {
|
|
124
128
|
if (this.scenePath) {
|
|
125
129
|
return get(this.appAttributes, [Fields.FullPath]) || this.getFullScenePathFromScenes();
|
|
@@ -145,6 +149,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
145
149
|
): Promise<{ appId: string; app: NetlessApp }> {
|
|
146
150
|
const params = this.params;
|
|
147
151
|
if (!params.kind) {
|
|
152
|
+
this.Logger?.error(`[WindowManager]: kind require`);
|
|
148
153
|
throw new Error("[WindowManager]: kind require");
|
|
149
154
|
}
|
|
150
155
|
const appImpl = await appRegister.appClasses.get(params.kind)?.();
|
|
@@ -162,6 +167,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
162
167
|
params.isDragContent
|
|
163
168
|
);
|
|
164
169
|
} else {
|
|
170
|
+
this.Logger?.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
|
165
171
|
throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
|
166
172
|
}
|
|
167
173
|
internalEmitter.emit("updateManagerRect");
|
|
@@ -210,7 +216,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
210
216
|
}
|
|
211
217
|
setTimeout(async () => {
|
|
212
218
|
// 延迟执行 setup, 防止初始化的属性没有更新成功
|
|
213
|
-
|
|
219
|
+
this.Logger?.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
|
|
214
220
|
const result = await app.setup(context);
|
|
215
221
|
this.appResult = result;
|
|
216
222
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
|
@@ -245,7 +251,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
245
251
|
this.boxManager.focusBox({ appId }, false);
|
|
246
252
|
}
|
|
247
253
|
} catch (error: any) {
|
|
248
|
-
|
|
254
|
+
this.Logger?.error(`[WindowManager]: app setup error: ${error.message}`);
|
|
249
255
|
throw new Error(`[WindowManager]: app setup error: ${error.message}`);
|
|
250
256
|
}
|
|
251
257
|
}
|
|
@@ -532,6 +538,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
532
538
|
await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
|
|
533
539
|
await this.appEmitter.emit("destroy", { error });
|
|
534
540
|
} catch (error) {
|
|
541
|
+
this.Logger?.error(`[WindowManager]: notifyApp error: ${error.message}`);
|
|
535
542
|
console.error("[WindowManager]: notifyApp error", error.message, error.stack);
|
|
536
543
|
}
|
|
537
544
|
this.appEmitter.clearListeners();
|
|
@@ -554,6 +561,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
554
561
|
this.manager.refresher.remove(this.stateKey);
|
|
555
562
|
this.manager.refresher.remove(`${this.id}-fullPath`);
|
|
556
563
|
this._prevFullPath = undefined;
|
|
564
|
+
this.Logger?.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
|
|
557
565
|
}
|
|
558
566
|
|
|
559
567
|
public close(): Promise<void> {
|
package/src/AppManager.ts
CHANGED
|
@@ -94,11 +94,6 @@ export class AppManager {
|
|
|
94
94
|
|
|
95
95
|
constructor(public windowManger: WindowManager) {
|
|
96
96
|
this.displayer = windowManger.displayer;
|
|
97
|
-
// this.store.setContext({
|
|
98
|
-
// getAttributes: () => this.attributes,
|
|
99
|
-
// safeSetAttributes: attributes => this.safeSetAttributes(attributes),
|
|
100
|
-
// safeUpdateAttributes: (keys, val) => this.safeUpdateAttributes(keys, val),
|
|
101
|
-
// });
|
|
102
97
|
this.store = createAttributesDelegate(WindowManager.extendClass, {
|
|
103
98
|
getAttributes: () => this.attributes,
|
|
104
99
|
safeSetAttributes: attributes => this.safeSetAttributes(attributes),
|
|
@@ -138,6 +133,7 @@ export class AppManager {
|
|
|
138
133
|
this.createRootDirScenesCallback();
|
|
139
134
|
|
|
140
135
|
appRegister.setSyncRegisterApp(payload => {
|
|
136
|
+
this.Logger?.info(`[WindowManager] syncRegisterApp ${JSON.stringify(payload)}`);
|
|
141
137
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
|
142
138
|
});
|
|
143
139
|
}
|
|
@@ -333,6 +329,10 @@ export class AppManager {
|
|
|
333
329
|
return this.room?.uid || "";
|
|
334
330
|
}
|
|
335
331
|
|
|
332
|
+
public get Logger() {
|
|
333
|
+
return this.windowManger.Logger;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
336
|
public getMainViewSceneDir() {
|
|
337
337
|
const scenePath = this.store.getMainViewScenePath();
|
|
338
338
|
if (scenePath) {
|
|
@@ -603,6 +603,9 @@ export class AppManager {
|
|
|
603
603
|
try {
|
|
604
604
|
const appAttributes = this.attributes[id];
|
|
605
605
|
if (!appAttributes) {
|
|
606
|
+
this.Logger?.error(
|
|
607
|
+
`[WindowManager]: appAttributes is undefined, appId: ${id}`
|
|
608
|
+
);
|
|
606
609
|
throw new Error("appAttributes is undefined");
|
|
607
610
|
}
|
|
608
611
|
|
|
@@ -725,6 +728,9 @@ export class AppManager {
|
|
|
725
728
|
|
|
726
729
|
public async addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined> {
|
|
727
730
|
log("addApp", params);
|
|
731
|
+
this.windowManger.Logger?.info(
|
|
732
|
+
`[WindowManager]: addApp ${params.kind}, isDynamicPPT: ${isDynamicPPT}`
|
|
733
|
+
);
|
|
728
734
|
const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
|
|
729
735
|
const appProxy = await this.baseInsertApp(params, appId, true, needFocus);
|
|
730
736
|
this.afterAddApp(appProxy);
|
|
@@ -773,7 +779,9 @@ export class AppManager {
|
|
|
773
779
|
focus?: boolean
|
|
774
780
|
) {
|
|
775
781
|
if (this.appProxies.has(appId)) {
|
|
776
|
-
|
|
782
|
+
this.windowManger.Logger?.warn(
|
|
783
|
+
`[WindowManager]: app duplicate exists and cannot be created again, appId: ${appId}`
|
|
784
|
+
);
|
|
777
785
|
return;
|
|
778
786
|
}
|
|
779
787
|
const AppProxyClass = getExtendClass(AppProxy, WindowManager.extendClass);
|
|
@@ -784,6 +792,7 @@ export class AppManager {
|
|
|
784
792
|
return appProxy;
|
|
785
793
|
} else {
|
|
786
794
|
this.appStatus.delete(appId);
|
|
795
|
+
this.Logger?.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
|
|
787
796
|
throw new Error("[WindowManger]: initialize AppProxy failed");
|
|
788
797
|
}
|
|
789
798
|
}
|
|
@@ -823,9 +832,11 @@ export class AppManager {
|
|
|
823
832
|
const scenePathType = this.displayer.scenePathType(scenePath);
|
|
824
833
|
const sceneDir = parseSceneDir(scenePath);
|
|
825
834
|
if (sceneDir !== ROOT_DIR) {
|
|
835
|
+
this.Logger?.error(`[WindowManager]: main view scenePath must in root dir "/"`);
|
|
826
836
|
throw new Error(`[WindowManager]: main view scenePath must in root dir "/"`);
|
|
827
837
|
}
|
|
828
838
|
if (scenePathType === ScenePathType.None) {
|
|
839
|
+
this.Logger?.error(`[WindowManager]: ${scenePath} not valid scene`);
|
|
829
840
|
throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
|
|
830
841
|
} else if (scenePathType === ScenePathType.Page) {
|
|
831
842
|
await this._setMainViewScenePath(scenePath);
|
|
@@ -875,6 +886,7 @@ export class AppManager {
|
|
|
875
886
|
this.dispatchSetMainViewScenePath(scenePath);
|
|
876
887
|
}
|
|
877
888
|
} else {
|
|
889
|
+
this.Logger?.error(`[WindowManager]: ${index} not valid index`);
|
|
878
890
|
throw new Error(`[WindowManager]: ${index} not valid index`);
|
|
879
891
|
}
|
|
880
892
|
}
|
package/src/index.ts
CHANGED
|
@@ -47,6 +47,7 @@ import type {
|
|
|
47
47
|
Player,
|
|
48
48
|
ImageInformation,
|
|
49
49
|
SceneState,
|
|
50
|
+
Logger,
|
|
50
51
|
} from "white-web-sdk";
|
|
51
52
|
import type { AppListeners } from "./AppListener";
|
|
52
53
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
|
@@ -242,6 +243,12 @@ export class WindowManager
|
|
|
242
243
|
|
|
243
244
|
private extendPluginManager?: ExtendPluginManager;
|
|
244
245
|
|
|
246
|
+
private _roomLogger?: Logger;
|
|
247
|
+
|
|
248
|
+
get Logger(): Logger | undefined {
|
|
249
|
+
return this._roomLogger;
|
|
250
|
+
}
|
|
251
|
+
|
|
245
252
|
constructor(context: InvisiblePluginContext) {
|
|
246
253
|
super(context);
|
|
247
254
|
WindowManager.displayer = context.displayer;
|
|
@@ -277,6 +284,16 @@ export class WindowManager
|
|
|
277
284
|
room.disableSerialization = false;
|
|
278
285
|
}
|
|
279
286
|
manager = await this.initManager(room);
|
|
287
|
+
if (manager) {
|
|
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
|
+
}
|
|
296
|
+
}
|
|
280
297
|
}
|
|
281
298
|
if (WindowManager.isCreated) {
|
|
282
299
|
throw new Error("[WindowManager]: Already created cannot be created again");
|
|
@@ -286,7 +303,13 @@ export class WindowManager
|
|
|
286
303
|
if (this.debug) {
|
|
287
304
|
setOptions({ verbose: true });
|
|
288
305
|
}
|
|
289
|
-
|
|
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
|
+
}
|
|
290
313
|
|
|
291
314
|
if (isRoom(this.displayer)) {
|
|
292
315
|
if (!manager) {
|
|
@@ -345,12 +368,25 @@ export class WindowManager
|
|
|
345
368
|
replaceRoomFunction(room, manager);
|
|
346
369
|
internalEmitter.emit("onCreated");
|
|
347
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
|
+
}
|
|
348
382
|
try {
|
|
349
383
|
await initDb();
|
|
350
384
|
} catch (error) {
|
|
385
|
+
manager._roomLogger?.warn(`[WindowManager] indexedDB open failed: ${error.message}`);
|
|
351
386
|
console.warn("[WindowManager]: indexedDB open failed");
|
|
352
387
|
console.log(error);
|
|
353
388
|
}
|
|
389
|
+
|
|
354
390
|
return manager;
|
|
355
391
|
}
|
|
356
392
|
|