@netless/window-manager 1.0.0-canary.57 → 1.0.0-canary.59
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 → index.js} +4555 -3461
- package/dist/{index.es.js → index.mjs} +4552 -3441
- package/dist/index.umd.js +4534 -3440
- package/dist/src/App/AppProxy.d.ts +1 -0
- package/dist/src/View/ViewSync.d.ts +2 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/typings.d.ts +1 -1
- package/dist/style.css +14 -0
- package/package.json +8 -8
- package/pnpm-lock.yaml +179 -142
- package/src/App/AppProxy.ts +20 -8
- package/src/Cursor/Cursor.svelte +6 -2
- package/src/Cursor/Cursor.ts +9 -2
- package/src/Cursor/icons.ts +6 -0
- package/src/View/ScrollMode.ts +4 -3
- package/src/View/ViewSync.ts +4 -1
- package/src/image/pencil-eraser-1.svg +3 -0
- package/src/image/pencil-eraser-2.svg +3 -0
- package/src/image/pencil-eraser-3.svg +3 -0
- package/src/index.ts +11 -0
- package/src/style.css +14 -0
- package/src/typings.ts +1 -1
package/src/App/AppProxy.ts
CHANGED
@@ -114,7 +114,7 @@ export class AppProxy implements PageRemoveService {
|
|
114
114
|
emitter.on("memberStateChange", this.onMemberStateChange)
|
115
115
|
);
|
116
116
|
this.sideEffectManager.add(() => [
|
117
|
-
this.syncCamera$.
|
117
|
+
this.syncCamera$.subscribe(syncCamera => {
|
118
118
|
if (!syncCamera) {
|
119
119
|
if (this.viewSync) {
|
120
120
|
this.viewSync.destroy();
|
@@ -328,12 +328,18 @@ export class AppProxy implements PageRemoveService {
|
|
328
328
|
this.setViewFocusScenePath();
|
329
329
|
setTimeout(async () => {
|
330
330
|
// 延迟执行 setup, 防止初始化的属性没有更新成功
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
this.
|
331
|
+
try {
|
332
|
+
const result = await app.setup(context);
|
333
|
+
this.appResult = result;
|
334
|
+
appRegister.notifyApp(this.kind, "created", { appId, result });
|
335
|
+
this.fixMobileSize();
|
336
|
+
if (this.isAddApp) {
|
337
|
+
this.setupDone();
|
338
|
+
}
|
339
|
+
} catch (error) {
|
340
|
+
console.error(error);
|
341
|
+
this.setupFailed();
|
342
|
+
this.destroy(false, true, true);
|
337
343
|
}
|
338
344
|
}, SETUP_APP_DELAY);
|
339
345
|
});
|
@@ -355,7 +361,6 @@ export class AppProxy implements PageRemoveService {
|
|
355
361
|
width: this.box.intrinsicWidth,
|
356
362
|
height: this.box.intrinsicHeight,
|
357
363
|
});
|
358
|
-
this.boxManager.focusBox({ appId }, false);
|
359
364
|
}
|
360
365
|
} catch (error: any) {
|
361
366
|
console.error(error);
|
@@ -701,6 +706,13 @@ export class AppProxy implements PageRemoveService {
|
|
701
706
|
private setupDone = () => {
|
702
707
|
this.store.updateAppAttributes(this.id, "setup", true);
|
703
708
|
this.manager.dispatchInternalEvent(Events.InvokeAttributesUpdateCallback);
|
709
|
+
if (this.boxManager && this.box) {
|
710
|
+
this.boxManager.focusBox({ appId: this.id }, false);
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
private setupFailed = () => {
|
715
|
+
this.store.cleanAppAttributes(this.id);
|
704
716
|
}
|
705
717
|
|
706
718
|
public close(): Promise<void> {
|
package/src/Cursor/Cursor.svelte
CHANGED
@@ -15,12 +15,16 @@
|
|
15
15
|
export let color: string;
|
16
16
|
export let cursorTagBackgroundColor: string;
|
17
17
|
export let opacity: number;
|
18
|
+
export let pencilEraserSize: number;
|
18
19
|
|
19
20
|
$: hasName = !isEmpty(cursorName);
|
20
21
|
$: hasTagName = !isEmpty(tagName);
|
21
22
|
$: hasAvatar = !isEmpty(avatar);
|
22
23
|
$: display = visible ? "initial" : "none";
|
23
24
|
$: isLaserPointer = appliance === ApplianceNames.laserPointer;
|
25
|
+
$: isLaserPointerPencilEraser = isLaserPointer || appliance === ApplianceNames.pencilEraser;
|
26
|
+
$: offset = isLaserPointerPencilEraser ? "netless-window-manager-laserPointer-pencilEraser-offset" : "";
|
27
|
+
$: pencilEraserSize3ImageOffset = pencilEraserSize === 3 ? "netless-window-manager-pencilEraser-3-offset" : "";
|
24
28
|
|
25
29
|
const computedAvatarStyle = () => {
|
26
30
|
return Object.entries({
|
@@ -40,7 +44,7 @@
|
|
40
44
|
style="transform: translateX({x}px) translateY({y}px);display: {display}"
|
41
45
|
>
|
42
46
|
{#if !isLaserPointer}
|
43
|
-
<div class="netless-window-manager-cursor-name">
|
47
|
+
<div class="netless-window-manager-cursor-name {offset} {pencilEraserSize3ImageOffset}">
|
44
48
|
<div
|
45
49
|
class={theme}
|
46
50
|
style="background-color: {backgroundColor};color: {color};opacity: {opacity}"
|
@@ -63,6 +67,6 @@
|
|
63
67
|
</div>
|
64
68
|
{/if}
|
65
69
|
<div class="cursor-image-wrapper">
|
66
|
-
<img class="netless-window-manager-cursor-{appliance}-image" {src} alt={appliance} />
|
70
|
+
<img class="netless-window-manager-cursor-{appliance}-image {pencilEraserSize3ImageOffset}" {src} alt={appliance} />
|
67
71
|
</div>
|
68
72
|
</div>
|
package/src/Cursor/Cursor.ts
CHANGED
@@ -157,14 +157,21 @@ export class Cursor {
|
|
157
157
|
cursorTagBackgroundColor: this.memberCursorTagBackgroundColor,
|
158
158
|
opacity: this.memberOpacity,
|
159
159
|
tagName: this.memberTagName,
|
160
|
+
pencilEraserSize: this.member?.memberState.pencilEraserSize,
|
160
161
|
};
|
161
162
|
}
|
162
163
|
|
163
164
|
private getIcon() {
|
164
165
|
if (this.member) {
|
165
166
|
const icons = this.cursorManager.applianceIcons;
|
166
|
-
|
167
|
-
|
167
|
+
let applianceSrc = icons[ApplianceNames.shape];
|
168
|
+
if (this.memberApplianceName === ApplianceNames.pencilEraser) {
|
169
|
+
const size = this.member?.memberState.pencilEraserSize || 1;
|
170
|
+
applianceSrc = icons[`${this.memberApplianceName}${size}`];
|
171
|
+
} else {
|
172
|
+
applianceSrc = icons[this.memberApplianceName || ApplianceNames.shape];
|
173
|
+
}
|
174
|
+
return applianceSrc;
|
168
175
|
}
|
169
176
|
}
|
170
177
|
|
package/src/Cursor/icons.ts
CHANGED
@@ -5,6 +5,9 @@ import eraser from "../image/eraser-cursor.png";
|
|
5
5
|
import shape from "../image/shape-cursor.svg";
|
6
6
|
import text from "../image/text-cursor.svg";
|
7
7
|
import laser from "../image/laser-pointer-cursor.svg";
|
8
|
+
import pencilEraser1 from "../image/pencil-eraser-1.svg";
|
9
|
+
import pencilEraser2 from "../image/pencil-eraser-2.svg";
|
10
|
+
import pencilEraser3 from "../image/pencil-eraser-3.svg";
|
8
11
|
|
9
12
|
export const ApplianceMap: {
|
10
13
|
[key: string]: string;
|
@@ -15,4 +18,7 @@ export const ApplianceMap: {
|
|
15
18
|
[ApplianceNames.shape]: shape,
|
16
19
|
[ApplianceNames.text]: text,
|
17
20
|
[ApplianceNames.laserPointer]: laser,
|
21
|
+
["pencilEraser1"]: pencilEraser1,
|
22
|
+
["pencilEraser2"]: pencilEraser2,
|
23
|
+
["pencilEraser3"]: pencilEraser3,
|
18
24
|
};
|
package/src/View/ScrollMode.ts
CHANGED
@@ -4,6 +4,7 @@ import { combine, derive, Val } from "value-enhancer";
|
|
4
4
|
import { createScrollStorage } from "../storage";
|
5
5
|
import { SCROLL_MODE_BASE_HEIGHT, SCROLL_MODE_BASE_WIDTH } from "../constants";
|
6
6
|
import { SideEffectManager } from "side-effect-manager";
|
7
|
+
import { round } from "lodash";
|
7
8
|
import type { ReadonlyVal } from "value-enhancer";
|
8
9
|
import type { AppManager } from "../AppManager";
|
9
10
|
import type { ScrollStorage } from "../storage";
|
@@ -138,9 +139,9 @@ export class ScrollMode {
|
|
138
139
|
[this._scrollTop$, this._page$, maxScrollPage$],
|
139
140
|
([scrollTop, page, maxScrollPage]) => {
|
140
141
|
return {
|
141
|
-
scrollTop,
|
142
|
-
page,
|
143
|
-
maxScrollPage,
|
142
|
+
scrollTop: round(scrollTop, 2),
|
143
|
+
page: round(page, 2),
|
144
|
+
maxScrollPage: round(maxScrollPage, 2),
|
144
145
|
};
|
145
146
|
}
|
146
147
|
);
|
package/src/View/ViewSync.ts
CHANGED
@@ -3,8 +3,9 @@ import { CameraSynchronizer } from "./CameraSynchronizer";
|
|
3
3
|
import { combine, derive } from "value-enhancer";
|
4
4
|
import { isEqual } from "lodash";
|
5
5
|
import { SideEffectManager } from "side-effect-manager";
|
6
|
+
import { Val } from "value-enhancer";
|
6
7
|
import type { Camera, View } from "white-web-sdk";
|
7
|
-
import type {
|
8
|
+
import type { ReadonlyVal } from "value-enhancer";
|
8
9
|
import type { ICamera, ISize } from "../AttributesDelegate";
|
9
10
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
10
11
|
import type { ManagerViewMode } from "../typings";
|
@@ -43,6 +44,8 @@ export class ViewSync {
|
|
43
44
|
]);
|
44
45
|
if (context.viewMode$) {
|
45
46
|
this.needRecoverCamera$ = derive(context.viewMode$, mode => mode !== "scroll");
|
47
|
+
} else {
|
48
|
+
this.needRecoverCamera$ = new Val(true);
|
46
49
|
}
|
47
50
|
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
48
51
|
camera$size$.reaction(([camera, size]) => {
|
package/src/index.ts
CHANGED
@@ -1019,6 +1019,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
1019
1019
|
});
|
1020
1020
|
}, 500);
|
1021
1021
|
}
|
1022
|
+
/**
|
1023
|
+
* 切换 focus 到指定的 app, 并且把这个 app 放到最前面
|
1024
|
+
*/
|
1025
|
+
public focusApp(appId: string) {
|
1026
|
+
const box = this.boxManager?.getBox(appId);
|
1027
|
+
if (box) {
|
1028
|
+
this.boxManager?.focusBox({ appId }, false);
|
1029
|
+
// 1.0 版本这里会有正式的 api
|
1030
|
+
(this.boxManager?.teleBoxManager as any).makeBoxTop(box, false);
|
1031
|
+
}
|
1032
|
+
}
|
1022
1033
|
|
1023
1034
|
public createPPTHandler() {
|
1024
1035
|
return {
|
package/src/style.css
CHANGED
@@ -119,6 +119,20 @@
|
|
119
119
|
margin-top: 3px;
|
120
120
|
}
|
121
121
|
|
122
|
+
.netless-window-manager-cursor-pencilEraser-image {
|
123
|
+
margin-left: -22px;
|
124
|
+
margin-top: 3px;
|
125
|
+
}
|
126
|
+
|
127
|
+
.netless-window-manager-laserPointer-pencilEraser-offset {
|
128
|
+
margin-left: -18px;
|
129
|
+
}
|
130
|
+
|
131
|
+
.netless-window-manager-pencilEraser-3-offset {
|
132
|
+
margin-top: -14px;
|
133
|
+
margin-left: -6px;
|
134
|
+
}
|
135
|
+
|
122
136
|
.netless-window-manager-cursor-name {
|
123
137
|
width: 100%;
|
124
138
|
height: 48px;
|
package/src/typings.ts
CHANGED
@@ -87,7 +87,7 @@ export type RegisterParams<AppOptions = any, SetupResult = any, Attributes exten
|
|
87
87
|
|
88
88
|
export type AppListenerKeys = keyof AppEmitterEvent;
|
89
89
|
|
90
|
-
export type ApplianceIcons = Partial<Record
|
90
|
+
export type ApplianceIcons = Partial<Record<`${ApplianceNames}` | string, string>>;
|
91
91
|
|
92
92
|
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
93
93
|
|