@netless/window-manager 1.0.0-canary.9 → 1.0.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.
Files changed (132) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +90 -64
  3. package/README.zh-cn.md +224 -0
  4. package/dist/index.d.ts +1133 -40
  5. package/dist/index.js +62 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/{index.es.js → index.mjs} +9480 -6984
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/style.css +1 -1
  10. package/docs/advanced.md +55 -55
  11. package/docs/api.md +124 -113
  12. package/docs/app-context.md +248 -209
  13. package/docs/basic.md +25 -26
  14. package/docs/camera.md +19 -20
  15. package/docs/cn/advanced.md +137 -0
  16. package/docs/cn/api.md +309 -0
  17. package/docs/cn/app-context.md +369 -0
  18. package/docs/cn/basic.md +64 -0
  19. package/docs/cn/camera.md +53 -0
  20. package/docs/cn/concept.md +9 -0
  21. package/docs/cn/custom-max-bar.md +31 -0
  22. package/docs/cn/develop-app.md +94 -0
  23. package/docs/cn/export-pdf.md +48 -0
  24. package/docs/cn/migrate.md +60 -0
  25. package/docs/cn/replay.md +40 -0
  26. package/docs/concept.md +6 -5
  27. package/docs/custom-max-bar.md +31 -0
  28. package/docs/develop-app.md +22 -19
  29. package/docs/export-pdf.md +48 -0
  30. package/docs/migrate.md +25 -27
  31. package/docs/quickstart.md +50 -0
  32. package/docs/replay.md +20 -20
  33. package/package.json +32 -22
  34. package/src/App/AppContext.ts +105 -73
  35. package/src/App/AppPageStateImpl.ts +6 -25
  36. package/src/App/AppProxy.ts +41 -166
  37. package/src/App/MagixEvent/index.ts +38 -38
  38. package/src/App/Storage/StorageEvent.ts +13 -13
  39. package/src/App/Storage/index.ts +269 -245
  40. package/src/App/Storage/typings.ts +4 -2
  41. package/src/App/Storage/utils.ts +3 -3
  42. package/src/App/index.ts +0 -1
  43. package/src/AppListener.ts +8 -8
  44. package/src/AppManager.ts +88 -77
  45. package/src/AttributesDelegate.ts +42 -22
  46. package/src/BoxEmitter.ts +12 -6
  47. package/src/BoxManager.ts +128 -108
  48. package/src/ContainerResizeObserver.ts +75 -0
  49. package/src/Cursor/Cursor.svelte +16 -5
  50. package/src/Cursor/Cursor.svelte.d.ts +21 -0
  51. package/src/Cursor/Cursor.ts +77 -13
  52. package/src/Cursor/icons.ts +6 -0
  53. package/src/Cursor/icons2.ts +66 -0
  54. package/src/Cursor/index.ts +127 -26
  55. package/src/Helper.ts +94 -14
  56. package/src/InternalEmitter.ts +2 -7
  57. package/src/Page/index.ts +1 -1
  58. package/src/PageState.ts +6 -5
  59. package/src/ReconnectRefresher.ts +9 -4
  60. package/src/RedoUndo.ts +3 -3
  61. package/src/Register/index.ts +22 -17
  62. package/src/Register/loader.ts +26 -22
  63. package/src/Register/storage.ts +13 -13
  64. package/src/Utils/Common.ts +18 -14
  65. package/src/Utils/Reactive.ts +26 -25
  66. package/src/Utils/RoomHacker.ts +4 -4
  67. package/src/Utils/error.ts +0 -1
  68. package/src/View/IframeBridge.ts +680 -0
  69. package/src/View/MainView.ts +127 -53
  70. package/src/callback.ts +21 -1
  71. package/src/constants.ts +0 -2
  72. package/src/image/pencil-eraser-1.svg +3 -0
  73. package/src/image/pencil-eraser-2.svg +3 -0
  74. package/src/image/pencil-eraser-3.svg +3 -0
  75. package/src/index.ts +220 -83
  76. package/src/style.css +27 -10
  77. package/src/typings.ts +20 -10
  78. package/.prettierignore +0 -7
  79. package/.prettierrc.json +0 -9
  80. package/CHANGELOG.md +0 -196
  81. package/__mocks__/white-web-sdk.ts +0 -50
  82. package/dist/App/AppContext.d.ts +0 -76
  83. package/dist/App/AppPageStateImpl.d.ts +0 -21
  84. package/dist/App/AppProxy.d.ts +0 -86
  85. package/dist/App/AppViewSync.d.ts +0 -11
  86. package/dist/App/MagixEvent/index.d.ts +0 -29
  87. package/dist/App/Storage/StorageEvent.d.ts +0 -8
  88. package/dist/App/Storage/index.d.ts +0 -39
  89. package/dist/App/Storage/typings.d.ts +0 -22
  90. package/dist/App/Storage/utils.d.ts +0 -5
  91. package/dist/App/WhiteboardView.d.ts +0 -22
  92. package/dist/App/index.d.ts +0 -3
  93. package/dist/AppListener.d.ts +0 -21
  94. package/dist/AppManager.d.ts +0 -107
  95. package/dist/AttributesDelegate.d.ts +0 -80
  96. package/dist/BoxEmitter.d.ts +0 -34
  97. package/dist/BoxManager.d.ts +0 -99
  98. package/dist/BuiltinApps.d.ts +0 -5
  99. package/dist/Cursor/Cursor.d.ts +0 -39
  100. package/dist/Cursor/icons.d.ts +0 -3
  101. package/dist/Cursor/index.d.ts +0 -46
  102. package/dist/Helper.d.ts +0 -17
  103. package/dist/InternalEmitter.d.ts +0 -39
  104. package/dist/Page/PageController.d.ts +0 -21
  105. package/dist/Page/index.d.ts +0 -3
  106. package/dist/PageState.d.ts +0 -9
  107. package/dist/ReconnectRefresher.d.ts +0 -24
  108. package/dist/RedoUndo.d.ts +0 -18
  109. package/dist/Register/index.d.ts +0 -28
  110. package/dist/Register/loader.d.ts +0 -4
  111. package/dist/Register/storage.d.ts +0 -8
  112. package/dist/Utils/AppCreateQueue.d.ts +0 -15
  113. package/dist/Utils/Common.d.ts +0 -23
  114. package/dist/Utils/Reactive.d.ts +0 -6
  115. package/dist/Utils/RoomHacker.d.ts +0 -3
  116. package/dist/Utils/error.d.ts +0 -27
  117. package/dist/Utils/log.d.ts +0 -1
  118. package/dist/View/CameraSynchronizer.d.ts +0 -16
  119. package/dist/View/MainView.d.ts +0 -47
  120. package/dist/View/ViewManager.d.ts +0 -13
  121. package/dist/callback.d.ts +0 -24
  122. package/dist/constants.d.ts +0 -49
  123. package/dist/index.cjs.js +0 -46
  124. package/dist/index.umd.js +0 -46
  125. package/dist/typings.d.ts +0 -82
  126. package/jest.config.js +0 -27
  127. package/pnpm-lock.yaml +0 -6302
  128. package/src/App/AppViewSync.ts +0 -68
  129. package/src/App/WhiteboardView.ts +0 -83
  130. package/src/View/CameraSynchronizer.ts +0 -56
  131. package/vite.config.js +0 -51
  132. /package/docs/{qickstart.md → cn/quickstart.md} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,52 +1,1104 @@
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 "video.js/dist/video-js.css";
6
- import "./style.css";
7
- import "@netless/telebox-insider/dist/style.css";
8
- import type { TELE_BOX_STATE } from "./BoxManager";
9
- import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
10
- import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, AnimationMode, CameraBound, Point, Rectangle, CameraState, Player, ImageInformation, SceneState } from "white-web-sdk";
11
- import type { AppListeners } from "./AppListener";
12
- import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
13
- import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
14
- import type { AppProxy } from "./App";
15
- import type { PublicEvent } from "./callback";
16
- import type Emittery from "emittery";
17
- import type { PageController, AddPageParams, PageState } from "./Page";
18
- export declare type WindowMangerAttributes = {
1
+ import * as lodash from 'lodash';
2
+ import * as white_web_sdk from 'white-web-sdk';
3
+ import { RoomMember, View, ApplianceNames, Camera, Size, SceneDefinition, SceneState, DisplayerState, ViewVisionMode, CameraState, MagixEventListenerOptions as MagixEventListenerOptions$1, Event as Event$1, Scope, EventPhase, autorun, reaction, toJS, listenUpdated, unlistenUpdated, listenDisposed, unlistenDisposed, Room, ViewMode, Displayer, MemberState, AnimationMode, Player, InvisiblePlugin, InvisiblePluginContext, Rectangle, Point, CameraBound, ImageInformation } from 'white-web-sdk';
4
+ export { AnimationMode, Displayer, Player, Room, SceneDefinition, SceneState, View } from 'white-web-sdk';
5
+ import Emittery from 'emittery';
6
+ import { TELE_BOX_STATE, TeleBoxRect, TeleBoxColorScheme, TeleBoxManager, ReadonlyTeleBox, TeleBoxManagerUpdateConfig, TeleBoxConfig, TeleBoxState } from '@netless/telebox-insider';
7
+ export { ReadonlyTeleBox, TeleBoxRect } from '@netless/telebox-insider';
8
+
9
+ declare enum Events {
10
+ AppMove = "AppMove",
11
+ AppFocus = "AppFocus",
12
+ AppResize = "AppResize",
13
+ AppBoxStateChange = "AppBoxStateChange",
14
+ GetAttributes = "GetAttributes",
15
+ UpdateWindowManagerWrapper = "UpdateWindowManagerWrapper",
16
+ InitReplay = "InitReplay",
17
+ WindowCreated = "WindowCreated",
18
+ SetMainViewScenePath = "SetMainViewScenePath",
19
+ SetMainViewSceneIndex = "SetMainViewSceneIndex",
20
+ SetAppFocusIndex = "SetAppFocusIndex",
21
+ SwitchViewsToFreedom = "SwitchViewsToFreedom",
22
+ MoveCamera = "MoveCamera",
23
+ MoveCameraToContain = "MoveCameraToContain",
24
+ CursorMove = "CursorMove",
25
+ RootDirRemoved = "RootDirRemoved",
26
+ Refresh = "Refresh",
27
+ InitMainViewCamera = "InitMainViewCamera"
28
+ }
29
+ declare enum AppAttributes {
30
+ Size = "size",
31
+ Position = "position",
32
+ SceneIndex = "SceneIndex",
33
+ ZIndex = "zIndex"
34
+ }
35
+ declare enum AppStatus {
36
+ StartCreate = "StartCreate"
37
+ }
38
+
39
+ declare class CursorManager {
40
+ private manager;
41
+ private enableCursor;
42
+ containerRect?: DOMRect;
43
+ wrapperRect?: DOMRect;
44
+ cursorInstances: Map<string, Cursor>;
45
+ roomMembers?: readonly RoomMember[];
46
+ userApplianceIcons: ApplianceIcons;
47
+ private mainViewElement?;
48
+ private sideEffectManager;
49
+ private store;
50
+ private leaveFlag;
51
+ private _style;
52
+ constructor(manager: AppManager, enableCursor: boolean, cursorOptions?: CursorOptions, applianceIcons?: ApplianceIcons);
53
+ get applianceIcons(): ApplianceIcons;
54
+ get style(): "default" | "custom";
55
+ set style(value: "default" | "custom");
56
+ private onCursorMove;
57
+ private initCursorInstance;
58
+ private enableCustomCursor;
59
+ private canMoveCursor;
60
+ setupWrapper(wrapper: HTMLElement): void;
61
+ setMainViewDivElement(div: HTMLDivElement): void;
62
+ get boxState(): any;
63
+ get focusView(): View | undefined;
64
+ private mouseMoveListener_;
65
+ private mouseMoveTimer;
66
+ private mouseMoveListener;
67
+ private mouseLeaveListener;
68
+ private showPencilEraserIfNeeded;
69
+ private updateCursor;
70
+ private getPoint;
71
+ /**
72
+ * 因为窗口内框在不同分辨率下的大小不一样,所以这里通过来鼠标事件的 target 来判断是在主白板还是在 APP 中
73
+ */
74
+ private getType;
75
+ updateContainerRect(): void;
76
+ deleteCursor(uid: string): void;
77
+ hideCursor(uid: string): void;
78
+ destroy(): void;
79
+ }
80
+
81
+ declare class Cursor {
82
+ private manager;
83
+ private memberId;
84
+ private cursorManager;
85
+ private wrapper?;
86
+ private member?;
87
+ private timer?;
88
+ private component?;
89
+ private style;
90
+ constructor(manager: AppManager, memberId: string, cursorManager: CursorManager, wrapper?: HTMLElement | undefined);
91
+ move: (position: Position) => void;
92
+ setStyle: (style: typeof this.style) => void;
93
+ leave: () => void;
94
+ private moveCursor;
95
+ get memberApplianceName(): ApplianceNames | undefined;
96
+ get memberColor(): string;
97
+ get memberColorHex(): string;
98
+ private get payload();
99
+ get memberCursorName(): any;
100
+ private get memberTheme();
101
+ private get memberCursorTextColor();
102
+ private get memberCursorTagBackgroundColor();
103
+ private get memberAvatar();
104
+ private get memberOpacity();
105
+ private get memberTagName();
106
+ private autoHidden;
107
+ private createCursor;
108
+ private initProps;
109
+ private getIcon;
110
+ private isCustomIcon;
111
+ updateMember(): RoomMember | undefined;
112
+ private updateComponent;
113
+ destroy(): void;
114
+ hide(): void;
115
+ }
116
+
117
+ type Apps = {
118
+ [key: string]: AppSyncAttributes;
119
+ };
120
+ type Position = {
121
+ x: number;
122
+ y: number;
123
+ type: PositionType;
124
+ id?: string;
125
+ };
126
+ type PositionType = "main" | "app";
127
+ type StoreContext = {
128
+ getAttributes: () => any;
129
+ safeUpdateAttributes: (keys: string[], value: any) => void;
130
+ safeSetAttributes: (attributes: any) => void;
131
+ };
132
+ type ICamera = Camera & {
133
+ id: string;
134
+ };
135
+ type ISize = Size & {
136
+ id: string;
137
+ };
138
+ declare class AttributesDelegate {
139
+ private context;
140
+ constructor(context: StoreContext);
141
+ setContext(context: StoreContext): void;
142
+ get attributes(): any;
143
+ apps(): Apps;
144
+ get focus(): string | undefined;
145
+ getAppAttributes(id: string): AppSyncAttributes;
146
+ getAppState(id: string): any;
147
+ getMaximized(): any;
148
+ getMinimized(): any;
149
+ setupAppAttributes(params: AddAppParams, id: string, isDynamicPPT: boolean): void;
150
+ updateAppState(appId: string, stateName: AppAttributes, state: any): void;
151
+ cleanAppAttributes(id: string): void;
152
+ cleanFocus(): void;
153
+ getAppSceneIndex(id: string): any;
154
+ getAppScenePath(id: string): any;
155
+ getMainViewScenePath(): string | undefined;
156
+ getMainViewSceneIndex(): any;
157
+ getBoxState(): any;
158
+ setMainViewScenePath(scenePath: string): void;
159
+ setMainViewSceneIndex(index: number): void;
160
+ getMainViewCamera(): MainViewCamera;
161
+ getMainViewSize(): MainViewSize;
162
+ setMainViewCamera(camera: ICamera): void;
163
+ setMainViewSize(size: ISize): void;
164
+ setMainViewCameraAndSize(camera: ICamera, size: ISize): void;
165
+ setAppFocus: (appId: string, focus: boolean) => void;
166
+ updateCursor(uid: string, position: Position): void;
167
+ updateCursorState(uid: string, cursorState: string | undefined): void;
168
+ getCursorState(uid: string): any;
169
+ cleanCursor(uid: string): void;
170
+ setMainViewFocusPath(mainView: View): void;
171
+ getIframeBridge(): any;
172
+ setIframeBridge(data: any): void;
173
+ }
174
+ type MainViewSize = {
175
+ id: string;
176
+ width: number;
177
+ height: number;
178
+ };
179
+ type MainViewCamera = {
180
+ id: string;
181
+ centerX: number;
182
+ centerY: number;
183
+ scale: number;
184
+ };
185
+
186
+ type StorageEventListener<T> = (event: T) => void;
187
+ declare class StorageEvent<TMessage> {
188
+ listeners: Set<StorageEventListener<TMessage>>;
189
+ get length(): number;
190
+ dispatch(message: TMessage): void;
191
+ addListener(listener: StorageEventListener<TMessage>): void;
192
+ removeListener(listener: StorageEventListener<TMessage>): void;
193
+ }
194
+
195
+ type DiffOne<T> = {
196
+ oldValue?: T;
197
+ newValue?: T;
198
+ };
199
+ type Diff<T> = {
200
+ [K in keyof T]?: DiffOne<T[K]>;
201
+ };
202
+ type StorageStateChangedEvent<TState = any> = Diff<TState>;
203
+ type StorageStateChangedListener<TState = any> = StorageEventListener<StorageStateChangedEvent<TState>>;
204
+ type StorageStateChangedListenerDisposer = () => void;
205
+
206
+ declare class Storage<TState extends Record<string, any> = any> implements Storage<TState> {
207
+ readonly id: string | null;
208
+ private readonly _context;
209
+ private readonly _sideEffect;
210
+ private _state;
211
+ private _destroyed;
212
+ private _refMap;
213
+ /**
214
+ * `setState` alters local state immediately before sending to server. This will cache the old value for onStateChanged diffing.
215
+ */
216
+ private _lastValue;
217
+ constructor(context: AppContext, id?: string, defaultState?: TState);
218
+ get state(): Readonly<TState>;
219
+ readonly onStateChanged: StorageEvent<Diff<TState>>;
220
+ addStateChangedListener(handler: StorageStateChangedListener<TState>): StorageStateChangedListenerDisposer;
221
+ ensureState(state: Partial<TState>): void;
222
+ setState(state: Partial<TState>): void;
223
+ /**
224
+ * Empty storage data.
225
+ */
226
+ emptyStorage(): void;
227
+ /**
228
+ * Delete storage index with all of its data and destroy the Storage instance.
229
+ */
230
+ deleteStorage(): void;
231
+ get destroyed(): boolean;
232
+ /**
233
+ * Destroy the Storage instance. The data will be kept.
234
+ */
235
+ destroy(): void;
236
+ private _getRawState;
237
+ private _setRawState;
238
+ private _updateProperties;
239
+ }
240
+
241
+ type BoxMovePayload = {
242
+ appId: string;
243
+ x: number;
244
+ y: number;
245
+ };
246
+ type BoxFocusPayload = {
247
+ appId: string;
248
+ };
249
+ type BoxResizePayload = {
250
+ appId: string;
251
+ width: number;
252
+ height: number;
253
+ x?: number;
254
+ y?: number;
255
+ };
256
+ type BoxClosePayload = {
257
+ appId: string;
258
+ error?: Error;
259
+ };
260
+ type BoxStateChangePayload = {
261
+ appId: string;
262
+ state: TELE_BOX_STATE;
263
+ };
264
+ type BoxEvent = {
265
+ move: BoxMovePayload;
266
+ focus: BoxFocusPayload;
267
+ resize: BoxResizePayload;
268
+ close: BoxClosePayload;
269
+ boxStateChange: BoxStateChangePayload;
270
+ };
271
+ type BoxEmitterType = Emittery<BoxEvent>;
272
+
273
+ type AddPageParams = {
274
+ after?: boolean;
275
+ scene?: SceneDefinition;
276
+ };
277
+ type PageState = {
278
+ index: number;
279
+ length: number;
280
+ };
281
+ interface PageController {
282
+ nextPage: () => Promise<boolean>;
283
+ prevPage: () => Promise<boolean>;
284
+ jumpPage: (index: number) => Promise<boolean>;
285
+ addPage: (params?: AddPageParams) => Promise<void>;
286
+ removePage: (index: number) => Promise<boolean>;
287
+ pageState: PageState;
288
+ }
289
+ interface PageRemoveService {
290
+ removeSceneByIndex: (index: number) => Promise<boolean>;
291
+ setSceneIndexWithoutSync: (index: number) => void;
292
+ }
293
+
294
+ declare const calculateNextIndex: (index: number, pageState: PageState) => number;
295
+
296
+ declare class AppCreateError extends Error {
297
+ message: string;
298
+ }
299
+ declare class AppNotRegisterError extends Error {
300
+ constructor(kind: string);
301
+ }
302
+ declare class AppManagerNotInitError extends Error {
303
+ message: string;
304
+ }
305
+ declare class WhiteWebSDKInvalidError extends Error {
306
+ constructor(version: string);
307
+ }
308
+ declare class ParamsInvalidError extends Error {
309
+ message: string;
310
+ }
311
+ declare class BoxNotCreatedError extends Error {
312
+ message: string;
313
+ }
314
+ declare class InvalidScenePath extends Error {
315
+ message: string;
316
+ }
317
+ declare class BoxManagerNotFoundError extends Error {
318
+ message: string;
319
+ }
320
+ declare class BindContainerRoomPhaseInvalidError extends Error {
321
+ message: string;
322
+ }
323
+
324
+ interface NetlessApp<Attributes extends {} = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
325
+ kind: string;
326
+ config?: {
327
+ /** Box width relative to whiteboard. 0~1. Default 0.5. */
328
+ width?: number;
329
+ /** Box height relative to whiteboard. 0~1. Default 0.5. */
330
+ height?: number;
331
+ /** Minimum box width relative to whiteboard. 0~1. Default 340 / 720. */
332
+ minwidth?: number;
333
+ /** Minimum box height relative to whiteboard. 0~1. Default 340 / 720. */
334
+ minheight?: number;
335
+ /** App only single instance. */
336
+ singleton?: boolean;
337
+ };
338
+ setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
339
+ }
340
+ type AppEmitterEvent<T = any> = {
341
+ /**
342
+ * before plugin destroyed
343
+ */
344
+ destroy: {
345
+ error?: Error;
346
+ };
347
+ attributesUpdate: T | undefined;
348
+ /**
349
+ * room isWritable change or box blur
350
+ */
351
+ writableChange: boolean;
352
+ sceneStateChange: SceneState;
353
+ setBoxSize: {
354
+ width: number;
355
+ height: number;
356
+ };
357
+ setBoxMinSize: {
358
+ minwidth: number;
359
+ minheight: number;
360
+ };
361
+ setBoxTitle: {
362
+ title: string;
363
+ };
364
+ containerRectUpdate: TeleBoxRect;
365
+ roomStateChange: Partial<DisplayerState>;
366
+ focus: boolean;
367
+ reconnected: void;
368
+ seek: number;
369
+ pageStateChange: PageState;
370
+ };
371
+ type RegisterEventData = {
372
+ appId: string;
373
+ };
374
+ type RegisterEvents<SetupResult = any> = {
375
+ created: RegisterEventData & {
376
+ result: SetupResult;
377
+ };
378
+ destroy: RegisterEventData;
379
+ focus: RegisterEventData;
380
+ };
381
+ type RegisterParams<AppOptions = any, SetupResult = any, Attributes extends {} = any> = {
382
+ kind: string;
383
+ src: NetlessApp<Attributes, SetupResult> | string | (() => Promise<NetlessApp<Attributes, SetupResult>>) | (() => Promise<{
384
+ default: NetlessApp<Attributes, SetupResult>;
385
+ }>);
386
+ appOptions?: AppOptions | (() => AppOptions);
387
+ addHooks?: (emitter: Emittery<RegisterEvents<SetupResult>>) => void;
388
+ /** dynamic load app package name */
389
+ name?: string;
390
+ };
391
+ type AppListenerKeys = keyof AppEmitterEvent;
392
+ type ApplianceIcons = Partial<Record<`${ApplianceNames}` | string, string>>;
393
+
394
+ type AppPayload = {
395
+ appId: string;
396
+ view: View;
397
+ };
398
+
399
+ type LoadAppEvent = {
400
+ kind: string;
401
+ status: "start" | "success" | "failed";
402
+ reason?: string;
403
+ };
404
+
405
+ type PublicEvent = {
406
+ mainViewModeChange: ViewVisionMode;
407
+ boxStateChange: `${TELE_BOX_STATE}`;
408
+ darkModeChange: boolean;
409
+ prefersColorSchemeChange: TeleBoxColorScheme;
410
+ cameraStateChange: CameraState;
411
+ mainViewScenePathChange: string;
412
+ mainViewSceneIndexChange: number;
413
+ focusedChange: string | undefined;
414
+ mainViewScenesLengthChange: number;
415
+ canRedoStepsChange: number;
416
+ canUndoStepsChange: number;
417
+ loadApp: LoadAppEvent;
418
+ ready: undefined;
419
+ sceneStateChange: SceneState;
420
+ pageStateChange: PageState;
421
+ fullscreenChange: boolean;
422
+ appsChange: string[];
423
+ onBoxMove: BoxMovePayload;
424
+ onBoxResize: BoxResizePayload;
425
+ onBoxFocus: BoxFocusPayload;
426
+ onBoxClose: BoxClosePayload;
427
+ onBoxStateChange: BoxStateChangePayload;
428
+ onMainViewMounted: View;
429
+ onMainViewRebind: View;
430
+ onAppViewMounted: AppPayload;
431
+ onAppSetup: string;
432
+ onAppScenePathChange: AppPayload;
433
+ };
434
+ type CallbacksType = Emittery<PublicEvent>;
435
+
436
+ type RemoveSceneParams = {
437
+ scenePath: string;
438
+ index?: number;
439
+ };
440
+ type EmitterEvent = {
441
+ onCreated: undefined;
442
+ InitReplay: AppInitState;
443
+ error: Error;
444
+ seekStart: undefined;
445
+ seek: number;
446
+ mainViewMounted: undefined;
447
+ observerIdChange: number;
448
+ boxStateChange: string;
449
+ playgroundSizeChange: DOMRect;
450
+ startReconnect: undefined;
451
+ onReconnected: undefined;
452
+ removeScenes: RemoveSceneParams;
453
+ cursorMove: CursorMovePayload;
454
+ updateManagerRect: undefined;
455
+ focusedChange: {
456
+ focused: string | undefined;
457
+ prev: string | undefined;
458
+ };
459
+ rootDirRemoved: undefined;
460
+ rootDirSceneRemoved: string;
461
+ setReadonly: boolean;
462
+ changePageState: undefined;
463
+ writableChange: boolean;
464
+ containerSizeRatioUpdate: number;
465
+ };
466
+ type EmitterType = Emittery<EmitterEvent>;
467
+
468
+ type CreateBoxParams = {
469
+ appId: string;
470
+ app: NetlessApp;
471
+ view?: View;
472
+ emitter?: Emittery;
473
+ options?: AddAppOptions;
474
+ canOperate?: boolean;
475
+ smartPosition?: boolean;
476
+ };
477
+ type AppId = {
478
+ appId: string;
479
+ };
480
+ type MoveBoxParams = AppId & {
481
+ x: number;
482
+ y: number;
483
+ };
484
+ type ResizeBoxParams = AppId & {
485
+ width: number;
486
+ height: number;
487
+ skipUpdate: boolean;
488
+ };
489
+ type SetBoxMinSizeParams = AppId & {
490
+ minWidth: number;
491
+ minHeight: number;
492
+ };
493
+ type SetBoxTitleParams = AppId & {
494
+ title: string;
495
+ };
496
+ type CreateTeleBoxManagerConfig = {
497
+ collectorContainer?: HTMLElement;
498
+ collectorStyles?: Partial<CSSStyleDeclaration>;
499
+ prefersColorScheme?: TeleBoxColorScheme;
500
+ };
501
+ type BoxManagerContext = {
502
+ safeSetAttributes: (attributes: any) => void;
503
+ getMainView: () => View;
504
+ updateAppState: (appId: string, field: AppAttributes, value: any) => void;
505
+ emitter: EmitterType;
506
+ boxEmitter: BoxEmitterType;
507
+ callbacks: CallbacksType;
508
+ canOperate: () => boolean;
509
+ notifyContainerRectUpdate: (rect: TeleBoxRect) => void;
510
+ cleanFocus: () => void;
511
+ setAppFocus: (appId: string) => void;
512
+ };
513
+ declare class BoxManager {
514
+ private context;
515
+ private createTeleBoxManagerConfig?;
516
+ teleBoxManager: TeleBoxManager;
517
+ constructor(context: BoxManagerContext, createTeleBoxManagerConfig?: CreateTeleBoxManagerConfig | undefined);
518
+ private get mainView();
519
+ private get canOperate();
520
+ get boxState(): "maximized" | "minimized" | "normal";
521
+ get maximized(): boolean;
522
+ get minimized(): boolean;
523
+ get darkMode(): boolean;
524
+ get prefersColorScheme(): TeleBoxColorScheme;
525
+ get boxSize(): number;
526
+ createBox(params: CreateBoxParams): void;
527
+ setBoxInitState(appId: string): void;
528
+ setupBoxManager(createTeleBoxManagerConfig?: CreateTeleBoxManagerConfig): TeleBoxManager;
529
+ setCollectorContainer(container: HTMLElement): void;
530
+ getBox(appId: string): ReadonlyTeleBox | undefined;
531
+ closeBox(appId: string, skipUpdate?: boolean): ReadonlyTeleBox | undefined;
532
+ boxIsFocus(appId: string): boolean | undefined;
533
+ getFocusBox(): ReadonlyTeleBox | undefined;
534
+ getTopBox(): ReadonlyTeleBox | undefined;
535
+ updateBoxState(state?: AppInitState): void;
536
+ updateManagerRect(): void;
537
+ moveBox({ appId, x, y }: MoveBoxParams): void;
538
+ focusBox({ appId }: AppId, skipUpdate?: boolean): void;
539
+ resizeBox({ appId, width, height, skipUpdate }: ResizeBoxParams): void;
540
+ setBoxMinSize(params: SetBoxMinSizeParams): void;
541
+ setBoxTitle(params: SetBoxTitleParams): void;
542
+ blurAllBox(): void;
543
+ updateAll(config: TeleBoxManagerUpdateConfig): void;
544
+ setMaximized(maximized: boolean, skipUpdate?: boolean): void;
545
+ setMinimized(minimized: boolean, skipUpdate?: boolean): void;
546
+ focusTopBox(): void;
547
+ updateBox(id: string, payload: TeleBoxConfig, skipUpdate?: boolean): void;
548
+ setReadonly(readonly: boolean): void;
549
+ setPrefersColorScheme(colorScheme: TeleBoxColorScheme): void;
550
+ setZIndex(id: string, zIndex: number, skipUpdate?: boolean): void;
551
+ destroy(): void;
552
+ }
553
+
554
+ interface MagixEventListenerOptions extends MagixEventListenerOptions$1 {
555
+ /**
556
+ * Rapid emitted callbacks will be slowed down to this interval (in ms).
557
+ */
558
+ fireInterval?: number;
559
+ /**
560
+ * If `true`, sent events will reach self-listeners after committed to server.
561
+ * Otherwise the events will reach self-listeners immediately.
562
+ */
563
+ fireSelfEventAfterCommit?: boolean;
564
+ }
565
+ interface MagixEventMessage<TPayloads = any, TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>> extends Omit<Event$1, "scope" | "phase"> {
566
+ /** Event name */
567
+ event: TEvent;
568
+ /** Event Payload */
569
+ payload: TPayloads[TEvent];
570
+ /** Whiteboard ID of the client who dispatched the event. It will be AdminObserverId for system events. */
571
+ authorId: number;
572
+ scope: `${Scope}`;
573
+ phase: `${EventPhase}`;
574
+ }
575
+ type MagixEventTypes<TPayloads = any> = Extract<keyof TPayloads, string>;
576
+ type MagixEventDispatcher<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, payload: TPayloads[TEvent]) => void;
577
+ type MagixEventHandler<TPayloads = any, TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>> = (message: MagixEventMessage<TPayloads, TEvent>) => void;
578
+ type MagixEventListenerDisposer = () => void;
579
+ type MagixEventAddListener<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, handler: MagixEventHandler<TPayloads, TEvent>, options?: MagixEventListenerOptions | undefined) => MagixEventListenerDisposer;
580
+ type MagixEventRemoveListener<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, handler?: MagixEventHandler<TPayloads, TEvent>) => void;
581
+
582
+ declare class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any> implements PageController {
583
+ private manager;
584
+ private boxManager;
585
+ appId: string;
586
+ private appProxy;
587
+ private appOptions?;
588
+ readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
589
+ readonly mobxUtils: {
590
+ autorun: typeof autorun;
591
+ reaction: typeof reaction;
592
+ toJS: typeof toJS;
593
+ };
594
+ readonly objectUtils: {
595
+ listenUpdated: typeof listenUpdated;
596
+ unlistenUpdated: typeof unlistenUpdated;
597
+ listenDisposed: typeof listenDisposed;
598
+ unlistenDisposed: typeof unlistenDisposed;
599
+ };
600
+ private store;
601
+ readonly isAddApp: boolean;
602
+ readonly isReplay: boolean;
603
+ constructor(manager: AppManager, boxManager: BoxManager, appId: string, appProxy: AppProxy, appOptions?: TAppOptions | (() => TAppOptions) | undefined);
604
+ getDisplayer: () => white_web_sdk.Displayer<white_web_sdk.DisplayerCallbacks>;
605
+ /** @deprecated Use context.storage.state instead. */
606
+ getAttributes: () => TAttributes | undefined;
607
+ getScenes: () => SceneDefinition[] | undefined;
608
+ getView: () => View | undefined;
609
+ mountView: (dom: HTMLElement) => void;
610
+ getInitScenePath: () => string | undefined;
611
+ /** Get App writable status. */
612
+ getIsWritable: () => boolean;
613
+ /** Get the App Window UI box. */
614
+ getBox: () => ReadonlyTeleBox;
615
+ getRoom: () => Room | undefined;
616
+ /** @deprecated Use context.storage.setState instead. */
617
+ setAttributes: (attributes: TAttributes) => void;
618
+ /** @deprecated Use context.storage.setState instead. */
619
+ updateAttributes: (keys: string[], value: any) => void;
620
+ setScenePath: (scenePath: string) => Promise<void>;
621
+ /** Get the local App options. */
622
+ getAppOptions: () => TAppOptions | undefined;
623
+ private _storage?;
624
+ /** Main Storage for attributes. */
625
+ get storage(): Storage<TAttributes>;
626
+ /**
627
+ * Create separated storages for flexible state management.
628
+ * @param storeId Namespace for the storage. Storages of the same namespace share the same data.
629
+ * @param defaultState Default state for initial storage creation.
630
+ * @returns
631
+ */
632
+ createStorage: <TState extends {}>(storeId: string, defaultState?: TState) => Storage<TState>;
633
+ /** Dispatch events to other clients (and self). */
634
+ dispatchMagixEvent: MagixEventDispatcher<TMagixEventPayloads>;
635
+ /** Listen to events from others clients (and self messages). */
636
+ addMagixEventListener: MagixEventAddListener<TMagixEventPayloads>;
637
+ /** Remove a Magix event listener. */
638
+ removeMagixEventListener: MagixEventRemoveListener<TMagixEventPayloads>;
639
+ /** PageController */
640
+ nextPage: () => Promise<boolean>;
641
+ jumpPage: (index: number) => Promise<boolean>;
642
+ prevPage: () => Promise<boolean>;
643
+ addPage: (params?: AddPageParams) => Promise<void>;
644
+ removePage: (index?: number) => Promise<boolean>;
645
+ get pageState(): PageState;
646
+ get kind(): string;
647
+ /** Dispatch a local event to `manager.onAppEvent()`. */
648
+ dispatchAppEvent(type: string, value?: any): void;
649
+ }
650
+
651
+ type AppEmitter = Emittery<AppEmitterEvent>;
652
+ declare class AppProxy implements PageRemoveService {
653
+ private params;
654
+ private manager;
655
+ kind: string;
656
+ id: string;
657
+ scenePath?: string;
658
+ appEmitter: AppEmitter;
659
+ scenes?: SceneDefinition[];
660
+ private appListener;
661
+ private boxManager;
662
+ private appProxies;
663
+ private viewManager;
664
+ private store;
665
+ isAddApp: boolean;
666
+ private status;
667
+ private stateKey;
668
+ private _pageState;
669
+ private _prevFullPath;
670
+ appResult?: NetlessApp<any>;
671
+ appContext?: AppContext<any, any>;
672
+ constructor(params: BaseInsertParams, manager: AppManager, appId: string, isAddApp: boolean);
673
+ private initScenes;
674
+ get view(): View | undefined;
675
+ get viewIndex(): number | undefined;
676
+ get isWritable(): boolean;
677
+ get attributes(): any;
678
+ get appAttributes(): AppSyncAttributes;
679
+ getFullScenePath(): string | undefined;
680
+ private getFullScenePathFromScenes;
681
+ setFullPath(path: string): void;
682
+ baseInsertApp(skipUpdate?: boolean): Promise<{
683
+ appId: string;
684
+ app: NetlessApp;
685
+ }>;
686
+ get box(): ReadonlyTeleBox | undefined;
687
+ private setupApp;
688
+ private fixMobileSize;
689
+ private afterSetupApp;
690
+ onSeek(time: number): Promise<void>;
691
+ onReconnected(): Promise<void>;
692
+ onRemoveScene(scenePath: string): Promise<void>;
693
+ getAppInitState: (id: string) => AppInitState | undefined;
694
+ emitAppSceneStateChange(sceneState: SceneState): void;
695
+ emitAppIsWritableChange(): void;
696
+ private makeAppEventListener;
697
+ private appAttributesUpdateListener;
698
+ private setFocusScenePathHandler;
699
+ setScenePath(): void;
700
+ setViewFocusScenePath(): string | undefined;
701
+ private createView;
702
+ notifyPageStateChange: lodash.DebouncedFunc<() => void>;
703
+ get pageState(): PageState;
704
+ removeSceneByIndex(index: number): Promise<boolean>;
705
+ setSceneIndexWithoutSync(index: number): void;
706
+ setSceneIndex(index: number): void;
707
+ destroy(needCloseBox: boolean, cleanAttrs: boolean, skipUpdate: boolean, error?: Error): Promise<void>;
708
+ close(): Promise<void>;
709
+ }
710
+
711
+ declare class MainViewProxy {
712
+ private manager;
713
+ /** Refresh the view's camera in an interval of 1.5s. */
714
+ polling: boolean;
715
+ private scale?;
716
+ private started;
717
+ private mainViewIsAddListener;
718
+ private mainView;
719
+ private store;
720
+ private viewMode;
721
+ private sideEffectManager;
722
+ constructor(manager: AppManager);
723
+ private syncCamera;
724
+ private startListenWritableChange;
725
+ ensureCameraAndSize(): void;
726
+ private get mainViewCamera();
727
+ private get mainViewSize();
728
+ private get didRelease();
729
+ private moveCameraSizeByAttributes;
730
+ start(): void;
731
+ addCameraReaction: () => void;
732
+ setCameraAndSize(): void;
733
+ private cameraReaction;
734
+ sizeChangeHandler: lodash.DebouncedFunc<(size: Size) => void>;
735
+ onUpdateContainerSizeRatio: () => void;
736
+ get view(): View;
737
+ get cameraState(): {
738
+ width: number;
739
+ height: number;
740
+ centerX: number;
741
+ centerY: number;
742
+ scale: number;
743
+ };
744
+ createMainView(): View;
745
+ onReconnect(): void;
746
+ setFocusScenePath(path: string | undefined): View | undefined;
747
+ rebind(): void;
748
+ private onCameraUpdatedByDevice;
749
+ addMainViewListener(): void;
750
+ removeMainViewListener(): void;
751
+ private mainViewClickListener;
752
+ mainViewClickHandler(): Promise<void>;
753
+ setMainViewSize: lodash.DebouncedFunc<(size: Size) => void>;
754
+ private addCameraListener;
755
+ private removeCameraListener;
756
+ private _syncMainViewTimer;
757
+ private onCameraOrSizeUpdated;
758
+ private ensureMainViewSize;
759
+ private syncMainView;
760
+ moveCameraToContian(size: Size): void;
761
+ moveCamera(camera: Camera): void;
762
+ stop(): void;
763
+ setViewMode: (mode: ViewMode) => void;
764
+ destroy(): void;
765
+ }
766
+
767
+ declare class ViewManager {
768
+ private displayer;
769
+ views: Map<string, View>;
770
+ constructor(displayer: Displayer);
771
+ createView(id: string): View;
772
+ getView(id: string): View | undefined;
773
+ destroyView(id: string): void;
774
+ setViewScenePath(id: string, scenePath: string): void;
775
+ destroy(): void;
776
+ }
777
+
778
+ type ReconnectRefresherContext = {
779
+ emitter: EmitterType;
780
+ };
781
+ declare class ReconnectRefresher {
782
+ private ctx;
783
+ private phase?;
784
+ private room;
785
+ private reactors;
786
+ private disposers;
787
+ constructor(ctx: ReconnectRefresherContext);
788
+ setRoom(room: Room | undefined): void;
789
+ setContext(ctx: ReconnectRefresherContext): void;
790
+ private onPhaseChanged;
791
+ private onReconnected;
792
+ private _onReconnected;
793
+ private releaseDisposers;
794
+ refresh(): void;
795
+ add(id: string, func: any): void;
796
+ remove(id: string): void;
797
+ hasReactor(id: string): boolean;
798
+ destroy(): void;
799
+ }
800
+
801
+ declare class AppManager {
802
+ windowManger: WindowManager;
803
+ displayer: Displayer;
804
+ viewManager: ViewManager;
805
+ appProxies: Map<string, AppProxy>;
806
+ appStatus: Map<string, AppStatus>;
807
+ store: AttributesDelegate;
808
+ mainViewProxy: MainViewProxy;
809
+ refresher: ReconnectRefresher;
810
+ isReplay: boolean;
811
+ mainViewScenesLength: number;
812
+ private appListeners;
813
+ boxManager?: BoxManager;
814
+ private _prevSceneIndex;
815
+ private _prevFocused;
816
+ private callbacksNode;
817
+ private appCreateQueue;
818
+ private sideEffectManager;
819
+ sceneState: SceneState | null;
820
+ rootDirRemoving: boolean;
821
+ constructor(windowManger: WindowManager);
822
+ getMemberState(): MemberState;
823
+ private onRemoveScenes;
824
+ /**
825
+ * 根目录被删除时所有的 scene 都会被删除.
826
+ * 所以需要关掉所有开启了 view 的 app
827
+ */
828
+ onRootDirRemoved(needClose?: boolean): Promise<void>;
829
+ private onReadonlyChanged;
830
+ private onPlayerSeekStart;
831
+ private onPlayerSeekDone;
832
+ createRootDirScenesCallback: () => void;
833
+ removeSceneByIndex: (index: number) => Promise<boolean>;
834
+ setSceneIndexWithoutSync: (index: number) => void;
835
+ private onSceneChange;
836
+ private emitMainViewScenesChange;
837
+ private updateSceneState;
838
+ private get eventName();
839
+ get attributes(): WindowMangerAttributes;
840
+ get canOperate(): boolean;
841
+ get room(): Room | undefined;
842
+ get mainView(): white_web_sdk.View;
843
+ get polling(): boolean;
844
+ set polling(b: boolean);
845
+ get focusApp(): AppProxy | undefined;
846
+ get uid(): string;
847
+ getMainViewSceneDir(): string;
848
+ private onCreated;
849
+ private onBoxMove;
850
+ private onBoxResize;
851
+ private onBoxFocus;
852
+ private onBoxClose;
853
+ private onBoxStateChange;
854
+ addAppsChangeListener: () => void;
855
+ addAppCloseListener: () => void;
856
+ private onMainViewIndexChange;
857
+ private onFocusChange;
858
+ attributesUpdateCallback: lodash.DebouncedFunc<(apps: any) => Promise<void>>;
859
+ private _appIds;
860
+ notifyAppsChange(appIds: string[]): void;
861
+ /**
862
+ * 插件更新 attributes 时的回调
863
+ *
864
+ * @param {*} attributes
865
+ * @memberof WindowManager
866
+ */
867
+ _attributesUpdateCallback(apps: any): Promise<void>;
868
+ private onRegisteredChange;
869
+ private onMinimized;
870
+ refresh(): void;
871
+ setBoxManager(boxManager: BoxManager): void;
872
+ resetMaximized(): void;
873
+ resetMinimized(): void;
874
+ private onAppDelete;
875
+ private closeAll;
876
+ bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean): void;
877
+ setMainViewFocusPath(scenePath?: string): boolean | undefined;
878
+ private resetScenePath;
879
+ addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined>;
880
+ private beforeAddApp;
881
+ private afterAddApp;
882
+ closeApp(appId: string, needClose?: boolean): Promise<void>;
883
+ private baseInsertApp;
884
+ private displayerStateListener;
885
+ displayerWritableListener: (isReadonly: boolean) => void;
886
+ safeSetAttributes(attributes: any): void;
887
+ safeUpdateAttributes(keys: string[], value: any): void;
888
+ setMainViewScenePath(scenePath: string): Promise<void>;
889
+ private _setMainViewScenePath;
890
+ private updateSceneIndex;
891
+ setMainViewSceneIndex(index: number): Promise<void>;
892
+ private dispatchSetMainViewScenePath;
893
+ getAppInitPath(appId: string): string | undefined;
894
+ safeDispatchMagixEvent(event: string, payload: any): void;
895
+ focusByAttributes(apps: any): void;
896
+ onReconnected(): Promise<void>;
897
+ notifyContainerRectUpdate(rect: TeleBoxRect): void;
898
+ updateRootDirRemoving: (removing: boolean) => void;
899
+ dispatchInternalEvent(event: Events, payload?: any): void;
900
+ destroy(): void;
901
+ }
902
+
903
+ declare class AppListeners {
904
+ private manager;
905
+ private displayer;
906
+ constructor(manager: AppManager);
907
+ private get boxManager();
908
+ addListeners(): void;
909
+ removeListeners(): void;
910
+ private mainMagixEventListener;
911
+ private appMoveHandler;
912
+ private appResizeHandler;
913
+ private boxStateChangeHandler;
914
+ private setMainViewScenePathHandler;
915
+ private moveCameraHandler;
916
+ private moveCameraToContainHandler;
917
+ private cursorMoveHandler;
918
+ private rootDirRemovedHandler;
919
+ private refreshHandler;
920
+ private initMainViewCameraHandler;
921
+ private setAppFocusViewIndexHandler;
922
+ }
923
+
924
+ declare enum IframeEvents {
925
+ Init = "Init",
926
+ AttributesUpdate = "AttributesUpdate",
927
+ SetAttributes = "SetAttributes",
928
+ RegisterMagixEvent = "RegisterMagixEvent",
929
+ RemoveMagixEvent = "RemoveMagixEvent",
930
+ RemoveAllMagixEvent = "RemoveAllMagixEvent",
931
+ RoomStateChanged = "RoomStateChanged",
932
+ DispatchMagixEvent = "DispatchMagixEvent",
933
+ ReciveMagixEvent = "ReciveMagixEvent",
934
+ NextPage = "NextPage",
935
+ PrevPage = "PrevPage",
936
+ SDKCreate = "SDKCreate",
937
+ OnCreate = "OnCreate",
938
+ SetPage = "SetPage",
939
+ GetAttributes = "GetAttributes",
940
+ Ready = "Ready",
941
+ Destory = "Destory",
942
+ StartCreate = "StartCreate",
943
+ WrapperDidUpdate = "WrapperDidUpdate",
944
+ DispayIframe = "DispayIframe",
945
+ HideIframe = "HideIframe",
946
+ GetRootRect = "GetRootRect",
947
+ ReplayRootRect = "ReplayRootRect",
948
+ PageTo = "PageTo"
949
+ }
950
+ declare enum DomEvents {
951
+ WrapperDidMount = "WrapperDidMount",
952
+ IframeLoad = "IframeLoad"
953
+ }
954
+ type IframeBridgeAttributes = {
955
+ readonly url: string;
956
+ readonly width: number;
957
+ readonly height: number;
958
+ readonly displaySceneDir: string;
959
+ readonly lastEvent?: {
960
+ name: string;
961
+ payload: any;
962
+ };
963
+ readonly useClicker?: boolean;
964
+ readonly useSelector?: boolean;
965
+ };
966
+ type IframeBridgeEvents = {
967
+ created: undefined;
968
+ [IframeEvents.Ready]: undefined;
969
+ [IframeEvents.StartCreate]: undefined;
970
+ [IframeEvents.OnCreate]: IframeBridge;
971
+ [IframeEvents.Destory]: undefined;
972
+ [IframeEvents.GetRootRect]: undefined;
973
+ [IframeEvents.ReplayRootRect]: DOMRect;
974
+ [DomEvents.WrapperDidMount]: undefined;
975
+ [IframeEvents.WrapperDidUpdate]: undefined;
976
+ [DomEvents.IframeLoad]: Event;
977
+ [IframeEvents.HideIframe]: undefined;
978
+ [IframeEvents.DispayIframe]: undefined;
979
+ };
980
+ type IframeSize = {
981
+ readonly width: number;
982
+ readonly height: number;
983
+ };
984
+ type BaseOption = {
985
+ readonly url: string;
986
+ readonly width: number;
987
+ readonly height: number;
988
+ readonly displaySceneDir: string;
989
+ };
990
+ type InsertOptions = {
991
+ readonly useClicker?: boolean;
992
+ readonly useSelector?: boolean;
993
+ } & BaseOption;
994
+ type OnCreateInsertOption = {
995
+ readonly displayer: Displayer;
996
+ } & BaseOption;
997
+ /**
998
+ * {@link https://github.com/netless-io/netless-iframe-bridge @netless/iframe-bridge}
999
+ */
1000
+ declare class IframeBridge {
1001
+ readonly manager: WindowManager;
1002
+ readonly appManager: AppManager;
1003
+ static readonly kind = "IframeBridge";
1004
+ static readonly hiddenClass = "netless-iframe-brdige-hidden";
1005
+ static emitter: Emittery<IframeBridgeEvents>;
1006
+ private static displayer;
1007
+ private static alreadyCreate;
1008
+ displayer: Displayer;
1009
+ iframe: HTMLIFrameElement;
1010
+ private readonly magixEventMap;
1011
+ private cssList;
1012
+ private allowAppliances;
1013
+ private bridgeDisposer;
1014
+ private rootRect;
1015
+ private sideEffectManager;
1016
+ constructor(manager: WindowManager, appManager: AppManager);
1017
+ static onCreate(plugin: IframeBridge): void;
1018
+ insert(options: InsertOptions): this;
1019
+ private getComputedIframeStyle;
1020
+ destroy(): void;
1021
+ private getIframe;
1022
+ setIframeSize(params: IframeSize): void;
1023
+ get attributes(): Partial<IframeBridgeAttributes>;
1024
+ setAttributes(data: Partial<IframeBridgeAttributes>): void;
1025
+ private _createIframe;
1026
+ scaleIframeToFit(animationMode?: AnimationMode): void;
1027
+ get isReplay(): boolean;
1028
+ private handleSetPage;
1029
+ private execListenIframe;
1030
+ private src_url_equal_anchor?;
1031
+ private listenIframe;
1032
+ private onPhaseChangedListener;
1033
+ private listenDisplayerState;
1034
+ private computedStyleAndIframeDisplay;
1035
+ private listenDisplayerCallbacks;
1036
+ private get callbackName();
1037
+ private stateChangeListener;
1038
+ private computedStyle;
1039
+ private computedIframeDisplay;
1040
+ computedZindex(): void;
1041
+ private updateStyle;
1042
+ private get iframeOrigin();
1043
+ private messageListener;
1044
+ private handleSDKCreate;
1045
+ private handleDispatchMagixEvent;
1046
+ private handleSetAttributes;
1047
+ private handleRegisterMagixEvent;
1048
+ private handleRemoveMagixEvent;
1049
+ private handleNextPage;
1050
+ private handlePrevPage;
1051
+ private handlePageTo;
1052
+ private handleRemoveAllMagixEvent;
1053
+ private handleGetAttributes;
1054
+ postMessage(message: any): void;
1055
+ dispatchMagixEvent(event: string, payload: any): void;
1056
+ private get currentIndex();
1057
+ private get currentPage();
1058
+ private get totalPage();
1059
+ private get readonly();
1060
+ get inDisplaySceneDir(): boolean;
1061
+ private isClicker;
1062
+ private get isDisableInput();
1063
+ }
1064
+
1065
+ declare const BuiltinApps: {
1066
+ DocsViewer: string;
1067
+ MediaPlayer: string;
1068
+ };
1069
+
1070
+ type WindowMangerAttributes = {
19
1071
  modelValue?: string;
20
1072
  boxState: TELE_BOX_STATE;
21
1073
  maximized?: boolean;
22
1074
  minimized?: boolean;
23
1075
  [key: string]: any;
24
1076
  };
