lycheedev 1.0.6 → 1.1.0

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/src/wow.js CHANGED
@@ -43,14 +43,27 @@ export function findPythonBin() {
43
43
  * the addon's Wrath TOC targets (Interface 38002). The previous value
44
44
  * `_classic_arena_` does not exist, so an installed Titan client was silently
45
45
  * skipped by both `install` and `doctor`.
46
+ *
47
+ * A folder name is a location, not an identity: the game reuses a test folder
48
+ * for whatever is on the test track. `_classic_beta_` currently carries WoW:
49
+ * Forever (`1.60.1`) for players on that track, so the folder alone cannot
50
+ * decide the product. `resolveProduct` reads the client's own `.flavor.info`
51
+ * product code first and falls back to the build version, and only then to the
52
+ * folder default recorded here.
46
53
  */
47
54
  export const CLIENT_FLAVORS = [
48
- { id: 'retail', folder: '_retail_', label: 'Retail', exe: 'Wow.exe', toc: 'Lychee Dev_Mainline.toc' },
49
- { id: 'classic', folder: '_classic_', label: 'Classic', exe: 'WowClassic.exe', toc: 'Lychee Dev_Mists.toc' },
50
- { id: 'titan', folder: '_classic_titan_', label: 'Classic Titan', exe: 'WowClassic.exe', toc: 'Lychee Dev_Wrath.toc' },
51
- { id: 'classicEra', folder: '_classic_era_', label: 'Classic Era', exe: 'WowClassic.exe', toc: null },
52
- { id: 'anniversary', folder: '_anniversary_', label: 'Anniversary', exe: 'WowClassic.exe', toc: null },
53
- { id: 'beta', folder: '_beta_', label: 'Beta', exe: 'WowB.exe', toc: null },
55
+ { id: 'retail', folder: '_retail_', label: 'Retail', exe: 'Wow.exe', toc: 'Lychee Dev_Mainline.toc', product: 'wow', buildPrefix: null },
56
+ { id: 'classic', folder: '_classic_', label: 'Classic', exe: 'WowClassic.exe', toc: 'Lychee Dev_Mists.toc', product: 'wow_classic', buildPrefix: null },
57
+ { id: 'titan', folder: '_classic_titan_', label: 'Classic Titan', exe: 'WowClassic.exe', toc: 'Lychee Dev_Wrath.toc', product: 'wow_classic_titan', buildPrefix: null },
58
+ // The Forever test track. Listed for both layouts so either one is detected.
59
+ { id: 'forever', folder: '_classic_beta_', label: 'Forever', exe: 'WowClassic.exe', toc: 'Lychee Dev_Forever.toc', product: 'wow_forever', buildPrefix: '1.60.' },
60
+ { id: 'forever', folder: '_forever_', label: 'Forever', exe: 'WowClassic.exe', toc: 'Lychee Dev_Forever.toc', product: 'wow_forever', buildPrefix: '1.60.' },
61
+ // The MoP-era classic test track historically used the same `_classic_beta_`
62
+ // folder, so keep it known and explain it instead of hiding the folder.
63
+ { id: 'classicBeta', folder: '_classic_beta_', label: 'Classic Beta', exe: 'WowClassic.exe', toc: null, product: 'wow_classic_beta', buildPrefix: '5.5.' },
64
+ { id: 'classicEra', folder: '_classic_era_', label: 'Classic Era', exe: 'WowClassic.exe', toc: null, product: 'wow_classic_era', buildPrefix: null },
65
+ { id: 'anniversary', folder: '_anniversary_', label: 'Anniversary', exe: 'WowClassic.exe', toc: null, product: 'wow_anniversary', buildPrefix: null },
66
+ { id: 'beta', folder: '_beta_', label: 'Beta', exe: 'WowB.exe', toc: null, product: 'wow_beta', buildPrefix: null },
54
67
  ];
55
68
 
56
69
  /** Flavors with an addon catalog, i.e. the builds the addon can install into. */
@@ -58,10 +71,70 @@ export function supportedFlavors() {
58
71
  return CLIENT_FLAVORS.filter((flavor) => flavor.toc);
59
72
  }
60
73
 
74
+ /**
75
+ * The client's own product code, read from the `.flavor.info` file the launcher
76
+ * writes next to the executable. It is ground truth for which product a folder
77
+ * actually holds, and the only signal that stays correct when Blizzard reuses a
78
+ * folder name. Returns null when the file is absent or unreadable.
79
+ */
80
+ export function readFlavorProduct(flavorDir) {
81
+ for (const name of ['.flavor.info', 'flavor.info']) {
82
+ const file = path.join(flavorDir, name);
83
+ if (!exists(file)) continue;
84
+ let text;
85
+ try {
86
+ text = fs.readFileSync(file, 'utf8');
87
+ } catch {
88
+ continue;
89
+ }
90
+ const match = text.match(/\b(wow[a-z0-9_]*)\b/i);
91
+ if (match) return match[1].toLowerCase();
92
+ }
93
+ return null;
94
+ }
95
+
96
+ /**
97
+ * The product a flavor folder actually holds. The client's declared product
98
+ * wins; then the build version, because a reused folder still reports its own
99
+ * version; then the folder default.
100
+ */
101
+ export function resolveProduct(flavor, flavorDir, version) {
102
+ return readFlavorProduct(flavorDir)
103
+ || (version && flavor.buildPrefix && version.startsWith(flavor.buildPrefix) ? flavor.product : null)
104
+ || flavor.product;
105
+ }
106
+
107
+ /**
108
+ * Pick the flavor entry that matches a client's real identity: the product, or
109
+ * the build when the product is unknown, and only then the folder default.
110
+ */
111
+ export function flavorForClient({ folder, product = null, version = null }) {
112
+ const byFolder = CLIENT_FLAVORS.filter((flavor) => flavor.folder === folder);
113
+ if (product) {
114
+ const exact = byFolder.find((flavor) => flavor.product === product);
115
+ if (exact) return exact;
116
+ }
117
+ if (version) {
118
+ const byBuild = byFolder.find((flavor) => flavor.buildPrefix && version.startsWith(flavor.buildPrefix));
119
+ if (byBuild) return byBuild;
120
+ }
121
+ return byFolder[0] || null;
122
+ }
123
+
124
+ /** Every folder name the CLI recognises, for error messages and documentation. */
125
+ export function knownFolders() {
126
+ return [...new Set(CLIENT_FLAVORS.map((flavor) => flavor.folder))];
127
+ }
128
+
61
129
  export function flavorById(id) {
62
130
  return CLIENT_FLAVORS.find((flavor) => flavor.id === id) || null;
63
131
  }
64
132
 
133
+ /**
134
+ * The first flavor registered for a folder. A folder may have several entries
135
+ * (see `_classic_beta_`), so use `flavorForClient` when the client's own
136
+ * product or build is known.
137
+ */
65
138
  export function flavorByFolder(folder) {
66
139
  return CLIENT_FLAVORS.find((flavor) => flavor.folder === folder) || null;
67
140
  }
@@ -116,27 +189,101 @@ function exeVersion(exePath) {
116
189
  }
117
190
  }
