@gjsify/resolve-npm 0.1.13 → 0.2.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 +40 -2
- package/lib/index.mjs +74 -4
- package/package.json +1 -1
package/lib/globals-map.mjs
CHANGED
|
@@ -45,12 +45,19 @@ 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',
|
|
56
|
+
'MediaDevices',
|
|
57
|
+
'RTCPeerConnection', 'RTCSessionDescription', 'RTCIceCandidate',
|
|
58
|
+
'RTCPeerConnectionIceEvent', 'RTCDataChannel', 'RTCDataChannelEvent',
|
|
59
|
+
'RTCError', 'RTCErrorEvent',
|
|
60
|
+
'MediaStream', 'MediaStreamTrack', 'RTCTrackEvent',
|
|
54
61
|
],
|
|
55
62
|
dom: [
|
|
56
63
|
'document', 'Image', 'HTMLCanvasElement', 'HTMLImageElement',
|
|
@@ -63,6 +70,16 @@ export const GJS_GLOBALS_MAP = {
|
|
|
63
70
|
// --- Node.js globals (granular register subpaths) ----------------------
|
|
64
71
|
Buffer: '@gjsify/node-globals/register/buffer',
|
|
65
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',
|
|
66
83
|
setImmediate: '@gjsify/node-globals/register/timers',
|
|
67
84
|
clearImmediate: '@gjsify/node-globals/register/timers',
|
|
68
85
|
queueMicrotask: '@gjsify/node-globals/register/microtask',
|
|
@@ -121,6 +138,12 @@ export const GJS_GLOBALS_MAP = {
|
|
|
121
138
|
FocusEvent: 'dom-events/register/ui-events',
|
|
122
139
|
EventSource: 'eventsource/register',
|
|
123
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
|
+
|
|
124
147
|
// --- Performance -------------------------------------------------------
|
|
125
148
|
performance: '@gjsify/web-globals/register/performance',
|
|
126
149
|
PerformanceObserver: '@gjsify/web-globals/register/performance',
|
|
@@ -128,8 +151,9 @@ export const GJS_GLOBALS_MAP = {
|
|
|
128
151
|
// --- DOMException ------------------------------------------------------
|
|
129
152
|
DOMException: 'dom-exception/register',
|
|
130
153
|
|
|
131
|
-
// --- XMLHttpRequest
|
|
132
|
-
XMLHttpRequest: '
|
|
154
|
+
// --- XMLHttpRequest (implemented in @gjsify/fetch) ---------------------
|
|
155
|
+
XMLHttpRequest: 'fetch/register/xhr',
|
|
156
|
+
XMLHttpRequestUpload: 'fetch/register/xhr',
|
|
133
157
|
|
|
134
158
|
// --- DOMParser ---------------------------------------------------------
|
|
135
159
|
DOMParser: '@gjsify/domparser/register',
|
|
@@ -143,6 +167,20 @@ export const GJS_GLOBALS_MAP = {
|
|
|
143
167
|
// --- Gamepad API (libmanette backend) -----------------------------------
|
|
144
168
|
GamepadEvent: '@gjsify/gamepad/register',
|
|
145
169
|
|
|
170
|
+
// --- WebRTC (GStreamer webrtcbin backend) -------------------------------
|
|
171
|
+
MediaDevices: '@gjsify/webrtc/register/media-devices',
|
|
172
|
+
RTCPeerConnection: '@gjsify/webrtc/register/peer-connection',
|
|
173
|
+
RTCSessionDescription: '@gjsify/webrtc/register/peer-connection',
|
|
174
|
+
RTCIceCandidate: '@gjsify/webrtc/register/peer-connection',
|
|
175
|
+
RTCPeerConnectionIceEvent: '@gjsify/webrtc/register/peer-connection',
|
|
176
|
+
RTCDataChannel: '@gjsify/webrtc/register/data-channel',
|
|
177
|
+
RTCDataChannelEvent: '@gjsify/webrtc/register/data-channel',
|
|
178
|
+
RTCError: '@gjsify/webrtc/register/error',
|
|
179
|
+
RTCErrorEvent: '@gjsify/webrtc/register/error',
|
|
180
|
+
MediaStream: '@gjsify/webrtc/register/media',
|
|
181
|
+
MediaStreamTrack: '@gjsify/webrtc/register/media',
|
|
182
|
+
RTCTrackEvent: '@gjsify/webrtc/register/media',
|
|
183
|
+
|
|
146
184
|
// --- DOM elements (granular register subpaths) -------------------------
|
|
147
185
|
document: '@gjsify/dom-elements/register/document',
|
|
148
186
|
Image: '@gjsify/dom-elements/register/image',
|
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
|
|
|
@@ -183,6 +219,15 @@ export const ALIASES_WEB_FOR_GJS = {
|
|
|
183
219
|
// Gamepad API (libmanette backend)
|
|
184
220
|
'gamepad': '@gjsify/gamepad',
|
|
185
221
|
'gamepad/register': '@gjsify/gamepad/register',
|
|
222
|
+
|
|
223
|
+
// WebRTC API (GStreamer webrtcbin backend)
|
|
224
|
+
'webrtc': '@gjsify/webrtc',
|
|
225
|
+
'webrtc/register': '@gjsify/webrtc/register',
|
|
226
|
+
'webrtc/register/peer-connection': '@gjsify/webrtc/register/peer-connection',
|
|
227
|
+
'webrtc/register/data-channel': '@gjsify/webrtc/register/data-channel',
|
|
228
|
+
'webrtc/register/error': '@gjsify/webrtc/register/error',
|
|
229
|
+
'webrtc/register/media': '@gjsify/webrtc/register/media',
|
|
230
|
+
'webrtc/register/media-devices': '@gjsify/webrtc/register/media-devices',
|
|
186
231
|
}
|
|
187
232
|
|
|
188
233
|
/** General record of modules for Node */
|
|
@@ -215,7 +260,11 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
215
260
|
'dom-events': '@gjsify/dom-events/globals',
|
|
216
261
|
'dom-exception': '@gjsify/dom-exception/globals',
|
|
217
262
|
'eventsource': '@gjsify/eventsource/globals',
|
|
218
|
-
'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',
|
|
219
268
|
'formdata': '@gjsify/formdata/globals',
|
|
220
269
|
'html-image-element': '@gjsify/html-image-element',
|
|
221
270
|
'webcrypto': '@gjsify/webcrypto/globals',
|
|
@@ -232,8 +281,10 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
232
281
|
'dom-events/register/ui-events': '@gjsify/empty',
|
|
233
282
|
'dom-exception/register': '@gjsify/empty',
|
|
234
283
|
'eventsource/register': '@gjsify/empty',
|
|
284
|
+
'websocket/register': '@gjsify/empty',
|
|
235
285
|
'fetch/register': '@gjsify/empty',
|
|
236
286
|
'fetch/register/fetch': '@gjsify/empty',
|
|
287
|
+
'fetch/register/xhr': '@gjsify/empty',
|
|
237
288
|
'webcrypto/register': '@gjsify/empty',
|
|
238
289
|
'web-streams/register': '@gjsify/empty',
|
|
239
290
|
'web-streams/register/readable': '@gjsify/empty',
|
|
@@ -249,8 +300,10 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
249
300
|
'@gjsify/dom-events/register/ui-events': '@gjsify/empty',
|
|
250
301
|
'@gjsify/dom-exception/register': '@gjsify/empty',
|
|
251
302
|
'@gjsify/eventsource/register': '@gjsify/empty',
|
|
303
|
+
'@gjsify/websocket/register': '@gjsify/empty',
|
|
252
304
|
'@gjsify/fetch/register': '@gjsify/empty',
|
|
253
305
|
'@gjsify/fetch/register/fetch': '@gjsify/empty',
|
|
306
|
+
'@gjsify/fetch/register/xhr': '@gjsify/empty',
|
|
254
307
|
'@gjsify/webcrypto/register': '@gjsify/empty',
|
|
255
308
|
'@gjsify/web-streams/register': '@gjsify/empty',
|
|
256
309
|
'@gjsify/web-streams/register/readable': '@gjsify/empty',
|
|
@@ -272,6 +325,7 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
272
325
|
// xmlhttprequest + DOMParser — no-op on Node
|
|
273
326
|
'xmlhttprequest': '@gjsify/empty',
|
|
274
327
|
'xmlhttprequest/register': '@gjsify/empty',
|
|
328
|
+
'@gjsify/xmlhttprequest': '@gjsify/empty',
|
|
275
329
|
'@gjsify/xmlhttprequest/register': '@gjsify/empty',
|
|
276
330
|
'domparser': '@gjsify/empty',
|
|
277
331
|
'domparser/register': '@gjsify/empty',
|
|
@@ -286,4 +340,20 @@ export const ALIASES_WEB_FOR_NODE = {
|
|
|
286
340
|
'gamepad': '@gjsify/empty',
|
|
287
341
|
'gamepad/register': '@gjsify/empty',
|
|
288
342
|
'@gjsify/gamepad/register': '@gjsify/empty',
|
|
343
|
+
|
|
344
|
+
// WebRTC API — no-op on Node (Phase 1 is GStreamer-only, no fallback)
|
|
345
|
+
'webrtc': '@gjsify/empty',
|
|
346
|
+
'webrtc/register': '@gjsify/empty',
|
|
347
|
+
'webrtc/register/peer-connection': '@gjsify/empty',
|
|
348
|
+
'webrtc/register/data-channel': '@gjsify/empty',
|
|
349
|
+
'webrtc/register/error': '@gjsify/empty',
|
|
350
|
+
'webrtc/register/media': '@gjsify/empty',
|
|
351
|
+
'webrtc/register/media-devices': '@gjsify/empty',
|
|
352
|
+
'@gjsify/webrtc': '@gjsify/empty',
|
|
353
|
+
'@gjsify/webrtc/register': '@gjsify/empty',
|
|
354
|
+
'@gjsify/webrtc/register/peer-connection': '@gjsify/empty',
|
|
355
|
+
'@gjsify/webrtc/register/data-channel': '@gjsify/empty',
|
|
356
|
+
'@gjsify/webrtc/register/error': '@gjsify/empty',
|
|
357
|
+
'@gjsify/webrtc/register/media': '@gjsify/empty',
|
|
358
|
+
'@gjsify/webrtc/register/media-devices': '@gjsify/empty',
|
|
289
359
|
}
|