diff --git a/index.mjs b/index.mjs index 8b26b48..878d647 100644 --- a/index.mjs +++ b/index.mjs @@ -11,7 +11,11 @@ * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved. */ -// Development environment check (must happen before holdmytask imports) +// Development environment check. NOTE: the static `import` of the core below is +// hoisted and evaluated before this IIFE body runs, so devcheck does NOT run before +// the core loads - it's a best-effort, fire-and-forget dev-time warning. (Running it +// strictly first would require a dynamic import + top-level await, which breaks the +// index.cjs bridge's synchronous `require` of this module - see PR #11 discussion.) (async () => { try { await import("./devcheck.mjs"); @@ -20,56 +24,51 @@ } })(); +import { HoldMyTask } from "@cldmv/holdmytask/main"; + /** * Creates a HoldMyTask instance for task queue management * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ -export default async function createHoldMyTask(options = {}) { - // Dynamic import after environment check - const mod = await import("@cldmv/holdmytask/main"); - const HoldMyTask = mod.HoldMyTask; +export async function createHoldMyTask(options = {}) { return new HoldMyTask(options); } /** * Create a task queue instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ export async function createQueue(options = {}) { - const mod = await import("@cldmv/holdmytask/main"); - const HoldMyTask = mod.HoldMyTask; return new HoldMyTask(options); } /** * Create a task manager instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ export async function createTaskManager(options = {}) { - const mod = await import("@cldmv/holdmytask/main"); - const HoldMyTask = mod.HoldMyTask; return new HoldMyTask(options); } /** * Create a task processor instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ export async function createTaskProcessor(options = {}) { - const mod = await import("@cldmv/holdmytask/main"); - const HoldMyTask = mod.HoldMyTask; return new HoldMyTask(options); } -// Named export aliases -export { createHoldMyTask as HoldMyTask }; -export { createQueue as queue }; -export { createQueue as Queue }; -export { createTaskManager as TaskManager }; -export { createQueue as TaskQueue }; -export { createQueue as QueueManager }; -export { createTaskProcessor as TaskProcessor }; +// HoldMyTask and its constructor aliases are the real class (see issue #3) - `new +// HoldMyTask()`, `new QueueManager()`, etc. all construct the same underlying type. +export { HoldMyTask }; +export default HoldMyTask; +export { HoldMyTask as queue }; +export { HoldMyTask as Queue }; +export { HoldMyTask as TaskManager }; +export { HoldMyTask as TaskQueue }; +export { HoldMyTask as QueueManager }; +export { HoldMyTask as TaskProcessor }; diff --git a/tests/CommonAliases.test.vitest.mjs b/tests/CommonAliases.test.vitest.mjs index b853c13..f7f560f 100644 --- a/tests/CommonAliases.test.vitest.mjs +++ b/tests/CommonAliases.test.vitest.mjs @@ -8,21 +8,10 @@ * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved. */ -// Whole file skipped: every describe block below assumes HoldMyTask / -// Queue / TaskManager / TaskQueue / QueueManager / TaskProcessor (as -// imported from "../index.mjs") are constructors ("new HoldMyTask()" -// etc.), but index.mjs actually exports async factory functions -// (createHoldMyTask() and friends) under those names. This is a -// pre-existing mismatch between the test suite and the real runtime -// exports, unrelated to the v4 CI/vitest-runner onboarding that first -// wired these tests into CI — see -// https://github.com/CLDMV/holdmytask/issues/3. Un-skip once that's -// resolved (either the aliases become real constructors, or these -// tests are rewritten to call the factories instead of `new`-ing them). import { test, expect, describe } from "vitest"; import { HoldMyTask, Queue, TaskManager, TaskQueue, QueueManager, TaskProcessor } from "../index.mjs"; -describe.skip("Common Queue System Aliases", () => { +describe("Common Queue System Aliases", () => { test("should export HoldMyTask as the main class", () => { expect(HoldMyTask).toBeDefined(); expect(typeof HoldMyTask).toBe("function"); @@ -340,7 +329,7 @@ describe.skip("Common Queue System Aliases", () => { }); }); -describe.skip("Primary Method Names", () => { +describe("Primary Method Names", () => { test("has() should work as primary method", () => { const queue = new HoldMyTask(); const customId = "primary-has-test"; @@ -393,7 +382,7 @@ describe.skip("Primary Method Names", () => { }); }); -describe.skip("Method Alias Compatibility", () => { +describe("Method Alias Compatibility", () => { test("hasTask() should work as alias for has()", () => { const queue = new HoldMyTask(); const customId = "hasTask-alias-test"; @@ -456,7 +445,7 @@ describe.skip("Method Alias Compatibility", () => { }); }); -describe.skip("Enqueue Method Aliases", () => { +describe("Enqueue Method Aliases", () => { test("schedule() should work as alias for enqueue()", () => { const queue = new HoldMyTask(); let executed = false; @@ -538,7 +527,7 @@ describe.skip("Enqueue Method Aliases", () => { }); }); -describe.skip("Import Aliases", () => { +describe("Import Aliases", () => { test("queue alias should work", async () => { const { queue } = await import("../index.mjs"); const instance = new queue(); @@ -606,7 +595,7 @@ describe.skip("Import Aliases", () => { }); }); -describe.skip("Control Method Aliases", () => { +describe("Control Method Aliases", () => { test("shutdown() should work as alias for destroy()", async () => { const queue = new HoldMyTask(); diff --git a/types/examples/priority-stress-test.d.mts b/types/examples/priority-stress-test.d.mts index 16a1388..ae7f36d 100644 --- a/types/examples/priority-stress-test.d.mts +++ b/types/examples/priority-stress-test.d.mts @@ -60,7 +60,7 @@ declare class PriorityVolumeController { declare function runPriorityStressTests(): Promise<{ scenario: string; totalDuration: number; - accurateCommands: number; + accurateCommands: any; totalCommands: number; accuracyRate: number; finalVolume: number; diff --git a/types/index.d.mts b/types/index.d.mts index 911b5fe..af165b3 100644 --- a/types/index.d.mts +++ b/types/index.d.mts @@ -10,35 +10,37 @@ * ----- * @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved. */ +import { HoldMyTask } from "@cldmv/holdmytask/main"; /** * Creates a HoldMyTask instance for task queue management * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ -export default function createHoldMyTask(options?: object): Promise; +export declare function createHoldMyTask(options?: object): Promise; /** * Create a task queue instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ -export declare function createQueue(options?: object): Promise; +export declare function createQueue(options?: object): Promise; /** * Create a task manager instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ -export declare function createTaskManager(options?: object): Promise; +export declare function createTaskManager(options?: object): Promise; /** * Create a task processor instance * @param {object} [options={}] - Configuration options - * @returns {Promise} HoldMyTask instance + * @returns {Promise} HoldMyTask instance */ -export declare function createTaskProcessor(options?: object): Promise; -export { createHoldMyTask as HoldMyTask }; -export { createQueue as queue }; -export { createQueue as Queue }; -export { createTaskManager as TaskManager }; -export { createQueue as TaskQueue }; -export { createQueue as QueueManager }; -export { createTaskProcessor as TaskProcessor }; +export declare function createTaskProcessor(options?: object): Promise; +export { HoldMyTask }; +export default HoldMyTask; +export { HoldMyTask as queue }; +export { HoldMyTask as Queue }; +export { HoldMyTask as TaskManager }; +export { HoldMyTask as TaskQueue }; +export { HoldMyTask as QueueManager }; +export { HoldMyTask as TaskProcessor }; //# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/types/index.d.mts.map b/types/index.d.mts.map index 72a5e49..9a1ce9d 100644 --- a/types/index.d.mts.map +++ b/types/index.d.mts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH;;;;GAIG;AACH,wBAA8B,gBAAgB,CAAC,OAAO,AAHnD,CACA,EADQ,MAGgD,GAF9C,OAAO,CAAC,MAAM,CAAC,CAO3B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,AAHtC,CACA,EADQ,MAGmC,GAFjC,OAAO,CAAC,MAAM,CAAC,CAM3B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,AAH5C,CACA,EADQ,MAGyC,GAFvC,OAAO,CAAC,MAAM,CAAC,CAM3B;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,AAH9C,CACA,EADQ,MAG2C,GAFzC,OAAO,CAAC,MAAM,CAAC,CAM3B;AAGD,OAAO,EAAE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AAU,IAAI,aAAa,EAAE,CAAC"} \ No newline at end of file