@netless/window-manager 1.0.0-canary.21 → 1.0.0-canary.22
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/App/AppContext.d.ts +5 -1
- package/dist/App/AppProxy.d.ts +2 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.es.js +105 -144
- package/dist/index.umd.js +12 -12
- package/package.json +1 -1
- package/src/App/AppContext.ts +14 -3
- package/src/App/AppProxy.ts +81 -140
- package/src/ReconnectRefresher.ts +5 -1
- package/src/View/ViewSync.ts +3 -2
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, isNumber, throttle, delay, omitBy, isUndefined, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
22
|
+
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isBoolean, isNumber, throttle, delay, omitBy, isUndefined, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
23
23
|
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, ViewMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin } from "white-web-sdk";
|
24
24
|
import { v4 } from "uuid";
|
25
25
|
import { genUID, SideEffectManager } from "side-effect-manager";
|
@@ -1032,7 +1032,7 @@ class AppContext {
|
|
1032
1032
|
return appAttr == null ? void 0 : appAttr.options["scenes"];
|
1033
1033
|
}
|
1034
1034
|
};
|
1035
|
-
this.createWhiteBoardView = (
|
1035
|
+
this.createWhiteBoardView = (params) => {
|
1036
1036
|
var _a;
|
1037
1037
|
if (this.whiteBoardView) {
|
1038
1038
|
return this.whiteBoardView;
|
@@ -1041,6 +1041,11 @@ class AppContext {
|
|
1041
1041
|
if (!view) {
|
1042
1042
|
view = this.appProxy.createAppDir();
|
1043
1043
|
}
|
1044
|
+
if (params) {
|
1045
|
+
if (isBoolean(params.syncCamera)) {
|
1046
|
+
this.appProxy.syncCamera$.setValue(params.syncCamera);
|
1047
|
+
}
|
1048
|
+
}
|
1044
1049
|
const viewWrapper = document.createElement("div");
|
1045
1050
|
this._viewWrapper = viewWrapper;
|
1046
1051
|
viewWrapper.className = "window-manager-view-wrapper";
|
@@ -1048,7 +1053,7 @@ class AppContext {
|
|
1048
1053
|
view.divElement = viewWrapper;
|
1049
1054
|
this.appProxy.fireMemberStateChange();
|
1050
1055
|
if (this.isAddApp) {
|
1051
|
-
this.ensurePageSize(
|
1056
|
+
this.ensurePageSize(params == null ? void 0 : params.size);
|
1052
1057
|
}
|
1053
1058
|
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1054
1059
|
this.appProxy.sideEffectManager.add(() => {
|
@@ -1056,6 +1061,7 @@ class AppContext {
|
|
1056
1061
|
this.whiteBoardView = void 0;
|
1057
1062
|
};
|
1058
1063
|
});
|
1064
|
+
this.appProxy.whiteBoardViewCreated$.setValue(true);
|
1059
1065
|
return this.whiteBoardView;
|
1060
1066
|
};
|
1061
1067
|
this.ensurePageSize = (size2) => {
|
@@ -1289,7 +1295,9 @@ class ViewSync {
|
|
1289
1295
|
}, "view");
|
1290
1296
|
};
|
1291
1297
|
this.onCameraUpdatedByDevice = (camera) => {
|
1292
|
-
|
1298
|
+
if (!camera)
|
1299
|
+
return;
|
1300
|
+
this.synchronizer.onLocalCameraUpdate(__spreadProps(__spreadValues({}, camera), { id: this.context.uid }));
|
1293
1301
|
const stage = this.context.stageRect$.value;
|
1294
1302
|
if (stage) {
|
1295
1303
|
const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
|
@@ -1560,6 +1568,8 @@ class AppProxy {
|
|
1560
1568
|
this.size$ = this.valManager.attach(new Val(void 0));
|
1561
1569
|
this.box$ = this.valManager.attach(new Val(void 0));
|
1562
1570
|
this.view$ = this.valManager.attach(new Val(void 0));
|
1571
|
+
this.syncCamera$ = this.valManager.attach(new Val(true));
|
1572
|
+
this.whiteBoardViewCreated$ = this.valManager.attach(new Val(false));
|
1563
1573
|
this.fireMemberStateChange = () => {
|
1564
1574
|
if (this.manager.room) {
|
1565
1575
|
this.onMemberStateChange(this.manager.room.state.memberState);
|
@@ -1613,34 +1623,36 @@ class AppProxy {
|
|
1613
1623
|
return Object.assign(payload, state);
|
1614
1624
|
};
|
1615
1625
|
this.appAttributesUpdateListener = (appId2) => {
|
1616
|
-
this.
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
(
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
this.
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1626
|
+
this.sideEffectManager.add(() => [
|
1627
|
+
this.manager.refresher.add(appId2, () => {
|
1628
|
+
return autorun(() => {
|
1629
|
+
const attrs = this.manager.attributes[appId2];
|
1630
|
+
if (attrs) {
|
1631
|
+
this.appEmitter.emit("attributesUpdate", attrs);
|
1632
|
+
}
|
1633
|
+
});
|
1634
|
+
}),
|
1635
|
+
this.manager.refresher.add(this.stateKey, () => {
|
1636
|
+
return autorun(() => {
|
1637
|
+
var _a2, _b, _c;
|
1638
|
+
const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
|
1639
|
+
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
|
1640
|
+
(_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
|
1641
|
+
}
|
1642
|
+
});
|
1643
|
+
}),
|
1644
|
+
this.manager.refresher.add(`${appId2}-fullPath`, () => {
|
1645
|
+
return autorun(() => {
|
1646
|
+
var _a2;
|
1647
|
+
const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
|
1648
|
+
this.setFocusScenePathHandler(fullPath);
|
1649
|
+
if (this.fullPath$.value !== fullPath) {
|
1650
|
+
this.notifyPageStateChange();
|
1651
|
+
this.fullPath$.setValue(fullPath);
|
1652
|
+
}
|
1653
|
+
});
|
1654
|
+
})
|
1655
|
+
]);
|
1644
1656
|
};
|
1645
1657
|
this.setFocusScenePathHandler = debounce((fullPath) => {
|
1646
1658
|
var _a2;
|
@@ -1734,101 +1746,63 @@ class AppProxy {
|
|
1734
1746
|
this.size$.setValue(toJS(this.appAttributes.size));
|
1735
1747
|
this.addCameraReaction();
|
1736
1748
|
this.addSizeReaction();
|
1737
|
-
this.sideEffectManager.add(() => combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1738
|
-
if (box && view) {
|
1739
|
-
if (!this.camera$.value) {
|
1740
|
-
this.storeCamera({
|
1741
|
-
centerX: null,
|
1742
|
-
centerY: null,
|
1743
|
-
scale: 1,
|
1744
|
-
id: this.uid
|
1745
|
-
});
|
1746
|
-
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1747
|
-
}
|
1748
|
-
if (!this.size$.value && box.contentStageRect) {
|
1749
|
-
const initialRect = this.computedInitialRect(box.contentStageRect);
|
1750
|
-
const width = (initialRect == null ? void 0 : initialRect.width) || box.contentStageRect.width;
|
1751
|
-
const height = (initialRect == null ? void 0 : initialRect.height) || box.contentStageRect.height;
|
1752
|
-
this.storeSize({
|
1753
|
-
id: this.uid,
|
1754
|
-
width,
|
1755
|
-
height
|
1756
|
-
});
|
1757
|
-
this.size$.setValue(toJS(this.appAttributes.size));
|
1758
|
-
}
|
1759
|
-
this.viewSync = new ViewSync({
|
1760
|
-
uid: this.uid,
|
1761
|
-
view$: this.view$,
|
1762
|
-
camera$: this.camera$,
|
1763
|
-
size$: this.size$,
|
1764
|
-
stageRect$: box._contentStageRect$,
|
1765
|
-
storeCamera: this.storeCamera,
|
1766
|
-
storeSize: this.storeSize
|
1767
|
-
});
|
1768
|
-
this.sideEffectManager.add(() => () => {
|
1769
|
-
var _a2;
|
1770
|
-
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1771
|
-
});
|
1772
|
-
}
|
1773
|
-
}));
|
1774
1749
|
this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
|
1775
|
-
this.
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
createValSync(() => {
|
1784
|
-
var _a2;
|
1785
|
-
return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.ratio;
|
1786
|
-
}, box._ratio$),
|
1787
|
-
createValSync(() => {
|
1788
|
-
var _a2;
|
1789
|
-
return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.stageRatio;
|
1790
|
-
}, box._stageRatio$),
|
1791
|
-
createValSync(() => {
|
1792
|
-
var _a2;
|
1793
|
-
return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.draggable;
|
1794
|
-
}, box._draggable$),
|
1795
|
-
createValSync(() => {
|
1796
|
-
var _a2;
|
1797
|
-
return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.resizable;
|
1798
|
-
}, box._resizable$),
|
1799
|
-
box._visible$.reaction((visible, skipUpdate) => {
|
1800
|
-
if (skipUpdate) {
|
1801
|
-
return;
|
1802
|
-
}
|
1803
|
-
this.store.updateAppState(this.id, AppAttributes.Visible, visible);
|
1804
|
-
}),
|
1805
|
-
box._ratio$.reaction((ratio, skipUpdate) => {
|
1806
|
-
console.log("ratio change", ratio, skipUpdate);
|
1807
|
-
if (skipUpdate) {
|
1808
|
-
return;
|
1809
|
-
}
|
1810
|
-
this.store.updateAppState(this.id, AppAttributes.Ratio, ratio);
|
1811
|
-
}),
|
1812
|
-
box._stageRatio$.reaction((stageRatio, skipUpdate) => {
|
1813
|
-
if (skipUpdate) {
|
1814
|
-
return;
|
1815
|
-
}
|
1816
|
-
this.store.updateAppState(this.id, AppAttributes.StageRatio, stageRatio);
|
1817
|
-
}),
|
1818
|
-
box._draggable$.reaction((draggable, skipUpdate) => {
|
1819
|
-
if (skipUpdate) {
|
1820
|
-
return;
|
1750
|
+
this.sideEffectManager.add(() => [
|
1751
|
+
this.syncCamera$.reaction((syncCamera) => {
|
1752
|
+
if (!syncCamera) {
|
1753
|
+
if (this.viewSync) {
|
1754
|
+
this.viewSync.destroy();
|
1755
|
+
this.viewSync = void 0;
|
1756
|
+
this.sideEffectManager.flush("camera");
|
1757
|
+
this.sideEffectManager.flush("size");
|
1821
1758
|
}
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1759
|
+
}
|
1760
|
+
}),
|
1761
|
+
this.whiteBoardViewCreated$.reaction((created) => {
|
1762
|
+
if (created && this.box) {
|
1763
|
+
if (!this.syncCamera$.value)
|
1826
1764
|
return;
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1765
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1766
|
+
if (box && view) {
|
1767
|
+
if (!this.camera$.value) {
|
1768
|
+
this.storeCamera({
|
1769
|
+
centerX: null,
|
1770
|
+
centerY: null,
|
1771
|
+
scale: 1,
|
1772
|
+
id: this.uid
|
1773
|
+
});
|
1774
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1775
|
+
}
|
1776
|
+
if (!this.size$.value && box.contentStageRect) {
|
1777
|
+
const initialRect = this.computedInitialRect(box.contentStageRect);
|
1778
|
+
const width = (initialRect == null ? void 0 : initialRect.width) || box.contentStageRect.width;
|
1779
|
+
const height = (initialRect == null ? void 0 : initialRect.height) || box.contentStageRect.height;
|
1780
|
+
this.storeSize({
|
1781
|
+
id: this.uid,
|
1782
|
+
width,
|
1783
|
+
height
|
1784
|
+
});
|
1785
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1786
|
+
}
|
1787
|
+
this.viewSync = new ViewSync({
|
1788
|
+
uid: this.uid,
|
1789
|
+
view$: this.view$,
|
1790
|
+
camera$: this.camera$,
|
1791
|
+
size$: this.size$,
|
1792
|
+
stageRect$: box._contentStageRect$,
|
1793
|
+
storeCamera: this.storeCamera,
|
1794
|
+
storeSize: this.storeSize
|
1795
|
+
});
|
1796
|
+
this.sideEffectManager.add(() => () => {
|
1797
|
+
var _a2;
|
1798
|
+
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1799
|
+
});
|
1800
|
+
this.whiteBoardViewCreated$.destroy();
|
1801
|
+
}
|
1802
|
+
});
|
1803
|
+
}
|
1804
|
+
})
|
1805
|
+
]);
|
1832
1806
|
}
|
1833
1807
|
createAppDir() {
|
1834
1808
|
const scenePath = this.scenePath || this.appScenePath;
|
@@ -1946,11 +1920,6 @@ class AppProxy {
|
|
1946
1920
|
this.box$.setValue(box);
|
1947
1921
|
if (this.isAddApp && this.box) {
|
1948
1922
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1949
|
-
this.store.updateAppState(appId, AppAttributes.Visible, this.box.visible);
|
1950
|
-
this.store.updateAppState(appId, AppAttributes.Ratio, this.box.ratio);
|
1951
|
-
this.store.updateAppState(appId, AppAttributes.StageRatio, this.box.stageRatio);
|
1952
|
-
this.store.updateAppState(appId, AppAttributes.Draggable, this.box.draggable);
|
1953
|
-
this.store.updateAppState(appId, AppAttributes.Resizable, this.box.resizable);
|
1954
1923
|
this.boxManager.focusBox({ appId }, false);
|
1955
1924
|
}
|
1956
1925
|
} catch (error) {
|
@@ -2145,24 +2114,12 @@ class AppProxy {
|
|
2145
2114
|
this.appProxies.delete(this.id);
|
2146
2115
|
this.viewManager.destroyView(this.id);
|
2147
2116
|
this.manager.appStatus.delete(this.id);
|
2148
|
-
this.manager.refresher.remove(this.id);
|
2149
|
-
this.manager.refresher.remove(this.stateKey);
|
2150
|
-
this.manager.refresher.remove(`${this.id}-fullPath`);
|
2151
|
-
this.manager.refresher.remove(`${this.id}-camera`);
|
2152
|
-
this.manager.refresher.remove(`${this.id}-size`);
|
2153
2117
|
this.valManager.destroy();
|
2154
2118
|
}
|
2155
2119
|
close() {
|
2156
2120
|
return this.destroy(true, true, false);
|
2157
2121
|
}
|
2158
2122
|
}
|
2159
|
-
const createValSync = (expr, Val2) => {
|
2160
|
-
return reaction(expr, (val) => {
|
2161
|
-
if (Val2.value !== val && val !== void 0) {
|
2162
|
-
Val2.setValue(val, true);
|
2163
|
-
}
|
2164
|
-
}, { fireImmediately: true });
|
2165
|
-
};
|
2166
2123
|
class ViewManager {
|
2167
2124
|
constructor(displayer) {
|
2168
2125
|
this.displayer = displayer;
|
@@ -5998,12 +5955,16 @@ class ReconnectRefresher {
|
|
5998
5955
|
this.reactors = /* @__PURE__ */ new Map();
|
5999
5956
|
this.disposers = /* @__PURE__ */ new Map();
|
6000
5957
|
this.onPhaseChanged = (phase) => {
|
6001
|
-
var _a;
|
5958
|
+
var _a, _b;
|
6002
5959
|
if (phase === RoomPhase.Reconnecting) {
|
6003
5960
|
this.ctx.emitter.emit("startReconnect");
|
6004
5961
|
}
|
6005
5962
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
6006
|
-
(_a = this.room) == null ? void 0 : _a.
|
5963
|
+
if ((_a = this.room) == null ? void 0 : _a.isWritable) {
|
5964
|
+
(_b = this.room) == null ? void 0 : _b.dispatchMagixEvent(EnsureReconnectEvent, {});
|
5965
|
+
} else {
|
5966
|
+
this.onReconnected();
|
5967
|
+
}
|
6007
5968
|
}
|
6008
5969
|
this.phase = phase;
|
6009
5970
|
};
|
@@ -15686,7 +15647,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15686
15647
|
const _WindowManager = class extends InvisiblePlugin {
|
15687
15648
|
constructor(context) {
|
15688
15649
|
super(context);
|
15689
|
-
this.version = "1.0.0-canary.
|
15650
|
+
this.version = "1.0.0-canary.22";
|
15690
15651
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.3.0", "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", "@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", "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.10" } };
|
15691
15652
|
this.emitter = callbacks$1;
|
15692
15653
|
this.viewMode = ViewMode.Broadcaster;
|