@jackwener/opencli 1.5.2 → 1.5.4

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.
Files changed (135) hide show
  1. package/.agents/skills/cross-project-adapter-migration/SKILL.md +3 -3
  2. package/.github/workflows/ci.yml +6 -7
  3. package/README.md +89 -235
  4. package/dist/browser/cdp.js +20 -1
  5. package/dist/browser/daemon-client.js +3 -2
  6. package/dist/browser/dom-helpers.d.ts +11 -0
  7. package/dist/browser/dom-helpers.js +42 -0
  8. package/dist/browser/dom-helpers.test.d.ts +1 -0
  9. package/dist/browser/dom-helpers.test.js +92 -0
  10. package/dist/browser/index.d.ts +0 -12
  11. package/dist/browser/index.js +0 -13
  12. package/dist/browser/mcp.js +4 -3
  13. package/dist/browser/page.d.ts +1 -0
  14. package/dist/browser/page.js +14 -1
  15. package/dist/browser.test.js +15 -11
  16. package/dist/build-manifest.d.ts +2 -3
  17. package/dist/build-manifest.js +75 -170
  18. package/dist/build-manifest.test.js +113 -88
  19. package/dist/cli-manifest.json +1199 -1106
  20. package/dist/clis/36kr/hot.js +1 -1
  21. package/dist/clis/36kr/search.js +1 -1
  22. package/dist/clis/_shared/common.d.ts +8 -0
  23. package/dist/clis/_shared/common.js +10 -0
  24. package/dist/clis/bloomberg/news.js +1 -1
  25. package/dist/clis/douban/utils.js +3 -6
  26. package/dist/clis/medium/utils.js +1 -1
  27. package/dist/clis/producthunt/browse.js +1 -1
  28. package/dist/clis/producthunt/hot.js +1 -1
  29. package/dist/clis/sinablog/utils.js +6 -7
  30. package/dist/clis/substack/utils.js +2 -2
  31. package/dist/clis/twitter/block.js +1 -1
  32. package/dist/clis/twitter/bookmark.js +1 -1
  33. package/dist/clis/twitter/delete.js +1 -1
  34. package/dist/clis/twitter/follow.js +1 -1
  35. package/dist/clis/twitter/followers.js +2 -2
  36. package/dist/clis/twitter/following.js +2 -2
  37. package/dist/clis/twitter/hide-reply.js +1 -1
  38. package/dist/clis/twitter/like.js +1 -1
  39. package/dist/clis/twitter/notifications.js +1 -1
  40. package/dist/clis/twitter/profile.js +1 -1
  41. package/dist/clis/twitter/reply-dm.js +1 -1
  42. package/dist/clis/twitter/reply.js +1 -1
  43. package/dist/clis/twitter/search.js +1 -1
  44. package/dist/clis/twitter/unblock.js +1 -1
  45. package/dist/clis/twitter/unbookmark.js +1 -1
  46. package/dist/clis/twitter/unfollow.js +1 -1
  47. package/dist/clis/xiaohongshu/comments.test.js +1 -0
  48. package/dist/clis/xiaohongshu/creator-note-detail.test.js +1 -0
  49. package/dist/clis/xiaohongshu/creator-notes.test.js +1 -0
  50. package/dist/clis/xiaohongshu/publish.test.js +1 -0
  51. package/dist/clis/xiaohongshu/search.test.js +1 -0
  52. package/dist/daemon.js +14 -3
  53. package/dist/download/index.js +39 -33
  54. package/dist/download/index.test.js +15 -1
  55. package/dist/execution.js +3 -2
  56. package/dist/external-clis.yaml +16 -0
  57. package/dist/main.js +2 -0
  58. package/dist/node-network.d.ts +10 -0
  59. package/dist/node-network.js +174 -0
  60. package/dist/node-network.test.d.ts +1 -0
  61. package/dist/node-network.test.js +55 -0
  62. package/dist/pipeline/executor.test.js +1 -0
  63. package/dist/pipeline/steps/download.test.js +1 -0
  64. package/dist/pipeline/steps/intercept.js +4 -5
  65. package/dist/serialization.js +6 -1
  66. package/dist/serialization.test.d.ts +1 -0
  67. package/dist/serialization.test.js +23 -0
  68. package/dist/types.d.ts +2 -0
  69. package/dist/utils.d.ts +2 -0
  70. package/dist/utils.js +4 -0
  71. package/docs/superpowers/plans/2026-03-28-perf-smart-wait.md +1143 -0
  72. package/docs/superpowers/specs/2026-03-28-perf-smart-wait-design.md +170 -0
  73. package/extension/dist/background.js +12 -5
  74. package/extension/manifest.json +2 -2
  75. package/extension/package-lock.json +2 -2
  76. package/extension/package.json +1 -1
  77. package/extension/src/background.ts +20 -6
  78. package/extension/src/protocol.ts +2 -1
  79. package/package.json +2 -1
  80. package/src/browser/cdp.ts +21 -0
  81. package/src/browser/daemon-client.ts +3 -2
  82. package/src/browser/dom-helpers.test.ts +100 -0
  83. package/src/browser/dom-helpers.ts +44 -0
  84. package/src/browser/index.ts +0 -15
  85. package/src/browser/mcp.ts +4 -3
  86. package/src/browser/page.ts +16 -0
  87. package/src/browser.test.ts +16 -12
  88. package/src/build-manifest.test.ts +117 -88
  89. package/src/build-manifest.ts +81 -180
  90. package/src/clis/36kr/hot.ts +1 -1
  91. package/src/clis/36kr/search.ts +1 -1
  92. package/src/clis/_shared/common.ts +11 -0
  93. package/src/clis/bloomberg/news.ts +1 -1
  94. package/src/clis/douban/utils.ts +3 -7
  95. package/src/clis/medium/utils.ts +1 -1
  96. package/src/clis/producthunt/browse.ts +1 -1
  97. package/src/clis/producthunt/hot.ts +1 -1
  98. package/src/clis/sinablog/utils.ts +6 -7
  99. package/src/clis/substack/utils.ts +2 -2
  100. package/src/clis/twitter/block.ts +1 -1
  101. package/src/clis/twitter/bookmark.ts +1 -1
  102. package/src/clis/twitter/delete.ts +1 -1
  103. package/src/clis/twitter/follow.ts +1 -1
  104. package/src/clis/twitter/followers.ts +2 -2
  105. package/src/clis/twitter/following.ts +2 -2
  106. package/src/clis/twitter/hide-reply.ts +1 -1
  107. package/src/clis/twitter/like.ts +1 -1
  108. package/src/clis/twitter/notifications.ts +1 -1
  109. package/src/clis/twitter/profile.ts +1 -1
  110. package/src/clis/twitter/reply-dm.ts +1 -1
  111. package/src/clis/twitter/reply.ts +1 -1
  112. package/src/clis/twitter/search.ts +1 -1
  113. package/src/clis/twitter/unblock.ts +1 -1
  114. package/src/clis/twitter/unbookmark.ts +1 -1
  115. package/src/clis/twitter/unfollow.ts +1 -1
  116. package/src/clis/xiaohongshu/comments.test.ts +1 -0
  117. package/src/clis/xiaohongshu/creator-note-detail.test.ts +1 -0
  118. package/src/clis/xiaohongshu/creator-notes.test.ts +1 -0
  119. package/src/clis/xiaohongshu/publish.test.ts +1 -0
  120. package/src/clis/xiaohongshu/search.test.ts +1 -0
  121. package/src/daemon.ts +16 -4
  122. package/src/download/index.test.ts +19 -1
  123. package/src/download/index.ts +50 -41
  124. package/src/execution.ts +3 -2
  125. package/src/external-clis.yaml +16 -0
  126. package/src/main.ts +3 -0
  127. package/src/node-network.test.ts +93 -0
  128. package/src/node-network.ts +213 -0
  129. package/src/pipeline/executor.test.ts +1 -0
  130. package/src/pipeline/steps/download.test.ts +1 -0
  131. package/src/pipeline/steps/intercept.ts +4 -5
  132. package/src/serialization.test.ts +26 -0
  133. package/src/serialization.ts +6 -1
  134. package/src/types.ts +2 -0
  135. package/src/utils.ts +5 -0
