tinybase 6.2.0-beta.3 → 6.2.0
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/@types/common/index.d.ts +295 -0
- package/@types/common/with-schemas/index.d.ts +375 -0
- package/@types/mergeable-store/index.d.ts +5 -34
- package/@types/mergeable-store/with-schemas/index.d.ts +5 -34
- package/@types/omni/with-schemas/index.d.ts +3 -3
- package/common/index.js +62 -3
- package/common/with-schemas/index.js +62 -3
- package/index.js +133 -86
- package/mergeable-store/index.js +102 -94
- package/mergeable-store/with-schemas/index.js +102 -94
- package/min/common/index.js +1 -1
- package/min/common/index.js.gz +0 -0
- package/min/common/with-schemas/index.js +1 -1
- package/min/common/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +148 -101
- package/omni/with-schemas/index.js +148 -101
- package/package.json +3 -3
- package/persisters/index.js +9 -9
- package/persisters/persister-durable-object-storage/index.js +12 -12
- package/persisters/persister-durable-object-storage/with-schemas/index.js +12 -12
- package/persisters/persister-pglite/index.js +11 -11
- package/persisters/persister-pglite/with-schemas/index.js +11 -11
- package/persisters/persister-postgres/index.js +11 -11
- package/persisters/persister-postgres/with-schemas/index.js +11 -11
- package/persisters/with-schemas/index.js +9 -9
- package/readme.md +2 -2
- package/releases.md +9 -10
- package/store/index.js +4 -4
- package/store/with-schemas/index.js +4 -4
- package/synchronizers/index.js +7 -7
- package/synchronizers/synchronizer-broadcast-channel/index.js +7 -7
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +7 -7
- package/synchronizers/synchronizer-local/index.js +7 -7
- package/synchronizers/synchronizer-local/with-schemas/index.js +7 -7
- package/synchronizers/synchronizer-ws-client/index.js +7 -7
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +7 -7
- package/synchronizers/synchronizer-ws-server/index.js +7 -7
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +7 -7
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +7 -7
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +7 -7
- package/synchronizers/with-schemas/index.js +7 -7
- package/ui-react-inspector/index.js +1 -1
- package/ui-react-inspector/with-schemas/index.js +1 -1
- package/with-schemas/index.js +133 -86
package/index.js
CHANGED
|
@@ -118,8 +118,8 @@ const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
|
|
|
118
118
|
|
|
119
119
|
const object = Object;
|
|
120
120
|
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
121
|
-
const objEntries = object.entries;
|
|
122
121
|
const objFrozen = object.isFrozen;
|
|
122
|
+
const objEntries = object.entries;
|
|
123
123
|
const isObject = (obj) =>
|
|
124
124
|
!isUndefined(obj) &&
|
|
125
125
|
ifNotUndefined(
|
|
@@ -785,16 +785,56 @@ const getUniqueId = (length = 16) =>
|
|
|
785
785
|
'',
|
|
786
786
|
);
|
|
787
787
|
|
|
788
|
+
const jsonString = JSON.stringify;
|
|
789
|
+
const jsonParse = JSON.parse;
|
|
790
|
+
const jsonStringWithMap = (obj) =>
|
|
791
|
+
jsonString(obj, (_key, value) =>
|
|
792
|
+
isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
|
|
793
|
+
);
|
|
794
|
+
|
|
788
795
|
const textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();
|
|
789
|
-
const getHash = (
|
|
796
|
+
const getHash = (string) => {
|
|
790
797
|
let hash = 2166136261;
|
|
791
|
-
arrayForEach(textEncoder.encode(
|
|
798
|
+
arrayForEach(textEncoder.encode(string), (char) => {
|
|
792
799
|
hash ^= char;
|
|
793
800
|
hash +=
|
|
794
801
|
(hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
795
802
|
});
|
|
796
803
|
return hash >>> 0;
|
|
797
804
|
};
|
|
805
|
+
const addOrRemoveHash = (hash1, hash2) => (hash1 ^ hash2) >>> 0;
|
|
806
|
+
const getValuesHash = (valueHashes) =>
|
|
807
|
+
arrayReduce(
|
|
808
|
+
objEntries(valueHashes),
|
|
809
|
+
(valuesHash, [valueId, valueHash]) =>
|
|
810
|
+
addOrRemoveHash(
|
|
811
|
+
valuesHash,
|
|
812
|
+
getValueInValuesHash(valueId, valueHash) ^
|
|
813
|
+
getValueInValuesHash(valueId, 0),
|
|
814
|
+
// legacy v5; remove in v7
|
|
815
|
+
),
|
|
816
|
+
0,
|
|
817
|
+
// legacy v5; valuesHlc in v7?
|
|
818
|
+
);
|
|
819
|
+
const getValueInValuesHash = (valueId, valueHash) =>
|
|
820
|
+
getHash(valueId + ':' + valueHash);
|
|
821
|
+
const getValueHash = (value, valueHlc) =>
|
|
822
|
+
getHash(jsonStringWithMap(value ?? null) + ':' + valueHlc);
|
|
823
|
+
const getCellHash = getValueHash;
|
|
824
|
+
const getCellInRowHash = getValueInValuesHash;
|
|
825
|
+
const getRowHash = getValuesHash;
|
|
826
|
+
const getRowInTableHash = getValueInValuesHash;
|
|
827
|
+
const getTableHash = (rowHashes) =>
|
|
828
|
+
// alias to getValuesHash in v7
|
|
829
|
+
arrayReduce(
|
|
830
|
+
objEntries(rowHashes),
|
|
831
|
+
(valuesHash, [rowId, rowHash]) =>
|
|
832
|
+
addOrRemoveHash(valuesHash, getValueInValuesHash(rowId, rowHash)),
|
|
833
|
+
0,
|
|
834
|
+
// legacy v5; rowHlc in v7?
|
|
835
|
+
);
|
|
836
|
+
const getTableInTablesHash = getValueInValuesHash;
|
|
837
|
+
const getTablesHash = getTableHash;
|
|
798
838
|
|
|
799
839
|
const SHIFT36 = 2 ** 36;
|
|
800
840
|
const SHIFT30 = 2 ** 30;
|
|
@@ -1090,38 +1130,30 @@ const createIndexes = getCreateFunction((store) => {
|
|
|
1090
1130
|
return objFreeze(indexes);
|
|
1091
1131
|
});
|
|
1092
1132
|
|
|
1093
|
-
const
|
|
1094
|
-
const
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
|
|
1098
|
-
);
|
|
1099
|
-
|
|
1100
|
-
const stampClone = ([value, time]) => stampNew(value, time);
|
|
1101
|
-
const stampCloneWithHash = ([value, time, hash]) => [value, time, hash];
|
|
1102
|
-
const stampNew = (value, time) => (time ? [value, time] : [value]);
|
|
1103
|
-
const stampNewWithHash = (value, time, hash) => [value, time, hash];
|
|
1133
|
+
const stampClone = ([value, hlc]) => stampNew(value, hlc);
|
|
1134
|
+
const stampCloneWithHash = ([value, hlc, hash]) => [value, hlc, hash];
|
|
1135
|
+
const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
|
|
1136
|
+
const stampNewWithHash = (value, hlc, hash) => [value, hlc, hash];
|
|
1104
1137
|
const getStampHash = (stamp) => stamp[2];
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
const getLatestTime = (time1, time2) =>
|
|
1138
|
+
const replaceHlcHash = (oldHlc, newHlc) =>
|
|
1139
|
+
newHlc > oldHlc ? (oldHlc ? getHash(oldHlc) : 0) ^ getHash(newHlc) : 0;
|
|
1140
|
+
const getLatestHlc = (hlc1, hlc2) =>
|
|
1109
1141
|
/* istanbul ignore next */
|
|
1110
|
-
((
|
|
1111
|
-
const stampUpdate = (stamp,
|
|
1112
|
-
if (
|
|
1113
|
-
stamp[1] =
|
|
1142
|
+
((hlc1 ?? '') > (hlc2 ?? '') ? hlc1 : hlc2) ?? '';
|
|
1143
|
+
const stampUpdate = (stamp, hlc, hash) => {
|
|
1144
|
+
if (hlc > stamp[1]) {
|
|
1145
|
+
stamp[1] = hlc;
|
|
1114
1146
|
}
|
|
1115
1147
|
stamp[2] = hash >>> 0;
|
|
1116
1148
|
};
|
|
1117
|
-
const stampNewObj = (
|
|
1118
|
-
const stampNewMap = (
|
|
1149
|
+
const stampNewObj = (hlc = EMPTY_STRING) => stampNew(objNew(), hlc);
|
|
1150
|
+
const stampNewMap = (hlc = EMPTY_STRING) => [mapNew(), hlc, 0];
|
|
1119
1151
|
const stampMapToObjWithHash = (
|
|
1120
|
-
[map,
|
|
1152
|
+
[map, hlc, hash],
|
|
1121
1153
|
mapper = stampCloneWithHash,
|
|
1122
|
-
) => [mapToObj(map, mapper),
|
|
1123
|
-
const stampMapToObjWithoutHash = ([map,
|
|
1124
|
-
stampNew(mapToObj(map, mapper),
|
|
1154
|
+
) => [mapToObj(map, mapper), hlc, hash];
|
|
1155
|
+
const stampMapToObjWithoutHash = ([map, hlc], mapper = stampClone) =>
|
|
1156
|
+
stampNew(mapToObj(map, mapper), hlc);
|
|
1125
1157
|
const stampValidate = (stamp, validateThing) =>
|
|
1126
1158
|
isArray(stamp) &&
|
|
1127
1159
|
size(stamp) == 3 &&
|
|
@@ -2566,25 +2598,25 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2566
2598
|
const tablesChanges = {};
|
|
2567
2599
|
const valuesChanges = {};
|
|
2568
2600
|
const [
|
|
2569
|
-
[tablesObj,
|
|
2601
|
+
[tablesObj, incomingTablesHlc = EMPTY_STRING, incomingTablesHash = 0],
|
|
2570
2602
|
values,
|
|
2571
2603
|
] = contentOrChanges;
|
|
2572
2604
|
const [tablesStampMap, valuesStampMap] = contentStampMap;
|
|
2573
|
-
const [tableStampMaps,
|
|
2605
|
+
const [tableStampMaps, oldTablesHlc, oldTablesHash] = tablesStampMap;
|
|
2574
2606
|
let tablesHash = isContent ? incomingTablesHash : oldTablesHash;
|
|
2575
|
-
let
|
|
2607
|
+
let tablesHlc = incomingTablesHlc;
|
|
2576
2608
|
objForEach(
|
|
2577
2609
|
tablesObj,
|
|
2578
2610
|
(
|
|
2579
|
-
[rowsObj,
|
|
2611
|
+
[rowsObj, incomingTableHlc = EMPTY_STRING, incomingTableHash = 0],
|
|
2580
2612
|
tableId,
|
|
2581
2613
|
) => {
|
|
2582
2614
|
const tableStampMap = mapEnsure(tableStampMaps, tableId, stampNewMap);
|
|
2583
|
-
const [rowStampMaps,
|
|
2615
|
+
const [rowStampMaps, oldTableHlc, oldTableHash] = tableStampMap;
|
|
2584
2616
|
let tableHash = isContent ? incomingTableHash : oldTableHash;
|
|
2585
|
-
let
|
|
2617
|
+
let tableHlc = incomingTableHlc;
|
|
2586
2618
|
objForEach(rowsObj, (row, rowId) => {
|
|
2587
|
-
const [
|
|
2619
|
+
const [rowHlc, oldRowHash, rowHash] = mergeCellsOrValues(
|
|
2588
2620
|
row,
|
|
2589
2621
|
mapEnsure(rowStampMaps, rowId, stampNewMap),
|
|
2590
2622
|
objEnsure(objEnsure(tablesChanges, tableId, objNew), rowId, objNew),
|
|
@@ -2592,32 +2624,36 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2592
2624
|
);
|
|
2593
2625
|
tableHash ^= isContent
|
|
2594
2626
|
? 0
|
|
2595
|
-
: (
|
|
2596
|
-
|
|
2597
|
-
|
|
2627
|
+
: addOrRemoveHash(
|
|
2628
|
+
oldRowHash ? getValueInValuesHash(rowId, oldRowHash) : 0,
|
|
2629
|
+
getValueInValuesHash(rowId, rowHash),
|
|
2630
|
+
);
|
|
2631
|
+
tableHlc = getLatestHlc(tableHlc, rowHlc);
|
|
2598
2632
|
});
|
|
2599
2633
|
tableHash ^= isContent
|
|
2600
2634
|
? 0
|
|
2601
|
-
:
|
|
2602
|
-
stampUpdate(tableStampMap,
|
|
2635
|
+
: replaceHlcHash(oldTableHlc, incomingTableHlc);
|
|
2636
|
+
stampUpdate(tableStampMap, incomingTableHlc, tableHash);
|
|
2603
2637
|
tablesHash ^= isContent
|
|
2604
2638
|
? 0
|
|
2605
|
-
: (
|
|
2606
|
-
|
|
2607
|
-
|
|
2639
|
+
: addOrRemoveHash(
|
|
2640
|
+
oldTableHash ? getValueInValuesHash(tableId, oldTableHash) : 0,
|
|
2641
|
+
getValueInValuesHash(tableId, tableStampMap[2]),
|
|
2642
|
+
);
|
|
2643
|
+
tablesHlc = getLatestHlc(tablesHlc, tableHlc);
|
|
2608
2644
|
},
|
|
2609
2645
|
);
|
|
2610
2646
|
tablesHash ^= isContent
|
|
2611
2647
|
? 0
|
|
2612
|
-
:
|
|
2613
|
-
stampUpdate(tablesStampMap,
|
|
2614
|
-
const [
|
|
2648
|
+
: replaceHlcHash(oldTablesHlc, incomingTablesHlc);
|
|
2649
|
+
stampUpdate(tablesStampMap, incomingTablesHlc, tablesHash);
|
|
2650
|
+
const [valuesHlc] = mergeCellsOrValues(
|
|
2615
2651
|
values,
|
|
2616
2652
|
valuesStampMap,
|
|
2617
2653
|
valuesChanges,
|
|
2618
2654
|
isContent,
|
|
2619
2655
|
);
|
|
2620
|
-
seenHlc(
|
|
2656
|
+
seenHlc(getLatestHlc(tablesHlc, valuesHlc));
|
|
2621
2657
|
return [tablesChanges, valuesChanges, 1];
|
|
2622
2658
|
};
|
|
2623
2659
|
const mergeCellsOrValues = (
|
|
@@ -2628,44 +2664,44 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2628
2664
|
) => {
|
|
2629
2665
|
const [
|
|
2630
2666
|
thingsObj,
|
|
2631
|
-
|
|
2667
|
+
incomingThingsHlc = EMPTY_STRING,
|
|
2632
2668
|
incomingThingsHash = 0,
|
|
2633
2669
|
] = things;
|
|
2634
|
-
const [thingStampMaps,
|
|
2635
|
-
let
|
|
2670
|
+
const [thingStampMaps, oldThingsHlc, oldThingsHash] = thingsStampMap;
|
|
2671
|
+
let thingsHlc = incomingThingsHlc;
|
|
2636
2672
|
let thingsHash = isContent ? incomingThingsHash : oldThingsHash;
|
|
2637
2673
|
objForEach(
|
|
2638
2674
|
thingsObj,
|
|
2639
|
-
([thing,
|
|
2675
|
+
([thing, thingHlc = EMPTY_STRING, incomingThingHash = 0], thingId) => {
|
|
2640
2676
|
const thingStampMap = mapEnsure(thingStampMaps, thingId, () => [
|
|
2641
2677
|
void 0,
|
|
2642
2678
|
EMPTY_STRING,
|
|
2643
2679
|
0,
|
|
2644
2680
|
]);
|
|
2645
|
-
const [,
|
|
2646
|
-
if (!
|
|
2681
|
+
const [, oldThingHlc, oldThingHash] = thingStampMap;
|
|
2682
|
+
if (!oldThingHlc || thingHlc > oldThingHlc) {
|
|
2647
2683
|
stampUpdate(
|
|
2648
2684
|
thingStampMap,
|
|
2649
|
-
|
|
2650
|
-
isContent
|
|
2651
|
-
? incomingThingHash
|
|
2652
|
-
: getHash(jsonStringWithMap(thing ?? null) + ':' + thingTime),
|
|
2685
|
+
thingHlc,
|
|
2686
|
+
isContent ? incomingThingHash : getValueHash(thing, thingHlc),
|
|
2653
2687
|
);
|
|
2654
2688
|
thingStampMap[0] = thing;
|
|
2655
2689
|
thingsChanges[thingId] = thing;
|
|
2656
2690
|
thingsHash ^= isContent
|
|
2657
2691
|
? 0
|
|
2658
|
-
:
|
|
2659
|
-
|
|
2660
|
-
|
|
2692
|
+
: addOrRemoveHash(
|
|
2693
|
+
getValueInValuesHash(thingId, oldThingHash),
|
|
2694
|
+
getValueInValuesHash(thingId, thingStampMap[2]),
|
|
2695
|
+
);
|
|
2696
|
+
thingsHlc = getLatestHlc(thingsHlc, thingHlc);
|
|
2661
2697
|
}
|
|
2662
2698
|
},
|
|
2663
2699
|
);
|
|
2664
2700
|
thingsHash ^= isContent
|
|
2665
2701
|
? 0
|
|
2666
|
-
:
|
|
2667
|
-
stampUpdate(thingsStampMap,
|
|
2668
|
-
return [
|
|
2702
|
+
: replaceHlcHash(oldThingsHlc, incomingThingsHlc);
|
|
2703
|
+
stampUpdate(thingsStampMap, incomingThingsHlc, thingsHash);
|
|
2704
|
+
return [thingsHlc, oldThingsHash, thingsStampMap[2]];
|
|
2669
2705
|
};
|
|
2670
2706
|
const preStartTransaction = noop;
|
|
2671
2707
|
const preFinishTransaction = noop;
|
|
@@ -2737,13 +2773,13 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2737
2773
|
const differingTableHashes = {};
|
|
2738
2774
|
mapForEach(
|
|
2739
2775
|
contentStampMap[0][0],
|
|
2740
|
-
(tableId, [tableStampMap,
|
|
2776
|
+
(tableId, [tableStampMap, tableHlc, hash]) =>
|
|
2741
2777
|
objHas(otherTableHashes, tableId)
|
|
2742
2778
|
? hash != otherTableHashes[tableId]
|
|
2743
2779
|
? (differingTableHashes[tableId] = hash)
|
|
2744
2780
|
: 0
|
|
2745
2781
|
: (newTables[0][tableId] = stampMapToObjWithoutHash(
|
|
2746
|
-
[tableStampMap,
|
|
2782
|
+
[tableStampMap, tableHlc],
|
|
2747
2783
|
(rowStampMap) => stampMapToObjWithoutHash(rowStampMap),
|
|
2748
2784
|
)),
|
|
2749
2785
|
);
|
|
@@ -2772,13 +2808,13 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2772
2808
|
objForEach(otherTableRowHashes, (otherRowHashes, tableId) =>
|
|
2773
2809
|
mapForEach(
|
|
2774
2810
|
mapGet(contentStampMap[0][0], tableId)?.[0],
|
|
2775
|
-
(rowId, [rowStampMap,
|
|
2811
|
+
(rowId, [rowStampMap, rowHlc, hash]) =>
|
|
2776
2812
|
objHas(otherRowHashes, rowId)
|
|
2777
2813
|
? hash !== otherRowHashes[rowId]
|
|
2778
2814
|
? (objEnsure(differingRowHashes, tableId, objNew)[rowId] = hash)
|
|
2779
2815
|
: 0
|
|
2780
2816
|
: (objEnsure(newRows[0], tableId, stampNewObj)[0][rowId] =
|
|
2781
|
-
stampMapToObjWithoutHash([rowStampMap,
|
|
2817
|
+
stampMapToObjWithoutHash([rowStampMap, rowHlc])),
|
|
2782
2818
|
),
|
|
2783
2819
|
);
|
|
2784
2820
|
return [newRows, differingRowHashes];
|
|
@@ -2809,43 +2845,43 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2809
2845
|
return cellHashes;
|
|
2810
2846
|
};
|
|
2811
2847
|
const getMergeableCellDiff = (otherTableRowCellHashes) => {
|
|
2812
|
-
const [[tableStampMaps,
|
|
2848
|
+
const [[tableStampMaps, tablesHlc]] = contentStampMap;
|
|
2813
2849
|
const tablesObj = {};
|
|
2814
2850
|
objForEach(otherTableRowCellHashes, (otherRowCellHashes, tableId) =>
|
|
2815
2851
|
objForEach(otherRowCellHashes, (otherCellHashes, rowId) =>
|
|
2816
2852
|
ifNotUndefined(
|
|
2817
2853
|
mapGet(tableStampMaps, tableId),
|
|
2818
|
-
([rowStampMaps,
|
|
2854
|
+
([rowStampMaps, tableHlc]) =>
|
|
2819
2855
|
ifNotUndefined(
|
|
2820
2856
|
mapGet(rowStampMaps, rowId),
|
|
2821
|
-
([cellStampMaps,
|
|
2822
|
-
mapForEach(cellStampMaps, (cellId, [cell,
|
|
2857
|
+
([cellStampMaps, rowHlc]) =>
|
|
2858
|
+
mapForEach(cellStampMaps, (cellId, [cell, cellHlc, hash]) =>
|
|
2823
2859
|
hash !== otherCellHashes[cellId]
|
|
2824
2860
|
? (objEnsure(
|
|
2825
2861
|
objEnsure(tablesObj, tableId, () =>
|
|
2826
|
-
stampNewObj(
|
|
2862
|
+
stampNewObj(tableHlc),
|
|
2827
2863
|
)[0],
|
|
2828
2864
|
rowId,
|
|
2829
|
-
() => stampNewObj(
|
|
2830
|
-
)[0][cellId] = [cell,
|
|
2865
|
+
() => stampNewObj(rowHlc),
|
|
2866
|
+
)[0][cellId] = [cell, cellHlc])
|
|
2831
2867
|
: 0,
|
|
2832
2868
|
),
|
|
2833
2869
|
),
|
|
2834
2870
|
),
|
|
2835
2871
|
),
|
|
2836
2872
|
);
|
|
2837
|
-
return stampNew(tablesObj,
|
|
2873
|
+
return stampNew(tablesObj, tablesHlc);
|
|
2838
2874
|
};
|
|
2839
2875
|
const getMergeableValueHashes = () =>
|
|
2840
2876
|
mapToObj(contentStampMap[1][0], getStampHash);
|
|
2841
2877
|
const getMergeableValueDiff = (otherValueHashes) => {
|
|
2842
|
-
const [, [valueStampMaps,
|
|
2878
|
+
const [, [valueStampMaps, valuesHlc]] = contentStampMap;
|
|
2843
2879
|
const values = mapToObj(
|
|
2844
2880
|
valueStampMaps,
|
|
2845
2881
|
stampClone,
|
|
2846
2882
|
([, , hash], valueId) => hash == otherValueHashes?.[valueId],
|
|
2847
2883
|
);
|
|
2848
|
-
return stampNew(values,
|
|
2884
|
+
return stampNew(values, valuesHlc);
|
|
2849
2885
|
};
|
|
2850
2886
|
const setMergeableContent = (mergeableContent) =>
|
|
2851
2887
|
disableListeningToRawStoreChanges(() =>
|
|
@@ -2867,20 +2903,20 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2867
2903
|
};
|
|
2868
2904
|
const getTransactionMergeableChanges = (withHashes = false) => {
|
|
2869
2905
|
const [
|
|
2870
|
-
[tableStampMaps,
|
|
2871
|
-
[valueStampMaps,
|
|
2906
|
+
[tableStampMaps, tablesHlc, tablesHash],
|
|
2907
|
+
[valueStampMaps, valuesHlc, valuesHash],
|
|
2872
2908
|
] = contentStampMap;
|
|
2873
2909
|
const newStamp = withHashes ? stampNewWithHash : stampNew;
|
|
2874
2910
|
const tablesObj = {};
|
|
2875
2911
|
collForEach(touchedCells, (touchedTable, tableId) =>
|
|
2876
2912
|
ifNotUndefined(
|
|
2877
2913
|
mapGet(tableStampMaps, tableId),
|
|
2878
|
-
([rowStampMaps,
|
|
2914
|
+
([rowStampMaps, tableHlc, tableHash]) => {
|
|
2879
2915
|
const tableObj = {};
|
|
2880
2916
|
collForEach(touchedTable, (touchedRow, rowId) =>
|
|
2881
2917
|
ifNotUndefined(
|
|
2882
2918
|
mapGet(rowStampMaps, rowId),
|
|
2883
|
-
([cellStampMaps,
|
|
2919
|
+
([cellStampMaps, rowHlc, rowHash]) => {
|
|
2884
2920
|
const rowObj = {};
|
|
2885
2921
|
collForEach(touchedRow, (cellId) => {
|
|
2886
2922
|
ifNotUndefined(
|
|
@@ -2889,11 +2925,11 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2889
2925
|
(rowObj[cellId] = newStamp(cell, time, hash)),
|
|
2890
2926
|
);
|
|
2891
2927
|
});
|
|
2892
|
-
tableObj[rowId] = newStamp(rowObj,
|
|
2928
|
+
tableObj[rowId] = newStamp(rowObj, rowHlc, rowHash);
|
|
2893
2929
|
},
|
|
2894
2930
|
),
|
|
2895
2931
|
);
|
|
2896
|
-
tablesObj[tableId] = newStamp(tableObj,
|
|
2932
|
+
tablesObj[tableId] = newStamp(tableObj, tableHlc, tableHash);
|
|
2897
2933
|
},
|
|
2898
2934
|
),
|
|
2899
2935
|
);
|
|
@@ -2906,8 +2942,8 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2906
2942
|
),
|
|
2907
2943
|
);
|
|
2908
2944
|
return [
|
|
2909
|
-
newStamp(tablesObj,
|
|
2910
|
-
newStamp(valuesObj,
|
|
2945
|
+
newStamp(tablesObj, tablesHlc, tablesHash),
|
|
2946
|
+
newStamp(valuesObj, valuesHlc, valuesHash),
|
|
2911
2947
|
1,
|
|
2912
2948
|
];
|
|
2913
2949
|
};
|
|
@@ -3795,6 +3831,7 @@ const createRelationships = getCreateFunction((store) => {
|
|
|
3795
3831
|
});
|
|
3796
3832
|
|
|
3797
3833
|
export {
|
|
3834
|
+
addOrRemoveHash,
|
|
3798
3835
|
createCheckpoints,
|
|
3799
3836
|
createIndexes,
|
|
3800
3837
|
createMergeableStore,
|
|
@@ -3803,7 +3840,17 @@ export {
|
|
|
3803
3840
|
createRelationships,
|
|
3804
3841
|
createStore,
|
|
3805
3842
|
defaultSorter,
|
|
3843
|
+
getCellHash,
|
|
3844
|
+
getCellInRowHash,
|
|
3845
|
+
getHash,
|
|
3806
3846
|
getHlcFunctions,
|
|
3807
|
-
|
|
3847
|
+
getRowHash,
|
|
3848
|
+
getRowInTableHash,
|
|
3849
|
+
getTableHash,
|
|
3850
|
+
getTableInTablesHash,
|
|
3851
|
+
getTablesHash,
|
|
3808
3852
|
getUniqueId,
|
|
3853
|
+
getValueHash,
|
|
3854
|
+
getValueInValuesHash,
|
|
3855
|
+
getValuesHash,
|
|
3809
3856
|
};
|