mol_dump_lib 0.0.874 → 0.0.876

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/web.js CHANGED
@@ -5978,9 +5978,11 @@ var $;
5978
5978
  (function ($) {
5979
5979
  class $mol_fetch_response extends $mol_object2 {
5980
5980
  native;
5981
- constructor(native) {
5981
+ request;
5982
+ constructor(native, request) {
5982
5983
  super();
5983
5984
  this.native = native;
5985
+ this.request = request;
5984
5986
  }
5985
5987
  status() {
5986
5988
  const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
@@ -5989,6 +5991,9 @@ var $;
5989
5991
  code() {
5990
5992
  return this.native.status;
5991
5993
  }
5994
+ ok() {
5995
+ return this.native.ok;
5996
+ }
5992
5997
  message() {
5993
5998
  return this.native.statusText || `HTTP Error ${this.code()}`;
5994
5999
  }
@@ -6003,8 +6008,7 @@ var $;
6003
6008
  }
6004
6009
  text() {
6005
6010
  const buffer = this.buffer();
6006
- const native = this.native;
6007
- const mime = native.headers.get('content-type') || '';
6011
+ const mime = this.mime() || '';
6008
6012
  const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
6009
6013
  const decoder = new TextDecoder(charset);
6010
6014
  return decoder.decode(buffer);
@@ -6044,14 +6048,17 @@ var $;
6044
6048
  $mol_action
6045
6049
  ], $mol_fetch_response.prototype, "html", null);
6046
6050
  $.$mol_fetch_response = $mol_fetch_response;
6047
- class $mol_fetch extends $mol_object2 {
6048
- static request(input, init = {}) {
6051
+ class $mol_fetch_request extends $mol_object2 {
6052
+ native;
6053
+ constructor(native) {
6054
+ super();
6055
+ this.native = native;
6056
+ }
6057
+ response_async() {
6049
6058
  const controller = new AbortController();
6050
6059
  let done = false;
6051
- const promise = fetch(input, {
6052
- ...init,
6053
- signal: controller.signal,
6054
- }).finally(() => {
6060
+ const request = new Request(this.native, { signal: controller.signal });
6061
+ const promise = fetch(request).finally(() => {
6055
6062
  done = true;
6056
6063
  });
6057
6064
  return Object.assign(promise, {
@@ -6061,15 +6068,30 @@ var $;
6061
6068
  },
6062
6069
  });
6063
6070
  }
6064
- static response(input, init) {
6065
- return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
6071
+ response() {
6072
+ return new this.$.$mol_fetch_response($mol_wire_sync(this).response_async(), this);
6066
6073
  }
6067
- static success(input, init) {
6068
- const response = this.response(input, init);
6074
+ success() {
6075
+ const response = this.response();
6069
6076
  if (response.status() === 'success')
6070
6077
  return response;
6071
6078
  throw new Error(response.message(), { cause: response });
6072
6079
  }
6080
+ }
6081
+ __decorate([
6082
+ $mol_action
6083
+ ], $mol_fetch_request.prototype, "response", null);
6084
+ $.$mol_fetch_request = $mol_fetch_request;
6085
+ class $mol_fetch extends $mol_object2 {
6086
+ static request(input, init) {
6087
+ return new this.$.$mol_fetch_request(new Request(input, init));
6088
+ }
6089
+ static response(input, init) {
6090
+ return this.request(input, init).response();
6091
+ }
6092
+ static success(input, init) {
6093
+ return this.request(input, init).success();
6094
+ }
6073
6095
  static stream(input, init) {
6074
6096
  return this.success(input, init).stream();
6075
6097
  }
@@ -6097,34 +6119,7 @@ var $;
6097
6119
  }
6098
6120
  __decorate([
6099
6121
  $mol_action
6100
- ], $mol_fetch, "response", null);
6101
- __decorate([
6102
- $mol_action
6103
- ], $mol_fetch, "success", null);
6104
- __decorate([
6105
- $mol_action
6106
- ], $mol_fetch, "stream", null);
6107
- __decorate([
6108
- $mol_action
6109
- ], $mol_fetch, "text", null);
6110
- __decorate([
6111
- $mol_action
6112
- ], $mol_fetch, "json", null);
6113
- __decorate([
6114
- $mol_action
6115
- ], $mol_fetch, "blob", null);
6116
- __decorate([
6117
- $mol_action
6118
- ], $mol_fetch, "buffer", null);
6119
- __decorate([
6120
- $mol_action
6121
- ], $mol_fetch, "xml", null);
6122
- __decorate([
6123
- $mol_action
6124
- ], $mol_fetch, "xhtml", null);
6125
- __decorate([
6126
- $mol_action
6127
- ], $mol_fetch, "html", null);
6122
+ ], $mol_fetch, "request", null);
6128
6123
  $.$mol_fetch = $mol_fetch;
6129
6124
  })($ || ($ = {}));
6130
6125