mol_view_tree2_lib 1.0.43 → 1.0.45

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.mjs CHANGED
@@ -4539,12 +4539,9 @@ var $;
4539
4539
  "use strict";
4540
4540
  var $;
4541
4541
  (function ($) {
4542
- class $mol_fetch_response extends $mol_object2 {
4542
+ class $mol_fetch_response extends $mol_object {
4543
4543
  native;
4544
- constructor(native) {
4545
- super();
4546
- this.native = native;
4547
- }
4544
+ request;
4548
4545
  status() {
4549
4546
  const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
4550
4547
  return types[Math.floor(this.native.status / 100)];
@@ -4552,6 +4549,9 @@ var $;
4552
4549
  code() {
4553
4550
  return this.native.status;
4554
4551
  }
4552
+ ok() {
4553
+ return this.native.ok;
4554
+ }
4555
4555
  message() {
4556
4556
  return this.native.statusText || `HTTP Error ${this.code()}`;
4557
4557
  }
@@ -4566,8 +4566,7 @@ var $;
4566
4566
  }
4567
4567
  text() {
4568
4568
  const buffer = this.buffer();
4569
- const native = this.native;
4570
- const mime = native.headers.get('content-type') || '';
4569
+ const mime = this.mime() || '';
4571
4570
  const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
4572
4571
  const decoder = new TextDecoder(charset);
4573
4572
  return decoder.decode(buffer);
@@ -4607,14 +4606,13 @@ var $;
4607
4606
  $mol_action
4608
4607
  ], $mol_fetch_response.prototype, "html", null);
4609
4608
  $.$mol_fetch_response = $mol_fetch_response;
4610
- class $mol_fetch extends $mol_object2 {
4611
- static request(input, init = {}) {
4609
+ class $mol_fetch_request extends $mol_object {
4610
+ native;
4611
+ response_async() {
4612
4612
  const controller = new AbortController();
4613
4613
  let done = false;
4614
- const promise = fetch(input, {
4615
- ...init,
4616
- signal: controller.signal,
4617
- }).finally(() => {
4614
+ const request = new Request(this.native, { signal: controller.signal });
4615
+ const promise = fetch(request).finally(() => {
4618
4616
  done = true;
4619
4617
  });
4620
4618
  return Object.assign(promise, {
@@ -4624,15 +4622,35 @@ var $;
4624
4622
  },
4625
4623
  });
4626
4624
  }
4627
- static response(input, init) {
4628
- return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
4625
+ response() {
4626
+ return this.$.$mol_fetch_response.make({
4627
+ native: $mol_wire_sync(this).response_async(),
4628
+ request: this
4629
+ });
4629
4630
  }
4630
- static success(input, init) {
4631
- const response = this.response(input, init);
4631
+ success() {
4632
+ const response = this.response();
4632
4633
  if (response.status() === 'success')
4633
4634
  return response;
4634
4635
  throw new Error(response.message(), { cause: response });
4635
4636
  }
4637
+ }
4638
+ __decorate([
4639
+ $mol_action
4640
+ ], $mol_fetch_request.prototype, "response", null);
4641
+ $.$mol_fetch_request = $mol_fetch_request;
4642
+ class $mol_fetch extends $mol_object {
4643
+ static request(input, init) {
4644
+ return this.$.$mol_fetch_request.make({
4645
+ native: new Request(input, init)
4646
+ });
4647
+ }
4648
+ static response(input, init) {
4649
+ return this.request(input, init).response();
4650
+ }
4651
+ static success(input, init) {
4652
+ return this.request(input, init).success();
4653
+ }
4636
4654
  static stream(input, init) {
4637
4655
  return this.success(input, init).stream();
4638
4656
  }
@@ -4660,34 +4678,7 @@ var $;
4660
4678
  }
4661
4679
  __decorate([
4662
4680
  $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);
4681
+ ], $mol_fetch, "request", null);
4691
4682
  $.$mol_fetch = $mol_fetch;
4692
4683
  })($ || ($ = {}));
4693
4684
 
package/web.test.js CHANGED
@@ -6012,6 +6012,20 @@ var $;
6012
6012
  });
6013
6013
  })($ || ($ = {}));
6014
6014
 
6015
+ ;
6016
+ "use strict";
6017
+ var $;
6018
+ (function ($_1) {
6019
+ var $$;
6020
+ (function ($$) {
6021
+ $mol_test({
6022
+ async "Get and parse"($) {
6023
+ $mol_assert_equal(await $mol_wire_async($mol_fetch).text('data:text/plain,foo'), 'foo');
6024
+ },
6025
+ });
6026
+ })($$ = $_1.$$ || ($_1.$$ = {}));
6027
+ })($ || ($ = {}));
6028
+
6015
6029
  ;
6016
6030
  "use strict";
6017
6031
  var $;