restty 0.1.23 → 0.1.25

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 (164) hide show
  1. package/dist/{chunk-mkkhfg0z.js → chunk-pab3ge3d.js} +11446 -7806
  2. package/dist/fonts/index.d.ts +4 -1
  3. package/dist/fonts/manager/classification.d.ts +13 -0
  4. package/dist/fonts/manager/entries.d.ts +13 -0
  5. package/dist/fonts/manager/picker.d.ts +6 -0
  6. package/dist/fonts/manager/sources.d.ts +16 -0
  7. package/dist/fonts/types.d.ts +20 -10
  8. package/dist/grid/grid.d.ts +5 -3
  9. package/dist/ime/ime.d.ts +13 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/input/index.d.ts +1 -1
  12. package/dist/input/keymap/before-input.d.ts +4 -0
  13. package/dist/input/keymap/constants.d.ts +13 -0
  14. package/dist/input/keymap/control.d.ts +2 -0
  15. package/dist/input/keymap/default-mapping.d.ts +1 -0
  16. package/dist/input/keymap/kitty.d.ts +1 -0
  17. package/dist/input/keymap/normalization.d.ts +4 -0
  18. package/dist/input/keymap/pty-map.d.ts +4 -0
  19. package/dist/input/keymap.d.ts +2 -11
  20. package/dist/input/output/csi.d.ts +33 -0
  21. package/dist/input/{output.d.ts → output/index.d.ts} +6 -9
  22. package/dist/input/output/osc.d.ts +15 -0
  23. package/dist/input/output/prompt.d.ts +11 -0
  24. package/dist/input/types.d.ts +13 -0
  25. package/dist/internal.d.ts +4 -4
  26. package/dist/internal.js +13 -150
  27. package/dist/renderer/index.d.ts +7 -2
  28. package/dist/renderer/shaders/glyph-gl.d.ts +4 -0
  29. package/dist/renderer/{shaders.d.ts → shaders/glyph-wgsl.d.ts} +0 -10
  30. package/dist/renderer/shaders/rect.d.ts +6 -0
  31. package/dist/renderer/shapes/block-elements.d.ts +3 -0
  32. package/dist/renderer/shapes/box-drawing/dashed-lines.d.ts +3 -0
  33. package/dist/renderer/shapes/box-drawing/diagonal.d.ts +2 -0
  34. package/dist/renderer/shapes/box-drawing/draw-box-drawing.d.ts +6 -0
  35. package/dist/renderer/shapes/box-drawing/fallback.d.ts +2 -0
  36. package/dist/renderer/shapes/box-drawing/mapped.d.ts +2 -0
  37. package/dist/renderer/shapes/box-drawing/rounded-corner.d.ts +2 -0
  38. package/dist/renderer/shapes/braille.d.ts +3 -0
  39. package/dist/renderer/shapes/classify.d.ts +18 -0
  40. package/dist/renderer/shapes/geometry.d.ts +9 -0
  41. package/dist/renderer/shapes/glyph-box.d.ts +7 -0
  42. package/dist/renderer/shapes/powerline.d.ts +3 -0
  43. package/dist/renderer/shapes/types.d.ts +38 -0
  44. package/dist/renderer/shapes.d.ts +8 -81
  45. package/dist/renderer/webgpu/buffers.d.ts +7 -0
  46. package/dist/renderer/webgpu/setup.d.ts +10 -0
  47. package/dist/renderer/webgpu/state.d.ts +15 -0
  48. package/dist/renderer/webgpu/webgl.d.ts +3 -0
  49. package/dist/restty.js +1 -1
  50. package/dist/{app → runtime}/atlas-builder.d.ts +53 -18
  51. package/dist/runtime/codepoint-utils.d.ts +12 -0
  52. package/dist/runtime/create-app-io-utils.d.ts +9 -0
  53. package/dist/runtime/create-app-symbols.d.ts +11 -0
  54. package/dist/runtime/create-app-types.d.ts +72 -0
  55. package/dist/runtime/create-runtime/atlas-debug-utils.d.ts +5 -0
  56. package/dist/runtime/create-runtime/blend-utils.d.ts +11 -0
  57. package/dist/runtime/create-runtime/color-glyph-atlas.d.ts +11 -0
  58. package/dist/runtime/create-runtime/debug-tools/create-dump-glyph-render.d.ts +2 -0
  59. package/dist/runtime/create-runtime/debug-tools/diagnose-codepoint.d.ts +2 -0
  60. package/dist/runtime/create-runtime/debug-tools/dump-atlas-for-codepoint.d.ts +2 -0
  61. package/dist/runtime/create-runtime/debug-tools/read-texture-to-image-data.d.ts +1 -0
  62. package/dist/runtime/create-runtime/debug-tools/setup-debug-expose.d.ts +2 -0
  63. package/dist/runtime/create-runtime/debug-tools/types.d.ts +63 -0
  64. package/dist/runtime/create-runtime/debug-tools.d.ts +6 -0
  65. package/dist/runtime/create-runtime/font-runtime-grid-helpers.d.ts +39 -0
  66. package/dist/runtime/create-runtime/font-runtime-helpers.d.ts +20 -0
  67. package/dist/runtime/create-runtime/font-runtime-helpers.types.d.ts +108 -0
  68. package/dist/runtime/create-runtime/font-runtime-text-helpers.d.ts +21 -0
  69. package/dist/runtime/create-runtime/font-runtime-webgpu-atlas.d.ts +26 -0
  70. package/dist/runtime/create-runtime/format-utils.d.ts +2 -0
  71. package/dist/runtime/create-runtime/input-hooks.d.ts +12 -0
  72. package/dist/runtime/create-runtime/interaction-runtime/bind-ime-events.d.ts +12 -0
  73. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-aux-handlers.d.ts +28 -0
  74. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-events.d.ts +41 -0
  75. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-up-handler.d.ts +28 -0
  76. package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.d.ts +18 -0
  77. package/dist/runtime/create-runtime/interaction-runtime/kitty-overlay-runtime.d.ts +15 -0
  78. package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.d.ts +30 -0
  79. package/dist/runtime/create-runtime/interaction-runtime/types.d.ts +110 -0
  80. package/dist/runtime/create-runtime/interaction-runtime.d.ts +3 -0
  81. package/dist/runtime/create-runtime/kitty-overlay-utils.d.ts +26 -0
  82. package/dist/runtime/create-runtime/lifecycle-theme-size-canvas.d.ts +13 -0
  83. package/dist/runtime/create-runtime/lifecycle-theme-size-theme.d.ts +6 -0
  84. package/dist/runtime/create-runtime/lifecycle-theme-size.d.ts +16 -0
  85. package/dist/runtime/create-runtime/lifecycle-theme-size.types.d.ts +85 -0
  86. package/dist/runtime/create-runtime/pty-input-runtime.d.ts +45 -0
  87. package/dist/runtime/create-runtime/render-tick-webgl-context.d.ts +4 -0
  88. package/dist/runtime/create-runtime/render-tick-webgl-glyph-pipeline.d.ts +2 -0
  89. package/dist/runtime/create-runtime/render-tick-webgl-overlays.d.ts +2 -0
  90. package/dist/runtime/create-runtime/render-tick-webgl-scene.d.ts +2 -0
  91. package/dist/runtime/create-runtime/render-tick-webgl.d.ts +3 -0
  92. package/dist/runtime/create-runtime/render-tick-webgl.types.d.ts +162 -0
  93. package/dist/runtime/create-runtime/render-tick-webgpu-cell-pass.d.ts +25 -0
  94. package/dist/runtime/create-runtime/render-tick-webgpu-draw-pass.d.ts +2 -0
  95. package/dist/runtime/create-runtime/render-tick-webgpu-emit-glyphs.d.ts +2 -0
  96. package/dist/runtime/create-runtime/render-tick-webgpu-overlays-atlas.d.ts +2 -0
  97. package/dist/runtime/create-runtime/render-tick-webgpu.d.ts +3 -0
  98. package/dist/runtime/create-runtime/render-tick-webgpu.types.d.ts +386 -0
  99. package/dist/runtime/create-runtime/render-ticks.d.ts +9 -0
  100. package/dist/runtime/create-runtime/runtime-app-api.d.ts +103 -0
  101. package/dist/runtime/create-runtime/runtime-logger.d.ts +17 -0
  102. package/dist/runtime/create-runtime/runtime-reporting.d.ts +40 -0
  103. package/dist/runtime/create-runtime/shader-stage-runtime.d.ts +29 -0
  104. package/dist/runtime/create-runtime.d.ts +7 -0
  105. package/dist/runtime/font-atlas-utils/bitmap-utils.d.ts +5 -0
  106. package/dist/runtime/font-atlas-utils/glyph-atlas-builder.d.ts +29 -0
  107. package/dist/runtime/font-atlas-utils/nerd-metrics-utils.d.ts +25 -0
  108. package/dist/runtime/font-atlas-utils/packing-utils.d.ts +13 -0
  109. package/dist/runtime/overlay-scrollbar.d.ts +24 -0
  110. package/dist/runtime/pty-output-buffer.d.ts +12 -0
  111. package/dist/runtime/render-color-utils.d.ts +6 -0
  112. package/dist/runtime/render-stage-runtime.d.ts +18 -0
  113. package/dist/runtime/render-stage-shaders.d.ts +6 -0
  114. package/dist/runtime/shader-stages.d.ts +9 -0
  115. package/dist/runtime/text-decoration.d.ts +4 -0
  116. package/dist/{app → runtime}/types.d.ts +39 -1
  117. package/dist/selection/clipboard.d.ts +4 -0
  118. package/dist/selection/{selection.d.ts → core.d.ts} +0 -11
  119. package/dist/selection/index.d.ts +3 -1
  120. package/dist/selection/text.d.ts +8 -0
  121. package/dist/surface/app-factory.d.ts +3 -0
  122. package/dist/{app → surface}/pane-app-manager.d.ts +2 -2
  123. package/dist/surface/panes/default-context-menu-items.d.ts +8 -0
  124. package/dist/surface/panes/layout.d.ts +9 -0
  125. package/dist/surface/panes/manager.d.ts +2 -0
  126. package/dist/surface/panes/pane-interactions.d.ts +11 -0
  127. package/dist/surface/panes/window-events.d.ts +10 -0
  128. package/dist/{app → surface}/panes-types.d.ts +1 -1
  129. package/dist/surface/restty/active-pane-api.d.ts +23 -0
  130. package/dist/surface/restty/manager-options.d.ts +24 -0
  131. package/dist/surface/restty/pane-ops.d.ts +42 -0
  132. package/dist/surface/restty/plugin-dispatcher.d.ts +39 -0
  133. package/dist/surface/restty/plugin-ops.d.ts +24 -0
  134. package/dist/surface/restty/shader-ops.d.ts +27 -0
  135. package/dist/surface/restty-pane-handle.d.ts +70 -0
  136. package/dist/surface/restty-plugin-runtime.d.ts +57 -0
  137. package/dist/surface/restty-plugin-types.d.ts +164 -0
  138. package/dist/surface/restty-plugin-utils.d.ts +22 -0
  139. package/dist/surface/restty.d.ts +93 -0
  140. package/dist/utils/base64.d.ts +12 -0
  141. package/dist/wasm/index.d.ts +2 -1
  142. package/dist/wasm/runtime/abi.d.ts +7 -0
  143. package/dist/wasm/runtime/kitty.d.ts +2 -0
  144. package/dist/wasm/runtime/render-state.d.ts +2 -0
  145. package/dist/wasm/runtime/restty-wasm.d.ts +42 -0
  146. package/dist/wasm/{runtime.d.ts → runtime/types.d.ts} +48 -41
  147. package/dist/wasm/runtime/view-cache.d.ts +4 -0
  148. package/dist/xterm/app-options.d.ts +2 -0
  149. package/dist/xterm/dimensions.d.ts +1 -0
  150. package/dist/xterm/listeners.d.ts +5 -0
  151. package/dist/xterm.d.ts +1 -6
  152. package/dist/xterm.js +61 -63
  153. package/package.json +1 -1
  154. package/dist/app/index.d.ts +0 -9
  155. package/dist/app/panes.d.ts +0 -15
  156. package/dist/app/restty.d.ts +0 -336
  157. package/dist/fonts/manager.d.ts +0 -45
  158. package/dist/renderer/webgpu.d.ts +0 -33
  159. package/dist/restty-input.d.ts +0 -1
  160. /package/dist/{app → runtime}/clipboard-paste.d.ts +0 -0
  161. /package/dist/{app → runtime}/font-sources.d.ts +0 -0
  162. /package/dist/{app → runtime}/session.d.ts +0 -0
  163. /package/dist/{app → surface}/panes-context-menu.d.ts +0 -0
  164. /package/dist/{app → surface}/panes-styles.d.ts +0 -0
