alinea 1.6.3 → 1.7.0-preview.1

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 (121) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +115 -115
  3. package/dist/adapter/core/cms.d.ts +1 -2
  4. package/dist/adapter/core/cms.js +1 -1
  5. package/dist/adapter/next/cms.d.ts +5 -1
  6. package/dist/adapter/next/cms.js +30 -2
  7. package/dist/adapter/next/handler.js +10 -4
  8. package/dist/adapter/next/with-alinea.d.ts +9 -1
  9. package/dist/adapter/next/with-alinea.js +85 -3
  10. package/dist/backend/Handler.js +12 -18
  11. package/dist/backend/Handler.test.d.ts +1 -0
  12. package/dist/backend/api/BasicAuth.d.ts +3 -1
  13. package/dist/backend/api/BasicAuth.js +5 -1
  14. package/dist/backend/api/CreateBackend.js +8 -10
  15. package/dist/backend/api/DatabaseApi.js +34 -8
  16. package/dist/backend/api/OAuth2.d.ts +1 -1
  17. package/dist/backend/api/OAuth2.js +3 -2
  18. package/dist/backend/resolver/ParsePreview.js +27 -22
  19. package/dist/backend/router/Proxy.d.ts +1 -0
  20. package/dist/backend/router/Proxy.js +32 -0
  21. package/dist/backend/util/ExecGit.d.ts +1 -0
  22. package/dist/backend/util/Syncable.d.ts +1 -0
  23. package/dist/backend/util/Syncable.js +22 -0
  24. package/dist/bundled.d.ts +556 -49
  25. package/dist/chunks/{chunk-UVC47CTF.js → chunk-DVF6JRD6.js} +4 -2
  26. package/dist/chunks/{chunk-H54PGW2N.js → chunk-SKF4L7JN.js} +73 -0
  27. package/dist/chunks/{chunk-APLOCHCC.js → chunk-XUSXCKEG.js} +5 -3
  28. package/dist/chunks/crypto-HZTUU327.js +11 -0
  29. package/dist/cli/Generate.d.ts +2 -1
  30. package/dist/cli/Generate.js +1 -1
  31. package/dist/cli/Serve.js +11 -8
  32. package/dist/cli/bin.js +1 -1
  33. package/dist/cli/generate/CopyStaticFiles.js +18 -2
  34. package/dist/cli/serve/CreateLocalServer.js +11 -4
  35. package/dist/cloud/CloudRemote.js +10 -9
  36. package/dist/config.d.ts +1 -0
  37. package/dist/config.js +2 -0
  38. package/dist/core/Config.d.ts +5 -1
  39. package/dist/core/Config.js +8 -1
  40. package/dist/core/Graph.d.ts +1 -1
  41. package/dist/core/Preview.d.ts +1 -1
  42. package/dist/core/Role.d.ts +130 -0
  43. package/dist/core/Role.js +256 -0
  44. package/dist/core/Role.test.d.ts +1 -0
  45. package/dist/core/Scope.d.ts +1 -0
  46. package/dist/core/Scope.js +3 -0
  47. package/dist/core/User.d.ts +2 -0
  48. package/dist/core/User.js +2 -1
  49. package/dist/core/db/EntryTransaction.d.ts +2 -1
  50. package/dist/core/db/EntryTransaction.js +39 -2
  51. package/dist/core/db/LocalDB.d.ts +2 -1
  52. package/dist/core/db/LocalDB.js +8 -2
  53. package/dist/core/db/WriteableGraph.d.ts +2 -0
  54. package/dist/core/db/WriteableGraph.js +15 -0
  55. package/dist/core/field/RichTextField.d.ts +1 -1
  56. package/dist/core/source/FilePatch.d.ts +12 -0
  57. package/dist/core/source/FilePatch.js +47 -0
  58. package/dist/core/source/FilePatch.test.d.ts +1 -0
  59. package/dist/core/source/GitDelta.d.ts +10 -0
  60. package/dist/core/source/GitDelta.js +196 -0
  61. package/dist/core/source/GitDelta.test.d.ts +1 -0
  62. package/dist/core/source/Utils.d.ts +4 -0
  63. package/dist/core/source/Utils.js +6 -3
  64. package/dist/core/util/Slugs.js +5 -3
  65. package/dist/dashboard/App.js +33 -15
  66. package/dist/dashboard/atoms/DashboardAtoms.js +2 -2
  67. package/dist/dashboard/atoms/DbAtoms.js +3 -3
  68. package/dist/dashboard/atoms/EntryAtoms.d.ts +1 -0
  69. package/dist/dashboard/atoms/EntryAtoms.js +51 -13
  70. package/dist/dashboard/atoms/EntryEditorAtoms.js +25 -3
  71. package/dist/dashboard/atoms/LocationAtoms.js +3 -3
  72. package/dist/dashboard/atoms/NavigationAtoms.js +25 -8
  73. package/dist/dashboard/atoms/PolicyAtom.d.ts +6 -0
  74. package/dist/dashboard/atoms/PolicyAtom.js +29 -0
  75. package/dist/dashboard/boot/Boot.js +2 -2
  76. package/dist/dashboard/boot/BootDev.js +4 -3
  77. package/dist/dashboard/editor/UseField.js +18 -1
  78. package/dist/dashboard/hook/UsePolicy.d.ts +1 -0
  79. package/dist/dashboard/hook/UsePolicy.js +14 -0
  80. package/dist/dashboard/pages/ContentView.js +12 -1
  81. package/dist/dashboard/view/ErrorBoundary.js +2 -18
  82. package/dist/dashboard/view/IconButton.d.ts +3 -3
  83. package/dist/dashboard/view/IconButton.js +4 -2
  84. package/dist/dashboard/view/MediaExplorer.js +4 -4
  85. package/dist/dashboard/view/Sidebar.js +5 -1
  86. package/dist/dashboard/view/entry/EntryHeader.d.ts +1 -2
  87. package/dist/dashboard/view/entry/EntryHeader.js +24 -14
  88. package/dist/dashboard/view/entry/EntryPreview.js +3 -3
  89. package/dist/dashboard/view/entry/NewEntry.js +19 -5
  90. package/dist/dashboard/view/sidebar/SidebarSettings.js +45 -9
  91. package/dist/field/link/LinkField.js +5 -0
  92. package/dist/field/list/ListField.view.js +3 -3
  93. package/dist/field/richtext/Extensions.d.ts +27 -0
  94. package/dist/field/richtext/{RichTextKit.js → Extensions.js} +94 -99
  95. package/dist/field/richtext/RichTextField.d.ts +7 -1
  96. package/dist/field/richtext/RichTextField.view.d.ts +1 -1
  97. package/dist/field/richtext/RichTextField.view.js +21 -16
  98. package/dist/field/richtext/RichTextToolbar.d.ts +36 -3
  99. package/dist/field/richtext/RichTextToolbar.js +150 -507
  100. package/dist/field/richtext/Toolbar.d.ts +152 -0
  101. package/dist/field/richtext/Toolbar.js +322 -0
  102. package/dist/index.css +168 -149
  103. package/dist/next.cjs +94 -3
  104. package/dist/picker/entry/EntryPicker.d.ts +1 -0
  105. package/dist/picker/entry/EntryPicker.js +11 -3
  106. package/dist/preview/PreviewPayload.js +2 -2
  107. package/dist/preview/PreviewPayload.test.d.ts +1 -0
  108. package/dist/test/EntryFixture.d.ts +30 -0
  109. package/dist/test/EntryFixture.js +91 -0
  110. package/dist/test/links.test.d.ts +1 -0
  111. package/dist/test/roles.test.d.ts +1 -0
  112. package/dist/ui/RichText.d.ts +1 -1
  113. package/dist/ui/RichText.js +15 -5
  114. package/package.json +2 -2
  115. package/dist/chunks/chunk-R2IV7GJV.js +0 -46
  116. package/dist/chunks/chunk-TO6JVYUN.js +0 -80
  117. package/dist/cli/Upgrade.d.ts +0 -1
  118. package/dist/cli/Upgrade.js +0 -8
  119. package/dist/core/EntrySearch.d.ts +0 -8
  120. package/dist/core/EntrySearch.js +0 -20
  121. package/dist/field/richtext/RichTextKit.d.ts +0 -2
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "39tRKcz5PoiEXazShsaBeNMNi3x",
2
+ "_id": "3A4E9JXR3UQVj3z5JLhuLI2V3rI",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -28,11 +28,34 @@ SOFTWARE.
28
28
 
