@byloth/core 2.2.0 → 2.2.1
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.cjs +2 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +225 -117
- package/dist/core.esm.js.map +1 -1
- package/dist/core.global.js +2 -2
- package/dist/core.global.js.map +1 -1
- package/dist/core.umd.cjs +1 -1
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -1
- package/src/models/callbacks/callback-chain.ts +163 -0
- package/src/models/callbacks/index.ts +2 -1
- package/src/models/index.ts +1 -1
package/dist/core.esm.js
CHANGED
|
@@ -78,7 +78,7 @@ class x extends c {
|
|
|
78
78
|
}
|
|
79
79
|
[Symbol.toStringTag] = "FatalErrorException";
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class P extends x {
|
|
82
82
|
/**
|
|
83
83
|
* Initializes a new instance of the {@link NotImplementedException} class.
|
|
84
84
|
*
|
|
@@ -166,7 +166,7 @@ class Y extends E {
|
|
|
166
166
|
}
|
|
167
167
|
[Symbol.toStringTag] = "FileNotFoundException";
|
|
168
168
|
}
|
|
169
|
-
class
|
|
169
|
+
class p extends c {
|
|
170
170
|
/**
|
|
171
171
|
* Initializes a new instance of the {@link KeyException} class.
|
|
172
172
|
*
|
|
@@ -232,7 +232,7 @@ class V extends c {
|
|
|
232
232
|
}
|
|
233
233
|
[Symbol.toStringTag] = "PermissionException";
|
|
234
234
|
}
|
|
235
|
-
class
|
|
235
|
+
class k extends c {
|
|
236
236
|
/**
|
|
237
237
|
* Initializes a new instance of the {@link ReferenceException} class.
|
|
238
238
|
*
|
|
@@ -254,7 +254,7 @@ class S extends c {
|
|
|
254
254
|
}
|
|
255
255
|
[Symbol.toStringTag] = "ReferenceException";
|
|
256
256
|
}
|
|
257
|
-
class
|
|
257
|
+
class _ extends c {
|
|
258
258
|
/**
|
|
259
259
|
* Initializes a new instance of the {@link RuntimeException} class.
|
|
260
260
|
*
|
|
@@ -276,7 +276,7 @@ class p extends c {
|
|
|
276
276
|
}
|
|
277
277
|
[Symbol.toStringTag] = "RuntimeException";
|
|
278
278
|
}
|
|
279
|
-
class
|
|
279
|
+
class j extends _ {
|
|
280
280
|
/**
|
|
281
281
|
* Initializes a new instance of the {@link EnvironmentException} class.
|
|
282
282
|
*
|
|
@@ -298,7 +298,7 @@ class P extends p {
|
|
|
298
298
|
}
|
|
299
299
|
[Symbol.toStringTag] = "EnvironmentException";
|
|
300
300
|
}
|
|
301
|
-
class
|
|
301
|
+
class O extends c {
|
|
302
302
|
/**
|
|
303
303
|
* Initializes a new instance of the {@link TimeoutException} class.
|
|
304
304
|
*
|
|
@@ -1605,7 +1605,7 @@ class u {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
[Symbol.toStringTag] = "ReducedIterator";
|
|
1607
1607
|
}
|
|
1608
|
-
class
|
|
1608
|
+
class w {
|
|
1609
1609
|
/**
|
|
1610
1610
|
* The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
|
|
1611
1611
|
*/
|
|
@@ -1699,7 +1699,7 @@ class m {
|
|
|
1699
1699
|
}
|
|
1700
1700
|
filter(e) {
|
|
1701
1701
|
const t = this._elements;
|
|
1702
|
-
return new
|
|
1702
|
+
return new w(async function* () {
|
|
1703
1703
|
const n = /* @__PURE__ */ new Map();
|
|
1704
1704
|
for await (const [s, r] of t) {
|
|
1705
1705
|
const o = n.get(s) ?? 0;
|
|
@@ -1741,7 +1741,7 @@ class m {
|
|
|
1741
1741
|
*/
|
|
1742
1742
|
map(e) {
|
|
1743
1743
|
const t = this._elements;
|
|
1744
|
-
return new
|
|
1744
|
+
return new w(async function* () {
|
|
1745
1745
|
const n = /* @__PURE__ */ new Map();
|
|
1746
1746
|
for await (const [s, r] of t) {
|
|
1747
1747
|
const o = n.get(s) ?? 0;
|
|
@@ -1806,7 +1806,7 @@ class m {
|
|
|
1806
1806
|
*/
|
|
1807
1807
|
flatMap(e) {
|
|
1808
1808
|
const t = this._elements;
|
|
1809
|
-
return new
|
|
1809
|
+
return new w(async function* () {
|
|
1810
1810
|
const n = /* @__PURE__ */ new Map();
|
|
1811
1811
|
for await (const [s, r] of t) {
|
|
1812
1812
|
const o = n.get(s) ?? 0, a = await e(s, r, o);
|
|
@@ -1850,7 +1850,7 @@ class m {
|
|
|
1850
1850
|
*/
|
|
1851
1851
|
drop(e) {
|
|
1852
1852
|
const t = this._elements;
|
|
1853
|
-
return new
|
|
1853
|
+
return new w(async function* () {
|
|
1854
1854
|
const n = /* @__PURE__ */ new Map();
|
|
1855
1855
|
for await (const [s, r] of t) {
|
|
1856
1856
|
const o = n.get(s) ?? 0;
|
|
@@ -1893,7 +1893,7 @@ class m {
|
|
|
1893
1893
|
*/
|
|
1894
1894
|
take(e) {
|
|
1895
1895
|
const t = this._elements;
|
|
1896
|
-
return new
|
|
1896
|
+
return new w(async function* () {
|
|
1897
1897
|
const n = /* @__PURE__ */ new Map();
|
|
1898
1898
|
for await (const [s, r] of t) {
|
|
1899
1899
|
const o = n.get(s) ?? 0;
|
|
@@ -1969,7 +1969,7 @@ class m {
|
|
|
1969
1969
|
*/
|
|
1970
1970
|
unique() {
|
|
1971
1971
|
const e = this._elements;
|
|
1972
|
-
return new
|
|
1972
|
+
return new w(async function* () {
|
|
1973
1973
|
const t = /* @__PURE__ */ new Map();
|
|
1974
1974
|
for await (const [n, s] of e) {
|
|
1975
1975
|
const r = t.get(n) ?? /* @__PURE__ */ new Set();
|
|
@@ -2076,7 +2076,7 @@ class m {
|
|
|
2076
2076
|
*/
|
|
2077
2077
|
reorganizeBy(e) {
|
|
2078
2078
|
const t = this._elements;
|
|
2079
|
-
return new
|
|
2079
|
+
return new w(async function* () {
|
|
2080
2080
|
const n = /* @__PURE__ */ new Map();
|
|
2081
2081
|
for await (const [s, r] of t) {
|
|
2082
2082
|
const o = n.get(s) ?? 0;
|
|
@@ -2882,7 +2882,7 @@ class d {
|
|
|
2882
2882
|
* @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
|
|
2883
2883
|
*/
|
|
2884
2884
|
groupBy(e) {
|
|
2885
|
-
return new
|
|
2885
|
+
return new w(this.map(async (t, n) => [await e(t, n), t]));
|
|
2886
2886
|
}
|
|
2887
2887
|
/**
|
|
2888
2888
|
* Materializes the iterator into an array.
|
|
@@ -3569,7 +3569,7 @@ class h {
|
|
|
3569
3569
|
[Symbol.toStringTag] = "AggregatedIterator";
|
|
3570
3570
|
}
|
|
3571
3571
|
const N = Function;
|
|
3572
|
-
class
|
|
3572
|
+
class M extends N {
|
|
3573
3573
|
/**
|
|
3574
3574
|
* Initializes a new instance of the {@link CallableObject} class.
|
|
3575
3575
|
*/
|
|
@@ -3580,6 +3580,113 @@ class O extends N {
|
|
|
3580
3580
|
}
|
|
3581
3581
|
[Symbol.toStringTag] = "CallableObject";
|
|
3582
3582
|
}
|
|
3583
|
+
class K extends M {
|
|
3584
|
+
/**
|
|
3585
|
+
* The array containing all the functions in the chain.
|
|
3586
|
+
*/
|
|
3587
|
+
_callbacks;
|
|
3588
|
+
/**
|
|
3589
|
+
* Gets the number of functions currently in the chain.
|
|
3590
|
+
*/
|
|
3591
|
+
get size() {
|
|
3592
|
+
return this._callbacks.length;
|
|
3593
|
+
}
|
|
3594
|
+
/**
|
|
3595
|
+
* Initializes a new instance of the {@link CallbackChain} class.
|
|
3596
|
+
*
|
|
3597
|
+
* ---
|
|
3598
|
+
*
|
|
3599
|
+
* @example
|
|
3600
|
+
* ```ts
|
|
3601
|
+
* const chain = new CallbackChain();
|
|
3602
|
+
* ```
|
|
3603
|
+
*
|
|
3604
|
+
* ---
|
|
3605
|
+
*
|
|
3606
|
+
* @param callback Optional initial functions to add to the chain.
|
|
3607
|
+
*/
|
|
3608
|
+
constructor(...e) {
|
|
3609
|
+
super(), this._callbacks = e;
|
|
3610
|
+
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Executes all functions in the chain sequentially with the provided arguments.
|
|
3613
|
+
*
|
|
3614
|
+
* ---
|
|
3615
|
+
*
|
|
3616
|
+
* @param args The arguments to pass to each function in the chain.
|
|
3617
|
+
*
|
|
3618
|
+
* @returns An array containing the return values of all functions.
|
|
3619
|
+
*/
|
|
3620
|
+
_invoke(...e) {
|
|
3621
|
+
return this._callbacks.map((t) => t(...e));
|
|
3622
|
+
}
|
|
3623
|
+
/**
|
|
3624
|
+
* Adds a function to the chain.
|
|
3625
|
+
*
|
|
3626
|
+
* ---
|
|
3627
|
+
*
|
|
3628
|
+
* @example
|
|
3629
|
+
* ```ts
|
|
3630
|
+
* const chain = new CallbackChain();
|
|
3631
|
+
* const cleanup = () => console.log("Cleaning up..."));
|
|
3632
|
+
*
|
|
3633
|
+
* chain.add(cleanup);
|
|
3634
|
+
* ```
|
|
3635
|
+
*
|
|
3636
|
+
* ---
|
|
3637
|
+
*
|
|
3638
|
+
* @param callback The function to add to the chain.
|
|
3639
|
+
*
|
|
3640
|
+
* @returns The current instance for method chaining.
|
|
3641
|
+
*/
|
|
3642
|
+
add(e) {
|
|
3643
|
+
return this._callbacks.push(e), this;
|
|
3644
|
+
}
|
|
3645
|
+
/**
|
|
3646
|
+
* Removes a specific function from the chain.
|
|
3647
|
+
*
|
|
3648
|
+
* ---
|
|
3649
|
+
*
|
|
3650
|
+
* @example
|
|
3651
|
+
* ```ts
|
|
3652
|
+
* const chain = new CallbackChain();
|
|
3653
|
+
* const cleanup = () => console.log("Cleaning up..."));
|
|
3654
|
+
*
|
|
3655
|
+
* chain.add(cleanup);
|
|
3656
|
+
* chain.remove(cleanup);
|
|
3657
|
+
* ```
|
|
3658
|
+
*
|
|
3659
|
+
* ---
|
|
3660
|
+
*
|
|
3661
|
+
* @param callback The function to remove from the chain.
|
|
3662
|
+
*
|
|
3663
|
+
* @returns `true` if the function was found and removed, `false` otherwise.
|
|
3664
|
+
*/
|
|
3665
|
+
remove(e) {
|
|
3666
|
+
const t = this._callbacks.indexOf(e);
|
|
3667
|
+
return t < 0 ? !1 : (this._callbacks.splice(t, 1), !0);
|
|
3668
|
+
}
|
|
3669
|
+
/**
|
|
3670
|
+
* Removes all functions from the chain.
|
|
3671
|
+
*
|
|
3672
|
+
* ---
|
|
3673
|
+
*
|
|
3674
|
+
* @example
|
|
3675
|
+
* ```ts
|
|
3676
|
+
* const chain = new CallbackChain();
|
|
3677
|
+
*
|
|
3678
|
+
* chain.add(() => console.log("Doing something..."));
|
|
3679
|
+
* chain.add(() => console.log("Doing something else..."));
|
|
3680
|
+
* chain.add(() => console.log("Doing yet another thing..."));
|
|
3681
|
+
*
|
|
3682
|
+
* chain.clear();
|
|
3683
|
+
* ```
|
|
3684
|
+
*/
|
|
3685
|
+
clear() {
|
|
3686
|
+
this._callbacks.length = 0;
|
|
3687
|
+
}
|
|
3688
|
+
[Symbol.toStringTag] = "CallbackChain";
|
|
3689
|
+
}
|
|
3583
3690
|
class g {
|
|
3584
3691
|
/**
|
|
3585
3692
|
* A map containing all the subscribers for each event.
|
|
@@ -3650,17 +3757,17 @@ class g {
|
|
|
3650
3757
|
return n.push(t), this._subscribers.set(e, n), () => {
|
|
3651
3758
|
const s = n.indexOf(t);
|
|
3652
3759
|
if (s < 0)
|
|
3653
|
-
throw new
|
|
3760
|
+
throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
|
|
3654
3761
|
n.splice(s, 1);
|
|
3655
3762
|
};
|
|
3656
3763
|
}
|
|
3657
3764
|
unsubscribe(e, t) {
|
|
3658
3765
|
const n = this._subscribers.get(e);
|
|
3659
3766
|
if (!n)
|
|
3660
|
-
throw new
|
|
3767
|
+
throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
|
|
3661
3768
|
const s = n.indexOf(t);
|
|
3662
3769
|
if (s < 0)
|
|
3663
|
-
throw new
|
|
3770
|
+
throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
|
|
3664
3771
|
n.splice(s, 1), n.length === 0 && this._subscribers.delete(e);
|
|
3665
3772
|
}
|
|
3666
3773
|
unsubscribeAll(e) {
|
|
@@ -3693,7 +3800,7 @@ class g {
|
|
|
3693
3800
|
}
|
|
3694
3801
|
const q = () => {
|
|
3695
3802
|
};
|
|
3696
|
-
class
|
|
3803
|
+
class Q extends M {
|
|
3697
3804
|
/**
|
|
3698
3805
|
* The currently selected implementation of the callback.
|
|
3699
3806
|
*/
|
|
@@ -3741,7 +3848,7 @@ class K extends O {
|
|
|
3741
3848
|
_invoke;
|
|
3742
3849
|
constructor(e, t = "default") {
|
|
3743
3850
|
super(), this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = (() => {
|
|
3744
|
-
throw new
|
|
3851
|
+
throw new P(
|
|
3745
3852
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3746
3853
|
);
|
|
3747
3854
|
})), this._key = t, this._callback = e, this._invoke = (...n) => this._callback(...n);
|
|
@@ -3771,16 +3878,16 @@ class K extends O {
|
|
|
3771
3878
|
enable(e) {
|
|
3772
3879
|
if (e === void 0) {
|
|
3773
3880
|
if (!this._key)
|
|
3774
|
-
throw new
|
|
3881
|
+
throw new p(
|
|
3775
3882
|
"The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
|
|
3776
3883
|
);
|
|
3777
3884
|
e = this._key;
|
|
3778
3885
|
} else if (e) {
|
|
3779
3886
|
if (!this._callbacks.has(e))
|
|
3780
|
-
throw new
|
|
3781
|
-
} else throw new
|
|
3887
|
+
throw new p(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3888
|
+
} else throw new p("The key must be a non-empty string.");
|
|
3782
3889
|
if (this._isEnabled)
|
|
3783
|
-
throw new
|
|
3890
|
+
throw new _("The `SwitchableCallback` is already enabled.");
|
|
3784
3891
|
this._callback = this._callbacks.get(e), this._isEnabled = !0;
|
|
3785
3892
|
}
|
|
3786
3893
|
/**
|
|
@@ -3798,7 +3905,7 @@ class K extends O {
|
|
|
3798
3905
|
*/
|
|
3799
3906
|
disable() {
|
|
3800
3907
|
if (!this._isEnabled)
|
|
3801
|
-
throw new
|
|
3908
|
+
throw new _("The `SwitchableCallback` is already disabled.");
|
|
3802
3909
|
this._callback = q, this._isEnabled = !1;
|
|
3803
3910
|
}
|
|
3804
3911
|
/**
|
|
@@ -3825,7 +3932,7 @@ class K extends O {
|
|
|
3825
3932
|
if (this._callbacks.size === 0)
|
|
3826
3933
|
this._key = e, this._callback = t;
|
|
3827
3934
|
else if (this._callbacks.has(e))
|
|
3828
|
-
throw new
|
|
3935
|
+
throw new p(`The key '${e}' has already been used for another callback.`);
|
|
3829
3936
|
this._callbacks.set(e, t);
|
|
3830
3937
|
}
|
|
3831
3938
|
/**
|
|
@@ -3848,9 +3955,9 @@ class K extends O {
|
|
|
3848
3955
|
*/
|
|
3849
3956
|
unregister(e) {
|
|
3850
3957
|
if (this._key === e)
|
|
3851
|
-
throw new
|
|
3958
|
+
throw new p("Unable to unregister the currently selected callback.");
|
|
3852
3959
|
if (!this._callbacks.has(e))
|
|
3853
|
-
throw new
|
|
3960
|
+
throw new p(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3854
3961
|
this._callbacks.delete(e);
|
|
3855
3962
|
}
|
|
3856
3963
|
/**
|
|
@@ -3873,12 +3980,12 @@ class K extends O {
|
|
|
3873
3980
|
*/
|
|
3874
3981
|
switch(e) {
|
|
3875
3982
|
if (!this._callbacks.has(e))
|
|
3876
|
-
throw new
|
|
3983
|
+
throw new p(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3877
3984
|
this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
|
|
3878
3985
|
}
|
|
3879
3986
|
[Symbol.toStringTag] = "SwitchableCallback";
|
|
3880
3987
|
}
|
|
3881
|
-
class
|
|
3988
|
+
class H extends Map {
|
|
3882
3989
|
/**
|
|
3883
3990
|
* The internal {@link Publisher} instance used to publish events.
|
|
3884
3991
|
*/
|
|
@@ -4035,7 +4142,7 @@ class Q extends Map {
|
|
|
4035
4142
|
}
|
|
4036
4143
|
[Symbol.toStringTag] = "MapView";
|
|
4037
4144
|
}
|
|
4038
|
-
class
|
|
4145
|
+
class X extends Set {
|
|
4039
4146
|
/**
|
|
4040
4147
|
* The internal {@link Publisher} instance used to publish events.
|
|
4041
4148
|
*/
|
|
@@ -4191,7 +4298,7 @@ class H extends Set {
|
|
|
4191
4298
|
}
|
|
4192
4299
|
[Symbol.toStringTag] = "SetView";
|
|
4193
4300
|
}
|
|
4194
|
-
class
|
|
4301
|
+
class Z {
|
|
4195
4302
|
/**
|
|
4196
4303
|
* Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
|
|
4197
4304
|
*
|
|
@@ -4226,7 +4333,7 @@ class X {
|
|
|
4226
4333
|
*/
|
|
4227
4334
|
constructor(e = !0) {
|
|
4228
4335
|
if (!T)
|
|
4229
|
-
throw new
|
|
4336
|
+
throw new j(
|
|
4230
4337
|
"The `JSONStorage` class can only be instantiated within a browser environment."
|
|
4231
4338
|
);
|
|
4232
4339
|
this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
|
|
@@ -4499,7 +4606,7 @@ class X {
|
|
|
4499
4606
|
}
|
|
4500
4607
|
[Symbol.toStringTag] = "JSONStorage";
|
|
4501
4608
|
}
|
|
4502
|
-
class
|
|
4609
|
+
class m {
|
|
4503
4610
|
/**
|
|
4504
4611
|
* Wraps a new {@link SmartPromise} object around an existing native {@link Promise} object.
|
|
4505
4612
|
*
|
|
@@ -4524,7 +4631,7 @@ class w {
|
|
|
4524
4631
|
* @returns A new {@link SmartPromise} object that wraps the provided promise.
|
|
4525
4632
|
*/
|
|
4526
4633
|
static FromPromise(e) {
|
|
4527
|
-
return new
|
|
4634
|
+
return new m((t, n) => e.then(t, n));
|
|
4528
4635
|
}
|
|
4529
4636
|
/**
|
|
4530
4637
|
* A flag indicating whether the promise is still pending or not.
|
|
@@ -4632,7 +4739,7 @@ class w {
|
|
|
4632
4739
|
}
|
|
4633
4740
|
[Symbol.toStringTag] = "SmartPromise";
|
|
4634
4741
|
}
|
|
4635
|
-
class
|
|
4742
|
+
class R extends m {
|
|
4636
4743
|
/**
|
|
4637
4744
|
* The exposed function that allows to resolve the promise.
|
|
4638
4745
|
*
|
|
@@ -4705,7 +4812,7 @@ class M extends w {
|
|
|
4705
4812
|
}
|
|
4706
4813
|
[Symbol.toStringTag] = "DeferredPromise";
|
|
4707
4814
|
}
|
|
4708
|
-
class
|
|
4815
|
+
class z extends m {
|
|
4709
4816
|
/**
|
|
4710
4817
|
* Initializes a new instance of the {@link TimedPromise} class.
|
|
4711
4818
|
*
|
|
@@ -4734,13 +4841,13 @@ class $ extends w {
|
|
|
4734
4841
|
clearTimeout(y), n(v);
|
|
4735
4842
|
}, o = (v) => {
|
|
4736
4843
|
clearTimeout(y), s(v);
|
|
4737
|
-
}, y = setTimeout(() => o(new
|
|
4844
|
+
}, y = setTimeout(() => o(new O("The operation has timed out.")), t);
|
|
4738
4845
|
e(r, o);
|
|
4739
4846
|
});
|
|
4740
4847
|
}
|
|
4741
4848
|
[Symbol.toStringTag] = "TimedPromise";
|
|
4742
4849
|
}
|
|
4743
|
-
class
|
|
4850
|
+
class W extends m {
|
|
4744
4851
|
/**
|
|
4745
4852
|
* The number of promises currently in the queue.
|
|
4746
4853
|
*/
|
|
@@ -4773,7 +4880,7 @@ class Z extends w {
|
|
|
4773
4880
|
super((e) => e()), this._count = 0, this._isPending = !1, this._isFulfilled = !1, this._isRejected = !1;
|
|
4774
4881
|
}
|
|
4775
4882
|
enqueue(e, t) {
|
|
4776
|
-
if (this._count += 1, e instanceof
|
|
4883
|
+
if (this._count += 1, e instanceof R) {
|
|
4777
4884
|
const s = e;
|
|
4778
4885
|
e = () => (s.resolve(), s);
|
|
4779
4886
|
}
|
|
@@ -4784,16 +4891,16 @@ class Z extends w {
|
|
|
4784
4891
|
this._count -= 1, r(o);
|
|
4785
4892
|
});
|
|
4786
4893
|
};
|
|
4787
|
-
return t ? new
|
|
4894
|
+
return t ? new z(n, t) : new m(n);
|
|
4788
4895
|
}
|
|
4789
4896
|
[Symbol.toStringTag] = "PromiseQueue";
|
|
4790
4897
|
}
|
|
4791
|
-
var
|
|
4792
|
-
function
|
|
4898
|
+
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))($ || {});
|
|
4899
|
+
function U(i, e, t = 864e5) {
|
|
4793
4900
|
let n;
|
|
4794
4901
|
return i = new Date(i), e = new Date(e), i < e ? n = Math.floor : n = Math.ceil, n((e.getTime() - i.getTime()) / t);
|
|
4795
4902
|
}
|
|
4796
|
-
function
|
|
4903
|
+
function ee(i, e, t = 864e5) {
|
|
4797
4904
|
if (i = new Date(i), e = new Date(e), i >= e)
|
|
4798
4905
|
throw new b("The end date must be greater than the start date.");
|
|
4799
4906
|
return new l(function* () {
|
|
@@ -4814,12 +4921,12 @@ function I(i, e = 864e5) {
|
|
|
4814
4921
|
);
|
|
4815
4922
|
return i = new Date(i), new Date(Math.floor(i.getTime() / e) * e);
|
|
4816
4923
|
}
|
|
4817
|
-
function
|
|
4924
|
+
function te(i, e = 0) {
|
|
4818
4925
|
i = new Date(i);
|
|
4819
4926
|
const t = 7 - e, n = (i.getUTCDay() + t) % 7, s = i.getTime() - 864e5 * n;
|
|
4820
4927
|
return I(new Date(s));
|
|
4821
4928
|
}
|
|
4822
|
-
class
|
|
4929
|
+
class F {
|
|
4823
4930
|
/**
|
|
4824
4931
|
* The handle of the interval or the animation frame, depending on the environment.
|
|
4825
4932
|
* It's used to stop the game loop when the {@link GameLoop._stop} method is called.
|
|
@@ -4924,7 +5031,7 @@ class R {
|
|
|
4924
5031
|
*/
|
|
4925
5032
|
start(e = 0) {
|
|
4926
5033
|
if (this._isRunning)
|
|
4927
|
-
throw new
|
|
5034
|
+
throw new _("The game loop has already been started.");
|
|
4928
5035
|
this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
4929
5036
|
}
|
|
4930
5037
|
/**
|
|
@@ -4942,7 +5049,7 @@ class R {
|
|
|
4942
5049
|
*/
|
|
4943
5050
|
stop() {
|
|
4944
5051
|
if (!this._isRunning)
|
|
4945
|
-
throw new
|
|
5052
|
+
throw new _("The game loop had already stopped or hadn't yet started.");
|
|
4946
5053
|
if (!this._handle)
|
|
4947
5054
|
throw new x();
|
|
4948
5055
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
@@ -4987,7 +5094,7 @@ class R {
|
|
|
4987
5094
|
}
|
|
4988
5095
|
[Symbol.toStringTag] = "GameLoop";
|
|
4989
5096
|
}
|
|
4990
|
-
class
|
|
5097
|
+
class ne extends F {
|
|
4991
5098
|
/**
|
|
4992
5099
|
* Initializes a new instance of the {@link Clock} class.
|
|
4993
5100
|
*
|
|
@@ -5004,7 +5111,7 @@ class te extends R {
|
|
|
5004
5111
|
* The interval in milliseconds at which the clock will tick if the environment is not a browser.
|
|
5005
5112
|
* `TimeUnit.Second` by default.
|
|
5006
5113
|
*/
|
|
5007
|
-
constructor(e =
|
|
5114
|
+
constructor(e = S.Second) {
|
|
5008
5115
|
super((t) => this._publisher.publish("tick", t), e);
|
|
5009
5116
|
}
|
|
5010
5117
|
/**
|
|
@@ -5026,7 +5133,7 @@ class te extends R {
|
|
|
5026
5133
|
*/
|
|
5027
5134
|
start(e = 0) {
|
|
5028
5135
|
if (this._isRunning)
|
|
5029
|
-
throw new
|
|
5136
|
+
throw new _("The clock has already been started.");
|
|
5030
5137
|
this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
|
|
5031
5138
|
}
|
|
5032
5139
|
/**
|
|
@@ -5044,7 +5151,7 @@ class te extends R {
|
|
|
5044
5151
|
*/
|
|
5045
5152
|
stop() {
|
|
5046
5153
|
if (!this._isRunning)
|
|
5047
|
-
throw new
|
|
5154
|
+
throw new _("The clock had already stopped or hadn't yet started.");
|
|
5048
5155
|
if (!this._handle)
|
|
5049
5156
|
throw new x();
|
|
5050
5157
|
this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
|
|
@@ -5085,7 +5192,7 @@ class te extends R {
|
|
|
5085
5192
|
}
|
|
5086
5193
|
[Symbol.toStringTag] = "Clock";
|
|
5087
5194
|
}
|
|
5088
|
-
class
|
|
5195
|
+
class se extends F {
|
|
5089
5196
|
/**
|
|
5090
5197
|
* The total duration of the countdown in milliseconds.
|
|
5091
5198
|
*
|
|
@@ -5129,7 +5236,7 @@ class ne extends R {
|
|
|
5129
5236
|
* The interval in milliseconds at which the countdown will tick if the environment is not a browser.
|
|
5130
5237
|
* `TimeUnit.Second` by default.
|
|
5131
5238
|
*/
|
|
5132
|
-
constructor(e, t =
|
|
5239
|
+
constructor(e, t = S.Second) {
|
|
5133
5240
|
const n = () => {
|
|
5134
5241
|
const s = this.remainingTime;
|
|
5135
5242
|
s <= 0 ? (this._deferrerStop(), this._publisher.publish("tick", 0), this._publisher.publish("expire")) : this._publisher.publish("tick", s);
|
|
@@ -5150,7 +5257,7 @@ class ne extends R {
|
|
|
5150
5257
|
*/
|
|
5151
5258
|
_deferrerStop(e) {
|
|
5152
5259
|
if (!this._isRunning)
|
|
5153
|
-
throw new
|
|
5260
|
+
throw new _("The countdown hadn't yet started.");
|
|
5154
5261
|
if (!this._deferrer)
|
|
5155
5262
|
throw new x();
|
|
5156
5263
|
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 +5285,10 @@ class ne extends R {
|
|
|
5178
5285
|
*/
|
|
5179
5286
|
start(e = this.duration) {
|
|
5180
5287
|
if (this._isRunning)
|
|
5181
|
-
throw new
|
|
5288
|
+
throw new _("The countdown had already stopped or hadn't yet started.");
|
|
5182
5289
|
if (this._deferrer)
|
|
5183
5290
|
throw new x();
|
|
5184
|
-
return this._deferrer = new
|
|
5291
|
+
return this._deferrer = new R(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
|
|
5185
5292
|
}
|
|
5186
5293
|
/**
|
|
5187
5294
|
* Stops the execution of the countdown.
|
|
@@ -5263,7 +5370,7 @@ class ne extends R {
|
|
|
5263
5370
|
}
|
|
5264
5371
|
[Symbol.toStringTag] = "Countdown";
|
|
5265
5372
|
}
|
|
5266
|
-
class
|
|
5373
|
+
class re {
|
|
5267
5374
|
/**
|
|
5268
5375
|
* Generates a given number of values following a linear curve.
|
|
5269
5376
|
* The values are equally spaced and normalized between 0 and 1.
|
|
@@ -5332,7 +5439,7 @@ class se {
|
|
|
5332
5439
|
}
|
|
5333
5440
|
[Symbol.toStringTag] = "Curve";
|
|
5334
5441
|
}
|
|
5335
|
-
class
|
|
5442
|
+
class C {
|
|
5336
5443
|
/**
|
|
5337
5444
|
* Generates a random boolean value.
|
|
5338
5445
|
*
|
|
@@ -5398,35 +5505,35 @@ class F {
|
|
|
5398
5505
|
* @returns A random element from the given array.
|
|
5399
5506
|
*/
|
|
5400
5507
|
static Choice(e) {
|
|
5401
|
-
return e[
|
|
5508
|
+
return e[C.Index(e)];
|
|
5402
5509
|
}
|
|
5403
5510
|
constructor() {
|
|
5404
5511
|
}
|
|
5405
5512
|
[Symbol.toStringTag] = "Random";
|
|
5406
5513
|
}
|
|
5407
|
-
function
|
|
5408
|
-
return new
|
|
5409
|
-
}
|
|
5410
|
-
function ie() {
|
|
5411
|
-
return new w((i) => requestAnimationFrame(() => i()));
|
|
5514
|
+
function ie(i) {
|
|
5515
|
+
return new m((e) => setTimeout(e, i));
|
|
5412
5516
|
}
|
|
5413
5517
|
function oe() {
|
|
5414
|
-
return new
|
|
5518
|
+
return new m((i) => requestAnimationFrame(() => i()));
|
|
5519
|
+
}
|
|
5520
|
+
function ae() {
|
|
5521
|
+
return new m((i) => setTimeout(i));
|
|
5415
5522
|
}
|
|
5416
|
-
function
|
|
5417
|
-
return new
|
|
5523
|
+
function le(i, e = "text/javascript") {
|
|
5524
|
+
return new m((t, n) => {
|
|
5418
5525
|
const s = document.createElement("script");
|
|
5419
5526
|
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
5527
|
});
|
|
5421
5528
|
}
|
|
5422
|
-
function
|
|
5529
|
+
function ue(...i) {
|
|
5423
5530
|
return new l(function* () {
|
|
5424
5531
|
for (const e of i)
|
|
5425
5532
|
for (const t of e)
|
|
5426
5533
|
yield t;
|
|
5427
5534
|
});
|
|
5428
5535
|
}
|
|
5429
|
-
function
|
|
5536
|
+
function ce(i) {
|
|
5430
5537
|
if (i instanceof Array)
|
|
5431
5538
|
return i.length;
|
|
5432
5539
|
let e = 0;
|
|
@@ -5434,14 +5541,14 @@ function ue(i) {
|
|
|
5434
5541
|
e += 1;
|
|
5435
5542
|
return e;
|
|
5436
5543
|
}
|
|
5437
|
-
function
|
|
5544
|
+
function he(i) {
|
|
5438
5545
|
return new l(function* () {
|
|
5439
5546
|
let e = 0;
|
|
5440
5547
|
for (const t of i)
|
|
5441
5548
|
yield [e, t], e += 1;
|
|
5442
5549
|
});
|
|
5443
5550
|
}
|
|
5444
|
-
function
|
|
5551
|
+
function fe(i, e, t = 1) {
|
|
5445
5552
|
if (t <= 0)
|
|
5446
5553
|
throw new b(
|
|
5447
5554
|
"Step must be always a positive number, even when generating numbers in reverse order."
|
|
@@ -5454,7 +5561,7 @@ function he(i, e, t = 1) {
|
|
|
5454
5561
|
yield n;
|
|
5455
5562
|
});
|
|
5456
5563
|
}
|
|
5457
|
-
function
|
|
5564
|
+
function de(i) {
|
|
5458
5565
|
const e = Array.from(i);
|
|
5459
5566
|
for (let t = e.length - 1; t > 0; t -= 1) {
|
|
5460
5567
|
const n = Math.floor(Math.random() * (t + 1));
|
|
@@ -5462,7 +5569,7 @@ function fe(i) {
|
|
|
5462
5569
|
}
|
|
5463
5570
|
return e;
|
|
5464
5571
|
}
|
|
5465
|
-
function
|
|
5572
|
+
function me(i) {
|
|
5466
5573
|
return new l(function* () {
|
|
5467
5574
|
const e = /* @__PURE__ */ new Set();
|
|
5468
5575
|
for (const t of i)
|
|
@@ -5501,7 +5608,7 @@ function we(i, e) {
|
|
|
5501
5608
|
throw new f("The sum of weights must be greater than zero.");
|
|
5502
5609
|
return t / n;
|
|
5503
5610
|
}
|
|
5504
|
-
function
|
|
5611
|
+
function _e(i) {
|
|
5505
5612
|
let e = 0;
|
|
5506
5613
|
for (let t = 0; t < i.length; t += 1) {
|
|
5507
5614
|
const n = i.charCodeAt(t);
|
|
@@ -5515,71 +5622,72 @@ function pe(i) {
|
|
|
5515
5622
|
e += t;
|
|
5516
5623
|
return e;
|
|
5517
5624
|
}
|
|
5518
|
-
function
|
|
5625
|
+
function ye(i) {
|
|
5519
5626
|
return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
|
|
5520
5627
|
}
|
|
5521
|
-
const
|
|
5628
|
+
const be = "2.2.1";
|
|
5522
5629
|
export {
|
|
5523
|
-
|
|
5630
|
+
w as AggregatedAsyncIterator,
|
|
5524
5631
|
h as AggregatedIterator,
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
ne as
|
|
5528
|
-
se as
|
|
5529
|
-
|
|
5530
|
-
|
|
5632
|
+
M as CallableObject,
|
|
5633
|
+
K as CallbackChain,
|
|
5634
|
+
ne as Clock,
|
|
5635
|
+
se as Countdown,
|
|
5636
|
+
re as Curve,
|
|
5637
|
+
R as DeferredPromise,
|
|
5638
|
+
j as EnvironmentException,
|
|
5531
5639
|
c as Exception,
|
|
5532
5640
|
x as FatalErrorException,
|
|
5533
5641
|
E as FileException,
|
|
5534
5642
|
J as FileExistsException,
|
|
5535
5643
|
Y as FileNotFoundException,
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5644
|
+
F as GameLoop,
|
|
5645
|
+
Z as JSONStorage,
|
|
5646
|
+
p as KeyException,
|
|
5647
|
+
H as MapView,
|
|
5540
5648
|
L as NetworkException,
|
|
5541
|
-
|
|
5649
|
+
P as NotImplementedException,
|
|
5542
5650
|
V as PermissionException,
|
|
5543
|
-
|
|
5651
|
+
W as PromiseQueue,
|
|
5544
5652
|
g as Publisher,
|
|
5545
|
-
|
|
5653
|
+
C as Random,
|
|
5546
5654
|
b as RangeException,
|
|
5547
5655
|
u as ReducedIterator,
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5656
|
+
k as ReferenceException,
|
|
5657
|
+
_ as RuntimeException,
|
|
5658
|
+
X as SetView,
|
|
5551
5659
|
d as SmartAsyncIterator,
|
|
5552
5660
|
l as SmartIterator,
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5661
|
+
m as SmartPromise,
|
|
5662
|
+
Q as SwitchableCallback,
|
|
5663
|
+
S as TimeUnit,
|
|
5664
|
+
z as TimedPromise,
|
|
5665
|
+
O as TimeoutException,
|
|
5558
5666
|
G as TypeException,
|
|
5559
|
-
|
|
5667
|
+
be as VERSION,
|
|
5560
5668
|
f as ValueException,
|
|
5561
|
-
|
|
5669
|
+
$ as WeekDay,
|
|
5562
5670
|
we as average,
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5671
|
+
ye as capitalize,
|
|
5672
|
+
ue as chain,
|
|
5673
|
+
ce as count,
|
|
5674
|
+
U as dateDifference,
|
|
5675
|
+
ee as dateRange,
|
|
5568
5676
|
I as dateRound,
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5677
|
+
ie as delay,
|
|
5678
|
+
he as enumerate,
|
|
5679
|
+
te as getWeek,
|
|
5680
|
+
_e as hash,
|
|
5573
5681
|
T as isBrowser,
|
|
5574
5682
|
D as isNode,
|
|
5575
5683
|
B as isWorker,
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5684
|
+
le as loadScript,
|
|
5685
|
+
oe as nextAnimationFrame,
|
|
5686
|
+
fe as range,
|
|
5687
|
+
de as shuffle,
|
|
5580
5688
|
pe as sum,
|
|
5581
|
-
|
|
5582
|
-
|
|
5689
|
+
me as unique,
|
|
5690
|
+
ae as yieldToEventLoop,
|
|
5583
5691
|
A as zip
|
|
5584
5692
|
};
|
|
5585
5693
|
//# sourceMappingURL=core.esm.js.map
|