@@ -0,0 +1,10 @@
1
+ import { type Dispatcher } from 'undici';
2
+ export interface ProxyDecision {
3
+ mode: 'direct' | 'proxy';
4
+ proxyUrl?: string;
5
+ }
6
+ export declare function hasProxyEnv(env?: NodeJS.ProcessEnv): boolean;
7
+ export declare function decideProxy(url: URL, env?: NodeJS.ProcessEnv): ProxyDecision;
8
+ export declare function getDispatcherForUrl(url: URL, env?: NodeJS.ProcessEnv): Dispatcher;
9
+ export declare function fetchWithNodeNetwork(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
10
+ export declare function installNodeNetwork(): void;
@@ -0,0 +1,174 @@
1
+ import { Agent, EnvHttpProxyAgent, fetch as undiciFetch } from 'undici';
2
+ const LOOPBACK_NO_PROXY_ENTRIES = ['127.0.0.1', 'localhost', '::1'];
3
+ const PROXY_ENV_BY_PROTOCOL = {
4
+ 'http:': ['http_proxy', 'HTTP_PROXY', 'all_proxy', 'ALL_PROXY'],
5
+ 'https:': ['https_proxy', 'HTTPS_PROXY', 'all_proxy', 'ALL_PROXY'],
6
+ };
7
+ const DEFAULT_PORT_BY_PROTOCOL = {
8
+ 'http:': '80',
9
+ 'https:': '443',
10
+ };
11
+ let installed = false;
12
+ const directDispatcher = new Agent();
13
+ const proxyDispatcherCache = new Map();
14
+ const nativeFetch = globalThis.fetch.bind(globalThis);
15
+ function readEnv(env, lower, upper) {
16
+ const lowerValue = env[lower];
17
+ if (typeof lowerValue === 'string' && lowerValue.trim() !== '')
18
+ return lowerValue;
19
+ const upperValue = env[upper];
20
+ if (typeof upperValue === 'string' && upperValue.trim() !== '')
21
+ return upperValue;
22
+ return undefined;
23
+ }
24
+ function readProxyEnv(env, keys) {
25
+ for (const key of keys) {
26
+ const value = env[key];
27
+ if (typeof value === 'string' && value.trim() !== '')
28
+ return value;
29
+ }
30
+ return undefined;
31
+ }
32
+ function normalizeHostname(hostname) {
33
+ return hostname.replace(/^\[(.*)\]$/, '$1').toLowerCase();
34
+ }
35
+ function splitNoProxy(raw) {
36
+ return (raw ?? '')
37
+ .split(/[,\s]+/)
38
+ .map((token) => token.trim())
39
+ .filter(Boolean);
40
+ }
41
+ function parseNoProxyEntry(entry) {
42
+ if (entry === '*')
43
+ return { host: '*' };
44
+ const trimmed = entry.trim().replace(/^\*?\./, '');
45
+ if (trimmed.startsWith('[')) {
46
+ const end = trimmed.indexOf(']');
47
+ if (end !== -1) {
48
+ const host = trimmed.slice(1, end);
49
+ const rest = trimmed.slice(end + 1);
50
+ if (rest.startsWith(':'))
51
+ return { host: normalizeHostname(host), port: rest.slice(1) };
52
+ return { host: normalizeHostname(host) };
53
+ }
54
+ }
55
+ const colonCount = (trimmed.match(/:/g) ?? []).length;
56
+ if (colonCount === 1) {
57
+ const [host, port] = trimmed.split(':');
58
+ return { host: normalizeHostname(host), port };
59
+ }
60
+ return { host: normalizeHostname(trimmed) };
61
+ }
62
+ function effectiveNoProxyEntries(env) {
63
+ const raw = readEnv(env, 'no_proxy', 'NO_PROXY');
64
+ const entries = splitNoProxy(raw).map(parseNoProxyEntry);
65
+ const seen = new Set(entries.map((entry) => `${entry.host}:${entry.port ?? ''}`));
66
+ for (const rawEntry of LOOPBACK_NO_PROXY_ENTRIES) {
67
+ const entry = parseNoProxyEntry(rawEntry);
68
+ const key = `${entry.host}:${entry.port ?? ''}`;
69
+ if (seen.has(key))
70
+ continue;
71
+ entries.push(entry);
72
+ seen.add(key);
73
+ }
74
+ return entries;
75
+ }
76
+ function serializeNoProxyEntry(entry) {
77
+ if (entry.host === '*')
78
+ return '*';
79
+ const host = entry.host.includes(':') ? `[${entry.host}]` : entry.host;
80
+ return entry.port ? `${host}:${entry.port}` : host;
81
+ }
82
+ function effectiveNoProxyValue(entries) {
83
+ if (entries.length === 0)
84
+ return undefined;
85
+ return entries.map(serializeNoProxyEntry).join(',');
86
+ }
87
+ function matchesNoProxyEntry(url, entry) {
88
+ const { host, port } = entry;
89
+ if (host === '*')
90
+ return true;
91
+ const hostname = normalizeHostname(url.hostname);
92
+ const urlPort = url.port || DEFAULT_PORT_BY_PROTOCOL[url.protocol] || undefined;
93
+ if (port && port !== urlPort)
94
+ return false;
95
+ return hostname === host || hostname.endsWith(`.${host}`);
96
+ }
97
+ function resolveProxyConfig(env = process.env) {
98
+ const noProxyEntries = effectiveNoProxyEntries(env);
99
+ return {
100
+ httpProxy: readProxyEnv(env, PROXY_ENV_BY_PROTOCOL['http:']),
101
+ httpsProxy: readProxyEnv(env, [
102
+ 'https_proxy',
103
+ 'HTTPS_PROXY',
104
+ 'http_proxy',
105
+ 'HTTP_PROXY',
106
+ 'all_proxy',
107
+ 'ALL_PROXY',
108
+ ]),
109
+ noProxy: effectiveNoProxyValue(noProxyEntries),
110
+ noProxyEntries,
111
+ };
112
+ }
113
+ function createProxyDispatcher(config) {
114
+ const cacheKey = JSON.stringify([
115
+ config.httpProxy ?? '',
116
+ config.httpsProxy ?? '',
117
+ config.noProxy ?? '',
118
+ ]);
119
+ const cached = proxyDispatcherCache.get(cacheKey);
120
+ if (cached)
121
+ return cached;
122
+ const dispatcher = new EnvHttpProxyAgent({
123
+ httpProxy: config.httpProxy,
124
+ httpsProxy: config.httpsProxy,
125
+ noProxy: config.noProxy,
126
+ });
127
+ proxyDispatcherCache.set(cacheKey, dispatcher);
128
+ return dispatcher;
129
+ }
130
+ function resolveUrl(input) {
131
+ if (typeof input === 'string')
132
+ return new URL(input);
133
+ if (input instanceof URL)
134
+ return input;
135
+ if (typeof Request !== 'undefined' && input instanceof Request)
136
+ return new URL(input.url);
137
+ return null;
138
+ }
139
+ export function hasProxyEnv(env = process.env) {
140
+ const config = resolveProxyConfig(env);
141
+ return Boolean(config.httpProxy || config.httpsProxy);
142
+ }
143
+ export function decideProxy(url, env = process.env) {
144
+ const config = resolveProxyConfig(env);
145
+ if (config.noProxyEntries.some((entry) => matchesNoProxyEntry(url, entry))) {
146
+ return { mode: 'direct' };
147
+ }
148
+ const proxyUrl = url.protocol === 'https:' ? config.httpsProxy : config.httpProxy;
149
+ if (!proxyUrl)
150
+ return { mode: 'direct' };
151
+ return { mode: 'proxy', proxyUrl };
152
+ }
153
+ export function getDispatcherForUrl(url, env = process.env) {
154
+ const config = resolveProxyConfig(env);
155
+ if (!config.httpProxy && !config.httpsProxy)
156
+ return directDispatcher;
157
+ return createProxyDispatcher(config);
158
+ }
159
+ export async function fetchWithNodeNetwork(input, init = {}) {
160
+ const url = resolveUrl(input);
161
+ if (!url || !hasProxyEnv()) {
162
+ return nativeFetch(input, init);
163
+ }
164
+ return (await undiciFetch(input, {
165
+ ...init,
166
+ dispatcher: getDispatcherForUrl(url),
167
+ }));
168
+ }
169
+ export function installNodeNetwork() {
170
+ if (installed)
171
+ return;
172
+ globalThis.fetch = ((input, init) => (fetchWithNodeNetwork(input, init)));
173
+ installed = true;
174
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { decideProxy, hasProxyEnv } from './node-network.js';
3
+ describe('node network proxy decisions', () => {
4
+ it('detects common proxy env variables', () => {
5
+ expect(hasProxyEnv({ https_proxy: 'http://127.0.0.1:7897' })).toBe(true);
6
+ expect(hasProxyEnv({ HTTP_PROXY: 'http://proxy.example:8080' })).toBe(true);
7
+ expect(hasProxyEnv({})).toBe(false);
8
+ });
9
+ it('routes external https traffic through https_proxy', () => {
10
+ const decision = decideProxy(new URL('https://www.v2ex.com/api/topics/latest.json'), { https_proxy: 'http://127.0.0.1:7897' });
11
+ expect(decision).toEqual({
12
+ mode: 'proxy',
13
+ proxyUrl: 'http://127.0.0.1:7897',
14
+ });
15
+ });
16
+ it('falls back to HTTP_PROXY for https traffic when HTTPS_PROXY is absent', () => {
17
+ const decision = decideProxy(new URL('https://www.v2ex.com/api/topics/latest.json'), { HTTP_PROXY: 'http://127.0.0.1:7897' });
18
+ expect(decision).toEqual({
19
+ mode: 'proxy',
20
+ proxyUrl: 'http://127.0.0.1:7897',
21
+ });
22
+ });
23
+ it('bypasses proxies for loopback addresses', () => {
24
+ const env = { https_proxy: 'http://127.0.0.1:7897', http_proxy: 'http://127.0.0.1:7897' };
25
+ expect(decideProxy(new URL('http://127.0.0.1:19825/status'), env)).toEqual({ mode: 'direct' });
26
+ expect(decideProxy(new URL('http://localhost:19825/status'), env)).toEqual({ mode: 'direct' });
27
+ expect(decideProxy(new URL('http://[::1]:19825/status'), env)).toEqual({ mode: 'direct' });
28
+ });
29
+ it('honors NO_PROXY domain matches', () => {
30
+ const decision = decideProxy(new URL('https://api.example.com/v1/items'), {
31
+ https_proxy: 'http://127.0.0.1:7897',
32
+ no_proxy: '.example.com',
33
+ });
34
+ expect(decision).toEqual({ mode: 'direct' });
35
+ });
36
+ it('supports wildcard-style NO_PROXY subdomain entries', () => {
37
+ const decision = decideProxy(new URL('https://api.example.com/v1/items'), {
38
+ https_proxy: 'http://127.0.0.1:7897',
39
+ no_proxy: '*.example.com',
40
+ });
41
+ expect(decision).toEqual({ mode: 'direct' });
42
+ });
43
+ it('matches NO_PROXY entries that rely on the default URL port', () => {
44
+ const env = { https_proxy: 'http://127.0.0.1:7897', http_proxy: 'http://127.0.0.1:7897' };
45
+ expect(decideProxy(new URL('https://example.com/'), { ...env, NO_PROXY: 'example.com:443' })).toEqual({ mode: 'direct' });
46
+ expect(decideProxy(new URL('http://example.com/health'), { ...env, NO_PROXY: 'example.com:80' })).toEqual({ mode: 'direct' });
47
+ });
48
+ it('falls back to ALL_PROXY when protocol-specific settings are absent', () => {
49
+ const decision = decideProxy(new URL('http://example.net/data'), { ALL_PROXY: 'socks5://127.0.0.1:1080' });
50
+ expect(decision).toEqual({
51
+ mode: 'proxy',
52
+ proxyUrl: 'socks5://127.0.0.1:1080',
53
+ });
54
+ });
55
+ });
@@ -28,6 +28,7 @@ function createMockPage(overrides = {}) {
28
28
  installInterceptor: vi.fn(),
29
29
  getInterceptedRequests: vi.fn().mockResolvedValue([]),
30
30
  screenshot: vi.fn().mockResolvedValue(''),
31
+ waitForCapture: vi.fn().mockResolvedValue(undefined),
31
32
  ...overrides,
32
33
  };
33
34
  }
@@ -39,6 +39,7 @@ function createMockPage(getCookies) {
39
39
  installInterceptor: vi.fn(),
40
40
  getInterceptedRequests: vi.fn().mockResolvedValue([]),
41
41
  screenshot: vi.fn().mockResolvedValue(''),
42
+ waitForCapture: vi.fn().mockResolvedValue(undefined),
42
43
  };
43
44
  }
