ts-swc-transform 2.11.1 → 2.11.2
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/cjs/transformDirectory.js +3 -3
- package/dist/cjs/transformDirectory.js.map +1 -1
- package/dist/cjs/transformTypes.js +3 -3
- package/dist/cjs/transformTypes.js.map +1 -1
- package/dist/esm/transformDirectory.js +3 -5
- package/dist/esm/transformDirectory.js.map +1 -1
- package/dist/esm/transformTypes.js +3 -5
- package/dist/esm/transformTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -72,12 +72,12 @@ function transformDirectory(src, dest, type, options, callback) {
|
|
|
72
72
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
73
73
|
return new Promise(function(resolve, reject) {
|
|
74
74
|
return worker(src, dest, type, opts, function(err, result) {
|
|
75
|
-
err ? reject(err) : resolve(result);
|
|
75
|
+
return err ? reject(err) : resolve(result);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
} catch (err) {
|
|
79
|
-
if (callback) callback(err);
|
|
80
|
-
|
|
79
|
+
if (typeof callback === 'function') return callback(err);
|
|
80
|
+
return Promise.reject(err);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\n return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","bind","callbacks","spawnOptions","Error","tsconfig","loadConfigSync","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASQ,IAAIC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOjB,SAASU,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,IAAMC,SAASvB,SAAS,KAAKiB,MAAMO,IAAAA,qBAAI,EAAC,QAAQT,YAAY;IAAEU,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS3B,mBAAmBmB,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;QACF,IAAI,OAAOJ,QAAQ,UAAU,MAAM,IAAIS,MAAM;QAC7C,IAAI,OAAOR,SAAS,UAAU,MAAM,IAAIQ,MAAM;QAC9C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,IAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAGC,IAAAA,yBAAc,EAACX;QACtE,IAAMY,OAAsB;YAAEF,UAAAA;WAAaP;QAE3C,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMU,MAAMR;QACzE,OAAO,IAAIS,QAAQ,SAACC,SAASC;mBAAWV,OAAOL,KAAKC,MAAMC,MAAMU,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;IACtH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOZ,aAAa,YAAY,OAAOA,SAASY;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -71,12 +71,12 @@ function transformTypes(src, dest, options, callback) {
|
|
|
71
71
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
72
72
|
return new Promise(function(resolve, reject) {
|
|
73
73
|
return worker(src, dest, opts, function(err, result) {
|
|
74
|
-
err ? reject(err) : resolve(result);
|
|
74
|
+
return err ? reject(err) : resolve(result);
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
} catch (err) {
|
|
78
|
-
if (callback) callback(err);
|
|
79
|
-
|
|
78
|
+
if (typeof callback === 'function') return callback(err);
|
|
79
|
+
return Promise.reject(err);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\n return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","bind","callbacks","spawnOptions","Error","tsconfig","loadConfigSync","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASQ,IAAIC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOhB,SAASU,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,IAAMC,SAAStB,SAAS,KAAKiB,MAAMM,IAAAA,qBAAI,EAAC,QAAQR,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS1B,eAAemB,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;QACF,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIQ,MAAM;QAC7C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,IAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAGC,IAAAA,yBAAc,EAACV;QACtE,IAAMW,OAAsB;YAAEF,UAAAA;WAAaP;QAE3C,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMU,MAAMR;QACnE,OAAO,IAAIS,QAAQ,SAACC,SAASC;mBAAWV,OAAOJ,KAAKC,MAAMU,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;IAChH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOZ,aAAa,YAAY,OAAOA,SAASY;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -28,11 +28,9 @@ export default function transformDirectory(src, dest, type, options, callback) {
|
|
|
28
28
|
...options
|
|
29
29
|
};
|
|
30
30
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
31
|
-
return new Promise((resolve, reject)=>worker(src, dest, type, opts, (err, result)=>
|
|
32
|
-
err ? reject(err) : resolve(result);
|
|
33
|
-
}));
|
|
31
|
+
return new Promise((resolve, reject)=>worker(src, dest, type, opts, (err, result)=>err ? reject(err) : resolve(result)));
|
|
34
32
|
} catch (err) {
|
|
35
|
-
if (callback) callback(err);
|
|
36
|
-
|
|
33
|
+
if (typeof callback === 'function') return callback(err);
|
|
34
|
+
return Promise.reject(err);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","callbacks","spawnOptions","transformDirectory","Error","tsconfig","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOd,SAASO,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,MAAMC,SAASpB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,mBAAmBR,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;QACF,IAAI,OAAOJ,QAAQ,UAAU,MAAM,IAAIS,MAAM;QAC7C,IAAI,OAAOR,SAAS,UAAU,MAAM,IAAIQ,MAAM;QAC9C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,MAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAG3B,eAAeiB;QACtE,MAAMW,OAAsB;YAAED;YAAU,GAAGP,OAAO;QAAC;QAEnD,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMS,MAAMP;QACzE,OAAO,IAAIQ,QAAQ,CAACC,SAASC,SAAWT,OAAOL,KAAKC,MAAMC,MAAMS,MAAM,CAACI,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;IACtH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOX,aAAa,YAAY,OAAOA,SAASW;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -27,11 +27,9 @@ export default function transformTypes(src, dest, options, callback) {
|
|
|
27
27
|
...options
|
|
28
28
|
};
|
|
29
29
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
30
|
-
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>
|
|
31
|
-
err ? reject(err) : resolve(result);
|
|
32
|
-
}));
|
|
30
|
+
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>err ? reject(err) : resolve(result)));
|
|
33
31
|
} catch (err) {
|
|
34
|
-
if (callback) callback(err);
|
|
35
|
-
|
|
32
|
+
if (typeof callback === 'function') return callback(err);
|
|
33
|
+
return Promise.reject(err);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","callbacks","spawnOptions","transformTypes","Error","tsconfig","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOb,SAASO,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,MAAMC,SAASnB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAEQ,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,eAAeP,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;QACF,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIQ,MAAM;QAC7C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,MAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAG1B,eAAeiB;QACtE,MAAMU,OAAsB;YAAED;YAAU,GAAGP,OAAO;QAAC;QAEnD,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMS,MAAMP;QACnE,OAAO,IAAIQ,QAAQ,CAACC,SAASC,SAAWT,OAAOJ,KAAKC,MAAMS,MAAM,CAACI,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;IAChH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOX,aAAa,YAAY,OAAOA,SAASW;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|