29
29
  ===
30
30
 
31
- # react-query@3.39.3 (MIT)
31
+ # htmlparser2@9.1.0 (MIT)
32
+
33
+ Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy
35
+ of this software and associated documentation files (the "Software"), to
36
+ deal in the Software without restriction, including without limitation the
37
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
38
+ sell copies of the Software, and to permit persons to whom the Software is
39
+ furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in
42
+ all copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
50
+ IN THE SOFTWARE.
51
+
52
+ ===
53
+
54
+ # @headlessui/react@2.2.0 (MIT)
32
55
 
33
56
  MIT License
34
57
 
35
- Copyright (c) 2019 Tanner Linsley
58
+ Copyright (c) 2020 Tailwind Labs
36
59
 
37
60
  Permission is hereby granted, free of charge, to any person obtaining a copy
38
61
  of this software and associated documentation files (the "Software"), to deal
@@ -52,14 +75,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
75
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53
76
  SOFTWARE.
54
77
 
55
-
56
78
  ===
57
79
 
58
- # lib0@0.2.88 (MIT)
80
+ # react-query@3.39.3 (MIT)
59
81
 
60
- The MIT License (MIT)
82
+ MIT License
61
83
 
62
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
84
+ Copyright (c) 2019 Tanner Linsley
63
85
 
