alinea 2.0.0-preview.7 → 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 (283) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +120 -120
  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 -1
  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 +1470 -442
  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-6P4UVRPH.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 +6 -6
  61. package/dist/components/Checkbox.js +3 -3
  62. package/dist/components/ColorSwatchPicker.js +2 -2
  63. package/dist/components/ComboBox.js +9 -9
  64. package/dist/components/DateField.js +1 -1
  65. package/dist/components/DatePicker.js +6 -6
  66. package/dist/components/DateRangePicker.js +6 -6
  67. package/dist/components/Disclosure.js +9 -9
  68. package/dist/components/Label.js +5 -5
  69. package/dist/components/List.js +33 -33
  70. package/dist/components/Menu.js +3 -3
  71. package/dist/components/Modal.js +3 -3
  72. package/dist/components/MultipleSelect.js +25 -25
  73. package/dist/components/NumberField.js +6 -6
  74. package/dist/components/ProgressCircle.js +3 -3
  75. package/dist/components/RadioGroup.js +2 -2
  76. package/dist/components/SearchField.js +5 -5
  77. package/dist/components/Select.js +7 -7
  78. package/dist/components/Surface.js +2 -2
  79. package/dist/components/Table.js +6 -6
  80. package/dist/components/Tabs.js +2 -2
  81. package/dist/components/TextField.js +6 -6
  82. package/dist/components/Toggle.js +2 -2
  83. package/dist/components/Toolbar.js +2 -2
  84. package/dist/components/Tooltip.js +4 -4
  85. package/dist/components/Tree.d.ts +2 -1
  86. package/dist/components/Tree.js +5 -5
  87. package/dist/core/Document.js +15 -3
  88. package/dist/core/Entry.d.ts +3 -0
  89. package/dist/core/Entry.js +4 -0
  90. package/dist/core/EntrySeed.d.ts +19 -0
  91. package/dist/core/EntrySeed.js +136 -0
  92. package/dist/core/Field.d.ts +7 -0
  93. package/dist/core/Field.js +4 -0
  94. package/dist/core/Filter.d.ts +40 -2
  95. package/dist/core/Filter.js +145 -0
  96. package/dist/core/Graph.d.ts +9 -0
  97. package/dist/core/ListRow.d.ts +1 -0
  98. package/dist/core/ListRow.js +1 -0
  99. package/dist/core/Reference.d.ts +1 -0
  100. package/dist/core/Root.js +1 -1
  101. package/dist/core/Scope.d.ts +2 -0
  102. package/dist/core/Scope.js +16 -1
  103. package/dist/core/Type.d.ts +2 -1
  104. package/dist/core/Type.js +13 -1
  105. package/dist/core/db/EntryAliases.js +1 -11
  106. package/dist/core/db/EntryReference.d.ts +0 -6
  107. package/dist/core/db/IndexEvent.d.ts +2 -1
  108. package/dist/core/db/IndexEvent.js +11 -3
  109. package/dist/core/db/LinkResolver.d.ts +6 -6
  110. package/dist/core/db/LinkResolver.js +0 -52
  111. package/dist/core/db/LocalStore.d.ts +25 -0
  112. package/dist/core/field/ListField.js +19 -0
  113. package/dist/core/field/RecordField.js +8 -0
  114. package/dist/core/field/RichTextField.js +42 -0
  115. package/dist/core/field/UnionField.js +8 -0
  116. package/dist/core/source/FSSource.d.ts +14 -2
  117. package/dist/core/source/FSSource.js +58 -13
  118. package/dist/core/source/GitUtils.d.ts +4 -0
  119. package/dist/core/source/GitUtils.js +9 -10
  120. package/dist/core/source/GithubSource.js +22 -11
  121. package/dist/core/source/IndexedDBSource.d.ts +2 -1
  122. package/dist/core/source/IndexedDBSource.js +67 -53
  123. package/dist/core/source/MemorySource.js +5 -3
  124. package/dist/core/source/OverlaySource.d.ts +5 -2
  125. package/dist/core/source/OverlaySource.js +31 -3
  126. package/dist/core/source/Source.d.ts +3 -0
  127. package/dist/core/source/Source.js +15 -2
  128. package/dist/core/source/Tree.d.ts +10 -7
  129. package/dist/core/source/Tree.js +118 -70
  130. package/dist/core/source/Utils.js +6 -3
  131. package/dist/core/util/Arrays.d.ts +1 -0
  132. package/dist/core/util/Arrays.js +10 -0
  133. package/dist/core/util/Async.d.ts +7 -0
  134. package/dist/core/util/Async.js +15 -0
  135. package/dist/core/util/Checks.js +1 -1
  136. package/dist/core/util/EntryFilenames.d.ts +22 -1
  137. package/dist/core/util/EntryFilenames.js +56 -2
  138. package/dist/core/util/IndexedDB.d.ts +4 -0
  139. package/dist/core/util/IndexedDB.js +20 -0
  140. package/dist/core/util/Paths.js +5 -1
  141. package/dist/dashboard/App.js +3 -3
  142. package/dist/dashboard/ViewKeys.d.ts +1 -0
  143. package/dist/dashboard/ViewKeys.js +1 -0
  144. package/dist/dashboard/app/AccessDenied.js +4 -4
  145. package/dist/dashboard/app/ActivityStatus.js +11 -11
  146. package/dist/dashboard/app/AppShell.js +2 -2
  147. package/dist/dashboard/app/AuthView.js +9 -9
  148. package/dist/dashboard/app/Badge.js +2 -2
  149. package/dist/dashboard/app/CompactField.js +10 -10
  150. package/dist/dashboard/app/DashboardErrorBoundary.js +6 -6
  151. package/dist/dashboard/app/EntryFields.js +2 -2
  152. package/dist/dashboard/app/EntryHeader.js +10 -10
  153. package/dist/dashboard/app/EntryReferences.js +8 -8
  154. package/dist/dashboard/app/EntrySidebar.js +8 -8
  155. package/dist/dashboard/app/EntrySidebarPreview.js +11 -11
  156. package/dist/dashboard/app/EntryTranslationBanner.js +6 -6
  157. package/dist/dashboard/app/Explorer.js +44 -44
  158. package/dist/dashboard/app/ExplorerCards.js +30 -30
  159. package/dist/dashboard/app/ExplorerFileCard.js +17 -17
  160. package/dist/dashboard/app/ExplorerList.js +14 -14
  161. package/dist/dashboard/app/ExplorerModal.js +5 -5
  162. package/dist/dashboard/app/ExplorerTable.js +47 -47
  163. package/dist/dashboard/app/LinkPicker.js +2 -2
  164. package/dist/dashboard/app/LocaleMenu.js +6 -6
  165. package/dist/dashboard/app/SidebarTree.js +76 -40
  166. package/dist/dashboard/app/WorkspaceMenu.js +10 -10
  167. package/dist/dashboard/app/WorkspaceRoots.js +27 -27
  168. package/dist/dashboard/app/editor/FileEditor.js +24 -24
  169. package/dist/dashboard/app/editor/FilePreview.js +6 -6
  170. package/dist/dashboard/app/modals/CreateEntry.js +4 -4
  171. package/dist/dashboard/app/pages/EntryPage.js +15 -15
  172. package/dist/dashboard/app/pages/RootPage.js +3 -3
  173. package/dist/dashboard/app/pages/SplashPage.js +47 -47
  174. package/dist/dashboard/app/pages/UsersPage.js +36 -36
  175. package/dist/dashboard/app/ui/DashboardModal.js +17 -17
  176. package/dist/dashboard/app/ui/Rail.js +4 -4
  177. package/dist/dashboard/atoms/config.d.ts +4 -4
  178. package/dist/dashboard/atoms/entry.d.ts +8 -9
  179. package/dist/dashboard/atoms/entry.js +34 -4
  180. package/dist/dashboard/atoms/explorer.d.ts +2 -0
  181. package/dist/dashboard/atoms/explorer.js +7 -2
  182. package/dist/dashboard/boot/Boot.js +2 -3
  183. package/dist/dashboard/boot/DashboardWorker.d.ts +3 -3
  184. package/dist/dashboard/boot/DashboardWorker.js +78 -27
  185. package/dist/dashboard/boot/LoadWorker.js +2 -3
  186. package/dist/dashboard/icons.d.ts +2 -0
  187. package/dist/dashboard/icons.js +40 -0
  188. package/dist/dashboard/plugins/alineaFixturePlugin.js +14 -3
  189. package/dist/database/BrowserEntryStore.d.ts +30 -0
  190. package/dist/database/BrowserEntryStore.js +168 -0
  191. package/dist/database/DatabaseSource.d.ts +13 -0
  192. package/dist/database/DatabaseSource.js +25 -0
  193. package/dist/database/DatabaseTables.d.ts +38 -0
  194. package/dist/database/DatabaseTables.js +53 -0
  195. package/dist/database/EntryDatabase.d.ts +21 -0
  196. package/dist/database/EntryDatabase.js +138 -0
  197. package/dist/database/EntryLayer.d.ts +93 -0
  198. package/dist/database/EntryLayer.js +459 -0
  199. package/dist/database/EntryStore.d.ts +60 -0
  200. package/dist/database/EntryStore.js +269 -0
  201. package/dist/database/EntryTransaction.d.ts +33 -0
  202. package/dist/database/EntryTransaction.js +889 -0
  203. package/dist/database/EntryUrlAliases.d.ts +2 -0
  204. package/dist/database/EntryUrlAliases.js +69 -0
  205. package/dist/database/LocalDB.d.ts +39 -0
  206. package/dist/database/LocalDB.js +79 -0
  207. package/dist/database/Version.d.ts +9 -0
  208. package/dist/database/Version.js +13 -0
  209. package/dist/database/driver/RuntimeDatabase.d.ts +8 -0
  210. package/dist/database/driver/RuntimeDatabase.js +33 -0
  211. package/dist/database/driver/WasmDatabase.d.ts +8 -0
  212. package/dist/database/driver/WasmDatabase.js +33 -0
  213. package/dist/database/entry/EntryData.d.ts +13 -0
  214. package/dist/database/entry/EntryData.js +51 -0
  215. package/dist/database/entry/EntryTable.d.ts +173 -0
  216. package/dist/database/entry/EntryTable.js +137 -0
  217. package/dist/database/entry/EntryView.d.ts +22 -0
  218. package/dist/database/entry/EntryView.js +106 -0
  219. package/dist/database/query/Condition.d.ts +8 -0
  220. package/dist/database/query/Condition.js +117 -0
  221. package/dist/database/query/EntryQuery.d.ts +43 -0
  222. package/dist/database/query/EntryQuery.js +414 -0
  223. package/dist/database/query/EntryReferences.d.ts +6 -0
  224. package/dist/database/query/EntryReferences.js +68 -0
  225. package/dist/database/query/Relation.d.ts +11 -0
  226. package/dist/database/query/Relation.js +113 -0
  227. package/dist/database/query/ResolveQuery.d.ts +15 -0
  228. package/dist/database/query/ResolveQuery.js +154 -0
  229. package/dist/database/query/Search.d.ts +47 -0
  230. package/dist/database/query/Search.js +169 -0
  231. package/dist/database/sync/Derive.d.ts +8 -0
  232. package/dist/database/sync/Derive.js +270 -0
  233. package/dist/database/sync/EntryParser.d.ts +4 -0
  234. package/dist/database/sync/EntryParser.js +87 -0
  235. package/dist/database/sync/EntrySyncer.d.ts +37 -0
  236. package/dist/database/sync/EntrySyncer.js +117 -0
  237. package/dist/database/sync/Ingest.d.ts +21 -0
  238. package/dist/database/sync/Ingest.js +136 -0
  239. package/dist/database/sync/SyncQueries.d.ts +157 -0
  240. package/dist/database/sync/SyncQueries.js +192 -0
  241. package/dist/field/code/CodeField.view.js +12 -12
  242. package/dist/field/link/LinkField.js +23 -0
  243. package/dist/field/link/LinkField.view.js +41 -40
  244. package/dist/field/list/ListField.view.js +177 -155
  245. package/dist/field/metadata/MetadataField.d.ts +28 -3
  246. package/dist/field/metadata/MetadataField.js +44 -7
  247. package/dist/field/metadata/MetadataField.view.d.ts +5 -0
  248. package/dist/field/metadata/MetadataField.view.js +34 -19
  249. package/dist/field/richtext/RichTextBlock.js +2 -2
  250. package/dist/field/richtext/RichTextDocument.js +4 -3
  251. package/dist/field/richtext/RichTextExtensions.d.ts +1 -1
  252. package/dist/field/richtext/RichTextExtensions.js +32 -28
  253. package/dist/field/richtext/RichTextField.view.js +15 -6
  254. package/dist/field/views.js +2 -0
  255. package/dist/next.cjs +0 -18
  256. package/dist/next.d.ts +4 -3
  257. package/dist/next.edge.d.ts +1 -1
  258. package/dist/next.js +1 -2
  259. package/dist/picker/entry/EntryPicker.js +2 -1
  260. package/dist/picker/url/UrlPicker.js +1 -0
  261. package/dist/preview/widget.d.ts +16 -0
  262. package/dist/preview/widget.js +70 -1
  263. package/dist/query.d.ts +28 -0
  264. package/package.json +2 -1
  265. package/dist/backend/store/GeneratedSource.d.ts +0 -2
  266. package/dist/backend/store/GeneratedSource.js +0 -21
  267. package/dist/chunks/chunk-G6E35DMJ.js +0 -1997
  268. package/dist/core/db/EntryDB.d.ts +0 -19
  269. package/dist/core/db/EntryDB.js +0 -48
  270. package/dist/core/db/EntryIndex.d.ts +0 -143
  271. package/dist/core/db/EntryIndex.js +0 -2773
  272. package/dist/core/db/EntryReferenceIndex.d.ts +0 -21
  273. package/dist/core/db/EntryReferenceIndex.js +0 -131
  274. package/dist/core/db/EntryResolver.d.ts +0 -56
  275. package/dist/core/db/EntryResolver.js +0 -699
  276. package/dist/core/db/EntryTarget.d.ts +0 -5
  277. package/dist/core/db/EntryTransaction.d.ts +0 -31
  278. package/dist/core/db/EntryTransaction.js +0 -956
  279. package/dist/core/db/LocalDB.d.ts +0 -42
  280. package/dist/core/db/LocalDB.js +0 -127
  281. package/dist/core/db/TestDB.d.ts +0 -19
  282. package/dist/core/db/TestDB.js +0 -50
  283. /package/dist/core/db/{EntryTarget.js → LocalStore.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "3JgVisHzgNS5eYmsJjOMUsgVkII",
2
+ "_id": "3JmA8NHtbBt6eB3HhLdaN4zhM7O",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -2,7 +2,7 @@ This file contains the licenses of the bundled modules in this distribution.
2
2
 
3
3
  ===
4
4
 
5
- # react-aria-components@1.17.0 (Apache-2.0)
5
+ # @internationalized/date@3.12.1 (Apache-2.0)
6
6
 
7
7
  Apache License
8
8
  Version 2.0, January 2004
@@ -236,60 +236,7 @@ SOFTWARE.
236
236
 
237
237
  ===
238
238
 
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)
266
-
267
- MIT License
268
-
269
- Copyright (c) 2021 Joel Gustafson
270
-
271
- Permission is hereby granted, free of charge, to any person obtaining a copy
272
- of this software and associated documentation files (the "Software"), to deal
273
- in the Software without restriction, including without limitation the rights
274
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
275
- copies of the Software, and to permit persons to whom the Software is
276
- furnished to do so, subject to the following conditions:
277
-
278
- The above copyright notice and this permission notice shall be included in all
279
- copies or substantial portions of the Software.
280
-
281
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
282
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
283
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
284
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
285
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
286
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
287
- SOFTWARE.
288
-
289
-
290
- ===
291
-
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,38 +703,11 @@ SOFTWARE.
730
703
 
