mindoodb 0.1.7 → 0.1.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.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `Automerge.applyChanges` in slices of bounded size.
3
+ *
4
+ * Automerge 3.5 applies one `applyChanges` call as a single batch, and the
5
+ * batch's working memory grows much faster than the changes it holds. A
6
+ * document whose changes each rewrite about a megabyte of text (16 changes,
7
+ * 16 MB) panics with "capacity overflow" in Node and runs the WebAssembly
8
+ * instance out of memory in WebKit. After that panic the Automerge instance is
9
+ * dead for the rest of the page ("Module terminated"), so every other document
10
+ * fails as well — and since the same document is loaded on every start, the
11
+ * failure comes back after each restart. Applied one megabyte at a time, the
12
+ * same changes load without trouble.
13
+ *
14
+ * Small batches, the normal case, still go through one call. Automerge keeps
15
+ * changes whose dependencies are still missing in its queue between calls, so
16
+ * the slices need not be in causal order.
17
+ */
18
+ import type * as AutomergeTypes from "@automerge/automerge/slim";
19
+ /** Upper bound for the change bytes handed to one `applyChanges` call. */
20
+ export declare const APPLY_CHANGES_SLICE_BYTES: number;
21
+ /**
22
+ * Apply `changes` to `doc` like `Automerge.applyChanges`, but in slices of at
23
+ * most `maxSliceBytes` (a single larger change gets a slice of its own).
24
+ *
25
+ * @returns The document after all slices, as `applyChanges` returns it.
26
+ */
27
+ export declare function applyChangesInSlices<T>(doc: AutomergeTypes.Doc<T>, changes: readonly Uint8Array[], maxSliceBytes?: number): AutomergeTypes.Doc<T>;
28
+ //# sourceMappingURL=applyChangesInSlices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyChangesInSlices.d.ts","sourceRoot":"","sources":["../../src/core/applyChangesInSlices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAIjE,0EAA0E;AAC1E,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAC1B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,aAAa,GAAE,MAAkC,GAChD,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAmBvB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPLY_CHANGES_SLICE_BYTES = void 0;
4
+ exports.applyChangesInSlices = applyChangesInSlices;
5
+ const automerge_adapter_1 = require("./automerge-adapter");
6
+ /** Upper bound for the change bytes handed to one `applyChanges` call. */
7
+ exports.APPLY_CHANGES_SLICE_BYTES = 2 * 1024 * 1024;
8
+ /**
9
+ * Apply `changes` to `doc` like `Automerge.applyChanges`, but in slices of at
10
+ * most `maxSliceBytes` (a single larger change gets a slice of its own).
11
+ *
12
+ * @returns The document after all slices, as `applyChanges` returns it.
13
+ */
14
+ function applyChangesInSlices(doc, changes, maxSliceBytes = exports.APPLY_CHANGES_SLICE_BYTES) {
15
+ let current = doc;
16
+ let slice = [];
17
+ let sliceBytes = 0;
18
+ const flush = () => {
19
+ if (slice.length === 0)
20
+ return;
21
+ [current] = automerge_adapter_1.Automerge.applyChanges(current, slice);
22
+ slice = [];
23
+ sliceBytes = 0;
24
+ };
25
+ for (const change of changes) {
26
+ if (slice.length > 0 && sliceBytes + change.byteLength > maxSliceBytes) {
27
+ flush();
28
+ }
29
+ slice.push(change);
30
+ sliceBytes += change.byteLength;
31
+ }
32
+ flush();
33
+ return current;
34
+ }
35
+ //# sourceMappingURL=applyChangesInSlices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyChangesInSlices.js","sourceRoot":"","sources":["../../src/core/applyChangesInSlices.ts"],"names":[],"mappings":";;;AA8BA,oDAuBC;AAlCD,2DAAgD;AAEhD,0EAA0E;AAC7D,QAAA,yBAAyB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzD;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,GAA0B,EAC1B,OAA8B,EAC9B,gBAAwB,iCAAyB;IAEjD,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,IAAI,KAAK,GAAiB,EAAE,CAAC;IAC7B,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC/B,CAAC,OAAO,CAAC,GAAG,6BAAS,CAAC,YAAY,CAAI,OAAO,EAAE,KAAK,CAAC,CAAC;QACtD,KAAK,GAAG,EAAE,CAAC;QACX,UAAU,GAAG,CAAC,CAAC;IACjB,CAAC,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,GAAG,MAAM,CAAC,UAAU,GAAG,aAAa,EAAE,CAAC;YACvE,KAAK,EAAE,CAAC;QACV,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC;IAClC,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindoodb",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "engines": {
5
5
  "node": ">=22.13.0"
6
6
  },