@flyingrobots/bijou-tui 2.1.0 → 3.1.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 (128) hide show
  1. package/README.md +64 -21
  2. package/dist/animate.d.ts +0 -2
  3. package/dist/animate.d.ts.map +1 -1
  4. package/dist/animate.js +17 -26
  5. package/dist/animate.js.map +1 -1
  6. package/dist/app-frame-actions.d.ts +1 -5
  7. package/dist/app-frame-actions.d.ts.map +1 -1
  8. package/dist/app-frame-actions.js +21 -17
  9. package/dist/app-frame-actions.js.map +1 -1
  10. package/dist/app-frame-render.d.ts +2 -0
  11. package/dist/app-frame-render.d.ts.map +1 -1
  12. package/dist/app-frame-render.js +55 -8
  13. package/dist/app-frame-render.js.map +1 -1
  14. package/dist/app-frame-types.d.ts +9 -0
  15. package/dist/app-frame-types.d.ts.map +1 -1
  16. package/dist/app-frame-types.js +4 -4
  17. package/dist/app-frame-types.js.map +1 -1
  18. package/dist/app-frame.d.ts +39 -2
  19. package/dist/app-frame.d.ts.map +1 -1
  20. package/dist/app-frame.js +195 -31
  21. package/dist/app-frame.js.map +1 -1
  22. package/dist/canvas.d.ts +37 -25
  23. package/dist/canvas.d.ts.map +1 -1
  24. package/dist/canvas.js +116 -30
  25. package/dist/canvas.js.map +1 -1
  26. package/dist/commands.d.ts.map +1 -1
  27. package/dist/commands.js +12 -4
  28. package/dist/commands.js.map +1 -1
  29. package/dist/css/install.d.ts +4 -0
  30. package/dist/css/install.d.ts.map +1 -0
  31. package/dist/css/install.js +24 -0
  32. package/dist/css/install.js.map +1 -0
  33. package/dist/css/parser.d.ts +14 -0
  34. package/dist/css/parser.d.ts.map +1 -0
  35. package/dist/css/parser.js +92 -0
  36. package/dist/css/parser.js.map +1 -0
  37. package/dist/css/resolver.d.ts +36 -0
  38. package/dist/css/resolver.d.ts.map +1 -0
  39. package/dist/css/resolver.js +130 -0
  40. package/dist/css/resolver.js.map +1 -0
  41. package/dist/css/text-style.d.ts +17 -0
  42. package/dist/css/text-style.d.ts.map +1 -0
  43. package/dist/css/text-style.js +59 -0
  44. package/dist/css/text-style.js.map +1 -0
  45. package/dist/css/types.d.ts +27 -0
  46. package/dist/css/types.d.ts.map +1 -0
  47. package/dist/css/types.js +5 -0
  48. package/dist/css/types.js.map +1 -0
  49. package/dist/driver.d.ts +14 -7
  50. package/dist/driver.d.ts.map +1 -1
  51. package/dist/driver.js +38 -17
  52. package/dist/driver.js.map +1 -1
  53. package/dist/eventbus.d.ts +42 -3
  54. package/dist/eventbus.d.ts.map +1 -1
  55. package/dist/eventbus.js +127 -3
  56. package/dist/eventbus.js.map +1 -1
  57. package/dist/focus-area.d.ts +4 -0
  58. package/dist/focus-area.d.ts.map +1 -1
  59. package/dist/focus-area.js +11 -1
  60. package/dist/focus-area.js.map +1 -1
  61. package/dist/index.d.ts +13 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +9 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/layout-v3.d.ts +10 -0
  66. package/dist/layout-v3.d.ts.map +1 -0
  67. package/dist/layout-v3.js +35 -0
  68. package/dist/layout-v3.js.map +1 -0
  69. package/dist/motion/motion.d.ts +14 -0
  70. package/dist/motion/motion.d.ts.map +1 -0
  71. package/dist/motion/motion.js +31 -0
  72. package/dist/motion/motion.js.map +1 -0
  73. package/dist/motion/reconciler.d.ts +15 -0
  74. package/dist/motion/reconciler.d.ts.map +1 -0
  75. package/dist/motion/reconciler.js +109 -0
  76. package/dist/motion/reconciler.js.map +1 -0
  77. package/dist/motion/types.d.ts +52 -0
  78. package/dist/motion/types.d.ts.map +1 -0
  79. package/dist/motion/types.js +2 -0
  80. package/dist/motion/types.js.map +1 -0
  81. package/dist/notification.d.ts +73 -0
  82. package/dist/notification.d.ts.map +1 -0
  83. package/dist/notification.js +693 -0
  84. package/dist/notification.js.map +1 -0
  85. package/dist/overlay.d.ts +3 -1
  86. package/dist/overlay.d.ts.map +1 -1
  87. package/dist/overlay.js.map +1 -1
  88. package/dist/pipeline/middleware/css.d.ts +20 -0
  89. package/dist/pipeline/middleware/css.d.ts.map +1 -0
  90. package/dist/pipeline/middleware/css.js +41 -0
  91. package/dist/pipeline/middleware/css.js.map +1 -0
  92. package/dist/pipeline/middleware/grayscale.d.ts +9 -0
  93. package/dist/pipeline/middleware/grayscale.d.ts.map +1 -0
  94. package/dist/pipeline/middleware/grayscale.js +39 -0
  95. package/dist/pipeline/middleware/grayscale.js.map +1 -0
  96. package/dist/pipeline/middleware/motion.d.ts +6 -0
  97. package/dist/pipeline/middleware/motion.d.ts.map +1 -0
  98. package/dist/pipeline/middleware/motion.js +19 -0
  99. package/dist/pipeline/middleware/motion.js.map +1 -0
  100. package/dist/pipeline/middleware/paint.d.ts +6 -0
  101. package/dist/pipeline/middleware/paint.d.ts.map +1 -0
  102. package/dist/pipeline/middleware/paint.js +21 -0
  103. package/dist/pipeline/middleware/paint.js.map +1 -0
  104. package/dist/pipeline/pipeline.d.ts +56 -0
  105. package/dist/pipeline/pipeline.d.ts.map +1 -0
  106. package/dist/pipeline/pipeline.js +45 -0
  107. package/dist/pipeline/pipeline.js.map +1 -0
  108. package/dist/runtime.d.ts +1 -1
  109. package/dist/runtime.d.ts.map +1 -1
  110. package/dist/runtime.js +180 -18
  111. package/dist/runtime.js.map +1 -1
  112. package/dist/screen.d.ts +12 -1
  113. package/dist/screen.d.ts.map +1 -1
  114. package/dist/screen.js +14 -1
  115. package/dist/screen.js.map +1 -1
  116. package/dist/subapp/mount.d.ts +67 -0
  117. package/dist/subapp/mount.d.ts.map +1 -0
  118. package/dist/subapp/mount.js +60 -0
  119. package/dist/subapp/mount.js.map +1 -0
  120. package/dist/types.d.ts +75 -8
  121. package/dist/types.d.ts.map +1 -1
  122. package/dist/types.js +9 -0
  123. package/dist/types.js.map +1 -1
  124. package/dist/view-output.d.ts +15 -0
  125. package/dist/view-output.d.ts.map +1 -0
  126. package/dist/view-output.js +53 -0
  127. package/dist/view-output.js.map +1 -0
  128. package/package.json +3 -3
