zion 2.0.5 → 2.2.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 +109 -21
  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 Box6, Text as Text8, 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";
@@ -24,7 +24,8 @@ var NAV_LINKS = [
24
24
  var COLORS = {
25
25
  subtle: "gray",
26
26
  text: "white",
27
- selectedBlog: "#006f3c"
27
+ selectedBlog: "#006f3c",
28
+ link: "#5c9fd4"
28
29
  };
29
30
 
30
31
  // src/components/HintBar.tsx
@@ -187,6 +188,9 @@ function loadBlogPostList() {
187
188
  function loadBlogPost(slug) {
188
189
  return fetchJson(`${BASE_URL}/api/posts/${slug}`);
189
190
  }
191
+ function loadPortfolioList() {
192
+ return fetchJson(`${BASE_URL}/api/portfolio`);
193
+ }
190
194
  function formatDate(dateStr) {
191
195
  const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
192
196
  return date.toLocaleDateString("en-US", {
@@ -221,7 +225,7 @@ function HomeView({ aboutTitle, aboutContent, contentWidth }) {
221
225
  return /* @__PURE__ */ jsxs4(Fragment3, { children: [
222
226
  /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(Text5, { bold: true, color: "white", children: aboutTitle }) }),
223
227
  /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(Markdown, { width: contentWidth, children: aboutContent }) }),
224
- /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(HintBar, { text: "Hint: b: blog | q, ctrl+c: quit" }) })
228
+ /* @__PURE__ */ jsx5(Box4, { marginTop: 1, children: /* @__PURE__ */ jsx5(HintBar, { text: "Hint: b: blog | p: portfolio | q, ctrl+c: quit" }) })
225
229
  ] });
226
230
  }
227
231
 
@@ -236,11 +240,59 @@ function NavBar() {
236
240
  ] }, link.name)) });
237
241
  }
238
242
 
243
+ // src/components/PortfolioListView.tsx
244
+ import { Box as Box6, Text as Text9 } from "ink";
245
+ import { ScrollView as ScrollView3 } from "ink-scroll-view";
246
+
247
+ // src/components/ui/Badge.tsx
248
+ import { Text as Text7 } from "ink";
249
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
250
+ function Badge({ color, background, children }) {
251
+ return /* @__PURE__ */ jsxs6(Fragment4, { children: [
252
+ /* @__PURE__ */ jsx7(Text7, { color: background, children: "\uE0B6" }),
253
+ /* @__PURE__ */ jsx7(Text7, { color, backgroundColor: background, bold: true, children }),
254
+ /* @__PURE__ */ jsx7(Text7, { color: background, children: "\uE0B4" })
255
+ ] });
256
+ }
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
+
266
+ // src/components/PortfolioListView.tsx
267
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
268
+ function PortfolioListView({ projects, highlightedIndex, scrollRef, viewportHeight }) {
269
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
270
+ /* @__PURE__ */ jsx9(Box6, { marginTop: 1, height: viewportHeight, flexDirection: "column", children: /* @__PURE__ */ jsx9(ScrollView3, { ref: scrollRef, children: projects.map((project, idx) => {
271
+ const isSelected = idx === highlightedIndex;
272
+ const prefix = isSelected ? "\u203A " : " ";
273
+ return /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", marginBottom: 2, children: [
274
+ /* @__PURE__ */ jsxs7(Box6, { flexDirection: "row", children: [
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 }) })
278
+ ] }),
279
+ /* @__PURE__ */ jsx9(Box6, { marginLeft: 3, paddingBottom: 1, children: /* @__PURE__ */ jsxs7(Text9, { color: COLORS.subtle, children: [
280
+ project.description,
281
+ " "
282
+ ] }) }),
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)) })
285
+ ] }, idx);
286
+ }) }) }),
287
+ /* @__PURE__ */ jsx9(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx9(HintBar, { text: "Hint: h/j/k: back, down, up | q: quit" }) })
288
+ ] });
289
+ }
290
+
239
291
  // src/components/ui/AnimatedText.tsx
240
292
  import chalk from "chalk";
241
293
  import { useEffect as useEffect2, useState } from "react";