44
45
  describe('stepDownload', () => {
@@ -2,7 +2,6 @@
2
2
  * Pipeline step: intercept — declarative XHR interception.
3
3
  */
4
4
  import { render, normalizeEvaluateSource } from '../template.js';
5
- import { generateInterceptorJs, generateReadInterceptedJs } from '../../interceptor.js';
6
5
  export async function stepIntercept(page, params, data, args) {
7
6
  const cfg = typeof params === 'object' ? params : {};
8
7
  const trigger = cfg.trigger ?? '';
@@ -12,7 +11,7 @@ export async function stepIntercept(page, params, data, args) {
12
11
  if (!capturePattern)
13
12
  return data;
14
13
  // Step 1: Inject fetch/XHR interceptor BEFORE trigger
15
- await page.evaluate(generateInterceptorJs(JSON.stringify(capturePattern)));
14
+ await page.installInterceptor(capturePattern);
16
15
  // Step 2: Execute the trigger action
17
16
  if (trigger.startsWith('navigate:')) {
18
17
  const url = render(trigger.slice('navigate:'.length), { args, data });
@@ -29,10 +28,10 @@ export async function stepIntercept(page, params, data, args) {
29
28
  else if (trigger === 'scroll') {
30
29
  await page.scroll('down');
31
30
  }
32
- // Step 3: Wait a bit for network requests to fire
33
- await page.wait(Math.min(timeout, 3));
31
+ // Step 3: Wait for network capture (event-driven, not fixed sleep)
32
+ await page.waitForCapture(timeout);
34
33
  // Step 4: Retrieve captured data
35
- const matchingResponses = await page.evaluate(generateReadInterceptedJs());
34
+ const matchingResponses = await page.getInterceptedRequests();
36
35
  // Step 5: Select from response if specified
37
36
  let result = matchingResponses.length === 1 ? matchingResponses[0] :
38
37
  matchingResponses.length > 1 ? matchingResponses : data;
@@ -44,6 +44,11 @@ export function formatArgSummary(args) {
44
44
  })
45
45
  .join(' ');
46
46
  }
47
+ function summarizeChoices(choices) {
48
+ if (choices.length <= 4)
49
+ return choices.join(', ');
50
+ return `${choices.slice(0, 4).join(', ')}, ... (+${choices.length - 4} more)`;
51
+ }
47
52
  /** Generate the --help appendix showing registry metadata not exposed by Commander. */
48
53
  export function formatRegistryHelpText(cmd) {
49
54
  const lines = [];
@@ -51,7 +56,7 @@ export function formatRegistryHelpText(cmd) {
51
56
  for (const a of choicesArgs) {
52
57
  const prefix = a.positional ? `<${a.name}>` : `--${a.name}`;
53
58
  const def = a.default != null ? ` (default: ${a.default})` : '';
54
- lines.push(` ${prefix}: ${a.choices.join(', ')}${def}`);
59
+ lines.push(` ${prefix}: ${summarizeChoices(a.choices)}${def}`);
55
60
  }
56
61
  const meta = [];
57
62
  meta.push(`Strategy: ${strategyLabel(cmd)}`);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { Strategy } from './registry.js';
3
+ import { formatRegistryHelpText } from './serialization.js';
4
+ describe('formatRegistryHelpText', () => {
5
+ it('summarizes long choices lists so help text stays readable', () => {
6
+ const cmd = {
7
+ site: 'demo',
8
+ name: 'dynamic',
9
+ description: 'Demo command',
10
+ strategy: Strategy.PUBLIC,
11
+ browser: false,
12
+ args: [
13
+ {
14
+ name: 'field',
15
+ help: 'Field to use',
16
+ choices: ['all-fields', 'topic', 'title', 'author', 'publication-titles', 'year-published', 'doi'],
17
+ },
18
+ ],
19
+ columns: ['field'],
20
+ };
21
+ expect(formatRegistryHelpText(cmd)).toContain('--field: all-fields, topic, title, author, ... (+3 more)');
22
+ });
23
+ });
package/dist/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface SnapshotOptions {
23
23
  }
24
24
  export interface WaitOptions {
25
25
  text?: string;
26
+ selector?: string;
26
27
  time?: number;
27
28
  timeout?: number;
28
29
  }
@@ -67,6 +68,7 @@ export interface IPage {
67
68
  }): Promise<void>;
68
69
  installInterceptor(pattern: string): Promise<void>;
69
70
  getInterceptedRequests(): Promise<any[]>;
71
+ waitForCapture(timeout?: number): Promise<void>;
70
72
  screenshot(options?: ScreenshotOptions): Promise<string>;
71
73
  closeWindow?(): Promise<void>;
72
74
  /** Returns the current page URL, or null if unavailable. */
package/dist/utils.d.ts CHANGED
@@ -5,5 +5,7 @@
5
5
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
6
6
  /** Simple async concurrency limiter. */
7
7
  export declare function mapConcurrent<T, R>(items: T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
8
+ /** Pause for the given number of milliseconds. */
9
+ export declare function sleep(ms: number): Promise<void>;
8
10
  /** Save a base64-encoded string to a file, creating parent directories as needed. */
9
11
  export declare function saveBase64ToFile(base64: string, filePath: string): Promise<void>;
package/dist/utils.js CHANGED
@@ -21,6 +21,10 @@ export async function mapConcurrent(items, limit, fn) {
21
21
  await Promise.all(workers);
22
22
  return results;
23
23
  }
24
+ /** Pause for the given number of milliseconds. */
25
+ export function sleep(ms) {
26
+ return new Promise(resolve => setTimeout(resolve, ms));
27
+ }
24
28
  /** Save a base64-encoded string to a file, creating parent directories as needed. */
25
29
  export async function saveBase64ToFile(base64, filePath) {
26
30
  const dir = path.dirname(filePath);