731
704
  ===
732
705
 
733
- # jotai-location@0.6.2 (MIT)
734
-
735
- The MIT License (MIT)
736
-
737
- Copyright (c) 2022 Daishi Kato
738
-
739
- Permission is hereby granted, free of charge, to any person obtaining a copy
740
- of this software and associated documentation files (the "Software"), to deal
741
- in the Software without restriction, including without limitation the rights
742
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
743
- copies of the Software, and to permit persons to whom the Software is
744
- furnished to do so, subject to the following conditions:
745
-
746
- The above copyright notice and this permission notice shall be included in
747
- all copies or substantial portions of the Software.
748
-
749
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
750
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
751
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
752
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
753
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
754
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
755
- THE SOFTWARE.
756
-
757
-
758
- ===
759
-
760
- # jotai-family@1.1.0 (MIT)
706
+ # @tiptap/core@3.30.5 (MIT)
761
707
 
762
708
  MIT License
763
709
 
764
- Copyright (c) 2025 Poimandres
710
+ Copyright (c) 2025, Tiptap GmbH
765
711
 
766
712
  Permission is hereby granted, free of charge, to any person obtaining a copy
767
713
  of this software and associated documentation files (the "Software"), to deal
@@ -991,11 +937,11 @@ SOFTWARE.
991
937
 
