zion 2.1.0 → 2.3.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.
Files changed (2) hide show
  1. package/dist/cli.js +81 -71
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/app.tsx
4
4
  import { useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
5
- import { Box as Box7, Text as Text10, useApp, useInput as useInput2, useStdout as useStdout2 } from "ink";
5
+ import { Box as Box7, Text as Text11, useApp, useInput as useInput2, useStdout as useStdout2 } from "ink";
6
6
 
7
7
  // src/components/BlogDetailView.tsx
8
8
  import { useEffect } from "react";
@@ -161,7 +161,7 @@ function BlogDetailView({ post, scrollRef, viewportHeight, contentWidth }) {
161
161
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
162
162
  /* @__PURE__ */ jsx3(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: "white", children: post.title }) }),
163
163
  /* @__PURE__ */ jsx3(Box2, { marginTop: 1, height: viewportHeight, flexDirection: "column", children: /* @__PURE__ */ jsx3(ScrollView, { ref: scrollRef, children: /* @__PURE__ */ jsx3(Markdown, { width: contentWidth, children: post.content }) }) }),
164
- /* @__PURE__ */ jsx3(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx3(HintBar, { text: "Hint: h/j/k: back, down, up | q: quit" }) })
164
+ /* @__PURE__ */ jsx3(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx3(HintBar, { text: "Hint: h: back | j/k: down, up | q: quit" }) })
165
165
  ] });
166
166
  }
167
167
 
@@ -214,7 +214,7 @@ function BlogListView({ posts, highlightedIndex, scrollRef, viewportHeight }) {
214
214
  /* @__PURE__ */ jsx4(Text4, { bold: isSelected, color: isSelected ? COLORS.selectedBlog : COLORS.text, children: post.title })
215
215
  ] }, post.slug);
216
216
  }) }) }),
217
- /* @__PURE__ */ jsx4(Box3, { marginTop: 1, children: /* @__PURE__ */ jsx4(HintBar, { text: "Hint: h/j/k/l/enter: back, down, up, open | q: quit" }) })
217
+ /* @__PURE__ */ jsx4(Box3, { marginTop: 1, children: /* @__PURE__ */ jsx4(HintBar, { text: "Hint: h/l: home, portfolio | j/k: down, up | enter: open | q: quit" }) })
218
218
  ] });
219
219
  }
220
220
 
@@ -225,7 +225,7 @@ function HomeView({ aboutTitle, aboutContent, contentWidth }) {
225
225
  return /* @__PURE__ */ jsxs4(Fragment3, { children: [
226
226
  /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(Text5, { bold: true, color: "white", children: aboutTitle }) }),
227
227
  /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(Markdown, { width: contentWidth, children: aboutContent }) }),
228
- /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(HintBar, { text: "Hint: b: blog | p: portfolio | q, ctrl+c: quit" }) })
228
+ /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(HintBar, { text: "Hint: l: blog | q, ctrl+c: quit" }) })
229
229
  ] });
230
230
  }
231
231
 
