alinea 1.4.7 → 1.4.9

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "30ohtUWBdhXO3y56mObqkCnSbWH",
2
+ "_id": "30ulr5UTckoCL1Upuj7QIxl3v7l",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -53,6 +53,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53
53
  SOFTWARE.
54
54
 
55
55
 
56
+ ===
57
+
58
+ # htmlparser2@9.1.0 (MIT)
59
+
60
+ Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy
62
+ of this software and associated documentation files (the "Software"), to
63
+ deal in the Software without restriction, including without limitation the
64
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
65
+ sell copies of the Software, and to permit persons to whom the Software is
66
+ furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in
69
+ all copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
76
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
77
+ IN THE SOFTWARE.
78
+
56
79
  ===
57
80
 
58
81
  # react-query@3.39.3 (MIT)
@@ -80,6 +103,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
80
103
  SOFTWARE.
81
104
 
82
105
 
106
+ ===
107
+
108
+ # domutils@3.1.0 (BSD-2-Clause)
109
+
110
+ Copyright (c) Felix Böhm
111
+ All rights reserved.
112
+
113
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
114
+
115
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
116
+
117
+ 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.
118
+
119
+ 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,
120
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
121
+
122
+
83
123
  ===
84
124
 
85
125
  # @headlessui/react@2.2.0 (MIT)
@@ -106,72 +146,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106
146
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107
147
  SOFTWARE.
108
148
 
109
- ===
110
-
111
- # htmlparser2@9.1.0 (MIT)
112
-
113
- Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
114
- Permission is hereby granted, free of charge, to any person obtaining a copy
115
- of this software and associated documentation files (the "Software"), to
116
- deal in the Software without restriction, including without limitation the
117
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
118
- sell copies of the Software, and to permit persons to whom the Software is
119
- furnished to do so, subject to the following conditions:
120
-
121
- The above copyright notice and this permission notice shall be included in
122
- all copies or substantial portions of the Software.
123
-
124
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
129
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
130
- IN THE SOFTWARE.
131
-
132
- ===
133
-
134
- # @popperjs/core@2.11.8 (MIT)
135
-
136
- The MIT License (MIT)
137
-
138
- Copyright (c) 2019 Federico Zivolo
139
-
140
- Permission is hereby granted, free of charge, to any person obtaining a copy of
141
- this software and associated documentation files (the "Software"), to deal in
142
- the Software without restriction, including without limitation the rights to
143
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
144
- the Software, and to permit persons to whom the Software is furnished to do so,
145
- subject to the following conditions:
146
-
147
- The above copyright notice and this permission notice shall be included in all
148
- copies or substantial portions of the Software.
149
-
150
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
152
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
153
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
154
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
155
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
156
-
157
-
158
- ===
159
-
160
- # domutils@3.1.0 (BSD-2-Clause)
161
-
162
- Copyright (c) Felix Böhm
163
- All rights reserved.
164
-
165
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
166
-
167
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
168
-
169
- 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.
170
-
171
- 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,
172
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173
-
174
-
175
149
  ===
176
150
 
177
151
  # domhandler@5.0.3 (BSD-2-Clause)
@@ -208,29 +182,28 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
208
182
 
209
183
  ===
210
184
 
211
- # prop-types@15.8.1 (MIT)
185
+ # @popperjs/core@2.11.8 (MIT)
212
186
 
213
- MIT License
187
+ The MIT License (MIT)
214
188
 
215
- Copyright (c) 2013-present, Facebook, Inc.
189
+ Copyright (c) 2019 Federico Zivolo
216
190
 
217
- Permission is hereby granted, free of charge, to any person obtaining a copy
218
- of this software and associated documentation files (the "Software"), to deal
219
- in the Software without restriction, including without limitation the rights
220
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
221
- copies of the Software, and to permit persons to whom the Software is
222
- furnished to do so, subject to the following conditions:
191
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
192
+ this software and associated documentation files (the "Software"), to deal in
193
+ the Software without restriction, including without limitation the rights to
194
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
195
+ the Software, and to permit persons to whom the Software is furnished to do so,
196
+ subject to the following conditions:
223
197
 
