@certik/skynet 0.22.0 → 0.22.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build.ts +23 -0
  3. package/bun.lockb +0 -0
  4. package/dist/abi.d.ts +1 -2
  5. package/dist/abi.js +1 -46
  6. package/dist/address.d.ts +0 -1
  7. package/dist/address.js +1 -46
  8. package/dist/api.d.ts +0 -1
  9. package/dist/api.js +100 -35013
  10. package/dist/app.d.ts +1 -2
  11. package/dist/app.js +1185 -70817
  12. package/dist/availability.d.ts +0 -1
  13. package/dist/availability.js +7 -800
  14. package/dist/cli.d.ts +0 -1
  15. package/dist/cli.js +1 -46
  16. package/dist/const.d.ts +0 -1
  17. package/dist/const.js +2 -47
  18. package/dist/databricks.d.ts +0 -1
  19. package/dist/databricks.js +12 -84724
  20. package/dist/date.d.ts +0 -1
  21. package/dist/date.js +2 -47
  22. package/dist/deploy.d.ts +0 -1
  23. package/dist/deploy.js +27 -16944
  24. package/dist/dynamodb.d.ts +3 -4
  25. package/dist/dynamodb.js +146 -27032
  26. package/dist/env.d.ts +2 -3
  27. package/dist/env.js +1 -46
  28. package/dist/graphql.d.ts +0 -1
  29. package/dist/graphql.js +1 -46
  30. package/dist/indexer.d.ts +0 -1
  31. package/dist/indexer.js +552 -36430
  32. package/dist/log.d.ts +0 -1
  33. package/dist/log.js +1 -46
  34. package/dist/object-hash.d.ts +0 -1
  35. package/dist/object-hash.js +3 -388
  36. package/dist/opsgenie.d.ts +1 -1
  37. package/dist/opsgenie.js +3 -284
  38. package/dist/por.d.ts +0 -1
  39. package/dist/por.js +1 -45
  40. package/dist/s3.d.ts +7 -8
  41. package/dist/s3.js +27 -28783
  42. package/dist/search.d.ts +0 -1
  43. package/dist/search.js +6 -37655
  44. package/dist/selector.d.ts +0 -1
  45. package/dist/selector.js +1 -46
  46. package/dist/slack.d.ts +0 -1
  47. package/dist/slack.js +3 -16815
  48. package/dist/util.d.ts +0 -1
  49. package/dist/util.js +1 -46
  50. package/examples/api.ts +1 -1
  51. package/examples/indexer.ts +1 -1
  52. package/examples/mode-indexer.ts +1 -1
  53. package/package.json +4 -3
  54. package/{graphql.ts → src/graphql.ts} +1 -1
  55. package/{opsgenie.ts → src/opsgenie.ts} +2 -1
  56. package/tsconfig.build.json +2 -6
  57. package/tsconfig.json +11 -20
  58. package/dist/abi.d.ts.map +0 -1
  59. package/dist/address.d.ts.map +0 -1
  60. package/dist/api.d.ts.map +0 -1
  61. package/dist/app.d.ts.map +0 -1
  62. package/dist/availability.d.ts.map +0 -1
  63. package/dist/cli.d.ts.map +0 -1
  64. package/dist/const.d.ts.map +0 -1
  65. package/dist/databricks.d.ts.map +0 -1
  66. package/dist/date.d.ts.map +0 -1
  67. package/dist/deploy.d.ts.map +0 -1
  68. package/dist/dynamodb.d.ts.map +0 -1
  69. package/dist/env.d.ts.map +0 -1
  70. package/dist/graphql.d.ts.map +0 -1
  71. package/dist/indexer.d.ts.map +0 -1
  72. package/dist/log.d.ts.map +0 -1
  73. package/dist/object-hash.d.ts.map +0 -1
  74. package/dist/opsgenie.d.ts.map +0 -1
  75. package/dist/por.d.ts.map +0 -1
  76. package/dist/s3.d.ts.map +0 -1
  77. package/dist/search.d.ts.map +0 -1
  78. package/dist/selector.d.ts.map +0 -1
  79. package/dist/slack.d.ts.map +0 -1
  80. package/dist/util.d.ts.map +0 -1
  81. package/dist/xxhash.win32-x64-msvc-hrdz34v7.node +0 -0
  82. /package/{abi.ts → src/abi.ts} +0 -0
  83. /package/{address.ts → src/address.ts} +0 -0
  84. /package/{api.ts → src/api.ts} +0 -0
  85. /package/{app.ts → src/app.ts} +0 -0
  86. /package/{availability.ts → src/availability.ts} +0 -0
  87. /package/{cli.ts → src/cli.ts} +0 -0
  88. /package/{const.ts → src/const.ts} +0 -0
  89. /package/{databricks.ts → src/databricks.ts} +0 -0
  90. /package/{date.ts → src/date.ts} +0 -0
  91. /package/{deploy.ts → src/deploy.ts} +0 -0
  92. /package/{dynamodb.ts → src/dynamodb.ts} +0 -0
  93. /package/{env.ts → src/env.ts} +0 -0
  94. /package/{indexer.ts → src/indexer.ts} +0 -0
  95. /package/{log.ts → src/log.ts} +0 -0
  96. /package/{object-hash.ts → src/object-hash.ts} +0 -0
  97. /package/{por.ts → src/por.ts} +0 -0
  98. /package/{s3.ts → src/s3.ts} +0 -0
  99. /package/{search.ts → src/search.ts} +0 -0
  100. /package/{selector.ts → src/selector.ts} +0 -0
  101. /package/{slack.ts → src/slack.ts} +0 -0
  102. /package/{util.ts → src/util.ts} +0 -0
