@byloth/core 2.2.0 → 2.2.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/dist/core.esm.js CHANGED
@@ -27,7 +27,7 @@ class c extends Error {
27
27
  return e;
28
28
  if (e instanceof Error) {
29
29
  const t = new c(e.message);
30
- return t.stack = e.stack, t.name = e.name, t;
30
+ return t.stack = e.stack, t.cause = e.cause, t.name = e.name, t;
31
31
  }
32
32
  return new c(`${e}`);
33
33
  }
@@ -48,11 +48,7 @@ class c extends Error {
48
48
  * @param name The name of the exception. Default is `"Exception"`.
49
49
  */
50
50
  constructor(e, t, n = "Exception") {
51
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
52
-
53
- Caused by ${t.stack}` : this.stack += `
54
-
55
- Caused by ${t}`);
51
+ super(e), this.cause = t, this.name = n;
56
52
  }
57
53
  [Symbol.toStringTag] = "Exception";
58
54
  }
@@ -78,7 +74,7 @@ class x extends c {
78
74
  }
79
75
  [Symbol.toStringTag] = "FatalErrorException";
80
76
  }
81
- class C extends x {
77
+ class P extends x {
82
78
  /**
83
79
  * Initializes a new instance of the {@link NotImplementedException} class.
84
80
  *
@@ -166,7 +162,7 @@ class Y extends E {
166
162
  }
167
163
  [Symbol.toStringTag] = "FileNotFoundException";
168
164
  }
169
- class _ extends c {
165
+ class p extends c {
170
166
  /**
171
167
  * Initializes a new instance of the {@link KeyException} class.
172
168
  *
@@ -232,7 +228,7 @@ class V extends c {
232
228
  }
233
229
  [Symbol.toStringTag] = "PermissionException";
234
230
  }
235
- class S extends c {
231
+ class k extends c {
236
232
  /**
237
233
  * Initializes a new instance of the {@link ReferenceException} class.
238
234
  *
@@ -254,7 +250,7 @@ class S extends c {
254
250
  }
255
251
  [Symbol.toStringTag] = "ReferenceException";
256
252
  }
257
- class p extends c {
253
+ class _ extends c {
258
254
  /**
259
255
  * Initializes a new instance of the {@link RuntimeException} class.
260
256
  *
@@ -276,7 +272,7 @@ class p extends c {
276
272
  }
277
273
  [Symbol.toStringTag] = "RuntimeException";
278
274
  }
279
- class P extends p {
275
+ class j extends _ {
280
276
  /**
281
277
  * Initializes a new instance of the {@link EnvironmentException} class.
282
278
  *
@@ -298,7 +294,7 @@ class P extends p {
298
294
  }
299
295
  [Symbol.toStringTag] = "EnvironmentException";
300
296
  }
301
- class j extends c {
297
+ class O extends c {
302
298
  /**
303
299
  * Initializes a new instance of the {@link TimeoutException} class.
304
300
  *
@@ -914,7 +910,7 @@ class l {
914
910
  * {
915
911
  * try
916
912
  * {
917
- * if (value > 5) { throw new Error("The index is too high."); }
913
+ * if (value > 5) { throw new Exception("The index is too high."); }
918
914
  *
919
915
  * console.log(value); // 1, 2, 3, 4, 5
920
916
  * }
@@ -1605,7 +1601,7 @@ class u {
1605
1601
  }
1606
1602
  [Symbol.toStringTag] = "ReducedIterator";
1607
1603
  }
1608
- class m {
1604
+ class w {
1609
1605
  /**
1610
1606
  * The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
1611
1607
  */
@@ -1699,7 +1695,7 @@ class m {
1699
1695
  }
1700
1696
  filter(e) {
1701
1697
  const t = this._elements;
1702
- return new m(async function* () {
1698
+ return new w(async function* () {
1703
1699
  const n = /* @__PURE__ */ new Map();
1704
1700
  for await (const [s, r] of t) {
1705
1701
  const o = n.get(s) ?? 0;
@@ -1741,7 +1737,7 @@ class m {
1741
1737
  */
1742
1738
  map(e) {
1743
1739
  const t = this._elements;
1744
- return new m(async function* () {
1740
+ return new w(async function* () {
1745
1741
  const n = /* @__PURE__ */ new Map();
1746
1742
  for await (const [s, r] of t) {
1747
1743
  const o = n.get(s) ?? 0;
@@ -1806,7 +1802,7 @@ class m {
1806
1802
  */
1807
1803
  flatMap(e) {
1808
1804
  const t = this._elements;
1809
- return new m(async function* () {
1805
+ return new w(async function* () {
1810
1806
  const n = /* @__PURE__ */ new Map();
1811
1807
  for await (const [s, r] of t) {
1812
1808
  const o = n.get(s) ?? 0, a = await e(s, r, o);
@@ -1850,7 +1846,7 @@ class m {
1850
1846
  */
1851
1847
  drop(e) {
1852
1848
  const t = this._elements;
1853
- return new m(async function* () {
1849
+ return new w(async function* () {
1854
1850
  const n = /* @__PURE__ */ new Map();
1855
1851
  for await (const [s, r] of t) {
1856
1852
  const o = n.get(s) ?? 0;
@@ -1893,7 +1889,7 @@ class m {
1893
1889
  */
1894
1890
  take(e) {
1895
1891
  const t = this._elements;
1896
- return new m(async function* () {
1892
+ return new w(async function* () {
1897
1893
  const n = /* @__PURE__ */ new Map();
1898
1894
  for await (const [s, r] of t) {
1899
1895
  const o = n.get(s) ?? 0;
@@ -1969,7 +1965,7 @@ class m {
1969
1965
  */
1970
1966
  unique() {
1971
1967
  const e = this._elements;
1972
- return new m(async function* () {
1968
+ return new w(async function* () {
1973
1969
  const t = /* @__PURE__ */ new Map();
1974
1970
  for await (const [n, s] of e) {
1975
1971
  const r = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -2076,7 +2072,7 @@ class m {
2076
2072
  */
2077
2073
  reorganizeBy(e) {
2078
2074
  const t = this._elements;
2079
- return new m(async function* () {
2075
+ return new w(async function* () {
2080
2076
  const n = /* @__PURE__ */ new Map();
2081
2077
  for await (const [s, r] of t) {
2082
2078
  const o = n.get(s) ?? 0;
@@ -2832,7 +2828,7 @@ class d {
2832
2828
  * {
2833
2829
  * try
2834
2830
  * {
2835
- * if (value > 5) { throw new Error("The index is too high."); }
2831
+ * if (value > 5) { throw new Exception("The index is too high."); }
2836
2832
  *
2837
2833
  * console.log(value); // 1, 2, 3, 4, 5
2838
2834
  * }
@@ -2882,7 +2878,7 @@ class d {
2882
2878
  * @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
2883
2879
  */
2884
2880
  groupBy(e) {
2885
- return new m(this.map(async (t, n) => [await e(t, n), t]));
2881
+ return new w(this.map(async (t, n) => [await e(t, n), t]));
2886
2882
  }
2887
2883
  /**
2888
2884
  * Materializes the iterator into an array.
@@ -3569,7 +3565,7 @@ class h {
3569
3565
  [Symbol.toStringTag] = "AggregatedIterator";
3570
3566
  }
3571
3567
  const N = Function;
3572
- class O extends N {
3568
+ class M extends N {
3573
3569
  /**
3574
3570
  * Initializes a new instance of the {@link CallableObject} class.
3575
3571
  */
@@ -3580,6 +3576,113 @@ class O extends N {
3580
3576
  }
3581
3577
  [Symbol.toStringTag] = "CallableObject";
3582
3578
  }
3579
+ class K extends M {
3580
+ /**
3581
+ * The array containing all the functions in the chain.
3582
+ */
3583
+ _callbacks;
3584
+ /**
3585
+ * Gets the number of functions currently in the chain.
3586
+ */
3587
+ get size() {
3588
+ return this._callbacks.length;
3589
+ }
3590
+ /**
3591
+ * Initializes a new instance of the {@link CallbackChain} class.
3592
+ *
3593
+ * ---
3594
+ *
3595
+ * @example
3596
+ * ```ts
3597
+ * const chain = new CallbackChain();
3598
+ * ```
3599
+ *
3600
+ * ---
3601
+ *
3602
+ * @param callback Optional initial functions to add to the chain.
3603
+ */
3604
+ constructor(...e) {
3605
+ super(), this._callbacks = e;
3606
+ }
3607
+ /**
3608
+ * Executes all functions in the chain sequentially with the provided arguments.
3609
+ *
3610
+ * ---
3611
+ *
3612
+ * @param args The arguments to pass to each function in the chain.
3613
+ *
3614
+ * @returns An array containing the return values of all functions.
3615
+ */
3616
+ _invoke(...e) {
3617
+ return this._callbacks.map((t) => t(...e));
3618
+ }
3619
+ /**
3620
+ * Adds a function to the chain.
3621
+ *
3622
+ * ---
3623
+ *
3624
+ * @example
3625
+ * ```ts
3626
+ * const chain = new CallbackChain();
3627
+ * const cleanup = () => console.log("Cleaning up..."));
3628
+ *
3629
+ * chain.add(cleanup);
3630
+ * ```
3631
+ *
3632
+ * ---
3633
+ *
3634
+ * @param callback The function to add to the chain.
3635
+ *
3636
+ * @returns The current instance for method chaining.
3637
+ */
3638
+ add(e) {
3639
+ return this._callbacks.push(e), this;
3640
+ }
3641
+ /**
3642
+ * Removes a specific function from the chain.
3643
+ *
3644
+ * ---
3645
+ *
3646
+ * @example
3647
+ * ```ts
3648
+ * const chain = new CallbackChain();
3649
+ * const cleanup = () => console.log("Cleaning up..."));
3650
+ *
3651
+ * chain.add(cleanup);
3652
+ * chain.remove(cleanup);
3653
+ * ```
3654
+ *
3655
+ * ---
3656
+ *
3657
+ * @param callback The function to remove from the chain.
3658
+ *
3659
+ * @returns `true` if the function was found and removed, `false` otherwise.
3660
+ */
3661
+ remove(e) {
3662
+ const t = this._callbacks.indexOf(e);
3663
+ return t < 0 ? !1 : (this._callbacks.splice(t, 1), !0);
3664
+ }
3665
+ /**
3666
+ * Removes all functions from the chain.
3667
+ *
3668
+ * ---
3669
+ *
3670
+ * @example
3671
+ * ```ts
3672
+ * const chain = new CallbackChain();
3673
+ *
3674
+ * chain.add(() => console.log("Doing something..."));
3675
+ * chain.add(() => console.log("Doing something else..."));
3676
+ * chain.add(() => console.log("Doing yet another thing..."));
3677
+ *
3678
+ * chain.clear();
3679
+ * ```
3680
+ */
3681
+ clear() {
3682
+ this._callbacks.length = 0;
3683
+ }
3684
+ [Symbol.toStringTag] = "CallbackChain";
3685
+ }
3583
3686
  class g {
3584
3687
  /**
3585
3688
  * A map containing all the subscribers for each event.
@@ -3650,17 +3753,17 @@ class g {
3650
3753
  return n.push(t), this._subscribers.set(e, n), () => {
3651
3754
  const s = n.indexOf(t);
3652
3755
  if (s < 0)
3653
- throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
3756
+ throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
3654
3757
  n.splice(s, 1);
3655
3758
  };
3656
3759
  }
3657
3760
  unsubscribe(e, t) {
3658
3761
  const n = this._subscribers.get(e);
3659
3762
  if (!n)
3660
- throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3763
+ throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3661
3764
  const s = n.indexOf(t);
3662
3765
  if (s < 0)
3663
- throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3766
+ throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3664
3767
  n.splice(s, 1), n.length === 0 && this._subscribers.delete(e);
3665
3768
  }
3666
3769
  unsubscribeAll(e) {
@@ -3693,7 +3796,7 @@ class g {
3693
3796
  }
3694
3797
  const q = () => {
3695
3798
  };
3696
- class K extends O {
3799
+ class Q extends M {
3697
3800
  /**
3698
3801
  * The currently selected implementation of the callback.
3699
3802
  */
@@ -3741,7 +3844,7 @@ class K extends O {
3741
3844
  _invoke;
3742
3845
  constructor(e, t = "default") {
3743
3846
  super(), this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = (() => {
3744
- throw new C(
3847
+ throw new P(
3745
3848
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3746
3849
  );
3747
3850
  })), this._key = t, this._callback = e, this._invoke = (...n) => this._callback(...n);
@@ -3771,16 +3874,16 @@ class K extends O {
3771
3874
  enable(e) {
3772
3875
  if (e === void 0) {
3773
3876
  if (!this._key)
3774
- throw new _(
3877
+ throw new p(
3775
3878
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3776
3879
  );
3777
3880
  e = this._key;
3778
3881
  } else if (e) {
3779
3882
  if (!this._callbacks.has(e))
3780
- throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3781
- } else throw new _("The key must be a non-empty string.");
3883
+ throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3884
+ } else throw new p("The key must be a non-empty string.");
3782
3885
  if (this._isEnabled)
3783
- throw new p("The `SwitchableCallback` is already enabled.");
3886
+ throw new _("The `SwitchableCallback` is already enabled.");
3784
3887
  this._callback = this._callbacks.get(e), this._isEnabled = !0;
3785
3888
  }
3786
3889
  /**
@@ -3798,7 +3901,7 @@ class K extends O {
3798
3901
  */
3799
3902
  disable() {
3800
3903
  if (!this._isEnabled)
3801
- throw new p("The `SwitchableCallback` is already disabled.");
3904
+ throw new _("The `SwitchableCallback` is already disabled.");
3802
3905
  this._callback = q, this._isEnabled = !1;
3803
3906
  }
3804
3907
  /**
@@ -3825,7 +3928,7 @@ class K extends O {
3825
3928
  if (this._callbacks.size === 0)
3826
3929
  this._key = e, this._callback = t;
3827
3930
  else if (this._callbacks.has(e))
3828
- throw new _(`The key '${e}' has already been used for another callback.`);
3931
+ throw new p(`The key '${e}' has already been used for another callback.`);
3829
3932
  this._callbacks.set(e, t);
3830
3933
  }
3831
3934
  /**
@@ -3848,9 +3951,9 @@ class K extends O {
3848
3951
  */
3849
3952
  unregister(e) {
3850
3953
  if (this._key === e)
3851
- throw new _("Unable to unregister the currently selected callback.");
3954
+ throw new p("Unable to unregister the currently selected callback.");
3852
3955
  if (!this._callbacks.has(e))
3853
- throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3956
+ throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3854
3957
  this._callbacks.delete(e);
3855
3958
  }
3856
3959
  /**
@@ -3873,12 +3976,12 @@ class K extends O {
3873
3976
  */
3874
3977
  switch(e) {
3875
3978
  if (!this._callbacks.has(e))
3876
- throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3979
+ throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3877
3980
  this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
3878
3981
  }
3879
3982
  [Symbol.toStringTag] = "SwitchableCallback";
3880
3983
  }
3881
- class Q extends Map {
3984
+ class H extends Map {
3882
3985
  /**
3883
3986
  * The internal {@link Publisher} instance used to publish events.
3884
3987
  */
@@ -4035,7 +4138,7 @@ class Q extends Map {
4035
4138
  }
4036
4139
  [Symbol.toStringTag] = "MapView";
4037
4140
  }
4038
- class H extends Set {
4141
+ class X extends Set {
4039
4142
  /**
4040
4143
  * The internal {@link Publisher} instance used to publish events.
4041
4144
  */
@@ -4191,7 +4294,7 @@ class H extends Set {
4191
4294
  }
4192
4295
  [Symbol.toStringTag] = "SetView";
4193
4296
  }
4194
- class X {
4297
+ class Z {
4195
4298
  /**
4196
4299
  * Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
4197
4300
  *
@@ -4226,7 +4329,7 @@ class X {
4226
4329
  */
4227
4330
  constructor(e = !0) {
4228
4331
  if (!T)
4229
- throw new P(
4332
+ throw new j(
4230
4333
  "The `JSONStorage` class can only be instantiated within a browser environment."
4231
4334
  );
4232
4335
  this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
@@ -4499,7 +4602,7 @@ class X {
4499
4602
  }
4500
4603
  [Symbol.toStringTag] = "JSONStorage";
4501
4604
  }
4502
- class w {
4605
+ class m {
4503
4606
  /**
4504
4607
  * Wraps a new {@link SmartPromise} object around an existing native {@link Promise} object.
4505
4608
  *
@@ -4524,7 +4627,7 @@ class w {
4524
4627
  * @returns A new {@link SmartPromise} object that wraps the provided promise.
4525
4628
  */
4526
4629
  static FromPromise(e) {
4527
- return new w((t, n) => e.then(t, n));
4630
+ return new m((t, n) => e.then(t, n));
4528
4631
  }
4529
4632
  /**
4530
4633
  * A flag indicating whether the promise is still pending or not.
@@ -4632,7 +4735,7 @@ class w {
4632
4735
  }
4633
4736
  [Symbol.toStringTag] = "SmartPromise";
4634
4737
  }
4635
- class M extends w {
4738
+ class R extends m {
4636
4739
  /**
4637
4740
  * The exposed function that allows to resolve the promise.
4638
4741
  *
@@ -4705,7 +4808,7 @@ class M extends w {
4705
4808
  }
4706
4809
  [Symbol.toStringTag] = "DeferredPromise";
4707
4810
  }
4708
- class $ extends w {
4811
+ class z extends m {
4709
4812
  /**
4710
4813
  * Initializes a new instance of the {@link TimedPromise} class.
4711
4814
  *
@@ -4734,13 +4837,13 @@ class $ extends w {
4734
4837
  clearTimeout(y), n(v);
4735
4838
  }, o = (v) => {
4736
4839
  clearTimeout(y), s(v);
4737
- }, y = setTimeout(() => o(new j("The operation has timed out.")), t);
4840
+ }, y = setTimeout(() => o(new O("The operation has timed out.")), t);
4738
4841
  e(r, o);
4739
4842
  });
4740
4843
  }
4741
4844
  [Symbol.toStringTag] = "TimedPromise";
4742
4845
  }
4743
- class Z extends w {
4846
+ class W extends m {
4744
4847
  /**
4745
4848
  * The number of promises currently in the queue.
4746
4849
  */
@@ -4773,7 +4876,7 @@ class Z extends w {
4773
4876
  super((e) => e()), this._count = 0, this._isPending = !1, this._isFulfilled = !1, this._isRejected = !1;
4774
4877
  }
4775
4878
  enqueue(e, t) {
4776
- if (this._count += 1, e instanceof M) {
4879
+ if (this._count += 1, e instanceof R) {
4777
4880
  const s = e;
4778
4881
  e = () => (s.resolve(), s);
4779
4882
  }
@@ -4784,16 +4887,16 @@ class Z extends w {
4784
4887
  this._count -= 1, r(o);
4785
4888
  });
4786
4889
  };
4787
- return t ? new $(n, t) : new w(n);
4890
+ return t ? new z(n, t) : new m(n);
4788
4891
  }
4789
4892
  [Symbol.toStringTag] = "PromiseQueue";
4790
4893
  }
4791
- var k = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(k || {}), z = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))(z || {});
4792
- function W(i, e, t = 864e5) {
4894
+ var S = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(S || {}), $ = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))($ || {});
4895
+ function U(i, e, t = 864e5) {
4793
4896
  let n;
4794
4897
  return i = new Date(i), e = new Date(e), i < e ? n = Math.floor : n = Math.ceil, n((e.getTime() - i.getTime()) / t);
4795
4898
  }
4796
- function U(i, e, t = 864e5) {
4899
+ function ee(i, e, t = 864e5) {
4797
4900
  if (i = new Date(i), e = new Date(e), i >= e)
4798
4901
  throw new b("The end date must be greater than the start date.");
4799
4902
  return new l(function* () {
@@ -4814,12 +4917,12 @@ function I(i, e = 864e5) {
4814
4917
  );
4815
4918
  return i = new Date(i), new Date(Math.floor(i.getTime() / e) * e);
4816
4919
  }
4817
- function ee(i, e = 0) {
4920
+ function te(i, e = 0) {
4818
4921
  i = new Date(i);
4819
4922
  const t = 7 - e, n = (i.getUTCDay() + t) % 7, s = i.getTime() - 864e5 * n;
4820
4923
  return I(new Date(s));
4821
4924
  }
4822
- class R {
4925
+ class F {
4823
4926
  /**
4824
4927
  * The handle of the interval or the animation frame, depending on the environment.
4825
4928
  * It's used to stop the game loop when the {@link GameLoop._stop} method is called.
@@ -4924,7 +5027,7 @@ class R {
4924
5027
  */
4925
5028
  start(e = 0) {
4926
5029
  if (this._isRunning)
4927
- throw new p("The game loop has already been started.");
5030
+ throw new _("The game loop has already been started.");
4928
5031
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
4929
5032
  }
4930
5033
  /**
@@ -4942,7 +5045,7 @@ class R {
4942
5045
  */
4943
5046
  stop() {
4944
5047
  if (!this._isRunning)
4945
- throw new p("The game loop had already stopped or hadn't yet started.");
5048
+ throw new _("The game loop had already stopped or hadn't yet started.");
4946
5049
  if (!this._handle)
4947
5050
  throw new x();
4948
5051
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
@@ -4987,7 +5090,7 @@ class R {
4987
5090
  }
4988
5091
  [Symbol.toStringTag] = "GameLoop";
4989
5092
  }
4990
- class te extends R {
5093
+ class ne extends F {
4991
5094
  /**
4992
5095
  * Initializes a new instance of the {@link Clock} class.
4993
5096
  *
@@ -5004,7 +5107,7 @@ class te extends R {
5004
5107
  * The interval in milliseconds at which the clock will tick if the environment is not a browser.
5005
5108
  * `TimeUnit.Second` by default.
5006
5109
  */
5007
- constructor(e = k.Second) {
5110
+ constructor(e = S.Second) {
5008
5111
  super((t) => this._publisher.publish("tick", t), e);
5009
5112
  }
5010
5113
  /**
@@ -5026,7 +5129,7 @@ class te extends R {
5026
5129
  */
5027
5130
  start(e = 0) {
5028
5131
  if (this._isRunning)
5029
- throw new p("The clock has already been started.");
5132
+ throw new _("The clock has already been started.");
5030
5133
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
5031
5134
  }
5032
5135
  /**
@@ -5044,7 +5147,7 @@ class te extends R {
5044
5147
  */
5045
5148
  stop() {
5046
5149
  if (!this._isRunning)
5047
- throw new p("The clock had already stopped or hadn't yet started.");
5150
+ throw new _("The clock had already stopped or hadn't yet started.");
5048
5151
  if (!this._handle)
5049
5152
  throw new x();
5050
5153
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
@@ -5085,7 +5188,7 @@ class te extends R {
5085
5188
  }
5086
5189
  [Symbol.toStringTag] = "Clock";
5087
5190
  }
5088
- class ne extends R {
5191
+ class se extends F {
5089
5192
  /**
5090
5193
  * The total duration of the countdown in milliseconds.
5091
5194
  *
@@ -5129,7 +5232,7 @@ class ne extends R {
5129
5232
  * The interval in milliseconds at which the countdown will tick if the environment is not a browser.
5130
5233
  * `TimeUnit.Second` by default.
5131
5234
  */
5132
- constructor(e, t = k.Second) {
5235
+ constructor(e, t = S.Second) {
5133
5236
  const n = () => {
5134
5237
  const s = this.remainingTime;
5135
5238
  s <= 0 ? (this._deferrerStop(), this._publisher.publish("tick", 0), this._publisher.publish("expire")) : this._publisher.publish("tick", s);
@@ -5150,7 +5253,7 @@ class ne extends R {
5150
5253
  */
5151
5254
  _deferrerStop(e) {
5152
5255
  if (!this._isRunning)
5153
- throw new p("The countdown hadn't yet started.");
5256
+ throw new _("The countdown hadn't yet started.");
5154
5257
  if (!this._deferrer)
5155
5258
  throw new x();
5156
5259
  this._stop(), this._handle = void 0, this._isRunning = !1, e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
@@ -5178,10 +5281,10 @@ class ne extends R {
5178
5281
  */
5179
5282
  start(e = this.duration) {
5180
5283
  if (this._isRunning)
5181
- throw new p("The countdown had already stopped or hadn't yet started.");
5284
+ throw new _("The countdown had already stopped or hadn't yet started.");
5182
5285
  if (this._deferrer)
5183
5286
  throw new x();
5184
- return this._deferrer = new M(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5287
+ return this._deferrer = new R(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5185
5288
  }
5186
5289
  /**
5187
5290
  * Stops the execution of the countdown.
@@ -5263,7 +5366,7 @@ class ne extends R {
5263
5366
  }
5264
5367
  [Symbol.toStringTag] = "Countdown";
5265
5368
  }
5266
- class se {
5369
+ class re {
5267
5370
  /**
5268
5371
  * Generates a given number of values following a linear curve.
5269
5372
  * The values are equally spaced and normalized between 0 and 1.
@@ -5332,7 +5435,7 @@ class se {
5332
5435
  }
5333
5436
  [Symbol.toStringTag] = "Curve";
5334
5437
  }
5335
- class F {
5438
+ class C {
5336
5439
  /**
5337
5440
  * Generates a random boolean value.
5338
5441
  *
@@ -5398,35 +5501,35 @@ class F {
5398
5501
  * @returns A random element from the given array.
5399
5502
  */
5400
5503
  static Choice(e) {
5401
- return e[F.Index(e)];
5504
+ return e[C.Index(e)];
5402
5505
  }
5403
5506
  constructor() {
5404
5507
  }
5405
5508
  [Symbol.toStringTag] = "Random";
5406
5509
  }
5407
- function re(i) {
5408
- return new w((e) => setTimeout(e, i));
5409
- }
5410
- function ie() {
5411
- return new w((i) => requestAnimationFrame(() => i()));
5510
+ function ie(i) {
5511
+ return new m((e) => setTimeout(e, i));
5412
5512
  }
5413
5513
  function oe() {
5414
- return new w((i) => setTimeout(i));
5514
+ return new m((i) => requestAnimationFrame(() => i()));
5515
+ }
5516
+ function ae() {
5517
+ return new m((i) => setTimeout(i));
5415
5518
  }
5416
- function ae(i, e = "text/javascript") {
5417
- return new w((t, n) => {
5519
+ function le(i, e = "text/javascript") {
5520
+ return new m((t, n) => {
5418
5521
  const s = document.createElement("script");
5419
5522
  s.async = !0, s.defer = !0, s.src = i, s.type = e, s.onload = (r) => t(), s.onerror = (r) => n(r), document.body.appendChild(s);
5420
5523
  });
5421
5524
  }
5422
- function le(...i) {
5525
+ function ue(...i) {
5423
5526
  return new l(function* () {
5424
5527
  for (const e of i)
5425
5528
  for (const t of e)
5426
5529
  yield t;
5427
5530
  });
5428
5531
  }
5429
- function ue(i) {
5532
+ function ce(i) {
5430
5533
  if (i instanceof Array)
5431
5534
  return i.length;
5432
5535
  let e = 0;
@@ -5434,14 +5537,14 @@ function ue(i) {
5434
5537
  e += 1;
5435
5538
  return e;
5436
5539
  }
5437
- function ce(i) {
5540
+ function he(i) {
5438
5541
  return new l(function* () {
5439
5542
  let e = 0;
5440
5543
  for (const t of i)
5441
5544
  yield [e, t], e += 1;
5442
5545
  });
5443
5546
  }
5444
- function he(i, e, t = 1) {
5547
+ function fe(i, e, t = 1) {
5445
5548
  if (t <= 0)
5446
5549
  throw new b(
5447
5550
  "Step must be always a positive number, even when generating numbers in reverse order."
@@ -5454,7 +5557,7 @@ function he(i, e, t = 1) {
5454
5557
  yield n;
5455
5558
  });
5456
5559
  }
5457
- function fe(i) {
5560
+ function de(i) {
5458
5561
  const e = Array.from(i);
5459
5562
  for (let t = e.length - 1; t > 0; t -= 1) {
5460
5563
  const n = Math.floor(Math.random() * (t + 1));
@@ -5462,7 +5565,7 @@ function fe(i) {
5462
5565
  }
5463
5566
  return e;
5464
5567
  }
5465
- function de(i) {
5568
+ function me(i) {
5466
5569
  return new l(function* () {
5467
5570
  const e = /* @__PURE__ */ new Set();
5468
5571
  for (const t of i)
@@ -5501,7 +5604,7 @@ function we(i, e) {
5501
5604
  throw new f("The sum of weights must be greater than zero.");
5502
5605
  return t / n;
5503
5606
  }
5504
- function me(i) {
5607
+ function _e(i) {
5505
5608
  let e = 0;
5506
5609
  for (let t = 0; t < i.length; t += 1) {
5507
5610
  const n = i.charCodeAt(t);
@@ -5515,71 +5618,72 @@ function pe(i) {
5515
5618
  e += t;
5516
5619
  return e;
5517
5620
  }
5518
- function _e(i) {
5621
+ function ye(i) {
5519
5622
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
5520
5623
  }
5521
- const ye = "2.2.0";
5624
+ const be = "2.2.2";
5522
5625
  export {
5523
- m as AggregatedAsyncIterator,
5626
+ w as AggregatedAsyncIterator,
5524
5627
  h as AggregatedIterator,
5525
- O as CallableObject,
5526
- te as Clock,
5527
- ne as Countdown,
5528
- se as Curve,
5529
- M as DeferredPromise,
5530
- P as EnvironmentException,
5628
+ M as CallableObject,
5629
+ K as CallbackChain,
5630
+ ne as Clock,
5631
+ se as Countdown,
5632
+ re as Curve,
5633
+ R as DeferredPromise,
5634
+ j as EnvironmentException,
5531
5635
  c as Exception,
5532
5636
  x as FatalErrorException,
5533
5637
  E as FileException,
5534
5638
  J as FileExistsException,
5535
5639
  Y as FileNotFoundException,
5536
- R as GameLoop,
5537
- X as JSONStorage,
5538
- _ as KeyException,
5539
- Q as MapView,
5640
+ F as GameLoop,
5641
+ Z as JSONStorage,
5642
+ p as KeyException,
5643
+ H as MapView,
5540
5644
  L as NetworkException,
5541
- C as NotImplementedException,
5645
+ P as NotImplementedException,
5542
5646
  V as PermissionException,
5543
- Z as PromiseQueue,
5647
+ W as PromiseQueue,
5544
5648
  g as Publisher,
5545
- F as Random,
5649
+ C as Random,
5546
5650
  b as RangeException,
5547
5651
  u as ReducedIterator,
5548
- S as ReferenceException,
5549
- p as RuntimeException,
5550
- H as SetView,
5652
+ k as ReferenceException,
5653
+ _ as RuntimeException,
5654
+ X as SetView,
5551
5655
  d as SmartAsyncIterator,
5552
5656
  l as SmartIterator,
5553
- w as SmartPromise,
5554
- K as SwitchableCallback,
5555
- k as TimeUnit,
5556
- $ as TimedPromise,
5557
- j as TimeoutException,
5657
+ m as SmartPromise,
5658
+ Q as SwitchableCallback,
5659
+ S as TimeUnit,
5660
+ z as TimedPromise,
5661
+ O as TimeoutException,
5558
5662
  G as TypeException,
5559
- ye as VERSION,
5663
+ be as VERSION,
5560
5664
  f as ValueException,
5561
- z as WeekDay,
5665
+ $ as WeekDay,
5562
5666
  we as average,
5563
- _e as capitalize,
5564
- le as chain,
5565
- ue as count,
5566
- W as dateDifference,
5567
- U as dateRange,
5667
+ ye as capitalize,
5668
+ ue as chain,
5669
+ ce as count,
5670
+ U as dateDifference,
5671
+ ee as dateRange,
5568
5672
  I as dateRound,
5569
- re as delay,
5570
- ce as enumerate,
5571
- ee as getWeek,
5572
- me as hash,
5673
+ ie as delay,
5674
+ he as enumerate,
5675
+ te as getWeek,
5676
+ _e as hash,
5573
5677
  T as isBrowser,
5574
5678
  D as isNode,
5575
5679
  B as isWorker,
5576
- ae as loadScript,
5577
- ie as nextAnimationFrame,
5578
- he as range,
5579
- fe as shuffle,
5680
+ le as loadScript,
5681
+ oe as nextAnimationFrame,
5682
+ fe as range,
5683
+ de as shuffle,
5580
5684
  pe as sum,
5581
- de as unique,
5582
- oe as yieldToEventLoop,
5685
+ me as unique,
5686
+ ae as yieldToEventLoop,
5583
5687
  A as zip
5584
5688
  };
5585
5689
  //# sourceMappingURL=core.esm.js.map