@netless/window-manager 0.3.16 → 0.3.17-canary.0

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.16",
3
+ "version": "0.3.17-canary.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -24,7 +24,7 @@
24
24
  "@juggle/resize-observer": "^3.3.1",
25
25
  "@netless/app-docs-viewer": "0.1.24",
26
26
  "@netless/app-media-player": "0.1.0-beta.5",
27
- "@netless/telebox-insider": "0.2.10",
27
+ "@netless/telebox-insider": "^0.2.16",
28
28
  "emittery": "^0.9.2",
29
29
  "lodash": "^4.17.21",
30
30
  "p-retry": "^4.6.1",
package/src/AppManager.ts CHANGED
@@ -100,7 +100,7 @@ export class AppManager {
100
100
  if (this.boxManager.minimized !== minimized) {
101
101
  if (minimized === true && this.store.focus !== undefined) {
102
102
  this.store.cleanFocus();
103
- this.boxManager.blurFocusBox();
103
+ this.boxManager.blurAllBox();
104
104
  }
105
105
  this.boxManager.setMinimized(Boolean(minimized));
106
106
  }
@@ -208,6 +208,7 @@ export class AppManager {
208
208
  x: box?.intrinsicX,
209
209
  y: box?.intrinsicY,
210
210
  });
211
+ this.store.updateAppState(appProxy.id, AppAttributes.ZIndex, box.zIndex);
211
212
  }
