termcast 1.3.30 → 1.3.32

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 (294) hide show
  1. package/dist/apis/cache.d.ts.map +1 -1
  2. package/dist/apis/cache.js +4 -39
  3. package/dist/apis/cache.js.map +1 -1
  4. package/dist/apis/hud.d.ts.map +1 -1
  5. package/dist/apis/hud.js +13 -31
  6. package/dist/apis/hud.js.map +1 -1
  7. package/dist/apis/localstorage.d.ts.map +1 -1
  8. package/dist/apis/localstorage.js +3 -27
  9. package/dist/apis/localstorage.js.map +1 -1
  10. package/dist/apis/toast.d.ts +16 -43
  11. package/dist/apis/toast.d.ts.map +1 -1
  12. package/dist/apis/toast.js +78 -177
  13. package/dist/apis/toast.js.map +1 -1
  14. package/dist/build.d.ts +3 -1
  15. package/dist/build.d.ts.map +1 -1
  16. package/dist/build.js +52 -2
  17. package/dist/build.js.map +1 -1
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +206 -25
  21. package/dist/cli.js.map +1 -1
  22. package/dist/colors.d.ts.map +1 -1
  23. package/dist/colors.js +1 -0
  24. package/dist/colors.js.map +1 -1
  25. package/dist/compile.d.ts +0 -1
  26. package/dist/compile.d.ts.map +1 -1
  27. package/dist/compile.js +18 -23
  28. package/dist/compile.js.map +1 -1
  29. package/dist/components/actions.d.ts.map +1 -1
  30. package/dist/components/actions.js +30 -15
  31. package/dist/components/actions.js.map +1 -1
  32. package/dist/components/animation-tick.d.ts +12 -0
  33. package/dist/components/animation-tick.d.ts.map +1 -0
  34. package/dist/components/animation-tick.js +63 -0
  35. package/dist/components/animation-tick.js.map +1 -0
  36. package/dist/components/detail.d.ts.map +1 -1
  37. package/dist/components/detail.js +10 -13
  38. package/dist/components/detail.js.map +1 -1
  39. package/dist/components/dropdown.d.ts +1 -0
  40. package/dist/components/dropdown.d.ts.map +1 -1
  41. package/dist/components/dropdown.js +27 -26
  42. package/dist/components/dropdown.js.map +1 -1
  43. package/dist/components/extension-preferences.d.ts.map +1 -1
  44. package/dist/components/extension-preferences.js +15 -10
  45. package/dist/components/extension-preferences.js.map +1 -1
  46. package/dist/components/footer.d.ts +13 -0
  47. package/dist/components/footer.d.ts.map +1 -0
  48. package/dist/components/footer.js +106 -0
  49. package/dist/components/footer.js.map +1 -0
  50. package/dist/components/form/file-autocomplete.d.ts +19 -4
  51. package/dist/components/form/file-autocomplete.d.ts.map +1 -1
  52. package/dist/components/form/file-autocomplete.js +56 -55
  53. package/dist/components/form/file-autocomplete.js.map +1 -1
  54. package/dist/components/form/file-picker.d.ts.map +1 -1
  55. package/dist/components/form/file-picker.js +26 -15
  56. package/dist/components/form/file-picker.js.map +1 -1
  57. package/dist/components/form/index.d.ts.map +1 -1
  58. package/dist/components/form/index.js +17 -15
  59. package/dist/components/form/index.js.map +1 -1
  60. package/dist/components/form/with-left-border.d.ts.map +1 -1
  61. package/dist/components/form/with-left-border.js +4 -12
  62. package/dist/components/form/with-left-border.js.map +1 -1
  63. package/dist/components/list.d.ts.map +1 -1
  64. package/dist/components/list.js +126 -86
  65. package/dist/components/list.js.map +1 -1
  66. package/dist/components/loading-bar.d.ts.map +1 -1
  67. package/dist/components/loading-bar.js +5 -22
  68. package/dist/components/loading-bar.js.map +1 -1
  69. package/dist/components/loading-text.d.ts.map +1 -1
  70. package/dist/components/loading-text.js +3 -22
  71. package/dist/components/loading-text.js.map +1 -1
  72. package/dist/components/theme-picker.d.ts +2 -0
  73. package/dist/components/theme-picker.d.ts.map +1 -0
  74. package/dist/components/theme-picker.js +37 -0
  75. package/dist/components/theme-picker.js.map +1 -0
  76. package/dist/descendants.d.ts +6 -0
  77. package/dist/descendants.d.ts.map +1 -1
  78. package/dist/descendants.js +74 -8
  79. package/dist/descendants.js.map +1 -1
  80. package/dist/examples/internal/descendants-rerender.d.ts +14 -0
  81. package/dist/examples/internal/descendants-rerender.d.ts.map +1 -0
  82. package/dist/examples/internal/descendants-rerender.js +145 -0
  83. package/dist/examples/internal/descendants-rerender.js.map +1 -0
  84. package/dist/examples/internal/simple-dialog.js +4 -1
  85. package/dist/examples/internal/simple-dialog.js.map +1 -1
  86. package/dist/examples/internal/simple-scrollbox.js +1 -1
  87. package/dist/examples/internal/simple-scrollbox.js.map +1 -1
  88. package/dist/examples/list-with-dropdown.js +1 -1
  89. package/dist/examples/list-with-dropdown.js.map +1 -1
  90. package/dist/examples/miscellaneous.js +1 -1
  91. package/dist/examples/miscellaneous.js.map +1 -1
  92. package/dist/examples/toast-action.d.ts +2 -0
  93. package/dist/examples/toast-action.d.ts.map +1 -0
  94. package/dist/examples/toast-action.js +76 -0
  95. package/dist/examples/toast-action.js.map +1 -0
  96. package/dist/examples/toast-variations.js +38 -36
  97. package/dist/examples/toast-variations.js.map +1 -1
  98. package/dist/extensions/dev.d.ts +1 -1
  99. package/dist/extensions/dev.d.ts.map +1 -1
  100. package/dist/extensions/dev.js +62 -30
  101. package/dist/extensions/dev.js.map +1 -1
  102. package/dist/extensions/home.d.ts.map +1 -1
  103. package/dist/extensions/home.js +4 -3
  104. package/dist/extensions/home.js.map +1 -1
  105. package/dist/extensions/react-refresh-init.d.ts +5 -0
  106. package/dist/extensions/react-refresh-init.d.ts.map +1 -0
  107. package/dist/extensions/react-refresh-init.js +52 -0
  108. package/dist/extensions/react-refresh-init.js.map +1 -0
  109. package/dist/internal/date-picker-widget.js +1 -1
  110. package/dist/internal/date-picker-widget.js.map +1 -1
  111. package/dist/internal/dialog.d.ts +8 -3
  112. package/dist/internal/dialog.d.ts.map +1 -1
  113. package/dist/internal/dialog.js +37 -53
  114. package/dist/internal/dialog.js.map +1 -1
  115. package/dist/internal/navigation.d.ts +1 -0
  116. package/dist/internal/navigation.d.ts.map +1 -1
  117. package/dist/internal/navigation.js +25 -1
  118. package/dist/internal/navigation.js.map +1 -1
  119. package/dist/internal/providers.d.ts.map +1 -1
  120. package/dist/internal/providers.js +9 -197
  121. package/dist/internal/providers.js.map +1 -1
  122. package/dist/internal/scrollbox.d.ts.map +1 -1
  123. package/dist/internal/scrollbox.js +1 -0
  124. package/dist/internal/scrollbox.js.map +1 -1
  125. package/dist/release.d.ts +1 -0
  126. package/dist/release.d.ts.map +1 -1
  127. package/dist/release.js +16 -9
  128. package/dist/release.js.map +1 -1
  129. package/dist/state.d.ts +27 -1
  130. package/dist/state.d.ts.map +1 -1
  131. package/dist/state.js +6 -0
  132. package/dist/state.js.map +1 -1
  133. package/dist/theme.d.ts +6 -19
  134. package/dist/theme.d.ts.map +1 -1
  135. package/dist/theme.js +76 -45
  136. package/dist/theme.js.map +1 -1
  137. package/dist/themes/aura.json +69 -0
  138. package/dist/themes/ayu.json +80 -0
  139. package/dist/themes/catppuccin-frappe.json +233 -0
  140. package/dist/themes/catppuccin-macchiato.json +233 -0
  141. package/dist/themes/catppuccin.json +112 -0
  142. package/dist/themes/cobalt2.json +228 -0
  143. package/dist/themes/cursor.json +249 -0
  144. package/dist/themes/dracula.json +219 -0
  145. package/dist/themes/everforest.json +241 -0
  146. package/dist/themes/flexoki.json +237 -0
  147. package/dist/themes/github-light.json +56 -0
  148. package/dist/themes/github.json +241 -0
  149. package/dist/themes/gruvbox.json +95 -0
  150. package/dist/themes/kanagawa.json +77 -0
  151. package/dist/themes/lucent-orng.json +227 -0
  152. package/dist/themes/material.json +235 -0
  153. package/dist/themes/matrix.json +77 -0
  154. package/dist/themes/mercury.json +245 -0
  155. package/dist/themes/monokai.json +221 -0
  156. package/dist/themes/nightowl.json +221 -0
  157. package/dist/themes/nord.json +223 -0
  158. package/dist/themes/one-dark.json +84 -0
  159. package/dist/themes/opencode-light.json +62 -0
  160. package/dist/themes/opencode.json +245 -0
  161. package/dist/themes/orng.json +245 -0
  162. package/dist/themes/palenight.json +222 -0
  163. package/dist/themes/rosepine.json +234 -0
  164. package/dist/themes/solarized.json +223 -0
  165. package/dist/themes/synthwave84.json +226 -0
  166. package/dist/themes/termcast.json +226 -0
  167. package/dist/themes/tokyonight.json +243 -0
  168. package/dist/themes/vercel.json +255 -0
  169. package/dist/themes/vesper.json +218 -0
  170. package/dist/themes/zenburn.json +223 -0
  171. package/dist/themes.d.ts +57 -0
  172. package/dist/themes.d.ts.map +1 -0
  173. package/dist/themes.js +181 -0
  174. package/dist/themes.js.map +1 -0
  175. package/dist/utils/run-command.d.ts +2 -1
  176. package/dist/utils/run-command.d.ts.map +1 -1
  177. package/dist/utils/run-command.js +20 -10
  178. package/dist/utils/run-command.js.map +1 -1
  179. package/dist/utils.d.ts +2 -1
  180. package/dist/utils.d.ts.map +1 -1
  181. package/dist/utils.js +90 -17
  182. package/dist/utils.js.map +1 -1
  183. package/dist/watcher.d.ts +3 -0
  184. package/dist/watcher.d.ts.map +1 -0
  185. package/dist/watcher.js +16 -0
  186. package/dist/watcher.js.map +1 -0
  187. package/package.json +16 -10
  188. package/src/apis/cache.tsx +5 -44
  189. package/src/apis/hud.tsx +17 -62
  190. package/src/apis/localstorage.tsx +3 -32
  191. package/src/apis/toast.tsx +91 -275
  192. package/src/build.test.tsx +10 -0
  193. package/src/build.tsx +61 -1
  194. package/src/cli.tsx +365 -103
  195. package/src/colors.tsx +1 -0
  196. package/src/compile.tsx +21 -29
  197. package/src/compile.vitest.tsx +300 -0
  198. package/src/components/actions.tsx +64 -45
  199. package/src/components/animation-tick.tsx +85 -0
  200. package/src/components/detail.tsx +31 -35
  201. package/src/components/dropdown.tsx +32 -21
  202. package/src/components/extension-preferences.tsx +14 -10
  203. package/src/components/footer.tsx +241 -0
  204. package/src/components/form/file-autocomplete.tsx +80 -60
  205. package/src/components/form/file-picker.tsx +37 -25
  206. package/src/components/form/index.tsx +45 -41
  207. package/src/components/form/with-left-border.tsx +4 -14
  208. package/src/components/list.tsx +181 -121
  209. package/src/components/loading-bar.tsx +5 -25
  210. package/src/components/loading-text.tsx +4 -23
  211. package/src/components/theme-picker.tsx +57 -0
  212. package/src/descendants.tsx +98 -9
  213. package/src/examples/actions-dialog-layout.vitest.tsx +112 -0
  214. package/src/examples/file-autocomplete.vitest.tsx +131 -122
  215. package/src/examples/form-basic.vitest.tsx +463 -644
  216. package/src/examples/form-dropdown.vitest.tsx +553 -571
  217. package/src/examples/form-scroll.vitest.tsx +112 -102
  218. package/src/examples/form-tagpicker.vitest.tsx +364 -338
  219. package/src/examples/internal/descendants-rerender.tsx +273 -0
  220. package/src/examples/internal/descendants-rerender.vitest.tsx +194 -0
  221. package/src/examples/internal/simple-dialog.tsx +4 -4
  222. package/src/examples/internal/simple-scrollbox.tsx +2 -2
  223. package/src/examples/internal/simple-scrollbox.vitest.tsx +43 -31
  224. package/src/examples/list-detail-metadata.vitest.tsx +34 -30
  225. package/src/examples/list-dropdown-default.vitest.tsx +84 -72
  226. package/src/examples/list-empty-view.vitest.tsx +93 -0
  227. package/src/examples/list-fetch-data.vitest.tsx +36 -30
  228. package/src/examples/list-scrollbox.vitest.tsx +59 -39
  229. package/src/examples/list-with-detail.vitest.tsx +339 -314
  230. package/src/examples/list-with-dropdown.tsx +1 -0
  231. package/src/examples/list-with-dropdown.vitest.tsx +176 -150
  232. package/src/examples/list-with-sections.vitest.tsx +289 -270
  233. package/src/examples/list-with-toast.vitest.tsx +44 -44
  234. package/src/examples/miscellaneous.tsx +10 -0
  235. package/src/examples/simple-file-picker.vitest.tsx +90 -86
  236. package/src/examples/simple-grid.vitest.tsx +275 -249
  237. package/src/examples/simple-navigation.vitest.tsx +192 -168
  238. package/src/examples/store.vitest.tsx +6 -4
  239. package/src/examples/swift-extension.vitest.tsx +31 -19
  240. package/src/examples/synonyms.vitest.tsx +93 -83
  241. package/src/examples/toast-action.tsx +160 -0
  242. package/src/examples/toast-action.vitest.tsx +404 -0
  243. package/src/examples/toast-variations.tsx +58 -57
  244. package/src/examples/toast-variations.vitest.tsx +186 -166
  245. package/src/extensions/dev.tsx +74 -33
  246. package/src/extensions/dev.vitest.tsx +162 -69
  247. package/src/extensions/home.tsx +5 -6
  248. package/src/extensions/react-refresh-init.tsx +59 -0
  249. package/src/internal/date-picker-widget.tsx +1 -1
  250. package/src/internal/dialog.tsx +59 -83
  251. package/src/internal/navigation.tsx +37 -4
  252. package/src/internal/providers.tsx +27 -315
  253. package/src/internal/scrollbox.tsx +1 -0
  254. package/src/release.tsx +16 -10
  255. package/src/state.tsx +36 -3
  256. package/src/theme.tsx +82 -51
  257. package/src/themes/aura.json +69 -0
  258. package/src/themes/ayu.json +80 -0
  259. package/src/themes/catppuccin-frappe.json +233 -0
  260. package/src/themes/catppuccin-macchiato.json +233 -0
  261. package/src/themes/catppuccin.json +112 -0
  262. package/src/themes/cobalt2.json +228 -0
  263. package/src/themes/cursor.json +249 -0
  264. package/src/themes/dracula.json +219 -0
  265. package/src/themes/everforest.json +241 -0
  266. package/src/themes/flexoki.json +237 -0
  267. package/src/themes/github-light.json +56 -0
  268. package/src/themes/github.json +241 -0
  269. package/src/themes/gruvbox.json +95 -0
  270. package/src/themes/kanagawa.json +77 -0
  271. package/src/themes/lucent-orng.json +227 -0
  272. package/src/themes/material.json +235 -0
  273. package/src/themes/matrix.json +77 -0
  274. package/src/themes/mercury.json +252 -0
  275. package/src/themes/monokai.json +221 -0
  276. package/src/themes/nightowl.json +221 -0
  277. package/src/themes/nord.json +223 -0
  278. package/src/themes/one-dark.json +84 -0
  279. package/src/themes/opencode-light.json +62 -0
  280. package/src/themes/opencode.json +245 -0
  281. package/src/themes/orng.json +245 -0
  282. package/src/themes/palenight.json +222 -0
  283. package/src/themes/rosepine.json +234 -0
  284. package/src/themes/solarized.json +223 -0
  285. package/src/themes/synthwave84.json +226 -0
  286. package/src/themes/termcast.json +227 -0
  287. package/src/themes/tokyonight.json +243 -0
  288. package/src/themes/vercel.json +255 -0
  289. package/src/themes/vesper.json +218 -0
  290. package/src/themes/zenburn.json +223 -0
  291. package/src/themes.ts +291 -0
  292. package/src/utils/run-command.tsx +23 -12
  293. package/src/utils.tsx +115 -18
  294. package/src/watcher.tsx +19 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher.js","sourceRoot":"","sources":["../src/watcher.tsx"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,iFAAiF;AACjF,2DAA2D;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAGvD,IAAI,QAA0C,CAAA;AAE9C,MAAM,UAAU,UAAU;IACxB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC7B,oFAAoF;IACpF,sDAAsD;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,MAAM,OAAO,GAAG,OAAO,CACrB,mBAAmB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAC/D,CAAA;IACD,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,QAAS,CAAA;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "termcast",
