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/mergeable-store/index.js
CHANGED
|
@@ -97,21 +97,10 @@ const collClear = (coll) => coll.clear();
|
|
|
97
97
|
const collForEach = (coll, cb) => coll?.forEach(cb);
|
|
98
98
|
const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
|
|
99
99
|
|
|
100
|
-
const textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();
|
|
101
|
-
const getHash = (value) => {
|
|
102
|
-
let hash = 2166136261;
|
|
103
|
-
arrayForEach(textEncoder.encode(value), (char) => {
|
|
104
|
-
hash ^= char;
|
|
105
|
-
hash +=
|
|
106
|
-
(hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
107
|
-
});
|
|
108
|
-
return hash >>> 0;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
100
|
const object = Object;
|
|
112
101
|
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
113
|
-
const objEntries = object.entries;
|
|
114
102
|
const objFrozen = object.isFrozen;
|
|
103
|
+
const objEntries = object.entries;
|
|
115
104
|
const isObject = (obj) =>
|
|
116
105
|
!isUndefined(obj) &&
|
|
117
106
|
ifNotUndefined(
|
|
@@ -163,6 +152,29 @@ const objValidate = (obj, validateChild, onInvalidObj, emptyIsValid = 0) => {
|
|
|
163
152
|
return emptyIsValid ? true : !objIsEmpty(obj);
|
|
164
153
|
};
|
|
165
154
|
|
|
155
|
+
const jsonString = JSON.stringify;
|
|
156
|
+
const jsonParse = JSON.parse;
|
|
157
|
+
const jsonStringWithMap = (obj) =>
|
|
158
|
+
jsonString(obj, (_key, value) =>
|
|
159
|
+
isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();
|
|
163
|
+
const getHash = (string) => {
|
|
164
|
+
let hash = 2166136261;
|
|
165
|
+
arrayForEach(textEncoder.encode(string), (char) => {
|
|
166
|
+
hash ^= char;
|
|
167
|
+
hash +=
|
|
168
|
+
(hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
169
|
+
});
|
|
170
|
+
return hash >>> 0;
|
|
171
|
+
};
|
|
172
|
+
const addOrRemoveHash = (hash1, hash2) => (hash1 ^ hash2) >>> 0;
|
|
173
|
+
const getValueInValuesHash = (valueId, valueHash) =>
|
|
174
|
+
getHash(valueId + ':' + valueHash);
|
|
175
|
+
const getValueHash = (value, valueHlc) =>
|
|
176
|
+
getHash(jsonStringWithMap(value ?? null) + ':' + valueHlc);
|
|
177
|
+
|
|
166
178
|
const mapNew = (entries) => new Map(entries);
|
|
167
179
|
const mapKeys = (map) => [...(map?.keys() ?? [])];
|
|
168
180
|
const mapGet = (map, key) => map?.get(key);
|
|
@@ -341,13 +353,6 @@ const getHlcFunctions = (uniqueId, getNow = Date.now) => {
|
|
|
341
353
|
];
|
|
342
354
|
};
|
|
343
355
|
|
|
344
|
-
const jsonString = JSON.stringify;
|
|
345
|
-
const jsonParse = JSON.parse;
|
|
346
|
-
const jsonStringWithMap = (obj) =>
|
|
347
|
-
jsonString(obj, (_key, value) =>
|
|
348
|
-
isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
|
|
349
|
-
);
|
|
350
|
-
|
|
351
356
|
const setNew = (entryOrEntries) =>
|
|
352
357
|
new Set(
|
|
353
358
|
isArray(entryOrEntries) || isUndefined(entryOrEntries)
|
|
@@ -356,31 +361,30 @@ const setNew = (entryOrEntries) =>
|
|
|
356
361
|
);
|
|
357
362
|
const setAdd = (set, value) => set?.add(value);
|
|
358
363
|
|
|
359
|
-
const stampClone = ([value,
|
|
360
|
-
const stampCloneWithHash = ([value,
|
|
361
|
-
const stampNew = (value,
|
|
362
|
-
const stampNewWithHash = (value,
|
|
364
|
+
const stampClone = ([value, hlc]) => stampNew(value, hlc);
|
|
365
|
+
const stampCloneWithHash = ([value, hlc, hash]) => [value, hlc, hash];
|
|
366
|
+
const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
|
|
367
|
+
const stampNewWithHash = (value, hlc, hash) => [value, hlc, hash];
|
|
363
368
|
const getStampHash = (stamp) => stamp[2];
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const getLatestTime = (time1, time2) =>
|
|
369
|
+
const replaceHlcHash = (oldHlc, newHlc) =>
|
|
370
|
+
newHlc > oldHlc ? (oldHlc ? getHash(oldHlc) : 0) ^ getHash(newHlc) : 0;
|
|
371
|
+
const getLatestHlc = (hlc1, hlc2) =>
|
|
368
372
|
/* istanbul ignore next */
|
|
369
|
-
((
|
|
370
|
-
const stampUpdate = (stamp,
|
|
371
|
-
if (
|
|
372
|
-
stamp[1] =
|
|
373
|
+
((hlc1 ?? '') > (hlc2 ?? '') ? hlc1 : hlc2) ?? '';
|
|
374
|
+
const stampUpdate = (stamp, hlc, hash) => {
|
|
375
|
+
if (hlc > stamp[1]) {
|
|
376
|
+
stamp[1] = hlc;
|
|
373
377
|
}
|
|
374
378
|
stamp[2] = hash >>> 0;
|
|
375
379
|
};
|
|
376
|
-
const stampNewObj = (
|
|
377
|
-
const stampNewMap = (
|
|
380
|
+
const stampNewObj = (hlc = EMPTY_STRING) => stampNew(objNew(), hlc);
|
|
381
|
+
const stampNewMap = (hlc = EMPTY_STRING) => [mapNew(), hlc, 0];
|
|
378
382
|
const stampMapToObjWithHash = (
|
|
379
|
-
[map,
|
|
383
|
+
[map, hlc, hash],
|
|
380
384
|
mapper = stampCloneWithHash,
|
|
381
|
-
) => [mapToObj(map, mapper),
|
|
382
|
-
const stampMapToObjWithoutHash = ([map,
|
|
383
|
-
stampNew(mapToObj(map, mapper),
|
|
385
|
+
) => [mapToObj(map, mapper), hlc, hash];
|
|
386
|
+
const stampMapToObjWithoutHash = ([map, hlc], mapper = stampClone) =>
|
|
387
|
+
stampNew(mapToObj(map, mapper), hlc);
|
|
384
388
|
const stampValidate = (stamp, validateThing) =>
|
|
385
389
|
isArray(stamp) &&
|
|
386
390
|
size(stamp) == 3 &&
|
|
@@ -1914,25 +1918,25 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
1914
1918
|
const tablesChanges = {};
|
|
1915
1919
|
const valuesChanges = {};
|
|
1916
1920
|
const [
|
|
1917
|
-
[tablesObj,
|
|
1921
|
+
[tablesObj, incomingTablesHlc = EMPTY_STRING, incomingTablesHash = 0],
|
|
1918
1922
|
values,
|
|
1919
1923
|
] = contentOrChanges;
|
|
1920
1924
|
const [tablesStampMap, valuesStampMap] = contentStampMap;
|
|
1921
|
-
const [tableStampMaps,
|
|
1925
|
+
const [tableStampMaps, oldTablesHlc, oldTablesHash] = tablesStampMap;
|
|
1922
1926
|
let tablesHash = isContent ? incomingTablesHash : oldTablesHash;
|
|
1923
|
-
let
|
|
1927
|
+
let tablesHlc = incomingTablesHlc;
|
|
1924
1928
|
objForEach(
|
|
1925
1929
|
tablesObj,
|
|
1926
1930
|
(
|
|
1927
|
-
[rowsObj,
|
|
1931
|
+
[rowsObj, incomingTableHlc = EMPTY_STRING, incomingTableHash = 0],
|
|
1928
1932
|
tableId,
|
|
1929
1933
|
) => {
|
|
1930
1934
|
const tableStampMap = mapEnsure(tableStampMaps, tableId, stampNewMap);
|
|
1931
|
-
const [rowStampMaps,
|
|
1935
|
+
const [rowStampMaps, oldTableHlc, oldTableHash] = tableStampMap;
|
|
1932
1936
|
let tableHash = isContent ? incomingTableHash : oldTableHash;
|
|
1933
|
-
let
|
|
1937
|
+
let tableHlc = incomingTableHlc;
|
|
1934
1938
|
objForEach(rowsObj, (row, rowId) => {
|
|
1935
|
-
const [
|
|
1939
|
+
const [rowHlc, oldRowHash, rowHash] = mergeCellsOrValues(
|
|
1936
1940
|
row,
|
|
1937
1941
|
mapEnsure(rowStampMaps, rowId, stampNewMap),
|
|
1938
1942
|
objEnsure(objEnsure(tablesChanges, tableId, objNew), rowId, objNew),
|
|
@@ -1940,32 +1944,36 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
1940
1944
|
);
|
|
1941
1945
|
tableHash ^= isContent
|
|
1942
1946
|
? 0
|
|
1943
|
-
: (
|
|
1944
|
-
|
|
1945
|
-
|
|
1947
|
+
: addOrRemoveHash(
|
|
1948
|
+
oldRowHash ? getValueInValuesHash(rowId, oldRowHash) : 0,
|
|
1949
|
+
getValueInValuesHash(rowId, rowHash),
|
|
1950
|
+
);
|
|
1951
|
+
tableHlc = getLatestHlc(tableHlc, rowHlc);
|
|
1946
1952
|
});
|
|
1947
1953
|
tableHash ^= isContent
|
|
1948
1954
|
? 0
|
|
1949
|
-
:
|
|
1950
|
-
stampUpdate(tableStampMap,
|
|
1955
|
+
: replaceHlcHash(oldTableHlc, incomingTableHlc);
|
|
1956
|
+
stampUpdate(tableStampMap, incomingTableHlc, tableHash);
|
|
1951
1957
|
tablesHash ^= isContent
|
|
1952
1958
|
? 0
|
|
1953
|
-
: (
|
|
1954
|
-
|
|
1955
|
-
|
|
1959
|
+
: addOrRemoveHash(
|
|
1960
|
+
oldTableHash ? getValueInValuesHash(tableId, oldTableHash) : 0,
|
|
1961
|
+
getValueInValuesHash(tableId, tableStampMap[2]),
|
|
1962
|
+
);
|
|
1963
|
+
tablesHlc = getLatestHlc(tablesHlc, tableHlc);
|
|
1956
1964
|
},
|
|
1957
1965
|
);
|
|
1958
1966
|
tablesHash ^= isContent
|
|
1959
1967
|
? 0
|
|
1960
|
-
:
|
|
1961
|
-
stampUpdate(tablesStampMap,
|
|
1962
|
-
const [
|
|
1968
|
+
: replaceHlcHash(oldTablesHlc, incomingTablesHlc);
|
|
1969
|
+
stampUpdate(tablesStampMap, incomingTablesHlc, tablesHash);
|
|
1970
|
+
const [valuesHlc] = mergeCellsOrValues(
|
|
1963
1971
|
values,
|
|
1964
1972
|
valuesStampMap,
|
|
1965
1973
|
valuesChanges,
|
|
1966
1974
|
isContent,
|
|
1967
1975
|
);
|
|
1968
|
-
seenHlc(
|
|
1976
|
+
seenHlc(getLatestHlc(tablesHlc, valuesHlc));
|
|
1969
1977
|
return [tablesChanges, valuesChanges, 1];
|
|
1970
1978
|
};
|
|
1971
1979
|
const mergeCellsOrValues = (
|
|
@@ -1976,44 +1984,44 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
1976
1984
|
) => {
|
|
1977
1985
|
const [
|
|
1978
1986
|
thingsObj,
|
|
1979
|
-
|
|
1987
|
+
incomingThingsHlc = EMPTY_STRING,
|
|
1980
1988
|
incomingThingsHash = 0,
|
|
1981
1989
|
] = things;
|
|
1982
|
-
const [thingStampMaps,
|
|
1983
|
-
let
|
|
1990
|
+
const [thingStampMaps, oldThingsHlc, oldThingsHash] = thingsStampMap;
|
|
1991
|
+
let thingsHlc = incomingThingsHlc;
|
|
1984
1992
|
let thingsHash = isContent ? incomingThingsHash : oldThingsHash;
|
|
1985
1993
|
objForEach(
|
|
1986
1994
|
thingsObj,
|
|
1987
|
-
([thing,
|
|
1995
|
+
([thing, thingHlc = EMPTY_STRING, incomingThingHash = 0], thingId) => {
|
|
1988
1996
|
const thingStampMap = mapEnsure(thingStampMaps, thingId, () => [
|
|
1989
1997
|
void 0,
|
|
1990
1998
|
EMPTY_STRING,
|
|
1991
1999
|
0,
|
|
1992
2000
|
]);
|
|
1993
|
-
const [,
|
|
1994
|
-
if (!
|
|
2001
|
+
const [, oldThingHlc, oldThingHash] = thingStampMap;
|
|
2002
|
+
if (!oldThingHlc || thingHlc > oldThingHlc) {
|
|
1995
2003
|
stampUpdate(
|
|
1996
2004
|
thingStampMap,
|
|
1997
|
-
|
|
1998
|
-
isContent
|
|
1999
|
-
? incomingThingHash
|
|
2000
|
-
: getHash(jsonStringWithMap(thing ?? null) + ':' + thingTime),
|
|
2005
|
+
thingHlc,
|
|
2006
|
+
isContent ? incomingThingHash : getValueHash(thing, thingHlc),
|
|
2001
2007
|
);
|
|
2002
2008
|
thingStampMap[0] = thing;
|
|
2003
2009
|
thingsChanges[thingId] = thing;
|
|
2004
2010
|
thingsHash ^= isContent
|
|
2005
2011
|
? 0
|
|
2006
|
-
:
|
|
2007
|
-
|
|
2008
|
-
|
|
2012
|
+
: addOrRemoveHash(
|
|
2013
|
+
getValueInValuesHash(thingId, oldThingHash),
|
|
2014
|
+
getValueInValuesHash(thingId, thingStampMap[2]),
|
|
2015
|
+
);
|
|
2016
|
+
thingsHlc = getLatestHlc(thingsHlc, thingHlc);
|
|
2009
2017
|
}
|
|
2010
2018
|
},
|
|
2011
2019
|
);
|
|
2012
2020
|
thingsHash ^= isContent
|
|
2013
2021
|
? 0
|
|
2014
|
-
:
|
|
2015
|
-
stampUpdate(thingsStampMap,
|
|
2016
|
-
return [
|
|
2022
|
+
: replaceHlcHash(oldThingsHlc, incomingThingsHlc);
|
|
2023
|
+
stampUpdate(thingsStampMap, incomingThingsHlc, thingsHash);
|
|
2024
|
+
return [thingsHlc, oldThingsHash, thingsStampMap[2]];
|
|
2017
2025
|
};
|
|
2018
2026
|
const preStartTransaction = noop;
|
|
2019
2027
|
const preFinishTransaction = noop;
|
|
@@ -2085,13 +2093,13 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2085
2093
|
const differingTableHashes = {};
|
|
2086
2094
|
mapForEach(
|
|
2087
2095
|
contentStampMap[0][0],
|
|
2088
|
-
(tableId, [tableStampMap,
|
|
2096
|
+
(tableId, [tableStampMap, tableHlc, hash]) =>
|
|
2089
2097
|
objHas(otherTableHashes, tableId)
|
|
2090
2098
|
? hash != otherTableHashes[tableId]
|
|
2091
2099
|
? (differingTableHashes[tableId] = hash)
|
|
2092
2100
|
: 0
|
|
2093
2101
|
: (newTables[0][tableId] = stampMapToObjWithoutHash(
|
|
2094
|
-
[tableStampMap,
|
|
2102
|
+
[tableStampMap, tableHlc],
|
|
2095
2103
|
(rowStampMap) => stampMapToObjWithoutHash(rowStampMap),
|
|
2096
2104
|
)),
|
|
2097
2105
|
);
|
|
@@ -2120,13 +2128,13 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2120
2128
|
objForEach(otherTableRowHashes, (otherRowHashes, tableId) =>
|
|
2121
2129
|
mapForEach(
|
|
2122
2130
|
mapGet(contentStampMap[0][0], tableId)?.[0],
|
|
2123
|
-
(rowId, [rowStampMap,
|
|
2131
|
+
(rowId, [rowStampMap, rowHlc, hash]) =>
|
|
2124
2132
|
objHas(otherRowHashes, rowId)
|
|
2125
2133
|
? hash !== otherRowHashes[rowId]
|
|
2126
2134
|
? (objEnsure(differingRowHashes, tableId, objNew)[rowId] = hash)
|
|
2127
2135
|
: 0
|
|
2128
2136
|
: (objEnsure(newRows[0], tableId, stampNewObj)[0][rowId] =
|
|
2129
|
-
stampMapToObjWithoutHash([rowStampMap,
|
|
2137
|
+
stampMapToObjWithoutHash([rowStampMap, rowHlc])),
|
|
2130
2138
|
),
|
|
2131
2139
|
);
|
|
2132
2140
|
return [newRows, differingRowHashes];
|
|
@@ -2157,43 +2165,43 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2157
2165
|
return cellHashes;
|
|
2158
2166
|
};
|
|
2159
2167
|
const getMergeableCellDiff = (otherTableRowCellHashes) => {
|
|
2160
|
-
const [[tableStampMaps,
|
|
2168
|
+
const [[tableStampMaps, tablesHlc]] = contentStampMap;
|
|
2161
2169
|
const tablesObj = {};
|
|
2162
2170
|
objForEach(otherTableRowCellHashes, (otherRowCellHashes, tableId) =>
|
|
2163
2171
|
objForEach(otherRowCellHashes, (otherCellHashes, rowId) =>
|
|
2164
2172
|
ifNotUndefined(
|
|
2165
2173
|
mapGet(tableStampMaps, tableId),
|
|
2166
|
-
([rowStampMaps,
|
|
2174
|
+
([rowStampMaps, tableHlc]) =>
|
|
2167
2175
|
ifNotUndefined(
|
|
2168
2176
|
mapGet(rowStampMaps, rowId),
|
|
2169
|
-
([cellStampMaps,
|
|
2170
|
-
mapForEach(cellStampMaps, (cellId, [cell,
|
|
2177
|
+
([cellStampMaps, rowHlc]) =>
|
|
2178
|
+
mapForEach(cellStampMaps, (cellId, [cell, cellHlc, hash]) =>
|
|
2171
2179
|
hash !== otherCellHashes[cellId]
|
|
2172
2180
|
? (objEnsure(
|
|
2173
2181
|
objEnsure(tablesObj, tableId, () =>
|
|
2174
|
-
stampNewObj(
|
|
2182
|
+
stampNewObj(tableHlc),
|
|
2175
2183
|
)[0],
|
|
2176
2184
|
rowId,
|
|
2177
|
-
() => stampNewObj(
|
|
2178
|
-
)[0][cellId] = [cell,
|
|
2185
|
+
() => stampNewObj(rowHlc),
|
|
2186
|
+
)[0][cellId] = [cell, cellHlc])
|
|
2179
2187
|
: 0,
|
|
2180
2188
|
),
|
|
2181
2189
|
),
|
|
2182
2190
|
),
|
|
2183
2191
|
),
|
|
2184
2192
|
);
|
|
2185
|
-
return stampNew(tablesObj,
|
|
2193
|
+
return stampNew(tablesObj, tablesHlc);
|
|
2186
2194
|
};
|
|
2187
2195
|
const getMergeableValueHashes = () =>
|
|
2188
2196
|
mapToObj(contentStampMap[1][0], getStampHash);
|
|
2189
2197
|
const getMergeableValueDiff = (otherValueHashes) => {
|
|
2190
|
-
const [, [valueStampMaps,
|
|
2198
|
+
const [, [valueStampMaps, valuesHlc]] = contentStampMap;
|
|
2191
2199
|
const values = mapToObj(
|
|
2192
2200
|
valueStampMaps,
|
|
2193
2201
|
stampClone,
|
|
2194
2202
|
([, , hash], valueId) => hash == otherValueHashes?.[valueId],
|
|
2195
2203
|
);
|
|
2196
|
-
return stampNew(values,
|
|
2204
|
+
return stampNew(values, valuesHlc);
|
|
2197
2205
|
};
|
|
2198
2206
|
const setMergeableContent = (mergeableContent) =>
|
|
2199
2207
|
disableListeningToRawStoreChanges(() =>
|
|
@@ -2215,20 +2223,20 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2215
2223
|
};
|
|
2216
2224
|
const getTransactionMergeableChanges = (withHashes = false) => {
|
|
2217
2225
|
const [
|
|
2218
|
-
[tableStampMaps,
|
|
2219
|
-
[valueStampMaps,
|
|
2226
|
+
[tableStampMaps, tablesHlc, tablesHash],
|
|
2227
|
+
[valueStampMaps, valuesHlc, valuesHash],
|
|
2220
2228
|
] = contentStampMap;
|
|
2221
2229
|
const newStamp = withHashes ? stampNewWithHash : stampNew;
|
|
2222
2230
|
const tablesObj = {};
|
|
2223
2231
|
collForEach(touchedCells, (touchedTable, tableId) =>
|
|
2224
2232
|
ifNotUndefined(
|
|
2225
2233
|
mapGet(tableStampMaps, tableId),
|
|
2226
|
-
([rowStampMaps,
|
|
2234
|
+
([rowStampMaps, tableHlc, tableHash]) => {
|
|
2227
2235
|
const tableObj = {};
|
|
2228
2236
|
collForEach(touchedTable, (touchedRow, rowId) =>
|
|
2229
2237
|
ifNotUndefined(
|
|
2230
2238
|
mapGet(rowStampMaps, rowId),
|
|
2231
|
-
([cellStampMaps,
|
|
2239
|
+
([cellStampMaps, rowHlc, rowHash]) => {
|
|
2232
2240
|
const rowObj = {};
|
|
2233
2241
|
collForEach(touchedRow, (cellId) => {
|
|
2234
2242
|
ifNotUndefined(
|
|
@@ -2237,11 +2245,11 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2237
2245
|
(rowObj[cellId] = newStamp(cell, time, hash)),
|
|
2238
2246
|
);
|
|
2239
2247
|
});
|
|
2240
|
-
tableObj[rowId] = newStamp(rowObj,
|
|
2248
|
+
tableObj[rowId] = newStamp(rowObj, rowHlc, rowHash);
|
|
2241
2249
|
},
|
|
2242
2250
|
),
|
|
2243
2251
|
);
|
|
2244
|
-
tablesObj[tableId] = newStamp(tableObj,
|
|
2252
|
+
tablesObj[tableId] = newStamp(tableObj, tableHlc, tableHash);
|
|
2245
2253
|
},
|
|
2246
2254
|
),
|
|
2247
2255
|
);
|
|
@@ -2254,8 +2262,8 @@ const createMergeableStore = (uniqueId, getNow) => {
|
|
|
2254
2262
|
),
|
|
2255
2263
|
);
|
|
2256
2264
|
return [
|
|
2257
|
-
newStamp(tablesObj,
|
|
2258
|
-
newStamp(valuesObj,
|
|
2265
|
+
newStamp(tablesObj, tablesHlc, tablesHash),
|
|
2266
|
+
newStamp(valuesObj, valuesHlc, valuesHash),
|
|
2259
2267
|
1,
|
|
2260
2268
|
];
|
|
2261
2269
|
};
|