ts-swc-transform 2.6.24 → 2.7.0
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/compat.d.cts +6 -0
- package/dist/cjs/compat.d.ts +6 -0
- package/dist/cjs/compat.js +49 -0
- package/dist/cjs/compat.js.map +1 -0
- package/dist/cjs/lib/rewriteExtensions.js +2 -7
- package/dist/cjs/lib/rewriteExtensions.js.map +1 -1
- package/dist/cjs/lib/urlFileUrl.d.cts +1 -2
- package/dist/cjs/lib/urlFileUrl.d.ts +1 -2
- package/dist/cjs/lib/urlFileUrl.js +31 -19
- package/dist/cjs/lib/urlFileUrl.js.map +1 -1
- package/dist/cjs/toPath.js +2 -2
- package/dist/cjs/toPath.js.map +1 -1
- package/dist/esm/compat.d.ts +6 -0
- package/dist/esm/compat.js +30 -0
- package/dist/esm/compat.js.map +1 -0
- package/dist/esm/lib/rewriteExtensions.js +2 -2
- package/dist/esm/lib/rewriteExtensions.js.map +1 -1
- package/dist/esm/lib/urlFileUrl.d.ts +1 -2
- package/dist/esm/lib/urlFileUrl.js +31 -19
- package/dist/esm/lib/urlFileUrl.js.map +1 -1
- package/dist/esm/toPath.js +2 -2
- package/dist/esm/toPath.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Layer for Node.js 0.8+
|
|
3
|
+
* Local to this package - contains only needed functions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stringStartsWith(str: string, search: string, position?: number): boolean;
|
|
6
|
+
export declare function stringReplaceAll(str: string, search: string, replace: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Layer for Node.js 0.8+
|
|
3
|
+
* Local to this package - contains only needed functions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stringStartsWith(str: string, search: string, position?: number): boolean;
|
|
6
|
+
export declare function stringReplaceAll(str: string, search: string, replace: string): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get stringReplaceAll () {
|
|
13
|
+
return stringReplaceAll;
|
|
14
|
+
},
|
|
15
|
+
get stringStartsWith () {
|
|
16
|
+
return stringStartsWith;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Compatibility Layer for Node.js 0.8+
|
|
21
|
+
* Local to this package - contains only needed functions.
|
|
22
|
+
*/ /**
|
|
23
|
+
* String.prototype.startsWith wrapper for Node.js 0.8+
|
|
24
|
+
* - Uses native startsWith on Node 4.0+ / ES2015+
|
|
25
|
+
* - Falls back to indexOf on Node 0.8-3.x
|
|
26
|
+
*/ var hasStartsWith = typeof String.prototype.startsWith === 'function';
|
|
27
|
+
function stringStartsWith(str, search, position) {
|
|
28
|
+
if (hasStartsWith) {
|
|
29
|
+
return str.startsWith(search, position);
|
|
30
|
+
}
|
|
31
|
+
position = position || 0;
|
|
32
|
+
return str.indexOf(search, position) === position;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* String.prototype.replaceAll wrapper for Node.js 0.8+
|
|
36
|
+
* - Uses native replaceAll on Node 15.0+ / ES2021+
|
|
37
|
+
* - Falls back to regex replace on older versions
|
|
38
|
+
*/ // biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll
|
|
39
|
+
var hasReplaceAll = typeof String.prototype.replaceAll === 'function';
|
|
40
|
+
function stringReplaceAll(str, search, replace) {
|
|
41
|
+
if (hasReplaceAll) {
|
|
42
|
+
// biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available
|
|
43
|
+
return str.replaceAll(search, replace);
|
|
44
|
+
}
|
|
45
|
+
// Escape special regex characters
|
|
46
|
+
var escaped = search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
47
|
+
return str.replace(new RegExp(escaped, 'g'), replace);
|
|
48
|
+
}
|
|
49
|
+
/* 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; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nvar hasStartsWith = typeof String.prototype.startsWith === 'function';\n\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) {\n return str.startsWith(search, position);\n }\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * String.prototype.replaceAll wrapper for Node.js 0.8+\n * - Uses native replaceAll on Node 15.0+ / ES2021+\n * - Falls back to regex replace on older versions\n */\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll\nvar hasReplaceAll = typeof (String.prototype as any).replaceAll === 'function';\n\nexport function stringReplaceAll(str: string, search: string, replace: string): string {\n if (hasReplaceAll) {\n // biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available\n return (str as any).replaceAll(search, replace);\n }\n // Escape special regex characters\n var escaped = search.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return str.replace(new RegExp(escaped, 'g'), replace);\n}\n"],"names":["stringReplaceAll","stringStartsWith","hasStartsWith","String","prototype","startsWith","str","search","position","indexOf","hasReplaceAll","replaceAll","replace","escaped","RegExp"],"mappings":";;;;;;;;;;;QA4BgBA;eAAAA;;QAhBAC;eAAAA;;;AAZhB;;;CAGC,GAED;;;;CAIC,GACD,IAAIC,gBAAgB,OAAOC,OAAOC,SAAS,CAACC,UAAU,KAAK;AAEpD,SAASJ,iBAAiBK,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC7E,IAAIN,eAAe;QACjB,OAAOI,IAAID,UAAU,CAACE,QAAQC;IAChC;IACAA,WAAWA,YAAY;IACvB,OAAOF,IAAIG,OAAO,CAACF,QAAQC,cAAcA;AAC3C;AAEA;;;;CAIC,GACD,sFAAsF;AACtF,IAAIE,gBAAgB,OAAO,AAACP,OAAOC,SAAS,CAASO,UAAU,KAAK;AAE7D,SAASX,iBAAiBM,GAAW,EAAEC,MAAc,EAAEK,OAAe;IAC3E,IAAIF,eAAe;QACjB,qFAAqF;QACrF,OAAO,AAACJ,IAAYK,UAAU,CAACJ,QAAQK;IACzC;IACA,kCAAkC;IAClC,IAAIC,UAAUN,OAAOK,OAAO,CAAC,uBAAuB;IACpD,OAAON,IAAIM,OAAO,CAAC,IAAIE,OAAOD,SAAS,MAAMD;AAC/C"}
|
|
@@ -22,12 +22,7 @@ _export(exports, {
|
|
|
22
22
|
return rewriteExtensionsCJS;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
var
|
|
26
|
-
function _interop_require_default(obj) {
|
|
27
|
-
return obj && obj.__esModule ? obj : {
|
|
28
|
-
default: obj
|
|
29
|
-
};
|
|
30
|
-
}
|
|
25
|
+
var _compatts = require("../compat.js");
|
|
31
26
|
var extensions = {
|
|
32
27
|
'.ts': '.js',
|
|
33
28
|
'.tsx': '.js',
|
|
@@ -40,7 +35,7 @@ function replaceExtension(ext) {
|
|
|
40
35
|
}
|
|
41
36
|
// Helper to check if a path is relative (starts with ./ or ../)
|
|
42
37
|
function isRelativePath(path) {
|
|
43
|
-
return (0,
|
|
38
|
+
return (0, _compatts.stringStartsWith)(path, './') || (0, _compatts.stringStartsWith)(path, '../');
|
|
44
39
|
}
|
|
45
40
|
function rewriteExtensions(content) {
|
|
46
41
|
var result = content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/rewriteExtensions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/rewriteExtensions.ts"],"sourcesContent":["import { stringStartsWith } from '../compat.ts';\n\nexport const extensions = {\n '.ts': '.js',\n '.tsx': '.js',\n '.mts': '.mjs',\n '.cts': '.cjs',\n};\n\nexport function replaceExtension(ext: string): string {\n const replace = extensions[ext];\n return replace === undefined ? ext : replace;\n}\n\n// Helper to check if a path is relative (starts with ./ or ../)\nfunction isRelativePath(path: string): boolean {\n return stringStartsWith(path, './') || stringStartsWith(path, '../');\n}\n\n// Multi-pattern transformer for TypeScript extension rewriting\n// See: https://github.com/microsoft/TypeScript/issues/61037\n// TODO: Remove when TypeScript natively supports rewriteRelativeImportExtensions in .d.ts files\n\nexport function rewriteExtensions(content: string): string {\n let result = content;\n\n // Pattern 1: Import/Export statements (with optional 'type' keyword)\n // Matches: import { X } from './path.ts'\n // import type { X } from './path.ts'\n // export * from './path.ts'\n // export type * from './path.ts'\n result = result.replace(/\\b(import|export)(\\s+type)?(?:\\s+[^'\"]*?\\s+from\\s+|\\s+)['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]/g, (match, _keyword, _typeKeyword, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n // Pattern 2: Dynamic import types\n // Matches: typeof import('./path.ts')\n result = result.replace(/\\bimport\\s*\\(\\s*['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]\\s*\\)/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n // Pattern 3: Triple-slash path references\n // Matches: /// <reference path=\"./file.ts\" />\n // /// <reference path=\"./file.d.ts\" />\n result = result.replace(/\\/\\/\\/\\s*<reference\\s+path\\s*=\\s*['\"]([^'\"]+)\\.(d\\.ts|tsx?|mts|cts)['\"]\\s*\\/>/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n // Special case: .d.ts → .d.js\n const newExt = ext === 'd.ts' ? '.d.js' : replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n return result;\n}\n\n// CJS-specific version that also handles require() statements\nexport function rewriteExtensionsCJS(content: string): string {\n // Start with all ESM patterns\n let result = rewriteExtensions(content);\n\n // Pattern 4: CommonJS require() statements\n // Matches: require('./path.ts')\n result = result.replace(/\\brequire\\s*\\(\\s*['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]\\s*\\)/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n return result;\n}\n"],"names":["extensions","replaceExtension","rewriteExtensions","rewriteExtensionsCJS","ext","replace","undefined","isRelativePath","path","stringStartsWith","content","result","match","_keyword","_typeKeyword","newExt"],"mappings":";;;;;;;;;;;QAEaA;eAAAA;;QAOGC;eAAAA;;QAcAC;eAAAA;;QAoCAC;eAAAA;;;wBA3DiB;AAE1B,IAAMH,aAAa;IACxB,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;AACV;AAEO,SAASC,iBAAiBG,GAAW;IAC1C,IAAMC,UAAUL,U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,OAAOJ,MAAMJ;QACtH,IAAI,CAACG,eAAeC,OAAO,OAAOI;QAClC,8BAA8B;QAC9B,IAAMG,SAASX,QAAQ,SAAS,UAAUH,iBAAiB,AAAC,IAAO,OAAJG;QAC/D,OAAOQ,MAAMP,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAI,AAAC,GAAS,OAAPW,QAAO,MAAIV,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAI,AAAC,GAAS,OAAPW,QAAO,MAAIV,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAK,AAAC,GAAS,OAAPW,QAAO;IAClH;IAEA,OAAOJ;AACT;AAGO,SAASR,qBAAqBO,OAAe;IAClD,8BAA8B;IAC9B,IAAIC,SAAST,kBAAkBQ;IAE/B,2CAA2C;IAC3C,gCAAgC;IAChCC,SAASA,OAAON,OAAO,CAAC,2DAA2D,SAACO,OAAOJ,MAAMJ;QAC/F,IAAI,CAACG,eAAeC,OAAO,OAAOI;QAClC,IAAMG,SAASd,iBAAiB,AAAC,IAAO,OAAJG;QACpC,OAAOQ,MAAMP,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAI,AAAC,GAAS,OAAPW,QAAO,MAAIV,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAI,AAAC,GAAS,OAAPW,QAAO,MAAIV,OAAO,CAAC,AAAC,IAAO,OAAJD,KAAI,MAAK,AAAC,GAAS,OAAPW,QAAO;IAClH;IAEA,OAAOJ;AACT"}
|
|
@@ -18,37 +18,49 @@ _export(exports, {
|
|
|
18
18
|
return pathToFileURL;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
var
|
|
22
|
-
var _index = /*#__PURE__*/ _interop_require_default(require("core-js-pure/actual/url/index.js"));
|
|
21
|
+
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
23
22
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
23
|
+
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
24
|
+
var _compatts = require("../compat.js");
|
|
24
25
|
function _interop_require_default(obj) {
|
|
25
26
|
return obj && obj.__esModule ? obj : {
|
|
26
27
|
default: obj
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
// ESM-compatible require
|
|
31
|
+
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
32
|
+
// URL class - available natively in Node 7.0+, use core-js-pure for Node 0.8-6.x
|
|
33
|
+
// biome-ignore lint/suspicious/noExplicitAny: Feature detection for URL class
|
|
34
|
+
var URLClass = _url.default.URL;
|
|
35
|
+
if (!URLClass) {
|
|
36
|
+
URLClass = _require('core-js-pure/actual/url/index.js');
|
|
37
|
+
}
|
|
29
38
|
var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
30
|
-
function fileURLToPath(
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
function fileURLToPath(urlInput) {
|
|
40
|
+
var parsedUrl;
|
|
41
|
+
if (typeof urlInput === 'string') {
|
|
42
|
+
parsedUrl = new URLClass(urlInput);
|
|
43
|
+
} else {
|
|
44
|
+
parsedUrl = urlInput;
|
|
33
45
|
}
|
|
34
|
-
if (
|
|
46
|
+
if (parsedUrl.protocol !== 'file:') {
|
|
35
47
|
throw new Error('The URL must use the file: protocol');
|
|
36
48
|
}
|
|
37
49
|
if (isWindows) {
|
|
38
|
-
if (/%2f|%5c/i.test(
|
|
50
|
+
if (/%2f|%5c/i.test(parsedUrl.pathname)) {
|
|
39
51
|
throw new Error('The file: URL path must not include encoded \\ or / characters');
|
|
40
52
|
}
|
|
41
53
|
} else {
|
|
42
|
-
if (
|
|
54
|
+
if (parsedUrl.hostname) {
|
|
43
55
|
throw new Error("The file: URL host must be 'localhost' or empty");
|
|
44
56
|
}
|
|
45
|
-
if (/%2f/i.test(
|
|
57
|
+
if (/%2f/i.test(parsedUrl.pathname)) {
|
|
46
58
|
throw new Error('The file: URL path must not include encoded / characters');
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
|
-
var pathname = _path.default.normalize(decodeURIComponent(
|
|
61
|
+
var pathname = _path.default.normalize(decodeURIComponent(parsedUrl.pathname));
|
|
50
62
|
if (isWindows) {
|
|
51
|
-
if (
|
|
63
|
+
if (parsedUrl.hostname) return "\\\\".concat(parsedUrl.hostname).concat(pathname);
|
|
52
64
|
var letter = pathname.charCodeAt(1) | 0x20;
|
|
53
65
|
if (letter < 0x61 /* a */ || letter > 0x7a /* z */ || pathname.charCodeAt(2) !== 0x3a /* : */ ) {
|
|
54
66
|
throw new Error('The file: URL path must be absolute');
|
|
@@ -64,15 +76,15 @@ function pathToFileURL(pathname) {
|
|
|
64
76
|
} else if (isWindows && pathname[pathname.length - 1] === '\\') {
|
|
65
77
|
resolved += '\\';
|
|
66
78
|
}
|
|
67
|
-
resolved = (0,
|
|
68
|
-
resolved = (0,
|
|
69
|
-
resolved = (0,
|
|
70
|
-
resolved = (0,
|
|
71
|
-
resolved = (0,
|
|
72
|
-
resolved = (0,
|
|
79
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '%', '%25'); // Must be first
|
|
80
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '#', '%23');
|
|
81
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '?', '%3f');
|
|
82
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '\n', '%0a');
|
|
83
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '\r', '%0d');
|
|
84
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '\t', '%09');
|
|
73
85
|
if (!isWindows) {
|
|
74
|
-
resolved = (0,
|
|
86
|
+
resolved = (0, _compatts.stringReplaceAll)(resolved, '\\', '%5c');
|
|
75
87
|
}
|
|
76
|
-
return new
|
|
88
|
+
return new URLClass("file:".concat(resolved));
|
|
77
89
|
}
|
|
78
90
|
/* 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/lib/urlFileUrl.ts"],"sourcesContent":["// Extracted from https://raw.githubusercontent.com/holepunchto/url-file-url/refs/heads/main/index.js\n// Apache 2 License https://github.com/holepunchto/url-file-url/blob/main/LICENSE\n\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/urlFileUrl.ts"],"sourcesContent":["// Extracted from https://raw.githubusercontent.com/holepunchto/url-file-url/refs/heads/main/index.js\n// Apache 2 License https://github.com/holepunchto/url-file-url/blob/main/LICENSE\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nimport { stringReplaceAll } from '../compat.ts';\n\n// ESM-compatible require\nvar _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// URL class - available natively in Node 7.0+, use core-js-pure for Node 0.8-6.x\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for URL class\nvar URLClass: typeof URL = (url as any).URL;\nif (!URLClass) {\n URLClass = _require('core-js-pure/actual/url/index.js');\n}\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nexport function fileURLToPath(urlInput: string | URL): string {\n var parsedUrl: URL;\n if (typeof urlInput === 'string') {\n parsedUrl = new URLClass(urlInput);\n } else {\n parsedUrl = urlInput;\n }\n\n if (parsedUrl.protocol !== 'file:') {\n throw new Error('The URL must use the file: protocol');\n }\n\n if (isWindows) {\n if (/%2f|%5c/i.test(parsedUrl.pathname)) {\n throw new Error('The file: URL path must not include encoded \\\\ or / characters');\n }\n } else {\n if (parsedUrl.hostname) {\n throw new Error(\"The file: URL host must be 'localhost' or empty\");\n }\n\n if (/%2f/i.test(parsedUrl.pathname)) {\n throw new Error('The file: URL path must not include encoded / characters');\n }\n }\n\n const pathname = path.normalize(decodeURIComponent(parsedUrl.pathname));\n\n if (isWindows) {\n if (parsedUrl.hostname) return `\\\\\\\\${parsedUrl.hostname}${pathname}`;\n\n const letter = pathname.charCodeAt(1) | 0x20;\n\n if (letter < 0x61 /* a */ || letter > 0x7a /* z */ || pathname.charCodeAt(2) !== 0x3a /* : */) {\n throw new Error('The file: URL path must be absolute');\n }\n\n return pathname.slice(1);\n }\n\n return pathname;\n}\n\nexport function pathToFileURL(pathname: string): URL {\n let resolved = path.resolve(pathname);\n\n if (pathname[pathname.length - 1] === '/') {\n resolved += '/';\n } else if (isWindows && pathname[pathname.length - 1] === '\\\\') {\n resolved += '\\\\';\n }\n\n resolved = stringReplaceAll(resolved, '%', '%25'); // Must be first\n resolved = stringReplaceAll(resolved, '#', '%23');\n resolved = stringReplaceAll(resolved, '?', '%3f');\n resolved = stringReplaceAll(resolved, '\\n', '%0a');\n resolved = stringReplaceAll(resolved, '\\r', '%0d');\n resolved = stringReplaceAll(resolved, '\\t', '%09');\n\n if (!isWindows) {\n resolved = stringReplaceAll(resolved, '\\\\', '%5c');\n }\n\n return new URLClass(`file:${resolved}`);\n}\n"],"names":["fileURLToPath","pathToFileURL","_require","require","Module","createRequire","URLClass","url","URL","isWindows","process","platform","test","env","OSTYPE","urlInput","parsedUrl","protocol","Error","pathname","hostname","path","normalize","decodeURIComponent","letter","charCodeAt","slice","resolved","resolve","length","stringReplaceAll"],"mappings":"AAAA,qGAAqG;AACrG,iFAAiF;;;;;;;;;;;;QAoBjEA;eAAAA;;QA2CAC;eAAAA;;;6DA7DG;2DACF;0DACD;wBAEiB;;;;;;AAEjC,yBAAyB;AACzB,IAAIC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAExF,iFAAiF;AACjF,8EAA8E;AAC9E,IAAIG,WAAuB,AAACC,YAAG,CAASC,GAAG;AAC3C,IAAI,CAACF,UAAU;IACbA,WAAWJ,SAAS;AACtB;AAEA,I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,EAACH,UAAU,KAAK,QAAQ,gBAAgB;IACnEA,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,KAAK;IAC3CA,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,KAAK;IAC3CA,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,MAAM;IAC5CA,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,MAAM;IAC5CA,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,MAAM;IAE5C,IAAI,CAAClB,WAAW;QACdkB,WAAWG,IAAAA,0BAAgB,EAACH,UAAU,MAAM;IAC9C;IAEA,OAAO,IAAIrB,SAAS,AAAC,QAAgB,OAATqB;AAC9B"}
|
package/dist/cjs/toPath.js
CHANGED
|
@@ -12,8 +12,8 @@ var _isabsolute = /*#__PURE__*/ _interop_require_default(require("is-absolute"))
|
|
|
12
12
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
13
13
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
14
14
|
var _resolve = /*#__PURE__*/ _interop_require_wildcard(require("resolve"));
|
|
15
|
-
var _startswith = /*#__PURE__*/ _interop_require_default(require("starts-with"));
|
|
16
15
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
16
|
+
var _compatts = require("./compat.js");
|
|
17
17
|
var _constantsts = require("./constants.js");
|
|
18
18
|
var _importmetaresolvets = /*#__PURE__*/ _interop_require_default(require("./lib/import-meta-resolve.js"));
|
|
19
19
|
var _urlFileUrlts = /*#__PURE__*/ _interop_require_wildcard(require("./lib/urlFileUrl.js"));
|
|
@@ -73,7 +73,7 @@ function getParentPath(context) {
|
|
|
73
73
|
return context.parentURL ? _path.default.dirname(toPath(context.parentURL)) : process.cwd();
|
|
74
74
|
}
|
|
75
75
|
function toPath(specifier, context) {
|
|
76
|
-
if ((0,
|
|
76
|
+
if ((0, _compatts.stringStartsWith)(specifier, 'file:')) return fileURLToPath(specifier);
|
|
77
77
|
if ((0, _isabsolute.default)(specifier)) return specifier;
|
|
78
78
|
if (specifier[0] === '.') {
|
|
79
79
|
var parentPath = context ? getParentPath(context) : process.cwd();
|
package/dist/cjs/toPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport * as resolve from 'resolve';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport * as resolve from 'resolve';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n if (!useCJS) {\n try {\n const entryURL = importMetaResolve(specifier, pathToFileURL(parentPath));\n if (entryURL) return fileURLToPath(entryURL);\n } catch (_) {\n /* it may fail due to commonjs edge cases */\n }\n }\n const entryPath = resolveSync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n if (entryPath) return entryPath;\n }\n\n return specifier;\n}\n"],"names":["toPath","resolve","resolveSync","default","sync","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","pathToFileURL","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","specifier","stringStartsWith","isAbsolute","join","moduleRegEx","test","entryURL","importMetaResolve","_","entryPath","basedir","extensions"],"mappings":";;;;+BAuBA;;;eAAwBA;;;iEAvBD;6DACJ;2DACF;+DACQ;0DACT;wBAEiB;2BACL;0EACE;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGTC;AAArB,IAAMC,cAAc,AAACD,CAAAA,CAAAA,mBAAAA,SAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,QAAM,EAAGG,IAAI;AAErD,IAAMC,SAAS,CAACC,eAAM,CAACC,aAAa;AACpC,IAAMC,gBAAgBC,YAAG,CAACD,aAAa,IAAIE,cAAaF,aAAa;AACrE,IAAMG,gBAAgBF,YAAG,CAACE,aAAa,IAAID,cAAaC,aAAa;AAErE,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAAChB,OAAOa,QAAQI,SAAS,KAAKC,QAAQC,GAAG;AAClF;AAEe,SAASnB,OAAOoB,SAAiB,EAAEP,OAAiB;IACjE,IAAIQ,IAAAA,0BAAgB,EAACD,WAAW,UAAU,OAAOZ,cAAcY;IAC/D,IAAIE,IAAAA,mBAAU,EAACF,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOJ,aAAI,CAACQ,IAAI,CAACT,YAAYM;IAC/B;IACA,IAAII,wBAAW,CAACC,IAAI,CAACL,YAAY;QAC/B,IAAMN,cAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,IAAI,CAACd,QAAQ;YACX,IAAI;gBACF,IAAMqB,WAAWC,IAAAA,4BAAiB,EAACP,WAAWT,cAAcG;gBAC5D,IAAIY,UAAU,OAAOlB,cAAckB;YACrC,EAAE,OAAOE,GAAG;YACV,0CAA0C,GAC5C;QACF;QACA,IAAMC,YAAY3B,YAAYkB,WAAW;YACvCU,SAAShB;YACTiB,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;QAC/C;QACA,IAAIF,WAAW,OAAOA;IACxB;IAEA,OAAOT;AACT"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Layer for Node.js 0.8+
|
|
3
|
+
* Local to this package - contains only needed functions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stringStartsWith(str: string, search: string, position?: number): boolean;
|
|
6
|
+
export declare function stringReplaceAll(str: string, search: string, replace: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Layer for Node.js 0.8+
|
|
3
|
+
* Local to this package - contains only needed functions.
|
|
4
|
+
*/ /**
|
|
5
|
+
* String.prototype.startsWith wrapper for Node.js 0.8+
|
|
6
|
+
* - Uses native startsWith on Node 4.0+ / ES2015+
|
|
7
|
+
* - Falls back to indexOf on Node 0.8-3.x
|
|
8
|
+
*/ var hasStartsWith = typeof String.prototype.startsWith === 'function';
|
|
9
|
+
export function stringStartsWith(str, search, position) {
|
|
10
|
+
if (hasStartsWith) {
|
|
11
|
+
return str.startsWith(search, position);
|
|
12
|
+
}
|
|
13
|
+
position = position || 0;
|
|
14
|
+
return str.indexOf(search, position) === position;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* String.prototype.replaceAll wrapper for Node.js 0.8+
|
|
18
|
+
* - Uses native replaceAll on Node 15.0+ / ES2021+
|
|
19
|
+
* - Falls back to regex replace on older versions
|
|
20
|
+
*/ // biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll
|
|
21
|
+
var hasReplaceAll = typeof String.prototype.replaceAll === 'function';
|
|
22
|
+
export function stringReplaceAll(str, search, replace) {
|
|
23
|
+
if (hasReplaceAll) {
|
|
24
|
+
// biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available
|
|
25
|
+
return str.replaceAll(search, replace);
|
|
26
|
+
}
|
|
27
|
+
// Escape special regex characters
|
|
28
|
+
var escaped = search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
29
|
+
return str.replace(new RegExp(escaped, 'g'), replace);
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nvar hasStartsWith = typeof String.prototype.startsWith === 'function';\n\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) {\n return str.startsWith(search, position);\n }\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * String.prototype.replaceAll wrapper for Node.js 0.8+\n * - Uses native replaceAll on Node 15.0+ / ES2021+\n * - Falls back to regex replace on older versions\n */\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll\nvar hasReplaceAll = typeof (String.prototype as any).replaceAll === 'function';\n\nexport function stringReplaceAll(str: string, search: string, replace: string): string {\n if (hasReplaceAll) {\n // biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available\n return (str as any).replaceAll(search, replace);\n }\n // Escape special regex characters\n var escaped = search.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return str.replace(new RegExp(escaped, 'g'), replace);\n}\n"],"names":["hasStartsWith","String","prototype","startsWith","stringStartsWith","str","search","position","indexOf","hasReplaceAll","replaceAll","stringReplaceAll","replace","escaped","RegExp"],"mappings":"AAAA;;;CAGC,GAED;;;;CAIC,GACD,IAAIA,gBAAgB,OAAOC,OAAOC,SAAS,CAACC,UAAU,KAAK;AAE3D,OAAO,SAASC,iBAAiBC,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC7E,IAAIP,eAAe;QACjB,OAAOK,IAAIF,UAAU,CAACG,QAAQC;IAChC;IACAA,WAAWA,YAAY;IACvB,OAAOF,IAAIG,OAAO,CAACF,QAAQC,cAAcA;AAC3C;AAEA;;;;CAIC,GACD,sFAAsF;AACtF,IAAIE,gBAAgB,OAAO,AAACR,OAAOC,SAAS,CAASQ,UAAU,KAAK;AAEpE,OAAO,SAASC,iBAAiBN,GAAW,EAAEC,MAAc,EAAEM,OAAe;IAC3E,IAAIH,eAAe;QACjB,qFAAqF;QACrF,OAAO,AAACJ,IAAYK,UAAU,CAACJ,QAAQM;IACzC;IACA,kCAAkC;IAClC,IAAIC,UAAUP,OAAOM,OAAO,CAAC,uBAAuB;IACpD,OAAOP,IAAIO,OAAO,CAAC,IAAIE,OAAOD,SAAS,MAAMD;AAC/C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { stringStartsWith } from '../compat.js';
|
|
2
2
|
export const extensions = {
|
|
3
3
|
'.ts': '.js',
|
|
4
4
|
'.tsx': '.js',
|
|
@@ -11,7 +11,7 @@ export function replaceExtension(ext) {
|
|
|
11
11
|
}
|
|
12
12
|
// Helper to check if a path is relative (starts with ./ or ../)
|
|
13
13
|
function isRelativePath(path) {
|
|
14
|
-
return
|
|
14
|
+
return stringStartsWith(path, './') || stringStartsWith(path, '../');
|
|
15
15
|
}
|
|
16
16
|
// Multi-pattern transformer for TypeScript extension rewriting
|
|
17
17
|
// See: https://github.com/microsoft/TypeScript/issues/61037
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/rewriteExtensions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/rewriteExtensions.ts"],"sourcesContent":["import { stringStartsWith } from '../compat.ts';\n\nexport const extensions = {\n '.ts': '.js',\n '.tsx': '.js',\n '.mts': '.mjs',\n '.cts': '.cjs',\n};\n\nexport function replaceExtension(ext: string): string {\n const replace = extensions[ext];\n return replace === undefined ? ext : replace;\n}\n\n// Helper to check if a path is relative (starts with ./ or ../)\nfunction isRelativePath(path: string): boolean {\n return stringStartsWith(path, './') || stringStartsWith(path, '../');\n}\n\n// Multi-pattern transformer for TypeScript extension rewriting\n// See: https://github.com/microsoft/TypeScript/issues/61037\n// TODO: Remove when TypeScript natively supports rewriteRelativeImportExtensions in .d.ts files\n\nexport function rewriteExtensions(content: string): string {\n let result = content;\n\n // Pattern 1: Import/Export statements (with optional 'type' keyword)\n // Matches: import { X } from './path.ts'\n // import type { X } from './path.ts'\n // export * from './path.ts'\n // export type * from './path.ts'\n result = result.replace(/\\b(import|export)(\\s+type)?(?:\\s+[^'\"]*?\\s+from\\s+|\\s+)['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]/g, (match, _keyword, _typeKeyword, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n // Pattern 2: Dynamic import types\n // Matches: typeof import('./path.ts')\n result = result.replace(/\\bimport\\s*\\(\\s*['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]\\s*\\)/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n // Pattern 3: Triple-slash path references\n // Matches: /// <reference path=\"./file.ts\" />\n // /// <reference path=\"./file.d.ts\" />\n result = result.replace(/\\/\\/\\/\\s*<reference\\s+path\\s*=\\s*['\"]([^'\"]+)\\.(d\\.ts|tsx?|mts|cts)['\"]\\s*\\/>/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n // Special case: .d.ts → .d.js\n const newExt = ext === 'd.ts' ? '.d.js' : replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n return result;\n}\n\n// CJS-specific version that also handles require() statements\nexport function rewriteExtensionsCJS(content: string): string {\n // Start with all ESM patterns\n let result = rewriteExtensions(content);\n\n // Pattern 4: CommonJS require() statements\n // Matches: require('./path.ts')\n result = result.replace(/\\brequire\\s*\\(\\s*['\"]([^'\"]+)\\.(tsx?|mts|cts)['\"]\\s*\\)/g, (match, path, ext) => {\n if (!isRelativePath(path)) return match;\n const newExt = replaceExtension(`.${ext}`);\n return match.replace(`.${ext}\"`, `${newExt}\"`).replace(`.${ext}'`, `${newExt}'`).replace(`.${ext}\\``, `${newExt}\\``);\n });\n\n return result;\n}\n"],"names":["stringStartsWith","extensions","replaceExtension","ext","replace","undefined","isRelativePath","path","rewriteExtensions","content","result","match","_keyword","_typeKeyword","newExt","rewriteExtensionsCJS"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,eAAe;AAEhD,OAAO,MAAMC,aAAa;IACxB,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;AACV,EAAE;AAEF,OAAO,SAASC,iBAAiBC,GAAW;IAC1C,MAAMC,UAAUH,UAAU,CAACE,IAAI;IAC/B,OAAOC,YAAYC,YAAYF,MAAMC;AACvC;AAEA,gEAAgE;AAChE,SAASE,eAAeC,IAAY;IAClC,OAAOP,iBAAiBO,MAAM,SAASP,iBAAiBO,MAAM;AAChE;AAEA,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I;QAClC,8BAA8B;QAC9B,MAAMG,SAASX,QAAQ,SAAS,UAAUD,iBAAiB,CAAC,CAAC,EAAEC,KAAK;QACpE,OAAOQ,MAAMP,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,CAAC,CAAC,EAAE,GAAGW,OAAO,CAAC,CAAC,EAAEV,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,CAAC,CAAC,EAAE,GAAGW,OAAO,CAAC,CAAC,EAAEV,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,EAAE,CAAC,EAAE,GAAGW,OAAO,EAAE,CAAC;IACrH;IAEA,OAAOJ;AACT;AAEA,8DAA8D;AAC9D,OAAO,SAASK,qBAAqBN,OAAe;IAClD,8BAA8B;IAC9B,IAAIC,SAASF,kBAAkBC;IAE/B,2CAA2C;IAC3C,gCAAgC;IAChCC,SAASA,OAAON,OAAO,CAAC,2DAA2D,CAACO,OAAOJ,MAAMJ;QAC/F,IAAI,CAACG,eAAeC,OAAO,OAAOI;QAClC,MAAMG,SAASZ,iBAAiB,CAAC,CAAC,EAAEC,KAAK;QACzC,OAAOQ,MAAMP,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,CAAC,CAAC,EAAE,GAAGW,OAAO,CAAC,CAAC,EAAEV,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,CAAC,CAAC,EAAE,GAAGW,OAAO,CAAC,CAAC,EAAEV,OAAO,CAAC,CAAC,CAAC,EAAED,IAAI,EAAE,CAAC,EAAE,GAAGW,OAAO,EAAE,CAAC;IACrH;IAEA,OAAOJ;AACT"}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
// Extracted from https://raw.githubusercontent.com/holepunchto/url-file-url/refs/heads/main/index.js
|
|
2
2
|
// Apache 2 License https://github.com/holepunchto/url-file-url/blob/main/LICENSE
|
|
3
|
-
import
|
|
4
|
-
import URL from 'core-js-pure/actual/url/index.js';
|
|
3
|
+
import Module from 'module';
|
|
5
4
|
import path from 'path';
|
|
5
|
+
import url from 'url';
|
|
6
|
+
import { stringReplaceAll } from '../compat.js';
|
|
7
|
+
// ESM-compatible require
|
|
8
|
+
var _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
9
|
+
// URL class - available natively in Node 7.0+, use core-js-pure for Node 0.8-6.x
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: Feature detection for URL class
|
|
11
|
+
var URLClass = url.URL;
|
|
12
|
+
if (!URLClass) {
|
|
13
|
+
URLClass = _require('core-js-pure/actual/url/index.js');
|
|
14
|
+
}
|
|
6
15
|
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
7
|
-
export function fileURLToPath(
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
export function fileURLToPath(urlInput) {
|
|
17
|
+
var parsedUrl;
|
|
18
|
+
if (typeof urlInput === 'string') {
|
|
19
|
+
parsedUrl = new URLClass(urlInput);
|
|
20
|
+
} else {
|
|
21
|
+
parsedUrl = urlInput;
|
|
10
22
|
}
|
|
11
|
-
if (
|
|
23
|
+
if (parsedUrl.protocol !== 'file:') {
|
|
12
24
|
throw new Error('The URL must use the file: protocol');
|
|
13
25
|
}
|
|
14
26
|
if (isWindows) {
|
|
15
|
-
if (/%2f|%5c/i.test(
|
|
27
|
+
if (/%2f|%5c/i.test(parsedUrl.pathname)) {
|
|
16
28
|
throw new Error('The file: URL path must not include encoded \\ or / characters');
|
|
17
29
|
}
|
|
18
30
|
} else {
|
|
19
|
-
if (
|
|
31
|
+
if (parsedUrl.hostname) {
|
|
20
32
|
throw new Error("The file: URL host must be 'localhost' or empty");
|
|
21
33
|
}
|
|
22
|
-
if (/%2f/i.test(
|
|
34
|
+
if (/%2f/i.test(parsedUrl.pathname)) {
|
|
23
35
|
throw new Error('The file: URL path must not include encoded / characters');
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
const pathname = path.normalize(decodeURIComponent(
|
|
38
|
+
const pathname = path.normalize(decodeURIComponent(parsedUrl.pathname));
|
|
27
39
|
if (isWindows) {
|
|
28
|
-
if (
|
|
40
|
+
if (parsedUrl.hostname) return `\\\\${parsedUrl.hostname}${pathname}`;
|
|
29
41
|
const letter = pathname.charCodeAt(1) | 0x20;
|
|
30
42
|
if (letter < 0x61 /* a */ || letter > 0x7a /* z */ || pathname.charCodeAt(2) !== 0x3a /* : */ ) {
|
|
31
43
|
throw new Error('The file: URL path must be absolute');
|
|
@@ -41,14 +53,14 @@ export function pathToFileURL(pathname) {
|
|
|
41
53
|
} else if (isWindows && pathname[pathname.length - 1] === '\\') {
|
|
42
54
|
resolved += '\\';
|
|
43
55
|
}
|
|
44
|
-
resolved =
|
|
45
|
-
resolved =
|
|
46
|
-
resolved =
|
|
47
|
-
resolved =
|
|
48
|
-
resolved =
|
|
49
|
-
resolved =
|
|
56
|
+
resolved = stringReplaceAll(resolved, '%', '%25'); // Must be first
|
|
57
|
+
resolved = stringReplaceAll(resolved, '#', '%23');
|
|
58
|
+
resolved = stringReplaceAll(resolved, '?', '%3f');
|
|
59
|
+
resolved = stringReplaceAll(resolved, '\n', '%0a');
|
|
60
|
+
resolved = stringReplaceAll(resolved, '\r', '%0d');
|
|
61
|
+
resolved = stringReplaceAll(resolved, '\t', '%09');
|
|
50
62
|
if (!isWindows) {
|
|
51
|
-
resolved =
|
|
63
|
+
resolved = stringReplaceAll(resolved, '\\', '%5c');
|
|
52
64
|
}
|
|
53
|
-
return new
|
|
65
|
+
return new URLClass(`file:${resolved}`);
|
|
54
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/urlFileUrl.ts"],"sourcesContent":["// Extracted from https://raw.githubusercontent.com/holepunchto/url-file-url/refs/heads/main/index.js\n// Apache 2 License https://github.com/holepunchto/url-file-url/blob/main/LICENSE\n\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/urlFileUrl.ts"],"sourcesContent":["// Extracted from https://raw.githubusercontent.com/holepunchto/url-file-url/refs/heads/main/index.js\n// Apache 2 License https://github.com/holepunchto/url-file-url/blob/main/LICENSE\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nimport { stringReplaceAll } from '../compat.ts';\n\n// ESM-compatible require\nvar _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// URL class - available natively in Node 7.0+, use core-js-pure for Node 0.8-6.x\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for URL class\nvar URLClass: typeof URL = (url as any).URL;\nif (!URLClass) {\n URLClass = _require('core-js-pure/actual/url/index.js');\n}\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nexport function fileURLToPath(urlInput: string | URL): string {\n var parsedUrl: URL;\n if (typeof urlInput === 'string') {\n parsedUrl = new URLClass(urlInput);\n } else {\n parsedUrl = urlInput;\n }\n\n if (parsedUrl.protocol !== 'file:') {\n throw new Error('The URL must use the file: protocol');\n }\n\n if (isWindows) {\n if (/%2f|%5c/i.test(parsedUrl.pathname)) {\n throw new Error('The file: URL path must not include encoded \\\\ or / characters');\n }\n } else {\n if (parsedUrl.hostname) {\n throw new Error(\"The file: URL host must be 'localhost' or empty\");\n }\n\n if (/%2f/i.test(parsedUrl.pathname)) {\n throw new Error('The file: URL path must not include encoded / characters');\n }\n }\n\n const pathname = path.normalize(decodeURIComponent(parsedUrl.pathname));\n\n if (isWindows) {\n if (parsedUrl.hostname) return `\\\\\\\\${parsedUrl.hostname}${pathname}`;\n\n const letter = pathname.charCodeAt(1) | 0x20;\n\n if (letter < 0x61 /* a */ || letter > 0x7a /* z */ || pathname.charCodeAt(2) !== 0x3a /* : */) {\n throw new Error('The file: URL path must be absolute');\n }\n\n return pathname.slice(1);\n }\n\n return pathname;\n}\n\nexport function pathToFileURL(pathname: string): URL {\n let resolved = path.resolve(pathname);\n\n if (pathname[pathname.length - 1] === '/') {\n resolved += '/';\n } else if (isWindows && pathname[pathname.length - 1] === '\\\\') {\n resolved += '\\\\';\n }\n\n resolved = stringReplaceAll(resolved, '%', '%25'); // Must be first\n resolved = stringReplaceAll(resolved, '#', '%23');\n resolved = stringReplaceAll(resolved, '?', '%3f');\n resolved = stringReplaceAll(resolved, '\\n', '%0a');\n resolved = stringReplaceAll(resolved, '\\r', '%0d');\n resolved = stringReplaceAll(resolved, '\\t', '%09');\n\n if (!isWindows) {\n resolved = stringReplaceAll(resolved, '\\\\', '%5c');\n }\n\n return new URLClass(`file:${resolved}`);\n}\n"],"names":["Module","path","url","stringReplaceAll","_require","require","createRequire","URLClass","URL","isWindows","process","platform","test","env","OSTYPE","fileURLToPath","urlInput","parsedUrl","protocol","Error","pathname","hostname","normalize","decodeURIComponent","letter","charCodeAt","slice","pathToFileURL","resolved","resolve","length"],"mappings":"AAAA,qGAAqG;AACrG,iFAAiF;AAEjF,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,yBAAyB;AACzB,IAAIC,WAAW,OAAOC,YAAY,cAAcL,OAAOM,aAAa,CAAC,YAAYJ,GAAG,IAAIG;AAExF,iFAAiF;AACjF,8EAA8E;AAC9E,IAAIE,WAAuB,AAACL,IAAYM,GAAG;AAC3C,IAAI,CAACD,UAAU;IACbA,WAAWH,SAAS;AACtB;AAEA,MAAMK,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAE3F,OAAO,SAASC,cAAcC,QAAsB;IAClD,IAAIC;IACJ,IAAI,OAAOD,aAAa,UAAU;QAChCC,YAAY,IAAIV,SAASS;IAC3B,OAAO;QACLC,YAAYD;IACd;IAEA,IAAIC,UAAUC,QAAQ,KAAK,SAAS;QAClC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIV,WAAW;QACb,IAAI,WAAWG,IA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,EAAEqB,UAAU;AACxC"}
|
package/dist/esm/toPath.js
CHANGED
|
@@ -2,8 +2,8 @@ import isAbsolute from 'is-absolute';
|
|
|
2
2
|
import module from 'module';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import * as resolve from 'resolve';
|
|
5
|
-
import startsWith from 'starts-with';
|
|
6
5
|
import url from 'url';
|
|
6
|
+
import { stringStartsWith } from './compat.js';
|
|
7
7
|
import { moduleRegEx } from './constants.js';
|
|
8
8
|
import importMetaResolve from './lib/import-meta-resolve.js';
|
|
9
9
|
import * as urlPolyfills from './lib/urlFileUrl.js';
|
|
@@ -17,7 +17,7 @@ function getParentPath(context) {
|
|
|
17
17
|
return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();
|
|
18
18
|
}
|
|
19
19
|
export default function toPath(specifier, context) {
|
|
20
|
-
if (
|
|
20
|
+
if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);
|
|
21
21
|
if (isAbsolute(specifier)) return specifier;
|
|
22
22
|
if (specifier[0] === '.') {
|
|
23
23
|
const parentPath = context ? getParentPath(context) : process.cwd();
|
package/dist/esm/toPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport * as resolve from 'resolve';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport * as resolve from 'resolve';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n if (!useCJS) {\n try {\n const entryURL = importMetaResolve(specifier, pathToFileURL(parentPath));\n if (entryURL) return fileURLToPath(entryURL);\n } catch (_) {\n /* it may fail due to commonjs edge cases */\n }\n }\n const entryPath = resolveSync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n if (entryPath) return entryPath;\n }\n\n return specifier;\n}\n"],"names":["isAbsolute","module","path","resolve","url","stringStartsWith","moduleRegEx","importMetaResolve","urlPolyfills","resolveSync","default","sync","useCJS","createRequire","fileURLToPath","pathToFileURL","getParentPath","context","parentPath","dirname","parentURL","toPath","process","cwd","specifier","join","test","entryURL","_","entryPath","basedir","extensions"],"mappings":"AAAA,OAAOA,gBAAgB,cAAc;AACrC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,YAAYC,aAAa,UAAU;AACnC,OAAOC,SAAS,MAAM;AAEtB,SAASC,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,uBAAuB,+BAA+B;AAC7D,YAAYC,kBAAkB,sBAAsB;IAG/BL;AAArB,MAAMM,cAAc,AAACN,CAAAA,CAAAA,mBAAAA,QAAQO,OAAO,cAAfP,8BAAAA,mBAAmBA,OAAM,EAAGQ,IAAI;AAErD,MAAMC,SAAS,CAACX,OAAOY,aAAa;AACpC,MAAMC,gBAAgBV,IAAIU,aAAa,IAAIN,aAAaM,aAAa;AACrE,MAAMC,gBAAgBX,IAAIW,aAAa,IAAIP,aAAaO,aAAa;AAErE,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOhB,KAAKiB,OAAO,CAACF,QAAQC,UAAU;IAC9D,OAAOD,QAAQG,SAAS,GAAGlB,KAAKiB,OAAO,CAACE,OAAOJ,QAAQG,SAAS,KAAKE,QAAQC,GAAG;AAClF;AAEA,eAAe,SAASF,OAAOG,SAAiB,EAAEP,OAAiB;IACjE,IAAIZ,iBAAiBmB,WAAW,UAAU,OAAOV,cAAcU;IAC/D,IAAIxB,WAAWwB,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOrB,KAAKuB,IAAI,CAACP,YAAYM;IAC/B;IACA,IAAIlB,YAAYoB,IAAI,CAACF,YAAY;QAC/B,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,IAAI,CAACX,QAAQ;YACX,IAAI;gBACF,MAAMe,WAAWpB,kBAAkBiB,WAAWT,cAAcG;gBAC5D,IAAIS,UAAU,OAAOb,cAAca;YACrC,EAAE,OAAOC,GAAG;YACV,0CAA0C,GAC5C;QACF;QACA,MAAMC,YAAYpB,YAAYe,WAAW;YACvCM,SAASZ;YACTa,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;QAC/C;QACA,IAAIF,WAAW,OAAOA;IACxB;IAEA,OAAOL;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build": "tsds build",
|
|
39
39
|
"format": "biome check --write --unsafe",
|
|
40
40
|
"prepublishOnly": "tsds validate",
|
|
41
|
-
"test": "
|
|
41
|
+
"test": "tsds test:node --no-timeouts",
|
|
42
42
|
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
43
43
|
"version": "tsds version"
|
|
44
44
|
},
|
|
@@ -57,19 +57,21 @@
|
|
|
57
57
|
"read-tsconfig-sync": "*",
|
|
58
58
|
"resolve": "*",
|
|
59
59
|
"rimraf2": "*",
|
|
60
|
-
"starts-with": "^1.0.2",
|
|
61
60
|
"test-match": "*",
|
|
62
61
|
"ts-node": "*",
|
|
63
62
|
"typescript": "*"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
65
|
+
"@biomejs/biome": "*",
|
|
66
66
|
"@types/mocha": "*",
|
|
67
67
|
"@types/node": "*",
|
|
68
68
|
"core-js": "*",
|
|
69
69
|
"cr": "*",
|
|
70
70
|
"cross-spawn-cb": "*",
|
|
71
|
+
"node-version-use": "*",
|
|
71
72
|
"pinkie-promise": "*",
|
|
72
|
-
"react": "*"
|
|
73
|
+
"react": "*",
|
|
74
|
+
"ts-dev-stack": "*"
|
|
73
75
|
},
|
|
74
76
|
"engines": {
|
|
75
77
|
"node": ">=0.8"
|