poi-plugin-kca-next 1.0.2 → 1.0.3
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.js +211 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10102,6 +10102,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10102
10102
|
const payload = JSON.stringify({
|
|
10103
10103
|
visible: Boolean(config.visible),
|
|
10104
10104
|
pickMode: Boolean(config.pickMode),
|
|
10105
|
+
pickToken: String(config.pickToken ?? ""),
|
|
10105
10106
|
pickLabel: String(config.pickLabel ?? ""),
|
|
10106
10107
|
markers: (config.markers ?? []).filter((m) => m && Number.isFinite(m.x) && Number.isFinite(m.y) && (m.x > 0 || m.y > 0)).map((m) => ({
|
|
10107
10108
|
id: String(m.id),
|
|
@@ -10128,21 +10129,35 @@ function buildCoordOverlayScript(config) {
|
|
|
10128
10129
|
};
|
|
10129
10130
|
|
|
10130
10131
|
let ctl = window[KEY];
|
|
10132
|
+
if (!cfg.visible && !cfg.pickMode) {
|
|
10133
|
+
if (ctl && typeof ctl.teardown === 'function') ctl.teardown();
|
|
10134
|
+
const stray = document.getElementById(DOM_ID);
|
|
10135
|
+
if (stray && stray.parentNode) stray.parentNode.removeChild(stray);
|
|
10136
|
+
return { active: false, pickMode: false, pickToken: '', hover: null, picked: null, cancelledToken: '' };
|
|
10137
|
+
}
|
|
10138
|
+
|
|
10139
|
+
if (!findGameCanvas()) {
|
|
10140
|
+
return null;
|
|
10141
|
+
}
|
|
10142
|
+
|
|
10131
10143
|
if (!ctl) {
|
|
10132
10144
|
ctl = {
|
|
10133
10145
|
active: false,
|
|
10134
10146
|
pickMode: false,
|
|
10147
|
+
pickToken: '',
|
|
10135
10148
|
pickLabel: '',
|
|
10136
10149
|
markers: [],
|
|
10137
10150
|
hover: null,
|
|
10138
10151
|
picked: null,
|
|
10139
|
-
|
|
10140
|
-
cancelledSeq: 0,
|
|
10152
|
+
cancelledToken: '',
|
|
10141
10153
|
swallowingUntil: 0,
|
|
10142
10154
|
swallowTimer: null,
|
|
10155
|
+
teardownTimer: null,
|
|
10143
10156
|
root: null,
|
|
10144
10157
|
hud: null,
|
|
10145
10158
|
banner: null,
|
|
10159
|
+
bannerText: null,
|
|
10160
|
+
bannerCancel: null,
|
|
10146
10161
|
crossX: null,
|
|
10147
10162
|
crossY: null,
|
|
10148
10163
|
cursorTag: null,
|
|
@@ -10151,6 +10166,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10151
10166
|
renderPins: null,
|
|
10152
10167
|
applyMode: null,
|
|
10153
10168
|
teardown: null,
|
|
10169
|
+
getStatus: null,
|
|
10154
10170
|
};
|
|
10155
10171
|
|
|
10156
10172
|
const root = document.createElement('div');
|
|
@@ -10198,18 +10214,36 @@ function buildCoordOverlayScript(config) {
|
|
|
10198
10214
|
'left:50%',
|
|
10199
10215
|
'top:8px',
|
|
10200
10216
|
'transform:translateX(-50%)',
|
|
10201
|
-
'padding:
|
|
10217
|
+
'padding:4px 10px',
|
|
10202
10218
|
'border-radius:6px',
|
|
10203
|
-
'background:rgba(30,58,138,0.
|
|
10219
|
+
'background:rgba(30,58,138,0.94)',
|
|
10204
10220
|
'border:1px solid rgba(96,165,250,0.95)',
|
|
10205
10221
|
'color:#ffffff',
|
|
10206
10222
|
'font-size:12px',
|
|
10207
10223
|
'font-weight:700',
|
|
10208
10224
|
'box-shadow:0 2px 10px rgba(0,0,0,0.55)',
|
|
10209
|
-
'pointer-events:none',
|
|
10210
10225
|
'display:none',
|
|
10226
|
+
'align-items:center',
|
|
10227
|
+
'gap:8px',
|
|
10211
10228
|
'white-space:nowrap',
|
|
10229
|
+
'pointer-events:auto',
|
|
10212
10230
|
].join(';');
|
|
10231
|
+
const bannerText = document.createElement('span');
|
|
10232
|
+
const bannerCancel = document.createElement('button');
|
|
10233
|
+
bannerCancel.type = 'button';
|
|
10234
|
+
bannerCancel.textContent = '\u2715 \u53D6\u6D88';
|
|
10235
|
+
bannerCancel.style.cssText = [
|
|
10236
|
+
'border:1px solid rgba(248,113,113,0.9)',
|
|
10237
|
+
'background:rgba(153,27,27,0.92)',
|
|
10238
|
+
'color:#ffffff',
|
|
10239
|
+
'border-radius:4px',
|
|
10240
|
+
'padding:1px 7px',
|
|
10241
|
+
'font-size:11px',
|
|
10242
|
+
'font-weight:700',
|
|
10243
|
+
'cursor:pointer',
|
|
10244
|
+
].join(';');
|
|
10245
|
+
banner.appendChild(bannerText);
|
|
10246
|
+
banner.appendChild(bannerCancel);
|
|
10213
10247
|
|
|
10214
10248
|
const cursorTag = document.createElement('div');
|
|
10215
10249
|
cursorTag.style.cssText = [
|
|
@@ -10239,6 +10273,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10239
10273
|
ctl.root = root;
|
|
10240
10274
|
ctl.hud = hud;
|
|
10241
10275
|
ctl.banner = banner;
|
|
10276
|
+
ctl.bannerText = bannerText;
|
|
10277
|
+
ctl.bannerCancel = bannerCancel;
|
|
10242
10278
|
ctl.crossX = crossX;
|
|
10243
10279
|
ctl.crossY = crossY;
|
|
10244
10280
|
ctl.cursorTag = cursorTag;
|
|
@@ -10260,12 +10296,16 @@ function buildCoordOverlayScript(config) {
|
|
|
10260
10296
|
};
|
|
10261
10297
|
ctl.syncRect = syncRect;
|
|
10262
10298
|
|
|
10263
|
-
const mapPointer = (e) => {
|
|
10299
|
+
const mapPointer = (e, clampInside) => {
|
|
10264
10300
|
const r = syncRect();
|
|
10265
10301
|
if (!r || r.width <= 0 || r.height <= 0) return null;
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
if (relX < 0 || relY < 0 || relX > r.width || relY > r.height)
|
|
10302
|
+
let relX = e.clientX - r.left;
|
|
10303
|
+
let relY = e.clientY - r.top;
|
|
10304
|
+
if (!clampInside && (relX < 0 || relY < 0 || relX > r.width || relY > r.height)) {
|
|
10305
|
+
return null;
|
|
10306
|
+
}
|
|
10307
|
+
relX = Math.max(0, Math.min(r.width, relX));
|
|
10308
|
+
relY = Math.max(0, Math.min(r.height, relY));
|
|
10269
10309
|
const x = Math.max(0, Math.min(W, Math.round((relX / r.width) * W)));
|
|
10270
10310
|
const y = Math.max(0, Math.min(H, Math.round((relY / r.height) * H)));
|
|
10271
10311
|
return { x, y, relX, relY, r };
|
|
@@ -10332,6 +10372,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10332
10372
|
|
|
10333
10373
|
const applyMode = () => {
|
|
10334
10374
|
syncRect();
|
|
10375
|
+
hud.style.display = 'block';
|
|
10376
|
+
pinsLayer.style.display = 'block';
|
|
10335
10377
|
if (ctl.pickMode) {
|
|
10336
10378
|
if (ctl.swallowTimer) {
|
|
10337
10379
|
clearTimeout(ctl.swallowTimer);
|
|
@@ -10343,8 +10385,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10343
10385
|
root.style.outline = '2px solid rgba(56,189,248,0.9)';
|
|
10344
10386
|
root.style.outlineOffset = '-2px';
|
|
10345
10387
|
root.style.background = 'rgba(15,23,42,0.10)';
|
|
10346
|
-
banner.style.display = '
|
|
10347
|
-
|
|
10388
|
+
banner.style.display = 'flex';
|
|
10389
|
+
bannerText.textContent = '\u{1F3AF} \u53D6\u70B9 [' + (ctl.pickLabel || '\u5750\u6807') + ']\uFF1A\u5DE6\u952E\u70B9\u51FB\u76EE\u6807\u70B9\u586B\u5165\uFF0C\u53F3\u952E\u6216 Esc \u53D6\u6D88';
|
|
10348
10390
|
} else {
|
|
10349
10391
|
const keepShield = ctl.swallowingUntil > Date.now();
|
|
10350
10392
|
root.style.pointerEvents = keepShield ? 'auto' : 'none';
|
|
@@ -10367,7 +10409,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10367
10409
|
|
|
10368
10410
|
const onPointerMove = (e) => {
|
|
10369
10411
|
if (!ctl.active) return;
|
|
10370
|
-
const pt = mapPointer(e);
|
|
10412
|
+
const pt = mapPointer(e, false);
|
|
10371
10413
|
if (!pt) {
|
|
10372
10414
|
crossX.style.display = 'none';
|
|
10373
10415
|
crossY.style.display = 'none';
|
|
@@ -10399,45 +10441,51 @@ function buildCoordOverlayScript(config) {
|
|
|
10399
10441
|
|
|
10400
10442
|
const finishPickWithShield = () => {
|
|
10401
10443
|
ctl.pickMode = false;
|
|
10402
|
-
ctl.swallowingUntil = Date.now() +
|
|
10444
|
+
ctl.swallowingUntil = Date.now() + 260;
|
|
10403
10445
|
applyMode();
|
|
10404
10446
|
};
|
|
10405
10447
|
|
|
10448
|
+
const cancelCurrentPick = (e) => {
|
|
10449
|
+
if (e) swallowEvent(e);
|
|
10450
|
+
if (!ctl.pickMode) return;
|
|
10451
|
+
ctl.cancelledToken = ctl.pickToken || ('cancel-' + Date.now());
|
|
10452
|
+
finishPickWithShield();
|
|
10453
|
+
};
|
|
10454
|
+
|
|
10406
10455
|
const onPickDown = (e) => {
|
|
10407
10456
|
if (!ctl.pickMode) {
|
|
10408
10457
|
swallowEvent(e);
|
|
10409
10458
|
return;
|
|
10410
10459
|
}
|
|
10460
|
+
if (e.target === bannerCancel || bannerCancel.contains(e.target)) {
|
|
10461
|
+
cancelCurrentPick(e);
|
|
10462
|
+
return;
|
|
10463
|
+
}
|
|
10411
10464
|
swallowEvent(e);
|
|
10412
10465
|
if (e.button === 2) {
|
|
10413
|
-
|
|
10414
|
-
finishPickWithShield();
|
|
10466
|
+
cancelCurrentPick();
|
|
10415
10467
|
return;
|
|
10416
10468
|
}
|
|
10417
10469
|
if (e.button !== 0) return;
|
|
10418
|
-
const pt = mapPointer(e);
|
|
10470
|
+
const pt = mapPointer(e, true);
|
|
10419
10471
|
if (!pt) return;
|
|
10420
|
-
ctl.
|
|
10421
|
-
ctl.picked = { x: pt.x, y: pt.y, seq: ctl.pickSeq };
|
|
10472
|
+
ctl.picked = { x: pt.x, y: pt.y, token: ctl.pickToken || ('pick-' + Date.now()) };
|
|
10422
10473
|
finishPickWithShield();
|
|
10423
10474
|
};
|
|
10424
10475
|
|
|
10425
10476
|
const onContextMenu = (e) => {
|
|
10426
10477
|
if (!ctl.pickMode && ctl.swallowingUntil <= Date.now()) return;
|
|
10427
|
-
swallowEvent(e);
|
|
10428
10478
|
if (ctl.pickMode) {
|
|
10429
|
-
|
|
10430
|
-
|
|
10479
|
+
cancelCurrentPick(e);
|
|
10480
|
+
} else {
|
|
10481
|
+
swallowEvent(e);
|
|
10431
10482
|
}
|
|
10432
10483
|
};
|
|
10433
10484
|
|
|
10434
10485
|
const onKeyDown = (e) => {
|
|
10435
10486
|
if (!ctl.pickMode) return;
|
|
10436
10487
|
if (e.key === 'Escape') {
|
|
10437
|
-
|
|
10438
|
-
ctl.pickMode = false;
|
|
10439
|
-
ctl.cancelledSeq++;
|
|
10440
|
-
applyMode();
|
|
10488
|
+
cancelCurrentPick(e);
|
|
10441
10489
|
}
|
|
10442
10490
|
};
|
|
10443
10491
|
|
|
@@ -10463,6 +10511,10 @@ function buildCoordOverlayScript(config) {
|
|
|
10463
10511
|
clearTimeout(ctl.swallowTimer);
|
|
10464
10512
|
ctl.swallowTimer = null;
|
|
10465
10513
|
}
|
|
10514
|
+
if (ctl.teardownTimer) {
|
|
10515
|
+
clearTimeout(ctl.teardownTimer);
|
|
10516
|
+
ctl.teardownTimer = null;
|
|
10517
|
+
}
|
|
10466
10518
|
window.removeEventListener('pointermove', onPointerMove, true);
|
|
10467
10519
|
window.removeEventListener('mousemove', onPointerMove, true);
|
|
10468
10520
|
window.removeEventListener('keydown', onKeyDown, true);
|
|
@@ -10479,21 +10531,19 @@ function buildCoordOverlayScript(config) {
|
|
|
10479
10531
|
ctl.getStatus = () => ({
|
|
10480
10532
|
active: Boolean(ctl.active),
|
|
10481
10533
|
pickMode: Boolean(ctl.pickMode),
|
|
10534
|
+
pickToken: String(ctl.pickToken || ''),
|
|
10482
10535
|
hover: ctl.hover,
|
|
10483
10536
|
picked: ctl.picked,
|
|
10484
|
-
|
|
10537
|
+
cancelledToken: String(ctl.cancelledToken || ''),
|
|
10485
10538
|
});
|
|
10486
10539
|
|
|
10487
10540
|
window[KEY] = ctl;
|
|
10488
10541
|
}
|
|
10489
10542
|
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
if (!findGameCanvas()) {
|
|
10496
|
-
return null;
|
|
10543
|
+
// Cancel any deferred teardown from a previous pick before re-activating!
|
|
10544
|
+
if (ctl.teardownTimer) {
|
|
10545
|
+
clearTimeout(ctl.teardownTimer);
|
|
10546
|
+
ctl.teardownTimer = null;
|
|
10497
10547
|
}
|
|
10498
10548
|
|
|
10499
10549
|
if (!document.getElementById(DOM_ID)) {
|
|
@@ -10502,6 +10552,13 @@ function buildCoordOverlayScript(config) {
|
|
|
10502
10552
|
|
|
10503
10553
|
ctl.active = true;
|
|
10504
10554
|
ctl.pickMode = Boolean(cfg.pickMode);
|
|
10555
|
+
if (cfg.pickMode && cfg.pickToken) {
|
|
10556
|
+
ctl.pickToken = cfg.pickToken;
|
|
10557
|
+
if (ctl.picked && ctl.picked.token !== cfg.pickToken) ctl.picked = null;
|
|
10558
|
+
if (ctl.cancelledToken === cfg.pickToken) ctl.cancelledToken = '';
|
|
10559
|
+
} else if (!cfg.pickMode) {
|
|
10560
|
+
ctl.pickToken = '';
|
|
10561
|
+
}
|
|
10505
10562
|
ctl.pickLabel = cfg.pickLabel;
|
|
10506
10563
|
ctl.markers = cfg.markers;
|
|
10507
10564
|
ctl.renderPins();
|
|
@@ -10517,7 +10574,7 @@ function buildPollCoordOverlayScript() {
|
|
|
10517
10574
|
try {
|
|
10518
10575
|
const ctl = window.__kcaNextCoordOverlayV1;
|
|
10519
10576
|
if (!ctl || typeof ctl.getStatus !== 'function') {
|
|
10520
|
-
return
|
|
10577
|
+
return null;
|
|
10521
10578
|
}
|
|
10522
10579
|
return ctl.getStatus();
|
|
10523
10580
|
} catch {
|
|
@@ -10528,18 +10585,22 @@ function buildPollCoordOverlayScript() {
|
|
|
10528
10585
|
function buildRemoveCoordOverlayScript() {
|
|
10529
10586
|
return `(() => {
|
|
10530
10587
|
try {
|
|
10588
|
+
let removed = false;
|
|
10531
10589
|
const ctl = window.__kcaNextCoordOverlayV1;
|
|
10532
10590
|
if (ctl && typeof ctl.teardown === 'function') {
|
|
10591
|
+
removed = true;
|
|
10533
10592
|
const remain = (ctl.swallowingUntil || 0) - Date.now();
|
|
10534
10593
|
if (remain > 0) {
|
|
10535
10594
|
ctl.pickMode = false;
|
|
10595
|
+
ctl.pickToken = '';
|
|
10536
10596
|
if (ctl.banner) ctl.banner.style.display = 'none';
|
|
10537
10597
|
if (ctl.hud) ctl.hud.style.display = 'none';
|
|
10538
10598
|
if (ctl.pinsLayer) ctl.pinsLayer.style.display = 'none';
|
|
10539
10599
|
if (ctl.crossX) ctl.crossX.style.display = 'none';
|
|
10540
10600
|
if (ctl.crossY) ctl.crossY.style.display = 'none';
|
|
10541
10601
|
if (ctl.cursorTag) ctl.cursorTag.style.display = 'none';
|
|
10542
|
-
|
|
10602
|
+
if (ctl.teardownTimer) clearTimeout(ctl.teardownTimer);
|
|
10603
|
+
ctl.teardownTimer = setTimeout(() => {
|
|
10543
10604
|
try {
|
|
10544
10605
|
const cur = window.__kcaNextCoordOverlayV1;
|
|
10545
10606
|
if (cur && !cur.pickMode && typeof cur.teardown === 'function') cur.teardown();
|
|
@@ -10550,8 +10611,11 @@ function buildRemoveCoordOverlayScript() {
|
|
|
10550
10611
|
ctl.teardown();
|
|
10551
10612
|
}
|
|
10552
10613
|
const el = document.getElementById('__kca_next_coord_overlay__');
|
|
10553
|
-
if (el && el.parentNode)
|
|
10554
|
-
|
|
10614
|
+
if (el && el.parentNode) {
|
|
10615
|
+
el.parentNode.removeChild(el);
|
|
10616
|
+
removed = true;
|
|
10617
|
+
}
|
|
10618
|
+
return removed;
|
|
10555
10619
|
} catch {
|
|
10556
10620
|
return false;
|
|
10557
10621
|
}
|
|
@@ -12447,10 +12511,40 @@ var PoiGameBridge = class {
|
|
|
12447
12511
|
async inspectShipPicker() {
|
|
12448
12512
|
return this.runInKcs2Frame(buildNativeShipInspectorSource());
|
|
12449
12513
|
}
|
|
12514
|
+
async runInAllFrames(script, timeoutMs = 800) {
|
|
12515
|
+
const contents = this.getGameWebContents();
|
|
12516
|
+
if (!isContentsAlive(contents)) return;
|
|
12517
|
+
let frames = [];
|
|
12518
|
+
try {
|
|
12519
|
+
const root = contents.mainFrame;
|
|
12520
|
+
if (root) {
|
|
12521
|
+
frames = Array.from(root.framesInSubtree || [root]);
|
|
12522
|
+
}
|
|
12523
|
+
} catch {
|
|
12524
|
+
frames = [];
|
|
12525
|
+
}
|
|
12526
|
+
const targets = frames.length > 0 ? frames : [contents];
|
|
12527
|
+
await Promise.all(
|
|
12528
|
+
targets.slice(0, 12).map((frame) => {
|
|
12529
|
+
if (!frame || typeof frame.executeJavaScript !== "function") return Promise.resolve();
|
|
12530
|
+
return Promise.race([
|
|
12531
|
+
frame.executeJavaScript(script).catch(() => void 0),
|
|
12532
|
+
new Promise((r) => setTimeout(r, timeoutMs))
|
|
12533
|
+
]);
|
|
12534
|
+
})
|
|
12535
|
+
);
|
|
12536
|
+
}
|
|
12450
12537
|
async syncCoordOverlay(config) {
|
|
12451
12538
|
if (!config.visible && !config.pickMode) {
|
|
12452
|
-
await this.
|
|
12453
|
-
return {
|
|
12539
|
+
await this.runInAllFrames(buildRemoveCoordOverlayScript(), 800);
|
|
12540
|
+
return {
|
|
12541
|
+
active: false,
|
|
12542
|
+
pickMode: false,
|
|
12543
|
+
pickToken: "",
|
|
12544
|
+
hover: null,
|
|
12545
|
+
picked: null,
|
|
12546
|
+
cancelledToken: ""
|
|
12547
|
+
};
|
|
12454
12548
|
}
|
|
12455
12549
|
return this.runInKcs2Frame(buildCoordOverlayScript(config), 1200);
|
|
12456
12550
|
}
|
|
@@ -12478,7 +12572,7 @@ var PoiGameBridge = class {
|
|
|
12478
12572
|
}
|
|
12479
12573
|
}
|
|
12480
12574
|
dispose() {
|
|
12481
|
-
void this.
|
|
12575
|
+
void this.runInAllFrames(buildRemoveCoordOverlayScript(), 500).catch(() => void 0);
|
|
12482
12576
|
this.start2Cache.dispose();
|
|
12483
12577
|
this.releaseBackgroundLease();
|
|
12484
12578
|
if (typeof window !== "undefined") {
|
|
@@ -15537,10 +15631,23 @@ var CoordPickerPanel = ({
|
|
|
15537
15631
|
const [liveGameHover, setLiveGameHover] = (0, import_react8.useState)(null);
|
|
15538
15632
|
const [lastFeedback, setLastFeedback] = (0, import_react8.useState)("");
|
|
15539
15633
|
const canvasBoxRef = (0, import_react8.useRef)(null);
|
|
15540
|
-
const
|
|
15541
|
-
const
|
|
15634
|
+
const pickSeqCounterRef = (0, import_react8.useRef)(0);
|
|
15635
|
+
const consumedTokenRef = (0, import_react8.useRef)("");
|
|
15636
|
+
const activePickToken = (0, import_react8.useMemo)(() => {
|
|
15637
|
+
if (!livePickTargetId) return "";
|
|
15638
|
+
pickSeqCounterRef.current += 1;
|
|
15639
|
+
return `pick-${Date.now().toString(36)}-${pickSeqCounterRef.current}`;
|
|
15640
|
+
}, [livePickTargetId]);
|
|
15641
|
+
const activePickTokenRef = (0, import_react8.useRef)(activePickToken);
|
|
15642
|
+
activePickTokenRef.current = activePickToken;
|
|
15542
15643
|
const livePickTargetRef = (0, import_react8.useRef)(livePickTargetId);
|
|
15543
15644
|
livePickTargetRef.current = livePickTargetId;
|
|
15645
|
+
const targetsRef = (0, import_react8.useRef)(targets);
|
|
15646
|
+
targetsRef.current = targets;
|
|
15647
|
+
const onPickCoordRef = (0, import_react8.useRef)(onPickCoord);
|
|
15648
|
+
onPickCoordRef.current = onPickCoord;
|
|
15649
|
+
const onCancelLivePickRef = (0, import_react8.useRef)(onCancelLivePick);
|
|
15650
|
+
onCancelLivePickRef.current = onCancelLivePick;
|
|
15544
15651
|
const selectedTarget = targets.find((t) => t.id === selectedTargetId) ?? targets[0];
|
|
15545
15652
|
const livePickTarget = livePickTargetId ? targets.find((t) => t.id === livePickTargetId) ?? null : null;
|
|
15546
15653
|
const allMarkers = [
|
|
@@ -15557,16 +15664,37 @@ var CoordPickerPanel = ({
|
|
|
15557
15664
|
const advanceTarget = (0, import_react8.useCallback)(
|
|
15558
15665
|
(justPickedId) => {
|
|
15559
15666
|
if (!autoAdvance) return;
|
|
15560
|
-
const
|
|
15667
|
+
const curTargets = targetsRef.current;
|
|
15668
|
+
const idx = curTargets.findIndex((t) => t.id === justPickedId);
|
|
15561
15669
|
if (idx < 0) return;
|
|
15562
|
-
const cur =
|
|
15563
|
-
const next =
|
|
15670
|
+
const cur = curTargets[idx];
|
|
15671
|
+
const next = curTargets[idx + 1];
|
|
15564
15672
|
if (next && next.group === cur.group) {
|
|
15565
15673
|
onSelectTarget(next.id);
|
|
15566
15674
|
}
|
|
15567
15675
|
},
|
|
15568
|
-
[autoAdvance,
|
|
15676
|
+
[autoAdvance, onSelectTarget]
|
|
15569
15677
|
);
|
|
15678
|
+
const advanceTargetRef = (0, import_react8.useRef)(advanceTarget);
|
|
15679
|
+
advanceTargetRef.current = advanceTarget;
|
|
15680
|
+
(0, import_react8.useEffect)(() => {
|
|
15681
|
+
if (!lastFeedback) return;
|
|
15682
|
+
const timer = setTimeout(() => {
|
|
15683
|
+
setLastFeedback("");
|
|
15684
|
+
}, 4500);
|
|
15685
|
+
return () => clearTimeout(timer);
|
|
15686
|
+
}, [lastFeedback]);
|
|
15687
|
+
(0, import_react8.useEffect)(() => {
|
|
15688
|
+
if (!livePickTargetId || typeof window === "undefined") return;
|
|
15689
|
+
const onKeyDown = (e) => {
|
|
15690
|
+
if (e.key === "Escape") {
|
|
15691
|
+
setLastFeedback("\u5DF2\u53D6\u6D88\u6E38\u620F\u753B\u9762\u53D6\u70B9");
|
|
15692
|
+
onCancelLivePickRef.current();
|
|
15693
|
+
}
|
|
15694
|
+
};
|
|
15695
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
15696
|
+
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
15697
|
+
}, [livePickTargetId]);
|
|
15570
15698
|
const captureScreenshot = (0, import_react8.useCallback)(async () => {
|
|
15571
15699
|
const fn = coordinator.bridge.captureGameDataUrl;
|
|
15572
15700
|
if (typeof fn !== "function") {
|
|
@@ -15601,6 +15729,7 @@ var CoordPickerPanel = ({
|
|
|
15601
15729
|
void syncFn.call(coordinator.bridge, {
|
|
15602
15730
|
visible: active,
|
|
15603
15731
|
pickMode: Boolean(livePickTargetId),
|
|
15732
|
+
pickToken: activePickToken,
|
|
15604
15733
|
pickLabel: livePickTarget?.label ?? "",
|
|
15605
15734
|
markers: allMarkers
|
|
15606
15735
|
}).then((status) => {
|
|
@@ -15608,22 +15737,16 @@ var CoordPickerPanel = ({
|
|
|
15608
15737
|
if (!status) {
|
|
15609
15738
|
if (livePickTargetId) {
|
|
15610
15739
|
setCaptureError("\u672A\u80FD\u8FDE\u63A5\u5230\u6E38\u620F\u753B\u9762\uFF08\u8BF7\u786E\u8BA4\u6E38\u620F\u5DF2\u8FDB\u5165\u753B\u5E03\uFF09\uFF0C\u5DF2\u53EF\u6539\u7528\u300C\u{1F4F8} \u622A\u56FE\u53EF\u89C6\u5316\u9009\u70B9\u300D\u3002");
|
|
15611
|
-
|
|
15740
|
+
onCancelLivePickRef.current();
|
|
15612
15741
|
}
|
|
15613
15742
|
return;
|
|
15614
15743
|
}
|
|
15615
|
-
if (status.picked && status.picked.seq > lastPickSeqRef.current) {
|
|
15616
|
-
lastPickSeqRef.current = status.picked.seq;
|
|
15617
|
-
}
|
|
15618
|
-
if (status.cancelledSeq > lastCancelSeqRef.current) {
|
|
15619
|
-
lastCancelSeqRef.current = status.cancelledSeq;
|
|
15620
|
-
}
|
|
15621
15744
|
setLiveGameHover(status.hover);
|
|
15622
15745
|
}).catch(() => void 0);
|
|
15623
15746
|
return () => {
|
|
15624
15747
|
cancelled = true;
|
|
15625
15748
|
};
|
|
15626
|
-
}, [coordinator.bridge, gameHudVisible, livePickTargetId, livePickTarget?.label, markersKey]);
|
|
15749
|
+
}, [coordinator.bridge, gameHudVisible, livePickTargetId, activePickToken, livePickTarget?.label, markersKey]);
|
|
15627
15750
|
(0, import_react8.useEffect)(() => {
|
|
15628
15751
|
const pollFn = coordinator.bridge.pollCoordOverlay;
|
|
15629
15752
|
if (typeof pollFn !== "function") return;
|
|
@@ -15633,40 +15756,39 @@ var CoordPickerPanel = ({
|
|
|
15633
15756
|
return;
|
|
15634
15757
|
}
|
|
15635
15758
|
let alive = true;
|
|
15636
|
-
|
|
15759
|
+
let inFlight = false;
|
|
15760
|
+
const intervalMs = livePickTargetId ? 140 : 280;
|
|
15637
15761
|
const timer = setInterval(() => {
|
|
15762
|
+
if (inFlight) return;
|
|
15763
|
+
inFlight = true;
|
|
15638
15764
|
void pollFn.call(coordinator.bridge).then((status) => {
|
|
15639
15765
|
if (!alive || !status) return;
|
|
15640
15766
|
setLiveGameHover(status.hover);
|
|
15641
15767
|
const pendingId = livePickTargetRef.current;
|
|
15642
|
-
|
|
15643
|
-
|
|
15768
|
+
const expectedToken = activePickTokenRef.current;
|
|
15769
|
+
if (!pendingId || !expectedToken || consumedTokenRef.current === expectedToken) return;
|
|
15770
|
+
if (status.picked && status.picked.token === expectedToken) {
|
|
15771
|
+
consumedTokenRef.current = expectedToken;
|
|
15644
15772
|
const { x, y } = status.picked;
|
|
15645
|
-
const lbl =
|
|
15646
|
-
|
|
15647
|
-
setLastFeedback(`\u5DF2\
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
} else if (
|
|
15651
|
-
|
|
15773
|
+
const lbl = targetsRef.current.find((t) => t.id === pendingId)?.label ?? pendingId;
|
|
15774
|
+
onPickCoordRef.current(pendingId, x, y);
|
|
15775
|
+
setLastFeedback(`\u5DF2\u586B\u5165 [${lbl}] \u2192 (${x}, ${y})`);
|
|
15776
|
+
onCancelLivePickRef.current();
|
|
15777
|
+
advanceTargetRef.current(pendingId);
|
|
15778
|
+
} else if (status.cancelledToken && status.cancelledToken === expectedToken) {
|
|
15779
|
+
consumedTokenRef.current = expectedToken;
|
|
15652
15780
|
setLastFeedback("\u5DF2\u53D6\u6D88\u6E38\u620F\u753B\u9762\u53D6\u70B9");
|
|
15653
|
-
|
|
15781
|
+
onCancelLivePickRef.current();
|
|
15654
15782
|
}
|
|
15655
|
-
}).catch(() => void 0)
|
|
15783
|
+
}).catch(() => void 0).finally(() => {
|
|
15784
|
+
inFlight = false;
|
|
15785
|
+
});
|
|
15656
15786
|
}, intervalMs);
|
|
15657
15787
|
return () => {
|
|
15658
15788
|
alive = false;
|
|
15659
15789
|
clearInterval(timer);
|
|
15660
15790
|
};
|
|
15661
|
-
}, [
|
|
15662
|
-
coordinator.bridge,
|
|
15663
|
-
gameHudVisible,
|
|
15664
|
-
livePickTargetId,
|
|
15665
|
-
targets,
|
|
15666
|
-
onPickCoord,
|
|
15667
|
-
onCancelLivePick,
|
|
15668
|
-
advanceTarget
|
|
15669
|
-
]);
|
|
15791
|
+
}, [coordinator.bridge, gameHudVisible, livePickTargetId]);
|
|
15670
15792
|
(0, import_react8.useEffect)(() => {
|
|
15671
15793
|
return () => {
|
|
15672
15794
|
const syncFn = coordinator.bridge.syncCoordOverlay;
|
|
@@ -15690,10 +15812,10 @@ var CoordPickerPanel = ({
|
|
|
15690
15812
|
setLastFeedback(`\u5DF2\u5728\u622A\u56FE\u586B\u5165 [${selectedTarget.label}] \u2192 (${pt.x}, ${pt.y})`);
|
|
15691
15813
|
advanceTarget(selectedTarget.id);
|
|
15692
15814
|
};
|
|
15693
|
-
if (!screenshotOpen && !gameHudVisible && !livePickTargetId && !lastFeedback) {
|
|
15815
|
+
if (!screenshotOpen && !gameHudVisible && !livePickTargetId && !lastFeedback && !captureError) {
|
|
15694
15816
|
return null;
|
|
15695
15817
|
}
|
|
15696
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-coord-studio" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between" } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("strong", { style: { color: "#7dd3fc" } }, "\u{1F3AF} \u53EF\u89C6\u5316\u5750\u6807\u62FE\u53D6\u5668 (1200\xD7720)"), liveGameHover && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-run" }, "\u6E38\u620F\u5B9E\u65F6\u9F20\u6807: X ", liveGameHover.x, ", Y ", liveGameHover.y), livePickTarget && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-warn" }, "\u53D6\u70B9\u4E2D [", livePickTarget.label, "] \u2014 \
|
|
15818
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-coord-studio" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between" } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("strong", { style: { color: "#7dd3fc" } }, "\u{1F3AF} \u53EF\u89C6\u5316\u5750\u6807\u62FE\u53D6\u5668 (1200\xD7720)"), liveGameHover && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-run" }, "\u6E38\u620F\u5B9E\u65F6\u9F20\u6807: X ", liveGameHover.x, ", Y ", liveGameHover.y), livePickTarget && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-warn" }, "\u53D6\u70B9\u4E2D [", livePickTarget.label, "] \u2014 \u5DE6\u952E\u70B9\u6E38\u620F\u753B\u9762\u586B\u5165\uFF08\u53F3\u952E / Esc / \u53D6\u6D88\uFF09"), !livePickTarget && lastFeedback && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-ok" }, lastFeedback)), /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 5 } }, livePickTarget && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm kca-btn-danger", onClick: onCancelLivePick }, "\u53D6\u6D88\u53D6\u70B9"), /* @__PURE__ */ import_react8.default.createElement(
|
|
15697
15819
|
"button",
|
|
15698
15820
|
{
|
|
15699
15821
|
className: `kca-btn kca-btn-sm ${gameHudVisible ? "kca-btn-primary" : ""}`,
|
|
@@ -15701,7 +15823,18 @@ var CoordPickerPanel = ({
|
|
|
15701
15823
|
title: "\u5728\u8230\u5A18\u6E38\u620F\u753B\u9762\u4E0A\u5B9E\u65F6\u663E\u793A\u9F20\u6807\u5750\u6807\u4E0E\u5168\u90E8\u5DF2\u914D\u7F6E\u7684\u5206\u6B67/\u9646\u822A/\u8DEF\u5F84\u6807\u8BB0\uFF08\u9F20\u6807\u7A7F\u900F\uFF0C\u4E0D\u5F71\u54CD\u6E38\u73A9\uFF09"
|
|
15702
15824
|
},
|
|
15703
15825
|
gameHudVisible ? "\u{1F441}\uFE0F \u5173\u95ED\u6E38\u620F\u5750\u6807\u663E\u793A" : "\u{1F441}\uFE0F \u6E38\u620F\u53E0\u52A0\u5B9E\u65F6\u5750\u6807"
|
|
15704
|
-
), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm", onClick: onCloseScreenshot }, "\u6536\u8D77\u622A\u56FE\u9762\u677F")
|
|
15826
|
+
), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm", onClick: onCloseScreenshot }, "\u6536\u8D77\u622A\u56FE\u9762\u677F"), !screenshotOpen && !gameHudVisible && !livePickTargetId && /* @__PURE__ */ import_react8.default.createElement(
|
|
15827
|
+
"button",
|
|
15828
|
+
{
|
|
15829
|
+
className: "kca-btn kca-btn-sm",
|
|
15830
|
+
title: "\u5173\u95ED\u6B64\u63D0\u793A",
|
|
15831
|
+
onClick: () => {
|
|
15832
|
+
setLastFeedback("");
|
|
15833
|
+
setCaptureError("");
|
|
15834
|
+
}
|
|
15835
|
+
},
|
|
15836
|
+
"\u2715 \u5173\u95ED"
|
|
15837
|
+
))), !screenshotOpen && captureError && /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-import-banner kca-import-banner-err" }, captureError), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between", gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-chip-list" }, /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-muted" }, "\u70B9\u51FB\u76EE\u6807\uFF1A"), targets.map((t) => {
|
|
15705
15838
|
const active = selectedTarget?.id === t.id;
|
|
15706
15839
|
const configured = t.x > 0 || t.y > 0;
|
|
15707
15840
|
return /* @__PURE__ */ import_react8.default.createElement(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-kca-next",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "High-performance native poi KanColle automation replacement for (非)提助手 — zero DRM, zero extra browser, event-driven in-process engine",
|
|
5
5
|
"author": "machilus",
|
|
6
6
|
"main": "dist/index.js",
|