@netless/window-manager 1.0.7-beta.5 → 1.0.7-beta.7
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/dist/index.d.ts +15 -2
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/App/AppProxy.ts +22 -3
- package/src/AppManager.ts +3 -0
- package/src/AttributesDelegate.ts +8 -1
- package/src/BoxManager.ts +15 -6
- package/src/index.ts +26 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/window-manager",
|
|
3
|
-
"version": "1.0.7-beta.
|
|
3
|
+
"version": "1.0.7-beta.7",
|
|
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.
|
|
35
|
+
"@netless/telebox-insider": "0.3.0-beta.13",
|
|
36
36
|
"emittery": "^0.9.2",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"p-retry": "^4.6.1",
|
package/src/App/AppProxy.ts
CHANGED
|
@@ -152,7 +152,10 @@ export class AppProxy implements PageRemoveService {
|
|
|
152
152
|
appImpl,
|
|
153
153
|
params.options,
|
|
154
154
|
appParams?.appOptions,
|
|
155
|
-
this.manager.useBoxesStatus ? TELE_BOX_STATE.Normal : undefined
|
|
155
|
+
this.manager.useBoxesStatus ? TELE_BOX_STATE.Normal : undefined,
|
|
156
|
+
params.forceTop,
|
|
157
|
+
params.forceNormal,
|
|
158
|
+
params.isDragContent
|
|
156
159
|
);
|
|
157
160
|
} else {
|
|
158
161
|
throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
|
|
@@ -174,9 +177,12 @@ export class AppProxy implements PageRemoveService {
|
|
|
174
177
|
app: NetlessApp,
|
|
175
178
|
options?: setAppOptions,
|
|
176
179
|
appOptions?: any,
|
|
177
|
-
boxStatus?: TeleBoxState
|
|
180
|
+
boxStatus?: TeleBoxState,
|
|
181
|
+
forceTop?: boolean,
|
|
182
|
+
forceNormal?: boolean,
|
|
183
|
+
isDragContent?: boolean
|
|
178
184
|
) {
|
|
179
|
-
log("setupApp", appId, app, options, boxStatus);
|
|
185
|
+
log("setupApp", appId, app, options, boxStatus, forceTop, forceNormal, isDragContent);
|
|
180
186
|
if (!this.boxManager) {
|
|
181
187
|
throw new BoxManagerNotFoundError();
|
|
182
188
|
}
|
|
@@ -219,6 +225,9 @@ export class AppProxy implements PageRemoveService {
|
|
|
219
225
|
canOperate: this.manager.canOperate,
|
|
220
226
|
smartPosition: this.isAddApp,
|
|
221
227
|
boxStatus,
|
|
228
|
+
forceTop,
|
|
229
|
+
forceNormal,
|
|
230
|
+
isDragContent,
|
|
222
231
|
});
|
|
223
232
|
if (this.isAddApp && this.box) {
|
|
224
233
|
if (boxStatus) {
|
|
@@ -311,6 +320,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
311
320
|
const minimized = this.attributes?.["minimized"];
|
|
312
321
|
const boxStatus = this.store.getBoxStatus(id) ?? undefined;
|
|
313
322
|
const lastNotMinimizedBoxStatus = this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
|
|
323
|
+
const { forceTop, forceNormal, isDragContent } = this.store.getAppAttributes(id);
|
|
314
324
|
const zIndex = attrs?.zIndex;
|
|
315
325
|
let payload = { maximized, minimized, zIndex } as AppInitState;
|
|
316
326
|
if (position) {
|
|
@@ -331,6 +341,15 @@ export class AppProxy implements PageRemoveService {
|
|
|
331
341
|
if (lastNotMinimizedBoxStatus) {
|
|
332
342
|
payload = { ...payload, lastNotMinimizedBoxStatus };
|
|
333
343
|
}
|
|
344
|
+
if (forceTop) {
|
|
345
|
+
payload = { ...payload, forceTop };
|
|
346
|
+
}
|
|
347
|
+
if (forceNormal) {
|
|
348
|
+
payload = { ...payload, forceNormal };
|
|
349
|
+
}
|
|
350
|
+
if (isDragContent) {
|
|
351
|
+
payload = { ...payload, isDragContent };
|
|
352
|
+
}
|
|
334
353
|
return payload;
|
|
335
354
|
};
|
|
336
355
|
|
package/src/AppManager.ts
CHANGED
|
@@ -133,7 +133,14 @@ export class AttributesDelegate {
|
|
|
133
133
|
attrNames.push("scenes");
|
|
134
134
|
}
|
|
135
135
|
const options = pick(params.options, attrNames);
|
|
136
|
-
const attrs: AppSyncAttributes = {
|
|
136
|
+
const attrs: AppSyncAttributes = {
|
|
137
|
+
kind: params.kind,
|
|
138
|
+
options,
|
|
139
|
+
isDynamicPPT,
|
|
140
|
+
forceTop: params.forceTop,
|
|
141
|
+
forceNormal: params.forceNormal,
|
|
142
|
+
isDragContent: params.isDragContent,
|
|
143
|
+
};
|
|
137
144
|
if (typeof params.src === "string") {
|
|
138
145
|
attrs.src = params.src;
|
|
139
146
|
}
|
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 };
|
|
@@ -270,6 +273,9 @@ export class BoxManager {
|
|
|
270
273
|
height,
|
|
271
274
|
id: params.appId,
|
|
272
275
|
boxStatus: params.boxStatus,
|
|
276
|
+
forceTop: params.forceTop,
|
|
277
|
+
forceNormal: params.forceNormal,
|
|
278
|
+
isDragContent: params.isDragContent,
|
|
273
279
|
};
|
|
274
280
|
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
|
275
281
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
|
|
@@ -296,9 +302,9 @@ export class BoxManager {
|
|
|
296
302
|
this.context.emitter.emit("boxesStatusChange", map);
|
|
297
303
|
}
|
|
298
304
|
|
|
299
|
-
public setBoxStatus(appId: string, status?: TeleBoxState): void {
|
|
300
|
-
|
|
301
|
-
}
|
|
305
|
+
// public setBoxStatus(appId: string, status?: TeleBoxState, skipUpdate = false): void {
|
|
306
|
+
// this.teleBoxManager.update(appId, { boxStatus: status }, true);
|
|
307
|
+
// }
|
|
302
308
|
|
|
303
309
|
public setLastNotMinimizedBoxesStatus(status?: Record<string, NotMinimizedBoxState>): void {
|
|
304
310
|
const map = new Map(Object.entries(status ?? {}));
|
|
@@ -307,9 +313,9 @@ export class BoxManager {
|
|
|
307
313
|
this.context.emitter.emit("lastNotMinimizedBoxesStatusChange", map);
|
|
308
314
|
}
|
|
309
315
|
|
|
310
|
-
public setLastNotMinimizedBoxStatus(appId: string, status?: NotMinimizedBoxState): void {
|
|
311
|
-
|
|
312
|
-
}
|
|
316
|
+
// public setLastNotMinimizedBoxStatus(appId: string, status?: NotMinimizedBoxState): void {
|
|
317
|
+
// this.teleBoxManager.update(appId, { lastNotMinimizedBoxStatus: status }, true);
|
|
318
|
+
// }
|
|
313
319
|
|
|
314
320
|
public setupBoxManager(
|
|
315
321
|
createTeleBoxManagerConfig?: CreateTeleBoxManagerConfig
|
|
@@ -386,6 +392,9 @@ export class BoxManager {
|
|
|
386
392
|
zIndex: state.zIndex,
|
|
387
393
|
boxStatus: state.boxStatus,
|
|
388
394
|
lastNotMinimizedBoxStatus: state.lastNotMinimizedBoxStatus,
|
|
395
|
+
forceTop: state.forceTop,
|
|
396
|
+
forceNormal: state.forceNormal,
|
|
397
|
+
isDragContent: state.isDragContent,
|
|
389
398
|
},
|
|
390
399
|
true
|
|
391
400
|
);
|
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 };
|
|
@@ -725,7 +749,7 @@ export class WindowManager
|
|
|
725
749
|
/** 设置指定 box 的状态, 如果为 undefined, 则移除状态*/
|
|
726
750
|
public setBoxStatus(boxId: string, boxStatus?: TELE_BOX_STATE): void {
|
|
727
751
|
if (!this.canOperate) return;
|
|
728
|
-
this.
|
|
752
|
+
this.appManager?.store.setBoxStatus(boxId, boxStatus);
|
|
729
753
|
}
|
|
730
754
|
|
|
731
755
|
/** 设置指定 box 的非最小化状态, 如果为 undefined, 则移除状态 */
|
|
@@ -734,7 +758,7 @@ export class WindowManager
|
|
|
734
758
|
lastNotMinimizedBoxStatus?: NotMinimizedBoxState
|
|
735
759
|
): void {
|
|
736
760
|
if (!this.canOperate) return;
|
|
737
|
-
this.
|
|
761
|
+
this.appManager?.store.setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus);
|
|
738
762
|
}
|
|
739
763
|
|
|
740
764
|
public setFullscreen(fullscreen: boolean): void {
|