@netless/window-manager 0.4.27-canary.0 → 0.4.29
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/App/AppContext.d.ts +1 -1
- package/dist/App/AppProxy.d.ts +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.es.js +22 -17
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/advanced.md +10 -1
- package/docs/api.md +4 -1
- package/package.json +1 -1
- package/src/App/AppContext.ts +8 -4
- package/src/App/AppProxy.ts +2 -5
- package/src/AppManager.ts +2 -2
- package/src/Page/index.ts +7 -8
- package/src/index.ts +13 -3
package/dist/index.d.ts
CHANGED
@@ -144,7 +144,12 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
144
144
|
nextPage(): Promise<boolean>;
|
145
145
|
prevPage(): Promise<boolean>;
|
146
146
|
addPage(params?: AddPageParams): Promise<void>;
|
147
|
-
|
147
|
+
/**
|
148
|
+
* 删除一页
|
149
|
+
* 默认删除当前页, 可以删除指定 index 页
|
150
|
+
* 最低保留一页
|
151
|
+
*/
|
152
|
+
removePage(index?: number): Promise<boolean>;
|
148
153
|
/**
|
149
154
|
* 返回 mainView 的 ScenePath
|
150
155
|
*/
|
package/dist/index.es.js
CHANGED
@@ -1021,12 +1021,16 @@ class AppContext {
|
|
1021
1021
|
}
|
1022
1022
|
};
|
1023
1023
|
this.removePage = async (index) => {
|
1024
|
-
|
1024
|
+
const needRemoveIndex = index === void 0 ? this.pageState.index : index;
|
1025
|
+
if (this.pageState.length === 1) {
|
1026
|
+
console.warn(`[WindowManager]: can not remove the last page`);
|
1027
|
+
return false;
|
1028
|
+
}
|
1029
|
+
if (needRemoveIndex < 0 || needRemoveIndex >= this.pageState.length) {
|
1025
1030
|
console.warn(`[WindowManager]: page index ${index} out of range`);
|
1026
1031
|
return false;
|
1027
1032
|
}
|
1028
|
-
this.appProxy.removeSceneByIndex(
|
1029
|
-
return true;
|
1033
|
+
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
1030
1034
|
};
|
1031
1035
|
this.emitter = appProxy.appEmitter;
|
1032
1036
|
this.isAddApp = appProxy.isAddApp;
|
@@ -1254,16 +1258,15 @@ const log = (...args) => {
|
|
1254
1258
|
};
|
1255
1259
|
const calculateNextIndex = (index, pageState) => {
|
1256
1260
|
let nextIndex = 0;
|
1257
|
-
|
1258
|
-
|
1259
|
-
}
|
1260
|
-
if (pageState.index !== 0 && index !== 0) {
|
1261
|
-
const maxIndex = pageState.length - 1;
|
1261
|
+
const maxIndex = pageState.length - 1;
|
1262
|
+
if (index === pageState.index) {
|
1262
1263
|
if (index === maxIndex) {
|
1263
|
-
nextIndex =
|
1264
|
-
} else
|
1265
|
-
nextIndex = index + 1;
|
1264
|
+
nextIndex = index - 1;
|
1265
|
+
} else {
|
1266
|
+
nextIndex = pageState.index + 1;
|
1266
1267
|
}
|
1268
|
+
} else {
|
1269
|
+
nextIndex = pageState.index;
|
1267
1270
|
}
|
1268
1271
|
return nextIndex;
|
1269
1272
|
};
|
@@ -1604,9 +1607,6 @@ class AppProxy {
|
|
1604
1607
|
async removeSceneByIndex(index) {
|
1605
1608
|
const scenePath = this._pageState.getFullPath(index);
|
1606
1609
|
if (scenePath) {
|
1607
|
-
if (this.pageState.length <= 1) {
|
1608
|
-
return false;
|
1609
|
-
}
|
1610
1610
|
const nextIndex = calculateNextIndex(index, this.pageState);
|
1611
1611
|
this.setSceneIndexWithoutSync(nextIndex);
|
1612
1612
|
this.manager.dispatchInternalEvent(Events.SetAppFocusIndex, {
|
@@ -15048,7 +15048,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15048
15048
|
const _WindowManager = class extends InvisiblePlugin {
|
15049
15049
|
constructor(context) {
|
15050
15050
|
super(context);
|
15051
|
-
this.version = "0.4.
|
15051
|
+
this.version = "0.4.29";
|
15052
15052
|
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", "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.12.4", "white-web-sdk": "2.16.10" } };
|
15053
15053
|
this.emitter = callbacks$1;
|
15054
15054
|
this.viewMode = ViewMode.Broadcaster;
|
@@ -15350,11 +15350,16 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15350
15350
|
}
|
15351
15351
|
async removePage(index) {
|
15352
15352
|
if (this.appManager) {
|
15353
|
-
|
15353
|
+
const needRemoveIndex = index === void 0 ? this.pageState.index : index;
|
15354
|
+
if (this.pageState.length === 1) {
|
15355
|
+
console.warn(`[WindowManager]: can not remove the last page`);
|
15356
|
+
return false;
|
15357
|
+
}
|
15358
|
+
if (needRemoveIndex < 0 || needRemoveIndex >= this.pageState.length) {
|
15354
15359
|
console.warn(`[WindowManager]: index ${index} out of range`);
|
15355
15360
|
return false;
|
15356
15361
|
}
|
15357
|
-
return this.appManager.removeSceneByIndex(
|
15362
|
+
return this.appManager.removeSceneByIndex(needRemoveIndex);
|
15358
15363
|
} else {
|
15359
15364
|
return false;
|
15360
15365
|
}
|