64
86
  Permission is hereby granted, free of charge, to any person obtaining a copy
65
87
  of this software and associated documentation files (the "Software"), to deal
@@ -82,34 +104,11 @@ SOFTWARE.
82
104
 
83
105
  ===
84
106
 
85
- # htmlparser2@9.1.0 (MIT)
86
-
87
- Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
88
- Permission is hereby granted, free of charge, to any person obtaining a copy
89
- of this software and associated documentation files (the "Software"), to
90
- deal in the Software without restriction, including without limitation the
91
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
92
- sell copies of the Software, and to permit persons to whom the Software is
93
- furnished to do so, subject to the following conditions:
94
-
95
- The above copyright notice and this permission notice shall be included in
96
- all copies or substantial portions of the Software.
97
-
98
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
99
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
100
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
101
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
102
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
103
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
104
- IN THE SOFTWARE.
105
-
106
- ===
107
-
108
- # @headlessui/react@2.2.0 (MIT)
107
+ # lib0@0.2.88 (MIT)
109
108
 
110
- MIT License
109
+ The MIT License (MIT)
111
110
 
112
- Copyright (c) 2020 Tailwind Labs
111
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
113
112
 
114
113
  Permission is hereby granted, free of charge, to any person obtaining a copy
115
114
  of this software and associated documentation files (the "Software"), to deal
@@ -129,6 +128,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129
128
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
130
129
  SOFTWARE.
131
130
 
131
+
132
132
  ===
133
133
 
134
134
  # domutils@3.1.0 (BSD-2-Clause)
@@ -180,6 +180,33 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
180
180
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
181
181
 
182
182
 
183
+ ===
184
+
185
+ # prop-types@15.8.1 (MIT)
186
+
187
+ MIT License
188
+
189
+ Copyright (c) 2013-present, Facebook, Inc.
190
+
191
+ Permission is hereby granted, free of charge, to any person obtaining a copy
192
+ of this software and associated documentation files (the "Software"), to deal
193
+ in the Software without restriction, including without limitation the rights
194
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
195
+ copies of the Software, and to permit persons to whom the Software is
196
+ furnished to do so, subject to the following conditions:
197
+
198
+ The above copyright notice and this permission notice shall be included in all
199
+ copies or substantial portions of the Software.
200
+
201
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
202
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
203
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
204
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
205
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
206
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
207
+ SOFTWARE.
208
+
209
+
183
210
  ===
184
211
 
185
212
  # @popperjs/core@2.11.8 (MIT)
@@ -440,33 +467,6 @@ SOFTWARE.
440
467
  limitations under the License.
441
468
 
442
469
 
