@nubjs/nub-win32-arm64 0.0.4 → 0.0.7
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/bin/nub.exe +0 -0
- package/package.json +1 -1
- package/runtime/addons/nub-native.node +0 -0
- package/runtime/cache-evict.mjs +69 -0
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/README.md +3 -0
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/package.json +39 -0
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/parser.win32-arm64-msvc.node +0 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/README.md +3 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/package.json +41 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/transform.win32-arm64-msvc.node +0 -0
- package/runtime/polyfills.mjs +73 -97
- package/runtime/preload-async-hooks.mjs +50 -0
- package/runtime/preload.mjs +274 -320
- package/runtime/transform-core.mjs +762 -0
- package/runtime/version.mjs +12 -0
- package/runtime/worker-polyfill.mjs +147 -9
- package/runtime/node_modules/get-tsconfig/LICENSE +0 -21
- package/runtime/node_modules/get-tsconfig/README.md +0 -268
- package/runtime/node_modules/get-tsconfig/dist/index.cjs +0 -7
- package/runtime/node_modules/get-tsconfig/dist/index.d.cts +0 -2116
- package/runtime/node_modules/get-tsconfig/dist/index.d.mts +0 -2116
- package/runtime/node_modules/get-tsconfig/dist/index.mjs +0 -7
- package/runtime/node_modules/get-tsconfig/package.json +0 -46
- package/runtime/node_modules/oxc-transform/LICENSE +0 -22
- package/runtime/node_modules/oxc-transform/README.md +0 -84
- package/runtime/node_modules/oxc-transform/browser.js +0 -1
- package/runtime/node_modules/oxc-transform/index.d.ts +0 -658
- package/runtime/node_modules/oxc-transform/index.js +0 -598
- package/runtime/node_modules/oxc-transform/package.json +0 -114
- package/runtime/node_modules/oxc-transform/webcontainer-fallback.cjs +0 -21
- package/runtime/node_modules/resolve-pkg-maps/LICENSE +0 -21
- package/runtime/node_modules/resolve-pkg-maps/README.md +0 -216
- package/runtime/node_modules/resolve-pkg-maps/dist/index.cjs +0 -1
- package/runtime/node_modules/resolve-pkg-maps/dist/index.d.cts +0 -11
- package/runtime/node_modules/resolve-pkg-maps/dist/index.d.mts +0 -11
- package/runtime/node_modules/resolve-pkg-maps/dist/index.mjs +0 -1
- package/runtime/node_modules/resolve-pkg-maps/package.json +0 -42
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Single source of truth for the nub version that salts the transpile-cache key.
|
|
2
|
+
//
|
|
3
|
+
// `make version` rewrites the NUB_VERSION line below in lockstep with every npm
|
|
4
|
+
// package + Cargo.toml, and `make version-check` fails the release build if it
|
|
5
|
+
// drifts. Keeping it in its own side-effect-free module lets every transpile
|
|
6
|
+
// surface — runtime/transform-core.mjs (the shared core), runtime/preload.mjs
|
|
7
|
+
// (fast path), and the compat-tier loader worker — import the SAME value, so the
|
|
8
|
+
// fast and compat tiers produce byte-identical cache entries under one key. (It
|
|
9
|
+
// previously lived as a literal inside preload.mjs, which `make version` patched,
|
|
10
|
+
// while the worker carried a hand-maintained "…-compat" copy that `make version`
|
|
11
|
+
// never touched — a latent staleness bug this module closes.)
|
|
12
|
+
export const NUB_VERSION = "0.0.7";
|
|
@@ -5,6 +5,26 @@
|
|
|
5
5
|
import { Worker as NodeWorker, parentPort, isMainThread } from "node:worker_threads";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
|
+
// `ErrorEvent` only became a global in Node 26. On the 22/24 floor it is
|
|
9
|
+
// undefined, so `new ErrorEvent(...)` below would throw a ReferenceError inside
|
|
10
|
+
// the worker's "error" handler — crashing the PARENT thread on every worker
|
|
11
|
+
// that throws. Resolve the constructor once at load: use the native global when
|
|
12
|
+
// present, otherwise a minimal Event subclass carrying the standard ErrorEvent
|
|
13
|
+
// fields (message/error/filename/lineno/colno). See wiki/research/worker-polyfill.md.
|
|
14
|
+
const ErrorEventCtor =
|
|
15
|
+
typeof globalThis.ErrorEvent === "function"
|
|
16
|
+
? globalThis.ErrorEvent
|
|
17
|
+
: class ErrorEvent extends Event {
|
|
18
|
+
constructor(type, init = {}) {
|
|
19
|
+
super(type, init);
|
|
20
|
+
this.message = init.message ?? "";
|
|
21
|
+
this.error = init.error ?? null;
|
|
22
|
+
this.filename = init.filename ?? "";
|
|
23
|
+
this.lineno = init.lineno ?? 0;
|
|
24
|
+
this.colno = init.colno ?? 0;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
8
28
|
if (typeof globalThis.Worker === "undefined") {
|
|
9
29
|
class Worker extends EventTarget {
|
|
10
30
|
#worker;
|
|
@@ -25,7 +45,12 @@ if (typeof globalThis.Worker === "undefined") {
|
|
|
25
45
|
throw new TypeError("Worker constructor: url must be a string or URL");
|
|
26
46
|
}
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
// `type: "module" | "classic"` is accepted for web compatibility but not
|
|
49
|
+
// enforced: Node decides module-vs-CJS for the worker entry by file
|
|
50
|
+
// extension + nearest package.json "type" (the same rule nub applies to
|
|
51
|
+
// the main entry), and there is no classic/importScripts mode. Passing
|
|
52
|
+
// `type` through to NodeWorker is harmless — it ignores unknown options.
|
|
53
|
+
// See wiki/research/worker-polyfill.md.
|
|
29
54
|
this.#worker = new NodeWorker(workerPath, {
|
|
30
55
|
...options,
|
|
31
56
|
eval: false,
|
|
@@ -41,7 +66,7 @@ if (typeof globalThis.Worker === "undefined") {
|
|
|
41
66
|
});
|
|
42
67
|
|
|
43
68
|
this.#worker.on("error", (err) => {
|
|
44
|
-
this.dispatchEvent(new
|
|
69
|
+
this.dispatchEvent(new ErrorEventCtor("error", { error: err, message: err.message }));
|
|
45
70
|
});
|
|
46
71
|
|
|
47
72
|
this.#worker.on("exit", (code) => {
|
|
@@ -72,20 +97,133 @@ if (typeof globalThis.Worker === "undefined") {
|
|
|
72
97
|
this.#onerrorHandler = fn;
|
|
73
98
|
if (fn) this.addEventListener("error", fn);
|
|
74
99
|
}
|
|
100
|
+
|
|
101
|
+
#onmessageerrorHandler = null;
|
|
102
|
+
get onmessageerror() { return this.#onmessageerrorHandler; }
|
|
103
|
+
set onmessageerror(fn) {
|
|
104
|
+
if (this.#onmessageerrorHandler) this.removeEventListener("messageerror", this.#onmessageerrorHandler);
|
|
105
|
+
this.#onmessageerrorHandler = fn;
|
|
106
|
+
if (fn) this.addEventListener("messageerror", fn);
|
|
107
|
+
}
|
|
75
108
|
}
|
|
76
109
|
|
|
77
110
|
globalThis.Worker = Worker;
|
|
78
111
|
}
|
|
79
112
|
|
|
80
|
-
// Worker-side bootstrap:
|
|
113
|
+
// Worker-side bootstrap: emulate the DedicatedWorkerGlobalScope on top of
|
|
114
|
+
// node:worker_threads — `self`, `postMessage`, `close`, AND inbound message
|
|
115
|
+
// events. Node's worker global is not an EventTarget and exposes none of these
|
|
116
|
+
// (verified), so the polyfill provides the whole surface. Without the inbound
|
|
117
|
+
// wiring, `self.onmessage` / `self.addEventListener("message", …)` never fire
|
|
118
|
+
// and a parent→worker round-trip hangs — see wiki/research/worker-polyfill.md.
|
|
81
119
|
if (!isMainThread && parentPort) {
|
|
82
|
-
|
|
83
|
-
|
|
120
|
+
const scope = globalThis;
|
|
121
|
+
scope.self = scope;
|
|
122
|
+
|
|
123
|
+
// `message`/`messageerror` are DELEGATED straight onto the native `parentPort`
|
|
124
|
+
// (a real Node MessagePort) so Node's own C++ event-loop ref-counting governs
|
|
125
|
+
// worker lifetime: a worker that never listens leaves parentPort with no
|
|
126
|
+
// listeners → Node unrefs it → the worker exits naturally (matching
|
|
127
|
+
// `node:worker_threads` and Bun); a worker listening via `self.onmessage` /
|
|
128
|
+
// `addEventListener("message", …)` refs it → stays alive. Node reflects
|
|
129
|
+
// `{once}`/`{signal}`/last-listener removal in the loop ref-count in C++,
|
|
130
|
+
// which no userland counter can observe. (Earlier this block eagerly held a
|
|
131
|
+
// `parentPort.on("message")` forwarder, which kept EVERY worker's event loop
|
|
132
|
+
// alive → pure `parentPort` workers that should exit hung forever. See
|
|
133
|
+
// wiki/research/worker-polyfill.md §4.) All OTHER event types go to a private
|
|
134
|
+
// EventTarget (additive; no globalThis prototype re-parenting — `event.target`
|
|
135
|
+
// is that private target, the documented minor divergence).
|
|
136
|
+
const other = new EventTarget();
|
|
137
|
+
const otherAdd =
|
|
138
|
+
typeof scope.addEventListener === "function"
|
|
139
|
+
? scope.addEventListener.bind(scope)
|
|
140
|
+
: other.addEventListener.bind(other);
|
|
141
|
+
const otherRemove =
|
|
142
|
+
typeof scope.removeEventListener === "function"
|
|
143
|
+
? scope.removeEventListener.bind(scope)
|
|
144
|
+
: other.removeEventListener.bind(other);
|
|
145
|
+
const otherDispatch =
|
|
146
|
+
typeof scope.dispatchEvent === "function"
|
|
147
|
+
? scope.dispatchEvent.bind(scope)
|
|
148
|
+
: other.dispatchEvent.bind(other);
|
|
149
|
+
|
|
150
|
+
const DELEGATED = new Set(["message", "messageerror"]);
|
|
151
|
+
// user listener → its parentPort wrapper (per delegated event), so
|
|
152
|
+
// removeEventListener detaches the exact wrapper Node registered.
|
|
153
|
+
const wrappers = { message: new Map(), messageerror: new Map() };
|
|
154
|
+
|
|
155
|
+
function addDelegated(evt, listener, opts) {
|
|
156
|
+
const cb =
|
|
157
|
+
typeof listener === "function"
|
|
158
|
+
? listener
|
|
159
|
+
: listener && typeof listener.handleEvent === "function"
|
|
160
|
+
? (e) => listener.handleEvent(e)
|
|
161
|
+
: null;
|
|
162
|
+
if (!cb) return;
|
|
163
|
+
const map = wrappers[evt];
|
|
164
|
+
if (map.has(listener)) return; // EventTarget dedups identical (type, listener)
|
|
165
|
+
const o = opts && typeof opts === "object" ? opts : {};
|
|
166
|
+
if (o.signal && o.signal.aborted) return;
|
|
167
|
+
const fire = (data) => cb.call(scope, new MessageEvent(evt, { data }));
|
|
168
|
+
let wrapper;
|
|
169
|
+
if (o.once) {
|
|
170
|
+
wrapper = (data) => {
|
|
171
|
+
map.delete(listener);
|
|
172
|
+
fire(data);
|
|
173
|
+
};
|
|
174
|
+
parentPort.once(evt, wrapper);
|
|
175
|
+
} else {
|
|
176
|
+
wrapper = fire;
|
|
177
|
+
parentPort.on(evt, wrapper);
|
|
178
|
+
}
|
|
179
|
+
map.set(listener, wrapper);
|
|
180
|
+
if (o.signal) {
|
|
181
|
+
o.signal.addEventListener("abort", () => removeDelegated(evt, listener), {
|
|
182
|
+
once: true,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function removeDelegated(evt, listener) {
|
|
187
|
+
const wrapper = wrappers[evt].get(listener);
|
|
188
|
+
if (wrapper) {
|
|
189
|
+
parentPort.off(evt, wrapper);
|
|
190
|
+
wrappers[evt].delete(listener);
|
|
191
|
+
}
|
|
84
192
|
}
|
|
85
|
-
|
|
86
|
-
|
|
193
|
+
|
|
194
|
+
scope.addEventListener = (type, listener, opts) =>
|
|
195
|
+
DELEGATED.has(type)
|
|
196
|
+
? addDelegated(type, listener, opts)
|
|
197
|
+
: otherAdd(type, listener, opts);
|
|
198
|
+
scope.removeEventListener = (type, listener, opts) =>
|
|
199
|
+
DELEGATED.has(type)
|
|
200
|
+
? removeDelegated(type, listener)
|
|
201
|
+
: otherRemove(type, listener, opts);
|
|
202
|
+
scope.dispatchEvent = (ev) => otherDispatch(ev);
|
|
203
|
+
|
|
204
|
+
// `onmessage` / `onmessageerror` register via the delegating add/remove above,
|
|
205
|
+
// mirroring the web API and the main-side Worker. Assigning `null` removes the
|
|
206
|
+
// last listener → parentPort unrefs → the worker can exit (Bun parity).
|
|
207
|
+
for (const evt of ["message", "messageerror"]) {
|
|
208
|
+
let handler = null;
|
|
209
|
+
Object.defineProperty(scope, "on" + evt, {
|
|
210
|
+
configurable: true,
|
|
211
|
+
get() {
|
|
212
|
+
return handler;
|
|
213
|
+
},
|
|
214
|
+
set(fn) {
|
|
215
|
+
if (handler) scope.removeEventListener(evt, handler);
|
|
216
|
+
handler = typeof fn === "function" ? fn : null;
|
|
217
|
+
if (handler) scope.addEventListener(evt, handler);
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Outbound + lifecycle.
|
|
223
|
+
if (typeof scope.postMessage !== "function") {
|
|
224
|
+
scope.postMessage = (data, transfer) => parentPort.postMessage(data, transfer);
|
|
87
225
|
}
|
|
88
|
-
if (typeof
|
|
89
|
-
|
|
226
|
+
if (typeof scope.close !== "function") {
|
|
227
|
+
scope.close = () => process.exit(0);
|
|
90
228
|
}
|
|
91
229
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img width="160" src=".github/logo.webp">
|
|
3
|
-
</p>
|
|
4
|
-
<h1 align="center">
|
|
5
|
-
<sup>get-tsconfig</sup>
|
|
6
|
-
<br>
|
|
7
|
-
<a href="https://npm.im/get-tsconfig"><img src="https://badgen.net/npm/v/get-tsconfig"></a> <a href="https://npm.im/get-tsconfig"><img src="https://badgen.net/npm/dm/get-tsconfig"></a>
|
|
8
|
-
</h1>
|
|
9
|
-
|
|
10
|
-
Find and parse `tsconfig.json` files.
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
- Zero dependency (not even TypeScript)
|
|
14
|
-
- Tested against TypeScript for correctness
|
|
15
|
-
- Supports comments & dangling commas in `tsconfig.json`
|
|
16
|
-
- Resolves [`extends`](https://www.typescriptlang.org/tsconfig/#extends)
|
|
17
|
-
- Fully typed `tsconfig.json`
|
|
18
|
-
- Validates and throws parsing errors
|
|
19
|
-
- Tiny! `7 kB` Minified + Gzipped
|
|
20
|
-
|
|
21
|
-
<br>
|
|
22
|
-
|
|
23
|
-
<p align="center">
|
|
24
|
-
<a href="https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771"><img width="412" src="https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/donate.webp"></a>
|
|
25
|
-
<a href="https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608"><img width="412" src="https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/sponsor.webp"></a>
|
|
26
|
-
</p>
|
|
27
|
-
<p align="center"><sup><i>Already a sponsor?</i> Join the discussion in the <a href="https://github.com/pvtnbr/get-tsconfig">Development repo</a>!</sup></p>
|
|
28
|
-
|
|
29
|
-
## Install
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install get-tsconfig
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Why?
|
|
36
|
-
For TypeScript related tooling to correctly parse `tsconfig.json` file without depending on TypeScript.
|
|
37
|
-
|
|
38
|
-
## API
|
|
39
|
-
|
|
40
|
-
### getTsconfig(searchPath?, configName?, cache?, includes?)
|
|
41
|
-
|
|
42
|
-
Searches for a tsconfig file (defaults to `tsconfig.json`) in the `searchPath` and parses it. (If you already know the tsconfig path, use [`parseTsconfig`](#parsetsconfigtsconfigpath-cache) instead). Returns `null` if a config file cannot be found, or an object containing the path and parsed TSConfig object if found.
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
type TsconfigResult = {
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The path to the tsconfig.json file
|
|
51
|
-
*/
|
|
52
|
-
path: string
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The resolved tsconfig.json file
|
|
56
|
-
*/
|
|
57
|
-
config: TsConfigJsonResolved
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
#### searchPath
|
|
62
|
-
Type: `string`
|
|
63
|
-
|
|
64
|
-
Default: `process.cwd()`
|
|
65
|
-
|
|
66
|
-
Path to a source file or directory. The directory tree is searched up for a `tsconfig.json` file. Typically a TypeScript/JavaScript file path (e.g. `./src/index.ts`), but a directory path also works if you don't have a specific file.
|
|
67
|
-
|
|
68
|
-
#### configName
|
|
69
|
-
Type: `string`
|
|
70
|
-
|
|
71
|
-
Default: `tsconfig.json`
|
|
72
|
-
|
|
73
|
-
The file name of the TypeScript config file.
|
|
74
|
-
|
|
75
|
-
#### cache
|
|
76
|
-
Type: `Map<string, any>`
|
|
77
|
-
|
|
78
|
-
Default: `new Map()`
|
|
79
|
-
|
|
80
|
-
Optional cache for fs operations.
|
|
81
|
-
|
|
82
|
-
#### includes
|
|
83
|
-
Type: `boolean`
|
|
84
|
-
|
|
85
|
-
Default: `false`
|
|
86
|
-
|
|
87
|
-
When `true` and `searchPath` is a file path, validates that the found tsconfig applies to the file (via `files`, `include`, and `exclude`). If the file isn't matched, continues searching parent directories.
|
|
88
|
-
|
|
89
|
-
By default, `getTsconfig` returns the nearest tsconfig — matching `tsc` CLI behavior ([`findConfigFile()`](https://github.com/microsoft/TypeScript/blob/b19a9da2a3b8/src/compiler/program.ts#L328)). With `includes`, it checks the file is included by `include`/`files` and not excluded by `exclude` before accepting the tsconfig — matching VS Code's TypeScript Language Server behavior ([`isMatchedByConfig()`](https://github.com/microsoft/TypeScript/blob/b19a9da2a3b8/src/server/editorServices.ts#L4486)).
|
|
90
|
-
|
|
91
|
-
#### Example
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
|
-
import { getTsconfig } from 'get-tsconfig'
|
|
95
|
-
|
|
96
|
-
// Searches for tsconfig.json starting in the current directory
|
|
97
|
-
console.log(getTsconfig())
|
|
98
|
-
|
|
99
|
-
// Find tsconfig.json from a TypeScript file path
|
|
100
|
-
console.log(getTsconfig('./path/to/index.ts'))
|
|
101
|
-
|
|
102
|
-
// Find tsconfig.json from a directory file path
|
|
103
|
-
console.log(getTsconfig('./path/to/directory'))
|
|
104
|
-
|
|
105
|
-
// Explicitly pass in tsconfig.json path
|
|
106
|
-
console.log(getTsconfig('./path/to/tsconfig.json'))
|
|
107
|
-
|
|
108
|
-
// Search for jsconfig.json - https://code.visualstudio.com/docs/languages/jsconfig
|
|
109
|
-
console.log(getTsconfig('.', 'jsconfig.json'))
|
|
110
|
-
|
|
111
|
-
// Find the tsconfig that actually applies to a file (Language Server behavior)
|
|
112
|
-
// Skips tsconfig files where the file is excluded or not included
|
|
113
|
-
console.log(getTsconfig('./src/index.ts', 'tsconfig.json', new Map(), true))
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
### findTsconfig(searchPath?, configName?, cache?, includes?)
|
|
119
|
-
|
|
120
|
-
Searches for a tsconfig file by walking up the directory tree. Returns the path to the found tsconfig file, or `undefined` if not found.
|
|
121
|
-
|
|
122
|
-
Supports the same [`includes`](#includes) option as `getTsconfig` to validate that the tsconfig applies to the `searchPath` file.
|
|
123
|
-
|
|
124
|
-
#### Example
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
import { findTsconfig } from 'get-tsconfig'
|
|
128
|
-
|
|
129
|
-
// Find the tsconfig.json path
|
|
130
|
-
findTsconfig()
|
|
131
|
-
|
|
132
|
-
// Find the tsconfig that includes the file
|
|
133
|
-
findTsconfig('./src/index.ts', 'tsconfig.json', new Map(), true)
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
### parseTsconfig(tsconfigPath, cache?)
|
|
139
|
-
|
|
140
|
-
Parse the tsconfig file provided. Used internally by `getTsconfig`. Returns the parsed tsconfig as `TsConfigJsonResolved`.
|
|
141
|
-
|
|
142
|
-
#### tsconfigPath
|
|
143
|
-
Type: `string`
|
|
144
|
-
|
|
145
|
-
Required path to the tsconfig file.
|
|
146
|
-
|
|
147
|
-
#### cache
|
|
148
|
-
Type: `Map<string, any>`
|
|
149
|
-
|
|
150
|
-
Default: `new Map()`
|
|
151
|
-
|
|
152
|
-
Optional cache for fs operations.
|
|
153
|
-
|
|
154
|
-
#### Example
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
import { parseTsconfig } from 'get-tsconfig'
|
|
158
|
-
|
|
159
|
-
// Must pass in a path to an existing tsconfig.json file
|
|
160
|
-
console.log(parseTsconfig('./path/to/tsconfig.custom.json'))
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
### createFilesMatcher(tsconfig: TsconfigResult, caseSensitivePaths?: boolean)
|
|
166
|
-
|
|
167
|
-
Given a `tsconfig.json` file, it returns a file-matcher function that determines whether it should apply to a file path.
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
type FileMatcher = (filePath: string) => TsconfigResult['config'] | undefined
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
#### tsconfig
|
|
174
|
-
Type: `TsconfigResult`
|
|
175
|
-
|
|
176
|
-
Pass in the return value from `getTsconfig`, or a `TsconfigResult` object.
|
|
177
|
-
|
|
178
|
-
#### caseSensitivePaths
|
|
179
|
-
Type: `boolean`
|
|
180
|
-
|
|
181
|
-
By default, it uses [`is-fs-case-sensitive`](https://github.com/privatenumber/is-fs-case-sensitive) to detect whether the file-system is case-sensitive.
|
|
182
|
-
|
|
183
|
-
Pass in `true` to make it case-sensitive.
|
|
184
|
-
|
|
185
|
-
#### Example
|
|
186
|
-
|
|
187
|
-
For example, if it's called with a `tsconfig.json` file that has `include`/`exclude`/`files` defined, the file-matcher will return the config for files that match `include`/`files`, and return `undefined` for files that don't match or match `exclude`.
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
const tsconfig = getTsconfig()
|
|
191
|
-
const fileMatcher = tsconfig && createFilesMatcher(tsconfig)
|
|
192
|
-
|
|
193
|
-
/*
|
|
194
|
-
* Returns tsconfig.json if it matches the file,
|
|
195
|
-
* undefined if not
|
|
196
|
-
*/
|
|
197
|
-
const configForFile = fileMatcher?.('/path/to/file.ts')
|
|
198
|
-
const distCode = compileTypescript({
|
|
199
|
-
code: sourceCode,
|
|
200
|
-
tsconfig: configForFile
|
|
201
|
-
})
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
### createPathsMatcher(tsconfig: TsconfigResult)
|
|
207
|
-
|
|
208
|
-
Given a tsconfig with [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths) defined, it returns a matcher function.
|
|
209
|
-
|
|
210
|
-
The matcher function accepts an [import specifier (the path to resolve)](https://nodejs.org/api/esm.html#terminology), checks it against `compilerOptions.paths`, and returns an array of possible paths to check:
|
|
211
|
-
```ts
|
|
212
|
-
function pathsMatcher(specifier: string): string[]
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
This function only returns possible paths and doesn't actually do any resolution. This helps increase compatibility wtih file/build systems which usually have their own resolvers.
|
|
216
|
-
|
|
217
|
-
#### Example
|
|
218
|
-
|
|
219
|
-
```ts
|
|
220
|
-
import { getTsconfig, createPathsMatcher } from 'get-tsconfig'
|
|
221
|
-
|
|
222
|
-
const tsconfig = getTsconfig()
|
|
223
|
-
const pathsMatcher = createPathsMatcher(tsconfig)
|
|
224
|
-
|
|
225
|
-
const exampleResolver = (request: string) => {
|
|
226
|
-
if (pathsMatcher) {
|
|
227
|
-
const tryPaths = pathsMatcher(request)
|
|
228
|
-
|
|
229
|
-
// Check if paths in `tryPaths` exist
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
## FAQ
|
|
235
|
-
|
|
236
|
-
### How can I use TypeScript to parse `tsconfig.json`?
|
|
237
|
-
This package is a re-implementation of TypeScript's `tsconfig.json` parser.
|
|
238
|
-
|
|
239
|
-
However, if you already have TypeScript as a dependency, you can simply use it's API:
|
|
240
|
-
|
|
241
|
-
```ts
|
|
242
|
-
import {
|
|
243
|
-
sys as tsSys,
|
|
244
|
-
findConfigFile,
|
|
245
|
-
readConfigFile,
|
|
246
|
-
parseJsonConfigFileContent
|
|
247
|
-
} from 'typescript'
|
|
248
|
-
|
|
249
|
-
// Find tsconfig.json file
|
|
250
|
-
const tsconfigPath = findConfigFile(process.cwd(), tsSys.fileExists, 'tsconfig.json')
|
|
251
|
-
|
|
252
|
-
// Read tsconfig.json file
|
|
253
|
-
const tsconfigFile = readConfigFile(tsconfigPath, tsSys.readFile)
|
|
254
|
-
|
|
255
|
-
// Resolve extends
|
|
256
|
-
const parsedTsconfig = parseJsonConfigFileContent(
|
|
257
|
-
tsconfigFile.config,
|
|
258
|
-
tsSys,
|
|
259
|
-
path.dirname(tsconfigPath)
|
|
260
|
-
)
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
## Sponsors
|
|
264
|
-
<p align="center">
|
|
265
|
-
<a href="https://github.com/sponsors/privatenumber">
|
|
266
|
-
<img src="https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg">
|
|
267
|
-
</a>
|
|
268
|
-
</p>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";var Be=Object.defineProperty;var r=(e,t)=>Be(e,"name",{value:t,configurable:!0});var d=require("node:path"),ce=require("node:fs"),xe=require("node:module"),Ie=require("resolve-pkg-maps"),$e=require("fs"),Ue=require("os"),Re=require("path");function h(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}r(h,"slash");const K=r(e=>{const t=ce[e];return(s,...n)=>{const i=`${e}:${n.join(":")}`;let l=s==null?void 0:s.get(i);return l===void 0&&(l=Reflect.apply(t,ce,n),s==null||s.set(i,l)),l}},"cacheFs"),B=K("existsSync"),Se=K("readFileSync"),q=K("statSync"),O=r((e,t,s)=>{for(;;){const n=d.posix.join(e,t);if(B(s,n))return n;const i=d.dirname(e);if(i===e)return;e=i}},"findUp"),C=/^\.{1,2}(\/.*)?$/,Q=r(e=>{const t=h(e);return C.test(t)?t:`./${t}`},"normalizeRelativePath");function Ne(e,t=!1){const s=e.length;let n=0,i="",l=0,o=16,f=0,u=0,g=0,m=0,w=0;function _(c,j){let y=0,T=0;for(;y<c;){let k=e.charCodeAt(n);if(k>=48&&k<=57)T=T*16+k-48;else if(k>=65&&k<=70)T=T*16+k-65+10;else if(k>=97&&k<=102)T=T*16+k-97+10;else break;n++,y++}return y<c&&(T=-1),T}r(_,"scanHexDigits");function b(c){n=c,i="",l=0,o=16,w=0}r(b,"setPosition");function p(){let c=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&R(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&R(e.charCodeAt(n)))for(n++;n<e.length&&R(e.charCodeAt(n));)n++;else return w=3,e.substring(c,n);let j=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&R(e.charCodeAt(n))){for(n++;n<e.length&&R(e.charCodeAt(n));)n++;j=n}else w=3;return e.substring(c,j)}r(p,"scanNumber");function L(){let c="",j=n;for(;;){if(n>=s){c+=e.substring(j,n),w=2;break}const y=e.charCodeAt(n);if(y===34){c+=e.substring(j,n),n++;break}if(y===92){if(c+=e.substring(j,n),n++,n>=s){w=2;break}switch(e.charCodeAt(n++)){case 34:c+='"';break;case 92:c+="\\";break;case 47:c+="/";break;case 98:c+="\b";break;case 102:c+="\f";break;case 110:c+=`
|
|
2
|
-
`;break;case 114:c+="\r";break;case 116:c+=" ";break;case 117:const k=_(4);k>=0?c+=String.fromCharCode(k):w=4;break;default:w=5}j=n;continue}if(y>=0&&y<=31)if(M(y)){c+=e.substring(j,n),w=2;break}else w=6;n++}return c}r(L,"scanString");function A(){if(i="",w=0,l=n,u=f,m=g,n>=s)return l=s,o=17;let c=e.charCodeAt(n);if(ee(c)){do n++,i+=String.fromCharCode(c),c=e.charCodeAt(n);while(ee(c));return o=15}if(M(c))return n++,i+=String.fromCharCode(c),c===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
3
|
-
`),f++,g=n,o=14;switch(c){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,i=L(),o=10;case 47:const j=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!M(e.charCodeAt(n));)n++;return i=e.substring(j,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const y=s-1;let T=!1;for(;n<y;){const k=e.charCodeAt(n);if(k===42&&e.charCodeAt(n+1)===47){n+=2,T=!0;break}n++,M(k)&&(k===13&&e.charCodeAt(n)===10&&n++,f++,g=n)}return T||(n++,w=1),i=e.substring(j,n),o=13}return i+=String.fromCharCode(c),n++,o=16;case 45:if(i+=String.fromCharCode(c),n++,n===s||!R(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=p(),o=11;default:for(;n<s&&D(c);)n++,c=e.charCodeAt(n);if(l!==n){switch(i=e.substring(l,n),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(c),n++,o=16}}r(A,"scanNext");function D(c){if(ee(c)||M(c))return!1;switch(c){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}r(D,"isUnknownContentCharacter");function x(){let c;do c=A();while(c>=12&&c<=15);return c}return r(x,"scanNextNonTrivia"),{setPosition:b,getPosition:r(()=>n,"getPosition"),scan:t?x:A,getToken:r(()=>o,"getToken"),getTokenValue:r(()=>i,"getTokenValue"),getTokenOffset:r(()=>l,"getTokenOffset"),getTokenLength:r(()=>n-l,"getTokenLength"),getTokenStartLine:r(()=>u,"getTokenStartLine"),getTokenStartCharacter:r(()=>l-m,"getTokenStartCharacter"),getTokenError:r(()=>w,"getTokenError")}}r(Ne,"createScanner");function ee(e){return e===32||e===9}r(ee,"isWhiteSpace");function M(e){return e===10||e===13}r(M,"isLineBreak");function R(e){return e>=48&&e<=57}r(R,"isDigit");var ge;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(ge||(ge={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const S=200;new Array(S).fill(0).map((e,t)=>`
|
|
4
|
-
`+" ".repeat(t)),new Array(S).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(S).fill(0).map((e,t)=>`\r
|
|
5
|
-
`+" ".repeat(t)),new Array(S).fill(0).map((e,t)=>`
|
|
6
|
-
`+" ".repeat(t)),new Array(S).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(S).fill(0).map((e,t)=>`\r
|
|
7
|
-
`+" ".repeat(t));var H;(function(e){e.DEFAULT={allowTrailingComma:!1}})(H||(H={}));function Pe(e,t=[],s=H.DEFAULT){let n=null,i=[];const l=[];function o(u){Array.isArray(i)?i.push(u):n!==null&&(i[n]=u)}return r(o,"onValue"),We(e,{onObjectBegin:r(()=>{const u={};o(u),l.push(i),i=u,n=null},"onObjectBegin"),onObjectProperty:r(u=>{n=u},"onObjectProperty"),onObjectEnd:r(()=>{i=l.pop()},"onObjectEnd"),onArrayBegin:r(()=>{const u=[];o(u),l.push(i),i=u,n=null},"onArrayBegin"),onArrayEnd:r(()=>{i=l.pop()},"onArrayEnd"),onLiteralValue:o,onError:r((u,g,m)=>{t.push({error:u,offset:g,length:m})},"onError")},s),i[0]}r(Pe,"parse$1");function We(e,t,s=H.DEFAULT){const n=Ne(e,!1),i=[];let l=0;function o(v){return v?()=>l===0&&v(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}r(o,"toNoArgVisit");function f(v){return v?F=>l===0&&v(F,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}r(f,"toOneArgVisit");function u(v){return v?F=>l===0&&v(F,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}r(u,"toOneArgVisitWithPath");function g(v){return v?()=>{l>0?l++:v(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(l=1)}:()=>!0}r(g,"toBeginVisit");function m(v){return v?()=>{l>0&&l--,l===0&&v(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}r(m,"toEndVisit");const w=g(t.onObjectBegin),_=u(t.onObjectProperty),b=m(t.onObjectEnd),p=g(t.onArrayBegin),L=m(t.onArrayEnd),A=u(t.onLiteralValue),D=f(t.onSeparator),x=o(t.onComment),c=f(t.onError),j=s&&s.disallowComments,y=s&&s.allowTrailingComma;function T(){for(;;){const v=n.scan();switch(n.getTokenError()){case 4:k(14);break;case 5:k(15);break;case 3:k(13);break;case 1:j||k(11);break;case 2:k(12);break;case 6:k(16);break}switch(v){case 12:case 13:j?k(10):x();break;case 16:k(1);break;case 15:case 14:break;default:return v}}}r(T,"scanNext");function k(v,F=[],W=[]){if(c(v),F.length+W.length>0){let $=n.getToken();for(;$!==17;){if(F.indexOf($)!==-1){T();break}else if(W.indexOf($)!==-1)break;$=T()}}}r(k,"handleError");function P(v){const F=n.getTokenValue();return v?A(F):(_(F),i.push(F)),T(),!0}r(P,"parseString");function J(){switch(n.getToken()){case 11:const v=n.getTokenValue();let F=Number(v);isNaN(F)&&(k(2),F=0),A(F);break;case 7:A(null);break;case 8:A(!0);break;case 9:A(!1);break;default:return!1}return T(),!0}r(J,"parseLiteral");function V(){return n.getToken()!==10?(k(3,[],[2,5]),!1):(P(!1),n.getToken()===6?(D(":"),T(),U()||k(4,[],[2,5])):k(5,[],[2,5]),i.pop(),!0)}r(V,"parseProperty");function z(){w(),T();let v=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(v||k(4,[],[]),D(","),T(),n.getToken()===2&&y)break}else v&&k(6,[],[]);V()||k(4,[],[2,5]),v=!0}return b(),n.getToken()!==2?k(7,[2],[]):T(),!0}r(z,"parseObject");function G(){p(),T();let v=!0,F=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(F||k(4,[],[]),D(","),T(),n.getToken()===4&&y)break}else F&&k(6,[],[]);v?(i.push(0),v=!1):i[i.length-1]++,U()||k(4,[],[4,5]),F=!0}return L(),v||i.pop(),n.getToken()!==4?k(8,[4],[]):T(),!0}r(G,"parseArray");function U(){switch(n.getToken()){case 3:return G();case 1:return z();case 10:return P(!0);default:return J()}}return r(U,"parseValue"),T(),n.getToken()===17?s.allowEmptyContent?!0:(k(4,[],[]),!1):U()?(n.getToken()!==17&&k(9,[],[]),!0):(k(4,[],[]),!1)}r(We,"visit");var ke;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(ke||(ke={}));var de;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(de||(de={}));const Me=Pe;var we;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(we||(we={}));const me=r((e,t)=>Me(Se(t,e,"utf8")),"readJsonc"),ne=Symbol("implicitBaseUrl"),E="${configDir}",Je=r(()=>{const{findPnpApi:e}=xe;return e&&e(process.cwd())},"getPnpApi"),te=r((e,t,s,n)=>{const i=`resolveFromPackageJsonPath:${e}:${t}:${s}`;if(n!=null&&n.has(i))return n.get(i);const l=me(e,n);if(!l)return;let o=t||"tsconfig.json";if(!s&&l.exports)try{const[f]=Ie.resolveExports(l.exports,t,["require","types"]);o=f}catch{return!1}else!t&&l.tsconfig&&(o=l.tsconfig);return o=d.join(e,"..",o),n==null||n.set(i,o),o},"resolveFromPackageJsonPath"),se="package.json",le="tsconfig.json",Ve=r((e,t,s)=>{let n=e;if(e===".."&&(n=d.join(n,le)),e[0]==="."&&(n=d.resolve(t,n)),d.isAbsolute(n)){if(B(s,n)){if(q(s,n).isFile())return n}else if(!n.endsWith(".json")){const b=`${n}.json`;if(B(s,b))return b}return}const[i,...l]=e.split("/"),o=i[0]==="@"?`${i}/${l.shift()}`:i,f=l.join("/"),u=Je();if(u){const{resolveRequest:b}=u;try{if(o===e){const p=b(d.join(o,se),t);if(p){const L=te(p,f,!1,s);if(L&&B(s,L))return L}}else{let p;try{p=b(e,t,{extensions:[".json"]})}catch{p=b(d.join(e,le),t)}if(p)return p}}catch{}}const g=O(d.resolve(t),d.join("node_modules",o),s);if(!g||!q(s,g).isDirectory())return;const m=d.join(g,se);if(B(s,m)){const b=te(m,f,!1,s);if(b===!1)return;if(b&&B(s,b)&&q(s,b).isFile())return b}const w=d.join(g,f),_=w.endsWith(".json");if(!_){const b=`${w}.json`;if(B(s,b))return b}if(B(s,w)){if(q(s,w).isDirectory()){const b=d.join(w,se);if(B(s,b)){const L=te(b,"",!0,s);if(L&&B(s,L))return L}const p=d.join(w,le);if(B(s,p))return p}else if(_)return w}},"resolveExtendsPath"),ie=r((e,t)=>Q(d.relative(e,t)),"pathRelative"),ve=["files","include","exclude"],N=r((e,t,s)=>{const n=d.join(t,s),i=d.relative(e,n);return h(i)||"./"},"resolveAndRelativize"),ze=r((e,t,s)=>{const n=d.relative(e,t);if(!n)return s;const i=s.startsWith("./")?s.slice(2):s;return h(`${n}/${i}`)},"prefixPattern"),Ge=r((e,t,s,n)=>{const i=Ve(e,t,n);if(!i)throw new Error(`File '${e}' not found.`);if(s.has(i))throw new Error(`Circularity detected while resolving configuration: ${i}`);s.add(i);const l=d.dirname(i),o=pe(i,n,s);delete o.references;const{compilerOptions:f}=o;if(f){const{baseUrl:u}=f;u&&!u.startsWith(E)&&(f.baseUrl=N(t,l,u));const{outDir:g}=f;g&&!g.startsWith(E)&&(f.outDir=N(t,l,g));const{declarationDir:m}=f;m&&!m.startsWith(E)&&(f.declarationDir=N(t,l,m));const{rootDir:w}=f;w&&!w.startsWith(E)&&(f.rootDir=N(t,l,w));const{rootDirs:_}=f;_&&(f.rootDirs=_.map(p=>p.startsWith(E)?p:N(t,l,p)));const{typeRoots:b}=f;b&&(f.typeRoots=b.map(p=>p.startsWith(E)?p:N(t,l,p)))}for(const u of ve){const g=o[u];g&&(o[u]=g.map(m=>m.startsWith(E)?m:ze(t,l,m)))}return o},"resolveExtends"),be=["outDir","declarationDir"],pe=r((e,t,s=new Set)=>{let n;try{n=me(e,t)||{}}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const i=d.dirname(e);if(n.compilerOptions){const{compilerOptions:l}=n;l.paths&&!l.baseUrl&&(l[ne]=i)}if(n.extends){const l=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const o of l.reverse()){const f=Ge(o,i,new Set(s),t),u={...f,...n,compilerOptions:{...f.compilerOptions,...n.compilerOptions}};f.watchOptions&&(u.watchOptions={...f.watchOptions,...n.watchOptions}),n=u}}if(n.compilerOptions){const{compilerOptions:l}=n,o=["baseUrl","rootDir"];for(const f of o){const u=l[f];if(u&&!u.startsWith(E)){const g=d.resolve(i,u),m=ie(i,g);l[f]=m}}for(const f of be){let u=l[f];u&&(Array.isArray(n.exclude)||(n.exclude=be.map(g=>l[g]).filter(Boolean)),u.startsWith(E)||(u=Q(u)),l[f]=u)}}else n.compilerOptions={};if(n.include&&(n.include=n.include.map(h)),n.files&&(n.files=n.files.map(l=>l.startsWith(E)?l:Q(l))),n.watchOptions){const{watchOptions:l}=n;l.excludeDirectories&&(l.excludeDirectories=l.excludeDirectories.map(o=>h(d.resolve(i,o)))),l.excludeFiles&&(l.excludeFiles=l.excludeFiles.map(o=>h(d.resolve(i,o)))),l.watchFile&&(l.watchFile=l.watchFile.toLowerCase()),l.watchDirectory&&(l.watchDirectory=l.watchDirectory.toLowerCase()),l.fallbackPolling&&(l.fallbackPolling=l.fallbackPolling.toLowerCase())}return n},"_parseTsconfig"),X=r((e,t)=>{if(e.startsWith(E))return h(d.join(t,e.slice(E.length)))},"interpolateConfigDir"),qe=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],Qe=r(e=>{var t,s,n,i,l,o,f,u,g,m,w,_,b,p,L,A,D,x,c,j,y,T,k,P,J,V,z,G,U,v,F,W,$;if(e.strict){const a=["noImplicitAny","noImplicitThis","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","strictBuiltinIteratorReturn","alwaysStrict","useUnknownInCatchVariables"];for(const I of a)e[I]===void 0&&(e[I]=!0)}if(e.composite&&((t=e.declaration)!=null||(e.declaration=!0),(s=e.incremental)!=null||(e.incremental=!0)),e.target){let a=e.target.toLowerCase();a==="es2015"&&(a="es6"),e.target=a,a==="esnext"&&((n=e.module)!=null||(e.module="es6"),(i=e.useDefineForClassFields)!=null||(e.useDefineForClassFields=!0)),(a==="es6"||a==="es2016"||a==="es2017"||a==="es2018"||a==="es2019"||a==="es2020"||a==="es2021"||a==="es2022"||a==="es2023"||a==="es2024")&&((l=e.module)!=null||(e.module="es6")),(a==="es2022"||a==="es2023"||a==="es2024")&&((o=e.useDefineForClassFields)!=null||(e.useDefineForClassFields=!0))}if(e.module){let a=e.module.toLowerCase();if(a==="es2015"&&(a="es6"),e.module=a,(a==="es6"||a==="es2020"||a==="es2022"||a==="esnext"||a==="none"||a==="system"||a==="umd"||a==="amd")&&((f=e.moduleResolution)!=null||(e.moduleResolution="classic")),a==="system"&&((u=e.allowSyntheticDefaultImports)!=null||(e.allowSyntheticDefaultImports=!0)),(a==="node16"||a==="node18"||a==="node20"||a==="nodenext"||a==="preserve")&&((g=e.esModuleInterop)!=null||(e.esModuleInterop=!0),(m=e.allowSyntheticDefaultImports)!=null||(e.allowSyntheticDefaultImports=!0)),(a==="node16"||a==="node18"||a==="node20"||a==="nodenext")&&((w=e.moduleDetection)!=null||(e.moduleDetection="force")),a==="node16"&&((_=e.target)!=null||(e.target="es2022"),(b=e.moduleResolution)!=null||(e.moduleResolution="node16")),a==="node18"&&((p=e.target)!=null||(e.target="es2022"),(L=e.moduleResolution)!=null||(e.moduleResolution="node16")),a==="node20"&&((A=e.target)!=null||(e.target="es2023"),(D=e.moduleResolution)!=null||(e.moduleResolution="node16"),(x=e.resolveJsonModule)!=null||(e.resolveJsonModule=!0)),a==="nodenext"&&((c=e.target)!=null||(e.target="esnext"),(j=e.moduleResolution)!=null||(e.moduleResolution="nodenext"),(y=e.resolveJsonModule)!=null||(e.resolveJsonModule=!0)),a==="node16"||a==="node18"||a==="node20"||a==="nodenext"){const I=e.target;(I==="es3"||I==="es2022"||I==="es2023"||I==="es2024"||I==="esnext")&&((T=e.useDefineForClassFields)!=null||(e.useDefineForClassFields=!0))}a==="preserve"&&((k=e.moduleResolution)!=null||(e.moduleResolution="bundler"))}if(e.moduleResolution){let a=e.moduleResolution.toLowerCase();a==="node"&&(a="node10"),e.moduleResolution=a,(a==="node16"||a==="nodenext"||a==="bundler")&&((P=e.resolvePackageJsonExports)!=null||(e.resolvePackageJsonExports=!0),(J=e.resolvePackageJsonImports)!=null||(e.resolvePackageJsonImports=!0)),a==="bundler"&&((V=e.allowSyntheticDefaultImports)!=null||(e.allowSyntheticDefaultImports=!0),(z=e.resolveJsonModule)!=null||(e.resolveJsonModule=!0))}e.jsx&&(e.jsx=e.jsx.toLowerCase()),e.moduleDetection&&(e.moduleDetection=e.moduleDetection.toLowerCase()),e.importsNotUsedAsValues&&(e.importsNotUsedAsValues=e.importsNotUsedAsValues.toLowerCase()),e.newLine&&(e.newLine=e.newLine.toLowerCase()),e.esModuleInterop&&((G=e.allowSyntheticDefaultImports)!=null||(e.allowSyntheticDefaultImports=!0)),e.verbatimModuleSyntax&&((U=e.isolatedModules)!=null||(e.isolatedModules=!0),(v=e.preserveConstEnums)!=null||(e.preserveConstEnums=!0)),e.isolatedModules&&((F=e.preserveConstEnums)!=null||(e.preserveConstEnums=!0)),e.rewriteRelativeImportExtensions&&((W=e.allowImportingTsExtensions)!=null||(e.allowImportingTsExtensions=!0)),e.lib&&(e.lib=e.lib.map(a=>a.toLowerCase())),e.checkJs&&(($=e.allowJs)!=null||(e.allowJs=!0))},"normalizeCompilerOptions"),oe=r((e,t=new Map)=>{const s=d.resolve(e),n=pe(s,t),i=d.dirname(s),{compilerOptions:l}=n;if(l){for(const f of qe){const u=l[f];if(u){const g=X(u,i);l[f]=g?ie(i,g):u}}for(const f of["rootDirs","typeRoots"]){const u=l[f];u&&(l[f]=u.map(g=>{const m=X(g,i);return m?ie(i,m):Q(g)}))}const{paths:o}=l;if(o)for(const f of Object.keys(o))o[f]=o[f].map(u=>{var g;return(g=X(u,i))!=null?g:u});Qe(l)}for(const o of ve){const f=n[o];f&&(n[o]=f.map(u=>{var g;return(g=X(u,i))!=null?g:u}))}return n},"parseTsconfig");var He=Object.defineProperty,Y=r((e,t)=>He(e,"name",{value:t,configurable:!0}),"s");const Te=Y(e=>{let t="";for(let s=0;s<e.length;s+=1){const n=e[s],i=n.toUpperCase();t+=n===i?n.toLowerCase():i}return t},"invertCase"),re=new Map,Ae=Y((e,t)=>{const s=Re.join(e,`.is-fs-case-sensitive-test-${process.pid}`);try{return t.writeFileSync(s,""),!t.existsSync(Te(s))}finally{try{t.unlinkSync(s)}catch{}}},"checkDirectoryCaseWithWrite"),Xe=Y((e,t,s)=>{try{return Ae(e,s)}catch(n){if(t===void 0)return Ae(Ue.tmpdir(),s);throw n}},"checkDirectoryCaseWithFallback"),Ye=Y((e,t=$e,s=!0)=>{const n=e!=null?e:process.cwd();if(s&&re.has(n))return re.get(n);let i;const l=Te(n);return l!==n&&t.existsSync(n)?i=!t.existsSync(l):i=Xe(n,e,t),s&&re.set(n,i),i},"isFsCaseSensitive"),{join:_e}=d.posix,ue={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},Ze=r(e=>{const t=[...ue.ts],s=[...ue.cts],n=[...ue.mts];return e!=null&&e.allowJs&&(t.push(".js",".jsx"),s.push(".cjs"),n.push(".mjs")),[...t,...s,...n]},"getSupportedExtensions"),Ke=r(e=>{const t=[];if(!e)return t;const{outDir:s,declarationDir:n}=e;return s&&t.push(s),n&&t.push(n),t},"getDefaultExcludeSpec"),ye=r(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegexp"),Oe=["node_modules","bower_components","jspm_packages"],fe=`(?!(${Oe.join("|")})(/|$))`,Ce=/(?:^|\/)[^.*?]+$/,je="**/*",Z="[^/]",ae="[^./]",Fe=process.platform==="win32",De=r(({config:e,path:t},s=Ye())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!d.isAbsolute(t))throw new Error("The tsconfig path must be absolute");Fe&&(t=h(t));const n=d.dirname(t),{files:i,include:l,exclude:o,compilerOptions:f}=e,u=r(A=>d.isAbsolute(A)?A:_e(n,A),"resolvePattern"),g=i==null?void 0:i.map(u),m=Ze(f),w=s?"":"i",b=(o||Ke(f)).map(A=>{const D=u(A),x=ye(D).replaceAll(String.raw`\*\*/`,"(.+/)?").replaceAll(String.raw`\*`,`${Z}*`).replaceAll(String.raw`\?`,Z);return new RegExp(`^${x}($|/)`,w)}),p=i||l?l:[je],L=p?p.map(A=>{let D=u(A);Ce.test(D)&&(D=_e(D,je));const x=ye(D).replaceAll(String.raw`/\*\*`,`(/${fe}${ae}${Z}*)*?`).replaceAll(/(\/)?\\\*/g,(c,j)=>{const y=`(${ae}|(\\.(?!min\\.js$))?)*`;return j?`/${fe}${ae}${y}`:y}).replaceAll(/(\/)?\\\?/g,(c,j)=>{const y=Z;return j?`/${fe}${y}`:y});return new RegExp(`^${x}$`,w)}):void 0;return A=>{if(!d.isAbsolute(A))throw new Error("filePath must be absolute");if(Fe&&(A=h(A)),g!=null&&g.includes(A))return e;if(!(!m.some(D=>A.endsWith(D))||b.some(D=>D.test(A)))&&L&&L.some(D=>D.test(A)))return e}},"createFilesMatcher"),Le=r((e,t,s)=>{const n=d.resolve(e);let i=h(e);for(;;){const l=O(i,t,s);if(!l)return;const o=d.resolve(l),f=oe(o,s),u={path:h(o),config:f};if(De(u)(n))return u;const m=d.dirname(l),w=d.dirname(m);if(w===m)return;i=w}},"findConfigApplicable"),he=r((e=process.cwd(),t="tsconfig.json",s=new Map,n=!1)=>{var i;return n?(i=Le(e,t,s))==null?void 0:i.path:O(h(e),t,s)},"findTsconfig"),en=r((e=process.cwd(),t="tsconfig.json",s=new Map,n=!1)=>{var i;if(!n){const l=he(e,t,s);if(!l)return null;const o=oe(l,s);return{path:l,config:o}}return(i=Le(e,t,s))!=null?i:null},"getTsconfig"),nn=/\*/g,Ee=r((e,t)=>{const s=e.match(nn);if(s&&s.length>1)throw new Error(t)},"assertStarCount"),tn=r(e=>{if(e.includes("*")){const[t,s]=e.split("*");return{prefix:t,suffix:s}}return e},"parsePattern"),sn=r(({prefix:e,suffix:t},s)=>s.startsWith(e)&&s.endsWith(t),"isPatternMatch"),ln=r((e,t,s)=>Object.entries(e).map(([n,i])=>(Ee(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:tn(n),substitutions:i.map(l=>{if(Ee(l,`Substitution '${l}' in pattern '${n}' can have at most one '*' character.`),!t&&!C.test(l)&&!d.isAbsolute(l))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return d.resolve(s,l)})})),"parsePaths"),on=r(e=>{const{compilerOptions:t}=e.config;if(!t)return null;const{baseUrl:s,paths:n}=t;if(!s&&!n)return null;const i=ne in t&&t[ne],l=d.resolve(d.dirname(e.path),s||i||"."),o=n?ln(n,s,l):[];return f=>{if(C.test(f))return[];const u=[];for(const _ of o){if(_.pattern===f)return _.substitutions.map(h);typeof _.pattern!="string"&&u.push(_)}let g,m=-1;for(const _ of u)sn(_.pattern,f)&&_.pattern.prefix.length>m&&(m=_.pattern.prefix.length,g=_);if(!g)return s?[h(d.join(l,f))]:[];const w=f.slice(g.pattern.prefix.length,f.length-g.pattern.suffix.length);return g.substitutions.map(_=>h(_.replace("*",w)))}},"createPathsMatcher");exports.createFilesMatcher=De,exports.createPathsMatcher=on,exports.findTsconfig=he,exports.getTsconfig=en,exports.parseTsconfig=oe;
|