alinea 2.0.0-preview.6 → 2.0.0-preview.8

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 (298) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +109 -109
  3. package/dist/adapter/next/cms.d.ts +18 -4
  4. package/dist/adapter/next/cms.js +125 -36
  5. package/dist/adapter/next/handler.d.ts +5 -1
  6. package/dist/adapter/next/handler.js +14 -7
  7. package/dist/adapter/next/node.d.ts +5 -0
  8. package/dist/adapter/next/node.js +16 -0
  9. package/dist/adapter/next/previews.d.ts +4 -1
  10. package/dist/adapter/next/previews.js +13 -3
  11. package/dist/adapter/next/renderStats.d.ts +24 -0
  12. package/dist/adapter/next/renderStats.js +74 -0
  13. package/dist/adapter/next/syncCheck.d.ts +8 -2
  14. package/dist/adapter/next/syncCheck.js +3 -3
  15. package/dist/adapter/next/with-alinea.js +0 -18
  16. package/dist/backend/Handler.d.ts +2 -2
  17. package/dist/backend/Handler.js +33 -12
  18. package/dist/backend/api/CreateBackend.js +15 -3
  19. package/dist/backend/api/DatabaseApi.js +22 -135
  20. package/dist/backend/api/database.js +15 -3
  21. package/dist/backend/resolver/ParsePreview.d.ts +2 -2
  22. package/dist/backend/router/NodeHandler.js +2 -0
  23. package/dist/backend/store/GeneratedDatabase.d.ts +5 -0
  24. package/dist/backend/store/GeneratedDatabase.js +31 -0
  25. package/dist/backend/store/GeneratedDatabaseNode.d.ts +4 -0
  26. package/dist/backend/store/GeneratedDatabaseNode.js +35 -0
  27. package/dist/backend/util/ORM.js +4 -2
  28. package/dist/bundled.d.ts +1485 -446
  29. package/dist/chunks/bun-sqlite-ZZDB7YQQ.js +18 -0
  30. package/dist/chunks/chunk-2BJ2IFQM.js +1085 -0
  31. package/dist/chunks/chunk-2PIFHEYR.js +364 -0
  32. package/dist/chunks/{chunk-X47OVDF3.js → chunk-2U43BB6P.js} +356 -1000
  33. package/dist/chunks/chunk-76VMZTLN.js +55 -0
  34. package/dist/chunks/chunk-A42DP5T7.js +94 -0
  35. package/dist/chunks/chunk-ATF42T2B.js +35 -0
  36. package/dist/chunks/{chunk-NWQXN4SB.js → chunk-ETBQTP2S.js} +40 -29
  37. package/dist/chunks/chunk-IL7FJQAY.js +94 -0
  38. package/dist/chunks/chunk-K62JP6HR.js +22 -0
  39. package/dist/chunks/chunk-K7LHQXI4.js +103 -0
  40. package/dist/chunks/chunk-M7KDJEGH.js +495 -0
  41. package/dist/chunks/chunk-N47Y62CI.js +396 -0
  42. package/dist/chunks/chunk-NLZLRQ5U.js +100 -0
  43. package/dist/chunks/chunk-QBPYWU6C.js +24 -0
  44. package/dist/chunks/{chunk-7IOKMUKO.js → chunk-RWWYUNVX.js} +2 -1
  45. package/dist/chunks/chunk-TFMUSWGG.js +605 -0
  46. package/dist/chunks/{chunk-I4GC3E65.js → chunk-UPY2RUZF.js} +0 -1
  47. package/dist/chunks/chunk-XCZXR3C2.js +112 -0
  48. package/dist/chunks/chunk-XTWYBWP2.js +81 -0
  49. package/dist/chunks/node-sqlite-7CSGL27V.js +18 -0
  50. package/dist/cli/Generate.js +74 -64
  51. package/dist/cli/Serve.js +1 -1
  52. package/dist/cli/bin.js +2 -1
  53. package/dist/cli/generate/CopyStaticFiles.js +17 -14
  54. package/dist/cli/generate/DevDB.d.ts +22 -5
  55. package/dist/cli/generate/DevDB.js +136 -24
  56. package/dist/cli/serve/CreateLocalServer.js +22 -4
  57. package/dist/cli/serve/LiveReload.d.ts +1 -1
  58. package/dist/cli/serve/LiveReload.js +3 -0
  59. package/dist/cloud/CloudRemote.js +2 -1
  60. package/dist/components/Calendar.js +5 -5
  61. package/dist/components/Checkbox.js +2 -2
  62. package/dist/components/ComboBox.js +13 -13
  63. package/dist/components/DateField.js +3 -3
  64. package/dist/components/DatePicker.js +5 -5
  65. package/dist/components/DateRangePicker.js +6 -6
  66. package/dist/components/Disclosure.js +7 -7
  67. package/dist/components/Label.js +4 -4
  68. package/dist/components/List.js +51 -49
  69. package/dist/components/Menu.js +4 -4
  70. package/dist/components/Modal.js +2 -2
  71. package/dist/components/MultipleSelect.js +25 -25
  72. package/dist/components/NumberField.js +3 -3
  73. package/dist/components/ProgressCircle.js +2 -2
  74. package/dist/components/RadioGroup.js +2 -2
  75. package/dist/components/SearchField.js +8 -8
  76. package/dist/components/Select.js +8 -8
  77. package/dist/components/Surface.js +3 -3
  78. package/dist/components/Table.js +7 -7
  79. package/dist/components/Tabs.js +4 -4
  80. package/dist/components/TagGroup.js +3 -3
  81. package/dist/components/TextField.js +3 -3
  82. package/dist/components/TimeField.js +3 -3
  83. package/dist/components/Toggle.js +2 -2
  84. package/dist/components/Toolbar.js +2 -2
  85. package/dist/components/Tooltip.js +3 -3
  86. package/dist/components/Tree.d.ts +2 -1
  87. package/dist/components/Tree.js +9 -9
  88. package/dist/core/Document.js +15 -3
  89. package/dist/core/Entry.d.ts +3 -0
  90. package/dist/core/Entry.js +4 -0
  91. package/dist/core/EntrySeed.d.ts +19 -0
  92. package/dist/core/EntrySeed.js +136 -0
  93. package/dist/core/Field.d.ts +7 -0
  94. package/dist/core/Field.js +4 -0
  95. package/dist/core/Filter.d.ts +40 -2
  96. package/dist/core/Filter.js +145 -0
  97. package/dist/core/Graph.d.ts +9 -0
  98. package/dist/core/ListRow.d.ts +1 -0
  99. package/dist/core/ListRow.js +1 -0
  100. package/dist/core/Reference.d.ts +1 -0
  101. package/dist/core/Root.js +1 -1
  102. package/dist/core/Scope.d.ts +2 -0
  103. package/dist/core/Scope.js +16 -1
  104. package/dist/core/TextDoc.d.ts +1 -0
  105. package/dist/core/Type.d.ts +2 -1
  106. package/dist/core/Type.js +13 -1
  107. package/dist/core/db/EntryAliases.js +1 -11
  108. package/dist/core/db/EntryReference.d.ts +0 -6
  109. package/dist/core/db/IndexEvent.d.ts +2 -1
  110. package/dist/core/db/IndexEvent.js +11 -3
  111. package/dist/core/db/LinkResolver.d.ts +6 -6
  112. package/dist/core/db/LinkResolver.js +0 -52
  113. package/dist/core/db/LocalStore.d.ts +25 -0
  114. package/dist/core/field/ListField.js +19 -0
  115. package/dist/core/field/RecordField.js +8 -0
  116. package/dist/core/field/RichTextField.js +45 -3
  117. package/dist/core/field/UnionField.js +8 -0
  118. package/dist/core/source/FSSource.d.ts +14 -2
  119. package/dist/core/source/FSSource.js +58 -13
  120. package/dist/core/source/GitUtils.d.ts +4 -0
  121. package/dist/core/source/GitUtils.js +9 -10
  122. package/dist/core/source/GithubSource.js +22 -11
  123. package/dist/core/source/IndexedDBSource.d.ts +2 -1
  124. package/dist/core/source/IndexedDBSource.js +67 -53
  125. package/dist/core/source/MemorySource.js +5 -3
  126. package/dist/core/source/OverlaySource.d.ts +5 -2
  127. package/dist/core/source/OverlaySource.js +31 -3
  128. package/dist/core/source/Source.d.ts +3 -0
  129. package/dist/core/source/Source.js +15 -2
  130. package/dist/core/source/Tree.d.ts +10 -7
  131. package/dist/core/source/Tree.js +118 -70
  132. package/dist/core/source/Utils.js +6 -3
  133. package/dist/core/util/Arrays.d.ts +1 -0
  134. package/dist/core/util/Arrays.js +10 -0
  135. package/dist/core/util/Async.d.ts +7 -0
  136. package/dist/core/util/Async.js +15 -0
  137. package/dist/core/util/Checks.js +1 -1
  138. package/dist/core/util/EntryFilenames.d.ts +22 -1
  139. package/dist/core/util/EntryFilenames.js +56 -2
  140. package/dist/core/util/IndexedDB.d.ts +4 -0
  141. package/dist/core/util/IndexedDB.js +20 -0
  142. package/dist/core/util/Paths.js +5 -1
  143. package/dist/dashboard/App.js +5 -3
  144. package/dist/dashboard/ViewKeys.d.ts +1 -0
  145. package/dist/dashboard/ViewKeys.js +1 -0
  146. package/dist/dashboard/app/AccessDenied.js +3 -3
  147. package/dist/dashboard/app/ActivityStatus.js +17 -17
  148. package/dist/dashboard/app/AppShell.js +2 -2
  149. package/dist/dashboard/app/AuthView.js +11 -11
  150. package/dist/dashboard/app/CompactField.js +12 -12
  151. package/dist/dashboard/app/DashboardErrorBoundary.js +6 -6
  152. package/dist/dashboard/app/DashboardLayout.js +6 -5
  153. package/dist/dashboard/app/EntryHeader.js +8 -8
  154. package/dist/dashboard/app/EntryReferences.js +12 -17
  155. package/dist/dashboard/app/EntrySidebar.js +27 -13
  156. package/dist/dashboard/app/EntrySidebarPreview.js +12 -12
  157. package/dist/dashboard/app/EntryTranslationBanner.js +3 -3
  158. package/dist/dashboard/app/Explorer.js +41 -41
  159. package/dist/dashboard/app/ExplorerCards.js +33 -33
  160. package/dist/dashboard/app/ExplorerFileCard.js +18 -18
  161. package/dist/dashboard/app/ExplorerList.js +13 -13
  162. package/dist/dashboard/app/ExplorerModal.js +5 -5
  163. package/dist/dashboard/app/ExplorerTable.js +48 -48
  164. package/dist/dashboard/app/LinkPicker.js +3 -3
  165. package/dist/dashboard/app/LocaleMenu.js +7 -7
  166. package/dist/dashboard/app/SidebarTree.js +81 -45
  167. package/dist/dashboard/app/WorkspaceMenu.js +9 -9
  168. package/dist/dashboard/app/WorkspaceRoots.js +21 -21
  169. package/dist/dashboard/app/editor/FileEditor.js +26 -26
  170. package/dist/dashboard/app/editor/FilePreview.js +6 -6
  171. package/dist/dashboard/app/modals/CreateEntry.js +5 -5
  172. package/dist/dashboard/app/pages/EntryPage.js +15 -15
  173. package/dist/dashboard/app/pages/RootPage.js +3 -3
  174. package/dist/dashboard/app/pages/SplashPage.js +43 -43
  175. package/dist/dashboard/app/pages/UsersPage.js +34 -34
  176. package/dist/dashboard/app/ui/DashboardModal.js +17 -17
  177. package/dist/dashboard/app/ui/Rail.js +3 -3
  178. package/dist/dashboard/app/ui/Sidebar.js +2 -2
  179. package/dist/dashboard/atoms/config.d.ts +4 -4
  180. package/dist/dashboard/atoms/dashboard.js +2 -1
  181. package/dist/dashboard/atoms/editor.js +7 -0
  182. package/dist/dashboard/atoms/entry.d.ts +10 -13
  183. package/dist/dashboard/atoms/entry.js +42 -7
  184. package/dist/dashboard/atoms/explorer.d.ts +2 -0
  185. package/dist/dashboard/atoms/explorer.js +7 -2
  186. package/dist/dashboard/atoms/root.d.ts +1 -0
  187. package/dist/dashboard/atoms/root.js +61 -35
  188. package/dist/dashboard/boot/Boot.js +9 -8
  189. package/dist/dashboard/boot/DashboardWorker.d.ts +3 -3
  190. package/dist/dashboard/boot/DashboardWorker.js +78 -27
  191. package/dist/dashboard/boot/LoadWorker.js +2 -3
  192. package/dist/dashboard/icons.d.ts +2 -0
  193. package/dist/dashboard/icons.js +40 -0
  194. package/dist/dashboard/plugins/alineaFixturePlugin.js +14 -3
  195. package/dist/database/BrowserEntryStore.d.ts +30 -0
  196. package/dist/database/BrowserEntryStore.js +168 -0
  197. package/dist/database/DatabaseSource.d.ts +13 -0
  198. package/dist/database/DatabaseSource.js +25 -0
  199. package/dist/database/DatabaseTables.d.ts +38 -0
  200. package/dist/database/DatabaseTables.js +53 -0
  201. package/dist/database/EntryDatabase.d.ts +21 -0
  202. package/dist/database/EntryDatabase.js +138 -0
  203. package/dist/database/EntryLayer.d.ts +93 -0
  204. package/dist/database/EntryLayer.js +459 -0
  205. package/dist/database/EntryStore.d.ts +60 -0
  206. package/dist/database/EntryStore.js +269 -0
  207. package/dist/database/EntryTransaction.d.ts +33 -0
  208. package/dist/database/EntryTransaction.js +889 -0
  209. package/dist/database/EntryUrlAliases.d.ts +2 -0
  210. package/dist/database/EntryUrlAliases.js +69 -0
  211. package/dist/database/LocalDB.d.ts +39 -0
  212. package/dist/database/LocalDB.js +79 -0
  213. package/dist/database/Version.d.ts +9 -0
  214. package/dist/database/Version.js +13 -0
  215. package/dist/database/driver/RuntimeDatabase.d.ts +8 -0
  216. package/dist/database/driver/RuntimeDatabase.js +33 -0
  217. package/dist/database/driver/WasmDatabase.d.ts +8 -0
  218. package/dist/database/driver/WasmDatabase.js +33 -0
  219. package/dist/database/entry/EntryData.d.ts +13 -0
  220. package/dist/database/entry/EntryData.js +51 -0
  221. package/dist/database/entry/EntryTable.d.ts +173 -0
  222. package/dist/database/entry/EntryTable.js +137 -0
  223. package/dist/database/entry/EntryView.d.ts +22 -0
  224. package/dist/database/entry/EntryView.js +106 -0
  225. package/dist/database/query/Condition.d.ts +8 -0
  226. package/dist/database/query/Condition.js +117 -0
  227. package/dist/database/query/EntryQuery.d.ts +43 -0
  228. package/dist/database/query/EntryQuery.js +414 -0
  229. package/dist/database/query/EntryReferences.d.ts +6 -0
  230. package/dist/database/query/EntryReferences.js +68 -0
  231. package/dist/database/query/Relation.d.ts +11 -0
  232. package/dist/database/query/Relation.js +113 -0
  233. package/dist/database/query/ResolveQuery.d.ts +15 -0
  234. package/dist/database/query/ResolveQuery.js +154 -0
  235. package/dist/database/query/Search.d.ts +47 -0
  236. package/dist/database/query/Search.js +169 -0
  237. package/dist/database/sync/Derive.d.ts +8 -0
  238. package/dist/database/sync/Derive.js +270 -0
  239. package/dist/database/sync/EntryParser.d.ts +4 -0
  240. package/dist/database/sync/EntryParser.js +87 -0
  241. package/dist/database/sync/EntrySyncer.d.ts +37 -0
  242. package/dist/database/sync/EntrySyncer.js +117 -0
  243. package/dist/database/sync/Ingest.d.ts +21 -0
  244. package/dist/database/sync/Ingest.js +136 -0
  245. package/dist/database/sync/SyncQueries.d.ts +157 -0
  246. package/dist/database/sync/SyncQueries.js +192 -0
  247. package/dist/field/check/CheckField.view.js +2 -2
  248. package/dist/field/code/CodeField.view.js +7 -7
  249. package/dist/field/link/FileLink.js +1 -7
  250. package/dist/field/link/LinkField.js +23 -0
  251. package/dist/field/link/LinkField.view.js +44 -43
  252. package/dist/field/list/ListField.d.ts +5 -0
  253. package/dist/field/list/ListField.stories.d.ts +1 -0
  254. package/dist/field/list/ListField.view.js +190 -156
  255. package/dist/field/metadata/MetadataField.d.ts +28 -3
  256. package/dist/field/metadata/MetadataField.js +44 -7
  257. package/dist/field/metadata/MetadataField.view.d.ts +5 -0
  258. package/dist/field/metadata/MetadataField.view.js +37 -22
  259. package/dist/field/richtext/PickTextLink.d.ts +3 -1
  260. package/dist/field/richtext/PickTextLink.js +7 -6
  261. package/dist/field/richtext/RichTextDocument.js +12 -4
  262. package/dist/field/richtext/RichTextExtensions.d.ts +1 -1
  263. package/dist/field/richtext/RichTextExtensions.js +34 -30
  264. package/dist/field/richtext/RichTextField.d.ts +3 -0
  265. package/dist/field/richtext/RichTextField.view.js +20 -11
  266. package/dist/field/richtext/RichTextInsertMenu.js +3 -3
  267. package/dist/field/views.js +2 -0
  268. package/dist/index.css +17 -6
  269. package/dist/next.cjs +0 -18
  270. package/dist/next.d.ts +4 -3
  271. package/dist/next.edge.d.ts +1 -1
  272. package/dist/next.js +1 -2
  273. package/dist/picker/entry/EntryPicker.js +2 -1
  274. package/dist/picker/url/UrlPicker.js +1 -0
  275. package/dist/preview/widget.d.ts +16 -0
  276. package/dist/preview/widget.js +70 -1
  277. package/dist/query.d.ts +28 -0
  278. package/dist/ui/RichText.js +33 -18
  279. package/package.json +2 -1
  280. package/dist/backend/store/GeneratedSource.d.ts +0 -2
  281. package/dist/backend/store/GeneratedSource.js +0 -21
  282. package/dist/chunks/chunk-G6E35DMJ.js +0 -1997
  283. package/dist/core/db/EntryDB.d.ts +0 -19
  284. package/dist/core/db/EntryDB.js +0 -48
  285. package/dist/core/db/EntryIndex.d.ts +0 -143
  286. package/dist/core/db/EntryIndex.js +0 -2773
  287. package/dist/core/db/EntryReferenceIndex.d.ts +0 -21
  288. package/dist/core/db/EntryReferenceIndex.js +0 -131
  289. package/dist/core/db/EntryResolver.d.ts +0 -56
  290. package/dist/core/db/EntryResolver.js +0 -699
  291. package/dist/core/db/EntryTarget.d.ts +0 -5
  292. package/dist/core/db/EntryTransaction.d.ts +0 -31
  293. package/dist/core/db/EntryTransaction.js +0 -956
  294. package/dist/core/db/LocalDB.d.ts +0 -42
  295. package/dist/core/db/LocalDB.js +0 -127
  296. package/dist/core/db/TestDB.d.ts +0 -19
  297. package/dist/core/db/TestDB.js +0 -50
  298. /package/dist/core/db/{EntryTarget.js → LocalStore.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "3JUoCAhRGalhjQEYxS2BD7bVGVb",
2
+ "_id": "3JmA8NHtbBt6eB3HhLdaN4zhM7O",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -2,34 +2,7 @@ This file contains the licenses of the bundled modules in this distribution.
2
2
 
3
3
  ===
4
4
 
5
- # jotai@3.0.0 (MIT)
6
-
7
- MIT License
8
-
9
- Copyright (c) 2020 Poimandres
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
-
29
-
30
- ===
31
-
32
- # react-aria-components@1.17.0 (Apache-2.0)
5
+ # @internationalized/date@3.12.1 (Apache-2.0)
33
6
 
34
7
  Apache License
35
8
  Version 2.0, January 2004
@@ -236,37 +209,11 @@ SOFTWARE.
236
209
 
237
210
  ===
238
211
 
239
- # rado@1.3.0-preview.6 (MIT)
240
-
241
- MIT License
242
-
243
- Copyright (c) 2024 Ben Merckx
244
-
245
- Permission is hereby granted, free of charge, to any person obtaining a copy
246
- of this software and associated documentation files (the "Software"), to deal
247
- in the Software without restriction, including without limitation the rights
248
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
249
- copies of the Software, and to permit persons to whom the Software is
250
- furnished to do so, subject to the following conditions:
251
-
252
- The above copyright notice and this permission notice shall be included in all
253
- copies or substantial portions of the Software.
254
-
255
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
256
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
257
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
258
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
259
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
260
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
261
- SOFTWARE.
262
-
263
- ===
264
-
265
- # microcbor@1.2.1 (MIT)
212
+ # jotai@3.0.0 (MIT)
266
213
 
267
214
  MIT License
268
215
 
269
- Copyright (c) 2021 Joel Gustafson
216
+ Copyright (c) 2020 Poimandres
270
217
 
271
218
  Permission is hereby granted, free of charge, to any person obtaining a copy
272
219
  of this software and associated documentation files (the "Software"), to deal
@@ -289,7 +236,7 @@ SOFTWARE.
289
236
 
290
237
  ===
291
238
 
292
- # @internationalized/date@3.12.1 (Apache-2.0)
239
+ # react-aria-components@1.17.0 (Apache-2.0)
293
240
 
294
241
  Apache License
295
242
  Version 2.0, January 2004
@@ -496,11 +443,37 @@ SOFTWARE.
496
443
 
497
444
  ===
498
445
 
499
- # @tiptap/core@3.30.5 (MIT)
446
+ # rado@1.3.0-preview.11 (MIT)
500
447
 
501
448
  MIT License
502
449
 
503
- Copyright (c) 2025, Tiptap GmbH
450
+ Copyright (c) 2024 Ben Merckx
451
+
452
+ Permission is hereby granted, free of charge, to any person obtaining a copy
453
+ of this software and associated documentation files (the "Software"), to deal
454
+ in the Software without restriction, including without limitation the rights
455
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
456
+ copies of the Software, and to permit persons to whom the Software is
457
+ furnished to do so, subject to the following conditions:
458
+
459
+ The above copyright notice and this permission notice shall be included in all
460
+ copies or substantial portions of the Software.
461
+
462
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
463
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
464
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
465
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
466
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
467
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
468
+ SOFTWARE.
469
+
470
+ ===
471
+
472
+ # microcbor@1.2.1 (MIT)
473
+
474
+ MIT License
475
+
476
+ Copyright (c) 2021 Joel Gustafson
504
477
 
505
478
  Permission is hereby granted, free of charge, to any person obtaining a copy
506
479
  of this software and associated documentation files (the "Software"), to deal
@@ -730,11 +703,11 @@ SOFTWARE.
730
703
 
731
704
  ===
732
705
 
733
- # jotai-family@1.1.0 (MIT)
706
+ # @tiptap/core@3.30.5 (MIT)
734
707
 
735
708
  MIT License
736
709
 
737
- Copyright (c) 2025 Poimandres
710
+ Copyright (c) 2025, Tiptap GmbH
738
711
 
739
712
  Permission is hereby granted, free of charge, to any person obtaining a copy
740
713
  of this software and associated documentation files (the "Software"), to deal
@@ -755,33 +728,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
755
728
  SOFTWARE.
756
729
 
757
730
 
758
- ===
759
-
760
- # jotai-location@0.6.2 (MIT)
761
-
762
- The MIT License (MIT)
763
-
764
- Copyright (c) 2022 Daishi Kato
765
-
766
- Permission is hereby granted, free of charge, to any person obtaining a copy
767
- of this software and associated documentation files (the "Software"), to deal
768
- in the Software without restriction, including without limitation the rights
769
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
770
- copies of the Software, and to permit persons to whom the Software is
771
- furnished to do so, subject to the following conditions:
772
-
773
- The above copyright notice and this permission notice shall be included in
774
- all copies or substantial portions of the Software.
775
-
776
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
777
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
778
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
779
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
780
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
781
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
782
- THE SOFTWARE.
783
-
784
-
785
731
  ===
786
732
 
787
733
  # react-aria@3.48.0 (Apache-2.0)
@@ -991,11 +937,38 @@ THE SOFTWARE.
991
937
 
992
938
  ===
993
939
 
994
- # @badgateway/oauth2-client@3.3.1 (MIT)
940
+ # jotai-location@0.6.2 (MIT)
941
+
942
+ The MIT License (MIT)
943
+
944
+ Copyright (c) 2022 Daishi Kato
945
+
946
+ Permission is hereby granted, free of charge, to any person obtaining a copy
947
+ of this software and associated documentation files (the "Software"), to deal
948
+ in the Software without restriction, including without limitation the rights
949
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
950
+ copies of the Software, and to permit persons to whom the Software is
951
+ furnished to do so, subject to the following conditions:
952
+
953
+ The above copyright notice and this permission notice shall be included in
954
+ all copies or substantial portions of the Software.
955
+
956
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
957
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
958
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
959
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
960
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
961
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
962
+ THE SOFTWARE.
963
+
964
+
965
+ ===
966
+
967
+ # jotai-family@1.1.0 (MIT)
995
968
 
996
969
  MIT License
997
970
 
998
- Copyright (c) 2019-2025 Evert Pot
971
+ Copyright (c) 2025 Poimandres
999
972
 
1000
973
  Permission is hereby granted, free of charge, to any person obtaining a copy
1001
974
  of this software and associated documentation files (the "Software"), to deal
@@ -1018,11 +991,11 @@ SOFTWARE.
1018
991
 
1019
992
  ===
1020
993
 
1021
- # use-sync-external-store@1.6.0 (MIT)
994
+ # @badgateway/oauth2-client@3.3.1 (MIT)
1022
995
 
1023
996
  MIT License
1024
997
 
1025
- Copyright (c) Meta Platforms, Inc. and affiliates.
998
+ Copyright (c) 2019-2025 Evert Pot
1026
999
 
1027
1000
  Permission is hereby granted, free of charge, to any person obtaining a copy
1028
1001
  of this software and associated documentation files (the "Software"), to deal
@@ -1045,34 +1018,38 @@ SOFTWARE.
1045
1018
 
1046
1019
  ===
1047
1020
 
1048
- # htmlparser2@9.1.0 (MIT)
1021
+ # @tiptap/extension-list@3.30.5 (MIT)
1022
+
1023
+ MIT License
1024
+
1025
+ Copyright (c) 2025, Tiptap GmbH
1049
1026
 
1050
- Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
1051
1027
  Permission is hereby granted, free of charge, to any person obtaining a copy
1052
- of this software and associated documentation files (the "Software"), to
1053
- deal in the Software without restriction, including without limitation the
1054
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1055
- sell copies of the Software, and to permit persons to whom the Software is
1028
+ of this software and associated documentation files (the "Software"), to deal
1029
+ in the Software without restriction, including without limitation the rights
1030
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1031
+ copies of the Software, and to permit persons to whom the Software is
1056
1032
  furnished to do so, subject to the following conditions:
1057
-
1058
- The above copyright notice and this permission notice shall be included in
1059
- all copies or substantial portions of the Software.
1060
-
1033
+
1034
+ The above copyright notice and this permission notice shall be included in all
1035
+ copies or substantial portions of the Software.
1036
+
1061
1037
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1062
1038
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1063
1039
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1064
1040
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1065
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1066
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1067
- IN THE SOFTWARE.
1041
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1042
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1043
+ SOFTWARE.
1044
+
1068
1045
 
1069
1046
  ===
1070
1047
 
1071
- # @tiptap/extension-list@3.30.5 (MIT)
1048
+ # use-sync-external-store@1.6.0 (MIT)
1072
1049
 
1073
1050
  MIT License
1074
1051
 
1075
- Copyright (c) 2025, Tiptap GmbH
1052
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1076
1053
 
1077
1054
  Permission is hereby granted, free of charge, to any person obtaining a copy
1078
1055
  of this software and associated documentation files (the "Software"), to deal
@@ -1122,7 +1099,30 @@ SOFTWARE.
1122
1099
 
1123
1100
  ===
1124
1101
 
1125
- # domutils@3.2.2 (BSD-2-Clause)
1102
+ # htmlparser2@9.1.0 (MIT)
1103
+
1104
+ Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
1105
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1106
+ of this software and associated documentation files (the "Software"), to
1107
+ deal in the Software without restriction, including without limitation the
1108
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1109
+ sell copies of the Software, and to permit persons to whom the Software is
1110
+ furnished to do so, subject to the following conditions:
1111
+
1112
+ The above copyright notice and this permission notice shall be included in
1113
+ all copies or substantial portions of the Software.
1114
+
1115
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1116
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1118
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1119
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1120
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1121
+ IN THE SOFTWARE.
1122
+
1123
+ ===
1124
+
1125
+ # domhandler@5.0.3 (BSD-2-Clause)
1126
1126
 
1127
1127
  Copyright (c) Felix Böhm
1128
1128
  All rights reserved.
@@ -1139,7 +1139,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1139
1139
 
1140
1140
  ===
1141
1141
 
1142
- # domhandler@5.0.3 (BSD-2-Clause)
1142
+ # domutils@3.2.2 (BSD-2-Clause)
1143
1143
 
1144
1144
  Copyright (c) Felix Böhm
1145
1145
  All rights reserved.
@@ -1,27 +1,41 @@
1
1
  import { CMS } from 'alinea/core/CMS';
2
2
  import { Config } from 'alinea/core/Config';
3
3
  import type { UploadResponse } from 'alinea/core/Connection';
4
- import { LocalDB } from 'alinea/core/db/LocalDB';
4
+ import type { LocalStore } from 'alinea/core/db/LocalStore';
5
5
  import type { Mutation } from 'alinea/core/db/Mutation';
6
6
  import type { GraphQuery } from 'alinea/core/Graph';
7
7
  import type { User } from 'alinea/core/User';
8
8
  import PLazy from 'p-lazy';
9
+ import type { DatabaseOptions } from 'rado';
9
10
  export interface PreviewProps {
10
11
  widget?: boolean;
12
+ /** Show the queries and syncs of each draft render in the widget */
13
+ stats?: boolean;
11
14
  workspace?: string;
12
15
  root?: string;
13
16
  }
17
+ export type OpenBundledDatabase = (config: Config, options?: DatabaseOptions) => Promise<LocalStore>;
18
+ export interface SyncStatus {
19
+ /** Whether queries are answered from the bundled database or the handler. */
20
+ source: 'database' | 'handler';
21
+ /** The content revision the answering side is at. */
22
+ sha: string | undefined;
23
+ /** When this isolate last synced its bundled database with the handler. */
24
+ syncedAt: Date | undefined;
25
+ }
14
26
  export declare class NextCMS<Definition extends Config = Config> extends CMS<Definition> {
15
27
  #private;
16
- constructor(config: Definition);
28
+ bundledDb: PLazy<LocalStore>;
29
+ constructor(config: Definition, openBundledDatabase?: OpenBundledDatabase);
17
30
  throttle: (sync: () => Promise<unknown>, interval?: number) => Promise<void>;
18
- bundledDb: PLazy<LocalDB>;
31
+ /** Where queries are answered from and how fresh that side is. */
32
+ status(): Promise<SyncStatus>;
19
33
  resolve<Query extends GraphQuery>(query: Query): Promise<any>;
20
34
  user(): Promise<User | undefined>;
21
35
  mutate(mutations: Array<Mutation>): Promise<{
22
36
  sha: string;
23
37
  }>;
24
38
  prepareUpload(file: string): Promise<UploadResponse>;
25
- previews: ({ widget, workspace, root }: PreviewProps) => Promise<import("react").JSX.Element | null>;
39
+ previews: ({ widget, stats: showStats, workspace, root }: PreviewProps) => Promise<import("react").JSX.Element | null>;
26
40
  }
27
41
  export declare function createCMS<Definition extends Config>(config: Definition): NextCMS<Definition>;
@@ -12,42 +12,90 @@ import { createThrottledSync } from "alinea/backend/util/Syncable";
12
12
  import { Client } from "alinea/core/Client";
13
13
  import { CMS } from "alinea/core/CMS";
14
14
  import { Config } from "alinea/core/Config";
15
- import { LocalDB } from "alinea/core/db/LocalDB";
16
15
  import { outcome } from "alinea/core/Outcome";
16
+ import { ReadonlyTree } from "alinea/core/source/Tree";
17
17
  import { trace } from "alinea/core/Trace";
18
18
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
19
19
  import { Headers } from "@alinea/iso";
20
20
  import { cache } from "react";
21
21
  import { requestContext } from "./context.js";
22
+ import { RenderStats, summarizeQuery, timed } from "./renderStats.js";
22
23
  import { syncIfStale } from "./syncCheck.js";
23
24
  import { jsx } from "react/jsx-runtime";
25
+ var preValidatedRemote = { validate: false };
24
26
  var NextCMS = class extends CMS {
25
- constructor(config) {
27
+ bundledDb;
28
+ #syncedAt;
29
+ constructor(config, openBundledDatabase) {
26
30
  super(config);
31
+ this.bundledDb = PLazy.from(async () => {
32
+ if (process.env.NEXT_RUNTIME === "edge")
33
+ throw new Error(
34
+ "Local DB is not supported in Edge runtime environments."
35
+ );
36
+ if (!openBundledDatabase)
37
+ throw new Error(
38
+ "A bundled database loader is required. Import createCMS from 'alinea/next'."
39
+ );
40
+ const span = trace(this.config, "alinea.next.cms.db");
41
+ return span(
42
+ () => openBundledDatabase(this.config, {
43
+ // Statements run in the async context of the query that caused
44
+ // them, which carries the React request of the render.
45
+ logQuery: (_query, durationMs) => this.#render().stats?.statement(durationMs)
46
+ })
47
+ );
48
+ });
27
49
  }
28
50
  throttle = createThrottledSync();
29
- bundledDb = PLazy.from(async () => {
30
- if (process.env.NEXT_RUNTIME === "edge")
31
- throw new Error("Local DB is not supported in Edge runtime environments.");
32
- const span = trace(this.config, "alinea.next.cms.db");
33
- return span(async () => {
34
- const { generatedSource } = await import("alinea/backend/store/GeneratedSource");
35
- const source = await generatedSource;
36
- const db = new LocalDB(this.config, source);
37
- await db.sync();
38
- return db;
39
- });
51
+ /**
52
+ * Per React request; outside a request (build, route handlers) every call
53
+ * returns a fresh holder, so nothing is recorded there.
54
+ */
55
+ #render = cache(() => ({}));
56
+ #isDraft = cache(async () => {
57
+ const { draftMode } = await import("next/headers.js");
58
+ const [isDraft] = await outcome(async () => (await draftMode()).isEnabled);
59
+ return Boolean(isDraft);
40
60
  });
41
- #applyPreview = cache(async () => {
42
- const context = await requestContext(this.config);
61
+ /** Draft renders collect their queries and syncs for the preview widget. */
62
+ async #renderStats() {
63
+ if (!await this.#isDraft()) return void 0;
64
+ const render = this.#render();
65
+ return render.stats ??= new RenderStats();
66
+ }
67
+ /** The bundled database answers outside Edge, except during development. */
68
+ async #environment(context) {
43
69
  const isEdge = process.env.NEXT_RUNTIME === "edge";
44
70
  const { PHASE_PRODUCTION_BUILD } = await import("next/constants.js");
45
71
  const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
46
- const useLocalDb = !isEdge && (!context.isDev || isBuild);
47
- const { cookies, draftMode } = await import("next/headers.js");
48
- const [isDraft] = await outcome(async () => (await draftMode()).isEnabled);
72
+ return { isBuild, useLocalDb: !isEdge && (!context.isDev || isBuild) };
73
+ }
74
+ /** Renders keep serving the current content when the handler is unreachable. */
75
+ async #syncDb(db, client, stats) {
76
+ if (stats)
77
+ return stats.track(
78
+ { kind: "sync", summary: "sync" },
79
+ (row) => timed(row, () => this.#syncDb(db, client, void 0))
80
+ );
81
+ try {
82
+ const sha = await db.syncWith(client, preValidatedRemote);
83
+ this.#syncedAt = Date.now();
84
+ return sha;
85
+ } catch (error) {
86
+ console.warn(
87
+ `Alinea could not sync with the handler, serving current content: ${error instanceof Error ? error.message : String(error)}`
88
+ );
89
+ return db.sha;
90
+ }
91
+ }
92
+ #applyPreview = cache(async () => {
93
+ const context = await requestContext(this.config);
94
+ const { isBuild, useLocalDb } = await this.#environment(context);
95
+ const isDraft = await this.#isDraft();
49
96
  if (!isDraft)
50
97
  return { context, hasPreview: false, isDraft, isBuild, useLocalDb };
98
+ const { cookies } = await import("next/headers.js");
51
99
  const cookie = await cookies();
52
100
  const payload = getPreviewPayloadFromCookies(cookie.getAll());
53
101
  if (!payload)
@@ -67,37 +115,73 @@ var NextCMS = class extends CMS {
67
115
  }
68
116
  return { context, hasPreview: true, isDraft, isBuild, preview, useLocalDb };
69
117
  });
