@netless/window-manager 0.4.61 → 0.4.63
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 +1 -0
- package/dist/AppManager.d.ts +2 -0
- package/dist/InternalEmitter.d.ts +1 -1
- package/dist/Page/PageController.d.ts +1 -0
- package/dist/callback.d.ts +2 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -95
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/App/AppContext.ts +9 -0
- package/src/App/AppProxy.ts +4 -4
- package/src/App/Storage/index.ts +5 -4
- package/src/AppListener.ts +3 -3
- package/src/AppManager.ts +34 -23
- package/src/Cursor/index.ts +3 -3
- package/src/InternalEmitter.ts +1 -1
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +6 -5
- package/src/RedoUndo.ts +3 -3
- package/src/Utils/Common.ts +4 -4
- package/src/Utils/RoomHacker.ts +4 -4
- package/src/View/MainView.ts +6 -6
- package/src/callback.ts +2 -0
- package/src/index.ts +55 -18
- package/src/style.css +8 -0
package/dist/index.mjs
CHANGED
@@ -142,7 +142,7 @@ class AppCreateQueue {
|
|
142
142
|
}
|
143
143
|
}
|
144
144
|
}
|
145
|
-
const
|
145
|
+
const internalEmitter = new Emittery();
|
146
146
|
const DatabaseName = "__WindowManagerAppCache";
|
147
147
|
let db$1;
|
148
148
|
let store$1;
|
@@ -324,9 +324,9 @@ class AppRegister {
|
|
324
324
|
return app;
|
325
325
|
});
|
326
326
|
if (params.addHooks) {
|
327
|
-
const
|
328
|
-
if (
|
329
|
-
params.addHooks(
|
327
|
+
const emitter = this.createKindEmitter(params.kind);
|
328
|
+
if (emitter) {
|
329
|
+
params.addHooks(emitter);
|
330
330
|
}
|
331
331
|
}
|
332
332
|
}
|
@@ -341,13 +341,13 @@ class AppRegister {
|
|
341
341
|
}
|
342
342
|
}
|
343
343
|
async notifyApp(kind2, event, payload) {
|
344
|
-
const
|
345
|
-
await (
|
344
|
+
const emitter = this.kindEmitters.get(kind2);
|
345
|
+
await (emitter == null ? void 0 : emitter.emit(event, payload));
|
346
346
|
}
|
347
347
|
createKindEmitter(kind2) {
|
348
348
|
if (!this.kindEmitters.has(kind2)) {
|
349
|
-
const
|
350
|
-
this.kindEmitters.set(kind2,
|
349
|
+
const emitter = new Emittery();
|
350
|
+
this.kindEmitters.set(kind2, emitter);
|
351
351
|
}
|
352
352
|
return this.kindEmitters.get(kind2);
|
353
353
|
}
|
@@ -394,7 +394,7 @@ const removeScenes = (room, scenePath, index2) => {
|
|
394
394
|
}
|
395
395
|
};
|
396
396
|
const addEmitterOnceListener = (event, listener) => {
|
397
|
-
|
397
|
+
internalEmitter.once(event).then(listener);
|
398
398
|
};
|
399
399
|
debounce((callbacks2, mode) => {
|
400
400
|
callbacks2.emit("mainViewModeChange", mode);
|
@@ -538,12 +538,12 @@ class AppListeners {
|
|
538
538
|
this.manager.mainView.moveCameraToContain(payload);
|
539
539
|
};
|
540
540
|
this.cursorMoveHandler = (payload) => {
|
541
|
-
|
541
|
+
internalEmitter.emit("cursorMove", payload);
|
542
542
|
};
|
543
543
|
this.rootDirRemovedHandler = () => {
|
544
544
|
this.manager.createRootDirScenesCallback();
|
545
545
|
this.manager.mainViewProxy.rebind();
|
546
|
-
|
546
|
+
internalEmitter.emit("rootDirRemoved");
|
547
547
|
};
|
548
548
|
this.refreshHandler = () => {
|
549
549
|
this.manager.windowManger._refresh();
|
@@ -669,13 +669,6 @@ const safeListenPropsUpdated = (getProps, callback, onDestroyed) => {
|
|
669
669
|
};
|
670
670
|
const onObjectRemoved = onObjectByEvent(UpdateEventKind.Removed);
|
671
671
|
onObjectByEvent(UpdateEventKind.Inserted);
|
672
|
-
const plainObjectKeys = Object.keys;
|
673
|
-
function isRef(e2) {
|
674
|
-
return Boolean(has(e2, "__isRef"));
|
675
|
-
}
|
676
|
-
function makeRef(v2) {
|
677
|
-
return { k: genUID(), v: v2, __isRef: true };
|
678
|
-
}
|
679
672
|
class StorageEvent {
|
680
673
|
constructor() {
|
681
674
|
this.listeners = /* @__PURE__ */ new Set();
|
@@ -693,6 +686,13 @@ class StorageEvent {
|
|
693
686
|
this.listeners.delete(listener);
|
694
687
|
}
|
695
688
|
}
|
689
|
+
const plainObjectKeys = Object.keys;
|
690
|
+
function isRef(e2) {
|
691
|
+
return Boolean(has(e2, "__isRef"));
|
692
|
+
}
|
693
|
+
function makeRef(v2) {
|
694
|
+
return { k: genUID(), v: v2, __isRef: true };
|
695
|
+
}
|
696
696
|
const STORAGE_NS = "_WM-STORAGE_";
|
697
697
|
class Storage {
|
698
698
|
constructor(context, id2, defaultState) {
|
@@ -1019,6 +1019,14 @@ class AppContext {
|
|
1019
1019
|
this.appProxy.setSceneIndex(nextIndex);
|
1020
1020
|
return true;
|
1021
1021
|
};
|
1022
|
+
this.jumpPage = async (index2) => {
|
1023
|
+
if (!(0 <= index2 && index2 < this.pageState.length)) {
|
1024
|
+
console.warn("[WindowManager] nextPage: index out of range");
|
1025
|
+
return false;
|
1026
|
+
}
|
1027
|
+
this.appProxy.setSceneIndex(index2);
|
1028
|
+
return true;
|
1029
|
+
};
|
1022
1030
|
this.prevPage = async () => {
|
1023
1031
|
const nextIndex = this.pageState.index - 1;
|
1024
1032
|
if (nextIndex < 0) {
|
@@ -1460,7 +1468,7 @@ class AppProxy {
|
|
1460
1468
|
} else {
|
1461
1469
|
throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
1462
1470
|
}
|
1463
|
-
|
1471
|
+
internalEmitter.emit("updateManagerRect");
|
1464
1472
|
return {
|
1465
1473
|
appId: this.id,
|
1466
1474
|
app: appImpl
|
@@ -1479,7 +1487,7 @@ class AppProxy {
|
|
1479
1487
|
const context = new AppContext(this.manager, this.boxManager, appId, this, appOptions);
|
1480
1488
|
this.appContext = context;
|
1481
1489
|
try {
|
1482
|
-
|
1490
|
+
internalEmitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
|
1483
1491
|
var _a2;
|
1484
1492
|
let boxInitState;
|
1485
1493
|
if (!skipUpdate) {
|
@@ -1695,7 +1703,7 @@ class AppProxy {
|
|
1695
1703
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1696
1704
|
}
|
1697
1705
|
this.appEmitter.clearListeners();
|
1698
|
-
|
1706
|
+
internalEmitter.emit(`destroy-${this.id}`, { error });
|
1699
1707
|
if (needCloseBox) {
|
1700
1708
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
1701
1709
|
}
|
@@ -1778,7 +1786,7 @@ class MainViewProxy {
|
|
1778
1786
|
this.sideEffectManager = new SideEffectManager();
|
1779
1787
|
this.startListenWritableChange = () => {
|
1780
1788
|
this.sideEffectManager.add(() => {
|
1781
|
-
return
|
1789
|
+
return internalEmitter.on("writableChange", (isWritable) => {
|
1782
1790
|
if (isWritable) {
|
1783
1791
|
this.ensureCameraAndSize();
|
1784
1792
|
}
|
@@ -1839,7 +1847,7 @@ class MainViewProxy {
|
|
1839
1847
|
};
|
1840
1848
|
this.mainView = this.createMainView();
|
1841
1849
|
this.moveCameraSizeByAttributes();
|
1842
|
-
|
1850
|
+
internalEmitter.once("mainViewMounted").then(() => {
|
1843
1851
|
this.addMainViewListener();
|
1844
1852
|
this.start();
|
1845
1853
|
this.ensureCameraAndSize();
|
@@ -1849,13 +1857,13 @@ class MainViewProxy {
|
|
1849
1857
|
this.sizeChangeHandler(this.mainViewSize);
|
1850
1858
|
};
|
1851
1859
|
this.sideEffectManager.add(() => {
|
1852
|
-
return
|
1860
|
+
return internalEmitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
1853
1861
|
});
|
1854
1862
|
this.sideEffectManager.add(() => {
|
1855
|
-
return
|
1863
|
+
return internalEmitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
|
1856
1864
|
});
|
1857
1865
|
this.sideEffectManager.add(() => {
|
1858
|
-
return
|
1866
|
+
return internalEmitter.on("startReconnect", () => {
|
1859
1867
|
if (!this.didRelease) {
|
1860
1868
|
this.mainView.release();
|
1861
1869
|
}
|
@@ -2052,13 +2060,13 @@ class RedoUndo {
|
|
2052
2060
|
this.disposeViewCallbacks(view);
|
2053
2061
|
}
|
2054
2062
|
};
|
2055
|
-
|
2063
|
+
internalEmitter.on("focusedChange", (changed) => {
|
2056
2064
|
this.disposePrevFocusViewRedoUndoListeners(changed.prev);
|
2057
2065
|
setTimeout(() => {
|
2058
2066
|
this.addRedoUndoListeners(changed.focused);
|
2059
2067
|
}, 0);
|
2060
2068
|
});
|
2061
|
-
|
2069
|
+
internalEmitter.on("rootDirRemoved", () => {
|
2062
2070
|
this.disposePrevFocusViewRedoUndoListeners(context.focus());
|
2063
2071
|
this.addRedoUndoListeners(context.focus());
|
2064
2072
|
});
|
@@ -2130,7 +2138,7 @@ class AppManager {
|
|
2130
2138
|
onAddScene: this.onSceneChange,
|
2131
2139
|
onRemoveScene: async (node, name) => {
|
2132
2140
|
await this.onSceneChange(node);
|
2133
|
-
|
2141
|
+
internalEmitter.emit("rootDirSceneRemoved", name);
|
2134
2142
|
}
|
2135
2143
|
});
|
2136
2144
|
if (this.callbacksNode) {
|
@@ -2153,7 +2161,7 @@ class AppManager {
|
|
2153
2161
|
}
|
2154
2162
|
}, 100);
|
2155
2163
|
return new Promise((resolve, reject) => {
|
2156
|
-
|
2164
|
+
internalEmitter.once("rootDirSceneRemoved").then((name) => {
|
2157
2165
|
if (name === scene) {
|
2158
2166
|
resolve(true);
|
2159
2167
|
}
|
@@ -2178,7 +2186,7 @@ class AppManager {
|
|
2178
2186
|
this.emitMainViewScenesChange = (length) => {
|
2179
2187
|
return Promise.all([
|
2180
2188
|
callbacks$1.emit("mainViewScenesLengthChange", length),
|
2181
|
-
|
2189
|
+
internalEmitter.emit("changePageState")
|
2182
2190
|
]);
|
2183
2191
|
};
|
2184
2192
|
this.updateSceneState = (node) => {
|
@@ -2247,7 +2255,7 @@ class AppManager {
|
|
2247
2255
|
this.onMainViewIndexChange = (index2) => {
|
2248
2256
|
if (index2 !== void 0 && this._prevSceneIndex !== index2) {
|
2249
2257
|
callbacks$1.emit("mainViewSceneIndexChange", index2);
|
2250
|
-
|
2258
|
+
internalEmitter.emit("changePageState");
|
2251
2259
|
if (this.callbacksNode) {
|
2252
2260
|
this.updateSceneState(this.callbacksNode);
|
2253
2261
|
}
|
@@ -2258,7 +2266,7 @@ class AppManager {
|
|
2258
2266
|
var _a;
|
2259
2267
|
if (this._prevFocused !== focused) {
|
2260
2268
|
callbacks$1.emit("focusedChange", focused);
|
2261
|
-
|
2269
|
+
internalEmitter.emit("focusedChange", { focused, prev: this._prevFocused });
|
2262
2270
|
this._prevFocused = focused;
|
2263
2271
|
if (focused !== void 0) {
|
2264
2272
|
(_a = this.boxManager) == null ? void 0 : _a.focusBox({ appId: focused });
|
@@ -2272,6 +2280,7 @@ class AppManager {
|
|
2272
2280
|
}
|
2273
2281
|
};
|
2274
2282
|
this.attributesUpdateCallback = debounce((apps) => this._attributesUpdateCallback(apps), 100);
|
2283
|
+
this._appIds = [];
|
2275
2284
|
this.onRegisteredChange = (registered) => {
|
2276
2285
|
if (!registered)
|
2277
2286
|
return;
|
@@ -2324,7 +2333,7 @@ class AppManager {
|
|
2324
2333
|
this.appProxies.forEach((appProxy) => {
|
2325
2334
|
appProxy.appEmitter.emit("roomStateChange", state);
|
2326
2335
|
});
|
2327
|
-
|
2336
|
+
internalEmitter.emit("observerIdChange", this.displayer.observerId);
|
2328
2337
|
};
|
2329
2338
|
this.displayerWritableListener = (isReadonly) => {
|
2330
2339
|
var _a, _b;
|
@@ -2338,7 +2347,7 @@ class AppManager {
|
|
2338
2347
|
this.appProxies.forEach((appProxy) => {
|
2339
2348
|
appProxy.emitAppIsWritableChange();
|
2340
2349
|
});
|
2341
|
-
|
2350
|
+
internalEmitter.emit("writableChange", isWritable);
|
2342
2351
|
};
|
2343
2352
|
this.updateSceneIndex = () => {
|
2344
2353
|
const scenePath = this.store.getMainViewScenePath();
|
@@ -2368,7 +2377,7 @@ class AppManager {
|
|
2368
2377
|
this.appListeners.addListeners();
|
2369
2378
|
this.refresher = reconnectRefresher;
|
2370
2379
|
this.refresher.setRoom(this.room);
|
2371
|
-
this.refresher.setContext({ emitter });
|
2380
|
+
this.refresher.setContext({ emitter: internalEmitter });
|
2372
2381
|
this.sideEffectManager.add(() => {
|
2373
2382
|
return () => {
|
2374
2383
|
var _a, _b, _c;
|
@@ -2380,14 +2389,14 @@ class AppManager {
|
|
2380
2389
|
(_c = this.callbacksNode) == null ? void 0 : _c.dispose();
|
2381
2390
|
};
|
2382
2391
|
});
|
2383
|
-
|
2384
|
-
|
2392
|
+
internalEmitter.once("onCreated").then(() => this.onCreated());
|
2393
|
+
internalEmitter.on("onReconnected", () => this.onReconnected());
|
2385
2394
|
if (isPlayer(this.displayer)) {
|
2386
|
-
|
2387
|
-
|
2395
|
+
internalEmitter.on("seekStart", this.onPlayerSeekStart);
|
2396
|
+
internalEmitter.on("seek", this.onPlayerSeekDone);
|
2388
2397
|
}
|
2389
|
-
|
2390
|
-
|
2398
|
+
internalEmitter.on("removeScenes", this.onRemoveScenes);
|
2399
|
+
internalEmitter.on("setReadonly", this.onReadonlyChanged);
|
2391
2400
|
this.createRootDirScenesCallback();
|
2392
2401
|
appRegister.setSyncRegisterApp((payload) => {
|
2393
2402
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
@@ -2402,7 +2411,7 @@ class AppManager {
|
|
2402
2411
|
}
|
2403
2412
|
}
|
2404
2413
|
this.mainViewProxy.rebind();
|
2405
|
-
|
2414
|
+
internalEmitter.emit("rootDirRemoved");
|
2406
2415
|
this.updateRootDirRemoving(false);
|
2407
2416
|
}
|
2408
2417
|
get eventName() {
|
@@ -2440,7 +2449,7 @@ class AppManager {
|
|
2440
2449
|
async onCreated() {
|
2441
2450
|
var _a, _b, _c, _d, _e, _f;
|
2442
2451
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2443
|
-
|
2452
|
+
internalEmitter.emit("updateManagerRect");
|
2444
2453
|
boxEmitter.on("move", this.onBoxMove);
|
2445
2454
|
boxEmitter.on("resize", this.onBoxResize);
|
2446
2455
|
boxEmitter.on("focus", this.onBoxFocus);
|
@@ -2497,19 +2506,27 @@ class AppManager {
|
|
2497
2506
|
return () => redoUndo.destroy();
|
2498
2507
|
});
|
2499
2508
|
}
|
2509
|
+
notifyAppsChange(appIds) {
|
2510
|
+
if (this._appIds.length !== appIds.length || !this._appIds.every((id2) => appIds.includes(id2))) {
|
2511
|
+
this._appIds = appIds;
|
2512
|
+
callbacks$1.emit("appsChange", appIds);
|
2513
|
+
}
|
2514
|
+
}
|
2500
2515
|
async _attributesUpdateCallback(apps) {
|
2501
2516
|
if (apps && WindowManager.container) {
|
2502
2517
|
const appIds = Object.keys(apps);
|
2503
2518
|
if (appIds.length === 0) {
|
2504
2519
|
this.appCreateQueue.emitReady();
|
2505
2520
|
}
|
2506
|
-
const appsWithCreatedAt = appIds.map((appId) => {
|
2521
|
+
const appsWithCreatedAt = orderBy(appIds.map((appId) => {
|
2507
2522
|
return {
|
2508
2523
|
id: appId,
|
2509
2524
|
createdAt: apps[appId].createdAt
|
2510
2525
|
};
|
2511
|
-
});
|
2512
|
-
|
2526
|
+
}), "createdAt", "asc");
|
2527
|
+
const orderedAppIds = appsWithCreatedAt.map(({ id: id2 }) => id2);
|
2528
|
+
this.notifyAppsChange(orderedAppIds);
|
2529
|
+
for (const id2 of orderedAppIds) {
|
2513
2530
|
if (!this.appProxies.has(id2) && !this.appStatus.has(id2)) {
|
2514
2531
|
const app = apps[id2];
|
2515
2532
|
try {
|
@@ -2554,7 +2571,7 @@ class AppManager {
|
|
2554
2571
|
if (!mainView.focusScenePath) {
|
2555
2572
|
this.setMainViewFocusPath();
|
2556
2573
|
}
|
2557
|
-
|
2574
|
+
internalEmitter.emit("mainViewMounted");
|
2558
2575
|
}
|
2559
2576
|
setMainViewFocusPath(scenePath) {
|
2560
2577
|
var _a;
|
@@ -2671,7 +2688,7 @@ class AppManager {
|
|
2671
2688
|
const success = this.setMainViewFocusPath(scenePath);
|
2672
2689
|
if (success) {
|
2673
2690
|
this.store.setMainViewScenePath(scenePath);
|
2674
|
-
this.
|
2691
|
+
this.store.setMainViewSceneIndex(index2);
|
2675
2692
|
this.dispatchSetMainViewScenePath(scenePath);
|
2676
2693
|
}
|
2677
2694
|
} else {
|
@@ -2681,6 +2698,7 @@ class AppManager {
|
|
2681
2698
|
}
|
2682
2699
|
dispatchSetMainViewScenePath(scenePath) {
|
2683
2700
|
this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
|
2701
|
+
callbacks$1.emit("mainViewScenePathChange", scenePath);
|
2684
2702
|
setScenePath(this.room, scenePath);
|
2685
2703
|
}
|
2686
2704
|
getAppInitPath(appId) {
|
@@ -2732,7 +2750,7 @@ class AppManager {
|
|
2732
2750
|
this.displayer.callbacks.off("onEnableWriteNowChanged", this.displayerWritableListener);
|
2733
2751
|
this.appListeners.removeListeners();
|
2734
2752
|
boxEmitter.clearListeners();
|
2735
|
-
|
2753
|
+
internalEmitter.clearListeners();
|
2736
2754
|
if (this.appProxies.size) {
|
2737
2755
|
this.appProxies.forEach((appProxy) => {
|
2738
2756
|
appProxy.destroy(true, false, true);
|
@@ -2794,11 +2812,11 @@ const createInvisiblePlugin = async (room) => {
|
|
2794
2812
|
};
|
2795
2813
|
const ResizeObserver$2 = window.ResizeObserver || ResizeObserver$3;
|
2796
2814
|
class ContainerResizeObserver {
|
2797
|
-
constructor(
|
2798
|
-
this.emitter =
|
2815
|
+
constructor(emitter) {
|
2816
|
+
this.emitter = emitter;
|
2799
2817
|
}
|
2800
|
-
static create(container, sizer, wrapper,
|
2801
|
-
const containerResizeObserver = new ContainerResizeObserver(
|
2818
|
+
static create(container, sizer, wrapper, emitter) {
|
2819
|
+
const containerResizeObserver = new ContainerResizeObserver(emitter);
|
2802
2820
|
containerResizeObserver.observePlaygroundSize(container, sizer, wrapper);
|
2803
2821
|
return containerResizeObserver;
|
2804
2822
|
}
|
@@ -3236,24 +3254,24 @@ var eventemitter3 = { exports: {} };
|
|
3236
3254
|
this.context = context;
|
3237
3255
|
this.once = once || false;
|
3238
3256
|
}
|
3239
|
-
function addListener(
|
3257
|
+
function addListener(emitter, event, fn, context, once) {
|
3240
3258
|
if (typeof fn !== "function") {
|
3241
3259
|
throw new TypeError("The listener must be a function");
|
3242
3260
|
}
|
3243
|
-
var listener = new EE(fn, context ||
|
3244
|
-
if (!
|
3245
|
-
|
3246
|
-
else if (!
|
3247
|
-
|
3261
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
3262
|
+
if (!emitter._events[evt])
|
3263
|
+
emitter._events[evt] = listener, emitter._eventsCount++;
|
3264
|
+
else if (!emitter._events[evt].fn)
|
3265
|
+
emitter._events[evt].push(listener);
|
3248
3266
|
else
|
3249
|
-
|
3250
|
-
return
|
3267
|
+
emitter._events[evt] = [emitter._events[evt], listener];
|
3268
|
+
return emitter;
|
3251
3269
|
}
|
3252
|
-
function clearEvent(
|
3253
|
-
if (--
|
3254
|
-
|
3270
|
+
function clearEvent(emitter, evt) {
|
3271
|
+
if (--emitter._eventsCount === 0)
|
3272
|
+
emitter._events = new Events2();
|
3255
3273
|
else
|
3256
|
-
delete
|
3274
|
+
delete emitter._events[evt];
|
3257
3275
|
}
|
3258
3276
|
function EventEmitter2() {
|
3259
3277
|
this._events = new Events2();
|
@@ -6173,7 +6191,7 @@ class TeleBoxManager {
|
|
6173
6191
|
return typeof boxOrID === "string" ? this.boxes.find((box) => box.id === boxOrID) : boxOrID;
|
6174
6192
|
}
|
6175
6193
|
}
|
6176
|
-
const createBoxManager = (manager, callbacks2,
|
6194
|
+
const createBoxManager = (manager, callbacks2, emitter, boxEmitter2, options) => {
|
6177
6195
|
return new BoxManager({
|
6178
6196
|
safeSetAttributes: (attributes) => manager.safeSetAttributes(attributes),
|
6179
6197
|
getMainView: () => manager.mainView,
|
@@ -6195,7 +6213,7 @@ const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) =
|
|
6195
6213
|
return (_a = manager.appManager) == null ? void 0 : _a.store.setAppFocus(appId, true);
|
6196
6214
|
},
|
6197
6215
|
callbacks: callbacks2,
|
6198
|
-
emitter
|
6216
|
+
emitter,
|
6199
6217
|
boxEmitter: boxEmitter2
|
6200
6218
|
}, options);
|
6201
6219
|
};
|
@@ -6203,11 +6221,11 @@ class BoxManager {
|
|
6203
6221
|
constructor(context, createTeleBoxManagerConfig) {
|
6204
6222
|
this.context = context;
|
6205
6223
|
this.createTeleBoxManagerConfig = createTeleBoxManagerConfig;
|
6206
|
-
const { emitter
|
6224
|
+
const { emitter, callbacks: callbacks2, boxEmitter: boxEmitter2 } = context;
|
6207
6225
|
this.teleBoxManager = this.setupBoxManager(createTeleBoxManagerConfig);
|
6208
6226
|
this.teleBoxManager._state$.reaction((state) => {
|
6209
6227
|
callbacks2.emit("boxStateChange", state);
|
6210
|
-
|
6228
|
+
emitter.emit("boxStateChange", state);
|
6211
6229
|
});
|
6212
6230
|
this.teleBoxManager._darkMode$.reaction((darkMode) => {
|
6213
6231
|
callbacks2.emit("darkModeChange", darkMode);
|
@@ -6268,8 +6286,8 @@ class BoxManager {
|
|
6268
6286
|
this.teleBoxManager.events.on("z_index", (box) => {
|
6269
6287
|
this.context.updateAppState(box.id, AppAttributes.ZIndex, box.zIndex);
|
6270
6288
|
});
|
6271
|
-
|
6272
|
-
|
6289
|
+
emitter.on("playgroundSizeChange", () => this.updateManagerRect());
|
6290
|
+
emitter.on("updateManagerRect", () => this.updateManagerRect());
|
6273
6291
|
}
|
6274
6292
|
get mainView() {
|
6275
6293
|
return this.context.getMainView();
|
@@ -7347,10 +7365,10 @@ class CursorManager {
|
|
7347
7365
|
this.setupWrapper(wrapper);
|
7348
7366
|
}
|
7349
7367
|
this.sideEffectManager.add(() => {
|
7350
|
-
return
|
7368
|
+
return internalEmitter.on("cursorMove", this.onCursorMove);
|
7351
7369
|
});
|
7352
7370
|
this.sideEffectManager.add(() => {
|
7353
|
-
return
|
7371
|
+
return internalEmitter.on("playgroundSizeChange", () => this.updateContainerRect());
|
7354
7372
|
});
|
7355
7373
|
if (applianceIcons) {
|
7356
7374
|
this.applianceIcons = __spreadValues(__spreadValues({}, ApplianceMap), applianceIcons);
|
@@ -7449,17 +7467,15 @@ class CursorManager {
|
|
7449
7467
|
class PageStateImpl {
|
7450
7468
|
constructor(manager) {
|
7451
7469
|
this.manager = manager;
|
7452
|
-
|
7470
|
+
internalEmitter.on("changePageState", () => {
|
7453
7471
|
callbacks$1.emit("pageStateChange", this.toObject());
|
7454
7472
|
});
|
7455
7473
|
}
|
7456
7474
|
get index() {
|
7457
|
-
|
7458
|
-
return ((_a = this.manager) == null ? void 0 : _a.store.getMainViewSceneIndex()) || 0;
|
7475
|
+
return this.manager.store.getMainViewSceneIndex() || 0;
|
7459
7476
|
}
|
7460
7477
|
get length() {
|
7461
|
-
|
7462
|
-
return ((_a = this.manager) == null ? void 0 : _a.mainViewScenesLength) || 0;
|
7478
|
+
return this.manager.mainViewScenesLength || 0;
|
7463
7479
|
}
|
7464
7480
|
toObject() {
|
7465
7481
|
const index2 = this.index >= this.length ? this.length - 1 : this.index;
|
@@ -7620,16 +7636,16 @@ const delegateRemoveScenes = (room, manager) => {
|
|
7620
7636
|
(_a = manager.appManager) == null ? void 0 : _a.updateRootDirRemoving(true);
|
7621
7637
|
}
|
7622
7638
|
const result = originRemoveScenes.call(room, scenePath);
|
7623
|
-
|
7639
|
+
internalEmitter.emit("removeScenes", { scenePath, index: index2 });
|
7624
7640
|
return result;
|
7625
7641
|
};
|
7626
7642
|
};
|
7627
7643
|
const delegateSeekToProgressTime = (player) => {
|
7628
7644
|
const originSeek = player.seekToProgressTime;
|
7629
7645
|
async function newSeek(time2) {
|
7630
|
-
await
|
7646
|
+
await internalEmitter.emit("seekStart");
|
7631
7647
|
const seekResult = await originSeek.call(player, time2);
|
7632
|
-
|
7648
|
+
internalEmitter.emit("seek", time2);
|
7633
7649
|
return seekResult;
|
7634
7650
|
}
|
7635
7651
|
player.seekToProgressTime = newSeek;
|
@@ -10004,6 +10020,11 @@ class StaticDocsViewer {
|
|
10004
10020
|
this.whiteboardView.callbacks.on("onCameraUpdated", handleCameraUpdate);
|
10005
10021
|
return () => this.whiteboardView.callbacks.off("onCameraUpdated", handleCameraUpdate);
|
10006
10022
|
});
|
10023
|
+
this.sideEffect.add(() => {
|
10024
|
+
const { updateUserScroll } = this;
|
10025
|
+
this.whiteboardView.callbacks.on("onCameraUpdatedByDevice", updateUserScroll);
|
10026
|
+
return () => this.whiteboardView.callbacks.off("onCameraUpdatedByDevice", updateUserScroll);
|
10027
|
+
});
|
10007
10028
|
this.sideEffect.add(() => {
|
10008
10029
|
const handleSizeUpdate = ({ width: wbWidth, height: wbHeight }) => {
|
10009
10030
|
if (wbWidth <= 0 || wbHeight <= 0) {
|
@@ -17439,18 +17460,18 @@ IframeBridge.hiddenClass = "netless-iframe-brdige-hidden";
|
|
17439
17460
|
IframeBridge.emitter = new Emittery();
|
17440
17461
|
IframeBridge.displayer = null;
|
17441
17462
|
IframeBridge.alreadyCreate = false;
|
17442
|
-
const reconnectRefresher = new ReconnectRefresher({ emitter });
|
17463
|
+
const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
17443
17464
|
const _WindowManager = class extends InvisiblePlugin {
|
17444
17465
|
constructor(context) {
|
17445
17466
|
super(context);
|
17446
|
-
this.version = "0.4.
|
17447
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.27", "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": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.
|
17467
|
+
this.version = "0.4.63";
|
17468
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.27", "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": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.16", "@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", "jspdf": "^2.5.1", "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.43" } };
|
17448
17469
|
this.emitter = callbacks$1;
|
17449
17470
|
this.viewMode = ViewMode.Broadcaster;
|
17450
17471
|
this.isReplay = isPlayer(this.displayer);
|
17451
17472
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
17452
17473
|
_WindowManager.displayer = context.displayer;
|
17453
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.27", "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": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.
|
17474
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.27", "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": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.16", "@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", "jspdf": "^2.5.1", "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.43" } };
|
17454
17475
|
}
|
17455
17476
|
static async mount(params) {
|
17456
17477
|
const room = params.room;
|
@@ -17496,6 +17517,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17496
17517
|
_WindowManager.containerSizeRatio = containerSizeRatio;
|
17497
17518
|
}
|
17498
17519
|
await manager.ensureAttributes();
|
17520
|
+
manager._fullscreen = params.fullscreen;
|
17499
17521
|
manager.appManager = new AppManager(manager);
|
17500
17522
|
manager._pageState = new PageStateImpl(manager.appManager);
|
17501
17523
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
@@ -17506,7 +17528,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17506
17528
|
manager.bindContainer(params.container);
|
17507
17529
|
}
|
17508
17530
|
replaceRoomFunction(room, manager);
|
17509
|
-
|
17531
|
+
internalEmitter.emit("onCreated");
|
17510
17532
|
_WindowManager.isCreated = true;
|
17511
17533
|
try {
|
17512
17534
|
await initDb();
|
@@ -17537,7 +17559,12 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17537
17559
|
}
|
17538
17560
|
return manager;
|
17539
17561
|
}
|
17540
|
-
static initContainer(manager, container,
|
17562
|
+
static initContainer(manager, container, params) {
|
17563
|
+
const {
|
17564
|
+
chessboard,
|
17565
|
+
overwriteStyles,
|
17566
|
+
fullscreen
|
17567
|
+
} = params;
|
17541
17568
|
if (!_WindowManager.container) {
|
17542
17569
|
_WindowManager.container = container;
|
17543
17570
|
}
|
@@ -17546,13 +17573,17 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17546
17573
|
if (chessboard) {
|
17547
17574
|
sizer.classList.add("netless-window-manager-chess-sizer");
|
17548
17575
|
}
|
17576
|
+
if (fullscreen) {
|
17577
|
+
sizer.classList.add("netless-window-manager-fullscreen");
|
17578
|
+
}
|
17549
17579
|
if (overwriteStyles) {
|
17550
17580
|
const style2 = document.createElement("style");
|
17551
17581
|
style2.textContent = overwriteStyles;
|
17552
17582
|
playground.appendChild(style2);
|
17553
17583
|
}
|
17554
|
-
manager.containerResizeObserver = ContainerResizeObserver.create(playground, sizer, wrapper,
|
17584
|
+
manager.containerResizeObserver = ContainerResizeObserver.create(playground, sizer, wrapper, internalEmitter);
|
17555
17585
|
_WindowManager.wrapper = wrapper;
|
17586
|
+
_WindowManager.sizer = sizer;
|
17556
17587
|
return mainViewElement;
|
17557
17588
|
}
|
17558
17589
|
static get registered() {
|
@@ -17570,11 +17601,11 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17570
17601
|
} else {
|
17571
17602
|
if (_WindowManager.params) {
|
17572
17603
|
const params = _WindowManager.params;
|
17573
|
-
const mainViewElement = _WindowManager.initContainer(this, container, params
|
17604
|
+
const mainViewElement = _WindowManager.initContainer(this, container, params);
|
17574
17605
|
if (this.boxManager) {
|
17575
17606
|
this.boxManager.destroy();
|
17576
17607
|
}
|
17577
|
-
const boxManager = createBoxManager(this, callbacks$1,
|
17608
|
+
const boxManager = createBoxManager(this, callbacks$1, internalEmitter, boxEmitter, {
|
17578
17609
|
collectorContainer: params.collectorContainer,
|
17579
17610
|
collectorStyles: params.collectorStyles,
|
17580
17611
|
prefersColorScheme: params.prefersColorScheme
|
@@ -17587,7 +17618,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17587
17618
|
}
|
17588
17619
|
}
|
17589
17620
|
}
|
17590
|
-
|
17621
|
+
internalEmitter.emit("updateManagerRect");
|
17591
17622
|
(_c = this.appManager) == null ? void 0 : _c.refresh();
|
17592
17623
|
(_d = this.appManager) == null ? void 0 : _d.resetMaximized();
|
17593
17624
|
(_e = this.appManager) == null ? void 0 : _e.resetMinimized();
|
@@ -17613,7 +17644,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17613
17644
|
if (this.appManager) {
|
17614
17645
|
if (this.appManager.rootDirRemoving) {
|
17615
17646
|
return new Promise((resolve, reject) => {
|
17616
|
-
|
17647
|
+
internalEmitter.once("rootDirRemoved").then(async () => {
|
17617
17648
|
try {
|
17618
17649
|
const appId = await this._addApp(params);
|
17619
17650
|
resolve(appId);
|
@@ -17731,6 +17762,18 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17731
17762
|
return false;
|
17732
17763
|
}
|
17733
17764
|
}
|
17765
|
+
async jumpPage(index2) {
|
17766
|
+
if (this.appManager) {
|
17767
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
17768
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
17769
|
+
return false;
|
17770
|
+
}
|
17771
|
+
await this.appManager.setMainViewSceneIndex(index2);
|
17772
|
+
return true;
|
17773
|
+
} else {
|
17774
|
+
return false;
|
17775
|
+
}
|
17776
|
+
}
|
17734
17777
|
async addPage(params) {
|
17735
17778
|
if (this.appManager) {
|
17736
17779
|
const after = params == null ? void 0 : params.after;
|
@@ -17771,7 +17814,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17771
17814
|
var _a;
|
17772
17815
|
this.readonly = readonly;
|
17773
17816
|
(_a = this.boxManager) == null ? void 0 : _a.setReadonly(readonly);
|
17774
|
-
|
17817
|
+
internalEmitter.emit("setReadonly", readonly);
|
17775
17818
|
}
|
17776
17819
|
switchMainViewToWriter() {
|
17777
17820
|
var _a;
|
@@ -17823,6 +17866,14 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17823
17866
|
return;
|
17824
17867
|
(_a = this.boxManager) == null ? void 0 : _a.setMinimized(minimized, false);
|
17825
17868
|
}
|
17869
|
+
setFullscreen(fullscreen) {
|
17870
|
+
var _a;
|
17871
|
+
if (this._fullscreen !== fullscreen) {
|
17872
|
+
this._fullscreen = fullscreen;
|
17873
|
+
(_a = _WindowManager.sizer) == null ? void 0 : _a.classList.toggle("netless-window-manager-fullscreen", fullscreen);
|
17874
|
+
callbacks$1.emit("fullscreenChange", fullscreen);
|
17875
|
+
}
|
17876
|
+
}
|
17826
17877
|
get mainView() {
|
17827
17878
|
if (this.appManager) {
|
17828
17879
|
return this.appManager.mainViewProxy.view;
|
@@ -17917,6 +17968,9 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17917
17968
|
throw new AppManagerNotInitError();
|
17918
17969
|
}
|
17919
17970
|
}
|
17971
|
+
get fullscreen() {
|
17972
|
+
return Boolean(this._fullscreen);
|
17973
|
+
}
|
17920
17974
|
queryAll() {
|
17921
17975
|
var _a;
|
17922
17976
|
return Array.from(((_a = this.appManager) == null ? void 0 : _a.appProxies.values()) || []);
|
@@ -17978,6 +18032,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
17978
18032
|
(_c = this.cursorManager) == null ? void 0 : _c.destroy();
|
17979
18033
|
_WindowManager.container = void 0;
|
17980
18034
|
_WindowManager.wrapper = void 0;
|
18035
|
+
_WindowManager.sizer = void 0;
|
17981
18036
|
_WindowManager.isCreated = false;
|
17982
18037
|
if (_WindowManager.playground) {
|
17983
18038
|
(_d = _WindowManager.playground.parentNode) == null ? void 0 : _d.removeChild(_WindowManager.playground);
|
@@ -18086,7 +18141,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18086
18141
|
}
|
18087
18142
|
_WindowManager.containerSizeRatio = ratio;
|
18088
18143
|
this.containerSizeRatio = ratio;
|
18089
|
-
|
18144
|
+
internalEmitter.emit("containerSizeRatioUpdate", ratio);
|
18090
18145
|
}
|
18091
18146
|
isDynamicPPT(scenes) {
|
18092
18147
|
var _a, _b;
|