@chromahq/core 1.0.58 → 1.0.62
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/dist/{boot-DPtu_qKj.js → boot-Ap8sFDzW.js} +59 -69
- package/dist/boot-Ap8sFDzW.js.map +1 -0
- package/dist/{boot--zb14Gg3.js → boot-BlwTZbY7.js} +59 -69
- package/dist/boot-BlwTZbY7.js.map +1 -0
- package/dist/boot.cjs.js +1 -1
- package/dist/boot.es.js +1 -1
- package/dist/index.cjs.js +5 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +27 -0
- package/dist/index.es.js +5 -6
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/boot--zb14Gg3.js.map +0 -1
- package/dist/boot-DPtu_qKj.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@inversifyjs/core');
|
|
4
|
-
var boot = require('./boot
|
|
4
|
+
var boot = require('./boot-BlwTZbY7.js');
|
|
5
5
|
require('@inversifyjs/container');
|
|
6
6
|
|
|
7
7
|
function Service() {
|
|
@@ -29,13 +29,10 @@ class Job {
|
|
|
29
29
|
this.data = data;
|
|
30
30
|
}
|
|
31
31
|
pause() {
|
|
32
|
-
console.log(`Job ${this.constructor.name} paused`);
|
|
33
32
|
}
|
|
34
33
|
resume() {
|
|
35
|
-
console.log(`Job ${this.constructor.name} resumed`);
|
|
36
34
|
}
|
|
37
35
|
stop() {
|
|
38
|
-
console.log(`Job ${this.constructor.name} stopped`);
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -60,7 +57,8 @@ function Every(cron, options) {
|
|
|
60
57
|
{
|
|
61
58
|
cron,
|
|
62
59
|
requiresPopup: options?.requiresPopup ?? false,
|
|
63
|
-
startPaused: options?.startPaused ?? false
|
|
60
|
+
startPaused: options?.startPaused ?? false,
|
|
61
|
+
schedulerDebug: options?.schedulerDebug ?? false
|
|
64
62
|
},
|
|
65
63
|
constructor
|
|
66
64
|
);
|
|
@@ -80,7 +78,8 @@ function EverySeconds(seconds, options) {
|
|
|
80
78
|
delay: seconds * 1e3,
|
|
81
79
|
recurring: true,
|
|
82
80
|
startPaused: options?.startPaused ?? false,
|
|
83
|
-
requiresPopup: options?.requiresPopup ?? false
|
|
81
|
+
requiresPopup: options?.requiresPopup ?? false,
|
|
82
|
+
schedulerDebug: options?.schedulerDebug ?? false
|
|
84
83
|
},
|
|
85
84
|
constructor
|
|
86
85
|
);
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/decorators/Service.ts","../src/decorators/Message.ts","../src/scheduler/core/Job.ts","../src/scheduler/decorators/Job.ts","../src/scheduler/decorators/Delay.ts","../src/scheduler/decorators/Every.ts","../src/scheduler/decorators/EverySeconds.ts","../src/services/booteable.ts"],"sourcesContent":["import { inject, injectable } from '@inversifyjs/core';\n\nexport function Service() {\n return injectable();\n}\n\nexport const Use = (id: symbol | string | NewableFunction) => inject(id);\nexport const Store = () => Use(Symbol.for('Store'));\nexport const EventBus = () => Use(Symbol.for('EventBus'));\n","import { injectable } from '@inversifyjs/core';\n\nexport abstract class IMessage {\n handle(...args: any[]): Promise<void> | void {\n throw new Error('Method not implemented.');\n }\n}\n\nexport function Message(name: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('name', name, constructor);\n return constructor;\n };\n}\n","import { IJob, JobContext } from './IJob';\n\nexport abstract class Job<T = unknown> implements IJob<T> {\n constructor(public readonly data?: T) {}\n\n abstract handle(context?: JobContext): Promise<void> | void;\n\n pause?(): Promise<void> | void {
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/decorators/Service.ts","../src/decorators/Message.ts","../src/scheduler/core/Job.ts","../src/scheduler/decorators/Job.ts","../src/scheduler/decorators/Delay.ts","../src/scheduler/decorators/Every.ts","../src/scheduler/decorators/EverySeconds.ts","../src/services/booteable.ts"],"sourcesContent":["import { inject, injectable } from '@inversifyjs/core';\n\nexport function Service() {\n return injectable();\n}\n\nexport const Use = (id: symbol | string | NewableFunction) => inject(id);\nexport const Store = () => Use(Symbol.for('Store'));\nexport const EventBus = () => Use(Symbol.for('EventBus'));\n","import { injectable } from '@inversifyjs/core';\n\nexport abstract class IMessage {\n handle(...args: any[]): Promise<void> | void {\n throw new Error('Method not implemented.');\n }\n}\n\nexport function Message(name: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('name', name, constructor);\n return constructor;\n };\n}\n","import { IJob, JobContext } from './IJob';\n\nexport abstract class Job<T = unknown> implements IJob<T> {\n constructor(public readonly data?: T) {}\n\n abstract handle(context?: JobContext): Promise<void> | void;\n\n pause?(): Promise<void> | void {}\n\n resume?(): Promise<void> | void {}\n\n stop?(): Promise<void> | void {}\n}\n","import { injectable } from '@inversifyjs/core';\nimport { JobOptions } from '../core/JobOptions';\n\nexport function JobConfig<T extends new (...args: any[]) => any>(options: JobOptions = {}) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('job:options', options, constructor);\n return constructor;\n };\n}\n","import { JobConfig } from './Job';\n\nexport const Delay = (ms: number) => JobConfig({ delay: ms });\n","import { injectable } from '@inversifyjs/core';\n\n/**\n * Options for the Every decorator.\n */\nexport interface EveryOptions {\n /**\n * If true, the job will only execute when the popup (or extension view) is visible.\n * This reduces unnecessary background activity when the user isn't looking at the extension.\n */\n requiresPopup?: boolean;\n\n /**\n * Explicit job name (survives minification). Recommended for production builds.\n */\n name?: string;\n\n /**\n * If true, job starts paused and must be resumed manually via Scheduler.resume()\n */\n startPaused?: boolean;\n\n /**\n * When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.\n * @see JobOptions.schedulerDebug\n */\n schedulerDebug?: boolean;\n}\n\n/**\n * Decorator for scheduling jobs using cron expressions.\n *\n * @param cron - Cron expression (e.g., '0 *\\/5 * * * *' for every 5 minutes)\n * @param options - Optional configuration for the job\n *\n * @example\n * ```typescript\n * // Basic usage - runs every 5 minutes\n * @Every('0 *\\/5 * * * *')\n * export class MyJob { ... }\n *\n * // With options - only runs when popup is visible\n * @Every('0 *\\/5 * * * *', { requiresPopup: true, name: 'MyJob' })\n * export class MyJob { ... }\n *\n * // Scheduler diagnostics at info for this job only\n * @Every('0 *\\/1 * * * *', { name: 'NoisyJob', schedulerDebug: true })\n * export class NoisyJob { ... }\n * ```\n */\nexport function Every(cron: string, options?: EveryOptions) {\n return function (constructor: any) {\n injectable()(constructor);\n\n // Set explicit name metadata to survive minification\n if (options?.name) {\n Reflect.defineMetadata('name', options.name, constructor);\n }\n\n Reflect.defineMetadata(\n 'job:options',\n {\n cron,\n requiresPopup: options?.requiresPopup ?? false,\n startPaused: options?.startPaused ?? false,\n schedulerDebug: options?.schedulerDebug ?? false,\n },\n constructor,\n );\n return constructor;\n };\n}\n","import { injectable } from '@inversifyjs/core';\n\n/**\n * Options for the EverySeconds decorator.\n */\nexport interface EverySecondsOptions {\n /** If true, job starts paused and must be resumed manually via Scheduler.resume() */\n startPaused?: boolean;\n\n /** Explicit job name (survives minification). Required for production builds. */\n name?: string;\n\n /**\n * If true, the job will only execute when the popup (or extension view) is visible.\n * This reduces unnecessary background activity when the user isn't looking at the extension.\n */\n requiresPopup?: boolean;\n\n /**\n * When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.\n * @see JobOptions.schedulerDebug\n */\n schedulerDebug?: boolean;\n}\n\n/**\n * Decorator for jobs that run at a specific interval in seconds.\n * Unlike cron expressions which have minute-level granularity,\n * this decorator allows for second-level precision.\n *\n * @param seconds - The interval in seconds between job executions\n * @param options - Optional configuration (startPaused, name, requiresPopup, etc.)\n *\n * @example\n * ```typescript\n * // Auto-starting job (default)\n * @EverySeconds(5, { name: 'MyJob' })\n * export class MyJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Runs every 5 seconds');\n * }\n * }\n *\n * // Job that only runs when popup is visible\n * @EverySeconds(10, { name: 'UiUpdateJob', requiresPopup: true })\n * export class UiUpdateJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Only runs when user is viewing extension');\n * }\n * }\n *\n * // Paused job that must be manually resumed\n * @EverySeconds(2, { startPaused: true, name: 'OnDemandJob' })\n * export class OnDemandJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Runs when resumed');\n * }\n * }\n * ```\n */\nexport function EverySeconds(seconds: number, options?: EverySecondsOptions) {\n return function (constructor: any) {\n injectable()(constructor);\n // Set explicit name metadata to survive minification\n if (options?.name) {\n Reflect.defineMetadata('name', options.name, constructor);\n }\n\n Reflect.defineMetadata(\n 'job:options',\n {\n delay: seconds * 1000,\n recurring: true,\n startPaused: options?.startPaused ?? false,\n requiresPopup: options?.requiresPopup ?? false,\n schedulerDebug: options?.schedulerDebug ?? false,\n },\n constructor,\n );\n return constructor;\n };\n}\n","export abstract class Booteable {\n /**\n * Boot method to be called when the service is initialized.\n * This method can be used to perform any setup or initialization logic.\n */\n abstract boot(): void;\n /**\n * Optional destroy method to be called when the service is being destroyed.\n * This can be used to clean up resources or perform any necessary teardown logic.\n */\n destroy?(): void {\n // Default implementation does nothing\n }\n}\n\nexport function isBooteable(obj: any): obj is Booteable {\n return typeof obj.boot === 'function';\n}\n\nexport function isDestroyable(obj: any): obj is Booteable {\n return typeof obj.destroy === 'function';\n}\n"],"names":["injectable","inject"],"mappings":";;;;;;AAEO,SAAS,OAAA,GAAU;AACxB,EAAA,OAAOA,eAAA,EAAW;AACpB;AAEO,MAAM,GAAA,GAAM,CAAC,EAAA,KAA0CC,WAAA,CAAO,EAAE;AAChE,MAAM,QAAQ,MAAM,GAAA,iBAAI,MAAA,CAAO,GAAA,CAAI,OAAO,CAAC;AAC3C,MAAM,WAAW,MAAM,GAAA,iBAAI,MAAA,CAAO,GAAA,CAAI,UAAU,CAAC;;ACNjD,MAAe,QAAA,CAAS;AAAA,EAC7B,UAAU,IA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AA;AAAA,QACrC,cAAA,EAAgB,SAAS,cAAA,IAAkB;AAAA,OAC7C;AAAA,MACA;AAAA,KACF;AACA,IAAA,OAAO,WAAA;AAAA,GACT;AACF;;ACXO,SAAS,YAAA,CAAa,SAAiB,OAAA,EAA+B;AAC3E,EAAA,OAAO,SAAU,WAAA,EAAkB;AACjC,IAAAA,eAAA,GAAa,WAAW,CAAA;AAExB,IAAA,IAAI,SAAS,IAAA,EAAM;AACjB,MAAA,OAAA,CAAQ,cAAA,CAAe,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,WAAW,CAAA;AAAA;AAG1D,IAAA,OAAA,CAAQ,cAAA;AAAA,MACN,aAAA;AAAA,MACA;AAAA,QACE,OAAO,OAAA,GAAU,GAAA;AAAA,QACjB,SAAA,EAAW,IAAA;AAAA,QACX,WAAA,EAAa,SAAS,WAAA,IAAe,KAAA;AAAA,QACrC,aAAA,EAAe,SAAS,aAAA,IAAiB,KAAA;AAAA,QACzC,cAAA,EAAgB,SAAS,cAAA,IAAkB;AAAA,OAC7C;AAAA,MACA;AAAA,KACF;AACA,IAAA,OAAO,WAAA;AAAA,GACT;AACF;;ACjFO,MAAe,SAAA,CAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAU9B,OAAA,GAAiB;AAAA;AAGnB;AAEO,SAAS,YAAY,GAAA,EAA4B;AACtD,EAAA,OAAO,OAAO,IAAI,IAAA,KAAS,UAAA;AAC7B;AAEO,SAAS,cAAc,GAAA,EAA4B;AACxD,EAAA,OAAO,OAAO,IAAI,OAAA,KAAY,UAAA;AAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -192,6 +192,12 @@ interface JobOptions {
|
|
|
192
192
|
* ```
|
|
193
193
|
*/
|
|
194
194
|
requiresPopup?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* When true, the scheduler emits diagnostics for **this job** at `logger.info`
|
|
197
|
+
* (schedule, execute, pause/resume/stop, popup-skip paths) instead of only
|
|
198
|
+
* `logger.debug`. Use for targeted troubleshooting without flooding all jobs.
|
|
199
|
+
*/
|
|
200
|
+
schedulerDebug?: boolean;
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
interface IJob<T = unknown> {
|
|
@@ -279,6 +285,11 @@ interface EveryOptions {
|
|
|
279
285
|
* If true, job starts paused and must be resumed manually via Scheduler.resume()
|
|
280
286
|
*/
|
|
281
287
|
startPaused?: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.
|
|
290
|
+
* @see JobOptions.schedulerDebug
|
|
291
|
+
*/
|
|
292
|
+
schedulerDebug?: boolean;
|
|
282
293
|
}
|
|
283
294
|
/**
|
|
284
295
|
* Decorator for scheduling jobs using cron expressions.
|
|
@@ -295,6 +306,10 @@ interface EveryOptions {
|
|
|
295
306
|
* // With options - only runs when popup is visible
|
|
296
307
|
* @Every('0 *\/5 * * * *', { requiresPopup: true, name: 'MyJob' })
|
|
297
308
|
* export class MyJob { ... }
|
|
309
|
+
*
|
|
310
|
+
* // Scheduler diagnostics at info for this job only
|
|
311
|
+
* @Every('0 *\/1 * * * *', { name: 'NoisyJob', schedulerDebug: true })
|
|
312
|
+
* export class NoisyJob { ... }
|
|
298
313
|
* ```
|
|
299
314
|
*/
|
|
300
315
|
declare function Every(cron: string, options?: EveryOptions): (constructor: any) => any;
|
|
@@ -312,6 +327,11 @@ interface EverySecondsOptions {
|
|
|
312
327
|
* This reduces unnecessary background activity when the user isn't looking at the extension.
|
|
313
328
|
*/
|
|
314
329
|
requiresPopup?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.
|
|
332
|
+
* @see JobOptions.schedulerDebug
|
|
333
|
+
*/
|
|
334
|
+
schedulerDebug?: boolean;
|
|
315
335
|
}
|
|
316
336
|
/**
|
|
317
337
|
* Decorator for jobs that run at a specific interval in seconds.
|
|
@@ -735,6 +755,13 @@ declare class Scheduler {
|
|
|
735
755
|
private readonly timeout;
|
|
736
756
|
private readonly logger;
|
|
737
757
|
private popupVisibilityUnsubscribe?;
|
|
758
|
+
/**
|
|
759
|
+
* When `options.schedulerDebug` is true, log at info so diagnostics show without
|
|
760
|
+
* enabling global debug. Otherwise logs at debug.
|
|
761
|
+
*/
|
|
762
|
+
private logJobDiagnostics;
|
|
763
|
+
/** Batch summary visible at info if any involved job has `schedulerDebug`. */
|
|
764
|
+
private logBatchIfAnyJobDebug;
|
|
738
765
|
constructor(logger?: Logger);
|
|
739
766
|
/**
|
|
740
767
|
* Setup listener for popup visibility changes.
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inject, injectable } from '@inversifyjs/core';
|
|
2
|
-
export { A as AppEventBus, E as EventBusToken, J as JobRegistry, l as JobState, N as NonceService, P as PopupVisibilityService, a as SUBSCRIBE_METADATA_KEY, k as Scheduler, S as Subscribe, e as arePortsClaimed, j as bootstrap, d as claimEarlyPorts, f as container, h as create, b as getNonceService, c as getPopupVisibilityService, g as getSubscribeMetadata, i as isEarlyListenerSetup, s as setupEarlyListener } from './boot-
|
|
2
|
+
export { A as AppEventBus, E as EventBusToken, J as JobRegistry, l as JobState, N as NonceService, P as PopupVisibilityService, a as SUBSCRIBE_METADATA_KEY, k as Scheduler, S as Subscribe, e as arePortsClaimed, j as bootstrap, d as claimEarlyPorts, f as container, h as create, b as getNonceService, c as getPopupVisibilityService, g as getSubscribeMetadata, i as isEarlyListenerSetup, s as setupEarlyListener } from './boot-Ap8sFDzW.js';
|
|
3
3
|
import '@inversifyjs/container';
|
|
4
4
|
|
|
5
5
|
function Service() {
|
|
@@ -27,13 +27,10 @@ class Job {
|
|
|
27
27
|
this.data = data;
|
|
28
28
|
}
|
|
29
29
|
pause() {
|
|
30
|
-
console.log(`Job ${this.constructor.name} paused`);
|
|
31
30
|
}
|
|
32
31
|
resume() {
|
|
33
|
-
console.log(`Job ${this.constructor.name} resumed`);
|
|
34
32
|
}
|
|
35
33
|
stop() {
|
|
36
|
-
console.log(`Job ${this.constructor.name} stopped`);
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
36
|
|
|
@@ -58,7 +55,8 @@ function Every(cron, options) {
|
|
|
58
55
|
{
|
|
59
56
|
cron,
|
|
60
57
|
requiresPopup: options?.requiresPopup ?? false,
|
|
61
|
-
startPaused: options?.startPaused ?? false
|
|
58
|
+
startPaused: options?.startPaused ?? false,
|
|
59
|
+
schedulerDebug: options?.schedulerDebug ?? false
|
|
62
60
|
},
|
|
63
61
|
constructor
|
|
64
62
|
);
|
|
@@ -78,7 +76,8 @@ function EverySeconds(seconds, options) {
|
|
|
78
76
|
delay: seconds * 1e3,
|
|
79
77
|
recurring: true,
|
|
80
78
|
startPaused: options?.startPaused ?? false,
|
|
81
|
-
requiresPopup: options?.requiresPopup ?? false
|
|
79
|
+
requiresPopup: options?.requiresPopup ?? false,
|
|
80
|
+
schedulerDebug: options?.schedulerDebug ?? false
|
|
82
81
|
},
|
|
83
82
|
constructor
|
|
84
83
|
);
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/decorators/Service.ts","../src/decorators/Message.ts","../src/scheduler/core/Job.ts","../src/scheduler/decorators/Job.ts","../src/scheduler/decorators/Delay.ts","../src/scheduler/decorators/Every.ts","../src/scheduler/decorators/EverySeconds.ts","../src/services/booteable.ts"],"sourcesContent":["import { inject, injectable } from '@inversifyjs/core';\n\nexport function Service() {\n return injectable();\n}\n\nexport const Use = (id: symbol | string | NewableFunction) => inject(id);\nexport const Store = () => Use(Symbol.for('Store'));\nexport const EventBus = () => Use(Symbol.for('EventBus'));\n","import { injectable } from '@inversifyjs/core';\n\nexport abstract class IMessage {\n handle(...args: any[]): Promise<void> | void {\n throw new Error('Method not implemented.');\n }\n}\n\nexport function Message(name: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('name', name, constructor);\n return constructor;\n };\n}\n","import { IJob, JobContext } from './IJob';\n\nexport abstract class Job<T = unknown> implements IJob<T> {\n constructor(public readonly data?: T) {}\n\n abstract handle(context?: JobContext): Promise<void> | void;\n\n pause?(): Promise<void> | void {
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/decorators/Service.ts","../src/decorators/Message.ts","../src/scheduler/core/Job.ts","../src/scheduler/decorators/Job.ts","../src/scheduler/decorators/Delay.ts","../src/scheduler/decorators/Every.ts","../src/scheduler/decorators/EverySeconds.ts","../src/services/booteable.ts"],"sourcesContent":["import { inject, injectable } from '@inversifyjs/core';\n\nexport function Service() {\n return injectable();\n}\n\nexport const Use = (id: symbol | string | NewableFunction) => inject(id);\nexport const Store = () => Use(Symbol.for('Store'));\nexport const EventBus = () => Use(Symbol.for('EventBus'));\n","import { injectable } from '@inversifyjs/core';\n\nexport abstract class IMessage {\n handle(...args: any[]): Promise<void> | void {\n throw new Error('Method not implemented.');\n }\n}\n\nexport function Message(name: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('name', name, constructor);\n return constructor;\n };\n}\n","import { IJob, JobContext } from './IJob';\n\nexport abstract class Job<T = unknown> implements IJob<T> {\n constructor(public readonly data?: T) {}\n\n abstract handle(context?: JobContext): Promise<void> | void;\n\n pause?(): Promise<void> | void {}\n\n resume?(): Promise<void> | void {}\n\n stop?(): Promise<void> | void {}\n}\n","import { injectable } from '@inversifyjs/core';\nimport { JobOptions } from '../core/JobOptions';\n\nexport function JobConfig<T extends new (...args: any[]) => any>(options: JobOptions = {}) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('job:options', options, constructor);\n return constructor;\n };\n}\n","import { JobConfig } from './Job';\n\nexport const Delay = (ms: number) => JobConfig({ delay: ms });\n","import { injectable } from '@inversifyjs/core';\n\n/**\n * Options for the Every decorator.\n */\nexport interface EveryOptions {\n /**\n * If true, the job will only execute when the popup (or extension view) is visible.\n * This reduces unnecessary background activity when the user isn't looking at the extension.\n */\n requiresPopup?: boolean;\n\n /**\n * Explicit job name (survives minification). Recommended for production builds.\n */\n name?: string;\n\n /**\n * If true, job starts paused and must be resumed manually via Scheduler.resume()\n */\n startPaused?: boolean;\n\n /**\n * When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.\n * @see JobOptions.schedulerDebug\n */\n schedulerDebug?: boolean;\n}\n\n/**\n * Decorator for scheduling jobs using cron expressions.\n *\n * @param cron - Cron expression (e.g., '0 *\\/5 * * * *' for every 5 minutes)\n * @param options - Optional configuration for the job\n *\n * @example\n * ```typescript\n * // Basic usage - runs every 5 minutes\n * @Every('0 *\\/5 * * * *')\n * export class MyJob { ... }\n *\n * // With options - only runs when popup is visible\n * @Every('0 *\\/5 * * * *', { requiresPopup: true, name: 'MyJob' })\n * export class MyJob { ... }\n *\n * // Scheduler diagnostics at info for this job only\n * @Every('0 *\\/1 * * * *', { name: 'NoisyJob', schedulerDebug: true })\n * export class NoisyJob { ... }\n * ```\n */\nexport function Every(cron: string, options?: EveryOptions) {\n return function (constructor: any) {\n injectable()(constructor);\n\n // Set explicit name metadata to survive minification\n if (options?.name) {\n Reflect.defineMetadata('name', options.name, constructor);\n }\n\n Reflect.defineMetadata(\n 'job:options',\n {\n cron,\n requiresPopup: options?.requiresPopup ?? false,\n startPaused: options?.startPaused ?? false,\n schedulerDebug: options?.schedulerDebug ?? false,\n },\n constructor,\n );\n return constructor;\n };\n}\n","import { injectable } from '@inversifyjs/core';\n\n/**\n * Options for the EverySeconds decorator.\n */\nexport interface EverySecondsOptions {\n /** If true, job starts paused and must be resumed manually via Scheduler.resume() */\n startPaused?: boolean;\n\n /** Explicit job name (survives minification). Required for production builds. */\n name?: string;\n\n /**\n * If true, the job will only execute when the popup (or extension view) is visible.\n * This reduces unnecessary background activity when the user isn't looking at the extension.\n */\n requiresPopup?: boolean;\n\n /**\n * When true, scheduler diagnostics for this job are logged at `info` instead of only `debug`.\n * @see JobOptions.schedulerDebug\n */\n schedulerDebug?: boolean;\n}\n\n/**\n * Decorator for jobs that run at a specific interval in seconds.\n * Unlike cron expressions which have minute-level granularity,\n * this decorator allows for second-level precision.\n *\n * @param seconds - The interval in seconds between job executions\n * @param options - Optional configuration (startPaused, name, requiresPopup, etc.)\n *\n * @example\n * ```typescript\n * // Auto-starting job (default)\n * @EverySeconds(5, { name: 'MyJob' })\n * export class MyJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Runs every 5 seconds');\n * }\n * }\n *\n * // Job that only runs when popup is visible\n * @EverySeconds(10, { name: 'UiUpdateJob', requiresPopup: true })\n * export class UiUpdateJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Only runs when user is viewing extension');\n * }\n * }\n *\n * // Paused job that must be manually resumed\n * @EverySeconds(2, { startPaused: true, name: 'OnDemandJob' })\n * export class OnDemandJob implements IJob {\n * async handle(context: JobContext) {\n * console.log('Runs when resumed');\n * }\n * }\n * ```\n */\nexport function EverySeconds(seconds: number, options?: EverySecondsOptions) {\n return function (constructor: any) {\n injectable()(constructor);\n // Set explicit name metadata to survive minification\n if (options?.name) {\n Reflect.defineMetadata('name', options.name, constructor);\n }\n\n Reflect.defineMetadata(\n 'job:options',\n {\n delay: seconds * 1000,\n recurring: true,\n startPaused: options?.startPaused ?? false,\n requiresPopup: options?.requiresPopup ?? false,\n schedulerDebug: options?.schedulerDebug ?? false,\n },\n constructor,\n );\n return constructor;\n };\n}\n","export abstract class Booteable {\n /**\n * Boot method to be called when the service is initialized.\n * This method can be used to perform any setup or initialization logic.\n */\n abstract boot(): void;\n /**\n * Optional destroy method to be called when the service is being destroyed.\n * This can be used to clean up resources or perform any necessary teardown logic.\n */\n destroy?(): void {\n // Default implementation does nothing\n }\n}\n\nexport function isBooteable(obj: any): obj is Booteable {\n return typeof obj.boot === 'function';\n}\n\nexport function isDestroyable(obj: any): obj is Booteable {\n return typeof obj.destroy === 'function';\n}\n"],"names":[],"mappings":";;;;AAEO,SAAS,OAAA,GAAU;A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