@gjsify/resolve-npm 0.0.4 → 0.1.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/README.md +26 -0
- package/lib/index.mjs +61 -164
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @gjsify/resolve-npm
|
|
2
|
+
|
|
3
|
+
Module resolution utilities for mapping Node.js and Web API modules to their @gjsify/* equivalents.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @gjsify/resolve-npm
|
|
11
|
+
# or
|
|
12
|
+
yarn add @gjsify/resolve-npm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { resolveNpm } from '@gjsify/resolve-npm';
|
|
19
|
+
|
|
20
|
+
// Maps Node.js module names to @gjsify/* packages
|
|
21
|
+
const resolved = resolveNpm('fs'); // '@gjsify/fs'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
package/lib/index.mjs
CHANGED
|
@@ -25,10 +25,7 @@ export const EXTERNALS_NODE = [
|
|
|
25
25
|
'net',
|
|
26
26
|
'os',
|
|
27
27
|
'path',
|
|
28
|
-
'path/common',
|
|
29
|
-
'path/glob',
|
|
30
28
|
'path/posix',
|
|
31
|
-
'path/separator',
|
|
32
29
|
'path/win32',
|
|
33
30
|
'perf_hooks',
|
|
34
31
|
'process',
|
|
@@ -54,6 +51,7 @@ export const EXTERNALS_NODE = [
|
|
|
54
51
|
'v8',
|
|
55
52
|
'vm',
|
|
56
53
|
'wasi',
|
|
54
|
+
'sqlite',
|
|
57
55
|
'worker_threads',
|
|
58
56
|
'zlib',
|
|
59
57
|
]
|
|
@@ -72,96 +70,59 @@ export const ALIASES_NODE_FOR_GJS = {
|
|
|
72
70
|
// Internal Node.js modules
|
|
73
71
|
'assert': '@gjsify/assert',
|
|
74
72
|
'assert/strict': '@gjsify/assert/strict',
|
|
75
|
-
'async_hooks': '@gjsify/
|
|
73
|
+
'async_hooks': '@gjsify/async_hooks',
|
|
76
74
|
'buffer': '@gjsify/buffer',
|
|
77
|
-
'child_process': '@gjsify/
|
|
78
|
-
'cluster': '@gjsify/
|
|
75
|
+
'child_process': '@gjsify/child_process',
|
|
76
|
+
'cluster': '@gjsify/cluster',
|
|
79
77
|
'console': '@gjsify/console',
|
|
80
|
-
'constants': '@gjsify/
|
|
81
|
-
'crypto': '@gjsify/
|
|
82
|
-
'dgram': '@gjsify/
|
|
83
|
-
'diagnostics_channel': '@gjsify/
|
|
84
|
-
'dns': '@gjsify/
|
|
85
|
-
'dns/promises': '@gjsify/
|
|
86
|
-
'domain': '@gjsify/
|
|
78
|
+
'constants': '@gjsify/constants',
|
|
79
|
+
'crypto': '@gjsify/crypto',
|
|
80
|
+
'dgram': '@gjsify/dgram',
|
|
81
|
+
'diagnostics_channel': '@gjsify/diagnostics_channel',
|
|
82
|
+
'dns': '@gjsify/dns',
|
|
83
|
+
'dns/promises': '@gjsify/dns/promises',
|
|
84
|
+
'domain': '@gjsify/domain',
|
|
87
85
|
'events': '@gjsify/events',
|
|
88
86
|
'fs': '@gjsify/fs',
|
|
89
87
|
'fs/promises': '@gjsify/fs/promises',
|
|
90
88
|
'http': '@gjsify/http',
|
|
91
|
-
'http2': '@gjsify/
|
|
92
|
-
'https': '@gjsify/
|
|
93
|
-
'inspector': '@gjsify/
|
|
94
|
-
'module': '@gjsify/
|
|
89
|
+
'http2': '@gjsify/http2',
|
|
90
|
+
'https': '@gjsify/https',
|
|
91
|
+
'inspector': '@gjsify/inspector',
|
|
92
|
+
'module': '@gjsify/module',
|
|
95
93
|
'net': '@gjsify/net',
|
|
96
94
|
'os': '@gjsify/os',
|
|
97
|
-
'path': '@gjsify/
|
|
98
|
-
'path/
|
|
99
|
-
'path/
|
|
100
|
-
'
|
|
101
|
-
'path/separator': '@gjsify/deno_std/node/path/separator', // TODO
|
|
102
|
-
'path/win32': '@gjsify/deno_std/node/path/win32', // TODO
|
|
103
|
-
'perf_hooks': '@gjsify/deno_std/node/perf_hooks', // TODO
|
|
95
|
+
'path': '@gjsify/path',
|
|
96
|
+
'path/posix': '@gjsify/path/posix',
|
|
97
|
+
'path/win32': '@gjsify/path/win32',
|
|
98
|
+
'perf_hooks': '@gjsify/perf_hooks',
|
|
104
99
|
'process': '@gjsify/process',
|
|
105
|
-
'punycode': '@gjsify/
|
|
100
|
+
'punycode': '@gjsify/punycode', // stub — deprecated, low priority
|
|
106
101
|
'querystring': '@gjsify/querystring',
|
|
107
|
-
'readline': '@gjsify/
|
|
108
|
-
'readline/promises': '@gjsify/
|
|
109
|
-
'repl': '@gjsify/
|
|
102
|
+
'readline': '@gjsify/readline',
|
|
103
|
+
'readline/promises': '@gjsify/readline/promises',
|
|
104
|
+
'repl': '@gjsify/repl', // stub — low priority
|
|
110
105
|
'stream': '@gjsify/stream',
|
|
111
106
|
'stream/web': '@gjsify/stream/web',
|
|
112
|
-
'stream/consumers': '@gjsify/stream/consumers',
|
|
113
|
-
'stream/promises': '@gjsify/stream/promises',
|
|
114
|
-
'string_decoder': '@gjsify/
|
|
115
|
-
'sys': '@gjsify/
|
|
116
|
-
// 'test': '@gjsify/
|
|
117
|
-
'timers': '@gjsify/
|
|
118
|
-
'timers/promises': '@gjsify/
|
|
119
|
-
'tls': '@gjsify/
|
|
107
|
+
'stream/consumers': '@gjsify/stream/consumers',
|
|
108
|
+
'stream/promises': '@gjsify/stream/promises',
|
|
109
|
+
'string_decoder': '@gjsify/string_decoder',
|
|
110
|
+
'sys': '@gjsify/sys',
|
|
111
|
+
// 'test': '@gjsify/test', // not planned — use @gjsify/unit instead
|
|
112
|
+
'timers': '@gjsify/timers',
|
|
113
|
+
'timers/promises': '@gjsify/timers/promises',
|
|
114
|
+
'tls': '@gjsify/tls',
|
|
120
115
|
'tty': '@gjsify/tty',
|
|
121
116
|
'url': '@gjsify/url',
|
|
122
117
|
'util': '@gjsify/util',
|
|
123
118
|
'util/types': '@gjsify/util/types',
|
|
124
|
-
'v8': '@gjsify/
|
|
125
|
-
'vm': '@gjsify/
|
|
126
|
-
'wasi': '@gjsify/
|
|
127
|
-
'
|
|
119
|
+
'v8': '@gjsify/v8',
|
|
120
|
+
'vm': '@gjsify/vm',
|
|
121
|
+
'wasi': '@gjsify/wasi', // stub — low priority (WebAssembly System Interface)
|
|
122
|
+
'sqlite': '@gjsify/sqlite',
|
|
123
|
+
'worker_threads': '@gjsify/worker_threads',
|
|
128
124
|
'zlib': '@gjsify/zlib',
|
|
129
125
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// 'cluster': '@gjsify/deno_std/node/cluster',
|
|
133
|
-
// 'domain': '@gjsify/deno_std/node/domain',
|
|
134
|
-
// 'stream': '@gjsify/deno_std/node/stream',
|
|
135
|
-
// 'assertion_error': '@gjsify/deno_std/node/assertion_error',
|
|
136
|
-
// 'console': '@@gjsify/deno_std/nodeconsole',
|
|
137
|
-
// 'module': '@gjsify/deno_std/node/module',
|
|
138
|
-
// 'v8': '@gjsify/deno_std/node/v8',
|
|
139
|
-
// assert: 'assert', // https://github.com/browserify/commonjs-assert
|
|
140
|
-
// constants: 'constants-browserify', // https://github.com/juliangruber/constants-browserify
|
|
141
|
-
// punycode: 'punycode',
|
|
142
|
-
// string_decoder: 'string_decoder', // https://github.com/nodejs/string_decoder
|
|
143
|
-
// 'async_hooks': '@gjsify/deno_std/node/async_hooks',
|
|
144
|
-
// 'sys': '@gjsify/deno_std/node/sys',
|
|
145
|
-
// 'vm': '@gjsify/deno_std/node/vm',
|
|
146
|
-
// 'upstream_modules': '@gjsify/deno_std/node/upstream_modules',
|
|
147
|
-
// 'wasi': '@gjsify/deno_std/node/wasi',
|
|
148
|
-
// crypto: 'crypto-browserify',
|
|
149
|
-
// 'inspector': '@gjsify/deno_std/node/inspector',
|
|
150
|
-
// 'timers': '@gjsify/deno_std/node/timers',
|
|
151
|
-
// 'dgram': '@gjsify/deno_std/node/dgram',
|
|
152
|
-
// path: 'path-browserify',
|
|
153
|
-
// 'readline': '@gjsify/deno_std/node/readline',
|
|
154
|
-
// 'worker_threads': '@gjsify/deno_std/node/worker_threads',
|
|
155
|
-
// 'diagnostics_channel': '@gjsify/deno_std/node/diagnostics_channel',
|
|
156
|
-
// 'http2': '@gjsify/deno_std/node/http2',
|
|
157
|
-
// 'module_all': '@gjsify/deno_std/node/module_all',
|
|
158
|
-
// 'repl': '@gjsify/deno_std/node/repl',
|
|
159
|
-
// 'child_process': '@gjsify/deno_std/node/child_process',
|
|
160
|
-
// 'dns': '@gjsify/deno_std/node/dns',
|
|
161
|
-
// 'module_esm': '@gjsify/deno_std/node/module_esm',
|
|
162
|
-
// 'perf_hooks': '@gjsify/deno_std/node/perf_hooks',
|
|
163
|
-
// 'tls': '@gjsify/deno_std/node/tls',
|
|
164
|
-
|
|
165
126
|
// Third party Node Modules
|
|
166
127
|
'node-fetch': '@gjsify/fetch',
|
|
167
128
|
}
|
|
@@ -169,106 +130,42 @@ export const ALIASES_NODE_FOR_GJS = {
|
|
|
169
130
|
/** Record of Web modules and his replacement for Gjs */
|
|
170
131
|
export const ALIASES_WEB_FOR_GJS = {
|
|
171
132
|
'abort-controller': '@gjsify/abort-controller',
|
|
133
|
+
'compression-streams': '@gjsify/compression-streams',
|
|
134
|
+
'dom-events': '@gjsify/dom-events',
|
|
135
|
+
'dom-exception': '@gjsify/dom-exception',
|
|
172
136
|
'event-target-shim': '@gjsify/dom-events',
|
|
137
|
+
'eventsource': '@gjsify/eventsource',
|
|
138
|
+
'fetch': '@gjsify/fetch',
|
|
139
|
+
'formdata': '@gjsify/formdata',
|
|
140
|
+
'html-image-element': '@gjsify/html-image-element',
|
|
141
|
+
'webcrypto': '@gjsify/webcrypto',
|
|
142
|
+
'webgl': '@gjsify/webgl',
|
|
143
|
+
'websocket': '@gjsify/websocket',
|
|
144
|
+
'webstorage': '@gjsify/webstorage',
|
|
173
145
|
}
|
|
174
146
|
|
|
175
|
-
/** General record of modules for Deno */
|
|
176
|
-
export const ALIASES_GENERAL_FOR_DENO = {
|
|
177
|
-
'@gjsify/deno-runtime/globals': '@gjsify/empty',
|
|
178
|
-
'@gjsify/deno-globals': '@gjsify/empty',
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** Record of Node.js modules (build in or not) and his replacement for Deno */
|
|
182
|
-
export const ALIASES_NODE_FOR_DENO = {
|
|
183
|
-
// Node packages
|
|
184
|
-
// TODO std@0.177.0 is the latest version that has the node directory
|
|
185
|
-
'assert': 'https://deno.land/std@0.177.0/node/assert.ts',
|
|
186
|
-
'assert/strict': 'https://deno.land/std@0.177.0/node/assert/strict.ts',
|
|
187
|
-
'async_hooks': 'https://deno.land/std@0.177.0/node/async_hooks.ts',
|
|
188
|
-
'buffer': 'https://deno.land/std@0.177.0/node/buffer.ts',
|
|
189
|
-
'child_process': 'https://deno.land/std@0.177.0/node/child_process.ts',
|
|
190
|
-
'cluster': 'https://deno.land/std@0.177.0/node/cluster.ts',
|
|
191
|
-
'console': 'https://deno.land/std@0.177.0/node/console.ts',
|
|
192
|
-
'constants': 'https://deno.land/std@0.177.0/node/constants.ts',
|
|
193
|
-
'crypto': 'https://deno.land/std@0.177.0/node/crypto.ts',
|
|
194
|
-
'dgram': 'https://deno.land/std@0.177.0/node/dgram.ts',
|
|
195
|
-
'diagnostics_channel': 'https://deno.land/std@0.177.0/node/diagnostics_channel.ts',
|
|
196
|
-
'dns': 'https://deno.land/std@0.177.0/node/dns.ts',
|
|
197
|
-
'dns/promises': 'https://deno.land/std@0.177.0/node/dns/promises.ts',
|
|
198
|
-
'domain': 'https://deno.land/std@0.177.0/node/domain.ts',
|
|
199
|
-
'events': 'https://deno.land/std@0.177.0/node/events.ts',
|
|
200
|
-
'fs': 'https://deno.land/std@0.177.0/node/fs.ts',
|
|
201
|
-
'fs/promises': 'https://deno.land/std@0.177.0/node/fs/promises.ts',
|
|
202
|
-
'http': 'https://deno.land/std@0.177.0/node/http.ts',
|
|
203
|
-
'http2': 'https://deno.land/std@0.177.0/node/http2.ts',
|
|
204
|
-
'https': 'https://deno.land/std@0.177.0/node/https.ts',
|
|
205
|
-
'inspector': 'https://deno.land/std@0.177.0/node/inspector.ts',
|
|
206
|
-
'module': 'https://deno.land/std@0.177.0/node/module.ts',
|
|
207
|
-
'net': 'https://deno.land/std@0.177.0/node/net.ts',
|
|
208
|
-
'os': 'https://deno.land/std@0.177.0/node/os.ts',
|
|
209
|
-
'path': 'https://deno.land/std@0.177.0/node/path.ts',
|
|
210
|
-
'path/common': 'https://deno.land/std@0.177.0/node/path/common.ts',
|
|
211
|
-
'path/glob': 'https://deno.land/std@0.177.0/node/path/glob.ts',
|
|
212
|
-
'path/posix': 'https://deno.land/std@0.177.0/node/path/posix.ts',
|
|
213
|
-
'path/separator': 'https://deno.land/std@0.177.0/node/path/separator.ts',
|
|
214
|
-
'path/win32': 'https://deno.land/std@0.177.0/node/path/win32.ts',
|
|
215
|
-
'perf_hooks': 'https://deno.land/std@0.177.0/node/perf_hooks.ts',
|
|
216
|
-
'process': 'https://deno.land/std@0.177.0/node/process.ts',
|
|
217
|
-
'punycode': 'https://deno.land/std@0.177.0/node/punycode.ts',
|
|
218
|
-
'querystring': 'https://deno.land/std@0.177.0/node/querystring.ts',
|
|
219
|
-
'readline': 'https://deno.land/std@0.177.0/node/readline.ts',
|
|
220
|
-
'readline/promises': 'https://deno.land/std@0.177.0/node/readline/promises.ts',
|
|
221
|
-
'repl': 'https://deno.land/std@0.177.0/node/repl.ts',
|
|
222
|
-
'stream': 'https://deno.land/std@0.177.0/node/stream.ts',
|
|
223
|
-
'stream/web': 'https://deno.land/std@0.177.0/node/stream/web.ts',
|
|
224
|
-
'stream/consumers': 'https://deno.land/std@0.177.0/node/stream/consumers.mjs',
|
|
225
|
-
'stream/promises': 'https://deno.land/std@0.177.0/node/stream/promises.mjs',
|
|
226
|
-
'string_decoder': 'https://deno.land/std@0.177.0/node/string_decoder.ts',
|
|
227
|
-
'sys': 'https://deno.land/std@0.177.0/node/sys.ts',
|
|
228
|
-
// 'test': 'https://deno.land/std@0.177.0/node/test.ts',
|
|
229
|
-
'timers': 'https://deno.land/std@0.177.0/node/timers.ts',
|
|
230
|
-
'timers/promises': 'https://deno.land/std@0.177.0/node/timers/promises.ts',
|
|
231
|
-
'tls': 'https://deno.land/std@0.177.0/node/tls.ts',
|
|
232
|
-
'tty': 'https://deno.land/std@0.177.0/node/tty.ts',
|
|
233
|
-
'url': 'https://deno.land/std@0.177.0/node/url.ts',
|
|
234
|
-
'util': 'https://deno.land/std@0.177.0/node/util.ts',
|
|
235
|
-
'util/types': 'https://deno.land/std@0.177.0/node/util/types.ts',
|
|
236
|
-
'v8': 'https://deno.land/std@0.177.0/node/v8.ts',
|
|
237
|
-
'vm': 'https://deno.land/std@0.177.0/node/vm.ts',
|
|
238
|
-
'wasi': 'https://deno.land/std@0.177.0/node/wasi.ts',
|
|
239
|
-
'worker_threads': 'https://deno.land/std@0.177.0/node/worker_threads.ts',
|
|
240
|
-
'zlib': 'https://deno.land/std@0.177.0/node/zlib.ts',
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/** Record of Gjs modules (build in or not) and his replacement for Deno */
|
|
244
|
-
export const ALIASES_GJS_FOR_DENO = {
|
|
245
|
-
'@gjsify/node-globals': 'https://deno.land/std@0.177.0/node/global.ts',
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/** Record of Web modules and his replacement for Deno */
|
|
249
|
-
export const ALIASES_WEB_FOR_DENO = {}
|
|
250
|
-
|
|
251
|
-
|
|
252
147
|
/** General record of modules for Node */
|
|
253
148
|
export const ALIASES_GENERAL_FOR_NODE = {
|
|
254
149
|
'@gjsify/node-globals': '@gjsify/empty',
|
|
255
|
-
'@gjsify/require': '@gjsify/empty',
|
|
256
|
-
|
|
257
|
-
// TODO we need a real replacement for this in the future
|
|
258
|
-
'@gjsify/deno-runtime/globals': '@gjsify/empty',
|
|
259
|
-
'@gjsify/deno-globals': '@gjsify/empty',
|
|
260
150
|
}
|
|
261
151
|
|
|
262
152
|
/** Record of Gjs modules (build in or not) and his replacement for Node */
|
|
263
153
|
const ALIASES_GJS_FOR_NODE = {}
|
|
264
154
|
|
|
265
|
-
// Revert the alias
|
|
266
|
-
for (const ALIAS_NODE_FOR_GJS in ALIASES_NODE_FOR_GJS) {
|
|
267
|
-
ALIASES_GJS_FOR_NODE[ALIASES_NODE_FOR_GJS[ALIAS_NODE_FOR_GJS]] = ALIAS_NODE_FOR_GJS
|
|
268
|
-
}
|
|
269
|
-
|
|
270
155
|
export { ALIASES_GJS_FOR_NODE };
|
|
271
156
|
|
|
272
157
|
/** Record of Web modules and his replacement for Node */
|
|
273
|
-
export const ALIASES_WEB_FOR_NODE = {
|
|
274
|
-
|
|
158
|
+
export const ALIASES_WEB_FOR_NODE = {
|
|
159
|
+
'abort-controller': '@gjsify/abort-controller/globals',
|
|
160
|
+
'compression-streams': '@gjsify/compression-streams/globals',
|
|
161
|
+
'dom-events': '@gjsify/dom-events/globals',
|
|
162
|
+
'dom-exception': '@gjsify/dom-exception/globals',
|
|
163
|
+
'eventsource': '@gjsify/eventsource/globals',
|
|
164
|
+
'fetch': '@gjsify/fetch/globals',
|
|
165
|
+
'formdata': '@gjsify/formdata/globals',
|
|
166
|
+
'html-image-element': '@gjsify/html-image-element',
|
|
167
|
+
'webcrypto': '@gjsify/webcrypto/globals',
|
|
168
|
+
'webgl': '@gjsify/webgl',
|
|
169
|
+
'websocket': '@gjsify/websocket/globals',
|
|
170
|
+
'webstorage': '@gjsify/webstorage',
|
|
171
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/resolve-npm",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Resolve NPM package aliases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"clear": "echo 'nothing to do'",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"build": "
|
|
11
|
+
"check": "true",
|
|
12
|
+
"test": "echo 'nothing to do'",
|
|
13
|
+
"build": "echo 'nothing to do'"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"gjs",
|