@@ -1,4 +1,7 @@
1
1
  export * from "./types";
2
- export * from "./manager";
2
+ export * from "./manager/classification";
3
+ export * from "./manager/entries";
4
+ export * from "./manager/picker";
5
+ export * from "./manager/sources";
3
6
  export * from "./nerd-ranges";
4
7
  export * from "./nerd-constraints";
@@ -0,0 +1,13 @@
1
+ import type { FontEntry, FontScaleOverride } from "../types";
2
+ /** Check whether a font entry is a symbol/icon font based on its label. */
3
+ export declare function isSymbolFont(entry: FontEntry | null | undefined): boolean;
4
+ /** Check whether a font entry is a Nerd Font symbols font. */
5
+ export declare function isNerdSymbolFont(entry: FontEntry | null | undefined): boolean;
6
+ /** Check whether a font entry is a color emoji font. */
7
+ export declare function isColorEmojiFont(entry: FontEntry | null | undefined): boolean;
8
+ /** Return the maximum cell span for a font (2 for CJK/emoji, 1 otherwise). */
9
+ export declare function fontMaxCellSpan(entry: FontEntry | null | undefined): number;
10
+ /** Return the scale multiplier for a font entry by matching its label against overrides. */
11
+ export declare function fontScaleOverride(entry: FontEntry | null | undefined, overrides?: FontScaleOverride[]): number;
12
+ /** Compute the atlas raster scale for a font, applying symbol atlas scaling for fallback symbol fonts. */
13
+ export declare function fontRasterScale(entry: FontEntry | null | undefined, fontIndex: number, maxSymbolAtlasScale: number, overrides?: FontScaleOverride[]): number;
@@ -0,0 +1,13 @@
1
+ import type { Font, FontEntry, FontManagerState, ShapedCluster } from "../types";
2
+ /** Create a new FontEntry with empty caches and default metadata. */
3
+ export declare function createFontEntry(font: Font, label: string): FontEntry;
4
+ /** Clear all caches and reset rendering metadata on a font entry. */
5
+ export declare function resetFontEntry(entry: FontEntry): void;
6
+ /** Create an empty FontManagerState for initialization. */
7
+ export declare function createFontManagerState(): FontManagerState;
8
+ /** Check whether a font has a non-zero glyph ID for the given character. */
9
+ export declare function fontHasGlyph(font: Font, ch: string): boolean;
10
+ /** Get the horizontal advance width in font design units, computing and caching it if needed. */
11
+ export declare function fontAdvanceUnits(entry: FontEntry, shapeClusterWithFont: (entry: FontEntry, text: string) => ShapedCluster): number;
12
+ /** Get the bounding-box width of a glyph in font design units, with caching. */
13
+ export declare function glyphWidthUnits(entry: FontEntry, glyphId: number | undefined | null): number;
@@ -0,0 +1,6 @@
1
+ import type { FontManagerState } from "../types";
2
+ /**
3
+ * Select the best font index from the manager's font list for rendering the
4
+ * given text cluster, searching in fallback order similar to Ghostty.
5
+ */
6
+ export declare function pickFontIndexForText(state: FontManagerState, text: string, expectedSpan: number): number;
@@ -0,0 +1,16 @@
1
+ import type { FallbackFontSource } from "../types";
2
+ /** Fetch a font file from a URL and return its ArrayBuffer, or null on failure. */
3
+ export declare function tryFetchFontBuffer(url: string): Promise<ArrayBuffer | null>;
4
+ /** Query locally installed fonts via the Local Font Access API and return the first match, or null. */
5
+ export declare function tryLocalFontBuffer(matchers: string[]): Promise<ArrayBuffer | null>;
6
+ /**
7
+ * Load the primary font buffer, trying local Nerd Font matchers first,
8
+ * then a remote fallback URL, then broader local font matchers. Throws
9
+ * if all sources fail.
10
+ */
11
+ export declare function loadPrimaryFontBuffer(localMatchers: string[], fallbackUrl: string, fallbackLocalMatchers: string[]): Promise<ArrayBuffer>;
12
+ /** Load fallback font buffers from a list of sources, trying remote URLs then local matchers. */
13
+ export declare function loadFallbackFontBuffers(sources: FallbackFontSource[]): Promise<{
14
+ name: string;
15
+ buffer: ArrayBuffer;
16
+ }[]>;
@@ -1,9 +1,24 @@
1
+ import type { Bitmap as TextShaperBitmap, Font as TextShaperFont, FontSizeMode as TextShaperFontSizeMode, GlyphAtlas as TextShaperGlyphAtlas, GlyphMetrics as TextShaperGlyphMetrics } from "text-shaper";
2
+ /** text-shaper Font used by runtime/font manager. */
3
+ export type Font = TextShaperFont;
4
+ /** text-shaper Bitmap used by atlas builders. */
5
+ export type FontAtlasBitmap = TextShaperBitmap;
6
+ /** text-shaper glyph metrics used inside atlases. */
7
+ export type FontAtlasGlyphMetrics = TextShaperGlyphMetrics;
8
+ /** text-shaper font size mode ("em" | "height"). */
9
+ export type FontSizeMode = TextShaperFontSizeMode;
10
+ /** Restty atlas extends text-shaper atlas with extra caches used internally. */
11
+ export type FontAtlas = TextShaperGlyphAtlas & {
12
+ glyphsByWidth?: Map<number, Map<number, FontAtlasGlyphMetrics>>;
13
+ inset?: number;
14
+ colorGlyphs?: Set<number>;
15
+ };
1
16
  /**
2
17
  * A loaded font with its associated caches and rendering metadata.
3
18
  */
