svelte-highlight 7.12.0 → 7.14.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 (600) hide show
  1. package/AnsiOutput.svelte +193 -0
  2. package/AnsiOutput.svelte.d.ts +112 -0
  3. package/CodeWindow.svelte +110 -0
  4. package/CodeWindow.svelte.d.ts +136 -0
  5. package/CopyButton.svelte +2 -5
  6. package/CopyButton.svelte.d.ts +16 -20
  7. package/FileTabs.svelte +161 -0
  8. package/FileTabs.svelte.d.ts +96 -0
  9. package/Highlight.svelte +15 -25
  10. package/Highlight.svelte.d.ts +9 -10
  11. package/HighlightAuto.svelte +20 -25
  12. package/HighlightAuto.svelte.d.ts +2 -2
  13. package/HighlightEditable.svelte +385 -0
  14. package/HighlightEditable.svelte.d.ts +113 -0
  15. package/HighlightStyle.svelte +21 -6
  16. package/HighlightStyle.svelte.d.ts +22 -1
  17. package/HighlightSvelte.svelte +15 -23
  18. package/HighlightSvelte.svelte.d.ts +1 -1
  19. package/LangTag.svelte.d.ts +3 -3
  20. package/LineNumbers.svelte.d.ts +10 -10
  21. package/README.md +621 -0
  22. package/Typewriter.svelte +238 -0
  23. package/Typewriter.svelte.d.ts +65 -0
  24. package/action.d.ts +20 -0
  25. package/action.js +22 -0
  26. package/ansi.d.ts +36 -0
  27. package/ansi.js +198 -0
  28. package/core.js +22 -0
  29. package/highlighter.svelte.js +22 -0
  30. package/index.d.ts +10 -0
  31. package/index.js +8 -0
  32. package/languages/bibtex.js +2 -2
  33. package/languages/bicep.js +6 -0
  34. package/languages/blade.js +35 -1
  35. package/languages/caddy.js +1 -1
  36. package/languages/cairo.js +15 -0
  37. package/languages/clarity.js +1 -1
  38. package/languages/cue.js +31 -1
  39. package/languages/cypher.js +9 -0
  40. package/languages/d2.js +2 -2
  41. package/languages/dax.d.ts +2 -0
  42. package/languages/dax.js +75 -0
  43. package/languages/dhall.js +7 -0
  44. package/languages/dotenv.js +5 -1
  45. package/languages/fish.js +8 -0
  46. package/languages/gleam.js +7 -0
  47. package/languages/groq.js +19 -0
  48. package/languages/hcl.js +4 -1
  49. package/languages/hlsl.d.ts +2 -0
  50. package/languages/hlsl.js +88 -0
  51. package/languages/html.js +28 -0
  52. package/languages/index.d.ts +20 -0
  53. package/languages/index.js +10 -0
  54. package/languages/jq.d.ts +2 -0
  55. package/languages/jq.js +120 -0
  56. package/languages/jsonnet.js +9 -2
  57. package/languages/just.d.ts +2 -0
  58. package/languages/just.js +120 -0
  59. package/languages/kql.d.ts +2 -0
  60. package/languages/kql.js +122 -0
  61. package/languages/liquid.js +1 -0
  62. package/languages/logql.d.ts +2 -0
  63. package/languages/logql.js +82 -0
  64. package/languages/marko.js +84 -1
  65. package/languages/mdx.js +40 -1
  66. package/languages/move.js +20 -0
  67. package/languages/nickel.js +16 -1
  68. package/languages/nushell.js +23 -0
  69. package/languages/pkl.js +2 -1
  70. package/languages/prisma.js +2 -1
  71. package/languages/promql.js +35 -2
  72. package/languages/pug.js +22 -0
  73. package/languages/razor.js +64 -5
  74. package/languages/rego.d.ts +2 -0
  75. package/languages/rego.js +94 -0
  76. package/languages/rescript.js +70 -2
  77. package/languages/rst.d.ts +2 -0
  78. package/languages/rst.js +144 -0
  79. package/languages/solidity.js +2 -1
  80. package/languages/svelte.js +12 -3
  81. package/languages/templ.d.ts +2 -0
  82. package/languages/templ.js +254 -0
  83. package/languages/toml.js +3 -1
  84. package/languages/typst.d.ts +2 -0
  85. package/languages/typst.js +185 -0
  86. package/languages/v.js +24 -2
  87. package/languages/vue.js +4 -2
  88. package/languages/vyper.js +18 -0
  89. package/languages/wgsl.js +14 -0
  90. package/languages/zig.js +7 -0
  91. package/load-language.d.ts +9 -0
  92. package/load-language.js +15 -0
  93. package/package.json +11 -2
  94. package/preprocessor.js +373 -0
  95. package/scoped.d.ts +12 -0
  96. package/scoped.js +55 -24
  97. package/static.d.ts +36 -0
  98. package/static.js +1 -0
  99. package/styles/1c-light.css +1 -1
  100. package/styles/1c-light.js +1 -1
  101. package/styles/3024.css +1 -1
  102. package/styles/3024.js +1 -1
  103. package/styles/a11y-dark.css +1 -1
  104. package/styles/a11y-dark.js +1 -1
  105. package/styles/a11y-light.css +1 -1
  106. package/styles/a11y-light.js +1 -1
  107. package/styles/agate.css +1 -1
  108. package/styles/agate.js +1 -1
  109. package/styles/an-old-hope.css +1 -1
  110. package/styles/an-old-hope.js +1 -1
  111. package/styles/androidstudio.css +1 -1
  112. package/styles/androidstudio.js +1 -1
  113. package/styles/apathy.css +1 -1
  114. package/styles/apathy.js +1 -1
  115. package/styles/apprentice.css +1 -1
  116. package/styles/apprentice.js +1 -1
  117. package/styles/arduino-light.css +1 -1
  118. package/styles/arduino-light.js +1 -1
  119. package/styles/arta.css +1 -1
  120. package/styles/arta.js +1 -1
  121. package/styles/ascetic.css +1 -1
  122. package/styles/ascetic.js +1 -1
  123. package/styles/ashes.css +1 -1
  124. package/styles/ashes.js +1 -1
  125. package/styles/atelier-cave-light.css +1 -1
  126. package/styles/atelier-cave-light.js +1 -1
  127. package/styles/atelier-cave.css +1 -1
  128. package/styles/atelier-cave.js +1 -1
  129. package/styles/atelier-dune-light.css +1 -1
  130. package/styles/atelier-dune-light.js +1 -1
  131. package/styles/atelier-dune.css +1 -1
  132. package/styles/atelier-dune.js +1 -1
  133. package/styles/atelier-estuary-light.css +1 -1
  134. package/styles/atelier-estuary-light.js +1 -1
  135. package/styles/atelier-estuary.css +1 -1
  136. package/styles/atelier-estuary.js +1 -1
  137. package/styles/atelier-forest-light.css +1 -1
  138. package/styles/atelier-forest-light.js +1 -1
  139. package/styles/atelier-forest.css +1 -1
  140. package/styles/atelier-forest.js +1 -1
  141. package/styles/atelier-heath-light.css +1 -1
  142. package/styles/atelier-heath-light.js +1 -1
  143. package/styles/atelier-heath.css +1 -1
  144. package/styles/atelier-heath.js +1 -1
  145. package/styles/atelier-lakeside-light.css +1 -1
  146. package/styles/atelier-lakeside-light.js +1 -1
  147. package/styles/atelier-lakeside.css +1 -1
  148. package/styles/atelier-lakeside.js +1 -1
  149. package/styles/atelier-plateau-light.css +1 -1
  150. package/styles/atelier-plateau-light.js +1 -1
  151. package/styles/atelier-plateau.css +1 -1
  152. package/styles/atelier-plateau.js +1 -1
  153. package/styles/atelier-savanna-light.css +1 -1
  154. package/styles/atelier-savanna-light.js +1 -1
  155. package/styles/atelier-savanna.css +1 -1
  156. package/styles/atelier-savanna.js +1 -1
  157. package/styles/atelier-seaside-light.css +1 -1
  158. package/styles/atelier-seaside-light.js +1 -1
  159. package/styles/atelier-seaside.css +1 -1
  160. package/styles/atelier-seaside.js +1 -1
  161. package/styles/atelier-sulphurpool-light.css +1 -1
  162. package/styles/atelier-sulphurpool-light.js +1 -1
  163. package/styles/atelier-sulphurpool.css +1 -1
  164. package/styles/atelier-sulphurpool.js +1 -1
  165. package/styles/atlas.css +1 -1
  166. package/styles/atlas.js +1 -1
  167. package/styles/atom-one-dark-reasonable.css +1 -1
  168. package/styles/atom-one-dark-reasonable.js +1 -1
  169. package/styles/atom-one-dark.css +1 -1
  170. package/styles/atom-one-dark.js +1 -1
  171. package/styles/atom-one-light.css +1 -1
  172. package/styles/atom-one-light.js +1 -1
  173. package/styles/base16-github.css +1 -1
  174. package/styles/base16-github.js +1 -1
  175. package/styles/base16-ir-black.css +1 -1
  176. package/styles/base16-ir-black.js +1 -1
  177. package/styles/base16-monokai.css +1 -1
  178. package/styles/base16-monokai.js +1 -1
  179. package/styles/base16-nord.css +1 -1
  180. package/styles/base16-nord.js +1 -1
  181. package/styles/bespin.css +1 -1
  182. package/styles/bespin.js +1 -1
  183. package/styles/black-metal-bathory.css +1 -1
  184. package/styles/black-metal-bathory.js +1 -1
  185. package/styles/black-metal-burzum.css +1 -1
  186. package/styles/black-metal-burzum.js +1 -1
  187. package/styles/black-metal-dark-funeral.css +1 -1
  188. package/styles/black-metal-dark-funeral.js +1 -1
  189. package/styles/black-metal-gorgoroth.css +1 -1
  190. package/styles/black-metal-gorgoroth.js +1 -1
  191. package/styles/black-metal-immortal.css +1 -1
  192. package/styles/black-metal-immortal.js +1 -1
  193. package/styles/black-metal-khold.css +1 -1
  194. package/styles/black-metal-khold.js +1 -1
  195. package/styles/black-metal-marduk.css +1 -1
  196. package/styles/black-metal-marduk.js +1 -1
  197. package/styles/black-metal-mayhem.css +1 -1
  198. package/styles/black-metal-mayhem.js +1 -1
  199. package/styles/black-metal-nile.css +1 -1
  200. package/styles/black-metal-nile.js +1 -1
  201. package/styles/black-metal-venom.css +1 -1
  202. package/styles/black-metal-venom.js +1 -1
  203. package/styles/black-metal.css +1 -1
  204. package/styles/black-metal.js +1 -1
  205. package/styles/brewer.css +1 -1
  206. package/styles/brewer.js +1 -1
  207. package/styles/bright.css +1 -1
  208. package/styles/bright.js +1 -1
  209. package/styles/brogrammer.css +1 -1
  210. package/styles/brogrammer.js +1 -1
  211. package/styles/brown-paper.css +1 -1
  212. package/styles/brown-paper.js +1 -1
  213. package/styles/brush-trees-dark.css +1 -1
  214. package/styles/brush-trees-dark.js +1 -1
  215. package/styles/brush-trees.css +1 -1
  216. package/styles/brush-trees.js +1 -1
  217. package/styles/chalk.css +1 -1
  218. package/styles/chalk.js +1 -1
  219. package/styles/circus.css +1 -1
  220. package/styles/circus.js +1 -1
  221. package/styles/classic-dark.css +1 -1
  222. package/styles/classic-dark.js +1 -1
  223. package/styles/classic-light.css +1 -1
  224. package/styles/classic-light.js +1 -1
  225. package/styles/codepen-embed.css +1 -1
  226. package/styles/codepen-embed.js +1 -1
  227. package/styles/codeschool.css +1 -1
  228. package/styles/codeschool.js +1 -1
  229. package/styles/color-brewer.css +1 -1
  230. package/styles/color-brewer.js +1 -1
  231. package/styles/colors.css +1 -1
  232. package/styles/colors.js +1 -1
  233. package/styles/cupcake.css +1 -1
  234. package/styles/cupcake.js +1 -1
  235. package/styles/cupertino.css +1 -1
  236. package/styles/cupertino.js +1 -1
  237. package/styles/danqing.css +1 -1
  238. package/styles/danqing.js +1 -1
  239. package/styles/darcula.css +1 -1
  240. package/styles/darcula.js +1 -1
  241. package/styles/dark-violet.css +1 -1
  242. package/styles/dark-violet.js +1 -1
  243. package/styles/dark.css +1 -1
  244. package/styles/dark.js +1 -1
  245. package/styles/darkmoss.css +1 -1
  246. package/styles/darkmoss.js +1 -1
  247. package/styles/darktooth.css +1 -1
  248. package/styles/darktooth.js +1 -1
  249. package/styles/decaf.css +1 -1
  250. package/styles/decaf.js +1 -1
  251. package/styles/default-dark.css +1 -1
  252. package/styles/default-dark.js +1 -1
  253. package/styles/default-light.css +1 -1
  254. package/styles/default-light.js +1 -1
  255. package/styles/default.css +1 -1
  256. package/styles/default.js +1 -1
  257. package/styles/devibeans.css +1 -1
  258. package/styles/devibeans.js +1 -1
  259. package/styles/dirtysea.css +1 -1
  260. package/styles/dirtysea.js +1 -1
  261. package/styles/docco.css +1 -1
  262. package/styles/docco.js +1 -1
  263. package/styles/dracula.css +1 -1
  264. package/styles/dracula.js +1 -1
  265. package/styles/edge-dark.css +1 -1
  266. package/styles/edge-dark.js +1 -1
  267. package/styles/edge-light.css +1 -1
  268. package/styles/edge-light.js +1 -1
  269. package/styles/eighties.css +1 -1
  270. package/styles/eighties.js +1 -1
  271. package/styles/embers.css +1 -1
  272. package/styles/embers.js +1 -1
  273. package/styles/equilibrium-dark.css +1 -1
  274. package/styles/equilibrium-dark.js +1 -1
  275. package/styles/equilibrium-gray-dark.css +1 -1
  276. package/styles/equilibrium-gray-dark.js +1 -1
  277. package/styles/equilibrium-gray-light.css +1 -1
  278. package/styles/equilibrium-gray-light.js +1 -1
  279. package/styles/equilibrium-light.css +1 -1
  280. package/styles/equilibrium-light.js +1 -1
  281. package/styles/espresso.css +1 -1
  282. package/styles/espresso.js +1 -1
  283. package/styles/eva-dim.css +1 -1
  284. package/styles/eva-dim.js +1 -1
  285. package/styles/eva.css +1 -1
  286. package/styles/eva.js +1 -1
  287. package/styles/far.css +1 -1
  288. package/styles/far.js +1 -1
  289. package/styles/felipec.css +1 -1
  290. package/styles/felipec.js +1 -1
  291. package/styles/flat.css +1 -1
  292. package/styles/flat.js +1 -1
  293. package/styles/foundation.css +1 -1
  294. package/styles/foundation.js +1 -1
  295. package/styles/framer.css +1 -1
  296. package/styles/framer.js +1 -1
  297. package/styles/fruit-soda.css +1 -1
  298. package/styles/fruit-soda.js +1 -1
  299. package/styles/gigavolt.css +1 -1
  300. package/styles/gigavolt.js +1 -1
  301. package/styles/github-dark-dimmed.css +1 -1
  302. package/styles/github-dark-dimmed.js +1 -1
  303. package/styles/github-dark.css +1 -1
  304. package/styles/github-dark.js +1 -1
  305. package/styles/github.css +1 -1
  306. package/styles/github.js +1 -1
  307. package/styles/gml.css +1 -1
  308. package/styles/gml.js +1 -1
  309. package/styles/google-dark.css +1 -1
  310. package/styles/google-dark.js +1 -1
  311. package/styles/google-light.css +1 -1
  312. package/styles/google-light.js +1 -1
  313. package/styles/googlecode.css +1 -2
  314. package/styles/googlecode.js +1 -2
  315. package/styles/gradient-dark.css +2 -3
  316. package/styles/gradient-dark.js +2 -3
  317. package/styles/gradient-light.css +2 -3
  318. package/styles/gradient-light.js +2 -3
  319. package/styles/grayscale-dark.css +1 -1
  320. package/styles/grayscale-dark.js +1 -1
  321. package/styles/grayscale-light.css +1 -1
  322. package/styles/grayscale-light.js +1 -1
  323. package/styles/grayscale.css +1 -1
  324. package/styles/grayscale.js +1 -1
  325. package/styles/green-screen.css +1 -1
  326. package/styles/green-screen.js +1 -1
  327. package/styles/gruvbox-dark-hard.css +1 -1
  328. package/styles/gruvbox-dark-hard.js +1 -1
  329. package/styles/gruvbox-dark-medium.css +1 -1
  330. package/styles/gruvbox-dark-medium.js +1 -1
  331. package/styles/gruvbox-dark-pale.css +1 -1
  332. package/styles/gruvbox-dark-pale.js +1 -1
  333. package/styles/gruvbox-dark-soft.css +1 -1
  334. package/styles/gruvbox-dark-soft.js +1 -1
  335. package/styles/gruvbox-light-hard.css +1 -1
  336. package/styles/gruvbox-light-hard.js +1 -1
  337. package/styles/gruvbox-light-medium.css +1 -1
  338. package/styles/gruvbox-light-medium.js +1 -1
  339. package/styles/gruvbox-light-soft.css +1 -1
  340. package/styles/gruvbox-light-soft.js +1 -1
  341. package/styles/hardcore.css +1 -1
  342. package/styles/hardcore.js +1 -1
  343. package/styles/harmonic16-dark.css +1 -1
  344. package/styles/harmonic16-dark.js +1 -1
  345. package/styles/harmonic16-light.css +1 -1
  346. package/styles/harmonic16-light.js +1 -1
  347. package/styles/heetch-dark.css +1 -1
  348. package/styles/heetch-dark.js +1 -1
  349. package/styles/heetch-light.css +1 -1
  350. package/styles/heetch-light.js +1 -1
  351. package/styles/helios.css +1 -1
  352. package/styles/helios.js +1 -1
  353. package/styles/hopscotch.css +1 -1
  354. package/styles/hopscotch.js +1 -1
  355. package/styles/horizon-dark.css +1 -1
  356. package/styles/horizon-dark.js +1 -1
  357. package/styles/horizon-light.css +1 -1
  358. package/styles/horizon-light.js +1 -1
  359. package/styles/humanoid-dark.css +1 -1
  360. package/styles/humanoid-dark.js +1 -1
  361. package/styles/humanoid-light.css +1 -1
  362. package/styles/humanoid-light.js +1 -1
  363. package/styles/hybrid.css +1 -1
  364. package/styles/hybrid.js +1 -1
  365. package/styles/ia-dark.css +1 -1
  366. package/styles/ia-dark.js +1 -1
  367. package/styles/ia-light.css +1 -1
  368. package/styles/ia-light.js +1 -1
  369. package/styles/icy-dark.css +1 -1
  370. package/styles/icy-dark.js +1 -1
  371. package/styles/idea.css +1 -1
  372. package/styles/idea.js +1 -1
  373. package/styles/intellij-light.css +1 -1
  374. package/styles/intellij-light.js +1 -1
  375. package/styles/ir-black.css +1 -1
  376. package/styles/ir-black.js +1 -1
  377. package/styles/isbl-editor-dark.css +1 -1
  378. package/styles/isbl-editor-dark.js +1 -1
  379. package/styles/isbl-editor-light.css +1 -1
  380. package/styles/isbl-editor-light.js +1 -1
  381. package/styles/isotope.css +1 -1
  382. package/styles/isotope.js +1 -1
  383. package/styles/kimber.css +1 -1
  384. package/styles/kimber.js +1 -1
  385. package/styles/kimbie-dark.css +1 -1
  386. package/styles/kimbie-dark.js +1 -1
  387. package/styles/kimbie-light.css +1 -1
  388. package/styles/kimbie-light.js +1 -1
  389. package/styles/lightfair.css +1 -1
  390. package/styles/lightfair.js +1 -1
  391. package/styles/lioshi.css +1 -1
  392. package/styles/lioshi.js +1 -1
  393. package/styles/london-tube.css +1 -1
  394. package/styles/london-tube.js +1 -1
  395. package/styles/macintosh.css +1 -1
  396. package/styles/macintosh.js +1 -1
  397. package/styles/magula.css +1 -2
  398. package/styles/magula.js +1 -2
  399. package/styles/marrakesh.css +1 -1
  400. package/styles/marrakesh.js +1 -1
  401. package/styles/materia.css +1 -1
  402. package/styles/materia.js +1 -1
  403. package/styles/material-darker.css +1 -1
  404. package/styles/material-darker.js +1 -1
  405. package/styles/material-lighter.css +1 -1
  406. package/styles/material-lighter.js +1 -1
  407. package/styles/material-palenight.css +1 -1
  408. package/styles/material-palenight.js +1 -1
  409. package/styles/material-vivid.css +1 -1
  410. package/styles/material-vivid.js +1 -1
  411. package/styles/material.css +1 -1
  412. package/styles/material.js +1 -1
  413. package/styles/mellow-purple.css +1 -1
  414. package/styles/mellow-purple.js +1 -1
  415. package/styles/mexico-light.css +1 -1
  416. package/styles/mexico-light.js +1 -1
  417. package/styles/mocha.css +1 -1
  418. package/styles/mocha.js +1 -1
  419. package/styles/mono-blue.css +1 -1
  420. package/styles/mono-blue.js +1 -1
  421. package/styles/monokai-sublime.css +1 -1
  422. package/styles/monokai-sublime.js +1 -1
  423. package/styles/monokai.css +1 -1
  424. package/styles/monokai.js +1 -1
  425. package/styles/nebula.css +1 -1
  426. package/styles/nebula.js +1 -1
  427. package/styles/night-owl.css +1 -1
  428. package/styles/night-owl.js +1 -1
  429. package/styles/nnfx-dark.css +1 -1
  430. package/styles/nnfx-dark.js +1 -1
  431. package/styles/nnfx-light.css +1 -1
  432. package/styles/nnfx-light.js +1 -1
  433. package/styles/nord.css +1 -1
  434. package/styles/nord.js +1 -1
  435. package/styles/nova.css +1 -1
  436. package/styles/nova.js +1 -1
  437. package/styles/obsidian.css +1 -1
  438. package/styles/obsidian.js +1 -1
  439. package/styles/ocean.css +1 -1
  440. package/styles/ocean.js +1 -1
  441. package/styles/oceanicnext.css +1 -1
  442. package/styles/oceanicnext.js +1 -1
  443. package/styles/one-light.css +1 -1
  444. package/styles/one-light.js +1 -1
  445. package/styles/onedark.css +1 -1
  446. package/styles/onedark.js +1 -1
  447. package/styles/outrun-dark.css +1 -1
  448. package/styles/outrun-dark.js +1 -1
  449. package/styles/panda-syntax-dark.css +1 -2
  450. package/styles/panda-syntax-dark.js +1 -2
  451. package/styles/papercolor-dark.css +1 -1
  452. package/styles/papercolor-dark.js +1 -1
  453. package/styles/papercolor-light.css +1 -1
  454. package/styles/papercolor-light.js +1 -1
  455. package/styles/paraiso-dark.css +1 -1
  456. package/styles/paraiso-dark.js +1 -1
  457. package/styles/paraiso-light.css +1 -1
  458. package/styles/paraiso-light.js +1 -1
  459. package/styles/paraiso.css +1 -1
  460. package/styles/paraiso.js +1 -1
  461. package/styles/pasque.css +1 -1
  462. package/styles/pasque.js +1 -1
  463. package/styles/phd.css +1 -1
  464. package/styles/phd.js +1 -1
  465. package/styles/pico.css +1 -1
  466. package/styles/pico.js +1 -1
  467. package/styles/pojoaque.css +1 -1
  468. package/styles/pojoaque.js +1 -1
  469. package/styles/pop.css +1 -1
  470. package/styles/pop.js +1 -1
  471. package/styles/porple.css +1 -1
  472. package/styles/porple.js +1 -1
  473. package/styles/purebasic.css +1 -1
  474. package/styles/purebasic.js +1 -1
  475. package/styles/qtcreator-dark.css +1 -1
  476. package/styles/qtcreator-dark.js +1 -1
  477. package/styles/qtcreator-light.css +1 -1
  478. package/styles/qtcreator-light.js +1 -1
  479. package/styles/qualia.css +1 -1
  480. package/styles/qualia.js +1 -1
  481. package/styles/railscasts.css +1 -1
  482. package/styles/railscasts.js +1 -1
  483. package/styles/rainbow.css +1 -1
  484. package/styles/rainbow.js +1 -1
  485. package/styles/rebecca.css +1 -1
  486. package/styles/rebecca.js +1 -1
  487. package/styles/ros-pine-dawn.css +1 -1
  488. package/styles/ros-pine-dawn.js +1 -1
  489. package/styles/ros-pine-moon.css +1 -1
  490. package/styles/ros-pine-moon.js +1 -1
  491. package/styles/ros-pine.css +1 -1
  492. package/styles/ros-pine.js +1 -1
  493. package/styles/rose-pine-dawn.css +1 -1
  494. package/styles/rose-pine-dawn.js +1 -1
  495. package/styles/rose-pine-moon.css +1 -1
  496. package/styles/rose-pine-moon.js +1 -1
  497. package/styles/rose-pine.css +1 -1
  498. package/styles/rose-pine.js +1 -1
  499. package/styles/routeros.css +1 -1
  500. package/styles/routeros.js +1 -1
  501. package/styles/sagelight.css +1 -1
  502. package/styles/sagelight.js +1 -1
  503. package/styles/sandcastle.css +1 -1
  504. package/styles/sandcastle.js +1 -1
  505. package/styles/school-book.css +1 -1
  506. package/styles/school-book.js +1 -1
  507. package/styles/seti-ui.css +1 -1
  508. package/styles/seti-ui.js +1 -1
  509. package/styles/shades-of-purple.css +2 -3
  510. package/styles/shades-of-purple.js +2 -3
  511. package/styles/shapeshifter.css +1 -1
  512. package/styles/shapeshifter.js +1 -1
  513. package/styles/silk-dark.css +1 -1
  514. package/styles/silk-dark.js +1 -1
  515. package/styles/silk-light.css +1 -1
  516. package/styles/silk-light.js +1 -1
  517. package/styles/snazzy.css +1 -1
  518. package/styles/snazzy.js +1 -1
  519. package/styles/solar-flare-light.css +1 -1
  520. package/styles/solar-flare-light.js +1 -1
  521. package/styles/solar-flare.css +1 -1
  522. package/styles/solar-flare.js +1 -1
  523. package/styles/solarized-dark.css +1 -1
  524. package/styles/solarized-dark.js +1 -1
  525. package/styles/solarized-light.css +1 -1
  526. package/styles/solarized-light.js +1 -1
  527. package/styles/spacemacs.css +1 -1
  528. package/styles/spacemacs.js +1 -1
  529. package/styles/srcery.css +1 -1
  530. package/styles/srcery.js +1 -1
  531. package/styles/stackoverflow-dark.css +1 -1
  532. package/styles/stackoverflow-dark.js +1 -1
  533. package/styles/stackoverflow-light.css +1 -1
  534. package/styles/stackoverflow-light.js +1 -1
  535. package/styles/summercamp.css +1 -1
  536. package/styles/summercamp.js +1 -1
  537. package/styles/summerfruit-dark.css +1 -1
  538. package/styles/summerfruit-dark.js +1 -1
  539. package/styles/summerfruit-light.css +1 -1
  540. package/styles/summerfruit-light.js +1 -1
  541. package/styles/sunburst.css +1 -1
  542. package/styles/sunburst.js +1 -1
  543. package/styles/synth-midnight-terminal-dark.css +1 -1
  544. package/styles/synth-midnight-terminal-dark.js +1 -1
  545. package/styles/synth-midnight-terminal-light.css +1 -1
  546. package/styles/synth-midnight-terminal-light.js +1 -1
  547. package/styles/tango.css +1 -1
  548. package/styles/tango.js +1 -1
  549. package/styles/tender.css +1 -1
  550. package/styles/tender.js +1 -1
  551. package/styles/tokyo-night-dark.css +1 -2
  552. package/styles/tokyo-night-dark.js +1 -2
  553. package/styles/tokyo-night-light.css +1 -2
  554. package/styles/tokyo-night-light.js +1 -2
  555. package/styles/tomorrow-night-blue.css +1 -1
  556. package/styles/tomorrow-night-blue.js +1 -1
  557. package/styles/tomorrow-night-bright.css +1 -1
  558. package/styles/tomorrow-night-bright.js +1 -1
  559. package/styles/tomorrow-night.css +1 -1
  560. package/styles/tomorrow-night.js +1 -1
  561. package/styles/tomorrow.css +1 -1
  562. package/styles/tomorrow.js +1 -1
  563. package/styles/twilight.css +1 -1
  564. package/styles/twilight.js +1 -1
  565. package/styles/unikitty-dark.css +1 -1
  566. package/styles/unikitty-dark.js +1 -1
  567. package/styles/unikitty-light.css +1 -1
  568. package/styles/unikitty-light.js +1 -1
  569. package/styles/vs.css +1 -1
  570. package/styles/vs.js +1 -1
  571. package/styles/vs2015.css +1 -1
  572. package/styles/vs2015.js +1 -1
  573. package/styles/vulcan.css +1 -1
  574. package/styles/vulcan.js +1 -1
  575. package/styles/windows-10-light.css +1 -1
  576. package/styles/windows-10-light.js +1 -1
  577. package/styles/windows-10.css +1 -1
  578. package/styles/windows-10.js +1 -1
  579. package/styles/windows-95-light.css +1 -1
  580. package/styles/windows-95-light.js +1 -1
  581. package/styles/windows-95.css +1 -1
  582. package/styles/windows-95.js +1 -1
  583. package/styles/windows-high-contrast-light.css +1 -1
  584. package/styles/windows-high-contrast-light.js +1 -1
  585. package/styles/windows-high-contrast.css +1 -1
  586. package/styles/windows-high-contrast.js +1 -1
  587. package/styles/windows-nt-light.css +1 -1
  588. package/styles/windows-nt-light.js +1 -1
  589. package/styles/windows-nt.css +1 -1
  590. package/styles/windows-nt.js +1 -1
  591. package/styles/woodland.css +1 -1
  592. package/styles/woodland.js +1 -1
  593. package/styles/xcode-dusk.css +1 -1
  594. package/styles/xcode-dusk.js +1 -1
  595. package/styles/xcode.css +1 -1
  596. package/styles/xcode.js +1 -1
  597. package/styles/xt256.css +1 -1
  598. package/styles/xt256.js +1 -1
  599. package/styles/zenburn.css +1 -1
  600. package/styles/zenburn.js +1 -1