443
- ===
444
-
445
- # prop-types@15.8.1 (MIT)
446
-
447
- MIT License
448
-
449
- Copyright (c) 2013-present, Facebook, Inc.
450
-
451
- Permission is hereby granted, free of charge, to any person obtaining a copy
452
- of this software and associated documentation files (the "Software"), to deal
453
- in the Software without restriction, including without limitation the rights
454
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
455
- copies of the Software, and to permit persons to whom the Software is
456
- furnished to do so, subject to the following conditions:
457
-
458
- The above copyright notice and this permission notice shall be included in all
459
- copies or substantial portions of the Software.
460
-
461
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
462
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
463
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
464
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
465
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
466
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
467
- SOFTWARE.
468
-
469
-
470
470
  ===
471
471
 
472
472
  # react-is@16.13.1 (MIT)
@@ -511,12 +511,6 @@ The above copyright notice and this permission notice shall be included in all c
511
511
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
512
512
 
513
513
 
514
- ===
515
-
516
- # @headless-tree/react@0.0.15 (MIT)
517
-
518
- MIT
519
-
520
514
  ===
521
515
 
522
516
  # @headless-tree/core@0.0.15 (MIT)
@@ -525,30 +519,9 @@ MIT
525
519
 
526
520
  ===
527
521
 
528
- # y-prosemirror@1.2.15 (MIT)
529
-
530
- The MIT License (MIT)
531
-
532
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
533
-
534
- Permission is hereby granted, free of charge, to any person obtaining a copy
535
- of this software and associated documentation files (the "Software"), to deal
536
- in the Software without restriction, including without limitation the rights
537
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
538
- copies of the Software, and to permit persons to whom the Software is
539
- furnished to do so, subject to the following conditions:
540
-
541
- The above copyright notice and this permission notice shall be included in all
542
- copies or substantial portions of the Software.
543
-
544
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
545
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
546
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
547
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
548
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
549
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
550
- SOFTWARE.
522
+ # @headless-tree/react@0.0.15 (MIT)
551
523
 
524
+ MIT
552
525
 
553
526
  ===
554
527
 
@@ -578,6 +551,33 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
578
551
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
579
552
 
580
553
 
554
+ ===
555
+
556
+ # y-prosemirror@1.2.15 (MIT)
557
+
558
+ The MIT License (MIT)
559
+
560
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
561
+
562
+ Permission is hereby granted, free of charge, to any person obtaining a copy
563
+ of this software and associated documentation files (the "Software"), to deal
564
+ in the Software without restriction, including without limitation the rights
565
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
566
+ copies of the Software, and to permit persons to whom the Software is
567
+ furnished to do so, subject to the following conditions:
568
+
569
+ The above copyright notice and this permission notice shall be included in all
570
+ copies or substantial portions of the Software.
571
+
572
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
573
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
574
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
575
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
576
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
577
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
578
+ SOFTWARE.
579
+
580
+
581
581
  ===
582
582
 
583
583
  # @react-aria/interactions@3.23.0 (Apache-2.0)
@@ -1612,6 +1612,33 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1612
1612
  See the License for the specific language governing permissions and
1613
1613
  limitations under the License.
1614
1614
 
1615
+ ===
1616
+
1617
+ # @tanstack/virtual-core@3.10.6 (MIT)
1618
+
1619
+ MIT License
1620
+
1621
+ Copyright (c) 2021-present Tanner Linsley
1622
+
1623
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1624
+ of this software and associated documentation files (the "Software"), to deal
1625
+ in the Software without restriction, including without limitation the rights
1626
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1627
+ copies of the Software, and to permit persons to whom the Software is
1628
+ furnished to do so, subject to the following conditions:
1629
+
1630
+ The above copyright notice and this permission notice shall be included in all
1631
+ copies or substantial portions of the Software.
1632
+
1633
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1634
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1635
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1636
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1637
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1638
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1639
+ SOFTWARE.
1640
+
1641
+
1615
1642
  ===
1616
1643
 
1617
1644
  # @react-stately/utils@3.10.5 (Apache-2.0)
@@ -1817,30 +1844,3 @@ limitations under the License.
1817
1844
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
1845
  See the License for the specific language governing permissions and
1819
1846
  limitations under the License.
