@rocicorp/zero 0.3.2024102502 → 0.3.2024102600
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/out/{chunk-2RUT5EQV.js → chunk-F5QR3K72.js} +2 -7
- package/out/chunk-F5QR3K72.js.map +7 -0
- package/out/chunk-HARIWJ2J.js +8 -0
- package/out/{chunk-2RUT5EQV.js.map → chunk-HARIWJ2J.js.map} +1 -1
- package/out/chunk-NKGIR6IA.js +1 -0
- package/out/chunk-NKGIR6IA.js.map +7 -0
- package/out/chunk-RCVGGCMG.js +288 -0
- package/out/chunk-RCVGGCMG.js.map +7 -0
- package/out/internal.js +9 -0
- package/out/internal.js.map +7 -0
- package/out/react.js +2 -1
- package/out/react.js.map +1 -1
- package/out/replicache/src/version.d.ts.map +1 -1
- package/out/replicache/src/version.js +2 -1
- package/out/replicache/src/version.js.map +1 -1
- package/out/solid.js +82 -0
- package/out/solid.js.map +7 -0
- package/out/zero/src/internal.d.ts +2 -0
- package/out/zero/src/internal.d.ts.map +1 -0
- package/out/zero/src/solid.d.ts +2 -0
- package/out/zero/src/solid.d.ts.map +1 -0
- package/out/zero-cache/src/config/config-query.d.ts +1 -1
- package/out/zero-cache/src/config/config-query.d.ts.map +1 -1
- package/out/zero-cache/src/server/life-cycle.d.ts +1 -0
- package/out/zero-cache/src/server/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/server/life-cycle.js +10 -9
- package/out/zero-cache/src/server/life-cycle.js.map +1 -1
- package/out/zero-cache/src/server/main.js +2 -0
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/task-state-watcher.d.ts +14 -0
- package/out/zero-cache/src/server/task-state-watcher.d.ts.map +1 -0
- package/out/zero-cache/src/server/task-state-watcher.js +75 -0
- package/out/zero-cache/src/server/task-state-watcher.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +10 -4
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-client/src/client/version.d.ts.map +1 -1
- package/out/zero-client/src/client/version.js +2 -1
- package/out/zero-client/src/client/version.js.map +1 -1
- package/out/zero-internal/src/mod.d.ts +7 -0
- package/out/zero-internal/src/mod.d.ts.map +1 -0
- package/out/zero-solid/src/mod.d.ts +2 -0
- package/out/zero-solid/src/mod.d.ts.map +1 -0
- package/out/zero-solid/src/solid-view.d.ts +10 -0
- package/out/zero-solid/src/solid-view.d.ts.map +1 -0
- package/out/zero-solid/src/use-query.d.ts +5 -0
- package/out/zero-solid/src/use-query.d.ts.map +1 -0
- package/out/zero.js +25 -279
- package/out/zero.js.map +4 -4
- package/out/zql/src/zql/ivm/array-view.d.ts +1 -10
- package/out/zql/src/zql/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/zql/ivm/array-view.js +2 -158
- package/out/zql/src/zql/ivm/array-view.js.map +1 -1
- package/out/zql/src/zql/ivm/view-apply-change.d.ts +5 -0
- package/out/zql/src/zql/ivm/view-apply-change.d.ts.map +1 -0
- package/out/zql/src/zql/ivm/view-apply-change.js +156 -0
- package/out/zql/src/zql/ivm/view-apply-change.js.map +1 -0
- package/out/zql/src/zql/ivm/view.d.ts +15 -0
- package/out/zql/src/zql/ivm/view.d.ts.map +1 -0
- package/out/zql/src/zql/ivm/view.js +2 -0
- package/out/zql/src/zql/ivm/view.js.map +1 -0
- package/out/zql/src/zql/query/query-impl.d.ts +4 -5
- package/out/zql/src/zql/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/zql/query/query-impl.js +8 -3
- package/out/zql/src/zql/query/query-impl.js.map +1 -1
- package/out/zql/src/zql/query/query.d.ts +2 -2
- package/out/zql/src/zql/query/query.d.ts.map +1 -1
- package/package.json +9 -1
package/out/zero.js
CHANGED
|
@@ -1,74 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__export,
|
|
3
|
-
__reExport,
|
|
4
2
|
hasOwn
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HARIWJ2J.js";
|
|
4
|
+
import {
|
|
5
|
+
applyChange,
|
|
6
|
+
assert,
|
|
7
|
+
assertArray,
|
|
8
|
+
assertBoolean,
|
|
9
|
+
assertNotNull,
|
|
10
|
+
assertNotUndefined,
|
|
11
|
+
assertNumber,
|
|
12
|
+
assertObject,
|
|
13
|
+
assertString,
|
|
14
|
+
must,
|
|
15
|
+
throwInvalidType,
|
|
16
|
+
unreachable
|
|
17
|
+
} from "./chunk-RCVGGCMG.js";
|
|
18
|
+
import {
|
|
19
|
+
__export,
|
|
20
|
+
__reExport
|
|
21
|
+
} from "./chunk-F5QR3K72.js";
|
|
6
22
|
|
|
7
23
|
// ../replicache/src/mod.ts
|
|
8
24
|
import { consoleLogSink as consoleLogSink3 } from "@rocicorp/logger";
|
|
9
25
|
|
|
10
|
-
// ../shared/src/asserts.ts
|
|
11
|
-
function assert(b, msg = "Assertion failed") {
|
|
12
|
-
if (!b) {
|
|
13
|
-
throw new Error(msg);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function assertString(v2) {
|
|
17
|
-
assertType(v2, "string");
|
|
18
|
-
}
|
|
19
|
-
function assertNumber(v2) {
|
|
20
|
-
assertType(v2, "number");
|
|
21
|
-
}
|
|
22
|
-
function assertBoolean(v2) {
|
|
23
|
-
assertType(v2, "boolean");
|
|
24
|
-
}
|
|
25
|
-
function assertType(v2, t2) {
|
|
26
|
-
if (typeof v2 !== t2) {
|
|
27
|
-
throwInvalidType(v2, t2);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function assertObject(v2) {
|
|
31
|
-
if (v2 === null) {
|
|
32
|
-
throwInvalidType(v2, "object");
|
|
33
|
-
}
|
|
34
|
-
assertType(v2, "object");
|
|
35
|
-
}
|
|
36
|
-
function assertArray(v2) {
|
|
37
|
-
if (!Array.isArray(v2)) {
|
|
38
|
-
throwInvalidType(v2, "array");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function invalidType(v2, t2) {
|
|
42
|
-
let s = "Invalid type: ";
|
|
43
|
-
if (v2 === null || v2 === void 0) {
|
|
44
|
-
s += v2;
|
|
45
|
-
} else {
|
|
46
|
-
s += `${typeof v2} \`${v2}\``;
|
|
47
|
-
}
|
|
48
|
-
return s + `, expected ${t2}`;
|
|
49
|
-
}
|
|
50
|
-
function throwInvalidType(v2, t2) {
|
|
51
|
-
throw new Error(invalidType(v2, t2));
|
|
52
|
-
}
|
|
53
|
-
function assertNotNull(v2) {
|
|
54
|
-
if (v2 === null) {
|
|
55
|
-
throw new Error("Expected non-null value");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function assertUndefined(v2, msg = "Expected undefined value") {
|
|
59
|
-
if (v2 !== void 0) {
|
|
60
|
-
throw new Error(msg);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function assertNotUndefined(v2, msg = "Expected non undefined value") {
|
|
64
|
-
if (v2 === void 0) {
|
|
65
|
-
throw new Error(msg);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function unreachable(_) {
|
|
69
|
-
throw new Error("Unreachable");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
26
|
// ../shared/src/config.ts
|
|
73
27
|
var isProd = process.env.NODE_ENV === "production";
|
|
74
28
|
|
|
@@ -9227,14 +9181,6 @@ async function anyPendingMutationsInClientGroups(perdag) {
|
|
|
9227
9181
|
// ../zql/src/zql/query/query-impl.ts
|
|
9228
9182
|
import { resolver as resolver7 } from "@rocicorp/resolver";
|
|
9229
9183
|
|
|
9230
|
-
// ../shared/src/must.ts
|
|
9231
|
-
function must(v2, msg) {
|
|
9232
|
-
if (v2 == null) {
|
|
9233
|
-
throw new Error(msg ?? `Unexpected ${v2} value`);
|
|
9234
|
-
}
|
|
9235
|
-
return v2;
|
|
9236
|
-
}
|
|
9237
|
-
|
|
9238
9184
|
// ../zql/src/zql/ivm/maybe-split-and-push-edit-change.ts
|
|
9239
9185
|
function maybeSplitAndPushEditChange(change, predicate, output) {
|
|
9240
9186
|
const oldWasPresent = predicate(change.oldRow);
|
|
@@ -10437,7 +10383,6 @@ var ArrayView = class {
|
|
|
10437
10383
|
this.#format = format;
|
|
10438
10384
|
this.#input.setOutput(this);
|
|
10439
10385
|
this.#root = { "": format.singular ? void 0 : [] };
|
|
10440
|
-
assertOrderingIncludesPK(this.#schema.sort, this.#schema.primaryKey);
|
|
10441
10386
|
this.#hydrate();
|
|
10442
10387
|
}
|
|
10443
10388
|
get data() {
|
|
@@ -10457,7 +10402,6 @@ var ArrayView = class {
|
|
|
10457
10402
|
}
|
|
10458
10403
|
}
|
|
10459
10404
|
destroy() {
|
|
10460
|
-
this.#input.destroy();
|
|
10461
10405
|
this.onDestroy?.();
|
|
10462
10406
|
}
|
|
10463
10407
|
#hydrate() {
|
|
@@ -10485,207 +10429,6 @@ var ArrayView = class {
|
|
|
10485
10429
|
this.#fireListeners();
|
|
10486
10430
|
}
|
|
10487
10431
|
};
|
|
10488
|
-
function applyChange(parentEntry, change, schema, relationship, format) {
|
|
10489
|
-
if (schema.isHidden) {
|
|
10490
|
-
switch (change.type) {
|
|
10491
|
-
case "add":
|
|
10492
|
-
case "remove":
|
|
10493
|
-
for (const [relationship2, children] of Object.entries(
|
|
10494
|
-
change.node.relationships
|
|
10495
|
-
)) {
|
|
10496
|
-
const childSchema = must(schema.relationships[relationship2]);
|
|
10497
|
-
for (const node of children) {
|
|
10498
|
-
applyChange(
|
|
10499
|
-
parentEntry,
|
|
10500
|
-
{ type: change.type, node },
|
|
10501
|
-
childSchema,
|
|
10502
|
-
relationship2,
|
|
10503
|
-
format
|
|
10504
|
-
);
|
|
10505
|
-
}
|
|
10506
|
-
}
|
|
10507
|
-
return;
|
|
10508
|
-
case "edit":
|
|
10509
|
-
return;
|
|
10510
|
-
case "child": {
|
|
10511
|
-
const childSchema = must(
|
|
10512
|
-
schema.relationships[change.child.relationshipName]
|
|
10513
|
-
);
|
|
10514
|
-
applyChange(
|
|
10515
|
-
parentEntry,
|
|
10516
|
-
change.child.change,
|
|
10517
|
-
childSchema,
|
|
10518
|
-
relationship,
|
|
10519
|
-
format
|
|
10520
|
-
);
|
|
10521
|
-
return;
|
|
10522
|
-
}
|
|
10523
|
-
default:
|
|
10524
|
-
unreachable(change);
|
|
10525
|
-
}
|
|
10526
|
-
}
|
|
10527
|
-
const { singular, relationships: childFormats } = format;
|
|
10528
|
-
switch (change.type) {
|
|
10529
|
-
case "add": {
|
|
10530
|
-
const newEntry = {
|
|
10531
|
-
...change.node.row
|
|
10532
|
-
};
|
|
10533
|
-
if (singular) {
|
|
10534
|
-
assertUndefined(
|
|
10535
|
-
parentEntry[relationship],
|
|
10536
|
-
"single output already exists"
|
|
10537
|
-
);
|
|
10538
|
-
parentEntry[relationship] = newEntry;
|
|
10539
|
-
} else {
|
|
10540
|
-
const view = parentEntry[relationship];
|
|
10541
|
-
assertArray(view);
|
|
10542
|
-
const { pos, found } = binarySearch3(view, newEntry, schema.compareRows);
|
|
10543
|
-
assert(!found, "node already exists");
|
|
10544
|
-
view.splice(pos, 0, newEntry);
|
|
10545
|
-
}
|
|
10546
|
-
for (const [relationship2, children] of Object.entries(
|
|
10547
|
-
change.node.relationships
|
|
10548
|
-
)) {
|
|
10549
|
-
const childSchema = must(schema.relationships[relationship2]);
|
|
10550
|
-
const childFormat = must(childFormats[relationship2]);
|
|
10551
|
-
const newView = childFormat.singular ? void 0 : [];
|
|
10552
|
-
newEntry[relationship2] = newView;
|
|
10553
|
-
for (const node of children) {
|
|
10554
|
-
applyChange(
|
|
10555
|
-
newEntry,
|
|
10556
|
-
{ type: "add", node },
|
|
10557
|
-
childSchema,
|
|
10558
|
-
relationship2,
|
|
10559
|
-
childFormat
|
|
10560
|
-
);
|
|
10561
|
-
}
|
|
10562
|
-
}
|
|
10563
|
-
break;
|
|
10564
|
-
}
|
|
10565
|
-
case "remove": {
|
|
10566
|
-
if (singular) {
|
|
10567
|
-
assertObject(parentEntry[relationship]);
|
|
10568
|
-
parentEntry[relationship] = void 0;
|
|
10569
|
-
} else {
|
|
10570
|
-
assertArray(parentEntry[relationship]);
|
|
10571
|
-
const view = parentEntry[relationship];
|
|
10572
|
-
const { pos, found } = binarySearch3(
|
|
10573
|
-
view,
|
|
10574
|
-
change.node.row,
|
|
10575
|
-
schema.compareRows
|
|
10576
|
-
);
|
|
10577
|
-
assert(found, "node does not exist");
|
|
10578
|
-
view.splice(pos, 1);
|
|
10579
|
-
}
|
|
10580
|
-
break;
|
|
10581
|
-
}
|
|
10582
|
-
case "child": {
|
|
10583
|
-
let existing;
|
|
10584
|
-
if (singular) {
|
|
10585
|
-
assertObject(parentEntry[relationship]);
|
|
10586
|
-
existing = parentEntry[relationship];
|
|
10587
|
-
} else {
|
|
10588
|
-
assertArray(parentEntry[relationship]);
|
|
10589
|
-
const list = parentEntry[relationship];
|
|
10590
|
-
const { pos, found } = binarySearch3(list, change.row, schema.compareRows);
|
|
10591
|
-
assert(found, "node does not exist");
|
|
10592
|
-
existing = list[pos];
|
|
10593
|
-
}
|
|
10594
|
-
const childSchema = must(
|
|
10595
|
-
schema.relationships[change.child.relationshipName]
|
|
10596
|
-
);
|
|
10597
|
-
const childFormat = must(
|
|
10598
|
-
format.relationships[change.child.relationshipName]
|
|
10599
|
-
);
|
|
10600
|
-
applyChange(
|
|
10601
|
-
existing,
|
|
10602
|
-
change.child.change,
|
|
10603
|
-
childSchema,
|
|
10604
|
-
change.child.relationshipName,
|
|
10605
|
-
childFormat
|
|
10606
|
-
);
|
|
10607
|
-
break;
|
|
10608
|
-
}
|
|
10609
|
-
case "edit": {
|
|
10610
|
-
if (singular) {
|
|
10611
|
-
assertObject(parentEntry[relationship]);
|
|
10612
|
-
parentEntry[relationship] = {
|
|
10613
|
-
...parentEntry[relationship],
|
|
10614
|
-
...change.row
|
|
10615
|
-
};
|
|
10616
|
-
} else {
|
|
10617
|
-
assertArray(parentEntry[relationship]);
|
|
10618
|
-
const view = parentEntry[relationship];
|
|
10619
|
-
if (schema.compareRows(change.oldRow, change.row) === 0) {
|
|
10620
|
-
const { pos, found } = binarySearch3(
|
|
10621
|
-
view,
|
|
10622
|
-
change.oldRow,
|
|
10623
|
-
schema.compareRows
|
|
10624
|
-
);
|
|
10625
|
-
assert(found, "node does not exists");
|
|
10626
|
-
view[pos] = makeEntryPreserveRelationships(
|
|
10627
|
-
change.row,
|
|
10628
|
-
view[pos],
|
|
10629
|
-
schema.relationships
|
|
10630
|
-
);
|
|
10631
|
-
} else {
|
|
10632
|
-
const { pos, found } = binarySearch3(
|
|
10633
|
-
view,
|
|
10634
|
-
change.oldRow,
|
|
10635
|
-
schema.compareRows
|
|
10636
|
-
);
|
|
10637
|
-
assert(found, "node does not exists");
|
|
10638
|
-
const oldEntry = view[pos];
|
|
10639
|
-
view.splice(pos, 1);
|
|
10640
|
-
{
|
|
10641
|
-
const { pos: pos2, found: found2 } = binarySearch3(
|
|
10642
|
-
view,
|
|
10643
|
-
change.row,
|
|
10644
|
-
schema.compareRows
|
|
10645
|
-
);
|
|
10646
|
-
assert(!found2, "node already exists");
|
|
10647
|
-
view.splice(
|
|
10648
|
-
pos2,
|
|
10649
|
-
0,
|
|
10650
|
-
makeEntryPreserveRelationships(
|
|
10651
|
-
change.row,
|
|
10652
|
-
oldEntry,
|
|
10653
|
-
schema.relationships
|
|
10654
|
-
)
|
|
10655
|
-
);
|
|
10656
|
-
}
|
|
10657
|
-
}
|
|
10658
|
-
}
|
|
10659
|
-
break;
|
|
10660
|
-
}
|
|
10661
|
-
default:
|
|
10662
|
-
unreachable(change);
|
|
10663
|
-
}
|
|
10664
|
-
}
|
|
10665
|
-
function binarySearch3(view, target, comparator) {
|
|
10666
|
-
let low = 0;
|
|
10667
|
-
let high = view.length - 1;
|
|
10668
|
-
while (low <= high) {
|
|
10669
|
-
const mid = low + high >>> 1;
|
|
10670
|
-
const comparison = comparator(view[mid], target);
|
|
10671
|
-
if (comparison < 0) {
|
|
10672
|
-
low = mid + 1;
|
|
10673
|
-
} else if (comparison > 0) {
|
|
10674
|
-
high = mid - 1;
|
|
10675
|
-
} else {
|
|
10676
|
-
return { pos: mid, found: true };
|
|
10677
|
-
}
|
|
10678
|
-
}
|
|
10679
|
-
return { pos: low, found: false };
|
|
10680
|
-
}
|
|
10681
|
-
function makeEntryPreserveRelationships(row, entry, relationships) {
|
|
10682
|
-
const result = { ...row };
|
|
10683
|
-
for (const relationship in relationships) {
|
|
10684
|
-
assert(!(relationship in row), "Relationship already exists");
|
|
10685
|
-
result[relationship] = entry[relationship];
|
|
10686
|
-
}
|
|
10687
|
-
return result;
|
|
10688
|
-
}
|
|
10689
10432
|
|
|
10690
10433
|
// ../shared/src/sorted-entries.ts
|
|
10691
10434
|
function sortedEntries(object16) {
|
|
@@ -11087,12 +10830,15 @@ var QueryImpl = class extends AbstractQuery {
|
|
|
11087
10830
|
const ast = this._completeAst();
|
|
11088
10831
|
const removeServerQuery = this.#delegate.addServerQuery(ast);
|
|
11089
10832
|
const input = buildPipeline(ast, this.#delegate, void 0);
|
|
10833
|
+
const schema = input.getSchema();
|
|
10834
|
+
assertOrderingIncludesPK(schema.sort, schema.primaryKey);
|
|
11090
10835
|
let removeCommitObserver;
|
|
11091
10836
|
const onDestroy = () => {
|
|
10837
|
+
input.destroy();
|
|
11092
10838
|
removeCommitObserver?.();
|
|
11093
10839
|
removeServerQuery();
|
|
11094
10840
|
};
|
|
11095
|
-
const view = (factory ??
|
|
10841
|
+
const view = (factory ?? arrayViewFactory)(
|
|
11096
10842
|
this,
|
|
11097
10843
|
input,
|
|
11098
10844
|
this.#format,
|
|
@@ -11138,7 +10884,7 @@ function addPrimaryKeysToAst(schema, ast) {
|
|
|
11138
10884
|
orderBy: addPrimaryKeys(schema, ast.orderBy)
|
|
11139
10885
|
};
|
|
11140
10886
|
}
|
|
11141
|
-
function
|
|
10887
|
+
function arrayViewFactory(_query, input, format, onDestroy, onTransactionCommit) {
|
|
11142
10888
|
const v2 = new ArrayView(input, format);
|
|
11143
10889
|
v2.onDestroy = onDestroy;
|
|
11144
10890
|
onTransactionCommit(() => {
|
|
@@ -14300,7 +14046,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
14300
14046
|
}
|
|
14301
14047
|
|
|
14302
14048
|
// ../zero-client/src/client/version.ts
|
|
14303
|
-
var version2 = "0.
|
|
14049
|
+
var version2 = "0.3.2024102600+0464d7";
|
|
14304
14050
|
|
|
14305
14051
|
// ../zero-client/src/client/log-options.ts
|
|
14306
14052
|
var LevelFilterLogSink = class {
|