4
19
  export type FontEntry = {
5
20
  /** text-shaper Font instance. */
6
- font: any;
21
+ font: Font;
7
22
  /** Human-readable font name. */
8
23
  label: string;
9
24
  /** Cache of shaped glyph clusters keyed by input string. */
@@ -15,7 +30,7 @@ export type FontEntry = {
15
30
  /** Set of all glyph IDs available in this font. */
16
31
  glyphIds: Set<number>;
17
32
  /** GPU texture atlas for this font, or null if not yet built. */
18
- atlas: any | null;
33
+ atlas: FontAtlas | null;
19
34
  /** Font size in CSS pixels. */
20
35
  fontSizePx: number;
21
36
  /** Scale factor applied when rasterizing to the atlas. */
@@ -54,18 +69,13 @@ export type ShapedGlyph = {
54
69
  */
55
70
  export type FontManagerState = {
56
71
  /** Primary text-shaper Font instance, or null before initialization. */
57
- font: any | null;
72
+ font: Font | null;
58
73
  /** Loaded font entries in priority order (primary + fallbacks). */
59
74
  fonts: FontEntry[];
60
75
  /** Current font size in CSS pixels. */
61
76
  fontSizePx: number;
62
- /**
63
- * How font size maps to design units.
64
- * - height: size equals cell height
65
- * - width: size equals cell width
66
- * - upem: size equals units-per-em
67
- */
68
- sizeMode: "height" | "width" | "upem";
77
+ /** How font size maps to design units ("em" | "height"). */
78
+ sizeMode: FontSizeMode;
69
79
  /** Cache mapping text strings to the index of the font chosen to render them. */
70
80
  fontPickCache: Map<string, number>;
71
81
  };
@@ -4,7 +4,7 @@ import type { CellMetrics, GridConfig, GridState } from "./types";
4
4
  */
5
5
  export type FontMetricsProvider = {
6
6
  /** Return the scale factor for a given pixel size and sizing mode. */
7
- scaleForSize(sizePx: number, sizeMode: string): number;
7
+ scaleForSize(sizePx: number, sizeMode?: "em" | "height"): number;
8
8
  /** Look up the glyph ID for a character, or null/undefined if missing. */
9
9
  glyphIdForChar(char: string): number | undefined | null;
10
10
  /** Return the advance width of a glyph in font units. */
@@ -16,13 +16,15 @@ export type FontMetricsProvider = {
16
16
  /** Explicit font height in font units, if available. */
17
17
  readonly height?: number;
18
18
  /** Units per em of the font. */
19
- readonly upem: number;
19
+ readonly unitsPerEm: number;
20
+ /** Legacy alias accepted for compatibility with older font objects. */
21
+ readonly upem?: number;
20
22
  };
21
23
  /** Result of shaping a text cluster, containing its advance width. */
22
24
  export type ShapeResult = {
23
25
  advance: number;
24
26
  };
25
- /** Resolve the font height in font units, falling back to ascender-descender or upem. */
27
+ /** Resolve the font height in font units, falling back to ascender-descender or units-per-em. */
26
28
  export declare function fontHeightUnits(font: FontMetricsProvider): number;
27
29
  /**
28
30
  * Compute cell width, height, and baseline from font metrics, grid config,
package/dist/ime/ime.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { ImeState, CursorPosition } from "./types";
2
+ /** Default CSS font stack used for IME preedit UI when terminal fonts are not directly available to CSS. */
3
+ export declare const DEFAULT_IME_FONT_FAMILY = "\"JetBrains Mono\",\"Fira Code\",\"SFMono-Regular\",\"Menlo\",\"Consolas\",\"Liberation Mono\",monospace";
2
4
  /** Create a fresh IME state with no active composition. */
3
5
  export declare function createImeState(): ImeState;
4
6
  /** Set the preedit string on the IME state and sync it to the hidden input element. */
@@ -15,6 +17,17 @@ export declare function endComposition(state: ImeState): string;
15
17
  export declare function syncImeSelection(state: ImeState, imeInput: HTMLInputElement | null): void;
16
18
  /** Reposition the hidden IME input element to align with the terminal cursor. */
17
19
  export declare function updateImePosition(imeInput: HTMLInputElement | null, cursor: CursorPosition | null, cellW: number, cellH: number, dpr: number, canvasRect: DOMRect): void;
20
+ /** Resolve a visible IME anchor from cursor coordinates, clamped to current viewport bounds. */
21
+ export declare function resolveImeAnchor(cursor: {
22
+ row: number;
23
+ col: number;
24
+ wideTail?: boolean;
25
+ } | null, cols: number, rows: number): CursorPosition | null;
26
+ /**
27
+ * Sync hidden IME input typography with terminal sizing so OS preedit/candidate UI
28
+ * uses the same visual scale as the terminal text.
29
+ */
30
+ export declare function syncImeInputTypography(imeInput: HTMLInputElement | HTMLTextAreaElement | null, fontSizePt: number, fontFamily?: string): void;
18
31
  /** Default RGBA background color for the preedit overlay. */
19
32
  export declare const PREEDIT_BG: readonly [0.16, 0.16, 0.2, 0.9];
20
33
  /** Default RGBA background color for the active (selected) preedit segment. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { RESTTY_PLUGIN_API_VERSION, Restty, ResttyPaneHandle, createRestty } from "./app/restty";
2
- export type { ResttyOptions, ResttyPaneApi, ResttyPluginApiRange, ResttyPlugin, ResttyPluginCleanup, ResttyPluginContext, ResttyPluginDisposable, ResttyPluginEvents, ResttyPluginInfo, ResttyPluginRequires, ResttyInputInterceptor, ResttyInputInterceptorPayload, ResttyInterceptorOptions, ResttyLifecycleHook, ResttyLifecycleHookPayload, ResttyPluginLoadResult, ResttyPluginLoadStatus, ResttyPluginManifestEntry, ResttyPluginRegistry, ResttyPluginRegistryEntry, ResttyRenderHook, ResttyRenderHookPayload, ResttyOutputInterceptor, ResttyOutputInterceptorPayload, } from "./app/restty";
1
+ export { RESTTY_PLUGIN_API_VERSION, Restty, ResttyPaneHandle, createRestty, } from "./surface/restty";
2
+ export type { ResttyOptions, ResttyPaneApi, ResttyPluginApiRange, ResttyPlugin, ResttyPluginCleanup, ResttyPluginContext, ResttyPluginDisposable, ResttyPluginEvents, ResttyPluginInfo, ResttyPluginRequires, ResttyInputInterceptor, ResttyInputInterceptorPayload, ResttyInterceptorOptions, ResttyLifecycleHook, ResttyLifecycleHookPayload, ResttyPluginLoadResult, ResttyPluginLoadStatus, ResttyPluginManifestEntry, ResttyPluginRegistry, ResttyPluginRegistryEntry, ResttyRenderHook, ResttyRenderHookPayload, ResttyOutputInterceptor, ResttyOutputInterceptorPayload, ResttyRenderStageHandle, } from "./surface/restty";
3
3
  export { getBuiltinTheme, getBuiltinThemeSource, isBuiltinThemeName, listBuiltinThemeNames, parseGhosttyTheme, } from "./theme";
4
4
  export type { GhosttyTheme, ResttyBuiltinThemeName } from "./theme";
5
- export type { ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, ResttyFontPreset, } from "./app/types";
5
+ export type { ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, ResttyFontPreset, ResttyShaderStage, ResttyShaderStageMode, ResttyShaderStageBackend, ResttyShaderStageSource, } from "./runtime/types";
@@ -3,4 +3,4 @@ import type { InputHandler, InputHandlerOptions } from "./types";
3
3
  * Create a terminal input handler with key, IME, PTY, and mouse support.
4
4
  */
5
5
  export declare function createInputHandler(options?: InputHandlerOptions): InputHandler;
6
- export type { CellPosition, CursorPosition, InputHandler, InputHandlerConfig, InputHandlerOptions, MouseMode, MouseStatus, } from "./types";
6
+ export type { CellPosition, CursorPosition, InputHandler, InputHandlerConfig, InputHandlerOptions, MouseMode, MouseStatus, DesktopNotification, } from "./types";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Encode beforeinput events (IME/paste/backspace) into terminal sequences.
3
+ */
4
+ export declare function encodeBeforeInputEvent(event: InputEvent): string;
@@ -0,0 +1,13 @@
1
+ import type { InputHandlerConfig } from "../types";
2
+ /**
3
+ * Standard sequences used by terminal emulators.
4
+ */
5
+ export declare const sequences: {
6
+ enter: string;
7
+ backspace: string;
8
+ delete: string;
9
+ tab: string;
10
+ shiftTab: string;
11
+ escape: string;
12
+ };
13
+ export declare const DEFAULT_CONFIG: Required<InputHandlerConfig>;
@@ -0,0 +1,2 @@
1
+ export declare function ctrlCharForKey(key: string): string;
2
+ export declare function modifierCode(event: KeyboardEvent): number;
@@ -0,0 +1 @@
1
+ export declare function encodeDefaultKeyEvent(event: KeyboardEvent): string;
@@ -0,0 +1 @@
1
+ export declare function encodeKittyKeyEvent(event: KeyboardEvent, kittyFlags: number): string;
@@ -0,0 +1,4 @@
1
+ export declare function deriveUnshiftedCodepoint(event: KeyboardEvent): number;
2
+ export declare function deriveShiftedCodepoint(event: KeyboardEvent, unshiftedCodepoint: number): number;
3
+ export declare function deriveBaseLayoutCodepoint(event: KeyboardEvent): number;
4
+ export declare function toCodepoints(text: string): number[];
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Map input sequences to PTY expectations (e.g., DEL vs backspace).
3
+ */
4
+ export declare function mapKeySequenceForPty(seq: string): string;
@@ -1,15 +1,6 @@
1
1
  import type { InputHandlerConfig } from "./types";
2
- /**
3
- * Standard sequences used by terminal emulators.
4
- */
5
- export declare const sequences: {
6
- enter: string;
7
- backspace: string;
8
- delete: string;
9
- tab: string;
10
- shiftTab: string;
11
- escape: string;
12
- };
2
+ import { sequences } from "./keymap/constants";
3
+ export { sequences };
13
4
  /**
14
5
  * Encode a KeyboardEvent into a terminal byte sequence.
15
6
  */
@@ -0,0 +1,33 @@
1
+ import type { CursorPosition, WindowOp } from "../types";
2
+ export type OutputModeState = {
3
+ bracketedPaste: boolean;
4
+ focusReporting: boolean;
5
+ synchronizedOutput: boolean;
6
+ };
7
+ export type WindowMetrics = {
8
+ rows: number;
9
+ cols: number;
10
+ widthPx: number;
11
+ heightPx: number;
12
+ cellWidthPx: number;
13
+ cellHeightPx: number;
14
+ };
15
+ export declare function deriveAltScreen(seq: string, current: boolean): boolean;
16
+ /**
17
+ * Apply tracked private mode flags. Returns true when one of the tracked
18
+ * modes was handled.
19
+ */
20
+ export declare function applyTrackedPrivateModes(seq: string, state: OutputModeState): boolean;
21
+ export type WindowOpHandlers = {
22
+ sendReply: (data: string) => void;
23
+ getWindowMetrics?: () => WindowMetrics;
24
+ onWindowOp?: (op: WindowOp) => void;
25
+ };
26
+ /** Handle XTWINOPS queries and window manipulation hooks. */
27
+ export declare function handleWindowOpSequence(seq: string, handlers: WindowOpHandlers): boolean;
28
+ export type CoreCsiHandlers = {
29
+ sendReply: (data: string) => void;
30
+ getCursorPosition: () => CursorPosition;
31
+ };
32
+ /** Handle core CSI queries intercepted by OutputFilter. */
33
+ export declare function handleCoreCsiSequence(seq: string, handlers: CoreCsiHandlers): boolean;
@@ -1,5 +1,5 @@
1
- import type { CellPosition, CursorPosition, WindowOp } from "./types";
2
- import type { MouseController } from "./mouse";
1
+ import type { CellPosition, CursorPosition, DesktopNotification, WindowOp } from "../types";
2
+ import type { MouseController } from "../mouse";
3
3
  /**
4
4
  * Construction options for OutputFilter.
5
5
  */
@@ -31,6 +31,8 @@ export type OutputFilterOptions = {
31
31
  cellWidthPx: number;
32
32
  cellHeightPx: number;
33
33
  };
34
+ /** Handler for desktop notifications (OSC 9 / OSC 777). */
35
+ onDesktopNotification?: (notification: DesktopNotification) => void;
34
36
  };
35
37
  /**
36
38
  * Parses output for control queries (CPR/DA) and mouse mode toggles,
@@ -50,10 +52,8 @@ export declare class OutputFilter {
50
52
  private clipboardWrite?;
51
53
  private clipboardRead?;
52
54
  private getDefaultColors?;
53
- private semanticPromptSeen;
54
- private promptClickEvents;
55
- private promptInputActive;
56
- private commandRunning;
55
+ private desktopNotificationHandler?;
56
+ private promptState;
57
57
  constructor(options: OutputFilterOptions);
58
58
  setCursorProvider(fn: () => CursorPosition): void;
59
59
  setReplySink(fn: (data: string) => void): void;
@@ -64,10 +64,7 @@ export declare class OutputFilter {
64
64
  isSynchronizedOutput(): boolean;
65
65
  isPromptClickEventsEnabled(): boolean;
66
66
  encodePromptClickEvent(cell: CellPosition): string;
67
- private readOsc133BoolOption;
68
- private observeSemanticPromptOsc;
69
67
  private observeOsc;
70
- private replyOscColor;
71
68
  private handleOsc;
72
69
  private handleModeSeq;
73
70
  private handleWindowOp;
@@ -0,0 +1,15 @@
1
+ import type { DesktopNotification } from "../types";
2
+ export type OscColorProvider = () => {
3
+ fg?: [number, number, number];
4
+ bg?: [number, number, number];
5
+ cursor?: [number, number, number];
6
+ };
7
+ export type OscHandlers = {
8
+ sendReply: (data: string) => void;
9
+ getDefaultColors?: OscColorProvider;
10
+ onClipboardWrite?: (text: string) => void | Promise<void>;
11
+ onClipboardRead?: () => string | null | Promise<string | null>;
12
+ onDesktopNotification?: (notification: DesktopNotification) => void;
13
+ };
14
+ /** Handle intercepted OSC queries and side effects. Returns true when handled. */
15
+ export declare function handleOscSequence(seq: string, handlers: OscHandlers): boolean;
@@ -0,0 +1,11 @@
1
+ export type PromptState = {
2
+ semanticPromptSeen: boolean;
3
+ promptClickEvents: boolean;
4
+ promptInputActive: boolean;
5
+ commandRunning: boolean;
6
+ };
7
+ export declare function createPromptState(): PromptState;
8
+ export declare function isPromptClickEventsEnabled(state: PromptState, altScreen: boolean): boolean;
9
+ export declare function observeSemanticPromptOsc(state: PromptState, action: string, options: string): void;
10
+ /** Observe OSC 133 prompt metadata and update prompt state. */
11
+ export declare function observeOscPromptState(state: PromptState, seq: string): void;
@@ -59,6 +59,15 @@ export type WindowOp = {
59
59
  params: number[];
60
60
  raw: string;
61
61
  };
62
+ /**
63
+ * Desktop notification payload parsed from terminal OSC sequences.
64
+ */
65
+ export type DesktopNotification = {
66
+ title: string;
67
+ body: string;
68
+ source: "osc9" | "osc777";
69
+ raw: string;
70
+ };
62
71
  /**
63
72
  * Input handler construction options.
64
73
  */
@@ -103,6 +112,10 @@ export type InputHandlerOptions = {
103
112
  */
104
113
  onClipboardWrite?: (text: string) => void | Promise<void>;
105
114
  onClipboardRead?: () => string | null | Promise<string | null>;
115
+ /**
116
+ * Optional handler for desktop notifications (OSC 9 / OSC 777).
117
+ */
118
+ onDesktopNotification?: (notification: DesktopNotification) => void;
106
119
  /**
107
120
  * Return active Kitty keyboard protocol flags (CSI ? u query result).
108
121
  */
@@ -12,7 +12,7 @@ export { loadResttyWasm, ResttyWasm } from "./wasm";
12
12
  export type { WasmAbi, WasmAbiKind, CursorInfo, RenderState, ResttyWasmExports, ResttyWasmOptions, } from "./wasm";
13
13
  export { parseGhosttyTheme, parseGhosttyColor, colorToFloats, colorToRgbU32, listBuiltinThemeNames, isBuiltinThemeName, getBuiltinThemeSource, getBuiltinTheme, } from "./theme";
14
14
  export type { GhosttyTheme, ThemeColor, ResttyBuiltinThemeName } from "./theme";
15
- export { Restty } from "./app/restty";
16
- export type { ResttyOptions } from "./app/restty";
17
- export type { ResttyManagedAppPane, ResttyPaneDomDefaults, ResttyManagedPaneStyleOptions, ResttyManagedPaneStylesOptions, ResttyPaneAppOptionsInput, } from "./app/pane-app-manager";
18
- export type { ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, } from "./app/types";
15
+ export { Restty } from "./surface/restty";
16
+ export type { ResttyOptions } from "./surface/restty";
17
+ export type { ResttyManagedAppPane, ResttyPaneDomDefaults, ResttyManagedPaneStyleOptions, ResttyManagedPaneStylesOptions, ResttyPaneAppOptionsInput, } from "./surface/pane-app-manager";
18
+ export type { ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, ResttyShaderStage, ResttyShaderStageMode, ResttyShaderStageBackend, ResttyShaderStageSource, } from "./runtime/types";
package/dist/internal.js CHANGED
@@ -18,12 +18,14 @@ import {
18
18
  applyAlpha,
19
19
  clamp,
20
20
  clearPreedit,
21
+ clearSelection,
21
22
  colorToFloats,
22
23
  colorToRgbU32,
23
24
  computeCellMetrics,
24
25
  configureContext,
25
26
  connectPty,
26
27
  constrainGlyphBox,
28
+ copyToClipboard,
27
29
  createFontEntry,
28
30
  createFontManagerState,
29
31
  createGridState,
@@ -32,6 +34,7 @@ import {
32
34
  createPtyConnection,
33
35
  createResizeState,
34
36
  createScrollbarState,
37
+ createSelectionState,
35
38
  createWebSocketPtyTransport,
36
39
  disconnectPty,
37
40
  drawBlockElement,
@@ -39,6 +42,7 @@ import {
39
42
  drawBraille,
40
43
  drawPowerline,
41
44
  endComposition,
45
+ endSelection,
42
46
  ensureGLInstanceBuffer,
43
47
  ensureInstanceBuffer,
44
48
  fontAdvanceUnits,
@@ -50,6 +54,7 @@ import {
50
54
  getBuiltinTheme,
51
55
  getBuiltinThemeSource,
52
56
  getNerdConstraint,
57
+ getSelectionText,
53
58
  glyphWidthUnits,
54
59
  initWebGL,
55
60
  initWebGPU,
@@ -72,172 +77,30 @@ import {
72
77
  loadFallbackFontBuffers,
73
78
  loadPrimaryFontBuffer,
74
79
  loadResttyWasm,
80
+ normalizeSelectionCell,
75
81
  parseGhosttyColor,
76
82
  parseGhosttyTheme,
83
+ pasteFromClipboard,
77
84
  pickFontIndexForText,
85
+ positionToCell,
78
86
  pushRect,
79
87
  pushRectBox,
80
88
  pushRectSnapped,
81
89
  resetFontEntry,
90
+ selectionForRow,
82
91
  sendPtyInput,
83
92
  sendPtyResize,
84
93
  setPreedit,
85
94
  startComposition,
95
+ startSelection,
86
96
  syncImeSelection,
87
97
  tryFetchFontBuffer,
88
98
  tryLocalFontBuffer,
89
99
  updateComposition,
90
100
  updateGridState,
91
- updateImePosition
92
- } from "./chunk-mkkhfg0z.js";
93
- // src/selection/selection.ts
94
- function createSelectionState() {
95
- return {
96
- active: false,
97
- dragging: false,
98
- anchor: null,
99
- focus: null
100
- };
101
- }
102
- function clearSelection(state) {
103
- state.active = false;
104
- state.dragging = false;
105
- state.anchor = null;
106
- state.focus = null;
107
- }
108
- function startSelection(state, cell) {
109
- state.active = true;
110
- state.dragging = true;
111
- state.anchor = cell;
112
- state.focus = cell;
113
- }
114
- function updateSelection(state, cell) {
115
- if (!state.dragging)
116
- return;
117
- state.focus = cell;
118
- }
119
- function endSelection(state, cell) {
120
- if (!state.dragging)
121
- return false;
122
- state.dragging = false;
123
- state.focus = cell;
124
- if (state.anchor && state.focus && state.anchor.row === state.focus.row && state.anchor.col === state.focus.col) {
125
- clearSelection(state);
126
- return false;
127
- }
128
- return true;
129
- }
130
- function selectionForRow(state, row, cols) {
131
- if (!state.active || !state.anchor || !state.focus)
132
- return null;
133
- const a = state.anchor;
134
- const f = state.focus;
135
- const forward = f.row > a.row || f.row === a.row && f.col >= a.col;
136
- const start = forward ? a : f;
137
- const end = forward ? f : a;
138
- if (start.row === end.row && row === start.row) {
139
- const left = Math.min(start.col, end.col);
140
- const right = Math.max(start.col, end.col) + 1;
141
- return { start: clamp(left, 0, cols), end: clamp(right, 0, cols) };
142
- }
143
- if (row < start.row || row > end.row)
144
- return null;
145
- if (row === start.row) {
146
- return { start: clamp(start.col, 0, cols), end: cols };
147
- }
148
- if (row === end.row) {
149
- return { start: 0, end: clamp(end.col + 1, 0, cols) };
150
- }
151
- return { start: 0, end: cols };
152
- }
153
- function getSelectionText(state, rows, cols, getCellText) {
154
- if (!state.active || !state.anchor || !state.focus)
155
- return "";
156
- if (!rows || !cols)
157
- return "";
158
- const a = state.anchor;
159
- const f = state.focus;
160
- const forward = f.row > a.row || f.row === a.row && f.col >= a.col;
161
- const startRow = forward ? a.row : f.row;
162
- const endRow = forward ? f.row : a.row;
163
- const lines = [];
164
- for (let row = startRow;row <= endRow; row += 1) {
165
- const range = selectionForRow(state, row, cols);
166
- if (!range)
167
- continue;
168
- let line = "";
169
- for (let col = range.start;col < range.end; col += 1) {
170
- const idx = row * cols + col;
171
- line += getCellText(idx);
172
- }
173
- line = line.replace(/[ \t]+$/g, "");
174
- lines.push(line);
175
- }
176
- return lines.join(`
177
- `);
178
- }
179
- function normalizeSelectionCell(cell, rows, cols, wideFlags) {
180
- if (!cell)
181
- return cell;
182
- if (!rows || !cols)
183
- return cell;
184
- const row = clamp(cell.row, 0, rows - 1);
185
- const col = clamp(cell.col, 0, cols - 1);
186
- if (!wideFlags)
187
- return { row, col };
188
- const idx = row * cols + col;
189
- const flag = wideFlags[idx] ?? 0;
190
- if (flag === 2) {
191
- const left = col > 0 ? col - 1 : col;
192
- return { row, col: left };
193
- }
194
- if (flag === 3 && row > 0) {
195
- const prevRow = row - 1;
196
- for (let c = cols - 1;c >= 0; c -= 1) {
197
- const f = wideFlags[prevRow * cols + c] ?? 0;
198
- if (f !== 2 && f !== 3)
199
- return { row: prevRow, col: c };
200
- }
201
- }
202
- return { row, col };
203
- }
204
- function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows) {
205
- const x = (clientX - canvasRect.left) * dpr;
206
- const y = (clientY - canvasRect.top) * dpr;
207
- const col = clamp(Math.floor(x / (cellW || 1)), 0, (cols || 1) - 1);
208
- const row = clamp(Math.floor(y / (cellH || 1)), 0, (rows || 1) - 1);
209
- return { row, col };
210
- }
211
- async function copyToClipboard(text) {
212
- if (!text)
213
- return false;
214
- try {
215
- await navigator.clipboard.writeText(text);
216
- return true;
217
- } catch {
218
- const temp = document.createElement("textarea");
219
- temp.value = text;
220
- temp.style.position = "fixed";
221
- temp.style.opacity = "0";
222
- document.body.appendChild(temp);
223
- temp.select();
224
- try {
225
- document.execCommand("copy");
226
- return true;
227
- } catch {
228
- return false;
229
- } finally {
230
- document.body.removeChild(temp);
231
- }
232
- }
233
- }
234
- async function pasteFromClipboard() {
235
- try {
236
- return await navigator.clipboard.readText();
237
- } catch {
238
- return null;
239
- }
240
- }
101
+ updateImePosition,
102
+ updateSelection
103
+ } from "./chunk-pab3ge3d.js";
241
104
  export {
242
105
  updateSelection,
243
106
  updateImePosition,
@@ -1,5 +1,10 @@
1
1
  export * from "./shapes";
2
2
  export * from "./types";
3
- export * from "./shaders";
4
- export * from "./webgpu";
3
+ export * from "./shaders/rect";
4
+ export * from "./shaders/glyph-gl";
5
+ export * from "./shaders/glyph-wgsl";
6
+ export * from "./webgpu/setup";
7
+ export * from "./webgpu/webgl";
8
+ export * from "./webgpu/buffers";
9
+ export * from "./webgpu/state";
5
10
  export { BOX_LINE_MAP } from "./box-drawing-map";
@@ -0,0 +1,4 @@
1
+ /** WebGL2 vertex shader for rendering textured glyph quads. */
2
+ export declare const GLYPH_SHADER_GL_VERT = "#version 300 es\nprecision highp float;\n\nuniform vec2 u_resolution;\n\nlayout(location = 0) in vec2 a_quad;\nlayout(location = 1) in vec2 a_pos;\nlayout(location = 2) in vec2 a_size;\nlayout(location = 3) in vec2 a_uv0;\nlayout(location = 4) in vec2 a_uv1;\nlayout(location = 5) in vec4 a_color;\nlayout(location = 6) in vec4 a_bg;\nlayout(location = 7) in float a_slant;\nlayout(location = 8) in float a_mode;\n\nout vec2 v_uv;\nout vec4 v_color;\nout vec4 v_bg;\nout float v_mode;\n\nvoid main() {\n vec2 pixel = a_pos + vec2(a_quad.x * a_size.x + a_slant * (1.0 - a_quad.y), a_quad.y * a_size.y);\n vec2 clip = vec2(\n (pixel.x / u_resolution.x) * 2.0 - 1.0,\n 1.0 - (pixel.y / u_resolution.y) * 2.0\n );\n v_uv = a_uv0 + (a_uv1 - a_uv0) * a_quad;\n gl_Position = vec4(clip, 0.0, 1.0);\n v_color = a_color;\n v_bg = a_bg;\n v_mode = a_mode;\n}\n";
3
+ /** WebGL2 fragment shader for sampling glyph atlas textures with linear filtering. */
4
+ export declare const GLYPH_SHADER_GL_FRAG = "#version 300 es\nprecision highp float;\n\nuniform sampler2D u_atlas;\nuniform vec2 u_blend;\n\nin vec2 v_uv;\nin vec4 v_color;\nin vec4 v_bg;\nin float v_mode;\nout vec4 fragColor;\n\n// sRGB to linear conversion for proper blending\nfloat srgbToLinear(float c) {\n if (c <= 0.04045) {\n return c / 12.92;\n }\n return pow((c + 0.055) / 1.055, 2.4);\n}\n\n// Linear to sRGB conversion\nfloat linearToSrgb(float c) {\n if (c <= 0.0031308) {\n return c * 12.92;\n }\n return 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\n\nvec3 srgbToLinear(vec3 c) {\n return vec3(srgbToLinear(c.r), srgbToLinear(c.g), srgbToLinear(c.b));\n}\n\nvec3 linearToSrgb(vec3 c) {\n return vec3(linearToSrgb(c.r), linearToSrgb(c.g), linearToSrgb(c.b));\n}\n\nfloat luminance(vec3 color) {\n return dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\n\nvoid main() {\n vec4 atlasSample = texture(u_atlas, v_uv);\n bool useLinear = u_blend.x > 0.5;\n bool useCorrection = u_blend.y > 0.5;\n\n if (v_mode > 0.5) {\n vec4 color = atlasSample;\n if (useLinear) {\n color.rgb = srgbToLinear(color.rgb);\n }\n color.rgb *= color.a;\n fragColor = color;\n return;\n }\n\n vec4 fg = v_color;\n vec4 bg = v_bg;\n if (useLinear) {\n fg.rgb = srgbToLinear(fg.rgb);\n bg.rgb = srgbToLinear(bg.rgb);\n }\n fg.rgb *= fg.a;\n bg.rgb *= bg.a;\n\n float alpha = atlasSample.a;\n if (useCorrection && useLinear) {\n float fg_l = luminance(fg.rgb);\n float bg_l = luminance(bg.rgb);\n if (abs(fg_l - bg_l) > 0.001) {\n float blend_l = srgbToLinear(linearToSrgb(fg_l) * alpha + linearToSrgb(bg_l) * (1.0 - alpha));\n alpha = clamp((blend_l - bg_l) / (fg_l - bg_l), 0.0, 1.0);\n }\n }\n\n vec4 color = fg * alpha;\n fragColor = color;\n}\n";