@webqit/fetch-plus 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "homepage": "https://fetch-plus.netlify.app/",
13
13
  "icon": "https://webqit.io/icon.svg",
14
- "version": "0.1.1",
14
+ "version": "0.1.2",
15
15
  "license": "MIT",
16
16
  "repository": {
17
17
  "type": "git",
@@ -35,12 +35,12 @@
35
35
  "@webqit/util": "^0.8.16"
36
36
  },
37
37
  "peerDependencies": {
38
- "@webqit/observer": "^3.8.14",
39
- "@webqit/port-plus": "^0.1.6"
38
+ "@webqit/observer": "^3.8.16",
39
+ "@webqit/port-plus": "^0.1.7"
40
40
  },
41
41
  "devDependencies": {
42
- "@webqit/observer": "^3.8.14",
43
- "@webqit/port-plus": "^0.1.6",
42
+ "@webqit/observer": "^3.8.16",
43
+ "@webqit/port-plus": "^0.1.7",
44
44
  "chai": "^4.3.4",
45
45
  "chai-as-promised": "^7.1.1",
46
46
  "esbuild": "^0.20.2",
@@ -6,7 +6,8 @@ import { dataType, _meta, _wq } from './core.js';
6
6
  export class FormDataPlus extends FormData {
7
7
 
8
8
  static upgradeInPlace(formData) {
9
- Object.setPrototypeOf(formData, FormDataPlus.prototype);
9
+ if (formData instanceof FormDataPlus) return formData;
10
+ return Object.setPrototypeOf(formData, FormDataPlus.prototype);
10
11
  }
11
12
 
12
13
  static json(data = {}, { recursive = true, getIsJsonfiable = false } = {}) {
@@ -5,7 +5,8 @@ import { _after } from '@webqit/util/str/index.js';
5
5
  export class HeadersPlus extends upgradeMixin(Headers) {
6
6
 
7
7
  static upgradeInPlace(headers) {
8
- Object.setPrototypeOf(headers, HeadersPlus.prototype);
8
+ if (headers instanceof HeadersPlus) return headers;
9
+ return Object.setPrototypeOf(headers, HeadersPlus.prototype);
9
10
  }
10
11
 
11
12
  set(name, value) {
@@ -211,7 +211,7 @@ export class LiveResponse extends EventTarget {
211
211
  this.#body = $body;
212
212
 
213
213
  // Must come after all property assignments above because it fires events
214
- Observer.defineProperty(this, 'body', { get: () => this.#body, enumerable: true, configurable: true });
214
+ Observer.defineProperty(this, 'body', { get: () => this.#body, enumerable: false, configurable: true });
215
215
 
216
216
  const readyStateInternals = getReadyStateInternals.call(this);
217
217
  readyStateInternals.live.state = true;
@@ -477,7 +477,7 @@ export function getReadyStateInternals() {
477
477
  const portPlusMeta = _meta(this);
478
478
  if (!portPlusMeta.has('readystate_registry')) {
479
479
  const $ref = (o) => {
480
- o.promise = new Promise((res, rej) => (o.resolve = res, o.reject = rej));
480
+ o.promise = new Promise((res, rej) => (o.resolve = () => res(this), o.reject = rej));
481
481
  return o;
482
482
  };
483
483
  portPlusMeta.set('readystate_registry', {
@@ -9,8 +9,10 @@ export class RequestPlus extends messageParserMixin(Request) {
9
9
  }
10
10
 
11
11
  static upgradeInPlace(request) {
12
+ if (request instanceof RequestPlus) return request;
12
13
  Object.setPrototypeOf(request, RequestPlus.prototype);
13
14
  HeadersPlus.upgradeInPlace(request.headers);
15
+ return request;
14
16
  }
15
17
 
16
18
  static from(url, { memoize = false, ...init } = {}) {
@@ -9,8 +9,10 @@ export class ResponsePlus extends messageParserMixin(Response) {
9
9
  }
10
10
 
11
11
  static upgradeInPlace(response) {
12
+ if (response instanceof ResponsePlus) return response;
12
13
  Object.setPrototypeOf(response, ResponsePlus.prototype);
13
14
  HeadersPlus.upgradeInPlace(response.headers);
15
+ return response;
14
16
  }
15
17
 
16
18
  static from(body, { memoize = false, ...init } = {}) {
package/src/core.js CHANGED
@@ -3,7 +3,7 @@ import { _wq as $wq } from '@webqit/util/js/index.js';
3
3
  import { FormDataPlus } from './FormDataPlus.js';
4
4
 
5
5
  export const _wq = (target, ...args) => $wq(target, 'fetch+', ...args);
6
- export const _meta = (target) => $wq(target, 'fetch+', 'meta');
6
+ export const _meta = (target, ...args) => $wq(target, 'fetch+', 'meta', ...args);
7
7
 
8
8
  export function messageParserMixin(superClass) {
9
9
  return class extends superClass {