nebula-cms 0.1.0 → 0.1.4

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 (386) hide show
  1. package/README.md +2 -0
  2. package/dist/astro/index.d.ts +43 -0
  3. package/dist/astro/index.d.ts.map +1 -0
  4. package/dist/astro/index.js +223 -0
  5. package/dist/client/Admin.svelte.d.ts +11 -0
  6. package/dist/client/Admin.svelte.d.ts.map +1 -0
  7. package/dist/client/components/BackendPicker.svelte.d.ts +4 -0
  8. package/dist/client/components/BackendPicker.svelte.d.ts.map +1 -0
  9. package/dist/client/components/DraftChip.svelte.d.ts +10 -0
  10. package/dist/client/components/DraftChip.svelte.d.ts.map +1 -0
  11. package/dist/client/components/MetadataForm.svelte.d.ts +12 -0
  12. package/dist/client/components/MetadataForm.svelte.d.ts.map +1 -0
  13. package/dist/client/components/ThemeToggle.svelte.d.ts +19 -0
  14. package/dist/client/components/ThemeToggle.svelte.d.ts.map +1 -0
  15. package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts +11 -0
  16. package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts.map +1 -0
  17. package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts +13 -0
  18. package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts.map +1 -0
  19. package/dist/client/components/editor/EditorPane.svelte.d.ts +4 -0
  20. package/dist/client/components/editor/EditorPane.svelte.d.ts.map +1 -0
  21. package/dist/client/components/editor/EditorTabs.svelte.d.ts +8 -0
  22. package/dist/client/components/editor/EditorTabs.svelte.d.ts.map +1 -0
  23. package/dist/client/components/editor/EditorToolbar.svelte.d.ts +4 -0
  24. package/dist/client/components/editor/EditorToolbar.svelte.d.ts.map +1 -0
  25. package/dist/client/components/editor/FormatSelector.svelte.d.ts +4 -0
  26. package/dist/client/components/editor/FormatSelector.svelte.d.ts.map +1 -0
  27. package/dist/client/components/editor/Toolbar.svelte.d.ts +19 -0
  28. package/dist/client/components/editor/Toolbar.svelte.d.ts.map +1 -0
  29. package/dist/client/components/fields/ArrayField.svelte.d.ts +15 -0
  30. package/dist/client/components/fields/ArrayField.svelte.d.ts.map +1 -0
  31. package/dist/client/components/fields/ArrayItem.svelte.d.ts +28 -0
  32. package/dist/client/components/fields/ArrayItem.svelte.d.ts.map +1 -0
  33. package/dist/client/components/fields/BooleanField.svelte.d.ts +16 -0
  34. package/dist/client/components/fields/BooleanField.svelte.d.ts.map +1 -0
  35. package/dist/client/components/fields/DateField.svelte.d.ts +16 -0
  36. package/dist/client/components/fields/DateField.svelte.d.ts.map +1 -0
  37. package/dist/client/components/fields/EnumField.svelte.d.ts +17 -0
  38. package/dist/client/components/fields/EnumField.svelte.d.ts.map +1 -0
  39. package/dist/client/components/fields/FieldWrapper.svelte.d.ts +18 -0
  40. package/dist/client/components/fields/FieldWrapper.svelte.d.ts.map +1 -0
  41. package/dist/client/components/fields/NumberField.svelte.d.ts +16 -0
  42. package/dist/client/components/fields/NumberField.svelte.d.ts.map +1 -0
  43. package/dist/client/components/fields/ObjectField.svelte.d.ts +16 -0
  44. package/dist/client/components/fields/ObjectField.svelte.d.ts.map +1 -0
  45. package/dist/client/components/fields/SchemaField.svelte.d.ts +16 -0
  46. package/dist/client/components/fields/SchemaField.svelte.d.ts.map +1 -0
  47. package/dist/client/components/fields/StringField.svelte.d.ts +16 -0
  48. package/dist/client/components/fields/StringField.svelte.d.ts.map +1 -0
  49. package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts +19 -0
  50. package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts.map +1 -0
  51. package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts +12 -0
  52. package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts.map +1 -0
  53. package/dist/client/css/icons.css +29 -0
  54. package/dist/client/index.d.ts +2 -0
  55. package/dist/client/index.d.ts.map +1 -0
  56. package/dist/client/js/drafts/merge.svelte.d.ts +24 -0
  57. package/dist/client/js/drafts/merge.svelte.d.ts.map +1 -0
  58. package/dist/client/js/drafts/merge.svelte.js +106 -0
  59. package/dist/client/js/drafts/ops.svelte.d.ts +31 -0
  60. package/dist/client/js/drafts/ops.svelte.d.ts.map +1 -0
  61. package/dist/client/js/drafts/ops.svelte.js +182 -0
  62. package/dist/client/js/drafts/storage.d.ts +45 -0
  63. package/dist/client/js/drafts/storage.d.ts.map +1 -0
  64. package/dist/client/js/drafts/storage.js +76 -0
  65. package/dist/client/js/drafts/workers/diff.d.ts +2 -0
  66. package/dist/client/js/drafts/workers/diff.d.ts.map +1 -0
  67. package/dist/client/js/drafts/workers/diff.js +20 -0
  68. package/dist/client/js/editor/editor.svelte.d.ts +124 -0
  69. package/dist/client/js/editor/editor.svelte.d.ts.map +1 -0
  70. package/dist/client/js/editor/editor.svelte.js +294 -0
  71. package/dist/client/js/editor/languages.d.ts +11 -0
  72. package/dist/client/js/editor/languages.d.ts.map +1 -0
  73. package/dist/client/js/editor/languages.js +93 -0
  74. package/dist/client/js/editor/link-wrap.d.ts +6 -0
  75. package/dist/client/js/editor/link-wrap.d.ts.map +1 -0
  76. package/{src/client/js/editor/link-wrap.ts → dist/client/js/editor/link-wrap.js} +17 -24
  77. package/dist/client/js/editor/markdown-shortcuts.d.ts +4 -0
  78. package/dist/client/js/editor/markdown-shortcuts.d.ts.map +1 -0
  79. package/dist/client/js/editor/markdown-shortcuts.js +219 -0
  80. package/dist/client/js/handlers/admin.d.ts +64 -0
  81. package/dist/client/js/handlers/admin.d.ts.map +1 -0
  82. package/dist/client/js/handlers/admin.js +186 -0
  83. package/dist/client/js/state/dialogs.svelte.d.ts +16 -0
  84. package/dist/client/js/state/dialogs.svelte.d.ts.map +1 -0
  85. package/dist/client/js/state/dialogs.svelte.js +28 -0
  86. package/dist/client/js/state/router.svelte.d.ts +44 -0
  87. package/dist/client/js/state/router.svelte.d.ts.map +1 -0
  88. package/dist/client/js/state/router.svelte.js +135 -0
  89. package/dist/client/js/state/schema.svelte.d.ts +51 -0
  90. package/dist/client/js/state/schema.svelte.d.ts.map +1 -0
  91. package/{src/client/js/state/schema.svelte.ts → dist/client/js/state/schema.svelte.js} +55 -70
  92. package/dist/client/js/state/state.svelte.d.ts +68 -0
  93. package/dist/client/js/state/state.svelte.d.ts.map +1 -0
  94. package/dist/client/js/state/state.svelte.js +291 -0
  95. package/dist/client/js/state/theme.svelte.d.ts +24 -0
  96. package/dist/client/js/state/theme.svelte.d.ts.map +1 -0
  97. package/{src/client/js/state/theme.svelte.ts → dist/client/js/state/theme.svelte.js} +54 -91
  98. package/dist/client/js/storage/adapter.d.ts +130 -0
  99. package/dist/client/js/storage/adapter.d.ts.map +1 -0
  100. package/dist/client/js/storage/adapter.js +5 -0
  101. package/dist/client/js/storage/client.d.ts +72 -0
  102. package/dist/client/js/storage/client.d.ts.map +1 -0
  103. package/dist/client/js/storage/client.js +121 -0
  104. package/dist/client/js/storage/db.d.ts +8 -0
  105. package/dist/client/js/storage/db.d.ts.map +1 -0
  106. package/dist/client/js/storage/db.js +35 -0
  107. package/dist/client/js/storage/fsa.d.ts +51 -0
  108. package/dist/client/js/storage/fsa.d.ts.map +1 -0
  109. package/dist/client/js/storage/fsa.js +91 -0
  110. package/dist/client/js/storage/github.d.ts +62 -0
  111. package/dist/client/js/storage/github.d.ts.map +1 -0
  112. package/dist/client/js/storage/github.js +216 -0
  113. package/dist/client/js/storage/storage.d.ts +32 -0
  114. package/dist/client/js/storage/storage.d.ts.map +1 -0
  115. package/dist/client/js/storage/storage.js +68 -0
  116. package/dist/client/js/storage/workers/frontmatter.d.ts +2 -0
  117. package/dist/client/js/storage/workers/frontmatter.d.ts.map +1 -0
  118. package/dist/client/js/storage/workers/frontmatter.js +253 -0
  119. package/dist/client/js/storage/workers/storage.d.ts +2 -0
  120. package/dist/client/js/storage/workers/storage.d.ts.map +1 -0
  121. package/dist/client/js/storage/workers/storage.js +167 -0
  122. package/dist/client/js/storage/workers/toml-parser.d.ts +2 -0
  123. package/dist/client/js/storage/workers/toml-parser.d.ts.map +1 -0
  124. package/dist/client/js/storage/workers/toml-parser.js +75 -0
  125. package/dist/client/js/storage/workers/yaml-parser.d.ts +2 -0
  126. package/dist/client/js/storage/workers/yaml-parser.d.ts.map +1 -0
  127. package/dist/client/js/storage/workers/yaml-parser.js +100 -0
  128. package/dist/client/js/utils/file-types.d.ts +58 -0
  129. package/dist/client/js/utils/file-types.d.ts.map +1 -0
  130. package/{src/client/js/utils/file-types.ts → dist/client/js/utils/file-types.js} +75 -107
  131. package/dist/client/js/utils/format.d.ts +8 -0
  132. package/dist/client/js/utils/format.d.ts.map +1 -0
  133. package/{src/client/js/utils/format.ts → dist/client/js/utils/format.js} +5 -6
  134. package/dist/client/js/utils/frontmatter.d.ts +12 -0
  135. package/dist/client/js/utils/frontmatter.d.ts.map +1 -0
  136. package/dist/client/js/utils/frontmatter.js +29 -0
  137. package/dist/client/js/utils/schema-utils.d.ts +110 -0
  138. package/dist/client/js/utils/schema-utils.d.ts.map +1 -0
  139. package/dist/client/js/utils/schema-utils.js +242 -0
  140. package/dist/client/js/utils/slug.d.ts +8 -0
  141. package/dist/client/js/utils/slug.d.ts.map +1 -0
  142. package/{src/client/js/utils/slug.ts → dist/client/js/utils/slug.js} +6 -7
  143. package/dist/client/js/utils/sort.d.ts +41 -0
  144. package/dist/client/js/utils/sort.d.ts.map +1 -0
  145. package/dist/client/js/utils/sort.js +65 -0
  146. package/dist/client/js/utils/stable-stringify.d.ts +8 -0
  147. package/dist/client/js/utils/stable-stringify.d.ts.map +1 -0
  148. package/dist/client/js/utils/stable-stringify.js +23 -0
  149. package/dist/client/js/utils/url-utils.d.ts +11 -0
  150. package/dist/client/js/utils/url-utils.d.ts.map +1 -0
  151. package/{src/client/js/utils/url-utils.ts → dist/client/js/utils/url-utils.js} +22 -23
  152. package/dist/types.d.ts +22 -0
  153. package/dist/types.d.ts.map +1 -0
  154. package/dist/types.js +1 -0
  155. package/package.json +8 -1
  156. package/.claude/settings.local.json +0 -42
  157. package/.github/workflows/ci.yml +0 -31
  158. package/.mcp.json +0 -12
  159. package/.prettierignore +0 -5
  160. package/.prettierrc.cjs +0 -22
  161. package/AGENTS.md +0 -183
  162. package/playground/.claude/settings.local.json +0 -5
  163. package/playground/astro.config.mjs +0 -7
  164. package/playground/node_modules/.bin/astro +0 -21
  165. package/playground/node_modules/.bin/rollup +0 -21
  166. package/playground/node_modules/.bin/tsc +0 -21
  167. package/playground/node_modules/.bin/tsserver +0 -21
  168. package/playground/node_modules/.bin/vite +0 -21
  169. package/playground/node_modules/.vite/_svelte_metadata.json +0 -1
  170. package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js +0 -80
  171. package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js.map +0 -7
  172. package/playground/node_modules/.vite/deps/_metadata.json +0 -184
  173. package/playground/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  174. package/playground/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  175. package/playground/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  176. package/playground/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  177. package/playground/node_modules/.vite/deps/astro___html-escaper.js +0 -34
  178. package/playground/node_modules/.vite/deps/astro___html-escaper.js.map +0 -7
  179. package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js +0 -0
  180. package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js.map +0 -7
  181. package/playground/node_modules/.vite/deps/chunk-ALJIOON6.js +0 -1005
  182. package/playground/node_modules/.vite/deps/chunk-ALJIOON6.js.map +0 -7
  183. package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  184. package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  185. package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js +0 -21
  186. package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js.map +0 -7
  187. package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js +0 -223
  188. package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js.map +0 -7
  189. package/playground/node_modules/.vite/deps/chunk-G3C2FXJT.js +0 -204
  190. package/playground/node_modules/.vite/deps/chunk-G3C2FXJT.js.map +0 -7
  191. package/playground/node_modules/.vite/deps/chunk-GKDKFWC5.js +0 -27
  192. package/playground/node_modules/.vite/deps/chunk-GKDKFWC5.js.map +0 -7
  193. package/playground/node_modules/.vite/deps/chunk-HNCLEOC5.js +0 -4376
  194. package/playground/node_modules/.vite/deps/chunk-HNCLEOC5.js.map +0 -7
  195. package/playground/node_modules/.vite/deps/chunk-JICYXBFU.js +0 -688
  196. package/playground/node_modules/.vite/deps/chunk-JICYXBFU.js.map +0 -7
  197. package/playground/node_modules/.vite/deps/chunk-KCUTL6DD.js +0 -5099
  198. package/playground/node_modules/.vite/deps/chunk-KCUTL6DD.js.map +0 -7
  199. package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js +0 -23
  200. package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js.map +0 -7
  201. package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js +0 -148
  202. package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js.map +0 -7
  203. package/playground/node_modules/.vite/deps/package.json +0 -3
  204. package/playground/node_modules/.vite/deps/smol-toml.js +0 -843
  205. package/playground/node_modules/.vite/deps/smol-toml.js.map +0 -7
  206. package/playground/node_modules/.vite/deps/svelte.js +0 -55
  207. package/playground/node_modules/.vite/deps/svelte.js.map +0 -7
  208. package/playground/node_modules/.vite/deps/svelte___clsx.js +0 -9
  209. package/playground/node_modules/.vite/deps/svelte___clsx.js.map +0 -7
  210. package/playground/node_modules/.vite/deps/svelte_animate.js +0 -57
  211. package/playground/node_modules/.vite/deps/svelte_animate.js.map +0 -7
  212. package/playground/node_modules/.vite/deps/svelte_attachments.js +0 -15
  213. package/playground/node_modules/.vite/deps/svelte_attachments.js.map +0 -7
  214. package/playground/node_modules/.vite/deps/svelte_easing.js +0 -67
  215. package/playground/node_modules/.vite/deps/svelte_easing.js.map +0 -7
  216. package/playground/node_modules/.vite/deps/svelte_events.js +0 -11
  217. package/playground/node_modules/.vite/deps/svelte_events.js.map +0 -7
  218. package/playground/node_modules/.vite/deps/svelte_internal.js +0 -5
  219. package/playground/node_modules/.vite/deps/svelte_internal.js.map +0 -7
  220. package/playground/node_modules/.vite/deps/svelte_internal_client.js +0 -402
  221. package/playground/node_modules/.vite/deps/svelte_internal_client.js.map +0 -7
  222. package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js +0 -10
  223. package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js.map +0 -7
  224. package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js +0 -8
  225. package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js.map +0 -7
  226. package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js +0 -8
  227. package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js.map +0 -7
  228. package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js +0 -8
  229. package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js.map +0 -7
  230. package/playground/node_modules/.vite/deps/svelte_legacy.js +0 -35
  231. package/playground/node_modules/.vite/deps/svelte_legacy.js.map +0 -7
  232. package/playground/node_modules/.vite/deps/svelte_motion.js +0 -545
  233. package/playground/node_modules/.vite/deps/svelte_motion.js.map +0 -7
  234. package/playground/node_modules/.vite/deps/svelte_reactivity.js +0 -29
  235. package/playground/node_modules/.vite/deps/svelte_reactivity.js.map +0 -7
  236. package/playground/node_modules/.vite/deps/svelte_reactivity_window.js +0 -127
  237. package/playground/node_modules/.vite/deps/svelte_reactivity_window.js.map +0 -7
  238. package/playground/node_modules/.vite/deps/svelte_store.js +0 -103
  239. package/playground/node_modules/.vite/deps/svelte_store.js.map +0 -7
  240. package/playground/node_modules/.vite/deps/svelte_transition.js +0 -208
  241. package/playground/node_modules/.vite/deps/svelte_transition.js.map +0 -7
  242. package/playground/package.json +0 -16
  243. package/playground/pnpm-lock.yaml +0 -3167
  244. package/playground/src/content/authors/jane-doe.json +0 -8
  245. package/playground/src/content/config/build.toml +0 -2
  246. package/playground/src/content/courses/web-fundamentals.json +0 -29
  247. package/playground/src/content/docs/advanced.mdx +0 -6
  248. package/playground/src/content/docs/intro.md +0 -6
  249. package/playground/src/content/guides/getting-started.mdx +0 -6
  250. package/playground/src/content/posts/hello-world.md +0 -7
  251. package/playground/src/content/products/t-shirt.json +0 -16
  252. package/playground/src/content/recipes/pancakes.mdoc +0 -8
  253. package/playground/src/content/settings/site.yml +0 -2
  254. package/playground/src/content.config.ts +0 -198
  255. package/playground/src/env.d.ts +0 -1
  256. package/playground/src/pages/index.astro +0 -11
  257. package/playground/src/pages/nebula.astro +0 -14
  258. package/pnpm-workspace.yaml +0 -2
  259. package/scripts/subset-icons.mjs +0 -178
  260. package/src/astro/index.ts +0 -295
  261. package/src/client/js/drafts/merge.svelte.ts +0 -121
  262. package/src/client/js/drafts/ops.svelte.ts +0 -227
  263. package/src/client/js/drafts/storage.ts +0 -108
  264. package/src/client/js/drafts/workers/diff.ts +0 -40
  265. package/src/client/js/editor/editor.svelte.ts +0 -343
  266. package/src/client/js/editor/languages.ts +0 -98
  267. package/src/client/js/editor/markdown-shortcuts.ts +0 -261
  268. package/src/client/js/handlers/admin.ts +0 -246
  269. package/src/client/js/state/dialogs.svelte.ts +0 -35
  270. package/src/client/js/state/router.svelte.ts +0 -156
  271. package/src/client/js/state/state.svelte.ts +0 -334
  272. package/src/client/js/storage/adapter.ts +0 -102
  273. package/src/client/js/storage/client.ts +0 -150
  274. package/src/client/js/storage/db.ts +0 -36
  275. package/src/client/js/storage/fsa.ts +0 -110
  276. package/src/client/js/storage/github.ts +0 -297
  277. package/src/client/js/storage/storage.ts +0 -83
  278. package/src/client/js/storage/workers/frontmatter.ts +0 -320
  279. package/src/client/js/storage/workers/storage.ts +0 -177
  280. package/src/client/js/storage/workers/toml-parser.ts +0 -106
  281. package/src/client/js/storage/workers/yaml-parser.ts +0 -132
  282. package/src/client/js/utils/frontmatter.ts +0 -38
  283. package/src/client/js/utils/schema-utils.ts +0 -295
  284. package/src/client/js/utils/sort.ts +0 -84
  285. package/src/client/js/utils/stable-stringify.ts +0 -27
  286. package/src/types.ts +0 -25
  287. package/svelte.config.js +0 -4
  288. package/tests/astro/build.test.ts +0 -63
  289. package/tests/astro/index.test.ts +0 -689
  290. package/tests/client/components/Admin.test.ts +0 -446
  291. package/tests/client/components/BackendPicker.test.ts +0 -239
  292. package/tests/client/components/DraftChip.test.ts +0 -53
  293. package/tests/client/components/MetadataForm.test.ts +0 -164
  294. package/tests/client/components/dialogs/DeleteDraftDialog.test.ts +0 -91
  295. package/tests/client/components/dialogs/FilenameDialog.test.ts +0 -209
  296. package/tests/client/components/dialogs/dialog-stubs.ts +0 -19
  297. package/tests/client/components/editor/EditorPane.test.ts +0 -100
  298. package/tests/client/components/editor/EditorTabs.test.ts +0 -253
  299. package/tests/client/components/editor/EditorToolbar.test.ts +0 -252
  300. package/tests/client/components/editor/fixtures.ts +0 -31
  301. package/tests/client/components/fields/ArrayField.test.ts +0 -197
  302. package/tests/client/components/fields/BooleanField.test.ts +0 -206
  303. package/tests/client/components/fields/DateField.test.ts +0 -210
  304. package/tests/client/components/fields/EnumField.test.ts +0 -246
  305. package/tests/client/components/fields/NumberField.test.ts +0 -240
  306. package/tests/client/components/fields/ObjectField.test.ts +0 -157
  307. package/tests/client/components/fields/SchemaField.test.ts +0 -190
  308. package/tests/client/components/fields/StringField.test.ts +0 -223
  309. package/tests/client/components/sidebar/AdminSidebar.test.ts +0 -285
  310. package/tests/client/components/sidebar/AdminSidebarSort.test.ts +0 -135
  311. package/tests/client/components/sidebar/sort-mock.ts +0 -23
  312. package/tests/client/js/drafts/fixtures.ts +0 -22
  313. package/tests/client/js/drafts/merge.test.ts +0 -282
  314. package/tests/client/js/drafts/ops.test.ts +0 -658
  315. package/tests/client/js/drafts/storage.test.ts +0 -200
  316. package/tests/client/js/drafts/workers/diff.test.ts +0 -165
  317. package/tests/client/js/editor/editor.test.ts +0 -616
  318. package/tests/client/js/editor/link-wrap.test.ts +0 -225
  319. package/tests/client/js/editor/markdown-shortcuts.test.ts +0 -370
  320. package/tests/client/js/handlers/admin.test.ts +0 -467
  321. package/tests/client/js/state/router.test.ts +0 -619
  322. package/tests/client/js/state/schema.test.ts +0 -266
  323. package/tests/client/js/state/state.test.ts +0 -328
  324. package/tests/client/js/storage/adapter.test.ts +0 -115
  325. package/tests/client/js/storage/client.test.ts +0 -250
  326. package/tests/client/js/storage/db.test.ts +0 -59
  327. package/tests/client/js/storage/fsa.test.ts +0 -284
  328. package/tests/client/js/storage/github.test.ts +0 -349
  329. package/tests/client/js/storage/mock-port.ts +0 -95
  330. package/tests/client/js/storage/storage.test.ts +0 -77
  331. package/tests/client/js/storage/workers/frontmatter.test.ts +0 -479
  332. package/tests/client/js/storage/workers/storage.test.ts +0 -299
  333. package/tests/client/js/storage/workers/toml-parser.test.ts +0 -169
  334. package/tests/client/js/storage/workers/yaml-parser.test.ts +0 -168
  335. package/tests/client/js/utils/file-types.test.ts +0 -268
  336. package/tests/client/js/utils/frontmatter.test.ts +0 -87
  337. package/tests/client/js/utils/schema-utils.test.ts +0 -318
  338. package/tests/client/js/utils/slug.test.ts +0 -58
  339. package/tests/client/js/utils/sort.test.ts +0 -276
  340. package/tests/client/js/utils/stable-stringify.test.ts +0 -68
  341. package/tests/client/js/utils/url-utils.test.ts +0 -70
  342. package/tests/e2e/backend-connection.test.ts +0 -301
  343. package/tests/e2e/draft-lifecycle.test.ts +0 -388
  344. package/tests/e2e/editing.test.ts +0 -355
  345. package/tests/e2e/github-adapter.test.ts +0 -330
  346. package/tests/e2e/helpers/mock-adapter.ts +0 -166
  347. package/tests/e2e/helpers/test-app.ts +0 -155
  348. package/tests/e2e/navigation.test.ts +0 -358
  349. package/tests/e2e/publishing.test.ts +0 -345
  350. package/tests/e2e/unsaved-changes.test.ts +0 -317
  351. package/tests/setup.ts +0 -2
  352. package/tests/stubs/codemirror.ts +0 -197
  353. package/tsconfig.json +0 -19
  354. package/vitest.config.ts +0 -178
  355. /package/{src → dist}/client/Admin.svelte +0 -0
  356. /package/{src → dist}/client/components/BackendPicker.svelte +0 -0
  357. /package/{src → dist}/client/components/DraftChip.svelte +0 -0
  358. /package/{src → dist}/client/components/MetadataForm.svelte +0 -0
  359. /package/{src → dist}/client/components/ThemeToggle.svelte +0 -0
  360. /package/{src → dist}/client/components/dialogs/DeleteDraftDialog.svelte +0 -0
  361. /package/{src → dist}/client/components/dialogs/FilenameDialog.svelte +0 -0
  362. /package/{src → dist}/client/components/editor/EditorPane.svelte +0 -0
  363. /package/{src → dist}/client/components/editor/EditorTabs.svelte +0 -0
  364. /package/{src → dist}/client/components/editor/EditorToolbar.svelte +0 -0
  365. /package/{src → dist}/client/components/editor/FormatSelector.svelte +0 -0
  366. /package/{src → dist}/client/components/editor/Toolbar.svelte +0 -0
  367. /package/{src → dist}/client/components/fields/ArrayField.svelte +0 -0
  368. /package/{src → dist}/client/components/fields/ArrayItem.svelte +0 -0
  369. /package/{src → dist}/client/components/fields/BooleanField.svelte +0 -0
  370. /package/{src → dist}/client/components/fields/DateField.svelte +0 -0
  371. /package/{src → dist}/client/components/fields/EnumField.svelte +0 -0
  372. /package/{src → dist}/client/components/fields/FieldWrapper.svelte +0 -0
  373. /package/{src → dist}/client/components/fields/NumberField.svelte +0 -0
  374. /package/{src → dist}/client/components/fields/ObjectField.svelte +0 -0
  375. /package/{src → dist}/client/components/fields/SchemaField.svelte +0 -0
  376. /package/{src → dist}/client/components/fields/StringField.svelte +0 -0
  377. /package/{src → dist}/client/components/sidebar/AdminSidebar.svelte +0 -0
  378. /package/{src → dist}/client/components/sidebar/AdminSidebarSort.svelte +0 -0
  379. /package/{src → dist}/client/css/a11y.css +0 -0
  380. /package/{src → dist}/client/css/btn.css +0 -0
  381. /package/{src → dist}/client/css/dialog.css +0 -0
  382. /package/{src → dist}/client/css/field-input.css +0 -0
  383. /package/{src → dist}/client/css/reset.css +0 -0
  384. /package/{src → dist}/client/css/theme.css +0 -0
  385. /package/{src/client/index.ts → dist/client/index.js} +0 -0
  386. /package/{src → dist}/virtual.d.ts +0 -0