992
938
  ===
993
939
 
994
- # @badgateway/oauth2-client@3.3.1 (MIT)
940
+ # jotai-location@0.6.2 (MIT)
995
941
 
996
- MIT License
942
+ The MIT License (MIT)
997
943
 
998
- Copyright (c) 2019-2025 Evert Pot
944
+ Copyright (c) 2022 Daishi Kato
999
945
 
1000
946
  Permission is hereby granted, free of charge, to any person obtaining a copy
1001
947
  of this software and associated documentation files (the "Software"), to deal
@@ -1004,25 +950,25 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1004
950
  copies of the Software, and to permit persons to whom the Software is
1005
951
  furnished to do so, subject to the following conditions:
1006
952
 
1007
- The above copyright notice and this permission notice shall be included in all
1008
- copies or substantial portions of the Software.
953
+ The above copyright notice and this permission notice shall be included in
954
+ all copies or substantial portions of the Software.
1009
955
 
1010
956
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1011
957
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1012
958
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1013
959
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1014
960
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1015
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1016
- SOFTWARE.
961
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
962
+ THE SOFTWARE.
1017
963
 
1018
964
 
1019
965
  ===
1020
966
 
1021
- # @tiptap/extension-list@3.30.5 (MIT)
967
+ # jotai-family@1.1.0 (MIT)
1022
968
 
