@netless/window-manager 1.0.7-beta.6 → 1.0.7-beta.8

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": "1.0.7-beta.6",
3
+ "version": "1.0.7-beta.8",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@juggle/resize-observer": "^3.3.1",
35
- "@netless/telebox-insider": "0.3.0-beta.10",
35
+ "@netless/telebox-insider": "0.3.0-beta.14",
36
36
  "emittery": "^0.9.2",
37
37
  "lodash": "^4.17.21",
38
38
  "p-retry": "^4.6.1",
@@ -34,6 +34,7 @@ import { callbacks } from "../callback";
34
34
  export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
35
35
  implements PageController
36
36
  {
37
+ static readonly kind = "AppContext";
37
38
  public readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
38
39
  public readonly mobxUtils = {
39
40
  autorun,
@@ -38,6 +38,7 @@ import { getExtendClass } from "../Utils/extendClass";
38
38
  export type AppEmitter = Emittery<AppEmitterEvent>;
39
39
 
40
40
  export class AppProxy implements PageRemoveService {
41
+ static readonly kind = "AppProxy";
41
42
  public kind: string;
42
43
  public id: string;
43
44
  public scenePath?: string;
@@ -152,7 +153,10 @@ export class AppProxy implements PageRemoveService {
152
153
  appImpl,
153
154
  params.options,
154
155
  appParams?.appOptions,
155
- this.manager.useBoxesStatus ? TELE_BOX_STATE.Normal : undefined
156
+ this.manager.useBoxesStatus ? TELE_BOX_STATE.Normal : undefined,
157
+ params.forceTop,
158
+ params.forceNormal,
159
+ params.isDragContent
156
160
  );
157
161
  } else {
158
162
  throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
@@ -174,9 +178,12 @@ export class AppProxy implements PageRemoveService {
174
178
  app: NetlessApp,
175
179
  options?: setAppOptions,
176
180
  appOptions?: any,
177
- boxStatus?: TeleBoxState
181
+ boxStatus?: TeleBoxState,
182
+ forceTop?: boolean,
183
+ forceNormal?: boolean,
184
+ isDragContent?: boolean
178
185
  ) {
179
- log("setupApp", appId, app, options, boxStatus);
186
+ log("setupApp", appId, app, options, boxStatus, forceTop, forceNormal, isDragContent);
180
187
  if (!this.boxManager) {
181
188
  throw new BoxManagerNotFoundError();
182
189
  }
@@ -219,6 +226,9 @@ export class AppProxy implements PageRemoveService {
219
226
  canOperate: this.manager.canOperate,
220
227
  smartPosition: this.isAddApp,
221
228
  boxStatus,
229
+ forceTop,
230
+ forceNormal,
231
+ isDragContent,
222
232
  });
223
233
  if (this.isAddApp && this.box) {
224
234
  if (boxStatus) {
@@ -311,6 +321,7 @@ export class AppProxy implements PageRemoveService {
311
321
  const minimized = this.attributes?.["minimized"];
312
322
  const boxStatus = this.store.getBoxStatus(id) ?? undefined;
313
323
  const lastNotMinimizedBoxStatus = this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
324
+ const { forceTop, forceNormal, isDragContent } = this.store.getAppAttributes(id);
314
325
  const zIndex = attrs?.zIndex;
315
326
  let payload = { maximized, minimized, zIndex } as AppInitState;
316
327
  if (position) {
@@ -331,6 +342,15 @@ export class AppProxy implements PageRemoveService {
331
342
  if (lastNotMinimizedBoxStatus) {
332
343
  payload = { ...payload, lastNotMinimizedBoxStatus };
333
344
  }
345
+ if (forceTop) {
346
+ payload = { ...payload, forceTop };
347
+ }
348
+ if (forceNormal) {
349
+ payload = { ...payload, forceNormal };
350
+ }
351
+ if (isDragContent) {
352
+ payload = { ...payload, isDragContent };
353
+ }
334
354
  return payload;
335
355
  };
336
356
 
package/src/AppManager.ts CHANGED
@@ -53,6 +53,7 @@ import { getExtendClass } from "./Utils/extendClass";
53
53
  import type { TeleBoxState } from "@netless/telebox-insider";
54
54
 
55
55
  export class AppManager {
56
+ static readonly kind = "AppManager";
56
57
  public displayer: Displayer;
57
58
  public viewManager: ViewManager;
58
59
  public appProxies: Map<string, AppProxy> = new Map();
@@ -602,6 +603,9 @@ export class AppManager {
602
603
  kind: app.kind,
603
604
  options: app.options,
604
605
  isDynamicPPT: app.isDynamicPPT,
606
+ forceNormal: app.forceNormal,
607
+ forceTop: app.forceTop,
608
+ isDragContent: app.isDragContent,
605
609
  },
606
610
  id,
607
611
  false
@@ -53,6 +53,7 @@ export type ICamera = Camera & { id: string };
53
53
  export type ISize = Size & { id: string };
54
54
 
55
55
  export class AttributesDelegate {
56
+ static readonly kind = "AttributesDelegate";
56
57
  constructor(private context: StoreContext) {}
57
58
 
58
59
  public setContext(context: StoreContext) {
@@ -133,7 +134,14 @@ export class AttributesDelegate {
133
134
  attrNames.push("scenes");
134
135
  }
135
136
  const options = pick(params.options, attrNames);
136
- const attrs: AppSyncAttributes = { kind: params.kind, options, isDynamicPPT };
137
+ const attrs: AppSyncAttributes = {
138
+ kind: params.kind,
139
+ options,
140
+ isDynamicPPT,
141
+ forceTop: params.forceTop,
142
+ forceNormal: params.forceNormal,
143
+ isDragContent: params.isDragContent,
144
+ };
137
145
  if (typeof params.src === "string") {
138
146
  attrs.src = params.src;
139
147
  }
package/src/BoxManager.ts CHANGED
@@ -33,6 +33,9 @@ export type CreateBoxParams = {
33
33
  canOperate?: boolean;
34
34
  smartPosition?: boolean;
35
35
  boxStatus?: TeleBoxState;
36
+ forceTop?: boolean;
37
+ forceNormal?: boolean;
38
+ isDragContent?: boolean;
36
39
  };
37
40
 
38
41
  type AppId = { appId: string };
@@ -104,6 +107,7 @@ export const createBoxManager = (
104
107
  };
105
108
 
106
109
  export class BoxManager {
110
+ static readonly kind = "BoxManager";
107
111
  public teleBoxManager: TeleBoxManager;
108
112
 
109
113
  constructor(
@@ -270,6 +274,9 @@ export class BoxManager {
270
274
  height,
271
275
  id: params.appId,
272
276
  boxStatus: params.boxStatus,
277
+ forceTop: params.forceTop,
278
+ forceNormal: params.forceNormal,
279
+ isDragContent: params.isDragContent,
273
280
  };
274
281
  this.teleBoxManager.create(createBoxConfig, params.smartPosition);
275
282
  this.context.emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
@@ -386,6 +393,9 @@ export class BoxManager {
386
393
  zIndex: state.zIndex,
387
394
  boxStatus: state.boxStatus,
388
395
  lastNotMinimizedBoxStatus: state.lastNotMinimizedBoxStatus,
396
+ forceTop: state.forceTop,
397
+ forceNormal: state.forceNormal,
398
+ isDragContent: state.isDragContent,
389
399
  },
390
400
  true
391
401
  );
@@ -26,6 +26,7 @@ export type MoveCursorParams = {
26
26
  const LocalCursorSideEffectId = "local-cursor";
27
27
 
28
28
  export class CursorManager {
29
+ static readonly kind = "CursorManager";
29
30
  public containerRect?: DOMRect;
30
31
  public wrapperRect?: DOMRect;
31
32
  public cursorInstances: Map<string, Cursor> = new Map();
@@ -36,24 +36,28 @@ export function getExtendClass<T extends ExtendClassAble>(
36
36
  baseClass: T,
37
37
  extendClass?: ExtendClass
38
38
  ): T {
39
- switch (baseClass.name) {
40
- case "AppManager":
41
- return (extendClass?.AppManager || AppManager) as T;
42
- case "BoxManager":
43
- return (extendClass?.BoxManager || BoxManager) as T;
44
- case "AttributesDelegate":
45
- return (extendClass?.AttributesDelegate || AttributesDelegate) as T;
46
- case "CursorManager":
47
- return (extendClass?.CursorManager || CursorManager) as T;
48
- case "AppProxy":
49
- return (extendClass?.AppProxy || AppProxy) as T;
50
- case "AppContext":
51
- return (extendClass?.AppContext || AppContext) as T;
52
- case "TeleBoxManager":
53
- return (extendClass?.TeleBoxManager || TeleBoxManager) as T;
54
- case "TeleBoxCollector":
55
- return (extendClass?.TeleBoxCollector || TeleBoxCollector) as T;
56
- default:
57
- return baseClass;
39
+ if (baseClass.kind && extendClass && Object.keys(extendClass).includes(baseClass.kind)) {
40
+ switch (baseClass.kind) {
41
+ case "AppManager":
42
+ return (extendClass?.AppManager || AppManager) as T;
43
+ case "BoxManager":
44
+ return (extendClass?.BoxManager || BoxManager) as T;
45
+ case "AttributesDelegate":
46
+ return (extendClass?.AttributesDelegate || AttributesDelegate) as T;
47
+ case "CursorManager":
48
+ return (extendClass?.CursorManager || CursorManager) as T;
49
+ case "AppProxy":
50
+ return (extendClass?.AppProxy || AppProxy) as T;
51
+ case "AppContext":
52
+ return (extendClass?.AppContext || AppContext) as T;
53
+ case "TeleBoxManager":
54
+ return (extendClass?.TeleBoxManager || TeleBoxManager) as T;
55
+ case "TeleBoxCollector":
56
+ return (extendClass?.TeleBoxCollector || TeleBoxCollector) as T;
57
+ default:
58
+ return baseClass;
59
+ }
60
+ } else {
61
+ return baseClass;
58
62
  }
59
63
  }
package/src/index.ts CHANGED
@@ -97,6 +97,12 @@ export type AddAppParams<TAttributes = any> = {
97
97
  options?: AddAppOptions;
98
98
  // 初始化 attributes
99
99
  attributes?: TAttributes;
100
+ // 强制置顶
101
+ forceTop?: boolean;
102
+ // 强制正常窗口
103
+ forceNormal?: boolean;
104
+ // 是否可以在内容区域拖动
105
+ isDragContent?: boolean;
100
106
  };
101
107
 
102
108
  export type BaseInsertParams = {
@@ -108,6 +114,12 @@ export type BaseInsertParams = {
108
114
  // 初始化 attributes
109
115
  attributes?: any;
110
116
  isDynamicPPT?: boolean;
117
+ // 强制置顶
118
+ forceTop?: boolean;
119
+ // 强制正常窗口
120
+ forceNormal?: boolean;
121
+ // 是否可以在内容区域拖动
122
+ isDragContent?: boolean;
111
123
  };
112
124
 
113
125
  export type AppSyncAttributes = {
@@ -118,6 +130,12 @@ export type AppSyncAttributes = {
118
130
  isDynamicPPT?: boolean;
119
131
  fullPath?: string;
120
132
  createdAt?: number;
133
+ // 强制置顶
134
+ forceTop?: boolean;
135
+ // 强制正常窗口
136
+ forceNormal?: boolean;
137
+ // 是否可以在内容区域拖动
138
+ isDragContent?: boolean;
121
139
  };
122
140
 
123
141
  export type AppInitState = {
@@ -137,6 +155,12 @@ export type AppInitState = {
137
155
  boxStatus?: TeleBoxState;
138
156
  /** 上次非最小化窗口状态 */
139
157
  lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
158
+ // 强制置顶
159
+ forceTop?: boolean;
160
+ // 强制正常窗口
161
+ forceNormal?: boolean;
162
+ // 是否可以在内容区域拖动
163
+ isDragContent?: boolean;
140
164
  };
141
165
 
142
166
  export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
@@ -178,7 +202,7 @@ export class WindowManager
178
202
  extends InvisiblePlugin<WindowMangerAttributes, any>
179
203
  implements PageController
180
204
  {
181
- public static kind = "WindowManager";
205
+ public static readonly kind = "WindowManager";
182
206
  public static displayer: Displayer;
183
207
  public static wrapper?: HTMLElement;
184
208
  public static sizer?: HTMLElement;