@@ -0,0 +1,72 @@
1
+ import type { StorageRequest, FileEntry, FileWrite } from './adapter';
2
+ export declare class StorageClient {
3
+ private port;
4
+ private pending;
5
+ private idCounter;
6
+ /**
7
+ * Creates a client wrapping the given port.
8
+ * @param {MessagePort} port - The port connected to the storage SharedWorker
9
+ */
10
+ constructor(port: MessagePort);
11
+ /**
12
+ * Routes responses to their pending promises. Responses without an _id are broadcast (like port-connected) and are ignored here.
13
+ * @param {StorageResponse & { _id?: string }} data - The response data
14
+ * @return {void}
15
+ */
16
+ private handleResponse;
17
+ /**
18
+ * Sends a request and waits for the matching response.
19
+ * @param {StorageRequest} msg - The request to send
20
+ * @return {Promise<StorageResponse>} The matched response
21
+ */
22
+ private send;
23
+ /**
24
+ * Initializes the backend adapter in the SharedWorker.
25
+ * @param {StorageRequest & { type: 'init' }} config - The init config
26
+ * @return {Promise<void>}
27
+ */
28
+ init(config: StorageRequest & {
29
+ type: 'init';
30
+ }): Promise<void>;
31
+ /**
32
+ * Lists files in a collection matching the given extensions.
33
+ * @param {string} collection - The collection name
34
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
35
+ * @return {Promise<FileEntry[]>} Array of file entries
36
+ */
37
+ listFiles(collection: string, extensions: string[]): Promise<FileEntry[]>;
38
+ /**
39
+ * Reads a single file's content.
40
+ * @param {string} collection - The collection name
41
+ * @param {string} filename - The filename
42
+ * @return {Promise<string>} The file content
43
+ */
44
+ readFile(collection: string, filename: string): Promise<string>;
45
+ /**
46
+ * Writes a single file.
47
+ * @param {string} collection - The collection name
48
+ * @param {string} filename - The filename
49
+ * @param {string} content - The content to write
50
+ * @return {Promise<void>}
51
+ */
52
+ writeFile(collection: string, filename: string, content: string): Promise<void>;
53
+ /**
54
+ * Writes multiple files atomically.
55
+ * @param {FileWrite[]} files - Array of files to write
56
+ * @return {Promise<void>}
57
+ */
58
+ writeFiles(files: FileWrite[]): Promise<void>;
59
+ /**
60
+ * Deletes a file from a collection. Used during file type conversion to remove the old file after the new one is written.
61
+ * @param {string} collection - The collection name
62
+ * @param {string} filename - The filename to delete
63
+ * @return {Promise<void>}
64
+ */
65
+ deleteFile(collection: string, filename: string): Promise<void>;
66
+ /**
67
+ * Tears down the active backend adapter.
68
+ * @return {Promise<void>}
69
+ */
70
+ teardown(): Promise<void>;
71
+ }
72
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client/js/storage/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,SAAS,EACV,MAAM,WAAW,CAAC;AAEnB,qBAAa,aAAa;IACxB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,OAAO,CAGX;IACJ,OAAO,CAAC,SAAS,CAAK;IAEtB;;;OAGG;gBACS,IAAI,EAAE,WAAW;IAQ7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAQZ;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;;OAKG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,SAAS,EAAE,CAAC;IAWvB;;;;;OAKG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrE;;;;;;OAMG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;;;;OAKG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Typed client for communicating with the storage SharedWorker over a MessagePort.
3
+ * Wraps postMessage/onmessage into async request/response calls.
4
+ */
5
+ export class StorageClient {
6
+ port;
7
+ pending = new Map();
8
+ idCounter = 0;
9
+ /**
10
+ * Creates a client wrapping the given port.
11
+ * @param {MessagePort} port - The port connected to the storage SharedWorker
12
+ */
13
+ constructor(port) {
14
+ this.port = port;
15
+ this.port.addEventListener('message', (event) => {
16
+ this.handleResponse(event.data);
17
+ });
18
+ this.port.start();
19
+ }
20
+ /**
21
+ * Routes responses to their pending promises. Responses without an _id are broadcast (like port-connected) and are ignored here.
22
+ * @param {StorageResponse & { _id?: string }} data - The response data
23
+ * @return {void}
24
+ */
25
+ handleResponse(data) {
26
+ if (!data._id)
27
+ return;
28
+ const entry = this.pending.get(data._id);
29
+ if (!entry)
30
+ return;
31
+ this.pending.delete(data._id);
32
+ if ('ok' in data && data.ok === false && 'error' in data) {
33
+ entry.reject(new Error(data.error));
34
+ }
35
+ else {
36
+ entry.resolve(data);
37
+ }
38
+ }
39
+ /**
40
+ * Sends a request and waits for the matching response.
41
+ * @param {StorageRequest} msg - The request to send
42
+ * @return {Promise<StorageResponse>} The matched response
43
+ */
44
+ send(msg) {
45
+ const _id = String(++this.idCounter);
46
+ return new Promise((resolve, reject) => {
47
+ this.pending.set(_id, { resolve, reject });
48
+ this.port.postMessage({ ...msg, _id });
49
+ });
50
+ }
51
+ /**
52
+ * Initializes the backend adapter in the SharedWorker.
53
+ * @param {StorageRequest & { type: 'init' }} config - The init config
54
+ * @return {Promise<void>}
55
+ */
56
+ async init(config) {
57
+ await this.send(config);
58
+ }
59
+ /**
60
+ * Lists files in a collection matching the given extensions.
61
+ * @param {string} collection - The collection name
62
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
63
+ * @return {Promise<FileEntry[]>} Array of file entries
64
+ */
65
+ async listFiles(collection, extensions) {
66
+ const res = await this.send({
67
+ type: 'listFiles',
68
+ collection,
69
+ extensions,
70
+ });
71
+ return res.files;
72
+ }
73
+ /**
74
+ * Reads a single file's content.
75
+ * @param {string} collection - The collection name
76
+ * @param {string} filename - The filename
77
+ * @return {Promise<string>} The file content
78
+ */
79
+ async readFile(collection, filename) {
80
+ const res = await this.send({
81
+ type: 'readFile',
82
+ collection,
83
+ filename,
84
+ });
85
+ return res.content;
86
+ }
87
+ /**
88
+ * Writes a single file.
89
+ * @param {string} collection - The collection name
90
+ * @param {string} filename - The filename
91
+ * @param {string} content - The content to write
92
+ * @return {Promise<void>}
93
+ */
94
+ async writeFile(collection, filename, content) {
95
+ await this.send({ type: 'writeFile', collection, filename, content });
96
+ }
97
+ /**
98
+ * Writes multiple files atomically.
99
+ * @param {FileWrite[]} files - Array of files to write
100
+ * @return {Promise<void>}
101
+ */
102
+ async writeFiles(files) {
103
+ await this.send({ type: 'writeFiles', files });
104
+ }
105
+ /**
106
+ * Deletes a file from a collection. Used during file type conversion to remove the old file after the new one is written.
107
+ * @param {string} collection - The collection name
108
+ * @param {string} filename - The filename to delete
109
+ * @return {Promise<void>}
110
+ */
111
+ async deleteFile(collection, filename) {
112
+ await this.send({ type: 'deleteFile', collection, filename });
113
+ }
114
+ /**
115
+ * Tears down the active backend adapter.
116
+ * @return {Promise<void>}
117
+ */
118
+ async teardown() {
119
+ await this.send({ type: 'teardown' });
120
+ }
121
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Opens (or returns the cached) shared IndexedDB database, creating or upgrading stores as needed.
3
+ * The connection is opened once and reused, avoiding a new indexedDB.open() round-trip per call.
4
+ * Version 1: handles store only. Version 2: adds drafts store.
5
+ * @return {Promise<IDBDatabase>} Promise resolving to the database instance
6
+ */
7
+ export declare function openDB(): Promise<IDBDatabase>;
8
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../../src/client/js/storage/db.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,CAqB7C"}
@@ -0,0 +1,35 @@
1
+ // Database name for admin CMS persistence
2
+ const DB_NAME = 'cms-admin';
3
+ // Current database version — bumped from 1 to add the drafts store
4
+ const DB_VERSION = 2;
5
+ // Cached database promise — opened once, reused by all callers
6
+ let dbPromise = null;
7
+ /**
8
+ * Opens (or returns the cached) shared IndexedDB database, creating or upgrading stores as needed.
9
+ * The connection is opened once and reused, avoiding a new indexedDB.open() round-trip per call.
10
+ * Version 1: handles store only. Version 2: adds drafts store.
11
+ * @return {Promise<IDBDatabase>} Promise resolving to the database instance
12
+ */
13
+ export function openDB() {
14
+ if (dbPromise)
15
+ return dbPromise;
16
+ dbPromise = new Promise((resolve, reject) => {
17
+ const request = indexedDB.open(DB_NAME, DB_VERSION);
18
+ request.onupgradeneeded = () => {
19
+ const db = request.result;
20
+ if (!db.objectStoreNames.contains('handles')) {
21
+ db.createObjectStore('handles');
22
+ }
23
+ if (!db.objectStoreNames.contains('drafts')) {
24
+ db.createObjectStore('drafts', { keyPath: 'id' });
25
+ }
26
+ };
27
+ request.onsuccess = () => resolve(request.result);
28
+ request.onerror = () => {
29
+ // Reset cache so the next caller retries instead of getting a stale rejection
30
+ dbPromise = null;
31
+ reject(request.error);
32
+ };
33
+ });
34
+ return dbPromise;
35
+ }
@@ -0,0 +1,51 @@
1
+ import type { StorageAdapter, FileEntry, FileWrite } from './adapter';
2
+ export declare class FsaAdapter implements StorageAdapter {
3
+ private root;
4
+ /**
5
+ * Creates an FSA adapter rooted at the given directory handle.
6
+ * @param {FileSystemDirectoryHandle} root - The project root directory handle
7
+ */
8
+ constructor(root: FileSystemDirectoryHandle);
9
+ /**
10
+ * Traverses root → src → content → {collection}.
11
+ * @param {string} collection - The collection name
12
+ * @return {Promise<FileSystemDirectoryHandle>} The collection directory handle
13
+ */
14
+ private getCollectionDir;
15
+ /**
16
+ * Lists files in the collection matching the given extensions, with their content.
17
+ * @param {string} collection - The collection name
18
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
19
+ * @return {Promise<FileEntry[]>} Array of filename + content pairs
20
+ */
21
+ listFiles(collection: string, extensions: string[]): Promise<FileEntry[]>;
22
+ /**
23
+ * Deletes a file from the collection directory.
24
+ * @param {string} collection - The collection name
25
+ * @param {string} filename - The filename to delete
26
+ * @return {Promise<void>}
27
+ */
28
+ deleteFile(collection: string, filename: string): Promise<void>;
29
+ /**
30
+ * Reads a single file's content from the collection.
31
+ * @param {string} collection - The collection name
32
+ * @param {string} filename - The filename
33
+ * @return {Promise<string>} The file content
34
+ */
35
+ readFile(collection: string, filename: string): Promise<string>;
36
+ /**
37
+ * Writes content to a file, creating it if necessary.
38
+ * @param {string} collection - The collection name
39
+ * @param {string} filename - The filename
40
+ * @param {string} content - The content to write
41
+ * @return {Promise<void>}
42
+ */
43
+ writeFile(collection: string, filename: string, content: string): Promise<void>;
44
+ /**
45
+ * Writes multiple files sequentially (FSA has no atomic multi-file write).
46
+ * @param {FileWrite[]} files - Array of files to write
47
+ * @return {Promise<void>}
48
+ */
49
+ writeFiles(files: FileWrite[]): Promise<void>;
50
+ }
51
+ //# sourceMappingURL=fsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsa.d.ts","sourceRoot":"","sources":["../../../../src/client/js/storage/fsa.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtE,qBAAa,UAAW,YAAW,cAAc;IAKnC,OAAO,CAAC,IAAI;IAJxB;;;OAGG;gBACiB,IAAI,EAAE,yBAAyB;IAEnD;;;;OAIG;YACW,gBAAgB;IAQ9B;;;;;OAKG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,SAAS,EAAE,CAAC;IAmBvB;;;;;OAKG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrE;;;;;OAKG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrE;;;;;;OAMG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAKpD"}
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Storage adapter backed by the File System Access API.
3
+ * Traverses from a project root handle through src/content/{collection}/ for all operations.
4
+ */
5
+ // FSA adapter implementation
6
+ export class FsaAdapter {
7
+ root;
8
+ /**
9
+ * Creates an FSA adapter rooted at the given directory handle.
10
+ * @param {FileSystemDirectoryHandle} root - The project root directory handle
11
+ */
12
+ constructor(root) {
13
+ this.root = root;
14
+ }
15
+ /**
16
+ * Traverses root → src → content → {collection}.
17
+ * @param {string} collection - The collection name
18
+ * @return {Promise<FileSystemDirectoryHandle>} The collection directory handle
19
+ */
20
+ async getCollectionDir(collection) {
21
+ const src = await this.root.getDirectoryHandle('src');
22
+ const content = await src.getDirectoryHandle('content');
23
+ return content.getDirectoryHandle(collection);
24
+ }
25
+ /**
26
+ * Lists files in the collection matching the given extensions, with their content.
27
+ * @param {string} collection - The collection name
28
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
29
+ * @return {Promise<FileEntry[]>} Array of filename + content pairs
30
+ */
31
+ async listFiles(collection, extensions) {
32
+ const dir = await this.getCollectionDir(collection);
33
+ const entries = [];
34
+ for await (const [name, entry] of dir.entries()) {
35
+ if (entry.kind !== 'file' ||
36
+ !extensions.some((ext) => name.endsWith(ext))) {
37
+ continue;
38
+ }
39
+ const file = await entry.getFile();
40
+ const content = await file.text();
41
+ entries.push({ filename: name, content });
42
+ }
43
+ return entries;
44
+ }
45
+ /**
46
+ * Deletes a file from the collection directory.
47
+ * @param {string} collection - The collection name
48
+ * @param {string} filename - The filename to delete
49
+ * @return {Promise<void>}
50
+ */
51
+ async deleteFile(collection, filename) {
52
+ const dir = await this.getCollectionDir(collection);
53
+ await dir.removeEntry(filename);
54
+ }
55
+ /**
56
+ * Reads a single file's content from the collection.
57
+ * @param {string} collection - The collection name
58
+ * @param {string} filename - The filename
59
+ * @return {Promise<string>} The file content
60
+ */
61
+ async readFile(collection, filename) {
62
+ const dir = await this.getCollectionDir(collection);
63
+ const fileHandle = await dir.getFileHandle(filename);
64
+ const file = await fileHandle.getFile();
65
+ return file.text();
66
+ }
67
+ /**
68
+ * Writes content to a file, creating it if necessary.
69
+ * @param {string} collection - The collection name
70
+ * @param {string} filename - The filename
71
+ * @param {string} content - The content to write
72
+ * @return {Promise<void>}
73
+ */
74
+ async writeFile(collection, filename, content) {
75
+ const dir = await this.getCollectionDir(collection);
76
+ const fileHandle = await dir.getFileHandle(filename, { create: true });
77
+ const writable = await fileHandle.createWritable();
78
+ await writable.write(content);
79
+ await writable.close();
80
+ }
81
+ /**
82
+ * Writes multiple files sequentially (FSA has no atomic multi-file write).
83
+ * @param {FileWrite[]} files - Array of files to write
84
+ * @return {Promise<void>}
85
+ */
86
+ async writeFiles(files) {
87
+ for (const f of files) {
88
+ await this.writeFile(f.collection, f.filename, f.content);
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,62 @@
1
+ import type { StorageAdapter, FileEntry, FileWrite } from './adapter';
2
+ export declare class GitHubAdapter implements StorageAdapter {
3
+ private token;
4
+ private owner;
5
+ private repo;
6
+ private defaultBranch;
7
+ /**
8
+ * @param {string} token - GitHub Personal Access Token
9
+ * @param {string} repoSlug - Repository in "owner/repo" format
10
+ */
11
+ constructor(token: string, repoSlug: string);
12
+ /**
13
+ * Validates credentials by fetching repo metadata and caches the default branch.
14
+ * @return {Promise<void>}
15
+ */
16
+ validate(): Promise<void>;
17
+ /**
18
+ * Lists files in a collection matching the given extensions, with their raw content.
19
+ * @param {string} collection - The collection name
20
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
21
+ * @return {Promise<FileEntry[]>} Array of filename + content pairs
22
+ */
23
+ listFiles(collection: string, extensions: string[]): Promise<FileEntry[]>;
24
+ /**
25
+ * Deletes a file from the repository via the Contents API.
26
+ * @param {string} collection - The collection name
27
+ * @param {string} filename - The filename to delete
28
+ * @return {Promise<void>}
29
+ */
30
+ deleteFile(collection: string, filename: string): Promise<void>;
31
+ /**
32
+ * Reads a single file's raw content via the raw+json Accept header.
33
+ * @param {string} collection - The collection name
34
+ * @param {string} filename - The filename
35
+ * @return {Promise<string>} The file content
36
+ */
37
+ readFile(collection: string, filename: string): Promise<string>;
38
+ /**
39
+ * Writes a single file via the Contents API. Fetches the current SHA for updates.
40
+ * @param {string} collection - The collection name
41
+ * @param {string} filename - The filename
42
+ * @param {string} content - The content to write
43
+ * @return {Promise<void>}
44
+ */
45
+ writeFile(collection: string, filename: string, content: string): Promise<void>;
46
+ /**
47
+ * Writes multiple files in a single atomic commit using the Git Trees + Commits API.
48
+ * @param {FileWrite[]} files - Array of files to write
49
+ * @return {Promise<void>}
50
+ */
51
+ writeFiles(files: FileWrite[]): Promise<void>;
52
+ /**
53
+ * Makes an authenticated request to the GitHub API.
54
+ * @param {string} method - HTTP method
55
+ * @param {string} path - API path (appended to https://api.github.com)
56
+ * @param {Record<string, string>} [extraHeaders] - Additional headers to merge
57
+ * @param {unknown} [body] - JSON body to send
58
+ * @return {Promise<Response>} The fetch response
59
+ */
60
+ private request;
61
+ }
62
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../src/client/js/storage/github.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAatE,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IAErB,OAAO,CAAC,aAAa,CAAkB;IAEvC;;;OAGG;gBACS,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAO3C;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B;;;;;OAKG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,SAAS,EAAE,CAAC;IA2BvB;;;;;OAKG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrE;;;;;OAKG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAarE;;;;;;OAMG;IACG,SAAS,CACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAgChB;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4EnD;;;;;;;OAOG;YACW,OAAO;CAyBtB"}
@@ -0,0 +1,216 @@
1
+ /*
2
+ * Storage adapter backed by the GitHub REST API.
3
+ * Uses a Personal Access Token for authentication. All file operations
4
+ * target src/content/{collection}/ within the repository.
5
+ */
6
+ /**
7
+ * Encodes a Uint8Array to a base64 string without using deprecated unescape().
8
+ * @param {Uint8Array} bytes - The bytes to encode
9
+ * @return {string} Base64-encoded string
10
+ */
11
+ function uint8ToBase64(bytes) {
12
+ let binary = '';
13
+ for (const byte of bytes)
14
+ binary += String.fromCharCode(byte);
15
+ return btoa(binary);
16
+ }
17
+ export class GitHubAdapter {
18
+ token;
19
+ owner;
20
+ repo;
21
+ // Cached on validate(); defaults to 'main' before validation
22
+ defaultBranch = 'main';
23
+ /**
24
+ * @param {string} token - GitHub Personal Access Token
25
+ * @param {string} repoSlug - Repository in "owner/repo" format
26
+ */
27
+ constructor(token, repoSlug) {
28
+ this.token = token;
29
+ const [owner, repo] = repoSlug.split('/');
30
+ this.owner = owner;
31
+ this.repo = repo;
32
+ }
33
+ /**
34
+ * Validates credentials by fetching repo metadata and caches the default branch.
35
+ * @return {Promise<void>}
36
+ */
37
+ async validate() {
38
+ const res = await this.request('GET', `/repos/${this.owner}/${this.repo}`);
39
+ if (!res.ok) {
40
+ const status = res.status;
41
+ if (status === 401)
42
+ throw new Error('Invalid or expired token');
43
+ if (status === 403)
44
+ throw new Error('Token lacks repository access');
45
+ if (status === 404)
46
+ throw new Error(`Repository "${this.owner}/${this.repo}" not found`);
47
+ throw new Error(`GitHub API error: ${status}`);
48
+ }
49
+ const data = await res.json();
50
+ this.defaultBranch = data.default_branch;
51
+ }
52
+ /**
53
+ * Lists files in a collection matching the given extensions, with their raw content.
54
+ * @param {string} collection - The collection name
55
+ * @param {string[]} extensions - File extensions to include (e.g. ['.md', '.mdx'])
56
+ * @return {Promise<FileEntry[]>} Array of filename + content pairs
57
+ */
58
+ async listFiles(collection, extensions) {
59
+ const path = `src/content/${collection}`;
60
+ // Get directory listing
61
+ const listRes = await this.request('GET', `/repos/${this.owner}/${this.repo}/contents/${path}?ref=${this.defaultBranch}`);
62
+ if (!listRes.ok) {
63
+ if (listRes.status === 404)
64
+ return [];
65
+ throw new Error(`Failed to list files: ${listRes.status}`);
66
+ }
67
+ const listing = await listRes.json();
68
+ // Filter to requested extensions and fetch all files in parallel
69
+ const filtered = listing.filter((f) => extensions.some((ext) => f.name.endsWith(ext)));
70
+ return Promise.all(filtered.map(async (file) => ({
71
+ filename: file.name,
72
+ content: await this.readFile(collection, file.name),
73
+ })));
74
+ }
75
+ /**
76
+ * Deletes a file from the repository via the Contents API.
77
+ * @param {string} collection - The collection name
78
+ * @param {string} filename - The filename to delete
79
+ * @return {Promise<void>}
80
+ */
81
+ async deleteFile(collection, filename) {
82
+ const path = `src/content/${collection}/${filename}`;
83
+ // Get the current SHA (required by the GitHub Contents API for deletion)
84
+ const existing = await this.request('GET', `/repos/${this.owner}/${this.repo}/contents/${path}?ref=${this.defaultBranch}`);
85
+ if (!existing.ok)
86
+ throw new Error(`File not found for deletion: ${path}`);
87
+ const data = await existing.json();
88
+ const res = await this.request('DELETE', `/repos/${this.owner}/${this.repo}/contents/${path}`, undefined, {
89
+ message: `Delete ${path}`,
90
+ sha: data.sha,
91
+ branch: this.defaultBranch,
92
+ });
93
+ if (!res.ok)
94
+ throw new Error(`Failed to delete ${path}: ${res.status}`);
95
+ }
96
+ /**
97
+ * Reads a single file's raw content via the raw+json Accept header.
98
+ * @param {string} collection - The collection name
99
+ * @param {string} filename - The filename
100
+ * @return {Promise<string>} The file content
101
+ */
102
+ async readFile(collection, filename) {
103
+ const path = `src/content/${collection}/${filename}`;
104
+ const res = await this.request('GET', `/repos/${this.owner}/${this.repo}/contents/${path}?ref=${this.defaultBranch}`, { Accept: 'application/vnd.github.raw+json' });
105
+ if (!res.ok) {
106
+ throw new Error(`Failed to read ${path}: ${res.status}`);
107
+ }
108
+ return res.text();
109
+ }
110
+ /**
111
+ * Writes a single file via the Contents API. Fetches the current SHA for updates.
112
+ * @param {string} collection - The collection name
113
+ * @param {string} filename - The filename
114
+ * @param {string} content - The content to write
115
+ * @return {Promise<void>}
116
+ */
117
+ async writeFile(collection, filename, content) {
118
+ const path = `src/content/${collection}/${filename}`;
119
+ // Get current SHA if file exists (required by GitHub API for updates)
120
+ let sha;
121
+ const existing = await this.request('GET', `/repos/${this.owner}/${this.repo}/contents/${path}?ref=${this.defaultBranch}`);
122
+ if (existing.ok) {
123
+ const data = await existing.json();
124
+ sha = data.sha;
125
+ }
126
+ const body = {
127
+ message: `Update ${path}`,
128
+ content: uint8ToBase64(new TextEncoder().encode(content)),
129
+ branch: this.defaultBranch,
130
+ };
131
+ if (sha)
132
+ body.sha = sha;
133
+ const res = await this.request('PUT', `/repos/${this.owner}/${this.repo}/contents/${path}`, undefined, body);
134
+ if (!res.ok) {
135
+ const errText = await res.text();
136
+ throw new Error(`Failed to write ${path}: ${res.status} ${errText}`);
137
+ }
138
+ }
139
+ /**
140
+ * Writes multiple files in a single atomic commit using the Git Trees + Commits API.
141
+ * @param {FileWrite[]} files - Array of files to write
142
+ * @return {Promise<void>}
143
+ */
144
+ async writeFiles(files) {
145
+ if (files.length === 0)
146
+ return;
147
+ if (files.length === 1) {
148
+ await this.writeFile(files[0].collection, files[0].filename, files[0].content);
149
+ return;
150
+ }
151
+ // 1. Get current commit SHA for the default branch
152
+ const refRes = await this.request('GET', `/repos/${this.owner}/${this.repo}/git/ref/heads/${this.defaultBranch}`);
153
+ if (!refRes.ok)
154
+ throw new Error(`Failed to get branch ref: ${refRes.status}`);
155
+ const refData = await refRes.json();
156
+ const baseCommitSHA = refData.object.sha;
157
+ // Get the base tree SHA from the current commit
158
+ const commitRes = await this.request('GET', `/repos/${this.owner}/${this.repo}/git/commits/${baseCommitSHA}`);
159
+ if (!commitRes.ok)
160
+ throw new Error(`Failed to get commit: ${commitRes.status}`);
161
+ const commitData = await commitRes.json();
162
+ const baseTreeSHA = commitData.tree.sha;
163
+ // 2. Create a new tree containing all file changes
164
+ const tree = files.map((f) => ({
165
+ path: `src/content/${f.collection}/${f.filename}`,
166
+ mode: '100644',
167
+ type: 'blob',
168
+ content: f.content,
169
+ }));
170
+ const treeRes = await this.request('POST', `/repos/${this.owner}/${this.repo}/git/trees`, undefined, { base_tree: baseTreeSHA, tree });
171
+ if (!treeRes.ok)
172
+ throw new Error(`Failed to create tree: ${treeRes.status}`);
173
+ const treeData = await treeRes.json();
174
+ // 3. Create a new commit pointing at the new tree
175
+ const paths = files.map((f) => `${f.collection}/${f.filename}`).join(', ');
176
+ const newCommitRes = await this.request('POST', `/repos/${this.owner}/${this.repo}/git/commits`, undefined, {
177
+ message: `Update ${paths}`,
178
+ tree: treeData.sha,
179
+ parents: [baseCommitSHA],
180
+ });
181
+ if (!newCommitRes.ok)
182
+ throw new Error(`Failed to create commit: ${newCommitRes.status}`);
183
+ const newCommitData = await newCommitRes.json();
184
+ // 4. Advance the branch ref to the new commit
185
+ const updateRefRes = await this.request('PATCH', `/repos/${this.owner}/${this.repo}/git/refs/heads/${this.defaultBranch}`, undefined, { sha: newCommitData.sha });
186
+ if (!updateRefRes.ok)
187
+ throw new Error(`Failed to update ref: ${updateRefRes.status}`);
188
+ }
189
+ /**
190
+ * Makes an authenticated request to the GitHub API.
191
+ * @param {string} method - HTTP method
192
+ * @param {string} path - API path (appended to https://api.github.com)
193
+ * @param {Record<string, string>} [extraHeaders] - Additional headers to merge
194
+ * @param {unknown} [body] - JSON body to send
195
+ * @return {Promise<Response>} The fetch response
196
+ */
197
+ async request(method, path, extraHeaders, body) {
198
+ const headers = {
199
+ Authorization: `Bearer ${this.token}`,
200
+ 'X-GitHub-Api-Version': '2026-03-10',
201
+ // Default to JSON so the browser cache distinguishes from raw content requests
202
+ Accept: 'application/vnd.github+json',
203
+ ...extraHeaders,
204
+ };
205
+ if (body) {
206
+ headers['Content-Type'] = 'application/json';
207
+ }
208
+ return fetch(`https://api.github.com${path}`, {
209
+ method,
210
+ headers,
211
+ body: body ? JSON.stringify(body) : undefined,
212
+ // API responses must never be served from browser cache
213
+ cache: 'no-store',
214
+ });
215
+ }
216
+ }