@byloth/core 2.0.0-rc.4 → 2.0.0-rc.5

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.js CHANGED
@@ -1,13 +1,13 @@
1
- var Ie = Object.defineProperty;
2
- var Ae = (i, t, e) => t in i ? Ie(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var a = (i, t, e) => Ae(i, typeof t != "symbol" ? t + "" : t, e);
4
- const Me = typeof window < "u" && typeof window.document < "u";
5
- var F;
6
- const Je = typeof process < "u" && ((F = process.versions) == null ? void 0 : F.node);
1
+ var Ae = Object.defineProperty;
2
+ var Oe = (i, t, e) => t in i ? Ae(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var a = (i, t, e) => Oe(i, typeof t != "symbol" ? t + "" : t, e);
4
+ const Re = typeof window < "u" && typeof window.document < "u";
7
5
  var P;
8
- const Ve = typeof self == "object" && ((P = self.constructor) == null ? void 0 : P.name) === "DedicatedWorkerGlobalScope";
9
- var j, I;
10
- class c extends (I = Error, j = Symbol.toStringTag, I) {
6
+ const Ve = typeof process < "u" && ((P = process.versions) == null ? void 0 : P.node);
7
+ var I;
8
+ const We = typeof self == "object" && ((I = self.constructor) == null ? void 0 : I.name) === "DedicatedWorkerGlobalScope";
9
+ var j, A;
10
+ class c extends (A = Error, j = Symbol.toStringTag, A) {
11
11
  constructor(e, n, r = "Exception") {
12
12
  super(e);
13
13
  a(this, j, "Exception");
@@ -27,120 +27,120 @@ Caused by ${n}`);
27
27
  return new c(`${e}`);
28
28
  }
29
29
  }
30
- var A, C;
31
- class x extends (C = c, A = Symbol.toStringTag, C) {
30
+ var O, C;
31
+ class g extends (C = c, O = Symbol.toStringTag, C) {
32
32
  constructor(e, n, r = "FatalErrorException") {
33
33
  e === void 0 && (e = "The program has encountered an unrecoverable error and cannot continue as expected. Please, try again later. If the problem persists, contact the support team.");
34
34
  super(e, n, r);
35
- a(this, A, "FatalErrorException");
35
+ a(this, O, "FatalErrorException");
36
36
  }
37
37
  }
38
- var D, O;
39
- class We extends (O = x, D = Symbol.toStringTag, O) {
38
+ var D, q;
39
+ class Ye extends (q = g, D = Symbol.toStringTag, q) {
40
40
  constructor(e, n, r = "NotImplementedException") {
41
41
  e === void 0 && (e = "This feature is not implemented yet. Please, try again later.");
42
42
  super(e, n, r);
43
43
  a(this, D, "NotImplementedException");
44
44
  }
45
45
  }
46
- var q, N;
47
- class Re extends (N = c, q = Symbol.toStringTag, N) {
46
+ var N, $;
47
+ class Pe extends ($ = c, N = Symbol.toStringTag, $) {
48
48
  constructor(e, n, r = "FileException") {
49
49
  super(e, n, r);
50
- a(this, q, "FileException");
50
+ a(this, N, "FileException");
51
51
  }
52
52
  }
53
- var $, J;
54
- class Ye extends (J = Re, $ = Symbol.toStringTag, J) {
53
+ var J, V;
54
+ class ze extends (V = Pe, J = Symbol.toStringTag, V) {
55
55
  constructor(e, n, r = "FileExistsException") {
56
56
  super(e, n, r);
57
- a(this, $, "FileExistsException");
57
+ a(this, J, "FileExistsException");
58
58
  }
59
59
  }
60
- var V, W;
61
- class ze extends (W = Re, V = Symbol.toStringTag, W) {
60
+ var W, Y;
61
+ class Be extends (Y = Pe, W = Symbol.toStringTag, Y) {
62
62
  constructor(e, n, r = "FileNotFoundException") {
63
63
  super(e, n, r);
64
- a(this, V, "FileNotFoundException");
64
+ a(this, W, "FileNotFoundException");
65
65
  }
66
66
  }
67
- var Y, z;
68
- class Be extends (z = c, Y = Symbol.toStringTag, z) {
67
+ var z, B;
68
+ class Ge extends (B = c, z = Symbol.toStringTag, B) {
69
69
  constructor(e, n, r = "KeyException") {
70
70
  super(e, n, r);
71
- a(this, Y, "KeyException");
71
+ a(this, z, "KeyException");
72
72
  }
73
73
  }
74
- var B, G;
75
- class Ge extends (G = c, B = Symbol.toStringTag, G) {
74
+ var G, K;
75
+ class Ke extends (K = c, G = Symbol.toStringTag, K) {
76
76
  constructor(e, n, r = "NetworkException") {
77
77
  super(e, n, r);
78
- a(this, B, "NetworkException");
78
+ a(this, G, "NetworkException");
79
79
  }
80
80
  }
81
- var K, H;
82
- class Ke extends (H = c, K = Symbol.toStringTag, H) {
81
+ var H, L;
82
+ class He extends (L = c, H = Symbol.toStringTag, L) {
83
83
  constructor(e, n, r = "PermissionException") {
84
84
  super(e, n, r);
85
- a(this, K, "PermissionException");
85
+ a(this, H, "PermissionException");
86
86
  }
87
87
  }
88
- var L, Q;
89
- class Ce extends (Q = c, L = Symbol.toStringTag, Q) {
88
+ var Q, X;
89
+ class Ce extends (X = c, Q = Symbol.toStringTag, X) {
90
90
  constructor(e, n, r = "ReferenceException") {
91
91
  super(e, n, r);
92
- a(this, L, "ReferenceException");
92
+ a(this, Q, "ReferenceException");
93
93
  }
94
94
  }
95
- var X, Z;
96
- class p extends (Z = c, X = Symbol.toStringTag, Z) {
95
+ var Z, U;
96
+ class p extends (U = c, Z = Symbol.toStringTag, U) {
97
97
  constructor(e, n, r = "RuntimeException") {
98
98
  super(e, n, r);
99
- a(this, X, "RuntimeException");
99
+ a(this, Z, "RuntimeException");
100
100
  }
101
101
  }
102
- var U, ee;
103
- class De extends (ee = p, U = Symbol.toStringTag, ee) {
102
+ var ee, te;
103
+ class De extends (te = p, ee = Symbol.toStringTag, te) {
104
104
  constructor(e, n, r = "EnvironmentException") {
105
105
  super(e, n, r);
106
- a(this, U, "EnvironmentException");
106
+ a(this, ee, "EnvironmentException");
107
107
  }
108
108
  }
109
- var te, ne;
110
- class Oe extends (ne = c, te = Symbol.toStringTag, ne) {
109
+ var ne, re;
110
+ class qe extends (re = c, ne = Symbol.toStringTag, re) {
111
111
  constructor(e, n, r = "TimeoutException") {
112
112
  super(e, n, r);
113
- a(this, te, "TimeoutException");
113
+ a(this, ne, "TimeoutException");
114
114
  }
115
115
  }
116
- var re, se;
117
- class He extends (se = c, re = Symbol.toStringTag, se) {
116
+ var se, ie;
117
+ class Le extends (ie = c, se = Symbol.toStringTag, ie) {
118
118
  constructor(e, n, r = "TypeException") {
119
119
  super(e, n, r);
120
- a(this, re, "TypeException");
120
+ a(this, se, "TypeException");
121
121
  }
122
122
  }
123
- var ie, oe;
124
- class d extends (oe = c, ie = Symbol.toStringTag, oe) {
123
+ var oe, ae;
124
+ class d extends (ae = c, oe = Symbol.toStringTag, ae) {
125
125
  constructor(e, n, r = "ValueException") {
126
126
  super(e, n, r);
127
- a(this, ie, "ValueException");
127
+ a(this, oe, "ValueException");
128
128
  }
129
129
  }
130
- var ae, ue;
131
- class Fe extends (ue = d, ae = Symbol.toStringTag, ue) {
130
+ var ue, le;
131
+ class Ie extends (le = d, ue = Symbol.toStringTag, le) {
132
132
  constructor(e, n, r = "RangeException") {
133
133
  super(e, n, r);
134
- a(this, ae, "RangeException");
134
+ a(this, ue, "RangeException");
135
135
  }
136
136
  }
137
- var le;
137
+ var ce;
138
138
  class l {
139
139
  constructor(t) {
140
140
  a(this, "_iterator");
141
141
  a(this, "return");
142
142
  a(this, "throw");
143
- a(this, le, "SmartIterator");
143
+ a(this, ce, "SmartIterator");
144
144
  t instanceof Function ? this._iterator = t() : Symbol.iterator in t ? this._iterator = t[Symbol.iterator]() : this._iterator = t, this._iterator.return && (this.return = (e) => this._iterator.return(e)), this._iterator.throw && (this.throw = (e) => this._iterator.throw(e));
145
145
  }
146
146
  every(t) {
@@ -295,21 +295,21 @@ class l {
295
295
  return this._iterator.next(...t);
296
296
  }
297
297
  groupBy(t) {
298
- return new g(this.map((e, n) => [t(e, n), e]));
298
+ return new v(this.map((e, n) => [t(e, n), e]));
299
299
  }
300
300
  toArray() {
301
301
  return Array.from(this);
302
302
  }
303
- [(le = Symbol.toStringTag, Symbol.iterator)]() {
303
+ [(ce = Symbol.toStringTag, Symbol.iterator)]() {
304
304
  return this;
305
305
  }
306
306
  }
307
- var ce;
308
- ce = Symbol.toStringTag;
309
- const y = class y {
307
+ var fe;
308
+ fe = Symbol.toStringTag;
309
+ const _ = class _ {
310
310
  constructor(t) {
311
311
  a(this, "_elements");
312
- a(this, ce, "ReducedIterator");
312
+ a(this, fe, "ReducedIterator");
313
313
  this._elements = new l(t);
314
314
  }
315
315
  every(t) {
@@ -326,14 +326,14 @@ const y = class y {
326
326
  }
327
327
  filter(t) {
328
328
  const e = this._elements.enumerate();
329
- return new y(function* () {
329
+ return new _(function* () {
330
330
  for (const [n, [r, s]] of e)
331
331
  t(r, s, n) && (yield [r, s]);
332
332
  });
333
333
  }
334
334
  map(t) {
335
335
  const e = this._elements.enumerate();
336
- return new y(function* () {
336
+ return new _(function* () {
337
337
  for (const [n, [r, s]] of e)
338
338
  yield [r, t(r, s, n)];
339
339
  });
@@ -352,7 +352,7 @@ const y = class y {
352
352
  }
353
353
  flatMap(t) {
354
354
  const e = this._elements.enumerate();
355
- return new g(function* () {
355
+ return new v(function* () {
356
356
  for (const [n, [r, s]] of e)
357
357
  for (const o of t(r, s, n))
358
358
  yield [r, o];
@@ -360,14 +360,14 @@ const y = class y {
360
360
  }
361
361
  drop(t) {
362
362
  const e = this._elements.enumerate();
363
- return new y(function* () {
363
+ return new _(function* () {
364
364
  for (const [n, [r, s]] of e)
365
365
  n >= t && (yield [r, s]);
366
366
  });
367
367
  }
368
368
  take(t) {
369
369
  const e = this._elements.enumerate();
370
- return new y(function* () {
370
+ return new _(function* () {
371
371
  for (const [n, [r, s]] of e) {
372
372
  if (n >= t)
373
373
  break;
@@ -380,7 +380,7 @@ const y = class y {
380
380
  }
381
381
  unique() {
382
382
  const t = this._elements;
383
- return new y(function* () {
383
+ return new _(function* () {
384
384
  const e = /* @__PURE__ */ new Set();
385
385
  for (const [n, r] of t)
386
386
  e.has(r) || (e.add(r), yield [n, r]);
@@ -423,13 +423,13 @@ const y = class y {
423
423
  return Object.fromEntries(this.items());
424
424
  }
425
425
  };
426
- let f = y;
427
- var fe;
428
- fe = Symbol.toStringTag;
426
+ let f = _;
427
+ var he;
428
+ he = Symbol.toStringTag;
429
429
  const m = class m {
430
430
  constructor(t) {
431
431
  a(this, "_elements");
432
- a(this, fe, "AggregatedAsyncIterator");
432
+ a(this, he, "AggregatedAsyncIterator");
433
433
  this._elements = new h(t);
434
434
  }
435
435
  async every(t) {
@@ -499,8 +499,8 @@ const m = class m {
499
499
  const n = /* @__PURE__ */ new Map();
500
500
  for await (const [r, s] of e) {
501
501
  const o = n.get(r) ?? 0, u = await t(r, s, o);
502
- for await (const _ of u)
503
- yield [r, _];
502
+ for await (const x of u)
503
+ yield [r, x];
504
504
  n.set(r, o + 1);
505
505
  }
506
506
  });
@@ -613,13 +613,13 @@ const m = class m {
613
613
  }
614
614
  };
615
615
  let S = m;
616
- var he;
616
+ var de;
617
617
  class h {
618
618
  constructor(t) {
619
619
  a(this, "_iterator");
620
620
  a(this, "return");
621
621
  a(this, "throw");
622
- a(this, he, "SmartAsyncIterator");
622
+ a(this, de, "SmartAsyncIterator");
623
623
  if (t instanceof Function) {
624
624
  const e = t();
625
625
  Symbol.asyncIterator in e ? this._iterator = e : this._iterator = async function* () {
@@ -812,16 +812,16 @@ class h {
812
812
  toArray() {
813
813
  return Array.fromAsync(this);
814
814
  }
815
- [(he = Symbol.toStringTag, Symbol.asyncIterator)]() {
815
+ [(de = Symbol.toStringTag, Symbol.asyncIterator)]() {
816
816
  return this;
817
817
  }
818
818
  }
819
- var de;
820
- de = Symbol.toStringTag;
819
+ var me;
820
+ me = Symbol.toStringTag;
821
821
  const w = class w {
822
822
  constructor(t) {
823
823
  a(this, "_elements");
824
- a(this, de, "AggregatedIterator");
824
+ a(this, me, "AggregatedIterator");
825
825
  this._elements = new l(t);
826
826
  }
827
827
  every(t) {
@@ -891,8 +891,8 @@ const w = class w {
891
891
  const n = /* @__PURE__ */ new Map();
892
892
  for (const [r, s] of e) {
893
893
  const o = n.get(r) ?? 0, u = t(r, s, o);
894
- for (const _ of u)
895
- yield [r, _];
894
+ for (const x of u)
895
+ yield [r, x];
896
896
  n.set(r, o + 1);
897
897
  }
898
898
  });
@@ -1007,39 +1007,23 @@ const w = class w {
1007
1007
  return t;
1008
1008
  }
1009
1009
  };
1010
- let g = w;
1011
- var b = /* @__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))(b || {});
1012
- function Le(i, t, e = 864e5) {
1013
- return i = new Date(i), t = new Date(t), Math.floor((t.getTime() - i.getTime()) / e);
1014
- }
1015
- function Qe(i, t, e = 864e5) {
1016
- return i = new Date(i), t = new Date(t), new l(function* () {
1017
- const n = t.getTime();
1018
- let r = i.getTime();
1019
- for (; r < n; )
1020
- yield new Date(r), r += e;
1021
- });
1022
- }
1023
- function Xe(i, t = 864e5) {
1024
- return i = new Date(i), new Date(Math.floor(i.getTime() / t) * t);
1025
- }
1026
- var me;
1027
- me = Symbol.toStringTag;
1028
- class Pe {
1029
- constructor(t, e = 30) {
1010
+ let v = w;
1011
+ var we;
1012
+ we = Symbol.toStringTag;
1013
+ class je {
1014
+ constructor(t, e = 40) {
1030
1015
  a(this, "_handle");
1031
1016
  a(this, "_startTime");
1032
1017
  a(this, "_isRunning");
1033
1018
  a(this, "_start");
1034
1019
  a(this, "_stop");
1035
- a(this, me, "GameLoop");
1036
- this._startTime = 0, this._isRunning = !1, Me ? (this._start = () => {
1020
+ a(this, we, "GameLoop");
1021
+ this._startTime = 0, this._isRunning = !1, Re ? (this._start = () => {
1037
1022
  t(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
1038
1023
  }, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
1039
- `Not a browser environment detected. Using setInterval@${e}fps instead of requestAnimationFrame...`
1024
+ `Not a browser environment detected. Using setInterval@${e}ms instead of requestAnimationFrame...`
1040
1025
  ), this._start = () => {
1041
- const n = b.Second / e;
1042
- this._handle = setInterval(() => t(this.elapsedTime), n);
1026
+ this._handle = setInterval(() => t(this.elapsedTime), e);
1043
1027
  }, this._stop = () => clearInterval(this._handle));
1044
1028
  }
1045
1029
  get startTime() {
@@ -1060,19 +1044,19 @@ class Pe {
1060
1044
  if (!this._isRunning)
1061
1045
  throw new p("The game loop hadn't yet started.");
1062
1046
  if (!this._handle)
1063
- throw new x();
1047
+ throw new g();
1064
1048
  this._stop(), this._handle = void 0, this._isRunning = !1;
1065
1049
  }
1066
1050
  }
1067
- var we;
1068
- we = Symbol.toStringTag;
1069
- class Ze {
1051
+ var _e;
1052
+ _e = Symbol.toStringTag;
1053
+ class Qe {
1070
1054
  constructor(t = !0) {
1071
1055
  a(this, "_preferPersistence");
1072
1056
  a(this, "_volatile");
1073
1057
  a(this, "_persistent");
1074
- a(this, we, "JSONStorage");
1075
- if (this._preferPersistence = t, !Me)
1058
+ a(this, _e, "JSONStorage");
1059
+ if (this._preferPersistence = t, !Re)
1076
1060
  throw new De(
1077
1061
  "The `JSONStorage` class can only be instantiated within a browser environment."
1078
1062
  );
@@ -1208,7 +1192,7 @@ class Ze {
1208
1192
  }
1209
1193
  var ye;
1210
1194
  ye = Symbol.toStringTag;
1211
- const E = class E {
1195
+ const T = class T {
1212
1196
  constructor(t) {
1213
1197
  a(this, "_isPending");
1214
1198
  a(this, "_isFulfilled");
@@ -1222,7 +1206,7 @@ const E = class E {
1222
1206
  this._promise = new Promise(t).then(e, n);
1223
1207
  }
1224
1208
  static FromPromise(t) {
1225
- return new E((e, n) => t.then(e, n));
1209
+ return new T((e, n) => t.then(e, n));
1226
1210
  }
1227
1211
  get isPending() {
1228
1212
  return this._isPending;
@@ -1243,9 +1227,9 @@ const E = class E {
1243
1227
  return this._promise.finally(t);
1244
1228
  }
1245
1229
  };
1246
- let v = E;
1247
- var pe, _e;
1248
- class qe extends (_e = v, pe = Symbol.toStringTag, _e) {
1230
+ let b = T;
1231
+ var pe, xe;
1232
+ class Ne extends (xe = b, pe = Symbol.toStringTag, xe) {
1249
1233
  constructor(e, n) {
1250
1234
  let r, s;
1251
1235
  super((o, u) => {
@@ -1266,26 +1250,80 @@ class qe extends (_e = v, pe = Symbol.toStringTag, _e) {
1266
1250
  return e.then(this.resolve, this.reject), this;
1267
1251
  }
1268
1252
  }
1269
- var xe, ge;
1270
- class Ue extends (ge = v, xe = Symbol.toStringTag, ge) {
1253
+ var ge;
1254
+ ge = Symbol.toStringTag;
1255
+ class Xe {
1256
+ constructor() {
1257
+ a(this, "_onFulfilled");
1258
+ a(this, ge, "Thenable");
1259
+ this._onFulfilled = (t) => t;
1260
+ }
1261
+ _resolve(t) {
1262
+ return this._onFulfilled(t);
1263
+ }
1264
+ then(t, e) {
1265
+ if (e) {
1266
+ const n = this._onFulfilled;
1267
+ this._onFulfilled = (r) => {
1268
+ try {
1269
+ return r = n(r), t(r);
1270
+ } catch (s) {
1271
+ return e(s);
1272
+ }
1273
+ };
1274
+ } else if (t) {
1275
+ const n = this._onFulfilled;
1276
+ this._onFulfilled = (r) => (r = n(r), t(r));
1277
+ }
1278
+ return this;
1279
+ }
1280
+ catch(t) {
1281
+ if (t) {
1282
+ const e = this._onFulfilled;
1283
+ this._onFulfilled = (n) => {
1284
+ try {
1285
+ return e(n);
1286
+ } catch (r) {
1287
+ return t(r);
1288
+ }
1289
+ };
1290
+ }
1291
+ return this;
1292
+ }
1293
+ finally(t) {
1294
+ if (t) {
1295
+ const e = this._onFulfilled;
1296
+ this._onFulfilled = (n) => {
1297
+ try {
1298
+ return e(n);
1299
+ } finally {
1300
+ t();
1301
+ }
1302
+ };
1303
+ }
1304
+ return this;
1305
+ }
1306
+ }
1307
+ var ve, be;
1308
+ class Ze extends (be = b, ve = Symbol.toStringTag, be) {
1271
1309
  constructor(e, n) {
1272
1310
  super((r, s) => {
1273
1311
  const o = (k) => {
1274
- clearTimeout(M), r(k);
1312
+ clearTimeout(F), r(k);
1275
1313
  }, u = (k) => {
1276
- clearTimeout(M), s(k);
1277
- }, M = setTimeout(() => u(new Oe("The operation has timed out.")), n);
1314
+ clearTimeout(F), s(k);
1315
+ }, F = setTimeout(() => u(new qe("The operation has timed out.")), n);
1278
1316
  e(o, u);
1279
1317
  });
1280
- a(this, xe, "TimedPromise");
1318
+ a(this, ve, "TimedPromise");
1281
1319
  }
1282
1320
  }
1283
- var ve;
1284
- ve = Symbol.toStringTag;
1285
- class je {
1321
+ var ke;
1322
+ ke = Symbol.toStringTag;
1323
+ class y {
1286
1324
  constructor() {
1287
1325
  a(this, "_subscribers");
1288
- a(this, ve, "Publisher");
1326
+ a(this, ke, "Publisher");
1289
1327
  this._subscribers = [];
1290
1328
  }
1291
1329
  subscribe(t) {
@@ -1300,47 +1338,73 @@ class je {
1300
1338
  return this._subscribers.slice().map((e) => e(...t));
1301
1339
  }
1302
1340
  }
1303
- var be, ke;
1304
- class et extends (ke = Pe, be = Symbol.toStringTag, ke) {
1305
- constructor(e = b.Second) {
1306
- super((n) => this._publisher.publish(n), e);
1307
- a(this, "_publisher");
1308
- a(this, be, "Clock");
1309
- this._publisher = new je();
1341
+ var E = /* @__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))(E || {});
1342
+ function Ue(i, t, e = 864e5) {
1343
+ return i = new Date(i), t = new Date(t), Math.floor((t.getTime() - i.getTime()) / e);
1344
+ }
1345
+ function et(i, t, e = 864e5) {
1346
+ return i = new Date(i), t = new Date(t), new l(function* () {
1347
+ const n = t.getTime();
1348
+ let r = i.getTime();
1349
+ for (; r < n; )
1350
+ yield new Date(r), r += e;
1351
+ });
1352
+ }
1353
+ function tt(i, t = 864e5) {
1354
+ return i = new Date(i), new Date(Math.floor(i.getTime() / t) * t);
1355
+ }
1356
+ var Se, Ee;
1357
+ class nt extends (Ee = je, Se = Symbol.toStringTag, Ee) {
1358
+ constructor(e = E.Second) {
1359
+ super((n) => this._ticker.publish(n), e);
1360
+ a(this, "_starter");
1361
+ a(this, "_stopper");
1362
+ a(this, "_ticker");
1363
+ a(this, Se, "Clock");
1364
+ this._starter = new y(), this._stopper = new y(), this._ticker = new y();
1310
1365
  }
1311
1366
  start(e = 0) {
1312
1367
  if (this._isRunning)
1313
1368
  throw new p("The clock has already been started.");
1314
- super.start(e);
1369
+ super.start(e), this._starter.publish();
1315
1370
  }
1316
1371
  stop() {
1317
1372
  if (!this._isRunning)
1318
1373
  throw new p("The clock hadn't yet started.");
1319
- super.stop();
1374
+ super.stop(), this._stopper.publish();
1375
+ }
1376
+ onStart(e) {
1377
+ return this._starter.subscribe(e);
1378
+ }
1379
+ onStop(e) {
1380
+ return this._stopper.subscribe(e);
1320
1381
  }
1321
1382
  onTick(e, n = 0) {
1322
1383
  if (n < 0)
1323
- throw new Fe("The tick step must be a non-negative number.");
1384
+ throw new Ie("The tick step must be a non-negative number.");
1324
1385
  if (n === 0)
1325
- return this._publisher.subscribe(e);
1386
+ return this._ticker.subscribe(e);
1326
1387
  let r = 0;
1327
- return this._publisher.subscribe((s) => {
1388
+ return this._ticker.subscribe((s) => {
1328
1389
  s - r < n || (e(s), r = s);
1329
1390
  });
1330
1391
  }
1331
1392
  }
1332
- var Se, Ee;
1333
- class tt extends (Ee = Pe, Se = Symbol.toStringTag, Ee) {
1334
- constructor(e, n = b.Second) {
1393
+ var Te, Me;
1394
+ class rt extends (Me = je, Te = Symbol.toStringTag, Me) {
1395
+ constructor(e, n = E.Second) {
1335
1396
  super(() => {
1336
1397
  const s = this.remainingTime;
1337
- this._publisher.publish(s), s <= 0 && this.stop();
1398
+ this._ticker.publish(s), s <= 0 && (this._deferrerStop(), this._expirer.publish());
1338
1399
  }, n);
1339
1400
  a(this, "_deferrer");
1340
- a(this, "_publisher");
1401
+ a(this, "_expirer");
1402
+ a(this, "_starter");
1403
+ a(this, "_stopper");
1404
+ a(this, "_ticker");
1341
1405
  a(this, "_duration");
1342
- a(this, Se, "Countdown");
1343
- this._publisher = new je(), this._duration = e;
1406
+ a(this, Te, "Countdown");
1407
+ this._expirer = new y(), this._starter = new y(), this._stopper = new y(), this._ticker = new y(), this._duration = e;
1344
1408
  }
1345
1409
  get duration() {
1346
1410
  return this._duration;
@@ -1348,36 +1412,48 @@ class tt extends (Ee = Pe, Se = Symbol.toStringTag, Ee) {
1348
1412
  get remainingTime() {
1349
1413
  return this._duration - this.elapsedTime;
1350
1414
  }
1415
+ _deferrerStop(e) {
1416
+ if (!this._isRunning)
1417
+ throw new p("The countdown hadn't yet started.");
1418
+ if (!this._deferrer)
1419
+ throw new g();
1420
+ super.stop(), e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
1421
+ }
1351
1422
  start(e = this.duration) {
1352
1423
  if (this._isRunning)
1353
1424
  throw new p("The countdown has already been started.");
1354
1425
  if (this._deferrer)
1355
- throw new x();
1356
- return this._deferrer = new qe(), super.start(this.duration - e), this._deferrer;
1426
+ throw new g();
1427
+ return this._deferrer = new Ne(), super.start(this.duration - e), this._starter.publish(), this._deferrer;
1357
1428
  }
1358
1429
  stop(e) {
1359
- if (!this._isRunning)
1360
- throw new p("The countdown hadn't yet started.");
1361
- if (!this._deferrer)
1362
- throw new x();
1363
- super.stop(), e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
1430
+ this._deferrerStop(e), this._stopper.publish(e);
1431
+ }
1432
+ onExpire(e) {
1433
+ return this._expirer.subscribe(e);
1434
+ }
1435
+ onStart(e) {
1436
+ return this._starter.subscribe(e);
1437
+ }
1438
+ onStop(e) {
1439
+ return this._stopper.subscribe(e);
1364
1440
  }
1365
1441
  onTick(e, n = 0) {
1366
1442
  if (n < 0)
1367
- throw new Fe("The tick step must be a non-negative number.");
1443
+ throw new Ie("The tick step must be a non-negative number.");
1368
1444
  if (n === 0)
1369
- return this._publisher.subscribe(e);
1445
+ return this._ticker.subscribe(e);
1370
1446
  let r = 0;
1371
- return this._publisher.subscribe((s) => {
1447
+ return this._ticker.subscribe((s) => {
1372
1448
  r - s < n || (e(s), r = s);
1373
1449
  });
1374
1450
  }
1375
1451
  }
1376
- var Te;
1377
- Te = Symbol.toStringTag;
1378
- const T = class T {
1452
+ var Fe;
1453
+ Fe = Symbol.toStringTag;
1454
+ const M = class M {
1379
1455
  constructor() {
1380
- a(this, Te, "Random");
1456
+ a(this, Fe, "Random");
1381
1457
  }
1382
1458
  static Boolean(t = 0.5) {
1383
1459
  return Math.random() < t;
@@ -1394,30 +1470,30 @@ const T = class T {
1394
1470
  return this.Integer(t.length);
1395
1471
  }
1396
1472
  static Choice(t) {
1397
- return t[T.Index(t)];
1473
+ return t[M.Index(t)];
1398
1474
  }
1399
1475
  };
1400
- let R = T;
1401
- function nt(i) {
1476
+ let R = M;
1477
+ function st(i) {
1402
1478
  return new Promise((t) => setTimeout(t, i));
1403
1479
  }
1404
- function rt() {
1480
+ function it() {
1405
1481
  return new Promise((i) => requestAnimationFrame(() => i()));
1406
1482
  }
1407
- function st(i, t = "text/javascript") {
1483
+ function ot(i, t = "text/javascript") {
1408
1484
  return new Promise((e, n) => {
1409
1485
  const r = document.createElement("script");
1410
1486
  r.async = !0, r.defer = !0, r.src = i, r.type = t, r.onload = () => e(), r.onerror = () => n(), document.body.appendChild(r);
1411
1487
  });
1412
1488
  }
1413
- function it(...i) {
1489
+ function at(...i) {
1414
1490
  return new l(function* () {
1415
1491
  for (const t of i)
1416
1492
  for (const e of t)
1417
1493
  yield e;
1418
1494
  });
1419
1495
  }
1420
- function ot(i) {
1496
+ function ut(i) {
1421
1497
  if (Array.isArray(i))
1422
1498
  return i.length;
1423
1499
  let t = 0;
@@ -1425,21 +1501,21 @@ function ot(i) {
1425
1501
  t += 1;
1426
1502
  return t;
1427
1503
  }
1428
- function at(i) {
1504
+ function lt(i) {
1429
1505
  return new l(function* () {
1430
1506
  let t = 0;
1431
1507
  for (const e of i)
1432
1508
  yield [t, e], t += 1;
1433
1509
  });
1434
1510
  }
1435
- function ut(i, t, e = 1) {
1511
+ function ct(i, t, e = 1) {
1436
1512
  return new l(function* () {
1437
1513
  t === void 0 && (t = i, i = 0), i > t && (e = e ?? -1);
1438
1514
  for (let n = i; n < t; n += e)
1439
1515
  yield n;
1440
1516
  });
1441
1517
  }
1442
- function lt(i) {
1518
+ function ft(i) {
1443
1519
  const t = Array.from(i);
1444
1520
  for (let e = t.length - 1; e > 0; e -= 1) {
1445
1521
  const n = Math.floor(Math.random() * (e + 1));
@@ -1447,14 +1523,14 @@ function lt(i) {
1447
1523
  }
1448
1524
  return t;
1449
1525
  }
1450
- function ct(i) {
1526
+ function ht(i) {
1451
1527
  return new l(function* () {
1452
1528
  const t = /* @__PURE__ */ new Set();
1453
1529
  for (const e of i)
1454
1530
  t.has(e) || (t.add(e), yield e);
1455
1531
  });
1456
1532
  }
1457
- function Ne(i, t) {
1533
+ function $e(i, t) {
1458
1534
  return new l(function* () {
1459
1535
  const e = i[Symbol.iterator](), n = t[Symbol.iterator]();
1460
1536
  for (; ; ) {
@@ -1465,7 +1541,7 @@ function Ne(i, t) {
1465
1541
  }
1466
1542
  });
1467
1543
  }
1468
- function ft(i, t) {
1544
+ function dt(i, t) {
1469
1545
  if (t === void 0) {
1470
1546
  let s = 0, o = 0;
1471
1547
  for (const u of i)
@@ -1475,7 +1551,7 @@ function ft(i, t) {
1475
1551
  return s / o;
1476
1552
  }
1477
1553
  let e = 0, n = 0, r = 0;
1478
- for (const [s, o] of Ne(i, t)) {
1554
+ for (const [s, o] of $e(i, t)) {
1479
1555
  if (o <= 0)
1480
1556
  throw new d(`The weight for the value #${r} must be greater than zero.`);
1481
1557
  e += s * o, n += o, r += 1;
@@ -1486,7 +1562,7 @@ function ft(i, t) {
1486
1562
  throw new d("The sum of weights must be greater than zero.");
1487
1563
  return e / n;
1488
1564
  }
1489
- function ht(i) {
1565
+ function mt(i) {
1490
1566
  let t = 0;
1491
1567
  for (let e = 0; e < i.length; e += 1) {
1492
1568
  const n = i.charCodeAt(e);
@@ -1494,67 +1570,68 @@ function ht(i) {
1494
1570
  }
1495
1571
  return t;
1496
1572
  }
1497
- function dt(i) {
1573
+ function wt(i) {
1498
1574
  let t = 0;
1499
1575
  for (const e of i)
1500
1576
  t += e;
1501
1577
  return t;
1502
1578
  }
1503
- function mt(i) {
1579
+ function _t(i) {
1504
1580
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
1505
1581
  }
1506
- const wt = "2.0.0-rc.4";
1582
+ const yt = "2.0.0-rc.5";
1507
1583
  export {
1508
1584
  S as AggregatedAsyncIterator,
1509
- g as AggregatedIterator,
1510
- et as Clock,
1511
- tt as Countdown,
1512
- qe as DeferredPromise,
1585
+ v as AggregatedIterator,
1586
+ nt as Clock,
1587
+ rt as Countdown,
1588
+ Ne as DeferredPromise,
1513
1589
  c as Exception,
1514
- x as FatalErrorException,
1515
- Re as FileException,
1516
- Ye as FileExistsException,
1517
- ze as FileNotFoundException,
1518
- Pe as GameLoop,
1519
- Ze as JSONStorage,
1520
- Be as KeyException,
1521
- Ge as NetworkException,
1522
- We as NotImplementedException,
1523
- Ke as PermissionException,
1524
- je as Publisher,
1590
+ g as FatalErrorException,
1591
+ Pe as FileException,
1592
+ ze as FileExistsException,
1593
+ Be as FileNotFoundException,
1594
+ je as GameLoop,
1595
+ Qe as JSONStorage,
1596
+ Ge as KeyException,
1597
+ Ke as NetworkException,
1598
+ Ye as NotImplementedException,
1599
+ He as PermissionException,
1600
+ y as Publisher,
1525
1601
  R as Random,
1526
- Fe as RangeException,
1602
+ Ie as RangeException,
1527
1603
  f as ReducedIterator,
1528
1604
  Ce as ReferenceException,
1529
1605
  p as RuntimeException,
1530
1606
  h as SmartAsyncIterator,
1531
1607
  l as SmartIterator,
1532
- v as SmartPromise,
1533
- b as TimeUnit,
1534
- Ue as TimedPromise,
1535
- Oe as TimeoutException,
1536
- He as TypeException,
1537
- wt as VERSION,
1608
+ b as SmartPromise,
1609
+ Xe as Thenable,
1610
+ E as TimeUnit,
1611
+ Ze as TimedPromise,
1612
+ qe as TimeoutException,
1613
+ Le as TypeException,
1614
+ yt as VERSION,
1538
1615
  d as ValueException,
1539
- ft as average,
1540
- mt as capitalize,
1541
- it as chain,
1542
- ot as count,
1543
- Le as dateDifference,
1544
- Qe as dateRange,
1545
- Xe as dateRound,
1546
- nt as delay,
1547
- at as enumerate,
1548
- ht as hash,
1549
- Me as isBrowser,
1550
- Je as isNode,
1551
- Ve as isWebWorker,
1552
- st as loadScript,
1553
- rt as nextAnimationFrame,
1554
- ut as range,
1555
- lt as shuffle,
1556
- dt as sum,
1557
- ct as unique,
1558
- Ne as zip
1616
+ dt as average,
1617
+ _t as capitalize,
1618
+ at as chain,
1619
+ ut as count,
1620
+ Ue as dateDifference,
1621
+ et as dateRange,
1622
+ tt as dateRound,
1623
+ st as delay,
1624
+ lt as enumerate,
1625
+ mt as hash,
1626
+ Re as isBrowser,
1627
+ Ve as isNode,
1628
+ We as isWebWorker,
1629
+ ot as loadScript,
1630
+ it as nextAnimationFrame,
1631
+ ct as range,
1632
+ ft as shuffle,
1633
+ wt as sum,
1634
+ ht as unique,
1635
+ $e as zip
1559
1636
  };
1560
1637
  //# sourceMappingURL=core.js.map