@valyrianjs/terminal 0.1.2 → 0.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export type { TerminalBoxProps, TerminalButtonPressEventPayload, TerminalButtonProps, TerminalChangeEventPayload, TerminalCommand, TerminalCommandContext, TerminalCommandId, TerminalCommandScope, InputInteractionState, TerminalClipboardAdapter, TerminalCaptureEventPayload, TerminalDirectiveProps, TerminalElementNode, TerminalEditorCancelEventPayload, TerminalEditorChangeEventPayload, TerminalEditorProps, TerminalEditorSubmitEventPayload, TerminalFrame, TerminalHitbox, TerminalInputChangeEventPayload, TerminalInputProps, TerminalInputSubmitEventPayload, TerminalKeyBinding, TerminalKeyBindingCondition, TerminalKeymapOptions, TerminalListPointerEventPayload, TerminalListChangeEventPayload, TerminalListProps, TerminalListPressEventPayload, TerminalLayoutProps, TerminalLogViewEntry, TerminalLogViewProps, TerminalMountOptions, TerminalMouseEventType, TerminalNode, TerminalOverlayProps, TerminalOutputStream, TerminalPaneProps, TerminalPointerCoordinates, TerminalPointerCaptureProps, TerminalPressEventPayload, TerminalPointerSource, TerminalRowPointerEventPayload, TerminalRowPointerEventPayloadBase, TerminalRowProps, TerminalScreenProps, TerminalScrollPointerEventPayload, TerminalScrollViewProps, TerminalSemanticStyleKind, TerminalSession, TerminalSize, TerminalSplitBreakpoint, TerminalSplitProps, TerminalSplitSize, TerminalStyleSpan, TerminalStyleToken, TerminalStyleDefinition, TerminalStyleProps, TerminalStyleReference, TerminalStyleTree, TerminalStyleValue, TerminalStateStyles, TerminalVisualState, TerminalColor, TerminalSpacing, TerminalBorder, TerminalBorderStyle, TerminalTableProps, TerminalTdProps, TerminalTheme, TerminalTextProps, TerminalValueEventPayloadBase, TerminalFocusableProps, TerminalEventPayloadBase, TerminalFocusScopeProps, TerminalFixedProps, TerminalViewProps, TerminalTextNode } from "./types.js";
1
+ export type { TerminalBoxProps, TerminalButtonPressEventPayload, TerminalButtonProps, TerminalChangeEventPayload, TerminalCommand, TerminalCommandContext, TerminalCommandId, TerminalCommandScope, InputInteractionState, TerminalClipboardAdapter, TerminalCaptureEventPayload, TerminalDirectiveProps, TerminalElementNode, TerminalEditorCancelEventPayload, TerminalEditorChangeEventPayload, TerminalEditorProps, TerminalEditorSubmitEventPayload, TerminalFrame, TerminalHitbox, TerminalInputChangeEventPayload, TerminalInputContextPressEventPayload, TerminalInputProps, TerminalInputSubmitEventPayload, TerminalKeyBinding, TerminalKeyBindingCondition, TerminalKeymapOptions, TerminalListPointerEventPayload, TerminalListChangeEventPayload, TerminalListProps, TerminalListPressEventPayload, TerminalLayoutProps, TerminalLogViewEntry, TerminalLogViewProps, TerminalMountOptions, TerminalMouseEventType, TerminalNode, TerminalOverlayProps, TerminalOutputStream, TerminalPaneProps, TerminalPointerCoordinates, TerminalPointerCaptureProps, TerminalPressEventPayload, TerminalPointerSource, TerminalRowPointerEventPayload, TerminalRowPointerEventPayloadBase, TerminalRowProps, TerminalScreenProps, TerminalScrollPointerEventPayload, TerminalScrollContextPressEventPayload, TerminalScrollViewProps, TerminalSemanticStyleKind, TerminalSession, TerminalSize, TerminalSplitBreakpoint, TerminalSplitProps, TerminalSplitSize, TerminalStyleSpan, TerminalStyleToken, TerminalStyleDefinition, TerminalStyleProps, TerminalStyleReference, TerminalStyleTree, TerminalStyleValue, TerminalStateStyles, TerminalVisualState, TerminalColor, TerminalSpacing, TerminalBorder, TerminalBorderStyle, TerminalTableProps, TerminalTdProps, TerminalTheme, TerminalTextProps, TerminalValueEventPayloadBase, TerminalFocusableProps, TerminalEventPayloadBase, TerminalFocusScopeProps, TerminalFixedProps, TerminalViewProps, TerminalTextNode } from "./types.js";
2
2
  export { Box, Button, Editor, Fixed, FocusScope, Input, List, LogView, Overlay, Pane, Row, Screen, ScrollView, Split, Table, Td, Text, View } from "./primitives.js";
