@netless/window-manager 1.0.18 → 1.0.20
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/index.d.ts +13 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +285 -13
- package/dist/index.mjs.map +1 -1
- package/docs/cn/box-size-change.md +144 -0
- package/package.json +3 -3
- package/src/App/AppBoxSizeSynchronizer.ts +124 -0
- package/src/App/AppContext.ts +2 -0
- package/src/App/AppProxy.ts +63 -1
- package/src/AppManager.ts +9 -0
- package/src/BoxManager.ts +15 -0
- package/src/ContainerResizeObserver.ts +134 -4
- package/src/constants.ts +4 -0
- package/src/index.ts +13 -1
- package/src/typings.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -56,6 +56,8 @@ const DEFAULT_CONTAINER_RATIO = 9 / 16;
|
|
|
56
56
|
const ROOT_DIR = "/";
|
|
57
57
|
const INIT_DIR = "/init";
|
|
58
58
|
const SETUP_APP_DELAY = 50;
|
|
59
|
+
const BOX_SIZE_SETTLE_DELAY = 650;
|
|
60
|
+
const CONTAINER_STATE_LOG_DEBOUNCE = 1e3;
|
|
59
61
|
const callbacks = new Emittery();
|
|
60
62
|
class AppCreateQueue {
|
|
61
63
|
constructor() {
|
|
@@ -1016,9 +1018,11 @@ class AppContext {
|
|
|
1016
1018
|
const view = this.getView();
|
|
1017
1019
|
if (view) {
|
|
1018
1020
|
view.divElement = dom;
|
|
1021
|
+
this.appProxy.scheduleBoxSizeSync();
|
|
1019
1022
|
setTimeout(() => {
|
|
1020
1023
|
var _a;
|
|
1021
1024
|
(_a = this.getRoom()) == null ? void 0 : _a.refreshViewSize();
|
|
1025
|
+
this.appProxy.scheduleBoxSizeSync();
|
|
1022
1026
|
callbacks.emit("onAppViewMounted", { appId: this.appId, view });
|
|
1023
1027
|
}, 1e3);
|
|
1024
1028
|
}
|
|
@@ -5337,6 +5341,10 @@ const createBoxManager = (manager, callbacks2, emitter, boxEmitter2, options) =>
|
|
|
5337
5341
|
var _a;
|
|
5338
5342
|
return (_a = manager.appManager) == null ? void 0 : _a.notifyContainerRectUpdate(rect);
|
|
5339
5343
|
},
|
|
5344
|
+
scheduleAppBoxSizeSync: (appId) => {
|
|
5345
|
+
var _a;
|
|
5346
|
+
return (_a = manager.appManager) == null ? void 0 : _a.scheduleAppBoxSizeSync(appId);
|
|
5347
|
+
},
|
|
5340
5348
|
cleanFocus: () => {
|
|
5341
5349
|
var _a;
|
|
5342
5350
|
return (_a = manager.appManager) == null ? void 0 : _a.store.cleanFocus();
|
|
@@ -5415,6 +5423,9 @@ class BoxManager {
|
|
|
5415
5423
|
});
|
|
5416
5424
|
}, 200)
|
|
5417
5425
|
);
|
|
5426
|
+
this.teleBoxManager.events.on("visual_resize", (box) => {
|
|
5427
|
+
this.context.scheduleAppBoxSizeSync(box.id);
|
|
5428
|
+
});
|
|
5418
5429
|
this.teleBoxManager.events.on("focused", (box) => {
|
|
5419
5430
|
if (box) {
|
|
5420
5431
|
if (this.canOperate) {
|
|
@@ -5437,6 +5448,7 @@ class BoxManager {
|
|
|
5437
5448
|
this.teleBoxManager.events.on(
|
|
5438
5449
|
"box_status",
|
|
5439
5450
|
(box) => {
|
|
5451
|
+
this.context.scheduleAppBoxSizeSync(box.id);
|
|
5440
5452
|
if (this.canOperate) {
|
|
5441
5453
|
this.context.setBoxStatus(box.id, box.boxStatus);
|
|
5442
5454
|
}
|
|
@@ -5523,6 +5535,7 @@ class BoxManager {
|
|
|
5523
5535
|
setBoxesStatus(status) {
|
|
5524
5536
|
const map = new Map(Object.entries(status != null ? status : {}));
|
|
5525
5537
|
this.teleBoxManager.setBoxesStatus(map, true);
|
|
5538
|
+
this.context.scheduleAppBoxSizeSync();
|
|
5526
5539
|
this.context.callbacks.emit("onBoxesStatusChange", map);
|
|
5527
5540
|
this.context.emitter.emit("boxesStatusChange", map);
|
|
5528
5541
|
}
|
|
@@ -5615,6 +5628,7 @@ class BoxManager {
|
|
|
5615
5628
|
if (state.minimized != null) {
|
|
5616
5629
|
this.teleBoxManager.setMinimized(Boolean(state.minimized), true);
|
|
5617
5630
|
}
|
|
5631
|
+
this.context.scheduleAppBoxSizeSync(box.id);
|
|
5618
5632
|
}, 50);
|
|
5619
5633
|
if (!state.boxStatus) {
|
|
5620
5634
|
this.context.callbacks.emit("boxStateChange", this.teleBoxManager.state);
|
|
@@ -5628,6 +5642,7 @@ class BoxManager {
|
|
|
5628
5642
|
const containerRect = { x: 0, y: 0, width: rect.width, height: rect.height };
|
|
5629
5643
|
this.teleBoxManager.setContainerRect(containerRect);
|
|
5630
5644
|
this.context.notifyContainerRectUpdate(this.teleBoxManager.containerRect);
|
|
5645
|
+
this.context.scheduleAppBoxSizeSync();
|
|
5631
5646
|
}
|
|
5632
5647
|
}
|
|
5633
5648
|
moveBox({ appId, x, y }) {
|
|
@@ -5638,6 +5653,7 @@ class BoxManager {
|
|
|
5638
5653
|
}
|
|
5639
5654
|
resizeBox({ appId, width, height, skipUpdate }) {
|
|
5640
5655
|
this.teleBoxManager.update(appId, { width, height }, skipUpdate);
|
|
5656
|
+
this.context.scheduleAppBoxSizeSync(appId);
|
|
5641
5657
|
}
|
|
5642
5658
|
setBoxMinSize(params) {
|
|
5643
5659
|
this.teleBoxManager.update(
|
|
@@ -5648,6 +5664,7 @@ class BoxManager {
|
|
|
5648
5664
|
},
|
|
5649
5665
|
true
|
|
5650
5666
|
);
|
|
5667
|
+
this.context.scheduleAppBoxSizeSync(params.appId);
|
|
5651
5668
|
}
|
|
5652
5669
|
setBoxTitle(params) {
|
|
5653
5670
|
this.teleBoxManager.update(params.appId, { title: params.title }, true);
|
|
@@ -5661,10 +5678,12 @@ class BoxManager {
|
|
|
5661
5678
|
setMaximized(maximized, skipUpdate = true) {
|
|
5662
5679
|
if (maximized !== this.maximized) {
|
|
5663
5680
|
this.teleBoxManager.setMaximized(maximized, skipUpdate);
|
|
5681
|
+
this.context.scheduleAppBoxSizeSync();
|
|
5664
5682
|
}
|
|
5665
5683
|
}
|
|
5666
5684
|
setMinimized(minimized, skipUpdate = true) {
|
|
5667
5685
|
this.teleBoxManager.setMinimized(minimized, skipUpdate);
|
|
5686
|
+
this.context.scheduleAppBoxSizeSync();
|
|
5668
5687
|
}
|
|
5669
5688
|
focusTopBox() {
|
|
5670
5689
|
const boxes = this.teleBoxManager.query();
|
|
@@ -5677,6 +5696,7 @@ class BoxManager {
|
|
|
5677
5696
|
}
|
|
5678
5697
|
updateBox(id, payload, skipUpdate = true) {
|
|
5679
5698
|
this.teleBoxManager.update(id, payload, skipUpdate);
|
|
5699
|
+
this.context.scheduleAppBoxSizeSync(id);
|
|
5680
5700
|
}
|
|
5681
5701
|
setReadonly(readonly) {
|
|
5682
5702
|
this.teleBoxManager.setReadonly(readonly);
|
|
@@ -7493,6 +7513,97 @@ const calculateNextIndex = (index2, pageState) => {
|
|
|
7493
7513
|
return nextIndex;
|
|
7494
7514
|
};
|
|
7495
7515
|
const boxEmitter = new Emittery();
|
|
7516
|
+
const BOX_SIZE_EPSILON = 0.5;
|
|
7517
|
+
const BOX_SIZE_CONFIRM_DELAY = 100;
|
|
7518
|
+
const sizesEqual = (left, right) => Boolean(
|
|
7519
|
+
left && Math.abs(left.width - right.width) <= BOX_SIZE_EPSILON && Math.abs(left.height - right.height) <= BOX_SIZE_EPSILON
|
|
7520
|
+
);
|
|
7521
|
+
class AppBoxSizeSynchronizer {
|
|
7522
|
+
constructor(appId, getView, getElement, notify, onError) {
|
|
7523
|
+
this.appId = appId;
|
|
7524
|
+
this.getView = getView;
|
|
7525
|
+
this.getElement = getElement;
|
|
7526
|
+
this.notify = notify;
|
|
7527
|
+
this.onError = onError;
|
|
7528
|
+
this.destroyed = false;
|
|
7529
|
+
this.schedule = () => {
|
|
7530
|
+
if (this.destroyed)
|
|
7531
|
+
return;
|
|
7532
|
+
if (this.timer != null)
|
|
7533
|
+
clearTimeout(this.timer);
|
|
7534
|
+
if (this.frame != null) {
|
|
7535
|
+
cancelAnimationFrame(this.frame);
|
|
7536
|
+
this.frame = void 0;
|
|
7537
|
+
}
|
|
7538
|
+
this.pendingSize = void 0;
|
|
7539
|
+
this.timer = setTimeout(() => {
|
|
7540
|
+
this.timer = void 0;
|
|
7541
|
+
this.frame = requestAnimationFrame(this.confirmDOMSize);
|
|
7542
|
+
}, BOX_SIZE_SETTLE_DELAY);
|
|
7543
|
+
};
|
|
7544
|
+
this.confirmDOMSize = () => {
|
|
7545
|
+
var _a, _b, _c, _d;
|
|
7546
|
+
this.frame = void 0;
|
|
7547
|
+
if (this.destroyed)
|
|
7548
|
+
return;
|
|
7549
|
+
const element2 = this.getElement();
|
|
7550
|
+
if (!element2)
|
|
7551
|
+
return;
|
|
7552
|
+
const rect = element2.getBoundingClientRect();
|
|
7553
|
+
const size2 = { width: rect.width, height: rect.height };
|
|
7554
|
+
if (!Number.isFinite(size2.width) || !Number.isFinite(size2.height) || size2.width <= 0 || size2.height <= 0) {
|
|
7555
|
+
this.pendingSize = void 0;
|
|
7556
|
+
return;
|
|
7557
|
+
}
|
|
7558
|
+
if (!sizesEqual(this.pendingSize, size2)) {
|
|
7559
|
+
this.pendingSize = size2;
|
|
7560
|
+
this.timer = setTimeout(() => {
|
|
7561
|
+
this.timer = void 0;
|
|
7562
|
+
this.frame = requestAnimationFrame(this.confirmDOMSize);
|
|
7563
|
+
}, BOX_SIZE_CONFIRM_DELAY);
|
|
7564
|
+
return;
|
|
7565
|
+
}
|
|
7566
|
+
this.pendingSize = void 0;
|
|
7567
|
+
const view = this.getView();
|
|
7568
|
+
if (view && !sizesEqual(view.size, size2)) {
|
|
7569
|
+
try {
|
|
7570
|
+
if (typeof view.refreshSize === "function") {
|
|
7571
|
+
view.refreshSize(size2.width, size2.height);
|
|
7572
|
+
} else if (typeof ((_a = view.screen) == null ? void 0 : _a.refreshSize) === "function") {
|
|
7573
|
+
const resizeObserver = view.screen.resizeObserver;
|
|
7574
|
+
(_b = resizeObserver == null ? void 0 : resizeObserver.disconnect) == null ? void 0 : _b.call(resizeObserver);
|
|
7575
|
+
try {
|
|
7576
|
+
view.screen.refreshSize(size2.width, size2.height);
|
|
7577
|
+
} finally {
|
|
7578
|
+
if (view.divElement)
|
|
7579
|
+
(_c = resizeObserver == null ? void 0 : resizeObserver.observe) == null ? void 0 : _c.call(resizeObserver, view.divElement);
|
|
7580
|
+
}
|
|
7581
|
+
}
|
|
7582
|
+
} catch (error) {
|
|
7583
|
+
(_d = this.onError) == null ? void 0 : _d.call(this, error);
|
|
7584
|
+
}
|
|
7585
|
+
}
|
|
7586
|
+
if (!sizesEqual(this.lastNotifiedSize, size2)) {
|
|
7587
|
+
this.lastNotifiedSize = size2;
|
|
7588
|
+
this.notify({ appId: this.appId, ...size2 });
|
|
7589
|
+
}
|
|
7590
|
+
};
|
|
7591
|
+
}
|
|
7592
|
+
destroy() {
|
|
7593
|
+
this.destroyed = true;
|
|
7594
|
+
if (this.timer != null) {
|
|
7595
|
+
clearTimeout(this.timer);
|
|
7596
|
+
this.timer = void 0;
|
|
7597
|
+
}
|
|
7598
|
+
if (this.frame != null) {
|
|
7599
|
+
cancelAnimationFrame(this.frame);
|
|
7600
|
+
this.frame = void 0;
|
|
7601
|
+
}
|
|
7602
|
+
this.pendingSize = void 0;
|
|
7603
|
+
this.lastNotifiedSize = void 0;
|
|
7604
|
+
}
|
|
7605
|
+
}
|
|
7606
|
+
const APP_SETUP_WATCHDOG_TIMEOUT = 1e4;
|
|
7496
7607
|
const _AppProxy = class {
|
|
7497
7608
|
constructor(params, manager, appId, isAddApp) {
|
|
7498
7609
|
var _a;
|
|
@@ -7503,6 +7614,10 @@ const _AppProxy = class {
|
|
|
7503
7614
|
this.viewManager = this.manager.viewManager;
|
|
7504
7615
|
this.store = this.manager.store;
|
|
7505
7616
|
this.status = "normal";
|
|
7617
|
+
this.scheduleBoxSizeSync = () => {
|
|
7618
|
+
if (this.status !== "destroyed")
|
|
7619
|
+
this.boxSizeSynchronizer.schedule();
|
|
7620
|
+
};
|
|
7506
7621
|
this.getAppInitState = (id) => {
|
|
7507
7622
|
var _a2, _b, _c, _d;
|
|
7508
7623
|
const attrs = this.store.getAppState(id);
|
|
@@ -7597,6 +7712,26 @@ const _AppProxy = class {
|
|
|
7597
7712
|
this.stateKey = `${this.id}_state`;
|
|
7598
7713
|
this.appProxies.set(this.id, this);
|
|
7599
7714
|
this.appEmitter = new Emittery();
|
|
7715
|
+
this.boxSizeSynchronizer = new AppBoxSizeSynchronizer(
|
|
7716
|
+
this.id,
|
|
7717
|
+
() => this.view,
|
|
7718
|
+
() => {
|
|
7719
|
+
var _a2, _b;
|
|
7720
|
+
return ((_a2 = this.view) == null ? void 0 : _a2.divElement) || ((_b = this.box) == null ? void 0 : _b.$content);
|
|
7721
|
+
},
|
|
7722
|
+
(payload) => {
|
|
7723
|
+
this.appEmitter.emit("boxSizeChange", payload).catch((error) => {
|
|
7724
|
+
var _a2;
|
|
7725
|
+
(_a2 = this.Logger) == null ? void 0 : _a2.error(
|
|
7726
|
+
`[WindowManager]: failed to notify app box size change: ${error}`
|
|
7727
|
+
);
|
|
7728
|
+
});
|
|
7729
|
+
},
|
|
7730
|
+
(error) => {
|
|
7731
|
+
var _a2;
|
|
7732
|
+
(_a2 = this.Logger) == null ? void 0 : _a2.error(`[WindowManager]: failed to refresh app view size: ${error}`);
|
|
7733
|
+
}
|
|
7734
|
+
);
|
|
7600
7735
|
this.appListener = this.makeAppEventListener(this.id);
|
|
7601
7736
|
this.isAddApp = isAddApp;
|
|
7602
7737
|
this.initScenes();
|
|
@@ -7725,8 +7860,12 @@ const _AppProxy = class {
|
|
|
7725
7860
|
this.Logger && this.Logger.info(
|
|
7726
7861
|
`[WindowManager]: setup app ${this.kind}, appId: ${appId}`
|
|
7727
7862
|
);
|
|
7728
|
-
const
|
|
7863
|
+
const setupResult = await this.runAppSetup(appId, app, context);
|
|
7864
|
+
if (!setupResult.succeeded)
|
|
7865
|
+
return;
|
|
7866
|
+
const { result } = setupResult;
|
|
7729
7867
|
this.appResult = result;
|
|
7868
|
+
this.scheduleBoxSizeSync();
|
|
7730
7869
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
|
7731
7870
|
this.afterSetupApp(boxInitState);
|
|
7732
7871
|
this.fixMobileSize();
|
|
@@ -7763,6 +7902,36 @@ const _AppProxy = class {
|
|
|
7763
7902
|
throw new Error(`[WindowManager]: app setup error: ${error.message}`);
|
|
7764
7903
|
}
|
|
7765
7904
|
}
|
|
7905
|
+
async runAppSetup(appId, app, context) {
|
|
7906
|
+
var _a;
|
|
7907
|
+
this.clearSetupWatchdog();
|
|
7908
|
+
this.setupWatchdogTimer = setTimeout(() => {
|
|
7909
|
+
var _a2;
|
|
7910
|
+
this.setupWatchdogTimer = void 0;
|
|
7911
|
+
if (this.status === "destroyed")
|
|
7912
|
+
return;
|
|
7913
|
+
(_a2 = this.Logger) == null ? void 0 : _a2.warn(
|
|
7914
|
+
`[WindowManager]: hydrate timeout, stage: app setup, kind: ${this.kind}, appId: ${appId}, timeout: ${APP_SETUP_WATCHDOG_TIMEOUT}ms`
|
|
7915
|
+
);
|
|
7916
|
+
}, APP_SETUP_WATCHDOG_TIMEOUT);
|
|
7917
|
+
try {
|
|
7918
|
+
return { succeeded: true, result: await app.setup(context) };
|
|
7919
|
+
} catch (error) {
|
|
7920
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7921
|
+
(_a = this.Logger) == null ? void 0 : _a.error(
|
|
7922
|
+
`[WindowManager]: app setup error, kind: ${this.kind}, appId: ${appId}, status: ${this.status}, error: ${message}`
|
|
7923
|
+
);
|
|
7924
|
+
return { succeeded: false };
|
|
7925
|
+
} finally {
|
|
7926
|
+
this.clearSetupWatchdog();
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
clearSetupWatchdog() {
|
|
7930
|
+
if (this.setupWatchdogTimer != null) {
|
|
7931
|
+
clearTimeout(this.setupWatchdogTimer);
|
|
7932
|
+
this.setupWatchdogTimer = void 0;
|
|
7933
|
+
}
|
|
7934
|
+
}
|
|
7766
7935
|
fixMobileSize() {
|
|
7767
7936
|
var _a, _b;
|
|
7768
7937
|
const box = (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
|
@@ -7934,6 +8103,8 @@ const _AppProxy = class {
|
|
|
7934
8103
|
if (this.status === "destroyed")
|
|
7935
8104
|
return;
|
|
7936
8105
|
this.status = "destroyed";
|
|
8106
|
+
this.clearSetupWatchdog();
|
|
8107
|
+
this.boxSizeSynchronizer.destroy();
|
|
7937
8108
|
try {
|
|
7938
8109
|
await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
|
|
7939
8110
|
await this.appEmitter.emit("destroy", { error });
|
|
@@ -8637,6 +8808,15 @@ class AppManager {
|
|
|
8637
8808
|
});
|
|
8638
8809
|
callbacks.emit("onBoxResize", payload);
|
|
8639
8810
|
}
|
|
8811
|
+
this.scheduleAppBoxSizeSync(payload.appId);
|
|
8812
|
+
};
|
|
8813
|
+
this.scheduleAppBoxSizeSync = (appId) => {
|
|
8814
|
+
var _a;
|
|
8815
|
+
if (appId) {
|
|
8816
|
+
(_a = this.appProxies.get(appId)) == null ? void 0 : _a.scheduleBoxSizeSync();
|
|
8817
|
+
} else {
|
|
8818
|
+
this.appProxies.forEach((appProxy) => appProxy.scheduleBoxSizeSync());
|
|
8819
|
+
}
|
|
8640
8820
|
};
|
|
8641
8821
|
this.onBoxFocus = (payload) => {
|
|
8642
8822
|
this.windowManger.safeSetAttributes({ focus: payload.appId });
|
|
@@ -9328,16 +9508,59 @@ class AppManager {
|
|
|
9328
9508
|
AppManager.kind = "AppManager";
|
|
9329
9509
|
const ResizeObserver = window.ResizeObserver || ResizeObserver$1;
|
|
9330
9510
|
class ContainerResizeObserver {
|
|
9331
|
-
constructor(emitter) {
|
|
9511
|
+
constructor(emitter, logger, getInternalState) {
|
|
9332
9512
|
this.emitter = emitter;
|
|
9513
|
+
this.getInternalState = getInternalState;
|
|
9333
9514
|
this.updateSizerLocalConsole = new LocalConsole("updateSizer", 100);
|
|
9515
|
+
this.flushContainerStateLog = () => {
|
|
9516
|
+
var _a, _b, _c, _d;
|
|
9517
|
+
this.containerStateLogTimer = void 0;
|
|
9518
|
+
const pendingState = this.pendingContainerState;
|
|
9519
|
+
this.pendingContainerState = void 0;
|
|
9520
|
+
if (!pendingState || !this.containerStateArgusLog || !this.container || !this.sizer || !this.wrapper) {
|
|
9521
|
+
return;
|
|
9522
|
+
}
|
|
9523
|
+
const internalState = (_a = this.getInternalState) == null ? void 0 : _a.call(this);
|
|
9524
|
+
const root = this.container.parentElement;
|
|
9525
|
+
const rootRect = root == null ? void 0 : root.getBoundingClientRect();
|
|
9526
|
+
const playgroundRect = this.container.getBoundingClientRect();
|
|
9527
|
+
const sizerRect = this.sizer.getBoundingClientRect();
|
|
9528
|
+
const wrapperRect = this.wrapper.getBoundingClientRect();
|
|
9529
|
+
const mainViewRect = (_b = internalState == null ? void 0 : internalState.mainViewElement) == null ? void 0 : _b.getBoundingClientRect();
|
|
9530
|
+
const rootStyle = root ? window.getComputedStyle(root) : void 0;
|
|
9531
|
+
this.containerStateArgusLog.log(
|
|
9532
|
+
`origin: ${pendingState.origin || "unknown"}, connected: ${Boolean(
|
|
9533
|
+
root == null ? void 0 : root.isConnected
|
|
9534
|
+
)}, observed: ${this.formatSize(
|
|
9535
|
+
pendingState.observedSize || playgroundRect
|
|
9536
|
+
)}, root: ${this.formatSize(rootRect)}, playground: ${this.formatSize(
|
|
9537
|
+
playgroundRect
|
|
9538
|
+
)}, sizer: ${this.formatSize(sizerRect)}, wrapper: ${this.formatSize(
|
|
9539
|
+
wrapperRect
|
|
9540
|
+
)}, mainViewDOM: ${this.formatSize(mainViewRect)}, mainViewSize: ${this.formatSize(
|
|
9541
|
+
internalState == null ? void 0 : internalState.mainViewSize
|
|
9542
|
+
)}, teleBoxRect: ${this.formatSize(
|
|
9543
|
+
internalState == null ? void 0 : internalState.teleBoxContainerRect
|
|
9544
|
+
)}, didRelease: ${(_c = internalState == null ? void 0 : internalState.mainViewDidRelease) != null ? _c : "unknown"}, ratio: ${(_d = internalState == null ? void 0 : internalState.containerSizeRatio) != null ? _d : "unknown"}, display: ${(rootStyle == null ? void 0 : rootStyle.display) || "unknown"}, visibility: ${(rootStyle == null ? void 0 : rootStyle.visibility) || "unknown"}, clientRects: ${(root == null ? void 0 : root.getClientRects().length) || 0}, inViewport: ${rootRect ? rootRect.bottom > 0 && rootRect.right > 0 && rootRect.top < window.innerHeight && rootRect.left < window.innerWidth : false}`
|
|
9545
|
+
);
|
|
9546
|
+
};
|
|
9547
|
+
if (logger) {
|
|
9548
|
+
this.containerStateArgusLog = new ArgusLog(logger, "containerState");
|
|
9549
|
+
}
|
|
9334
9550
|
}
|
|
9335
|
-
static create(container, sizer, wrapper, emitter) {
|
|
9336
|
-
const containerResizeObserver = new ContainerResizeObserver(
|
|
9551
|
+
static create(container, sizer, wrapper, emitter, logger, getInternalState) {
|
|
9552
|
+
const containerResizeObserver = new ContainerResizeObserver(
|
|
9553
|
+
emitter,
|
|
9554
|
+
logger,
|
|
9555
|
+
getInternalState
|
|
9556
|
+
);
|
|
9337
9557
|
containerResizeObserver.observePlaygroundSize(container, sizer, wrapper);
|
|
9338
9558
|
return containerResizeObserver;
|
|
9339
9559
|
}
|
|
9340
9560
|
observePlaygroundSize(container, sizer, wrapper) {
|
|
9561
|
+
this.container = container;
|
|
9562
|
+
this.sizer = sizer;
|
|
9563
|
+
this.wrapper = wrapper;
|
|
9341
9564
|
this.updateSizer(
|
|
9342
9565
|
container.getBoundingClientRect(),
|
|
9343
9566
|
sizer,
|
|
@@ -9360,6 +9583,7 @@ class ContainerResizeObserver {
|
|
|
9360
9583
|
this.containerResizeObserver.observe(container);
|
|
9361
9584
|
}
|
|
9362
9585
|
updateSizer({ width, height }, sizer, wrapper, origin) {
|
|
9586
|
+
const observedSize = { width, height };
|
|
9363
9587
|
if (width && height) {
|
|
9364
9588
|
if (height / width > WindowManager.containerSizeRatio) {
|
|
9365
9589
|
height = width * WindowManager.containerSizeRatio;
|
|
@@ -9380,13 +9604,48 @@ class ContainerResizeObserver {
|
|
|
9380
9604
|
origin
|
|
9381
9605
|
});
|
|
9382
9606
|
}
|
|
9607
|
+
this.scheduleContainerStateLog(origin, observedSize);
|
|
9608
|
+
}
|
|
9609
|
+
logCurrentState(origin) {
|
|
9610
|
+
this.scheduleContainerStateLog(origin);
|
|
9611
|
+
}
|
|
9612
|
+
scheduleContainerStateLog(origin, observedSize) {
|
|
9613
|
+
if (!this.containerStateArgusLog || !this.container || !this.sizer || !this.wrapper)
|
|
9614
|
+
return;
|
|
9615
|
+
this.pendingContainerState = {
|
|
9616
|
+
origin,
|
|
9617
|
+
observedSize: observedSize ? { width: observedSize.width, height: observedSize.height } : void 0
|
|
9618
|
+
};
|
|
9619
|
+
if (this.containerStateLogTimer != null) {
|
|
9620
|
+
clearTimeout(this.containerStateLogTimer);
|
|
9621
|
+
}
|
|
9622
|
+
this.containerStateLogTimer = setTimeout(
|
|
9623
|
+
this.flushContainerStateLog,
|
|
9624
|
+
CONTAINER_STATE_LOG_DEBOUNCE
|
|
9625
|
+
);
|
|
9626
|
+
}
|
|
9627
|
+
formatSize(rect) {
|
|
9628
|
+
if (!rect)
|
|
9629
|
+
return "unknown";
|
|
9630
|
+
return `${Math.round(rect.width * 100) / 100}x${Math.round(rect.height * 100) / 100}`;
|
|
9383
9631
|
}
|
|
9384
9632
|
disconnect() {
|
|
9385
|
-
var _a, _b;
|
|
9633
|
+
var _a, _b, _c;
|
|
9386
9634
|
this.updateSizerLocalConsole.destroy();
|
|
9387
|
-
(
|
|
9388
|
-
|
|
9635
|
+
if (this.containerStateLogTimer != null) {
|
|
9636
|
+
clearTimeout(this.containerStateLogTimer);
|
|
9637
|
+
this.containerStateLogTimer = void 0;
|
|
9638
|
+
}
|
|
9639
|
+
this.pendingContainerState = void 0;
|
|
9640
|
+
(_a = this.containerStateArgusLog) == null ? void 0 : _a.destroy();
|
|
9641
|
+
this.containerStateArgusLog = void 0;
|
|
9642
|
+
(_b = this.containerResizeObserver) == null ? void 0 : _b.disconnect();
|
|
9643
|
+
(_c = this.disposer) == null ? void 0 : _c.call(this);
|
|
9389
9644
|
this.disposer = void 0;
|
|
9645
|
+
this.container = void 0;
|
|
9646
|
+
this.sizer = void 0;
|
|
9647
|
+
this.wrapper = void 0;
|
|
9648
|
+
this.getInternalState = void 0;
|
|
9390
9649
|
}
|
|
9391
9650
|
}
|
|
9392
9651
|
class PageStateImpl {
|
|
@@ -10243,8 +10502,8 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
|
10243
10502
|
const _WindowManager = class extends InvisiblePlugin {
|
|
10244
10503
|
constructor(context) {
|
|
10245
10504
|
super(context);
|
|
10246
|
-
this.version = "1.0.
|
|
10247
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.
|
|
10505
|
+
this.version = "1.0.20";
|
|
10506
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.57" }, "devDependencies": { "@hyrious/dts": "^0.2.2", "@netless/app-docs-viewer": "^0.2.19", "@netless/app-media-player": "0.1.4", "@netless/app-presentation": "^0.1.10", "@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.30", "@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", "side-effect-manager": "0.1.5", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.9.9", "vitest": "^0.14.1", "white-web-sdk": "^2.16.57" } };
|
|
10248
10507
|
this.emitter = callbacks;
|
|
10249
10508
|
this.viewMode = ViewMode.Broadcaster;
|
|
10250
10509
|
this.isReplay = isPlayer(this.displayer);
|
|
@@ -10274,7 +10533,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
|
10274
10533
|
);
|
|
10275
10534
|
};
|
|
10276
10535
|
_WindowManager.displayer = context.displayer;
|
|
10277
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.
|
|
10536
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.57" }, "devDependencies": { "@hyrious/dts": "^0.2.2", "@netless/app-docs-viewer": "^0.2.19", "@netless/app-media-player": "0.1.4", "@netless/app-presentation": "^0.1.10", "@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.30", "@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", "side-effect-manager": "0.1.5", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.9.9", "vitest": "^0.14.1", "white-web-sdk": "^2.16.57" } };
|
|
10278
10537
|
this.emitter.on("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
|
|
10279
10538
|
}
|
|
10280
10539
|
get Logger() {
|
|
@@ -10433,7 +10692,19 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
|
10433
10692
|
playground,
|
|
10434
10693
|
sizer,
|
|
10435
10694
|
wrapper,
|
|
10436
|
-
internalEmitter
|
|
10695
|
+
internalEmitter,
|
|
10696
|
+
manager.Logger,
|
|
10697
|
+
() => {
|
|
10698
|
+
var _a, _b;
|
|
10699
|
+
const mainView = (_a = manager.appManager) == null ? void 0 : _a.mainViewProxy.view;
|
|
10700
|
+
return {
|
|
10701
|
+
mainViewElement: mainView == null ? void 0 : mainView.divElement,
|
|
10702
|
+
mainViewSize: mainView == null ? void 0 : mainView.size,
|
|
10703
|
+
teleBoxContainerRect: (_b = manager.boxManager) == null ? void 0 : _b.teleBoxManager.containerRect,
|
|
10704
|
+
mainViewDidRelease: Boolean(mainView == null ? void 0 : mainView.didRelease),
|
|
10705
|
+
containerSizeRatio: manager.containerSizeRatio
|
|
10706
|
+
};
|
|
10707
|
+
}
|
|
10437
10708
|
);
|
|
10438
10709
|
_WindowManager.wrapper = wrapper;
|
|
10439
10710
|
_WindowManager.sizer = sizer;
|
|
@@ -10443,7 +10714,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
|
10443
10714
|
return appRegister.registered;
|
|
10444
10715
|
}
|
|
10445
10716
|
bindContainer(container) {
|
|
10446
|
-
var _a, _b, _c, _d, _e, _f;
|
|
10717
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
10447
10718
|
if (isRoom(this.displayer) && this.room.phase !== RoomPhase.Connected) {
|
|
10448
10719
|
throw new BindContainerRoomPhaseInvalidError();
|
|
10449
10720
|
}
|
|
@@ -10481,7 +10752,8 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
|
10481
10752
|
(_d = this.appManager) == null ? void 0 : _d.resetMinimized();
|
|
10482
10753
|
(_e = this.appManager) == null ? void 0 : _e.displayerWritableListener(!this.room.isWritable);
|
|
10483
10754
|
_WindowManager.container = container;
|
|
10484
|
-
(_f = this.
|
|
10755
|
+
(_f = this.containerResizeObserver) == null ? void 0 : _f.logCurrentState("bindContainer");
|
|
10756
|
+
(_g = this.extendPluginManager) == null ? void 0 : _g.refreshContainer(container);
|
|
10485
10757
|
}
|
|
10486
10758
|
bindCollectorContainer(container) {
|
|
10487
10759
|
if (_WindowManager.isCreated && this.boxManager) {
|