@netless/window-manager 0.4.61-beta.0 → 0.4.62

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/docs/api.md CHANGED
@@ -275,7 +275,7 @@ manager.setContainerSizeRatio(10 / 16)
275
275
  <h2 id="events">event callback</h2>
276
276
 
277
277
  ```typescript
278
- manager.callbacks.on(events, listener)
278
+ manager.emitter.on(events, listener)
279
279
  ```
280
280
 
281
281
  | name | type | default | desc |
package/docs/cn/api.md CHANGED
@@ -273,7 +273,7 @@ manager.setContainerSizeRatio(10 / 16)
273
273
  <h2 id="events">事件回调</h2>
274
274
 
275
275
  ```typescript
276
- manager.callbacks.on(events, listener)
276
+ manager.emitter.on(events, listener)
277
277
  ```
278
278
 
279
279
  | name | type | default | desc |
@@ -306,4 +306,4 @@ type PageState = {
306
306
  index: number;
307
307
  length: number;
308
308
  }
309
- ```
309
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.61-beta.0",
3
+ "version": "0.4.62",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "video.js": ">=7"
34
34
  },
35
35
  "devDependencies": {
36
- "@netless/app-docs-viewer": "^0.2.15",
36
+ "@netless/app-docs-viewer": "^0.2.16",
37
37
  "@netless/app-media-player": "0.1.0-beta.5",
38
38
  "@rollup/plugin-commonjs": "^20.0.0",
39
39
  "@rollup/plugin-node-resolve": "^13.0.4",
@@ -208,6 +208,15 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
208
208
  return true;
209
209
  };
210
210
 
211
+ public jumpPage = async (index: number): Promise<boolean> => {
212
+ if (!(0 <= index && index < this.pageState.length)) {
213
+ console.warn("[WindowManager] nextPage: index out of range");
214
+ return false;
215
+ }
216
+ this.appProxy.setSceneIndex(index);
217
+ return true;
218
+ };
219
+
211
220
  public prevPage = async (): Promise<boolean> => {
212
221
  const nextIndex = this.pageState.index - 1;
213
222
  if (nextIndex < 0) {
package/src/AppManager.ts CHANGED
@@ -739,7 +739,7 @@ export class AppManager {
739
739
  const success = this.setMainViewFocusPath(scenePath);
740
740
  if (success) {
741
741
  this.store.setMainViewScenePath(scenePath);
742
- this.safeSetAttributes({ _mainSceneIndex: index });
742
+ this.store.setMainViewSceneIndex(index);
743
743
  this.dispatchSetMainViewScenePath(scenePath);
744
744
  }
745
745
  } else {
@@ -750,6 +750,7 @@ export class AppManager {
750
750
 
751
751
  private dispatchSetMainViewScenePath(scenePath: string): void {
752
752
  this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
753
+ callbacks.emit("mainViewScenePathChange", scenePath);
753
754
  // 兼容 15 的 SDK, 需要 room 的当前 ScenePath
754
755
  setScenePath(this.room, scenePath);
755
756
  }
@@ -13,6 +13,7 @@ export type PageState = {
13
13
  export interface PageController {
14
14
  nextPage: () => Promise<boolean>;
15
15
  prevPage: () => Promise<boolean>;
16
+ jumpPage: (index: number) => Promise<boolean>;
16
17
  addPage: (params?: AddPageParams) => Promise<void>;
17
18
  removePage: (index: number) => Promise<boolean>;
18
19
  pageState: PageState;
package/src/index.ts CHANGED
@@ -515,6 +515,19 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
515
515
  }
516
516
  }
517
517
 
518
+ public async jumpPage(index: number): Promise<boolean> {
519
+ if (this.appManager) {
520
+ if (index < 0 || index >= this.pageState.length) {
521
+ console.warn(`[WindowManager]: index ${index} out of range`);
522
+ return false;
523
+ }
524
+ await this.appManager.setMainViewSceneIndex(index);
525
+ return true;
526
+ } else {
527
+ return false;
528
+ }
529
+ }
530
+
518
531
  public async addPage(params?: AddPageParams): Promise<void> {
519
532
  if (this.appManager) {
520
533
  const after = params?.after;