118
+ /**
119
+ * The preview cookie carries the content hash the dashboard rendered
120
+ * against, which is the freshness signal in draft mode: Next bypasses the
121
+ * `unstable_cache` that `syncIfStale` shares between renders there, so the
122
+ * cookie hash replaces the uncached lookup of the latest sha. A mismatch
123
+ * means this isolate is behind (or ahead of) the previewed content, and one
124
+ * sync brings it to the handler revision before the patch is applied.
125
+ */
70
126
  async #prepareLocalPreview(db, decoded, context) {
71
127
  if ("entry" in decoded) return decoded;
72
- if (db.sha === decoded.contentHash) return applyPreviewUpdate(db, decoded);
73
- const source = await db.source.getTree();
74
- if (source.sha === decoded.contentHash) {
75
- await db.sync();
76
- return applyPreviewUpdate(db, decoded);
77
- }
78
- const applied = await applyPreviewUpdate(db, decoded);
79
- if (applied) return applied;
80
- await db.syncWith(createClient(this.config, context));
128
+ if (await db.sha !== decoded.contentHash)
129
+ await this.#syncDb(
130
+ db,
131
+ createClient(this.config, context),
132
+ this.#render().stats
133
+ );
81
134
  return applyPreviewUpdate(db, decoded);
82
135
  }
