@oh-my-pi-zen/pi-utils 16.3.6-zen.1
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/CHANGELOG.md +245 -0
- package/README.md +36 -0
- package/dist/types/abortable.d.ts +32 -0
- package/dist/types/async.d.ts +6 -0
- package/dist/types/binary.d.ts +17 -0
- package/dist/types/cli.d.ts +117 -0
- package/dist/types/color.d.ts +102 -0
- package/dist/types/dirs.d.ts +260 -0
- package/dist/types/env.d.ts +74 -0
- package/dist/types/fetch-retry.d.ts +94 -0
- package/dist/types/format.d.ts +37 -0
- package/dist/types/frontmatter.d.ts +25 -0
- package/dist/types/fs-error.d.ts +31 -0
- package/dist/types/glob.d.ts +28 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/json-parse.d.ts +48 -0
- package/dist/types/json.d.ts +4 -0
- package/dist/types/logger.d.ts +83 -0
- package/dist/types/loop-phase.d.ts +10 -0
- package/dist/types/mermaid-ascii.d.ts +11 -0
- package/dist/types/mime.d.ts +29 -0
- package/dist/types/module-timer.d.ts +1 -0
- package/dist/types/path-tree.d.ts +76 -0
- package/dist/types/path.d.ts +2 -0
- package/dist/types/peek-file.d.ts +29 -0
- package/dist/types/postmortem.d.ts +37 -0
- package/dist/types/procmgr.d.ts +29 -0
- package/dist/types/prompt.d.ts +18 -0
- package/dist/types/ptree.d.ts +108 -0
- package/dist/types/ring.d.ts +93 -0
- package/dist/types/runtime-install.d.ts +68 -0
- package/dist/types/sanitize-text.d.ts +29 -0
- package/dist/types/snowflake.d.ts +25 -0
- package/dist/types/stream.d.ts +68 -0
- package/dist/types/tab-spacing.d.ts +24 -0
- package/dist/types/temp.d.ts +17 -0
- package/dist/types/timing-buffer.d.ts +22 -0
- package/dist/types/tls-fetch.d.ts +37 -0
- package/dist/types/type-guards.d.ts +3 -0
- package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
- package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
- package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
- package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
- package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
- package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
- package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
- package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
- package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
- package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
- package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
- package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
- package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
- package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
- package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
- package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
- package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +21 -0
- package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
- package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
- package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
- package/dist/types/which.d.ts +37 -0
- package/dist/types/worker-host.d.ts +47 -0
- package/package.json +62 -0
- package/src/abortable.ts +109 -0
- package/src/async.ts +50 -0
- package/src/binary.ts +50 -0
- package/src/cli.ts +457 -0
- package/src/color.ts +302 -0
- package/src/dirs.ts +925 -0
- package/src/env.ts +226 -0
- package/src/fetch-retry.ts +355 -0
- package/src/format.ts +113 -0
- package/src/frontmatter.ts +162 -0
- package/src/fs-error.ts +56 -0
- package/src/glob.ts +189 -0
- package/src/index.ts +55 -0
- package/src/json-parse.ts +612 -0
- package/src/json.ts +10 -0
- package/src/logger.ts +672 -0
- package/src/loop-phase.ts +49 -0
- package/src/mermaid-ascii.ts +31 -0
- package/src/mime.ts +159 -0
- package/src/module-timer.ts +148 -0
- package/src/path-tree.ts +147 -0
- package/src/path.ts +28 -0
- package/src/peek-file.ts +188 -0
- package/src/postmortem.ts +222 -0
- package/src/procmgr.ts +195 -0
- package/src/prompt.ts +562 -0
- package/src/ptree.ts +395 -0
- package/src/ring.ts +169 -0
- package/src/runtime-install.ts +372 -0
- package/src/sanitize-text.ts +96 -0
- package/src/snowflake.ts +121 -0
- package/src/stream.ts +432 -0
- package/src/tab-spacing.ts +336 -0
- package/src/temp.ts +134 -0
- package/src/timing-buffer.ts +47 -0
- package/src/tls-fetch.ts +178 -0
- package/src/type-guards.ts +11 -0
- package/src/vendor/mermaid-ascii/NOTICE +33 -0
- package/src/vendor/mermaid-ascii/ascii/ansi.ts +409 -0
- package/src/vendor/mermaid-ascii/ascii/canvas.ts +476 -0
- package/src/vendor/mermaid-ascii/ascii/class-diagram.ts +699 -0
- package/src/vendor/mermaid-ascii/ascii/converter.ts +271 -0
- package/src/vendor/mermaid-ascii/ascii/draw.ts +1382 -0
- package/src/vendor/mermaid-ascii/ascii/edge-bundling.ts +328 -0
- package/src/vendor/mermaid-ascii/ascii/edge-routing.ts +297 -0
- package/src/vendor/mermaid-ascii/ascii/er-diagram.ts +441 -0
- package/src/vendor/mermaid-ascii/ascii/grid.ts +578 -0
- package/src/vendor/mermaid-ascii/ascii/index.ts +187 -0
- package/src/vendor/mermaid-ascii/ascii/multiline-utils.ts +78 -0
- package/src/vendor/mermaid-ascii/ascii/pathfinder.ts +215 -0
- package/src/vendor/mermaid-ascii/ascii/sequence.ts +460 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/circle.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/corners.ts +127 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/diamond.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/hexagon.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/index.ts +101 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rectangle.ts +175 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rounded.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/special.ts +296 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/stadium.ts +114 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/state.ts +192 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/types.ts +73 -0
- package/src/vendor/mermaid-ascii/ascii/types.ts +273 -0
- package/src/vendor/mermaid-ascii/ascii/validate.ts +120 -0
- package/src/vendor/mermaid-ascii/ascii/xychart.ts +875 -0
- package/src/vendor/mermaid-ascii/class/parser.ts +290 -0
- package/src/vendor/mermaid-ascii/class/types.ts +121 -0
- package/src/vendor/mermaid-ascii/er/parser.ts +181 -0
- package/src/vendor/mermaid-ascii/er/types.ts +91 -0
- package/src/vendor/mermaid-ascii/index.ts +14 -0
- package/src/vendor/mermaid-ascii/multiline-utils.ts +30 -0
- package/src/vendor/mermaid-ascii/parser.ts +645 -0
- package/src/vendor/mermaid-ascii/sequence/parser.ts +207 -0
- package/src/vendor/mermaid-ascii/sequence/types.ts +146 -0
- package/src/vendor/mermaid-ascii/text-metrics.ts +71 -0
- package/src/vendor/mermaid-ascii/types.ts +164 -0
- package/src/vendor/mermaid-ascii/xychart/colors.ts +140 -0
- package/src/vendor/mermaid-ascii/xychart/parser.ts +115 -0
- package/src/vendor/mermaid-ascii/xychart/types.ts +150 -0
- package/src/which.ts +232 -0
- package/src/worker-host.ts +92 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { stripWindowsExtendedLengthPathPrefix } from "./path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main-module path declared by self-dispatching CLI entrypoints — entries
|
|
5
|
+
* whose top-level argv handling routes hidden `__omp_*` worker selectors.
|
|
6
|
+
* Worker spawn sites re-enter this module via `new Worker(entry, { argv })`,
|
|
7
|
+
* so every distribution (source, npm bundle, compiled binary) needs exactly
|
|
8
|
+
* one JavaScript entrypoint. Never set under `bun test`, SDK embedding, or
|
|
9
|
+
* standalone package bins — those hosts load worker modules directly.
|
|
10
|
+
*/
|
|
11
|
+
let workerHostMain: string | null = null;
|
|
12
|
+
|
|
13
|
+
/** Called by CLI entrypoints whose main module dispatches worker argv selectors. */
|
|
14
|
+
export function declareWorkerHostEntry(): void {
|
|
15
|
+
workerHostMain = stripWindowsExtendedLengthPathPrefix(Bun.main);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Main-module path of the self-dispatching CLI host, or null outside it. */
|
|
19
|
+
export function workerHostEntry(): string | null {
|
|
20
|
+
return workerHostMain;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Buffers messages a Bun worker thread receives before its real handler is
|
|
25
|
+
* attached, then hands them off once it is.
|
|
26
|
+
*
|
|
27
|
+
* Bun delivers messages the parent posted before the worker spawned exactly
|
|
28
|
+
* once — when the worker entry module's top-level evaluation completes — to the
|
|
29
|
+
* `message` listeners present at that moment. A worker whose handler attaches
|
|
30
|
+
* via a later `await import(...)` therefore misses that flush. The
|
|
31
|
+
* self-dispatching CLI host imports each worker module dynamically from inside
|
|
32
|
+
* its argv dispatch, so the worker's own `parentPort.on("message")` lands after
|
|
33
|
+
* the flush and the parent's synchronously-posted `init` handshake is dropped —
|
|
34
|
+
* every run then stalls until the init timeout fires and silently falls back to
|
|
35
|
+
* the inline worker (issue: eval cells always taking the full timeout).
|
|
36
|
+
*
|
|
37
|
+
* The host calls {@link installWorkerInbox} synchronously in the entry's sync
|
|
38
|
+
* prefix (before importing the worker module) so a `parentPort` listener exists
|
|
39
|
+
* at flush time; the worker module then {@link consumeWorkerInbox}es it and
|
|
40
|
+
* binds the real handler, replaying anything buffered. Re-dispatching through
|
|
41
|
+
* `parentPort.emit("message", …)` is not an option — Bun's port is an
|
|
42
|
+
* `EventTarget` whose `emit` throws — so the inbox calls the handler directly.
|
|
43
|
+
*/
|
|
44
|
+
export interface WorkerInbox {
|
|
45
|
+
/** Route buffered and subsequent messages to `handler`; returns an unbind fn. */
|
|
46
|
+
bind(handler: (message: unknown) => void): () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Minimal `parentPort` surface the inbox needs (Node/Bun `MessagePort`). */
|
|
50
|
+
interface MessageListenerPort {
|
|
51
|
+
on(event: "message", listener: (value: unknown) => void): unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let pendingInbox: WorkerInbox | null = null;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Attach a buffering `message` listener on `port` synchronously and stash the
|
|
58
|
+
* resulting inbox for the worker module to {@link consumeWorkerInbox}. MUST be
|
|
59
|
+
* called in the entry module's synchronous prefix — before the worker module is
|
|
60
|
+
* imported — so the listener exists when Bun flushes pre-spawn messages.
|
|
61
|
+
*/
|
|
62
|
+
export function installWorkerInbox(port: MessageListenerPort): WorkerInbox {
|
|
63
|
+
const queue: unknown[] = [];
|
|
64
|
+
let handler: ((message: unknown) => void) | null = null;
|
|
65
|
+
port.on("message", (data: unknown) => {
|
|
66
|
+
if (handler) handler(data);
|
|
67
|
+
else queue.push(data);
|
|
68
|
+
});
|
|
69
|
+
const inbox: WorkerInbox = {
|
|
70
|
+
bind(next) {
|
|
71
|
+
handler = next;
|
|
72
|
+
for (const data of queue) next(data);
|
|
73
|
+
queue.length = 0;
|
|
74
|
+
return () => {
|
|
75
|
+
if (handler === next) handler = null;
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
pendingInbox = inbox;
|
|
80
|
+
return inbox;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Take the inbox installed by {@link installWorkerInbox} for this worker, or
|
|
85
|
+
* `null` when the worker module was loaded directly (no host pre-buffering, so
|
|
86
|
+
* the module's own synchronous top-level listener already wins the flush).
|
|
87
|
+
*/
|
|
88
|
+
export function consumeWorkerInbox(): WorkerInbox | null {
|
|
89
|
+
const inbox = pendingInbox;
|
|
90
|
+
pendingInbox = null;
|
|
91
|
+
return inbox;
|
|
92
|
+
}
|