create-rezi 0.1.0-alpha.30 → 0.1.0-alpha.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rezi",
3
- "version": "0.1.0-alpha.30",
3
+ "version": "0.1.0-alpha.31",
4
4
  "description": "Scaffold a Rezi terminal UI app.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://rezitui.dev",
@@ -28,6 +28,6 @@
28
28
  "bun": ">=1.3.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@rezi-ui/testkit": "0.1.0-alpha.30"
31
+ "@rezi-ui/testkit": "0.1.0-alpha.31"
32
32
  }
33
33
  }
@@ -1,6 +1,5 @@
1
1
  import { exit } from "node:process";
2
- import { createApp } from "@rezi-ui/core";
3
- import { createNodeBackend } from "@rezi-ui/node";
2
+ import { createNodeApp } from "@rezi-ui/node";
4
3
  import { resolveAnimationLabCommand } from "./helpers/keybindings.js";
5
4
  import { createInitialState, reduceAnimationLabState } from "./helpers/state.js";
6
5
  import { renderReactorLab } from "./screens/reactor-lab.js";
@@ -11,16 +10,12 @@ function describeThrown(error: unknown): string {
11
10
  return String(error);
12
11
  }
13
12
 
14
- const app = createApp({
15
- backend: createNodeBackend({
16
- fpsCap: 30,
17
- executionMode: "inline",
18
- }),
13
+ const app = createNodeApp({
19
14
  initialState: createInitialState({
20
15
  cols: typeof process.stdout.columns === "number" ? process.stdout.columns : 96,
21
16
  rows: typeof process.stdout.rows === "number" ? process.stdout.rows : 32,
22
17
  }),
23
- config: { fpsCap: 30 },
18
+ config: { fpsCap: 30, executionMode: "inline" },
24
19
  });
25
20
 
26
21
  function dispatch(action: AnimationLabAction): void {
@@ -14,42 +14,56 @@ type ScreenHandlers = Readonly<{
14
14
  export function renderMainScreen(state: MinimalState, handlers: ScreenHandlers): VNode {
15
15
  const theme = themeSpec(state.themeName);
16
16
 
17
- const content = ui.column({ p: 1, gap: 1 }, [
18
- ui.box({ border: "rounded", px: 1, py: 0 }, [
19
- ui.column({ gap: 1 }, [
20
- ui.row({ gap: 1, wrap: true }, [
21
- ui.text(PRODUCT_NAME, { variant: "heading" }),
22
- ui.badge(TEMPLATE_LABEL, { variant: "info" }),
23
- ui.tag(`Theme ${theme.label}`, { variant: theme.badge }),
24
- ]),
25
- ui.text(PRODUCT_TAGLINE),
26
- ]),
27
- ]),
28
-
29
- ui.box({ title: "Counter", border: "rounded", px: 1, py: 0 }, [
30
- ui.column({ gap: 1 }, [
31
- ui.text(`Count: ${String(state.count)}`, { variant: "heading" }),
32
- ui.row({ gap: 1, wrap: true }, [
33
- ui.button({ id: "dec", label: "-1", onPress: handlers.onDecrement }),
34
- ui.button({ id: "inc", label: "+1", onPress: handlers.onIncrement }),
35
- ui.button({ id: "theme", label: "Cycle Theme", onPress: handlers.onCycleTheme }),
36
- ui.button({ id: "help", label: "Help", onPress: handlers.onToggleHelp }),
17
+ const content = ui.page({
18
+ p: 1,
19
+ gap: 1,
20
+ header: ui.header({
21
+ title: PRODUCT_NAME,
22
+ subtitle: PRODUCT_TAGLINE,
23
+ actions: [
24
+ ui.badge(TEMPLATE_LABEL, { variant: "info" }),
25
+ ui.tag(`Theme ${theme.label}`, { variant: theme.badge }),
26
+ ],
27
+ }),
28
+ body: ui.column({ gap: 1 }, [
29
+ ui.panel("Counter", [
30
+ ui.column({ gap: 1 }, [
31
+ ui.text(`Count: ${String(state.count)}`, { variant: "heading" }),
32
+ ui.toolbar({ gap: 1 }, [
33
+ ui.button({ id: "dec", label: "-1", onPress: handlers.onDecrement }),
34
+ ui.button({
35
+ id: "inc",
36
+ label: "+1",
37
+ intent: "primary",
38
+ onPress: handlers.onIncrement,
39
+ }),
40
+ ui.button({ id: "theme", label: "Cycle Theme", onPress: handlers.onCycleTheme }),
41
+ ui.button({ id: "help", label: "Help", intent: "link", onPress: handlers.onToggleHelp }),
42
+ ]),
37
43
  ]),
38
44
  ]),
45
+ state.lastError
46
+ ? ui.panel("Alerts", [
47
+ ui.callout(state.lastError, {
48
+ title: "Example Error Pattern",
49
+ variant: "error",
50
+ }),
51
+ ui.actions([
52
+ ui.button({
53
+ id: "clear-error",
54
+ label: "Clear",
55
+ intent: "danger",
56
+ onPress: handlers.onClearError,
57
+ }),
58
+ ]),
59
+ ])
60
+ : ui.panel("Status", [ui.text("No runtime error. Press e to simulate one.")]),
39
61
  ]),
40
-
41
- state.lastError
42
- ? ui.column({ gap: 1 }, [
43
- ui.callout(state.lastError, {
44
- title: "Example Error Pattern",
45
- variant: "error",
46
- }),
47
- ui.button({ id: "clear-error", label: "Clear", onPress: handlers.onClearError }),
48
- ])
49
- : ui.text("No runtime error. Press e to simulate one."),
50
-
51
- ui.text("Keys: q quit · ? help · +/- counter · t theme · e error"),
52
- ]);
62
+ footer: ui.statusBar({
63
+ left: [ui.status("online"), ui.text("Ready")],
64
+ right: [ui.text("Keys: q quit · ? help · +/- counter · t theme · e error")],
65
+ }),
66
+ });
53
67
 
54
68
  if (!state.showHelp) return content;
55
69
 
@@ -3,7 +3,6 @@ import { devNull, tmpdir } from "node:os";
3
3
  import * as path from "node:path";
4
4
  import type { BadgeVariant, RichTextSpan, TextStyle, ThemeDefinition, VNode } from "@rezi-ui/core";
5
5
  import {
6
- createApp,
7
6
  darkTheme,
8
7
  dimmedTheme,
9
8
  draculaTheme,
@@ -13,7 +12,7 @@ import {
13
12
  rgb,
14
13
  ui,
15
14
  } from "@rezi-ui/core";
16
- import { createNodeBackend } from "@rezi-ui/node";
15
+ import { type NodeBackend, createNodeApp } from "@rezi-ui/node";
17
16
 
18
17
  // ---------------------------------------------------------------------------
19
18
  // Types
@@ -693,7 +692,7 @@ let _lastViewMs = 0;
693
692
 
694
693
  let _backendPerfInFlight = false;
695
694
  let _lastBackendPerfSampleMs = 0;
696
- let _backend: ReturnType<typeof createNodeBackend> | null = null;
695
+ let _backend: NodeBackend | null = null;
697
696
 
698
697
  let _memoryBallast: Buffer[] = [];
699
698
  let _memoryBallastBytes = 0;
@@ -976,16 +975,10 @@ function simulateTick(state: State, nowMs: number): State {
976
975
  // ---------------------------------------------------------------------------
977
976
 
978
977
  const initialNowMs = Date.now();
979
- const backend = createNodeBackend({
980
- fpsCap: UI_FPS_CAP,
981
- executionMode: "worker",
982
- });
983
- _backend = backend;
984
-
985
- const app = createApp<State>({
986
- backend,
978
+ const app = createNodeApp<State>({
987
979
  config: {
988
980
  fpsCap: UI_FPS_CAP,
981
+ executionMode: "worker",
989
982
  internal_onRender: (metrics) => {
990
983
  _lastRenderMs = round2(metrics.renderTime);
991
984
  },
@@ -1037,6 +1030,8 @@ const app = createApp<State>({
1037
1030
  },
1038
1031
  });
1039
1032
 
1033
+ _backend = app.backend;
1034
+
1040
1035
  // ---------------------------------------------------------------------------
1041
1036
  // Actions
1042
1037
  // ---------------------------------------------------------------------------