224
198
  The above copyright notice and this permission notice shall be included in all
225
199
  copies or substantial portions of the Software.
226
200
 
227
201
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
228
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
229
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
230
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
231
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
232
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
- SOFTWARE.
202
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
203
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
204
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
205
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
206
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
234
207
 
235
208
 
236
209
  ===
@@ -442,11 +415,11 @@ SOFTWARE.
442
415
 
443
416
  ===
444
417
 
445
- # react-is@16.13.1 (MIT)
418
+ # prop-types@15.8.1 (MIT)
446
419
 
447
420
  MIT License
448
421
 
449
- Copyright (c) Facebook, Inc. and its affiliates.
422
+ Copyright (c) 2013-present, Facebook, Inc.
450
423
 
451
424
  Permission is hereby granted, free of charge, to any person obtaining a copy
452
425
  of this software and associated documentation files (the "Software"), to deal
@@ -486,11 +459,11 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
486
459
 
487
460
  ===
488
461
 
489
- # y-prosemirror@1.2.15 (MIT)
462
+ # react-is@16.13.1 (MIT)
490
463
 
491
- The MIT License (MIT)
464
+ MIT License
492
465
 
493
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
466
+ Copyright (c) Facebook, Inc. and its affiliates.
494
467
 
495
468
  Permission is hereby granted, free of charge, to any person obtaining a copy
496
469
  of this software and associated documentation files (the "Software"), to deal
@@ -523,6 +496,33 @@ MIT
523
496
 
524
497
  MIT
525
498
 
499
+ ===
500
+
501
+ # y-prosemirror@1.2.15 (MIT)
502
+
503
+ The MIT License (MIT)
504
+
505
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
506
+
507
+ Permission is hereby granted, free of charge, to any person obtaining a copy
508
+ of this software and associated documentation files (the "Software"), to deal
509
+ in the Software without restriction, including without limitation the rights
510
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
511
+ copies of the Software, and to permit persons to whom the Software is
512
+ furnished to do so, subject to the following conditions:
513
+
514
+ The above copyright notice and this permission notice shall be included in all
515
+ copies or substantial portions of the Software.
516
+
517
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
518
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
519
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
520
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
521
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
522
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
523
+ SOFTWARE.
524
+
525
+
526
526
  ===
527
527
 
528
528
  # @babel/runtime@7.25.4 (MIT)
@@ -1585,6 +1585,33 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1585
1585
  See the License for the specific language governing permissions and
1586
1586
  limitations under the License.
1587
1587
 
1588
+ ===
1589
+
1590
+ # @tanstack/virtual-core@3.10.6 (MIT)
1591
+
1592
+ MIT License
1593
+
1594
+ Copyright (c) 2021-present Tanner Linsley
1595
+
1596
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1597
+ of this software and associated documentation files (the "Software"), to deal
1598
+ in the Software without restriction, including without limitation the rights
1599
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1600
+ copies of the Software, and to permit persons to whom the Software is
1601
+ furnished to do so, subject to the following conditions:
1602
+
1603
+ The above copyright notice and this permission notice shall be included in all
1604
+ copies or substantial portions of the Software.
1605
+
1606
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1607
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1608
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1609
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1610
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1611
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1612
+ SOFTWARE.
1613
+
1614
+
1588
1615
  ===
1589
1616
 
1590
1617
  # @react-stately/utils@3.10.5 (Apache-2.0)
@@ -1790,30 +1817,3 @@ limitations under the License.
1790
1817
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791
1818
  See the License for the specific language governing permissions and
1792
1819
  limitations under the License.
