@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/dist/index.mjs
CHANGED
@@ -954,6 +954,9 @@ class AppContext {
|
|
954
954
|
setTimeout(() => {
|
955
955
|
var _a;
|
956
956
|
(_a = this.getRoom()) == null ? void 0 : _a.refreshViewSize();
|
957
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
958
|
+
callbacks$1.emit("onAppViewMounted", { appId: this.appId, view });
|
959
|
+
}
|
957
960
|
}, 1e3);
|
958
961
|
}
|
959
962
|
};
|
@@ -1397,6 +1400,9 @@ class AppProxy {
|
|
1397
1400
|
var _a2;
|
1398
1401
|
if (this.view && fullPath && fullPath !== ((_a2 = this.view) == null ? void 0 : _a2.focusScenePath)) {
|
1399
1402
|
setViewFocusScenePath(this.view, fullPath);
|
1403
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
1404
|
+
callbacks$1.emit("onAppScenePathChange", { appId: this.id, view: this.view });
|
1405
|
+
}
|
1400
1406
|
}
|
1401
1407
|
}, 50);
|
1402
1408
|
this.notifyPageStateChange = debounce$1(() => {
|
@@ -1514,6 +1520,9 @@ class AppProxy {
|
|
1514
1520
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
1515
1521
|
this.afterSetupApp(boxInitState);
|
1516
1522
|
this.fixMobileSize();
|
1523
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
1524
|
+
callbacks$1.emit("onAppSetup", appId);
|
1525
|
+
}
|
1517
1526
|
}, SETUP_APP_DELAY);
|
1518
1527
|
});
|
1519
1528
|
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
@@ -2243,6 +2252,9 @@ class AppManager {
|
|
2243
2252
|
x: payload.x,
|
2244
2253
|
y: payload.y
|
2245
2254
|
});
|
2255
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2256
|
+
callbacks$1.emit("onBoxMove", payload);
|
2257
|
+
}
|
2246
2258
|
};
|
2247
2259
|
this.onBoxResize = (payload) => {
|
2248
2260
|
if (payload.width && payload.height) {
|
@@ -2251,19 +2263,31 @@ class AppManager {
|
|
2251
2263
|
width: payload.width,
|
2252
2264
|
height: payload.height
|
2253
2265
|
});
|
2266
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2267
|
+
callbacks$1.emit("onBoxResize", payload);
|
2268
|
+
}
|
2254
2269
|
}
|
2255
2270
|
};
|
2256
2271
|
this.onBoxFocus = (payload) => {
|
2257
2272
|
this.windowManger.safeSetAttributes({ focus: payload.appId });
|
2273
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2274
|
+
callbacks$1.emit("onBoxFocus", payload);
|
2275
|
+
}
|
2258
2276
|
};
|
2259
2277
|
this.onBoxClose = (payload) => {
|
2260
2278
|
const appProxy = this.appProxies.get(payload.appId);
|
2261
2279
|
if (appProxy) {
|
2262
2280
|
appProxy.destroy(false, true, true, payload.error);
|
2263
2281
|
}
|
2282
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2283
|
+
callbacks$1.emit("onBoxClose", payload);
|
2284
|
+
}
|
2264
2285
|
};
|
2265
2286
|
this.onBoxStateChange = (payload) => {
|
2266
2287
|
this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
|
2288
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2289
|
+
callbacks$1.emit("onBoxStateChange", payload);
|
2290
|
+
}
|
2267
2291
|
};
|
2268
2292
|
this.addAppsChangeListener = () => {
|
2269
2293
|
this.refresher.add("apps", () => {
|
@@ -2417,6 +2441,10 @@ class AppManager {
|
|
2417
2441
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
2418
2442
|
});
|
2419
2443
|
}
|
2444
|
+
getMemberState() {
|
2445
|
+
var _a;
|
2446
|
+
return ((_a = this.room) == null ? void 0 : _a.state.memberState) || { strokeColor: [0, 0, 0] };
|
2447
|
+
}
|
2420
2448
|
async onRootDirRemoved(needClose = true) {
|
2421
2449
|
this.setMainViewScenePath(INIT_DIR);
|
2422
2450
|
this.createRootDirScenesCallback();
|
@@ -2593,6 +2621,9 @@ class AppManager {
|
|
2593
2621
|
this.setMainViewFocusPath();
|
2594
2622
|
}
|
2595
2623
|
internalEmitter.emit("mainViewMounted");
|
2624
|
+
if (WindowManager.supportTeachingAidsPlugin) {
|
2625
|
+
callbacks$1.emit("onMainViewMounted", mainView);
|
2626
|
+
}
|
2596
2627
|
}
|
2597
2628
|
setMainViewFocusPath(scenePath) {
|
2598
2629
|
var _a;
|
@@ -6764,8 +6795,8 @@ function create_if_block(ctx) {
|
|
6764
6795
|
let t1;
|
6765
6796
|
let t2;
|
6766
6797
|
let div1_class_value;
|
6767
|
-
let if_block0 = ctx[
|
6768
|
-
let if_block1 = ctx[
|
6798
|
+
let if_block0 = ctx[17] && create_if_block_2(ctx);
|
6799
|
+
let if_block1 = ctx[18] && create_if_block_1(ctx);
|
6769
6800
|
return {
|
6770
6801
|
c() {
|
6771
6802
|
div1 = element("div");
|
@@ -6786,7 +6817,7 @@ function create_if_block(ctx) {
|
|
6786
6817
|
set_style(div0, "background-color", ctx[2]);
|
6787
6818
|
set_style(div0, "color", ctx[9]);
|
6788
6819
|
set_style(div0, "opacity", ctx[11]);
|
6789
|
-
attr(div1, "class", div1_class_value = "netless-window-manager-cursor-name " + ctx[
|
6820
|
+
attr(div1, "class", div1_class_value = "netless-window-manager-cursor-name " + ctx[15] + " " + ctx[14]);
|
6790
6821
|
},
|
6791
6822
|
m(target, anchor) {
|
6792
6823
|
insert(target, div1, anchor);
|
@@ -6801,7 +6832,7 @@ function create_if_block(ctx) {
|
|
6801
6832
|
if_block1.m(div0, null);
|
6802
6833
|
},
|
6803
6834
|
p(ctx2, dirty) {
|
6804
|
-
if (ctx2[
|
6835
|
+
if (ctx2[17]) {
|
6805
6836
|
if (if_block0) {
|
6806
6837
|
if_block0.p(ctx2, dirty);
|
6807
6838
|
} else {
|
@@ -6815,7 +6846,7 @@ function create_if_block(ctx) {
|
|
6815
6846
|
}
|
6816
6847
|
if (dirty & 1)
|
6817
6848
|
set_data(t1, ctx2[0]);
|
6818
|
-
if (ctx2[
|
6849
|
+
if (ctx2[18]) {
|
6819
6850
|
if (if_block1) {
|
6820
6851
|
if_block1.p(ctx2, dirty);
|
6821
6852
|
} else {
|
@@ -6839,7 +6870,7 @@ function create_if_block(ctx) {
|
|
6839
6870
|
if (dirty & 2048) {
|
6840
6871
|
set_style(div0, "opacity", ctx2[11]);
|
6841
6872
|
}
|
6842
|
-
if (dirty &
|
6873
|
+
if (dirty & 49152 && div1_class_value !== (div1_class_value = "netless-window-manager-cursor-name " + ctx2[15] + " " + ctx2[14])) {
|
6843
6874
|
attr(div1, "class", div1_class_value);
|
6844
6875
|
}
|
6845
6876
|
},
|
@@ -6860,7 +6891,7 @@ function create_if_block_2(ctx) {
|
|
6860
6891
|
c() {
|
6861
6892
|
img = element("img");
|
6862
6893
|
attr(img, "class", "netless-window-manager-cursor-selector-avatar");
|
6863
|
-
attr(img, "style", ctx[
|
6894
|
+
attr(img, "style", ctx[19]());
|
6864
6895
|
if (!src_url_equal(img.src, img_src_value = ctx[7]))
|
6865
6896
|
attr(img, "src", img_src_value);
|
6866
6897
|
attr(img, "alt", "avatar");
|
@@ -6913,7 +6944,8 @@ function create_fragment(ctx) {
|
|
6913
6944
|
let img;
|
6914
6945
|
let img_class_value;
|
6915
6946
|
let img_src_value;
|
6916
|
-
let
|
6947
|
+
let div1_class_value;
|
6948
|
+
let if_block = !ctx[13] && create_if_block(ctx);
|
6917
6949
|
return {
|
6918
6950
|
c() {
|
6919
6951
|
div1 = element("div");
|
@@ -6922,14 +6954,14 @@ function create_fragment(ctx) {
|
|
6922
6954
|
t2 = space();
|
6923
6955
|
div0 = element("div");
|
6924
6956
|
img = element("img");
|
6925
|
-
attr(img, "class", img_class_value = "netless-window-manager-cursor-" + ctx[3] + "-image " + ctx[
|
6957
|
+
attr(img, "class", img_class_value = "netless-window-manager-cursor-" + ctx[3] + "-image " + ctx[14]);
|
6926
6958
|
if (!src_url_equal(img.src, img_src_value = ctx[6]))
|
6927
6959
|
attr(img, "src", img_src_value);
|
6928
6960
|
attr(img, "alt", ctx[3]);
|
6929
6961
|
attr(div0, "class", "cursor-image-wrapper");
|
6930
|
-
attr(div1, "class", "netless-window-manager-cursor-mid");
|
6962
|
+
attr(div1, "class", div1_class_value = "netless-window-manager-cursor-mid" + (ctx[12] ? " netless-window-manager-cursor-custom" : ""));
|
6931
6963
|
set_style(div1, "transform", "translateX(" + ctx[4] + "px) translateY(" + ctx[5] + "px)");
|
6932
|
-
set_style(div1, "display", ctx[
|
6964
|
+
set_style(div1, "display", ctx[16]);
|
6933
6965
|
},
|
6934
6966
|
m(target, anchor) {
|
6935
6967
|
insert(target, div1, anchor);
|
@@ -6940,7 +6972,7 @@ function create_fragment(ctx) {
|
|
6940
6972
|
append(div0, img);
|
6941
6973
|
},
|
6942
6974
|
p(ctx2, [dirty]) {
|
6943
|
-
if (!ctx2[
|
6975
|
+
if (!ctx2[13]) {
|
6944
6976
|
if (if_block) {
|
6945
6977
|
if_block.p(ctx2, dirty);
|
6946
6978
|
} else {
|
@@ -6952,7 +6984,7 @@ function create_fragment(ctx) {
|
|
6952
6984
|
if_block.d(1);
|
6953
6985
|
if_block = null;
|
6954
6986
|
}
|
6955
|
-
if (dirty &
|
6987
|
+
if (dirty & 16392 && img_class_value !== (img_class_value = "netless-window-manager-cursor-" + ctx2[3] + "-image " + ctx2[14])) {
|
6956
6988
|
attr(img, "class", img_class_value);
|
6957
6989
|
}
|
6958
6990
|
if (dirty & 64 && !src_url_equal(img.src, img_src_value = ctx2[6])) {
|
@@ -6961,11 +6993,14 @@ function create_fragment(ctx) {
|
|
6961
6993
|
if (dirty & 8) {
|
6962
6994
|
attr(img, "alt", ctx2[3]);
|
6963
6995
|
}
|
6996
|
+
if (dirty & 4096 && div1_class_value !== (div1_class_value = "netless-window-manager-cursor-mid" + (ctx2[12] ? " netless-window-manager-cursor-custom" : ""))) {
|
6997
|
+
attr(div1, "class", div1_class_value);
|
6998
|
+
}
|
6964
6999
|
if (dirty & 48) {
|
6965
7000
|
set_style(div1, "transform", "translateX(" + ctx2[4] + "px) translateY(" + ctx2[5] + "px)");
|
6966
7001
|
}
|
6967
|
-
if (dirty &
|
6968
|
-
set_style(div1, "display", ctx2[
|
7002
|
+
if (dirty & 65536) {
|
7003
|
+
set_style(div1, "display", ctx2[16]);
|
6969
7004
|
}
|
6970
7005
|
},
|
6971
7006
|
i: noop,
|
@@ -7001,6 +7036,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
7001
7036
|
let { cursorTagBackgroundColor } = $$props;
|
7002
7037
|
let { opacity } = $$props;
|
7003
7038
|
let { pencilEraserSize } = $$props;
|
7039
|
+
let { custom } = $$props;
|
7004
7040
|
const computedAvatarStyle = () => {
|
7005
7041
|
return Object.entries({
|
7006
7042
|
width: (hasName ? 19 : 28) + "px",
|
@@ -7026,7 +7062,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
7026
7062
|
if ("src" in $$props2)
|
7027
7063
|
$$invalidate(6, src = $$props2.src);
|
7028
7064
|
if ("visible" in $$props2)
|
7029
|
-
$$invalidate(
|
7065
|
+
$$invalidate(20, visible = $$props2.visible);
|
7030
7066
|
if ("avatar" in $$props2)
|
7031
7067
|
$$invalidate(7, avatar = $$props2.avatar);
|
7032
7068
|
if ("theme" in $$props2)
|
@@ -7038,32 +7074,34 @@ function instance($$self, $$props, $$invalidate) {
|
|
7038
7074
|
if ("opacity" in $$props2)
|
7039
7075
|
$$invalidate(11, opacity = $$props2.opacity);
|
7040
7076
|
if ("pencilEraserSize" in $$props2)
|
7041
|
-
$$invalidate(
|
7077
|
+
$$invalidate(21, pencilEraserSize = $$props2.pencilEraserSize);
|
7078
|
+
if ("custom" in $$props2)
|
7079
|
+
$$invalidate(12, custom = $$props2.custom);
|
7042
7080
|
};
|
7043
7081
|
$$self.$$.update = () => {
|
7044
7082
|
if ($$self.$$.dirty & 1) {
|
7045
7083
|
hasName = !isEmpty(cursorName);
|
7046
7084
|
}
|
7047
7085
|
if ($$self.$$.dirty & 2) {
|
7048
|
-
$$invalidate(
|
7086
|
+
$$invalidate(18, hasTagName = !isEmpty(tagName));
|
7049
7087
|
}
|
7050
7088
|
if ($$self.$$.dirty & 128) {
|
7051
|
-
$$invalidate(
|
7089
|
+
$$invalidate(17, hasAvatar = !isEmpty(avatar));
|
7052
7090
|
}
|
7053
|
-
if ($$self.$$.dirty &
|
7054
|
-
$$invalidate(
|
7091
|
+
if ($$self.$$.dirty & 1048576) {
|
7092
|
+
$$invalidate(16, display = visible ? "initial" : "none");
|
7055
7093
|
}
|
7056
7094
|
if ($$self.$$.dirty & 8) {
|
7057
|
-
$$invalidate(
|
7095
|
+
$$invalidate(13, isLaserPointer = appliance === ApplianceNames.laserPointer);
|
7058
7096
|
}
|
7059
|
-
if ($$self.$$.dirty &
|
7060
|
-
$$invalidate(
|
7097
|
+
if ($$self.$$.dirty & 8200) {
|
7098
|
+
$$invalidate(22, isLaserPointerPencilEraser = isLaserPointer || appliance === ApplianceNames.pencilEraser);
|
7061
7099
|
}
|
7062
|
-
if ($$self.$$.dirty &
|
7063
|
-
$$invalidate(
|
7100
|
+
if ($$self.$$.dirty & 4194304) {
|
7101
|
+
$$invalidate(15, offset = isLaserPointerPencilEraser ? "netless-window-manager-laserPointer-pencilEraser-offset" : "");
|
7064
7102
|
}
|
7065
|
-
if ($$self.$$.dirty &
|
7066
|
-
$$invalidate(
|
7103
|
+
if ($$self.$$.dirty & 2097152) {
|
7104
|
+
$$invalidate(14, pencilEraserSize3ImageOffset = pencilEraserSize === 3 ? "netless-window-manager-pencilEraser-3-offset" : "");
|
7067
7105
|
}
|
7068
7106
|
};
|
7069
7107
|
return [
|
@@ -7079,6 +7117,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
7079
7117
|
color2,
|
7080
7118
|
cursorTagBackgroundColor,
|
7081
7119
|
opacity,
|
7120
|
+
custom,
|
7082
7121
|
isLaserPointer,
|
7083
7122
|
pencilEraserSize3ImageOffset,
|
7084
7123
|
offset,
|
@@ -7102,22 +7141,78 @@ class Cursor$1 extends SvelteComponent {
|
|
7102
7141
|
x: 4,
|
7103
7142
|
y: 5,
|
7104
7143
|
src: 6,
|
7105
|
-
visible:
|
7144
|
+
visible: 20,
|
7106
7145
|
avatar: 7,
|
7107
7146
|
theme: 8,
|
7108
7147
|
color: 9,
|
7109
7148
|
cursorTagBackgroundColor: 10,
|
7110
7149
|
opacity: 11,
|
7111
|
-
pencilEraserSize:
|
7150
|
+
pencilEraserSize: 21,
|
7151
|
+
custom: 12
|
7112
7152
|
});
|
7113
7153
|
}
|
7114
7154
|
}
|
7155
|
+
const staticCircle = `data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23000' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23FFF'/%3E%3C/g%3E%3C/svg%3E`;
|
7156
|
+
function circleUrl(color2) {
|
7157
|
+
return `data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23${color2}' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23${color2}'/%3E%3C/g%3E%3C/svg%3E`;
|
7158
|
+
}
|
7159
|
+
function crossUrl(color2) {
|
7160
|
+
return `data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg' fill='none'%3E%3Cpath d='M5 12H19' stroke='%23${color2}' stroke-linejoin='round'/%3E%3Cpath d='M12 5V19' stroke='%23${color2}' stroke-linejoin='round'/%3E%3C/svg%3E`;
|
7161
|
+
}
|
7162
|
+
function cssCursor(url) {
|
7163
|
+
return `url("${url}") 12 12, auto`;
|
7164
|
+
}
|
7165
|
+
function makeStyleContent(config) {
|
7166
|
+
let result = "";
|
7167
|
+
for (const cursor in config) {
|
7168
|
+
result += `.netless-whiteboard.${cursor} {cursor: ${config[cursor]}}
|
7169
|
+
`;
|
7170
|
+
}
|
7171
|
+
return result;
|
7172
|
+
}
|
7173
|
+
const $style = document.createElement("style");
|
7174
|
+
function enableLocal(memberState) {
|
7175
|
+
const [r2, g, b] = memberState.strokeColor;
|
7176
|
+
const hex2 = ((1 << 24) + (r2 << 16) + (g << 8) + b).toString(16).slice(1);
|
7177
|
+
$style.textContent = makeStyleContent({
|
7178
|
+
"cursor-pencil": cssCursor(circleUrl(hex2)),
|
7179
|
+
"cursor-eraser": cssCursor(staticCircle),
|
7180
|
+
"cursor-rectangle": cssCursor(crossUrl(hex2)),
|
7181
|
+
"cursor-ellipse": cssCursor(crossUrl(hex2)),
|
7182
|
+
"cursor-straight": cssCursor(crossUrl(hex2)),
|
7183
|
+
"cursor-arrow": cssCursor(crossUrl(hex2)),
|
7184
|
+
"cursor-shape": cssCursor(crossUrl(hex2))
|
7185
|
+
});
|
7186
|
+
document.head.appendChild($style);
|
7187
|
+
return () => {
|
7188
|
+
if ($style.parentNode == null)
|
7189
|
+
return;
|
7190
|
+
document.head.removeChild($style);
|
7191
|
+
};
|
7192
|
+
}
|
7193
|
+
const shapeAppliances = /* @__PURE__ */ new Set([
|
7194
|
+
ApplianceNames.rectangle,
|
7195
|
+
ApplianceNames.ellipse,
|
7196
|
+
ApplianceNames.straight,
|
7197
|
+
ApplianceNames.arrow,
|
7198
|
+
ApplianceNames.shape
|
7199
|
+
]);
|
7200
|
+
function remoteIcon(applianceName, hex2) {
|
7201
|
+
if (applianceName === ApplianceNames.pencil) {
|
7202
|
+
return circleUrl(hex2);
|
7203
|
+
} else if (applianceName === ApplianceNames.eraser) {
|
7204
|
+
return staticCircle;
|
7205
|
+
} else if (shapeAppliances.has(applianceName)) {
|
7206
|
+
return crossUrl(hex2);
|
7207
|
+
}
|
7208
|
+
}
|
7115
7209
|
class Cursor {
|
7116
7210
|
constructor(manager, memberId, cursorManager, wrapper) {
|
7117
7211
|
this.manager = manager;
|
7118
7212
|
this.memberId = memberId;
|
7119
7213
|
this.cursorManager = cursorManager;
|
7120
7214
|
this.wrapper = wrapper;
|
7215
|
+
this.style = "default";
|
7121
7216
|
this.move = (position) => {
|
7122
7217
|
var _a;
|
7123
7218
|
if (position.type === "main") {
|
@@ -7136,12 +7231,22 @@ class Cursor {
|
|
7136
7231
|
}
|
7137
7232
|
}
|
7138
7233
|
};
|
7234
|
+
this.setStyle = (style2) => {
|
7235
|
+
this.style = style2;
|
7236
|
+
if (this.component) {
|
7237
|
+
this.component.$set({
|
7238
|
+
src: this.getIcon(),
|
7239
|
+
custom: this.isCustomIcon()
|
7240
|
+
});
|
7241
|
+
}
|
7242
|
+
};
|
7139
7243
|
this.leave = () => {
|
7140
7244
|
this.hide();
|
7141
7245
|
};
|
7142
7246
|
this.updateMember();
|
7143
7247
|
this.createCursor();
|
7144
7248
|
this.autoHidden();
|
7249
|
+
this.setStyle(cursorManager.style);
|
7145
7250
|
}
|
7146
7251
|
moveCursor(cursor, rect, view) {
|
7147
7252
|
var _a, _b;
|
@@ -7150,6 +7255,10 @@ class Cursor {
|
|
7150
7255
|
if (point) {
|
7151
7256
|
let translateX = point.x - 2;
|
7152
7257
|
let translateY = point.y - 18;
|
7258
|
+
if (this.isCustomIcon()) {
|
7259
|
+
translateX -= 11;
|
7260
|
+
translateY += 4;
|
7261
|
+
}
|
7153
7262
|
if (type === "app") {
|
7154
7263
|
const wrapperRect = this.cursorManager.wrapperRect;
|
7155
7264
|
if (wrapperRect) {
|
@@ -7173,6 +7282,11 @@ class Cursor {
|
|
7173
7282
|
const rgb = (_b = (_a = this.member) == null ? void 0 : _a.memberState) == null ? void 0 : _b.strokeColor.join(",");
|
7174
7283
|
return `rgb(${rgb})`;
|
7175
7284
|
}
|
7285
|
+
get memberColorHex() {
|
7286
|
+
var _a, _b;
|
7287
|
+
const [r2, g, b] = ((_b = (_a = this.member) == null ? void 0 : _a.memberState) == null ? void 0 : _b.strokeColor) || [236, 52, 85];
|
7288
|
+
return ((1 << 24) + (r2 << 16) + (g << 8) + b).toString(16).slice(1);
|
7289
|
+
}
|
7176
7290
|
get payload() {
|
7177
7291
|
var _a;
|
7178
7292
|
return (_a = this.member) == null ? void 0 : _a.payload;
|
@@ -7236,6 +7350,7 @@ class Cursor {
|
|
7236
7350
|
appliance: this.memberApplianceName,
|
7237
7351
|
avatar: this.memberAvatar,
|
7238
7352
|
src: this.getIcon(),
|
7353
|
+
custom: this.isCustomIcon(),
|
7239
7354
|
visible: false,
|
7240
7355
|
backgroundColor: this.memberColor,
|
7241
7356
|
cursorName: this.memberCursorName,
|
@@ -7249,17 +7364,44 @@ class Cursor {
|
|
7249
7364
|
}
|
7250
7365
|
getIcon() {
|
7251
7366
|
var _a;
|
7252
|
-
if (this.member)
|
7253
|
-
|
7254
|
-
|
7255
|
-
|
7256
|
-
|
7257
|
-
|
7258
|
-
}
|
7259
|
-
|
7260
|
-
|
7261
|
-
|
7367
|
+
if (!this.member)
|
7368
|
+
return;
|
7369
|
+
const { memberApplianceName, memberColorHex } = this;
|
7370
|
+
const { userApplianceIcons, applianceIcons } = this.cursorManager;
|
7371
|
+
let iconsKey = this.memberApplianceName;
|
7372
|
+
if (iconsKey === ApplianceNames.pencilEraser) {
|
7373
|
+
iconsKey = `${iconsKey}${((_a = this.member) == null ? void 0 : _a.memberState.pencilEraserSize) || 1}`;
|
7374
|
+
}
|
7375
|
+
const userApplianceSrc = iconsKey && userApplianceIcons[iconsKey];
|
7376
|
+
if (userApplianceSrc)
|
7377
|
+
return userApplianceSrc;
|
7378
|
+
if (this.style === "custom" && memberApplianceName) {
|
7379
|
+
const customApplianceSrc = remoteIcon(memberApplianceName, memberColorHex);
|
7380
|
+
if (customApplianceSrc)
|
7381
|
+
return customApplianceSrc;
|
7382
|
+
}
|
7383
|
+
const applianceSrc = applianceIcons[iconsKey || ApplianceNames.shape];
|
7384
|
+
return applianceSrc || applianceIcons[ApplianceNames.shape];
|
7385
|
+
}
|
7386
|
+
isCustomIcon() {
|
7387
|
+
var _a;
|
7388
|
+
if (!this.member)
|
7389
|
+
return false;
|
7390
|
+
const { memberApplianceName, memberColorHex } = this;
|
7391
|
+
const { userApplianceIcons } = this.cursorManager;
|
7392
|
+
let iconsKey = this.memberApplianceName;
|
7393
|
+
if (iconsKey === ApplianceNames.pencilEraser) {
|
7394
|
+
iconsKey = `${iconsKey}${((_a = this.member) == null ? void 0 : _a.memberState.pencilEraserSize) || 1}`;
|
7395
|
+
}
|
7396
|
+
const userApplianceSrc = iconsKey && userApplianceIcons[iconsKey];
|
7397
|
+
if (userApplianceSrc)
|
7398
|
+
return false;
|
7399
|
+
if (this.style === "custom" && memberApplianceName) {
|
7400
|
+
const customApplianceSrc = remoteIcon(memberApplianceName, memberColorHex);
|
7401
|
+
if (customApplianceSrc)
|
7402
|
+
return true;
|
7262
7403
|
}
|
7404
|
+
return false;
|
7263
7405
|
}
|
7264
7406
|
updateMember() {
|
7265
7407
|
this.member = findMemberByUid(this.manager.room, this.memberId);
|
@@ -7306,15 +7448,18 @@ const ApplianceMap = {
|
|
7306
7448
|
["pencilEraser2"]: pencilEraser2,
|
7307
7449
|
["pencilEraser3"]: pencilEraser3
|
7308
7450
|
};
|
7451
|
+
const LocalCursorSideEffectId = "local-cursor";
|
7309
7452
|
class CursorManager {
|
7310
|
-
constructor(manager, enableCursor, applianceIcons) {
|
7453
|
+
constructor(manager, enableCursor, cursorOptions, applianceIcons) {
|
7311
7454
|
var _a;
|
7312
7455
|
this.manager = manager;
|
7313
7456
|
this.enableCursor = enableCursor;
|
7314
7457
|
this.cursorInstances = /* @__PURE__ */ new Map();
|
7458
|
+
this.userApplianceIcons = {};
|
7315
7459
|
this.sideEffectManager = new SideEffectManager$1();
|
7316
7460
|
this.store = this.manager.store;
|
7317
|
-
this.
|
7461
|
+
this.leaveFlag = true;
|
7462
|
+
this._style = "default";
|
7318
7463
|
this.onCursorMove = (payload) => {
|
7319
7464
|
const cursorInstance = this.initCursorInstance(payload.uid);
|
7320
7465
|
if (payload.state === CursorState.Leave) {
|
@@ -7347,7 +7492,18 @@ class CursorManager {
|
|
7347
7492
|
const now2 = Date.now();
|
7348
7493
|
if (now2 - this.mouseMoveTimer > 48) {
|
7349
7494
|
this.mouseMoveTimer = now2;
|
7495
|
+
if (WindowManager.supportTeachingAidsPlugin && isRoom(WindowManager.displayer) && WindowManager.displayer.disableDeviceInputs) {
|
7496
|
+
if (this.leaveFlag) {
|
7497
|
+
this.manager.dispatchInternalEvent(Events.CursorMove, {
|
7498
|
+
uid: this.manager.uid,
|
7499
|
+
state: CursorState.Leave
|
7500
|
+
});
|
7501
|
+
this.leaveFlag = false;
|
7502
|
+
}
|
7503
|
+
return;
|
7504
|
+
}
|
7350
7505
|
this.mouseMoveListener_(event, isTouch);
|
7506
|
+
this.leaveFlag = true;
|
7351
7507
|
}
|
7352
7508
|
};
|
7353
7509
|
this.mouseLeaveListener = () => {
|
@@ -7391,9 +7547,43 @@ class CursorManager {
|
|
7391
7547
|
this.sideEffectManager.add(() => {
|
7392
7548
|
return internalEmitter.on("playgroundSizeChange", () => this.updateContainerRect());
|
7393
7549
|
});
|
7550
|
+
const room = this.manager.room;
|
7551
|
+
if (room) {
|
7552
|
+
this.sideEffectManager.add(() => {
|
7553
|
+
const update2 = (state) => {
|
7554
|
+
if (this.style === "custom" && state.memberState)
|
7555
|
+
this.enableCustomCursor();
|
7556
|
+
};
|
7557
|
+
room.callbacks.on("onRoomStateChanged", update2);
|
7558
|
+
return () => room.callbacks.off("onRoomStateChanged", update2);
|
7559
|
+
});
|
7560
|
+
}
|
7394
7561
|
if (applianceIcons) {
|
7395
|
-
this.
|
7562
|
+
this.userApplianceIcons = applianceIcons;
|
7396
7563
|
}
|
7564
|
+
this.style = (cursorOptions == null ? void 0 : cursorOptions.style) || "default";
|
7565
|
+
}
|
7566
|
+
get applianceIcons() {
|
7567
|
+
return __spreadValues(__spreadValues({}, ApplianceMap), this.userApplianceIcons);
|
7568
|
+
}
|
7569
|
+
get style() {
|
7570
|
+
return this._style;
|
7571
|
+
}
|
7572
|
+
set style(value) {
|
7573
|
+
if (this._style !== value) {
|
7574
|
+
this._style = value;
|
7575
|
+
this.cursorInstances.forEach((cursor) => {
|
7576
|
+
cursor.setStyle(value);
|
7577
|
+
});
|
7578
|
+
if (value === "custom") {
|
7579
|
+
this.enableCustomCursor();
|
7580
|
+
} else {
|
7581
|
+
this.sideEffectManager.flush(LocalCursorSideEffectId);
|
7582
|
+
}
|
7583
|
+
}
|
7584
|
+
}
|
7585
|
+
enableCustomCursor() {
|
7586
|
+
this.sideEffectManager.add(() => enableLocal(this.manager.getMemberState()), LocalCursorSideEffectId);
|
7397
7587
|
}
|
7398
7588
|
canMoveCursor(member) {
|
7399
7589
|
const isLaserPointer = (member == null ? void 0 : member.memberState.currentApplianceName) === ApplianceNames.laserPointer;
|
@@ -18236,7 +18426,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
18236
18426
|
const _WindowManager = class extends InvisiblePlugin {
|
18237
18427
|
constructor(context) {
|
18238
18428
|
super(context);
|
18239
|
-
this.version = "0.4.
|
18429
|
+
this.version = "0.4.71";
|
18240
18430
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.2.28", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^0.1.5", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.17", "@netless/app-media-player": "0.1.0-beta.6", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "jspdf": "^2.5.1", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.43" } };
|
18241
18431
|
this.emitter = callbacks$1;
|
18242
18432
|
this.viewMode = ViewMode.Broadcaster;
|
@@ -18248,6 +18438,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18248
18438
|
static async mount(params) {
|
18249
18439
|
const room = params.room;
|
18250
18440
|
_WindowManager.container = params.container;
|
18441
|
+
_WindowManager.supportTeachingAidsPlugin = params.supportTeachingAidsPlugin;
|
18251
18442
|
const containerSizeRatio = params.containerSizeRatio;
|
18252
18443
|
const debug2 = params.debug;
|
18253
18444
|
const cursor = params.cursor;
|
@@ -18296,7 +18487,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18296
18487
|
manager.appManager = new AppManager(manager);
|
18297
18488
|
manager.appManager.polling = params.polling || false;
|
18298
18489
|
manager._pageState = new PageStateImpl(manager.appManager);
|
18299
|
-
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
18490
|
+
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.cursorOptions, params.applianceIcons);
|
18300
18491
|
if (containerSizeRatio) {
|
18301
18492
|
manager.containerSizeRatio = containerSizeRatio;
|
18302
18493
|
}
|
@@ -18336,11 +18527,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18336
18527
|
return manager;
|
18337
18528
|
}
|
18338
18529
|
static initContainer(manager, container, params) {
|
18339
|
-
const {
|
18340
|
-
chessboard,
|
18341
|
-
overwriteStyles,
|
18342
|
-
fullscreen
|
18343
|
-
} = params;
|
18530
|
+
const { chessboard, overwriteStyles, fullscreen } = params;
|
18344
18531
|
if (!_WindowManager.container) {
|
18345
18532
|
_WindowManager.container = container;
|
18346
18533
|
}
|
@@ -18718,6 +18905,16 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
18718
18905
|
this.appManager.polling = b;
|
18719
18906
|
}
|
18720
18907
|
}
|
18908
|
+
get cursorStyle() {
|
18909
|
+
var _a;
|
18910
|
+
return ((_a = this.cursorManager) == null ? void 0 : _a.style) || "default";
|
18911
|
+
}
|
18912
|
+
set cursorStyle(value) {
|
18913
|
+
if (!this.cursorManager) {
|
18914
|
+
throw new Error("[WindowManager]: cursor is not enabled, please set { cursor: true }.");
|
18915
|
+
}
|
18916
|
+
this.cursorManager.style = value;
|
18917
|
+
}
|
18721
18918
|
get mainViewSceneIndex() {
|
18722
18919
|
var _a;
|
18723
18920
|
return ((_a = this._pageState) == null ? void 0 : _a.index) || 0;
|