@netless/window-manager 0.4.21 → 0.4.24
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 +12 -0
- package/dist/AppListener.d.ts +1 -0
- package/dist/AttributesDelegate.d.ts +9 -6
- package/dist/InternalEmitter.d.ts +1 -0
- package/dist/View/MainView.d.ts +3 -0
- package/dist/constants.d.ts +2 -1
- package/dist/index.cjs.js +47 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +44 -15
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/AppListener.ts +8 -0
- package/src/AppManager.ts +12 -8
- package/src/AttributesDelegate.ts +14 -2
- package/src/InternalEmitter.ts +1 -0
- package/src/View/MainView.ts +31 -13
- package/src/constants.ts +1 -0
- package/vite.config.js +1 -1
package/dist/index.es.js
CHANGED
|
@@ -42,6 +42,7 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
|
42
42
|
Events2["CursorMove"] = "CursorMove";
|
|
43
43
|
Events2["RootDirRemoved"] = "RootDirRemoved";
|
|
44
44
|
Events2["Refresh"] = "Refresh";
|
|
45
|
+
Events2["InitMainViewCamera"] = "InitMainViewCamera";
|
|
45
46
|
return Events2;
|
|
46
47
|
})(Events || {});
|
|
47
48
|
const MagixEventName = "__WindowManger";
|
|
@@ -470,6 +471,10 @@ class AppListeners {
|
|
|
470
471
|
this.refreshHandler();
|
|
471
472
|
break;
|
|
472
473
|
}
|
|
474
|
+
case Events.InitMainViewCamera: {
|
|
475
|
+
this.initMainViewCameraHandler();
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
473
478
|
}
|
|
474
479
|
}
|
|
475
480
|
};
|
|
@@ -508,6 +513,9 @@ class AppListeners {
|
|
|
508
513
|
this.refreshHandler = () => {
|
|
509
514
|
this.manager.windowManger._refresh();
|
|
510
515
|
};
|
|
516
|
+
this.initMainViewCameraHandler = () => {
|
|
517
|
+
this.manager.mainViewProxy.addCameraReaction();
|
|
518
|
+
};
|
|
511
519
|
}
|
|
512
520
|
get boxManager() {
|
|
513
521
|
return this.manager.boxManager;
|
|
@@ -1145,6 +1153,12 @@ class AttributesDelegate {
|
|
|
1145
1153
|
setMainViewSize(size2) {
|
|
1146
1154
|
this.context.safeSetAttributes({ ["mainViewSize"]: __spreadValues({}, size2) });
|
|
1147
1155
|
}
|
|
1156
|
+
setMainViewCameraAndSize(camera, size2) {
|
|
1157
|
+
this.context.safeSetAttributes({
|
|
1158
|
+
["mainViewCamera"]: __spreadValues({}, camera),
|
|
1159
|
+
["mainViewSize"]: __spreadValues({}, size2)
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1148
1162
|
updateCursor(uid, position) {
|
|
1149
1163
|
if (!get(this.attributes, ["cursors"])) {
|
|
1150
1164
|
this.context.safeUpdateAttributes(["cursors"], {});
|
|
@@ -1603,15 +1617,26 @@ class MainViewProxy {
|
|
|
1603
1617
|
this.mainViewIsAddListener = false;
|
|
1604
1618
|
this.store = this.manager.store;
|
|
1605
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
|
+
};
|
|
1629
|
+
this.addCameraReaction = () => {
|
|
1630
|
+
var _a;
|
|
1631
|
+
(_a = this.manager.refresher) == null ? void 0 : _a.add(Fields.MainViewCamera, this.cameraReaction);
|
|
1632
|
+
};
|
|
1606
1633
|
this.cameraReaction = () => {
|
|
1607
1634
|
return reaction(() => this.mainViewCamera, (camera) => {
|
|
1608
1635
|
if (camera && camera.id !== this.manager.uid) {
|
|
1609
1636
|
this.moveCameraToContian(this.mainViewSize);
|
|
1610
1637
|
this.moveCamera(camera);
|
|
1611
1638
|
}
|
|
1612
|
-
}, {
|
|
1613
|
-
fireImmediately: true
|
|
1614
|
-
});
|
|
1639
|
+
}, { fireImmediately: true });
|
|
1615
1640
|
};
|
|
1616
1641
|
this.sizeChangeHandler = debounce((size2) => {
|
|
1617
1642
|
if (size2) {
|
|
@@ -1637,13 +1662,10 @@ class MainViewProxy {
|
|
|
1637
1662
|
this.mainView = this.createMainView();
|
|
1638
1663
|
this.moveCameraSizeByAttributes();
|
|
1639
1664
|
emitter.once("mainViewMounted").then(() => {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
this.setCameraAndSize();
|
|
1645
|
-
}
|
|
1646
|
-
}, 200);
|
|
1665
|
+
this.addMainViewListener();
|
|
1666
|
+
this.start();
|
|
1667
|
+
this.ensureCameraAndSize();
|
|
1668
|
+
this.startListenWritableChange();
|
|
1647
1669
|
});
|
|
1648
1670
|
const playgroundSizeChangeListener = () => {
|
|
1649
1671
|
this.sizeChangeHandler(this.mainViewSize);
|
|
@@ -1653,6 +1675,12 @@ class MainViewProxy {
|
|
|
1653
1675
|
return () => emitter.off("playgroundSizeChange", playgroundSizeChangeListener);
|
|
1654
1676
|
});
|
|
1655
1677
|
}
|
|
1678
|
+
ensureCameraAndSize() {
|
|
1679
|
+
if (!this.mainViewCamera || !this.mainViewSize) {
|
|
1680
|
+
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
|
1681
|
+
this.setCameraAndSize();
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1656
1684
|
get mainViewCamera() {
|
|
1657
1685
|
return this.store.getMainViewCamera();
|
|
1658
1686
|
}
|
|
@@ -1664,17 +1692,17 @@ class MainViewProxy {
|
|
|
1664
1692
|
this.moveCamera(this.mainViewCamera);
|
|
1665
1693
|
}
|
|
1666
1694
|
start() {
|
|
1667
|
-
var _a;
|
|
1668
1695
|
if (this.started)
|
|
1669
1696
|
return;
|
|
1670
1697
|
this.sizeChangeHandler(this.mainViewSize);
|
|
1671
1698
|
this.addCameraListener();
|
|
1672
|
-
|
|
1699
|
+
this.addCameraReaction();
|
|
1673
1700
|
this.started = true;
|
|
1674
1701
|
}
|
|
1675
1702
|
setCameraAndSize() {
|
|
1676
|
-
|
|
1677
|
-
|
|
1703
|
+
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
|
1704
|
+
const size2 = __spreadProps(__spreadValues({}, this.mainView.size), { id: this.manager.uid });
|
|
1705
|
+
this.store.setMainViewCameraAndSize(camera, size2);
|
|
1678
1706
|
}
|
|
1679
1707
|
get view() {
|
|
1680
1708
|
return this.mainView;
|
|
@@ -2042,6 +2070,7 @@ class AppManager {
|
|
|
2042
2070
|
} else {
|
|
2043
2071
|
this.mainView.disableCameraTransform = true;
|
|
2044
2072
|
}
|
|
2073
|
+
emitter.emit("writableChange", isWritable);
|
|
2045
2074
|
};
|
|
2046
2075
|
this.updateSceneIndex = () => {
|
|
2047
2076
|
const scenePath = this.store.getMainViewScenePath();
|
|
@@ -14839,7 +14868,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
|
14839
14868
|
const _WindowManager = class extends InvisiblePlugin {
|
|
14840
14869
|
constructor(context) {
|
|
14841
14870
|
super(context);
|
|
14842
|
-
this.version = "0.4.
|
|
14871
|
+
this.version = "0.4.24";
|
|
14843
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/jest": "^27.4.1", "@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", "jest": "^27.5.1", "jest-canvas-mock": "^2.3.1", "jest-fetch-mock": "^3.0.3", "jest-transform-stub": "^2.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", "svelte-jester": "^2.3.2", "ts-jest": "^27.1.4", "typescript": "^4.5.5", "vite": "^2.5.3", "white-web-sdk": "2.16.10" } };
|
|
14844
14873
|
this.emitter = callbacks$1;
|
|
14845
14874
|
this.viewMode = ViewMode.Broadcaster;
|