1023
969
  MIT License
1024
970
 
1025
- Copyright (c) 2025, Tiptap GmbH
971
+ Copyright (c) 2025 Poimandres
1026
972
 
1027
973
  Permission is hereby granted, free of charge, to any person obtaining a copy
1028
974
  of this software and associated documentation files (the "Software"), to deal
@@ -1045,34 +991,38 @@ SOFTWARE.
1045
991
 
1046
992
  ===
1047
993
 
1048
- # htmlparser2@9.1.0 (MIT)
994
+ # @badgateway/oauth2-client@3.3.1 (MIT)
995
+
996
+ MIT License
997
+
998
+ Copyright (c) 2019-2025 Evert Pot
1049
999
 
1050
- Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
1051
1000
  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
1001
+ of this software and associated documentation files (the "Software"), to deal
1002
+ in the Software without restriction, including without limitation the rights
1003
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1004
+ copies of the Software, and to permit persons to whom the Software is
1056
1005
  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
-
1006
+
1007
+ The above copyright notice and this permission notice shall be included in all
1008
+ copies or substantial portions of the Software.
1009
+
1061
1010
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1062
1011
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1063
1012
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1064
1013
  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.
1014
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1015
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1016
+ SOFTWARE.
1017
+
1068
1018
 
1069
1019
  ===
