@gjsify/fetch 0.0.3 → 0.0.4

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/test.node.mjs CHANGED
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? requir
9
9
  }) : x2)(function(x2) {
10
10
  if (typeof require !== "undefined")
11
11
  return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x2 + '" is not supported');
12
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
13
13
  });
14
14
  var __esm = (fn, res) => function __init() {
15
15
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -37,24 +37,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
38
  mod
39
39
  ));
40
- var __accessCheck = (obj, member, msg) => {
41
- if (!member.has(obj))
42
- throw TypeError("Cannot " + msg);
43
- };
44
- var __privateGet = (obj, member, getter) => {
45
- __accessCheck(obj, member, "read from private field");
46
- return getter ? getter.call(obj) : member.get(obj);
47
- };
48
- var __privateAdd = (obj, member, value) => {
49
- if (member.has(obj))
50
- throw TypeError("Cannot add the same private member more than once");
51
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
52
- };
53
- var __privateSet = (obj, member, value, setter) => {
54
- __accessCheck(obj, member, "write to private field");
55
- setter ? setter.call(obj, value) : member.set(obj, value);
56
- return value;
57
- };
58
40
 
59
41
  // ../../../node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
60
42
  var require_ponyfill_es2018 = __commonJS({
@@ -604,7 +586,7 @@ var require_ponyfill_es2018 = __commonJS({
604
586
  }
605
587
  try {
606
588
  return x2._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
607
- } catch (_a4) {
589
+ } catch (_a) {
608
590
  return false;
609
591
  }
610
592
  }
@@ -1501,7 +1483,7 @@ var require_ponyfill_es2018 = __commonJS({
1501
1483
  }
1502
1484
  try {
1503
1485
  return typeof value.aborted === "boolean";
1504
- } catch (_a4) {
1486
+ } catch (_a) {
1505
1487
  return false;
1506
1488
  }
1507
1489
  }
@@ -1642,12 +1624,12 @@ var require_ponyfill_es2018 = __commonJS({
1642
1624
  return true;
1643
1625
  }
1644
1626
  function WritableStreamAbort(stream, reason) {
1645
- var _a4;
1627
+ var _a;
1646
1628
  if (stream._state === "closed" || stream._state === "errored") {
1647
1629
  return promiseResolvedWith(void 0);
1648
1630
  }
1649
1631
  stream._writableStreamController._abortReason = reason;
1650
- (_a4 = stream._writableStreamController._abortController) === null || _a4 === void 0 ? void 0 : _a4.abort();
1632
+ (_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
1651
1633
  const state = stream._state;
1652
1634
  if (state === "closed" || state === "errored") {
1653
1635
  return promiseResolvedWith(void 0);
@@ -2377,7 +2359,7 @@ var require_ponyfill_es2018 = __commonJS({
2377
2359
  try {
2378
2360
  new ctor();
2379
2361
  return true;
2380
- } catch (_a4) {
2362
+ } catch (_a) {
2381
2363
  return false;
2382
2364
  }
2383
2365
  }
@@ -3433,7 +3415,7 @@ var require_ponyfill_es2018 = __commonJS({
3433
3415
  value: "size",
3434
3416
  configurable: true
3435
3417
  });
3436
- } catch (_a4) {
3418
+ } catch (_a) {
3437
3419
  }
3438
3420
  class ByteLengthQueuingStrategy {
3439
3421
  constructor(options) {
@@ -3490,7 +3472,7 @@ var require_ponyfill_es2018 = __commonJS({
3490
3472
  value: "size",
3491
3473
  configurable: true
3492
3474
  });
3493
- } catch (_a4) {
3475
+ } catch (_a) {
3494
3476
  }
3495
3477
  class CountQueuingStrategy {
3496
3478
  constructor(options) {
@@ -3892,9 +3874,9 @@ var require_streams = __commonJS({
3892
3874
  }
3893
3875
  }
3894
3876
  try {
3895
- const { Blob: Blob2 } = __require("buffer");
3896
- if (Blob2 && !Blob2.prototype.stream) {
3897
- Blob2.prototype.stream = function name(params) {
3877
+ const { Blob: Blob3 } = __require("buffer");
3878
+ if (Blob3 && !Blob3.prototype.stream) {
3879
+ Blob3.prototype.stream = function name(params) {
3898
3880
  let position = 0;
3899
3881
  const blob = this;
3900
3882
  return new ReadableStream({
@@ -3951,12 +3933,17 @@ async function* toIterator(parts, clone2 = true) {
3951
3933
  }
3952
3934
  }
3953
3935
  }
3954
- var import_streams, POOL_SIZE, _parts, _type, _size, _endings, _a, _Blob, Blob, fetch_blob_default;
3936
+ var import_streams, POOL_SIZE, _Blob, Blob2, fetch_blob_default;
3955
3937
  var init_fetch_blob = __esm({
3956
3938
  "../../../node_modules/fetch-blob/index.js"() {
3957
3939
  import_streams = __toESM(require_streams(), 1);
3958
3940
  POOL_SIZE = 65536;
3959
- _Blob = (_a = class {
3941
+ _Blob = class Blob {
3942
+ /** @type {Array.<(Blob|Uint8Array)>} */
3943
+ #parts = [];
3944
+ #type = "";
3945
+ #size = 0;
3946
+ #endings = "transparent";
3960
3947
  /**
3961
3948
  * The Blob() constructor returns a new Blob object. The content
3962
3949
  * of the blob consists of the concatenation of the values given
@@ -3966,11 +3953,6 @@ var init_fetch_blob = __esm({
3966
3953
  * @param {{ type?: string, endings?: string }} [options]
3967
3954
  */
3968
3955
  constructor(blobParts = [], options = {}) {
3969
- /** @type {Array.<(Blob|Uint8Array)>} */
3970
- __privateAdd(this, _parts, []);
3971
- __privateAdd(this, _type, "");
3972
- __privateAdd(this, _size, 0);
3973
- __privateAdd(this, _endings, "transparent");
3974
3956
  if (typeof blobParts !== "object" || blobParts === null) {
3975
3957
  throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
3976
3958
  }
@@ -3989,30 +3971,30 @@ var init_fetch_blob = __esm({
3989
3971
  part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
3990
3972
  } else if (element instanceof ArrayBuffer) {
3991
3973
  part = new Uint8Array(element.slice(0));
3992
- } else if (element instanceof _a) {
3974
+ } else if (element instanceof Blob) {
3993
3975
  part = element;
3994
3976
  } else {
3995
3977
  part = encoder.encode(`${element}`);
3996
3978
  }
3997
- __privateSet(this, _size, __privateGet(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
3998
- __privateGet(this, _parts).push(part);
3979
+ this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
3980
+ this.#parts.push(part);
3999
3981
  }
4000
- __privateSet(this, _endings, `${options.endings === void 0 ? "transparent" : options.endings}`);
3982
+ this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
4001
3983
  const type = options.type === void 0 ? "" : String(options.type);
4002
- __privateSet(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
3984
+ this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
4003
3985
  }
4004
3986
  /**
4005
3987
  * The Blob interface's size property returns the
4006
3988
  * size of the Blob in bytes.
4007
3989
  */
4008
3990
  get size() {
4009
- return __privateGet(this, _size);
3991
+ return this.#size;
4010
3992
  }
4011
3993
  /**
4012
3994
  * The type property of a Blob object returns the MIME type of the file.
4013
3995
  */
4014
3996
  get type() {
4015
- return __privateGet(this, _type);
3997
+ return this.#type;
4016
3998
  }
4017
3999
  /**
4018
4000
  * The text() method in the Blob interface returns a Promise
@@ -4024,7 +4006,7 @@ var init_fetch_blob = __esm({
4024
4006
  async text() {
4025
4007
  const decoder = new TextDecoder();
4026
4008
  let str = "";
4027
- for await (const part of toIterator(__privateGet(this, _parts), false)) {
4009
+ for await (const part of toIterator(this.#parts, false)) {
4028
4010
  str += decoder.decode(part, { stream: true });
4029
4011
  }
4030
4012
  str += decoder.decode();
@@ -4040,14 +4022,14 @@ var init_fetch_blob = __esm({
4040
4022
  async arrayBuffer() {
4041
4023
  const data = new Uint8Array(this.size);
4042
4024
  let offset = 0;
4043
- for await (const chunk of toIterator(__privateGet(this, _parts), false)) {
4025
+ for await (const chunk of toIterator(this.#parts, false)) {
4044
4026
  data.set(chunk, offset);
4045
4027
  offset += chunk.length;
4046
4028
  }
4047
4029
  return data.buffer;
4048
4030
  }
4049
4031
  stream() {
4050
- const it2 = toIterator(__privateGet(this, _parts), true);
4032
+ const it2 = toIterator(this.#parts, true);
4051
4033
  return new globalThis.ReadableStream({
4052
4034
  // @ts-ignore
4053
4035
  type: "bytes",
@@ -4074,7 +4056,7 @@ var init_fetch_blob = __esm({
4074
4056
  let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
4075
4057
  let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
4076
4058
  const span = Math.max(relativeEnd - relativeStart, 0);
4077
- const parts = __privateGet(this, _parts);
4059
+ const parts = this.#parts;
4078
4060
  const blobParts = [];
4079
4061
  let added = 0;
4080
4062
  for (const part of parts) {
@@ -4099,9 +4081,9 @@ var init_fetch_blob = __esm({
4099
4081
  relativeStart = 0;
4100
4082
  }
4101
4083
  }
4102
- const blob = new _a([], { type: String(type).toLowerCase() });
4103
- __privateSet(blob, _size, span);
4104
- __privateSet(blob, _parts, blobParts);
4084
+ const blob = new Blob([], { type: String(type).toLowerCase() });
4085
+ blob.#size = span;
4086
+ blob.#parts = blobParts;
4105
4087
  return blob;
4106
4088
  }
4107
4089
  get [Symbol.toStringTag]() {
@@ -4110,23 +4092,25 @@ var init_fetch_blob = __esm({
4110
4092
  static [Symbol.hasInstance](object) {
4111
4093
  return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
4112
4094
  }
4113
- }, _parts = new WeakMap(), _type = new WeakMap(), _size = new WeakMap(), _endings = new WeakMap(), _a);
4095
+ };
4114
4096
  Object.defineProperties(_Blob.prototype, {
4115
4097
  size: { enumerable: true },
4116
4098
  type: { enumerable: true },
4117
4099
  slice: { enumerable: true }
4118
4100
  });
4119
- Blob = _Blob;
4120
- fetch_blob_default = Blob;
4101
+ Blob2 = _Blob;
4102
+ fetch_blob_default = Blob2;
4121
4103
  }
4122
4104
  });
4123
4105
 
4124
4106
  // ../../../node_modules/fetch-blob/file.js
4125
- var _lastModified, _name, _a2, _File, File, file_default;
4107
+ var _File, File2, file_default;
4126
4108
  var init_file = __esm({
4127
4109
  "../../../node_modules/fetch-blob/file.js"() {
4128
4110
  init_fetch_blob();
4129
- _File = (_a2 = class extends fetch_blob_default {
4111
+ _File = class File extends fetch_blob_default {
4112
+ #lastModified = 0;
4113
+ #name = "";
4130
4114
  /**
4131
4115
  * @param {*[]} fileBits
4132
4116
  * @param {string} fileName
@@ -4138,21 +4122,19 @@ var init_file = __esm({
4138
4122
  throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
4139
4123
  }
4140
4124
  super(fileBits, options);
4141
- __privateAdd(this, _lastModified, 0);
4142
- __privateAdd(this, _name, "");
4143
4125
  if (options === null)
4144
4126
  options = {};
4145
4127
  const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
4146
4128
  if (!Number.isNaN(lastModified)) {
4147
- __privateSet(this, _lastModified, lastModified);
4129
+ this.#lastModified = lastModified;
4148
4130
  }
4149
- __privateSet(this, _name, String(fileName));
4131
+ this.#name = String(fileName);
4150
4132
  }
4151
4133
  get name() {
4152
- return __privateGet(this, _name);
4134
+ return this.#name;
4153
4135
  }
4154
4136
  get lastModified() {
4155
- return __privateGet(this, _lastModified);
4137
+ return this.#lastModified;
4156
4138
  }
4157
4139
  get [Symbol.toStringTag]() {
4158
4140
  return "File";
@@ -4160,9 +4142,9 @@ var init_file = __esm({
4160
4142
  static [Symbol.hasInstance](object) {
4161
4143
  return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
4162
4144
  }
4163
- }, _lastModified = new WeakMap(), _name = new WeakMap(), _a2);
4164
- File = _File;
4165
- file_default = File;
4145
+ };
4146
+ File2 = _File;
4147
+ file_default = File2;
4166
4148
  }
4167
4149
  });
4168
4150
 
@@ -4180,7 +4162,7 @@ Content-Type: ${v.type || "application/octet-stream"}\r
4180
4162
  c.push(`--${b}--`);
4181
4163
  return new B(c, { type: "multipart/form-data; boundary=" + b });
4182
4164
  }
4183
- var t, i, h, r, m, f, e, x, _d, _a3, FormData;
4165
+ var t, i, h, r, m, f, e, x, FormData;
4184
4166
  var init_esm_min = __esm({
4185
4167
  "../../../node_modules/formdata-polyfill/esm.min.js"() {
4186
4168
  init_fetch_blob();
@@ -4195,9 +4177,9 @@ var init_esm_min = __esm({
4195
4177
  throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
4196
4178
  }
4197
4179
  };
4198
- FormData = (_a3 = class {
4180
+ FormData = class FormData2 {
4181
+ #d = [];
4199
4182
  constructor(...a) {
4200
- __privateAdd(this, _d, []);
4201
4183
  if (a.length)
4202
4184
  throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
4203
4185
  }
@@ -4212,17 +4194,17 @@ var init_esm_min = __esm({
4212
4194
  }
4213
4195
  append(...a) {
4214
4196
  x("append", arguments, 2);
4215
- __privateGet(this, _d).push(f(...a));
4197
+ this.#d.push(f(...a));
4216
4198
  }
4217
4199
  delete(a) {
4218
4200
  x("delete", arguments, 1);
4219
4201
  a += "";
4220
- __privateSet(this, _d, __privateGet(this, _d).filter(([b]) => b !== a));
4202
+ this.#d = this.#d.filter(([b]) => b !== a);
4221
4203
  }
4222
4204
  get(a) {
4223
4205
  x("get", arguments, 1);
4224
4206
  a += "";
4225
- for (var b = __privateGet(this, _d), l = b.length, c = 0; c < l; c++)
4207
+ for (var b = this.#d, l = b.length, c = 0; c < l; c++)
4226
4208
  if (b[c][0] === a)
4227
4209
  return b[c][1];
4228
4210
  return null;
@@ -4231,13 +4213,13 @@ var init_esm_min = __esm({
4231
4213
  x("getAll", arguments, 1);
4232
4214
  b = [];
4233
4215
  a += "";
4234
- __privateGet(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
4216
+ this.#d.forEach((c) => c[0] === a && b.push(c[1]));
4235
4217
  return b;
4236
4218
  }
4237
4219
  has(a) {
4238
4220
  x("has", arguments, 1);
4239
4221
  a += "";
4240
- return __privateGet(this, _d).some((b) => b[0] === a);
4222
+ return this.#d.some((b) => b[0] === a);
4241
4223
  }
4242
4224
  forEach(a, b) {
4243
4225
  x("forEach", arguments, 1);
@@ -4248,14 +4230,14 @@ var init_esm_min = __esm({
4248
4230
  x("set", arguments, 2);
4249
4231
  var b = [], c = true;
4250
4232
  a = f(...a);
4251
- __privateGet(this, _d).forEach((d) => {
4233
+ this.#d.forEach((d) => {
4252
4234
  d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
4253
4235
  });
4254
4236
  c && b.push(a);
4255
- __privateSet(this, _d, b);
4237
+ this.#d = b;
4256
4238
  }
4257
4239
  *entries() {
4258
- yield* __privateGet(this, _d);
4240
+ yield* this.#d;
4259
4241
  }
4260
4242
  *keys() {
4261
4243
  for (var [a] of this)
@@ -4265,7 +4247,7 @@ var init_esm_min = __esm({
4265
4247
  for (var [, a] of this)
4266
4248
  yield a;
4267
4249
  }
4268
- }, _d = new WeakMap(), _a3);
4250
+ };
4269
4251
  }
4270
4252
  });
4271
4253
 
@@ -4293,7 +4275,7 @@ var init_from = __esm({
4293
4275
  init_file();
4294
4276
  init_fetch_blob();
4295
4277
  ({ stat } = fs);
4296
- BlobDataItem = class {
4278
+ BlobDataItem = class _BlobDataItem {
4297
4279
  #path;
4298
4280
  #start;
4299
4281
  constructor(options) {
@@ -4307,7 +4289,7 @@ var init_from = __esm({
4307
4289
  * to not be out of range by Blob.prototype.slice
4308
4290
  */
4309
4291
  slice(start, end) {
4310
- return new BlobDataItem({
4292
+ return new _BlobDataItem({
4311
4293
  path: this.#path,
4312
4294
  lastModified: this.lastModified,
4313
4295
  size: end - start,
@@ -4706,14 +4688,14 @@ var BLUE = "\x1B[34m";
4706
4688
  var GRAY = "\x1B[90m";
4707
4689
  var RESET = "\x1B[39m";
4708
4690
  var print = globalThis.print || console.log;
4709
- var MatcherFactory = class {
4691
+ var MatcherFactory = class _MatcherFactory {
4710
4692
  constructor(actualValue, positive, negated) {
4711
4693
  this.actualValue = actualValue;
4712
4694
  this.positive = positive;
4713
4695
  if (negated) {
4714
4696
  this.not = negated;
4715
4697
  } else {
4716
- this.not = new MatcherFactory(actualValue, !positive, this);
4698
+ this.not = new _MatcherFactory(actualValue, !positive, this);
4717
4699
  }
4718
4700
  }
4719
4701
  not;
@@ -5354,7 +5336,7 @@ var validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.
5354
5336
  throw error;
5355
5337
  }
5356
5338
  };
5357
- var Headers = class extends URLSearchParams {
5339
+ var Headers = class _Headers extends URLSearchParams {
5358
5340
  /**
5359
5341
  * Headers class
5360
5342
  *
@@ -5363,7 +5345,7 @@ var Headers = class extends URLSearchParams {
5363
5345
  */
5364
5346
  constructor(init) {
5365
5347
  let result = [];
5366
- if (init instanceof Headers) {
5348
+ if (init instanceof _Headers) {
5367
5349
  const raw = init.raw();
5368
5350
  for (const [name, values] of Object.entries(raw)) {
5369
5351
  result.push(...values.map((value) => [name, value]));
@@ -5531,7 +5513,7 @@ var isRedirect = (code) => {
5531
5513
 
5532
5514
  // ../../../node_modules/node-fetch/src/response.js
5533
5515
  var INTERNALS2 = Symbol("Response internals");
5534
- var Response = class extends Body {
5516
+ var Response = class _Response extends Body {
5535
5517
  constructor(body = null, options = {}) {
5536
5518
  super(body, options);
5537
5519
  const status = options.status != null ? options.status : 200;
@@ -5585,7 +5567,7 @@ var Response = class extends Body {
5585
5567
  * @return Response
5586
5568
  */
5587
5569
  clone() {
5588
- return new Response(clone(this, this.highWaterMark), {
5570
+ return new _Response(clone(this, this.highWaterMark), {
5589
5571
  type: this.type,
5590
5572
  url: this.url,
5591
5573
  status: this.status,
@@ -5606,7 +5588,7 @@ var Response = class extends Body {
5606
5588
  if (!isRedirect(status)) {
5607
5589
  throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
5608
5590
  }
5609
- return new Response(null, {
5591
+ return new _Response(null, {
5610
5592
  headers: {
5611
5593
  location: new URL(url).toString()
5612
5594
  },
@@ -5614,7 +5596,7 @@ var Response = class extends Body {
5614
5596
  });
5615
5597
  }
5616
5598
  static error() {
5617
- const response = new Response(null, { status: 0, statusText: "" });
5599
+ const response = new _Response(null, { status: 0, statusText: "" });
5618
5600
  response[INTERNALS2].type = "error";
5619
5601
  return response;
5620
5602
  }
@@ -5627,7 +5609,7 @@ var Response = class extends Body {
5627
5609
  if (!headers.has("content-type")) {
5628
5610
  headers.set("content-type", "application/json");
5629
5611
  }
5630
- return new Response(body, {
5612
+ return new _Response(body, {
5631
5613
  ...init,
5632
5614
  headers
5633
5615
  });
@@ -5812,7 +5794,7 @@ var doBadDataWarn = deprecate2(
5812
5794
  ".data is not a valid RequestInit property, use .body instead",
5813
5795
  "https://github.com/node-fetch/node-fetch/issues/1000 (request)"
5814
5796
  );
5815
- var Request = class extends Body {
5797
+ var Request = class _Request extends Body {
5816
5798
  constructor(input, init = {}) {
5817
5799
  let parsedURL;
5818
5800
  if (isRequest(input)) {
@@ -5921,7 +5903,7 @@ var Request = class extends Body {
5921
5903
  * @return Request
5922
5904
  */
5923
5905
  clone() {
5924
- return new Request(this);
5906
+ return new _Request(this);
5925
5907
  }
5926
5908
  get [Symbol.toStringTag]() {
5927
5909
  return "Request";
@@ -5977,9 +5959,6 @@ var getNodeRequestOptions = (request) => {
5977
5959
  if (typeof agent === "function") {
5978
5960
  agent = agent(parsedURL);
5979
5961
  }
5980
- if (!headers.has("Connection") && !agent) {
5981
- headers.set("Connection", "close");
5982
- }
5983
5962
  const search = getSearch(parsedURL);
5984
5963
  const options = {
5985
5964
  // Overwrite search to retain trailing ? (issue #776)
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "ESNext",
3
+ "module": "NodeNext",
4
4
  "types": ["node"],
5
5
  "target": "ESNext",
6
6
  "moduleResolution": "NodeNext",