@crawlee/core 4.0.0-beta.170 → 4.0.0-beta.172

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 (77) hide show
  1. package/errors.d.ts +0 -57
  2. package/errors.js +0 -71
  3. package/events/index.d.ts +1 -0
  4. package/events/system_info.d.ts +38 -0
  5. package/index.d.ts +1 -7
  6. package/index.js +1 -7
  7. package/internal.d.ts +8 -0
  8. package/internal.js +9 -0
  9. package/package.json +7 -9
  10. package/request.d.ts +4 -2
  11. package/service_locator.js +1 -0
  12. package/storages/index.d.ts +0 -2
  13. package/storages/index.js +0 -2
  14. package/autoscaling/autoscaled_pool.d.ts +0 -196
  15. package/autoscaling/autoscaled_pool.js +0 -386
  16. package/autoscaling/concurrency_system.d.ts +0 -268
  17. package/autoscaling/concurrency_system.js +0 -364
  18. package/autoscaling/cpu_load_signal.d.ts +0 -43
  19. package/autoscaling/cpu_load_signal.js +0 -47
  20. package/autoscaling/event_loop_load_signal.d.ts +0 -51
  21. package/autoscaling/event_loop_load_signal.js +0 -60
  22. package/autoscaling/index.d.ts +0 -9
  23. package/autoscaling/index.js +0 -9
  24. package/autoscaling/load_signal.d.ts +0 -98
  25. package/autoscaling/load_signal.js +0 -103
  26. package/autoscaling/memory_load_signal.d.ts +0 -47
  27. package/autoscaling/memory_load_signal.js +0 -106
  28. package/autoscaling/snapshotter.d.ts +0 -84
  29. package/autoscaling/snapshotter.js +0 -67
  30. package/autoscaling/storage_backend_load_signal.d.ts +0 -56
  31. package/autoscaling/storage_backend_load_signal.js +0 -73
  32. package/autoscaling/system_status.d.ts +0 -159
  33. package/autoscaling/system_status.js +0 -139
  34. package/autoscaling/weighted_avg.d.ts +0 -5
  35. package/autoscaling/weighted_avg.js +0 -14
  36. package/cookie_utils.d.ts +0 -44
  37. package/cookie_utils.js +0 -122
  38. package/crawlers/context_pipeline.d.ts +0 -70
  39. package/crawlers/context_pipeline.js +0 -122
  40. package/crawlers/crawler_commons.d.ts +0 -199
  41. package/crawlers/error_snapshotter.d.ts +0 -57
  42. package/crawlers/error_snapshotter.js +0 -117
  43. package/crawlers/error_tracker.d.ts +0 -54
  44. package/crawlers/error_tracker.js +0 -308
  45. package/crawlers/index.d.ts +0 -5
  46. package/crawlers/index.js +0 -4
  47. package/crawlers/internals/types.d.ts +0 -7
  48. package/crawlers/internals/types.js +0 -1
  49. package/crawlers/statistics.d.ts +0 -319
  50. package/crawlers/statistics.js +0 -527
  51. package/enqueue_links/enqueue_links.d.ts +0 -156
  52. package/enqueue_links/enqueue_links.js +0 -77
  53. package/enqueue_links/index.d.ts +0 -2
  54. package/enqueue_links/index.js +0 -2
  55. package/enqueue_links/shared.d.ts +0 -100
  56. package/enqueue_links/shared.js +0 -259
  57. package/http.d.ts +0 -9
  58. package/http.js +0 -28
  59. package/router.d.ts +0 -306
  60. package/router.js +0 -309
  61. package/session_pool/consts.d.ts +0 -3
  62. package/session_pool/consts.js +0 -3
  63. package/session_pool/errors.d.ts +0 -7
  64. package/session_pool/errors.js +0 -11
  65. package/session_pool/fingerprint.d.ts +0 -9
  66. package/session_pool/fingerprint.js +0 -30
  67. package/session_pool/index.d.ts +0 -4
  68. package/session_pool/index.js +0 -4
  69. package/session_pool/session.d.ts +0 -153
  70. package/session_pool/session.js +0 -221
  71. package/session_pool/session_pool.d.ts +0 -242
  72. package/session_pool/session_pool.js +0 -431
  73. package/storages/sitemap_request_loader.d.ts +0 -197
  74. package/storages/sitemap_request_loader.js +0 -439
  75. package/storages/throttling_request_manager.d.ts +0 -223
  76. package/storages/throttling_request_manager.js +0 -835
  77. /package/{crawlers/crawler_commons.js → events/system_info.js} +0 -0