242
- import { Text as Text7 } from "ink";
243
- import { jsx as jsx7 } from "react/jsx-runtime";
294
+ import { Text as Text10 } from "ink";
295
+ import { jsx as jsx10 } from "react/jsx-runtime";
244
296
  function hexToRgb(hex) {
245
297
  const h = hex.replace("#", "");
246
298
  const n = h.length === 3 ? parseInt(h[0] + h[0] + h[1] + h[1] + h[2] + h[2], 16) : parseInt(h, 16);
@@ -396,7 +448,7 @@ function AnimatedText({
396
448
  if (underline) animated = chalk.underline(animated);
397
449
  if (strikethrough) animated = chalk.strikethrough(animated);
398
450
  if (dimColor) animated = chalk.dim(animated);
399
- return /* @__PURE__ */ jsx7(Text7, { children: animated });
451
+ return /* @__PURE__ */ jsx10(Text10, { children: animated });
400
452
  }
401
453
 
402
454
  // src/hooks/useListNavigation.ts
@@ -450,7 +502,7 @@ function useListNavigation({ length, onSelect, isActive }) {
450
502
  }
451
503
 
452
504
  // src/app.tsx
453
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
505
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
454
506
  function App() {
455
507
  const { exit } = useApp();
456
508
  const { stdout } = useStdout2();
@@ -462,6 +514,7 @@ function App() {
462
514
  const [aboutContent, setAboutContent] = useState3("");
463
515
  const [blogPosts, setBlogPosts] = useState3([]);
464
516
  const [currentPost, setCurrentPost] = useState3(null);
517
+ const [portfolioProjects, setPortfolioProjects] = useState3([]);
465
518
  const [loading, setLoading] = useState3("about");
466
519
  const detailScrollRef = useRef2(null);
467
520
  const addError = (key, message) => setErrors((prev) => ({ ...prev, [key]: message }));
@@ -489,6 +542,10 @@ function App() {
489
542
  });
490
543
  }
491
544
  });