3
- "version": "1.3.30",
3
+ "version": "1.3.32",
4
4
  "description": "Raycast for the terminal",
5
5
  "repository": "https://github.com/remorses/termcast",
6
6
  "scripts": {
7
7
  "build": "tsc && bun run binary",
8
- "prepublishOnly": "tsc",
8
+ "prepublishOnly": "tsc && chmod +x dist/cli.js",
9
9
  "release": "cd .. && bun changeset version && /Users/morse/Documents/GitHub/changesets/packages/cli/bin.js publish # my own fork to support github releases",
10
10
  "binary": "bun build ./src/cli.tsx --env-file=\"\" --compile --outfile bin",
11
11
  "see-raycast-types": "zed node_modules/@raycast/api/types/index.d.ts",
@@ -13,7 +13,9 @@
13
13
  "test": "bun test && bun e2e",
14
14
  "e2e": "vitest -u"
15
15
  },
16
- "bin": "./dist/cli.js",
16
+ "bin": {
17
+ "termcast": "./dist/cli.js"
18
+ },
17
19
  "exports": {
18
20
  ".": {
19
21
  "bun": "./src/index.tsx",
@@ -31,9 +33,11 @@
31
33
  "author": "Tommaso De Rossi, morse <beats.by.morse@gmail.com>",
32
34
  "license": "",
33
35
  "dependencies": {
34
- "@opentui/core": "0.1.61",
35
- "@opentui/react": "0.1.61",
36
+ "@opentui/core": "0.1.68",
37
+ "@opentui/react": "0.1.68",
36
38
  "@parcel/watcher": "^2.5.1",
39
+ "@swc/core": "^1.15.7",
40
+ "@swc/wasm": "^1.15.8",
37
41
  "@tanstack/react-query": "^5.85.5",
38
42
  "@tanstack/react-query-persist-client": "^5.85.5",
39
43
  "cac": "^6.7.14",
@@ -44,6 +48,7 @@
44
48
  "nanoid": "^5.1.5",
45
49
  "node-diff3": "^3.2.0",
46
50
  "react-hook-form": "^7.62.0",
51
+ "react-refresh": "^0.18.0",
47
52
  "string-dedent": "^3.0.2",
48
53
  "zustand": "^5.0.8"
49
54
  },
@@ -51,15 +56,16 @@
51
56
  "react": "*"
52
57
  },
53
58
  "devDependencies": {
54
- "tuistory": "workspace:*",
55
- "react": "^19.2.0",
56
- "@types/bun": "^1.3.5",
57
- "@types/node": "^25.0.3",
58
59
  "@raycast/api": "^1.102.5",
59
60
  "@raycast/utils": "^2.2.1",
61
+ "@types/bun": "^1.3.5",
62
+ "@types/node": "^25.0.3",
60
63
  "@xterm/addon-serialize": "^0.13.0",
61
64
  "@xterm/headless": "^5.5.0",
62
- "bun-pty": "^0.4.2",
65
+ "bun-pty": "0.4.2",
66
+ "node-pty": "^1.1.0",
67
+ "react": "^19.2.0",
68
+ "tuistory": "workspace:*",
63
69
  "vitest": "^4.0.16"
64
70
  }
65
71
  }
