@netless/window-manager 0.4.23 → 0.4.26
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/CHANGELOG.md +13 -0
- package/__mocks__/white-web-sdk.ts +41 -0
- package/dist/App/AppProxy.d.ts +1 -0
- package/dist/ContainerResizeObserver.d.ts +2 -1
- package/dist/InternalEmitter.d.ts +3 -1
- package/dist/View/MainView.d.ts +3 -1
- package/dist/index.cjs.js +47 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +57 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/docs/advanced.md +12 -4
- package/docs/api.md +9 -0
- package/package.json +6 -10
- package/pnpm-lock.yaml +793 -2690
- package/src/App/AppProxy.ts +6 -1
- package/src/ContainerResizeObserver.ts +12 -1
- package/src/InternalEmitter.ts +3 -1
- package/src/ReconnectRefresher.ts +4 -1
- package/src/View/MainView.ts +33 -8
- package/src/index.ts +10 -1
- package/vite.config.js +10 -2
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
@@ -19,7 +19,7 @@ var __spreadValues = (a2, b2) => {
|
|
19
19
|
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
20
20
|
import pRetry from "p-retry";
|
21
21
|
import Emittery from "emittery";
|
22
|
-
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isEmpty, isInteger, orderBy, throttle,
|
22
|
+
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isEmpty, isInteger, orderBy, isFunction, throttle, isNumber, isNull } from "lodash";
|
23
23
|
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, WhiteVersion, ApplianceNames, RoomPhase, InvisiblePlugin, ViewMode } from "white-web-sdk";
|
24
24
|
import { v4 } from "uuid";
|
25
25
|
import { genUID, SideEffectManager } from "side-effect-manager";
|
@@ -1264,7 +1264,10 @@ class AppProxy {
|
|
1264
1264
|
var _a3;
|
1265
1265
|
const fullPath = (_a3 = this.appAttributes) == null ? void 0 : _a3.fullPath;
|
1266
1266
|
this.setFocusScenePathHandler(fullPath);
|
1267
|
-
this.
|
1267
|
+
if (this._prevFullPath !== fullPath) {
|
1268
|
+
this.notifyPageStateChange();
|
1269
|
+
this._prevFullPath = fullPath;
|
1270
|
+
}
|
1268
1271
|
});
|
1269
1272
|
});
|
1270
1273
|
};
|
@@ -1555,6 +1558,7 @@ class AppProxy {
|
|
1555
1558
|
(_b = this.manager.refresher) == null ? void 0 : _b.remove(this.id);
|
1556
1559
|
(_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
|
1557
1560
|
(_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
|
1561
|
+
this._prevFullPath = void 0;
|
1558
1562
|
}
|
1559
1563
|
close() {
|
1560
1564
|
return this.destroy(true, true, false);
|
@@ -1644,6 +1648,13 @@ class MainViewProxy {
|
|
1644
1648
|
this.moveCamera(this.mainViewCamera);
|
1645
1649
|
}
|
1646
1650
|
}, 30);
|
1651
|
+
this.onUpdateContainerSizeRatio = () => {
|
1652
|
+
const size2 = this.store.getMainViewSize();
|
1653
|
+
this.sizeChangeHandler(size2);
|
1654
|
+
if (size2.id === this.manager.uid) {
|
1655
|
+
this.setCameraAndSize();
|
1656
|
+
}
|
1657
|
+
};
|
1647
1658
|
this.onCameraUpdatedByDevice = (camera) => {
|
1648
1659
|
this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid }));
|
1649
1660
|
if (!isEqual(this.mainViewSize, __spreadProps(__spreadValues({}, this.mainView.size), { id: this.manager.uid }))) {
|
@@ -1671,8 +1682,15 @@ class MainViewProxy {
|
|
1671
1682
|
this.sizeChangeHandler(this.mainViewSize);
|
1672
1683
|
};
|
1673
1684
|
this.sideEffectManager.add(() => {
|
1674
|
-
emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
1675
|
-
|
1685
|
+
return emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
1686
|
+
});
|
1687
|
+
this.sideEffectManager.add(() => {
|
1688
|
+
return emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
|
1689
|
+
});
|
1690
|
+
this.sideEffectManager.add(() => {
|
1691
|
+
return emitter.on("startReconnect", () => {
|
1692
|
+
this.mainView.release();
|
1693
|
+
});
|
1676
1694
|
});
|
1677
1695
|
}
|
1678
1696
|
ensureCameraAndSize() {
|
@@ -1687,6 +1705,9 @@ class MainViewProxy {
|
|
1687
1705
|
get mainViewSize() {
|
1688
1706
|
return this.store.getMainViewSize();
|
1689
1707
|
}
|
1708
|
+
get didRelease() {
|
1709
|
+
return get(this.view, ["didRelease"]);
|
1710
|
+
}
|
1690
1711
|
moveCameraSizeByAttributes() {
|
1691
1712
|
this.moveCameraToContian(this.mainViewSize);
|
1692
1713
|
this.moveCamera(this.mainViewCamera);
|
@@ -1719,16 +1740,22 @@ class MainViewProxy {
|
|
1719
1740
|
return mainView;
|
1720
1741
|
}
|
1721
1742
|
onReconnect() {
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1743
|
+
if (this.didRelease) {
|
1744
|
+
this.rebind();
|
1745
|
+
} else {
|
1746
|
+
const mainViewScenePath = this.store.getMainViewScenePath();
|
1747
|
+
if (mainViewScenePath) {
|
1748
|
+
setViewFocusScenePath(this.view, mainViewScenePath);
|
1749
|
+
}
|
1725
1750
|
}
|
1726
1751
|
}
|
1727
1752
|
rebind() {
|
1728
1753
|
const divElement = this.mainView.divElement;
|
1729
1754
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
1730
1755
|
this.stop();
|
1731
|
-
this.
|
1756
|
+
if (!this.didRelease) {
|
1757
|
+
this.mainView.release();
|
1758
|
+
}
|
1732
1759
|
this.removeMainViewListener();
|
1733
1760
|
this.mainView = this.createMainView();
|
1734
1761
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
@@ -2555,6 +2582,9 @@ class ContainerResizeObserver {
|
|
2555
2582
|
this.emitter.emit("playgroundSizeChange", containerRect);
|
2556
2583
|
}
|
2557
2584
|
});
|
2585
|
+
this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
|
2586
|
+
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
2587
|
+
});
|
2558
2588
|
this.containerResizeObserver.observe(container);
|
2559
2589
|
}
|
2560
2590
|
updateSizer({ width, height }, sizer, wrapper) {
|
@@ -2573,6 +2603,10 @@ class ContainerResizeObserver {
|
|
2573
2603
|
disconnect() {
|
2574
2604
|
var _a;
|
2575
2605
|
(_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
|
2606
|
+
if (isFunction(this.disposer)) {
|
2607
|
+
this.disposer();
|
2608
|
+
this.disposer = void 0;
|
2609
|
+
}
|
2576
2610
|
}
|
2577
2611
|
}
|
2578
2612
|
var react = { exports: {} };
|
@@ -5557,6 +5591,9 @@ class ReconnectRefresher {
|
|
5557
5591
|
this.reactors = /* @__PURE__ */ new Map();
|
5558
5592
|
this.disposers = /* @__PURE__ */ new Map();
|
5559
5593
|
this.onPhaseChanged = (phase) => {
|
5594
|
+
if (phase === RoomPhase.Reconnecting) {
|
5595
|
+
this.ctx.emitter.emit("startReconnect");
|
5596
|
+
}
|
5560
5597
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
5561
5598
|
this.onReconnected();
|
5562
5599
|
}
|
@@ -5573,7 +5610,7 @@ class ReconnectRefresher {
|
|
5573
5610
|
this.disposers.set(id2, func());
|
5574
5611
|
}
|
5575
5612
|
});
|
5576
|
-
this.ctx.emitter.emit("onReconnected"
|
5613
|
+
this.ctx.emitter.emit("onReconnected");
|
5577
5614
|
};
|
5578
5615
|
}
|
5579
5616
|
setRoom(room) {
|
@@ -14868,14 +14905,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
14868
14905
|
const _WindowManager = class extends InvisiblePlugin {
|
14869
14906
|
constructor(context) {
|
14870
14907
|
super(context);
|
14871
|
-
this.version = "0.4.
|
14872
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.26", "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": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@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/
|
14908
|
+
this.version = "0.4.26";
|
14909
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.26", "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": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@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", "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", "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.12.4", "white-web-sdk": "2.16.10" } };
|
14873
14910
|
this.emitter = callbacks$1;
|
14874
14911
|
this.viewMode = ViewMode.Broadcaster;
|
14875
14912
|
this.isReplay = isPlayer(this.displayer);
|
14876
14913
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
14877
14914
|
_WindowManager.displayer = context.displayer;
|
14878
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.26", "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": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@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/
|
14915
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.26", "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": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@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", "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", "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.12.4", "white-web-sdk": "2.16.10" } };
|
14879
14916
|
}
|
14880
14917
|
static async mount(params) {
|
14881
14918
|
const room = params.room;
|
@@ -15474,6 +15511,14 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15474
15511
|
}
|
15475
15512
|
(_c = (_b = this.appManager) == null ? void 0 : _b.refresher) == null ? void 0 : _c.refresh();
|
15476
15513
|
}
|
15514
|
+
setContainerSizeRatio(ratio) {
|
15515
|
+
if (!isNumber(ratio)) {
|
15516
|
+
throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${ratio}`);
|
15517
|
+
}
|
15518
|
+
_WindowManager.containerSizeRatio = ratio;
|
15519
|
+
this.containerSizeRatio = ratio;
|
15520
|
+
emitter.emit("containerSizeRatioUpdate", ratio);
|
15521
|
+
}
|
15477
15522
|
isDynamicPPT(scenes) {
|
15478
15523
|
var _a, _b;
|
15479
15524
|
const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;
|