jazz-tools 0.11.0 → 0.11.3

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
- > jazz-tools@0.11.0 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.11.3 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -9,14 +9,14 @@
9
9
  CLI Target: es2021
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/index.js 1.50 KB
13
12
  ESM dist/testing.js 6.18 KB
14
- ESM dist/chunk-RTRX7HIO.js 119.14 KB
15
- ESM dist/index.js.map 259.00 B
13
+ ESM dist/index.js 1.50 KB
14
+ ESM dist/chunk-MVDJNBLV.js 119.45 KB
16
15
  ESM dist/testing.js.map 12.24 KB
17
- ESM dist/chunk-RTRX7HIO.js.map 283.79 KB
18
- ESM ⚡️ Build success in 46ms
16
+ ESM dist/index.js.map 259.00 B
17
+ ESM dist/chunk-MVDJNBLV.js.map 284.49 KB
18
+ ESM ⚡️ Build success in 54ms
19
19
 
20
- > jazz-tools@0.11.0 types /home/runner/_work/jazz/jazz/packages/jazz-tools
20
+ > jazz-tools@0.11.3 types /home/runner/_work/jazz/jazz/packages/jazz-tools
21
21
  > tsc --outDir dist
22
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [68b0242]
8
+ - cojson@0.11.3
9
+
10
+ ## 0.11.2
11
+
12
+ ### Patch Changes
13
+
14
+ - 6892dc6: Adds `applyDiff` to `CoList`
15
+
3
16
  ## 0.11.0
4
17
 
5
18
  ### Minor Changes
@@ -2423,6 +2423,7 @@ var FileStream = class extends CoValueBase {
2423
2423
 
2424
2424
  // src/coValues/coList.ts
2425
2425
  import { RawAccount as RawAccount5 } from "cojson";
2426
+ import { calcPatch } from "fast-myers-diff";
2426
2427
  var _CoList = class _CoList extends Array {
2427
2428
  /**
2428
2429
  * Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.
@@ -2587,12 +2588,20 @@ var _CoList = class _CoList extends Array {
2587
2588
  }
2588
2589
  let appendAfter = Math.max(start - 1, 0);
2589
2590
  for (const item of toRawItems(items, this._schema[ItemsSym])) {
2590
- console.log(this._raw.asArray(), appendAfter);
2591
2591
  this._raw.append(item, appendAfter);
2592
2592
  appendAfter++;
2593
2593
  }
2594
2594
  return deleted;
2595
2595
  }
2596
+ applyDiff(other) {
2597
+ const current = this._raw.asArray();
2598
+ const cmp = isRefEncoded(this._schema[ItemsSym]) ? (aIdx, bIdx) => current[aIdx].id === other[bIdx].id : void 0;
2599
+ for (const [from, to, insert] of [
2600
+ ...calcPatch(current, other, cmp)
2601
+ ].reverse()) {
2602
+ this.splice(from, to - from, ...insert);
2603
+ }
2604
+ }
2596
2605
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2597
2606
  toJSON(_key, seenAbove) {
2598
2607
  const itemDescriptor = this._schema[ItemsSym];
@@ -4157,4 +4166,4 @@ export {
4157
4166
  consumeInviteLink
4158
4167
  };
4159
4168
  /* istanbul ignore file -- @preserve */
4160
- //# sourceMappingURL=chunk-RTRX7HIO.js.map
4169
+ //# sourceMappingURL=chunk-MVDJNBLV.js.map