136
+ /** Where queries are answered from and how fresh that side is. */
137
+ async status() {
138
+ const context = await requestContext(this.config);
139
+ const { useLocalDb } = await this.#environment(context);
140
+ if (useLocalDb) {
141
+ const db = await this.bundledDb;
142
+ return {
143
+ source: "database",
144
+ sha: await db.sha,
145
+ syncedAt: this.#syncedAt ? new Date(this.#syncedAt) : void 0
146
+ };
147
+ }
148
+ const client = createClient(this.config, context);
149
+ const tree = await client.getTreeIfDifferent(ReadonlyTree.EMPTY.sha).catch(() => void 0);
150
+ return { source: "handler", sha: tree?.sha, syncedAt: void 0 };
151
+ }
83
152
  async resolve(query) {
153
+ const stats = await this.#renderStats();
154
+ if (!stats) return this.#resolve(query, void 0);
155
+ return stats.track(
156
+ { kind: "query", summary: summarizeQuery(query) },
157
+ (row) => this.#resolve(query, row)
158
+ );
159
+ }
160
+ async #resolve(query, row) {
84
161
  let status = query.status;
85
162
  const { context, hasPreview, isDraft, isBuild, preview, useLocalDb } = await this.#applyPreview();
86
163
  if (isDraft && !status) status = "preferDraft";
