@netless/window-manager 1.0.0-canary.19 → 1.0.0-canary.21
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/AppProxy.d.ts +3 -2
- package/dist/App/index.d.ts +1 -0
- package/dist/App/type.d.ts +21 -0
- package/dist/BoxManager.d.ts +4 -3
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/InternalEmitter.d.ts +1 -2
- package/dist/constants.d.ts +6 -2
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +119 -54
- package/dist/index.umd.js +12 -12
- package/package.json +1 -1
- package/src/App/AppProxy.ts +81 -19
- package/src/App/index.ts +1 -0
- package/src/App/type.ts +22 -0
- package/src/AppManager.ts +5 -1
- package/src/BoxManager.ts +8 -7
- package/src/Cursor/index.ts +0 -2
- package/src/InternalEmitter.ts +1 -2
- package/src/Utils/Reactive.ts +27 -26
- package/src/View/ViewSync.ts +7 -13
- package/src/constants.ts +5 -1
- package/src/index.ts +5 -0
package/dist/index.d.ts
CHANGED
@@ -70,6 +70,11 @@ export declare type AppInitState = {
|
|
70
70
|
sceneIndex?: number;
|
71
71
|
boxState?: TeleBoxState;
|
72
72
|
zIndex?: number;
|
73
|
+
visible?: boolean;
|
74
|
+
stageRatio?: number;
|
75
|
+
resizable?: boolean;
|
76
|
+
draggable?: boolean;
|
77
|
+
ratio?: number;
|
73
78
|
};
|
74
79
|
export declare type CursorMovePayload = {
|
75
80
|
uid: string;
|
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, 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, 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";
|
@@ -33,7 +33,6 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
33
33
|
Events2["AppBoxStateChange"] = "AppBoxStateChange";
|
34
34
|
Events2["GetAttributes"] = "GetAttributes";
|
35
35
|
Events2["UpdateWindowManagerWrapper"] = "UpdateWindowManagerWrapper";
|
36
|
-
Events2["InitReplay"] = "InitReplay";
|
37
36
|
Events2["WindowCreated"] = "WindowCreated";
|
38
37
|
Events2["SetMainViewScenePath"] = "SetMainViewScenePath";
|
39
38
|
Events2["SetMainViewSceneIndex"] = "SetMainViewSceneIndex";
|
@@ -54,6 +53,11 @@ var AppAttributes = /* @__PURE__ */ ((AppAttributes2) => {
|
|
54
53
|
AppAttributes2["Position"] = "position";
|
55
54
|
AppAttributes2["SceneIndex"] = "SceneIndex";
|
56
55
|
AppAttributes2["ZIndex"] = "zIndex";
|
56
|
+
AppAttributes2["Visible"] = "visible";
|
57
|
+
AppAttributes2["Ratio"] = "ratio";
|
58
|
+
AppAttributes2["StageRatio"] = "stageRatio";
|
59
|
+
AppAttributes2["Draggable"] = "draggable";
|
60
|
+
AppAttributes2["Resizable"] = "resizable";
|
57
61
|
return AppAttributes2;
|
58
62
|
})(AppAttributes || {});
|
59
63
|
var AppEvents = /* @__PURE__ */ ((AppEvents2) => {
|
@@ -1285,7 +1289,7 @@ class ViewSync {
|
|
1285
1289
|
}, "view");
|
1286
1290
|
};
|
1287
1291
|
this.onCameraUpdatedByDevice = (camera) => {
|
1288
|
-
this.synchronizer.onLocalCameraUpdate(Object.assign(camera, { id: this.context.uid }));
|
1292
|
+
this.synchronizer.onLocalCameraUpdate(Object.assign(toJS(camera), { id: this.context.uid }));
|
1289
1293
|
const stage = this.context.stageRect$.value;
|
1290
1294
|
if (stage) {
|
1291
1295
|
const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
|
@@ -1304,33 +1308,35 @@ class ViewSync {
|
|
1304
1308
|
}
|
1305
1309
|
});
|
1306
1310
|
this.bindView(this.context.view$.value);
|
1307
|
-
this.sem.add(() =>
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1311
|
+
this.sem.add(() => [
|
1312
|
+
this.context.view$.subscribe((view) => {
|
1313
|
+
const currentCamera = this.context.camera$.value;
|
1314
|
+
if (currentCamera && this.context.size$.value) {
|
1315
|
+
view == null ? void 0 : view.moveCamera({
|
1316
|
+
scale: 1,
|
1317
|
+
animationMode: AnimationMode.Immediately
|
1318
|
+
});
|
1319
|
+
this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
|
1320
|
+
}
|
1321
|
+
this.bindView(view);
|
1322
|
+
}),
|
1323
|
+
this.context.camera$.subscribe((camera, skipUpdate) => {
|
1324
|
+
const size2 = this.context.size$.value;
|
1325
|
+
if (camera && size2 && !skipUpdate) {
|
1326
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1327
|
+
}
|
1328
|
+
}),
|
1329
|
+
this.context.size$.subscribe((size2) => {
|
1330
|
+
if (size2) {
|
1331
|
+
this.synchronizer.onRemoteSizeUpdate(size2);
|
1332
|
+
}
|
1333
|
+
}),
|
1334
|
+
this.context.stageRect$.reaction((rect) => {
|
1335
|
+
if (rect) {
|
1336
|
+
this.synchronizer.setRect(rect);
|
1337
|
+
}
|
1338
|
+
})
|
1339
|
+
]);
|
1334
1340
|
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
1335
1341
|
camera$size$.reaction(([camera, size2]) => {
|
1336
1342
|
if (camera && size2) {
|
@@ -1596,27 +1602,15 @@ class AppProxy {
|
|
1596
1602
|
const attrs = this.store.getAppState(id2);
|
1597
1603
|
if (!attrs)
|
1598
1604
|
return;
|
1599
|
-
const position = attrs == null ? void 0 : attrs[AppAttributes.Position];
|
1600
1605
|
const focus = this.store.focus;
|
1601
|
-
const size2 = attrs == null ? void 0 : attrs[AppAttributes.Size];
|
1602
|
-
const sceneIndex = attrs == null ? void 0 : attrs[AppAttributes.SceneIndex];
|
1603
1606
|
const maximized = (_a2 = this.attributes) == null ? void 0 : _a2["maximized"];
|
1604
1607
|
const minimized = (_b = this.attributes) == null ? void 0 : _b["minimized"];
|
1605
|
-
|
1606
|
-
|
1607
|
-
if (position) {
|
1608
|
-
payload = __spreadProps(__spreadValues({}, payload), { id: id2, x: position.x, y: position.y });
|
1609
|
-
}
|
1608
|
+
let payload = { maximized, minimized, id: id2 };
|
1609
|
+
const state = omitBy(attrs, isUndefined);
|
1610
1610
|
if (focus === id2) {
|
1611
1611
|
payload = __spreadProps(__spreadValues({}, payload), { focus: true });
|
1612
1612
|
}
|
1613
|
-
|
1614
|
-
payload = __spreadProps(__spreadValues({}, payload), { width: size2.width, height: size2.height });
|
1615
|
-
}
|
1616
|
-
if (sceneIndex) {
|
1617
|
-
payload = __spreadProps(__spreadValues({}, payload), { sceneIndex });
|
1618
|
-
}
|
1619
|
-
return payload;
|
1613
|
+
return Object.assign(payload, state);
|
1620
1614
|
};
|
1621
1615
|
this.appAttributesUpdateListener = (appId2) => {
|
1622
1616
|
this.manager.refresher.add(appId2, () => {
|
@@ -1778,6 +1772,63 @@ class AppProxy {
|
|
1778
1772
|
}
|
1779
1773
|
}));
|
1780
1774
|
this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
|
1775
|
+
this.box$.subscribe((box) => {
|
1776
|
+
if (!box)
|
1777
|
+
return;
|
1778
|
+
this.sideEffectManager.add(() => [
|
1779
|
+
createValSync(() => {
|
1780
|
+
var _a2;
|
1781
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.visible;
|
1782
|
+
}, box._visible$),
|
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;
|
1821
|
+
}
|
1822
|
+
this.store.updateAppState(this.id, AppAttributes.Draggable, draggable);
|
1823
|
+
}),
|
1824
|
+
box._resizable$.reaction((resizable, skipUpdate) => {
|
1825
|
+
if (skipUpdate) {
|
1826
|
+
return;
|
1827
|
+
}
|
1828
|
+
this.store.updateAppState(this.id, AppAttributes.Resizable, resizable);
|
1829
|
+
})
|
1830
|
+
]);
|
1831
|
+
});
|
1781
1832
|
}
|
1782
1833
|
createAppDir() {
|
1783
1834
|
const scenePath = this.scenePath || this.appScenePath;
|
@@ -1895,6 +1946,11 @@ class AppProxy {
|
|
1895
1946
|
this.box$.setValue(box);
|
1896
1947
|
if (this.isAddApp && this.box) {
|
1897
1948
|
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);
|
1898
1954
|
this.boxManager.focusBox({ appId }, false);
|
1899
1955
|
}
|
1900
1956
|
} catch (error) {
|
@@ -2100,6 +2156,13 @@ class AppProxy {
|
|
2100
2156
|
return this.destroy(true, true, false);
|
2101
2157
|
}
|
2102
2158
|
}
|
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
|
+
};
|
2103
2166
|
class ViewManager {
|
2104
2167
|
constructor(displayer) {
|
2105
2168
|
this.displayer = displayer;
|
@@ -2938,7 +3001,9 @@ class AppManager {
|
|
2938
3001
|
bindMainView(divElement, disableCameraTransform) {
|
2939
3002
|
const mainView = this.mainViewProxy.view;
|
2940
3003
|
mainView.disableCameraTransform = disableCameraTransform;
|
2941
|
-
|
3004
|
+
wait(30).then(() => {
|
3005
|
+
mainView.divElement = divElement;
|
3006
|
+
});
|
2942
3007
|
if (!mainView.focusScenePath) {
|
2943
3008
|
this.setMainViewFocusPath();
|
2944
3009
|
}
|
@@ -4911,15 +4976,16 @@ class BoxManager {
|
|
4911
4976
|
return this.teleBoxManager.topBox;
|
4912
4977
|
}
|
4913
4978
|
updateBoxState(state) {
|
4979
|
+
var _a, _b, _c, _d;
|
4914
4980
|
if (!state)
|
4915
4981
|
return;
|
4916
4982
|
const box = this.getBox(state.id);
|
4917
4983
|
if (box) {
|
4918
4984
|
this.teleBoxManager.update(box.id, {
|
4919
|
-
x: state.x,
|
4920
|
-
y: state.y,
|
4921
|
-
width: state.width || 0.5,
|
4922
|
-
height: state.height || 0.5,
|
4985
|
+
x: (_a = state.position) == null ? void 0 : _a.x,
|
4986
|
+
y: (_b = state.position) == null ? void 0 : _b.y,
|
4987
|
+
width: ((_c = state.size) == null ? void 0 : _c.width) || 0.5,
|
4988
|
+
height: ((_d = state.size) == null ? void 0 : _d.height) || 0.5,
|
4923
4989
|
zIndex: state.zIndex
|
4924
4990
|
}, true);
|
4925
4991
|
setTimeout(() => {
|
@@ -5877,9 +5943,8 @@ class CursorManager {
|
|
5877
5943
|
}
|
5878
5944
|
}
|
5879
5945
|
updateContainerRect() {
|
5880
|
-
var _a
|
5881
|
-
this.
|
5882
|
-
this.wrapperRect = (_b = WindowManager.playground) == null ? void 0 : _b.getBoundingClientRect();
|
5946
|
+
var _a;
|
5947
|
+
this.wrapperRect = (_a = WindowManager.playground) == null ? void 0 : _a.getBoundingClientRect();
|
5883
5948
|
}
|
5884
5949
|
deleteCursor(uid) {
|
5885
5950
|
this.store.cleanCursor(uid);
|
@@ -15621,7 +15686,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15621
15686
|
const _WindowManager = class extends InvisiblePlugin {
|
15622
15687
|
constructor(context) {
|
15623
15688
|
super(context);
|
15624
|
-
this.version = "1.0.0-canary.
|
15689
|
+
this.version = "1.0.0-canary.21";
|
15625
15690
|
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" } };
|
15626
15691
|
this.emitter = callbacks$1;
|
15627
15692
|
this.viewMode = ViewMode.Broadcaster;
|