jazz-tools 0.11.2 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-MVDJNBLV.js → chunk-IOK4K3XC.js} +64 -12
- package/dist/chunk-IOK4K3XC.js.map +1 -0
- package/dist/coValues/coFeed.d.ts +2 -1
- package/dist/coValues/coFeed.d.ts.map +1 -1
- package/dist/coValues/coList.d.ts +15 -2
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coMap.d.ts +2 -1
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coFeed.ts +2 -1
- package/src/coValues/coList.ts +77 -13
- package/src/coValues/coMap.ts +7 -2
- package/src/tests/coList.test.ts +313 -6
- package/src/tests/schemaUnion.test.ts +2 -1
- package/dist/chunk-MVDJNBLV.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.11.
|
2
|
+
> jazz-tools@0.11.4 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup && pnpm types
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -10,13 +10,13 @@
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.js [22m[32m1.50 KB[39m
|
13
|
-
[32mESM[39m [1mdist/chunk-MVDJNBLV.js [22m[32m119.45 KB[39m
|
14
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.18 KB[39m
|
14
|
+
[32mESM[39m [1mdist/chunk-IOK4K3XC.js [22m[32m120.99 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m259.00 B[39m
|
16
|
-
[32mESM[39m [1mdist/chunk-MVDJNBLV.js.map [22m[32m284.49 KB[39m
|
17
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.24 KB[39m
|
18
|
-
[32mESM[39m
|
17
|
+
[32mESM[39m [1mdist/chunk-IOK4K3XC.js.map [22m[32m287.57 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
19
19
|
|
20
|
-
> jazz-tools@0.11.
|
20
|
+
> jazz-tools@0.11.4 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
21
21
|
> tsc --outDir dist
|
22
22
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.11.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 57a3dbe: Throw when assigning invalid values to ref fields
|
8
|
+
- a717754: Use RegisteredAccount types for `by` props
|
9
|
+
- a91f343: Fixes coList.splice to handle insertions at start of list
|
10
|
+
- Updated dependencies [7f036c1]
|
11
|
+
- cojson@0.11.4
|
12
|
+
|
13
|
+
## 0.11.3
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- Updated dependencies [68b0242]
|
18
|
+
- cojson@0.11.3
|
19
|
+
|
3
20
|
## 0.11.2
|
4
21
|
|
5
22
|
### Patch Changes
|
@@ -1511,9 +1511,13 @@ var CoMapProxyHandler = {
|
|
1511
1511
|
} else {
|
1512
1512
|
throw new Error(`Cannot set required reference ${key} to null`);
|
1513
1513
|
}
|
1514
|
-
} else {
|
1514
|
+
} else if (value?.id) {
|
1515
1515
|
target._raw.set(key, value.id);
|
1516
1516
|
subscriptionsScopes.get(target)?.onRefAccessedOrSet(target.id, value.id);
|
1517
|
+
} else {
|
1518
|
+
throw new Error(
|
1519
|
+
`Cannot set reference ${key} to a non-CoValue. Got ${value}`
|
1520
|
+
);
|
1517
1521
|
}
|
1518
1522
|
}
|
1519
1523
|
return true;
|
@@ -2581,24 +2585,60 @@ var _CoList = class _CoList extends Array {
|
|
2581
2585
|
this._raw.delete(0);
|
2582
2586
|
return first;
|
2583
2587
|
}
|
2588
|
+
/**
|
2589
|
+
* Splice the `CoList` at a given index.
|
2590
|
+
*
|
2591
|
+
* @param start - The index to start the splice.
|
2592
|
+
* @param deleteCount - The number of items to delete.
|
2593
|
+
* @param items - The items to insert.
|
2594
|
+
*/
|
2584
2595
|
splice(start, deleteCount, ...items) {
|
2585
2596
|
const deleted = this.slice(start, start + deleteCount);
|
2586
2597
|
for (let idxToDelete = start + deleteCount - 1; idxToDelete >= start; idxToDelete--) {
|
2587
2598
|
this._raw.delete(idxToDelete);
|
2588
2599
|
}
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2600
|
+
const rawItems = toRawItems(items, this._schema[ItemsSym]);
|
2601
|
+
if (rawItems.length === 0) {
|
2602
|
+
return deleted;
|
2603
|
+
}
|
2604
|
+
if (rawItems.length === 1) {
|
2605
|
+
const item = rawItems[0];
|
2606
|
+
if (item === void 0) return deleted;
|
2607
|
+
if (start === 0) {
|
2608
|
+
this._raw.prepend(item);
|
2609
|
+
} else {
|
2610
|
+
this._raw.append(item, Math.max(start - 1, 0));
|
2611
|
+
}
|
2612
|
+
return deleted;
|
2613
|
+
}
|
2614
|
+
if (start === 0) {
|
2615
|
+
for (let i = rawItems.length - 1; i >= 0; i--) {
|
2616
|
+
const item = rawItems[i];
|
2617
|
+
if (item === void 0) continue;
|
2618
|
+
this._raw.prepend(item);
|
2619
|
+
}
|
2620
|
+
} else {
|
2621
|
+
let appendAfter = Math.max(start - 1, 0);
|
2622
|
+
for (const item of rawItems) {
|
2623
|
+
if (item === void 0) continue;
|
2624
|
+
this._raw.append(item, appendAfter);
|
2625
|
+
appendAfter++;
|
2626
|
+
}
|
2593
2627
|
}
|
2594
2628
|
return deleted;
|
2595
2629
|
}
|
2596
|
-
|
2630
|
+
/**
|
2631
|
+
* Modify the `CoList` to match another list, where the changes are managed internally.
|
2632
|
+
*
|
2633
|
+
* @param result - The resolved list of items.
|
2634
|
+
*/
|
2635
|
+
applyDiff(result) {
|
2597
2636
|
const current = this._raw.asArray();
|
2598
|
-
const
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2637
|
+
const comparator = isRefEncoded(this._schema[ItemsSym]) ? (aIdx, bIdx) => {
|
2638
|
+
return current[aIdx]?.id === result[bIdx]?.id;
|
2639
|
+
} : void 0;
|
2640
|
+
const patches = [...calcPatch(current, result, comparator)];
|
2641
|
+
for (const [from, to, insert] of patches.reverse()) {
|
2602
2642
|
this.splice(from, to - from, ...insert);
|
2603
2643
|
}
|
2604
2644
|
}
|
@@ -2728,7 +2768,19 @@ var CoListProxyHandler = {
|
|
2728
2768
|
} else if ("encoded" in itemDescriptor) {
|
2729
2769
|
rawValue = itemDescriptor.encoded.encode(value);
|
2730
2770
|
} else if (isRefEncoded(itemDescriptor)) {
|
2731
|
-
|
2771
|
+
if (value === null) {
|
2772
|
+
if (itemDescriptor.optional) {
|
2773
|
+
rawValue = null;
|
2774
|
+
} else {
|
2775
|
+
throw new Error(`Cannot set required reference ${key} to null`);
|
2776
|
+
}
|
2777
|
+
} else if (value?.id) {
|
2778
|
+
rawValue = value.id;
|
2779
|
+
} else {
|
2780
|
+
throw new Error(
|
2781
|
+
`Cannot set reference ${key} to a non-CoValue. Got ${value}`
|
2782
|
+
);
|
2783
|
+
}
|
2732
2784
|
}
|
2733
2785
|
target._raw.replace(Number(key), rawValue);
|
2734
2786
|
return true;
|
@@ -4166,4 +4218,4 @@ export {
|
|
4166
4218
|
consumeInviteLink
|
4167
4219
|
};
|
4168
4220
|
/* istanbul ignore file -- @preserve */
|
4169
|
-
//# sourceMappingURL=chunk-
|
4221
|
+
//# sourceMappingURL=chunk-IOK4K3XC.js.map
|