118
191
 
192
+ /**
193
+ * Every flavor folder's executable version under one root, in a single call.
194
+ *
195
+ * The version has to come from the executable's file metadata, which needs
196
+ * PowerShell on Windows, and starting it once per client costs about a second on
197
+ * a full install. One invocation returns the whole map, so the cost is paid once
198
+ * no matter how many clients are present.
199
+ */
200
+ const FLAVOR_EXE_CANDIDATES = ['Wow.exe', 'WowClassic.exe', 'WowB.exe'];
201
+
202
+ export function readExecutableVersions(wowRoot) {
203
+ const dirs = [...new Set(CLIENT_FLAVORS.map((flavor) => flavor.folder))];
204
+ const script = [
205
+ '$ErrorActionPreference = "SilentlyContinue"',
206
+ '$root = $env:LYCHEEDEV_VERSIONS_ROOT',
207
+ '$names = $env:LYCHEEDEV_VERSIONS_FOLDERS -split ","',
208
+ '$exes = @("Wow.exe", "WowClassic.exe", "WowB.exe")',
209
+ 'foreach ($name in $names) {',
210
+ ' foreach ($exe in $exes) {',
211
+ ' $path = Join-Path $root ($name + "\\" + $exe)',
212
+ ' if (Test-Path -LiteralPath $path) {',
213
+ ' $version = (Get-Item -LiteralPath $path).VersionInfo.FileVersion',
214
+ ' Write-Output ($name + "`t" + $version)',
215
+ ' break',
216
+ ' }',
217
+ ' }',
218
+ '}',
219
+ ].join('\n');
220
+
221
+ const versions = new Map();
222
+ if (process.platform !== 'win32') return versions;
223
+ try {
224
+ // The root and folder list travel as environment variables: passing them as
225
+ // arguments to `-Command` lets PowerShell reinterpret a Windows path, which
226
+ // silently yields an empty map and a much slower per-client fallback.
227
+ const out = execFileSync('powershell', [
228
+ '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', script,
229
+ ], {
230
+ encoding: 'utf8',
231
+ windowsHide: true,
232
+ timeout: 60000,
233
+ env: {
234
+ ...process.env,
235
+ LYCHEEDEV_VERSIONS_ROOT: wowRoot,
236
+ LYCHEEDEV_VERSIONS_FOLDERS: dirs.join(','),
237
+ },
238
+ });
239
+ for (const line of out.replace(/^\uFEFF/, '').split(/\r?\n/)) {
240
+ const [folder, version] = line.split('\t');
241
+ if (!folder || !version) continue;
242
+ versions.set(folder.trim(), version.trim());
243
+ }
244
+ } catch {
245
+ return versions;
246
+ }
247
+ return versions;
248
+ }
249
+
119
250
  /**
120
251
  * Describe every flavor present under a root, including builds the addon does
121
252
  * not serve, so `doctor` can explain them instead of ignoring them silently.
122
253
  */
