@svelterm/core 0.1.0 → 0.21.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 (164) hide show
  1. package/CHANGELOG.md +425 -0
  2. package/README.md +42 -29
  3. package/dist/src/cli/build.d.ts +13 -0
  4. package/dist/src/cli/build.js +119 -0
  5. package/dist/src/cli/bundle.d.ts +25 -0
  6. package/dist/src/cli/bundle.js +61 -0
  7. package/dist/src/cli/dev.d.ts +10 -0
  8. package/dist/src/cli/dev.js +152 -0
  9. package/dist/src/cli/devtools.d.ts +9 -0
  10. package/dist/src/cli/devtools.js +47 -0
  11. package/dist/src/cli/init.d.ts +8 -0
  12. package/dist/src/cli/init.js +153 -0
  13. package/dist/src/cli/main.d.ts +9 -0
  14. package/dist/src/cli/main.js +52 -0
  15. package/dist/src/cli/svt-bin.d.ts +2 -0
  16. package/dist/src/cli/svt-bin.js +6 -0
  17. package/dist/src/cli/svt.d.ts +14 -0
  18. package/dist/src/cli/svt.js +76 -0
  19. package/dist/src/components/text-buffer.js +8 -5
  20. package/dist/src/css/animation-runner.d.ts +15 -6
  21. package/dist/src/css/animation-runner.js +80 -29
  22. package/dist/src/css/animation.d.ts +12 -0
  23. package/dist/src/css/animation.js +21 -0
  24. package/dist/src/css/calc.js +4 -3
  25. package/dist/src/css/color.d.ts +19 -0
  26. package/dist/src/css/color.js +371 -62
  27. package/dist/src/css/compute.d.ts +30 -3
  28. package/dist/src/css/compute.js +272 -33
  29. package/dist/src/css/defaults.d.ts +1 -1
  30. package/dist/src/css/defaults.js +9 -0
  31. package/dist/src/css/easing.d.ts +9 -0
  32. package/dist/src/css/easing.js +95 -0
  33. package/dist/src/css/incremental.d.ts +1 -1
  34. package/dist/src/css/incremental.js +2 -2
  35. package/dist/src/css/interpolate.d.ts +13 -0
  36. package/dist/src/css/interpolate.js +41 -0
  37. package/dist/src/css/parser.js +59 -3
  38. package/dist/src/css/pseudo-elements.d.ts +9 -0
  39. package/dist/src/css/pseudo-elements.js +97 -0
  40. package/dist/src/css/selector.d.ts +17 -2
  41. package/dist/src/css/selector.js +128 -13
  42. package/dist/src/css/specificity.js +17 -6
  43. package/dist/src/css/values.d.ts +6 -1
  44. package/dist/src/css/values.js +13 -6
  45. package/dist/src/debug/context.d.ts +13 -0
  46. package/dist/src/debug/context.js +11 -0
  47. package/dist/src/debug/css.d.ts +12 -0
  48. package/dist/src/debug/css.js +28 -0
  49. package/dist/src/debug/dom.d.ts +17 -0
  50. package/dist/src/debug/dom.js +92 -0
  51. package/dist/src/devtools/DevTools.compiled.js +327 -0
  52. package/dist/src/devtools/DevTools.css.js +1 -0
  53. package/dist/src/devtools/client.d.ts +36 -0
  54. package/dist/src/devtools/client.js +76 -0
  55. package/dist/src/framelog.d.ts +54 -0
  56. package/dist/src/framelog.js +99 -0
  57. package/dist/src/headless.js +12 -4
  58. package/dist/src/index.d.ts +65 -3
  59. package/dist/src/index.js +609 -81
  60. package/dist/src/input/checkable.d.ts +8 -0
  61. package/dist/src/input/checkable.js +66 -0
  62. package/dist/src/input/details.d.ts +6 -0
  63. package/dist/src/input/details.js +34 -0
  64. package/dist/src/input/focus.d.ts +6 -0
  65. package/dist/src/input/focus.js +27 -9
  66. package/dist/src/input/keyboard.d.ts +2 -2
  67. package/dist/src/input/keyboard.js +32 -5
  68. package/dist/src/input/label.d.ts +8 -0
  69. package/dist/src/input/label.js +53 -0
  70. package/dist/src/input/modal.d.ts +9 -0
  71. package/dist/src/input/modal.js +28 -0
  72. package/dist/src/input/mouse.d.ts +2 -2
  73. package/dist/src/input/mouse.js +15 -2
  74. package/dist/src/input/select.d.ts +12 -0
  75. package/dist/src/input/select.js +63 -0
  76. package/dist/src/input/selection.d.ts +48 -0
  77. package/dist/src/input/selection.js +150 -0
  78. package/dist/src/layout/engine.d.ts +2 -0
  79. package/dist/src/layout/engine.js +1084 -142
  80. package/dist/src/layout/flex.js +4 -4
  81. package/dist/src/layout/size.js +3 -2
  82. package/dist/src/layout/text.d.ts +3 -2
  83. package/dist/src/layout/text.js +96 -17
  84. package/dist/src/layout/unicode.d.ts +20 -0
  85. package/dist/src/layout/unicode.js +121 -0
  86. package/dist/src/render/animation-clock.d.ts +51 -0
  87. package/dist/src/render/animation-clock.js +213 -0
  88. package/dist/src/render/ansi-text.d.ts +26 -0
  89. package/dist/src/render/ansi-text.js +131 -0
  90. package/dist/src/render/ansi.d.ts +18 -0
  91. package/dist/src/render/ansi.js +64 -19
  92. package/dist/src/render/border.js +166 -17
  93. package/dist/src/render/buffer.d.ts +1 -0
  94. package/dist/src/render/buffer.js +5 -2
  95. package/dist/src/render/color-depth.d.ts +8 -0
  96. package/dist/src/render/color-depth.js +59 -0
  97. package/dist/src/render/context.d.ts +1 -0
  98. package/dist/src/render/context.js +17 -21
  99. package/dist/src/render/cursor-emit.d.ts +18 -0
  100. package/dist/src/render/cursor-emit.js +50 -0
  101. package/dist/src/render/diff.d.ts +12 -0
  102. package/dist/src/render/diff.js +120 -0
  103. package/dist/src/render/generation.d.ts +9 -0
  104. package/dist/src/render/generation.js +14 -0
  105. package/dist/src/render/graphics-layer.d.ts +27 -0
  106. package/dist/src/render/graphics-layer.js +86 -0
  107. package/dist/src/render/image.d.ts +27 -0
  108. package/dist/src/render/image.js +113 -0
  109. package/dist/src/render/incremental-paint.d.ts +7 -3
  110. package/dist/src/render/incremental-paint.js +52 -79
  111. package/dist/src/render/inline.d.ts +59 -0
  112. package/dist/src/render/inline.js +219 -0
  113. package/dist/src/render/kitty-graphics.d.ts +24 -0
  114. package/dist/src/render/kitty-graphics.js +58 -0
  115. package/dist/src/render/paint-text.js +68 -22
  116. package/dist/src/render/paint.d.ts +8 -1
  117. package/dist/src/render/paint.js +328 -30
  118. package/dist/src/render/png.d.ts +13 -0
  119. package/dist/src/render/png.js +145 -0
  120. package/dist/src/render/scrollbar.d.ts +8 -2
  121. package/dist/src/render/scrollbar.js +71 -14
  122. package/dist/src/render/snapshot.js +3 -1
  123. package/dist/src/renderer/default.d.ts +7 -0
  124. package/dist/src/renderer/default.js +11 -0
  125. package/dist/src/renderer/index.d.ts +8 -2
  126. package/dist/src/renderer/index.js +4 -2
  127. package/dist/src/renderer/node.d.ts +109 -0
  128. package/dist/src/renderer/node.js +165 -1
  129. package/dist/src/terminal/capabilities.d.ts +33 -0
  130. package/dist/src/terminal/capabilities.js +66 -0
  131. package/dist/src/terminal/clipboard.d.ts +9 -0
  132. package/dist/src/terminal/clipboard.js +39 -0
  133. package/dist/src/terminal/io.d.ts +82 -0
  134. package/dist/src/terminal/io.js +155 -0
  135. package/dist/src/terminal/screen.d.ts +3 -10
  136. package/dist/src/terminal/screen.js +5 -28
  137. package/dist/src/terminal/stdin-router.d.ts +8 -5
  138. package/dist/src/terminal/stdin-router.js +22 -11
  139. package/dist/src/utils/node-map.d.ts +24 -0
  140. package/dist/src/utils/node-map.js +75 -0
  141. package/dist/src/vite/config.d.ts +62 -0
  142. package/dist/src/vite/config.js +191 -0
  143. package/docs/compatibility.md +67 -0
  144. package/docs/debug/devtools.md +40 -0
  145. package/docs/debug/svt.md +50 -0
  146. package/docs/distribution.md +106 -0
  147. package/docs/elements.md +120 -0
  148. package/docs/getting-started.md +177 -0
  149. package/docs/guide/css.md +187 -0
  150. package/docs/guide/input.md +143 -0
  151. package/docs/guide/layout.md +171 -0
  152. package/docs/guide/theming.md +94 -0
  153. package/docs/how-it-works.md +115 -0
  154. package/docs/inline-mode.md +77 -0
  155. package/docs/layout.md +106 -0
  156. package/docs/motion.md +91 -0
  157. package/docs/reference/README.md +65 -0
  158. package/docs/reference/css/properties/border-corner.md +82 -0
  159. package/docs/reference/css/properties/border-style.md +168 -0
  160. package/docs/reference.md +226 -0
  161. package/docs/selectors.md +80 -0
  162. package/docs/terminal-css.md +149 -0
  163. package/docs/terminals.md +83 -0
  164. package/package.json +28 -7