@@ -236,12 +236,12 @@ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
236
236
  function NavBar() {
237
237
  return /* @__PURE__ */ jsx6(Box5, { flexDirection: "row", children: NAV_LINKS.map((link, idx) => /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", children: [
238
238
  idx > 0 && /* @__PURE__ */ jsx6(Text6, { color: COLORS.subtle, children: DOT_CHAR }),
239
- /* @__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}`) }) })
239
+ /* @__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}`, { fallback: () => link.name }) }) })
240
240
  ] }, link.name)) });
241
241
  }
242
242
 
243
243
  // src/components/PortfolioListView.tsx
244
- import { Box as Box6, Text as Text8 } from "ink";
244
+ import { Box as Box6, Text as Text9 } from "ink";
245
245
  import { ScrollView as ScrollView3 } from "ink-scroll-view";
246
246
 
247
247
  // src/components/ui/Badge.tsx
@@ -255,35 +255,44 @@ function Badge({ color, background, children }) {
255
255
  ] });
256
256
  }
257
257
 
258
+ // src/components/ui/Stars.tsx
259
+ import { Text as Text8 } from "ink";
260
+ import { jsx as jsx8 } from "react/jsx-runtime";
261
+ var formatter = new Intl.NumberFormat("en", { notation: "compact", maximumFractionDigits: 1 });
262
+ function Stars({ count }) {
263
+ return /* @__PURE__ */ jsx8(Text8, { color: COLORS.subtle, children: `\u2605 ${formatter.format(count).toLowerCase()}` });
264
+ }
265
+
258
266
  // src/components/PortfolioListView.tsx
259
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
267
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
260
268
  function PortfolioListView({ projects, highlightedIndex, scrollRef, viewportHeight }) {
261
269
  return /* @__PURE__ */ jsxs7(Fragment5, { children: [
262
- /* @__PURE__ */ jsx8(Box6, { marginTop: 1, height: viewportHeight, flexDirection: "column", children: /* @__PURE__ */ jsx8(ScrollView3, { ref: scrollRef, children: projects.map((project, idx) => {
270
+ /* @__PURE__ */ jsx9(Box6, { marginTop: 1, height: viewportHeight, flexDirection: "column", children: /* @__PURE__ */ jsx9(ScrollView3, { ref: scrollRef, children: projects.map((project, idx) => {
263
271
  const isSelected = idx === highlightedIndex;
264
272
  const prefix = isSelected ? "\u203A " : " ";
265
273
  return /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", marginBottom: 2, children: [
266
274
  /* @__PURE__ */ jsxs7(Box6, { flexDirection: "row", children: [
267
- /* @__PURE__ */ jsx8(Text8, { bold: isSelected, color: isSelected ? COLORS.selectedBlog : void 0, children: prefix }),
268
- /* @__PURE__ */ jsx8(Text8, { bold: isSelected, color: isSelected ? COLORS.selectedBlog : COLORS.text, children: project.title })
275
+ /* @__PURE__ */ jsx9(Text9, { bold: isSelected, color: isSelected ? COLORS.selectedBlog : void 0, children: prefix }),
276
+ /* @__PURE__ */ jsx9(Text9, { bold: isSelected, color: isSelected ? COLORS.selectedBlog : COLORS.text, children: project.title }),
277
+ project.stars !== void 0 && /* @__PURE__ */ jsx9(Box6, { marginLeft: 2, children: /* @__PURE__ */ jsx9(Stars, { count: project.stars }) })
269
278
  ] }),
270
- /* @__PURE__ */ jsx8(Box6, { marginLeft: 3, paddingBottom: 1, children: /* @__PURE__ */ jsxs7(Text8, { color: COLORS.subtle, children: [
279
+ /* @__PURE__ */ jsx9(Box6, { marginLeft: 3, paddingBottom: 1, children: /* @__PURE__ */ jsxs7(Text9, { color: COLORS.subtle, children: [
271
280
  project.description,
272
281
  " "
273
282
  ] }) }),
274
- project.links && project.links.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginLeft: 3, flexDirection: "column", paddingBottom: 1, children: project.links.map((link, linkIdx) => /* @__PURE__ */ jsx8(Text8, { color: COLORS.link, children: link.url }, linkIdx)) }),
275
- project.tools && project.tools.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginLeft: 3, flexDirection: "row", gap: 1, paddingBottom: 1, children: project.tools.map((tool, toolIdx) => /* @__PURE__ */ jsx8(Box6, { children: /* @__PURE__ */ jsx8(Badge, { color: "white", background: "gray", children: tool }) }, toolIdx)) })
283
+ project.links && project.links.length > 0 && /* @__PURE__ */ jsx9(Box6, { marginLeft: 3, flexDirection: "column", paddingBottom: 1, children: project.links.map((link, linkIdx) => /* @__PURE__ */ jsx9(Text9, { color: COLORS.link, children: link.url }, linkIdx)) }),
284
+ project.tools && project.tools.length > 0 && /* @__PURE__ */ jsx9(Box6, { marginLeft: 3, flexDirection: "row", gap: 1, paddingBottom: 1, children: project.tools.map((tool, toolIdx) => /* @__PURE__ */ jsx9(Box6, { children: /* @__PURE__ */ jsx9(Badge, { color: "white", background: "gray", children: tool }) }, toolIdx)) })
276
285
  ] }, idx);
277
286
  }) }) }),
278
- /* @__PURE__ */ jsx8(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx8(HintBar, { text: "Hint: h/j/k: back, down, up | q: quit" }) })
287
+ /* @__PURE__ */ jsx9(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx9(HintBar, { text: "Hint: h: blog | j/k: down, up | q: quit" }) })
279
288
  ] });
280
289
  }
281
290
 
282
291
  // src/components/ui/AnimatedText.tsx
283
292
  import chalk from "chalk";
284
293
  import { useEffect as useEffect2, useState } from "react";
285
- import { Text as Text9 } from "ink";
286
- import { jsx as jsx9 } from "react/jsx-runtime";
294
+ import { Text as Text10 } from "ink";
295
+ import { jsx as jsx10 } from "react/jsx-runtime";
287
296
  function hexToRgb(hex) {
288
297
  const h = hex.replace("#", "");
289
298
  const n = h.length === 3 ? parseInt(h[0] + h[0] + h[1] + h[1] + h[2] + h[2], 16) : parseInt(h, 16);
@@ -439,7 +448,7 @@ function AnimatedText({
439
448
  if (underline) animated = chalk.underline(animated);
440
449
  if (strikethrough) animated = chalk.strikethrough(animated);
441
450
  if (dimColor) animated = chalk.dim(animated);
442
- return /* @__PURE__ */ jsx9(Text9, { children: animated });
451
+ return /* @__PURE__ */ jsx10(Text10, { children: animated });
443
452
  }
444
453
 
445
454
  // src/hooks/useListNavigation.ts
@@ -479,7 +488,7 @@ function useListNavigation({ length, onSelect, isActive }) {
479
488
  if (key.downArrow || input === "j") {
480
489
  setHighlightedIndex((i) => Math.min(length - 1, i + 1));
481
490
  }
482
- if ((input === "l" || key.return) && onSelect) {
491
+ if (key.return && onSelect) {
483
492
  onSelect(highlightedIndex);
484
493
  }
485
494
  },
@@ -493,7 +502,7 @@ function useListNavigation({ length, onSelect, isActive }) {
493
502
  }
494
503
 
495
504
  // src/app.tsx
496
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
505
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
497
506
  function App() {
498
507
  const { exit } = useApp();
499
508
  const { stdout } = useStdout2();
@@ -561,57 +570,58 @@ function App() {
561
570
  }
562
571
  if (currentView === "blogDetail" && errors.post) visibleErrors.push(errors.post);
563
572
  if (currentView === "portfolioList" && errors.portfolio) visibleErrors.push(errors.portfolio);
573
+ const openBlogList = () => {
574
+ setCurrentView("blogList");
575
+ blogList.reset();
576
+ if (blogPosts.length === 0) {
577
+ setLoading("posts");
578
+ loadBlogPostList().then((result) => {
579
+ setLoading(null);
580
+ if (result.ok) {
581
+ clearError("posts");
582
+ setBlogPosts(result.data);
583
+ } else {
584
+ addError("posts", result.error);
585
+ }
586
+ });
587
+ }
588
+ };
589
+ const openPortfolioList = () => {
590
+ setCurrentView("portfolioList");
591
+ portfolioList.reset();
592
+ if (portfolioProjects.length === 0) {
593
+ setLoading("portfolio");
594
+ loadPortfolioList().then((result) => {
595
+ setLoading(null);
596
+ if (result.ok) {
597
+ clearError("portfolio");
598
+ setPortfolioProjects(result.data);
599
+ } else {
600
+ addError("portfolio", result.error);
601
+ }
602
+ });
603
+ }
604
+ };
564
605
  useInput2((input, key) => {
565
606
  if (input === "q" || key.ctrl && input === "c") {
566
607
  exit();
567
608
  return;
568
609
  }
610
+ const left = input === "h" || key.leftArrow;
611
+ const right = input === "l" || key.rightArrow;
569
612
  switch (currentView) {
570
613
  case "home":
571
- if (input === "b") {
572
- setCurrentView("blogList");
573
- blogList.reset();
574
- if (blogPosts.length === 0) {
575
- setLoading("posts");
576
- loadBlogPostList().then((result) => {
577
- setLoading(null);
578
- if (result.ok) {
579
- clearError("posts");
580
- setBlogPosts(result.data);
581
- } else {
582
- addError("posts", result.error);
583
- }
584
- });
585
- }
586
- } else if (input === "p") {
587
- setCurrentView("portfolioList");
588
- portfolioList.reset();
589
- if (portfolioProjects.length === 0) {
590
- setLoading("portfolio");
591
- loadPortfolioList().then((result) => {
592
- setLoading(null);
593
- if (result.ok) {
594
- clearError("portfolio");
595
- setPortfolioProjects(result.data);
596
- } else {
597
- addError("portfolio", result.error);
598
- }
599
- });
600
- }
601
- }
614
+ if (right) openBlogList();
602
615
  break;
603
616
  case "blogList":
604
- if (input === "h") {
605
- setCurrentView("home");
606
- }
617
+ if (left) setCurrentView("home");
618
+ else if (right) openPortfolioList();
607
619
  break;
608
620
  case "portfolioList":
609
- if (input === "h") {
610
- setCurrentView("home");
611
- }
621
+ if (left) openBlogList();
612
622
  break;
613
623
  case "blogDetail":
614
- if (input === "h") {
624
+ if (left) {
615
625
  setCurrentView("blogList");
616
626
  setCurrentPost(null);
617
627
  } else if (input === "j" || key.downArrow) {
@@ -622,12 +632,12 @@ function App() {
622
632
  break;
623
633
  }
624
634
  });
625
- return /* @__PURE__ */ jsx10(Box7, { width: columns, height: rows, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", width: contentWidth, children: [
626
- /* @__PURE__ */ jsx10(NavBar, {}),
627
- visibleErrors.length > 0 && /* @__PURE__ */ jsx10(Box7, { marginTop: 1, flexDirection: "column", children: visibleErrors.map((err, i) => /* @__PURE__ */ jsx10(Text10, { color: "red", children: err }, i)) }),
628
- loading && /* @__PURE__ */ jsx10(Box7, { paddingY: 2, children: /* @__PURE__ */ jsx10(AnimatedText, { name: "radar", speed: 0.6, children: "Loading" }) }),
629
- currentView === "home" && !loading && /* @__PURE__ */ jsx10(HomeView, { aboutTitle, aboutContent, contentWidth }),
630
- currentView === "blogList" && !loading && /* @__PURE__ */ jsx10(
635
+ return /* @__PURE__ */ jsx11(Box7, { width: columns, height: rows, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", width: contentWidth, children: [
636
+ /* @__PURE__ */ jsx11(NavBar, {}),
637
+ visibleErrors.length > 0 && /* @__PURE__ */ jsx11(Box7, { marginTop: 1, flexDirection: "column", children: visibleErrors.map((err, i) => /* @__PURE__ */ jsx11(Text11, { color: "red", children: err }, i)) }),
638
+ loading && /* @__PURE__ */ jsx11(Box7, { paddingY: 2, children: /* @__PURE__ */ jsx11(AnimatedText, { name: "radar", speed: 0.6, children: "Loading" }) }),
639
+ currentView === "home" && !loading && /* @__PURE__ */ jsx11(HomeView, { aboutTitle, aboutContent, contentWidth }),
640
+ currentView === "blogList" && !loading && /* @__PURE__ */ jsx11(
631
641
  BlogListView,
632
642
  {
633
643
  posts: blogPosts,
@@ -636,7 +646,7 @@ function App() {
636
646
  viewportHeight: blogListVPHeight
637
647
  }
638
648
  ),
639
- currentView === "blogDetail" && currentPost && /* @__PURE__ */ jsx10(
649
+ currentView === "blogDetail" && currentPost && /* @__PURE__ */ jsx11(
640
650
  BlogDetailView,
641
651
  {
642
652
  post: currentPost,
@@ -645,7 +655,7 @@ function App() {
645
655
  contentWidth
646
656
  }
647
657
  ),
648
- currentView === "portfolioList" && !loading && /* @__PURE__ */ jsx10(
658
+ currentView === "portfolioList" && !loading && /* @__PURE__ */ jsx11(
649
659
  PortfolioListView,
650
660
  {
651
661
  projects: portfolioProjects,
@@ -663,7 +673,7 @@ import { render as inkRender } from "ink";
663
673
  // src/lib/Screen.tsx
664
674
  import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
665
675
  import { Box as Box8, useStdout as useStdout3 } from "ink";
666
- import { jsx as jsx11 } from "react/jsx-runtime";
676
+ import { jsx as jsx12 } from "react/jsx-runtime";
667
677
  function Screen({ children }) {
668
678
  const { stdout } = useStdout3();
669
679
  const getSize = useCallback(() => ({ height: stdout.rows, width: stdout.columns }), [stdout]);
@@ -675,17 +685,17 @@ function Screen({ children }) {
675
685
  stdout.off("resize", onResize);
676
686
  };
677
687
  }, [stdout, getSize]);
678
- return /* @__PURE__ */ jsx11(Box8, { height: size.height, width: size.width, children });
688
+ return /* @__PURE__ */ jsx12(Box8, { height: size.height, width: size.width, children });
679
689
  }
680
690
 
681
691
  // src/lib/render.tsx
682
- import { jsx as jsx12 } from "react/jsx-runtime";
692
+ import { jsx as jsx13 } from "react/jsx-runtime";
683
693
  var ENTER_ALT_BUFFER = "\x1B[?1049h";
684
694
  var EXIT_ALT_BUFFER = "\x1B[?1049l";
685
695
  var CLEAR_SCREEN = "\x1B[2J\x1B[H";
686
696
  function render(node, options) {
687
697
  process.stdout.write(ENTER_ALT_BUFFER + CLEAR_SCREEN);
688
- const element = /* @__PURE__ */ jsx12(Screen, { children: node });
698
+ const element = /* @__PURE__ */ jsx13(Screen, { children: node });
689
699
  const instance = inkRender(element, options);
690
700
  setImmediate(() => instance.rerender(element));
691
701
  const cleanup = () => process.stdout.write(EXIT_ALT_BUFFER);
@@ -706,5 +716,5 @@ function render(node, options) {
706
716
  }
707
717
 
708
718
  // src/cli.tsx
709
- import { jsx as jsx13 } from "react/jsx-runtime";
710
- render(/* @__PURE__ */ jsx13(App, {}));
719
+ import { jsx as jsx14 } from "react/jsx-runtime";
720
+ render(/* @__PURE__ */ jsx14(App, {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",