87
164
  const request = { ...query, preview, status };
88
165
  const client = createClient(this.config, context);
166
+ if (row) row.source = useLocalDb ? "database" : "handler";
89
167
  if (!useLocalDb) {
90
168
  const span = trace(this.config, "alinea.cms.resolve.client");
91
- return span(() => client.resolve(request));
169
+ return timed(row, () => span(() => client.resolve(request)));
92
170
  }
93
171
  const db = await this.bundledDb;
94
172
  const syncInterval = request.disableSync ? Number.POSITIVE_INFINITY : request.syncInterval ?? this.config.syncInterval;
95
- if (hasPreview) return db.resolve(request);
173
+ if (hasPreview) return timed(row, () => db.resolve(request));
96
174
  if (!isBuild) {
97
- const settled = await syncIfStale(db, client, syncInterval);
98
- if (!settled) await this.throttle(() => db.syncWith(client), syncInterval);
175
+ const stats = this.#render().stats;
176
+ const tracked = {
177
+ sha: db.sha,
178
+ syncWith: () => this.#syncDb(db, client, stats)
179
+ };
180
+ const settled = !isDraft && await syncIfStale(tracked, client, syncInterval);
181
+ if (!settled)
182
+ await this.throttle(() => this.#syncDb(db, client, stats), syncInterval);
99
183
  }
100
- return db.resolve(request);
184
+ return timed(row, () => db.resolve(request));
101
185
  }