25
- export declare type apps = {
1077
+ type apps = {
26
1078
  [key: string]: NetlessApp;
27
1079
  };
28
- export declare type AddAppOptions = {
1080
+ type AddAppOptions = {
29
1081
  scenePath?: string;
30
1082
  title?: string;
31
1083
  scenes?: SceneDefinition[];
32
1084
  };
33
- export declare type setAppOptions = AddAppOptions & {
1085
+ type setAppOptions = AddAppOptions & {
34
1086
  appOptions?: any;
35
1087
  };
36
- export declare type AddAppParams<TAttributes = any> = {
1088
+ type AddAppParams<TAttributes = any> = {
37
1089
  kind: string;
38
1090
  src?: string;
39
1091
  options?: AddAppOptions;
40
1092
  attributes?: TAttributes;
41
1093
  };
42
- export declare type BaseInsertParams = {
1094
+ type BaseInsertParams = {
43
1095
  kind: string;
44
1096
  src?: string;
45
1097
  options?: AddAppOptions;
46
1098
  attributes?: any;
47
1099
  isDynamicPPT?: boolean;
48
1100
  };
49
- export declare type AppSyncAttributes = {
1101
+ type AppSyncAttributes = {
50
1102
  kind: string;
51
1103
  src?: string;
52
1104
  options: any;
@@ -54,10 +1106,8 @@ export declare type AppSyncAttributes = {
54
1106
  isDynamicPPT?: boolean;
55
1107
  fullPath?: string;
56
1108
  createdAt?: number;
57
- camera?: ICamera;
58
- size?: ISize;
59
1109
  };
60
- export declare type AppInitState = {
1110
+ type AppInitState = {
61
1111
  id: string;
62
1112
  x?: number;
63
1113
  y?: number;
@@ -70,36 +1120,52 @@ export declare type AppInitState = {
70
1120
  boxState?: TeleBoxState;
71
1121
  zIndex?: number;
72
1122
  };
73
- export declare type CursorMovePayload = {
1123
+ type CursorMovePayload = {
74
1124
  uid: string;
75
1125
  state?: "leave";
76
1126
  position: Position;
77
1127
  };
78
- export declare type MountParams = {
1128
+ type CursorOptions = {
1129
+ /**
1130
+ * If `"custom"`, it will render the pencil / eraser cursor as a circle and shapes cursor as a cross.
1131
+ *
1132
+ * @default "default"
1133
+ */
1134
+ style?: "default" | "custom";
1135
+ };
1136
+ type MountParams = {
79
1137
  room: Room | Player;
80
1138
  container?: HTMLElement;
81
1139
  /** 白板高宽比例, 默认为 9 / 16 */
82
1140
  containerSizeRatio?: number;
83
- /** 是否高亮显示同步区域, 默认为 true */
84
- highlightStage?: boolean;
1141
+ /** @deprecated 显示 PS 透明背景,默认 true */
1142
+ chessboard?: boolean;
85
1143
  collectorContainer?: HTMLElement;
86
1144
  collectorStyles?: Partial<CSSStyleDeclaration>;
87
1145
  overwriteStyles?: string;
88
1146
  cursor?: boolean;
1147
+ cursorOptions?: CursorOptions;
89
1148
  debug?: boolean;
90
1149
  disableCameraTransform?: boolean;
91
1150
  prefersColorScheme?: TeleBoxColorScheme;
92
1151
  applianceIcons?: ApplianceIcons;
1152
+ fullscreen?: boolean;
1153
+ polling?: boolean;
1154
+ supportAppliancePlugin?: boolean;
93
1155
  };
94
- export declare const reconnectRefresher: ReconnectRefresher;
95
- export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> implements PageController {
1156
+ declare const reconnectRefresher: ReconnectRefresher;
1157
+ declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any> implements PageController {
96
1158
  static kind: string;
97
1159
  static displayer: Displayer;
1160
+ static wrapper?: HTMLElement;
1161
+ static sizer?: HTMLElement;
98
1162
  static playground?: HTMLElement;
99
1163
  static container?: HTMLElement;
100
1164
  static debug: boolean;
101
1165
  static containerSizeRatio: number;
1166
+ static supportAppliancePlugin?: boolean;
102
1167
  private static isCreated;
1168
+ private static _resolve;
103
1169
  version: string;
104
1170
  dependencies: Record<string, string>;
105
1171
  appListeners?: AppListeners;
@@ -110,20 +1176,25 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
110
1176
  viewMode: ViewMode;
111
1177
  isReplay: boolean;
112
1178
  private _pageState?;
1179
+ private _fullscreen?;
1180
+ private _cursorUIDs;
1181
+ private _cursorUIDsStyleDOM?;
113
1182
  private boxManager?;
114
1183
  private static params?;
1184
+ private containerResizeObserver?;
115
1185
  containerSizeRatio: number;
116
1186
  constructor(context: InvisiblePluginContext);
1187
+ static onCreate(manager: WindowManager): void;
117
1188
  static mount(params: MountParams): Promise<WindowManager>;
118
1189
  private static initManager;
119
1190
  private static initContainer;
120
- static get registered(): Map<string, RegisterParams<any, any, any>>;
1191
+ static get registered(): Map<string, RegisterParams>;
121
1192
  bindContainer(container: HTMLElement): void;
122
1193
  bindCollectorContainer(container: HTMLElement): void;
123
1194
  /**
124
1195
  * 注册插件
125
1196
  */
126
- static register<AppOptions = any, SetupResult = any, Attributes = any>(params: RegisterParams<AppOptions, SetupResult, Attributes>): Promise<void>;
1197
+ static register(params: RegisterParams<any, any, any>): Promise<void>;
127
1198
  /**
128
1199
  * 注销插件
129
1200
  */
@@ -172,6 +1243,17 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
172
1243
  * app destroy 回调
173
1244
  */
174
1245
  onAppDestroy(kind: string, listener: (error: Error) => void): void;
1246
+ /**
1247
+ * app 本地自定义事件回调
1248
+ *
1249
+ * 返回一个用于撤销此监听的函数
1250
+ */
1251
+ onAppEvent(kind: string, listener: (args: {
1252
+ kind: string;
1253
+ appId: string;
1254
+ type: string;
1255
+ value: any;
1256
+ }) => void): () => void;
175
1257
  /**
176
1258
  * 设置 ViewMode
177
1259
  */
@@ -179,6 +1261,9 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
179
1261
  setBoxState(boxState: TeleBoxState): void;
180
1262
  setMaximized(maximized: boolean): void;
181
1263
  setMinimized(minimized: boolean): void;
1264
+ setFullscreen(fullscreen: boolean): void;
1265
+ get cursorUIDs(): string[];
1266
+ setCursorUIDs(cursorUIDs?: string[] | null): void;
182
1267
  get mainView(): View;
183
1268
  get camera(): Camera;
184
1269
  get cameraState(): CameraState;
@@ -188,6 +1273,10 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
188
1273
  get prefersColorScheme(): TeleBoxColorScheme | undefined;
189
1274
  get focused(): string | undefined;
190
1275
  get focusedView(): View | undefined;
1276
+ get polling(): boolean;
1277
+ set polling(b: boolean);
1278
+ get cursorStyle(): "default" | "custom";
1279
+ set cursorStyle(value: "default" | "custom");
191
1280
  get mainViewSceneIndex(): number;
192
1281
  get mainViewSceneDir(): string;
193
1282
  get topApp(): string | undefined;
@@ -196,6 +1285,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
196
1285
  get canUndoSteps(): number;
197
1286
  get sceneState(): SceneState;
198
1287
  get pageState(): PageState;
1288
+ get fullscreen(): boolean;
199
1289
  /**
200
1290
  * 查询所有的 App
201
1291
  */
@@ -208,6 +1298,10 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
208
1298
  * 关闭 APP
209
1299
  */
210
1300
  closeApp(appId: string): Promise<void>;
1301
+ /**
1302
+ * 切换 focus 到指定的 app, 并且把这个 app 放到最前面
1303
+ */
1304
+ focusApp(appId: string): void;
211
1305
  moveCamera(camera: Partial<Camera> & {
212
1306
  animationMode?: AnimationMode | undefined;
213
1307
  }): void;
@@ -238,12 +1332,11 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
238
1332
  lockImage(uuid: string, locked: boolean): void;
239
1333
  lockImages(locked: boolean): void;
240
1334
  refresh(): void;
241
- /** @inner */
242
- _refresh(): void;
243
1335
  setContainerSizeRatio(ratio: number): void;
244
1336
  private isDynamicPPT;
245
1337
  private ensureAttributes;
1338
+ private _iframeBridge?;
1339
+ getIframeBridge(): IframeBridge;
246
1340
  }
247
- export * from "./typings";
248
- export { BuiltinApps } from "./BuiltinApps";
249
- export type { PublicEvent } from "./callback";
1341
+
1342
+ export { type AddAppOptions, type AddAppParams, type AddPageParams, AppContext, AppCreateError, type AppEmitterEvent, type AppInitState, type AppListenerKeys, AppManagerNotInitError, AppNotRegisterError, type AppPayload, type AppSyncAttributes, type ApplianceIcons, type BaseInsertParams, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, type CursorMovePayload, type CursorOptions, DomEvents, IframeBridge, type IframeBridgeAttributes, type IframeBridgeEvents, IframeEvents, type IframeSize, type InsertOptions, InvalidScenePath, type MountParams, type NetlessApp, type OnCreateInsertOption, type PageController, type PageRemoveService, type PageState, ParamsInvalidError, type PublicEvent, type RegisterEventData, type RegisterEvents, type RegisterParams, Storage, type StorageStateChangedEvent, type StorageStateChangedListener, WhiteWebSDKInvalidError, WindowManager, type WindowMangerAttributes, type apps, calculateNextIndex, reconnectRefresher, type setAppOptions };