@netless/window-manager 0.4.0-canary.3 → 0.4.0-canary.30
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 +2 -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 +1 -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 +4 -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/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 +15 -14
- 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 +5 -4
- package/src/image/laser-pointer-cursor.svg +17 -0
- package/src/index.ts +158 -99
- 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 { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
12
13
|
import { isNull, isObject } 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
|
}
|
@@ -416,6 +432,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
416
432
|
const appScenePath = appManager.store.getAppScenePath(appId);
|
417
433
|
if (appScenePath && appScenePath === scenePath) {
|
418
434
|
console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
|
435
|
+
if (this.boxManager) {
|
436
|
+
const topBox = this.boxManager.getTopBox();
|
437
|
+
if (topBox) {
|
438
|
+
this.boxManager.setZIndex(appId, topBox.zIndex + 1, false);
|
439
|
+
}
|
440
|
+
}
|
419
441
|
return;
|
420
442
|
}
|
421
443
|
}
|
@@ -423,11 +445,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
423
445
|
if (scenePath && scenes && scenes.length > 0) {
|
424
446
|
if (this.isDynamicPPT(scenes)) {
|
425
447
|
isDynamicPPT = true;
|
426
|
-
if (!this.displayer
|
448
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
427
449
|
this.room?.putScenes(scenePath, scenes);
|
428
450
|
}
|
429
451
|
} else {
|
430
|
-
if (!this.displayer
|
452
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
431
453
|
this.room?.putScenes(scenePath, [{ name: scenes[0].name }]);
|
432
454
|
}
|
433
455
|
}
|
@@ -460,7 +482,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
460
482
|
/**
|
461
483
|
* 返回 mainView 的 ScenePath
|
462
484
|
*/
|
463
|
-
public getMainViewScenePath(): string {
|
485
|
+
public getMainViewScenePath(): string | undefined {
|
464
486
|
return this.appManager?.store.getMainViewScenePath();
|
465
487
|
}
|
466
488
|
|
@@ -475,10 +497,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
475
497
|
* 设置所有 app 的 readonly 模式
|
476
498
|
*/
|
477
499
|
public setReadonly(readonly: boolean): void {
|
478
|
-
|
479
|
-
|
480
|
-
this.appManager?.boxManager?.setReadonly(readonly);
|
481
|
-
}
|
500
|
+
this.readonly = readonly;
|
501
|
+
this.boxManager?.setReadonly(readonly);
|
482
502
|
}
|
483
503
|
|
484
504
|
/**
|
@@ -510,6 +530,35 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
510
530
|
this.viewMode = mode;
|
511
531
|
}
|
512
532
|
|
533
|
+
public setBoxState(boxState: TeleBoxState): void {
|
534
|
+
if (!this.canOperate) return;
|
535
|
+
switch (boxState) {
|
536
|
+
case "normal":
|
537
|
+
this.setMaximized(false);
|
538
|
+
this.setMinimized(false);
|
539
|
+
break;
|
540
|
+
case "maximized":
|
541
|
+
this.setMaximized(true);
|
542
|
+
this.setMinimized(false);
|
543
|
+
break;
|
544
|
+
case "minimized":
|
545
|
+
this.setMinimized(true);
|
546
|
+
break;
|
547
|
+
default:
|
548
|
+
break;
|
549
|
+
}
|
550
|
+
}
|
551
|
+
|
552
|
+
public setMaximized(maximized: boolean): void {
|
553
|
+
if (!this.canOperate) return;
|
554
|
+
this.boxManager?.setMaximized(maximized, false);
|
555
|
+
}
|
556
|
+
|
557
|
+
public setMinimized(minimized: boolean): void {
|
558
|
+
if (!this.canOperate) return;
|
559
|
+
this.boxManager?.setMinimized(minimized, false);
|
560
|
+
}
|
561
|
+
|
513
562
|
public get mainView(): View {
|
514
563
|
if (this.appManager) {
|
515
564
|
return this.appManager.mainViewProxy.view;
|
@@ -558,6 +607,48 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
558
607
|
}
|
559
608
|
}
|
560
609
|
|
610
|
+
public get focused(): string | undefined {
|
611
|
+
return this.attributes.focus;
|
612
|
+
}
|
613
|
+
|
614
|
+
public get mainViewSceneIndex(): number {
|
615
|
+
return this.appManager?.store.getMainViewSceneIndex();
|
616
|
+
}
|
617
|
+
|
618
|
+
public get mainViewSceneDir(): string {
|
619
|
+
if (this.appManager) {
|
620
|
+
return this.appManager?.getMainViewSceneDir();
|
621
|
+
} else {
|
622
|
+
throw new AppManagerNotInitError();
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
public get topApp(): string | undefined {
|
627
|
+
return this.boxManager?.getTopBox()?.id;
|
628
|
+
}
|
629
|
+
|
630
|
+
public get mainViewScenesLength(): number {
|
631
|
+
return this.appManager?.mainViewScenesLength || 0;
|
632
|
+
}
|
633
|
+
|
634
|
+
public get canRedoSteps(): number {
|
635
|
+
const focused = this.focused;
|
636
|
+
if (focused) {
|
637
|
+
return this.appManager?.focusApp?.view?.canRedoSteps || 0;
|
638
|
+
} else {
|
639
|
+
return this.mainView.canRedoSteps;
|
640
|
+
}
|
641
|
+
}
|
642
|
+
|
643
|
+
public get canUndoSteps(): number {
|
644
|
+
const focused = this.focused;
|
645
|
+
if (focused) {
|
646
|
+
return this.appManager?.focusApp?.view?.canUndoSteps || 0;
|
647
|
+
} else {
|
648
|
+
return this.mainView.canUndoSteps;
|
649
|
+
}
|
650
|
+
}
|
651
|
+
|
561
652
|
/**
|
562
653
|
* 查询所有的 App
|
563
654
|
*/
|
@@ -666,18 +757,38 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
666
757
|
this.appManager?.boxManager?.setPrefersColorScheme(scheme);
|
667
758
|
}
|
668
759
|
|
669
|
-
|
670
|
-
const
|
671
|
-
|
760
|
+
public cleanCurrentScene(): void {
|
761
|
+
const focused = this.focused;
|
762
|
+
if (focused) {
|
763
|
+
this.appManager?.focusApp?.view?.cleanCurrentScene();
|
764
|
+
} else {
|
765
|
+
this.mainView.cleanCurrentScene();
|
766
|
+
}
|
672
767
|
}
|
673
768
|
|
674
|
-
|
675
|
-
const
|
676
|
-
if (
|
677
|
-
|
769
|
+
public redo(): void {
|
770
|
+
const focused = this.focused;
|
771
|
+
if (focused) {
|
772
|
+
this.appManager?.focusApp?.view?.redo();
|
773
|
+
} else {
|
774
|
+
this.mainView.redo();
|
775
|
+
}
|
776
|
+
}
|
777
|
+
|
778
|
+
public undo(): void {
|
779
|
+
const focused = this.focused;
|
780
|
+
if (focused) {
|
781
|
+
this.appManager?.focusApp?.view?.undo();
|
782
|
+
} else {
|
783
|
+
this.mainView.undo();
|
678
784
|
}
|
679
785
|
}
|
680
786
|
|
787
|
+
private isDynamicPPT(scenes: SceneDefinition[]) {
|
788
|
+
const sceneSrc = scenes[0]?.ppt?.src;
|
789
|
+
return sceneSrc?.startsWith("pptx://");
|
790
|
+
}
|
791
|
+
|
681
792
|
private async ensureAttributes() {
|
682
793
|
if (isNull(this.attributes)) {
|
683
794
|
await wait(50);
|
@@ -698,62 +809,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
698
809
|
}
|
699
810
|
}
|
700
811
|
}
|
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
812
|
}
|
742
813
|
|
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
|
-
};
|
814
|
+
setupBuiltin();
|
756
815
|
|
757
816
|
export * from "./typings";
|
758
817
|
|
759
|
-
export {
|
818
|
+
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 {};
|
package/src/Base/Context.ts
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
import { emitter } from "../index";
|
2
|
-
import type { AppManager } from "../AppManager";
|
3
|
-
|
4
|
-
export class Context {
|
5
|
-
public observerId: number;
|
6
|
-
|
7
|
-
constructor(private manager: AppManager) {
|
8
|
-
this.observerId = manager.displayer.observerId;
|
9
|
-
|
10
|
-
emitter.on("observerIdChange", id => {
|
11
|
-
this.observerId = id;
|
12
|
-
});
|
13
|
-
};
|
14
|
-
|
15
|
-
public get uid() {
|
16
|
-
return this.manager.room?.uid || "";
|
17
|
-
}
|
18
|
-
|
19
|
-
public findMember = (memberId: number) => {
|
20
|
-
const roomMembers = this.manager.room?.state.roomMembers;
|
21
|
-
return roomMembers?.find(member => member.memberId === memberId);
|
22
|
-
}
|
23
|
-
|
24
|
-
public findMemberByUid = (uid: string) => {
|
25
|
-
const roomMembers = this.manager.room?.state.roomMembers;
|
26
|
-
return roomMembers?.find(member => member.payload?.uid === uid);
|
27
|
-
}
|
28
|
-
|
29
|
-
public updateManagerRect() {
|
30
|
-
this.manager.boxManager?.updateManagerRect();
|
31
|
-
}
|
32
|
-
|
33
|
-
public blurFocusBox() {
|
34
|
-
this.manager.boxManager?.blurAllBox();
|
35
|
-
}
|
36
|
-
|
37
|
-
public switchAppToWriter(id: string) {
|
38
|
-
this.manager.viewManager.switchAppToWriter(id);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
let context: Context;
|
43
|
-
|
44
|
-
export const createContext = (manager: AppManager) => {
|
45
|
-
if (!context) {
|
46
|
-
context = new Context(manager);
|
47
|
-
}
|
48
|
-
return context;
|
49
|
-
};
|
package/src/Base/index.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { AppManager } from "../AppManager";
|
2
|
-
import { store } from "../AttributesDelegate";
|
3
|
-
import { createContext } from "./Context";
|
4
|
-
|
5
|
-
export class Base {
|
6
|
-
public store = store;
|
7
|
-
public context = createContext(this.manager);
|
8
|
-
|
9
|
-
constructor(public manager: AppManager) {}
|
10
|
-
}
|