@@ -1,392 +1,7 @@
1
- // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
- var __moduleCache = /* @__PURE__ */ new WeakMap;
20
- var __toCommonJS = (from) => {
21
- var entry = __moduleCache.get(from), desc;
22
- if (entry)
23
- return entry;
24
- entry = __defProp({}, "__esModule", { value: true });
25
- if (from && typeof from === "object" || typeof from === "function")
26
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
- get: () => from[key],
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- }));
30
- __moduleCache.set(from, entry);
31
- return entry;
32
- };
33
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
- var __export = (target, all) => {
35
- for (var name in all)
36
- __defProp(target, name, {
37
- get: all[name],
38
- enumerable: true,
39
- configurable: true,
40
- set: (newValue) => all[name] = () => newValue
41
- });
42
- };
43
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
44
- var __require = import.meta.require;
45
-
46
- // node_modules/@node-rs/xxhash-win32-x64-msvc/xxhash.win32-x64-msvc.node
47
- var require_xxhash_win32_x64_msvc = __commonJS((exports, module) => {
48
- module.exports = __require("./xxhash.win32-x64-msvc-hrdz34v7.node");
49
- });
50
-
51
- // node_modules/@node-rs/xxhash/index.js
52
- var require_xxhash = __commonJS((exports, module) => {
53
- var __filename = "G:\\certik\\certik-skynet\\lib-skynet\\node_modules\\@node-rs\\xxhash\\index.js";
54
- var { createRequire } = __require("module");
55
- __require = createRequire(__filename);
56
- var { readFileSync } = __require("fs");
57
- var nativeBinding = null;
58
- var loadErrors = [];
59
- var isMusl = () => {
60
- let musl = false;
61
- if (process.platform === "linux") {
62
- musl = isMuslFromFilesystem();
63
- if (musl === null) {
64
- musl = isMuslFromReport();
65
- }
66
- if (musl === null) {
67
- musl = isMuslFromChildProcess();
68
- }
69
- }
70
- return musl;
71
- };
72
- var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
73
- var isMuslFromFilesystem = () => {
74
- try {
75
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
76
- } catch {
77
- return null;
78
- }
79
- };
80
- var isMuslFromReport = () => {
81
- const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
82
- if (!report) {
83
- return null;
84
- }
85
- if (report.header && report.header.glibcVersionRuntime) {
86
- return false;
87
- }
88
- if (Array.isArray(report.sharedObjects)) {
89
- if (report.sharedObjects.some(isFileMusl)) {
90
- return true;
91
- }
92
- }
93
- return false;
94
- };
95
- var isMuslFromChildProcess = () => {
96
- try {
97
- return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
98
- } catch (e) {
99
- return false;
100
- }
101
- };
102
- function requireNative() {
103
- if (process.platform === "android") {
104
- if (process.arch === "arm64") {
105
- try {
106
- return (()=>{throw new Error("Cannot require module "+"./xxhash.android-arm64.node");})();
107
- } catch (e) {
108
- loadErrors.push(e);
109
- }
110
- try {
111
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-android-arm64");})();
112
- } catch (e) {
113
- loadErrors.push(e);
114
- }
115
- } else if (process.arch === "arm") {
116
- try {
117
- return (()=>{throw new Error("Cannot require module "+"./xxhash.android-arm-eabi.node");})();
118
- } catch (e) {
119
- loadErrors.push(e);
120
- }
121
- try {
122
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-android-arm-eabi");})();
123
- } catch (e) {
124
- loadErrors.push(e);
125
- }
126
- } else {
127
- loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
128
- }
129
- } else if (process.platform === "win32") {
130
- if (process.arch === "x64") {
131
- try {
132
- return (()=>{throw new Error("Cannot require module "+"./xxhash.win32-x64-msvc.node");})();
133
- } catch (e) {
134
- loadErrors.push(e);
135
- }
136
- try {
137
- return require_xxhash_win32_x64_msvc();
138
- } catch (e) {
139
- loadErrors.push(e);
140
- }
141
- } else if (process.arch === "ia32") {
142
- try {
143
- return (()=>{throw new Error("Cannot require module "+"./xxhash.win32-ia32-msvc.node");})();
144
- } catch (e) {
145
- loadErrors.push(e);
146
- }
147
- try {
148
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-win32-ia32-msvc");})();
149
- } catch (e) {
150
- loadErrors.push(e);
151
- }
152
- } else if (process.arch === "arm64") {
153
- try {
154
- return (()=>{throw new Error("Cannot require module "+"./xxhash.win32-arm64-msvc.node");})();
155
- } catch (e) {
156
- loadErrors.push(e);
157
- }
158
- try {
159
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-win32-arm64-msvc");})();
160
- } catch (e) {
161
- loadErrors.push(e);
162
- }
163
- } else {
164
- loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
165
- }
166
- } else if (process.platform === "darwin") {
167
- try {
168
- return (()=>{throw new Error("Cannot require module "+"./xxhash.darwin-universal.node");})();
169
- } catch (e) {
170
- loadErrors.push(e);
171
- }
172
- try {
173
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-darwin-universal");})();
174
- } catch (e) {
175
- loadErrors.push(e);
176
- }
177
- if (process.arch === "x64") {
178
- try {
179
- return (()=>{throw new Error("Cannot require module "+"./xxhash.darwin-x64.node");})();
180
- } catch (e) {
181
- loadErrors.push(e);
182
- }
183
- try {
184
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-darwin-x64");})();
185
- } catch (e) {
186
- loadErrors.push(e);
187
- }
188
- } else if (process.arch === "arm64") {
189
- try {
190
- return (()=>{throw new Error("Cannot require module "+"./xxhash.darwin-arm64.node");})();
191
- } catch (e) {
192
- loadErrors.push(e);
193
- }
194
- try {
195
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-darwin-arm64");})();
196
- } catch (e) {
197
- loadErrors.push(e);
198
- }
199
- } else {
200
- loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
201
- }
202
- } else if (process.platform === "freebsd") {
203
- if (process.arch === "x64") {
204
- try {
205
- return (()=>{throw new Error("Cannot require module "+"./xxhash.freebsd-x64.node");})();
206
- } catch (e) {
207
- loadErrors.push(e);
208
- }
209
- try {
210
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-freebsd-x64");})();
211
- } catch (e) {
212
- loadErrors.push(e);
213
- }
214
- } else if (process.arch === "arm64") {
215
- try {
216
- return (()=>{throw new Error("Cannot require module "+"./xxhash.freebsd-arm64.node");})();
217
- } catch (e) {
218
- loadErrors.push(e);
219
- }
220
- try {
221
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-freebsd-arm64");})();
222
- } catch (e) {
223
- loadErrors.push(e);
224
- }
225
- } else {
226
- loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
227
- }
228
- } else if (process.platform === "linux") {
229
- if (process.arch === "x64") {
230
- if (isMusl()) {
231
- try {
232
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-x64-musl.node");})();
233
- } catch (e) {
234
- loadErrors.push(e);
235
- }
236
- try {
237
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-x64-musl");})();
238
- } catch (e) {
239
- loadErrors.push(e);
240
- }
241
- } else {
242
- try {
243
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-x64-gnu.node");})();
244
- } catch (e) {
245
- loadErrors.push(e);
246
- }
247
- try {
248
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-x64-gnu");})();
249
- } catch (e) {
250
- loadErrors.push(e);
251
- }
252
- }
253
- } else if (process.arch === "arm64") {
254
- if (isMusl()) {
255
- try {
256
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-arm64-musl.node");})();
257
- } catch (e) {
258
- loadErrors.push(e);
259
- }
260
- try {
261
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-arm64-musl");})();
262
- } catch (e) {
263
- loadErrors.push(e);
264
- }
265
- } else {
266
- try {
267
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-arm64-gnu.node");})();
268
- } catch (e) {
269
- loadErrors.push(e);
270
- }
271
- try {
272
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-arm64-gnu");})();
273
- } catch (e) {
274
- loadErrors.push(e);
275
- }
276
- }
277
- } else if (process.arch === "arm") {
278
- if (isMusl()) {
279
- try {
280
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-arm-musleabihf.node");})();
281
- } catch (e) {
282
- loadErrors.push(e);
283
- }
284
- try {
285
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-arm-musleabihf");})();
286
- } catch (e) {
287
- loadErrors.push(e);
288
- }
289
- } else {
290
- try {
291
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-arm-gnueabihf.node");})();
292
- } catch (e) {
293
- loadErrors.push(e);
294
- }
295
- try {
296
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-arm-gnueabihf");})();
297
- } catch (e) {
298
- loadErrors.push(e);
299
- }
300
- }
301
- } else if (process.arch === "riscv64") {
302
- if (isMusl()) {
303
- try {
304
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-riscv64-musl.node");})();
305
- } catch (e) {
306
- loadErrors.push(e);
307
- }
308
- try {
309
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-riscv64-musl");})();
310
- } catch (e) {
311
- loadErrors.push(e);
312
- }
313
- } else {
314
- try {
315
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-riscv64-gnu.node");})();
316
- } catch (e) {
317
- loadErrors.push(e);
318
- }
319
- try {
320
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-riscv64-gnu");})();
321
- } catch (e) {
322
- loadErrors.push(e);
323
- }
324
- }
325
- } else if (process.arch === "ppc64") {
326
- try {
327
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-ppc64-gnu.node");})();
328
- } catch (e) {
329
- loadErrors.push(e);
330
- }
331
- try {
332
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-ppc64-gnu");})();
333
- } catch (e) {
334
- loadErrors.push(e);
335
- }
336
- } else if (process.arch === "s390x") {
337
- try {
338
- return (()=>{throw new Error("Cannot require module "+"./xxhash.linux-s390x-gnu.node");})();
339
- } catch (e) {
340
- loadErrors.push(e);
341
- }
342
- try {
343
- return (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-linux-s390x-gnu");})();
344
- } catch (e) {
345
- loadErrors.push(e);
346
- }
347
- } else {
348
- loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
349
- }
350
- } else {
351
- loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
352
- }
353
- }
354
- nativeBinding = requireNative();
355
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
356
- try {
357
- nativeBinding = (()=>{throw new Error("Cannot require module "+"./xxhash.wasi.cjs");})();
358
- } catch (err) {
359
- if (process.env.NAPI_RS_FORCE_WASI) {
360
- loadErrors.push(err);
361
- }
362
- }
363
- if (!nativeBinding) {
364
- try {
365
- nativeBinding = (()=>{throw new Error("Cannot require module "+"@node-rs/xxhash-wasm32-wasi");})();
366
- } catch (err) {
367
- if (process.env.NAPI_RS_FORCE_WASI) {
368
- loadErrors.push(err);
369
- }
370
- }
371
- }
372
- }
373
- if (!nativeBinding) {
374
- if (loadErrors.length > 0) {
375
- throw new Error("Failed to load native binding", { cause: loadErrors });
376
- }
377
- throw new Error(`Failed to load native binding`);
378
- }
379
- exports.Xxh32 = nativeBinding.Xxh32;
380
- exports.Xxh64 = nativeBinding.Xxh64;
381
- exports.xxh32 = nativeBinding.xxh32;
382
- exports.xxh64 = nativeBinding.xxh64;
383
- exports.xxh3 = nativeBinding.xxh3;
384
- });
385
-
386
- // object-hash.ts
387
- var import_xxhash = __toESM(require_xxhash(), 1);
1
+ // src/object-hash.ts
2
+ import xh from "@node-rs/xxhash";
388
3
  function getHash(obj) {
389
- const xxh3 = import_xxhash.default.xxh3.Xxh3.withSeed();
4
+ const xxh3 = xh.xxh3.Xxh3.withSeed();
390
5
  hash(obj, xxh3);
391
6
  return xxh3.digest().toString(16);
392
7
  }
