@gjsify/fetch 0.36.0 → 0.38.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/utils/root-relative.d.ts +11 -17
- package/lib/utils/root-relative.js +21 -35
- package/package.json +8 -8
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Rewrite a root-relative URL (starts with `/` but not
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Rewrite a root-relative URL (starts with `/` but not `//`) to a `file://` URL under the
|
|
3
|
+
* program path's directory, so a GJS/GTK app loads bundled assets with the same paths a
|
|
4
|
+
* browser resolves against its origin. Returns the input unchanged when it is not
|
|
5
|
+
* root-relative or no usable program path is given.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* acceptable for the current use cases — revisit if these packages ever handle
|
|
10
|
-
* untrusted input.
|
|
7
|
+
* The security implications (arbitrary file reads) are acceptable for the current use
|
|
8
|
+
* cases — revisit if these packages ever handle untrusted input.
|
|
11
9
|
*
|
|
12
|
-
* Deliberately no `GLib.path_get_dirname`: `@girs/glib-2.0` is emptied to `{}`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* program path is `/`-separated on every runtime this rewrite serves, making
|
|
16
|
-
* dirname a string slice.
|
|
10
|
+
* Deliberately no `GLib.path_get_dirname`: `@girs/glib-2.0` is emptied to `{}` in a
|
|
11
|
+
* plain-Node bundle, so a GLib call here only ever "worked" behind a swallowing catch. The
|
|
12
|
+
* program path is `/`-separated on every runtime this serves, making dirname a slice.
|
|
17
13
|
*
|
|
18
|
-
* @param
|
|
19
|
-
*
|
|
20
|
-
* System.programInvocationName` on gjs; `process.argv[1]` — the bundle
|
|
21
|
-
* itself — on the node-gi reverse bridge).
|
|
14
|
+
* @param programPath `System.programPath ?? System.programInvocationName` on gjs;
|
|
15
|
+
* `process.argv[1]` — the bundle itself — on the node-gi reverse bridge.
|
|
22
16
|
*/
|
|
23
17
|
export declare function rewriteRootRelativeUrl(url: string, programPath: string): string;
|
|
@@ -1,43 +1,29 @@
|
|
|
1
|
-
// Root-relative URL → `file://` under the program directory.
|
|
1
|
+
// Root-relative URL → `file://` under the program directory. THE one copy: `@gjsify/fetch`
|
|
2
|
+
// and `@gjsify/xmlhttprequest` used to carry two spellings, and they drifted — the fetch
|
|
3
|
+
// copy read `globalThis.imports.system` (GJS-only) while the XHR copy imported the `system`
|
|
4
|
+
// built-in, so on the node-gi reverse bridge XHR-loaded assets resolved and every
|
|
5
|
+
// root-relative `fetch()` died with `ERR_INVALID_URL` (#869).
|
|
2
6
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// with `ERR_INVALID_URL` (#869 — the excalibur-jelly-jumper showcase rendered an
|
|
9
|
-
// empty level because its Tiled map is the one asset fetched rather than XHR'd).
|
|
10
|
-
//
|
|
11
|
-
// This module is deliberately PURE — the program path is a PARAMETER, and the
|
|
12
|
-
// `system` built-in is read one module over (`root-relative-system.ts`). The
|
|
13
|
-
// split is load-bearing for cross-platform loadability: on `--app node` the
|
|
14
|
-
// bare `system` specifier is aliased to `@gjsify/node-gi/system` and kept
|
|
15
|
-
// EXTERNAL, so any module that imports it makes the emitted bundle hard-require
|
|
16
|
-
// the node-gi bridge at load. `@gjsify/fetch` is a cross-platform package whose
|
|
17
|
-
// node test bundle must load on plain Node — its spec therefore covers THIS
|
|
18
|
-
// pure function on gjs AND node, while the `system` read stays confined to the
|
|
19
|
-
// GJS-reachable wrapper.
|
|
7
|
+
// Deliberately PURE — the program path is a PARAMETER and the `system` built-in is read one
|
|
8
|
+
// module over (`root-relative-system.ts`). The split is load-bearing: on `--app node` the
|
|
9
|
+
// bare `system` specifier is aliased to `@gjsify/node-gi/system` and kept EXTERNAL, so any
|
|
10
|
+
// module importing it makes the bundle hard-require the bridge at load, and this package's
|
|
11
|
+
// node test bundle must load on plain Node.
|
|
20
12
|
/**
|
|
21
|
-
* Rewrite a root-relative URL (starts with `/` but not
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
13
|
+
* Rewrite a root-relative URL (starts with `/` but not `//`) to a `file://` URL under the
|
|
14
|
+
* program path's directory, so a GJS/GTK app loads bundled assets with the same paths a
|
|
15
|
+
* browser resolves against its origin. Returns the input unchanged when it is not
|
|
16
|
+
* root-relative or no usable program path is given.
|
|
25
17
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* acceptable for the current use cases — revisit if these packages ever handle
|
|
29
|
-
* untrusted input.
|
|
18
|
+
* The security implications (arbitrary file reads) are acceptable for the current use
|
|
19
|
+
* cases — revisit if these packages ever handle untrusted input.
|
|
30
20
|
*
|
|
31
|
-
* Deliberately no `GLib.path_get_dirname`: `@girs/glib-2.0` is emptied to `{}`
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* program path is `/`-separated on every runtime this rewrite serves, making
|
|
35
|
-
* dirname a string slice.
|
|
21
|
+
* Deliberately no `GLib.path_get_dirname`: `@girs/glib-2.0` is emptied to `{}` in a
|
|
22
|
+
* plain-Node bundle, so a GLib call here only ever "worked" behind a swallowing catch. The
|
|
23
|
+
* program path is `/`-separated on every runtime this serves, making dirname a slice.
|
|
36
24
|
*
|
|
37
|
-
* @param
|
|
38
|
-
*
|
|
39
|
-
* System.programInvocationName` on gjs; `process.argv[1]` — the bundle
|
|
40
|
-
* itself — on the node-gi reverse bridge).
|
|
25
|
+
* @param programPath `System.programPath ?? System.programInvocationName` on gjs;
|
|
26
|
+
* `process.argv[1]` — the bundle itself — on the node-gi reverse bridge.
|
|
41
27
|
*/
|
|
42
28
|
export function rewriteRootRelativeUrl(url, programPath) {
|
|
43
29
|
if (!url.startsWith('/') || url.startsWith('//'))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Web and Node.js fetch module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"fetch"
|
|
52
52
|
],
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@gjsify/cli": "^0.
|
|
55
|
-
"@gjsify/unit": "^0.
|
|
54
|
+
"@gjsify/cli": "^0.38.0",
|
|
55
|
+
"@gjsify/unit": "^0.38.0",
|
|
56
56
|
"@types/node": "^25.9.2",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
},
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"@girs/gjs": "^4.1.0",
|
|
62
62
|
"@girs/glib-2.0": "^4.1.0",
|
|
63
63
|
"@girs/soup-3.0": "^4.1.0",
|
|
64
|
-
"@gjsify/dom-events": "^0.
|
|
65
|
-
"@gjsify/formdata": "^0.
|
|
66
|
-
"@gjsify/http": "^0.
|
|
67
|
-
"@gjsify/url": "^0.
|
|
68
|
-
"@gjsify/utils": "^0.
|
|
64
|
+
"@gjsify/dom-events": "^0.38.0",
|
|
65
|
+
"@gjsify/formdata": "^0.38.0",
|
|
66
|
+
"@gjsify/http": "^0.38.0",
|
|
67
|
+
"@gjsify/url": "^0.38.0",
|
|
68
|
+
"@gjsify/utils": "^0.38.0"
|
|
69
69
|
},
|
|
70
70
|
"gjsify": {
|
|
71
71
|
"runtimes": {
|