@nextclaw/x-harness 0.2.39 → 0.2.40

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/SOURCE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Corresponding source
2
2
 
3
- Version 0.2.39, commit e3d0f784983fbdef6162a4e92d9921fe15ce3237.
3
+ Version 0.2.40, commit 26581c241d56f52365a0e1e903cb0e0122c6988d.
4
4
 
5
- Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/e3d0f784983fbdef6162a4e92d9921fe15ce3237
5
+ Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/26581c241d56f52365a0e1e903cb0e0122c6988d
6
6
 
7
7
  Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
8
8
 
@@ -9,6 +9,8 @@ export declare class PlatformCollections {
9
9
  private handleCollectSources;
10
10
  private handleReadCreator;
11
11
  private handleReadBookmarks;
12
+ private bookmarkDiscovery;
13
+ private waitForBookmarkLabel;
12
14
  private handleSearchSources;
13
15
  }
14
16
  export declare function createPlatformCollections(...args: ConstructorParameters<typeof PlatformCollections>): PlatformCollections;
@@ -174,8 +174,15 @@ export class PlatformCollections {
174
174
  targetLabel: folder,
175
175
  bookmarkNavigation: true,
176
176
  });
177
+ if (discoverOnly && nav.bookmarkFolders?.length)
178
+ return this.bookmarkDiscovery(nav);
177
179
  const bookmark = (c) => /^(书签|收藏|Bookmarks)$/i.test(c.label);
178
- if (!(await this.#choose(nav, bookmark, { activateSelected: true })) &&
180
+ const matching = (nav.controls ?? []).filter(bookmark);
181
+ const entered = await this.#choose(nav, bookmark, {
182
+ activateSelected: true,
183
+ });
184
+ const openedTab = entered && matching.length === 1 && matching[0].role === "tab";
185
+ if (!entered &&
179
186
  !(await this.#choose(nav, (c) => /^(历史|History)$/i.test(c.label)))) {
180
187
  if (await this.#choose(nav, (c) => /^(更多菜单项|More menu items)$/i.test(c.label))) {
181
188
  nav = await this.#ready({ view: "menu" });
@@ -207,13 +214,19 @@ export class PlatformCollections {
207
214
  targetLabel: folder,
208
215
  bookmarkNavigation: true,
209
216
  });
217
+ if (discoverOnly &&
218
+ !(nav.controls ?? []).some((c) => c.role === "tab")) {
219
+ await this.waitForBookmarkLabel(nav, "书签", "Bookmarks");
220
+ nav = await this.#ready({ view: "navigation", bookmarkNavigation: true });
221
+ }
210
222
  const tabs = (nav.controls ?? []).filter((c) => c.role === "tab" &&
211
223
  (bookmark(c) ||
212
224
  (discoverOnly &&
213
225
  /\/i\/(?:history|bookmarks)(?:\/|$)/.test(nav.page ?? "") &&
214
226
  c.selected &&
215
227
  !/^(喜欢|Likes)$/i.test(c.label))));
216
- if (tabs.length === 1 &&
228
+ if (!openedTab &&
229
+ tabs.length === 1 &&
217
230
  (!tabs[0].selected ||
218
231
  !(nav.controls ?? []).some((c) => c.label.split("\n")[0] === folder))) {
219
232
  await this.#choose(nav, (c) => c === tabs[0], {
@@ -226,17 +239,14 @@ export class PlatformCollections {
226
239
  });
227
240
  }
228
241
  if (discoverOnly) {
229
- const folders = nav.bookmarkFolders ?? [];
230
- return {
231
- page: nav.page,
232
- accountHandle: nav.accountHandle,
233
- observedAt: nav.observedAt,
234
- fresh: true,
235
- complete: folders.length > 0 && !nav.alerts?.length,
236
- pageComplete: false,
237
- folders,
238
- missing: folders.length ? [] : ["bookmark-folder-menu-unconfirmed"],
239
- };
242
+ if (!nav.bookmarkFolders?.length) {
243
+ await this.waitForBookmarkLabel(nav, "所有书签", "All bookmarks");
244
+ nav = await this.#ready({
245
+ view: "navigation",
246
+ bookmarkNavigation: true,
247
+ });
248
+ }
249
+ return this.bookmarkDiscovery(nav);
240
250
  }
241
251
  if (!(nav.controls ?? []).some((c) => c.label.split("\n")[0] === folder)) {
242
252
  try {
@@ -281,6 +291,31 @@ export class PlatformCollections {
281
291
  },
282
292
  };
283
293
  }
294
+ bookmarkDiscovery(nav) {
295
+ const folders = nav.bookmarkFolders ?? [];
296
+ return {
297
+ page: nav.page,
298
+ accountHandle: nav.accountHandle,
299
+ observedAt: nav.observedAt,
300
+ fresh: true,
301
+ complete: folders.length > 0 && !nav.alerts?.length,
302
+ pageComplete: false,
303
+ folders,
304
+ missing: folders.length ? [] : ["bookmark-folder-menu-unconfirmed"],
305
+ };
306
+ }
307
+ async waitForBookmarkLabel(nav, chinese, english) {
308
+ const folder = (nav.controls ?? []).some((c) => /^(History|Bookmarks)$/i.test(c.label))
309
+ ? english
310
+ : chinese;
311
+ try {
312
+ await this.#browser.act({ operation: "waitForFolder", folder });
313
+ }
314
+ catch (error) {
315
+ if (!/timed out|timeout/i.test(error.message))
316
+ throw error;
317
+ }
318
+ }
284
319
  async handleSearchSources({ query, limit = 3, maxPages = 1, processedIds = [], } = {}) {
285
320
  await this.#browser.act({ operation: "searchSources", query });
286
321
  const value = await this.handleCollectSources({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/x-harness",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "type": "module",
5
5
  "description": "Typed X task harness with compact business results and explicit diagnostics.",
6
6
  "main": "./dist/index.js",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "e3d0f784983fbdef6162a4e92d9921fe15ce3237"
45
+ "gitHead": "26581c241d56f52365a0e1e903cb0e0122c6988d"
46
46
  }