3
3
  export { createResolvedTerminalKeymap, createTerminalKeyBindings, defaultTerminalKeyBindings, resolveTerminalKeyBinding, validateTerminalKeyBindings } from "./keymap.js";
4
4
  export { defaultTerminalTheme, highContrastTerminalTheme, mergeTerminalTheme, resolveTerminalStyle, resolveTerminalStyleToken } from "./theme.js";
5
5
  export { renderTerminal } from "./render.js";
6
+ export type { TerminalRenderContext } from "./render.js";
6
7
  export { mountTerminal } from "./session.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,+BAA+B,EAC/B,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,EACnB,gCAAgC,EAChC,gCAAgC,EAChC,mBAAmB,EACnB,gCAAgC,EAChC,aAAa,EACb,cAAc,EACd,+BAA+B,EAC/B,kBAAkB,EAClB,+BAA+B,EAC/B,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,+BAA+B,EAC/B,8BAA8B,EAC9B,iBAAiB,EACjB,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACrB,8BAA8B,EAC9B,kCAAkC,EAClC,gBAAgB,EAChB,mBAAmB,EACnB,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EACzB,eAAe,EACf,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,mB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AE,kBAAkB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiFA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACrK,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmFA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACrK,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -1,5 +1,10 @@
1
- import type { AnyProps, TerminalBoxProps, TerminalButtonProps, TerminalEditorProps, TerminalFocusScopeProps, TerminalFixedProps, TerminalInputProps, TerminalListProps, TerminalLogViewProps, TerminalOverlayProps, TerminalPaneProps, TerminalRowProps, TerminalScreenProps, TerminalScrollViewProps, TerminalSplitProps, TerminalTableProps, TerminalTdProps, TerminalTextProps, TerminalViewProps } from "./types.js";
2
- type TerminalPrimitiveComponent<P> = (props: P | AnyProps, children: any[]) => any;
1
+ import type { TerminalBoxProps, TerminalButtonProps, TerminalEditorProps, TerminalFocusScopeProps, TerminalFixedProps, TerminalInputProps, TerminalListProps, TerminalLogViewProps, TerminalOverlayProps, TerminalPaneProps, TerminalRowProps, TerminalScreenProps, TerminalScrollViewProps, TerminalSplitProps, TerminalTableProps, TerminalTdProps, TerminalTextProps, TerminalViewProps } from "./types.js";
2
+ type TerminalPrimitiveComponentProps<P> = P & {
3
+ children?: any;
4
+ key?: any;
5
+ };
6
+ type TerminalPrimitiveComponent<P> = (props: TerminalPrimitiveComponentProps<P>, children: any[]) => any;
7
+ type TerminalListComponent = <T>(props: TerminalPrimitiveComponentProps<TerminalListProps<T>>, children: any[]) => any;
3
8
  export declare const Screen: TerminalPrimitiveComponent<TerminalScreenProps>;
4
9
  export declare const Box: TerminalPrimitiveComponent<TerminalBoxProps>;
5
10
  export declare const View: TerminalPrimitiveComponent<TerminalViewProps>;
@@ -14,7 +19,7 @@ export declare const Editor: TerminalPrimitiveComponent<TerminalEditorProps>;
14
19
  export declare const Button: TerminalPrimitiveComponent<TerminalButtonProps>;
15
20
  export declare const ScrollView: TerminalPrimitiveComponent<TerminalScrollViewProps>;
16
21
  export declare const LogView: TerminalPrimitiveComponent<TerminalLogViewProps>;
