@twinsearth/dsh-fang 3.1.22 → 3.1.23

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 (112) hide show
  1. package/client.js +36 -2
  2. package/package.json +1 -1
  3. package/src/kernel/types.mjs +1 -1
  4. package/LICENSES/LICENSES/cordis-MIT.txt +0 -39
  5. package/defaults/defaults/umbrella-rules.yaml +0 -113
  6. package/sdk/sdk/README.md +0 -65
  7. package/sdk/sdk/examples/status-badge/README.md +0 -16
  8. package/sdk/sdk/examples/status-badge/client.js +0 -60
  9. package/sdk/sdk/examples/status-badge/cordis.patch.yml +0 -7
  10. package/sdk/sdk/examples/status-badge/index.js +0 -12
  11. package/sdk/sdk/examples/status-badge/package.json +0 -24
  12. package/sdk/sdk/templates/plugin/README.md +0 -36
  13. package/sdk/sdk/templates/plugin/client.js +0 -35
  14. package/sdk/sdk/templates/plugin/cordis.patch.yml +0 -8
  15. package/sdk/sdk/templates/plugin/icon.svg +0 -5
  16. package/sdk/sdk/templates/plugin/index.js +0 -23
  17. package/sdk/sdk/templates/plugin/locale/en.json +0 -6
  18. package/sdk/sdk/templates/plugin/package.json +0 -36
  19. package/src/src/compose.mjs +0 -67
  20. package/src/src/contract/client.js +0 -86
  21. package/src/src/contract/constants.js +0 -79
  22. package/src/src/contract/envelope.js +0 -83
  23. package/src/src/contract/index.js +0 -19
  24. package/src/src/contract/negotiate.js +0 -106
  25. package/src/src/contract/server.js +0 -77
  26. package/src/src/contract/transports.js +0 -301
  27. package/src/src/index.mjs +0 -11
  28. package/src/src/kernel/core.mjs +0 -100
  29. package/src/src/kernel/extensions.mjs +0 -61
  30. package/src/src/kernel/fsx.mjs +0 -349
  31. package/src/src/kernel/index.mjs +0 -21
  32. package/src/src/kernel/ledger.mjs +0 -94
  33. package/src/src/kernel/paths.mjs +0 -182
  34. package/src/src/kernel/role.mjs +0 -68
  35. package/src/src/kernel/rounds.mjs +0 -172
  36. package/src/src/kernel/schema.mjs +0 -5
  37. package/src/src/kernel/types.mjs +0 -264
  38. package/src/src/kernel/vendor/cosmokit.mjs +0 -421
  39. package/src/src/kernel/vendor/schemastery.mjs +0 -638
  40. package/src/src/lib/adapter-client.mjs +0 -383
  41. package/src/src/lib/adapter-protocol.mjs +0 -243
  42. package/src/src/lib/ai-secret-store.mjs +0 -202
  43. package/src/src/lib/boot-guard.mjs +0 -182
  44. package/src/src/lib/branch-store.mjs +0 -84
  45. package/src/src/lib/branch.mjs +0 -74
  46. package/src/src/lib/bridge-client.mjs +0 -133
  47. package/src/src/lib/broker-adapter.mjs +0 -67
  48. package/src/src/lib/broker.mjs +0 -45
  49. package/src/src/lib/business-producers.mjs +0 -109
  50. package/src/src/lib/command-cache.mjs +0 -209
  51. package/src/src/lib/compat.mjs +0 -170
  52. package/src/src/lib/composer-journal.mjs +0 -128
  53. package/src/src/lib/container/index.mjs +0 -806
  54. package/src/src/lib/decision-events.mjs +0 -129
  55. package/src/src/lib/decision-ingest-client.mjs +0 -41
  56. package/src/src/lib/decision-outbox.mjs +0 -129
  57. package/src/src/lib/default-essence.mjs +0 -61
  58. package/src/src/lib/desktop-launch.mjs +0 -138
  59. package/src/src/lib/essence.mjs +0 -1211
  60. package/src/src/lib/fork-client.mjs +0 -410
  61. package/src/src/lib/fork-config-lock.mjs +0 -153
  62. package/src/src/lib/fork-seed.mjs +0 -304
  63. package/src/src/lib/fork-supervision-settings.mjs +0 -58
  64. package/src/src/lib/fork-supervisor.mjs +0 -122
  65. package/src/src/lib/fs-guard.mjs +0 -28
  66. package/src/src/lib/http-auth.mjs +0 -162
  67. package/src/src/lib/idle-audit.mjs +0 -178
  68. package/src/src/lib/interaction-poke.mjs +0 -61
  69. package/src/src/lib/mirror-etag.mjs +0 -92
  70. package/src/src/lib/mirror-official-source.mjs +0 -93
  71. package/src/src/lib/mirror.mjs +0 -478
  72. package/src/src/lib/mother-link.mjs +0 -156
  73. package/src/src/lib/mutex.mjs +0 -31
  74. package/src/src/lib/permissions.mjs +0 -115
  75. package/src/src/lib/pnpm-store.mjs +0 -189
  76. package/src/src/lib/preferences.mjs +0 -212
  77. package/src/src/lib/producer-contract.mjs +0 -162
  78. package/src/src/lib/reflow.mjs +0 -41
  79. package/src/src/lib/remote.mjs +0 -408
  80. package/src/src/lib/restart-contract.mjs +0 -650
  81. package/src/src/lib/roots.mjs +0 -30
  82. package/src/src/lib/rule-registry.mjs +0 -1101
  83. package/src/src/lib/runtime-capture.mjs +0 -307
  84. package/src/src/lib/semaphore.mjs +0 -34
  85. package/src/src/lib/session-bundle.mjs +0 -138
  86. package/src/src/lib/session-format.mjs +0 -658
  87. package/src/src/lib/sse-parser.mjs +0 -102
  88. package/src/src/lib/ssrf-guard.mjs +0 -170
  89. package/src/src/lib/status-store.mjs +0 -257
  90. package/src/src/lib/task-handle.mjs +0 -622
  91. package/src/src/lib/ui-actions.mjs +0 -55
  92. package/src/src/lib/umbrella.mjs +0 -1661
  93. package/src/src/lib/upgrade-coordinator.mjs +0 -107
  94. package/src/src/lib/upgrade-status.mjs +0 -43
  95. package/src/src/plugins/adapter.mjs +0 -1468
  96. package/src/src/plugins/approver.mjs +0 -1210
  97. package/src/src/plugins/auditor.mjs +0 -330
  98. package/src/src/plugins/buffer-keeper.mjs +0 -522
  99. package/src/src/plugins/decision-center.mjs +0 -2265
  100. package/src/src/plugins/forker.mjs +0 -1594
  101. package/src/src/plugins/healer.mjs +0 -664
  102. package/src/src/plugins/hot-reloader.mjs +0 -274
  103. package/src/src/plugins/imports.mjs +0 -247
  104. package/src/src/plugins/orchestrator.mjs +0 -3806
  105. package/src/src/plugins/restart-guard.mjs +0 -948
  106. package/src/src/plugins/router.mjs +0 -714
  107. package/src/src/plugins/scorer.mjs +0 -624
  108. package/src/src/plugins/session-bridge.mjs +0 -166
  109. package/src/src/plugins/session-catalog.mjs +0 -771
  110. package/src/src/plugins/session-router.mjs +0 -125
  111. package/src/src/plugins/session-sync.mjs +0 -171
  112. package/src/src/plugins/umbrella.mjs +0 -419