@@ -0,0 +1,193 @@
1
+ <script>
2
+ /** @type {string} */
3
+ export let text;
4
+
5
+ /**
6
+ * Flip foreground to black/white when contrast on a background span is too low.
7
+ * @type {boolean}
8
+ */
9
+ export let autoContrast = true;
10
+
11
+ import { parseAnsi } from "./ansi.js";
12
+
13
+ // Default foreground and minimum WCAG contrast ratio against backgrounds.
14
+ const FOREGROUND_FALLBACK = "#d4d4d4";
15
+ const CONTRAST_TARGET = 4.5;
16
+ /** @type {[number, number, number]} */
17
+ const BLACK = [0, 0, 0];
18
+ /** @type {[number, number, number]} */
19
+ const WHITE = [255, 255, 255];
20
+
21
+ // 16-color xterm defaults, each overridable via `--ansi-<name>`.
22
+ const DEFAULTS = {
23
+ black: "#000000",
24
+ red: "#cd0000",
25
+ green: "#00cd00",
26
+ yellow: "#cdcd00",
27
+ blue: "#0000ee",
28
+ magenta: "#cd00cd",
29
+ cyan: "#00cdcd",
30
+ white: "#e5e5e5",
31
+ "bright-black": "#7f7f7f",
32
+ "bright-red": "#ff0000",
33
+ "bright-green": "#00ff00",
34
+ "bright-yellow": "#ffff00",
35
+ "bright-blue": "#5c5cff",
36
+ "bright-magenta": "#ff00ff",
37
+ "bright-cyan": "#00ffff",
38
+ "bright-white": "#ffffff",
39
+ };
40
+
41
+ // 256-color cube steps (6×6×6).
42
+ const CUBE = [0, 95, 135, 175, 215, 255];
43
+
44
+ /** 256-color index → hex. */
45
+ function indexedHex(index) {
46
+ if (index >= 232) {
47
+ const value = (index - 232) * 10 + 8;
48
+ const hex = value.toString(16).padStart(2, "0");
49
+ return `#${hex}${hex}${hex}`;
50
+ }
51
+ const n = index - 16;
52
+ const r = CUBE[Math.floor(n / 36) % 6];
53
+ const g = CUBE[Math.floor(n / 6) % 6];
54
+ const b = CUBE[n % 6];
55
+ return `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
56
+ }
57
+
58
+ /** Parsed color → CSS (named colors use `--ansi-*` vars). */
59
+ function cssColor(color) {
60
+ if ("name" in color) {
61
+ return `var(--ansi-${color.name}, ${DEFAULTS[color.name]})`;
62
+ }
63
+ if ("rgb" in color) {
64
+ return `rgb(${color.rgb[0]}, ${color.rgb[1]}, ${color.rgb[2]})`;
65
+ }
66
+ return indexedHex(color.index);
67
+ }
68
+
69
+ /**
70
+ * @param {string} hex A `#rrggbb` string.
71
+ * @returns {[number, number, number]}
72
+ */
73
+ function hexToRgb(hex) {
74
+ const value = hex.replace("#", "");
75
+ return [
76
+ Number.parseInt(value.slice(0, 2), 16),
77
+ Number.parseInt(value.slice(2, 4), 16),
78
+ Number.parseInt(value.slice(4, 6), 16),
79
+ ];
80
+ }
81
+
82
+ /** Named colors use the default palette (theme overrides aren't known here). */
83
+ function colorToRgb(color) {
84
+ if ("name" in color) return hexToRgb(DEFAULTS[color.name] ?? "#000000");
85
+ if ("rgb" in color) return color.rgb;
86
+ return hexToRgb(indexedHex(color.index));
87
+ }
88
+
89
+ /** WCAG relative luminance. */
90
+ function luminance([r, g, b]) {
91
+ const channels = [r, g, b].map((c) => {
92
+ const v = c / 255;
93
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
94
+ });
95
+ return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];
96
+ }
97
+
98
+ /** WCAG contrast ratio. */
99
+ function contrastRatio(a, b) {
100
+ const la = luminance(a);
101
+ const lb = luminance(b);
102
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
103
+ }
104
+
105
+ /** Black or white, whichever contrasts more with `bg`. */
106
+ function readableForeground(bg) {
107
+ return contrastRatio(BLACK, bg) >= contrastRatio(WHITE, bg)
108
+ ? "#000000"
109
+ : "#ffffff";
110
+ }
111
+
112
+ /** Foreground CSS, with auto-contrast override when needed. */
113
+ function foregroundCss(segment) {
114
+ if (autoContrast && segment.bg) {
115
+ const bg = colorToRgb(segment.bg);
116
+ const fg = segment.fg
117
+ ? colorToRgb(segment.fg)
118
+ : hexToRgb(FOREGROUND_FALLBACK);
119
+ if (contrastRatio(fg, bg) < CONTRAST_TARGET)
120
+ return readableForeground(bg);
121
+ }
122
+ return segment.fg ? cssColor(segment.fg) : undefined;
123
+ }
124
+
125
+ /** @param {import("./ansi").AnsiSegment} segment */
126
+ function classNames(segment) {
127
+ const names = [];
128
+ if (segment.bold) names.push("bold");
129
+ if (segment.dim) names.push("dim");
130
+ if (segment.italic) names.push("italic");
131
+ if (segment.underline) names.push("underline");
132
+ return names.length ? names.join(" ") : undefined;
133
+ }
134
+
135
+ /** @param {import("./ansi").AnsiSegment} segment */
136
+ function inlineStyle(segment) {
137
+ let style = "";
138
+ if (segment.bg) style += `background-color:${cssColor(segment.bg)};`;
139
+ const fg = foregroundCss(segment);
140
+ if (fg) style += `color:${fg};`;
141
+ return style || undefined;
142
+ }
143
+
144
+ // Precompute class/style per segment. Parse only when `text` changes.
145
+ $: parsed = parseAnsi(text);
146
+ $: segments = parsed.map((segment) => ({
147
+ text: segment.text,
148
+ class: classNames(segment),
149
+ style: inlineStyle(segment),
150
+ }));
151
+ </script>
152
+
153
+ <pre class="ansi" {...$$restProps}><code
154
+ >{#each segments as segment}<span class={segment.class} style={segment.style}
155
+ >{segment.text}</span
156
+ >{/each}</code
157
+ ></pre>
158
+
159
+ <style>
160
+ .ansi {
161
+ margin: 0;
162
+ overflow: auto;
163
+ padding: var(--ansi-padding, 1em);
164
+ background: var(--ansi-background, #1e1e1e);
165
+ color: var(--ansi-foreground, #d4d4d4);
166
+ font-family: var(
167
+ --ansi-font-family,
168
+ ui-monospace,
169
+ "SFMono-Regular",
170
+ "Menlo",
171
+ monospace
172
+ );
173
+ font-size: var(--ansi-font-size, 0.875em);
174
+ line-height: var(--ansi-line-height, 1.5);
175
+ tab-size: var(--ansi-tab-size, 4);
176
+ }
177
+
178
+ .bold {
179
+ font-weight: var(--ansi-bold-weight, 700);
180
+ }
181
+
182
+ .dim {
183
+ opacity: var(--ansi-dim-opacity, 0.5);
184
+ }
185
+
186
+ .italic {
187
+ font-style: italic;
188
+ }
189
+
190
+ .underline {
191
+ text-decoration: underline;
192
+ }
193
+ </style>
@@ -0,0 +1,112 @@
1
+ import type { SvelteComponentTyped } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+
4
+ export type AnsiOutputProps = HTMLAttributes<HTMLPreElement> & {
5
+ /**
6
+ * Terminal output, including ANSI SGR codes.
7
+ */
8
+ text: string;
9
+
10
+ /**
11
+ * Flip foreground to black/white when contrast on a background is too low.
12
+ * @default true
13
+ */
14
+ autoContrast?: boolean;
15
+
16
+ /**
17
+ * Output block padding.
18
+ * @default "1em"
19
+ */
20
+ "--ansi-padding"?: string;
21
+
22
+ /**
23
+ * Output block background.
24
+ * @default "#1e1e1e"
25
+ */
26
+ "--ansi-background"?: string;
27
+
28
+ /**
29
+ * Default text color.
30
+ * @default "#d4d4d4"
31
+ */
32
+ "--ansi-foreground"?: string;
33
+
34
+ /**
35
+ * Monospace font family.
36
+ * @default "ui-monospace, SFMono-Regular, Menlo, monospace"
37
+ */
38
+ "--ansi-font-family"?: string;
39
+
40
+ /**
41
+ * Font size.
42
+ * @default "0.875em"
43
+ */
44
+ "--ansi-font-size"?: string;
45
+
46
+ /**
47
+ * Line height.
48
+ * @default 1.5
49
+ */
50
+ "--ansi-line-height"?: string | number;
51
+
52
+ /**
53
+ * Tab size.
54
+ * @default 4
55
+ */
56
+ "--ansi-tab-size"?: string | number;
57
+
58
+ /**
59
+ * Bold font weight.
60
+ * @default 700
61
+ */
62
+ "--ansi-bold-weight"?: string | number;
63
+
64
+ /**
65
+ * Dim opacity.
66
+ * @default 0.5
67
+ */
68
+ "--ansi-dim-opacity"?: string | number;
69
+
70
+ /** Standard black. @default "#000000" */
71
+ "--ansi-black"?: string;
72
+ /** Standard red. @default "#cd0000" */
73
+ "--ansi-red"?: string;
74
+ /** Standard green. @default "#00cd00" */
75
+ "--ansi-green"?: string;
76
+ /** Standard yellow. @default "#cdcd00" */
77
+ "--ansi-yellow"?: string;
78
+ /** Standard blue. @default "#0000ee" */
79
+ "--ansi-blue"?: string;
80
+ /** Standard magenta. @default "#cd00cd" */
81
+ "--ansi-magenta"?: string;
82
+ /** Standard cyan. @default "#00cdcd" */
83
+ "--ansi-cyan"?: string;
84
+ /** Standard white. @default "#e5e5e5" */
85
+ "--ansi-white"?: string;
86
+ /** Bright black. @default "#7f7f7f" */
87
+ "--ansi-bright-black"?: string;
88
+ /** Bright red. @default "#ff0000" */
89
+ "--ansi-bright-red"?: string;
90
+ /** Bright green. @default "#00ff00" */
91
+ "--ansi-bright-green"?: string;
92
+ /** Bright yellow. @default "#ffff00" */
93
+ "--ansi-bright-yellow"?: string;
94
+ /** Bright blue. @default "#5c5cff" */
95
+ "--ansi-bright-blue"?: string;
96
+ /** Bright magenta. @default "#ff00ff" */
97
+ "--ansi-bright-magenta"?: string;
98
+ /** Bright cyan. @default "#00ffff" */
99
+ "--ansi-bright-cyan"?: string;
100
+ /** Bright white. @default "#ffffff" */
101
+ "--ansi-bright-white"?: string;
102
+ };
103
+
104
+ export type AnsiOutputEvents = {};
105
+
106
+ export type AnsiOutputSlots = {};
107
+
108
+ export default class AnsiOutput extends SvelteComponentTyped<
109
+ AnsiOutputProps,
110
+ AnsiOutputEvents,
111
+ AnsiOutputSlots
112
+ > {}
@@ -0,0 +1,110 @@
1
+ <script>
2
+ /** @type {"macos" | "terminal" | "plain"} */
3
+ export let variant = "macos";
4
+
5
+ /** @type {string} */
6
+ export let title = "";
7
+ </script>
8
+
9
+ <div class="code-window {variant}" {...$$restProps}>
10
+ <div class="titlebar">
11
+ {#if variant === "macos"}
12
+ <span class="dots" aria-hidden="true">
13
+ <span class="dot close"></span>
14
+ <span class="dot minimize"></span>
15
+ <span class="dot maximize"></span>
16
+ </span>
17
+ {:else if variant === "terminal"}
18
+ <span class="prompt" aria-hidden="true">&gt;_</span>
19
+ {/if}
20
+
21
+ {#if title}
22
+ <span class="title">{title}</span>
23
+ {/if}
24
+ </div>
25
+
26
+ <div class="content">
27
+ <slot />
28
+ </div>
29
+ </div>
30
+
31
+ <style>
32
+ .code-window {
33
+ overflow: hidden;
34
+ background: var(--window-background, #1e1e1e);
35
+ border: var(--window-border, 1px solid rgba(255, 255, 255, 0.1));
36
+ border-radius: var(--window-radius, 0);
37
+ }
38
+
39
+ .titlebar {
40
+ position: relative;
41
+ display: flex;
42
+ align-items: center;
43
+ gap: var(--titlebar-gap, 0.5em);
44
+ padding: var(--titlebar-padding, 0.65em 1em);
45
+ background: var(--titlebar-background, #2d2d2d);
46
+ border-bottom: var(--titlebar-border, 1px solid rgba(255, 255, 255, 0.1));
47
+ color: var(--titlebar-color, rgba(255, 255, 255, 0.6));
48
+ font-family: var(
49
+ --titlebar-font-family,
50
+ system-ui,
51
+ -apple-system,
52
+ sans-serif
53
+ );
54
+ font-size: var(--titlebar-font-size, 0.8125em);
55
+ }
56
+
57
+ .dots {
58
+ display: flex;
59
+ align-items: center;
60
+ gap: var(--dot-gap, 0.5em);
61
+ }
62
+
63
+ .dot {
64
+ width: var(--dot-size, 0.75em);
65
+ height: var(--dot-size, 0.75em);
66
+ border-radius: 50%;
67
+ }
68
+
69
+ .dot.close {
70
+ background: var(--dot-close, #ff5f56);
71
+ }
72
+
73
+ .dot.minimize {
74
+ background: var(--dot-minimize, #ffbd2e);
75
+ }
76
+
77
+ .dot.maximize {
78
+ background: var(--dot-maximize, #27c93f);
79
+ }
80
+
81
+ .prompt {
82
+ font-family: var(--prompt-font-family, ui-monospace, monospace);
83
+ font-weight: var(--prompt-font-weight, 700);
84
+ color: var(--prompt-color, inherit);
85
+ }
86
+
87
+ .title {
88
+ /* Center title across titlebar, ignoring dots/prompt. */
89
+ position: absolute;
90
+ left: 50%;
91
+ transform: translateX(-50%);
92
+ max-width: 70%;
93
+ overflow: hidden;
94
+ white-space: nowrap;
95
+ text-overflow: ellipsis;
96
+ pointer-events: none;
97
+ }
98
+
99
+ .plain .title {
100
+ /* Plain variant: no chrome, left-align title. */
101
+ position: static;
102
+ left: auto;
103
+ transform: none;
104
+ max-width: 100%;
105
+ }
106
+
107
+ .content {
108
+ overflow: auto;
109
+ }
110
+ </style>
@@ -0,0 +1,136 @@
1
+ import type { SvelteComponentTyped } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+
4
+ export type CodeWindowProps = HTMLAttributes<HTMLDivElement> & {
5
+ /**
6
+ * Window chrome style.
7
+ * @default "macos"
8
+ */
9
+ variant?: "macos" | "terminal" | "plain";
10
+
11
+ /**
12
+ * Title bar text.
13
+ * @default ""
14
+ */
15
+ title?: string;
16
+
17
+ /**
18
+ * Window body background.
19
+ * @default "#1e1e1e"
20
+ */
21
+ "--window-background"?: string;
22
+
23
+ /**
24
+ * Window border.
25
+ * @default "1px solid rgba(255, 255, 255, 0.1)"
26
+ */
27
+ "--window-border"?: string;
28
+
29
+ /**
30
+ * Window corner radius.
31
+ * @default "0"
32
+ */
33
+ "--window-radius"?: string;
34
+
35
+ /**
36
+ * Title bar gap.
37
+ * @default "0.5em"
38
+ */
39
+ "--titlebar-gap"?: string;
40
+
41
+ /**
42
+ * Title bar padding.
43
+ * @default "0.65em 1em"
44
+ */
45
+ "--titlebar-padding"?: string;
46
+
47
+ /**
48
+ * Title bar background.
49
+ * @default "#2d2d2d"
50
+ */
51
+ "--titlebar-background"?: string;
52
+
53
+ /**
54
+ * Title bar bottom border.
55
+ * @default "1px solid rgba(255, 255, 255, 0.1)"
56
+ */
57
+ "--titlebar-border"?: string;
58
+
59
+ /**
60
+ * Title bar text color.
61
+ * @default "rgba(255, 255, 255, 0.6)"
62
+ */
63
+ "--titlebar-color"?: string;
64
+
65
+ /**
66
+ * Title bar font family.
67
+ * @default "system-ui, -apple-system, sans-serif"
68
+ */
69
+ "--titlebar-font-family"?: string;
70
+
71
+ /**
72
+ * Title bar font size.
73
+ * @default "0.8125em"
74
+ */
75
+ "--titlebar-font-size"?: string;
76
+
77
+ /**
78
+ * Traffic-light dot gap.
79
+ * @default "0.5em"
80
+ */
81
+ "--dot-gap"?: string;
82
+
83
+ /**
84
+ * Traffic-light dot size.
85
+ * @default "0.75em"
86
+ */
87
+ "--dot-size"?: string;
88
+
89
+ /**
90
+ * Close dot color.
91
+ * @default "#ff5f56"
92
+ */
93
+ "--dot-close"?: string;
94
+
95
+ /**
96
+ * Minimize dot color.
97
+ * @default "#ffbd2e"
98
+ */
99
+ "--dot-minimize"?: string;
100
+
101
+ /**
102
+ * Maximize dot color.
103
+ * @default "#27c93f"
104
+ */
105
+ "--dot-maximize"?: string;
106
+
107
+ /**
108
+ * Terminal prompt font family.
109
+ * @default "ui-monospace, monospace"
110
+ */
111
+ "--prompt-font-family"?: string;
112
+
113
+ /**
114
+ * Terminal prompt font weight.
115
+ * @default 700
116
+ */
117
+ "--prompt-font-weight"?: string | number;
118
+
119
+ /**
120
+ * Terminal prompt color.
121
+ * @default "inherit"
122
+ */
123
+ "--prompt-color"?: string;
124
+ };
125
+
126
+ export type CodeWindowEvents = {};
127
+
128
+ export type CodeWindowSlots = {
129
+ default: {};
130
+ };
131
+
132
+ export default class CodeWindow extends SvelteComponentTyped<
133
+ CodeWindowProps,
134
+ CodeWindowEvents,
135
+ CodeWindowSlots
136
+ > {}
package/CopyButton.svelte CHANGED
@@ -3,8 +3,7 @@
3
3
  export let code;
4
4
 
5
5
  /**
6
- * Override the copy behavior. Receives the `code` to copy and may
7
- * return a promise. When omitted, the native Clipboard API is used.
6
+ * Override copy behavior. Defaults to `navigator.clipboard.writeText`.
8
7
  * @type {(code: string) => void | Promise<void>}
9
8
  */
10
9
  export let copy = (code) => navigator.clipboard.writeText(code);
@@ -32,9 +31,7 @@
32
31
  let timeoutId;
33
32
 
34
33
  async function handleClick() {
35
- // Ignore clicks while a copy is in flight or the "copied" state is active,
36
- // so no duplicate copy fires (even for slow async `copy` functions) and the
37
- // "copied" icon stays visible until the timeout elapses.
34
+ // Ignore clicks while copying or showing "Copied".
38
35
  if (copying || copied) return;
39
36
 
40
37
  try {
@@ -3,88 +3,86 @@ import type { HTMLButtonAttributes } from "svelte/elements";
3
3
 
4
4
  export type CopyButtonProps = HTMLButtonAttributes & {
5
5
  /**
6
- * Specify the text to copy to the clipboard.
6
+ * Text to copy.
7
7
  */
8
8
  code: string;
9
9
 
10
10
  /**
11
- * Override the copy behavior. Receives the `code` to copy and may
12
- * return a promise. When omitted, the native Clipboard API is used.
11
+ * Copy handler. Defaults to `navigator.clipboard.writeText`.
13
12
  * @default (code) => navigator.clipboard.writeText(code)
14
13
  */
15
14
  copy?: (code: string) => void | Promise<void>;
16
15
 
17
16
  /**
18
- * Set the duration in milliseconds to show the
19
- * "copied" state before reverting.
17
+ * How long the "copied" state lasts (ms).
20
18
  * @default 2000
21
19
  */
22
20
  timeout?: number;
23
21
 
24
22
  /**
25
- * Specify the accessible label (`aria-label`) for the button.
23
+ * Copy button `aria-label`.
26
24
  * Used as the fallback text only if the default icon slot is overridden.
27
25
  * @default "Copy"
28
26
  */
29
27
  text?: string;
30
28
 
31
29
  /**
32
- * Specify the accessible label (`aria-label`) shown after a successful copy.
30
+ * Copied state `aria-label`.
33
31
  * Used as the fallback text only if the default icon slot is overridden.
34
32
  * @default "Copied!"
35
33
  */
36
34
  copiedText?: string;
37
35
 
38
36
  /**
39
- * Customize the top offset of the button.
37
+ * Top offset.
40
38
  * @default "0.5em"
41
39
  */
42
40
  "--copy-top"?: string;
43
41
 
44
42
  /**
45
- * Customize the right offset of the button.
43
+ * Right offset.
46
44
  * @default "0.5em"
47
45
  */
48
46
  "--copy-right"?: string;
49
47
 
50
48
  /**
51
- * Customize the width and height of the button.
49
+ * Button size.
52
50
  * @default "2em"
53
51
  */
54
52
  "--copy-size"?: string;
55
53
 
56
54
  /**
57
- * Customize the inner padding of the button.
55
+ * Button padding.
58
56
  * @default "0.5em"
59
57
  */
60
58
  "--copy-padding"?: string;
61
59
 
62
60
  /**
63
- * Customize the background color of the button.
61
+ * Button background.
64
62
  * @default "inherit"
65
63
  */
66
64
  "--copy-background"?: string;
67
65
 
68
66
  /**
69
- * Customize the foreground color of the button.
67
+ * Button color.
70
68
  * @default "inherit"
71
69
  */
72
70
  "--copy-color"?: string;
73
71
 
74
72
  /**
75
- * Customize the border radius of the button.
73
+ * Button border radius.
76
74
  * @default "4px"
77
75
  */
78
76
  "--copy-border-radius"?: string;
79
77
 
80
78
  /**
81
- * Customize the border of the button.
79
+ * Button border.
82
80
  * @default "none"
83
81
  */
84
82
  "--copy-border"?: string;
85
83
 
86
84
  /**
87
- * Customize the stacking order of the button.
85
+ * Button z-index.
88
86
  * @default 2
89
87
  */
90
88
  "--copy-z-index"?: string | number;
@@ -105,8 +103,7 @@ export type CopyButtonEvents = {
105
103
  }>;
106
104
 
107
105
  /**
108
- * Forwarded from the `button` element. Useful for prefetching
109
- * an async copy on hover.
106
+ * Useful for prefetching an async copy on hover.
110
107
  */
111
108
  mouseenter: MouseEvent;
112
109
 
@@ -124,8 +121,7 @@ export type CopyButtonSlots = {
124
121
  copied: boolean;
125
122
 
126
123
  /**
127
- * `true` while an async `copy` is in flight (before it resolves).
128
- * Useful for rendering a pending state for slow copy functions.
124
+ * `true` while async `copy` is in flight.
129
125
  */
130
126
  copying: boolean;
131
127
  };