1820
-
1821
-
1822
- ===
1823
-
1824
- # @tanstack/virtual-core@3.10.6 (MIT)
1825
-
1826
- MIT License
1827
-
1828
- Copyright (c) 2021-present Tanner Linsley
1829
-
1830
- Permission is hereby granted, free of charge, to any person obtaining a copy
1831
- of this software and associated documentation files (the "Software"), to deal
1832
- in the Software without restriction, including without limitation the rights
1833
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1834
- copies of the Software, and to permit persons to whom the Software is
1835
- furnished to do so, subject to the following conditions:
1836
-
1837
- The above copyright notice and this permission notice shall be included in all
1838
- copies or substantial portions of the Software.
1839
-
1840
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1841
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1842
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1843
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1844
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1845
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1846
- SOFTWARE.
@@ -2,11 +2,10 @@ import { CMS } from 'alinea/core/CMS';
2
2
  import type { Config } from 'alinea/core/Config';
3
3
  import type { UploadResponse } from 'alinea/core/Connection';
4
4
  import type { AnyQueryResult, GraphQuery } from 'alinea/core/Graph';
5
- import type { Mutation } from 'alinea/core/db/Mutation';
6
5
  export declare class CoreCMS<Definition extends Config = Config> extends CMS<Definition> {
7
6
  sync(): Promise<string>;
8
7
  resolve<Query extends GraphQuery>(query: Query): Promise<AnyQueryResult<Query>>;
9
- mutate(mutations: Array<Mutation>): Promise<{
8
+ mutate(): Promise<{
10
9
  sha: string;
11
10
  }>;
12
11
  prepareUpload(file: string): Promise<UploadResponse>;
@@ -9,7 +9,7 @@ var CoreCMS = class extends CMS {
9
9
  async resolve(query) {
10
10
  throw new Error("Not implemented");
11
11
  }
12
- async mutate(mutations) {
12
+ async mutate() {
13
13
  throw new Error("Not implemented");
14
14
  }
15
15
  async prepareUpload(file) {
@@ -1,9 +1,11 @@
1
1
  import { CMS } from 'alinea/core/CMS';
2
- import type { Config } from 'alinea/core/Config';
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
5
  import type { Mutation } from 'alinea/core/db/Mutation';
5
6
  import type { GraphQuery } from 'alinea/core/Graph';
6
7
  import type { User } from 'alinea/core/User';
8
+ import PLazy from 'p-lazy';
7
9
  export interface PreviewProps {
8
10
  widget?: boolean;
9
11
  workspace?: string;
@@ -12,6 +14,8 @@ export interface PreviewProps {
12
14
  export declare class NextCMS<Definition extends Config = Config> extends CMS<Definition> {
13
15
  #private;
14
16
  constructor(config: Definition);
17
+ throttle: (sync: () => Promise<unknown>, interval?: number) => Promise<void>;
18
+ bundledDb: PLazy<LocalDB>;
15
19
  resolve<Query extends GraphQuery>(query: Query): Promise<any>;
16
20
  user(): Promise<User | undefined>;
17
21
  mutate(mutations: Array<Mutation>): Promise<{
@@ -1,9 +1,15 @@
1
+ import {
2
+ PLazy
3
+ } from "../../chunks/chunk-IKINPSS5.js";
1
4
  import "../../chunks/chunk-NZLE2WMY.js";
2
5
 
3
6
  // src/adapter/next/cms.tsx
4
7
  import { Headers } from "@alinea/iso";
8
+ import { createThrottledSync } from "alinea/backend/util/Syncable";
5
9
  import { Client } from "alinea/core/Client";
6
10
  import { CMS } from "alinea/core/CMS";
11
+ import { Config } from "alinea/core/Config";
12
+ import { LocalDB } from "alinea/core/db/LocalDB";
7
13
  import { outcome } from "alinea/core/Outcome";
8
14
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
9
15
  import { requestContext } from "./context.js";
@@ -12,6 +18,16 @@ var NextCMS = class extends CMS {
12
18
  constructor(config) {
13
19
  super(config);
14
20
  }
21
+ throttle = createThrottledSync();
22
+ bundledDb = PLazy.from(async () => {
23
+ if (process.env.NEXT_RUNTIME === "edge")
24
+ throw new Error("Local DB is not supported in Edge runtime environments.");
25
+ const { generatedSource } = await import("alinea/backend/store/GeneratedSource");
26
+ const source = await generatedSource;
27
+ const db = new LocalDB(this.config, source);
28
+ await db.sync();
29
+ return db;
30
+ });
15
31
  async resolve(query) {
16
32
  let status = query.status;
17
33
  const { handlerUrl, apiKey } = await requestContext(this.config);
@@ -33,7 +49,19 @@ var NextCMS = class extends CMS {
33
49
  const payload = getPreviewPayloadFromCookies(cookie.getAll());
34
50
  if (payload) preview = { payload };
35
51
  }
36
- return client.resolve({ preview, ...query, status });
52
+ const { PHASE_PRODUCTION_BUILD } = await import("next/constants");
53
+ const isEdge = process.env.NEXT_RUNTIME === "edge";
54
+ const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
55
+ const isDev = process.env.NODE_ENV === "development";
56
+ const request = { preview, ...query, status };
57
+ const useRemote = isDev || isEdge || preview;
58
+ const useLocalDb = !useRemote || isBuild;
59
+ if (useLocalDb) {
60
+ const db = await this.bundledDb;
61
+ await this.throttle(() => db.syncWith(client), request.syncInterval);
62
+ return db.resolve(request);
63
+ }
64
+ return client.resolve(request);
37
65
  }
38
66
  async #authenticatedClient() {
39
67
  const { handlerUrl, apiKey } = await requestContext(this.config);
@@ -81,7 +109,7 @@ var NextCMS = class extends CMS {
81
109
  const [isDraft] = await outcome(async () => (await draftMode()).isEnabled);
82
110
  if (!isDraft) return null;
83
111
  const { isDev, handlerUrl } = await requestContext(this.config);
84
- let file = this.config.dashboardFile ?? "/admin.html";
112
+ let file = `${Config.adminPath(this.config)}.html`;
85
113
  if (!file.startsWith("/")) file = `/${file}`;
86
114
  const dashboardUrl = isDev ? new URL("/", handlerUrl) : new URL(file, handlerUrl);
87
115
  const NextPreviews = dynamic(() => import("./previews.js"), {
@@ -34,17 +34,23 @@ function createHandler(input) {
34
34
  db
35
35
  });
36
36
  const handle = async (request) => {
37
+ const url = new URL(request.url);
38
+ const { searchParams } = url;
39
+ const context = await requestContext(config);
40
+ const handlerPath = config.handlerUrl ?? "/api/cms";
41
+ if (!url.pathname.startsWith(handlerPath))
42
+ return new Response(`Expected handler to be served on ${handlerPath}`, {
43
+ status: 400
44
+ });
37
45
  try {
38
- const context = await requestContext(config);
39
46
  const previews = new JWTPreviews(context.apiKey);
40
- const { searchParams } = new URL(request.url);
41
47
  const previewToken = searchParams.get("preview");
42
48
  if (previewToken) {
43
49
  const { draftMode } = await import("next/headers");
44
- const { url } = await previews.verify(previewToken);
50
+ const { url: url2 } = await previews.verify(previewToken);
45
51
  const source = new URL(request.url);
46
52
  if (source.hostname === "0.0.0.0") source.hostname = "localhost";
47
- const location = new URL(url, source.origin);
53
+ const location = new URL(url2, source.origin);
48
54
  const dm = await draftMode();
49
55
  dm.enable();
50
56
  return new Response("Redirecting...", {
@@ -1,3 +1,11 @@
1
1
  import type { NextConfig } from 'next/dist/types.js';
2
+ export interface WithAlineaOptions {
3
+ /**
4
+ * Base path where the dashboard is mounted.
5
+ *
6
+ * @default '/admin'
7
+ */
8
+ adminPath?: string;
9
+ }
2
10
  export declare function createCMS(): void;
3
- export declare function withAlinea(config: NextConfig): NextConfig;
11
+ export declare function withAlinea(config?: NextConfig): NextConfig;
@@ -1,15 +1,25 @@
1
+ import {
2
+ version
3
+ } from "../../chunks/chunk-DVF6JRD6.js";
1
4
  import "../../chunks/chunk-NZLE2WMY.js";
2
5
 
3
6
  // src/adapter/next/with-alinea.ts
4
7
  import { readFileSync } from "node:fs";
5
8
  import { createRequire } from "node:module";
6
9
  import { resolve } from "node:path";
10
+ import { bold, cyan, gray } from "alinea/cli/util/Report";
7
11
  function createCMS() {
8
12
  throw new Error(
9
13
  'Alinea was loaded in a CJS environment. Please ensure your project is marked as "type": "module" in package.json.'
10
14
  );
11
15
  }
12
- function withAlinea(config) {
16
+ function withAlinea(config = {}) {
17
+ if (!process.env.ALINEA_ADMIN_PATH) {
18
+ console.warn(
19
+ "ALINEA_ADMIN_PATH environment variable is not set, did you run with the Alinea CLI?"
20
+ );
21
+ return config;
22
+ }
13
23
  let nextVersion = 15;
14
24
  try {
15
25
  const require2 = createRequire(resolve("./index.js"));
@@ -31,6 +41,9 @@ function withAlinea(config) {
31
41
  ...imagesConfig,
32
42
  remotePatterns
33
43
  };
44
+ const adminPath = normalizeBasePath(process.env.ALINEA_ADMIN_PATH);
45
+ const redirects = createRedirects(config, adminPath);
46
+ const rewrites = createRewrites(config, adminPath);
34
47
  if (nextVersion < 15)
35
48
  return {
36
49
  ...config,
@@ -41,7 +54,9 @@ function withAlinea(config) {
41
54
  "@alinea/generated"
42
55
  ]
43
56
  },
44
- images
57
+ images,
58
+ redirects,
59
+ rewrites
45
60
  };
46
61
  return {
47
62
  ...config,
@@ -49,9 +64,76 @@ function withAlinea(config) {
49
64
  ...config.serverExternalPackages ?? [],
50
65
  "@alinea/generated"
51
66
  ],
52
- images
67
+ images,
68
+ redirects,
69
+ rewrites
70
+ };
71
+ }
72
+ function createRedirects(config, adminPath) {
73
+ const dev = process.env.ALINEA_DEV_SERVER;
74
+ if (!dev) return config.redirects;
75
+ return async () => {
76
+ const existing = config.redirects ? await config.redirects() : [];
77
+ return [
78
+ ...existing,
79
+ {
80
+ permanent: true,
81
+ source: `${adminPath}/~dev`,
82
+ destination: `${dev}/~dev`
83
+ }
84
+ ];
85
+ };
86
+ }
87
+ var emptyRewrites = {
88
+ beforeFiles: [],
89
+ afterFiles: [],
90
+ fallback: []
91
+ };
92
+ function createRewrites(config, adminPath) {
93
+ return async () => {
94
+ const devServer = process.env.ALINEA_DEV_SERVER;
95
+ const nodeEnv = process.env.NODE_ENV;
96
+ const isDev = devServer && nodeEnv === "development";
97
+ const nextOrigin = process.env.__NEXT_PRIVATE_ORIGIN;
98
+ const nextHost = process.env.__NEXT_PRIVATE_HOST;
99
+ const origin = nextOrigin ?? (nextHost ? `http://${nextHost}` : null);
100
+ const location = origin ? new URL(adminPath, origin).href : adminPath;
101
+ if (isDev) {
102
+ const alineaVersion = gray(version);
103
+ const header = `
104
+ ${cyan(bold("\u0251 Alinea"))} ${alineaVersion}
105
+ `;
106
+ console.log(`${header} - Local CMS: ${location}
107
+ `);
108
+ }
109
+ const existing = config.rewrites ? await config.rewrites() : [];
110
+ const rewrites = Array.isArray(existing) ? { ...emptyRewrites, afterFiles: existing } : { ...emptyRewrites, ...existing };
111
+ if (isDev) {
112
+ return {
113
+ ...rewrites,
114
+ beforeFiles: [
115
+ ...rewrites.beforeFiles,
116
+ {
117
+ source: `${adminPath}/:path*`,
118
+ destination: `${devServer}${adminPath}/:path*`
119
+ }
120
+ ]
121
+ };
122
+ }
123
+ return {
124
+ ...rewrites,
125
+ afterFiles: [
126
+ {
127
+ source: adminPath,
128
+ destination: `${adminPath}.html`
129
+ }
130
+ ]
131
+ };
53
132
  };
54
133
  }
134
+ function normalizeBasePath(value) {
135
+ return value.startsWith("/") ? value : `/${value}`;
136
+ }
55
137
  export {
56
138
  createCMS,
57
139
  withAlinea
@@ -3,9 +3,6 @@ import {
3
3
  object,
4
4
  string
5
5
  } from "../chunks/chunk-WD7H5L2L.js";
6
- import {
7
- pLimit
8
- } from "../chunks/chunk-C53YJRET.js";
9
6
  import {
10
7
  PLazy
11
8
  } from "../chunks/chunk-IKINPSS5.js";
@@ -15,13 +12,14 @@ import "../chunks/chunk-NZLE2WMY.js";
15
12
  import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
16
13
  import { CloudRemote } from "alinea/cloud/CloudRemote";
17
14
  import { HttpError } from "alinea/core/HttpError";
15
+ import { Permission } from "alinea/core/Role";
18
16
  import { getScope } from "alinea/core/Scope";
19
17
  import { ShaMismatchError } from "alinea/core/source/ShaMismatchError";
20
18
  import { base64 } from "alinea/core/util/Encoding";
21
19
  import { InvalidCredentialsError, MissingCredentialsError } from "./Auth.js";
22
20
  import { HandleAction } from "./HandleAction.js";
23
21
  import { createPreviewParser } from "./resolver/ParsePreview.js";
24
- var limit = pLimit(1);
22
+ import { createThrottledSync } from "./util/Syncable.js";
25
23
  var PrepareBody = object({
26
24
  filename: string
27
25
  });
@@ -34,7 +32,7 @@ function createHandler({
34
32
  db,
35
33
  ...hooks
36
34
  }) {
37
- let lastSync = 0;
35
+ const throttle = createThrottledSync();
38
36
  const previewParser = PLazy.from(async () => {
39
37
  const local = await db;
40
38
  return createPreviewParser(local);
@@ -44,17 +42,9 @@ function createHandler({
44
42
  const local = await db;
45
43
  const simulateLatency = process.env.ALINEA_LATENCY;
46
44
  if (simulateLatency) await new Promise((resolve) => setTimeout(resolve, 2e3));
47
- async function periodicSync(cnx, syncInterval = 60) {
45
+ async function periodicSync(cnx, syncInterval) {
48
46
  if (dev) return;
49
- return limit(async () => {
50
- if (syncInterval === Number.POSITIVE_INFINITY) return;
51
- const now = Date.now();
52
- if (now - lastSync < syncInterval * 1e3) return;
53
- lastSync = now;
54
- await local.syncWith(cnx);
55
- }).catch((error) => {
56
- console.error(error);
57
- });
47
+ return throttle(() => local.syncWith(cnx), syncInterval);
58
48
  }
59
49
  try {
60
50
  const previews = new JWTPreviews(context.apiKey);
@@ -97,6 +87,7 @@ function createHandler({
97
87
  }
98
88
  const expectUser = () => {
99
89
  if (!userCtx) throw new Response("Unauthorized", { status: 401 });
90
+ return userCtx.user;
100
91
  };
101
92
  const body = PLazy.from(() => {
102
93
  const isJson = request.headers.get("content-type")?.includes("application/json");
@@ -123,12 +114,13 @@ function createHandler({
123
114
  return Response.json(await local.resolve(query) ?? null);
124
115
  }
125
116
  if (action === HandleAction.Mutate && request.method === "POST") {
126
- expectUser();
117
+ const user = expectUser();
127
118
  expectJson();
119
+ const policy = await local.createPolicy(user.roles);
128
120
  const mutations = await body;
129
121
  const attempt = async (retry = 0) => {
130
122
  await local.syncWith(cnx);
131
- const request2 = await local.request(mutations);
123
+ const request2 = await local.request(mutations, policy);
132
124
  try {
133
125
  let { sha } = await cnx.write(request2);
134
126
  if (sha === request2.intoSha) {
@@ -189,7 +181,9 @@ function createHandler({
189
181
  return new Response(formData);
190
182
  }
191
183
  if (action === HandleAction.Upload) {
192
- expectUser();
184
+ const user = expectUser();
185
+ const policy = await local.createPolicy(user.roles);
186
+ policy.assert(Permission.Upload);
193
187
  const entryId = url.searchParams.get("entryId");
194
188
  if (!entryId) {
195
189
  expectJson();
@@ -0,0 +1 @@
1
+ export {};