@gjsify/xmlhttprequest 0.4.28 → 0.4.29

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.
Files changed (2) hide show
  1. package/lib/index.js +7 -11
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -114,10 +114,7 @@ async function readFileUrl(url) {
114
114
  }
115
115
  /** Write bytes to a temp file and return the path. */
116
116
  function writeToTmp(bytes, ext) {
117
- const tmpPath = GLib.build_filenamev([
118
- GLib.get_tmp_dir(),
119
- `gjsify-blob-${_blobCounter++}${ext}`,
120
- ]);
117
+ const tmpPath = GLib.build_filenamev([GLib.get_tmp_dir(), `gjsify-blob-${_blobCounter++}${ext}`]);
121
118
  GLib.file_set_contents(tmpPath, bytes);
122
119
  return tmpPath;
123
120
  }
@@ -183,8 +180,7 @@ export class XMLHttpRequest {
183
180
  if (url.startsWith('file://')) {
184
181
  return readFileUrl(url);
185
182
  }
186
- return fetch(url, { method: this._method })
187
- .then((r) => {
183
+ return fetch(url, { method: this._method }).then((r) => {
188
184
  if (DEBUG)
189
185
  console.log(`[xmlhttprequest] fetch ok ${url} status=${r.status}`);
190
186
  this.status = r.status === 0 ? 200 : r.status;
@@ -198,7 +194,8 @@ export class XMLHttpRequest {
198
194
  // Wrap doFetch() in Promise.resolve().then(...) so synchronous throws
199
195
  // (e.g. new URL('/path') when fetch parses the input) propagate into
200
196
  // the .catch chain instead of escaping send() as an uncaught exception.
201
- Promise.resolve().then(doFetch)
197
+ Promise.resolve()
198
+ .then(doFetch)
202
199
  .then((arrBuf) => {
203
200
  if (this._aborted)
204
201
  return;
@@ -253,7 +250,7 @@ export class XMLHttpRequest {
253
250
  (this._listeners[type] ??= []).push(fn);
254
251
  }
255
252
  removeEventListener(type, fn) {
256
- this._listeners[type] = (this._listeners[type] ?? []).filter(f => f !== fn);
253
+ this._listeners[type] = (this._listeners[type] ?? []).filter((f) => f !== fn);
257
254
  }
258
255
  getResponseHeader(_name) {
259
256
  return null;
@@ -267,7 +264,7 @@ export class XMLHttpRequest {
267
264
  // `onprogress` / `ontimeout` / `onabort` / `onreadystatechange`
268
265
  // properties, but indexing by computed `'on' + type` defeats
269
266
  // structural typing. Cast through a typed view keyed on the union.
270
- const handler = this['on' + type];
267
+ const handler = this[('on' + type)];
271
268
  if (typeof handler === 'function')
272
269
  handler.call(this, { type, ...event });
273
270
  for (const fn of this._listeners[type] ?? [])
@@ -277,8 +274,7 @@ export class XMLHttpRequest {
277
274
  export function installObjectURLSupport() {
278
275
  const urlPatch = URL;
279
276
  // Only install if not already a real implementation
280
- if (typeof urlPatch.createObjectURL !== 'function' ||
281
- urlPatch.__gjsify_objecturl !== true) {
277
+ if (typeof urlPatch.createObjectURL !== 'function' || urlPatch.__gjsify_objecturl !== true) {
282
278
  const _objectURLPaths = new Map();
283
279
  urlPatch.createObjectURL = function (blob) {
284
280
  if (blob._tmpPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/xmlhttprequest",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "description": "XMLHttpRequest and URL.createObjectURL/revokeObjectURL for GJS — backed by @gjsify/fetch and GLib",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -38,10 +38,10 @@
38
38
  "@girs/gio-2.0": "2.88.0-4.0.1",
39
39
  "@girs/gjs": "4.0.1",
40
40
  "@girs/glib-2.0": "2.88.0-4.0.1",
41
- "@gjsify/fetch": "^0.4.28"
41
+ "@gjsify/fetch": "^0.4.29"
42
42
  },
43
43
  "devDependencies": {
44
- "@gjsify/cli": "^0.4.28",
44
+ "@gjsify/cli": "^0.4.29",
45
45
  "@types/node": "^25.9.1",
46
46
  "typescript": "^6.0.3"
47
47
  }