@j-o-r/sh 1.1.31 → 1.2.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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Per-`within()`-block option overrides.
3
+ *
4
+ * A plain object keyed by option name. A key present in the store shadows the
5
+ * global default for every command created inside the `within()` block; a key
6
+ * absent from the store inherits the enclosing scope (or the global default).
7
+ */
8
+ export type OptionScopeStore = {
9
+ [x: string]: any;
10
+ };
11
+ /**
12
+ * Default options applied to all SH commands unless overridden.
13
+ *
14
+ * `cwd` is intentionally lazy: the getter resolves `process.cwd()` at read
15
+ * time, so commands created after a `cd()` run in the new directory instead of
16
+ * the directory the process was started in. `SHDispatch` spreads these
17
+ * defaults (`{ ...defaultOptions }`) per command, which invokes the getters and
18
+ * freezes the values for that command — "defaults captured at creation time".
19
+ * Do not "optimize" this into a static snapshot.
20
+ *
21
+ * Every getter/setter is scope-aware: inside a `within()` block it reads/writes
22
+ * the block's scoped override (see {@link optionScope}); outside it reads/writes
23
+ * the global default. An explicit `SH.cwd = dir` assignment takes precedence
24
+ * over `process.cwd()` (it only redirects SH commands; it does not `chdir` the
25
+ * process). `cd()` clears the override again, so the most recent of the two
26
+ * always wins.
27
+ *
28
+ * @type {import('./SHDispatch.js').SHOptions}
29
+ */
30
+ export const defaultOptions: import("./SHDispatch.js").SHOptions;
31
+ /**
32
+ * Known global option keys exposed by the `SH` proxy in `lib/SH.js`.
33
+ *
34
+ * Derived from the own keys of {@link defaultOptions}, so the key set can
35
+ * never drift from the defaults. (The previous hard-coded list in `lib/SH.js`
36
+ * readable-exposed `maxBuffer`/`detached`, which were uninitialized in the
37
+ * defaults.) The proxy routes reads/writes for these keys to
38
+ * `defaultOptions` and throws a `TypeError` on writes to any other key
39
+ * (decision D1).
40
+ *
41
+ * @type {Set<string>}
42
+ */
43
+ export const defaultOptionKeys: Set<string>;
44
+ /**
45
+ * Clears the `SH.cwd` override so the lazy `cwd` getter follows
46
+ * `process.cwd()` again. Called by `cd()` after a successful
47
+ * `process.chdir()`.
48
+ */
49
+ export function clearCwdOverride(): void;
50
+ /**
51
+ * Default maximum buffered bytes per stdout/stderr stream: 512000 (500 KiB).
52
+ * Used by `SHExecute` when `options.maxBuffer` is unset or invalid.
53
+ */
54
+ export const DEFAULT_MAX_BUFFER: number;
55
+ /**
56
+ * Parses a human-readable duration into milliseconds.
57
+ *
58
+ * Accepts finite non-negative numbers (milliseconds) and strings in the exact
59
+ * forms `'Nms'`, `'Ns'`, or a bare `'N'`. The bare-number form is treated as
60
+ * milliseconds on purpose: it preserves the leniency of the former `SHExecute`
61
+ * parser, so e.g. `timeout: '100'` keeps working.
62
+ *
63
+ * `null`/`undefined` are not special-cased here; call sites that allow an
64
+ * absent duration handle it themselves (e.g. `parseDuration(timeout ?? 0)`).
65
+ *
66
+ * @param {number|string} d - Duration as number (ms) or string ('5s', '100ms', '100').
67
+ * @returns {number} Duration in milliseconds.
68
+ * @throws {Error} If the duration type or format is invalid.
69
+ */
70
+ export function parseDuration(d: number | string): number;
71
+ /**
72
+ * Per-`within()`-block option overrides.
73
+ *
74
+ * A plain object keyed by option name. A key present in the store shadows the
75
+ * global default for every command created inside the `within()` block; a key
76
+ * absent from the store inherits the enclosing scope (or the global default).
77
+ *
78
+ * @typedef {Object<string, any>} OptionScopeStore
79
+ */
80
+ /**
81
+ * AsyncLocalStorage backing `within()` scoping (decision D2).
82
+ *
83
+ * `within()` runs its callback inside a fresh store seeded with a shallow copy
84
+ * of the enclosing store, so nested blocks inherit their parent's scoped
85
+ * values but never leak their own assignments outward. `getDefault`/`setDefault`
86
+ * consult the current store first and fall back to the global defaults.
87
+ *
88
+ * @type {AsyncLocalStorage<OptionScopeStore>}
89
+ */
90
+ export const optionScope: AsyncLocalStorage<OptionScopeStore>;
91
+ import { AsyncLocalStorage } from 'node:async_hooks';
package/TODO.md DELETED
@@ -1,8 +0,0 @@
1
- # TODOs for @j-o-r/sh project
2
-
3
- ## lib/SH.js review findings (2026-06-26)
4
-
5
- ## In Progress
6
-
7
- ## Done
8
-