1070
1020
 
1071
- # use-sync-external-store@1.6.0 (MIT)
1021
+ # @tiptap/extension-list@3.30.5 (MIT)
1072
1022
 
1073
1023
  MIT License
1074
1024
 
1075
- Copyright (c) Meta Platforms, Inc. and affiliates.
1025
+ Copyright (c) 2025, Tiptap GmbH
1076
1026
 
1077
1027
  Permission is hereby granted, free of charge, to any person obtaining a copy
1078
1028
  of this software and associated documentation files (the "Software"), to deal
@@ -1095,19 +1045,29 @@ SOFTWARE.
1095
1045
 
1096
1046
  ===
1097
1047
 
1098
- # domutils@3.2.2 (BSD-2-Clause)
1048
+ # use-sync-external-store@1.6.0 (MIT)
1099
1049
 
1100
- Copyright (c) Felix Böhm
1101
- All rights reserved.
1050
+ MIT License
1102
1051
 
1103
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1052
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1104
1053
 
1105
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1054
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1055
+ of this software and associated documentation files (the "Software"), to deal
1056
+ in the Software without restriction, including without limitation the rights
1057
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1058
+ copies of the Software, and to permit persons to whom the Software is
1059
+ furnished to do so, subject to the following conditions:
1106
1060
 