212
213
  if (this.boxManager.minimized) {
213
214
  this.boxManager.setMinimized(false, false);
@@ -395,9 +396,6 @@ export class AppManager {
395
396
  if (appProxy) {
396
397
  appProxy.destroy(false, true, payload.error);
397
398
  }
398
- if (this.boxManager.maximized) {
399
- this.boxManager.focusTopBox();
400
- }
401
399
  break;
402
400
  }
403
401
  case "boxStateChange": {
package/src/AppProxy.ts CHANGED
@@ -172,6 +172,7 @@ export class AppProxy extends Base {
172
172
  app,
173
173
  options,
174
174
  canOperate: this.manager.canOperate,
175
+ smartPosition: this.isAddApp,
175
176
  });
176
177
  } catch (error: any) {
177
178
  console.error(error);
@@ -247,7 +248,8 @@ export class AppProxy extends Base {
247
248
  const sceneIndex = attrs?.[AppAttributes.SceneIndex];
248
249
  const maximized = this.attributes?.["maximized"];
249
250
  const minimized = this.attributes?.["minimized"];
250
- let payload = { maximized, minimized } as AppInitState;
251
+ const zIndex = attrs?.zIndex;
252
+ let payload = { maximized, minimized, zIndex } as AppInitState;
251
253
  if (position) {
252
254
  payload = { ...payload, id: id, x: position.x, y: position.y };
253
255
  }
@@ -74,8 +74,8 @@ export class AttributesDelegate {
74
74
  this.manager.safeUpdateAttributes([Fields.Apps, id, Fields.State], {
75
75
  [AppAttributes.Size]: {},
76
76
  [AppAttributes.Position]: {},
77
- [AppAttributes.SnapshotRect]: {},
78
77
  [AppAttributes.SceneIndex]: 0,
78
+ [AppAttributes.ZIndex]: 100,
79
79
  });
80
80
  }
81
81
 
@@ -31,7 +31,7 @@ export class Context {
31
31
  }
32
32
 
33
33
  public blurFocusBox() {
34
- this.manager.boxManager.blurFocusBox();
34
+ this.manager.boxManager.blurAllBox();
35
35
  }
36
36
 
37
37
  public switchAppToWriter(id: string) {
package/src/BoxManager.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { callbacks, emitter, WindowManager } from "./index";
2
2
  import { debounce, maxBy } from "lodash";
3
- import { DEFAULT_COLLECTOR_STYLE, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
3
+ import { AppAttributes, DEFAULT_COLLECTOR_STYLE, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
4
4
  import {
5
5
  TELE_BOX_MANAGER_EVENT,
6
6
  TELE_BOX_STATE,
@@ -29,6 +29,7 @@ export type CreateBoxParams = {
29
29
  emitter?: Emittery;
30
30
  options?: AddAppOptions;
31
31
  canOperate?: boolean;
32
+ smartPosition?: boolean;
32
33
  };
33
34
 
34
35
  type AppId = { appId: string };
@@ -95,10 +96,8 @@ export class BoxManager {
95
96
  if (this.manager.canOperate) {
96
97
  emitter.emit("focus", { appId: box.id });
97
98
  } else {
98
- this.teleBoxManager.update(box.id, { focus: false });
99
+ this.teleBoxManager.blurBox(box.id);
99
100
  }
100
- } else {
101
- this.blurFocusBox();
102
101
  }
103
102
  });
104
103
  this.teleBoxManager.events.on("dark_mode", darkMode => {
@@ -107,6 +106,9 @@ export class BoxManager {
107
106
  this.teleBoxManager.events.on("prefers_color_scheme", colorScheme => {
108
107
  callbacks.emit("prefersColorSchemeChange", colorScheme);
109
108
  });
109
+ this.teleBoxManager.events.on("z_index", box => {
110
+ this.manager.store.updateAppState(box.id, AppAttributes.ZIndex, box.zIndex);
111
+ });
110
112
  }
111
113
 
112
114
  public get boxState() {
@@ -152,7 +154,7 @@ export class BoxManager {
152
154
  height,
153
155
  id: params.appId,
154
156
  };
155
- this.teleBoxManager.create(createBoxConfig);
157
+ this.teleBoxManager.create(createBoxConfig, params.smartPosition);
156
158
  emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
157
159
  }
158
160
 
@@ -239,6 +241,7 @@ export class BoxManager {
239
241
  y: state.y,
240
242
  width: state.width || 0.5,
241
243
  height: state.height || 0.5,
244
+ zIndex: state.zIndex,
242
245
  },
243
246
  true
244
247
  );
@@ -248,7 +251,7 @@ export class BoxManager {
248
251
  }
249
252
  setTimeout(() => {
250
253
  if (state.focus) {
251
- this.teleBoxManager.update(box.id, { focus: true }, true);
254
+ this.teleBoxManager.focusBox(box.id, true)
252
255
  }
253
256
  }, 50);
254
257
  callbacks.emit("boxStateChange", this.teleBoxManager.state);
@@ -269,7 +272,7 @@ export class BoxManager {
269
272
  }
270
273
 
271
274
  public focusBox({ appId }: AppId, skipUpdate = true): void {
272
- this.teleBoxManager.update(appId, { focus: true }, skipUpdate);
275
+ this.teleBoxManager.focusBox(appId, skipUpdate);
273
276
  }
274
277
 
275
278
  public resizeBox({ appId, width, height, skipUpdate }: ResizeBoxParams): void {
@@ -292,15 +295,7 @@ export class BoxManager {
292
295
  }
293
296
 
294
297
  public blurAllBox(): void {
295
- this.teleBoxManager.updateAll({ focus: false });
296
- }
297
-
298
- public blurFocusBox(): void {
299
- const focusBoxes = this.teleBoxManager.query({ focus: true });
300
- if (focusBoxes.length) {
301
- const box = focusBoxes[0];
302
- this.teleBoxManager.update(box.id, { focus: false });
303
- }
298
+ this.teleBoxManager.blurAll();
304
299
  }
305
300
 
306
301
  public updateAll(config: TeleBoxManagerUpdateConfig): void {
package/src/constants.ts CHANGED
@@ -17,8 +17,8 @@ export const MagixEventName = "__WindowManger";
17
17
  export enum AppAttributes {
18
18
  Size = "size",
19
19
  Position = "position",
20
- SnapshotRect = "SnapshotRect",
21
20
  SceneIndex = "SceneIndex",
21
+ ZIndex = "zIndex",
22
22
  }
23
23
 
24
24
  export enum AppEvents {
package/src/index.ts CHANGED
@@ -121,6 +121,7 @@ export type AppInitState = {
121
121
  minimized?: boolean;
122
122
  sceneIndex?: number;
123
123
  boxState?: TeleBoxState; // 兼容旧版 telebox
124
+ zIndex?: number;
124
125
  };
125
126
 
126
127
  export type EmitterEvent = {
@@ -176,7 +177,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
176
177
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
177
178
  private static isCreated = false;
178
179
 
179
- public version = "0.3.16";
180
+ public version = "0.3.17-canary.0";
180
181
 
181
182
  public appListeners?: AppListeners;
182
183