123
254
  export function scanClients(wowRoot) {
255
+ const versions = readExecutableVersions(wowRoot);
124
256
  const found = [];
257
+ const seenDirs = new Set();
125
258
  for (const flavor of CLIENT_FLAVORS) {
126
259
  const flavorDir = path.join(wowRoot, flavor.folder);
127
260
  if (!isDir(flavorDir)) continue;
261
+ // Two entries can share one folder; describe that folder only once.
262
+ if (seenDirs.has(flavorDir)) continue;
263
+ seenDirs.add(flavorDir);
264
+
128
265
  const addonsDir = path.join(flavorDir, 'Interface', 'AddOns');
129
266
  const exePath = path.join(flavorDir, flavor.exe);
130
267
  const hasExe = exists(exePath);
268
+ // The batch result is keyed by folder; fall back to a direct read for an
269
+ // install whose executable name does not match the recorded one.
270
+ const version = versions.get(flavor.folder)
271
+ || (hasExe ? exeVersion(exePath) : null);
272
+ // Which product this folder really holds decides id, label and catalog.
273
+ const product = resolveProduct(flavor, flavorDir, version);
274
+ const resolved = flavorForClient({ folder: flavor.folder, product, version }) || flavor;
275
+
131
276
  found.push({
132
277
  ...flavor,
278
+ ...resolved,
133
279
  flavorDir,
134
280
  addonsDir,
135
281
  addonsDirExists: isDir(addonsDir),
136
282
  exePath: hasExe ? exePath : null,
137
- version: hasExe ? exeVersion(exePath) : null,
283
+ version,
284
+ folderProduct: product,
138
285
  installedDir: path.join(addonsDir, addonFolderName),
139
- installed: flavor.toc ? exists(path.join(addonsDir, addonFolderName, flavor.toc)) : false,
286
+ installed: resolved.toc ? exists(path.join(addonsDir, addonFolderName, resolved.toc)) : false,
140
287
  });
141
288
  }
142
289
  return found;
@@ -170,10 +317,25 @@ export function findSavedVariablesCandidates(wowRoot, flavorFolder) {
170
317
  * windows and reads process image paths without opening a process.
171
318
  *
172
319
  * Blizzard ships every non-retail client as `WowClassic.exe`, so the process
173
- * name cannot identify a build; the executable path can, because each install
174
- * lives under a `_flavor_` directory.
320
+ * name cannot identify a build. The executable path narrows it to an install
321
+ * folder, but a folder is a location rather than an identity: the helper also
322
+ * reports the folder's `.flavor.info` product and `version.txt` build, and
323
+ * those decide which client the window actually is.
324
+ *
325
+ * The answer is memoized for the life of the process. A single command resolves
326
+ * the target more than once (once to pick the window, once to forward), and
327
+ * re-enumerating would both pay for another interpreter start and risk the two
328
+ * lookups disagreeing about which windows exist.
175
329
  */
176
- export function findInstances({ pythonBin = null } = {}) {
330
+ let instancesCache = null;
331
+
332
+ export function findInstances({ pythonBin = null, refresh = false } = {}) {
333
+ if (!refresh && instancesCache !== null) return instancesCache;
334
+ instancesCache = enumerateInstances(pythonBin);
335
+ return instancesCache;
336
+ }
337
+
338
+ function enumerateInstances(pythonBin) {
177
339
  if (process.platform !== 'win32') return [];
178
340
  const python = pythonBin || findPythonBin();
179
341
  if (!python || !exists(instancesScript)) return [];
@@ -194,8 +356,17 @@ export function findInstances({ pythonBin = null } = {}) {
194
356
 
195
357
  return rows
196
358
  .map((row) => {
197
- const flavor = flavorByFolder(row.flavorFolder);
198
- return { ...row, supported: Boolean(flavor && flavor.toc) };
359
+ const resolved = flavorForClient({
360
+ folder: row.flavorFolder,
361
+ product: row.product || null,
362
+ version: row.version || null,
363
+ });
364
+ return {
365
+ ...row,
366
+ flavorId: resolved ? resolved.id : row.flavorId,
367
+ flavorLabel: resolved ? resolved.label : row.flavorLabel,
368
+ supported: Boolean(resolved && resolved.toc),
369
+ };
199
370
  })
200
371
  .sort((a, b) => (a.flavorId || '').localeCompare(b.flavorId || '') || a.pid - b.pid);
201
372
  }
@@ -245,6 +416,14 @@ export function matchPinned(instances, pin) {
245
416
  const supported = instances.filter((item) => item.supported);
246
417
  const ofFlavor = supported.filter((item) => item.flavorId === pin.flavor);
247
418
  if (ofFlavor.length === 0) return null;
419
+ // A pin taken while the windows carried identity markers names the character,
420
+ // which survives the window being closed and reopened far better than an
421
+ // ordinal does. Fall back to the ordinal for pins saved before identity was
422
+ // available, and for builds whose windows show no marker.
423
+ if (pin.character) {
424
+ const named = ofFlavor.filter((item) => identityKey(item) === pin.character);
425
+ if (named.length === 1) return named[0];
426
+ }
248
427
  return ofFlavor[pin.ordinal || 0] || ofFlavor[0];
249
428
  }
250
429
 
@@ -252,20 +431,50 @@ export function formatInstance(instance, index) {
252
431
  const flavor = instance.flavorLabel || instance.flavorFolder || 'unknown';
253
432
  const suffix = instance.supported ? '' : ' (the addon does not serve this build)';
254
433
  const hwnd = instance.hwnd ? `0x${instance.hwnd.toString(16)}` : '-';
434
+ const version = instance.version ? ` v${instance.version}` : '';
255
435
  const title = instance.title ? ` "${instance.title}"` : '';
256
- return ` [${index}] ${flavor.padEnd(14)} pid=${String(instance.pid).padEnd(8)} `
257
- + `hwnd=${hwnd.padEnd(12)}${title}${suffix}`;
436
+ const line = ` [${index}] ${flavor.padEnd(14)} pid=${String(instance.pid).padEnd(8)} `
437
+ + `hwnd=${hwnd.padEnd(12)}${version}${title}${suffix}`;
438
+ // Identity comes from the in-game marker when the caller asked for it; it is
439
+ // the only thing that says which character is behind the window.
440
+ const identity = instance.identity;
441
+ if (!identity) return line;
442
+ const name = identity.realm ? `${identity.id}-${identity.realm}` : identity.id;
443
+ return `${line}\n character: ${name}`
444
+ + `${identity.client ? ` client: ${identity.client}` : ''}`
445
+ + `${identity.build ? ` build: ${identity.build}` : ''}`;
446
+ }
447
+
448
+ /**
449
+ * A stable key for the character a window reports, or null when it reported none.
450
+ *
451
+ * The identity marker is the only thing that says which character is behind a
452
+ * window, so it is what makes two same-build windows distinguishable. Realm is
453
+ * part of the key because two realms can carry a character with the same name.
454
+ */
455
+ export function identityKey(instance) {
456
+ const identity = instance && instance.identity;
457
+ if (!identity || !identity.id) return null;
458
+ return `${identity.id}\u0000${identity.realm || ''}`;
459
+ }
460
+
461
+ /** The `character-realm` label shown to the user, or null without a marker. */
462
+ export function identityLabel(instance) {
463
+ const identity = instance && instance.identity;
464
+ if (!identity || !identity.id) return null;
465
+ return identity.realm ? `${identity.id}-${identity.realm}` : identity.id;
258
466
  }
259
467
 
260
468
  /**
261
469
  * Decide whether several running instances can be told apart.
262
470
  *
263
471
  * Different builds are safe: the install path identifies them, so `--client`
264
- * picks one. Several instances of the *same* build are not, because nothing
265
- * observable from outside the game says which character is behind which pid —
266
- * only a build-specific memory reader could, and none ships here. Rather than
267
- * let the user pin an ordinal that may point at the wrong window, the caller is
268
- * told to close the extras.
472
+ * picks one. Several windows of the *same* build are only a problem when they
473
+ * cannot be named: if each window shows an identity marker with a distinct
474
+ * character, the user can choose one by name. Identical characters — or windows
475
+ * that showed no marker — remain genuinely indistinguishable, and pinning an
476
+ * ordinal there would only look precise while risking a command in the wrong
477
+ * game, so the caller still asks for one window.
269
478
  */
270
479
  export function describeAmbiguity(instances) {
271
480
  const supported = instances.filter((item) => item.supported);
@@ -275,13 +484,58 @@ export function describeAmbiguity(instances) {
275
484
  byBuild.get(instance.flavorId).push(instance);
276
485
  }
277
486
  const duplicates = [...byBuild.entries()].filter(([, list]) => list.length > 1);
278
- const distinct = byBuild.size;
487
+
488
+ // Within each colliding build, group the windows by the character they report.
489
+ // Every window without a marker shares one anonymous group: a pid is not
490
+ // something the user can recognise or confirm, so two unmarked windows of one
491
+ // build must stay ambiguous rather than looking separable.
492
+ const collisions = [];
493
+ for (const [flavorId, list] of duplicates) {
494
+ const byCharacter = new Map();
495
+ for (const instance of list) {
496
+ const key = identityKey(instance) || '\u0000anonymous';
497
+ if (!byCharacter.has(key)) byCharacter.set(key, []);
498
+ byCharacter.get(key).push(instance);
499
+ }
500
+ const sameCharacter = [...byCharacter.values()].filter((group) => group.length > 1);
501
+ collisions.push({ flavorId, instances: list, byCharacter, sameCharacter });
502
+ }
503
+
279
504
  return {
280
505
  supported,
281
506
  duplicates,
507
+ collisions,
282
508
  // Several builds open: picking one is unambiguous.
283
- multipleBuilds: distinct > 1,
284
- // Several windows of one build: nothing can tell them apart.
285
- sameBuildCollision: duplicates.length > 0,
509
+ multipleBuilds: byBuild.size > 1,
510
+ // Same build, but every window carries its own character: the user can pick.
511
+ sameBuildNamed: collisions.some((entry) => entry.sameCharacter.length === 0
512
+ && entry.byCharacter.size > 1),
513
+ // Same build and no way to separate them: still ask for a single window.
514
+ sameBuildCollision: collisions.some((entry) => entry.sameCharacter.length > 0),
286
515
  };
287
516
  }
517
+
518
+ /**
519
+ * Resolve the character a user named to the window that reports it.
520
+ *
521
+ * Accepts `Name-Realm` or a bare `Name`. A bare name that matches several
522
+ * windows is ambiguous and returns the candidates instead of guessing.
523
+ */
524
+ export function matchIdentity(instances, query) {
525
+ const wanted = String(query || '').trim().toLowerCase();
526
+ if (!wanted) return { error: 'no character name given' };
527
+ const supported = instances.filter((item) => item.supported);
528
+ const matches = supported.filter((instance) => {
529
+ const label = identityLabel(instance);
530
+ if (!label) return false;
531
+ const lower = label.toLowerCase();
532
+ return lower === wanted || lower.split('-')[0] === wanted;
533
+ });
534
+ if (matches.length === 0) {
535
+ return { error: `no running window reports the character '${query}'`, candidates: supported };
536
+ }
537
+ if (matches.length > 1) {
538
+ return { error: `${matches.length} windows report '${query}'; use Name-Realm`, candidates: matches };
539
+ }
540
+ return { instance: matches[0] };
541
+ }
@@ -0,0 +1,9 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ ns.Client = {
4
+ id = "forever",
5
+ name = "Forever",
6
+ flavor = "Forever",
7
+ interface = 16001,
8
+ baseline = "1.60.1",
9
+ }
@@ -194,7 +194,7 @@ ns.L = {
194
194
  ABOUT_CLIENT = "支持客户端",
195
195
  ABOUT_COMMAND = "打开命令",
196
196
  ABOUT_DEPENDENCY = "错误采集",
197
- ABOUT_CLIENT_VALUE = "正式服 12.1+",
197
+ ABOUT_CLIENT_VALUE = "正式服 12.1 / 经典版 5.5.4 / 经典泰坦 3.80.2 / 无限服 1.60.1",
198
198
  ABOUT_DEPENDENCY_VALUE = "BugGrabber",
199
199
  ABOUT_GITHUB = "GitHub",
200
200
  ABOUT_REPOSITORY = "源代码与问题反馈",
@@ -266,13 +266,17 @@ ns.L = {
266
266
  AUTO_COMMIT_FAILED = "自动化结果提交失败:%s",
267
267
  AUTO_RESULT_READY = "自动化结果已就绪:%s(请重载界面,等待外部读取)",
268
268
  AUTO_STOPPED = "完成通知已隐藏,待落盘记录保留。",
269
+ AUTO_IDENTITY_SHOWN = "已显示 %s(%s)的身份标记;外部读取左上角即可定位该窗口。",
270
+ AUTO_IDENTITY_HIDDEN = "身份标记已隐藏。",
271
+ AUTO_IDENTITY_UNAVAILABLE = "无法生成身份标记:当前客户端取不到角色名。",
272
+ AUTO_IDENTITY_NOTICE_SHOWN = "当前屏幕上有完成通知;请先执行 /dev auto stop 或回执其 Ticket,再显示身份标记。",
269
273
  AUTO_INVALID_COUNT = "数量必须是 1 到 100 之间的整数。",
270
274
  AUTO_INVALID_TICKET = "Ticket 格式无效。",
271
275
  AUTO_NO_ACTIVE = "没有正在执行的任务 '%s'。",
272
276
  AUTO_STATUS_LINE = "任务 %s | 请求 %s | 状态 %s | 结果 %s",
273
277
  AUTO_RESULT_EXPIRED = "结果已过期",
274
278
  AUTO_RESULT_MISSING = "没有找到 Ticket %s 对应的已保存结果。",
275
- AUTO_USAGE = "用法:/dev auto run <任务ID> | bug <1-100> [请求ID] | status <任务ID> | show <Ticket> | ack <Ticket> received|failed | cancel <任务ID> | stop",
279
+ AUTO_USAGE = "用法:/dev auto run <任务ID> | bug <1-100> [请求ID] | status <任务ID> | show <Ticket> | ack <Ticket> received|failed | cancel <任务ID> | identify | unidentify | stop",
276
280
  AUTO_PROVIDER_FAILED = "错误快照失败:%s",
277
281
  AUTO_BUG_TITLE = "错误快照(%d 条)",
278
282
  AUTO_EXECUTION_COUNT = "%d 条执行记录",
@@ -201,7 +201,7 @@ local english = {
201
201
  ABOUT_CLIENT = "Supported Clients",
202
202
  ABOUT_COMMAND = "Open Command",
203
203
  ABOUT_DEPENDENCY = "Error Capture",
204
- ABOUT_CLIENT_VALUE = "Retail 12.1 / Classic 5.5.4 / Titan 3.80.2",
204
+ ABOUT_CLIENT_VALUE = "Retail 12.1 / Classic 5.5.4 / Titan 3.80.2 / Forever 1.60.1",
205
205
  ABOUT_DEPENDENCY_VALUE = "BugGrabber",
206
206
  ABOUT_GITHUB = "GitHub",
207
207
  ABOUT_REPOSITORY = "Source Code and Issues",
@@ -273,13 +273,17 @@ local english = {
273
273
  AUTO_COMMIT_FAILED = "Could not commit the automation result: %s",
274
274
  AUTO_RESULT_READY = "Automation result ready: %s (reload the UI so the external reader can pick it up)",
275
275
  AUTO_STOPPED = "Completion notice hidden; pending records are kept.",
276
+ AUTO_IDENTITY_SHOWN = "Identity marker for %s (%s) is shown; scan the top-left corner to target this window.",
277
+ AUTO_IDENTITY_HIDDEN = "Identity marker hidden.",
278
+ AUTO_IDENTITY_UNAVAILABLE = "Could not build the identity marker; this client cannot report a character name.",
279
+ AUTO_IDENTITY_NOTICE_SHOWN = "A completion notice is on screen; run /dev auto stop or acknowledge its ticket before showing the identity marker.",
276
280
  AUTO_INVALID_COUNT = "Count must be an integer between 1 and 100.",
277
281
  AUTO_INVALID_TICKET = "The ticket format is invalid.",
278
282
  AUTO_NO_ACTIVE = "No active automation task with id '%s'.",
279
283
  AUTO_STATUS_LINE = "Task %s | request %s | status %s | result %s",
280
284
  AUTO_RESULT_EXPIRED = "Result expired",
281
285
  AUTO_RESULT_MISSING = "No saved result found for ticket %s.",
282
- AUTO_USAGE = "Usage: /dev auto run <task-id> | bug <1-100> [request-id] | status <task-id> | show <ticket> | ack <ticket> received|failed | cancel <task-id> | stop",
286
+ AUTO_USAGE = "Usage: /dev auto run <task-id> | bug <1-100> [request-id] | status <task-id> | show <ticket> | ack <ticket> received|failed | cancel <task-id> | identify | unidentify | stop",
283
287
  AUTO_PROVIDER_FAILED = "Error snapshot failed: %s",
284
288
  AUTO_BUG_TITLE = "Bug snapshot (%d)",
285
289
  AUTO_EXECUTION_COUNT = "%d executions",
@@ -0,0 +1,43 @@
1
+ ## Interface: 16001
2
+ ## Title: |cffd83b4e[Lychee]|r Dev Tools
3
+ ## Title-zhCN: |cffd83b4e[荔枝]|r开发工具
4
+ ## Title-zhTW: |cffd83b4e[荔枝]|r開發工具
5
+ ## Notes: Run Lua, inspect objects and events, and trace functions.
6
+ ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
+ ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
+ ## Author: Follen
9
+ ## Version: 1.1.0
10
+ ## Dependencies: !BugGrabber
11
+ ## SavedVariables: LycheeDevDB, DumperDB
12
+ ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
13
+ ## X-Flavor: Forever
14
+
15
+ Core\Clients\Forever.lua
16
+ Core\Compatibility.lua
17
+ Core\Locale.lua
18
+ Core\Locale_enUS.lua
19
+ Core\Database.lua
20
+ Core\Serializer.lua
21
+ Core\Inspector.lua
22
+ Core\Safety.lua
23
+ Core\Bootstrap.lua
24
+ Modules\ObjectInspector.lua
25
+ Modules\Diagnostics.lua
26
+ Modules\FunctionTrace.lua
27
+ Modules\Automation\auto\auto.lua
28
+ Modules\Automation\Report.lua
29
+ Modules\Automation\Controller.lua
30
+ Modules\Events\CatalogData_Forever.lua
31
+ Modules\Events\Catalog.lua
32
+ Modules\Events\Monitor.lua
33
+ Libs\AutomationQR.lua
34
+ UI\Export.lua
35
+ UI\AutomationOverlay.lua
36
+ UI\Pages\ExportRecords.lua
37
+ UI\Features.lua
38
+ UI\Pages\Object.lua
39
+ UI\Pages\Trace.lua
40
+ UI\Pages\Diagnostics.lua
41
+ UI\Pages\Automation.lua
42
+ UI\Pages\About.lua
43
+ UI\MainWindow.lua
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.6
9
+ ## Version: 1.1.0
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.6
9
+ ## Version: 1.1.0
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -6,7 +6,7 @@
6
6
  ## Notes-zhCN: 运行 Lua,检查对象与事件,追踪函数并查看错误。
7
7
  ## Notes-zhTW: 執行 Lua,檢查物件與事件,追蹤函式並檢視錯誤。
8
8
  ## Author: Follen
9
- ## Version: 1.0.6
9
+ ## Version: 1.1.0
10
10
  ## Dependencies: !BugGrabber
11
11
  ## SavedVariables: LycheeDevDB, DumperDB
12
12
  ## IconTexture: Interface\AddOns\Lychee Dev\Media\Logo.png
@@ -637,9 +637,84 @@ end
637
637
  function Controller.Stop()
638
638
  ns.AutomationOverlay.HideNotice()
639
639
  ns.AutomationOverlay.HideStatus()
640
+ ns.AutomationOverlay.HideIdentity()
640
641
  Print(L.AUTO_STOPPED)
641
642
  end
642
643
 
644
+ function Controller.StopIdentify()
645
+ ns.AutomationOverlay.HideIdentity()
646
+ Print(L.AUTO_IDENTITY_HIDDEN)
647
+ end
648
+
649
+ -- Identity marker for host-side window discovery.
650
+ --
651
+ -- The host can capture several game windows but cannot tell which character is
652
+ -- behind each one; nothing observable from outside the game says so. This shows
653
+ -- a tiny QR code carrying the character identity and build, so a host can map
654
+ -- every running window to a name and let the user choose. It appears only on
655
+ -- explicit request because it shares the top-left corner with the completion
656
+ -- notice and would otherwise sit on screen permanently.
657
+ function Controller.Identify()
658
+ if not EnsureReady() then
659
+ return
660
+ end
661
+
662
+ local character, realm
663
+ local succeeded, name = pcall(UnitName, "player")
664
+ if succeeded and type(name) == "string" and name ~= ""
665
+ and not (issecretvalue and issecretvalue(name)) then
666
+ character = name
667
+ end
668
+ succeeded, name = pcall(GetRealmName)
669
+ if succeeded and type(name) == "string" and name ~= ""
670
+ and not (issecretvalue and issecretvalue(name)) then
671
+ realm = name
672
+ end
673
+
674
+ if not character then
675
+ Print(L.AUTO_IDENTITY_UNAVAILABLE)
676
+ return
677
+ end
678
+
679
+ -- The marker and the completion notice share one corner. Replacing a notice
680
+ -- would take away the only on-screen reference to its Ticket, so refuse
681
+ -- instead of hiding evidence the user may still need.
682
+ if awaitingNotice then
683
+ Print(L.AUTO_IDENTITY_NOTICE_SHOWN)
684
+ return
685
+ end
686
+
687
+ local version = GetBuildInfo and select(1, GetBuildInfo()) or nil
688
+ if issecretvalue and issecretvalue(version) then
689
+ version = nil
690
+ end
691
+
692
+ -- Character names and realm names are plain text, so escape them before
693
+ -- embedding rather than assuming they are JSON-safe.
694
+ local function EscapeJson(value)
695
+ value = tostring(value or "")
696
+ value = value:gsub("\\", "\\\\"):gsub('"', '\\"'):gsub("[%c]", " ")
697
+ return value
698
+ end
699
+
700
+ local json = string.format('{"v":1,"id":"%s","realm":"%s","client":"%s","build":"%s"}',
701
+ EscapeJson(character),
702
+ EscapeJson(realm or ""),
703
+ EscapeJson(ns.Client and ns.Client.id or ""),
704
+ EscapeJson(version or ""))
705
+
706
+ if #json > MAX_NOTICE_BYTES then
707
+ Print(L.AUTO_IDENTITY_UNAVAILABLE)
708
+ return
709
+ end
710
+
711
+ if ns.AutomationOverlay.ShowIdentity(json) then
712
+ Print(L.AUTO_IDENTITY_SHOWN:format(character, realm or "-"))
713
+ else
714
+ Print(L.AUTO_IDENTITY_UNAVAILABLE)
715
+ end
716
+ end
717
+
643
718
  -- The plugin cannot observe whether the host read a result, so the host reports
644
719
  -- it back as a chat command: `/dev auto ack <ticket> <received|failed>`. That
645
720
  -- clears the pending-flush block immediately (no reload needed) and records the
@@ -725,6 +800,18 @@ function Controller.HandleCommand(text)
725
800
  return
726
801
  end
727
802
  Controller.Stop()
803
+ elseif action == "identify" then
804
+ if rest ~= "" then
805
+ Print(L.AUTO_USAGE)
806
+ return
807
+ end
808
+ Controller.Identify()
809
+ elseif action == "unidentify" then
810
+ if rest ~= "" then
811
+ Print(L.AUTO_USAGE)
812
+ return
813
+ end
814
+ Controller.StopIdentify()
728
815
  elseif action == "ack" then
729
816
  local ticket, outcome = rest:match("^(%S+)%s+(%S+)$")
730
817
  if not ticket or not outcome then
@@ -755,3 +842,13 @@ end
755
842
  function Controller.GetAwaitingNotice()
756
843
  return awaitingNotice
757
844
  end
845
+
846
+ -- The identity marker is own UI and must not survive a combat lockout, matching
847
+ -- the notice and status blocks. The callback is constant time while the overlay
848
+ -- has never been built, so registering it costs nothing for users who never use
849
+ -- the automation page.
850
+ ns.RegisterCombatShutdown(function()
851
+ if ns.AutomationOverlay then
852
+ ns.AutomationOverlay.HideIdentity()
853
+ end
854
+ end)