@netless/window-manager 0.4.70 → 0.4.71
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/AppManager.d.ts +2 -1
- package/dist/Cursor/Cursor.d.ts +7 -3
- package/dist/Cursor/icons2.d.ts +4 -0
- package/dist/Cursor/index.d.ts +9 -3
- package/dist/callback.d.ts +12 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -50
- package/dist/index.mjs.map +1 -1
- package/dist/typings.d.ts +4 -0
- package/package.json +1 -1
- package/src/App/AppContext.ts +5 -0
- package/src/App/AppProxy.ts +8 -0
- package/src/AppManager.ts +31 -1
- package/src/Cursor/Cursor.svelte +9 -4
- package/src/Cursor/Cursor.svelte.d.ts +21 -0
- package/src/Cursor/Cursor.ts +75 -19
- package/src/Cursor/icons2.ts +66 -0
- package/src/Cursor/index.ts +84 -14
- package/src/callback.ts +12 -1
- package/src/index.ts +48 -15
- package/src/style.css +0 -1
- package/src/typings.ts +5 -0
package/src/index.ts
CHANGED
@@ -126,6 +126,15 @@ export type AppInitState = {
|
|
126
126
|
|
127
127
|
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
128
128
|
|
129
|
+
export type CursorOptions = {
|
130
|
+
/**
|
131
|
+
* If `"custom"`, it will render the pencil / eraser cursor as a circle and shapes cursor as a cross.
|
132
|
+
*
|
133
|
+
* @default "default"
|
134
|
+
*/
|
135
|
+
style?: "default" | "custom";
|
136
|
+
};
|
137
|
+
|
129
138
|
export type MountParams = {
|
130
139
|
room: Room | Player;
|
131
140
|
container?: HTMLElement;
|
@@ -137,17 +146,22 @@ export type MountParams = {
|
|
137
146
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
138
147
|
overwriteStyles?: string;
|
139
148
|
cursor?: boolean;
|
149
|
+
cursorOptions?: CursorOptions;
|
140
150
|
debug?: boolean;
|
141
151
|
disableCameraTransform?: boolean;
|
142
152
|
prefersColorScheme?: TeleBoxColorScheme;
|
143
153
|
applianceIcons?: ApplianceIcons;
|
144
154
|
fullscreen?: boolean;
|
145
155
|
polling?: boolean;
|
156
|
+
supportTeachingAidsPlugin?: boolean;
|
146
157
|
};
|
147
158
|
|
148
159
|
export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
149
160
|
|
150
|
-
export class WindowManager
|
161
|
+
export class WindowManager
|
162
|
+
extends InvisiblePlugin<WindowMangerAttributes, any>
|
163
|
+
implements PageController
|
164
|
+
{
|
151
165
|
public static kind = "WindowManager";
|
152
166
|
public static displayer: Displayer;
|
153
167
|
public static wrapper?: HTMLElement;
|
@@ -156,6 +170,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
156
170
|
public static container?: HTMLElement;
|
157
171
|
public static debug = false;
|
158
172
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
173
|
+
public static supportTeachingAidsPlugin?: boolean;
|
159
174
|
private static isCreated = false;
|
160
175
|
|
161
176
|
public version = __APP_VERSION__;
|
@@ -187,6 +202,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
187
202
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
188
203
|
const room = params.room;
|
189
204
|
WindowManager.container = params.container;
|
205
|
+
WindowManager.supportTeachingAidsPlugin = params.supportTeachingAidsPlugin;
|
190
206
|
const containerSizeRatio = params.containerSizeRatio;
|
191
207
|
const debug = params.debug;
|
192
208
|
|
@@ -246,7 +262,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
246
262
|
manager.appManager = new AppManager(manager);
|
247
263
|
manager.appManager.polling = params.polling || false;
|
248
264
|
manager._pageState = new PageStateImpl(manager.appManager);
|
249
|
-
manager.cursorManager = new CursorManager(
|
265
|
+
manager.cursorManager = new CursorManager(
|
266
|
+
manager.appManager,
|
267
|
+
Boolean(cursor),
|
268
|
+
params.cursorOptions,
|
269
|
+
params.applianceIcons
|
270
|
+
);
|
250
271
|
if (containerSizeRatio) {
|
251
272
|
manager.containerSizeRatio = containerSizeRatio;
|
252
273
|
}
|
@@ -293,16 +314,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
293
314
|
manager: WindowManager,
|
294
315
|
container: HTMLElement,
|
295
316
|
params: {
|
296
|
-
chessboard?: boolean
|
297
|
-
overwriteStyles?: string
|
298
|
-
fullscreen?: boolean
|
317
|
+
chessboard?: boolean;
|
318
|
+
overwriteStyles?: string;
|
319
|
+
fullscreen?: boolean;
|
299
320
|
}
|
300
321
|
) {
|
301
|
-
const {
|
302
|
-
chessboard,
|
303
|
-
overwriteStyles,
|
304
|
-
fullscreen,
|
305
|
-
} = params;
|
322
|
+
const { chessboard, overwriteStyles, fullscreen } = params;
|
306
323
|
if (!WindowManager.container) {
|
307
324
|
WindowManager.container = container;
|
308
325
|
}
|
@@ -578,7 +595,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
578
595
|
console.warn(`[WindowManager]: index ${index} out of range`);
|
579
596
|
return false;
|
580
597
|
}
|
581
|
-
return this.appManager.removeSceneByIndex(needRemoveIndex)
|
598
|
+
return this.appManager.removeSceneByIndex(needRemoveIndex);
|
582
599
|
} else {
|
583
600
|
return false;
|
584
601
|
}
|
@@ -626,7 +643,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
626
643
|
*
|
627
644
|
* 返回一个用于撤销此监听的函数
|
628
645
|
*/
|
629
|
-
public onAppEvent(
|
646
|
+
public onAppEvent(
|
647
|
+
kind: string,
|
648
|
+
listener: (args: { kind: string; appId: string; type: string; value: any }) => void
|
649
|
+
): () => void {
|
630
650
|
return internalEmitter.on(`custom-${kind}` as any, listener);
|
631
651
|
}
|
632
652
|
|
@@ -750,6 +770,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
750
770
|
}
|
751
771
|
}
|
752
772
|
|
773
|
+
public get cursorStyle(): "default" | "custom" {
|
774
|
+
return this.cursorManager?.style || "default";
|
775
|
+
}
|
776
|
+
|
777
|
+
public set cursorStyle(value: "default" | "custom") {
|
778
|
+
if (!this.cursorManager) {
|
779
|
+
throw new Error("[WindowManager]: cursor is not enabled, please set { cursor: true }.");
|
780
|
+
}
|
781
|
+
this.cursorManager.style = value;
|
782
|
+
}
|
783
|
+
|
753
784
|
public get mainViewSceneIndex(): number {
|
754
785
|
return this._pageState?.index || 0;
|
755
786
|
}
|
@@ -979,8 +1010,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
979
1010
|
}
|
980
1011
|
|
981
1012
|
public refresh() {
|
982
|
-
|
983
|
-
|
1013
|
+
this._refresh();
|
1014
|
+
this.appManager?.dispatchInternalEvent(Events.Refresh);
|
984
1015
|
}
|
985
1016
|
|
986
1017
|
/** @inner */
|
@@ -994,7 +1025,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
994
1025
|
|
995
1026
|
public setContainerSizeRatio(ratio: number) {
|
996
1027
|
if (!isNumber(ratio) || !(ratio > 0)) {
|
997
|
-
throw new Error(
|
1028
|
+
throw new Error(
|
1029
|
+
`[WindowManager]: updateContainerSizeRatio error, ratio must be a positive number. but got ${ratio}`
|
1030
|
+
);
|
998
1031
|
}
|
999
1032
|
WindowManager.containerSizeRatio = ratio;
|
1000
1033
|
this.containerSizeRatio = ratio;
|
package/src/style.css
CHANGED
package/src/typings.ts
CHANGED
@@ -88,3 +88,8 @@ export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room,
|
|
88
88
|
export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
|
89
89
|
export * from "./Page";
|
90
90
|
export * from "./Utils/error";
|
91
|
+
|
92
|
+
export type AppPayload = {
|
93
|
+
appId: string,
|
94
|
+
view: View
|
95
|
+
}
|