diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 30e6ae8..02675d5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -10,7 +10,7 @@ }, "problemMatcher": [], "label": "npm: build", - "detail": "pwsh -Command \"npx tsc && copy src/workers.d.ts dist/\"" + "detail": "Build package" } ] } \ No newline at end of file diff --git a/package.json b/package.json index 371d866..a4cef35 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "types": "dist/index.d.ts", "main": "dist/index.js", "scripts": { - "build": "pwsh -Command \"npx tsc && copy src/workers.d.ts dist/\"", + "build": "npx tsc", "postbuild": "publint", "deploy-pages": "cd ./pages && npm run deploy-pages", "test": "npm run test:unit && npm run test:types", diff --git a/src/cancellation/CancellationSource.ts b/src/cancellation/CancellationSource.ts index 93be82b..66d7053 100644 --- a/src/cancellation/CancellationSource.ts +++ b/src/cancellation/CancellationSource.ts @@ -1,7 +1,7 @@ import { Event } from "../sync/Event.js"; import { cancellationSourceIdentityData } from "../sync/identifiers.js"; import { isSignaled } from "../sync/ManualResetEvent.js"; -import type { Token } from "../workers.js"; +import type { Token } from "../types.js"; import { TaskCancelledError } from "./TaskCancelledError.js"; /** diff --git a/src/index.ts b/src/index.ts index 150b37f..d5393eb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,3 +12,4 @@ export * from './workers/AsyncWorker.js'; export * from "./workers/workerListener.js"; export * from './workers/WorkerTerminatedMessage.js'; export * from "./workers/WorkItem.js"; +export type * from "./types.js"; diff --git a/src/sync/AutoResetEvent.ts b/src/sync/AutoResetEvent.ts index b2204d8..f1fa9f5 100644 --- a/src/sync/AutoResetEvent.ts +++ b/src/sync/AutoResetEvent.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.js"; +import type { Token } from "../types.js"; import { Event } from "./Event.js"; import { autoResetEventIdentityData, checkToken } from "./identifiers.js"; diff --git a/src/sync/ManualResetEvent.ts b/src/sync/ManualResetEvent.ts index c974d54..7d2bac4 100644 --- a/src/sync/ManualResetEvent.ts +++ b/src/sync/ManualResetEvent.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.js"; +import type { Token } from "../types.js"; import { Event } from './Event.js'; import { checkToken, manualResetEventIdentityData, type IdentifierData } from "./identifiers.js"; diff --git a/src/sync/Mutex.ts b/src/sync/Mutex.ts index 67e3b1c..8b3056f 100644 --- a/src/sync/Mutex.ts +++ b/src/sync/Mutex.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.d.ts"; +import type { Token } from "../types.js"; import { mutexIdentityData } from "./identifiers.js"; import { acquire, acquireAsync, SemaphoreInternal, type Releaser } from "./Semaphore.js"; diff --git a/src/sync/Semaphore.ts b/src/sync/Semaphore.ts index a8d54bf..3066d34 100644 --- a/src/sync/Semaphore.ts +++ b/src/sync/Semaphore.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.js"; +import type { Token } from "../types.js"; import { checkToken, semaphoreIdentityData, type IdentifierData } from "./identifiers.js"; import { SyncObject } from "./SyncObject.js"; diff --git a/src/sync/SyncObject.ts b/src/sync/SyncObject.ts index 6b79b9c..1cc6a7f 100644 --- a/src/sync/SyncObject.ts +++ b/src/sync/SyncObject.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.d.ts"; +import type { Token } from "../types.js"; /** * Base class for synchronization objects. diff --git a/src/sync/identifiers.ts b/src/sync/identifiers.ts index a3a1d97..255490d 100644 --- a/src/sync/identifiers.ts +++ b/src/sync/identifiers.ts @@ -1,4 +1,4 @@ -import type { Token } from "../workers.d.ts"; +import type { Token } from "../types.js"; export type IdentifierData = [ number, diff --git a/src/workers.d.ts b/src/types.ts similarity index 100% rename from src/workers.d.ts rename to src/types.ts diff --git a/src/workers/AsyncWorker.ts b/src/workers/AsyncWorker.ts index f88b965..e7a3720 100644 --- a/src/workers/AsyncWorker.ts +++ b/src/workers/AsyncWorker.ts @@ -1,6 +1,6 @@ import { Queue } from "../misc/Queue.js"; import { nextWorkItemId } from "../misc/nextWorkItemId.js"; -import type { IWorker, QueueingOptions, RejectFn, WorkerTasks, WorkItemData } from "../workers.js"; +import type { IWorker, QueueingOptions, RejectFn, WorkerTasks, WorkItemData } from "../types.js"; import { InternalSharedWorker } from "./InternalSharedWorker.js"; import { InternalWorker } from "./InternalWorker.js"; import { WorkItem } from "./WorkItem.js"; diff --git a/src/workers/InternalSharedWorker.ts b/src/workers/InternalSharedWorker.ts index bf99ebc..729bd3d 100644 --- a/src/workers/InternalSharedWorker.ts +++ b/src/workers/InternalSharedWorker.ts @@ -1,5 +1,5 @@ import { CancelledMessage } from "../cancellation/CancelledMessage.js"; -import type { AsyncMessageUntyped, AsyncResponse, DisconnectFn, IWorker, ProcessMessageFn, RejectFn, TaskCancelledMessage } from "../workers.js"; +import type { AsyncMessageUntyped, AsyncResponse, DisconnectFn, IWorker, ProcessMessageFn, RejectFn, TaskCancelledMessage } from "../types.js"; function isTaskCancelledMessage(message: any): message is TaskCancelledMessage { return message?.payload?._$cancelled === true && typeof message.workItemId === 'number'; diff --git a/src/workers/InternalWorker.ts b/src/workers/InternalWorker.ts index 9e00125..4276205 100644 --- a/src/workers/InternalWorker.ts +++ b/src/workers/InternalWorker.ts @@ -1,5 +1,5 @@ import { CancelledMessage } from "../cancellation/CancelledMessage.js"; -import type { AsyncMessageUntyped, AsyncResponse, DisconnectFn, IWorker, ProcessMessageFn, RejectFn, TaskCancelledMessage } from "../workers.js"; +import type { AsyncMessageUntyped, AsyncResponse, DisconnectFn, IWorker, ProcessMessageFn, RejectFn, TaskCancelledMessage } from "../types.js"; import { WorkerTerminatedMessage } from "./WorkerTerminatedMessage.js"; function isTaskCancelledMessage(message: any): message is TaskCancelledMessage { diff --git a/src/workers/WorkItemInternal.ts b/src/workers/WorkItemInternal.ts index 5513fb6..345a4d3 100644 --- a/src/workers/WorkItemInternal.ts +++ b/src/workers/WorkItemInternal.ts @@ -1,6 +1,6 @@ import { CancellationSource } from "../cancellation/CancellationSource.js"; import { CancelledMessage } from "../cancellation/CancelledMessage.js"; -import type { AsyncMessageUntyped, DisconnectFn, IWorker, QueueingOptions, WorkItemData } from "../workers.js"; +import type { AsyncMessageUntyped, DisconnectFn, IWorker, QueueingOptions, WorkItemData } from "../types.js"; import { WorkItemStatus, type WorkItemStatusEnum } from "./AsyncWorker.js"; import { WorkerTerminatedMessage } from "./WorkerTerminatedMessage.js"; diff --git a/src/workers/workerListener.ts b/src/workers/workerListener.ts index b5f027e..3336a2e 100644 --- a/src/workers/workerListener.ts +++ b/src/workers/workerListener.ts @@ -1,5 +1,5 @@ import { TaskCancelledError } from "../cancellation/TaskCancelledError.js"; -import type { AsyncMessageUntyped, AsyncResponse } from "../workers.d.ts"; +import type { AsyncMessageUntyped, AsyncResponse } from "../types.js"; /** * Defines the function provided to worker tasks so workers can communicate back to the calling thread. diff --git a/tests/typetests/index.test.ts b/tests/typetests/index.test.ts index 1747865..09a37d9 100644 --- a/tests/typetests/index.test.ts +++ b/tests/typetests/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "tstyche"; -import type { Token, WorkerTasks, AsyncMessage, QueueingOptions } from "../../src/workers.js"; +import type { Token, WorkerTasks, AsyncMessage, QueueingOptions } from "../../src/types.js"; import { CancellationSource } from "../../src/cancellation/CancellationSource.js"; import { TaskCancelledError } from "../../src/cancellation/TaskCancelledError.js"; import { Queue } from "../../src/misc/Queue.js"; diff --git a/tests/ut/helpers/helpers.ts b/tests/ut/helpers/helpers.ts index 5fcc021..cb520cb 100644 --- a/tests/ut/helpers/helpers.ts +++ b/tests/ut/helpers/helpers.ts @@ -1,6 +1,6 @@ import { sinon } from "../../setup.js"; import Worker from 'web-worker'; -import type { Token } from "../../../src/workers.js"; +import type { Token } from "../../../src/types.js"; import { SyncObject } from "../../../src/sync/SyncObject.js"; export type StubbedAtomics = { diff --git a/tests/ut/workers/WorkItem.test.ts b/tests/ut/workers/WorkItem.test.ts index 79f07a7..2f511c5 100644 --- a/tests/ut/workers/WorkItem.test.ts +++ b/tests/ut/workers/WorkItem.test.ts @@ -6,7 +6,7 @@ import { WorkItemInternal } from '../../../src/workers/WorkItemInternal.js'; import { WorkItemStatus } from '../../../src/workers/AsyncWorker.js'; import { CancelledMessage } from '../../../src/cancellation/CancelledMessage.js'; import { CancellationSource } from '../../../src/cancellation/CancellationSource.js'; -import { WorkItemData, IWorker } from '../../../src/workers.js'; +import type { WorkItemData, IWorker } from '../../../src/types.js'; describe('WorkItem', () => { let workItem: WorkItem;