@@ -5,64 +5,25 @@ import * as fs from 'fs'
5
5
  import { logger } from '../logger'
6
6
  import { useStore } from '../state'
7
7
 
8
- // Detect install directory for compiled extensions from binary path
9
- // Binary is at ~/.termcast/compiled/{name}/bin/{name}, data goes in ~/.termcast/compiled/{name}/
10
- function getCompiledExtensionDir(): string | null {
11
- const execPath = process.execPath
12
- const homeDir = os.homedir()
13
- const compiledPrefix = path.join(homeDir, '.termcast', 'compiled')
14
-
15
- // Check if binary is inside ~/.termcast/compiled/{name}/bin/
16
- if (execPath.startsWith(compiledPrefix)) {
17
- const relativePath = execPath.slice(compiledPrefix.length + 1) // +1 for trailing slash
18
- const parts = relativePath.split(path.sep)
19
- if (parts.length >= 2 && parts[1] === 'bin') {
20
- // parts[0] is the extension name
21
- return path.join(compiledPrefix, parts[0])
22
- }
23
- }
24
- return null
25
- }
26
-
27
8
  function getCurrentDatabasePath(): string {
28
9
  const { extensionPath } = useStore.getState()
29
10
 
30
- // For filesystem-based extensions (dev mode, store mode), use the extension directory
31
11
  if (extensionPath) {
32
12
  return path.join(extensionPath, '.termcast-bundle', 'data.db')
33
13
  }
34
14
 
35
- // For compiled extensions, detect install dir from binary path
36
- const compiledDir = getCompiledExtensionDir()
37
- if (compiledDir) {
38
- return path.join(compiledDir, 'data.db')
39
- }
40
-
41
- // Fallback for unknown context
15
+ // Fallback for examples/tests that don't set extensionPath
42
16
  return path.join(os.homedir(), '.termcast', '.termcast-bundle', 'data.db')
43
17
  }
