@gjsify/resolve-npm 0.17.0 → 0.19.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/lib/globals-map.mjs +29 -0
- package/lib/index.mjs +15 -14
- package/package.json +1 -1
package/lib/globals-map.mjs
CHANGED
|
@@ -216,6 +216,35 @@ export const GJS_GLOBALS_MAP = {
|
|
|
216
216
|
navigator: '@gjsify/dom-elements/register/navigator',
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Reverse-bridge native-override identifiers.
|
|
221
|
+
*
|
|
222
|
+
* On a `--app node` reverse-bridge build (a genuine GJS app run on Node via
|
|
223
|
+
* `@gjsify/node-gi`, EXPLICIT `--globals` requested), the register bodies for
|
|
224
|
+
* these identifiers MUST win over the runtime-native globals the host ships —
|
|
225
|
+
* unlike the default existence-guard (`if (typeof globalThis.X === 'undefined')`),
|
|
226
|
+
* which is correct for a cross-platform package loaded on plain Node but wrong
|
|
227
|
+
* here, where the app expects GJS Web-API semantics.
|
|
228
|
+
*
|
|
229
|
+
* Only `fetch` and its constructors qualify today: Node/Bun/Deno ship a native
|
|
230
|
+
* global `fetch` (undici) that rejects the root-relative `/res/...` asset paths a
|
|
231
|
+
* browser/GJS app uses, while `@gjsify/fetch` rewrites them to `file://` against
|
|
232
|
+
* the program directory and drives Soup. Every OTHER Web/DOM global gjsify
|
|
233
|
+
* injects (`XMLHttpRequest`, `document`, `Image`, `AudioContext`, the event
|
|
234
|
+
* classes, …) is ABSENT on the host, so its guard already installs gjsify's
|
|
235
|
+
* version — no override needed. `WebAssembly`/`URL`/`crypto`/streams are host
|
|
236
|
+
* globals whose gjsify register deliberately DEFERS to the working native, so
|
|
237
|
+
* they must NOT be listed here.
|
|
238
|
+
*
|
|
239
|
+
* Consumed by the `--app node` register-inject machinery
|
|
240
|
+
* (`writeRegisterInjectFile`): the natives are cleared just before the injected
|
|
241
|
+
* register bodies run, but ONLY for identifiers whose register is actually
|
|
242
|
+
* injected (so no host global is deleted without a gjsify replacement).
|
|
243
|
+
*/
|
|
244
|
+
export const REVERSE_BRIDGE_NATIVE_OVERRIDE_IDENTS = [
|
|
245
|
+
'fetch', 'Headers', 'Request', 'Response',
|
|
246
|
+
];
|
|
247
|
+
|
|
219
248
|
/**
|
|
220
249
|
* Register subpaths whose module imports a GObject-Introspection typelib
|
|
221
250
|
* (`gi://…`) at load time, keyed by register-path PREFIX → the GI namespaces
|
package/lib/index.mjs
CHANGED
|
@@ -444,27 +444,28 @@ export const ALIASES_GENERAL_FOR_NODE = {
|
|
|
444
444
|
/**
|
|
445
445
|
* Record of GJS built-in module specifiers and their replacement for the
|
|
446
446
|
* `--app node` target. These are the bare ESM module names a GJS source imports
|
|
447
|
-
* (`import System from 'system'`, `import Gettext from 'gettext'`
|
|
448
|
-
* them as built-in modules; Node has no equivalent,
|
|
449
|
-
* route to the `@gjsify/node-gi` reverse-bridge shims,
|
|
450
|
-
* (resolved at runtime against the consumer's node_modules
|
|
451
|
-
* `app/node.ts`'s external set), never bundled. This is the analogue of the
|
|
447
|
+
* (`import System from 'system'`, `import Gettext from 'gettext'`, `import cairo
|
|
448
|
+
* from 'cairo'`) — GJS exposes them as built-in modules; Node has no equivalent,
|
|
449
|
+
* so on the node target they route to the `@gjsify/node-gi` reverse-bridge shims,
|
|
450
|
+
* which are kept EXTERNAL (resolved at runtime against the consumer's node_modules
|
|
451
|
+
* — see `app/node.ts`'s external set), never bundled. This is the analogue of the
|
|
452
452
|
* `gi://` rewrite + `@gjsify/node-gi/globals` injection, and like them it is
|
|
453
453
|
* NODE-TARGET-ONLY: the gjs/browser/nativescript alias maps do not include this
|
|
454
|
-
* record, so a bare `system` / `gettext` import keeps resolving natively
|
|
455
|
-
* built-in / npm package) on every other target. The risk of hijacking a real
|
|
456
|
-
* npm package literally named `system`/`gettext` is identical to (and
|
|
457
|
-
* the same way as) the `gi://` design: it only applies when building a
|
|
458
|
-
* source for Node.
|
|
454
|
+
* record, so a bare `system` / `gettext` / `cairo` import keeps resolving natively
|
|
455
|
+
* (GJS built-in / npm package) on every other target. The risk of hijacking a real
|
|
456
|
+
* npm package literally named `system`/`gettext`/`cairo` is identical to (and
|
|
457
|
+
* bounded the same way as) the `gi://` design: it only applies when building a
|
|
458
|
+
* GJS/GI source for Node.
|
|
459
459
|
*
|
|
460
|
-
* `cairo`
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
460
|
+
* `cairo` maps to `@gjsify/node-gi/cairo`, the native cairo binding (a FOREIGN
|
|
461
|
+
* struct in GObject-Introspection — an npm cairo package cannot stand in, since a
|
|
462
|
+
* GI function taking/returning a cairo_t must marshal through the SAME cairo module
|
|
463
|
+
* the engine's foreign-struct seam knows about).
|
|
464
464
|
*/
|
|
465
465
|
const ALIASES_GJS_FOR_NODE = {
|
|
466
466
|
'system': '@gjsify/node-gi/system',
|
|
467
467
|
'gettext': '@gjsify/node-gi/gettext',
|
|
468
|
+
'cairo': '@gjsify/node-gi/cairo',
|
|
468
469
|
}
|
|
469
470
|
|
|
470
471
|
export { ALIASES_GJS_FOR_NODE };
|