17
- export declare const List: TerminalPrimitiveComponent<TerminalListProps<any>>;
22
+ export declare const List: TerminalListComponent;
18
23
  export declare const Table: TerminalPrimitiveComponent<TerminalTableProps>;
19
24
  export declare const Row: TerminalPrimitiveComponent<TerminalRowProps>;
20
25
  export declare const Td: TerminalPrimitiveComponent<TerminalTdProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EAEjB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,KAAK,0BAA0B,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AASnF,eAAO,MAAM,MAAM,iDAAoD,CAAC;AACxE,eAAO,MAAM,GAAG,8CAA8C,CAAC;AAC/D,eAAO,MAAM,IAAI,+CAAgD,CAAC;AAClE,eAAO,MAAM,IAAI,+CAAgD,CAAC;AAClE,eAAO,MAAM,KAAK,gDAAkD,CAAC;AACrE,eAAO,MAAM,KAAK,gDAAkD,CAAC;AACrE,eAAO,MAAM,OAAO,kDAAsD,CAAC;AAC3E,eAAO,MAAM,UAAU,qDAA6D,CAAC;AACrF,eAAO,MAAM,IAAI,+CAAgD,CAAC;AAClE,eAAO,MAAM,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K,GAAG,SAAS,CAAqB,gBAAgB,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAmB,cAAc,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,EAAE,GAAG,SAAS,CAAkB,aAAa,CAAC,CAAC"}
package/dist/render.d.ts CHANGED
@@ -6,5 +6,5 @@ export interface TerminalRenderContext {
6
6
  }
7
7
  export declare function renderTerminalFrame(node: TerminalNode, context?: TerminalRenderContext): TerminalFrame;
8
8
  export declare function renderTerminalNode(node: TerminalNode, context?: TerminalRenderContext): string;
9
- export declare function renderTerminal(input: any): string;
9
+ export declare function renderTerminal(input: any, context?: TerminalRenderContext): string;
10
10
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAiE,aAAa,EAAE,YAAY,EAA2G,aAAa,EAAuB,MAAM,YAAY,CAAC;AAE1Q,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAmjCD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,aAAa,CAKtG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAE9F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAMjD"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAiE,aAAa,EAAE,YAAY,EAA2G,aAAa,EAAuB,MAAM,YAAY,CAAC;AAE1Q,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAmpCD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,aAAa,CAKtG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAE9F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAOlF"}
package/dist/render.js CHANGED
@@ -5,6 +5,22 @@ import { isFocusable, textContent } from "./tree.js";
5
5
  import { renderValyrianTerminal } from "./runtime.js";
6
6
  import { plainText } from "./text.js";
7
7
  import { resolveTerminalStyle } from "./theme.js";
8
+ function validateRenderContextDimension(name, value) {
9
+ if (!Number.isInteger(value) || value < 1) {
10
+ throw new RangeError(`Invalid render context ${name}: expected an integer >= 1`);
11
+ }
12
+ return value;
13
+ }
14
+ function validateRenderContext(context) {
15
+ if (typeof context === "undefined") {
16
+ return undefined;
17
+ }
18
+ return {
19
+ cols: validateRenderContextDimension("cols", context.cols),
20
+ rows: validateRenderContextDimension("rows", context.rows),
21
+ theme: context.theme
22
+ };
23
+ }
8
24
  const VISUAL_STATE_ORDER = [
9
25
  "disabled", "readonly", "loading", "empty", "muted", "error", "warning", "success", "invalid", "valid", "placeholder", "selection", "selected", "current", "expanded", "collapsed", "checked", "unchecked", "indeterminate", "editing", "submitted", "dragging", "dropTarget", "capturing", "focus", "hover", "pressed"
10
26
  ];
