@netless/window-manager 1.0.0-canary.24 → 1.0.0-canary.27

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.
Files changed (83) hide show
  1. package/dist/App/AppContext.d.ts +1 -1
  2. package/dist/App/WhiteboardView.d.ts +6 -4
  3. package/dist/AppListener.d.ts +0 -2
  4. package/dist/BoxManager.d.ts +2 -1
  5. package/dist/BuiltinApps.d.ts +3 -0
  6. package/dist/Cursor/index.d.ts +3 -2
  7. package/dist/Helper.d.ts +3 -1
  8. package/dist/callback.d.ts +5 -0
  9. package/dist/constants.d.ts +0 -2
  10. package/dist/index.cjs.js +82 -12
  11. package/dist/index.d.ts +16 -9
  12. package/dist/index.es.js +1620 -704
  13. package/dist/index.umd.js +82 -12
  14. package/dist/src/App/AppContext.d.ts +78 -0
  15. package/dist/src/App/AppPageStateImpl.d.ts +21 -0
  16. package/dist/src/App/AppProxy.d.ts +98 -0
  17. package/dist/src/App/MagixEvent/index.d.ts +29 -0
  18. package/dist/src/App/Storage/StorageEvent.d.ts +8 -0
  19. package/dist/src/App/Storage/index.d.ts +39 -0
  20. package/dist/src/App/Storage/typings.d.ts +22 -0
  21. package/dist/src/App/Storage/utils.d.ts +5 -0
  22. package/dist/src/App/WhiteboardView.d.ts +27 -0
  23. package/dist/src/App/index.d.ts +4 -0
  24. package/dist/src/App/type.d.ts +21 -0
  25. package/dist/src/AppListener.d.ts +19 -0
  26. package/dist/src/AppManager.d.ts +107 -0
  27. package/dist/src/AttributesDelegate.d.ts +83 -0
  28. package/dist/src/BoxEmitter.d.ts +34 -0
  29. package/dist/src/BoxManager.d.ts +102 -0
  30. package/dist/src/BuiltinApps.d.ts +8 -0
  31. package/dist/src/Cursor/Cursor.d.ts +39 -0
  32. package/dist/src/Cursor/icons.d.ts +3 -0
  33. package/dist/src/Cursor/index.d.ts +46 -0
  34. package/dist/src/Helper.d.ts +19 -0
  35. package/dist/src/InternalEmitter.d.ts +38 -0
  36. package/dist/src/Page/PageController.d.ts +21 -0
  37. package/dist/src/Page/index.d.ts +3 -0
  38. package/dist/src/PageState.d.ts +9 -0
  39. package/dist/src/ReconnectRefresher.d.ts +24 -0
  40. package/dist/src/RedoUndo.d.ts +18 -0
  41. package/dist/src/Register/index.d.ts +28 -0
  42. package/dist/src/Register/loader.d.ts +4 -0
  43. package/dist/src/Register/storage.d.ts +8 -0
  44. package/dist/src/Utils/AppCreateQueue.d.ts +15 -0
  45. package/dist/src/Utils/Common.d.ts +23 -0
  46. package/dist/src/Utils/Reactive.d.ts +6 -0
  47. package/dist/src/Utils/RoomHacker.d.ts +3 -0
  48. package/dist/src/Utils/error.d.ts +27 -0
  49. package/dist/src/Utils/log.d.ts +1 -0
  50. package/dist/src/View/CameraSynchronizer.d.ts +17 -0
  51. package/dist/src/View/MainView.d.ts +59 -0
  52. package/dist/src/View/ViewManager.d.ts +13 -0
  53. package/dist/src/View/ViewSync.d.ts +24 -0
  54. package/dist/src/callback.d.ts +29 -0
  55. package/dist/src/constants.d.ts +51 -0
  56. package/dist/src/image.d.ts +19 -0
  57. package/dist/src/index.d.ts +267 -0
  58. package/dist/src/shim.d.ts +11 -0
  59. package/dist/src/typings.d.ts +88 -0
  60. package/dist/style.css +1 -1
  61. package/dist/typings.d.ts +6 -0
  62. package/docs/app-context.md +68 -26
  63. package/package.json +10 -5
  64. package/playwright.config.ts +28 -0
  65. package/pnpm-lock.yaml +516 -30
  66. package/src/App/AppContext.ts +14 -6
  67. package/src/App/AppProxy.ts +17 -7
  68. package/src/App/WhiteboardView.ts +23 -18
  69. package/src/AppListener.ts +1 -21
  70. package/src/AppManager.ts +2 -1
  71. package/src/BoxManager.ts +32 -24
  72. package/src/BuiltinApps.ts +5 -0
  73. package/src/Cursor/Cursor.ts +6 -2
  74. package/src/Cursor/index.ts +5 -5
  75. package/src/Helper.ts +23 -5
  76. package/src/View/CameraSynchronizer.ts +5 -9
  77. package/src/View/MainView.ts +3 -1
  78. package/src/callback.ts +1 -0
  79. package/src/constants.ts +0 -2
  80. package/src/index.ts +69 -45
  81. package/src/style.css +2 -45
  82. package/src/typings.ts +6 -0
  83. package/vite.config.js +5 -3
