dsh-plugin-live2d-stage 0.5.1 → 0.5.2
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/README.md +33 -59
- package/assets/floating.html +1 -1
- package/assets/floating.js +16 -16
- package/lib/client.js +42 -3
- package/lib/floating.mjs +1 -1
- package/lib/native/Live2DFloating.exe +0 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -18207,6 +18207,7 @@ var init_platform_live2dmanager = __esm({
|
|
|
18207
18207
|
this._watermarkPlan
|
|
18208
18208
|
);
|
|
18209
18209
|
}
|
|
18210
|
+
if (cubismModel) cubismModel.update();
|
|
18210
18211
|
model.draw(projection);
|
|
18211
18212
|
if (portrait && cubismModel) {
|
|
18212
18213
|
const head = ActiveCharacter?.hitAreas.find((area) => /head|face|头|脸/i.test(area.name));
|
|
@@ -19796,6 +19797,9 @@ var init_PlatformDelegate = __esm({
|
|
|
19796
19797
|
getParameterValue(paramId) {
|
|
19797
19798
|
return this.subdelegate?.getLive2DManager().getParameterValue(paramId) ?? 0;
|
|
19798
19799
|
}
|
|
19800
|
+
setLookTarget(x, y) {
|
|
19801
|
+
this.subdelegate?.getLive2DManager().setLookTarget(x, y);
|
|
19802
|
+
}
|
|
19799
19803
|
setParameterValue(paramId, value) {
|
|
19800
19804
|
this.subdelegate?.getLive2DManager().setParameterValue(paramId, value);
|
|
19801
19805
|
}
|
|
@@ -20155,6 +20159,41 @@ function Player({ character, onStatus }) {
|
|
|
20155
20159
|
watch();
|
|
20156
20160
|
return () => media.removeEventListener("change", changed);
|
|
20157
20161
|
}, []);
|
|
20162
|
+
(0, import_react5.useEffect)(() => {
|
|
20163
|
+
let pointer = null;
|
|
20164
|
+
const move = (e) => {
|
|
20165
|
+
if (e.pointerType === "mouse") pointer = { x: e.clientX, y: e.clientY };
|
|
20166
|
+
};
|
|
20167
|
+
const leave = (e) => {
|
|
20168
|
+
if (!e.relatedTarget) pointer = null;
|
|
20169
|
+
};
|
|
20170
|
+
const clear = () => {
|
|
20171
|
+
pointer = null;
|
|
20172
|
+
};
|
|
20173
|
+
const native = (e) => {
|
|
20174
|
+
const d = e.data;
|
|
20175
|
+
if (d?.type === "live2d-pointer" && Number.isFinite(d.x) && Number.isFinite(d.y)) pointer = { x: d.x, y: d.y };
|
|
20176
|
+
};
|
|
20177
|
+
const webview = window.chrome?.webview;
|
|
20178
|
+
window.addEventListener("pointermove", move, true);
|
|
20179
|
+
window.addEventListener("mouseout", leave);
|
|
20180
|
+
window.addEventListener("blur", clear);
|
|
20181
|
+
webview?.addEventListener?.("message", native);
|
|
20182
|
+
const timer = window.setInterval(() => {
|
|
20183
|
+
if (!pointer || document.hidden) return;
|
|
20184
|
+
const canvas = document.querySelector(".l2ds canvas");
|
|
20185
|
+
const rect = canvas?.getBoundingClientRect();
|
|
20186
|
+
if (!rect?.width || !rect.height) return;
|
|
20187
|
+
PlatformDelegate.getInstance().setLookTarget((pointer.x - rect.left - rect.width / 2) / (rect.width / 2), (rect.top + rect.height / 2 - pointer.y) / (rect.height / 2));
|
|
20188
|
+
}, 50);
|
|
20189
|
+
return () => {
|
|
20190
|
+
clearInterval(timer);
|
|
20191
|
+
window.removeEventListener("pointermove", move, true);
|
|
20192
|
+
window.removeEventListener("mouseout", leave);
|
|
20193
|
+
window.removeEventListener("blur", clear);
|
|
20194
|
+
webview?.removeEventListener?.("message", native);
|
|
20195
|
+
};
|
|
20196
|
+
}, [character.id]);
|
|
20158
20197
|
const model = (0, import_react5.useMemo)(() => {
|
|
20159
20198
|
const split = character.modelPath.lastIndexOf("/"), dir = split < 0 ? "" : character.modelPath.slice(0, split + 1);
|
|
20160
20199
|
const refs = character.model.FileReferences;
|
|
@@ -20697,7 +20736,7 @@ function Settings({ store, close }) {
|
|
|
20697
20736
|
async function preview(actionId) {
|
|
20698
20737
|
setError("");
|
|
20699
20738
|
if (state.preferences?.visible === false && !state.preferences?.desktopFloating) {
|
|
20700
|
-
setError("\u8BF7\u5148\u542F\u7528\u684C\u9762\
|
|
20739
|
+
setError("\u8BF7\u5148\u542F\u7528\u300CHarness \u5185\u4F7F\u7528\u300D\u6216\u300C\u684C\u9762\u60AC\u6D6E\u300D\uFF0C\u7B49\u5F85\u6A21\u578B\u5C31\u7EEA\u540E\u518D\u8BD5\u64AD\u3002");
|
|
20701
20740
|
return;
|
|
20702
20741
|
}
|
|
20703
20742
|
try {
|
|
@@ -20717,7 +20756,7 @@ function Settings({ store, close }) {
|
|
|
20717
20756
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "l2ds-muted", children: "\u914D\u7F6E\u89D2\u8272\u6A21\u578B\u4E0E\u6F14\u51FA\u52A8\u4F5C\uFF0C\u8BA9 Agent \u6839\u636E\u5F53\u524D\u89D2\u8272\u9009\u62E9\u52A8\u4F5C\u3002" }),
|
|
20718
20757
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "l2ds-config-card l2ds-toggle", children: [
|
|
20719
20758
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
20720
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "\
|
|
20759
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Harness \u5185\u4F7F\u7528" }),
|
|
20721
20760
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "l2ds-muted", children: "\u4EC5\u663E\u793A\u89D2\u8272\u3002\u62D6\u62FD\u79FB\u52A8\u753B\u5E03\uFF0C\u53CC\u51FB\u540E\u5206\u522B\u8C03\u6574\u753B\u5E03\u548C\u4EBA\u7269\u7684\u5927\u5C0F\u3001\u4F4D\u7F6E\u3002" })
|
|
20722
20761
|
] }),
|
|
20723
20762
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
@@ -20796,7 +20835,7 @@ function Settings({ store, close }) {
|
|
|
20796
20835
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "l2ds-save", "aria-live": "polite", children: busy ? "\u6B63\u5728\u4FDD\u5B58\u2026" : saved }),
|
|
20797
20836
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "l2ds-config-card", children: [
|
|
20798
20837
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Agent \u6F14\u51FA\u80FD\u529B" }),
|
|
20799
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "l2ds-muted", children: "\u52A8\u4F5C\u63A7\u5236\u9ED8\u8BA4\u5173\u95ED\uFF1B\u5F00\u542F\u540E\u624D\u5411 Agent \u63D0\u4F9B\u6F14\u51FA\u5DE5\u5177\u4E0E\u9009\u62E9\u8BF4\u660E\
|
|
20838
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "l2ds-muted", children: "\u52A8\u4F5C\u63A7\u5236\u9ED8\u8BA4\u5173\u95ED\uFF1B\u5F00\u542F\u540E\u624D\u5411 Agent \u63D0\u4F9B\u6F14\u51FA\u5DE5\u5177\u4E0E\u9009\u62E9\u8BF4\u660E\u3002Harness \u5185\u7684\u89D2\u8272\u6216\u684C\u9762\u60AC\u6D6E\u89D2\u8272\u5C31\u7EEA\u540E\u5747\u53EF\u64AD\u653E\uFF1B\u6CA1\u6709\u5408\u9002\u52A8\u4F5C\u65F6\u7EE7\u7EED\u6B63\u5E38\u56DE\u590D\u3002" })
|
|
20800
20839
|
] })
|
|
20801
20840
|
] });
|
|
20802
20841
|
}
|
package/lib/floating.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export class FloatingController {
|
|
|
18
18
|
child.stderr.on('data',()=>{});child.on('error',error=>{if(this.child===child){this.child=null;this.token='';}finish(error);});
|
|
19
19
|
child.on('exit',()=>{lines.close();if(this.child===child){this.child=null;this.token='';this.status='closed';this.onClose();}finish(new Error(this.error||'桌面悬浮窗口已关闭'));});
|
|
20
20
|
child.stdin.on('error',()=>{});
|
|
21
|
-
child.stdin.write(JSON.stringify({url:this.origin+'/live2d-stage/assets/floating.html?launch='+randomBytes(12).toString('hex'),token:this.token,profile:this.profile,parentPid:process.pid,...testOptions})+'\n');
|
|
21
|
+
child.stdin.write(JSON.stringify({url:this.origin+'/live2d-stage/assets/floating.html?launch='+randomBytes(12).toString('hex'),token:this.token,profile:this.profile,parentPid:process.pid,...testOptions})+'\n','utf8');
|
|
22
22
|
}).finally(()=>{this.pending=null;});return this.pending;
|
|
23
23
|
}
|
|
24
24
|
async stop(){const child=this.child;if(!child)return;this.child=null;this.token='';this.status='closed';await new Promise(resolveStop=>{const timer=setTimeout(()=>{child.kill();resolveStop();},4000);child.once('exit',()=>{clearTimeout(timer);resolveStop();});child.stdin.end();});}
|
|
Binary file
|