@netless/window-manager 0.4.0-canary.3 → 0.4.0-canary.33
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/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/window-manager.iml +12 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +32 -1
- package/README.md +3 -0
- package/dist/App/MagixEvent/index.d.ts +29 -0
- package/dist/App/Storage/StorageEvent.d.ts +8 -0
- package/dist/App/Storage/index.d.ts +39 -0
- package/dist/App/Storage/typings.d.ts +22 -0
- package/dist/App/Storage/utils.d.ts +5 -0
- package/dist/AppContext.d.ts +40 -16
- package/dist/AppListener.d.ts +2 -1
- package/dist/AppManager.d.ts +26 -12
- package/dist/AppProxy.d.ts +7 -8
- package/dist/AttributesDelegate.d.ts +2 -2
- package/dist/BoxManager.d.ts +6 -3
- package/dist/BuiltinApps.d.ts +5 -0
- package/dist/ContainerResizeObserver.d.ts +10 -0
- package/dist/Cursor/Cursor.d.ts +10 -12
- package/dist/Cursor/index.d.ts +6 -16
- package/dist/Helper.d.ts +7 -0
- package/dist/ReconnectRefresher.d.ts +0 -1
- package/dist/Register/storage.d.ts +5 -1
- package/dist/Utils/AppCreateQueue.d.ts +11 -0
- package/dist/Utils/Common.d.ts +7 -2
- package/dist/Utils/Reactive.d.ts +1 -1
- package/dist/Utils/RoomHacker.d.ts +3 -3
- package/dist/{MainView.d.ts → View/MainView.d.ts} +5 -6
- package/dist/View/ViewManager.d.ts +13 -0
- package/dist/constants.d.ts +5 -7
- package/dist/index.d.ts +36 -14
- package/dist/index.es.js +41 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +41 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +3 -2
- package/docs/advanced.md +39 -0
- package/docs/api.md +69 -6
- package/docs/concept.md +9 -0
- package/docs/replay.md +40 -0
- package/package.json +7 -6
- package/src/App/MagixEvent/index.ts +68 -0
- package/src/App/Storage/StorageEvent.ts +21 -0
- package/src/App/Storage/index.ts +289 -0
- package/src/App/Storage/typings.ts +23 -0
- package/src/App/Storage/utils.ts +17 -0
- package/src/AppContext.ts +69 -24
- package/src/AppListener.ts +28 -16
- package/src/AppManager.ts +261 -83
- package/src/AppProxy.ts +53 -64
- package/src/AttributesDelegate.ts +2 -2
- package/src/BoxManager.ts +40 -24
- package/src/BuiltinApps.ts +23 -0
- package/src/ContainerResizeObserver.ts +62 -0
- package/src/Cursor/Cursor.svelte +25 -21
- package/src/Cursor/Cursor.ts +25 -38
- package/src/Cursor/icons.ts +2 -0
- package/src/Cursor/index.ts +45 -139
- package/src/Helper.ts +41 -0
- package/src/ReconnectRefresher.ts +0 -5
- package/src/Register/index.ts +25 -16
- package/src/Register/loader.ts +2 -2
- package/src/Register/storage.ts +6 -1
- package/src/Utils/AppCreateQueue.ts +54 -0
- package/src/Utils/Common.ts +69 -14
- package/src/Utils/Reactive.ts +9 -3
- package/src/Utils/RoomHacker.ts +44 -14
- package/src/{MainView.ts → View/MainView.ts} +25 -36
- package/src/View/ViewManager.ts +52 -0
- package/src/constants.ts +6 -4
- package/src/image/laser-pointer-cursor.svg +17 -0
- package/src/index.ts +168 -101
- package/src/shim.d.ts +5 -0
- package/src/style.css +7 -1
- package/src/typings.ts +3 -2
- package/vite.config.js +8 -2
- package/dist/Base/Context.d.ts +0 -13
- package/dist/Base/index.d.ts +0 -7
- package/dist/Utils/CameraStore.d.ts +0 -15
- package/dist/ViewManager.d.ts +0 -29
- package/dist/sdk.d.ts +0 -14
- package/src/Base/Context.ts +0 -49
- package/src/Base/index.ts +0 -10
- package/src/Utils/CameraStore.ts +0 -72
- package/src/sdk.ts +0 -39
- package/src/viewManager.ts +0 -177
package/src/index.ts
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
import AppDocsViewer from "@netless/app-docs-viewer";
|
2
|
-
import AppMediaPlayer, { setOptions } from "@netless/app-media-player";
|
3
1
|
import Emittery from "emittery";
|
4
2
|
import pRetry from "p-retry";
|
5
3
|
import { AppManager } from "./AppManager";
|
6
4
|
import { appRegister } from "./Register";
|
5
|
+
import { checkVersion, setupWrapper } from "./Helper";
|
6
|
+
import { ContainerResizeObserver } from "./ContainerResizeObserver";
|
7
7
|
import { createBoxManager } from "./BoxManager";
|
8
8
|
import { CursorManager } from "./Cursor";
|
9
|
-
import { DEFAULT_CONTAINER_RATIO, Events
|
9
|
+
import { DEFAULT_CONTAINER_RATIO, Events } from "./constants";
|
10
10
|
import { Fields } from "./AttributesDelegate";
|
11
11
|
import { initDb } from "./Register/storage";
|
12
|
-
import {
|
12
|
+
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
+
import { isEqual, isNull, isObject, omit } from "lodash";
|
13
14
|
import { log } from "./Utils/log";
|
15
|
+
import { ReconnectRefresher } from "./ReconnectRefresher";
|
14
16
|
import { replaceRoomFunction } from "./Utils/RoomHacker";
|
15
|
-
import {
|
16
|
-
import { setupWrapper } from "./ViewManager";
|
17
|
+
import { setupBuiltin } from "./BuiltinApps";
|
17
18
|
import "./style.css";
|
18
19
|
import "@netless/telebox-insider/dist/style.css";
|
19
20
|
import {
|
20
21
|
addEmitterOnceListener,
|
21
22
|
ensureValidScenePath,
|
22
|
-
|
23
|
+
entireScenes,
|
23
24
|
isValidScenePath,
|
24
25
|
wait,
|
25
26
|
} from "./Utils/Common";
|
@@ -29,17 +30,8 @@ import {
|
|
29
30
|
AppManagerNotInitError,
|
30
31
|
InvalidScenePath,
|
31
32
|
ParamsInvalidError,
|
32
|
-
WhiteWebSDKInvalidError,
|
33
33
|
} from "./Utils/error";
|
34
|
-
import type { Apps } from "./AttributesDelegate";
|
35
|
-
import {
|
36
|
-
InvisiblePlugin,
|
37
|
-
isPlayer,
|
38
|
-
isRoom,
|
39
|
-
RoomPhase,
|
40
|
-
ViewMode,
|
41
|
-
WhiteVersion,
|
42
|
-
} from "white-web-sdk";
|
34
|
+
import type { Apps, Position } from "./AttributesDelegate";
|
43
35
|
import type {
|
44
36
|
Displayer,
|
45
37
|
SceneDefinition,
|
@@ -53,14 +45,13 @@ import type {
|
|
53
45
|
Rectangle,
|
54
46
|
ViewVisionMode,
|
55
47
|
CameraState,
|
48
|
+
Player,
|
56
49
|
} from "white-web-sdk";
|
57
50
|
import type { AppListeners } from "./AppListener";
|
58
51
|
import type { NetlessApp, RegisterParams } from "./typings";
|
59
52
|
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
60
53
|
import type { AppProxy } from "./AppProxy";
|
61
54
|
|
62
|
-
const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
|
63
|
-
|
64
55
|
export type WindowMangerAttributes = {
|
65
56
|
modelValue?: string;
|
66
57
|
boxState: TELE_BOX_STATE;
|
@@ -126,6 +117,8 @@ export type AppInitState = {
|
|
126
117
|
zIndex?: number;
|
127
118
|
};
|
128
119
|
|
120
|
+
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
121
|
+
|
129
122
|
export type EmitterEvent = {
|
130
123
|
onCreated: undefined;
|
131
124
|
InitReplay: AppInitState;
|
@@ -140,6 +133,8 @@ export type EmitterEvent = {
|
|
140
133
|
boxStateChange: string;
|
141
134
|
playgroundSizeChange: DOMRect;
|
142
135
|
onReconnected: void;
|
136
|
+
removeScenes: string;
|
137
|
+
cursorMove: CursorMovePayload;
|
143
138
|
};
|
144
139
|
|
145
140
|
export type EmitterType = Emittery<EmitterEvent>;
|
@@ -151,10 +146,16 @@ export type PublicEvent = {
|
|
151
146
|
darkModeChange: boolean;
|
152
147
|
prefersColorSchemeChange: TeleBoxColorScheme;
|
153
148
|
cameraStateChange: CameraState;
|
149
|
+
mainViewScenePathChange: string;
|
150
|
+
mainViewSceneIndexChange: number;
|
151
|
+
focusedChange: string | undefined;
|
152
|
+
mainViewScenesLengthChange: number;
|
153
|
+
canRedoStepsChange: number;
|
154
|
+
canUndoStepsChange: number;
|
154
155
|
};
|
155
156
|
|
156
157
|
export type MountParams = {
|
157
|
-
room: Room;
|
158
|
+
room: Room | Player;
|
158
159
|
container?: HTMLElement;
|
159
160
|
/** 白板高宽比例, 默认为 9 / 16 */
|
160
161
|
containerSizeRatio?: number;
|
@@ -172,6 +173,8 @@ export type MountParams = {
|
|
172
173
|
export type CallbacksType = Emittery<PublicEvent>;
|
173
174
|
export const callbacks: CallbacksType = new Emittery();
|
174
175
|
|
176
|
+
export const reconnectRefresher = new ReconnectRefresher({ emitter });
|
177
|
+
|
175
178
|
export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
176
179
|
public static kind = "WindowManager";
|
177
180
|
public static displayer: Displayer;
|
@@ -182,7 +185,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
182
185
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
183
186
|
private static isCreated = false;
|
184
187
|
|
185
|
-
public version =
|
188
|
+
public version = __APP_VERSION__;
|
189
|
+
public dependencies = __APP_DEPENDENCIES__;
|
186
190
|
|
187
191
|
public appListeners?: AppListeners;
|
188
192
|
|
@@ -196,9 +200,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
196
200
|
private boxManager?: BoxManager;
|
197
201
|
private static params?: MountParams;
|
198
202
|
|
203
|
+
private containerResizeObserver?: ContainerResizeObserver;
|
204
|
+
|
199
205
|
constructor(context: InvisiblePluginContext) {
|
200
206
|
super(context);
|
201
207
|
WindowManager.displayer = context.displayer;
|
208
|
+
(window as any).NETLESS_DEPS = __APP_DEPENDENCIES__;
|
202
209
|
}
|
203
210
|
|
204
211
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
@@ -210,20 +217,23 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
210
217
|
const cursor = params.cursor;
|
211
218
|
WindowManager.params = params;
|
212
219
|
|
213
|
-
|
220
|
+
checkVersion();
|
221
|
+
let manager: WindowManager | undefined = undefined;
|
214
222
|
if (isRoom(room)) {
|
215
223
|
if (room.phase !== RoomPhase.Connected) {
|
216
224
|
throw new Error("[WindowManager]: Room only Connected can be mount");
|
217
225
|
}
|
226
|
+
if (room.phase === RoomPhase.Connected && room.isWritable) {
|
227
|
+
// redo undo 需要设置这个属性
|
228
|
+
room.disableSerialization = false;
|
229
|
+
}
|
230
|
+
manager = await this.initManager(room);
|
218
231
|
}
|
219
232
|
if (WindowManager.isCreated) {
|
220
233
|
throw new Error("[WindowManager]: Already created cannot be created again");
|
221
234
|
}
|
222
|
-
|
235
|
+
|
223
236
|
this.debug = Boolean(debug);
|
224
|
-
if (this.debug) {
|
225
|
-
setOptions({ verbose: true });
|
226
|
-
}
|
227
237
|
log("Already insert room", manager);
|
228
238
|
|
229
239
|
if (isRoom(this.displayer)) {
|
@@ -233,7 +243,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
233
243
|
} else {
|
234
244
|
await pRetry(
|
235
245
|
async count => {
|
236
|
-
manager = await
|
246
|
+
manager = (await room.getInvisiblePlugin(WindowManager.kind)) as WindowManager;
|
237
247
|
if (!manager) {
|
238
248
|
log(`manager is empty. retrying ${count}`);
|
239
249
|
throw new Error();
|
@@ -243,16 +253,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
243
253
|
);
|
244
254
|
}
|
245
255
|
|
256
|
+
if (!manager) {
|
257
|
+
throw new Error("[WindowManager]: create manager failed");
|
258
|
+
}
|
259
|
+
|
246
260
|
if (containerSizeRatio) {
|
247
261
|
WindowManager.containerSizeRatio = containerSizeRatio;
|
248
262
|
}
|
249
263
|
await manager.ensureAttributes();
|
250
264
|
|
251
265
|
manager.appManager = new AppManager(manager);
|
252
|
-
|
253
|
-
if (cursor) {
|
254
|
-
manager.cursorManager = new CursorManager(manager.appManager);
|
255
|
-
}
|
266
|
+
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor));
|
256
267
|
|
257
268
|
if (params.container) {
|
258
269
|
manager.bindContainer(params.container);
|
@@ -317,7 +328,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
317
328
|
style.textContent = overwriteStyles;
|
318
329
|
playground.appendChild(style);
|
319
330
|
}
|
320
|
-
manager.
|
331
|
+
manager.containerResizeObserver = ContainerResizeObserver.create(
|
332
|
+
playground,
|
333
|
+
sizer,
|
334
|
+
wrapper,
|
335
|
+
emitter
|
336
|
+
);
|
321
337
|
WindowManager.wrapper = wrapper;
|
322
338
|
return mainViewElement;
|
323
339
|
}
|
@@ -353,6 +369,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
353
369
|
this.appManager?.refresh();
|
354
370
|
this.appManager?.resetMaximized();
|
355
371
|
this.appManager?.resetMinimized();
|
372
|
+
this.appManager?.displayerWritableListener(!this.room.isWritable);
|
356
373
|
WindowManager.container = container;
|
357
374
|
}
|
358
375
|
|
@@ -416,6 +433,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
416
433
|
const appScenePath = appManager.store.getAppScenePath(appId);
|
417
434
|
if (appScenePath && appScenePath === scenePath) {
|
418
435
|
console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
|
436
|
+
if (this.boxManager) {
|
437
|
+
const topBox = this.boxManager.getTopBox();
|
438
|
+
if (topBox) {
|
439
|
+
this.boxManager.setZIndex(appId, topBox.zIndex + 1, false);
|
440
|
+
}
|
441
|
+
}
|
419
442
|
return;
|
420
443
|
}
|
421
444
|
}
|
@@ -423,11 +446,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
423
446
|
if (scenePath && scenes && scenes.length > 0) {
|
424
447
|
if (this.isDynamicPPT(scenes)) {
|
425
448
|
isDynamicPPT = true;
|
426
|
-
if (!this.displayer
|
449
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
427
450
|
this.room?.putScenes(scenePath, scenes);
|
428
451
|
}
|
429
452
|
} else {
|
430
|
-
if (!this.displayer
|
453
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
431
454
|
this.room?.putScenes(scenePath, [{ name: scenes[0].name }]);
|
432
455
|
}
|
433
456
|
}
|
@@ -460,7 +483,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
460
483
|
/**
|
461
484
|
* 返回 mainView 的 ScenePath
|
462
485
|
*/
|
463
|
-
public getMainViewScenePath(): string {
|
486
|
+
public getMainViewScenePath(): string | undefined {
|
464
487
|
return this.appManager?.store.getMainViewScenePath();
|
465
488
|
}
|
466
489
|
|
@@ -475,10 +498,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
475
498
|
* 设置所有 app 的 readonly 模式
|
476
499
|
*/
|
477
500
|
public setReadonly(readonly: boolean): void {
|
478
|
-
|
479
|
-
|
480
|
-
this.appManager?.boxManager?.setReadonly(readonly);
|
481
|
-
}
|
501
|
+
this.readonly = readonly;
|
502
|
+
this.boxManager?.setReadonly(readonly);
|
482
503
|
}
|
483
504
|
|
484
505
|
/**
|
@@ -510,6 +531,35 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
510
531
|
this.viewMode = mode;
|
511
532
|
}
|
512
533
|
|
534
|
+
public setBoxState(boxState: TeleBoxState): void {
|
535
|
+
if (!this.canOperate) return;
|
536
|
+
switch (boxState) {
|
537
|
+
case "normal":
|
538
|
+
this.setMaximized(false);
|
539
|
+
this.setMinimized(false);
|
540
|
+
break;
|
541
|
+
case "maximized":
|
542
|
+
this.setMaximized(true);
|
543
|
+
this.setMinimized(false);
|
544
|
+
break;
|
545
|
+
case "minimized":
|
546
|
+
this.setMinimized(true);
|
547
|
+
break;
|
548
|
+
default:
|
549
|
+
break;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
|
553
|
+
public setMaximized(maximized: boolean): void {
|
554
|
+
if (!this.canOperate) return;
|
555
|
+
this.boxManager?.setMaximized(maximized, false);
|
556
|
+
}
|
557
|
+
|
558
|
+
public setMinimized(minimized: boolean): void {
|
559
|
+
if (!this.canOperate) return;
|
560
|
+
this.boxManager?.setMinimized(minimized, false);
|
561
|
+
}
|
562
|
+
|
513
563
|
public get mainView(): View {
|
514
564
|
if (this.appManager) {
|
515
565
|
return this.appManager.mainViewProxy.view;
|
@@ -558,6 +608,48 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
558
608
|
}
|
559
609
|
}
|
560
610
|
|
611
|
+
public get focused(): string | undefined {
|
612
|
+
return this.attributes.focus;
|
613
|
+
}
|
614
|
+
|
615
|
+
public get mainViewSceneIndex(): number {
|
616
|
+
return this.appManager?.store.getMainViewSceneIndex();
|
617
|
+
}
|
618
|
+
|
619
|
+
public get mainViewSceneDir(): string {
|
620
|
+
if (this.appManager) {
|
621
|
+
return this.appManager?.getMainViewSceneDir();
|
622
|
+
} else {
|
623
|
+
throw new AppManagerNotInitError();
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
public get topApp(): string | undefined {
|
628
|
+
return this.boxManager?.getTopBox()?.id;
|
629
|
+
}
|
630
|
+
|
631
|
+
public get mainViewScenesLength(): number {
|
632
|
+
return this.appManager?.mainViewScenesLength || 0;
|
633
|
+
}
|
634
|
+
|
635
|
+
public get canRedoSteps(): number {
|
636
|
+
const focused = this.focused;
|
637
|
+
if (focused) {
|
638
|
+
return this.appManager?.focusApp?.view?.canRedoSteps || 0;
|
639
|
+
} else {
|
640
|
+
return this.mainView.canRedoSteps;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
public get canUndoSteps(): number {
|
645
|
+
const focused = this.focused;
|
646
|
+
if (focused) {
|
647
|
+
return this.appManager?.focusApp?.view?.canUndoSteps || 0;
|
648
|
+
} else {
|
649
|
+
return this.mainView.canUndoSteps;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
561
653
|
/**
|
562
654
|
* 查询所有的 App
|
563
655
|
*/
|
@@ -582,7 +674,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
582
674
|
public moveCamera(
|
583
675
|
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
584
676
|
): void {
|
677
|
+
const pureCamera = omit(camera, ["animationMode"]);
|
678
|
+
const mainViewCamera = { ...this.mainView.camera };
|
679
|
+
if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
|
585
680
|
this.mainView.moveCamera(camera);
|
681
|
+
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
682
|
+
setTimeout(() => {
|
683
|
+
this.appManager?.mainViewProxy.setCameraAndSize();
|
684
|
+
}, 100);
|
586
685
|
}
|
587
686
|
|
588
687
|
public moveCameraToContain(
|
@@ -595,7 +694,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
595
694
|
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
596
695
|
setTimeout(() => {
|
597
696
|
this.appManager?.mainViewProxy.setCameraAndSize();
|
598
|
-
},
|
697
|
+
}, 100);
|
599
698
|
}
|
600
699
|
|
601
700
|
public convertToPointInWorld(point: Point): Point {
|
@@ -666,18 +765,38 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
666
765
|
this.appManager?.boxManager?.setPrefersColorScheme(scheme);
|
667
766
|
}
|
668
767
|
|
669
|
-
|
670
|
-
const
|
671
|
-
|
768
|
+
public cleanCurrentScene(): void {
|
769
|
+
const focused = this.focused;
|
770
|
+
if (focused) {
|
771
|
+
this.appManager?.focusApp?.view?.cleanCurrentScene();
|
772
|
+
} else {
|
773
|
+
this.mainView.cleanCurrentScene();
|
774
|
+
}
|
672
775
|
}
|
673
776
|
|
674
|
-
|
675
|
-
const
|
676
|
-
if (
|
677
|
-
|
777
|
+
public redo(): number {
|
778
|
+
const focused = this.focused;
|
779
|
+
if (focused) {
|
780
|
+
return this.appManager?.focusApp?.view?.redo() || 0;
|
781
|
+
} else {
|
782
|
+
return this.mainView.redo();
|
783
|
+
}
|
784
|
+
}
|
785
|
+
|
786
|
+
public undo(): number {
|
787
|
+
const focused = this.focused;
|
788
|
+
if (focused) {
|
789
|
+
return this.appManager?.focusApp?.view?.undo() || 0;
|
790
|
+
} else {
|
791
|
+
return this.mainView.undo();
|
678
792
|
}
|
679
793
|
}
|
680
794
|
|
795
|
+
private isDynamicPPT(scenes: SceneDefinition[]) {
|
796
|
+
const sceneSrc = scenes[0]?.ppt?.src;
|
797
|
+
return sceneSrc?.startsWith("pptx://");
|
798
|
+
}
|
799
|
+
|
681
800
|
private async ensureAttributes() {
|
682
801
|
if (isNull(this.attributes)) {
|
683
802
|
await wait(50);
|
@@ -698,62 +817,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
698
817
|
}
|
699
818
|
}
|
700
819
|
}
|
701
|
-
|
702
|
-
private containerResizeObserver?: ResizeObserver;
|
703
|
-
|
704
|
-
private observePlaygroundSize(
|
705
|
-
container: HTMLElement,
|
706
|
-
sizer: HTMLElement,
|
707
|
-
wrapper: HTMLDivElement
|
708
|
-
) {
|
709
|
-
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
710
|
-
|
711
|
-
this.containerResizeObserver = new ResizeObserver(entries => {
|
712
|
-
const containerRect = entries[0]?.contentRect;
|
713
|
-
if (containerRect) {
|
714
|
-
this.updateSizer(containerRect, sizer, wrapper);
|
715
|
-
this.cursorManager?.updateContainerRect();
|
716
|
-
this.boxManager?.updateManagerRect();
|
717
|
-
emitter.emit("playgroundSizeChange", containerRect);
|
718
|
-
}
|
719
|
-
});
|
720
|
-
|
721
|
-
this.containerResizeObserver.observe(container);
|
722
|
-
}
|
723
|
-
|
724
|
-
private updateSizer(
|
725
|
-
{ width, height }: DOMRectReadOnly,
|
726
|
-
sizer: HTMLElement,
|
727
|
-
wrapper: HTMLDivElement
|
728
|
-
) {
|
729
|
-
if (width && height) {
|
730
|
-
if (height / width > WindowManager.containerSizeRatio) {
|
731
|
-
height = width * WindowManager.containerSizeRatio;
|
732
|
-
sizer.classList.toggle("netless-window-manager-sizer-horizontal", true);
|
733
|
-
} else {
|
734
|
-
width = height / WindowManager.containerSizeRatio;
|
735
|
-
sizer.classList.toggle("netless-window-manager-sizer-horizontal", false);
|
736
|
-
}
|
737
|
-
wrapper.style.width = `${width}px`;
|
738
|
-
wrapper.style.height = `${height}px`;
|
739
|
-
}
|
740
|
-
}
|
741
820
|
}
|
742
821
|
|
743
|
-
|
744
|
-
kind: AppDocsViewer.kind,
|
745
|
-
src: AppDocsViewer,
|
746
|
-
});
|
747
|
-
WindowManager.register({
|
748
|
-
kind: AppMediaPlayer.kind,
|
749
|
-
src: AppMediaPlayer,
|
750
|
-
});
|
751
|
-
|
752
|
-
export const BuiltinApps = {
|
753
|
-
DocsViewer: AppDocsViewer.kind as string,
|
754
|
-
MediaPlayer: AppMediaPlayer.kind as string,
|
755
|
-
};
|
822
|
+
setupBuiltin();
|
756
823
|
|
757
824
|
export * from "./typings";
|
758
825
|
|
759
|
-
export {
|
826
|
+
export { BuiltinApps } from "./BuiltinApps";
|
package/src/shim.d.ts
CHANGED
package/src/style.css
CHANGED
@@ -122,7 +122,7 @@
|
|
122
122
|
left: 0;
|
123
123
|
top: 0;
|
124
124
|
will-change: transform;
|
125
|
-
transition: transform 0.
|
125
|
+
transition: transform 0.1s;
|
126
126
|
transform-origin: 0 0;
|
127
127
|
user-select: none;
|
128
128
|
}
|
@@ -167,3 +167,9 @@
|
|
167
167
|
display: flex;
|
168
168
|
justify-content: center;
|
169
169
|
}
|
170
|
+
|
171
|
+
.telebox-collector {
|
172
|
+
position: absolute;
|
173
|
+
right: 10px;
|
174
|
+
bottom: 15px;
|
175
|
+
}
|
package/src/typings.ts
CHANGED
@@ -12,7 +12,7 @@ import type {
|
|
12
12
|
import type { AppContext } from "./AppContext";
|
13
13
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
14
14
|
|
15
|
-
export interface NetlessApp<Attributes = any,
|
15
|
+
export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
|
16
16
|
kind: string;
|
17
17
|
config?: {
|
18
18
|
/** Box width relative to whiteboard. 0~1. Default 0.5. */
|
@@ -28,7 +28,7 @@ export interface NetlessApp<Attributes = any, SetupResult = any, AppOptions = an
|
|
28
28
|
/** App only single instance. */
|
29
29
|
singleton?: boolean;
|
30
30
|
};
|
31
|
-
setup: (context: AppContext<Attributes, AppOptions>) => SetupResult;
|
31
|
+
setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
|
32
32
|
}
|
33
33
|
|
34
34
|
export type AppEmitterEvent<T = any> = {
|
@@ -76,3 +76,4 @@ export type AppListenerKeys = keyof AppEmitterEvent;
|
|
76
76
|
export type { AppContext } from "./AppContext";
|
77
77
|
export type { ReadonlyTeleBox, TeleBoxRect };
|
78
78
|
export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room, Player };
|
79
|
+
export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
|
package/vite.config.js
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { defineConfig } from "vite";
|
3
3
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
4
|
-
import { dependencies ,
|
4
|
+
import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
|
5
5
|
|
6
6
|
|
7
7
|
export default defineConfig(({ mode }) => {
|
8
8
|
const isProd = mode === "production";
|
9
9
|
|
10
10
|
return {
|
11
|
+
define: {
|
12
|
+
__APP_VERSION__: JSON.stringify(version),
|
13
|
+
__APP_DEPENDENCIES__: JSON.stringify({
|
14
|
+
dependencies, peerDependencies, devDependencies
|
15
|
+
}),
|
16
|
+
},
|
11
17
|
plugins: [
|
12
18
|
svelte({
|
13
19
|
emitCss: false,
|
@@ -20,7 +26,7 @@ export default defineConfig(({ mode }) => {
|
|
20
26
|
lib: {
|
21
27
|
// eslint-disable-next-line no-undef
|
22
28
|
entry: path.resolve(__dirname, "src/index.ts"),
|
23
|
-
formats: ["es","umd"], // TODO cjs 版本待修复
|
29
|
+
formats: ["es", "umd"], // TODO cjs 版本待修复
|
24
30
|
name: "WindowManager",
|
25
31
|
fileName: "index"
|
26
32
|
},
|
package/dist/Base/Context.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { AppManager } from "../AppManager";
|
2
|
-
export declare class Context {
|
3
|
-
private manager;
|
4
|
-
observerId: number;
|
5
|
-
constructor(manager: AppManager);
|
6
|
-
get uid(): string;
|
7
|
-
findMember: (memberId: number) => import("white-web-sdk").RoomMember | undefined;
|
8
|
-
findMemberByUid: (uid: string) => import("white-web-sdk").RoomMember | undefined;
|
9
|
-
updateManagerRect(): void;
|
10
|
-
blurFocusBox(): void;
|
11
|
-
switchAppToWriter(id: string): void;
|
12
|
-
}
|
13
|
-
export declare const createContext: (manager: AppManager) => Context;
|
package/dist/Base/index.d.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import type { Camera, View } from "white-web-sdk";
|
2
|
-
export declare class CameraStore {
|
3
|
-
private cameras;
|
4
|
-
private listeners;
|
5
|
-
setCamera(id: string, camera: Camera): void;
|
6
|
-
getCamera(id: string): Camera | undefined;
|
7
|
-
deleteCamera(id: string): void;
|
8
|
-
recoverCamera(id: string, view?: View): void;
|
9
|
-
register(id: string, view: View): void;
|
10
|
-
unregister(id: string, view?: View): void;
|
11
|
-
private onListener;
|
12
|
-
private offListener;
|
13
|
-
switchView(id: string, view: View | undefined, callback: () => void): Promise<void>;
|
14
|
-
private getOrCreateListener;
|
15
|
-
}
|
package/dist/ViewManager.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import { Base } from "./Base";
|
2
|
-
import type { View, Displayer } from "white-web-sdk";
|
3
|
-
import type { AppManager } from "./AppManager";
|
4
|
-
export declare class ViewManager extends Base {
|
5
|
-
private views;
|
6
|
-
private timer?;
|
7
|
-
private appTimer?;
|
8
|
-
private mainViewProxy;
|
9
|
-
private displayer;
|
10
|
-
constructor(manager: AppManager);
|
11
|
-
get currentScenePath(): string;
|
12
|
-
get mainView(): View;
|
13
|
-
createView(appId: string): View;
|
14
|
-
destroyView(appId: string): void;
|
15
|
-
private releaseView;
|
16
|
-
getView(appId: string): View | undefined;
|
17
|
-
switchMainViewToWriter(): Promise<boolean> | undefined;
|
18
|
-
freedomAllViews(): void;
|
19
|
-
switchAppToWriter(id: string): void;
|
20
|
-
destroy(): void;
|
21
|
-
}
|
22
|
-
export declare const createView: (displayer: Displayer) => View;
|
23
|
-
export declare const setDefaultCameraBound: (view: View) => void;
|
24
|
-
export declare const setupWrapper: (root: HTMLElement) => {
|
25
|
-
playground: HTMLDivElement;
|
26
|
-
wrapper: HTMLDivElement;
|
27
|
-
sizer: HTMLDivElement;
|
28
|
-
mainViewElement: HTMLDivElement;
|
29
|
-
};
|
package/dist/sdk.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { WindowManager } from './index';
|
2
|
-
import type { MountParams } from "./index";
|
3
|
-
import type { WhiteWebSdkConfiguration, JoinRoomParams } from "white-web-sdk";
|
4
|
-
declare type WhiteWindowSDKConfiguration = Omit<WhiteWebSdkConfiguration, "useMobXState">;
|
5
|
-
declare type WindowJoinRoomParams = {
|
6
|
-
joinRoomParams: Omit<JoinRoomParams, "useMultiViews" | "disableMagixEventDispatchLimit">;
|
7
|
-
mountParams: Omit<MountParams, "room">;
|
8
|
-
};
|
9
|
-
export declare class WhiteWindowSDK {
|
10
|
-
private sdk;
|
11
|
-
constructor(params: WhiteWindowSDKConfiguration);
|
12
|
-
mount(params: WindowJoinRoomParams): Promise<WindowManager>;
|
13
|
-
}
|
14
|
-
export {};
|