@netless/window-manager 0.4.22 → 0.4.25
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 -1
- package/__mocks__/white-web-sdk.ts +41 -0
- package/dist/AttributesDelegate.d.ts +9 -6
- package/dist/ContainerResizeObserver.d.ts +2 -1
- package/dist/InternalEmitter.d.ts +2 -0
- package/dist/View/MainView.d.ts +4 -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 +8 -8
- 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/AppManager.ts +1 -0
- package/src/AttributesDelegate.ts +14 -2
- package/src/ContainerResizeObserver.ts +12 -1
- package/src/InternalEmitter.ts +2 -0
- package/src/View/MainView.ts +38 -11
- 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";
|
@@ -1153,6 +1153,12 @@ class AttributesDelegate {
|
|
1153
1153
|
setMainViewSize(size2) {
|
1154
1154
|
this.context.safeSetAttributes({ ["mainViewSize"]: __spreadValues({}, size2) });
|
1155
1155
|
}
|
1156
|
+
setMainViewCameraAndSize(camera, size2) {
|
1157
|
+
this.context.safeSetAttributes({
|
1158
|
+
["mainViewCamera"]: __spreadValues({}, camera),
|
1159
|
+
["mainViewSize"]: __spreadValues({}, size2)
|
1160
|
+
});
|
1161
|
+
}
|
1156
1162
|
updateCursor(uid, position) {
|
1157
1163
|
if (!get(this.attributes, ["cursors"])) {
|
1158
1164
|
this.context.safeUpdateAttributes(["cursors"], {});
|
@@ -1611,6 +1617,15 @@ class MainViewProxy {
|
|
1611
1617
|
this.mainViewIsAddListener = false;
|
1612
1618
|
this.store = this.manager.store;
|
1613
1619
|
this.sideEffectManager = new SideEffectManager();
|
1620
|
+
this.startListenWritableChange = () => {
|
1621
|
+
this.sideEffectManager.add(() => {
|
1622
|
+
return emitter.on("writableChange", (isWritable) => {
|
1623
|
+
if (isWritable) {
|
1624
|
+
this.ensureCameraAndSize();
|
1625
|
+
}
|
1626
|
+
});
|
1627
|
+
});
|
1628
|
+
};
|
1614
1629
|
this.addCameraReaction = () => {
|
1615
1630
|
var _a;
|
1616
1631
|
(_a = this.manager.refresher) == null ? void 0 : _a.add(Fields.MainViewCamera, this.cameraReaction);
|
@@ -1629,6 +1644,13 @@ class MainViewProxy {
|
|
1629
1644
|
this.moveCamera(this.mainViewCamera);
|
1630
1645
|
}
|
1631
1646
|
}, 30);
|
1647
|
+
this.onUpdateContainerSizeRatio = () => {
|
1648
|
+
const size2 = this.store.getMainViewSize();
|
1649
|
+
this.sizeChangeHandler(size2);
|
1650
|
+
if (size2.id === this.manager.uid) {
|
1651
|
+
this.setCameraAndSize();
|
1652
|
+
}
|
1653
|
+
};
|
1632
1654
|
this.onCameraUpdatedByDevice = (camera) => {
|
1633
1655
|
this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid }));
|
1634
1656
|
if (!isEqual(this.mainViewSize, __spreadProps(__spreadValues({}, this.mainView.size), { id: this.manager.uid }))) {
|
@@ -1649,19 +1671,25 @@ class MainViewProxy {
|
|
1649
1671
|
emitter.once("mainViewMounted").then(() => {
|
1650
1672
|
this.addMainViewListener();
|
1651
1673
|
this.start();
|
1652
|
-
|
1653
|
-
|
1654
|
-
this.setCameraAndSize();
|
1655
|
-
}
|
1674
|
+
this.ensureCameraAndSize();
|
1675
|
+
this.startListenWritableChange();
|
1656
1676
|
});
|
1657
1677
|
const playgroundSizeChangeListener = () => {
|
1658
1678
|
this.sizeChangeHandler(this.mainViewSize);
|
1659
1679
|
};
|
1660
1680
|
this.sideEffectManager.add(() => {
|
1661
|
-
emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
1662
|
-
|
1681
|
+
return emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
1682
|
+
});
|
1683
|
+
this.sideEffectManager.add(() => {
|
1684
|
+
return emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
|
1663
1685
|
});
|
1664
1686
|
}
|
1687
|
+
ensureCameraAndSize() {
|
1688
|
+
if (!this.mainViewCamera || !this.mainViewSize) {
|
1689
|
+
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
1690
|
+
this.setCameraAndSize();
|
1691
|
+
}
|
1692
|
+
}
|
1665
1693
|
get mainViewCamera() {
|
1666
1694
|
return this.store.getMainViewCamera();
|
1667
1695
|
}
|
@@ -1681,8 +1709,9 @@ class MainViewProxy {
|
|
1681
1709
|
this.started = true;
|
1682
1710
|
}
|
1683
1711
|
setCameraAndSize() {
|
1684
|
-
|
1685
|
-
|
1712
|
+
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
1713
|
+
const size2 = __spreadProps(__spreadValues({}, this.mainView.size), { id: this.manager.uid });
|
1714
|
+
this.store.setMainViewCameraAndSize(camera, size2);
|
1686
1715
|
}
|
1687
1716
|
get view() {
|
1688
1717
|
return this.mainView;
|
@@ -2050,6 +2079,7 @@ class AppManager {
|
|
2050
2079
|
} else {
|
2051
2080
|
this.mainView.disableCameraTransform = true;
|
2052
2081
|
}
|
2082
|
+
emitter.emit("writableChange", isWritable);
|
2053
2083
|
};
|
2054
2084
|
this.updateSceneIndex = () => {
|
2055
2085
|
const scenePath = this.store.getMainViewScenePath();
|
@@ -2534,6 +2564,9 @@ class ContainerResizeObserver {
|
|
2534
2564
|
this.emitter.emit("playgroundSizeChange", containerRect);
|
2535
2565
|
}
|
2536
2566
|
});
|
2567
|
+
this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
|
2568
|
+
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
2569
|
+
});
|
2537
2570
|
this.containerResizeObserver.observe(container);
|
2538
2571
|
}
|
2539
2572
|
updateSizer({ width, height }, sizer, wrapper) {
|
@@ -2552,6 +2585,10 @@ class ContainerResizeObserver {
|
|
2552
2585
|
disconnect() {
|
2553
2586
|
var _a;
|
2554
2587
|
(_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
|
2588
|
+
if (isFunction(this.disposer)) {
|
2589
|
+
this.disposer();
|
2590
|
+
this.disposer = void 0;
|
2591
|
+
}
|
2555
2592
|
}
|
2556
2593
|
}
|
2557
2594
|
var react = { exports: {} };
|
@@ -14847,14 +14884,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
14847
14884
|
const _WindowManager = class extends InvisiblePlugin {
|
14848
14885
|
constructor(context) {
|
14849
14886
|
super(context);
|
14850
|
-
this.version = "0.4.
|
14851
|
-
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/
|
14887
|
+
this.version = "0.4.25";
|
14888
|
+
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" } };
|
14852
14889
|
this.emitter = callbacks$1;
|
14853
14890
|
this.viewMode = ViewMode.Broadcaster;
|
14854
14891
|
this.isReplay = isPlayer(this.displayer);
|
14855
14892
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
14856
14893
|
_WindowManager.displayer = context.displayer;
|
14857
|
-
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/
|
14894
|
+
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" } };
|
14858
14895
|
}
|
14859
14896
|
static async mount(params) {
|
14860
14897
|
const room = params.room;
|
@@ -15453,6 +15490,14 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15453
15490
|
}
|
15454
15491
|
(_c = (_b = this.appManager) == null ? void 0 : _b.refresher) == null ? void 0 : _c.refresh();
|
15455
15492
|
}
|
15493
|
+
setContainerSizeRatio(ratio) {
|
15494
|
+
if (!isNumber(ratio)) {
|
15495
|
+
throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${ratio}`);
|
15496
|
+
}
|
15497
|
+
_WindowManager.containerSizeRatio = ratio;
|
15498
|
+
this.containerSizeRatio = ratio;
|
15499
|
+
emitter.emit("containerSizeRatioUpdate", ratio);
|
15500
|
+
}
|
15456
15501
|
isDynamicPPT(scenes) {
|
15457
15502
|
var _a, _b;
|
15458
15503
|
const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;
|