@netless/window-manager 1.0.0-canary.25 → 1.0.0-canary.28
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/index.cjs.js +93 -12
- package/dist/index.es.js +1585 -698
- package/dist/index.umd.js +93 -12
- package/dist/{App → src/App}/AppContext.d.ts +0 -0
- package/dist/{App → src/App}/AppPageStateImpl.d.ts +0 -0
- package/dist/{App → src/App}/AppProxy.d.ts +0 -0
- package/dist/{App → src/App}/MagixEvent/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/StorageEvent.d.ts +0 -0
- package/dist/{App → src/App}/Storage/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/typings.d.ts +0 -0
- package/dist/{App → src/App}/Storage/utils.d.ts +0 -0
- package/dist/{App → src/App}/WhiteboardView.d.ts +6 -4
- package/dist/{App → src/App}/index.d.ts +0 -0
- package/dist/{App → src/App}/type.d.ts +0 -0
- package/dist/{AppListener.d.ts → src/AppListener.d.ts} +0 -2
- package/dist/{AppManager.d.ts → src/AppManager.d.ts} +0 -0
- package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +0 -0
- package/dist/{BoxEmitter.d.ts → src/BoxEmitter.d.ts} +0 -0
- package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +2 -4
- package/dist/{BuiltinApps.d.ts → src/BuiltinApps.d.ts} +3 -0
- package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/index.d.ts +0 -0
- package/dist/{Helper.d.ts → src/Helper.d.ts} +1 -1
- package/dist/{InternalEmitter.d.ts → src/InternalEmitter.d.ts} +0 -0
- package/dist/{Page → src/Page}/PageController.d.ts +0 -0
- package/dist/{Page → src/Page}/index.d.ts +0 -0
- package/dist/{PageState.d.ts → src/PageState.d.ts} +0 -0
- package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +0 -0
- package/dist/{RedoUndo.d.ts → src/RedoUndo.d.ts} +0 -0
- package/dist/{Register → src/Register}/index.d.ts +0 -0
- package/dist/{Register → src/Register}/loader.d.ts +0 -0
- package/dist/{Register → src/Register}/storage.d.ts +0 -0
- package/dist/{Utils → src/Utils}/AppCreateQueue.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Common.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Reactive.d.ts +0 -0
- package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
- package/dist/{Utils → src/Utils}/error.d.ts +0 -0
- package/dist/{Utils → src/Utils}/log.d.ts +0 -0
- package/dist/{View → src/View}/CameraSynchronizer.d.ts +0 -0
- package/dist/{View → src/View}/MainView.d.ts +0 -0
- package/dist/{View → src/View}/ViewManager.d.ts +0 -0
- package/dist/{View → src/View}/ViewSync.d.ts +0 -0
- package/dist/{callback.d.ts → src/callback.d.ts} +5 -0
- package/dist/{constants.d.ts → src/constants.d.ts} +0 -2
- package/dist/src/image.d.ts +19 -0
- package/dist/{index.d.ts → src/index.d.ts} +16 -12
- package/dist/src/shim.d.ts +11 -0
- package/dist/{typings.d.ts → src/typings.d.ts} +6 -0
- package/dist/style.css +1 -1
- package/docs/app-context.md +2 -2
- package/package.json +10 -5
- package/playwright.config.ts +28 -0
- package/pnpm-lock.yaml +514 -21
- package/src/App/AppContext.ts +2 -2
- package/src/App/AppProxy.ts +18 -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 -36
- package/src/BuiltinApps.ts +5 -0
- package/src/Helper.ts +3 -2
- package/src/Utils/Common.ts +3 -0
- 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 +62 -34
- package/src/style.css +3 -41
- package/src/typings.ts +6 -0
- package/vite.config.js +5 -3
package/src/index.ts
CHANGED
@@ -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) {
|
@@ -292,12 +293,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
292
293
|
|
293
294
|
private static initContainer(
|
294
295
|
container: HTMLElement,
|
296
|
+
target: HTMLElement,
|
295
297
|
overwriteStyles: string | undefined
|
296
298
|
) {
|
297
299
|
if (!WindowManager.container) {
|
298
300
|
WindowManager.container = container;
|
299
301
|
}
|
300
|
-
const { playground, mainViewElement } = setupWrapper(container);
|
302
|
+
const { playground, mainViewElement } = setupWrapper(container, target);
|
301
303
|
WindowManager.playground = playground;
|
302
304
|
if (overwriteStyles) {
|
303
305
|
const style = document.createElement("style");
|
@@ -320,15 +322,16 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
320
322
|
container.appendChild(WindowManager.container.firstChild);
|
321
323
|
}
|
322
324
|
} else {
|
323
|
-
|
325
|
+
const teleboxContainer = this.boxManager?.teleBoxManager.$stage;
|
326
|
+
if (WindowManager.params && teleboxContainer) {
|
324
327
|
const params = WindowManager.params;
|
325
328
|
const mainViewElement = WindowManager.initContainer(
|
326
329
|
container,
|
330
|
+
teleboxContainer,
|
327
331
|
params.overwriteStyles
|
328
332
|
);
|
329
333
|
if (this.boxManager && WindowManager.playground) {
|
330
334
|
this.boxManager.setRoot(WindowManager.playground);
|
331
|
-
this.boxManager.mainViewElement$.setValue(mainViewElement);
|
332
335
|
}
|
333
336
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
334
337
|
if (WindowManager.playground) {
|
@@ -657,6 +660,22 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
657
660
|
}
|
658
661
|
}
|
659
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
|
+
|
660
679
|
public get cameraState(): CameraState {
|
661
680
|
if (this.appManager) {
|
662
681
|
return this.appManager.mainViewProxy.cameraState;
|
@@ -763,30 +782,31 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
763
782
|
return this.appManager?.closeApp(appId);
|
764
783
|
}
|
765
784
|
|
766
|
-
public moveCamera(
|
767
|
-
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
768
|
-
): void {
|
769
|
-
const pureCamera = omit(camera, ["animationMode"]);
|
785
|
+
public moveCamera(camera: Partial<Camera> ): void {
|
770
786
|
const mainViewCamera = { ...this.mainView.camera };
|
771
|
-
|
772
|
-
|
773
|
-
this.appManager
|
774
|
-
|
775
|
-
this.appManager
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
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
|
+
}
|
790
810
|
}
|
791
811
|
|
792
812
|
public convertToPointInWorld(point: Point): Point {
|
@@ -926,6 +946,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
926
946
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
927
947
|
}
|
928
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
|
+
|
929
957
|
public createPPTHandler() {
|
930
958
|
return {
|
931
959
|
onPageJumpTo: (_pptUUID: string, index: number) => {
|
@@ -977,5 +1005,5 @@ setupBuiltin();
|
|
977
1005
|
|
978
1006
|
export * from "./typings";
|
979
1007
|
|
980
|
-
export { BuiltinApps } from "./BuiltinApps";
|
1008
|
+
export { BuiltinApps, BuiltinAppsMap } from "./BuiltinApps";
|
981
1009
|
export type { PublicEvent } from "./callback";
|
package/src/style.css
CHANGED
@@ -7,49 +7,11 @@
|
|
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 {
|
52
12
|
position: absolute;
|
13
|
+
width: 100%;
|
14
|
+
height: 100%;
|
53
15
|
}
|
54
16
|
|
55
17
|
|
@@ -180,5 +142,5 @@
|
|
180
142
|
|
181
143
|
.window-manager-view-wrapper {
|
182
144
|
position: absolute;
|
183
|
-
z-index:
|
145
|
+
z-index: 10;
|
184
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
|
+
})
|