@@ -0,0 +1,83 @@
1
+ # Terminal support
2
+
3
+ ## Support matrix
4
+
5
+ "Verified" means exercised interactively (rendering, input, the feature
6
+ columns below). "Expected" means the terminal advertises the required
7
+ capabilities and svelterm's output round-trips against a terminal model
8
+ in CI, but nobody has watched it run there yet — reports welcome.
9
+
10
+ | Terminal | Status | Truecolor | DEC 2026 | Kitty keys | OSC 52 | Graphics |
11
+ |---|---|---|---|---|---|---|
12
+ | Ghostty | verified | ✓ | ✓ | ✓ | ✓ | ✓ |
13
+ | tmux (3.4+) | verified | ✓ (with `tmux-256color`) | ✓ | pass-through | needs `set-clipboard on` | passthrough only |
14
+ | kitty | expected | ✓ | ✓ | ✓ | ✓ | ✓ |
15
+ | WezTerm | expected | ✓ | ✓ | ✓ | ✓ | ✓ |
16
+ | iTerm2 | expected | ✓ | ✓ | ✗ (legacy keys) | ✓ | ✗ (own protocol) |
17
+ | Alacritty | expected | ✓ | ✗ | ✓ | ✓ | ✗ |
18
+ | Terminal.app | expected | ✗ (256) | ✗ | ✗ | ✗ | ✗ |
19
+ | Windows Terminal | unknown | ✓ | ✗ | ✗ | ✓ | ✗ |
20
+ | Linux console | unknown | ✗ (16) | ✗ | ✗ | ✗ | ✗ |
21
+
22
+ Every degradation path (truecolor → 256 → 16 → mono, sync output off,
23
+ legacy keys) is tested in CI by round-tripping svelterm's emitted ANSI
24
+ through a terminal model and asserting the resulting grid — so an
25
+ "expected" terminal failing would mean a capability report bug, not a
26
+ rendering one.
27
+
28
+ svelterm adapts its output to the terminal it lands in. Detection runs in
29
+ the background at startup; the first frame paints with today's most common
30
+ defaults (truecolor, synchronized output) and re-paints if the terminal
31
+ turns out to be older.
32
+
33
+ ## Colour depth
34
+
35
+ Hex/RGB colours quantize at emit time to what the terminal can show:
36
+
37
+ | Depth | Emitted as | Chosen when |
38
+ |---|---|---|
39
+ | `truecolor` | `38;2;r;g;b` | `COLORTERM=truecolor`/`24bit`, or a known-truecolor terminal answers XTVERSION (iTerm2, kitty, WezTerm, Ghostty, Alacritty, Contour, Rio, VS Code) |
40
+ | `256` | `38;5;n` — nearest xterm cube/grey-ramp entry | `TERM` contains `256color` |
41
+ | `16` | nearest base colour's SGR code | everything else |
42
+ | `mono` | no colour output | [`NO_COLOR`](https://no-color.org/) is set |
43
+
44
+ ANSI colour names (`red`, `cyan`, …) pass through unchanged at every depth
45
+ — they always mean "the terminal's palette colour".
46
+
47
+ Override detection with `run(App, { colorDepth: '256' })`.
48
+
49
+ ## Synchronized output
50
+
51
+ Frames are wrapped in DEC 2026 begin/end-synchronized-update so terminals
52
+ that support it repaint atomically (no tearing on large updates). Support
53
+ is probed with `DECRQM`; terminals that don't answer get plain writes.
54
+
55
+ ## Colour scheme
56
+
57
+ `prefers-color-scheme` resolves from an OSC 11 background query, polled so
58
+ a live theme switch re-renders the app. Pin it with
59
+ `run(App, { colorScheme: 'light' })` (embedded terminals do this — the
60
+ OSC channel is meaningless there).
61
+
62
+ ## Text selection and clipboard
63
+
64
+ Mouse reporting turns off the terminal's native selection, so svelterm
65
+ provides its own: **drag** selects a cell range (painted inverted),
66
+ **double-click** selects the word, **triple-click** the line. Releasing
67
+ the button copies the selection — via OSC 52 (survives ssh; needs the
68
+ terminal to allow clipboard writes) and the platform tool (`pbcopy`,
69
+ `wl-copy`/`xclip`, `clip`) when one exists. The highlight clears on the
70
+ next click.
71
+
72
+ ## Cursor shape
73
+
74
+ The real terminal cursor becomes a **bar** while a focused
75
+ `<input>`/`<textarea>` owns it (DECSCUSR), and resets to the terminal's
76
+ configured shape otherwise — including on exit.
77
+
78
+ ## Queries a svelterm app may send
79
+
80
+ At startup: OSC 11 (background colour), `CSI > 0 q` (XTVERSION, only when
81
+ the environment didn't already decide colour depth), `CSI ? 2026 $ p`
82
+ (DECRQM for synchronized output). All race a short timeout, so a terminal
83
+ that answers none of them just gets the conservative defaults.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svelterm/core",
3
- "version": "0.1.0",
3
+ "version": "0.21.0",
4
4
  "description": "Svelte 5 components rendered to the terminal with real CSS",
5
5
  "type": "module",
6
6
  "exports": {
@@ -15,17 +15,27 @@
15
15
  "./headless": {
16
16
  "types": "./dist/src/headless.d.ts",
17
17
  "default": "./dist/src/headless.js"
18
+ },
19
+ "./vite": {
20
+ "types": "./dist/src/vite/config.d.ts",
21
+ "default": "./dist/src/vite/config.js"
18
22
  }
19
23
  },
24
+ "bin": {
25
+ "svelterm": "./dist/src/cli/main.js",
26
+ "svt": "./dist/src/cli/svt-bin.js"
27
+ },
20
28
  "main": "./dist/src/renderer/default.js",
21
29
  "types": "./dist/src/renderer/default.d.ts",
22
30
  "files": [
23
31
  "dist/src",
32
+ "docs",
24
33
  "README.md",
25
- "LICENSE"
34
+ "LICENSE",
35
+ "CHANGELOG.md"
26
36
  ],
27
37
  "scripts": {
28
- "build": "tsc",
38
+ "build": "tsc && node scripts/compile-devtools.mjs",
29
39
  "test": "node --test dist/**/*.test.js",
30
40
  "dev": "tsc --watch",
31
41
  "demo": "DEMO=${DEMO:-counter} npx vite build && node dist-demo/${DEMO:-counter}/main.js",
@@ -35,17 +45,20 @@
35
45
  "demo:showcase": "DEMO=showcase npx vite build && node dist-demo/showcase/main.js",
36
46
  "demo:keyboard-hero": "DEMO=keyboard-hero npx vite build && node dist-demo/keyboard-hero/main.js",
37
47
  "demo:snake": "DEMO=snake npx vite build && node dist-demo/snake/main.js",
38
- "demo:themes": "DEMO=themes npx vite build && node dist-demo/themes/main.js"
48
+ "demo:themes": "DEMO=themes npx vite build && node dist-demo/themes/main.js",
49
+ "dev:counter": "npx vite dev --config vite.dev.config.ts",
50
+ "demo:inline": "DEMO=inline npx vite build && node dist-demo/inline/main.js"
39
51
  },
40
52
  "peerDependencies": {
41
53
  "svelte": "^5.0.0"
42
54
  },
43
55
  "devDependencies": {
44
- "@sveltejs/vite-plugin-svelte": "^7.0.0",
56
+ "@sveltejs/vite-plugin-svelte": "file:../vite-plugin-svelte-fork/packages/vite-plugin-svelte",
45
57
  "@types/node": "^25.5.0",
46
58
  "@types/ws": "^8.18.1",
47
59
  "typescript": "^6.0.2",
48
- "vite": "^8.0.3"
60
+ "vite": "^8.0.3",
61
+ "yoga-layout": "^3.2.1"
49
62
  },
50
63
  "dependencies": {
51
64
  "ws": "^8.20.0"
@@ -60,5 +73,13 @@
60
73
  "renderer"
61
74
  ],
62
75
  "author": "Tom Yandell",
63
- "license": "MIT"
76
+ "license": "MIT",
77
+ "repository": {
78
+ "type": "git",
79
+ "url": "git+https://github.com/tomyan/svelterm.git"
80
+ },
81
+ "homepage": "https://svelterm.dev",
82
+ "bugs": {
83
+ "url": "https://github.com/tomyan/svelterm/issues"
84
+ }
64
85
  }