@netless/window-manager 0.4.67-beta.1 → 0.4.68
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/AppManager.d.ts +3 -1
- package/dist/View/MainView.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App/AppProxy.ts +6 -6
- package/src/AppManager.ts +23 -17
- package/src/View/MainView.ts +16 -3
- package/src/index.ts +19 -4
package/dist/index.mjs
CHANGED
@@ -1363,8 +1363,7 @@ class AppProxy {
|
|
1363
1363
|
return payload;
|
1364
1364
|
};
|
1365
1365
|
this.appAttributesUpdateListener = (appId2) => {
|
1366
|
-
|
1367
|
-
(_a2 = this.manager.refresher) == null ? void 0 : _a2.add(appId2, () => {
|
1366
|
+
this.manager.refresher.add(appId2, () => {
|
1368
1367
|
return autorun(() => {
|
1369
1368
|
const attrs = this.manager.attributes[appId2];
|
1370
1369
|
if (attrs) {
|
@@ -1372,20 +1371,20 @@ class AppProxy {
|
|
1372
1371
|
}
|
1373
1372
|
});
|
1374
1373
|
});
|
1375
|
-
|
1374
|
+
this.manager.refresher.add(this.stateKey, () => {
|
1376
1375
|
return autorun(() => {
|
1377
|
-
var
|
1378
|
-
const appState = (
|
1379
|
-
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((
|
1380
|
-
(
|
1376
|
+
var _a2, _b, _c, _d;
|
1377
|
+
const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
|
1378
|
+
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
|
1379
|
+
(_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
|
1381
1380
|
(_d = this.boxManager) == null ? void 0 : _d.focusBox({ appId: appId2 });
|
1382
1381
|
}
|
1383
1382
|
});
|
1384
1383
|
});
|
1385
|
-
|
1384
|
+
this.manager.refresher.add(`${appId2}-fullPath`, () => {
|
1386
1385
|
return autorun(() => {
|
1387
|
-
var
|
1388
|
-
const fullPath = (
|
1386
|
+
var _a2;
|
1387
|
+
const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
|
1389
1388
|
this.setFocusScenePathHandler(fullPath);
|
1390
1389
|
if (this._prevFullPath !== fullPath) {
|
1391
1390
|
this.notifyPageStateChange();
|
@@ -1703,7 +1702,7 @@ class AppProxy {
|
|
1703
1702
|
}
|
1704
1703
|
}
|
1705
1704
|
async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
|
1706
|
-
var _a
|
1705
|
+
var _a;
|
1707
1706
|
if (this.status === "destroyed")
|
1708
1707
|
return;
|
1709
1708
|
this.status = "destroyed";
|
@@ -1728,9 +1727,9 @@ class AppProxy {
|
|
1728
1727
|
this._pageState.destroy();
|
1729
1728
|
this.viewManager.destroyView(this.id);
|
1730
1729
|
this.manager.appStatus.delete(this.id);
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1730
|
+
this.manager.refresher.remove(this.id);
|
1731
|
+
this.manager.refresher.remove(this.stateKey);
|
1732
|
+
this.manager.refresher.remove(`${this.id}-fullPath`);
|
1734
1733
|
this._prevFullPath = void 0;
|
1735
1734
|
}
|
1736
1735
|
close() {
|
@@ -1790,11 +1789,20 @@ const setDefaultCameraBound = (view) => {
|
|
1790
1789
|
class MainViewProxy {
|
1791
1790
|
constructor(manager) {
|
1792
1791
|
this.manager = manager;
|
1792
|
+
this.polling = false;
|
1793
1793
|
this.started = false;
|
1794
1794
|
this.mainViewIsAddListener = false;
|
1795
1795
|
this.store = this.manager.store;
|
1796
1796
|
this.viewMode = this.manager.windowManger.viewMode;
|
1797
1797
|
this.sideEffectManager = new SideEffectManager$1();
|
1798
|
+
this.syncCamera = () => {
|
1799
|
+
if (!this.polling || this.viewMode !== ViewMode.Broadcaster)
|
1800
|
+
return;
|
1801
|
+
const { mainViewCamera } = this;
|
1802
|
+
if (mainViewCamera && mainViewCamera.id !== this.manager.uid) {
|
1803
|
+
this.moveCameraSizeByAttributes();
|
1804
|
+
}
|
1805
|
+
};
|
1798
1806
|
this.startListenWritableChange = () => {
|
1799
1807
|
this.sideEffectManager.add(() => {
|
1800
1808
|
return internalEmitter.on("writableChange", (isWritable) => {
|
@@ -1807,8 +1815,7 @@ class MainViewProxy {
|
|
1807
1815
|
});
|
1808
1816
|
};
|
1809
1817
|
this.addCameraReaction = () => {
|
1810
|
-
|
1811
|
-
(_a = this.manager.refresher) == null ? void 0 : _a.add(Fields.MainViewCamera, this.cameraReaction);
|
1818
|
+
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
1812
1819
|
};
|
1813
1820
|
this.cameraReaction = () => {
|
1814
1821
|
return reaction(() => this.mainViewCamera, (camera) => {
|
@@ -1884,6 +1891,7 @@ class MainViewProxy {
|
|
1884
1891
|
}
|
1885
1892
|
});
|
1886
1893
|
});
|
1894
|
+
this.sideEffectManager.setInterval(this.syncCamera, 1500);
|
1887
1895
|
}
|
1888
1896
|
ensureCameraAndSize() {
|
1889
1897
|
if (this.viewMode !== ViewMode.Broadcaster)
|
@@ -2027,10 +2035,9 @@ class MainViewProxy {
|
|
2027
2035
|
}
|
2028
2036
|
}
|
2029
2037
|
stop() {
|
2030
|
-
var _a, _b;
|
2031
2038
|
this.removeCameraListener();
|
2032
|
-
|
2033
|
-
|
2039
|
+
this.manager.refresher.remove(Fields.MainViewCamera);
|
2040
|
+
this.manager.refresher.remove(Fields.MainViewSize);
|
2034
2041
|
this.started = false;
|
2035
2042
|
}
|
2036
2043
|
destroy() {
|
@@ -2259,16 +2266,14 @@ class AppManager {
|
|
2259
2266
|
this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
|
2260
2267
|
};
|
2261
2268
|
this.addAppsChangeListener = () => {
|
2262
|
-
|
2263
|
-
(_a = this.refresher) == null ? void 0 : _a.add("apps", () => {
|
2269
|
+
this.refresher.add("apps", () => {
|
2264
2270
|
return safeListenPropsUpdated(() => this.attributes.apps, () => {
|
2265
2271
|
this.attributesUpdateCallback(this.attributes.apps);
|
2266
2272
|
});
|
2267
2273
|
});
|
2268
2274
|
};
|
2269
2275
|
this.addAppCloseListener = () => {
|
2270
|
-
|
2271
|
-
(_a = this.refresher) == null ? void 0 : _a.add("appsClose", () => {
|
2276
|
+
this.refresher.add("appsClose", () => {
|
2272
2277
|
return onObjectRemoved(this.attributes.apps, () => {
|
2273
2278
|
this.onAppDelete(this.attributes.apps);
|
2274
2279
|
});
|
@@ -2400,16 +2405,14 @@ class AppManager {
|
|
2400
2405
|
this.refresher = reconnectRefresher;
|
2401
2406
|
this.refresher.setRoom(this.room);
|
2402
2407
|
this.refresher.setContext({ emitter: internalEmitter });
|
2403
|
-
this.sideEffectManager.
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
(_c = this.callbacksNode) == null ? void 0 : _c.dispose();
|
2412
|
-
};
|
2408
|
+
this.sideEffectManager.addDisposer(() => {
|
2409
|
+
var _a, _b;
|
2410
|
+
this.appCreateQueue.destroy();
|
2411
|
+
this.mainViewProxy.destroy();
|
2412
|
+
this.refresher.destroy();
|
2413
|
+
this.viewManager.destroy();
|
2414
|
+
(_a = this.boxManager) == null ? void 0 : _a.destroy();
|
2415
|
+
(_b = this.callbacksNode) == null ? void 0 : _b.dispose();
|
2413
2416
|
});
|
2414
2417
|
internalEmitter.once("onCreated").then(() => this.onCreated());
|
2415
2418
|
internalEmitter.on("onReconnected", () => this.onReconnected());
|
@@ -2451,6 +2454,12 @@ class AppManager {
|
|
2451
2454
|
get mainView() {
|
2452
2455
|
return this.mainViewProxy.view;
|
2453
2456
|
}
|
2457
|
+
get polling() {
|
2458
|
+
return this.mainViewProxy.polling;
|
2459
|
+
}
|
2460
|
+
set polling(b2) {
|
2461
|
+
this.mainViewProxy.polling = b2;
|
2462
|
+
}
|
2454
2463
|
get focusApp() {
|
2455
2464
|
if (this.store.focus) {
|
2456
2465
|
return this.appProxies.get(this.store.focus);
|
@@ -2469,7 +2478,7 @@ class AppManager {
|
|
2469
2478
|
}
|
2470
2479
|
}
|
2471
2480
|
async onCreated() {
|
2472
|
-
var _a
|
2481
|
+
var _a;
|
2473
2482
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2474
2483
|
internalEmitter.emit("updateManagerRect");
|
2475
2484
|
boxEmitter.on("move", this.onBoxMove);
|
@@ -2479,32 +2488,32 @@ class AppManager {
|
|
2479
2488
|
boxEmitter.on("boxStateChange", this.onBoxStateChange);
|
2480
2489
|
this.addAppsChangeListener();
|
2481
2490
|
this.addAppCloseListener();
|
2482
|
-
|
2491
|
+
this.refresher.add("maximized", () => {
|
2483
2492
|
return autorun(() => {
|
2484
2493
|
var _a2;
|
2485
2494
|
const maximized = this.attributes.maximized;
|
2486
2495
|
(_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
|
2487
2496
|
});
|
2488
2497
|
});
|
2489
|
-
|
2498
|
+
this.refresher.add("minimized", () => {
|
2490
2499
|
return autorun(() => {
|
2491
2500
|
const minimized = this.attributes.minimized;
|
2492
2501
|
this.onMinimized(minimized);
|
2493
2502
|
});
|
2494
2503
|
});
|
2495
|
-
|
2504
|
+
this.refresher.add("mainViewIndex", () => {
|
2496
2505
|
return autorun(() => {
|
2497
2506
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
2498
2507
|
this.onMainViewIndexChange(mainSceneIndex);
|
2499
2508
|
});
|
2500
2509
|
});
|
2501
|
-
|
2510
|
+
this.refresher.add("focusedChange", () => {
|
2502
2511
|
return autorun(() => {
|
2503
2512
|
const focused = get(this.attributes, "focus");
|
2504
2513
|
this.onFocusChange(focused);
|
2505
2514
|
});
|
2506
2515
|
});
|
2507
|
-
|
2516
|
+
this.refresher.add("registeredChange", () => {
|
2508
2517
|
return autorun(() => {
|
2509
2518
|
const registered = get(this.attributes, Fields.Registered);
|
2510
2519
|
this.onRegisteredChange(registered);
|
@@ -2516,7 +2525,7 @@ class AppManager {
|
|
2516
2525
|
return;
|
2517
2526
|
this.resetScenePath(mainScenePath);
|
2518
2527
|
}
|
2519
|
-
this.displayerWritableListener(!((
|
2528
|
+
this.displayerWritableListener(!((_a = this.room) == null ? void 0 : _a.isWritable));
|
2520
2529
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
2521
2530
|
this._prevFocused = this.attributes.focus;
|
2522
2531
|
this.sideEffectManager.add(() => {
|
@@ -17516,7 +17525,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
17516
17525
|
const _WindowManager = class extends InvisiblePlugin {
|
17517
17526
|
constructor(context) {
|
17518
17527
|
super(context);
|
17519
|
-
this.version = "0.4.
|
17528
|
+
this.version = "0.4.68";
|
17520
17529
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.27", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^0.1.5", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.17", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "jspdf": "^2.5.1", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.43" } };
|
17521
17530
|
this.emitter = callbacks$1;
|
17522
17531
|
this.viewMode = ViewMode.Broadcaster;
|
@@ -17555,7 +17564,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17555
17564
|
}
|
17556
17565
|
} else {
|
17557
17566
|
await pRetry(async (count) => {
|
17558
|
-
manager =
|
17567
|
+
manager = room.getInvisiblePlugin(_WindowManager.kind);
|
17559
17568
|
if (!manager) {
|
17560
17569
|
log(`manager is empty. retrying ${count}`);
|
17561
17570
|
throw new Error();
|
@@ -17571,6 +17580,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17571
17580
|
await manager.ensureAttributes();
|
17572
17581
|
manager._fullscreen = params.fullscreen;
|
17573
17582
|
manager.appManager = new AppManager(manager);
|
17583
|
+
manager.appManager.polling = params.polling || false;
|
17574
17584
|
manager._pageState = new PageStateImpl(manager.appManager);
|
17575
17585
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
17576
17586
|
if (containerSizeRatio) {
|
@@ -17718,6 +17728,9 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17718
17728
|
if (!params.kind || typeof params.kind !== "string") {
|
17719
17729
|
throw new ParamsInvalidError();
|
17720
17730
|
}
|
17731
|
+
if (params.src && typeof params.src === "string") {
|
17732
|
+
appRegister.register({ kind: params.kind, src: params.src });
|
17733
|
+
}
|
17721
17734
|
const appImpl = await ((_a = appRegister.appClasses.get(params.kind)) == null ? void 0 : _a());
|
17722
17735
|
if (appImpl && ((_b = appImpl.config) == null ? void 0 : _b.singleton)) {
|
17723
17736
|
if (this.appManager.appProxies.has(params.kind)) {
|
@@ -17982,6 +17995,15 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17982
17995
|
var _a, _b;
|
17983
17996
|
return ((_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.view) || this.mainView;
|
17984
17997
|
}
|
17998
|
+
get polling() {
|
17999
|
+
var _a;
|
18000
|
+
return ((_a = this.appManager) == null ? void 0 : _a.polling) || false;
|
18001
|
+
}
|
18002
|
+
set polling(b2) {
|
18003
|
+
if (this.appManager) {
|
18004
|
+
this.appManager.polling = b2;
|
18005
|
+
}
|
18006
|
+
}
|
17985
18007
|
get mainViewSceneIndex() {
|
17986
18008
|
var _a;
|
17987
18009
|
return ((_a = this._pageState) == null ? void 0 : _a.index) || 0;
|
@@ -18184,12 +18206,12 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18184
18206
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.Refresh);
|
18185
18207
|
}
|
18186
18208
|
_refresh() {
|
18187
|
-
var _a, _b
|
18209
|
+
var _a, _b;
|
18188
18210
|
(_a = this.appManager) == null ? void 0 : _a.mainViewProxy.rebind();
|
18189
18211
|
if (_WindowManager.container) {
|
18190
18212
|
this.bindContainer(_WindowManager.container);
|
18191
18213
|
}
|
18192
|
-
(
|
18214
|
+
(_b = this.appManager) == null ? void 0 : _b.refresher.refresh();
|
18193
18215
|
}
|
18194
18216
|
setContainerSizeRatio(ratio) {
|
18195
18217
|
if (!isNumber(ratio) || !(ratio > 0)) {
|