zion 2.0.1 → 2.0.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/README.md +5 -0
- package/dist/cli.js +22 -24
- package/package.json +3 -3
package/README.md
ADDED
package/dist/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ function HintBar({ text }) {
|
|
|
37
37
|
import Table from "cli-table3";
|
|
38
38
|
import { marked } from "marked";
|
|
39
39
|
import { Box, Text as Text2 } from "ink";
|
|
40
|
-
import
|
|
40
|
+
import terminalLink from "terminal-link";
|
|
41
41
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
42
42
|
function Markdown({ children, width }) {
|
|
43
43
|
const tokens = marked.lexer(children);
|
|
@@ -47,15 +47,8 @@ function TokenRenderer({ token, width }) {
|
|
|
47
47
|
switch (token.type) {
|
|
48
48
|
case "heading":
|
|
49
49
|
return /* @__PURE__ */ jsx2(Box, { marginTop: token.depth === 1 ? 0 : 1, children: /* @__PURE__ */ jsx2(Text2, { bold: true, underline: token.depth === 1, children: renderInline(token.tokens) }) });
|
|
50
|
-
case "paragraph":
|
|
51
|
-
const hasLinks = token.tokens?.some(
|
|
52
|
-
(t) => t.type === "link" || t.type === "strong" && "tokens" in t && t.tokens?.some((st) => st.type === "link")
|
|
53
|
-
);
|
|
54
|
-
if (hasLinks) {
|
|
55
|
-
return /* @__PURE__ */ jsx2(Box, { flexDirection: "row", flexWrap: "wrap", children: renderInline(token.tokens) });
|
|
56
|
-
}
|
|
50
|
+
case "paragraph":
|
|
57
51
|
return /* @__PURE__ */ jsx2(Text2, { wrap: "wrap", children: renderInline(token.tokens) });
|
|
58
|
-
}
|
|
59
52
|
case "code": {
|
|
60
53
|
const innerWidth = width ? width - 4 : 76;
|
|
61
54
|
const horizontalBar = "\u2500".repeat(innerWidth + 2);
|
|
@@ -115,8 +108,10 @@ function renderInline(tokens) {
|
|
|
115
108
|
token.text,
|
|
116
109
|
"`"
|
|
117
110
|
] }, idx);
|
|
118
|
-
case "link":
|
|
119
|
-
|
|
111
|
+
case "link": {
|
|
112
|
+
const text = renderInlineToString(token.tokens);
|
|
113
|
+
return /* @__PURE__ */ jsx2(Text2, { color: "blue", children: terminalLink(text, token.href) }, idx);
|
|
114
|
+
}
|
|
120
115
|
case "image":
|
|
121
116
|
return /* @__PURE__ */ jsxs(Text2, { color: "blue", children: [
|
|
122
117
|
"[Image: ",
|
|
@@ -232,12 +227,12 @@ function HomeView({ aboutTitle, aboutContent, contentWidth }) {
|
|
|
232
227
|
|
|
233
228
|
// src/components/NavBar.tsx
|
|
234
229
|
import { Box as Box5, Text as Text6 } from "ink";
|
|
235
|
-
import
|
|
230
|
+
import terminalLink2 from "terminal-link";
|
|
236
231
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
237
232
|
function NavBar() {
|
|
238
233
|
return /* @__PURE__ */ jsx6(Box5, { flexDirection: "row", children: NAV_LINKS.map((link, idx) => /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", children: [
|
|
239
234
|
idx > 0 && /* @__PURE__ */ jsx6(Text6, { color: COLORS.subtle, children: DOT_CHAR }),
|
|
240
|
-
/* @__PURE__ */ jsx6(Box5, { marginRight: 2, children: link.name === "home" || link.name === "blog" ? /* @__PURE__ */ jsx6(Text6, { color: link.color, children: link.name }) : /* @__PURE__ */ jsx6(
|
|
235
|
+
/* @__PURE__ */ jsx6(Box5, { marginRight: 2, children: link.name === "home" || link.name === "blog" ? /* @__PURE__ */ jsx6(Text6, { color: link.color, children: link.name }) : /* @__PURE__ */ jsx6(Text6, { color: link.color, children: terminalLink2(link.name, `${BASE_URL}${link.path}`) }) })
|
|
241
236
|
] }, link.name)) });
|
|
242
237
|
}
|
|
243
238
|
|
|
@@ -286,7 +281,7 @@ function applyRadar(text, frame, config) {
|
|
|
286
281
|
const chars = [];
|
|
287
282
|
for (let i = 0; i < text.length; i++) {
|
|
288
283
|
const pos = -(i - globalPos);
|
|
289
|
-
if (pos
|
|
284
|
+
if (pos >= 0 && pos < depth) {
|
|
290
285
|
const t = (depth - pos) / depth;
|
|
291
286
|
chars.push(chalk.rgb(lerp(br, 255, t), lerp(bg, 255, t), lerp(bb, 255, t))(text[i]));
|
|
292
287
|
} else {
|
|
@@ -505,15 +500,6 @@ function App() {
|
|
|
505
500
|
addError("about", result.error);
|
|
506
501
|
}
|
|
507
502
|
});
|
|
508
|
-
loadBlogPostList().then((result) => {
|
|
509
|
-
setLoading((prev) => prev === "posts" ? null : prev);
|
|
510
|
-
if (result.ok) {
|
|
511
|
-
clearError("posts");
|
|
512
|
-
setBlogPosts(result.data);
|
|
513
|
-
} else {
|
|
514
|
-
addError("posts", result.error);
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
503
|
}, []);
|
|
518
504
|
const contentWidth = Math.max(Math.min(Math.floor(columns * 2 / 3), 80), 40);
|
|
519
505
|
const blogListVPHeight = Math.min(blogPosts.length, Math.min(Math.floor(rows / 2), 20));
|
|
@@ -535,6 +521,18 @@ function App() {
|
|
|
535
521
|
if (input === "b") {
|
|
536
522
|
setCurrentView("blogList");
|
|
537
523
|
blogList.reset();
|
|
524
|
+
if (blogPosts.length === 0) {
|
|
525
|
+
setLoading("posts");
|
|
526
|
+
loadBlogPostList().then((result) => {
|
|
527
|
+
setLoading(null);
|
|
528
|
+
if (result.ok) {
|
|
529
|
+
clearError("posts");
|
|
530
|
+
setBlogPosts(result.data);
|
|
531
|
+
} else {
|
|
532
|
+
addError("posts", result.error);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
538
536
|
}
|
|
539
537
|
break;
|
|
540
538
|
case "blogList":
|
|
@@ -557,7 +555,7 @@ function App() {
|
|
|
557
555
|
return /* @__PURE__ */ jsx8(Box6, { width: columns, height: rows, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", width: contentWidth, children: [
|
|
558
556
|
/* @__PURE__ */ jsx8(NavBar, {}),
|
|
559
557
|
visibleErrors.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginTop: 1, flexDirection: "column", children: visibleErrors.map((err, i) => /* @__PURE__ */ jsx8(Text8, { color: "red", children: err }, i)) }),
|
|
560
|
-
loading && /* @__PURE__ */ jsx8(AnimatedText, { name: "radar", children: "Loading" }),
|
|
558
|
+
loading && /* @__PURE__ */ jsx8(Box6, { paddingY: 5, children: /* @__PURE__ */ jsx8(AnimatedText, { name: "radar", speed: 0.6, children: "Loading" }) }),
|
|
561
559
|
currentView === "home" && !loading && /* @__PURE__ */ jsx8(HomeView, { aboutTitle, aboutContent, contentWidth }),
|
|
562
560
|
currentView === "blogList" && !loading && /* @__PURE__ */ jsx8(
|
|
563
561
|
BlogListView,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zion",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"chalk": "^5.6.2",
|
|
26
26
|
"cli-table3": "^0.6.5",
|
|
27
27
|
"ink": "^6.6.0",
|
|
28
|
-
"ink-link": "^5.0.0",
|
|
29
28
|
"ink-scroll-view": "^0.3.5",
|
|
30
29
|
"marked": "^17.0.1",
|
|
31
|
-
"react": "^19.2.4"
|
|
30
|
+
"react": "^19.2.4",
|
|
31
|
+
"terminal-link": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|