@@ -1,77 +0,0 @@
1
- import { EnqueueStrategy } from '@crawlee/utils';
2
- import { getDomain } from 'tldts';
3
- export { EnqueueStrategy };
4
- /**
5
- * @internal
6
- * This method helps resolve the baseUrl that will be used for filtering in {@link enqueueLinks}.
7
- * - If a user provides a base url, we always return it
8
- * - If a user specifies {@link EnqueueStrategy.All} strategy, they do not care if the newly found urls are on the original
9
- * request domain, or a redirected one
10
- * - In all other cases, we return the domain of the original request as that's the one we need to use for filtering
11
- */
12
- export function resolveBaseUrlForEnqueueLinksFiltering({ enqueueStrategy, finalRequestUrl, originalRequestUrl, userProvidedBaseUrl, }) {
13
- // User provided base url takes priority
14
- if (userProvidedBaseUrl) {
15
- return userProvidedBaseUrl;
16
- }
17
- const originalUrlOrigin = new URL(originalRequestUrl).origin;
18
- const finalUrlOrigin = new URL(finalRequestUrl ?? originalRequestUrl).origin;
19
- // We can assume users want to go off the domain in this case
20
- if (enqueueStrategy === EnqueueStrategy.All) {
21
- return finalUrlOrigin;
22
- }
23
- // If the user wants to ensure the same domain is accessed, regardless of subdomains, we check to ensure the domains match
24
- // If they don't (we went off domain via a redirect), we keep filtering against the original domain - returning undefined would disable the filtering entirely
25
- if (enqueueStrategy === EnqueueStrategy.SameDomain) {
26
- const originalHostname = getDomain(originalUrlOrigin, { mixedInputs: false });
27
- const finalHostname = getDomain(finalUrlOrigin, { mixedInputs: false });
28
- if (originalHostname === finalHostname) {
29
- return finalUrlOrigin;
30
- }
31
- return originalUrlOrigin;
32
- }
33
- // Always enqueue urls that are from the same origin in all other cases, as the filtering happens on the original request url, even if there was a redirect
34
- // before actually finding the urls
35
- return originalUrlOrigin;
36
- }
37
- /**
38
- * @internal
39
- * Builds the glob patterns a URL must match to satisfy the given enqueue `strategy`, anchored at `baseUrl`.
40
- */
41
- export function buildEnqueueStrategyPatterns(baseUrl, strategy) {
42
- const url = new URL(baseUrl);
43
- switch (strategy) {
44
- case EnqueueStrategy.SameHostname:
45
- // We need to get the origin of the passed in domain in the event someone sets baseUrl
46
- // to an url like https://example.com/deep/default/path and one of the found urls is an
47
- // absolute relative path (/path/to/page)
48
- return [{ glob: ignoreHttpSchema(`${url.origin}/**`) }];
49
- case EnqueueStrategy.SameDomain: {
50
- // Get the actual hostname from the base url
51
- const baseUrlHostname = getDomain(url.hostname, { mixedInputs: false });
52
- if (baseUrlHostname) {
53
- // We have a hostname, so we can use it to match all links on the page that point to it and any subdomains of it
54
- url.hostname = baseUrlHostname;
55
- return [
56
- { glob: ignoreHttpSchema(`${url.origin.replace(baseUrlHostname, `*.${baseUrlHostname}`)}/**`) },
57
- { glob: ignoreHttpSchema(`${url.origin}/**`) },
58
- ];
59
- }
60
- // We don't have a hostname (can happen for ips for instance), so reproduce the same behavior
61
- // as SameDomainAndSubdomain
62
- return [{ glob: ignoreHttpSchema(`${url.origin}/**`) }];
63
- }
64
- case EnqueueStrategy.SameOrigin:
65
- // The same behavior as SameHostname, but respecting the protocol of the URL
66
- return [{ glob: `${url.origin}/**` }];
67
- case EnqueueStrategy.All:
68
- default:
69
- return [{ glob: `http{s,}://**` }];
70
- }
71
- }
72
- /**
73
- * Internal function that changes the enqueue glob patterns to match both http and https
74
- */
75
- function ignoreHttpSchema(pattern) {
76
- return pattern.replace(/^(https?):\/\//, 'http{s,}://');
77
- }
@@ -1,2 +0,0 @@
1
- export * from './enqueue_links.js';
2
- export * from './shared.js';
@@ -1,2 +0,0 @@
1
- export * from './enqueue_links.js';
2
- export * from './shared.js';
@@ -1,100 +0,0 @@
1
- import type { Awaitable, Dictionary } from '@crawlee/types';
2
- import { z } from 'zod';
3
- import type { RequestOptions, Source } from '../request.js';
4
- import { Request } from '../request.js';
5
- import type { EnqueueStrategyOption } from './enqueue_links.js';
6
- export interface UrlPatternObject {
7
- glob?: string;
8
- regexp?: RegExp;
9
- }
10
- export interface GlobObject {
11
- glob: string;
12
- }
13
- export type GlobInput = string | GlobObject;
14
- export interface RegExpObject {
15
- regexp: RegExp;
16
- }
17
- export type RegExpInput = RegExp | RegExpObject;
18
- /** Unified URL pattern input — accepts glob strings, glob objects, RegExp instances, or regexp objects. */
19
- export type UrlPatternInput = GlobInput | RegExpInput;
20
- /**
21
- * Accepts one {@link UrlPatternInput} — a glob string, a RegExp instance, or a `{ glob }` / `{ regexp }` object.
22
- * @internal
23
- */
24
- export declare const urlPatternSchema: z.ZodType<UrlPatternInput>;
25
- export type SkippedRequestReason = 'robotsTxt' | 'limit' | 'enqueueLimit' | 'filters' | 'transform' | 'redirect' | 'depth';
26
- export type SkippedRequestCallback = (args: {
27
- request: Request;
28
- reason: SkippedRequestReason;
29
- }) => Awaitable<void>;
30
- /**
31
- * Builds the `{ request, reason }` argument passed to a {@link SkippedRequestCallback}, constructing the
32
- * `Request` lazily on first access to `request` (and caching it) since most skips are never observed by a
33
- * real callback and building a `Request` isn't free.
34
- * @ignore
35
- */
36
- export declare function createSkippedRequestArgs(source: string | Source, reason: SkippedRequestReason): Parameters<SkippedRequestCallback>[0];
37
- /**
38
- * @ignore
39
- */
40
- export declare function updateEnqueueLinksPatternCache(item: GlobInput | RegExpInput, pattern: RegExpObject | GlobObject): void;
41
- /**
42
- * Helper factory used in the `enqueueLinks()` and enqueueLinksByClickingElements() function
43
- * to construct Glob objects from Glob pattern strings.
44
- * @ignore
45
- */
46
- export declare function constructGlobObjectsFromGlobs(globs: readonly GlobInput[]): GlobObject[];
47
- /**
48
- * @internal
49
- */
50
- export declare function validateGlobPattern(glob: string): string;
51
- /**
52
- * Helper factory used in the `enqueueLinks()` and enqueueLinksByClickingElements() function
53
- * to check RegExps input and return valid RegExps.
54
- * @ignore
55
- */
56
- export declare function constructRegExpObjectsFromRegExps(regexps: readonly RegExpInput[]): RegExpObject[];
57
- /**
58
- * Helper factory used in the `enqueueLinks()` function to construct UrlPatternObjects
59
- * from a mixed array of glob strings, glob objects, RegExp instances, and regexp objects.
60
- * @ignore
61
- */
62
- export declare function constructUrlPatternObjects(patterns: readonly UrlPatternInput[]): UrlPatternObject[];
63
- /**
64
- * Filters request options by URL patterns.
65
- *
66
- * When `includePatterns` is empty/undefined, all options pass through (only exclude filtering applies).
67
- * @ignore
68
- */
69
- export declare function filterRequestOptionsByPatterns(requestOptions: RequestOptions[], includePatterns: UrlPatternObject[] | undefined, excludePatterns?: UrlPatternObject[], strategy?: EnqueueStrategyOption, onSkippedRequestOptions?: (options: RequestOptions) => void): RequestOptions[];
70
- /**
71
- * @ignore
72
- */
73
- export declare function createRequestOptions(sources: readonly (string | Record<string, unknown>)[], options?: {
74
- label?: string;
75
- userData?: Dictionary;
76
- baseUrl?: string;
77
- skipNavigation?: boolean;
78
- sessionId?: string;
79
- strategy?: EnqueueStrategyOption;
80
- }): RequestOptions[];
81
- /**
82
- * Takes a {@link RequestOptions} object and changes its attributes in a desired way. This user-function is used
83
- * by {@link enqueueLinks} to modify request options before they are converted to {@link Request} instances.
84
- */
85
- export interface RequestTransform {
86
- /**
87
- * @param original Request options to be modified.
88
- * @returns The modified request options to enqueue, `'unchanged'` to keep the original options as-is,
89
- * or a falsy value / `'skip'` to exclude the request from the queue.
90
- */
91
- (original: RequestOptions): RequestOptions | false | undefined | null | 'skip' | 'unchanged';
92
- }
93
- /**
94
- * Applies a {@link RequestTransform} function to a list of request options.
95
- * Options for which the transform returns a falsy value are removed from the list.
96
- * @param onSkipped Called with the original request options when the transform returns a falsy value (i.e. the request is skipped).
97
- * @ignore
98
- * @internal
99
- */
100
- export declare function applyRequestTransform(requestOptions: RequestOptions[], transformFn: RequestTransform, onSkipped?: (requestOptions: RequestOptions) => void): RequestOptions[];
@@ -1,259 +0,0 @@
1
- import { URL } from 'node:url';
2
- import { Minimatch } from 'minimatch';
3
- import { z } from 'zod';
4
- import { Request } from '../request.js';
5
- import { schemas } from '../validators.js';
6
- const MAX_ENQUEUE_LINKS_CACHE_SIZE = 1000;
7
- /**
8
- * To keep high performance when the same patterns are passed on every `enqueueLinks()` call,
9
- * each glob/regexp is only compiled once and then kept in a cache.
10
- * @ignore
11
- */
12
- const enqueueLinksPatternCache = new Map();
13
- /**
14
- * Accepts one {@link UrlPatternInput} — a glob string, a RegExp instance, or a `{ glob }` / `{ regexp }` object.
15
- * @internal
16
- */
17
- export const urlPatternSchema = z.union([
18
- z.string(),
19
- z.instanceof(RegExp),
20
- schemas.objectWithKeys(['glob']),
21
- schemas.objectWithKeys(['regexp']),
22
- ]);
23
- /**
24
- * Builds the `{ request, reason }` argument passed to a {@link SkippedRequestCallback}, constructing the
25
- * `Request` lazily on first access to `request` (and caching it) since most skips are never observed by a
26
- * real callback and building a `Request` isn't free.
27
- * @ignore
28
- */
29
- export function createSkippedRequestArgs(source, reason) {
30
- const sourceReason = typeof source === 'string' ? undefined : source.skippedReason;
31
- let request;
32
- return {
33
- reason: sourceReason ?? reason,
34
- get request() {
35
- request ??=
36
- source instanceof Request
37
- ? source
38
- : new Request(typeof source === 'string' ? { url: source } : source);
39
- return request;
40
- },
41
- };
42
- }
43
- /**
44
- * @ignore
45
- */
46
- export function updateEnqueueLinksPatternCache(item, pattern) {
47
- enqueueLinksPatternCache.set(item, pattern);
48
- if (enqueueLinksPatternCache.size > MAX_ENQUEUE_LINKS_CACHE_SIZE) {
49
- const key = enqueueLinksPatternCache.keys().next().value;
50
- enqueueLinksPatternCache.delete(key);
51
- }
52
- }
53
- /**
54
- * Helper factory used in the `enqueueLinks()` and enqueueLinksByClickingElements() function
55
- * to construct Glob objects from Glob pattern strings.
56
- * @ignore
57
- */
58
- export function constructGlobObjectsFromGlobs(globs) {
59
- return globs
60
- .filter((glob) => {
61
- // Skip possibly nullish, empty strings
62
- if (!glob) {
63
- return false;
64
- }
65
- if (typeof glob === 'string') {
66
- return glob.trim().length > 0;
67
- }
68
- if (glob.glob) {
69
- return glob.glob.trim().length > 0;
70
- }
71
- return false;
72
- })
73
- .map((item) => {
74
- // Get glob object from cache.
75
- let globObject = enqueueLinksPatternCache.get(item);
76
- if (globObject)
77
- return globObject;
78
- if (typeof item === 'string') {
79
- globObject = { glob: validateGlobPattern(item) };
80
- }
81
- else {
82
- globObject = { glob: validateGlobPattern(item.glob) };
83
- }
84
- updateEnqueueLinksPatternCache(item, globObject);
85
- return globObject;
86
- });
87
- }
88
- /**
89
- * @internal
90
- */
91
- export function validateGlobPattern(glob) {
92
- const globTrimmed = glob.trim();
93
- if (globTrimmed.length === 0)
94
- throw new Error(`Cannot parse Glob pattern '${globTrimmed}': it must be an non-empty string`);
95
- return globTrimmed;
96
- }
97
- /**
98
- * Helper factory used in the `enqueueLinks()` and enqueueLinksByClickingElements() function
99
- * to check RegExps input and return valid RegExps.
100
- * @ignore
101
- */
102
- export function constructRegExpObjectsFromRegExps(regexps) {
103
- return regexps.map((item) => {
104
- // Get regexp object from cache.
105
- let regexpObject = enqueueLinksPatternCache.get(item);
106
- if (regexpObject)
107
- return regexpObject;
108
- if (item instanceof RegExp) {
109
- regexpObject = { regexp: item };
110
- }
111
- else {
112
- regexpObject = { regexp: item.regexp };
113
- }
114
- updateEnqueueLinksPatternCache(item, regexpObject);
115
- return regexpObject;
116
- });
117
- }
118
- /**
119
- * Helper factory used in the `enqueueLinks()` function to construct UrlPatternObjects
120
- * from a mixed array of glob strings, glob objects, RegExp instances, and regexp objects.
121
- * @ignore
122
- */
123
- export function constructUrlPatternObjects(patterns) {
124
- const result = [];
125
- for (const item of patterns) {
126
- if (typeof item === 'string' || 'glob' in item) {
127
- result.push(...constructGlobObjectsFromGlobs([item]));
128
- }
129
- else if (item instanceof RegExp || 'regexp' in item) {
130
- result.push(...constructRegExpObjectsFromRegExps([item]));
131
- }
132
- }
133
- return result;
134
- }
135
- /**
136
- * Filters request options by URL patterns.
137
- *
138
- * When `includePatterns` is empty/undefined, all options pass through (only exclude filtering applies).
139
- * @ignore
140
- */
141
- export function filterRequestOptionsByPatterns(requestOptions, includePatterns, excludePatterns = [], strategy, onSkippedRequestOptions) {
142
- const excludeMatchers = excludePatterns.map(createPatternObjectMatcher);
143
- const includeMatchers = includePatterns?.length ? includePatterns.map(createPatternObjectMatcher) : undefined;
144
- return requestOptions
145
- .filter((opts) => {
146
- const matchesExclude = excludeMatchers.some(({ match }) => match(opts.url));
147
- if (matchesExclude) {
148
- onSkippedRequestOptions?.(opts);
149
- }
150
- return !matchesExclude;
151
- })
152
- .map((opts) => {
153
- if (!includeMatchers) {
154
- return { ...opts, enqueueStrategy: strategy };
155
- }
156
- for (const { match } of includeMatchers) {
157
- if (match(opts.url)) {
158
- return { ...opts, enqueueStrategy: strategy };
159
- }
160
- }
161
- // didn't match any positive pattern
162
- onSkippedRequestOptions?.(opts);
163
- return null;
164
- })
165
- .filter((opts) => opts !== null);
166
- }
167
- function isAbsoluteUrl(url) {
168
- try {
169
- // eslint-disable-next-line no-new
170
- new URL(url);
171
- return true;
172
- }
173
- catch {
174
- return false;
175
- }
176
- }
177
- /**
178
- * @ignore
179
- */
180
- export function createRequestOptions(sources, options = {}) {
181
- return sources
182
- .map((src) => typeof src === 'string'
183
- ? { url: src, enqueueStrategy: options.strategy }
184
- : { ...src, enqueueStrategy: options.strategy })
185
- .filter(({ url }) => {
186
- try {
187
- return new URL(url, options.baseUrl).href;
188
- }
189
- catch (err) {
190
- return false;
191
- }
192
- })
193
- .map((requestOptions) => {
194
- // Leave already-absolute URLs untouched - re-deriving them via `new URL()` would normalize them
195
- // (e.g. adding a trailing slash to a bare domain), which is surprising for URLs that didn't need
196
- // resolving against `baseUrl` in the first place.
197
- if (!isAbsoluteUrl(requestOptions.url)) {
198
- requestOptions.url = new URL(requestOptions.url, options.baseUrl).href;
199
- }
200
- requestOptions.userData ??= options.userData ?? {};
201
- if (typeof options.label === 'string') {
202
- requestOptions.userData = {
203
- ...requestOptions.userData,
204
- label: options.label,
205
- };
206
- }
207
- if (options.skipNavigation) {
208
- requestOptions.skipNavigation = true;
209
- }
210
- if (options.sessionId) {
211
- requestOptions.sessionId = options.sessionId;
212
- }
213
- return requestOptions;
214
- });
215
- }
216
- /**
217
- * @ignore
218
- */
219
- function createPatternObjectMatcher(urlPatternObject) {
220
- const { regexp, glob } = urlPatternObject;
221
- let match;
222
- if (regexp) {
223
- match = (url) => regexp.test(url);
224
- }
225
- else if (glob) {
226
- const m = new Minimatch(glob, { nocase: true });
227
- match = (url) => m.match(url);
228
- }
229
- else {
230
- match = () => false;
231
- }
232
- return { match };
233
- }
234
- /**
235
- * Applies a {@link RequestTransform} function to a list of request options.
236
- * Options for which the transform returns a falsy value are removed from the list.
237
- * @param onSkipped Called with the original request options when the transform returns a falsy value (i.e. the request is skipped).
238
- * @ignore
239
- * @internal
240
- */
241
- export function applyRequestTransform(requestOptions, transformFn, onSkipped) {
242
- return requestOptions
243
- .map((opts) => {
244
- const transformed = transformFn(opts);
245
- if (transformed === 'skip') {
246
- onSkipped?.(opts);
247
- return null;
248
- }
249
- if (transformed === 'unchanged') {
250
- return opts;
251
- }
252
- if (!transformed) {
253
- onSkipped?.(opts);
254
- return null;
255
- }
256
- return transformed;
257
- })
258
- .filter((r) => r !== null);
259
- }
package/http.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Parses a `Retry-After` response header into a delay in milliseconds.
3
- *
4
- * The header holds either a non-negative number of seconds or an HTTP-date.
5
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After).
6
- *
7
- * @returns The delay in milliseconds, or `null` if the header is absent, unparseable, or already elapsed.
8
- */
9
- export declare function parseRetryAfterHeader(value?: string | null): number | null;
package/http.js DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Parses a `Retry-After` response header into a delay in milliseconds.
3
- *
4
- * The header holds either a non-negative number of seconds or an HTTP-date.
5
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After).
6
- *
7
- * @returns The delay in milliseconds, or `null` if the header is absent, unparseable, or already elapsed.
8
- */
9
- export function parseRetryAfterHeader(value) {
10
- if (!value) {
11
- return null;
12
- }
13
- const trimmed = value.trim();
14
- // Per the spec this is a `delay-seconds`: digits only, so a negative or fractional value is not one.
15
- if (/^\d+$/.test(trimmed)) {
16
- // `Retry-After: 0` names no future deadline, same as an HTTP-date that has already passed. Reporting it
17
- // as a zero delay would leave the domain unthrottled while still counting as a rate-limit event, so the
18
- // caller would defer the request for free and re-send it immediately.
19
- const delayMs = Number(trimmed) * 1000;
20
- return delayMs > 0 ? delayMs : null;
21
- }
22
- const date = Date.parse(trimmed);
23
- if (!Number.isNaN(date)) {
24
- const delayMs = date - Date.now();
25
- return delayMs > 0 ? delayMs : null;
26
- }
27
- return null;
28
- }