@@ -442,418 +57,10 @@ function objectHash(obj, xxh3) {
442
57
  }
443
58
  }
444
59
 
445
- // node_modules/p-throttle/index.js
446
- var registry = new FinalizationRegistry(({ signal, aborted }) => {
447
- signal?.removeEventListener("abort", aborted);
448
- });
449
- function pThrottle({ limit, interval, strict, signal, onDelay }) {
450
- if (!Number.isFinite(limit)) {
451
- throw new TypeError("Expected `limit` to be a finite number");
452
- }
453
- if (!Number.isFinite(interval)) {
454
- throw new TypeError("Expected `interval` to be a finite number");
455
- }
456
- const queue = new Map;
457
- let currentTick = 0;
458
- let activeCount = 0;
459
- function windowedDelay() {
460
- const now = Date.now();
461
- if (now - currentTick > interval) {
462
- activeCount = 1;
463
- currentTick = now;
464
- return 0;
465
- }
466
- if (activeCount < limit) {
467
- activeCount++;
468
- } else {
469
- currentTick += interval;
470
- activeCount = 1;
471
- }
472
- return currentTick - now;
473
- }
474
- const strictTicks = [];
475
- function strictDelay() {
476
- const now = Date.now();
477
- if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
478
- strictTicks.length = 0;
479
- }
480
- if (strictTicks.length < limit) {
481
- strictTicks.push(now);
482
- return 0;
483
- }
484
- const nextExecutionTime = strictTicks[0] + interval;
485
- strictTicks.shift();
486
- strictTicks.push(nextExecutionTime);
487
- return Math.max(0, nextExecutionTime - now);
488
- }
489
- const getDelay = strict ? strictDelay : windowedDelay;
490
- return (function_) => {
491
- const throttled = function(...arguments_) {
492
- if (!throttled.isEnabled) {
493
- return (async () => function_.apply(this, arguments_))();
494
- }
495
- let timeoutId;
496
- return new Promise((resolve, reject) => {
497
- const execute = () => {
498
- resolve(function_.apply(this, arguments_));
499
- queue.delete(timeoutId);
500
- };
501
- const delay = getDelay();
502
- if (delay > 0) {
503
- timeoutId = setTimeout(execute, delay);
504
- queue.set(timeoutId, reject);
505
- onDelay?.(...arguments_);
506
- } else {
507
- execute();
508
- }
509
- });
510
- };
511
- const aborted = () => {
512
- for (const timeout of queue.keys()) {
513
- clearTimeout(timeout);
514
- queue.get(timeout)(signal.reason);
515
- }
516
- queue.clear();
517
- strictTicks.splice(0, strictTicks.length);
518
- };
519
- registry.register(throttled, { signal, aborted });
520
- signal?.throwIfAborted();
521
- signal?.addEventListener("abort", aborted, { once: true });
522
- throttled.isEnabled = true;
523
- Object.defineProperty(throttled, "queueSize", {
524
- get() {
525
- return queue.size;
526
- }
527
- });
528
- return throttled;
529
- };
530
- }
531
-
532
- // node_modules/mimic-fn/index.js
533
- var copyProperty = (to, from, property, ignoreNonConfigurable) => {
534
- if (property === "length" || property === "prototype") {
535
- return;
536
- }
537
- if (property === "arguments" || property === "caller") {
538
- return;
539
- }
540
- const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
541
- const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
542
- if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
543
- return;
544
- }
545
- Object.defineProperty(to, property, fromDescriptor);
546
- };
547
- var canCopyProperty = function(toDescriptor, fromDescriptor) {
548
- return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
549
- };
550
- var changePrototype = (to, from) => {
551
- const fromPrototype = Object.getPrototypeOf(from);
552
- if (fromPrototype === Object.getPrototypeOf(to)) {
553
- return;
554
- }
555
- Object.setPrototypeOf(to, fromPrototype);
556
- };
557
- var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
558
- ${fromBody}`;
559
- var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
560
- var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
561
- var changeToString = (to, from, name) => {
562
- const withName = name === "" ? "" : `with ${name.trim()}() `;
563
- const newToString = wrappedToString.bind(null, withName, from.toString());
564
- Object.defineProperty(newToString, "name", toStringName);
565
- Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
566
- };
567
- function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
568
- const { name } = to;
569
- for (const property of Reflect.ownKeys(from)) {
570
- copyProperty(to, from, property, ignoreNonConfigurable);
571
- }
572
- changePrototype(to, from);
573
- changeToString(to, from, name);
574
- return to;
575
- }
576
-
577
- // node_modules/p-memoize/dist/index.js
578
- var cacheStore = new WeakMap;
579
- function pMemoize(fn, { cacheKey = ([firstArgument]) => firstArgument, cache = new Map } = {}) {
580
- const promiseCache = new Map;
581
- const memoized = function(...arguments_) {
582
- const key = cacheKey(arguments_);
583
- if (promiseCache.has(key)) {
584
- return promiseCache.get(key);
585
- }
586
- const promise = (async () => {
587
- try {
588
- if (cache && await cache.has(key)) {
589
- return await cache.get(key);
590
- }
591
- const promise2 = fn.apply(this, arguments_);
592
- const result = await promise2;
593
- try {
594
- return result;
595
- } finally {
596
- if (cache) {
597
- await cache.set(key, result);
598
- }
599
- }
600
- } finally {
601
- promiseCache.delete(key);
602
- }
603
- })();
604
- promiseCache.set(key, promise);
605
- return promise;
606
- };
607
- mimicFunction(memoized, fn, {
608
- ignoreNonConfigurable: true
609
- });
610
- cacheStore.set(memoized, cache);
611
- return memoized;
612
- }
613
-
614
- // node_modules/quick-lru/index.js
615
- class QuickLRU extends Map {
616
- #size = 0;
617
- #cache = new Map;
618
- #oldCache = new Map;
619
- #maxSize;
620
- #maxAge;
621
- #onEviction;
622
- constructor(options = {}) {
623
- super();
624
- if (!(options.maxSize && options.maxSize > 0)) {
625
- throw new TypeError("`maxSize` must be a number greater than 0");
626
- }
627
- if (typeof options.maxAge === "number" && options.maxAge === 0) {
628
- throw new TypeError("`maxAge` must be a number greater than 0");
629
- }
630
- this.#maxSize = options.maxSize;
631
- this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;
632
- this.#onEviction = options.onEviction;
633
- }
634
- get __oldCache() {
635
- return this.#oldCache;
636
- }
637
- #emitEvictions(cache) {
638
- if (typeof this.#onEviction !== "function") {
639
- return;
640
- }
641
- for (const [key, item] of cache) {
642
- this.#onEviction(key, item.value);
643
- }
644
- }
645
- #deleteIfExpired(key, item) {
646
- if (typeof item.expiry === "number" && item.expiry <= Date.now()) {
647
- if (typeof this.#onEviction === "function") {
648
- this.#onEviction(key, item.value);
649
- }
650
- return this.delete(key);
651
- }
652
- return false;
653
- }
654
- #getOrDeleteIfExpired(key, item) {
655
- const deleted = this.#deleteIfExpired(key, item);
656
- if (deleted === false) {
657
- return item.value;
658
- }
659
- }
660
- #getItemValue(key, item) {
661
- return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;
662
- }
663
- #peek(key, cache) {
664
- const item = cache.get(key);
665
- return this.#getItemValue(key, item);
666
- }
667
- #set(key, value) {
668
- this.#cache.set(key, value);
669
- this.#size++;
670
- if (this.#size >= this.#maxSize) {
671
- this.#size = 0;
672
- this.#emitEvictions(this.#oldCache);
673
- this.#oldCache = this.#cache;
674
- this.#cache = new Map;
675
- }
676
- }
677
- #moveToRecent(key, item) {
678
- this.#oldCache.delete(key);
679
- this.#set(key, item);
680
- }
681
- *#entriesAscending() {
682
- for (const item of this.#oldCache) {
683
- const [key, value] = item;
684
- if (!this.#cache.has(key)) {
685
- const deleted = this.#deleteIfExpired(key, value);
686
- if (deleted === false) {
687
- yield item;
688
- }
689
- }
690
- }
691
- for (const item of this.#cache) {
692
- const [key, value] = item;
693
- const deleted = this.#deleteIfExpired(key, value);
694
- if (deleted === false) {
695
- yield item;
696
- }
697
- }
698
- }
699
- get(key) {
700
- if (this.#cache.has(key)) {
701
- const item = this.#cache.get(key);
702
- return this.#getItemValue(key, item);
703
- }
704
- if (this.#oldCache.has(key)) {
705
- const item = this.#oldCache.get(key);
706
- if (this.#deleteIfExpired(key, item) === false) {
707
- this.#moveToRecent(key, item);
708
- return item.value;
709
- }
710
- }
711
- }
712
- set(key, value, { maxAge = this.#maxAge } = {}) {
713
- const expiry = typeof maxAge === "number" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : undefined;
714
- if (this.#cache.has(key)) {
715
- this.#cache.set(key, {
716
- value,
717
- expiry
718
- });
719
- } else {
720
- this.#set(key, { value, expiry });
721
- }
722
- return this;
723
- }
724
- has(key) {
725
- if (this.#cache.has(key)) {
726
- return !this.#deleteIfExpired(key, this.#cache.get(key));
727
- }
728
- if (this.#oldCache.has(key)) {
729
- return !this.#deleteIfExpired(key, this.#oldCache.get(key));
730
- }
731
- return false;
732
- }
733
- peek(key) {
734
- if (this.#cache.has(key)) {
735
- return this.#peek(key, this.#cache);
736
- }
737
- if (this.#oldCache.has(key)) {
738
- return this.#peek(key, this.#oldCache);
739
- }
740
- }
741
- delete(key) {
742
- const deleted = this.#cache.delete(key);
743
- if (deleted) {
744
- this.#size--;
745
- }
746
- return this.#oldCache.delete(key) || deleted;
747
- }
748
- clear() {
749
- this.#cache.clear();
750
- this.#oldCache.clear();
751
- this.#size = 0;
752
- }
753
- resize(newSize) {
754
- if (!(newSize && newSize > 0)) {
755
- throw new TypeError("`maxSize` must be a number greater than 0");
756
- }
757
- const items = [...this.#entriesAscending()];
758
- const removeCount = items.length - newSize;
759
- if (removeCount < 0) {
760
- this.#cache = new Map(items);
761
- this.#oldCache = new Map;
762
- this.#size = items.length;
763
- } else {
764
- if (removeCount > 0) {
765
- this.#emitEvictions(items.slice(0, removeCount));
766
- }
767
- this.#oldCache = new Map(items.slice(removeCount));
768
- this.#cache = new Map;
769
- this.#size = 0;
770
- }
771
- this.#maxSize = newSize;
772
- }
773
- *keys() {
774
- for (const [key] of this) {
775
- yield key;
776
- }
777
- }
778
- *values() {
779
- for (const [, value] of this) {
780
- yield value;
781
- }
782
- }
783
- *[Symbol.iterator]() {
784
- for (const item of this.#cache) {
785
- const [key, value] = item;
786
- const deleted = this.#deleteIfExpired(key, value);
787
- if (deleted === false) {
788
- yield [key, value.value];
789
- }
790
- }
791
- for (const item of this.#oldCache) {
792
- const [key, value] = item;
793
- if (!this.#cache.has(key)) {
794
- const deleted = this.#deleteIfExpired(key, value);
795
- if (deleted === false) {
796
- yield [key, value.value];
797
- }
798
- }
799
- }
800
- }
801
- *entriesDescending() {
802
- let items = [...this.#cache];
803
- for (let i = items.length - 1;i >= 0; --i) {
804
- const item = items[i];
805
- const [key, value] = item;
806
- const deleted = this.#deleteIfExpired(key, value);
807
- if (deleted === false) {
808
- yield [key, value.value];
809
- }
810
- }
811
- items = [...this.#oldCache];
812
- for (let i = items.length - 1;i >= 0; --i) {
813
- const item = items[i];
814
- const [key, value] = item;
815
- if (!this.#cache.has(key)) {
816
- const deleted = this.#deleteIfExpired(key, value);
817
- if (deleted === false) {
818
- yield [key, value.value];
819
- }
820
- }
821
- }
822
- }
823
- *entriesAscending() {
824
- for (const [key, value] of this.#entriesAscending()) {
825
- yield [key, value.value];
826
- }
827
- }
828
- get size() {
829
- if (!this.#size) {
830
- return this.#oldCache.size;
831
- }
832
- let oldCacheSize = 0;
833
- for (const key of this.#oldCache.keys()) {
834
- if (!this.#cache.has(key)) {
835
- oldCacheSize++;
836
- }
837
- }
838
- return Math.min(this.#size + oldCacheSize, this.#maxSize);
839
- }
840
- get maxSize() {
841
- return this.#maxSize;
842
- }
843
- entries() {
844
- return this.entriesAscending();
845
- }
846
- forEach(callbackFunction, thisArgument = this) {
847
- for (const [key, value] of this.entriesAscending()) {
848
- callbackFunction.call(thisArgument, value, key, this);
849
- }
850
- }
851
- get [Symbol.toStringTag]() {
852
- return JSON.stringify([...this.entriesAscending()]);
853
- }
854
- }
855
-
856
- // availability.ts
60
+ // src/availability.ts
61
+ import pThrottle from "p-throttle";
62
+ import pMemoize from "p-memoize";
63
+ import QuickLRU from "quick-lru";
857
64
  async function wait(time) {
858
65
  return new Promise((resolve) => {
859
66
  setTimeout(resolve, time);