@@ -86,6 +102,18 @@ function mergeStyleDefinitions(base, next) {
86
102
  function styleSpan(kind, style) {
87
103
  return typeof style === "undefined" ? { kind } : { kind, style };
88
104
  }
105
+ const BASE_STYLE_KIND_BY_TAG = {
106
+ "terminal-button": "button.base",
107
+ "terminal-input": "input.base",
108
+ "terminal-editor": "editor.base",
109
+ "terminal-list": "list.base",
110
+ "terminal-scroll": "scroll.base",
111
+ "terminal-log-view": "log.base",
112
+ "terminal-overlay": "overlay.base"
113
+ };
114
+ function baseStyleKindForNode(node) {
115
+ return BASE_STYLE_KIND_BY_TAG[node.tag];
116
+ }
89
117
  function nodeStates(node) {
90
118
  const declared = Array.isArray(node.props.state) ? node.props.state : typeof node.props.state === "string" ? [node.props.state] : [];
91
119
  const states = new Set();
@@ -109,7 +137,7 @@ function resolveLayoutStyle(baseKind, node, context) {
109
137
  return mergeStyleDefinitions(resolveTerminalStyle(baseKind, context?.theme), resolveTerminalStyle(node.props.style, context?.theme));
110
138
  }
111
139
  function resolveNodeLayoutStyle(node, context) {
112
- return resolveTerminalStyle(node.props.style, context?.theme);
140
+ return mergeStyleDefinitions(resolveTerminalStyle(baseStyleKindForNode(node), context?.theme), resolveTerminalStyle(node.props.style, context?.theme));
113
141
  }
114
142
  function decoratedControlFrame(content, style) {
115
143
  const padding = normalizeSpacing(style?.padding, "Control padding");
@@ -125,11 +153,18 @@ function fullFrameSpans(kinds, width, height) {
125
153
  }
126
154
  return spans;
127
155
  }
128
- function resolveNodeStyle(node, context) {
129
- let style = resolveTerminalStyle(node.props.style, context?.theme);
130
- const spanKinds = typeof node.props.style === "string"
131
- ? [styleSpan(node.props.style)]
132
- : style ? [styleSpan("#style", style)] : [];
156
+ function resolveNodeStyle(node, context, options = {}) {
157
+ const baseKind = options.includeBase === false ? undefined : baseStyleKindForNode(node);
158
+ let style = resolveTerminalStyle(baseKind, context?.theme);
159
+ const spanKinds = typeof baseKind === "undefined" ? [] : [styleSpan(baseKind)];
160
+ const explicitStyle = resolveTerminalStyle(node.props.style, context?.theme);
161
+ if (typeof node.props.style === "string") {
162
+ spanKinds.push(styleSpan(node.props.style));
163
+ }
164
+ else if (explicitStyle) {
165
+ spanKinds.push(styleSpan("#style", explicitStyle));
166
+ }
167
+ style = mergeStyleDefinitions(style, explicitStyle);
133
168
  for (const state of nodeStates(node)) {
134
169
  const stateStyle = node.props.styles?.[state];
135
170
  if (stateStyle) {
@@ -663,17 +698,58 @@ function renderStandaloneFixedFrame(node, context) {
663
698
  ? constrainFrame(frame, { height: size })
664
699
  : constrainFrame(frame, { width: size });
665
700
  }
666
- function overlayGeometry(node) {
701
+ function overlayMarginValue(value, axisSize, label) {
702
+ if (typeof value === "number") {
703
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0) {
704
+ throw new RangeError(`${label} must be a non-negative finite integer or percentage string`);
705
+ }
706
+ return value;
707
+ }
708
+ if (typeof value === "string") {
709
+ const match = value.match(/^(\d+(?:\.\d+)?)%$/);
710
+ if (!match) {
711
+ throw new RangeError(`${label} must be a non-negative finite integer or percentage string`);
712
+ }
713
+ const percent = Number(match[1]);
714
+ if (!Number.isFinite(percent) || percent < 0) {
715
+ throw new RangeError(`${label} must be a non-negative finite integer or percentage string`);
716
+ }
717
+ return Math.round(axisSize * percent / 100);
718
+ }
719
+ throw new RangeError(`${label} must be a non-negative finite integer or percentage string`);
720
+ }
721
+ function overlayMargins(margin, width, height) {
722
+ if (typeof margin === "number" || typeof margin === "string") {
723
+ const x = overlayMarginValue(margin, width, "Overlay margin");
724
+ const y = overlayMarginValue(margin, height, "Overlay margin");
725
+ return { x, y };
726
+ }
727
+ if (margin && typeof margin === "object" && !Array.isArray(margin)) {
728
+ const axes = margin;
729
+ return {
730
+ x: overlayMarginValue(axes.x, width, "Overlay margin x"),
731
+ y: overlayMarginValue(axes.y, height, "Overlay margin y")
732
+ };
733
+ }
734
+ throw new RangeError("Overlay margin is required");
735
+ }
736
+ function overlayGeometry(node, width, height) {
737
+ const margin = overlayMargins(node.props.margin, width, height);
738
+ const overlayWidth = width - margin.x * 2;
739
+ const overlayHeight = height - margin.y * 2;
740
+ if (overlayWidth < 1 || overlayHeight < 1) {
741
+ throw new RangeError("Overlay margin leaves no renderable area");
742
+ }
667
743
  return {
668
- x: positiveInteger(node.props.x, "Overlay x"),
669
- y: positiveInteger(node.props.y, "Overlay y"),
670
- width: positiveInteger(node.props.width, "Overlay width"),
671
- height: positiveInteger(node.props.height, "Overlay height")
744
+ x: margin.x + 1,
745
+ y: margin.y + 1,
746
+ width: overlayWidth,
747
+ height: overlayHeight
672
748
  };
673
749
  }
674
- function renderOverlayChildFrame(node, context) {
675
- const geometry = overlayGeometry(node);
676
- let frame = constrainFrame(renderBodyFrame(node.children, {}, { cols: geometry.width, rows: geometry.height }), { width: geometry.width, height: geometry.height });
750
+ function renderOverlayChildFrame(node, width, height, context) {
751
+ const geometry = overlayGeometry(node, width, height);
752
+ let frame = constrainFrame(renderBodyFrame(node.children, {}, { cols: geometry.width, rows: geometry.height, theme: context?.theme }), { width: geometry.width, height: geometry.height });
677
753
  frame = addContainerStyleSpans(frame, node, resolveNodeStyle(node, context));
678
754
  if (node.props.id && isFocusable(node)) {
679
755
  frame = addFocusableHitbox(frame, node);
@@ -682,8 +758,10 @@ function renderOverlayChildFrame(node, context) {
682
758
  }
683
759
  function applyDirectOverlays(base, overlays, context) {
684
760
  let frame = base;
761
+ const width = Math.max(1, getFrameWidth(base));
762
+ const height = Math.max(1, getFrameHeight(base));
685
763
  for (const overlay of overlays) {
686
- const rendered = renderOverlayChildFrame(overlay, context);
764
+ const rendered = renderOverlayChildFrame(overlay, width, height, context);
687
765
  frame = overlayFrame(frame, rendered.frame, rendered.geometry);
688
766
  }
689
767
  return frame;
@@ -741,8 +819,11 @@ function renderPaneFrame(node, context) {
741
819
  }
742
820
  return overlays.length ? applyDirectOverlays(frame, overlays, context) : frame;
743
821
  }
744
- function renderStandaloneOverlayFrame(node) {
745
- const rendered = renderOverlayChildFrame(node);
822
+ function renderStandaloneOverlayFrame(node, context) {
823
+ if (!context) {
824
+ throw new RangeError("Standalone Overlay requires exact render context dimensions");
825
+ }
826
+ const rendered = renderOverlayChildFrame(node, context.cols, context.rows, context);
746
827
  return rendered.frame;
747
828
  }
748
829
  function renderLogViewFrame(node, context) {
@@ -882,7 +963,7 @@ function renderElementFrame(node, context) {
882
963
  case "terminal-fixed":
883
964
  return renderStandaloneFixedFrame(node, context);
884
965
  case "terminal-overlay":
885
- return renderStandaloneOverlayFrame(node);
966
+ return renderStandaloneOverlayFrame(node, context);
886
967
  case "terminal-log-view":
887
968
  return renderLogViewFrame(node, context);
888
969
  case "terminal-list": {
@@ -917,7 +998,7 @@ function renderElementFrame(node, context) {
917
998
  }
918
999
  }
919
1000
  const frame = createFrame(decorated.lines, [], decorated.cursor, spans);
920
- const styled = addFullFrameSpans(frame, resolveNodeStyle(node, context).spanKinds);
1001
+ const styled = addFullFrameSpans(frame, resolveNodeStyle(node, context, { includeBase: false }).spanKinds);
921
1002
  if (!node.props.id) {
922
1003
  return styled;
923
1004
  }
@@ -938,7 +1019,7 @@ function renderElementFrame(node, context) {
938
1019
  case "terminal-text": {
939
1020
  const value = typeof node.props.value !== "undefined" ? plainText(node.props.value) : plainText(node.children.map(textContent).join(""));
940
1021
  const frame = createFrame(value.split("\n"));
941
- return addFullFrameSpans(frame, resolveNodeStyle(node, context).spanKinds);
1022
+ return addFullFrameSpans(frame, resolveNodeStyle(node, context, { includeBase: false }).spanKinds);
942
1023
  }
943
1024
  case "terminal-input": {
944
1025
  const value = typeof node.props.value !== "undefined" ? node.props.value : node.props.placeholder || "";
@@ -957,7 +1038,7 @@ function renderElementFrame(node, context) {
957
1038
  const height = Math.max(1, getFrameHeight(decorated));
958
1039
  const hitboxes = node.props.id ? [{ id: node.props.id, tag: node.tag, x1: 1, x2: width, y1: 1, y2: height, textStartX, textLength: stringValue.length }] : [];
959
1040
  const spans = fullFrameSpans(["input.base"], width, height);
960
- return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context).spanKinds);
1041
+ return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context, { includeBase: false }).spanKinds);
961
1042
  }
962
1043
  const rendered = renderInputLine(stringValue, node.props.__inputState || { cursor: stringValue.length, anchor: stringValue.length }, inputPadding);
963
1044
  const decorated = addBorder(createFrame([rendered.line], [], rendered.cursor, rendered.spans), inputBorder);
@@ -965,7 +1046,7 @@ function renderElementFrame(node, context) {
965
1046
  const height = Math.max(1, getFrameHeight(decorated));
966
1047
  const hitboxes = node.props.id ? [{ id: node.props.id, tag: node.tag, x1: 1, x2: width, y1: 1, y2: height, textStartX, textLength: stringValue.length }] : [];
967
1048
  const spans = [...fullFrameSpans(["input.base", "input.focus"], width, height), ...decorated.spans];
968
- return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context).spanKinds);
1049
+ return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context, { includeBase: false }).spanKinds);
969
1050
  }
970
1051
  case "terminal-editor":
971
1052
  return addFullFrameSpans(renderEditorFrame(node), resolveNodeStyle(node, context).spanKinds);
@@ -978,7 +1059,7 @@ function renderElementFrame(node, context) {
978
1059
  const hitboxes = node.props.id ? [{ id: node.props.id, tag: node.tag, x1: 1, x2: width, y1: 1, y2: height }] : [];
979
1060
  const kinds = ["button.base", ...nodeStates(node).map((state) => `button.${state}`)];
980
1061
  const spans = fullFrameSpans(kinds, width, height);
981
- return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context).spanKinds);
1062
+ return addFullFrameSpans(createFrame(decorated.lines, hitboxes, decorated.cursor, spans), resolveNodeStyle(node, context, { includeBase: false }).spanKinds);
982
1063
  }
983
1064
  default:
984
1065
  return mergeVertical(node.children.map((child) => renderTerminalFrame(child, context)));
@@ -993,9 +1074,10 @@ export function renderTerminalFrame(node, context) {
993
1074
  export function renderTerminalNode(node, context) {
994
1075
  return renderTerminalFrame(node, context).lines.join("\n");
995
1076
  }
996
- export function renderTerminal(input) {
1077
+ export function renderTerminal(input, context) {
1078
+ const renderContext = validateRenderContext(context);
997
1079
  return renderValyrianTerminal(input)
998
- .map((node) => renderTerminalNode(node))
1080
+ .map((node) => renderTerminalNode(node, renderContext))
999
1081
  .filter(Boolean)
1000
1082
  .join("\n")
1001
1083
  .trimEnd();