@netless/window-manager 0.3.8-canary.2 → 0.3.8-canary.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.8-canary.2",
3
+ "version": "0.3.8-canary.3",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
package/src/AppManager.ts CHANGED
@@ -1,12 +1,24 @@
1
- import { AppAttributes, AppStatus, Events, MagixEventName } from "./constants";
1
+ import pRetry from "p-retry";
2
+ import {
3
+ AppAttributes,
4
+ AppStatus,
5
+ Events,
6
+ MagixEventName
7
+ } from "./constants";
2
8
  import { AppListeners } from "./AppListener";
3
9
  import { AppProxy } from "./AppProxy";
4
10
  import { AttributesDelegate } from "./AttributesDelegate";
11
+ import {
12
+ autorun,
13
+ isPlayer,
14
+ isRoom,
15
+ ScenePathType,
16
+ ViewVisionMode
17
+ } from "white-web-sdk";
5
18
  import { BoxManager } from "./BoxManager";
6
19
  import { callbacks, emitter } from "./index";
7
20
  import { CameraStore } from "./Utils/CameraStore";
8
21
  import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
9
- import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
10
22
  import { log } from "./Utils/log";
11
23
  import { MainViewProxy } from "./MainView";
12
24
  import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
@@ -117,16 +129,28 @@ export class AppManager {
117
129
  for (const id in apps) {
118
130
  if (!this.appProxies.has(id) && !this.appStatus.has(id)) {
119
131
  const app = apps[id];
120
- await this.baseInsertApp(
121
- {
122
- kind: app.kind,
123
- options: app.options,
124
- isDynamicPPT: app.isDynamicPPT,
125
- },
126
- id,
127
- false
128
- );
129
- this.focusByAttributes(apps);
132
+
133
+ pRetry(async () => {
134
+ this.appStatus.set(id, AppStatus.StartCreate);
135
+ // 防御 appAttributes 有可能为 undefined 的情况,这里做一个重试
136
+ const appAttributes = this.attributes[id];
137
+ if (!appAttributes) {
138
+ throw new Error("appAttributes is undefined");
139
+ }
140
+ await this.baseInsertApp(
141
+ {
142
+ kind: app.kind,
143
+ options: app.options,
144
+ isDynamicPPT: app.isDynamicPPT,
145
+ },
146
+ id,
147
+ false
148
+ );
149
+ this.focusByAttributes(apps);
150
+ }, { retries: 3 }).catch(err => {
151
+ console.warn(`[WindowManager]: Insert App Error`, err);
152
+ this.appStatus.delete(id);
153
+ });
130
154
  }
131
155
  }
132
156
  }
@@ -202,7 +226,6 @@ export class AppManager {
202
226
  isAddApp: boolean,
203
227
  focus?: boolean
204
228
  ) {
205
- this.appStatus.set(appId, AppStatus.StartCreate);
206
229
  if (this.appProxies.has(appId)) {
207
230
  console.warn("[WindowManager]: app duplicate exists and cannot be created again");
208
231
  return;
package/src/index.ts CHANGED
@@ -169,7 +169,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
169
169
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
170
170
  private static isCreated = false;
171
171
 
172
- public version = "0.3.8-canary.2";
172
+ public version = "0.3.8-canary.3";
173
173
 
174
174
  public appListeners?: AppListeners;
175
175