@rebon/cli-win32-x64 1.3.0 → 1.5.0
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/LICENSE +202 -0
- package/NOTICE +10 -0
- package/README.md +239 -144
- package/THIRD_PARTY_NOTICES.txt +1232 -1232
- package/bin/rebon.js +22 -22
- package/lib/windows-managed.js +390 -390
- package/package.json +9 -2
- package/payload/compose-runtime/package.json +17 -17
- package/payload/compose-runtime/payload/compose/shims/dsh-anonymous-user-id.js +10 -10
- package/payload/compose-runtime/payload/compose/shims/dsh-credentials.js +13 -13
- package/payload/compose-runtime/payload/compose/shims/dsh-launch-environment.js +21 -21
- package/payload/compose-runtime/payload/compose/shims/dsh-llm.js +313 -313
- package/payload/compose-runtime/payload/compose/shims/dsh-settings.js +43 -43
- package/payload/compose-runtime/payload/compose/shims/dsh-tools.js +20 -20
- package/payload/compose-runtime/payload/compose/shims/dsh-web.js +10 -10
- package/payload/compose-runtime/payload/compose/shims/llm-adapter.js +32 -32
- package/payload/compose-runtime/payload/compose/shims/zod-lite.js +49 -49
- package/payload/compose-runtime/payload/vendor/cordis/LICENSE +21 -21
- package/payload/compose-runtime/payload/vendor/cordis/index.js +1530 -1530
- package/payload/compose-runtime/payload/vendor/cosmokit/LICENSE +21 -21
- package/payload/compose-runtime/payload/vendor/cosmokit/index.mjs +357 -357
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-agent +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-agent-loop +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-llm-core +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-llm-deepseek +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-logger-console +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-scope +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-session +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-system-prompt +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-timeout +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-timer +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-tool-todo +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-tool-web +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-tools-schema +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-turndown +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-turndown-plugin-gfm +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/LICENSE-web-search-exa +21 -21
- package/payload/compose-runtime/payload/vendor/dsh/agent-loop.js +1193 -1193
- package/payload/compose-runtime/payload/vendor/dsh/agent.js +714 -714
- package/payload/compose-runtime/payload/vendor/dsh/llm-core.js +269 -269
- package/payload/compose-runtime/payload/vendor/dsh/llm-deepseek.js +672 -672
- package/payload/compose-runtime/payload/vendor/dsh/logger-console.js +83 -83
- package/payload/compose-runtime/payload/vendor/dsh/scope.js +287 -287
- package/payload/compose-runtime/payload/vendor/dsh/session.js +1668 -1668
- package/payload/compose-runtime/payload/vendor/dsh/system-prompt.js +309 -309
- package/payload/compose-runtime/payload/vendor/dsh/timeout.js +100 -100
- package/payload/compose-runtime/payload/vendor/dsh/timer.js +128 -128
- package/payload/compose-runtime/payload/vendor/dsh/tool-todo.js +143 -143
- package/payload/compose-runtime/payload/vendor/dsh/tool-web.js +1527 -1527
- package/payload/compose-runtime/payload/vendor/dsh/tools-schema.js +849 -849
- package/payload/compose-runtime/payload/vendor/dsh/web-search-exa.js +122 -122
- package/payload/compose-runtime/payload/vendor/eventsource-parser/LICENSE +21 -21
- package/payload/compose-runtime/payload/vendor/eventsource-parser/index.js +177 -177
- package/payload/compose-runtime/payload/vendor/eventsource-parser/stream.js +48 -48
- package/payload/compose-runtime/payload/vendor/schemastery/LICENSE +21 -21
- package/payload/compose-runtime/payload/vendor/schemastery/index.mjs +656 -656
- package/payload/compose-runtime/payload-manifests.json +48 -48
- package/payload/compose-runtime/src/bridge.mjs +193 -195
- package/payload/compose-runtime/src/credentials-runtime.mjs +50 -50
- package/payload/compose-runtime/src/eventsource-stream.mjs +48 -48
- package/payload/compose-runtime/src/index.mjs +7 -7
- package/payload/compose-runtime/src/llm-runtime.mjs +326 -326
- package/payload/compose-runtime/src/loader.mjs +78 -78
- package/payload/compose-runtime/src/loop-assembly.mjs +237 -237
- package/payload/compose-runtime/src/payload.mjs +49 -49
- package/payload/compose-runtime/src/plugin.mjs +59 -59
- package/payload/compose-runtime/src/realm.mjs +223 -223
- package/payload/compose-runtime/src/registry.mjs +191 -191
- package/payload/compose-runtime/src/resolve.mjs +115 -115
- package/payload/compose-runtime/src/systemprompt-runtime.mjs +67 -67
- package/payload/compose-runtime/src/tools-runtime.mjs +239 -239
- package/payload/compose-runtime/src/web-runtime.mjs +209 -209
- package/payload/plugin-host/package.json +11 -11
- package/payload/plugin-host/src/bridge.mjs +64 -64
- package/payload/plugin-host/src/cli.mjs +147 -147
- package/payload/plugin-host/src/framing.mjs +113 -113
- package/payload/plugin-host/src/host.mjs +691 -691
- package/payload/plugin-host/src/json.mjs +208 -208
- package/payload/plugin-host/src/lifecycle.mjs +114 -114
- package/payload/plugin-host/src/loader.mjs +183 -183
- package/payload/plugin-host/src/methods.mjs +377 -377
- package/payload/plugin-host/src/ownership.mjs +57 -57
- package/payload/plugin-host/src/protocol.mjs +129 -129
- package/payload/plugin-host/src/sdk.mjs +7 -7
- package/payload/rebon-boa-helper.exe +0 -0
- package/payload/rebon-browser-mcp.exe +0 -0
- package/payload/rebon-computer-use.exe +0 -0
- package/payload/rebon-lsp-mcp.exe +0 -0
- package/payload/rebon.exe +2 -2
- package/payload/sandbox-win.exe +0 -0
- package/scripts/postinstall.js +112 -112
|
@@ -1,357 +1,357 @@
|
|
|
1
|
-
// src/misc.ts
|
|
2
|
-
function noop() {
|
|
3
|
-
}
|
|
4
|
-
function isNullable(value) {
|
|
5
|
-
return value === null || value === void 0;
|
|
6
|
-
}
|
|
7
|
-
function isNonNullable(value) {
|
|
8
|
-
return !isNullable(value);
|
|
9
|
-
}
|
|
10
|
-
function isPlainObject(data) {
|
|
11
|
-
return data && typeof data === "object" && !Array.isArray(data);
|
|
12
|
-
}
|
|
13
|
-
function filterKeys(object, filter) {
|
|
14
|
-
return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
|
|
15
|
-
}
|
|
16
|
-
function mapValues(object, transform) {
|
|
17
|
-
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
|
|
18
|
-
}
|
|
19
|
-
function pick(source, keys, forced) {
|
|
20
|
-
if (!keys) return { ...source };
|
|
21
|
-
const result = {};
|
|
22
|
-
for (const key of keys) {
|
|
23
|
-
if (forced || source[key] !== void 0) result[key] = source[key];
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
function omit(source, keys) {
|
|
28
|
-
if (!keys) return { ...source };
|
|
29
|
-
const result = { ...source };
|
|
30
|
-
for (const key of keys) {
|
|
31
|
-
Reflect.deleteProperty(result, key);
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
function defineProperty(object, key, value) {
|
|
36
|
-
return Object.defineProperty(object, key, { writable: true, value, enumerable: false });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// src/array.ts
|
|
40
|
-
function contain(array1, array2) {
|
|
41
|
-
return array2.every((item) => array1.includes(item));
|
|
42
|
-
}
|
|
43
|
-
function intersection(array1, array2) {
|
|
44
|
-
return array1.filter((item) => array2.includes(item));
|
|
45
|
-
}
|
|
46
|
-
function difference(array1, array2) {
|
|
47
|
-
return array1.filter((item) => !array2.includes(item));
|
|
48
|
-
}
|
|
49
|
-
function union(array1, array2) {
|
|
50
|
-
return Array.from(/* @__PURE__ */ new Set([...array1, ...array2]));
|
|
51
|
-
}
|
|
52
|
-
function deduplicate(array) {
|
|
53
|
-
return [...new Set(array)];
|
|
54
|
-
}
|
|
55
|
-
function remove(list, item) {
|
|
56
|
-
const index = list?.indexOf(item);
|
|
57
|
-
if (index >= 0) {
|
|
58
|
-
list.splice(index, 1);
|
|
59
|
-
return true;
|
|
60
|
-
} else {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function makeArray(source) {
|
|
65
|
-
return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/types.ts
|
|
69
|
-
function is(type, value) {
|
|
70
|
-
if (arguments.length === 1) return (value2) => is(type, value2);
|
|
71
|
-
return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
|
|
72
|
-
}
|
|
73
|
-
function isArrayBufferLike(value) {
|
|
74
|
-
return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
|
|
75
|
-
}
|
|
76
|
-
function isArrayBufferSource(value) {
|
|
77
|
-
return isArrayBufferLike(value) || ArrayBuffer.isView(value);
|
|
78
|
-
}
|
|
79
|
-
var Binary;
|
|
80
|
-
((Binary2) => {
|
|
81
|
-
Binary2.is = isArrayBufferLike;
|
|
82
|
-
Binary2.isSource = isArrayBufferSource;
|
|
83
|
-
function fromSource(source) {
|
|
84
|
-
if (ArrayBuffer.isView(source)) {
|
|
85
|
-
return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
86
|
-
} else {
|
|
87
|
-
return source;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
Binary2.fromSource = fromSource;
|
|
91
|
-
function toBase64(source) {
|
|
92
|
-
source = fromSource(source);
|
|
93
|
-
if (typeof Buffer !== "undefined") {
|
|
94
|
-
return Buffer.from(source).toString("base64");
|
|
95
|
-
}
|
|
96
|
-
let binary = "";
|
|
97
|
-
const bytes = new Uint8Array(source);
|
|
98
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
99
|
-
binary += String.fromCharCode(bytes[i]);
|
|
100
|
-
}
|
|
101
|
-
return btoa(binary);
|
|
102
|
-
}
|
|
103
|
-
Binary2.toBase64 = toBase64;
|
|
104
|
-
function fromBase64(source) {
|
|
105
|
-
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
|
|
106
|
-
return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
|
|
107
|
-
}
|
|
108
|
-
Binary2.fromBase64 = fromBase64;
|
|
109
|
-
function toHex(source) {
|
|
110
|
-
source = fromSource(source);
|
|
111
|
-
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
|
|
112
|
-
return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
113
|
-
}
|
|
114
|
-
Binary2.toHex = toHex;
|
|
115
|
-
function fromHex(source) {
|
|
116
|
-
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
|
|
117
|
-
const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
|
|
118
|
-
const buffer = [];
|
|
119
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
120
|
-
buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
|
|
121
|
-
}
|
|
122
|
-
return Uint8Array.from(buffer).buffer;
|
|
123
|
-
}
|
|
124
|
-
Binary2.fromHex = fromHex;
|
|
125
|
-
})(Binary || (Binary = {}));
|
|
126
|
-
var base64ToArrayBuffer = Binary.fromBase64;
|
|
127
|
-
var arrayBufferToBase64 = Binary.toBase64;
|
|
128
|
-
var hexToArrayBuffer = Binary.fromHex;
|
|
129
|
-
var arrayBufferToHex = Binary.toHex;
|
|
130
|
-
function clone(source, refs = /* @__PURE__ */ new Map()) {
|
|
131
|
-
if (!source || typeof source !== "object") return source;
|
|
132
|
-
if (is("Date", source)) return new Date(source.valueOf());
|
|
133
|
-
if (is("RegExp", source)) return new RegExp(source.source, source.flags);
|
|
134
|
-
if (isArrayBufferLike(source)) return source.slice(0);
|
|
135
|
-
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
136
|
-
const cached = refs.get(source);
|
|
137
|
-
if (cached) return cached;
|
|
138
|
-
if (Array.isArray(source)) {
|
|
139
|
-
const result2 = [];
|
|
140
|
-
refs.set(source, result2);
|
|
141
|
-
source.forEach((value, index) => {
|
|
142
|
-
result2[index] = Reflect.apply(clone, null, [value, refs]);
|
|
143
|
-
});
|
|
144
|
-
return result2;
|
|
145
|
-
}
|
|
146
|
-
const result = Object.create(Object.getPrototypeOf(source));
|
|
147
|
-
refs.set(source, result);
|
|
148
|
-
for (const key of Reflect.ownKeys(source)) {
|
|
149
|
-
const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
|
|
150
|
-
if ("value" in descriptor) {
|
|
151
|
-
descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
|
|
152
|
-
}
|
|
153
|
-
Reflect.defineProperty(result, key, descriptor);
|
|
154
|
-
}
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
function deepEqual(a, b, strict) {
|
|
158
|
-
if (a === b) return true;
|
|
159
|
-
if (!strict && isNullable(a) && isNullable(b)) return true;
|
|
160
|
-
if (typeof a !== typeof b) return false;
|
|
161
|
-
if (typeof a !== "object") return false;
|
|
162
|
-
if (!a || !b) return false;
|
|
163
|
-
function check(test, then) {
|
|
164
|
-
return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
|
|
165
|
-
}
|
|
166
|
-
return check(Array.isArray, (a2, b2) => a2.length === b2.length && a2.every((item, index) => deepEqual(item, b2[index]))) ?? check(is("Date"), (a2, b2) => a2.valueOf() === b2.valueOf()) ?? check(is("RegExp"), (a2, b2) => a2.source === b2.source && a2.flags === b2.flags) ?? check(isArrayBufferLike, (a2, b2) => {
|
|
167
|
-
if (a2.byteLength !== b2.byteLength) return false;
|
|
168
|
-
const viewA = new Uint8Array(a2);
|
|
169
|
-
const viewB = new Uint8Array(b2);
|
|
170
|
-
for (let i = 0; i < viewA.length; i++) {
|
|
171
|
-
if (viewA[i] !== viewB[i]) return false;
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
}) ?? Object.keys({ ...a, ...b }).every((key) => deepEqual(a[key], b[key], strict));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// src/string.ts
|
|
178
|
-
function capitalize(source) {
|
|
179
|
-
return source.charAt(0).toUpperCase() + source.slice(1);
|
|
180
|
-
}
|
|
181
|
-
function uncapitalize(source) {
|
|
182
|
-
return source.charAt(0).toLowerCase() + source.slice(1);
|
|
183
|
-
}
|
|
184
|
-
function camelCase(source) {
|
|
185
|
-
return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
|
|
186
|
-
}
|
|
187
|
-
function tokenize(source, delimiters, delimiter) {
|
|
188
|
-
const output = [];
|
|
189
|
-
let state = 0 /* DELIM */;
|
|
190
|
-
for (let i = 0; i < source.length; i++) {
|
|
191
|
-
const code = source.charCodeAt(i);
|
|
192
|
-
if (code >= 65 && code <= 90) {
|
|
193
|
-
if (state === 1 /* UPPER */) {
|
|
194
|
-
const next = source.charCodeAt(i + 1);
|
|
195
|
-
if (next >= 97 && next <= 122) {
|
|
196
|
-
output.push(delimiter);
|
|
197
|
-
}
|
|
198
|
-
output.push(code + 32);
|
|
199
|
-
} else {
|
|
200
|
-
if (state !== 0 /* DELIM */) {
|
|
201
|
-
output.push(delimiter);
|
|
202
|
-
}
|
|
203
|
-
output.push(code + 32);
|
|
204
|
-
}
|
|
205
|
-
state = 1 /* UPPER */;
|
|
206
|
-
} else if (code >= 97 && code <= 122) {
|
|
207
|
-
output.push(code);
|
|
208
|
-
state = 2 /* LOWER */;
|
|
209
|
-
} else if (delimiters.includes(code)) {
|
|
210
|
-
if (state !== 0 /* DELIM */) {
|
|
211
|
-
output.push(delimiter);
|
|
212
|
-
}
|
|
213
|
-
state = 0 /* DELIM */;
|
|
214
|
-
} else {
|
|
215
|
-
output.push(code);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return String.fromCharCode(...output);
|
|
219
|
-
}
|
|
220
|
-
function paramCase(source) {
|
|
221
|
-
return tokenize(source, [45, 95], 45);
|
|
222
|
-
}
|
|
223
|
-
function snakeCase(source) {
|
|
224
|
-
return tokenize(source, [45, 95], 95);
|
|
225
|
-
}
|
|
226
|
-
var camelize = camelCase;
|
|
227
|
-
var hyphenate = paramCase;
|
|
228
|
-
function formatProperty(key) {
|
|
229
|
-
if (typeof key !== "string") return `[${key.toString()}]`;
|
|
230
|
-
return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
|
|
231
|
-
}
|
|
232
|
-
function trimSlash(source) {
|
|
233
|
-
return source.replace(/\/$/, "");
|
|
234
|
-
}
|
|
235
|
-
function sanitize(source) {
|
|
236
|
-
if (!source.startsWith("/")) source = "/" + source;
|
|
237
|
-
return trimSlash(source);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// src/time.ts
|
|
241
|
-
var Time;
|
|
242
|
-
((Time2) => {
|
|
243
|
-
Time2.millisecond = 1;
|
|
244
|
-
Time2.second = 1e3;
|
|
245
|
-
Time2.minute = Time2.second * 60;
|
|
246
|
-
Time2.hour = Time2.minute * 60;
|
|
247
|
-
Time2.day = Time2.hour * 24;
|
|
248
|
-
Time2.week = Time2.day * 7;
|
|
249
|
-
let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
250
|
-
function setTimezoneOffset(offset) {
|
|
251
|
-
timezoneOffset = offset;
|
|
252
|
-
}
|
|
253
|
-
Time2.setTimezoneOffset = setTimezoneOffset;
|
|
254
|
-
function getTimezoneOffset() {
|
|
255
|
-
return timezoneOffset;
|
|
256
|
-
}
|
|
257
|
-
Time2.getTimezoneOffset = getTimezoneOffset;
|
|
258
|
-
function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
|
|
259
|
-
if (typeof date === "number") date = new Date(date);
|
|
260
|
-
if (offset === void 0) offset = timezoneOffset;
|
|
261
|
-
return Math.floor((date.valueOf() / Time2.minute - offset) / 1440);
|
|
262
|
-
}
|
|
263
|
-
Time2.getDateNumber = getDateNumber;
|
|
264
|
-
function fromDateNumber(value, offset) {
|
|
265
|
-
const date = new Date(value * Time2.day);
|
|
266
|
-
if (offset === void 0) offset = timezoneOffset;
|
|
267
|
-
return new Date(+date + offset * Time2.minute);
|
|
268
|
-
}
|
|
269
|
-
Time2.fromDateNumber = fromDateNumber;
|
|
270
|
-
const numeric = /\d+(?:\.\d+)?/.source;
|
|
271
|
-
const timeRegExp = new RegExp(`^${[
|
|
272
|
-
"w(?:eek(?:s)?)?",
|
|
273
|
-
"d(?:ay(?:s)?)?",
|
|
274
|
-
"h(?:our(?:s)?)?",
|
|
275
|
-
"m(?:in(?:ute)?(?:s)?)?",
|
|
276
|
-
"s(?:ec(?:ond)?(?:s)?)?"
|
|
277
|
-
].map((unit) => `(${numeric}${unit})?`).join("")}$`);
|
|
278
|
-
function parseTime(source) {
|
|
279
|
-
const capture = timeRegExp.exec(source);
|
|
280
|
-
if (!capture) return 0;
|
|
281
|
-
return (parseFloat(capture[1]) * Time2.week || 0) + (parseFloat(capture[2]) * Time2.day || 0) + (parseFloat(capture[3]) * Time2.hour || 0) + (parseFloat(capture[4]) * Time2.minute || 0) + (parseFloat(capture[5]) * Time2.second || 0);
|
|
282
|
-
}
|
|
283
|
-
Time2.parseTime = parseTime;
|
|
284
|
-
function parseDate(date) {
|
|
285
|
-
const parsed = parseTime(date);
|
|
286
|
-
if (parsed) {
|
|
287
|
-
date = Date.now() + parsed;
|
|
288
|
-
} else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
|
|
289
|
-
date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
|
|
290
|
-
} else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
|
|
291
|
-
date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
|
|
292
|
-
}
|
|
293
|
-
return date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
294
|
-
}
|
|
295
|
-
Time2.parseDate = parseDate;
|
|
296
|
-
function format(ms) {
|
|
297
|
-
const abs = Math.abs(ms);
|
|
298
|
-
if (abs >= Time2.day - Time2.hour / 2) {
|
|
299
|
-
return Math.round(ms / Time2.day) + "d";
|
|
300
|
-
} else if (abs >= Time2.hour - Time2.minute / 2) {
|
|
301
|
-
return Math.round(ms / Time2.hour) + "h";
|
|
302
|
-
} else if (abs >= Time2.minute - Time2.second / 2) {
|
|
303
|
-
return Math.round(ms / Time2.minute) + "m";
|
|
304
|
-
} else if (abs >= Time2.second) {
|
|
305
|
-
return Math.round(ms / Time2.second) + "s";
|
|
306
|
-
}
|
|
307
|
-
return ms + "ms";
|
|
308
|
-
}
|
|
309
|
-
Time2.format = format;
|
|
310
|
-
function toDigits(source, length = 2) {
|
|
311
|
-
return source.toString().padStart(length, "0");
|
|
312
|
-
}
|
|
313
|
-
Time2.toDigits = toDigits;
|
|
314
|
-
function template(template2, time = /* @__PURE__ */ new Date()) {
|
|
315
|
-
return template2.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));
|
|
316
|
-
}
|
|
317
|
-
Time2.template = template;
|
|
318
|
-
})(Time || (Time = {}));
|
|
319
|
-
export {
|
|
320
|
-
Binary,
|
|
321
|
-
Time,
|
|
322
|
-
arrayBufferToBase64,
|
|
323
|
-
arrayBufferToHex,
|
|
324
|
-
base64ToArrayBuffer,
|
|
325
|
-
camelCase,
|
|
326
|
-
camelize,
|
|
327
|
-
capitalize,
|
|
328
|
-
clone,
|
|
329
|
-
contain,
|
|
330
|
-
deduplicate,
|
|
331
|
-
deepEqual,
|
|
332
|
-
defineProperty,
|
|
333
|
-
difference,
|
|
334
|
-
filterKeys,
|
|
335
|
-
formatProperty,
|
|
336
|
-
hexToArrayBuffer,
|
|
337
|
-
hyphenate,
|
|
338
|
-
intersection,
|
|
339
|
-
is,
|
|
340
|
-
isNonNullable,
|
|
341
|
-
isNullable,
|
|
342
|
-
isPlainObject,
|
|
343
|
-
makeArray,
|
|
344
|
-
mapValues,
|
|
345
|
-
noop,
|
|
346
|
-
omit,
|
|
347
|
-
paramCase,
|
|
348
|
-
pick,
|
|
349
|
-
remove,
|
|
350
|
-
sanitize,
|
|
351
|
-
snakeCase,
|
|
352
|
-
trimSlash,
|
|
353
|
-
uncapitalize,
|
|
354
|
-
union,
|
|
355
|
-
mapValues as valueMap
|
|
356
|
-
};
|
|
357
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
// src/misc.ts
|
|
2
|
+
function noop() {
|
|
3
|
+
}
|
|
4
|
+
function isNullable(value) {
|
|
5
|
+
return value === null || value === void 0;
|
|
6
|
+
}
|
|
7
|
+
function isNonNullable(value) {
|
|
8
|
+
return !isNullable(value);
|
|
9
|
+
}
|
|
10
|
+
function isPlainObject(data) {
|
|
11
|
+
return data && typeof data === "object" && !Array.isArray(data);
|
|
12
|
+
}
|
|
13
|
+
function filterKeys(object, filter) {
|
|
14
|
+
return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
|
|
15
|
+
}
|
|
16
|
+
function mapValues(object, transform) {
|
|
17
|
+
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
|
|
18
|
+
}
|
|
19
|
+
function pick(source, keys, forced) {
|
|
20
|
+
if (!keys) return { ...source };
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
if (forced || source[key] !== void 0) result[key] = source[key];
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
function omit(source, keys) {
|
|
28
|
+
if (!keys) return { ...source };
|
|
29
|
+
const result = { ...source };
|
|
30
|
+
for (const key of keys) {
|
|
31
|
+
Reflect.deleteProperty(result, key);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
function defineProperty(object, key, value) {
|
|
36
|
+
return Object.defineProperty(object, key, { writable: true, value, enumerable: false });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/array.ts
|
|
40
|
+
function contain(array1, array2) {
|
|
41
|
+
return array2.every((item) => array1.includes(item));
|
|
42
|
+
}
|
|
43
|
+
function intersection(array1, array2) {
|
|
44
|
+
return array1.filter((item) => array2.includes(item));
|
|
45
|
+
}
|
|
46
|
+
function difference(array1, array2) {
|
|
47
|
+
return array1.filter((item) => !array2.includes(item));
|
|
48
|
+
}
|
|
49
|
+
function union(array1, array2) {
|
|
50
|
+
return Array.from(/* @__PURE__ */ new Set([...array1, ...array2]));
|
|
51
|
+
}
|
|
52
|
+
function deduplicate(array) {
|
|
53
|
+
return [...new Set(array)];
|
|
54
|
+
}
|
|
55
|
+
function remove(list, item) {
|
|
56
|
+
const index = list?.indexOf(item);
|
|
57
|
+
if (index >= 0) {
|
|
58
|
+
list.splice(index, 1);
|
|
59
|
+
return true;
|
|
60
|
+
} else {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function makeArray(source) {
|
|
65
|
+
return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/types.ts
|
|
69
|
+
function is(type, value) {
|
|
70
|
+
if (arguments.length === 1) return (value2) => is(type, value2);
|
|
71
|
+
return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
|
|
72
|
+
}
|
|
73
|
+
function isArrayBufferLike(value) {
|
|
74
|
+
return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
|
|
75
|
+
}
|
|
76
|
+
function isArrayBufferSource(value) {
|
|
77
|
+
return isArrayBufferLike(value) || ArrayBuffer.isView(value);
|
|
78
|
+
}
|
|
79
|
+
var Binary;
|
|
80
|
+
((Binary2) => {
|
|
81
|
+
Binary2.is = isArrayBufferLike;
|
|
82
|
+
Binary2.isSource = isArrayBufferSource;
|
|
83
|
+
function fromSource(source) {
|
|
84
|
+
if (ArrayBuffer.isView(source)) {
|
|
85
|
+
return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
86
|
+
} else {
|
|
87
|
+
return source;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
Binary2.fromSource = fromSource;
|
|
91
|
+
function toBase64(source) {
|
|
92
|
+
source = fromSource(source);
|
|
93
|
+
if (typeof Buffer !== "undefined") {
|
|
94
|
+
return Buffer.from(source).toString("base64");
|
|
95
|
+
}
|
|
96
|
+
let binary = "";
|
|
97
|
+
const bytes = new Uint8Array(source);
|
|
98
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
99
|
+
binary += String.fromCharCode(bytes[i]);
|
|
100
|
+
}
|
|
101
|
+
return btoa(binary);
|
|
102
|
+
}
|
|
103
|
+
Binary2.toBase64 = toBase64;
|
|
104
|
+
function fromBase64(source) {
|
|
105
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
|
|
106
|
+
return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
|
|
107
|
+
}
|
|
108
|
+
Binary2.fromBase64 = fromBase64;
|
|
109
|
+
function toHex(source) {
|
|
110
|
+
source = fromSource(source);
|
|
111
|
+
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
|
|
112
|
+
return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
113
|
+
}
|
|
114
|
+
Binary2.toHex = toHex;
|
|
115
|
+
function fromHex(source) {
|
|
116
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
|
|
117
|
+
const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
|
|
118
|
+
const buffer = [];
|
|
119
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
120
|
+
buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
|
|
121
|
+
}
|
|
122
|
+
return Uint8Array.from(buffer).buffer;
|
|
123
|
+
}
|
|
124
|
+
Binary2.fromHex = fromHex;
|
|
125
|
+
})(Binary || (Binary = {}));
|
|
126
|
+
var base64ToArrayBuffer = Binary.fromBase64;
|
|
127
|
+
var arrayBufferToBase64 = Binary.toBase64;
|
|
128
|
+
var hexToArrayBuffer = Binary.fromHex;
|
|
129
|
+
var arrayBufferToHex = Binary.toHex;
|
|
130
|
+
function clone(source, refs = /* @__PURE__ */ new Map()) {
|
|
131
|
+
if (!source || typeof source !== "object") return source;
|
|
132
|
+
if (is("Date", source)) return new Date(source.valueOf());
|
|
133
|
+
if (is("RegExp", source)) return new RegExp(source.source, source.flags);
|
|
134
|
+
if (isArrayBufferLike(source)) return source.slice(0);
|
|
135
|
+
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
136
|
+
const cached = refs.get(source);
|
|
137
|
+
if (cached) return cached;
|
|
138
|
+
if (Array.isArray(source)) {
|
|
139
|
+
const result2 = [];
|
|
140
|
+
refs.set(source, result2);
|
|
141
|
+
source.forEach((value, index) => {
|
|
142
|
+
result2[index] = Reflect.apply(clone, null, [value, refs]);
|
|
143
|
+
});
|
|
144
|
+
return result2;
|
|
145
|
+
}
|
|
146
|
+
const result = Object.create(Object.getPrototypeOf(source));
|
|
147
|
+
refs.set(source, result);
|
|
148
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
149
|
+
const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
|
|
150
|
+
if ("value" in descriptor) {
|
|
151
|
+
descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
|
|
152
|
+
}
|
|
153
|
+
Reflect.defineProperty(result, key, descriptor);
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
function deepEqual(a, b, strict) {
|
|
158
|
+
if (a === b) return true;
|
|
159
|
+
if (!strict && isNullable(a) && isNullable(b)) return true;
|
|
160
|
+
if (typeof a !== typeof b) return false;
|
|
161
|
+
if (typeof a !== "object") return false;
|
|
162
|
+
if (!a || !b) return false;
|
|
163
|
+
function check(test, then) {
|
|
164
|
+
return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
|
|
165
|
+
}
|
|
166
|
+
return check(Array.isArray, (a2, b2) => a2.length === b2.length && a2.every((item, index) => deepEqual(item, b2[index]))) ?? check(is("Date"), (a2, b2) => a2.valueOf() === b2.valueOf()) ?? check(is("RegExp"), (a2, b2) => a2.source === b2.source && a2.flags === b2.flags) ?? check(isArrayBufferLike, (a2, b2) => {
|
|
167
|
+
if (a2.byteLength !== b2.byteLength) return false;
|
|
168
|
+
const viewA = new Uint8Array(a2);
|
|
169
|
+
const viewB = new Uint8Array(b2);
|
|
170
|
+
for (let i = 0; i < viewA.length; i++) {
|
|
171
|
+
if (viewA[i] !== viewB[i]) return false;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}) ?? Object.keys({ ...a, ...b }).every((key) => deepEqual(a[key], b[key], strict));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/string.ts
|
|
178
|
+
function capitalize(source) {
|
|
179
|
+
return source.charAt(0).toUpperCase() + source.slice(1);
|
|
180
|
+
}
|
|
181
|
+
function uncapitalize(source) {
|
|
182
|
+
return source.charAt(0).toLowerCase() + source.slice(1);
|
|
183
|
+
}
|
|
184
|
+
function camelCase(source) {
|
|
185
|
+
return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
|
|
186
|
+
}
|
|
187
|
+
function tokenize(source, delimiters, delimiter) {
|
|
188
|
+
const output = [];
|
|
189
|
+
let state = 0 /* DELIM */;
|
|
190
|
+
for (let i = 0; i < source.length; i++) {
|
|
191
|
+
const code = source.charCodeAt(i);
|
|
192
|
+
if (code >= 65 && code <= 90) {
|
|
193
|
+
if (state === 1 /* UPPER */) {
|
|
194
|
+
const next = source.charCodeAt(i + 1);
|
|
195
|
+
if (next >= 97 && next <= 122) {
|
|
196
|
+
output.push(delimiter);
|
|
197
|
+
}
|
|
198
|
+
output.push(code + 32);
|
|
199
|
+
} else {
|
|
200
|
+
if (state !== 0 /* DELIM */) {
|
|
201
|
+
output.push(delimiter);
|
|
202
|
+
}
|
|
203
|
+
output.push(code + 32);
|
|
204
|
+
}
|
|
205
|
+
state = 1 /* UPPER */;
|
|
206
|
+
} else if (code >= 97 && code <= 122) {
|
|
207
|
+
output.push(code);
|
|
208
|
+
state = 2 /* LOWER */;
|
|
209
|
+
} else if (delimiters.includes(code)) {
|
|
210
|
+
if (state !== 0 /* DELIM */) {
|
|
211
|
+
output.push(delimiter);
|
|
212
|
+
}
|
|
213
|
+
state = 0 /* DELIM */;
|
|
214
|
+
} else {
|
|
215
|
+
output.push(code);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return String.fromCharCode(...output);
|
|
219
|
+
}
|
|
220
|
+
function paramCase(source) {
|
|
221
|
+
return tokenize(source, [45, 95], 45);
|
|
222
|
+
}
|
|
223
|
+
function snakeCase(source) {
|
|
224
|
+
return tokenize(source, [45, 95], 95);
|
|
225
|
+
}
|
|
226
|
+
var camelize = camelCase;
|
|
227
|
+
var hyphenate = paramCase;
|
|
228
|
+
function formatProperty(key) {
|
|
229
|
+
if (typeof key !== "string") return `[${key.toString()}]`;
|
|
230
|
+
return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
|
|
231
|
+
}
|
|
232
|
+
function trimSlash(source) {
|
|
233
|
+
return source.replace(/\/$/, "");
|
|
234
|
+
}
|
|
235
|
+
function sanitize(source) {
|
|
236
|
+
if (!source.startsWith("/")) source = "/" + source;
|
|
237
|
+
return trimSlash(source);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/time.ts
|
|
241
|
+
var Time;
|
|
242
|
+
((Time2) => {
|
|
243
|
+
Time2.millisecond = 1;
|
|
244
|
+
Time2.second = 1e3;
|
|
245
|
+
Time2.minute = Time2.second * 60;
|
|
246
|
+
Time2.hour = Time2.minute * 60;
|
|
247
|
+
Time2.day = Time2.hour * 24;
|
|
248
|
+
Time2.week = Time2.day * 7;
|
|
249
|
+
let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
250
|
+
function setTimezoneOffset(offset) {
|
|
251
|
+
timezoneOffset = offset;
|
|
252
|
+
}
|
|
253
|
+
Time2.setTimezoneOffset = setTimezoneOffset;
|
|
254
|
+
function getTimezoneOffset() {
|
|
255
|
+
return timezoneOffset;
|
|
256
|
+
}
|
|
257
|
+
Time2.getTimezoneOffset = getTimezoneOffset;
|
|
258
|
+
function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
|
|
259
|
+
if (typeof date === "number") date = new Date(date);
|
|
260
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
261
|
+
return Math.floor((date.valueOf() / Time2.minute - offset) / 1440);
|
|
262
|
+
}
|
|
263
|
+
Time2.getDateNumber = getDateNumber;
|
|
264
|
+
function fromDateNumber(value, offset) {
|
|
265
|
+
const date = new Date(value * Time2.day);
|
|
266
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
267
|
+
return new Date(+date + offset * Time2.minute);
|
|
268
|
+
}
|
|
269
|
+
Time2.fromDateNumber = fromDateNumber;
|
|
270
|
+
const numeric = /\d+(?:\.\d+)?/.source;
|
|
271
|
+
const timeRegExp = new RegExp(`^${[
|
|
272
|
+
"w(?:eek(?:s)?)?",
|
|
273
|
+
"d(?:ay(?:s)?)?",
|
|
274
|
+
"h(?:our(?:s)?)?",
|
|
275
|
+
"m(?:in(?:ute)?(?:s)?)?",
|
|
276
|
+
"s(?:ec(?:ond)?(?:s)?)?"
|
|
277
|
+
].map((unit) => `(${numeric}${unit})?`).join("")}$`);
|
|
278
|
+
function parseTime(source) {
|
|
279
|
+
const capture = timeRegExp.exec(source);
|
|
280
|
+
if (!capture) return 0;
|
|
281
|
+
return (parseFloat(capture[1]) * Time2.week || 0) + (parseFloat(capture[2]) * Time2.day || 0) + (parseFloat(capture[3]) * Time2.hour || 0) + (parseFloat(capture[4]) * Time2.minute || 0) + (parseFloat(capture[5]) * Time2.second || 0);
|
|
282
|
+
}
|
|
283
|
+
Time2.parseTime = parseTime;
|
|
284
|
+
function parseDate(date) {
|
|
285
|
+
const parsed = parseTime(date);
|
|
286
|
+
if (parsed) {
|
|
287
|
+
date = Date.now() + parsed;
|
|
288
|
+
} else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
|
|
289
|
+
date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
|
|
290
|
+
} else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) {
|
|
291
|
+
date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
|
|
292
|
+
}
|
|
293
|
+
return date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
294
|
+
}
|
|
295
|
+
Time2.parseDate = parseDate;
|
|
296
|
+
function format(ms) {
|
|
297
|
+
const abs = Math.abs(ms);
|
|
298
|
+
if (abs >= Time2.day - Time2.hour / 2) {
|
|
299
|
+
return Math.round(ms / Time2.day) + "d";
|
|
300
|
+
} else if (abs >= Time2.hour - Time2.minute / 2) {
|
|
301
|
+
return Math.round(ms / Time2.hour) + "h";
|
|
302
|
+
} else if (abs >= Time2.minute - Time2.second / 2) {
|
|
303
|
+
return Math.round(ms / Time2.minute) + "m";
|
|
304
|
+
} else if (abs >= Time2.second) {
|
|
305
|
+
return Math.round(ms / Time2.second) + "s";
|
|
306
|
+
}
|
|
307
|
+
return ms + "ms";
|
|
308
|
+
}
|
|
309
|
+
Time2.format = format;
|
|
310
|
+
function toDigits(source, length = 2) {
|
|
311
|
+
return source.toString().padStart(length, "0");
|
|
312
|
+
}
|
|
313
|
+
Time2.toDigits = toDigits;
|
|
314
|
+
function template(template2, time = /* @__PURE__ */ new Date()) {
|
|
315
|
+
return template2.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));
|
|
316
|
+
}
|
|
317
|
+
Time2.template = template;
|
|
318
|
+
})(Time || (Time = {}));
|
|
319
|
+
export {
|
|
320
|
+
Binary,
|
|
321
|
+
Time,
|
|
322
|
+
arrayBufferToBase64,
|
|
323
|
+
arrayBufferToHex,
|
|
324
|
+
base64ToArrayBuffer,
|
|
325
|
+
camelCase,
|
|
326
|
+
camelize,
|
|
327
|
+
capitalize,
|
|
328
|
+
clone,
|
|
329
|
+
contain,
|
|
330
|
+
deduplicate,
|
|
331
|
+
deepEqual,
|
|
332
|
+
defineProperty,
|
|
333
|
+
difference,
|
|
334
|
+
filterKeys,
|
|
335
|
+
formatProperty,
|
|
336
|
+
hexToArrayBuffer,
|
|
337
|
+
hyphenate,
|
|
338
|
+
intersection,
|
|
339
|
+
is,
|
|
340
|
+
isNonNullable,
|
|
341
|
+
isNullable,
|
|
342
|
+
isPlainObject,
|
|
343
|
+
makeArray,
|
|
344
|
+
mapValues,
|
|
345
|
+
noop,
|
|
346
|
+
omit,
|
|
347
|
+
paramCase,
|
|
348
|
+
pick,
|
|
349
|
+
remove,
|
|
350
|
+
sanitize,
|
|
351
|
+
snakeCase,
|
|
352
|
+
trimSlash,
|
|
353
|
+
uncapitalize,
|
|
354
|
+
union,
|
|
355
|
+
mapValues as valueMap
|
|
356
|
+
};
|
|
357
|
+
//# sourceMappingURL=index.mjs.map
|