1107
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1061
+ The above copyright notice and this permission notice shall be included in all
1062
+ copies or substantial portions of the Software.
1108
1063
 
1109
- THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
1110
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1064
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1065
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1066
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1067
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1068
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1069
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1070
+ SOFTWARE.
1111
1071
 
1112
1072
 
1113
1073
  ===
@@ -1137,6 +1097,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1137
1097
  SOFTWARE.
1138
1098
 
1139
1099
 
1100
+ ===
1101
+
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
+
1140
1123
  ===
1141
1124
 
1142
1125
  # domhandler@5.0.3 (BSD-2-Clause)
@@ -1154,6 +1137,23 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
1154
1137
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1155
1138
 
1156
1139
 
1140
+ ===
1141
+
1142
+ # domutils@3.2.2 (BSD-2-Clause)
1143
+
1144
+ Copyright (c) Felix Böhm
1145
+ All rights reserved.
1146
+
1147
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1148
+
1149
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1150
+
1151
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1152
+
1153
+ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
1154
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1155
+
1156
+
1157
1157
  ===
1158
1158
 
1159
1159
  # entities@4.5.0 (BSD-2-Clause)
@@ -1190,7 +1190,7 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1190
1190
 
1191
1191
  ===
1192
1192
 
1193
- # @internationalized/string@3.2.8 (Apache-2.0)
1193
+ # @internationalized/number@3.6.6 (Apache-2.0)
1194
1194
 
1195
1195
  Apache License
1196
1196
  Version 2.0, January 2004
@@ -1397,7 +1397,7 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1397
1397
 
1398
1398
  ===
1399
1399
 
1400
- # @internationalized/number@3.6.6 (Apache-2.0)
1400
+ # @internationalized/string@3.2.8 (Apache-2.0)
1401
1401
 
1402
1402
  Apache License
1403
1403
  Version 2.0, January 2004
@@ -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 {};