@xiaohhhh1/canvas-agent 0.4.31 → 0.4.33

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.
@@ -135,6 +135,7 @@ export declare class FastMossIntegration {
135
135
  private resetObservedVideoRecords;
136
136
  private observeVideoRankingResponses;
137
137
  private waitForVideoResponseTasks;
138
+ private waitForObservedVideoRecords;
138
139
  private clickVideoLearningTab;
139
140
  private clickVideoLearningNextPage;
140
141
  private waitForVideoLearningNavigation;
@@ -330,8 +330,8 @@ export class FastMossIntegration {
330
330
  await this.openVideoLearningPage(fastMossVideoLearningRankUrl(market), market === "GLOBAL" ? "全球视频商品榜" : `${market} 视频商品榜`);
331
331
  await collect("commerce-video", Math.min(VIDEO_COMMERCE_TARGET, requestedTarget));
332
332
  const aiDimensions = [
333
- { dimension: "high-sales", labels: ["高销量榜单", "High Sales"] },
334
333
  { dimension: "high-roas", labels: ["高ROAS榜单", "High ROAS"] },
334
+ { dimension: "high-sales", labels: ["高销量榜单", "High Sales"] },
335
335
  { dimension: "high-exposure", labels: ["高曝光榜单", "High Exposure"] },
336
336
  { dimension: "high-engagement", labels: ["高互动榜单", "High Engagement"] },
337
337
  ];
@@ -353,15 +353,7 @@ export class FastMossIntegration {
353
353
  await this.inspect();
354
354
  if (this.verificationRequired)
355
355
  throw new Error("采集 AI 视频榜时出现滑块验证;请手动完成后重新采集");
356
- await this.waitForVideoResponseTasks();
357
- // High Sales is server-rendered on the first load, so there is no
358
- // ranking JSON response to observe. Moving to page 2 through the
359
- // visible pager produces the same public ranking data as every
360
- // subsequent tab and avoids scraping hidden application state.
361
- if (entryIndex === 0 && this.observedVideoRecords.length === 0 && await this.clickVideoLearningNextPage()) {
362
- await this.waitForVideoLearningNavigation();
363
- await this.waitForVideoResponseTasks();
364
- }
356
+ await this.waitForObservedVideoRecords();
365
357
  const remaining = Math.min(VIDEO_AI_TARGET_PER_DIMENSION, requestedTarget - sources.length);
366
358
  await collect(entry.dimension, remaining);
367
359
  }
@@ -575,6 +567,15 @@ export class FastMossIntegration {
575
567
  if (this.videoResponseTasks.size)
576
568
  await Promise.allSettled([...this.videoResponseTasks]);
577
569
  }
570
+ async waitForObservedVideoRecords(timeoutMs = 5_000) {
571
+ const deadline = Date.now() + timeoutMs;
572
+ while (Date.now() < deadline) {
573
+ await this.waitForVideoResponseTasks();
574
+ if (this.observedVideoRecords.length)
575
+ return;
576
+ await new Promise((resolve) => setTimeout(resolve, 200));
577
+ }
578
+ }
578
579
  async clickVideoLearningTab(labels) {
579
580
  let lastError;
580
581
  for (let attempt = 0; attempt < 3; attempt += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaohhhh1/canvas-agent",
3
- "version": "0.4.31",
3
+ "version": "0.4.33",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",