package/dist/types.d.ts CHANGED
@@ -7,6 +7,9 @@
7
7
  * @module
8
8
  */
9
9
  import type { BijouContext } from '@flyingrobots/bijou';
10
+ import type { Middleware } from './eventbus.js';
11
+ import type { RenderPipeline } from './pipeline/pipeline.js';
12
+ import type { ViewOutput } from './view-output.js';
10
13
  /** Represent a keyboard input event with key name and modifier flags. */
11
14
  export interface KeyMsg {
12
15
  /** Discriminant tag identifying this as a keyboard message. */
@@ -29,6 +32,13 @@ export interface ResizeMsg {
29
32
  /** New terminal height in rows. */
30
33
  readonly rows: number;
31
34
  }
35
+ /** Represent a system animation pulse event. */
36
+ export interface PulseMsg {
37
+ /** Discriminant tag identifying this as a pulse message. */
38
+ readonly type: 'pulse';
39
+ /** Time delta in seconds since the last pulse. */
40
+ readonly dt: number;
41
+ }
32
42
  /** Mouse button identifier. `"none"` is used for scroll and motion events without a button. */
33
43
  export type MouseButton = 'left' | 'middle' | 'right' | 'none';
34
44
  /** Mouse action type including press, release, move, and scroll directions. */
@@ -66,6 +76,13 @@ export declare function isKeyMsg(msg: unknown): msg is KeyMsg;
66
76
  * @returns `true` if `msg` is a `ResizeMsg`.
67
77
  */
68
78
  export declare function isResizeMsg(msg: unknown): msg is ResizeMsg;
79
+ /**
80
+ * Narrow an unknown message to {@link PulseMsg}.
81
+ *
82
+ * @param msg - Value to test.
83
+ * @returns `true` if `msg` is a `PulseMsg`.
84
+ */
85
+ export declare function isPulseMsg(msg: unknown): msg is PulseMsg;
69
86
  /**
70
87
  * Narrow an unknown message to {@link MouseMsg}.
71
88
  *
@@ -85,7 +102,40 @@ export type QuitSignal = typeof QUIT;
85
102
  *
86
103
  * @template M - Application message type.
87
104
  */
88
- export type Cmd<M> = (emit: (msg: M) => void) => Promise<M | QuitSignal | void>;
105
+ export type Cmd<M> = (emit: (msg: M) => void, capabilities: CmdCapabilities) => Promise<M | QuitSignal | void>;
106
+ /** Capabilities provided to commands by the runtime. */
107
+ export interface CmdCapabilities {
108
+ /**
109
+ * Subscribe to the system animation pulse.
110
+ * Returns a dispose function.
111
+ */
112
+ onPulse(handler: (dt: number) => void): {
113
+ dispose(): void;
114
+ };
115
+ /** Sleep for a bounded amount of time using the runtime clock. */
116
+ sleep?(ms: number): Promise<void>;
117
+ /** Yield to the next microtask using the runtime clock. */
118
+ defer?(): Promise<void>;
119
+ /** Read the current wall-clock time from the runtime clock. */
120
+ now?(): number;
121
+ }
122
+ /** Severity of a runtime issue surfaced by the framework itself. */
123
+ export type RuntimeIssueLevel = 'warning' | 'error';
124
+ /** Origin of a runtime issue surfaced by the framework itself. */
125
+ export type RuntimeIssueSource = 'command' | 'eventbus' | 'runtime';
126
+ /** Framework-level issue routed alongside normal app messages when supported. */
127
+ export interface RuntimeIssue {
128
+ /** Warning or error severity. */
129
+ readonly level: RuntimeIssueLevel;
130
+ /** Subsystem that surfaced the issue. */
131
+ readonly source: RuntimeIssueSource;
132
+ /** Human-readable issue text. */
133
+ readonly message: string;
134
+ /** Runtime clock timestamp for deterministic routing. */
135
+ readonly atMs: number;
136
+ /** Original thrown value when available. */
137
+ readonly error?: unknown;
138
+ }
89
139
  /**
90
140
  * TEA (The Elm Architecture) application interface.
91
141
  *
@@ -105,21 +155,32 @@ export interface App<Model, M = never> {
105
155
  /**
106
156
  * Handle a message and return the updated model with commands.
107
157
  *
108
- * @param msg - Incoming message (key, resize, mouse, or custom).
158
+ * @param msg - Incoming message (key, resize, mouse, pulse, or custom).
109
159
  * @param model - Current application state.
110
160
  * @returns A tuple of `[updatedModel, commands]`.
111
161
  */
112
- update(msg: KeyMsg | ResizeMsg | MouseMsg | M, model: Model): [Model, Cmd<M>[]];
162
+ update(msg: KeyMsg | ResizeMsg | MouseMsg | PulseMsg | M, model: Model): [Model, Cmd<M>[]];
113
163
  /**
114
- * Render the current model as a string for terminal display.
164
+ * Render the current model as a Surface, LayoutNode, or legacy string view.
115
165
  *
116
166
  * @param model - Current application state.
117
- * @returns Rendered string output.
167
+ * @returns Rendered Surface, Layout tree, or legacy string output.
168
+ */
169
+ view(model: Model): ViewOutput;
170
+ /**
171
+ * Optionally translate framework warnings/errors into application messages.
172
+ *
173
+ * This lets higher-level shells surface runtime issues through their own UI
174
+ * while the framework still writes them to stderr as usual.
118
175
  */
119
- view(model: Model): string;
176
+ routeRuntimeIssue?(issue: RuntimeIssue): M | undefined;
120
177
  }