545
+ const portfolioList = useListNavigation({
546
+ length: portfolioProjects.length,
547
+ isActive: currentView === "portfolioList"
548
+ });
492
549
  useEffect4(() => {
493
550
  loadAboutContent().then((result) => {
494
551
  setLoading(null);
@@ -504,6 +561,7 @@ function App() {
504
561
  const contentWidth = Math.max(Math.min(Math.floor(columns * 2 / 3), 80), 40);
505
562
  const blogListVPHeight = Math.min(blogPosts.length, Math.min(Math.floor(rows / 2), 20));
506
563
  const blogDetailVPHeight = Math.min(Math.floor(rows / 2), 25);
564
+ const portfolioListVPHeight = Math.min(Math.floor(rows / 2), 20);
507
565
  const visibleErrors = [];
508
566
  if (currentView === "home" && errors.about) visibleErrors.push(errors.about);
509
567
  if (currentView === "blogList") {
@@ -511,6 +569,7 @@ function App() {
511
569
  if (errors.post) visibleErrors.push(errors.post);
512
570
  }
513
571
  if (currentView === "blogDetail" && errors.post) visibleErrors.push(errors.post);
572
+ if (currentView === "portfolioList" && errors.portfolio) visibleErrors.push(errors.portfolio);
514
573
  useInput2((input, key) => {
515
574
  if (input === "q" || key.ctrl && input === "c") {
516
575
  exit();
@@ -533,6 +592,21 @@ function App() {
533
592
  }
534
593
  });
535
594
  }
595
+ } else if (input === "p") {
596
+ setCurrentView("portfolioList");
597
+ portfolioList.reset();
598
+ if (portfolioProjects.length === 0) {
599
+ setLoading("portfolio");
600
+ loadPortfolioList().then((result) => {
601
+ setLoading(null);
602
+ if (result.ok) {
603
+ clearError("portfolio");
604
+ setPortfolioProjects(result.data);
605
+ } else {
606
+ addError("portfolio", result.error);
607
+ }
608
+ });
609
+ }
536
610
  }
537
611
  break;
538
612
  case "blogList":
@@ -540,6 +614,11 @@ function App() {
540
614
  setCurrentView("home");
541
615
  }
542
616
  break;
617
+ case "portfolioList":
618
+ if (input === "h") {
619
+ setCurrentView("home");
620
+ }
621
+ break;
543
622
  case "blogDetail":
544
623
  if (input === "h") {
545
624
  setCurrentView("blogList");
@@ -552,12 +631,12 @@ function App() {
552
631
  break;
553
632
  }
554
633
  });
555
- return /* @__PURE__ */ jsx8(Box6, { width: columns, height: rows, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", width: contentWidth, children: [
556
- /* @__PURE__ */ jsx8(NavBar, {}),
557
- visibleErrors.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginTop: 1, flexDirection: "column", children: visibleErrors.map((err, i) => /* @__PURE__ */ jsx8(Text8, { color: "red", children: err }, i)) }),
558
- loading && /* @__PURE__ */ jsx8(Box6, { paddingY: 2, children: /* @__PURE__ */ jsx8(AnimatedText, { name: "radar", speed: 0.6, children: "Loading" }) }),
559
- currentView === "home" && !loading && /* @__PURE__ */ jsx8(HomeView, { aboutTitle, aboutContent, contentWidth }),
560
- currentView === "blogList" && !loading && /* @__PURE__ */ jsx8(
634
+ return /* @__PURE__ */ jsx11(Box7, { width: columns, height: rows, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", width: contentWidth, children: [
635
+ /* @__PURE__ */ jsx11(NavBar, {}),
636
+ visibleErrors.length > 0 && /* @__PURE__ */ jsx11(Box7, { marginTop: 1, flexDirection: "column", children: visibleErrors.map((err, i) => /* @__PURE__ */ jsx11(Text11, { color: "red", children: err }, i)) }),
637
+ loading && /* @__PURE__ */ jsx11(Box7, { paddingY: 2, children: /* @__PURE__ */ jsx11(AnimatedText, { name: "radar", speed: 0.6, children: "Loading" }) }),
638
+ currentView === "home" && !loading && /* @__PURE__ */ jsx11(HomeView, { aboutTitle, aboutContent, contentWidth }),
639
+ currentView === "blogList" && !loading && /* @__PURE__ */ jsx11(
561
640
  BlogListView,
562
641
  {
563
642
  posts: blogPosts,
@@ -566,7 +645,7 @@ function App() {
566
645
  viewportHeight: blogListVPHeight
567
646
  }
568
647
  ),
569
- currentView === "blogDetail" && currentPost && /* @__PURE__ */ jsx8(
648
+ currentView === "blogDetail" && currentPost && /* @__PURE__ */ jsx11(
570
649
  BlogDetailView,
571
650
  {
572
651
  post: currentPost,
@@ -574,6 +653,15 @@ function App() {
574
653
  viewportHeight: blogDetailVPHeight,
575
654
  contentWidth
576
655
  }
656
+ ),
657
+ currentView === "portfolioList" && !loading && /* @__PURE__ */ jsx11(
658
+ PortfolioListView,
659
+ {
660
+ projects: portfolioProjects,
661
+ highlightedIndex: portfolioList.highlightedIndex,
662
+ scrollRef: portfolioList.scrollRef,
663
+ viewportHeight: portfolioListVPHeight
664
+ }
577
665
  )
578
666
  ] }) });
579
667
  }
@@ -583,8 +671,8 @@ import { render as inkRender } from "ink";
583
671
 
584
672
  // src/lib/Screen.tsx
585
673
  import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
586
- import { Box as Box7, useStdout as useStdout3 } from "ink";
587
- import { jsx as jsx9 } from "react/jsx-runtime";
674
+ import { Box as Box8, useStdout as useStdout3 } from "ink";
675
+ import { jsx as jsx12 } from "react/jsx-runtime";
588
676
  function Screen({ children }) {
589
677
  const { stdout } = useStdout3();
590
678
  const getSize = useCallback(() => ({ height: stdout.rows, width: stdout.columns }), [stdout]);
@@ -596,17 +684,17 @@ function Screen({ children }) {
596
684
  stdout.off("resize", onResize);
597
685
  };
598
686
  }, [stdout, getSize]);
599
- return /* @__PURE__ */ jsx9(Box7, { height: size.height, width: size.width, children });
687
+ return /* @__PURE__ */ jsx12(Box8, { height: size.height, width: size.width, children });
600
688
  }
601
689
 
602
690
  // src/lib/render.tsx
603
- import { jsx as jsx10 } from "react/jsx-runtime";
691
+ import { jsx as jsx13 } from "react/jsx-runtime";
604
692
  var ENTER_ALT_BUFFER = "\x1B[?1049h";
605
693
  var EXIT_ALT_BUFFER = "\x1B[?1049l";
606
694
  var CLEAR_SCREEN = "\x1B[2J\x1B[H";
607
695
  function render(node, options) {
608
696
  process.stdout.write(ENTER_ALT_BUFFER + CLEAR_SCREEN);
609
- const element = /* @__PURE__ */ jsx10(Screen, { children: node });
697
+ const element = /* @__PURE__ */ jsx13(Screen, { children: node });
610
698
  const instance = inkRender(element, options);
611
699
  setImmediate(() => instance.rerender(element));
612
700
  const cleanup = () => process.stdout.write(EXIT_ALT_BUFFER);
@@ -627,5 +715,5 @@ function render(node, options) {
627
715
  }
628
716
 
629
717
  // src/cli.tsx
630
- import { jsx as jsx11 } from "react/jsx-runtime";
631
- render(/* @__PURE__ */ jsx11(App, {}));
718
+ import { jsx as jsx14 } from "react/jsx-runtime";
719
+ render(/* @__PURE__ */ jsx14(App, {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "2.0.5",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",