102
186
  async #authenticatedClient() {
103
187
  const context = await requestContext(this.config);
@@ -139,11 +223,15 @@ var NextCMS = class extends CMS {
139
223
  const client = await this.#authenticatedClient();
140
224
  return client.prepareUpload(file);
141
225
  }
142
- previews = async ({ widget, workspace, root }) => {
143
- const { draftMode } = await import("next/headers.js");
226
+ previews = async ({
227
+ widget,
228
+ stats: showStats,
229
+ workspace,
230
+ root
231
+ }) => {
232
+ const stats = await this.#renderStats();
233
+ if (!stats) return null;
144
234
  const { default: dynamic } = await import("next/dynamic.js");
145
- const [isDraft] = await outcome(async () => (await draftMode()).isEnabled);
146
- if (!isDraft) return null;
147
235
  const { isDev, handlerUrl } = await requestContext(this.config);
148
236
  let file = `${Config.adminPath(this.config)}.html`;
149
237
  if (!file.startsWith("/")) file = `/${file}`;
@@ -156,6 +244,7 @@ var NextCMS = class extends CMS {
156
244
  {
157
245
  dashboardUrl: dashboardUrl.href,
158
246
  widget,
247
+ stats: widget && showStats ? stats.settled() : void 0,
159
248
  workspace,
160
249
  root
161
250
  }
@@ -1,12 +1,16 @@
1
1
  import { type BackendFactory, type BackendOptions } from 'alinea/backend/api/CreateBackend';
2
2
  import { type HandlerHooks } from 'alinea/backend/Handler';
3
3
  import { Config } from 'alinea/core/Config';
4
+ import type { LocalStore } from 'alinea/core/db/LocalStore';
4
5
  import { NextCMS } from './cms.js';
5
6
  type Handler = (request: Request) => Promise<Response>;
6
7
  export interface NextHandlerOptions extends HandlerHooks {
7
8
  cms: NextCMS;
8
9
  backend?: BackendFactory | BackendOptions;
9
10
  }
10
- export declare function createHandler(input: NextCMS | NextHandlerOptions): Handler;
11
+ export type OpenGeneratedDatabase = (config: Config) => Promise<LocalStore>;
12
+ export declare function createHandlerWithDatabase(input: NextCMS | NextHandlerOptions, openGeneratedDatabase?: OpenGeneratedDatabase): Handler;
11
13
  export declare function handlerPathname(config: Config, requestUrl: URL): string;
14
+ /** A handler without a generated database, as used in the Edge runtime. */
15
+ export declare function createHandler(input: NextCMS | NextHandlerOptions): Handler;
12
16
  export {};
@@ -10,17 +10,15 @@ import {
10
10
  import {
11
11
  createHandler as createCoreHandler
12
12
  } from "alinea/backend/Handler";
13
- import { generatedSource } from "alinea/backend/store/GeneratedSource";
14
13
  import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
15
14
  import { CloudRemote } from "alinea/cloud/CloudRemote";
16
15
  import { Config } from "alinea/core/Config";
17
- import { LocalDB } from "alinea/core/db/LocalDB";
18
16
  import { trace } from "alinea/core/Trace";
19
17
  import { NextCMS } from "./cms.js";
20
18
  import { requestContext } from "./context.js";
21
19
  import { createDevRemote } from "./DevRemote.js";
22
20
  import { revalidateContentSha } from "./syncCheck.js";
23
- function createHandler(input) {
21
+ function createHandlerWithDatabase(input, openGeneratedDatabase) {
24
22
  const options = input instanceof NextCMS ? { cms: input } : input;
25
23
  const config = options.cms.config;
26
24
  const backend = typeof options.backend === "function" ? options.backend : options.backend ? backendFromOptions(options.backend) : (context) => new CloudRemote(context, config);
@@ -28,10 +26,15 @@ function createHandler(input) {
28
26
  const span = trace(config, "alinea.next.handler.db");
29
27
  const db = PLazy.from(
30
28
  () => span(async () => {
31
- const source = await generatedSource;
32
- const db2 = new LocalDB(config, source);
33
- await db2.sync();
34
- return db2;
29
+ if (process.env.NEXT_RUNTIME === "edge")
30
+ throw new Error(
31
+ "The Alinea handler is not supported in Edge runtime environments."
32
+ );
33
+ if (!openGeneratedDatabase)
34
+ throw new Error(
35
+ "A generated database loader is required. Import createHandler from 'alinea/next'."
36
+ );
37
+ return openGeneratedDatabase(config);
35
38
  })
36
39
  );
37
40
  const handleBackend = createCoreHandler({
@@ -108,7 +111,11 @@ function rewrittenFilePath(config, request) {
108
111
  return;
109
112
  }
110
113
  }
114
+ function createHandler(input) {
115
+ return createHandlerWithDatabase(input);
116
+ }
111
117
  export {
112
118
  createHandler,
119
+ createHandlerWithDatabase,
113
120
  handlerPathname
114
121
  };
@@ -0,0 +1,5 @@
1
+ import type { Config } from 'alinea/core/Config';
2
+ import { NextCMS } from './cms.js';
3
+ import { type NextHandlerOptions } from './handler.js';
4
+ export declare function createCMS<Definition extends Config>(config: Definition): NextCMS<Definition>;
5
+ export declare function createHandler(input: NextCMS | NextHandlerOptions): (request: Request) => Promise<Response>;