mol_view_tree2_lib 1.0.42 → 1.0.44

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
@@ -4541,9 +4541,11 @@ var $;
4541
4541
  (function ($) {
4542
4542
  class $mol_fetch_response extends $mol_object2 {
4543
4543
  native;
4544
- constructor(native) {
4544
+ request;
4545
+ constructor(native, request) {
4545
4546
  super();
4546
4547
  this.native = native;
4548
+ this.request = request;
4547
4549
  }
4548
4550
  status() {
4549
4551
  const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
@@ -4552,6 +4554,9 @@ var $;
4552
4554
  code() {
4553
4555
  return this.native.status;
4554
4556
  }
4557
+ ok() {
4558
+ return this.native.ok;
4559
+ }
4555
4560
  message() {
4556
4561
  return this.native.statusText || `HTTP Error ${this.code()}`;
4557
4562
  }
@@ -4566,8 +4571,7 @@ var $;
4566
4571
  }
4567
4572
  text() {
4568
4573
  const buffer = this.buffer();
4569
- const native = this.native;
4570
- const mime = native.headers.get('content-type') || '';
4574
+ const mime = this.mime() || '';
4571
4575
  const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
4572
4576
  const decoder = new TextDecoder(charset);
4573
4577
  return decoder.decode(buffer);
@@ -4607,14 +4611,17 @@ var $;
4607
4611
  $mol_action
4608
4612
  ], $mol_fetch_response.prototype, "html", null);
4609
4613
  $.$mol_fetch_response = $mol_fetch_response;
4610
- class $mol_fetch extends $mol_object2 {
4611
- static request(input, init = {}) {
4614
+ class $mol_fetch_request extends $mol_object2 {
4615
+ native;
4616
+ constructor(native) {
4617
+ super();
4618
+ this.native = native;
4619
+ }
4620
+ response_async() {
4612
4621
  const controller = new AbortController();
4613
4622
  let done = false;
4614
- const promise = fetch(input, {
4615
- ...init,
4616
- signal: controller.signal,
4617
- }).finally(() => {
4623
+ const request = new Request(this.native, { signal: controller.signal });
4624
+ const promise = fetch(request).finally(() => {
4618
4625
  done = true;
4619
4626
  });
4620
4627
  return Object.assign(promise, {
@@ -4624,15 +4631,30 @@ var $;
4624
4631
  },
4625
4632
  });
4626
4633
  }
4627
- static response(input, init) {
4628
- return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
4634
+ response() {
4635
+ return new this.$.$mol_fetch_response($mol_wire_sync(this).response_async(), this);
4629
4636
  }
4630
- static success(input, init) {
4631
- const response = this.response(input, init);
4637
+ success() {
4638
+ const response = this.response();
4632
4639
  if (response.status() === 'success')
4633
4640
  return response;
4634
4641
  throw new Error(response.message(), { cause: response });
4635
4642
  }
4643
+ }
4644
+ __decorate([
4645
+ $mol_action
4646
+ ], $mol_fetch_request.prototype, "response", null);
4647
+ $.$mol_fetch_request = $mol_fetch_request;
4648
+ class $mol_fetch extends $mol_object2 {
4649
+ static request(input, init) {
4650
+ return new this.$.$mol_fetch_request(new Request(input, init));
4651
+ }
4652
+ static response(input, init) {
4653
+ return this.request(input, init).response();
4654
+ }
4655
+ static success(input, init) {
4656
+ return this.request(input, init).success();
4657
+ }
4636
4658
  static stream(input, init) {
4637
4659
  return this.success(input, init).stream();
4638
4660
  }
@@ -4660,34 +4682,7 @@ var $;
4660
4682
  }
4661
4683
  __decorate([
4662
4684
  $mol_action
4663
- ], $mol_fetch, "response", null);
4664
- __decorate([
4665
- $mol_action
4666
- ], $mol_fetch, "success", null);
4667
- __decorate([
4668
- $mol_action
4669
- ], $mol_fetch, "stream", null);
4670
- __decorate([
4671
- $mol_action
4672
- ], $mol_fetch, "text", null);
4673
- __decorate([
4674
- $mol_action
4675
- ], $mol_fetch, "json", null);
4676
- __decorate([
4677
- $mol_action
4678
- ], $mol_fetch, "blob", null);
4679
- __decorate([
4680
- $mol_action
4681
- ], $mol_fetch, "buffer", null);
4682
- __decorate([
4683
- $mol_action
4684
- ], $mol_fetch, "xml", null);
4685
- __decorate([
4686
- $mol_action
4687
- ], $mol_fetch, "xhtml", null);
4688
- __decorate([
4689
- $mol_action
4690
- ], $mol_fetch, "html", null);
4685
+ ], $mol_fetch, "request", null);
4691
4686
  $.$mol_fetch = $mol_fetch;
4692
4687
  })($ || ($ = {}));
4693
4688