@gjsify/resolve-npm 0.4.35 → 0.4.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/globals-map.mjs +135 -0
- package/lib/index.d.ts +10 -3
- package/lib/index.mjs +171 -0
- package/lib/runtime-aliases.mjs +12 -5
- package/package.json +12 -2
package/lib/globals-map.mjs
CHANGED
|
@@ -215,3 +215,138 @@ export const GJS_GLOBALS_MAP = {
|
|
|
215
215
|
location: '@gjsify/dom-elements/register/location',
|
|
216
216
|
navigator: '@gjsify/dom-elements/register/navigator',
|
|
217
217
|
};
|
|
218
|
+
|
|
219
|
+
// ─── Browser target ────────────────────────────────────────────────────────
|
|
220
|
+
//
|
|
221
|
+
// `GJS_GLOBALS_MAP` is the GJS-target authority — every identifier needs a
|
|
222
|
+
// `@gjsify/<X>/register` install path because GJS ships none of them natively.
|
|
223
|
+
// The `--app browser` target inverts that: nearly every identifier in
|
|
224
|
+
// `GJS_GLOBALS_GROUPS.web` and `.dom` is already on the browser's `globalThis`
|
|
225
|
+
// (fetch, Headers, ReadableStream, Event, document, …). Only a handful of
|
|
226
|
+
// Node-group identifiers (Buffer, process, setImmediate, clearImmediate)
|
|
227
|
+
// need a polyfill register entry.
|
|
228
|
+
//
|
|
229
|
+
// The split below mirrors the T-Plan section 5b distinction:
|
|
230
|
+
// - `BROWSER_NATIVE_IDENTS` — identifier set that resolves to no-op
|
|
231
|
+
// register entries for `--app browser`. Used by both the audit-runtimes
|
|
232
|
+
// `BROWSER_NATIVE_RE_EXPORTS` probe (T-Plan 5b-i) and the future
|
|
233
|
+
// esbuild/rolldown `--globals` consumer to recognise that the identifier
|
|
234
|
+
// does NOT need an injected register module on the browser target.
|
|
235
|
+
// - `BROWSER_GLOBALS_MAP` — the strict subset of `GJS_GLOBALS_MAP` that
|
|
236
|
+
// still needs a polyfill register path on the browser target. Today only
|
|
237
|
+
// `Buffer` (`@gjsify/buffer/register`) and `process` (no `/register`
|
|
238
|
+
// subpath shipped yet — placeholder string mirrored from GJS map until
|
|
239
|
+
// `@gjsify/process` lands a browser-runnable register module).
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Identifiers that are natively present on a browser's `globalThis` and
|
|
243
|
+
* therefore need no `/register` injection when `--app browser` is targeting
|
|
244
|
+
* the bundle. Consumed by:
|
|
245
|
+
*
|
|
246
|
+
* - `scripts/audit-runtimes.mjs` `BROWSER_NATIVE_RE_EXPORTS` probe
|
|
247
|
+
* (T-Plan section 1b) to decide whether a `globals.mjs` re-export source
|
|
248
|
+
* is recognisable as a browser-resolvable specifier.
|
|
249
|
+
* - `@gjsify/cli` `--globals` flag indirection — future browser-target
|
|
250
|
+
* consumer (T-Plan section 5b-iii `getGlobalsMapFor(target)`) maps these
|
|
251
|
+
* to a no-op register entry instead of injecting a `/register` shim.
|
|
252
|
+
*
|
|
253
|
+
* Drawn from `GJS_GLOBALS_GROUPS.web` and `.dom` (every entry there is
|
|
254
|
+
* browser-native) plus a small set of shared identifiers from `.node`
|
|
255
|
+
* (`queueMicrotask`, `structuredClone`, `btoa`, `atob`, `URL`,
|
|
256
|
+
* `URLSearchParams`, and the unprefixed timer family).
|
|
257
|
+
*/
|
|
258
|
+
export const BROWSER_NATIVE_IDENTS = new Set([
|
|
259
|
+
// Web group — all browser-native
|
|
260
|
+
'fetch', 'Headers', 'Request', 'Response',
|
|
261
|
+
'FormData', 'Blob', 'File',
|
|
262
|
+
'ReadableStream', 'WritableStream', 'TransformStream',
|
|
263
|
+
'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest',
|
|
264
|
+
'ReadableByteStreamController', 'ReadableStreamDefaultController',
|
|
265
|
+
'ReadableStreamDefaultReader',
|
|
266
|
+
'TextEncoderStream', 'TextDecoderStream',
|
|
267
|
+
'ByteLengthQueuingStrategy', 'CountQueuingStrategy',
|
|
268
|
+
'CompressionStream', 'DecompressionStream',
|
|
269
|
+
'crypto',
|
|
270
|
+
'AbortController', 'AbortSignal',
|
|
271
|
+
'MessageChannel', 'MessagePort',
|
|
272
|
+
'Event', 'EventTarget', 'CustomEvent', 'MessageEvent',
|
|
273
|
+
'ErrorEvent', 'CloseEvent', 'ProgressEvent',
|
|
274
|
+
'UIEvent', 'MouseEvent', 'PointerEvent', 'KeyboardEvent',
|
|
275
|
+
'WheelEvent', 'FocusEvent',
|
|
276
|
+
'EventSource', 'WebSocket', 'WebAssembly',
|
|
277
|
+
'DOMException',
|
|
278
|
+
'performance', 'PerformanceObserver',
|
|
279
|
+
'XMLHttpRequest', 'XMLHttpRequestUpload',
|
|
280
|
+
'DOMParser',
|
|
281
|
+
'AudioContext', 'webkitAudioContext', 'Audio', 'HTMLAudioElement',
|
|
282
|
+
'GamepadEvent',
|
|
283
|
+
'MediaDevices',
|
|
284
|
+
'RTCPeerConnection', 'RTCSessionDescription', 'RTCIceCandidate',
|
|
285
|
+
'RTCPeerConnectionIceEvent', 'RTCDataChannel', 'RTCDataChannelEvent',
|
|
286
|
+
'RTCError', 'RTCErrorEvent',
|
|
287
|
+
'MediaStream', 'MediaStreamTrack', 'RTCTrackEvent',
|
|
288
|
+
// DOM group — all browser-native
|
|
289
|
+
'document', 'Image', 'HTMLCanvasElement', 'HTMLImageElement',
|
|
290
|
+
'HTMLElement', 'MutationObserver', 'ResizeObserver', 'IntersectionObserver',
|
|
291
|
+
'FontFace', 'matchMedia', 'location', 'navigator',
|
|
292
|
+
// Shared Node-group identifiers that are also browser-native
|
|
293
|
+
'queueMicrotask', 'structuredClone', 'btoa', 'atob',
|
|
294
|
+
'URL', 'URLSearchParams',
|
|
295
|
+
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Identifier → register-subpath map for the `--app browser` target. Strict
|
|
300
|
+
* subset of `GJS_GLOBALS_MAP`: only identifiers that do NOT exist natively
|
|
301
|
+
* on `globalThis` in a browser need a polyfill register injection.
|
|
302
|
+
*
|
|
303
|
+
* Today: `Buffer` (the sole Node-group identifier with a shipped
|
|
304
|
+
* `@gjsify/<X>/register` subpath that ALSO has a browser-runnable polyfill
|
|
305
|
+
* landed on `main`). `process`, `setImmediate`, and `clearImmediate` will
|
|
306
|
+
* join the map as `@gjsify/{process,timers}/register` granular subpaths
|
|
307
|
+
* land (browser polyfill wave 3-A onwards).
|
|
308
|
+
*/
|
|
309
|
+
export const BROWSER_GLOBALS_MAP = {
|
|
310
|
+
Buffer: '@gjsify/buffer/register',
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* NativeScript globals map. NS' bundled V8 already provides every Web /
|
|
315
|
+
* Node-runtime global that `GJS_GLOBALS_MAP` covers — `fetch`, `URL`,
|
|
316
|
+
* `URLSearchParams`, `crypto` (incl. `crypto.getRandomValues`), `Promise`,
|
|
317
|
+
* `setTimeout` / `setInterval`, `console`, `TextEncoder` / `TextDecoder`,
|
|
318
|
+
* `atob` / `btoa`, `Blob`, `File`, `FormData`, `WebSocket`,
|
|
319
|
+
* `XMLHttpRequest`, `structuredClone`, etc. — so no register-subpath
|
|
320
|
+
* injection is needed for the default surface.
|
|
321
|
+
*
|
|
322
|
+
* `Buffer` is the one exception: NS does not ship `Buffer` as a global
|
|
323
|
+
* (it's a Node-specific concept). Apps that consume `node:buffer` get the
|
|
324
|
+
* polyfill via the alias layer; this map covers the bare `Buffer`
|
|
325
|
+
* free-identifier case (parallel to the BROWSER_GLOBALS_MAP entry).
|
|
326
|
+
*
|
|
327
|
+
* Per-pillar Welle-5 PRs will extend this map as packages declare
|
|
328
|
+
* `runtimes.nativescript = "polyfill"` and need a specific global stubbed.
|
|
329
|
+
*/
|
|
330
|
+
export const NATIVESCRIPT_GLOBALS_MAP = {
|
|
331
|
+
Buffer: '@gjsify/buffer/register',
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Helper for consumers (esbuild/rolldown plugins, future audit consumers)
|
|
336
|
+
* to fetch the right identifier → register-subpath map for a given build
|
|
337
|
+
* target. Centralises the per-target choice so a consumer with a `target`
|
|
338
|
+
* variable does not need to branch on the strings itself.
|
|
339
|
+
*
|
|
340
|
+
* - `'gjs'` → full `GJS_GLOBALS_MAP` (every identifier needs a register)
|
|
341
|
+
* - `'node'` → `{}` (every GJS-mapped identifier is Node-native)
|
|
342
|
+
* - `'browser'` → `BROWSER_GLOBALS_MAP` (subset that still needs a polyfill)
|
|
343
|
+
* - `'nativescript'` → `NATIVESCRIPT_GLOBALS_MAP` (subset NS V8 doesn't ship)
|
|
344
|
+
* - default → `GJS_GLOBALS_MAP` (safer fallback for unknown targets)
|
|
345
|
+
*/
|
|
346
|
+
export function getGlobalsMapFor(target) {
|
|
347
|
+
if (target === 'gjs') return GJS_GLOBALS_MAP;
|
|
348
|
+
if (target === 'node') return {};
|
|
349
|
+
if (target === 'browser') return BROWSER_GLOBALS_MAP;
|
|
350
|
+
if (target === 'nativescript') return NATIVESCRIPT_GLOBALS_MAP;
|
|
351
|
+
return GJS_GLOBALS_MAP;
|
|
352
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,14 @@ export declare const EXTERNALS_NPM: string[];
|
|
|
8
8
|
export declare const ALIASES_GENERAL_FOR_GJS: {[alias:string]: string};
|
|
9
9
|
|
|
10
10
|
/** Record of Node.js modules (build in or not) and his replacement for Gjs */
|
|
11
|
-
export declare const ALIASES_NODE_FOR_GJS: {[alias:string]: string};
|
|
11
|
+
export declare const ALIASES_NODE_FOR_GJS: {[alias:string]: string};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Record of Node.js modules (build in or not) and his replacement for `--app browser`.
|
|
15
|
+
* Unwired in this PR — exported for future consumption by browser.ts.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ALIASES_NODE_FOR_BROWSER: {[alias:string]: string};
|
|
18
|
+
export declare const ALIASES_NODE_FOR_NATIVESCRIPT: {[alias:string]: string};
|
|
12
19
|
|
|
13
20
|
/** Record of Web modules and his replacement for Gjs */
|
|
14
21
|
export declare const ALIASES_WEB_FOR_GJS: {[alias:string]: string};
|
|
@@ -46,11 +53,11 @@ export interface RuntimeTriplet {
|
|
|
46
53
|
* by each workspace package's declared `gjsify.runtimes` triplet. See
|
|
47
54
|
* `runtime-aliases.mjs` for the routing semantics.
|
|
48
55
|
*/
|
|
49
|
-
export declare function getDerivedAliasesSync(target: 'gjs' | 'node' | 'browser'): {[alias: string]: string};
|
|
56
|
+
export declare function getDerivedAliasesSync(target: 'gjs' | 'node' | 'browser' | 'nativescript'): {[alias: string]: string};
|
|
50
57
|
|
|
51
58
|
/** Async variant of {@link getDerivedAliasesSync}. */
|
|
52
59
|
export declare function getDerivedAliases(
|
|
53
|
-
target: 'gjs' | 'node' | 'browser',
|
|
60
|
+
target: 'gjs' | 'node' | 'browser' | 'nativescript',
|
|
54
61
|
): Promise<{[alias: string]: string}>;
|
|
55
62
|
|
|
56
63
|
/** Reset the in-memory cache. Test-only. */
|
package/lib/index.mjs
CHANGED
|
@@ -179,6 +179,177 @@ export const ALIASES_NODE_FOR_GJS = {
|
|
|
179
179
|
'isomorphic-ws': '@gjsify/websocket',
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Record of Node.js modules (built-in or 3rd-party) and their `@gjsify/<X>`
|
|
184
|
+
* replacement for `--app browser` builds. Mirrors `ALIASES_NODE_FOR_GJS` in
|
|
185
|
+
* shape — bare bridge from the NPM-specifier namespace into `@gjsify/*` so the
|
|
186
|
+
* dynamic per-runtimes-triplet resolver (`getDerivedAliasesSync`) can finish
|
|
187
|
+
* the routing in a second pass (`@gjsify/<X>` → `@gjsify/<X>/globals` or
|
|
188
|
+
* `@gjsify/empty` depending on the slot declaration).
|
|
189
|
+
*
|
|
190
|
+
* `none`-slot entries are deliberately hardcoded to `@gjsify/empty` here
|
|
191
|
+
* (e.g. `child_process`, `fs`, `net`, ...) rather than relying on the dynamic
|
|
192
|
+
* runtime layer — bare `fs` / `net` / ... do NOT start with `@gjsify/` and
|
|
193
|
+
* therefore never enter `getDerivedAliasesSync`. This table is the bridge.
|
|
194
|
+
*
|
|
195
|
+
* NOTE — UNWIRED IN THIS PR. The browser-app orchestrator
|
|
196
|
+
* (`packages/infra/rolldown-plugin-gjsify/src/app/browser.ts`) does NOT
|
|
197
|
+
* consume this map yet. PR-D (T-Plan Sektion 2b-ii + 2b-iii, Welle 3) flips
|
|
198
|
+
* `browser.ts` to spread `ALIASES_NODE_FOR_BROWSER` (+ generated `node:*`
|
|
199
|
+
* prefix-map) into its `aliasMap` UNDER `browserPolyfillAliases` and the user
|
|
200
|
+
* aliases. Decoupled here so the table is exportable / reviewable in
|
|
201
|
+
* isolation, while consumer wiring waits on the R1 wave delivering browser-
|
|
202
|
+
* baubable `@gjsify/{process,buffer,stream,...}` builds. Adopt only when the
|
|
203
|
+
* per-package browser slots are R1-validated.
|
|
204
|
+
*/
|
|
205
|
+
export const ALIASES_NODE_FOR_BROWSER = {
|
|
206
|
+
'assert': '@gjsify/assert',
|
|
207
|
+
'assert/strict': '@gjsify/assert/strict',
|
|
208
|
+
'async_hooks': '@gjsify/async_hooks',
|
|
209
|
+
'buffer': '@gjsify/buffer',
|
|
210
|
+
'child_process': '@gjsify/empty', // none-slot — browser has no process model
|
|
211
|
+
'cluster': '@gjsify/empty',
|
|
212
|
+
'console': '@gjsify/console',
|
|
213
|
+
'constants': '@gjsify/constants',
|
|
214
|
+
'crypto': '@gjsify/crypto',
|
|
215
|
+
'dgram': '@gjsify/empty',
|
|
216
|
+
'diagnostics_channel': '@gjsify/diagnostics_channel',
|
|
217
|
+
'dns': '@gjsify/empty',
|
|
218
|
+
'dns/promises': '@gjsify/empty',
|
|
219
|
+
'domain': '@gjsify/domain',
|
|
220
|
+
'events': '@gjsify/events',
|
|
221
|
+
'fs': '@gjsify/empty', // phase 1: stub; later @gjsify/fs/browser
|
|
222
|
+
'fs/promises': '@gjsify/empty',
|
|
223
|
+
'http': '@gjsify/empty', // browser fetch covers most cases
|
|
224
|
+
'http2': '@gjsify/empty',
|
|
225
|
+
'https': '@gjsify/empty',
|
|
226
|
+
'inspector': '@gjsify/empty',
|
|
227
|
+
'module': '@gjsify/empty',
|
|
228
|
+
'net': '@gjsify/empty',
|
|
229
|
+
'os': '@gjsify/os',
|
|
230
|
+
'path': '@gjsify/path',
|
|
231
|
+
'path/posix': '@gjsify/path/posix',
|
|
232
|
+
'path/win32': '@gjsify/path/win32',
|
|
233
|
+
'perf_hooks': '@gjsify/perf_hooks',
|
|
234
|
+
'process': '@gjsify/process', // PR-D: flips today's `@gjsify/empty`
|
|
235
|
+
'punycode': '@gjsify/punycode',
|
|
236
|
+
'querystring': '@gjsify/querystring',
|
|
237
|
+
'readline': '@gjsify/empty',
|
|
238
|
+
'readline/promises': '@gjsify/empty',
|
|
239
|
+
'repl': '@gjsify/empty',
|
|
240
|
+
'stream': '@gjsify/stream',
|
|
241
|
+
'stream/web': '@gjsify/stream/web',
|
|
242
|
+
'stream/consumers': '@gjsify/stream/consumers',
|
|
243
|
+
'stream/promises': '@gjsify/stream/promises',
|
|
244
|
+
'string_decoder': '@gjsify/string_decoder',
|
|
245
|
+
'sys': '@gjsify/sys',
|
|
246
|
+
'timers': '@gjsify/timers',
|
|
247
|
+
'timers/promises': '@gjsify/timers/promises',
|
|
248
|
+
'tls': '@gjsify/empty',
|
|
249
|
+
'tty': '@gjsify/empty',
|
|
250
|
+
'url': '@gjsify/url',
|
|
251
|
+
'util': '@gjsify/util',
|
|
252
|
+
'util/types': '@gjsify/util/types',
|
|
253
|
+
'v8': '@gjsify/empty',
|
|
254
|
+
'vm': '@gjsify/vm',
|
|
255
|
+
'wasi': '@gjsify/empty',
|
|
256
|
+
'sqlite': '@gjsify/empty',
|
|
257
|
+
'worker_threads': '@gjsify/empty',
|
|
258
|
+
'zlib': '@gjsify/zlib',
|
|
259
|
+
|
|
260
|
+
// Third-party
|
|
261
|
+
'node-fetch': '@gjsify/empty', // browser native fetch
|
|
262
|
+
'ws': '@gjsify/empty', // browser native WebSocket
|
|
263
|
+
'isomorphic-ws': '@gjsify/empty',
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Bare Node-builtin specifier → polyfill / empty-stub mapping for `--app
|
|
268
|
+
* nativescript` builds. Mirrors `ALIASES_NODE_FOR_BROWSER` in shape, with
|
|
269
|
+
* different per-module decisions reflecting what makes sense on a mobile-V8
|
|
270
|
+
* runtime (NativeScript on iOS + Android):
|
|
271
|
+
*
|
|
272
|
+
* - **Server-only Node built-ins → `@gjsify/empty`.** There is no listening
|
|
273
|
+
* socket / process model on a mobile-app runtime, so `child_process`,
|
|
274
|
+
* `cluster`, `dgram`, `dns`, `inspector`, `net`, `tls`, `tty`, `http*`
|
|
275
|
+
* resolve to an empty stub. NativeScript apps that need network I/O use
|
|
276
|
+
* the runtime-native `fetch` / `XMLHttpRequest` / `WebSocket`.
|
|
277
|
+
* - **Mobile-tractable Node built-ins → `@gjsify/<X>`.** `assert`,
|
|
278
|
+
* `async_hooks`, `buffer`, `crypto`, `events`, `fs`, `os`, `path`,
|
|
279
|
+
* `process`, `stream`, `string_decoder`, `url`, `util`, `querystring`
|
|
280
|
+
* route to their gjsify polyfills. The polyfills themselves may declare
|
|
281
|
+
* `runtimes.nativescript = "polyfill" | "partial" | "none"`; the
|
|
282
|
+
* triplet-driven `getDerivedAliasesSync('nativescript')` second pass
|
|
283
|
+
* reads the declaration and either keeps the resolution as-is (polyfill /
|
|
284
|
+
* partial) or redirects to `/globals` (native) or `@gjsify/empty` (none).
|
|
285
|
+
* - **`ws` / `isomorphic-ws` → `@gjsify/empty`.** NS apps use `WebSocket`
|
|
286
|
+
* from the global runtime, not the `ws` package.
|
|
287
|
+
*
|
|
288
|
+
* Entries here are PROVISIONAL — per-pillar Welle-5 PRs will refine them as
|
|
289
|
+
* each `@gjsify/<X>` package lands an explicit `nativescript` slot.
|
|
290
|
+
*/
|
|
291
|
+
export const ALIASES_NODE_FOR_NATIVESCRIPT = {
|
|
292
|
+
// Server-only Node built-ins → empty stub
|
|
293
|
+
'child_process': '@gjsify/empty',
|
|
294
|
+
'cluster': '@gjsify/empty',
|
|
295
|
+
'dgram': '@gjsify/empty',
|
|
296
|
+
'dns': '@gjsify/empty',
|
|
297
|
+
'dns/promises': '@gjsify/empty',
|
|
298
|
+
'inspector': '@gjsify/empty',
|
|
299
|
+
'net': '@gjsify/empty',
|
|
300
|
+
'tls': '@gjsify/empty',
|
|
301
|
+
'tty': '@gjsify/empty',
|
|
302
|
+
'http': '@gjsify/empty',
|
|
303
|
+
'https': '@gjsify/empty',
|
|
304
|
+
'http2': '@gjsify/empty',
|
|
305
|
+
'readline': '@gjsify/empty',
|
|
306
|
+
'repl': '@gjsify/empty',
|
|
307
|
+
'v8': '@gjsify/empty',
|
|
308
|
+
'vm': '@gjsify/empty',
|
|
309
|
+
'worker_threads': '@gjsify/empty',
|
|
310
|
+
'perf_hooks': '@gjsify/empty',
|
|
311
|
+
'diagnostics_channel': '@gjsify/empty',
|
|
312
|
+
'domain': '@gjsify/empty',
|
|
313
|
+
'sqlite': '@gjsify/empty',
|
|
314
|
+
'sys': '@gjsify/empty',
|
|
315
|
+
'zlib': '@gjsify/empty',
|
|
316
|
+
|
|
317
|
+
// Mobile-tractable Node built-ins → @gjsify/<X>
|
|
318
|
+
'assert': '@gjsify/assert',
|
|
319
|
+
'assert/strict': '@gjsify/assert',
|
|
320
|
+
'async_hooks': '@gjsify/async_hooks',
|
|
321
|
+
'buffer': '@gjsify/buffer',
|
|
322
|
+
// `@gjsify/module` (not `@gjsify/empty`): provides the named exports
|
|
323
|
+
// `createRequire` / `builtinModules` / `isBuiltin`, so `import { createRequire }
|
|
324
|
+
// from 'module'` in deps (e.g. css-tree) resolves instead of failing the build.
|
|
325
|
+
'module': '@gjsify/module',
|
|
326
|
+
'crypto': '@gjsify/crypto',
|
|
327
|
+
'events': '@gjsify/events',
|
|
328
|
+
'fs': '@gjsify/fs',
|
|
329
|
+
'fs/promises': '@gjsify/fs/promises',
|
|
330
|
+
'os': '@gjsify/os',
|
|
331
|
+
'path': '@gjsify/path',
|
|
332
|
+
'path/posix': '@gjsify/path/posix',
|
|
333
|
+
'path/win32': '@gjsify/path/win32',
|
|
334
|
+
'process': '@gjsify/process',
|
|
335
|
+
'stream': '@gjsify/stream',
|
|
336
|
+
'stream/promises': '@gjsify/stream/promises',
|
|
337
|
+
'stream/web': '@gjsify/stream/web',
|
|
338
|
+
'string_decoder': '@gjsify/string_decoder',
|
|
339
|
+
'url': '@gjsify/url',
|
|
340
|
+
'util': '@gjsify/util',
|
|
341
|
+
'util/types': '@gjsify/util/types',
|
|
342
|
+
'querystring': '@gjsify/querystring',
|
|
343
|
+
'console': '@gjsify/console',
|
|
344
|
+
'timers': '@gjsify/timers',
|
|
345
|
+
'timers/promises': '@gjsify/timers/promises',
|
|
346
|
+
|
|
347
|
+
// Third-party
|
|
348
|
+
'node-fetch': '@gjsify/empty', // NS has native fetch
|
|
349
|
+
'ws': '@gjsify/empty', // NS has its own WebSocket
|
|
350
|
+
'isomorphic-ws': '@gjsify/empty',
|
|
351
|
+
}
|
|
352
|
+
|
|
182
353
|
/** Record of Web modules and his replacement for Gjs */
|
|
183
354
|
export const ALIASES_WEB_FOR_GJS = {
|
|
184
355
|
// Bare specifiers (named imports, pure — no side-effects after Stage 2)
|
package/lib/runtime-aliases.mjs
CHANGED
|
@@ -39,10 +39,17 @@ import { join, dirname, resolve } from 'node:path';
|
|
|
39
39
|
import { fileURLToPath } from 'node:url';
|
|
40
40
|
|
|
41
41
|
const VALID_SLOTS = new Set(['polyfill', 'native', 'partial', 'none']);
|
|
42
|
-
const VALID_TARGETS = new Set(['gjs', 'node', 'browser']);
|
|
42
|
+
const VALID_TARGETS = new Set(['gjs', 'node', 'browser', 'nativescript']);
|
|
43
43
|
|
|
44
44
|
/** @typedef {'polyfill'|'native'|'partial'|'none'} Slot */
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Per-package runtime slot declaration. Quadruplet (gjs / node / browser /
|
|
47
|
+
* nativescript). The legacy "triplet" name is kept on the typedef for
|
|
48
|
+
* minimal churn while NativeScript is being landed; the type is canonically
|
|
49
|
+
* a quadruplet from VALID_TARGETS' perspective.
|
|
50
|
+
*
|
|
51
|
+
* @typedef {{gjs?:Slot, node?:Slot, browser?:Slot, nativescript?:Slot}} RuntimeTriplet
|
|
52
|
+
*/
|
|
46
53
|
/** @typedef {{name:string, dir:string, runtimes:RuntimeTriplet, hasGlobals:boolean}} PackageRecord */
|
|
47
54
|
|
|
48
55
|
let _cache = null;
|
|
@@ -313,7 +320,7 @@ function warnOnce(key, message) {
|
|
|
313
320
|
* Given a package record + target runtime, resolve the alias target.
|
|
314
321
|
*
|
|
315
322
|
* @param {PackageRecord} rec
|
|
316
|
-
* @param {'gjs'|'node'|'browser'} target
|
|
323
|
+
* @param {'gjs'|'node'|'browser'|'nativescript'} target
|
|
317
324
|
* @returns {string|null} The alias target specifier, or null if no rewrite applies.
|
|
318
325
|
*/
|
|
319
326
|
function resolveSlot(rec, target) {
|
|
@@ -365,7 +372,7 @@ function resolveSlot(rec, target) {
|
|
|
365
372
|
* (callers should `{ ...derived, ...hardcoded }` to preserve current behavior
|
|
366
373
|
* for packages opted out of the triplet model).
|
|
367
374
|
*
|
|
368
|
-
* @param {'gjs'|'node'|'browser'} target
|
|
375
|
+
* @param {'gjs'|'node'|'browser'|'nativescript'} target
|
|
369
376
|
* @returns {Record<string,string>}
|
|
370
377
|
*/
|
|
371
378
|
export function getDerivedAliasesSync(target) {
|
|
@@ -386,7 +393,7 @@ export function getDerivedAliasesSync(target) {
|
|
|
386
393
|
* Async variant of {@link getDerivedAliasesSync} — preferred when callable from
|
|
387
394
|
* an async config hook.
|
|
388
395
|
*
|
|
389
|
-
* @param {'gjs'|'node'|'browser'} target
|
|
396
|
+
* @param {'gjs'|'node'|'browser'|'nativescript'} target
|
|
390
397
|
* @returns {Promise<Record<string,string>>}
|
|
391
398
|
*/
|
|
392
399
|
export async function getDerivedAliases(target) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/resolve-npm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37",
|
|
4
4
|
"description": "Resolve NPM package aliases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
@@ -29,5 +29,15 @@
|
|
|
29
29
|
"node",
|
|
30
30
|
"npm",
|
|
31
31
|
"alias"
|
|
32
|
-
]
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/gjsify/gjsify.git",
|
|
37
|
+
"directory": "packages/infra/resolve-npm"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/gjsify/gjsify/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/resolve-npm#readme"
|
|
33
43
|
}
|