@netless/window-manager 0.4.73-beta.0 → 0.4.73
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 +1093 -40
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -164
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/App/AppContext.ts +13 -8
- package/src/App/AppProxy.ts +3 -8
- package/src/App/MagixEvent/index.ts +38 -38
- package/src/App/Storage/StorageEvent.ts +13 -13
- package/src/App/Storage/index.ts +265 -242
- package/src/App/Storage/typings.ts +4 -2
- package/src/App/Storage/utils.ts +3 -3
- package/src/AppListener.ts +5 -5
- package/src/AppManager.ts +6 -19
- package/src/AttributesDelegate.ts +5 -7
- package/src/BoxEmitter.ts +12 -6
- package/src/BoxManager.ts +1 -1
- package/src/ContainerResizeObserver.ts +1 -1
- package/src/Cursor/Cursor.svelte +3 -1
- package/src/Cursor/Cursor.ts +1 -0
- package/src/Cursor/index.ts +1 -1
- package/src/Helper.ts +67 -15
- package/src/InternalEmitter.ts +4 -3
- package/src/Page/index.ts +1 -1
- package/src/Register/index.ts +5 -7
- package/src/Register/loader.ts +1 -1
- package/src/Register/storage.ts +13 -13
- package/src/Utils/Common.ts +10 -5
- package/src/Utils/Reactive.ts +26 -25
- package/src/Utils/RoomHacker.ts +1 -1
- package/src/Utils/error.ts +0 -1
- package/src/View/IframeBridge.ts +627 -583
- package/src/View/MainView.ts +8 -6
- package/src/callback.ts +7 -1
- package/src/index.ts +34 -24
- package/src/typings.ts +11 -6
- package/dist/App/AppContext.d.ts +0 -79
- package/dist/App/AppPageStateImpl.d.ts +0 -17
- package/dist/App/AppProxy.d.ts +0 -67
- package/dist/App/MagixEvent/index.d.ts +0 -29
- package/dist/App/Storage/StorageEvent.d.ts +0 -8
- package/dist/App/Storage/index.d.ts +0 -39
- package/dist/App/Storage/typings.d.ts +0 -22
- package/dist/App/Storage/utils.d.ts +0 -5
- package/dist/App/index.d.ts +0 -2
- package/dist/AppListener.d.ts +0 -21
- package/dist/AppManager.d.ts +0 -110
- package/dist/AttributesDelegate.d.ts +0 -91
- package/dist/BoxEmitter.d.ts +0 -34
- package/dist/BoxManager.d.ts +0 -98
- package/dist/BuiltinApps.d.ts +0 -5
- package/dist/ContainerResizeObserver.d.ts +0 -11
- package/dist/Cursor/Cursor.d.ts +0 -43
- package/dist/Cursor/icons.d.ts +0 -3
- package/dist/Cursor/icons2.d.ts +0 -4
- package/dist/Cursor/index.d.ts +0 -55
- package/dist/Helper.d.ts +0 -11
- package/dist/InternalEmitter.d.ts +0 -34
- package/dist/Page/PageController.d.ts +0 -21
- package/dist/Page/index.d.ts +0 -3
- package/dist/PageState.d.ts +0 -9
- package/dist/ReconnectRefresher.d.ts +0 -24
- package/dist/RedoUndo.d.ts +0 -18
- package/dist/Register/index.d.ts +0 -28
- package/dist/Register/loader.d.ts +0 -4
- package/dist/Register/storage.d.ts +0 -8
- package/dist/Utils/AppCreateQueue.d.ts +0 -15
- package/dist/Utils/Common.d.ts +0 -22
- package/dist/Utils/Reactive.d.ts +0 -6
- package/dist/Utils/RoomHacker.d.ts +0 -3
- package/dist/Utils/error.d.ts +0 -27
- package/dist/Utils/log.d.ts +0 -1
- package/dist/View/IframeBridge.d.ts +0 -146
- package/dist/View/MainView.d.ts +0 -58
- package/dist/View/ViewManager.d.ts +0 -13
- package/dist/callback.d.ts +0 -38
- package/dist/constants.d.ts +0 -48
- package/dist/typings.d.ts +0 -84
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "0.4.73
|
3
|
+
"version": "0.4.73",
|
4
4
|
"description": "Multi-window mode for Netless Whiteboard",
|
5
5
|
"author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
|
6
6
|
"license": "MIT",
|
@@ -13,6 +13,14 @@
|
|
13
13
|
"docs",
|
14
14
|
"src"
|
15
15
|
],
|
16
|
+
"scripts": {
|
17
|
+
"build": "vite build && npm run type-gen",
|
18
|
+
"lint": "eslint --ext .ts,.tsx,.svelte . && prettier --check .",
|
19
|
+
"predev": "npm run type-gen",
|
20
|
+
"prettier": "prettier --write .",
|
21
|
+
"test": "vitest",
|
22
|
+
"type-gen": "dts src/index.ts -o dist/index.d.ts"
|
23
|
+
},
|
16
24
|
"peerDependencies": {
|
17
25
|
"jspdf": "2.5.1",
|
18
26
|
"white-web-sdk": "^2.16.0"
|
@@ -28,11 +36,11 @@
|
|
28
36
|
"emittery": "^0.9.2",
|
29
37
|
"lodash": "^4.17.21",
|
30
38
|
"p-retry": "^4.6.1",
|
31
|
-
"side-effect-manager": "0.1.5",
|
32
39
|
"uuid": "^7.0.3",
|
33
40
|
"video.js": ">=7"
|
34
41
|
},
|
35
42
|
"devDependencies": {
|
43
|
+
"@hyrious/dts": "^0.2.2",
|
36
44
|
"@netless/app-docs-viewer": "^0.2.17",
|
37
45
|
"@netless/app-media-player": "0.1.0-beta.6",
|
38
46
|
"@rollup/plugin-commonjs": "^20.0.0",
|
@@ -59,19 +67,11 @@
|
|
59
67
|
"prettier-plugin-svelte": "^2.4.0",
|
60
68
|
"rollup-plugin-analyzer": "^4.0.0",
|
61
69
|
"rollup-plugin-styles": "^3.14.1",
|
70
|
+
"side-effect-manager": "0.1.5",
|
62
71
|
"svelte": "^3.42.4",
|
63
72
|
"typescript": "^4.5.5",
|
64
|
-
"vite": "^2.
|
73
|
+
"vite": "^2.9.9",
|
65
74
|
"vitest": "^0.14.1",
|
66
75
|
"white-web-sdk": "2.16.43"
|
67
|
-
},
|
68
|
-
"scripts": {
|
69
|
-
"build": "vite build && yarn type-gen",
|
70
|
-
"build:lib:types": "tsc --emitDeclarationOnly",
|
71
|
-
"lint": "eslint --ext .ts,.tsx,.svelte . && prettier --check .",
|
72
|
-
"predev": "yarn type-gen",
|
73
|
-
"prettier": "prettier --write .",
|
74
|
-
"test": "vitest",
|
75
|
-
"type-gen": "tsc --emitDeclarationOnly"
|
76
76
|
}
|
77
|
-
}
|
77
|
+
}
|
package/src/App/AppContext.ts
CHANGED
@@ -29,7 +29,6 @@ import type {
|
|
29
29
|
} from "./MagixEvent";
|
30
30
|
import type { AddPageParams, PageController, PageState } from "../Page";
|
31
31
|
import { internalEmitter } from "../InternalEmitter";
|
32
|
-
import { WindowManager } from "../index";
|
33
32
|
import { callbacks } from "../callback";
|
34
33
|
|
35
34
|
export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
|
@@ -92,9 +91,7 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
|
|
92
91
|
setTimeout(() => {
|
93
92
|
// 渲染需要时间,延迟 refresh
|
94
93
|
this.getRoom()?.refreshViewSize();
|
95
|
-
|
96
|
-
callbacks.emit("onAppViewMounted", {appId: this.appId, view});
|
97
|
-
}
|
94
|
+
callbacks.emit("onAppViewMounted", { appId: this.appId, view });
|
98
95
|
}, 1000);
|
99
96
|
}
|
100
97
|
};
|
@@ -164,7 +161,10 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
|
|
164
161
|
* @param defaultState Default state for initial storage creation.
|
165
162
|
* @returns
|
166
163
|
*/
|
167
|
-
public createStorage = <TState extends {}>(
|
164
|
+
public createStorage = <TState extends {}>(
|
165
|
+
storeId: string,
|
166
|
+
defaultState?: TState
|
167
|
+
): Storage<TState> => {
|
168
168
|
const storage = new Storage(this, storeId, defaultState);
|
169
169
|
this.emitter.on("destroy", () => {
|
170
170
|
storage.destroy();
|
@@ -256,8 +256,8 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
|
|
256
256
|
console.warn(`[WindowManager]: page index ${index} out of range`);
|
257
257
|
return false;
|
258
258
|
}
|
259
|
-
return this.appProxy.removeSceneByIndex(needRemoveIndex)
|
260
|
-
}
|
259
|
+
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
260
|
+
};
|
261
261
|
|
262
262
|
public get pageState(): PageState {
|
263
263
|
return this.appProxy.pageState;
|
@@ -269,6 +269,11 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
|
|
269
269
|
|
270
270
|
/** Dispatch a local event to `manager.onAppEvent()`. */
|
271
271
|
public dispatchAppEvent(type: string, value?: any): void {
|
272
|
-
internalEmitter.emit(`custom-${this.kind}` as any, {
|
272
|
+
internalEmitter.emit(`custom-${this.kind}` as any, {
|
273
|
+
kind: this.kind,
|
274
|
+
appId: this.appId,
|
275
|
+
type,
|
276
|
+
value,
|
277
|
+
});
|
273
278
|
}
|
274
279
|
}
|
package/src/App/AppProxy.ts
CHANGED
@@ -30,7 +30,6 @@ import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
|
30
30
|
import type { PageRemoveService, PageState } from "../Page";
|
31
31
|
import { calculateNextIndex } from "../Page";
|
32
32
|
import { boxEmitter } from "../BoxEmitter";
|
33
|
-
import { WindowManager } from "../index";
|
34
33
|
import { callbacks } from "../callback";
|
35
34
|
|
36
35
|
export type AppEmitter = Emittery<AppEmitterEvent>;
|
@@ -196,9 +195,7 @@ export class AppProxy implements PageRemoveService {
|
|
196
195
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
197
196
|
this.afterSetupApp(boxInitState);
|
198
197
|
this.fixMobileSize();
|
199
|
-
|
200
|
-
callbacks.emit("onAppSetup", appId);
|
201
|
-
}
|
198
|
+
callbacks.emit("onAppSetup", appId);
|
202
199
|
}, SETUP_APP_DELAY);
|
203
200
|
});
|
204
201
|
this.boxManager?.createBox({
|
@@ -212,7 +209,7 @@ export class AppProxy implements PageRemoveService {
|
|
212
209
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
213
210
|
this.store.updateAppState(appId, AppAttributes.Size, {
|
214
211
|
width: this.box.intrinsicWidth,
|
215
|
-
height: this.box.intrinsicHeight
|
212
|
+
height: this.box.intrinsicHeight,
|
216
213
|
});
|
217
214
|
this.boxManager.focusBox({ appId }, false);
|
218
215
|
}
|
@@ -396,9 +393,7 @@ export class AppProxy implements PageRemoveService {
|
|
396
393
|
private setFocusScenePathHandler = debounce((fullPath: string | undefined) => {
|
397
394
|
if (this.view && fullPath && fullPath !== this.view?.focusScenePath) {
|
398
395
|
setViewFocusScenePath(this.view, fullPath);
|
399
|
-
|
400
|
-
callbacks.emit("onAppScenePathChange", {appId: this.id, view:this.view});
|
401
|
-
}
|
396
|
+
callbacks.emit("onAppScenePathChange", { appId: this.id, view: this.view });
|
402
397
|
}
|
403
398
|
}, 50);
|
404
399
|
|
@@ -1,68 +1,68 @@
|
|
1
1
|
import type {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
MagixEventListenerOptions as WhiteMagixListenerOptions,
|
3
|
+
Event as WhiteEvent,
|
4
|
+
EventPhase as WhiteEventPhase,
|
5
|
+
Scope as WhiteScope,
|
6
6
|
} from "white-web-sdk";
|
7
7
|
|
8
8
|
export interface MagixEventListenerOptions extends WhiteMagixListenerOptions {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
/**
|
10
|
+
* Rapid emitted callbacks will be slowed down to this interval (in ms).
|
11
|
+
*/
|
12
|
+
fireInterval?: number;
|
13
|
+
/**
|
14
|
+
* If `true`, sent events will reach self-listeners after committed to server.
|
15
|
+
* Otherwise the events will reach self-listeners immediately.
|
16
|
+
*/
|
17
|
+
fireSelfEventAfterCommit?: boolean;
|
18
18
|
}
|
19
19
|
|
20
20
|
export interface MagixEventMessage<
|
21
|
-
|
22
|
-
|
21
|
+
TPayloads = any,
|
22
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
23
23
|
> extends Omit<WhiteEvent, "scope" | "phase"> {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
/** Event name */
|
25
|
+
event: TEvent;
|
26
|
+
/** Event Payload */
|
27
|
+
payload: TPayloads[TEvent];
|
28
|
+
/** Whiteboard ID of the client who dispatched the event. It will be AdminObserverId for system events. */
|
29
|
+
authorId: number;
|
30
|
+
scope: `${WhiteScope}`;
|
31
|
+
phase: `${WhiteEventPhase}`;
|
32
32
|
}
|
33
33
|
|
34
34
|
export type MagixEventTypes<TPayloads = any> = Extract<keyof TPayloads, string>;
|
35
35
|
|
36
36
|
export type MagixEventPayload<
|
37
|
-
|
38
|
-
|
37
|
+
TPayloads = any,
|
38
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
39
39
|
> = TPayloads[TEvent];
|
40
40
|
|
41
41
|
export type MagixEventDispatcher<TPayloads = any> = <
|
42
|
-
|
42
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
43
43
|
>(
|
44
|
-
|
45
|
-
|
44
|
+
event: TEvent,
|
45
|
+
payload: TPayloads[TEvent]
|
46
46
|
) => void;
|
47
47
|
|
48
48
|
export type MagixEventHandler<
|
49
|
-
|
50
|
-
|
49
|
+
TPayloads = any,
|
50
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
51
51
|
> = (message: MagixEventMessage<TPayloads, TEvent>) => void;
|
52
52
|
|
53
|
-
export type MagixEventListenerDisposer = () => void
|
53
|
+
export type MagixEventListenerDisposer = () => void;
|
54
54
|
|
55
55
|
export type MagixEventAddListener<TPayloads = any> = <
|
56
|
-
|
56
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
57
57
|
>(
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
event: TEvent,
|
59
|
+
handler: MagixEventHandler<TPayloads, TEvent>,
|
60
|
+
options?: MagixEventListenerOptions | undefined
|
61
61
|
) => MagixEventListenerDisposer;
|
62
62
|
|
63
63
|
export type MagixEventRemoveListener<TPayloads = any> = <
|
64
|
-
|
64
|
+
TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>
|
65
65
|
>(
|
66
|
-
|
67
|
-
|
66
|
+
event: TEvent,
|
67
|
+
handler?: MagixEventHandler<TPayloads, TEvent>
|
68
68
|
) => void;
|
@@ -1,21 +1,21 @@
|
|
1
1
|
export type StorageEventListener<T> = (event: T) => void;
|
2
2
|
|
3
3
|
export class StorageEvent<TMessage> {
|
4
|
-
|
4
|
+
listeners = new Set<StorageEventListener<TMessage>>();
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
get length(): number {
|
7
|
+
return this.listeners.size;
|
8
|
+
}
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
dispatch(message: TMessage): void {
|
11
|
+
this.listeners.forEach(callback => callback(message));
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
addListener(listener: StorageEventListener<TMessage>): void {
|
15
|
+
this.listeners.add(listener);
|
16
|
+
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
removeListener(listener: StorageEventListener<TMessage>): void {
|
19
|
+
this.listeners.delete(listener);
|
20
|
+
}
|
21
21
|
}
|