@gjsify/resolve-npm 0.1.15 → 0.3.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 +21 -2
- package/lib/index.mjs +49 -4
- package/package.json +1 -1
package/lib/globals-map.mjs
CHANGED
|
@@ -45,9 +45,11 @@ export const GJS_GLOBALS_GROUPS = {
|
|
|
45
45
|
'ErrorEvent', 'CloseEvent', 'ProgressEvent', 'UIEvent',
|
|
46
46
|
'MouseEvent', 'PointerEvent', 'KeyboardEvent', 'WheelEvent', 'FocusEvent',
|
|
47
47
|
'EventSource',
|
|
48
|
+
'WebSocket',
|
|
48
49
|
'DOMException',
|
|
49
50
|
'performance', 'PerformanceObserver',
|
|
50
51
|
'XMLHttpRequest',
|
|
52
|
+
'XMLHttpRequestUpload',
|
|
51
53
|
'DOMParser',
|
|
52
54
|
'AudioContext', 'webkitAudioContext', 'Audio', 'HTMLAudioElement',
|
|
53
55
|
'GamepadEvent',
|
|
@@ -68,6 +70,16 @@ export const GJS_GLOBALS_MAP = {
|
|
|
68
70
|
// --- Node.js globals (granular register subpaths) ----------------------
|
|
69
71
|
Buffer: '@gjsify/node-globals/register/buffer',
|
|
70
72
|
process: '@gjsify/node-globals/register/process',
|
|
73
|
+
// setTimeout / setInterval ARE provided natively by GJS, but their return
|
|
74
|
+
// value is a GLib.Source BoxedInstance whose deferred-GC finalize calls
|
|
75
|
+
// g_source_unref on a possibly-freed source — silent SIGSEGV ~10 s after
|
|
76
|
+
// any third-party library uses them. Our `register/timers` replacement
|
|
77
|
+
// returns numeric IDs instead. Listing them here forces auto-globals to
|
|
78
|
+
// inject the override on every bundle that calls setTimeout.
|
|
79
|
+
setTimeout: '@gjsify/node-globals/register/timers',
|
|
80
|
+
setInterval: '@gjsify/node-globals/register/timers',
|
|
81
|
+
clearTimeout: '@gjsify/node-globals/register/timers',
|
|
82
|
+
clearInterval: '@gjsify/node-globals/register/timers',
|
|
71
83
|
setImmediate: '@gjsify/node-globals/register/timers',
|
|
72
84
|
clearImmediate: '@gjsify/node-globals/register/timers',
|
|
73
85
|
queueMicrotask: '@gjsify/node-globals/register/microtask',
|
|
@@ -126,6 +138,12 @@ export const GJS_GLOBALS_MAP = {
|
|
|
126
138
|
FocusEvent: 'dom-events/register/ui-events',
|
|
127
139
|
EventSource: 'eventsource/register',
|
|
128
140
|
|
|
141
|
+
// --- WebSocket ---------------------------------------------------------
|
|
142
|
+
// Single register module sets globalThis.{WebSocket,MessageEvent,CloseEvent}.
|
|
143
|
+
// MessageEvent is shared with dom-events in practice — whichever register
|
|
144
|
+
// runs first installs it; both guard with typeof === 'undefined'.
|
|
145
|
+
WebSocket: 'websocket/register',
|
|
146
|
+
|
|
129
147
|
// --- Performance -------------------------------------------------------
|
|
130
148
|
performance: '@gjsify/web-globals/register/performance',
|
|
131
149
|
PerformanceObserver: '@gjsify/web-globals/register/performance',
|
|
@@ -133,8 +151,9 @@ export const GJS_GLOBALS_MAP = {
|
|
|
133
151
|
// --- DOMException ------------------------------------------------------
|
|
134
152
|
DOMException: 'dom-exception/register',
|
|
135
153
|
|
|
136
|
-
// --- XMLHttpRequest
|
|
137
|
-
XMLHttpRequest: '
|
|
154
|
+
// --- XMLHttpRequest (implemented in @gjsify/fetch) ---------------------
|
|
155
|
+
XMLHttpRequest: 'fetch/register/xhr',
|
|
156
|
+
XMLHttpRequestUpload: 'fetch/register/xhr',
|
|
138
157
|
|
|
139
158
|
// --- DOMParser ---------------------------------------------------------
|
|
140
159
|
DOMParser: '@gjsify/domparser/register',
|
package/lib/index.mjs
CHANGED
|
@@ -70,6 +70,19 @@ export const ALIASES_GENERAL_FOR_GJS = {
|
|
|
70
70
|
// @gjsify/domparser, so jsdom and its whatwg-url/webidl-conversions
|
|
71
71
|
// deps (which use SharedArrayBuffer — unavailable in GJS) are never needed.
|
|
72
72
|
'jsdom': '@gjsify/empty',
|
|
73
|
+
|
|
74
|
+
// engine.io-client ships both polling-xhr.node.js (uses xmlhttprequest-ssl /
|
|
75
|
+
// Node http.request) and polling-xhr.js (uses globalThis.XMLHttpRequest).
|
|
76
|
+
// The package.json `browser` field maps .node.js → .js for browser builds, but
|
|
77
|
+
// esbuild with platform:neutral does not apply browser-field path maps.
|
|
78
|
+
// We apply them explicitly here: the aliasPlugin matches the relative import
|
|
79
|
+
// specifier exactly (since onResolve args.path = the original import string)
|
|
80
|
+
// and resolves ./polling-xhr.js relative to the importer's directory.
|
|
81
|
+
// @gjsify/fetch provides a proper XMLHttpRequest on globalThis via register/xhr.
|
|
82
|
+
'./polling-xhr.node.js': './polling-xhr.js',
|
|
83
|
+
'./websocket.node.js': './websocket.js',
|
|
84
|
+
'./globals.node.js': './globals.js',
|
|
85
|
+
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
/** Record of Node.js modules (build in or not) and his replacement for Gjs */
|
|
@@ -132,6 +145,25 @@ export const ALIASES_NODE_FOR_GJS = {
|
|
|
132
145
|
|
|
133
146
|
// Third party Node Modules
|
|
134
147
|
'node-fetch': '@gjsify/fetch',
|
|
148
|
+
// `ws` npm package — drop-in CLIENT+SERVER wrapper. The client side
|
|
149
|
+
// delegates to globalThis.WebSocket (Soup.WebsocketConnection via
|
|
150
|
+
// @gjsify/websocket); the server side wraps Soup.Server. Aliasing
|
|
151
|
+
// `ws` here replaces the broken browser-field stub in the upstream
|
|
152
|
+
// package ("ws does not work in the browser") that esbuild's
|
|
153
|
+
// "browser" condition would otherwise load. Consumer code like
|
|
154
|
+
// import ws, { WebSocket, WebSocketServer } from 'ws'
|
|
155
|
+
// resolves to @gjsify/ws unchanged, including the `typeof ws ===
|
|
156
|
+
// 'function'` heuristic used by @thaunknown/simple-websocket and
|
|
157
|
+
// similar transitive users.
|
|
158
|
+
'ws': '@gjsify/ws',
|
|
159
|
+
|
|
160
|
+
// isomorphic-ws's browser.js is literally `module.exports = WebSocket`
|
|
161
|
+
// — just the native class. On GJS that native class is @gjsify/websocket
|
|
162
|
+
// (Soup.WebsocketConnection), so skip the @gjsify/ws ws-API wrapper
|
|
163
|
+
// entirely and route isomorphic-ws directly to @gjsify/websocket.
|
|
164
|
+
// Consumers who do `import WS from 'isomorphic-ws'` get our class
|
|
165
|
+
// unchanged — one less delegation hop than going through @gjsify/ws.
|
|
166
|
+
'isomorphic-ws': '@gjsify/websocket',
|
|
135
167
|
}
|
|
136
168
|
|
|
137
169
|
/** Record of Web modules and his replacement for Gjs */
|
|
@@ -160,8 +192,10 @@ export const ALIASES_WEB_FOR_GJS = {
|
|
|
160
192
|
'dom-events/register/ui-events': '@gjsify/dom-events/register/ui-events',
|
|
161
193
|
'dom-exception/register': '@gjsify/dom-exception/register',
|
|
162
194
|
'eventsource/register': '@gjsify/eventsource/register',
|
|
195
|
+
'websocket/register': '@gjsify/websocket/register',
|
|
163
196
|
'fetch/register': '@gjsify/fetch/register',
|
|
164
197
|
'fetch/register/fetch': '@gjsify/fetch/register/fetch',
|
|
198
|
+
'fetch/register/xhr': '@gjsify/fetch/register/xhr',
|
|
165
199
|
'webcrypto/register': '@gjsify/webcrypto/register',
|
|
166
200
|
'web-streams/register': '@gjsify/web-streams/register',
|
|
167
201
|
'web-streams/register/readable': '@gjsify/web-streams/register/readable',
|
|
@@ -170,9 +204,11 @@ export const ALIASES_WEB_FOR_GJS = {
|
|
|
170
204
|
'web-streams/register/text-streams': '@gjsify/web-streams/register/text-streams',
|
|
171
205
|
'web-streams/register/queuing': '@gjsify/web-streams/register/queuing',
|
|
172
206
|
|
|
173
|
-
// xmlhttprequest
|
|
174
|
-
'xmlhttprequest': '@gjsify/
|
|
175
|
-
'xmlhttprequest/register': '@gjsify/
|
|
207
|
+
// xmlhttprequest (implemented in @gjsify/fetch)
|
|
208
|
+
'xmlhttprequest': '@gjsify/fetch',
|
|
209
|
+
'xmlhttprequest/register': '@gjsify/fetch/register/xhr',
|
|
210
|
+
'@gjsify/xmlhttprequest': '@gjsify/fetch',
|
|
211
|
+
'@gjsify/xmlhttprequest/register': '@gjsify/fetch/register/xhr',
|
|
176
212
|
'domparser': '@gjsify/domparser',
|
|
177
213
|
'domparser/register': '@gjsify/domparser/register',
|
|
178
214
|
|
|
@@ -224,7 +260,11 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
224
260
|
'dom-events': '@gjsify/dom-events/globals',
|
|
225
261
|
'dom-exception': '@gjsify/dom-exception/globals',
|
|
226
262
|
'eventsource': '@gjsify/eventsource/globals',
|
|
227
|
-
'fetch':
|
|
263
|
+
// 'fetch' bare specifier is intentionally not aliased on Node:
|
|
264
|
+
// fetch/Headers/Request/Response/FormData are native globals since Node 18,
|
|
265
|
+
// so specs / app code should read them off globalThis. Users who need the
|
|
266
|
+
// value form should `import { fetch } from '@gjsify/fetch'` explicitly.
|
|
267
|
+
// 'fetch': '@gjsify/fetch/globals',
|
|
228
268
|
'formdata': '@gjsify/formdata/globals',
|
|
229
269
|
'html-image-element': '@gjsify/html-image-element',
|
|
230
270
|
'webcrypto': '@gjsify/webcrypto/globals',
|
|
@@ -241,8 +281,10 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
241
281
|
'dom-events/register/ui-events': '@gjsify/empty',
|
|
242
282
|
'dom-exception/register': '@gjsify/empty',
|
|
243
283
|
'eventsource/register': '@gjsify/empty',
|
|
284
|
+
'websocket/register': '@gjsify/empty',
|
|
244
285
|
'fetch/register': '@gjsify/empty',
|
|
245
286
|
'fetch/register/fetch': '@gjsify/empty',
|
|
287
|
+
'fetch/register/xhr': '@gjsify/empty',
|
|
246
288
|
'webcrypto/register': '@gjsify/empty',
|
|
247
289
|
'web-streams/register': '@gjsify/empty',
|
|
248
290
|
'web-streams/register/readable': '@gjsify/empty',
|
|
@@ -258,8 +300,10 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
258
300
|
'@gjsify/dom-events/register/ui-events': '@gjsify/empty',
|
|
259
301
|
'@gjsify/dom-exception/register': '@gjsify/empty',
|
|
260
302
|
'@gjsify/eventsource/register': '@gjsify/empty',
|
|
303
|
+
'@gjsify/websocket/register': '@gjsify/empty',
|
|
261
304
|
'@gjsify/fetch/register': '@gjsify/empty',
|
|
262
305
|
'@gjsify/fetch/register/fetch': '@gjsify/empty',
|
|
306
|
+
'@gjsify/fetch/register/xhr': '@gjsify/empty',
|
|
263
307
|
'@gjsify/webcrypto/register': '@gjsify/empty',
|
|
264
308
|
'@gjsify/web-streams/register': '@gjsify/empty',
|
|
265
309
|
'@gjsify/web-streams/register/readable': '@gjsify/empty',
|
|
@@ -281,6 +325,7 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
281
325
|
// xmlhttprequest + DOMParser — no-op on Node
|
|
282
326
|
'xmlhttprequest': '@gjsify/empty',
|
|
283
327
|
'xmlhttprequest/register': '@gjsify/empty',
|
|
328
|
+
'@gjsify/xmlhttprequest': '@gjsify/empty',
|
|
284
329
|
'@gjsify/xmlhttprequest/register': '@gjsify/empty',
|
|
285
330
|
'domparser': '@gjsify/empty',
|
|
286
331
|
'domparser/register': '@gjsify/empty',
|