@@ -1,421 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2022-present Shigma and cordis contributors (upstream: https://github.com/shigma/cordis)
3
- // Vendored into dsh-Fang; see LICENSES/cordis-MIT.txt.
4
- //#region lib/types/misc.js
5
- /** No-op callback returning `undefined` at runtime and `any` at type level. */
6
- function noop() {}
7
- /** Return true when a value is `null` or `undefined`. */
8
- function isNullable(value) {
9
- return value === null || value === void 0;
10
- }
11
- /** Return true when a value is neither `null` nor `undefined`. */
12
- function isNonNullable(value) {
13
- return !isNullable(value);
14
- }
15
- /** Return true for non-array object values. */
16
- function isPlainObject(data) {
17
- return data && typeof data === "object" && !Array.isArray(data);
18
- }
19
- /** Filter object entries and return a new object. */
20
- function filterKeys(object, filter) {
21
- return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
22
- }
23
- /** Map object values while preserving the original key set. */
24
- function mapValues(object, transform) {
25
- return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
26
- }
27
- /** Pick selected keys from an object, optionally including `undefined` values. */
28
- function pick(source, keys, forced) {
29
- if (!keys) return { ...source };
30
- const result = {};
31
- for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
32
- return result;
33
- }
34
- /** Omit selected keys from a shallow object copy. */
35
- function omit(source, keys) {
36
- if (!keys) return { ...source };
37
- const result = { ...source };
38
- for (const key of keys) Reflect.deleteProperty(result, key);
39
- return result;
40
- }
41
- /** Define a non-enumerable writable property and return the object. */
42
- function defineProperty(object, key, value) {
43
- return Object.defineProperty(object, key, {
44
- writable: true,
45
- value,
46
- enumerable: false
47
- });
48
- }
49
- //#endregion
50
- //#region lib/types/array.js
51
- /** Return true when every item in `array2` is present in `array1`. */
52
- function contain(array1, array2) {
53
- return array2.every((item) => array1.includes(item));
54
- }
55
- /** Return items that appear in both arrays. */
56
- function intersection(array1, array2) {
57
- return array1.filter((item) => array2.includes(item));
58
- }
59
- /** Return items from `array1` that do not appear in `array2`. */
60
- function difference(array1, array2) {
61
- return array1.filter((item) => !array2.includes(item));
62
- }
63
- /** Return the set-union of two arrays while preserving first occurrence order. */
64
- function union(array1, array2) {
65
- return Array.from(new Set([...array1, ...array2]));
66
- }
67
- /** Remove duplicate values while preserving first occurrence order. */
68
- function deduplicate(array) {
69
- return [...new Set(array)];
70
- }
71
- /** Remove one item from an array and report whether it was found. */
72
- function remove(list, item) {
73
- const index = list?.indexOf(item);
74
- if (index >= 0) {
75
- list.splice(index, 1);
76
- return true;
77
- } else return false;
78
- }
79
- /** Normalize nullish, scalar, or array input to an array. */
80
- function makeArray(source) {
81
- return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
82
- }
83
- //#endregion
84
- //#region lib/types/volatile.js
85
- /** Shared config references used by schema validators and plugin runtimes. */
86
- const write = Symbol.for("cosmokit.volatile.write");
87
- function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
88
- if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
89
- if (value === null || typeof value !== "object") return value;
90
- if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
91
- ancestors.add(value);
92
- try {
93
- if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
94
- if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
95
- return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
96
- } finally {
97
- ancestors.delete(value);
98
- }
99
- }
100
- /**
101
- * Create a detached reference containing an immutable copy of the supplied data.
102
- * @param value - validated config data; class instances and functions are unsupported.
103
- * @returns a reference whose value is updated only by its owning runtime.
104
- */
105
- function createVolatile(value) {
106
- let current = snapshot(value);
107
- return Object.freeze({
108
- get: () => current,
109
- [write]: (value) => {
110
- current = value;
111
- }
112
- });
113
- }
114
- /**
115
- * Identify references across ESM/CJS copies of the shared library.
116
- * @param value - a parsed config value.
117
- * @returns whether the value implements the shared reference protocol.
118
- */
119
- function isVolatile(value) {
120
- return typeof value === "object" && value !== null && write in value;
121
- }
122
- /**
123
- * Collect config references without descending into their snapshots or opaque objects.
124
- * @internal
125
- * @param value - parsed config; cyclic ordinary fields are visited once per path.
126
- * @returns references and their object-key paths, including an empty path for a root reference.
127
- */
128
- function volatileEntries(value) {
129
- const ancestors = /* @__PURE__ */ new Set();
130
- function visit(value, path) {
131
- if (isVolatile(value)) return [{
132
- path,
133
- ref: value
134
- }];
135
- if (!value || typeof value !== "object" || ancestors.has(value)) return [];
136
- if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return [];
137
- ancestors.add(value);
138
- try {
139
- return Object.entries(value).flatMap(([key, child]) => visit(child, [...path, key]));
140
- } finally {
141
- ancestors.delete(value);
142
- }
143
- }
144
- return visit(value, []);
145
- }
146
- /**
147
- * Commit an already validated immutable snapshot from another reference.
148
- * @internal
149
- * @param target - the owning plugin's stable reference.
150
- * @param source - a newly parsed candidate reference.
151
- */
152
- function updateVolatile(target, source) {
153
- target[write](source.get());
154
- }
155
- //#endregion
156
- //#region lib/types/types.js
157
- /** Test values using `instanceof` with a `toStringTag` fallback. */
158
- function is(type, value) {
159
- if (arguments.length === 1) return (value) => is(type, value);
160
- return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
161
- }
162
- function isArrayBufferLike(value) {
163
- return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
164
- }
165
- function isArrayBufferSource(value) {
166
- return isArrayBufferLike(value) || ArrayBuffer.isView(value);
167
- }
168
- /** Binary source detection and base64/hex conversion helpers. */
169
- var Binary;
170
- (function(Binary) {
171
- Binary.is = isArrayBufferLike;
172
- Binary.isSource = isArrayBufferSource;
173
- function fromSource(source) {
174
- if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
175
- else return source;
176
- }
177
- Binary.fromSource = fromSource;
178
- function toBase64(source) {
179
- source = fromSource(source);
180
- if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
181
- let binary = "";
182
- const bytes = new Uint8Array(source);
183
- for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
184
- return btoa(binary);
185
- }
186
- Binary.toBase64 = toBase64;
187
- function fromBase64(source) {
188
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
189
- return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
190
- }
191
- Binary.fromBase64 = fromBase64;
192
- function toHex(source) {
193
- source = fromSource(source);
194
- if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
195
- return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
196
- }
197
- Binary.toHex = toHex;
198
- function fromHex(source) {
199
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
200
- const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
201
- const buffer = [];
202
- for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
203
- return Uint8Array.from(buffer).buffer;
204
- }
205
- Binary.fromHex = fromHex;
206
- })(Binary || (Binary = {}));
207
- /** Decode a base64 string into binary data. */
208
- const base64ToArrayBuffer = Binary.fromBase64;
209
- /** Encode binary data as base64. */
210
- const arrayBufferToBase64 = Binary.toBase64;
211
- /** Decode a hex string into binary data. */
212
- const hexToArrayBuffer = Binary.fromHex;
213
- /** Encode binary data as hex. */
214
- const arrayBufferToHex = Binary.toHex;
215
- /** Deep-clone common JavaScript values while preserving prototypes and cycles. */
216
- function clone(source, refs = /* @__PURE__ */ new Map()) {
217
- if (!source || typeof source !== "object") return source;
218
- if (is("Date", source)) return new Date(source.valueOf());
219
- if (is("RegExp", source)) return new RegExp(source.source, source.flags);
220
- if (isArrayBufferLike(source)) return source.slice(0);
221
- if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
222
- const cached = refs.get(source);
223
- if (cached) return cached;
224
- if (Array.isArray(source)) {
225
- const result = [];
226
- refs.set(source, result);
227
- source.forEach((value, index) => {
228
- result[index] = Reflect.apply(clone, null, [value, refs]);
229
- });
230
- return result;
231
- }
232
- const result = Object.create(Object.getPrototypeOf(source));
233
- refs.set(source, result);
234
- for (const key of Reflect.ownKeys(source)) {
235
- const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
236
- if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
237
- Reflect.defineProperty(result, key, descriptor);
238
- }
239
- return result;
240
- }
241
- /**
242
- * Compare values recursively, treating two volatile references as equal regardless of value.
243
- * Strict comparison distinguishes null/undefined, treats opaque objects by identity,
244
- * compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
245
- * @param a - first value.
246
- * @param b - second value.
247
- * @param strict - whether to require strict data equality outside volatile references.
248
- * @returns whether the values compare equal.
249
- */
250
- function deepEqual(a, b, strict) {
251
- const ancestors = /* @__PURE__ */ new Set();
252
- function compare(a, b) {
253
- if (a === b) return true;
254
- if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
255
- if (!strict && isNullable(a) && isNullable(b)) return true;
256
- if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
257
- if (ancestors.has(a)) return false;
258
- function check(test, then) {
259
- return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
260
- }
261
- ancestors.add(a);
262
- try {
263
- return check(Array.isArray, (a, b) => {
264
- if (a.length !== b.length) return false;
265
- for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
266
- return true;
267
- }) ?? check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ?? check(is("URL"), (a, b) => a.href === b.href) ?? check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ?? check(isArrayBufferLike, (a, b) => {
268
- if (a.byteLength !== b.byteLength) return false;
269
- const viewA = new Uint8Array(a);
270
- const viewB = new Uint8Array(b);
271
- for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
272
- return true;
273
- }) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
274
- ...a,
275
- ...b
276
- }).every((key) => compare(a[key], b[key])));
277
- } finally {
278
- ancestors.delete(a);
279
- }
280
- }
281
- return compare(a, b);
282
- }
283
- //#endregion
284
- //#region lib/types/string.js
285
- /** Uppercase the first character of a string. */
286
- function capitalize(source) {
287
- return source.charAt(0).toUpperCase() + source.slice(1);
288
- }
289
- /** Lowercase the first character of a string. */
290
- function uncapitalize(source) {
291
- return source.charAt(0).toLowerCase() + source.slice(1);
292
- }
293
- /** Convert dash or underscore delimited text to camelCase. */
294
- function camelCase(source) {
295
- return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
296
- }
297
- function tokenize(source, delimiters, delimiter) {
298
- const output = [];
299
- let state = 0;
300
- for (let i = 0; i < source.length; i++) {
301
- const code = source.charCodeAt(i);
302
- if (code >= 65 && code <= 90) {
303
- if (state === 1) {
304
- const next = source.charCodeAt(i + 1);
305
- if (next >= 97 && next <= 122) output.push(delimiter);
306
- output.push(code + 32);
307
- } else {
308
- if (state !== 0) output.push(delimiter);
309
- output.push(code + 32);
310
- }
311
- state = 1;
312
- } else if (code >= 97 && code <= 122) {
313
- output.push(code);
314
- state = 2;
315
- } else if (delimiters.includes(code)) {
316
- if (state !== 0) output.push(delimiter);
317
- state = 0;
318
- } else output.push(code);
319
- }
320
- return String.fromCharCode(...output);
321
- }
322
- /** Convert text to dash-delimited parameter case. */
323
- function paramCase(source) {
324
- return tokenize(source, [45, 95], 45);
325
- }
326
- /** Convert text to underscore-delimited snake case. */
327
- function snakeCase(source) {
328
- return tokenize(source, [45, 95], 95);
329
- }
330
- /** Runtime alias for `camelCase`. */
331
- const camelize = camelCase;
332
- /** Runtime alias for `paramCase`. */
333
- const hyphenate = paramCase;
334
- /** Format a property key as a JavaScript member access suffix. */
335
- function formatProperty(key) {
336
- if (typeof key !== "string") return `[${key.toString()}]`;
337
- return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
338
- }
339
- /** Remove one trailing slash from a path string. */
340
- function trimSlash(source) {
341
- return source.replace(/\/$/, "");
342
- }
343
- /** Ensure a path starts with `/` and has no trailing slash. */
344
- function sanitize(source) {
345
- if (!source.startsWith("/")) source = "/" + source;
346
- return trimSlash(source);
347
- }
348
- //#endregion
349
- //#region lib/types/time.js
350
- /** Time constants plus parsing and formatting helpers. */
351
- var Time;
352
- (function(Time) {
353
- Time.millisecond = 1;
354
- Time.second = 1e3;
355
- Time.minute = Time.second * 60;
356
- Time.hour = Time.minute * 60;
357
- Time.day = Time.hour * 24;
358
- Time.week = Time.day * 7;
359
- let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
360
- function setTimezoneOffset(offset) {
361
- timezoneOffset = offset;
362
- }
363
- Time.setTimezoneOffset = setTimezoneOffset;
364
- function getTimezoneOffset() {
365
- return timezoneOffset;
366
- }
367
- Time.getTimezoneOffset = getTimezoneOffset;
368
- function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
369
- if (typeof date === "number") date = new Date(date);
370
- if (offset === void 0) offset = timezoneOffset;
371
- return Math.floor((date.valueOf() / Time.minute - offset) / 1440);
372
- }
373
- Time.getDateNumber = getDateNumber;
374
- function fromDateNumber(value, offset) {
375
- const date = new Date(value * Time.day);
376
- if (offset === void 0) offset = timezoneOffset;
377
- return new Date(+date + offset * Time.minute);
378
- }
379
- Time.fromDateNumber = fromDateNumber;
380
- const numeric = /\d+(?:\.\d+)?/.source;
381
- const timeRegExp = new RegExp(`^${[
382
- "w(?:eek(?:s)?)?",
383
- "d(?:ay(?:s)?)?",
384
- "h(?:our(?:s)?)?",
385
- "m(?:in(?:ute)?(?:s)?)?",
386
- "s(?:ec(?:ond)?(?:s)?)?"
387
- ].map((unit) => `(${numeric}${unit})?`).join("")}$`);
388
- function parseTime(source) {
389
- const capture = timeRegExp.exec(source);
390
- if (!capture) return 0;
391
- return (parseFloat(capture[1]) * Time.week || 0) + (parseFloat(capture[2]) * Time.day || 0) + (parseFloat(capture[3]) * Time.hour || 0) + (parseFloat(capture[4]) * Time.minute || 0) + (parseFloat(capture[5]) * Time.second || 0);
392
- }
393
- Time.parseTime = parseTime;
394
- function parseDate(date) {
395
- const parsed = parseTime(date);
396
- if (parsed) date = Date.now() + parsed;
397
- else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
398
- else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
399
- return date ? new Date(date) : /* @__PURE__ */ new Date();
400
- }
401
- Time.parseDate = parseDate;
402
- function format(ms) {
403
- const abs = Math.abs(ms);
404
- if (abs >= Time.day - Time.hour / 2) return Math.round(ms / Time.day) + "d";
405
- else if (abs >= Time.hour - Time.minute / 2) return Math.round(ms / Time.hour) + "h";
406
- else if (abs >= Time.minute - Time.second / 2) return Math.round(ms / Time.minute) + "m";
407
- else if (abs >= Time.second) return Math.round(ms / Time.second) + "s";
408
- return ms + "ms";
409
- }
410
- Time.format = format;
411
- function toDigits(source, length = 2) {
412
- return source.toString().padStart(length, "0");
413
- }
414
- Time.toDigits = toDigits;
415
- function template(template, time = /* @__PURE__ */ new Date()) {
416
- return template.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
417
- }
418
- Time.template = template;
419
- })(Time || (Time = {}));
420
- //#endregion
421
- export { Binary, Time, arrayBufferToBase64, arrayBufferToHex, base64ToArrayBuffer, camelCase, camelize, capitalize, clone, contain, createVolatile, deduplicate, deepEqual, defineProperty, difference, filterKeys, formatProperty, hexToArrayBuffer, hyphenate, intersection, is, isNonNullable, isNullable, isPlainObject, isVolatile, makeArray, mapValues, mapValues as valueMap, noop, omit, paramCase, pick, remove, sanitize, snakeCase, trimSlash, uncapitalize, union, updateVolatile, volatileEntries };