1793
-
1794
-
1795
- ===
1796
-
1797
- # @tanstack/virtual-core@3.10.6 (MIT)
1798
-
1799
- MIT License
1800
-
1801
- Copyright (c) 2021-present Tanner Linsley
1802
-
1803
- Permission is hereby granted, free of charge, to any person obtaining a copy
1804
- of this software and associated documentation files (the "Software"), to deal
1805
- in the Software without restriction, including without limitation the rights
1806
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1807
- copies of the Software, and to permit persons to whom the Software is
1808
- furnished to do so, subject to the following conditions:
1809
-
1810
- The above copyright notice and this permission notice shall be included in all
1811
- copies or substantial portions of the Software.
1812
-
1813
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1814
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1815
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1816
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1817
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1819
- SOFTWARE.
package/dist/bundled.d.ts CHANGED
@@ -1296,10 +1296,8 @@ declare module 'alinea/core/Connection' {
1296
1296
 
1297
1297
  declare module 'alinea/core/db/CommitRequest' {
1298
1298
 
1299
- import type { CommitApi, SyncApi } from 'alinea/core/Connection';
1300
1299
  import type { Change, ChangeFile, ChangesBatch } from 'alinea/core/source/Change';
1301
1300
  import type { ReadonlyTree } from 'alinea/core/source/Tree';
1302
- import type { LocalDB } from 'alinea/core/db/LocalDB';
1303
1301
  import type { RemoveFileMutation, UploadFileMutation } from 'alinea/core/db/Mutation';
1304
1302
  export interface AddContent extends ChangeFile {
1305
1303
  op: 'addContent';
@@ -1319,7 +1317,6 @@ declare module 'alinea/core/db/CommitRequest' {
1319
1317
  changes: Array<CommitChange>;
1320
1318
  }
1321
1319
  export function checkCommit(tree: ReadonlyTree, request: CommitRequest): void;
1322
- export function attemptCommit(local: LocalDB, remote: CommitApi & SyncApi, request: CommitRequest): Promise<void>;
1323
1320
 
1324
1321
  }
1325
1322
 
@@ -3548,7 +3545,7 @@ declare module 'alinea/core/source/ShaMismatchError' {
3548
3545
  export class ShaMismatchError extends HttpError {
3549
3546
  actual: string;
3550
3547
  expected: string;
3551
- constructor(actual: string, expected: string);
3548
+ constructor(actual: string, expected: string, message?: string);
3552
3549
  }
3553
3550
 
3554
3551
  }
@@ -3663,6 +3660,7 @@ declare module 'alinea/core/source/Tree' {
3663
3660
  constructor({ sha, entries }: Tree);
3664
3661
  get isEmpty(): boolean;
3665
3662
  get entries(): Array<Entry>;
3663
+ get shas(): ReadonlySet<string>;
3666
3664
  hasSha(sha: string): boolean;
3667
3665
  clone(): WriteableTree;
3668
3666
  toJSON(): {
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "1.4.7",
5
+ version: "1.4.9",
6
6
  description: "Headless git-based CMS",
7
7
  repository: {
8
8
  type: "git",
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-T7IP7EGH.js";
3
+ } from "../chunks/chunk-NEFR4CFI.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-T7IP7EGH.js";
3
+ } from "../chunks/chunk-NEFR4CFI.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-T7IP7EGH.js";
3
+ } from "../chunks/chunk-NEFR4CFI.js";
4
4
  import {
5
5
  PLazy
6
6
  } from "../chunks/chunk-IKINPSS5.js";
@@ -347,7 +347,7 @@ async function parseOutcome(expected) {
347
347
  }
348
348
  const output = await response.json();
349
349
  if (output.success) {
350
- return output.value;
350
+ return output.data;
351
351
  }
352
352
  if (output.error) {
353
353
  throw new HttpError(response.status, output.error);
@@ -1,7 +1,5 @@
1
- import type { CommitApi, SyncApi } from '../Connection.js';
2
1
  import type { Change, ChangeFile, ChangesBatch } from '../source/Change.js';
3
2
  import type { ReadonlyTree } from '../source/Tree.js';
4
- import type { LocalDB } from './LocalDB.js';
5
3
  import type { RemoveFileMutation, UploadFileMutation } from './Mutation.js';
6
4
  export interface AddContent extends ChangeFile {
7
5
  op: 'addContent';
@@ -21,4 +19,3 @@ export interface CommitRequest {
21
19
  changes: Array<CommitChange>;
22
20
  }
23
21
  export declare function checkCommit(tree: ReadonlyTree, request: CommitRequest): void;
24
- export declare function attemptCommit(local: LocalDB, remote: CommitApi & SyncApi, request: CommitRequest): Promise<void>;
@@ -48,21 +48,7 @@ function checkCommit(tree, request) {
48
48
  if (entry.sha !== sha) throw new Error(`Entry ${path} has changed`);
49
49
  }
50
50
  }
51
- async function attemptCommit(local, remote, request) {
52
- const contentChanges = sourceChanges(request);
53
- await local.indexChanges(contentChanges);
54
- try {
55
- const { sha } = await remote.write(request);
56
- if (sha === request.intoSha) {
57
- await local.applyChanges(contentChanges);
58
- return;
59
- }
60
- } finally {
61
- await local.syncWith(remote);
62
- }
63
- }
64
51
  export {
65
- attemptCommit,
66
52
  checkCommit,
67
53
  commitChanges,
68
54
  sourceChanges
@@ -1,6 +1,7 @@
1
1
  import "../../chunks/chunk-NZLE2WMY.js";
2
2
 
3
3
  // src/core/source/IndexedDBSource.ts
4
+ import { ShaMismatchError } from "./ShaMismatchError.js";
4
5
  import { ReadonlyTree } from "./Tree.js";
5
6
  var IndexedDBSource = class {
6
7
  #factory;
@@ -45,16 +46,31 @@ var IndexedDBSource = class {
45
46
  getTree() {
46
47
  const handle = async () => {
47
48
  const db = await this.#connect();
48
- return new Promise((resolve, reject) => {
49
- const transaction = db.transaction(["tree"], "readonly");
50
- const store = transaction.objectStore("tree");
51
- const request = store.get("tree");
52
- request.onsuccess = (event) => {
53
- const entry = event.target.result;
54
- resolve(entry ? new ReadonlyTree(entry) : ReadonlyTree.EMPTY);
55
- };
56
- request.onerror = (event) => reject(event.target.error);
57
- });
49
+ const transaction = db.transaction(["tree", "blobs"], "readonly");
50
+ const treeStore = transaction.objectStore("tree");
51
+ const blobsStore = transaction.objectStore("blobs");
52
+ const [tree, blobKeys] = await Promise.all([
53
+ new Promise((resolve, reject) => {
54
+ const request = treeStore.get("tree");
55
+ request.onsuccess = (event) => {
56
+ const entry = event.target.result;
57
+ resolve(entry ? new ReadonlyTree(entry) : ReadonlyTree.EMPTY);
58
+ };
59
+ request.onerror = (event) => reject(event.target.error);
60
+ }),
61
+ new Promise((resolve, reject) => {
62
+ const request = blobsStore.getAllKeys();
63
+ request.onsuccess = () => resolve(request.result);
64
+ request.onerror = (event) => reject(event.target.error);
65
+ })
66
+ ]);
67
+ for (const sha of tree.shas) {
68
+ if (!blobKeys.includes(sha)) {
69
+ console.warn(`Blob ${sha} in tree, but not found`);
70
+ return ReadonlyTree.EMPTY;
71
+ }
72
+ }
73
+ return tree;
58
74
  };
59
75
  return handle().catch(this.#retryIfClosing(handle));
60
76
  }
@@ -81,6 +97,12 @@ var IndexedDBSource = class {
81
97
  async applyChanges(batch) {
82
98
  const db = await this.#connect();
83
99
  const current = await this.getTree();
100
+ if (batch.fromSha !== current.sha)
101
+ throw new ShaMismatchError(
102
+ current.sha,
103
+ batch.fromSha,
104
+ "Cannot apply changes locally due to SHA mismatch"
105
+ );
84
106
  const updatedTree = current.clone();
85
107
  updatedTree.applyChanges(batch);
86
108
  const compiled = await updatedTree.compile();
@@ -93,10 +115,15 @@ var IndexedDBSource = class {
93
115
  case "add":
94
116
  blobs.put(change.contents, change.sha);
95
117
  break;
96
- case "delete":
97
- blobs.delete(change.sha);
98
- break;
99
118
  }
119
+ const blobKeys = await new Promise((resolve, reject) => {
120
+ const request = blobs.getAllKeys();
121
+ request.onsuccess = () => resolve(request.result);
122
+ request.onerror = (event) => reject(event.target.error);
123
+ });
124
+ for (const sha of blobKeys) {
125
+ if (!compiled.hasSha(sha)) blobs.delete(sha);
126
+ }
100
127
  return new Promise((resolve, reject) => {
101
128
  transaction.oncomplete = () => resolve();
102
129
  transaction.onerror = (event) => reject(event.target.error);
@@ -41,13 +41,13 @@ var MemorySource = class {
41
41
  this.#blobs.set(change.sha, change.contents);
42
42
  continue;
43
43
  }
44
- case "delete": {
45
- this.#blobs.delete(change.sha);
46
- continue;
47
- }
48
44
  }
49
45
  }
50
- this.#tree = await this.#tree.withChanges(batch);
46
+ const compiled = await this.#tree.withChanges(batch);
47
+ for (const sha of this.#blobs.keys()) {
48
+ if (!compiled.hasSha(sha)) this.#blobs.delete(sha);
49
+ }
50
+ this.#tree = compiled;
51
51
  }
52
52
  };
53
53
  export {
@@ -2,5 +2,5 @@ import { HttpError } from '../HttpError.js';
2
2
  export declare class ShaMismatchError extends HttpError {
3
3
  actual: string;
4
4
  expected: string;
5
- constructor(actual: string, expected: string);
5
+ constructor(actual: string, expected: string, message?: string);
6
6
  }
@@ -3,8 +3,8 @@ import "../../chunks/chunk-NZLE2WMY.js";
3
3
  // src/core/source/ShaMismatchError.ts
4
4
  import { HttpError } from "../HttpError.js";
5
5
  var ShaMismatchError = class extends HttpError {
6
- constructor(actual, expected) {
7
- super(409, `SHA mismatch: ${actual} != ${expected}`);
6
+ constructor(actual, expected, message = "SHA mismatch") {
7
+ super(409, `${message}: ${actual} <> ${expected}`);
8
8
  this.actual = actual;
9
9
  this.expected = expected;
10
10
  }
@@ -50,6 +50,7 @@ export declare class ReadonlyTree extends TreeBase<ReadonlyTree> {
50
50
  constructor({ sha, entries }: Tree);
51
51
  get isEmpty(): boolean;
52
52
  get entries(): Array<Entry>;
53
+ get shas(): ReadonlySet<string>;
53
54
  hasSha(sha: string): boolean;
54
55
  clone(): WriteableTree;
55
56
  toJSON(): {
@@ -125,6 +125,9 @@ var ReadonlyTree = class _ReadonlyTree extends TreeBase {
125
125
  ...entry.toJSON()
126
126
  }));
127
127
  }
128
+ get shas() {
129
+ return this.#shas;
130
+ }
128
131
  hasSha(sha) {
129
132
  return this.#shas.has(sha);
130
133
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "1.4.7",
4
+ "version": "1.4.9",
5
5
  "description": "Headless git-based CMS",
6
6
  "repository": {
7
7
  "type": "git",