synckit 0.11.7 → 0.11.8
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/lib/index.cjs +2 -8
- package/lib/index.d.cts +2 -5
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
//#region rolldown:runtime
|
3
2
|
var __create = Object.create;
|
4
3
|
var __defProp = Object.defineProperty;
|
@@ -383,12 +382,7 @@ function startWorkerThread(workerPath, { timeout = DEFAULT_TIMEOUT, execArgv = D
|
|
383
382
|
].includes(finalTsRunner)) throw new Error(`${finalTsRunner} is not supported for ${ext} files yet` + (isTsxSupported ? ", you can try [tsx](https://github.com/esbuild-kit/tsx) instead" : MTS_SUPPORTED ? ", you can try [oxc](https://github.com/oxc-project/oxc-node) or [swc](https://github.com/swc-project/swc-node/tree/master/packages/register) instead" : ""));
|
384
383
|
}
|
385
384
|
const finalGlobalShims = (globalShims === true ? DEFAULT_GLOBAL_SHIMS_PRESET : Array.isArray(globalShims) ? globalShims : []).filter(({ moduleName }) => (0, __pkgr_core.isPkgAvailable)(moduleName));
|
386
|
-
sharedBufferView ?? (sharedBufferView = new Int32Array(
|
387
|
-
/* istanbul ignore next */
|
388
|
-
sharedBuffer ?? (sharedBuffer = new SharedArrayBuffer(INT32_BYTES)),
|
389
|
-
0,
|
390
|
-
1
|
391
|
-
));
|
385
|
+
sharedBufferView ?? (sharedBufferView = new Int32Array(sharedBuffer ?? (sharedBuffer = new SharedArrayBuffer(INT32_BYTES)), 0, 1));
|
392
386
|
const useGlobals = finalGlobalShims.length > 0;
|
393
387
|
const useEval = isTs ? !tsUseEsm : !jsUseEsm && useGlobals;
|
394
388
|
const worker = new node_worker_threads.Worker(jsUseEsm && useGlobals || tsUseEsm && finalTsRunner === TsRunner.TsNode ? dataUrl(`${generateGlobals(finalWorkerPath, finalGlobalShims)};import '${String(workerPathUrl)}'`) : useEval ? `${generateGlobals(finalWorkerPath, finalGlobalShims, "require")};${encodeImportModule(finalWorkerPath, "require")}` : workerPathUrl, {
|
@@ -482,7 +476,7 @@ function createSyncFn(workerPath, timeoutOrOptions) {
|
|
482
476
|
workerPath,
|
483
477
|
/* istanbul ignore next */
|
484
478
|
typeof timeoutOrOptions === "number" ? { timeout: timeoutOrOptions } : timeoutOrOptions
|
485
|
-
);
|
479
|
+
);
|
486
480
|
syncFnCache.set(workerPath, syncFn);
|
487
481
|
return syncFn;
|
488
482
|
}
|
package/lib/index.d.cts
CHANGED
@@ -38,7 +38,8 @@ declare const LOADER_FLAG = "--loader";
|
|
38
38
|
declare const EXPERIMENTAL_LOADER_FLAG = "--experimental-loader";
|
39
39
|
declare const LOADER_FLAGS: Set<string>;
|
40
40
|
declare const IMPORT_FLAG_SUPPORTED: boolean;
|
41
|
-
declare const INT32_BYTES = 4;
|
41
|
+
declare const INT32_BYTES = 4;
|
42
|
+
//#endregion
|
42
43
|
//#region src/types.d.ts
|
43
44
|
type AnyFn<R = any, T extends any[] = any[]> = (...args: T) => R;
|
44
45
|
type Syncify<T extends AnyFn> = (...args: Parameters<T>) => Awaited<ReturnType<T>>;
|
@@ -86,7 +87,6 @@ interface SynckitOptions {
|
|
86
87
|
transferList?: TransferListItem[];
|
87
88
|
tsRunner?: TsRunner;
|
88
89
|
}
|
89
|
-
|
90
90
|
//#endregion
|
91
91
|
//#region src/common.d.ts
|
92
92
|
declare const hasFlag: (flag: string) => boolean;
|
@@ -94,7 +94,6 @@ declare const parseVersion: (version: string) => number[];
|
|
94
94
|
declare const compareVersion: (version1: string, version2: string) => 1 | -1 | 0;
|
95
95
|
declare const NODE_VERSION: string;
|
96
96
|
declare const compareNodeVersion: (version: string) => 1 | -1 | 0;
|
97
|
-
|
98
97
|
//#endregion
|
99
98
|
//#region src/helpers.d.ts
|
100
99
|
declare const isFile: (path: string) => boolean;
|
@@ -131,11 +130,9 @@ declare function startWorkerThread<T extends AnyFn, R = Awaited<ReturnType<T>>>(
|
|
131
130
|
globalShims
|
132
131
|
}?: SynckitOptions): (...args: Parameters<T>) => R;
|
133
132
|
declare const overrideStdio: (stdio: StdioChunk[]) => void;
|
134
|
-
|
135
133
|
//#endregion
|
136
134
|
//#region src/index.d.ts
|
137
135
|
declare function createSyncFn<T extends AnyFn>(workerPath: URL | string, timeoutOrOptions?: SynckitOptions | number): Syncify<T>;
|
138
136
|
declare function runAsWorker<T extends AnyFn<Promise<R> | R>, R = ReturnType<T>>(fn: T): void;
|
139
|
-
|
140
137
|
//#endregion
|
141
138
|
export { AnyFn, DEFAULT_EXEC_ARGV, DEFAULT_GLOBAL_SHIMS, DEFAULT_GLOBAL_SHIMS_PRESET, DEFAULT_TIMEOUT, DEFAULT_TS_RUNNER, DEFAULT_TYPES_NODE_VERSION, DataMessage, EXPERIMENTAL_LOADER_FLAG, FEATURE_TYPESCRIPT_NODE_VERSION, GlobalShim, IMPORT_FLAG, IMPORT_FLAG_SUPPORTED, INT32_BYTES, LOADER_FLAG, LOADER_FLAGS, MODULE_REGISTER_SUPPORTED, MTS_SUPPORTED, MainToWorkerCommandMessage, MainToWorkerMessage, NODE_OPTIONS, NODE_VERSION, NO_STRIP_TYPES, NO_STRIP_TYPES_FLAG, PackageJson, REQUIRE_ABBR_FLAG, REQUIRE_FLAG, REQUIRE_FLAGS, STRIP_TYPES_FLAG, STRIP_TYPES_NODE_VERSION, StdioChunk, Syncify, SynckitOptions, TRANSFORM_TYPES_FLAG, TRANSFORM_TYPES_NODE_VERSION, TS_ESM_PARTIAL_SUPPORTED, TsRunner, ValueOf, WorkerData, WorkerToMainMessage, compareNodeVersion, compareVersion, createSyncFn, dataUrl, encodeImportModule, extractProperties, generateGlobals, hasFlag, hasImportFlag, hasLoaderFlag, hasRequireFlag, isFile, md5Hash, overrideStdio, parseVersion, runAsWorker, setupTsRunner, startWorkerThread };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "synckit",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.8",
|
4
4
|
"type": "module",
|
5
5
|
"description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",
|
6
6
|
"repository": "https://github.com/un-ts/synckit.git",
|