@spaceflow/core 0.1.2 → 0.1.3

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/dist/129.js ADDED
@@ -0,0 +1,9 @@
1
+ export const __rspack_esm_id = "129";
2
+ export const __rspack_esm_ids = ["129"];
3
+ export const __webpack_modules__ = {
4
+ 56(module) {
5
+ module.exports = import("@modelcontextprotocol/sdk/server/mcp.js").then(function(module) { return module; });
6
+
7
+ },
8
+
9
+ };
package/dist/260.js ADDED
@@ -0,0 +1,9 @@
1
+ export const __rspack_esm_id = "260";
2
+ export const __rspack_esm_ids = ["260"];
3
+ export const __webpack_modules__ = {
4
+ 991(module) {
5
+ module.exports = import("@modelcontextprotocol/sdk/server/stdio.js").then(function(module) { return module; });
6
+
7
+ },
8
+
9
+ };
package/dist/524.js ADDED
@@ -0,0 +1,9 @@
1
+ export const __rspack_esm_id = "524";
2
+ export const __rspack_esm_ids = ["524"];
3
+ export const __webpack_modules__ = {
4
+ 463(module) {
5
+ module.exports = import("fs/promises").then(function(module) { return module; });
6
+
7
+ },
8
+
9
+ };
package/dist/976.js ADDED
@@ -0,0 +1,157 @@
1
+ import chalk from "chalk";
2
+ import ora from "ora";
3
+ import log_update from "log-update";
4
+ export const __rspack_esm_id = "976";
5
+ export const __rspack_esm_ids = ["976"];
6
+ export const __webpack_modules__ = {
7
+ 115(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8
+
9
+ // EXPORTS
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ TuiRenderer: () => (/* binding */ TuiRenderer)
12
+ });
13
+
14
+ ;// CONCATENATED MODULE: external "chalk"
15
+
16
+ ;// CONCATENATED MODULE: external "ora"
17
+
18
+ ;// CONCATENATED MODULE: external "log-update"
19
+
20
+ ;// CONCATENATED MODULE: ./src/shared/logger/renderers/tui.renderer.ts
21
+
22
+
23
+
24
+ /** 进度条默认宽度 */ const DEFAULT_BAR_WIDTH = 30;
25
+ /** 任务状态图标 */ const TASK_ICONS = {
26
+ pending: chalk.gray("○"),
27
+ running: chalk.cyan("◌"),
28
+ success: chalk.green("✔"),
29
+ failed: chalk.red("✖"),
30
+ skipped: chalk.yellow("⊘")
31
+ };
32
+ /** 渲染进度条字符串 */ const renderBar = (current, total, width)=>{
33
+ const ratio = Math.min(current / total, 1);
34
+ const filled = Math.round(ratio * width);
35
+ const empty = width - filled;
36
+ const bar = chalk.green("█".repeat(filled)) + chalk.gray("░".repeat(empty));
37
+ const pct = Math.round(ratio * 100);
38
+ return `${bar} ${pct}%`;
39
+ };
40
+ /** TUI 模式渲染器:富交互输出,适合终端 */ class TuiRenderer {
41
+ info(prefix, message) {
42
+ console.log(`${chalk.gray(prefix)} ${message}`);
43
+ }
44
+ success(prefix, message) {
45
+ console.log(`${chalk.gray(prefix)} ${chalk.green("✔")} ${message}`);
46
+ }
47
+ warn(prefix, message) {
48
+ console.warn(`${chalk.gray(prefix)} ${chalk.yellow("⚠")} ${chalk.yellow(message)}`);
49
+ }
50
+ error(prefix, message) {
51
+ console.error(`${chalk.gray(prefix)} ${chalk.red("✖")} ${chalk.red(message)}`);
52
+ }
53
+ debug(prefix, message) {
54
+ console.log(`${chalk.gray(prefix)} ${chalk.magenta("[DEBUG]")} ${chalk.gray(message)}`);
55
+ }
56
+ verbose(prefix, message) {
57
+ console.log(`${chalk.gray(prefix)} ${chalk.gray(message)}`);
58
+ }
59
+ createSpinner(prefix, message) {
60
+ const spinner = ora({
61
+ text: `${chalk.gray(prefix)} ${message}`,
62
+ prefixText: ""
63
+ }).start();
64
+ return {
65
+ update: (msg)=>{
66
+ spinner.text = `${chalk.gray(prefix)} ${msg}`;
67
+ },
68
+ succeed: (msg)=>{
69
+ spinner.succeed(`${chalk.gray(prefix)} ${msg ?? message}`);
70
+ },
71
+ fail: (msg)=>{
72
+ spinner.fail(`${chalk.gray(prefix)} ${msg ?? message}`);
73
+ },
74
+ stop: ()=>{
75
+ spinner.stop();
76
+ }
77
+ };
78
+ }
79
+ createProgressBar(prefix, options) {
80
+ const { total, label = "", width = DEFAULT_BAR_WIDTH } = options;
81
+ const tag = label ? `${label} ` : "";
82
+ log_update(`${chalk.gray(prefix)} ${tag}${renderBar(0, total, width)} 0/${total}`);
83
+ return {
84
+ update: (current, msg)=>{
85
+ const suffix = msg ? ` ${chalk.gray(msg)}` : "";
86
+ log_update(`${chalk.gray(prefix)} ${tag}${renderBar(current, total, width)} ${current}/${total}${suffix}`);
87
+ },
88
+ finish: (msg)=>{
89
+ const suffix = msg ? ` ${msg}` : "";
90
+ log_update.done();
91
+ console.log(`${chalk.gray(prefix)} ${chalk.green("✔")} ${tag}${total}/${total} (100%)${suffix}`);
92
+ }
93
+ };
94
+ }
95
+ async runTasks(prefix, items) {
96
+ const enabledItems = items.filter((item)=>item.enabled !== false);
97
+ const statuses = enabledItems.map(()=>"pending");
98
+ const messages = enabledItems.map((item)=>item.title);
99
+ const results = [];
100
+ const renderTaskList = ()=>{
101
+ return enabledItems.map((item, i)=>{
102
+ const icon = TASK_ICONS[statuses[i]];
103
+ const title = statuses[i] === "running" ? chalk.cyan(item.title) : item.title;
104
+ const suffix = messages[i] !== item.title ? chalk.gray(` ${messages[i]}`) : "";
105
+ return `${chalk.gray(prefix)} ${icon} ${title}${suffix}`;
106
+ }).join("\n");
107
+ };
108
+ log_update(renderTaskList());
109
+ for(let i = 0; i < enabledItems.length; i++){
110
+ statuses[i] = "running";
111
+ log_update(renderTaskList());
112
+ let skipped = false;
113
+ let skipReason = "";
114
+ const control = {
115
+ update: (msg)=>{
116
+ messages[i] = msg;
117
+ log_update(renderTaskList());
118
+ },
119
+ skip: (reason)=>{
120
+ skipped = true;
121
+ skipReason = reason ?? "";
122
+ }
123
+ };
124
+ try {
125
+ const ctx = results.length > 0 ? results[results.length - 1] : undefined;
126
+ const result = await enabledItems[i].task(ctx, control);
127
+ if (skipped) {
128
+ statuses[i] = "skipped";
129
+ messages[i] = skipReason ? `${enabledItems[i].title} (${skipReason})` : enabledItems[i].title;
130
+ } else {
131
+ statuses[i] = "success";
132
+ messages[i] = enabledItems[i].title;
133
+ }
134
+ results.push(result);
135
+ } catch (err) {
136
+ statuses[i] = "failed";
137
+ messages[i] = err instanceof Error ? err.message : String(err);
138
+ log_update(renderTaskList());
139
+ log_update.done();
140
+ throw err;
141
+ }
142
+ log_update(renderTaskList());
143
+ }
144
+ log_update.done();
145
+ return results;
146
+ }
147
+ table(_prefix, data) {
148
+ console.table(data);
149
+ }
150
+ }
151
+
152
+
153
+ },
154
+
155
+ };
156
+
157
+ //# sourceMappingURL=976.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"976.js","sources":["webpack://@spaceflow/core/./src/shared/logger/renderers/tui.renderer.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport ora from \"ora\";\nimport logUpdate from \"log-update\";\nimport type {\n LogRenderer,\n Spinner,\n ProgressBar,\n ProgressBarOptions,\n TaskItem,\n TaskControl,\n TaskStatus,\n} from \"../logger.interface\";\n\n/** 进度条默认宽度 */\nconst DEFAULT_BAR_WIDTH = 30;\n\n/** 任务状态图标 */\nconst TASK_ICONS: Record<TaskStatus, string> = {\n pending: chalk.gray(\"○\"),\n running: chalk.cyan(\"◌\"),\n success: chalk.green(\"✔\"),\n failed: chalk.red(\"✖\"),\n skipped: chalk.yellow(\"⊘\"),\n};\n\n/** 渲染进度条字符串 */\nconst renderBar = (current: number, total: number, width: number): string => {\n const ratio = Math.min(current / total, 1);\n const filled = Math.round(ratio * width);\n const empty = width - filled;\n const bar = chalk.green(\"█\".repeat(filled)) + chalk.gray(\"░\".repeat(empty));\n const pct = Math.round(ratio * 100);\n return `${bar} ${pct}%`;\n};\n\n/** TUI 模式渲染器:富交互输出,适合终端 */\nexport class TuiRenderer implements LogRenderer {\n info(prefix: string, message: string): void {\n console.log(`${chalk.gray(prefix)} ${message}`);\n }\n\n success(prefix: string, message: string): void {\n console.log(`${chalk.gray(prefix)} ${chalk.green(\"✔\")} ${message}`);\n }\n\n warn(prefix: string, message: string): void {\n console.warn(`${chalk.gray(prefix)} ${chalk.yellow(\"⚠\")} ${chalk.yellow(message)}`);\n }\n\n error(prefix: string, message: string): void {\n console.error(`${chalk.gray(prefix)} ${chalk.red(\"✖\")} ${chalk.red(message)}`);\n }\n\n debug(prefix: string, message: string): void {\n console.log(`${chalk.gray(prefix)} ${chalk.magenta(\"[DEBUG]\")} ${chalk.gray(message)}`);\n }\n\n verbose(prefix: string, message: string): void {\n console.log(`${chalk.gray(prefix)} ${chalk.gray(message)}`);\n }\n\n createSpinner(prefix: string, message: string): Spinner {\n const spinner = ora({\n text: `${chalk.gray(prefix)} ${message}`,\n prefixText: \"\",\n }).start();\n return {\n update: (msg: string) => {\n spinner.text = `${chalk.gray(prefix)} ${msg}`;\n },\n succeed: (msg?: string) => {\n spinner.succeed(`${chalk.gray(prefix)} ${msg ?? message}`);\n },\n fail: (msg?: string) => {\n spinner.fail(`${chalk.gray(prefix)} ${msg ?? message}`);\n },\n stop: () => {\n spinner.stop();\n },\n };\n }\n\n createProgressBar(prefix: string, options: ProgressBarOptions): ProgressBar {\n const { total, label = \"\", width = DEFAULT_BAR_WIDTH } = options;\n const tag = label ? `${label} ` : \"\";\n logUpdate(`${chalk.gray(prefix)} ${tag}${renderBar(0, total, width)} 0/${total}`);\n return {\n update: (current: number, msg?: string) => {\n const suffix = msg ? ` ${chalk.gray(msg)}` : \"\";\n logUpdate(\n `${chalk.gray(prefix)} ${tag}${renderBar(current, total, width)} ${current}/${total}${suffix}`,\n );\n },\n finish: (msg?: string) => {\n const suffix = msg ? ` ${msg}` : \"\";\n logUpdate.done();\n console.log(\n `${chalk.gray(prefix)} ${chalk.green(\"✔\")} ${tag}${total}/${total} (100%)${suffix}`,\n );\n },\n };\n }\n\n async runTasks<T>(prefix: string, items: TaskItem<T>[]): Promise<T[]> {\n const enabledItems = items.filter((item) => item.enabled !== false);\n const statuses: TaskStatus[] = enabledItems.map(() => \"pending\");\n const messages: string[] = enabledItems.map((item) => item.title);\n const results: T[] = [];\n const renderTaskList = (): string => {\n return enabledItems\n .map((item, i) => {\n const icon = TASK_ICONS[statuses[i]];\n const title = statuses[i] === \"running\" ? chalk.cyan(item.title) : item.title;\n const suffix = messages[i] !== item.title ? chalk.gray(` ${messages[i]}`) : \"\";\n return `${chalk.gray(prefix)} ${icon} ${title}${suffix}`;\n })\n .join(\"\\n\");\n };\n logUpdate(renderTaskList());\n for (let i = 0; i < enabledItems.length; i++) {\n statuses[i] = \"running\";\n logUpdate(renderTaskList());\n let skipped = false;\n let skipReason = \"\";\n const control: TaskControl = {\n update: (msg: string) => {\n messages[i] = msg;\n logUpdate(renderTaskList());\n },\n skip: (reason?: string) => {\n skipped = true;\n skipReason = reason ?? \"\";\n },\n };\n try {\n const ctx = (results.length > 0 ? results[results.length - 1] : undefined) as T;\n const result = await enabledItems[i].task(ctx, control);\n if (skipped) {\n statuses[i] = \"skipped\";\n messages[i] = skipReason ? `${enabledItems[i].title} (${skipReason})` : enabledItems[i].title;\n } else {\n statuses[i] = \"success\";\n messages[i] = enabledItems[i].title;\n }\n results.push(result);\n } catch (err) {\n statuses[i] = \"failed\";\n messages[i] = err instanceof Error ? err.message : String(err);\n logUpdate(renderTaskList());\n logUpdate.done();\n throw err;\n }\n logUpdate(renderTaskList());\n }\n logUpdate.done();\n return results;\n }\n\n table(_prefix: string, data: Record<string, unknown>[]): void {\n console.table(data);\n }\n}\n"],"names":["chalk","ora","logUpdate","DEFAULT_BAR_WIDTH","TASK_ICONS","renderBar","current","total","width","ratio","Math","filled","empty","bar","pct","TuiRenderer","prefix","message","console","spinner","msg","options","label","tag","suffix","items","enabledItems","item","statuses","messages","results","renderTaskList","i","icon","title","skipped","skipReason","control","reason","ctx","undefined","result","err","Error","String","_prefix","data"],"mappings":";;;;;;;;;;;;;;;;;;;;AAA0B;AACJ;AACa;AAWnC,YAAY,GACZ,MAAMG,oBAAoB;AAE1B,WAAW,GACX,MAAMC,aAAyC;IAC7C,SAASJ,UAAU,CAAC;IACpB,SA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