44
18
 
45
19
  function getCurrentCacheDir(namespace?: string): string {
46
20
  const { extensionPath } = useStore.getState()
47
21
 
48
- // For filesystem-based extensions (dev mode, store mode), use the extension directory
49
- if (extensionPath) {
50
- return namespace
51
- ? path.join(extensionPath, '.termcast-bundle', 'cache', namespace)
52
- : path.join(extensionPath, '.termcast-bundle', 'cache')
53
- }
54
-
55
- // For compiled extensions, detect install dir from binary path
56
- const compiledDir = getCompiledExtensionDir()
57
- if (compiledDir) {
58
- const baseDir = path.join(compiledDir, 'cache')
59
- return namespace ? path.join(baseDir, namespace) : baseDir
60
- }
61
-
62
- // Fallback for unknown context
63
- return namespace
64
- ? path.join(os.homedir(), '.termcast', '.termcast-bundle', 'cache', namespace)
22
+ const baseDir = extensionPath
23
+ ? path.join(extensionPath, '.termcast-bundle', 'cache')
65
24
  : path.join(os.homedir(), '.termcast', '.termcast-bundle', 'cache')
25
+
26
+ return namespace ? path.join(baseDir, namespace) : baseDir
66
27
  }
67
28
 
68
29
  export class Cache {
package/src/apis/hud.tsx CHANGED
@@ -1,63 +1,10 @@
1
- import React, { useEffect } from 'react'
2
- import { Theme } from 'termcast/src/theme'
3
- import { TextAttributes } from '@opentui/core'
4
1
  import { logger } from 'termcast/src/logger'
5
- import { useStore } from 'termcast/src/state'
6
- import { useTerminalDimensions } from '@opentui/react'
7
- import { Toast } from 'termcast/src/apis/toast'
2
+ import { useStore, ToastData } from 'termcast/src/state'
8
3
  import { PopToRootType } from 'termcast/src/apis/window'
9
4
 
10
5
  // Re-export PopToRootType from window module
11
6
  export { PopToRootType } from 'termcast/src/apis/window'
12
7
 
13
- interface HUDComponentProps {
14
- title: string
15
- onHide: () => void
16
- }
17
-
18
- function HUDComponent({ title, onHide }: HUDComponentProps): any {
19
- const dimensions = useTerminalDimensions()
20
-
21
- useEffect(() => {
22
- // HUD displays for 2 seconds then automatically hides
23
- const timer = setTimeout(() => {
24
- onHide()
25
- }, 2000)
26
- return () => clearTimeout(timer)
27
- }, [onHide])
28
-
29
- // Center the HUD message
30
- const padding = Math.max(
31
- 0,
32
- Math.floor((dimensions.width - title.length - 4) / 2),
33
- )
34
-
35
- return (
36
- <box
37
- borderColor={Theme.border}
38
- paddingLeft={1}
39
- paddingRight={1}
40
- flexDirection='row'
41
- alignItems='center'
42
- >
43
- <text paddingLeft={padding}>✓ </text>
44
- <text fg={Theme.text} attributes={TextAttributes.BOLD}>
45
- {title}
46
- </text>
47
- </box>
48
- )
49
- }
50
-
51
- // Create a custom Toast class for HUD that displays with HUD styling
52
- class HUDToast extends Toast {
53
- constructor(title: string) {
54
- super({
55
- title,
56
- style: Toast.Style.Success,
57
- })
58
- }
59
- }
60
-
61
8
  export async function showHUD(
62
9
  title: string,
63
10
  options?: {
@@ -65,18 +12,26 @@ export async function showHUD(
65
12
  popToRootType?: PopToRootType
66
13
  },
67
14
  ): Promise<void> {
15
+ const onHide = () => {
16
+ useStore.setState({ toast: null, toastWithPrimaryAction: false })
17
+ }
18
+
19
+ const toastData: ToastData = {
20
+ id: Math.random().toString(36).substring(7),
21
+ title,
22
+ style: 'SUCCESS',
23
+ onHide,
24
+ }
25
+
68
26
  // Show the HUD component in the toast area (bottom of screen)
69
27
  useStore.setState({
70
- toast: (
71
- <HUDComponent
72
- title={title}
73
- onHide={() => {
74
- useStore.setState({ toast: null })
75
- }}
76
- />
77
- ),
28
+ toast: toastData,
29
+ toastWithPrimaryAction: false,
78
30
  })
79
31
 
32
+ // HUD auto-hides after 2 seconds
33
+ setTimeout(onHide, 2000)
34
+
80
35
  // TODO: Handle closeMainWindow behavior with clearRootSearch and popToRootType options
81
36
  // This would need to be implemented based on the actual window management system
82
37
 
@@ -1,6 +1,5 @@
1
1
  import { Database } from 'bun:sqlite'
2
2
  import * as path from 'path'
3
- import * as os from 'os'
4
3
  import * as fs from 'fs'
5
4
  import { logger } from '../logger'
6
5
  import { useStore } from '../state'
@@ -8,42 +7,14 @@ import { useStore } from '../state'
8
7
  let db: Database | null = null
9
8
  let currentDbPath: string | null = null
10
9
 
11
- // Detect install directory for compiled extensions from binary path
12
- // Binary is at ~/.termcast/compiled/{name}/bin/{name}, data goes in ~/.termcast/compiled/{name}/
13
- function getCompiledExtensionDir(): string | null {
14
- const execPath = process.execPath
15
- const homeDir = os.homedir()
16
- const compiledPrefix = path.join(homeDir, '.termcast', 'compiled')
17
-
18
- // Check if binary is inside ~/.termcast/compiled/{name}/bin/
19
- if (execPath.startsWith(compiledPrefix)) {
20
- const relativePath = execPath.slice(compiledPrefix.length + 1) // +1 for trailing slash
21
- const parts = relativePath.split(path.sep)
22
- if (parts.length >= 2 && parts[1] === 'bin') {
23
- // parts[0] is the extension name
24
- return path.join(compiledPrefix, parts[0])
25
- }
26
- }
27
- return null
28
- }
29
-
30
10
  function getCurrentDatabasePath(): string {
31
11
  const { extensionPath } = useStore.getState()
32
12
 
33
- // For filesystem-based extensions (dev mode, store mode), use the extension directory
34
- if (extensionPath) {
35
- return path.join(extensionPath, '.termcast-bundle', 'data.db')
36
- }
37
-
38
- // For compiled extensions, detect install dir from binary path
39
- const compiledDir = getCompiledExtensionDir()
40
- if (compiledDir) {
41
- return path.join(compiledDir, 'data.db')
13
+ if (!extensionPath) {
14
+ throw new Error('Cannot access LocalStorage - extensionPath not set')
42
15
  }
43
16
 
44
- throw new Error(
45
- 'Cannot access LocalStorage - extension not initialized (no extensionPath and not a compiled extension)',
46
- )
17
+ return path.join(extensionPath, '.termcast-bundle', 'data.db')
47
18
  }
48
19
 
49
20
  function getDatabase(): Database {