@netless/window-manager 0.4.19 → 0.4.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/CHANGELOG.md +11 -0
- package/dist/AppListener.d.ts +2 -0
- package/dist/AppManager.d.ts +4 -1
- package/dist/ReconnectRefresher.d.ts +2 -0
- package/dist/View/MainView.d.ts +1 -0
- package/dist/constants.d.ts +3 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +83 -32
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/typings.d.ts +1 -0
- package/docs/api.md +8 -0
- package/package.json +1 -1
- package/src/AppListener.ts +16 -0
- package/src/AppManager.ts +33 -19
- package/src/ReconnectRefresher.ts +13 -1
- package/src/View/MainView.ts +13 -12
- package/src/constants.ts +2 -0
- package/src/index.ts +17 -0
- package/src/typings.ts +1 -0
package/CHANGELOG.md
CHANGED
package/dist/AppListener.d.ts
CHANGED
package/dist/AppManager.d.ts
CHANGED
@@ -50,15 +50,18 @@ export declare class AppManager {
|
|
50
50
|
get uid(): string;
|
51
51
|
getMainViewSceneDir(): string;
|
52
52
|
private onCreated;
|
53
|
+
addAppsChangeListener: () => void;
|
54
|
+
addAppCloseListener: () => void;
|
53
55
|
private onMainViewIndexChange;
|
54
56
|
private onFocusChange;
|
57
|
+
attributesUpdateCallback: import("lodash").DebouncedFunc<(apps: any) => Promise<void>>;
|
55
58
|
/**
|
56
59
|
* 插件更新 attributes 时的回调
|
57
60
|
*
|
58
61
|
* @param {*} attributes
|
59
62
|
* @memberof WindowManager
|
60
63
|
*/
|
61
|
-
|
64
|
+
_attributesUpdateCallback(apps: any): Promise<void>;
|
62
65
|
private onRegisteredChange;
|
63
66
|
private onMinimized;
|
64
67
|
refresh(): void;
|
@@ -14,7 +14,9 @@ export declare class ReconnectRefresher {
|
|
14
14
|
setContext(ctx: ReconnectRefresherContext): void;
|
15
15
|
private onPhaseChanged;
|
16
16
|
private onReconnected;
|
17
|
+
private _onReconnected;
|
17
18
|
private releaseDisposers;
|
19
|
+
refresh(): void;
|
18
20
|
add(id: string, func: any): void;
|
19
21
|
remove(id: string): void;
|
20
22
|
hasReactor(id: string): boolean;
|
package/dist/View/MainView.d.ts
CHANGED
package/dist/constants.d.ts
CHANGED
@@ -13,7 +13,9 @@ export declare enum Events {
|
|
13
13
|
MoveCamera = "MoveCamera",
|
14
14
|
MoveCameraToContain = "MoveCameraToContain",
|
15
15
|
CursorMove = "CursorMove",
|
16
|
-
RootDirRemoved = "RootDirRemoved"
|
16
|
+
RootDirRemoved = "RootDirRemoved",
|
17
|
+
Refresh = "Refresh",
|
18
|
+
InitMainViewCamera = "InitMainViewCamera"
|
17
19
|
}
|
18
20
|
export declare const MagixEventName = "__WindowManger";
|
19
21
|
export declare enum AppAttributes {
|
package/dist/index.d.ts
CHANGED
@@ -229,6 +229,9 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
229
229
|
completeImageUpload(uuid: string, url: string): void;
|
230
230
|
lockImage(uuid: string, locked: boolean): void;
|
231
231
|
lockImages(locked: boolean): void;
|
232
|
+
refresh(): void;
|
233
|
+
/** @inner */
|
234
|
+
_refresh(): void;
|
232
235
|
private isDynamicPPT;
|
233
236
|
private ensureAttributes;
|
234
237
|
}
|
package/dist/index.es.js
CHANGED
@@ -41,6 +41,8 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
41
41
|
Events2["MoveCameraToContain"] = "MoveCameraToContain";
|
42
42
|
Events2["CursorMove"] = "CursorMove";
|
43
43
|
Events2["RootDirRemoved"] = "RootDirRemoved";
|
44
|
+
Events2["Refresh"] = "Refresh";
|
45
|
+
Events2["InitMainViewCamera"] = "InitMainViewCamera";
|
44
46
|
return Events2;
|
45
47
|
})(Events || {});
|
46
48
|
const MagixEventName = "__WindowManger";
|
@@ -465,6 +467,14 @@ class AppListeners {
|
|
465
467
|
this.rootDirRemovedHandler();
|
466
468
|
break;
|
467
469
|
}
|
470
|
+
case Events.Refresh: {
|
471
|
+
this.refreshHandler();
|
472
|
+
break;
|
473
|
+
}
|
474
|
+
case Events.InitMainViewCamera: {
|
475
|
+
this.initMainViewCameraHandler();
|
476
|
+
break;
|
477
|
+
}
|
468
478
|
}
|
469
479
|
}
|
470
480
|
};
|
@@ -500,6 +510,12 @@ class AppListeners {
|
|
500
510
|
this.manager.mainViewProxy.rebind();
|
501
511
|
emitter.emit("rootDirRemoved");
|
502
512
|
};
|
513
|
+
this.refreshHandler = () => {
|
514
|
+
this.manager.windowManger._refresh();
|
515
|
+
};
|
516
|
+
this.initMainViewCameraHandler = () => {
|
517
|
+
this.manager.mainViewProxy.addCameraReaction();
|
518
|
+
};
|
503
519
|
}
|
504
520
|
get boxManager() {
|
505
521
|
return this.manager.boxManager;
|
@@ -1595,15 +1611,17 @@ class MainViewProxy {
|
|
1595
1611
|
this.mainViewIsAddListener = false;
|
1596
1612
|
this.store = this.manager.store;
|
1597
1613
|
this.sideEffectManager = new SideEffectManager();
|
1614
|
+
this.addCameraReaction = () => {
|
1615
|
+
var _a;
|
1616
|
+
(_a = this.manager.refresher) == null ? void 0 : _a.add(Fields.MainViewCamera, this.cameraReaction);
|
1617
|
+
};
|
1598
1618
|
this.cameraReaction = () => {
|
1599
1619
|
return reaction(() => this.mainViewCamera, (camera) => {
|
1600
1620
|
if (camera && camera.id !== this.manager.uid) {
|
1601
1621
|
this.moveCameraToContian(this.mainViewSize);
|
1602
1622
|
this.moveCamera(camera);
|
1603
1623
|
}
|
1604
|
-
}, {
|
1605
|
-
fireImmediately: true
|
1606
|
-
});
|
1624
|
+
}, { fireImmediately: true });
|
1607
1625
|
};
|
1608
1626
|
this.sizeChangeHandler = debounce((size2) => {
|
1609
1627
|
if (size2) {
|
@@ -1629,13 +1647,12 @@ class MainViewProxy {
|
|
1629
1647
|
this.mainView = this.createMainView();
|
1630
1648
|
this.moveCameraSizeByAttributes();
|
1631
1649
|
emitter.once("mainViewMounted").then(() => {
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
}, 200);
|
1650
|
+
this.addMainViewListener();
|
1651
|
+
this.start();
|
1652
|
+
if (!this.mainViewCamera || !this.mainViewSize) {
|
1653
|
+
manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
1654
|
+
this.setCameraAndSize();
|
1655
|
+
}
|
1639
1656
|
});
|
1640
1657
|
const playgroundSizeChangeListener = () => {
|
1641
1658
|
this.sizeChangeHandler(this.mainViewSize);
|
@@ -1656,12 +1673,11 @@ class MainViewProxy {
|
|
1656
1673
|
this.moveCamera(this.mainViewCamera);
|
1657
1674
|
}
|
1658
1675
|
start() {
|
1659
|
-
var _a;
|
1660
1676
|
if (this.started)
|
1661
1677
|
return;
|
1662
1678
|
this.sizeChangeHandler(this.mainViewSize);
|
1663
1679
|
this.addCameraListener();
|
1664
|
-
|
1680
|
+
this.addCameraReaction();
|
1665
1681
|
this.started = true;
|
1666
1682
|
}
|
1667
1683
|
setCameraAndSize() {
|
@@ -1916,6 +1932,22 @@ class AppManager {
|
|
1916
1932
|
};
|
1917
1933
|
callbacks$1.emit("sceneStateChange", this.sceneState);
|
1918
1934
|
};
|
1935
|
+
this.addAppsChangeListener = () => {
|
1936
|
+
var _a;
|
1937
|
+
(_a = this.refresher) == null ? void 0 : _a.add("apps", () => {
|
1938
|
+
return safeListenPropsUpdated(() => this.attributes.apps, () => {
|
1939
|
+
this.attributesUpdateCallback(this.attributes.apps);
|
1940
|
+
});
|
1941
|
+
});
|
1942
|
+
};
|
1943
|
+
this.addAppCloseListener = () => {
|
1944
|
+
var _a;
|
1945
|
+
(_a = this.refresher) == null ? void 0 : _a.add("appsClose", () => {
|
1946
|
+
return onObjectRemoved(this.attributes.apps, () => {
|
1947
|
+
this.onAppDelete(this.attributes.apps);
|
1948
|
+
});
|
1949
|
+
});
|
1950
|
+
};
|
1919
1951
|
this.onMainViewIndexChange = (index) => {
|
1920
1952
|
if (index !== void 0 && this._prevSceneIndex !== index) {
|
1921
1953
|
callbacks$1.emit("mainViewSceneIndexChange", index);
|
@@ -1943,6 +1975,7 @@ class AppManager {
|
|
1943
1975
|
}
|
1944
1976
|
}
|
1945
1977
|
};
|
1978
|
+
this.attributesUpdateCallback = debounce((apps) => this._attributesUpdateCallback(apps), 100);
|
1946
1979
|
this.onRegisteredChange = (registered) => {
|
1947
1980
|
if (!registered)
|
1948
1981
|
return;
|
@@ -2153,46 +2186,38 @@ class AppManager {
|
|
2153
2186
|
}
|
2154
2187
|
}
|
2155
2188
|
async onCreated() {
|
2156
|
-
var _a, _b, _c, _d, _e2, _f
|
2189
|
+
var _a, _b, _c, _d, _e2, _f;
|
2157
2190
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2158
2191
|
emitter.emit("updateManagerRect");
|
2159
2192
|
emitter.onAny(this.boxEventListener);
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
});
|
2164
|
-
});
|
2165
|
-
(_b = this.refresher) == null ? void 0 : _b.add("appsClose", () => {
|
2166
|
-
return onObjectRemoved(this.attributes.apps, () => {
|
2167
|
-
this.onAppDelete(this.attributes.apps);
|
2168
|
-
});
|
2169
|
-
});
|
2170
|
-
(_c = this.refresher) == null ? void 0 : _c.add("maximized", () => {
|
2193
|
+
this.addAppsChangeListener();
|
2194
|
+
this.addAppCloseListener();
|
2195
|
+
(_a = this.refresher) == null ? void 0 : _a.add("maximized", () => {
|
2171
2196
|
return autorun(() => {
|
2172
2197
|
var _a2;
|
2173
2198
|
const maximized = this.attributes.maximized;
|
2174
2199
|
(_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
|
2175
2200
|
});
|
2176
2201
|
});
|
2177
|
-
(
|
2202
|
+
(_b = this.refresher) == null ? void 0 : _b.add("minimized", () => {
|
2178
2203
|
return autorun(() => {
|
2179
2204
|
const minimized = this.attributes.minimized;
|
2180
2205
|
this.onMinimized(minimized);
|
2181
2206
|
});
|
2182
2207
|
});
|
2183
|
-
(
|
2208
|
+
(_c = this.refresher) == null ? void 0 : _c.add("mainViewIndex", () => {
|
2184
2209
|
return autorun(() => {
|
2185
2210
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
2186
2211
|
this.onMainViewIndexChange(mainSceneIndex);
|
2187
2212
|
});
|
2188
2213
|
});
|
2189
|
-
(
|
2214
|
+
(_d = this.refresher) == null ? void 0 : _d.add("focusedChange", () => {
|
2190
2215
|
return autorun(() => {
|
2191
2216
|
const focused = get(this.attributes, "focus");
|
2192
2217
|
this.onFocusChange(focused);
|
2193
2218
|
});
|
2194
2219
|
});
|
2195
|
-
(
|
2220
|
+
(_e2 = this.refresher) == null ? void 0 : _e2.add("registeredChange", () => {
|
2196
2221
|
return autorun(() => {
|
2197
2222
|
const registered = get(this.attributes, Fields.Registered);
|
2198
2223
|
this.onRegisteredChange(registered);
|
@@ -2204,7 +2229,7 @@ class AppManager {
|
|
2204
2229
|
return;
|
2205
2230
|
this.resetScenePath(mainScenePath);
|
2206
2231
|
}
|
2207
|
-
this.displayerWritableListener(!((
|
2232
|
+
this.displayerWritableListener(!((_f = this.room) == null ? void 0 : _f.isWritable));
|
2208
2233
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
2209
2234
|
this._prevFocused = this.attributes.focus;
|
2210
2235
|
this.sideEffectManager.add(() => {
|
@@ -2216,7 +2241,7 @@ class AppManager {
|
|
2216
2241
|
return () => redoUndo.destroy();
|
2217
2242
|
});
|
2218
2243
|
}
|
2219
|
-
async
|
2244
|
+
async _attributesUpdateCallback(apps) {
|
2220
2245
|
if (apps && WindowManager.container) {
|
2221
2246
|
const appIds = Object.keys(apps);
|
2222
2247
|
if (appIds.length === 0) {
|
@@ -5517,6 +5542,9 @@ class ReconnectRefresher {
|
|
5517
5542
|
this.phase = phase;
|
5518
5543
|
};
|
5519
5544
|
this.onReconnected = debounce(() => {
|
5545
|
+
this._onReconnected();
|
5546
|
+
}, 3e3);
|
5547
|
+
this._onReconnected = () => {
|
5520
5548
|
log("onReconnected refresh reactors");
|
5521
5549
|
this.releaseDisposers();
|
5522
5550
|
this.reactors.forEach((func, id2) => {
|
@@ -5525,7 +5553,7 @@ class ReconnectRefresher {
|
|
5525
5553
|
}
|
5526
5554
|
});
|
5527
5555
|
this.ctx.emitter.emit("onReconnected", void 0);
|
5528
|
-
}
|
5556
|
+
};
|
5529
5557
|
}
|
5530
5558
|
setRoom(room) {
|
5531
5559
|
this.room = room;
|
@@ -5544,7 +5572,14 @@ class ReconnectRefresher {
|
|
5544
5572
|
});
|
5545
5573
|
this.disposers.clear();
|
5546
5574
|
}
|
5575
|
+
refresh() {
|
5576
|
+
this._onReconnected();
|
5577
|
+
}
|
5547
5578
|
add(id2, func) {
|
5579
|
+
const disposer = this.disposers.get(id2);
|
5580
|
+
if (disposer && isFunction(disposer)) {
|
5581
|
+
disposer();
|
5582
|
+
}
|
5548
5583
|
if (isFunction(func)) {
|
5549
5584
|
this.reactors.set(id2, func);
|
5550
5585
|
this.disposers.set(id2, func());
|
@@ -14812,7 +14847,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
14812
14847
|
const _WindowManager = class extends InvisiblePlugin {
|
14813
14848
|
constructor(context) {
|
14814
14849
|
super(context);
|
14815
|
-
this.version = "0.4.
|
14850
|
+
this.version = "0.4.22";
|
14816
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/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" } };
|
14817
14852
|
this.emitter = callbacks$1;
|
14818
14853
|
this.viewMode = ViewMode.Broadcaster;
|
@@ -14937,6 +14972,9 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
14937
14972
|
if (_WindowManager.params) {
|
14938
14973
|
const params = _WindowManager.params;
|
14939
14974
|
const mainViewElement = _WindowManager.initContainer(this, container, params.chessboard, params.overwriteStyles);
|
14975
|
+
if (this.boxManager) {
|
14976
|
+
this.boxManager.destroy();
|
14977
|
+
}
|
14940
14978
|
const boxManager = createBoxManager(this, callbacks$1, emitter, {
|
14941
14979
|
collectorContainer: params.collectorContainer,
|
14942
14980
|
collectorStyles: params.collectorStyles,
|
@@ -15402,6 +15440,19 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15402
15440
|
var _a;
|
15403
15441
|
return (_a = this.focusedView) == null ? void 0 : _a.lockImages(locked);
|
15404
15442
|
}
|
15443
|
+
refresh() {
|
15444
|
+
var _a;
|
15445
|
+
this._refresh();
|
15446
|
+
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.Refresh);
|
15447
|
+
}
|
15448
|
+
_refresh() {
|
15449
|
+
var _a, _b, _c;
|
15450
|
+
(_a = this.appManager) == null ? void 0 : _a.mainViewProxy.rebind();
|
15451
|
+
if (_WindowManager.container) {
|
15452
|
+
this.bindContainer(_WindowManager.container);
|
15453
|
+
}
|
15454
|
+
(_c = (_b = this.appManager) == null ? void 0 : _b.refresher) == null ? void 0 : _c.refresh();
|
15455
|
+
}
|
15405
15456
|
isDynamicPPT(scenes) {
|
15406
15457
|
var _a, _b;
|
15407
15458
|
const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;
|