@netless/window-manager 1.0.0-canary.24 → 1.0.0-canary.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App/AppContext.d.ts +1 -1
- package/dist/App/WhiteboardView.d.ts +6 -4
- package/dist/AppListener.d.ts +0 -2
- package/dist/BoxManager.d.ts +2 -1
- package/dist/BuiltinApps.d.ts +3 -0
- package/dist/Cursor/index.d.ts +3 -2
- package/dist/Helper.d.ts +3 -1
- package/dist/callback.d.ts +5 -0
- package/dist/constants.d.ts +0 -2
- package/dist/index.cjs.js +82 -12
- package/dist/index.d.ts +16 -9
- package/dist/index.es.js +1620 -704
- package/dist/index.umd.js +82 -12
- package/dist/src/App/AppContext.d.ts +78 -0
- package/dist/src/App/AppPageStateImpl.d.ts +21 -0
- package/dist/src/App/AppProxy.d.ts +98 -0
- package/dist/src/App/MagixEvent/index.d.ts +29 -0
- package/dist/src/App/Storage/StorageEvent.d.ts +8 -0
- package/dist/src/App/Storage/index.d.ts +39 -0
- package/dist/src/App/Storage/typings.d.ts +22 -0
- package/dist/src/App/Storage/utils.d.ts +5 -0
- package/dist/src/App/WhiteboardView.d.ts +27 -0
- package/dist/src/App/index.d.ts +4 -0
- package/dist/src/App/type.d.ts +21 -0
- package/dist/src/AppListener.d.ts +19 -0
- package/dist/src/AppManager.d.ts +107 -0
- package/dist/src/AttributesDelegate.d.ts +83 -0
- package/dist/src/BoxEmitter.d.ts +34 -0
- package/dist/src/BoxManager.d.ts +102 -0
- package/dist/src/BuiltinApps.d.ts +8 -0
- package/dist/src/Cursor/Cursor.d.ts +39 -0
- package/dist/src/Cursor/icons.d.ts +3 -0
- package/dist/src/Cursor/index.d.ts +46 -0
- package/dist/src/Helper.d.ts +19 -0
- package/dist/src/InternalEmitter.d.ts +38 -0
- package/dist/src/Page/PageController.d.ts +21 -0
- package/dist/src/Page/index.d.ts +3 -0
- package/dist/src/PageState.d.ts +9 -0
- package/dist/src/ReconnectRefresher.d.ts +24 -0
- package/dist/src/RedoUndo.d.ts +18 -0
- package/dist/src/Register/index.d.ts +28 -0
- package/dist/src/Register/loader.d.ts +4 -0
- package/dist/src/Register/storage.d.ts +8 -0
- package/dist/src/Utils/AppCreateQueue.d.ts +15 -0
- package/dist/src/Utils/Common.d.ts +23 -0
- package/dist/src/Utils/Reactive.d.ts +6 -0
- package/dist/src/Utils/RoomHacker.d.ts +3 -0
- package/dist/src/Utils/error.d.ts +27 -0
- package/dist/src/Utils/log.d.ts +1 -0
- package/dist/src/View/CameraSynchronizer.d.ts +17 -0
- package/dist/src/View/MainView.d.ts +59 -0
- package/dist/src/View/ViewManager.d.ts +13 -0
- package/dist/src/View/ViewSync.d.ts +24 -0
- package/dist/src/callback.d.ts +29 -0
- package/dist/src/constants.d.ts +51 -0
- package/dist/src/image.d.ts +19 -0
- package/dist/src/index.d.ts +267 -0
- package/dist/src/shim.d.ts +11 -0
- package/dist/src/typings.d.ts +88 -0
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +6 -0
- package/docs/app-context.md +68 -26
- package/package.json +10 -5
- package/playwright.config.ts +28 -0
- package/pnpm-lock.yaml +516 -30
- package/src/App/AppContext.ts +14 -6
- package/src/App/AppProxy.ts +17 -7
- package/src/App/WhiteboardView.ts +23 -18
- package/src/AppListener.ts +1 -21
- package/src/AppManager.ts +2 -1
- package/src/BoxManager.ts +32 -24
- package/src/BuiltinApps.ts +5 -0
- package/src/Cursor/Cursor.ts +6 -2
- package/src/Cursor/index.ts +5 -5
- package/src/Helper.ts +23 -5
- package/src/View/CameraSynchronizer.ts +5 -9
- package/src/View/MainView.ts +3 -1
- package/src/callback.ts +1 -0
- package/src/constants.ts +0 -2
- package/src/index.ts +69 -45
- package/src/style.css +2 -45
- package/src/typings.ts +6 -0
- package/vite.config.js +5 -3
package/src/index.ts
CHANGED
@@ -2,7 +2,7 @@ import pRetry from "p-retry";
|
|
2
2
|
import { AppManager } from "./AppManager";
|
3
3
|
import { appRegister } from "./Register";
|
4
4
|
import { callbacks } from "./callback";
|
5
|
-
import { checkVersion, setupWrapper } from "./Helper";
|
5
|
+
import { checkVersion, createInvisiblePlugin, setupWrapper } from "./Helper";
|
6
6
|
import { createBoxManager } from "./BoxManager";
|
7
7
|
import { CursorManager } from "./Cursor";
|
8
8
|
import { DEFAULT_CONTAINER_RATIO, Events, INIT_DIR, ROOT_DIR } from "./constants";
|
@@ -10,7 +10,7 @@ import { emitter } from "./InternalEmitter";
|
|
10
10
|
import { Fields } from "./AttributesDelegate";
|
11
11
|
import { initDb } from "./Register/storage";
|
12
12
|
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
-
import { isEqual, isNull, isObject,
|
13
|
+
import { isEqual, isNull, isObject, isNumber } from "lodash";
|
14
14
|
import { log } from "./Utils/log";
|
15
15
|
import { PageStateImpl } from "./PageState";
|
16
16
|
import { ReconnectRefresher } from "./ReconnectRefresher";
|
@@ -27,6 +27,8 @@ import {
|
|
27
27
|
putScenes,
|
28
28
|
wait,
|
29
29
|
} from "./Utils/Common";
|
30
|
+
import { boxEmitter } from "./BoxEmitter";
|
31
|
+
import { Val } from "value-enhancer";
|
30
32
|
import type { TELE_BOX_STATE, BoxManager } from "./BoxManager";
|
31
33
|
import * as Errors from "./Utils/error";
|
32
34
|
import type { Apps, Position , ICamera, ISize } from "./AttributesDelegate";
|
@@ -37,15 +39,13 @@ import type {
|
|
37
39
|
Room,
|
38
40
|
InvisiblePluginContext,
|
39
41
|
Camera,
|
40
|
-
AnimationMode,
|
41
42
|
CameraBound,
|
42
43
|
Point,
|
43
|
-
Rectangle,
|
44
44
|
CameraState,
|
45
45
|
Player,
|
46
46
|
ImageInformation,
|
47
47
|
SceneState,
|
48
|
-
} from "white-web-sdk";
|
48
|
+
Rectangle} from "white-web-sdk";
|
49
49
|
import type { AppListeners } from "./AppListener";
|
50
50
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
51
51
|
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
@@ -53,8 +53,6 @@ import type { AppProxy } from "./App";
|
|
53
53
|
import type { PublicEvent } from "./callback";
|
54
54
|
import type Emittery from "emittery";
|
55
55
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
56
|
-
import { boxEmitter } from "./BoxEmitter";
|
57
|
-
import { Val } from "value-enhancer";
|
58
56
|
|
59
57
|
export type WindowMangerAttributes = {
|
60
58
|
modelValue?: string;
|
@@ -142,6 +140,8 @@ export type MountParams = {
|
|
142
140
|
collectorContainer?: HTMLElement;
|
143
141
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
144
142
|
overwriteStyles?: string;
|
143
|
+
containerStyle?: string;
|
144
|
+
stageStyle?: string;
|
145
145
|
cursor?: boolean;
|
146
146
|
debug?: boolean;
|
147
147
|
disableCameraTransform?: boolean;
|
@@ -249,7 +249,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
249
249
|
collectorStyles: params.collectorStyles,
|
250
250
|
prefersColorScheme: params.prefersColorScheme,
|
251
251
|
stageRatio: WindowManager.containerSizeRatio,
|
252
|
-
|
252
|
+
containerStyle: params.containerStyle,
|
253
|
+
stageStyle: params.stageStyle,
|
253
254
|
});
|
254
255
|
manager.appManager?.setBoxManager(manager.boxManager);
|
255
256
|
if (params.container) {
|
@@ -268,8 +269,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
268
269
|
return manager;
|
269
270
|
}
|
270
271
|
|
271
|
-
private static async initManager(room: Room): Promise<WindowManager> {
|
272
|
-
let manager = room.getInvisiblePlugin(WindowManager.kind) as WindowManager;
|
272
|
+
private static async initManager(room: Room): Promise<WindowManager | undefined> {
|
273
|
+
let manager = room.getInvisiblePlugin(WindowManager.kind) as WindowManager | undefined;
|
273
274
|
if (!manager) {
|
274
275
|
if (isRoom(room)) {
|
275
276
|
if (room.isWritable === false) {
|
@@ -278,18 +279,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
278
279
|
} catch (error) {
|
279
280
|
throw new Error("[WindowManger]: room must be switched to be writable");
|
280
281
|
}
|
281
|
-
manager =
|
282
|
-
|
283
|
-
{}
|
284
|
-
)) as WindowManager;
|
285
|
-
manager.ensureAttributes();
|
282
|
+
manager = await createInvisiblePlugin(room);
|
283
|
+
manager?.ensureAttributes();
|
286
284
|
await wait(500);
|
287
285
|
await room.setWritable(false);
|
288
286
|
} else {
|
289
|
-
manager =
|
290
|
-
WindowManager,
|
291
|
-
{}
|
292
|
-
)) as WindowManager;
|
287
|
+
manager = await createInvisiblePlugin(room);
|
293
288
|
}
|
294
289
|
}
|
295
290
|
}
|
@@ -298,12 +293,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
298
293
|
|
299
294
|
private static initContainer(
|
300
295
|
container: HTMLElement,
|
296
|
+
target: HTMLElement,
|
301
297
|
overwriteStyles: string | undefined
|
302
298
|
) {
|
303
299
|
if (!WindowManager.container) {
|
304
300
|
WindowManager.container = container;
|
305
301
|
}
|
306
|
-
const { playground, mainViewElement } = setupWrapper(container);
|
302
|
+
const { playground, mainViewElement } = setupWrapper(container, target);
|
307
303
|
WindowManager.playground = playground;
|
308
304
|
if (overwriteStyles) {
|
309
305
|
const style = document.createElement("style");
|
@@ -326,10 +322,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
326
322
|
container.appendChild(WindowManager.container.firstChild);
|
327
323
|
}
|
328
324
|
} else {
|
329
|
-
|
325
|
+
const teleboxContainer = this.boxManager?.teleBoxManager.$stage;
|
326
|
+
if (WindowManager.params && teleboxContainer) {
|
330
327
|
const params = WindowManager.params;
|
331
328
|
const mainViewElement = WindowManager.initContainer(
|
332
329
|
container,
|
330
|
+
teleboxContainer,
|
333
331
|
params.overwriteStyles
|
334
332
|
);
|
335
333
|
if (this.boxManager && WindowManager.playground) {
|
@@ -339,6 +337,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
339
337
|
if (WindowManager.playground) {
|
340
338
|
this.cursorManager?.setupWrapper(WindowManager.playground);
|
341
339
|
}
|
340
|
+
|
342
341
|
}
|
343
342
|
}
|
344
343
|
emitter.emit("updateManagerRect");
|
@@ -661,6 +660,22 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
661
660
|
}
|
662
661
|
}
|
663
662
|
|
663
|
+
public get baseCamera$() {
|
664
|
+
if (this.appManager) {
|
665
|
+
return this.appManager.mainViewProxy.camera$;
|
666
|
+
} else {
|
667
|
+
throw new Errors.AppManagerNotInitError();
|
668
|
+
}
|
669
|
+
}
|
670
|
+
|
671
|
+
public get baseSize$() {
|
672
|
+
if (this.appManager) {
|
673
|
+
return this.appManager.mainViewProxy.size$;
|
674
|
+
} else {
|
675
|
+
throw new Errors.AppManagerNotInitError();
|
676
|
+
}
|
677
|
+
}
|
678
|
+
|
664
679
|
public get cameraState(): CameraState {
|
665
680
|
if (this.appManager) {
|
666
681
|
return this.appManager.mainViewProxy.cameraState;
|
@@ -767,30 +782,31 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
767
782
|
return this.appManager?.closeApp(appId);
|
768
783
|
}
|
769
784
|
|
770
|
-
public moveCamera(
|
771
|
-
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
772
|
-
): void {
|
773
|
-
const pureCamera = omit(camera, ["animationMode"]);
|
785
|
+
public moveCamera(camera: Partial<Camera> ): void {
|
774
786
|
const mainViewCamera = { ...this.mainView.camera };
|
775
|
-
|
776
|
-
|
777
|
-
this.appManager
|
778
|
-
|
779
|
-
this.appManager
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
787
|
+
const nextCamera = { ...mainViewCamera, ...camera };
|
788
|
+
if (isEqual(nextCamera, mainViewCamera)) return;
|
789
|
+
if (!this.appManager) return;
|
790
|
+
this.appManager.mainViewProxy.storeCamera({
|
791
|
+
id: this.appManager.uid,
|
792
|
+
...nextCamera
|
793
|
+
});
|
794
|
+
}
|
795
|
+
|
796
|
+
public moveCameraToContain(rectangle: Rectangle): void {
|
797
|
+
if (!this.appManager) return;
|
798
|
+
const mainViewSize = this.appManager.mainViewProxy.size$.value;
|
799
|
+
if (mainViewSize) {
|
800
|
+
const wScale = mainViewSize.width / rectangle.width;
|
801
|
+
const hScale = mainViewSize.height / rectangle.height;
|
802
|
+
const nextScale = Math.min(wScale, hScale);
|
803
|
+
this.appManager.mainViewProxy.storeCamera({
|
804
|
+
id: this.appManager.uid,
|
805
|
+
scale: nextScale,
|
806
|
+
centerX: rectangle.originX,
|
807
|
+
centerY: rectangle.originY,
|
808
|
+
});
|
809
|
+
}
|
794
810
|
}
|
795
811
|
|
796
812
|
public convertToPointInWorld(point: Point): Point {
|
@@ -930,6 +946,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
930
946
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
931
947
|
}
|
932
948
|
|
949
|
+
public setContainerStyle(style: string) {
|
950
|
+
this.boxManager?.teleBoxManager.setContainerStyle(style);
|
951
|
+
}
|
952
|
+
|
953
|
+
public setStageStyle(style: string) {
|
954
|
+
this.boxManager?.teleBoxManager.setStageStyle(style);
|
955
|
+
}
|
956
|
+
|
933
957
|
public createPPTHandler() {
|
934
958
|
return {
|
935
959
|
onPageJumpTo: (_pptUUID: string, index: number) => {
|
@@ -981,5 +1005,5 @@ setupBuiltin();
|
|
981
1005
|
|
982
1006
|
export * from "./typings";
|
983
1007
|
|
984
|
-
export { BuiltinApps } from "./BuiltinApps";
|
1008
|
+
export { BuiltinApps, BuiltinAppsMap } from "./BuiltinApps";
|
985
1009
|
export type { PublicEvent } from "./callback";
|
package/src/style.css
CHANGED
@@ -7,48 +7,9 @@
|
|
7
7
|
user-select: none;
|
8
8
|
}
|
9
9
|
|
10
|
-
.netless-window-manager-sizer {
|
11
|
-
position: absolute;
|
12
|
-
top: 0;
|
13
|
-
left: 0;
|
14
|
-
width: 100%;
|
15
|
-
height: 100%;
|
16
|
-
z-index: 1;
|
17
|
-
overflow: hidden;
|
18
|
-
display: flex;
|
19
|
-
}
|
20
|
-
|
21
|
-
.netless-window-manager-sizer-horizontal {
|
22
|
-
flex-direction: column;
|
23
|
-
}
|
24
|
-
|
25
|
-
.netless-window-manager-sizer::before,
|
26
|
-
.netless-window-manager-sizer::after {
|
27
|
-
flex: 1;
|
28
|
-
content: "";
|
29
|
-
display: block;
|
30
|
-
}
|
31
|
-
|
32
|
-
.netless-window-manager-chess-sizer::before,
|
33
|
-
.netless-window-manager-chess-sizer::after {
|
34
|
-
background-image: linear-gradient(45deg, #b0b0b0 25%, transparent 25%),
|
35
|
-
linear-gradient(-45deg, #b0b0b0 25%, transparent 25%),
|
36
|
-
linear-gradient(45deg, transparent 75%, #b0b0b0 75%),
|
37
|
-
linear-gradient(-45deg, transparent 75%, #b0b0b0 75%);
|
38
|
-
background-color: #fff;
|
39
|
-
background-size: 20px 20px;
|
40
|
-
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
|
41
|
-
}
|
42
|
-
|
43
|
-
.netless-window-manager-wrapper {
|
44
|
-
position: relative;
|
45
|
-
z-index: 1;
|
46
|
-
width: 100%;
|
47
|
-
height: 100%;
|
48
|
-
overflow: hidden;
|
49
|
-
}
|
50
10
|
|
51
11
|
.netless-window-manager-main-view {
|
12
|
+
position: absolute;
|
52
13
|
width: 100%;
|
53
14
|
height: 100%;
|
54
15
|
}
|
@@ -180,10 +141,6 @@
|
|
180
141
|
}
|
181
142
|
|
182
143
|
.window-manager-view-wrapper {
|
183
|
-
width: 100%;
|
184
|
-
height: 100%;
|
185
144
|
position: absolute;
|
186
|
-
|
187
|
-
top: 0;
|
188
|
-
z-index: 1;
|
145
|
+
z-index: 10;
|
189
146
|
}
|
package/src/typings.ts
CHANGED
@@ -30,6 +30,9 @@ export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptio
|
|
30
30
|
|
31
31
|
/** App only single instance. */
|
32
32
|
singleton?: boolean;
|
33
|
+
|
34
|
+
/** App box enableShadowDom. Default true */
|
35
|
+
enableShadowDOM?: boolean;
|
33
36
|
};
|
34
37
|
setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
|
35
38
|
}
|
@@ -74,12 +77,15 @@ export type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any
|
|
74
77
|
addHooks?: (emitter: Emittery<RegisterEvents<SetupResult>>) => void;
|
75
78
|
/** dynamic load app package name */
|
76
79
|
name?: string;
|
80
|
+
contentStyles?: string;
|
77
81
|
};
|
78
82
|
|
79
83
|
export type AppListenerKeys = keyof AppEmitterEvent;
|
80
84
|
|
81
85
|
export type ApplianceIcons = Partial<Record<ApplianceNames, string>>;
|
82
86
|
|
87
|
+
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
88
|
+
|
83
89
|
export type { AppContext } from "./App/AppContext";
|
84
90
|
export type { WhiteBoardView } from "./App";
|
85
91
|
export type { ReadonlyTeleBox, TeleBoxRect };
|
package/vite.config.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import path from "path";
|
2
|
+
import dts from 'vite-plugin-dts'
|
2
3
|
import { defineConfig } from 'vitest/config'
|
3
4
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
4
5
|
import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
|
@@ -28,7 +29,8 @@ export default defineConfig(({ mode }) => {
|
|
28
29
|
experimental: {
|
29
30
|
useVitePreprocess: true,
|
30
31
|
},
|
31
|
-
})
|
32
|
+
}),
|
33
|
+
dts()
|
32
34
|
],
|
33
35
|
build: {
|
34
36
|
lib: {
|
@@ -45,7 +47,7 @@ export default defineConfig(({ mode }) => {
|
|
45
47
|
...peerDependencies,
|
46
48
|
}),
|
47
49
|
},
|
48
|
-
minify: isProd
|
50
|
+
minify: isProd
|
49
51
|
},
|
50
52
|
};
|
51
|
-
})
|
53
|
+
})
|