@fnndsc/chell 4.2.8
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 +21 -0
- package/README.md +325 -0
- package/dist/builtins/debug.d.ts +6 -0
- package/dist/builtins/debug.js +47 -0
- package/dist/builtins/debug.js.map +1 -0
- package/dist/builtins/executable.d.ts +22 -0
- package/dist/builtins/executable.js +115 -0
- package/dist/builtins/executable.js.map +1 -0
- package/dist/builtins/fs/cat.d.ts +16 -0
- package/dist/builtins/fs/cat.js +249 -0
- package/dist/builtins/fs/cat.js.map +1 -0
- package/dist/builtins/fs/cd.d.ts +41 -0
- package/dist/builtins/fs/cd.js +178 -0
- package/dist/builtins/fs/cd.js.map +1 -0
- package/dist/builtins/fs/cp.d.ts +7 -0
- package/dist/builtins/fs/cp.js +73 -0
- package/dist/builtins/fs/cp.js.map +1 -0
- package/dist/builtins/fs/download.d.ts +6 -0
- package/dist/builtins/fs/download.js +41 -0
- package/dist/builtins/fs/download.js.map +1 -0
- package/dist/builtins/fs/du.d.ts +58 -0
- package/dist/builtins/fs/du.js +210 -0
- package/dist/builtins/fs/du.js.map +1 -0
- package/dist/builtins/fs/edit.d.ts +7 -0
- package/dist/builtins/fs/edit.js +86 -0
- package/dist/builtins/fs/edit.js.map +1 -0
- package/dist/builtins/fs/ls.d.ts +8 -0
- package/dist/builtins/fs/ls.js +68 -0
- package/dist/builtins/fs/ls.js.map +1 -0
- package/dist/builtins/fs/mkdir.d.ts +6 -0
- package/dist/builtins/fs/mkdir.js +38 -0
- package/dist/builtins/fs/mkdir.js.map +1 -0
- package/dist/builtins/fs/mv.d.ts +7 -0
- package/dist/builtins/fs/mv.js +75 -0
- package/dist/builtins/fs/mv.js.map +1 -0
- package/dist/builtins/fs/pull.args.d.ts +22 -0
- package/dist/builtins/fs/pull.args.js +30 -0
- package/dist/builtins/fs/pull.args.js.map +1 -0
- package/dist/builtins/fs/pull.d.ts +26 -0
- package/dist/builtins/fs/pull.js +413 -0
- package/dist/builtins/fs/pull.js.map +1 -0
- package/dist/builtins/fs/pwd.d.ts +7 -0
- package/dist/builtins/fs/pwd.js +75 -0
- package/dist/builtins/fs/pwd.js.map +1 -0
- package/dist/builtins/fs/rm.d.ts +31 -0
- package/dist/builtins/fs/rm.js +148 -0
- package/dist/builtins/fs/rm.js.map +1 -0
- package/dist/builtins/fs/touch.d.ts +6 -0
- package/dist/builtins/fs/touch.js +64 -0
- package/dist/builtins/fs/touch.js.map +1 -0
- package/dist/builtins/fs/tree.d.ts +15 -0
- package/dist/builtins/fs/tree.js +84 -0
- package/dist/builtins/fs/tree.js.map +1 -0
- package/dist/builtins/fs/upload.d.ts +6 -0
- package/dist/builtins/fs/upload.js +45 -0
- package/dist/builtins/fs/upload.js.map +1 -0
- package/dist/builtins/help.d.ts +74 -0
- package/dist/builtins/help.js +1217 -0
- package/dist/builtins/help.js.map +1 -0
- package/dist/builtins/index.d.ts +45 -0
- package/dist/builtins/index.js +45 -0
- package/dist/builtins/index.js.map +1 -0
- package/dist/builtins/net/connect.d.ts +7 -0
- package/dist/builtins/net/connect.js +42 -0
- package/dist/builtins/net/connect.js.map +1 -0
- package/dist/builtins/net/cubepath.d.ts +18 -0
- package/dist/builtins/net/cubepath.js +102 -0
- package/dist/builtins/net/cubepath.js.map +1 -0
- package/dist/builtins/net/logout.d.ts +6 -0
- package/dist/builtins/net/logout.js +24 -0
- package/dist/builtins/net/logout.js.map +1 -0
- package/dist/builtins/net/pacs.d.ts +24 -0
- package/dist/builtins/net/pacs.js +121 -0
- package/dist/builtins/net/pacs.js.map +1 -0
- package/dist/builtins/net/pacsUtils.d.ts +85 -0
- package/dist/builtins/net/pacsUtils.js +184 -0
- package/dist/builtins/net/pacsUtils.js.map +1 -0
- package/dist/builtins/net/query.d.ts +60 -0
- package/dist/builtins/net/query.js +304 -0
- package/dist/builtins/net/query.js.map +1 -0
- package/dist/builtins/parametersofplugin.d.ts +13 -0
- package/dist/builtins/parametersofplugin.js +43 -0
- package/dist/builtins/parametersofplugin.js.map +1 -0
- package/dist/builtins/pluginExecute.d.ts +27 -0
- package/dist/builtins/pluginExecute.js +165 -0
- package/dist/builtins/pluginExecute.js.map +1 -0
- package/dist/builtins/proc.d.ts +6 -0
- package/dist/builtins/proc.helpers.d.ts +68 -0
- package/dist/builtins/proc.helpers.js +102 -0
- package/dist/builtins/proc.helpers.js.map +1 -0
- package/dist/builtins/proc.js +289 -0
- package/dist/builtins/proc.js.map +1 -0
- package/dist/builtins/res/compute.d.ts +6 -0
- package/dist/builtins/res/compute.js +55 -0
- package/dist/builtins/res/compute.js.map +1 -0
- package/dist/builtins/res/feed.d.ts +6 -0
- package/dist/builtins/res/feed.js +244 -0
- package/dist/builtins/res/feed.js.map +1 -0
- package/dist/builtins/res/feed.notes.d.ts +28 -0
- package/dist/builtins/res/feed.notes.js +24 -0
- package/dist/builtins/res/feed.notes.js.map +1 -0
- package/dist/builtins/res/files.d.ts +18 -0
- package/dist/builtins/res/files.js +85 -0
- package/dist/builtins/res/files.js.map +1 -0
- package/dist/builtins/res/group.d.ts +6 -0
- package/dist/builtins/res/group.js +54 -0
- package/dist/builtins/res/group.js.map +1 -0
- package/dist/builtins/res/pipeline.args.d.ts +22 -0
- package/dist/builtins/res/pipeline.args.js +28 -0
- package/dist/builtins/res/pipeline.args.js.map +1 -0
- package/dist/builtins/res/pipeline.d.ts +20 -0
- package/dist/builtins/res/pipeline.js +252 -0
- package/dist/builtins/res/pipeline.js.map +1 -0
- package/dist/builtins/res/plugin.d.ts +13 -0
- package/dist/builtins/res/plugin.js +140 -0
- package/dist/builtins/res/plugin.js.map +1 -0
- package/dist/builtins/res/plugininstance.d.ts +6 -0
- package/dist/builtins/res/plugininstance.js +53 -0
- package/dist/builtins/res/plugininstance.js.map +1 -0
- package/dist/builtins/res/pluginmeta.d.ts +6 -0
- package/dist/builtins/res/pluginmeta.js +53 -0
- package/dist/builtins/res/pluginmeta.js.map +1 -0
- package/dist/builtins/res/tag.d.ts +6 -0
- package/dist/builtins/res/tag.js +53 -0
- package/dist/builtins/res/tag.js.map +1 -0
- package/dist/builtins/res/workflow.d.ts +6 -0
- package/dist/builtins/res/workflow.js +53 -0
- package/dist/builtins/res/workflow.js.map +1 -0
- package/dist/builtins/store.d.ts +6 -0
- package/dist/builtins/store.js +108 -0
- package/dist/builtins/store.js.map +1 -0
- package/dist/builtins/sys/context.d.ts +6 -0
- package/dist/builtins/sys/context.js +50 -0
- package/dist/builtins/sys/context.js.map +1 -0
- package/dist/builtins/sys/physicalmode.d.ts +6 -0
- package/dist/builtins/sys/physicalmode.js +41 -0
- package/dist/builtins/sys/physicalmode.js.map +1 -0
- package/dist/builtins/sys/prompt.d.ts +13 -0
- package/dist/builtins/sys/prompt.helpers.d.ts +31 -0
- package/dist/builtins/sys/prompt.helpers.js +36 -0
- package/dist/builtins/sys/prompt.helpers.js.map +1 -0
- package/dist/builtins/sys/prompt.js +182 -0
- package/dist/builtins/sys/prompt.js.map +1 -0
- package/dist/builtins/sys/timing.d.ts +6 -0
- package/dist/builtins/sys/timing.js +41 -0
- package/dist/builtins/sys/timing.js.map +1 -0
- package/dist/builtins/sys/whoami.d.ts +12 -0
- package/dist/builtins/sys/whoami.js +37 -0
- package/dist/builtins/sys/whoami.js.map +1 -0
- package/dist/builtins/utils.d.ts +55 -0
- package/dist/builtins/utils.js +145 -0
- package/dist/builtins/utils.js.map +1 -0
- package/dist/builtins/wildcard.d.ts +26 -0
- package/dist/builtins/wildcard.js +120 -0
- package/dist/builtins/wildcard.js.map +1 -0
- package/dist/chell.d.ts +16 -0
- package/dist/chell.js +1193 -0
- package/dist/chell.js.map +1 -0
- package/dist/command-keys.d.ts +8 -0
- package/dist/command-keys.js +32 -0
- package/dist/command-keys.js.map +1 -0
- package/dist/config/settings.d.ts +39 -0
- package/dist/config/settings.js +93 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/bootFlags.d.ts +32 -0
- package/dist/core/bootFlags.js +25 -0
- package/dist/core/bootFlags.js.map +1 -0
- package/dist/core/cli.d.ts +58 -0
- package/dist/core/cli.js +251 -0
- package/dist/core/cli.js.map +1 -0
- package/dist/core/prompt/index.d.ts +80 -0
- package/dist/core/prompt/index.js +29 -0
- package/dist/core/prompt/index.js.map +1 -0
- package/dist/core/prompt/theme_default.d.ts +19 -0
- package/dist/core/prompt/theme_default.js +47 -0
- package/dist/core/prompt/theme_default.js.map +1 -0
- package/dist/core/prompt/theme_p10k.d.ts +22 -0
- package/dist/core/prompt/theme_p10k.js +164 -0
- package/dist/core/prompt/theme_p10k.js.map +1 -0
- package/dist/core/prompt/utils.d.ts +23 -0
- package/dist/core/prompt/utils.js +40 -0
- package/dist/core/prompt/utils.js.map +1 -0
- package/dist/core/question.d.ts +34 -0
- package/dist/core/question.js +76 -0
- package/dist/core/question.js.map +1 -0
- package/dist/core/repl.d.ts +31 -0
- package/dist/core/repl.js +146 -0
- package/dist/core/repl.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/bootsequence.d.ts +62 -0
- package/dist/lib/bootsequence.js +222 -0
- package/dist/lib/bootsequence.js.map +1 -0
- package/dist/lib/completer/index.d.ts +15 -0
- package/dist/lib/completer/index.js +212 -0
- package/dist/lib/completer/index.js.map +1 -0
- package/dist/lib/completer/pathComplete.helpers.d.ts +22 -0
- package/dist/lib/completer/pathComplete.helpers.js +49 -0
- package/dist/lib/completer/pathComplete.helpers.js.map +1 -0
- package/dist/lib/logo.d.ts +47 -0
- package/dist/lib/logo.js +313 -0
- package/dist/lib/logo.js.map +1 -0
- package/dist/lib/parser.d.ts +13 -0
- package/dist/lib/parser.js +52 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/pipe.d.ts +11 -0
- package/dist/lib/pipe.js +90 -0
- package/dist/lib/pipe.js.map +1 -0
- package/dist/lib/prefetch.d.ts +25 -0
- package/dist/lib/prefetch.js +64 -0
- package/dist/lib/prefetch.js.map +1 -0
- package/dist/lib/semicolonParser.d.ts +22 -0
- package/dist/lib/semicolonParser.js +53 -0
- package/dist/lib/semicolonParser.js.map +1 -0
- package/dist/lib/spinner.d.ts +23 -0
- package/dist/lib/spinner.js +68 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/vfs/providers/static.d.ts +65 -0
- package/dist/lib/vfs/providers/static.js +164 -0
- package/dist/lib/vfs/providers/static.js.map +1 -0
- package/dist/lib/vfs/providers/static_content.d.ts +27 -0
- package/dist/lib/vfs/providers/static_content.js +180 -0
- package/dist/lib/vfs/providers/static_content.js.map +1 -0
- package/dist/lib/vfs/vfs.d.ts +59 -0
- package/dist/lib/vfs/vfs.js +198 -0
- package/dist/lib/vfs/vfs.js.map +1 -0
- package/dist/session/index.d.ts +76 -0
- package/dist/session/index.js +120 -0
- package/dist/session/index.js.map +1 -0
- package/package.json +65 -0
package/dist/lib/pipe.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Process piping helper for shell command chains.
|
|
3
|
+
*
|
|
4
|
+
* Spawns a single shell segment, feeds it an input buffer (with backpressure
|
|
5
|
+
* handling), and resolves with its captured stdout.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'child_process';
|
|
10
|
+
/**
|
|
11
|
+
* Pipes an input buffer through a spawned shell command and captures its stdout.
|
|
12
|
+
*
|
|
13
|
+
* Writes the input to the child's stdin with drain-aware backpressure handling,
|
|
14
|
+
* tolerates early-close EPIPE, and rejects on non-zero exit or spawn error.
|
|
15
|
+
*
|
|
16
|
+
* @param segment - The shell command to run (executed with `shell: true`).
|
|
17
|
+
* @param input - The data to write to the command's stdin.
|
|
18
|
+
* @returns The command's captured stdout.
|
|
19
|
+
*/
|
|
20
|
+
export function segment_pipeThrough(segment, input) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const chunks = [];
|
|
23
|
+
// When using shell: true, pass the entire command as a single string
|
|
24
|
+
const child = spawn(segment, {
|
|
25
|
+
stdio: ['pipe', 'pipe', 'inherit'],
|
|
26
|
+
shell: true,
|
|
27
|
+
});
|
|
28
|
+
child.stdout.on('data', (chunk) => {
|
|
29
|
+
chunks.push(chunk);
|
|
30
|
+
});
|
|
31
|
+
child.on('close', (code) => {
|
|
32
|
+
if (code !== 0 && code !== null) {
|
|
33
|
+
reject(new Error(`Command '${segment}' exited with code ${code}`));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
resolve(Buffer.concat(chunks));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
child.on('error', (err) => {
|
|
40
|
+
reject(err);
|
|
41
|
+
});
|
|
42
|
+
// Handle EPIPE errors when child closes stdin early
|
|
43
|
+
child.stdin.on('error', (err) => {
|
|
44
|
+
if (err.code === 'EPIPE') {
|
|
45
|
+
// Child closed stdin, this is normal if it exits early — handled by 'close'.
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Writes all buffered data to child stdin with backpressure handling.
|
|
53
|
+
* Splits large buffers into chunks and waits for drain events when needed.
|
|
54
|
+
*/
|
|
55
|
+
const data_writeAll = async () => {
|
|
56
|
+
if (input.length === 0) {
|
|
57
|
+
child.stdin.end();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return new Promise((resolveWrite, rejectWrite) => {
|
|
61
|
+
let offset = 0;
|
|
62
|
+
const chunkSize = 64 * 1024; // 64KB chunks
|
|
63
|
+
const chunk_writeNext = () => {
|
|
64
|
+
try {
|
|
65
|
+
while (offset < input.length) {
|
|
66
|
+
const end = Math.min(offset + chunkSize, input.length);
|
|
67
|
+
const chunk = input.subarray(offset, end);
|
|
68
|
+
offset = end;
|
|
69
|
+
const canContinue = child.stdin.write(chunk);
|
|
70
|
+
if (!canContinue) {
|
|
71
|
+
child.stdin.once('drain', chunk_writeNext);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
child.stdin.end();
|
|
76
|
+
resolveWrite();
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
rejectWrite(err);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
chunk_writeNext();
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
// Start writing in parallel with reading output; ignore write errors if the
|
|
86
|
+
// child already closed (EPIPE is handled by the stdin error handler).
|
|
87
|
+
data_writeAll().catch(() => { });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../src/lib/pipe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,KAAa;IAChE,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,qEAAqE;QACrE,MAAM,KAAK,GAAiB,KAAK,CAAC,OAAO,EAAE;YACzC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;YAClC,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,KAAK,CAAC,MAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACzC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAmB,EAAE,EAAE;YACxC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,KAAK,CAAC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,GAAG,CAAC;4BAEb,MAAM,WAAW,GAAY,KAAK,CAAC,KAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;4BACvD,IAAI,CAAC,WAAW,EAAE,CAAC;gCACjB,KAAK,CAAC,KAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;gCAC5C,OAAO;4BACT,CAAC;wBACH,CAAC;wBACD,KAAK,CAAC,KAAM,CAAC,GAAG,EAAE,CAAC;wBACnB,YAAY,EAAE,CAAC;oBACjB,CAAC;oBAAC,OAAO,GAAY,EAAE,CAAC;wBACtB,WAAW,CAAC,GAAY,CAAC,CAAC;oBAC5B,CAAC;gBACH,CAAC,CAAC;gBAEF,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,4EAA4E;QAC5E,sEAAsE;QACtE,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome of a prefetch operation (counts and status).
|
|
3
|
+
*/
|
|
4
|
+
export interface PrefetchResult {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
count?: number;
|
|
7
|
+
pipelineCount?: number;
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Prefetch a VFS path into the list cache.
|
|
12
|
+
*
|
|
13
|
+
* @param target - Absolute VFS path to prefetch.
|
|
14
|
+
* @returns Count of items cached on success, error message on failure.
|
|
15
|
+
*/
|
|
16
|
+
export declare function prefetch_path(target: string): Promise<PrefetchResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Run a prefetch action behind a spinner (interactive) or plain log (non-interactive).
|
|
19
|
+
*
|
|
20
|
+
* @param label - Short label shown in the spinner column (padded to 12 chars).
|
|
21
|
+
* @param message - Descriptive message shown next to the label.
|
|
22
|
+
* @param isInteractive - Whether the session is interactive (controls spinner vs plain log).
|
|
23
|
+
* @param action - Async work to run; returns a PrefetchResult.
|
|
24
|
+
*/
|
|
25
|
+
export declare function prefetch_withSpinner(label: string, message: string, isInteractive: boolean, action: () => Promise<PrefetchResult>): Promise<PrefetchResult>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Boot-time prefetch helpers for warming the VFS cache.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from chell_start() to keep that fn focused on orchestration.
|
|
5
|
+
* All functions are pure top-level — no closure over session state.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { errorStack } from '@fnndsc/cumin';
|
|
10
|
+
import { vfs } from './vfs/vfs.js';
|
|
11
|
+
import { spinner } from './spinner.js';
|
|
12
|
+
import { error_stripDebugPrefix } from '../builtins/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Prefetch a VFS path into the list cache.
|
|
15
|
+
*
|
|
16
|
+
* @param target - Absolute VFS path to prefetch.
|
|
17
|
+
* @returns Count of items cached on success, error message on failure.
|
|
18
|
+
*/
|
|
19
|
+
export async function prefetch_path(target) {
|
|
20
|
+
try {
|
|
21
|
+
const result = await vfs.data_get(target);
|
|
22
|
+
if (result.ok) {
|
|
23
|
+
return { ok: true, count: result.value.length };
|
|
24
|
+
}
|
|
25
|
+
const err = errorStack.stack_pop();
|
|
26
|
+
return { ok: false, message: err ? error_stripDebugPrefix(err.message) : `Prefetch failed for ${target}` };
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
30
|
+
return { ok: false, message: msg };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Run a prefetch action behind a spinner (interactive) or plain log (non-interactive).
|
|
35
|
+
*
|
|
36
|
+
* @param label - Short label shown in the spinner column (padded to 12 chars).
|
|
37
|
+
* @param message - Descriptive message shown next to the label.
|
|
38
|
+
* @param isInteractive - Whether the session is interactive (controls spinner vs plain log).
|
|
39
|
+
* @param action - Async work to run; returns a PrefetchResult.
|
|
40
|
+
*/
|
|
41
|
+
export async function prefetch_withSpinner(label, message, isInteractive, action) {
|
|
42
|
+
const paddedLabel = label.padEnd(12);
|
|
43
|
+
// Spinner adds its own glyph and a following space. Pad so the label column
|
|
44
|
+
// aligns with the fixed-width status logs (e.g., "[ OK ] " = 7 chars).
|
|
45
|
+
const spinnerPrefix = ' '.repeat(5); // 1 glyph + 1 space + 5 = 7
|
|
46
|
+
const spinnerMessage = `${spinnerPrefix}${paddedLabel} ${message}`;
|
|
47
|
+
const showSpinner = isInteractive && process.stdout.isTTY;
|
|
48
|
+
if (showSpinner) {
|
|
49
|
+
spinner.start(spinnerMessage, true);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(spinnerMessage);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
return await action();
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
if (showSpinner) {
|
|
59
|
+
spinner.stop();
|
|
60
|
+
process.stdout.write('\r\x1b[K');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=prefetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetch.js","sourceRoot":"","sources":["../../src/lib/prefetch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAY9D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QA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AAC,cAAc,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,EAAE,CAAC;IACxB,CAAC;YAAS,CAAC;QACT,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Semicolon command parser
|
|
3
|
+
*
|
|
4
|
+
* Parses semicolon-separated commands while respecting quotes.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Parses a command line for semicolon separators and returns individual commands.
|
|
10
|
+
* Respects quoted strings - semicolons inside quotes are not treated as separators.
|
|
11
|
+
*
|
|
12
|
+
* @param line - The full command line.
|
|
13
|
+
* @returns An array of individual commands.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* semicolons_parse("ls; pwd") // Returns: ["ls", "pwd"]
|
|
18
|
+
* semicolons_parse("echo 'a;b'; pwd") // Returns: ["echo 'a;b'", "pwd"]
|
|
19
|
+
* semicolons_parse("cd /tmp; ls; cat file.txt") // Returns: ["cd /tmp", "ls", "cat file.txt"]
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function semicolons_parse(line: string): string[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Semicolon command parser
|
|
3
|
+
*
|
|
4
|
+
* Parses semicolon-separated commands while respecting quotes.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Parses a command line for semicolon separators and returns individual commands.
|
|
10
|
+
* Respects quoted strings - semicolons inside quotes are not treated as separators.
|
|
11
|
+
*
|
|
12
|
+
* @param line - The full command line.
|
|
13
|
+
* @returns An array of individual commands.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* semicolons_parse("ls; pwd") // Returns: ["ls", "pwd"]
|
|
18
|
+
* semicolons_parse("echo 'a;b'; pwd") // Returns: ["echo 'a;b'", "pwd"]
|
|
19
|
+
* semicolons_parse("cd /tmp; ls; cat file.txt") // Returns: ["cd /tmp", "ls", "cat file.txt"]
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function semicolons_parse(line) {
|
|
23
|
+
const commands = [];
|
|
24
|
+
let currentCommand = '';
|
|
25
|
+
let inSingleQuote = false;
|
|
26
|
+
let inDoubleQuote = false;
|
|
27
|
+
for (let i = 0; i < line.length; i++) {
|
|
28
|
+
const char = line[i];
|
|
29
|
+
if (char === "'" && !inDoubleQuote) {
|
|
30
|
+
inSingleQuote = !inSingleQuote;
|
|
31
|
+
currentCommand += char;
|
|
32
|
+
}
|
|
33
|
+
else if (char === '"' && !inSingleQuote) {
|
|
34
|
+
inDoubleQuote = !inDoubleQuote;
|
|
35
|
+
currentCommand += char;
|
|
36
|
+
}
|
|
37
|
+
else if (char === ';' && !inSingleQuote && !inDoubleQuote) {
|
|
38
|
+
const trimmed = currentCommand.trim();
|
|
39
|
+
if (trimmed)
|
|
40
|
+
commands.push(trimmed);
|
|
41
|
+
currentCommand = '';
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
currentCommand += char;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Add final command
|
|
48
|
+
const trimmed = currentCommand.trim();
|
|
49
|
+
if (trimmed)
|
|
50
|
+
commands.push(trimmed);
|
|
51
|
+
return commands;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=semicolonParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semicolonParser.js","sourceRoot":"","sources":["../../src/lib/semicolonParser.ts"],"names":[],"mappings":"AAAA;;;;;;GA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*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Terminal spinner indicating progress of async work.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Spinner {
|
|
10
|
+
private interval;
|
|
11
|
+
private message;
|
|
12
|
+
private frames;
|
|
13
|
+
private frameIndex;
|
|
14
|
+
private spinnerActive;
|
|
15
|
+
private startTime;
|
|
16
|
+
private showTiming;
|
|
17
|
+
constructor(initialMessage?: string);
|
|
18
|
+
start(message?: string, showTiming?: boolean): void;
|
|
19
|
+
stop(clearLine?: boolean): void;
|
|
20
|
+
updateMessage(newMessage: string): void;
|
|
21
|
+
}
|
|
22
|
+
declare const globalSpinner: Spinner;
|
|
23
|
+
export { globalSpinner as spinner };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Terminal spinner utility for long-running operations.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
/**
|
|
8
|
+
* Terminal spinner indicating progress of async work.
|
|
9
|
+
*/
|
|
10
|
+
export class Spinner {
|
|
11
|
+
interval = null;
|
|
12
|
+
message = '';
|
|
13
|
+
frames = ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"];
|
|
14
|
+
frameIndex = 0;
|
|
15
|
+
spinnerActive = false;
|
|
16
|
+
startTime = 0;
|
|
17
|
+
showTiming = false;
|
|
18
|
+
constructor(initialMessage = 'Loading...') {
|
|
19
|
+
this.message = initialMessage;
|
|
20
|
+
}
|
|
21
|
+
start(message, showTiming = false) {
|
|
22
|
+
// Do not start spinner if not in a TTY (e.g. piped output)
|
|
23
|
+
if (!process.stdout.isTTY) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (this.spinnerActive) {
|
|
27
|
+
this.stop(); // Stop any existing spinner
|
|
28
|
+
}
|
|
29
|
+
this.message = message || this.message;
|
|
30
|
+
this.spinnerActive = true;
|
|
31
|
+
this.frameIndex = 0;
|
|
32
|
+
this.showTiming = showTiming;
|
|
33
|
+
this.startTime = Date.now();
|
|
34
|
+
// Hide cursor
|
|
35
|
+
process.stdout.write('\x1B[?25l');
|
|
36
|
+
this.interval = setInterval(() => {
|
|
37
|
+
const frame = this.frames[this.frameIndex = (this.frameIndex + 1) % this.frames.length];
|
|
38
|
+
let displayMessage = this.message;
|
|
39
|
+
// Add timing if enabled
|
|
40
|
+
if (this.showTiming) {
|
|
41
|
+
const elapsedSeconds = ((Date.now() - this.startTime) / 1000).toFixed(1);
|
|
42
|
+
displayMessage = `${this.message} (${elapsedSeconds}s)`;
|
|
43
|
+
}
|
|
44
|
+
// Note: We use chalk.gray for the message to match the existing "Fetching..." style
|
|
45
|
+
process.stdout.write(`\r${chalk.bgBlack.cyanBright.bold(frame)} ${chalk.gray(displayMessage)}`);
|
|
46
|
+
}, 80);
|
|
47
|
+
}
|
|
48
|
+
stop(clearLine = true) {
|
|
49
|
+
if (this.interval) {
|
|
50
|
+
clearInterval(this.interval);
|
|
51
|
+
this.interval = null;
|
|
52
|
+
}
|
|
53
|
+
if (this.spinnerActive) {
|
|
54
|
+
if (clearLine) {
|
|
55
|
+
process.stdout.write('\r\x1b[K'); // Clear line
|
|
56
|
+
}
|
|
57
|
+
// Show cursor
|
|
58
|
+
process.stdout.write('\x1B[?25h');
|
|
59
|
+
this.spinnerActive = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
updateMessage(newMessage) {
|
|
63
|
+
this.message = newMessage;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const globalSpinner = new Spinner();
|
|
67
|
+
export { globalSpinner as spinner };
|
|
68
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/lib/spinner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B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|
1
|
+
/**
|
|
2
|
+
* @file Static Virtual File System Provider.
|
|
3
|
+
*
|
|
4
|
+
* Implements virtual directories for `/bin`, `/usr`, and `/usr/bin` under the VFSDispatcher.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { Result } from '@fnndsc/cumin';
|
|
9
|
+
import { VFSProvider, VFSItem, CpOptions } from '@fnndsc/salsa';
|
|
10
|
+
/**
|
|
11
|
+
* Static virtual filesystem provider for command and builtin paths.
|
|
12
|
+
*/
|
|
13
|
+
export declare class StaticVfsProvider implements VFSProvider {
|
|
14
|
+
/** The prefix path this provider handles. */
|
|
15
|
+
prefix: string;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the static provider with its target prefix path.
|
|
18
|
+
*
|
|
19
|
+
* @param prefix - The absolute virtual directory prefix.
|
|
20
|
+
*/
|
|
21
|
+
constructor(prefix: string);
|
|
22
|
+
/**
|
|
23
|
+
* Lists the contents of the matched static prefix path.
|
|
24
|
+
*
|
|
25
|
+
* @param pathStr - The absolute path.
|
|
26
|
+
* @param options - Sort controls.
|
|
27
|
+
* @returns Promise resolving to Result of VFSItems.
|
|
28
|
+
*/
|
|
29
|
+
list(pathStr: string, options?: {
|
|
30
|
+
sort?: "name" | "size" | "date" | "owner";
|
|
31
|
+
reverse?: boolean;
|
|
32
|
+
}): Promise<Result<VFSItem[]>>;
|
|
33
|
+
/**
|
|
34
|
+
* Block copy operations for static paths.
|
|
35
|
+
*
|
|
36
|
+
* @param src - Source path.
|
|
37
|
+
* @param dest - Destination path.
|
|
38
|
+
* @param options - Copy options.
|
|
39
|
+
* @returns Promise resolving to false always to block copying.
|
|
40
|
+
*/
|
|
41
|
+
cp(src: string, dest: string, options: CpOptions): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Standard sort helper for virtual items.
|
|
44
|
+
*
|
|
45
|
+
* @param items - The VFSItem array to sort.
|
|
46
|
+
* @param sortField - Field to sort by.
|
|
47
|
+
* @param reverse - True to reverse output sorting.
|
|
48
|
+
* @returns Sorted VFSItem array.
|
|
49
|
+
*/
|
|
50
|
+
private staticVfsItems_sort;
|
|
51
|
+
/**
|
|
52
|
+
* Reads virtual file content under command and builtin static paths.
|
|
53
|
+
*
|
|
54
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
55
|
+
* @returns Promise resolving to a Result containing the file contents.
|
|
56
|
+
*/
|
|
57
|
+
read(pathStr: string): Promise<Result<string>>;
|
|
58
|
+
/**
|
|
59
|
+
* Reads virtual file binary content under command and builtin static paths.
|
|
60
|
+
*
|
|
61
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
62
|
+
* @returns Promise resolving to a Result containing the file contents as a Buffer.
|
|
63
|
+
*/
|
|
64
|
+
readBinary(pathStr: string): Promise<Result<Buffer>>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Static Virtual File System Provider.
|
|
3
|
+
*
|
|
4
|
+
* Implements virtual directories for `/bin`, `/usr`, and `/usr/bin` under the VFSDispatcher.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { Ok, Err, errorStack } from '@fnndsc/cumin';
|
|
9
|
+
import { plugins_listAll, pipelines_getAll } from '@fnndsc/salsa';
|
|
10
|
+
import { builtinCommands_list } from '../../../builtins/help.js';
|
|
11
|
+
import { staticVfs_read, staticVfs_readBinary } from './static_content.js';
|
|
12
|
+
/**
|
|
13
|
+
* Static virtual filesystem provider for command and builtin paths.
|
|
14
|
+
*/
|
|
15
|
+
export class StaticVfsProvider {
|
|
16
|
+
/** The prefix path this provider handles. */
|
|
17
|
+
prefix;
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the static provider with its target prefix path.
|
|
20
|
+
*
|
|
21
|
+
* @param prefix - The absolute virtual directory prefix.
|
|
22
|
+
*/
|
|
23
|
+
constructor(prefix) {
|
|
24
|
+
this.prefix = prefix;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Lists the contents of the matched static prefix path.
|
|
28
|
+
*
|
|
29
|
+
* @param pathStr - The absolute path.
|
|
30
|
+
* @param options - Sort controls.
|
|
31
|
+
* @returns Promise resolving to Result of VFSItems.
|
|
32
|
+
*/
|
|
33
|
+
async list(pathStr, options) {
|
|
34
|
+
try {
|
|
35
|
+
let effectivePath = pathStr.startsWith("/") ? pathStr : "/" + pathStr;
|
|
36
|
+
if (effectivePath.length > 1 && effectivePath.endsWith("/")) {
|
|
37
|
+
effectivePath = effectivePath.slice(0, -1);
|
|
38
|
+
}
|
|
39
|
+
if (effectivePath === "/bin") {
|
|
40
|
+
const [plugins, pipelinesResult] = await Promise.all([
|
|
41
|
+
plugins_listAll({}),
|
|
42
|
+
pipelines_getAll(),
|
|
43
|
+
]);
|
|
44
|
+
const items = [];
|
|
45
|
+
if (plugins && plugins.tableData) {
|
|
46
|
+
plugins.tableData.forEach((plugin) => {
|
|
47
|
+
const pluginName = typeof plugin.name === 'string' ? plugin.name : String(plugin.name);
|
|
48
|
+
const pluginVersion = typeof plugin.version === 'string' ? plugin.version : String(plugin.version || '');
|
|
49
|
+
const displayName = pluginVersion ? `${pluginName}-v${pluginVersion}` : pluginName;
|
|
50
|
+
items.push({
|
|
51
|
+
name: displayName,
|
|
52
|
+
type: "plugin",
|
|
53
|
+
size: 0,
|
|
54
|
+
owner: "system",
|
|
55
|
+
date: typeof plugin.creation_date === 'string' ? plugin.creation_date : '',
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (pipelinesResult.ok) {
|
|
60
|
+
pipelinesResult.value.forEach((pipeline) => {
|
|
61
|
+
const slug = typeof pipeline.slug === 'string' ? pipeline.slug : pipeline.name.replace(/\s+/g, '_');
|
|
62
|
+
items.push({
|
|
63
|
+
name: slug,
|
|
64
|
+
type: "pipeline",
|
|
65
|
+
size: 0,
|
|
66
|
+
owner: typeof pipeline.authors === 'string' ? pipeline.authors : 'system',
|
|
67
|
+
date: '',
|
|
68
|
+
title: pipeline.name,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const sorted = this.staticVfsItems_sort(items, options?.sort, options?.reverse);
|
|
73
|
+
return Ok(sorted);
|
|
74
|
+
}
|
|
75
|
+
if (effectivePath === "/usr") {
|
|
76
|
+
const items = [
|
|
77
|
+
{
|
|
78
|
+
name: "bin",
|
|
79
|
+
type: "vfs",
|
|
80
|
+
size: 0,
|
|
81
|
+
owner: "root",
|
|
82
|
+
date: new Date().toISOString(),
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
return Ok(items);
|
|
86
|
+
}
|
|
87
|
+
if (effectivePath === "/usr/bin") {
|
|
88
|
+
const builtinNames = builtinCommands_list();
|
|
89
|
+
const items = builtinNames.map((name) => ({
|
|
90
|
+
name,
|
|
91
|
+
type: "plugin",
|
|
92
|
+
size: 0,
|
|
93
|
+
owner: "system",
|
|
94
|
+
date: new Date().toISOString(),
|
|
95
|
+
}));
|
|
96
|
+
const sorted = this.staticVfsItems_sort(items, options?.sort, options?.reverse);
|
|
97
|
+
return Ok(sorted);
|
|
98
|
+
}
|
|
99
|
+
return Ok([]);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
103
|
+
errorStack.stack_push("error", `Static VFS list failed for prefix ${this.prefix}: ${msg}`);
|
|
104
|
+
return Err();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Block copy operations for static paths.
|
|
109
|
+
*
|
|
110
|
+
* @param src - Source path.
|
|
111
|
+
* @param dest - Destination path.
|
|
112
|
+
* @param options - Copy options.
|
|
113
|
+
* @returns Promise resolving to false always to block copying.
|
|
114
|
+
*/
|
|
115
|
+
async cp(src, dest, options) {
|
|
116
|
+
errorStack.stack_push("error", `cp: Copying from static VFS path '${src}' is not supported.`);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Standard sort helper for virtual items.
|
|
121
|
+
*
|
|
122
|
+
* @param items - The VFSItem array to sort.
|
|
123
|
+
* @param sortField - Field to sort by.
|
|
124
|
+
* @param reverse - True to reverse output sorting.
|
|
125
|
+
* @returns Sorted VFSItem array.
|
|
126
|
+
*/
|
|
127
|
+
staticVfsItems_sort(items, sortField, reverse) {
|
|
128
|
+
const field = sortField || "name";
|
|
129
|
+
const sorted = [...items].sort((a, b) => {
|
|
130
|
+
const valA = a[field];
|
|
131
|
+
const valB = b[field];
|
|
132
|
+
if (typeof valA === "string" && typeof valB === "string") {
|
|
133
|
+
return valA.localeCompare(valB);
|
|
134
|
+
}
|
|
135
|
+
if (typeof valA === "number" && typeof valB === "number") {
|
|
136
|
+
return valA - valB;
|
|
137
|
+
}
|
|
138
|
+
return 0;
|
|
139
|
+
});
|
|
140
|
+
if (reverse) {
|
|
141
|
+
sorted.reverse();
|
|
142
|
+
}
|
|
143
|
+
return sorted;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Reads virtual file content under command and builtin static paths.
|
|
147
|
+
*
|
|
148
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
149
|
+
* @returns Promise resolving to a Result containing the file contents.
|
|
150
|
+
*/
|
|
151
|
+
async read(pathStr) {
|
|
152
|
+
return staticVfs_read(pathStr, this.prefix);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Reads virtual file binary content under command and builtin static paths.
|
|
156
|
+
*
|
|
157
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
158
|
+
* @returns Promise resolving to a Result containing the file contents as a Buffer.
|
|
159
|
+
*/
|
|
160
|
+
async readBinary(pathStr) {
|
|
161
|
+
return staticVfs_readBinary(pathStr, this.prefix);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../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C;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAe;QACxB,OAAO,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,OAAO,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Static VFS Content Handler.
|
|
3
|
+
*
|
|
4
|
+
* Implements specialized virtual file reading and content generation
|
|
5
|
+
* for static command directories (/bin, /usr/bin).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Result } from '@fnndsc/cumin';
|
|
10
|
+
/**
|
|
11
|
+
* Reads virtual file content under command and builtin static paths.
|
|
12
|
+
*
|
|
13
|
+
* Handles help text formatting for /usr/bin and fetches parameter specifications for /bin plugins.
|
|
14
|
+
*
|
|
15
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
16
|
+
* @param prefix - The prefix of the calling provider (e.g. '/usr/bin', '/bin').
|
|
17
|
+
* @returns Promise resolving to a Result containing the file contents as a string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function staticVfs_read(pathStr: string, prefix: string): Promise<Result<string>>;
|
|
20
|
+
/**
|
|
21
|
+
* Reads virtual file binary content under command and builtin static paths.
|
|
22
|
+
*
|
|
23
|
+
* @param pathStr - The absolute virtual path of the file to read.
|
|
24
|
+
* @param prefix - The prefix of the calling provider.
|
|
25
|
+
* @returns Promise resolving to a Result containing the file contents as a Buffer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function staticVfs_readBinary(pathStr: string, prefix: string): Promise<Result<Buffer>>;
|