@banbolee/dsh-fish-shell 0.6.0 → 0.8.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +310 -13
  3. package/README.zh.md +99 -4
  4. package/THIRD-PARTY-NOTICES.md +91 -0
  5. package/cordis.patch.yml +56 -0
  6. package/node_modules/@deepseek-ai/cosmokit/LICENSE +21 -0
  7. package/node_modules/@deepseek-ai/cosmokit/README.md +30 -0
  8. package/node_modules/@deepseek-ai/cosmokit/lib/index.js +418 -0
  9. package/node_modules/@deepseek-ai/cosmokit/lib/types/array.d.ts +15 -0
  10. package/node_modules/@deepseek-ai/cosmokit/lib/types/array.d.ts.map +1 -0
  11. package/node_modules/@deepseek-ai/cosmokit/lib/types/index.d.ts +13 -0
  12. package/node_modules/@deepseek-ai/cosmokit/lib/types/index.d.ts.map +1 -0
  13. package/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts +41 -0
  14. package/node_modules/@deepseek-ai/cosmokit/lib/types/misc.d.ts.map +1 -0
  15. package/node_modules/@deepseek-ai/cosmokit/lib/types/string.d.ts +89 -0
  16. package/node_modules/@deepseek-ai/cosmokit/lib/types/string.d.ts.map +1 -0
  17. package/node_modules/@deepseek-ai/cosmokit/lib/types/time.d.ts +19 -0
  18. package/node_modules/@deepseek-ai/cosmokit/lib/types/time.d.ts.map +1 -0
  19. package/node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts +42 -0
  20. package/node_modules/@deepseek-ai/cosmokit/lib/types/types.d.ts.map +1 -0
  21. package/node_modules/@deepseek-ai/cosmokit/lib/types/volatile.d.ts +40 -0
  22. package/node_modules/@deepseek-ai/cosmokit/lib/types/volatile.d.ts.map +1 -0
  23. package/node_modules/@deepseek-ai/cosmokit/package.json +32 -0
  24. package/node_modules/@deepseek-ai/cosmokit/src/array.ts +42 -0
  25. package/node_modules/@deepseek-ai/cosmokit/src/index.ts +12 -0
  26. package/node_modules/@deepseek-ai/cosmokit/src/misc.ts +78 -0
  27. package/node_modules/@deepseek-ai/cosmokit/src/string.ts +113 -0
  28. package/node_modules/@deepseek-ai/cosmokit/src/time.ts +92 -0
  29. package/node_modules/@deepseek-ai/cosmokit/src/types.ts +168 -0
  30. package/node_modules/@deepseek-ai/cosmokit/src/volatile.ts +86 -0
  31. package/node_modules/@deepseek-ai/dsh-tool-terminal/LICENSE +21 -0
  32. package/node_modules/@deepseek-ai/dsh-tool-terminal/README.i18n.yaml +100 -0
  33. package/node_modules/@deepseek-ai/dsh-tool-terminal/README.md +186 -0
  34. package/node_modules/@deepseek-ai/dsh-tool-terminal/README.zh.md +186 -0
  35. package/node_modules/@deepseek-ai/dsh-tool-terminal/lib/index.js +646 -0
  36. package/node_modules/@deepseek-ai/dsh-tool-terminal/lib/types/background.d.ts +20 -0
  37. package/node_modules/@deepseek-ai/dsh-tool-terminal/lib/types/index.d.ts +32 -0
  38. package/node_modules/@deepseek-ai/dsh-tool-terminal/lib/types/render.d.ts +81 -0
  39. package/node_modules/@deepseek-ai/dsh-tool-terminal/package.json +63 -0
  40. package/node_modules/@deepseek-ai/schemastery/LICENSE +21 -0
  41. package/node_modules/@deepseek-ai/schemastery/README.md +393 -0
  42. package/node_modules/@deepseek-ai/schemastery/lib/index.cjs +635 -0
  43. package/node_modules/@deepseek-ai/schemastery/lib/index.mjs +635 -0
  44. package/node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts +211 -0
  45. package/node_modules/@deepseek-ai/schemastery/lib/types/index.d.ts.map +1 -0
  46. package/node_modules/@deepseek-ai/schemastery/package.json +39 -0
  47. package/node_modules/@deepseek-ai/schemastery/src/index.ts +962 -0
  48. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  49. package/node_modules/@standard-schema/spec/README.md +198 -0
  50. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  51. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  52. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  53. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  54. package/node_modules/@standard-schema/spec/package.json +52 -0
  55. package/package.json +56 -42
  56. package/terminal-fish.js +18 -0
  57. package/terminal-tools.js +259 -0
  58. package/terminal.js +297 -0
