@talex-touch/utils 1.0.23 → 1.0.25
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/common/file-scan-constants.ts +543 -0
- package/common/file-scan-utils.ts +432 -0
- package/common/index.ts +2 -0
- package/common/storage/entity/app-settings.ts +7 -1
- package/common/utils/polling.ts +4 -4
- package/common/utils/timing.ts +257 -13
- package/core-box/tuff/tuff-dsl.ts +17 -0
- package/package.json +1 -1
- package/plugin/index.ts +78 -3
- package/plugin/sdk/common.ts +63 -14
- package/plugin/sdk/core-box.ts +27 -0
- package/plugin/sdk/examples/storage-onDidChange-example.js +201 -0
- package/plugin/sdk/features.ts +324 -0
- package/plugin/sdk/index.ts +2 -0
- package/plugin/sdk/types.ts +142 -0
- package/renderer/touch-sdk/index.ts +9 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用文件扫描工具函数
|
|
3
|
+
* 提供统一的文件过滤和扫描逻辑,支持跨平台(Windows、macOS、Linux)
|
|
4
|
+
*
|
|
5
|
+
* @fileoverview 跨平台文件扫描工具集
|
|
6
|
+
* @author Talex Touch Team
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import path from 'path'
|
|
11
|
+
import {
|
|
12
|
+
type FileScanOptions,
|
|
13
|
+
DEFAULT_SCAN_OPTIONS,
|
|
14
|
+
BASE_BLACKLISTED_DIRS,
|
|
15
|
+
BLACKLISTED_EXTENSIONS,
|
|
16
|
+
BLACKLISTED_FILE_PREFIXES,
|
|
17
|
+
BLACKLISTED_FILE_SUFFIXES,
|
|
18
|
+
PHOTOS_LIBRARY_CONFIG,
|
|
19
|
+
PATH_PATTERNS,
|
|
20
|
+
PLATFORM
|
|
21
|
+
} from './file-scan-constants'
|
|
22
|
+
|
|
23
|
+
// 重新导出类型
|
|
24
|
+
export type { FileScanOptions }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 扫描文件信息接口
|
|
28
|
+
*
|
|
29
|
+
* @interface ScannedFileInfo
|
|
30
|
+
* @description 表示扫描到的文件信息
|
|
31
|
+
*/
|
|
32
|
+
export interface ScannedFileInfo {
|
|
33
|
+
/** 文件的完整路径 */
|
|
34
|
+
path: string
|
|
35
|
+
/** 文件名(不包含路径) */
|
|
36
|
+
name: string
|
|
37
|
+
/** 文件扩展名(包含点号,如 '.txt') */
|
|
38
|
+
extension: string
|
|
39
|
+
/** 文件大小(字节) */
|
|
40
|
+
size: number
|
|
41
|
+
/** 文件创建时间 */
|
|
42
|
+
ctime: Date
|
|
43
|
+
/** 文件修改时间 */
|
|
44
|
+
mtime: Date
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 检查文件是否可被索引
|
|
49
|
+
*
|
|
50
|
+
* @function isIndexableFile
|
|
51
|
+
* @description 根据文件路径、扩展名、文件名和扫描选项判断文件是否应该被索引
|
|
52
|
+
* @param fullPath - 完整文件路径
|
|
53
|
+
* @param extension - 文件扩展名(包含点号,如 '.txt')
|
|
54
|
+
* @param fileName - 文件名(不包含路径)
|
|
55
|
+
* @param options - 扫描选项配置,可选
|
|
56
|
+
* @returns 如果文件可被索引返回 true,否则返回 false
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // 基础用法
|
|
61
|
+
* const isIndexable = isIndexableFile('/path/to/file.txt', '.txt', 'file.txt')
|
|
62
|
+
*
|
|
63
|
+
* // 使用自定义选项
|
|
64
|
+
* const customOptions = createScanOptions({
|
|
65
|
+
* enablePhotosLibraryFilter: true,
|
|
66
|
+
* customBlacklistedDirs: new Set(['my-custom-dir'])
|
|
67
|
+
* })
|
|
68
|
+
* const isIndexable = isIndexableFile('/path/to/file.txt', '.txt', 'file.txt', customOptions)
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
73
|
+
export function isIndexableFile(
|
|
74
|
+
fullPath: string,
|
|
75
|
+
extension: string,
|
|
76
|
+
fileName: string,
|
|
77
|
+
options: FileScanOptions = DEFAULT_SCAN_OPTIONS
|
|
78
|
+
): boolean {
|
|
79
|
+
// 合并选项
|
|
80
|
+
const opts = { ...DEFAULT_SCAN_OPTIONS, ...options }
|
|
81
|
+
|
|
82
|
+
// 基础检查
|
|
83
|
+
if (!extension) return false
|
|
84
|
+
|
|
85
|
+
// 检查扩展名黑名单
|
|
86
|
+
const blacklistedExtensions = new Set([
|
|
87
|
+
...BLACKLISTED_EXTENSIONS,
|
|
88
|
+
...(opts.customBlacklistedExtensions || [])
|
|
89
|
+
])
|
|
90
|
+
|
|
91
|
+
if (blacklistedExtensions.has(extension)) return false
|
|
92
|
+
|
|
93
|
+
// 检查文件名前缀和后缀
|
|
94
|
+
if (fileName) {
|
|
95
|
+
const firstChar = fileName[0]
|
|
96
|
+
const lastChar = fileName[fileName.length - 1]
|
|
97
|
+
|
|
98
|
+
if (BLACKLISTED_FILE_PREFIXES.has(firstChar)) return false
|
|
99
|
+
if (BLACKLISTED_FILE_SUFFIXES.has(lastChar)) return false
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Photos Library 智能过滤(仅 macOS)
|
|
103
|
+
if (opts.enablePhotosLibraryFilter && PLATFORM.IS_MACOS && fullPath.includes('Photos Library.photoslibrary')) {
|
|
104
|
+
if (!isPhotosLibraryPathAllowed(fullPath)) {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 系统路径过滤
|
|
110
|
+
if (opts.enableSystemPathFilter && isSystemPath(fullPath)) {
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 开发路径过滤
|
|
115
|
+
if (opts.enableDevPathFilter && isDevPath(fullPath)) {
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 缓存路径过滤
|
|
120
|
+
if (opts.enableCachePathFilter && isCachePath(fullPath)) {
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 目录黑名单检查
|
|
125
|
+
const blacklistedDirs = new Set([
|
|
126
|
+
...BASE_BLACKLISTED_DIRS,
|
|
127
|
+
...(opts.customBlacklistedDirs || [])
|
|
128
|
+
])
|
|
129
|
+
|
|
130
|
+
const segments = fullPath.split(path.sep)
|
|
131
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
132
|
+
const segment = segments[i]
|
|
133
|
+
if (!segment) continue
|
|
134
|
+
if (segment.startsWith('.')) return false
|
|
135
|
+
if (blacklistedDirs.has(segment)) return false
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 自定义排除路径检查
|
|
139
|
+
if (opts.customExcludePaths?.has(fullPath)) {
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 检查 Photos Library 路径是否允许扫描
|
|
148
|
+
*
|
|
149
|
+
* @function isPhotosLibraryPathAllowed
|
|
150
|
+
* @description 检查给定的 Photos Library 路径是否在允许扫描的范围内
|
|
151
|
+
* @param fullPath - 完整文件路径
|
|
152
|
+
* @returns 如果路径允许扫描返回 true,否则返回 false
|
|
153
|
+
* @private
|
|
154
|
+
* @since 1.0.0
|
|
155
|
+
*/
|
|
156
|
+
function isPhotosLibraryPathAllowed(fullPath: string): boolean {
|
|
157
|
+
const config = PHOTOS_LIBRARY_CONFIG
|
|
158
|
+
|
|
159
|
+
// 检查允许的子目录
|
|
160
|
+
for (const allowedPath of config.PATH_PATTERNS.ALLOWED) {
|
|
161
|
+
if (fullPath.includes(allowedPath)) {
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 检查禁止的子目录
|
|
167
|
+
for (const blockedPath of config.PATH_PATTERNS.BLOCKED) {
|
|
168
|
+
if (fullPath.includes(blockedPath)) {
|
|
169
|
+
return false
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 默认允许(可能是根目录或其他未明确禁止的目录)
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 检查是否为系统路径
|
|
179
|
+
*
|
|
180
|
+
* @function isSystemPath
|
|
181
|
+
* @description 检查给定路径是否为系统路径(跨平台)
|
|
182
|
+
* @param fullPath - 完整文件路径
|
|
183
|
+
* @returns 如果是系统路径返回 true,否则返回 false
|
|
184
|
+
* @private
|
|
185
|
+
* @since 1.0.0
|
|
186
|
+
*/
|
|
187
|
+
function isSystemPath(fullPath: string): boolean {
|
|
188
|
+
return PATH_PATTERNS.SYSTEM_PATHS.some(pattern => pattern.test(fullPath))
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 检查是否为开发路径
|
|
193
|
+
*
|
|
194
|
+
* @function isDevPath
|
|
195
|
+
* @description 检查给定路径是否为开发相关路径
|
|
196
|
+
* @param fullPath - 完整文件路径
|
|
197
|
+
* @returns 如果是开发路径返回 true,否则返回 false
|
|
198
|
+
* @private
|
|
199
|
+
* @since 1.0.0
|
|
200
|
+
*/
|
|
201
|
+
function isDevPath(fullPath: string): boolean {
|
|
202
|
+
return PATH_PATTERNS.DEV_PATHS.some(pattern => pattern.test(fullPath))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 检查是否为缓存路径
|
|
207
|
+
*
|
|
208
|
+
* @function isCachePath
|
|
209
|
+
* @description 检查给定路径是否为缓存路径(跨平台)
|
|
210
|
+
* @param fullPath - 完整文件路径
|
|
211
|
+
* @returns 如果是缓存路径返回 true,否则返回 false
|
|
212
|
+
* @private
|
|
213
|
+
* @since 1.0.0
|
|
214
|
+
*/
|
|
215
|
+
function isCachePath(fullPath: string): boolean {
|
|
216
|
+
return PATH_PATTERNS.CACHE_PATHS.some(pattern => pattern.test(fullPath))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 扫描目录获取文件列表
|
|
221
|
+
*
|
|
222
|
+
* @function scanDirectory
|
|
223
|
+
* @description 递归扫描指定目录,返回符合过滤条件的文件列表
|
|
224
|
+
* @param dirPath - 要扫描的目录路径
|
|
225
|
+
* @param options - 扫描选项配置,可选
|
|
226
|
+
* @param excludePaths - 排除路径集合,可选
|
|
227
|
+
* @returns Promise<ScannedFileInfo[]> 扫描到的文件信息列表
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* // 基础用法
|
|
232
|
+
* const files = await scanDirectory('/path/to/scan')
|
|
233
|
+
*
|
|
234
|
+
* // 使用自定义选项
|
|
235
|
+
* const customOptions = createScanOptions({
|
|
236
|
+
* enablePhotosLibraryFilter: true,
|
|
237
|
+
* customBlacklistedDirs: new Set(['my-custom-dir'])
|
|
238
|
+
* })
|
|
239
|
+
* const files = await scanDirectory('/path/to/scan', customOptions)
|
|
240
|
+
*
|
|
241
|
+
* // 排除特定路径
|
|
242
|
+
* const excludePaths = new Set(['/path/to/exclude'])
|
|
243
|
+
* const files = await scanDirectory('/path/to/scan', undefined, excludePaths)
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @throws {Error} 当目录不存在或无法访问时,会静默返回空数组
|
|
247
|
+
* @since 1.0.0
|
|
248
|
+
*/
|
|
249
|
+
export async function scanDirectory(
|
|
250
|
+
dirPath: string,
|
|
251
|
+
options: FileScanOptions = DEFAULT_SCAN_OPTIONS,
|
|
252
|
+
excludePaths?: Set<string>
|
|
253
|
+
): Promise<ScannedFileInfo[]> {
|
|
254
|
+
const opts = { ...DEFAULT_SCAN_OPTIONS, ...options }
|
|
255
|
+
|
|
256
|
+
// 检查是否在排除路径中
|
|
257
|
+
if (excludePaths?.has(dirPath)) {
|
|
258
|
+
return []
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 检查目录名是否在黑名单中
|
|
262
|
+
const dirName = path.basename(dirPath)
|
|
263
|
+
const blacklistedDirs = new Set([
|
|
264
|
+
...BASE_BLACKLISTED_DIRS,
|
|
265
|
+
...(opts.customBlacklistedDirs || [])
|
|
266
|
+
])
|
|
267
|
+
|
|
268
|
+
if (blacklistedDirs.has(dirName) || dirName.startsWith('.')) {
|
|
269
|
+
return []
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 检查是否为系统/开发/缓存路径
|
|
273
|
+
if (opts.enableSystemPathFilter && isSystemPath(dirPath)) {
|
|
274
|
+
return []
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (opts.enableDevPathFilter && isDevPath(dirPath)) {
|
|
278
|
+
return []
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (opts.enableCachePathFilter && isCachePath(dirPath)) {
|
|
282
|
+
return []
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 读取目录
|
|
286
|
+
let entries: any[] = []
|
|
287
|
+
try {
|
|
288
|
+
const fs = await import('fs/promises')
|
|
289
|
+
entries = await fs.readdir(dirPath, { withFileTypes: true })
|
|
290
|
+
} catch {
|
|
291
|
+
// 忽略权限错误等
|
|
292
|
+
return []
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const files: ScannedFileInfo[] = []
|
|
296
|
+
|
|
297
|
+
for (const entry of entries) {
|
|
298
|
+
const fullPath = path.join(dirPath, entry.name)
|
|
299
|
+
|
|
300
|
+
if (excludePaths?.has(fullPath)) {
|
|
301
|
+
continue
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (entry.isDirectory()) {
|
|
305
|
+
// 递归扫描子目录
|
|
306
|
+
const subFiles = await scanDirectory(fullPath, opts, excludePaths)
|
|
307
|
+
files.push(...subFiles)
|
|
308
|
+
} else if (entry.isFile()) {
|
|
309
|
+
const fileName = entry.name
|
|
310
|
+
const fileExtension = path.extname(fileName).toLowerCase()
|
|
311
|
+
|
|
312
|
+
// 检查文件是否可索引
|
|
313
|
+
if (!isIndexableFile(fullPath, fileExtension, fileName, opts)) {
|
|
314
|
+
continue
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
const fs = await import('fs/promises')
|
|
319
|
+
const stats = await fs.stat(fullPath)
|
|
320
|
+
files.push({
|
|
321
|
+
path: fullPath,
|
|
322
|
+
name: fileName,
|
|
323
|
+
extension: fileExtension,
|
|
324
|
+
size: stats.size,
|
|
325
|
+
ctime: stats.birthtime ?? stats.ctime,
|
|
326
|
+
mtime: stats.mtime
|
|
327
|
+
})
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.error(`[FileScanUtils] Could not stat file ${fullPath}:`, error)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return files
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 批量扫描多个目录
|
|
339
|
+
*
|
|
340
|
+
* @function scanDirectories
|
|
341
|
+
* @description 批量扫描多个目录,返回所有符合过滤条件的文件列表
|
|
342
|
+
* @param dirPaths - 要扫描的目录路径数组
|
|
343
|
+
* @param options - 扫描选项配置,可选
|
|
344
|
+
* @param excludePaths - 排除路径集合,可选
|
|
345
|
+
* @returns Promise<ScannedFileInfo[]> 所有目录扫描到的文件信息列表
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* // 扫描多个目录
|
|
350
|
+
* const dirPaths = ['/path/to/scan1', '/path/to/scan2', '/path/to/scan3']
|
|
351
|
+
* const files = await scanDirectories(dirPaths)
|
|
352
|
+
*
|
|
353
|
+
* // 使用自定义选项
|
|
354
|
+
* const customOptions = createScanOptions({
|
|
355
|
+
* enablePhotosLibraryFilter: true
|
|
356
|
+
* })
|
|
357
|
+
* const files = await scanDirectories(dirPaths, customOptions)
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @throws {Error} 当某个目录扫描失败时,会记录错误但继续扫描其他目录
|
|
361
|
+
* @since 1.0.0
|
|
362
|
+
*/
|
|
363
|
+
export async function scanDirectories(
|
|
364
|
+
dirPaths: string[],
|
|
365
|
+
options: FileScanOptions = DEFAULT_SCAN_OPTIONS,
|
|
366
|
+
excludePaths?: Set<string>
|
|
367
|
+
): Promise<ScannedFileInfo[]> {
|
|
368
|
+
const allFiles: ScannedFileInfo[] = []
|
|
369
|
+
|
|
370
|
+
for (const dirPath of dirPaths) {
|
|
371
|
+
try {
|
|
372
|
+
const files = await scanDirectory(dirPath, options, excludePaths)
|
|
373
|
+
allFiles.push(...files)
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error(`[FileScanUtils] Error scanning directory ${dirPath}:`, error)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return allFiles
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* 创建自定义扫描选项
|
|
384
|
+
*
|
|
385
|
+
* @function createScanOptions
|
|
386
|
+
* @description 基于默认选项创建自定义扫描配置
|
|
387
|
+
* @param customOptions - 自定义选项配置
|
|
388
|
+
* @returns FileScanOptions 合并后的扫描选项
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* // 创建自定义选项
|
|
393
|
+
* const customOptions = createScanOptions({
|
|
394
|
+
* enablePhotosLibraryFilter: true,
|
|
395
|
+
* customBlacklistedDirs: new Set(['my-custom-dir']),
|
|
396
|
+
* strictMode: false
|
|
397
|
+
* })
|
|
398
|
+
*
|
|
399
|
+
* // 使用自定义选项扫描
|
|
400
|
+
* const files = await scanDirectory('/path', undefined, customOptions)
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @since 1.0.0
|
|
404
|
+
*/
|
|
405
|
+
export function createScanOptions(customOptions: Partial<FileScanOptions> = {}): FileScanOptions {
|
|
406
|
+
return { ...DEFAULT_SCAN_OPTIONS, ...customOptions }
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* 创建严格模式扫描选项
|
|
411
|
+
*
|
|
412
|
+
* @function createStrictScanOptions
|
|
413
|
+
* @description 创建启用严格模式的扫描配置
|
|
414
|
+
* @param customOptions - 额外的自定义选项配置
|
|
415
|
+
* @returns FileScanOptions 严格模式扫描选项
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* // 创建严格模式选项
|
|
420
|
+
* const strictOptions = createStrictScanOptions({
|
|
421
|
+
* customBlacklistedDirs: new Set(['additional-dir'])
|
|
422
|
+
* })
|
|
423
|
+
*
|
|
424
|
+
* // 使用严格模式扫描
|
|
425
|
+
* const files = await scanDirectory('/path', undefined, strictOptions)
|
|
426
|
+
* ```
|
|
427
|
+
*
|
|
428
|
+
* @since 1.0.0
|
|
429
|
+
*/
|
|
430
|
+
export function createStrictScanOptions(customOptions: Partial<FileScanOptions> = {}): FileScanOptions {
|
|
431
|
+
return { ...DEFAULT_SCAN_OPTIONS, strictMode: true, ...customOptions }
|
|
432
|
+
}
|
package/common/index.ts
CHANGED
|
@@ -33,6 +33,12 @@ const _appSettingOriginData = {
|
|
|
33
33
|
autoHide: true,
|
|
34
34
|
autoClear: 600,
|
|
35
35
|
},
|
|
36
|
+
dashboard: {
|
|
37
|
+
enable: false,
|
|
38
|
+
},
|
|
39
|
+
searchEngine: {
|
|
40
|
+
logsEnabled: false,
|
|
41
|
+
},
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
export const appSettingOriginData = Object.freeze(_appSettingOriginData)
|
|
@@ -44,4 +50,4 @@ export const appSettingOriginData = Object.freeze(_appSettingOriginData)
|
|
|
44
50
|
*/
|
|
45
51
|
export type AppSetting = typeof _appSettingOriginData & {
|
|
46
52
|
[key: string]: any;
|
|
47
|
-
};
|
|
53
|
+
};
|
package/common/utils/polling.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class PollingService {
|
|
|
64
64
|
console.error(`[PollingService] Task '${id}' has an invalid interval of ${intervalMs}ms. Registration aborted.`);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
const nextRunMs = options.runImmediately ? Date.now() : Date.now() + intervalMs;
|
|
69
69
|
|
|
70
70
|
this.tasks.set(id, {
|
|
@@ -114,7 +114,7 @@ export class PollingService {
|
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
this.isRunning = true;
|
|
117
|
-
console.
|
|
117
|
+
console.debug('[PollingService] Service started.');
|
|
118
118
|
this._reschedule();
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -161,7 +161,7 @@ export class PollingService {
|
|
|
161
161
|
tasksToRun.push(task);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
if (tasksToRun.length > 0) {
|
|
166
166
|
// console.debug(`[PollingService] Executing ${tasksToRun.length} tasks.`);
|
|
167
167
|
for (const task of tasksToRun) {
|
|
@@ -181,4 +181,4 @@ export class PollingService {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
export const pollingService = PollingService.getInstance();
|
|
184
|
+
export const pollingService = PollingService.getInstance();
|