121
- /** Configuration options for the TEA runtime. */
122
- export interface RunOptions {
178
+ /**
179
+ * Configuration options for the TEA runtime.
180
+ *
181
+ * @template M - Custom application message type.
182
+ */
183
+ export interface RunOptions<M = any> {
123
184
  /** Enter the alternate screen buffer on startup. */
124
185
  altScreen?: boolean;
125
186
  /** Hide the cursor on startup. */
@@ -128,5 +189,11 @@ export interface RunOptions {
128
189
  mouse?: boolean;
129
190
  /** Bijou context providing I/O and runtime ports. */
130
191
  ctx?: BijouContext;
192
+ /** Optional middleware to intercept or modify messages. */
193
+ middlewares?: Middleware<M>[];
194
+ /** Optional hook to extend the render pipeline with custom middleware. */
195
+ configurePipeline?: (pipeline: RenderPipeline) => void;
196
+ /** Optional BCSS stylesheet string. */
197
+ css?: string;
131
198
  }
132
199
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD,yEAAyE;AACzE,MAAM,WAAW,MAAM;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED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B,kCAAkC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9B,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IACvD,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
package/dist/types.js CHANGED
@@ -25,6 +25,15 @@ export function isKeyMsg(msg) {
25
25
  export function isResizeMsg(msg) {
26
26
  return typeof msg === 'object' && msg !== null && 'type' in msg && msg.type === 'resize';
27
27
  }
28
+ /**
29
+ * Narrow an unknown message to {@link PulseMsg}.
30
+ *
31
+ * @param msg - Value to test.
32
+ * @returns `true` if `msg` is a `PulseMsg`.
33
+ */
34
+ export function isPulseMsg(msg) {
35
+ return typeof msg === 'object' && msg !== null && 'type' in msg && msg.type === 'pulse';
36
+ }
28
37
  /**
29
38
  * Narrow an unknown message to {@link MouseMsg}.
30
39
  *
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0DH,sBAAsB;AAEtB;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,MAAM,IAAI,GAAG,IAAK,GAAc,CAAC,IAAI,KAAK,KAAK,CAAC;AACpG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,MAAM,IAAI,GAAG,IAAK,GAAiB,CAAC,IAAI,KA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,MAAM,IAAI,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type LayoutNode, type Surface } from '@flyingrobots/bijou';
2
+ export type ViewOutput = Surface | LayoutNode | string;
3
+ export interface ViewportSize {
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface NormalizedViewOutput {
8
+ kind: 'surface' | 'layout' | 'string';
9
+ legacyString: boolean;
10
+ surface: Surface;
11
+ }
12
+ export declare function isSurfaceView(value: unknown): value is Surface;
13
+ export declare function normalizeViewOutput(output: ViewOutput, size: ViewportSize): NormalizedViewOutput;
14
+ export declare function wrapViewOutputAsLayoutRoot(output: ViewOutput, size: ViewportSize): LayoutNode;
15
+ //# sourceMappingURL=view-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-output.d.ts","sourceRoot":"","sources":["../src/view-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE9D;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,YAAY,GACjB,oBAAoB,CAsBtB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,YAAY,GACjB,UAAU,CAqBZ"}
@@ -0,0 +1,53 @@
1
+ import { createSurface, paintLayoutNode, parseAnsiToSurface, } from '@flyingrobots/bijou';
2
+ export function isSurfaceView(value) {
3
+ return typeof value === 'object' && value !== null && 'cells' in value;
4
+ }
5
+ export function normalizeViewOutput(output, size) {
6
+ if (typeof output === 'string') {
7
+ return {
8
+ kind: 'string',
9
+ legacyString: true,
10
+ surface: parseAnsiToSurface(output, size.width, size.height),
11
+ };
12
+ }
13
+ if (isSurfaceView(output)) {
14
+ return {
15
+ kind: 'surface',
16
+ legacyString: false,
17
+ surface: output,
18
+ };
19
+ }
20
+ return {
21
+ kind: 'layout',
22
+ legacyString: false,
23
+ surface: paintViewLayout(output, size),
24
+ };
25
+ }
26
+ export function wrapViewOutputAsLayoutRoot(output, size) {
27
+ if (typeof output === 'string') {
28
+ return {
29
+ type: 'LegacyTextView',
30
+ classes: ['legacy-view'],
31
+ rect: { x: 0, y: 0, width: size.width, height: size.height },
32
+ children: [],
33
+ surface: parseAnsiToSurface(output, size.width, size.height),
34
+ };
35
+ }
36
+ if (isSurfaceView(output)) {
37
+ return {
38
+ type: 'SurfaceView',
39
+ rect: { x: 0, y: 0, width: output.width, height: output.height },
40
+ children: [],
41
+ surface: output,
42
+ };
43
+ }
44
+ return output;
45
+ }
46
+ function paintViewLayout(node, size) {
47
+ const width = Math.max(size.width, node.rect.x + node.rect.width, 0);
48
+ const height = Math.max(size.height, node.rect.y + node.rect.height, 0);
49
+ const surface = createSurface(width, height);
50
+ paintLayoutNode(surface, node);
51
+ return surface;
52
+ }
53
+ //# sourceMappingURL=view-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-output.js","sourceRoot":"","sources":["../src/view-output.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,kBAAkB,GAGnB,MAAM,qBAAqB,CAAC;AAe7B,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC;AACz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,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAChE,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,IAAgB,EAAE,IAAkB;IAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flyingrobots/bijou-tui",
3
- "version": "2.1.0",
4
- "description": "TEA runtime for terminal UIs \u2014 model/update/view with keyboard input, alt screen, and layout helpers.",
3
+ "version": "3.1.0",
4
+ "description": "TEA runtime for terminal UIs model/update/view with keyboard input, alt screen, and layout helpers.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "lint": "tsc --noEmit"
25
25
  },
26
26
  "peerDependencies": {
27
- "@flyingrobots/bijou": "2.1.0"
27
+ "@flyingrobots/bijou": "3.1.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^22.0.0",