@@ -0,0 +1,91 @@
1
+ # Third-party notices — `@banbolee/dsh-fish-shell`
2
+
3
+ This package distributes third-party code inside its tarball. The runtime
4
+ dependency listed under `bundledDependencies` in `package.json` — and its
5
+ transitive dependencies — are packed as real files under
6
+ `package/node_modules/**` by the release chain
7
+ (`pnpm install --prod --config.node-linker=hoisted` then
8
+ `pnpm pack --config.node-linker=hoisted`), so an offline profile can install
9
+ the bundle without fetching them separately.
10
+
11
+ This file records the origin, version and license of each bundled package. It
12
+ is a human-readable provenance note, **not** a replacement for the license
13
+ texts: every bundled package ships its own `LICENSE` file inside the tarball,
14
+ and that packaged file is the authoritative text. The license names below come
15
+ from the packaged `LICENSE` file and the package's own `package.json`; where
16
+ either was ambiguous this file would say "see the packaged LICENSE" instead of
17
+ naming one.
18
+
19
+ ## Bundled inventory
20
+
21
+ | Package | Version | License | Location inside the tarball |
22
+ |---|---|---|---|
23
+ | `@deepseek-ai/dsh-tool-terminal` | `0.2.0-rc.1` | MIT | `package/node_modules/@deepseek-ai/dsh-tool-terminal/` |
24
+ | `@deepseek-ai/schemastery` | `3.18.4` | MIT | `package/node_modules/@deepseek-ai/schemastery/` |
25
+ | `@deepseek-ai/cosmokit` | `1.8.5` | MIT | `package/node_modules/@deepseek-ai/cosmokit/` |
26
+ | `@standard-schema/spec` | `1.1.0` | MIT | `package/node_modules/@standard-schema/spec/` |
27
+
28
+ Dependency edges, as declared by the packaged manifests:
29
+
30
+ - `@deepseek-ai/dsh-tool-terminal@0.2.0-rc.1` → `@deepseek-ai/schemastery ~3.18.4`
31
+ - `@deepseek-ai/schemastery@3.18.4` → `@standard-schema/spec ^1.1.0`, `@deepseek-ai/cosmokit ~1.8.5`
32
+ - `@standard-schema/spec@1.1.0` and `@deepseek-ai/cosmokit@1.8.5` → no runtime dependencies
33
+
34
+ Those four packages are the complete `node_modules/` inventory of the packed
35
+ tarball; each of them includes its `LICENSE` file.
36
+
37
+ ## `@deepseek-ai/dsh-tool-terminal` 0.2.0-rc.1 — MIT
38
+
39
+ - Origin: `git+https://github.com/deepseek-ai/deepseek-harness.git`, directory
40
+ `packages/terminal/tool-terminal` (from the packaged `package.json`
41
+ `repository`).
42
+ - License: MIT (`package.json` `"license": "MIT"`), license text header
43
+ "MIT License", copyright notice `Copyright (c) 2026 DeepSeek`.
44
+ - Role here: the six model-facing `terminal_*` tools mounted by the
45
+ `terminal-tools` row of this bundle's `cordis.patch.yml`. It is declared as a
46
+ `dependencies` + `bundledDependencies` entry of this package, not as a peer,
47
+ so it resolves from inside this package.
48
+
49
+ ## `@deepseek-ai/schemastery` 3.18.4 — MIT
50
+
51
+ - Origin: `git+https://github.com/deepseek-ai/deepseek-harness.git`, directory
52
+ `vendor/schemastery` (from the packaged `package.json` `repository`).
53
+ - License: MIT (`package.json` `"license": "MIT"`), license text header
54
+ "MIT License", copyright notice `Copyright (c) 2021-present Shigma`
55
+ (packaged `author`: `Shigma <shigma10826@gmail.com>`).
56
+ - Role here: transitive runtime dependency of
57
+ `@deepseek-ai/dsh-tool-terminal`.
58
+
59
+ ## `@deepseek-ai/cosmokit` 1.8.5 — MIT
60
+
61
+ - Origin: `git+https://github.com/deepseek-ai/deepseek-harness.git`, directory
62
+ `vendor/cosmokit` (from the packaged `package.json` `repository`).
63
+ - License: MIT (`package.json` `"license": "MIT"`), license text header
64
+ "MIT License", copyright notice `Copyright (c) 2021-present Shigma`
65
+ (packaged `author`: `Shigma <shigma10826@gmail.com>`).
66
+ - Role here: transitive runtime dependency of `@deepseek-ai/schemastery`.
67
+
68
+ ## `@standard-schema/spec` 1.1.0 — MIT
69
+
70
+ - Origin: `https://github.com/standard-schema/standard-schema` (from the
71
+ packaged `package.json` `repository`; packaged `homepage`:
72
+ `https://standardschema.dev`).
73
+ - License: MIT (`package.json` `"license": "MIT"`), license text header
74
+ "MIT License", copyright notice `Copyright (c) 2024 Colin McDonnell`
75
+ (packaged `author`: `Colin McDonnell`).
76
+ - Role here: transitive runtime dependency of `@deepseek-ai/schemastery`.
77
+
78
+ ## Re-verifying this inventory
79
+
80
+ After packing, list the tarball and check the four packages (and their
81
+ `LICENSE` files) are present:
82
+
83
+ ```sh
84
+ pnpm install --prod --config.node-linker=hoisted
85
+ pnpm pack --config.node-linker=hoisted
86
+ tar tzf banbolee-dsh-fish-shell-*.tgz | grep '^package/node_modules/'
87
+ ```
88
+
89
+ Version bumps of the bundled dependency must update this file together with
90
+ `dependencies` in `package.json` (the version pin is asserted by the
91
+ plugin's contract tests).
package/cordis.patch.yml CHANGED
@@ -52,3 +52,59 @@
52
52
 
53
53
  - id: fish-preset-policy
54
54
  name: '@banbolee/dsh-fish-shell/policy'
55
+ # ── L2 interactive terminal sessions (fish-shell-tty-v3 §3.1) ───────────────────
56
+ # A self-contained group: `isolate.terminals` keeps the `terminals` service
57
+ # entry-local to the group (mounting it at the host plane would leave the entry
58
+ # pending in profiles whose host plane has no `terminals` service). Inside it:
59
+ # - `pty` the official terminal registry;
60
+ # - `terminal-fish-pty` this bundle's `terminal` module: the OFFICIAL
61
+ # `@deepseek-ai/dsh-terminal-bash` backend, driven with fish argv, PLUS the
62
+ # harness home contract (`DSH_HOME`, `DSH_PROFILE`, `DSH_PROFILE_DIR`) in
63
+ # the PTY child environment — the same facts the one-shot `fish` tool gets
64
+ # from `ctx.shellEnv`, so a nested `dsh` resolves the real harness home
65
+ # instead of `~/.dsh`. The row used to mount the official package directly;
66
+ # it cannot any more because that row has no `env` config field and its
67
+ # `childEnvironment()` is module-private, so owning the row is the only way
68
+ # to add the contract without editing or patching the official module.
69
+ # Everything else is still the official class (see `terminal.js`): the
70
+ # backend type stays `shell`, argv confinement and the sandbox-mode fence
71
+ # stay official, and readiness still comes from `session.initialize()`.
72
+ # The prompt setup rides in `-C` (startup submits nothing) so the motd stays
73
+ # clean — feeding the same setup through PTY input gets it echoed back by
74
+ # the fish line editor. The string below is FISH_PROMPT_SETUP from
75
+ # `terminal-fish.js` verbatim: the `\x1b` / `\x07` escapes must reach fish
76
+ # as literal backslash sequences for its `printf` to build the bytes at
77
+ # runtime (a contract test compares this value with the exported constant);
78
+ # - `terminal-tools` the official tool package; `tools` is NOT isolated,
79
+ # so its six `terminal_*` tools register into the host registry and are
80
+ # visible to agents;
81
+ # - `fish-terminal-tools` this bundle's `terminalTools` policy, mounted in the
82
+ # same group so its scope matches the session surface (`deny` restricts the
83
+ # six explicit names per agent; `allow` is the default no-op).
84
+ # The host-plane rows above (bash disabled + fish-shell/tool-fish/
85
+ # fish-preset-policy) are untouched: `ctx.shell` and the one-shot `fish` tool
86
+ # keep their exact code path.
87
+ - insert:
88
+ - id: fish-terminal-group
89
+ name: 'cordis:group'
90
+ group: true
91
+ isolate:
92
+ terminals: true
93
+ config:
94
+ - id: pty
95
+ name: '@deepseek-ai/dsh-terminal'
96
+
97
+ - id: terminal-fish-pty
98
+ name: '@banbolee/dsh-fish-shell/terminal'
99
+ config:
100
+ shellPath: fish
101
+ shellArgs: ["--no-config","-i","-C","function fish_greeting; end; function fish_prompt; printf '\\x1b]133;D;%s\\x07' $status; echo -n 'dsh> '; end; function fish_right_prompt; end;"]
102
+ timeoutMs: 300000
103
+
104
+ - id: terminal-tools
105
+ name: '@deepseek-ai/dsh-tool-terminal'
106
+
107
+ - id: fish-terminal-tools
108
+ name: '@banbolee/dsh-fish-shell/terminal-tools'
109
+ config:
110
+ terminalTools: allow
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Shigma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # cosmokit
2
+
3
+ [![Codecov](https://img.shields.io/codecov/c/github/shigma/cosmokit?style=flat-square)](https://codecov.io/gh/shigma/cosmokit)
4
+ [![npm](https://img.shields.io/npm/v/cosmokit?style=flat-square)](https://www.npmjs.com/package/cosmokit)
5
+
6
+ A collection of common utilities.
7
+
8
+ ## Usage
9
+
10
+ ### Node.js
11
+
12
+ ```sh
13
+ npm install cosmokit
14
+ ```
15
+
16
+ ```ts
17
+ import cosmokit from 'cosmokit'
18
+ ```
19
+
20
+ ### Deno
21
+
22
+ ```ts
23
+ import cosmokit from 'npm:cosmokit@latest'
24
+ ```
25
+
26
+ ## Config references
27
+
28
+ `Volatile<T>` exposes `get()` for immutable data snapshots. `createVolatile()` copies and freezes validated data; framework-owned `updateVolatile()` transfers a candidate snapshot into an existing reference. Framework-owned `volatileEntries()` enumerates references and their paths through plain config containers, stopping at snapshots and opaque objects. The shared symbol protocol recognizes references across ESM/CJS copies. Plugin consumers import the type from Cordis and retain the reference rather than caching values between operations.
29
+
30
+ `deepEqual()` treats two volatile references as equal regardless of their snapshots. Strict comparisons distinguish null from undefined recursively, compare URLs by normalized `href` and other opaque objects by identity, and treat distinct cyclic structures as unequal. Array comparison visits every index and treats holes as undefined. Snapshot-change detection must compare `.get()` results separately.
@@ -0,0 +1,418 @@
1
+ //#region lib/types/misc.js
2
+ /** No-op callback returning `undefined` at runtime and `any` at type level. */
3
+ function noop() {}
4
+ /** Return true when a value is `null` or `undefined`. */
5
+ function isNullable(value) {
6
+ return value === null || value === void 0;
7
+ }
8
+ /** Return true when a value is neither `null` nor `undefined`. */
9
+ function isNonNullable(value) {
10
+ return !isNullable(value);
11
+ }
12
+ /** Return true for non-array object values. */
13
+ function isPlainObject(data) {
14
+ return data && typeof data === "object" && !Array.isArray(data);
15
+ }
16
+ /** Filter object entries and return a new object. */
17
+ function filterKeys(object, filter) {
18
+ return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
19
+ }
20
+ /** Map object values while preserving the original key set. */
21
+ function mapValues(object, transform) {
22
+ return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
23
+ }
24
+ /** Pick selected keys from an object, optionally including `undefined` values. */
25
+ function pick(source, keys, forced) {
26
+ if (!keys) return { ...source };
27
+ const result = {};
28
+ for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
29
+ return result;
30
+ }
31
+ /** Omit selected keys from a shallow object copy. */
32
+ function omit(source, keys) {
33
+ if (!keys) return { ...source };
34
+ const result = { ...source };
35
+ for (const key of keys) Reflect.deleteProperty(result, key);
36
+ return result;
37
+ }
38
+ /** Define a non-enumerable writable property and return the object. */
39
+ function defineProperty(object, key, value) {
40
+ return Object.defineProperty(object, key, {
41
+ writable: true,
42
+ value,
43
+ enumerable: false
44
+ });
45
+ }
46
+ //#endregion
47
+ //#region lib/types/array.js
48
+ /** Return true when every item in `array2` is present in `array1`. */
49
+ function contain(array1, array2) {
50
+ return array2.every((item) => array1.includes(item));
51
+ }
52
+ /** Return items that appear in both arrays. */
53
+ function intersection(array1, array2) {
54
+ return array1.filter((item) => array2.includes(item));
55
+ }
56
+ /** Return items from `array1` that do not appear in `array2`. */
57
+ function difference(array1, array2) {
58
+ return array1.filter((item) => !array2.includes(item));
59
+ }
60
+ /** Return the set-union of two arrays while preserving first occurrence order. */
61
+ function union(array1, array2) {
62
+ return Array.from(new Set([...array1, ...array2]));
63
+ }
64
+ /** Remove duplicate values while preserving first occurrence order. */
65
+ function deduplicate(array) {
66
+ return [...new Set(array)];
67
+ }
68
+ /** Remove one item from an array and report whether it was found. */
69
+ function remove(list, item) {
70
+ const index = list?.indexOf(item);
71
+ if (index >= 0) {
72
+ list.splice(index, 1);
73
+ return true;
74
+ } else return false;
75
+ }
76
+ /** Normalize nullish, scalar, or array input to an array. */
77
+ function makeArray(source) {
78
+ return Array.isArray(source) ? source : isNullable(source) ? [] : [source];
79
+ }
80
+ //#endregion
81
+ //#region lib/types/volatile.js
82
+ /** Shared config references used by schema validators and plugin runtimes. */
83
+ const write = Symbol.for("cosmokit.volatile.write");
84
+ function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
85
+ if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
86
+ if (value === null || typeof value !== "object") return value;
87
+ if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
88
+ ancestors.add(value);
89
+ try {
90
+ if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
91
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
92
+ return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
93
+ } finally {
94
+ ancestors.delete(value);
95
+ }
96
+ }
97
+ /**
98
+ * Create a detached reference containing an immutable copy of the supplied data.
99
+ * @param value - validated config data; class instances and functions are unsupported.
100
+ * @returns a reference whose value is updated only by its owning runtime.
101
+ */
102
+ function createVolatile(value) {
103
+ let current = snapshot(value);
104
+ return Object.freeze({
105
+ get: () => current,
106
+ [write]: (value) => {
107
+ current = value;
108
+ }
109
+ });
110
+ }
111
+ /**
112
+ * Identify references across ESM/CJS copies of the shared library.
113
+ * @param value - a parsed config value.
114
+ * @returns whether the value implements the shared reference protocol.
115
+ */
116
+ function isVolatile(value) {
117
+ return typeof value === "object" && value !== null && write in value;
118
+ }
119
+ /**
120
+ * Collect config references without descending into their snapshots or opaque objects.
121
+ * @internal
122
+ * @param value - parsed config; cyclic ordinary fields are visited once per path.
123
+ * @returns references and their object-key paths, including an empty path for a root reference.
124
+ */
125
+ function volatileEntries(value) {
126
+ const ancestors = /* @__PURE__ */ new Set();
127
+ function visit(value, path) {
128
+ if (isVolatile(value)) return [{
129
+ path,
130
+ ref: value
131
+ }];
132
+ if (!value || typeof value !== "object" || ancestors.has(value)) return [];
133
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return [];
134
+ ancestors.add(value);
135
+ try {
136
+ return Object.entries(value).flatMap(([key, child]) => visit(child, [...path, key]));
137
+ } finally {
138
+ ancestors.delete(value);
139
+ }
140
+ }
141
+ return visit(value, []);
142
+ }
143
+ /**
144
+ * Commit an already validated immutable snapshot from another reference.
145
+ * @internal
146
+ * @param target - the owning plugin's stable reference.
147
+ * @param source - a newly parsed candidate reference.
148
+ */
149
+ function updateVolatile(target, source) {
150
+ target[write](source.get());
151
+ }
152
+ //#endregion
153
+ //#region lib/types/types.js
154
+ /** Test values using `instanceof` with a `toStringTag` fallback. */
155
+ function is(type, value) {
156
+ if (arguments.length === 1) return (value) => is(type, value);
157
+ return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
158
+ }
159
+ function isArrayBufferLike(value) {
160
+ return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
161
+ }
162
+ function isArrayBufferSource(value) {
163
+ return isArrayBufferLike(value) || ArrayBuffer.isView(value);
164
+ }
165
+ /** Binary source detection and base64/hex conversion helpers. */
166
+ var Binary;
167
+ (function(Binary) {
168
+ Binary.is = isArrayBufferLike;
169
+ Binary.isSource = isArrayBufferSource;
170
+ function fromSource(source) {
171
+ if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
172
+ else return source;
173
+ }
174
+ Binary.fromSource = fromSource;
175
+ function toBase64(source) {
176
+ source = fromSource(source);
177
+ if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
178
+ let binary = "";
179
+ const bytes = new Uint8Array(source);
180
+ for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
181
+ return btoa(binary);
182
+ }
183
+ Binary.toBase64 = toBase64;
184
+ function fromBase64(source) {
185
+ if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
186
+ return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
187
+ }
188
+ Binary.fromBase64 = fromBase64;
189
+ function toHex(source) {
190
+ source = fromSource(source);
191
+ if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
192
+ return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
193
+ }
194
+ Binary.toHex = toHex;
195
+ function fromHex(source) {
196
+ if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
197
+ const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
198
+ const buffer = [];
199
+ for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
200
+ return Uint8Array.from(buffer).buffer;
201
+ }
202
+ Binary.fromHex = fromHex;
203
+ })(Binary || (Binary = {}));
204
+ /** Decode a base64 string into binary data. */
205
+ const base64ToArrayBuffer = Binary.fromBase64;
206
+ /** Encode binary data as base64. */
207
+ const arrayBufferToBase64 = Binary.toBase64;
208
+ /** Decode a hex string into binary data. */
209
+ const hexToArrayBuffer = Binary.fromHex;
210
+ /** Encode binary data as hex. */
211
+ const arrayBufferToHex = Binary.toHex;
212
+ /** Deep-clone common JavaScript values while preserving prototypes and cycles. */
213
+ function clone(source, refs = /* @__PURE__ */ new Map()) {
214
+ if (!source || typeof source !== "object") return source;
215
+ if (is("Date", source)) return new Date(source.valueOf());
216
+ if (is("RegExp", source)) return new RegExp(source.source, source.flags);
217
+ if (isArrayBufferLike(source)) return source.slice(0);
218
+ if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
219
+ const cached = refs.get(source);
220
+ if (cached) return cached;
221
+ if (Array.isArray(source)) {
222
+ const result = [];
223
+ refs.set(source, result);
224
+ source.forEach((value, index) => {
225
+ result[index] = Reflect.apply(clone, null, [value, refs]);
226
+ });
227
+ return result;
228
+ }
229
+ const result = Object.create(Object.getPrototypeOf(source));
230
+ refs.set(source, result);
231
+ for (const key of Reflect.ownKeys(source)) {
232
+ const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
233
+ if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
234
+ Reflect.defineProperty(result, key, descriptor);
235
+ }
236
+ return result;
237
+ }
238
+ /**
239
+ * Compare values recursively, treating two volatile references as equal regardless of value.
240
+ * Strict comparison distinguishes null/undefined, treats opaque objects by identity,
241
+ * compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
242
+ * @param a - first value.
243
+ * @param b - second value.
244
+ * @param strict - whether to require strict data equality outside volatile references.
245
+ * @returns whether the values compare equal.
246
+ */
247
+ function deepEqual(a, b, strict) {
248
+ const ancestors = /* @__PURE__ */ new Set();
249
+ function compare(a, b) {
250
+ if (a === b) return true;
251
+ if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
252
+ if (!strict && isNullable(a) && isNullable(b)) return true;
253
+ if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
254
+ if (ancestors.has(a)) return false;
255
+ function check(test, then) {
256
+ return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
257
+ }
258
+ ancestors.add(a);
259
+ try {
260
+ return check(Array.isArray, (a, b) => {
261
+ if (a.length !== b.length) return false;
262
+ for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
263
+ return true;
264
+ }) ?? 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) => {
265
+ if (a.byteLength !== b.byteLength) return false;
266
+ const viewA = new Uint8Array(a);
267
+ const viewB = new Uint8Array(b);
268
+ for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
269
+ return true;
270
+ }) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
271
+ ...a,
272
+ ...b
273
+ }).every((key) => compare(a[key], b[key])));
274
+ } finally {
275
+ ancestors.delete(a);
276
+ }
277
+ }
278
+ return compare(a, b);
279
+ }
280
+ //#endregion
281
+ //#region lib/types/string.js
282
+ /** Uppercase the first character of a string. */
283
+ function capitalize(source) {
284
+ return source.charAt(0).toUpperCase() + source.slice(1);
285
+ }
286
+ /** Lowercase the first character of a string. */
287
+ function uncapitalize(source) {
288
+ return source.charAt(0).toLowerCase() + source.slice(1);
289
+ }
290
+ /** Convert dash or underscore delimited text to camelCase. */
291
+ function camelCase(source) {
292
+ return source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase());
293
+ }
294
+ function tokenize(source, delimiters, delimiter) {
295
+ const output = [];
296
+ let state = 0;
297
+ for (let i = 0; i < source.length; i++) {
298
+ const code = source.charCodeAt(i);
299
+ if (code >= 65 && code <= 90) {
300
+ if (state === 1) {
301
+ const next = source.charCodeAt(i + 1);
302
+ if (next >= 97 && next <= 122) output.push(delimiter);
303
+ output.push(code + 32);
304
+ } else {
305
+ if (state !== 0) output.push(delimiter);
306
+ output.push(code + 32);
307
+ }
308
+ state = 1;
309
+ } else if (code >= 97 && code <= 122) {
310
+ output.push(code);
311
+ state = 2;
312
+ } else if (delimiters.includes(code)) {
313
+ if (state !== 0) output.push(delimiter);
314
+ state = 0;
315
+ } else output.push(code);
316
+ }
317
+ return String.fromCharCode(...output);
318
+ }
319
+ /** Convert text to dash-delimited parameter case. */
320
+ function paramCase(source) {
321
+ return tokenize(source, [45, 95], 45);
322
+ }
323
+ /** Convert text to underscore-delimited snake case. */
324
+ function snakeCase(source) {
325
+ return tokenize(source, [45, 95], 95);
326
+ }
327
+ /** Runtime alias for `camelCase`. */
328
+ const camelize = camelCase;
329
+ /** Runtime alias for `paramCase`. */
330
+ const hyphenate = paramCase;
331
+ /** Format a property key as a JavaScript member access suffix. */
332
+ function formatProperty(key) {
333
+ if (typeof key !== "string") return `[${key.toString()}]`;
334
+ return /^[a-z_$][\w$]*$/i.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
335
+ }
336
+ /** Remove one trailing slash from a path string. */
337
+ function trimSlash(source) {
338
+ return source.replace(/\/$/, "");
339
+ }
340
+ /** Ensure a path starts with `/` and has no trailing slash. */
341
+ function sanitize(source) {
342
+ if (!source.startsWith("/")) source = "/" + source;
343
+ return trimSlash(source);
344
+ }
345
+ //#endregion
346
+ //#region lib/types/time.js
347
+ /** Time constants plus parsing and formatting helpers. */
348
+ var Time;
349
+ (function(Time) {
350
+ Time.millisecond = 1;
351
+ Time.second = 1e3;
352
+ Time.minute = Time.second * 60;
353
+ Time.hour = Time.minute * 60;
354
+ Time.day = Time.hour * 24;
355
+ Time.week = Time.day * 7;
356
+ let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
357
+ function setTimezoneOffset(offset) {
358
+ timezoneOffset = offset;
359
+ }
360
+ Time.setTimezoneOffset = setTimezoneOffset;
361
+ function getTimezoneOffset() {
362
+ return timezoneOffset;
363
+ }
364
+ Time.getTimezoneOffset = getTimezoneOffset;
365
+ function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
366
+ if (typeof date === "number") date = new Date(date);
367
+ if (offset === void 0) offset = timezoneOffset;
368
+ return Math.floor((date.valueOf() / Time.minute - offset) / 1440);
369
+ }
370
+ Time.getDateNumber = getDateNumber;
371
+ function fromDateNumber(value, offset) {
372
+ const date = new Date(value * Time.day);
373
+ if (offset === void 0) offset = timezoneOffset;
374
+ return new Date(+date + offset * Time.minute);
375
+ }
376
+ Time.fromDateNumber = fromDateNumber;
377
+ const numeric = /\d+(?:\.\d+)?/.source;
378
+ const timeRegExp = new RegExp(`^${[
379
+ "w(?:eek(?:s)?)?",
380
+ "d(?:ay(?:s)?)?",
381
+ "h(?:our(?:s)?)?",
382
+ "m(?:in(?:ute)?(?:s)?)?",
383
+ "s(?:ec(?:ond)?(?:s)?)?"
384
+ ].map((unit) => `(${numeric}${unit})?`).join("")}$`);
385
+ function parseTime(source) {
386
+ const capture = timeRegExp.exec(source);
387
+ if (!capture) return 0;
388
+ 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);
389
+ }
390
+ Time.parseTime = parseTime;
391
+ function parseDate(date) {
392
+ const parsed = parseTime(date);
393
+ if (parsed) date = Date.now() + parsed;
394
+ else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
395
+ else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
396
+ return date ? new Date(date) : /* @__PURE__ */ new Date();
397
+ }
398
+ Time.parseDate = parseDate;
399
+ function format(ms) {
400
+ const abs = Math.abs(ms);
401
+ if (abs >= Time.day - Time.hour / 2) return Math.round(ms / Time.day) + "d";
402
+ else if (abs >= Time.hour - Time.minute / 2) return Math.round(ms / Time.hour) + "h";
403
+ else if (abs >= Time.minute - Time.second / 2) return Math.round(ms / Time.minute) + "m";
404
+ else if (abs >= Time.second) return Math.round(ms / Time.second) + "s";
405
+ return ms + "ms";
406
+ }
407
+ Time.format = format;
408
+ function toDigits(source, length = 2) {
409
+ return source.toString().padStart(length, "0");
410
+ }
411
+ Time.toDigits = toDigits;
412
+ function template(template, time = /* @__PURE__ */ new Date()) {
413
+ 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));
414
+ }
415
+ Time.template = template;
416
+ })(Time || (Time = {}));
417
+ //#endregion
418
+ 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 };
@@ -0,0 +1,15 @@
1
+ /** Return true when every item in `array2` is present in `array1`. */
2
+ export declare function contain(array1: readonly any[], array2: readonly any[]): boolean;
3
+ /** Return items that appear in both arrays. */
4
+ export declare function intersection<T>(array1: readonly T[], array2: readonly T[]): T[];
5
+ /** Return items from `array1` that do not appear in `array2`. */
6
+ export declare function difference<S>(array1: readonly S[], array2: readonly any[]): S[];
7
+ /** Return the set-union of two arrays while preserving first occurrence order. */
8
+ export declare function union<T>(array1: readonly T[], array2: readonly T[]): T[];
9
+ /** Remove duplicate values while preserving first occurrence order. */
10
+ export declare function deduplicate<T>(array: readonly T[]): T[];
11
+ /** Remove one item from an array and report whether it was found. */
12
+ export declare function remove<T>(list: T[], item: T): boolean;
13
+ /** Normalize nullish, scalar, or array input to an array. */
14
+ export declare function makeArray<T>(source: null | undefined | T | T[]): T[];
15
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/array.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,WAErE;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAEzE;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,OAEzE;AAED,kFAAkF;AAClF,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAElE;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,OAEjD;AAED,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,WAQ3C;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,CAAC,GAAG,CAAC,EAAE,OAE9D"}
@@ -0,0 +1,13 @@
1
+ /** Array set and normalization helpers. */
2
+ export * from './array.ts';
3
+ /** Runtime type, binary, clone, and equality helpers. */
4
+ export * from './types.ts';
5
+ /** Shared utility types and object helpers. */
6
+ export * from './misc.ts';
7
+ /** String case, path, and property formatting helpers. */
8
+ export * from './string.ts';
9
+ /** Time constants, parsing, and formatting helpers. */
10
+ export * from './time.ts';
11
+ /** Immutable config references shared by schema validators and runtimes. */
12
+ export * from './volatile.ts';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,cAAc,YAAY,CAAA;AAC1B,yDAAyD;AACzD,cAAc,YAAY,CAAA;AAC1B,+CAA+C;AAC/C,cAAc,WAAW,CAAA;AACzB,0DAA0D;AAC1D,cAAc,aAAa,CAAA;AAC3B,uDAAuD;AACvD,cAAc,WAAW,CAAA;AACzB,4EAA4E;AAC5E,cAAc,eAAe,CAAA"}