@@ -0,0 +1,51 @@
1
+ export declare enum Events {
2
+ AppMove = "AppMove",
3
+ AppFocus = "AppFocus",
4
+ AppResize = "AppResize",
5
+ AppBoxStateChange = "AppBoxStateChange",
6
+ GetAttributes = "GetAttributes",
7
+ UpdateWindowManagerWrapper = "UpdateWindowManagerWrapper",
8
+ WindowCreated = "WindowCreated",
9
+ SetMainViewScenePath = "SetMainViewScenePath",
10
+ SetMainViewSceneIndex = "SetMainViewSceneIndex",
11
+ SetAppFocusIndex = "SetAppFocusIndex",
12
+ SwitchViewsToFreedom = "SwitchViewsToFreedom",
13
+ CursorMove = "CursorMove",
14
+ RootDirRemoved = "RootDirRemoved",
15
+ Refresh = "Refresh",
16
+ InitMainViewCamera = "InitMainViewCamera"
17
+ }
18
+ export declare const MagixEventName = "__WindowManger";
19
+ export declare const EnsureReconnectEvent = "__WindowMangerEnsureReconnected__";
20
+ export declare enum AppAttributes {
21
+ Size = "size",
22
+ Position = "position",
23
+ SceneIndex = "SceneIndex",
24
+ ZIndex = "zIndex",
25
+ Visible = "visible",
26
+ Ratio = "ratio",
27
+ StageRatio = "stageRatio",
28
+ Draggable = "draggable",
29
+ Resizable = "resizable"
30
+ }
31
+ export declare enum AppEvents {
32
+ setBoxSize = "setBoxSize",
33
+ setBoxMinSize = "setBoxMinSize",
34
+ destroy = "destroy"
35
+ }
36
+ export declare enum AppStatus {
37
+ StartCreate = "StartCreate"
38
+ }
39
+ export declare enum CursorState {
40
+ Leave = "leave",
41
+ Normal = "normal"
42
+ }
43
+ export declare const REQUIRE_VERSION = "2.16.1";
44
+ export declare const MIN_WIDTH: number;
45
+ export declare const MIN_HEIGHT: number;
46
+ export declare const SET_SCENEPATH_DELAY = 100;
47
+ export declare const DEFAULT_CONTAINER_RATIO: number;
48
+ export declare const ROOT_DIR = "/";
49
+ export declare const INIT_DIR = "/init";
50
+ export declare const SETUP_APP_DELAY = 50;
51
+ export declare const MAX_PAGE_SIZE = 500;
@@ -0,0 +1,19 @@
1
+ declare module "*.svg" {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module "*.jpg" {
7
+ const content: string;
8
+ export default content;
9
+ }
10
+
11
+ declare module "*.png" {
12
+ const content: string;
13
+ export default content;
14
+ }
15
+
16
+ declare module "*.gif" {
17
+ const content: string;
18
+ export default content;
19
+ }
@@ -0,0 +1,267 @@
1
+ import { AppManager } from "./AppManager";
2
+ import { CursorManager } from "./Cursor";
3
+ import { InvisiblePlugin, ViewMode } from "white-web-sdk";
4
+ import { ReconnectRefresher } from "./ReconnectRefresher";
5
+ import { Val } from "value-enhancer";
6
+ import type { TELE_BOX_STATE } from "./BoxManager";
7
+ import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
8
+ import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Rectangle } from "white-web-sdk";
9
+ import type { AppListeners } from "./AppListener";
10
+ import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
11
+ import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
12
+ import type { AppProxy } from "./App";
13
+ import type { PublicEvent } from "./callback";
14
+ import type Emittery from "emittery";
15
+ import type { PageController, AddPageParams, PageState } from "./Page";
16
+ export declare type WindowMangerAttributes = {
17
+ modelValue?: string;
18
+ boxState: TELE_BOX_STATE;
19
+ maximized?: boolean;
20
+ minimized?: boolean;
21
+ [key: string]: any;
22
+ };
23
+ export declare type apps = {
24
+ [key: string]: NetlessApp;
25
+ };
26
+ export declare type AddAppOptions = {
27
+ scenePath?: string;
28
+ title?: string;
29
+ scenes?: SceneDefinition[];
30
+ };
31
+ export declare type setAppOptions = AddAppOptions & {
32
+ appOptions?: any;
33
+ };
34
+ export declare type AddAppParams<TAttributes = any> = {
35
+ kind: string;
36
+ src?: string;
37
+ options?: AddAppOptions;
38
+ attributes?: TAttributes;
39
+ };
40
+ export declare type BaseInsertParams = {
41
+ kind: string;
42
+ src?: string;
43
+ options?: AddAppOptions;
44
+ attributes?: any;
45
+ isDynamicPPT?: boolean;
46
+ };
47
+ export declare type AppSyncAttributes = {
48
+ kind: string;
49
+ src?: string;
50
+ options: any;
51
+ state?: any;
52
+ isDynamicPPT?: boolean;
53
+ fullPath?: string;
54
+ createdAt?: number;
55
+ camera?: ICamera;
56
+ size?: ISize;
57
+ };
58
+ export declare type AppInitState = {
59
+ id: string;
60
+ x?: number;
61
+ y?: number;
62
+ width?: number;
63
+ height?: number;
64
+ focus?: boolean;
65
+ maximized?: boolean;
66
+ minimized?: boolean;
67
+ sceneIndex?: number;
68
+ boxState?: TeleBoxState;
69
+ zIndex?: number;
70
+ visible?: boolean;
71
+ stageRatio?: number;
72
+ resizable?: boolean;
73
+ draggable?: boolean;
74
+ ratio?: number;
75
+ };
76
+ export declare type CursorMovePayload = {
77
+ uid: string;
78
+ state?: "leave";
79
+ position: Position;
80
+ };
81
+ export declare type MountParams = {
82
+ room: Room | Player;
83
+ container?: HTMLElement;
84
+ /** 白板高宽比例, 默认为 9 / 16 */
85
+ containerSizeRatio?: number;
86
+ /** @deprecated */
87
+ chessboard?: boolean;
88
+ /** 是否高亮显示同步区域, 默认为 true */
89
+ highlightStage?: boolean;
90
+ collectorContainer?: HTMLElement;
91
+ collectorStyles?: Partial<CSSStyleDeclaration>;
92
+ overwriteStyles?: string;
93
+ containerStyle?: string;
94
+ stageStyle?: string;
95
+ cursor?: boolean;
96
+ debug?: boolean;
97
+ disableCameraTransform?: boolean;
98
+ prefersColorScheme?: TeleBoxColorScheme;
99
+ applianceIcons?: ApplianceIcons;
100
+ };
101
+ export declare const reconnectRefresher: ReconnectRefresher;
102
+ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> implements PageController {
103
+ static kind: string;
104
+ static displayer: Displayer;
105
+ static playground?: HTMLElement;
106
+ static container?: HTMLElement;
107
+ static debug: boolean;
108
+ static containerSizeRatio: number;
109
+ private static isCreated;
110
+ version: string;
111
+ dependencies: Record<string, string>;
112
+ appListeners?: AppListeners;
113
+ readonly?: boolean;
114
+ emitter: Emittery<PublicEvent>;
115
+ appManager?: AppManager;
116
+ cursorManager?: CursorManager;
117
+ viewMode: ViewMode;
118
+ viewMode$: Val<ViewMode, any>;
119
+ isReplay: boolean;
120
+ private _pageState?;
121
+ private boxManager?;
122
+ private static params?;
123
+ containerSizeRatio: number;
124
+ constructor(context: InvisiblePluginContext);
125
+ static mount(params: MountParams): Promise<WindowManager>;
126
+ private static initManager;
127
+ private static initContainer;
128
+ static get registered(): Map<string, RegisterParams<any, any, any>>;
129
+ bindContainer(container: HTMLElement): void;
130
+ bindCollectorContainer(container: HTMLElement): void;
131
+ /**
132
+ * 注册插件
133
+ */
134
+ static register<AppOptions = any, SetupResult = any, Attributes = any>(params: RegisterParams<AppOptions, SetupResult, Attributes>): Promise<void>;
135
+ /**
136
+ * 注销插件
137
+ */
138
+ static unregister(kind: string): void;
139
+ /**
140
+ * 创建一个 app 至白板
141
+ */
142
+ addApp<T = any>(params: AddAppParams<T>): Promise<string | undefined>;
143
+ private _addApp;
144
+ private setupScenePath;
145
+ /**
146
+ * 设置 mainView 的 ScenePath, 并且切换白板为可写状态
147
+ */
148
+ setMainViewScenePath(scenePath: string): Promise<void>;
149
+ /**
150
+ * 设置 mainView 的 SceneIndex, 并且切换白板为可写状态
151
+ */
152
+ setMainViewSceneIndex(index: number): Promise<void>;
153
+ nextPage(): Promise<boolean>;
154
+ prevPage(): Promise<boolean>;
155
+ jumpPage(index: number): Promise<boolean>;
156
+ addPage(params?: AddPageParams): Promise<void>;
157
+ /**
158
+ * 删除一页
159
+ * 默认删除当前页, 可以删除指定 index 页
160
+ * 最低保留一页
161
+ */
162
+ removePage(index?: number): Promise<boolean>;
163
+ /**
164
+ * 返回 mainView 的 ScenePath
165
+ */
166
+ getMainViewScenePath(): string | undefined;
167
+ /**
168
+ * 返回 mainView 的 SceneIndex
169
+ */
170
+ getMainViewSceneIndex(): number;
171
+ /**
172
+ * 设置所有 app 的 readonly 模式
173
+ */
174
+ setReadonly(readonly: boolean): void;
175
+ /**
176
+ * 切换 mainView 为可写
177
+ */
178
+ switchMainViewToWriter(): Promise<void> | undefined;
179
+ /**
180
+ * app destroy 回调
181
+ */
182
+ onAppDestroy(kind: string, listener: (error: Error) => void): void;
183
+ /**
184
+ * 设置 ViewMode
185
+ */
186
+ setViewMode(mode: ViewMode): void;
187
+ setBoxState(boxState: TeleBoxState): void;
188
+ setMaximized(maximized: boolean): void;
189
+ setMinimized(minimized: boolean): void;
190
+ get mainView(): View;
191
+ get camera(): Camera;
192
+ get baseCamera$(): Val<{
193
+ id: string;
194
+ centerX: number | null;
195
+ centerY: number | null;
196
+ scale: number;
197
+ } | undefined, any>;
198
+ get baseSize$(): Val<ISize | undefined, any>;
199
+ get cameraState(): CameraState;
200
+ get apps(): Apps | undefined;
201
+ get boxState(): TeleBoxState | undefined;
202
+ get darkMode(): boolean;
203
+ get prefersColorScheme(): TeleBoxColorScheme | undefined;
204
+ get focused(): string | undefined;
205
+ get focusedView(): View | undefined;
206
+ get mainViewSceneIndex(): number;
207
+ get mainViewSceneDir(): string;
208
+ get topApp(): string | undefined;
209
+ get mainViewScenesLength(): number;
210
+ get canRedoSteps(): number;
211
+ get canUndoSteps(): number;
212
+ get sceneState(): SceneState;
213
+ get pageState(): PageState;
214
+ /**
215
+ * 查询所有的 App
216
+ */
217
+ queryAll(): AppProxy[];
218
+ /**
219
+ * 查询单个 App
220
+ */
221
+ queryOne(appId: string): AppProxy | undefined;
222
+ /**
223
+ * 关闭 APP
224
+ */
225
+ closeApp(appId: string): Promise<void>;
226
+ moveCamera(camera: Partial<Camera>): void;
227
+ moveCameraToContain(rectangle: Rectangle): void;
228
+ convertToPointInWorld(point: Point): Point;
229
+ setCameraBound(cameraBound: CameraBound): void;
230
+ onDestroy(): void;
231
+ destroy(): void;
232
+ private _destroy;
233
+ private bindMainView;
234
+ get canOperate(): boolean;
235
+ get room(): Room;
236
+ safeSetAttributes(attributes: any): void;
237
+ safeUpdateAttributes(keys: string[], value: any): void;
238
+ setPrefersColorScheme(scheme: TeleBoxColorScheme): void;
239
+ cleanCurrentScene(): void;
240
+ redo(): number;
241
+ undo(): number;
242
+ delete(): void;
243
+ copy(): void;
244
+ paste(): void;
245
+ duplicate(): void;
246
+ insertText(x: number, y: number, text: string | undefined): string;
247
+ insertImage(info: ImageInformation): void;
248
+ completeImageUpload(uuid: string, url: string): void;
249
+ lockImage(uuid: string, locked: boolean): void;
250
+ lockImages(locked: boolean): void;
251
+ refresh(): void;
252
+ /** @inner */
253
+ _refresh(): void;
254
+ setContainerSizeRatio(ratio: number): void;
255
+ setContainerStyle(style: string): void;
256
+ setStageStyle(style: string): void;
257
+ createPPTHandler(): {
258
+ onPageJumpTo: (_pptUUID: string, index: number) => void;
259
+ onPageToNext: () => void;
260
+ onPageToPrev: () => void;
261
+ };
262
+ private isDynamicPPT;
263
+ private ensureAttributes;
264
+ }
265
+ export * from "./typings";
266
+ export { BuiltinApps, BuiltinAppsMap } from "./BuiltinApps";
267
+ export type { PublicEvent } from "./callback";
@@ -0,0 +1,11 @@
1
+ import type { SvelteComponent } from "svelte";
2
+
3
+ declare module "*.svelte" {
4
+ const app: SvelteComponent;
5
+ export default app;
6
+ }
7
+
8
+ declare global {
9
+ const __APP_VERSION__: string;
10
+ const __APP_DEPENDENCIES__: Record<string, string>;
11
+ }
@@ -0,0 +1,88 @@
1
+ import type Emittery from "emittery";
2
+ import type { AnimationMode, ApplianceNames, Displayer, DisplayerState, Player, Room, SceneDefinition, SceneState, View } from "white-web-sdk";
3
+ import type { AppContext } from "./App";
4
+ import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
5
+ import type { PageState } from "./Page";
6
+ import type { Member } from "./Helper";
7
+ export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
8
+ kind: string;
9
+ config?: {
10
+ /** Box width relative to whiteboard. 0~1. Default 0.5. */
11
+ width?: number;
12
+ /** Box height relative to whiteboard. 0~1. Default 0.5. */
13
+ height?: number;
14
+ /** Minimum box width relative to whiteboard. 0~1. Default 340 / 720. */
15
+ minwidth?: number;
16
+ /** Minimum box height relative to whiteboard. 0~1. Default 340 / 720. */
17
+ minheight?: number;
18
+ /** App only single instance. */
19
+ singleton?: boolean;
20
+ /** App box enableShadowDom. Default true */
21
+ enableShadowDOM?: boolean;
22
+ };
23
+ setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
24
+ }
25
+ export declare type AppEmitterEvent<T = any> = {
26
+ /**
27
+ * before plugin destroyed
28
+ */
29
+ destroy: {
30
+ error?: Error;
31
+ };
32
+ attributesUpdate: T | undefined;
33
+ /**
34
+ * room isWritable change or box blur
35
+ */
36
+ writableChange: boolean;
37
+ sceneStateChange: SceneState;
38
+ setBoxSize: {
39
+ width: number;
40
+ height: number;
41
+ };
42
+ setBoxMinSize: {
43
+ minwidth: number;
44
+ minheight: number;
45
+ };
46
+ setBoxTitle: {
47
+ title: string;
48
+ };
49
+ containerRectUpdate: TeleBoxRect;
50
+ roomStateChange: Partial<DisplayerState>;
51
+ focus: boolean;
52
+ reconnected: void;
53
+ seek: number;
54
+ pageStateChange: PageState;
55
+ roomMembersChange: Member[];
56
+ };
57
+ export declare type RegisterEventData = {
58
+ appId: string;
59
+ };
60
+ export declare type RegisterEvents<SetupResult = any> = {
61
+ created: RegisterEventData & {
62
+ result: SetupResult;
63
+ };
64
+ destroy: RegisterEventData;
65
+ focus: RegisterEventData;
66
+ };
67
+ export declare type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
68
+ kind: string;
69
+ src: NetlessApp<Attributes, SetupResult> | string | (() => Promise<NetlessApp<Attributes, SetupResult>>);
70
+ appOptions?: AppOptions | (() => AppOptions);
71
+ addHooks?: (emitter: Emittery<RegisterEvents<SetupResult>>) => void;
72
+ /** dynamic load app package name */
73
+ name?: string;
74
+ contentStyles?: string;
75
+ };
76
+ export declare type AppListenerKeys = keyof AppEmitterEvent;
77
+ export declare type ApplianceIcons = Partial<Record<ApplianceNames, string>>;
78
+ export declare type Writeable<T> = {
79
+ -readonly [P in keyof T]: T[P];
80
+ };
81
+ export type { AppContext } from "./App/AppContext";
82
+ export type { WhiteBoardView } from "./App";
83
+ export type { ReadonlyTeleBox, TeleBoxRect };
84
+ export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room, Player };
85
+ export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
86
+ export * from "./Page";
87
+ export * from "./Utils/error";
88
+ export type { Member } from "./Helper";