@netless/window-manager 0.4.36 → 0.4.39
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 +13 -1
- package/dist/Register/loader.d.ts +1 -1
- package/dist/index.cjs.js +11 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +48 -37
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +11 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/typings.d.ts +3 -1
- package/package.json +1 -1
- package/src/BoxManager.ts +12 -8
- package/src/Register/index.ts +13 -11
- package/src/Register/loader.ts +27 -23
- package/src/View/MainView.ts +3 -4
- package/src/typings.ts +5 -1
package/dist/index.es.js
CHANGED
@@ -223,30 +223,36 @@ const executeScript = (text2, appName) => {
|
|
223
223
|
const loadApp = async (url, key, name) => {
|
224
224
|
const appName = name || Prefix + key;
|
225
225
|
callbacks$1.emit("loadApp", { kind: key, status: "start" });
|
226
|
+
let text2;
|
226
227
|
try {
|
227
|
-
|
228
|
+
text2 = await getScript(url);
|
228
229
|
if (!text2 || text2.length === 0) {
|
229
230
|
callbacks$1.emit("loadApp", { kind: key, status: "failed", reason: "script is empty." });
|
230
|
-
|
231
|
+
throw new Error("[WindowManager]: script is empty.");
|
231
232
|
}
|
232
|
-
|
233
|
+
} catch (error) {
|
234
|
+
callbacks$1.emit("loadApp", { kind: key, status: "failed", reason: error.message });
|
235
|
+
throw error;
|
236
|
+
}
|
237
|
+
return getResult(text2, appName, key);
|
238
|
+
};
|
239
|
+
const getResult = (text2, appName, key) => {
|
240
|
+
try {
|
241
|
+
const result = executeScript(text2, appName);
|
242
|
+
callbacks$1.emit("loadApp", { kind: key, status: "success" });
|
243
|
+
return result;
|
244
|
+
} catch (error) {
|
245
|
+
if (error.message.includes("Can only have one anonymous define call per script file")) {
|
246
|
+
const define = window.define;
|
247
|
+
if (typeof define == "function" && define.amd) {
|
248
|
+
delete define.amd;
|
249
|
+
}
|
233
250
|
const result = executeScript(text2, appName);
|
234
251
|
callbacks$1.emit("loadApp", { kind: key, status: "success" });
|
235
252
|
return result;
|
236
|
-
} catch (error) {
|
237
|
-
if (error.message.includes("Can only have one anonymous define call per script file")) {
|
238
|
-
const define = window.define;
|
239
|
-
if (typeof define == "function" && define.amd) {
|
240
|
-
delete define.amd;
|
241
|
-
}
|
242
|
-
const result = executeScript(text2, appName);
|
243
|
-
callbacks$1.emit("loadApp", { kind: key, status: "success" });
|
244
|
-
return result;
|
245
|
-
}
|
246
|
-
callbacks$1.emit("loadApp", { kind: key, status: "failed", reason: error.message });
|
247
253
|
}
|
248
|
-
} catch (error) {
|
249
254
|
callbacks$1.emit("loadApp", { kind: key, status: "failed", reason: error.message });
|
255
|
+
throw error;
|
250
256
|
}
|
251
257
|
};
|
252
258
|
async function fetchWithTimeout(resource, options) {
|
@@ -279,11 +285,18 @@ class AppRegister {
|
|
279
285
|
async register(params) {
|
280
286
|
this.appClassesCache.delete(params.kind);
|
281
287
|
this.registered.set(params.kind, params);
|
282
|
-
const
|
288
|
+
const paramSrc = params.src;
|
289
|
+
let srcOrAppOrFunction;
|
283
290
|
let downloadApp;
|
284
|
-
if (typeof
|
291
|
+
if (typeof paramSrc === "string") {
|
292
|
+
srcOrAppOrFunction = () => loadApp(paramSrc, params.kind, params.name);
|
293
|
+
if (this.syncRegisterApp) {
|
294
|
+
this.syncRegisterApp({ kind: params.kind, src: paramSrc, name: params.name });
|
295
|
+
}
|
296
|
+
}
|
297
|
+
if (typeof paramSrc === "function") {
|
285
298
|
downloadApp = async () => {
|
286
|
-
let appClass = await
|
299
|
+
let appClass = await srcOrAppOrFunction();
|
287
300
|
if (appClass) {
|
288
301
|
if (appClass.__esModule) {
|
289
302
|
appClass = appClass.default;
|
@@ -293,13 +306,9 @@ class AppRegister {
|
|
293
306
|
throw new Error(`[WindowManager]: load remote script failed, ${srcOrAppOrFunction}`);
|
294
307
|
}
|
295
308
|
};
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
} else if (typeof srcOrAppOrFunction === "function") {
|
300
|
-
downloadApp = srcOrAppOrFunction;
|
301
|
-
} else {
|
302
|
-
downloadApp = async () => srcOrAppOrFunction;
|
309
|
+
}
|
310
|
+
if (typeof paramSrc === "object") {
|
311
|
+
downloadApp = async () => paramSrc;
|
303
312
|
}
|
304
313
|
this.appClasses.set(params.kind, async () => {
|
305
314
|
let app = this.appClassesCache.get(params.kind);
|
@@ -1769,9 +1778,6 @@ class MainViewProxy {
|
|
1769
1778
|
this.onUpdateContainerSizeRatio = () => {
|
1770
1779
|
const size2 = this.store.getMainViewSize();
|
1771
1780
|
this.sizeChangeHandler(size2);
|
1772
|
-
if (size2.id === this.manager.uid) {
|
1773
|
-
this.setCameraAndSize();
|
1774
|
-
}
|
1775
1781
|
};
|
1776
1782
|
this.onCameraUpdatedByDevice = (camera) => {
|
1777
1783
|
this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid }));
|
@@ -1807,7 +1813,9 @@ class MainViewProxy {
|
|
1807
1813
|
});
|
1808
1814
|
this.sideEffectManager.add(() => {
|
1809
1815
|
return emitter.on("startReconnect", () => {
|
1810
|
-
this.
|
1816
|
+
if (!this.didRelease) {
|
1817
|
+
this.mainView.release();
|
1818
|
+
}
|
1811
1819
|
});
|
1812
1820
|
});
|
1813
1821
|
}
|
@@ -4583,6 +4591,16 @@ class BoxManager {
|
|
4583
4591
|
this.teleBoxManager._prefersColorScheme$.reaction((colorScheme) => {
|
4584
4592
|
callbacks2.emit("prefersColorSchemeChange", colorScheme);
|
4585
4593
|
});
|
4594
|
+
this.teleBoxManager._minimized$.reaction((minimized) => {
|
4595
|
+
if (!minimized) {
|
4596
|
+
setTimeout(() => {
|
4597
|
+
const offset = 1e-3 * (Math.random() > 0.5 ? 1 : -1);
|
4598
|
+
this.teleBoxManager.boxes.forEach((box) => {
|
4599
|
+
box.resize(box.intrinsicWidth + offset, box.intrinsicHeight + offset, true);
|
4600
|
+
});
|
4601
|
+
}, 400);
|
4602
|
+
}
|
4603
|
+
});
|
4586
4604
|
this.teleBoxManager.events.on("minimized", (minimized) => {
|
4587
4605
|
this.context.safeSetAttributes({ minimized });
|
4588
4606
|
if (minimized) {
|
@@ -4594,13 +4612,6 @@ class BoxManager {
|
|
4594
4612
|
this.context.setAppFocus(topBox.id);
|
4595
4613
|
this.focusBox({ appId: topBox.id }, false);
|
4596
4614
|
}
|
4597
|
-
setTimeout(() => {
|
4598
|
-
this.teleBoxManager.boxes.forEach((box) => {
|
4599
|
-
const width = box.width;
|
4600
|
-
const height = box.height;
|
4601
|
-
box._size$.setValue({ width: width + 1e-3, height: height + 1e-3 }, true);
|
4602
|
-
});
|
4603
|
-
}, 100);
|
4604
4615
|
}
|
4605
4616
|
});
|
4606
4617
|
this.teleBoxManager.events.on("maximized", (maximized) => {
|
@@ -15101,7 +15112,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15101
15112
|
const _WindowManager = class extends InvisiblePlugin {
|
15102
15113
|
constructor(context) {
|
15103
15114
|
super(context);
|
15104
|
-
this.version = "0.4.
|
15115
|
+
this.version = "0.4.39";
|
15105
15116
|
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/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" } };
|
15106
15117
|
this.emitter = callbacks$1;
|
15107
15118
|
this.viewMode = ViewMode.Broadcaster;
|