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.
Files changed (76) hide show
  1. package/@types/common/index.d.ts +295 -0
  2. package/@types/common/with-schemas/index.d.ts +375 -0
  3. package/@types/mergeable-store/index.d.ts +5 -34
  4. package/@types/mergeable-store/with-schemas/index.d.ts +5 -34
  5. package/@types/omni/with-schemas/index.d.ts +3 -3
  6. package/common/index.js +62 -3
  7. package/common/with-schemas/index.js +62 -3
  8. package/index.js +133 -86
  9. package/mergeable-store/index.js +102 -94
  10. package/mergeable-store/with-schemas/index.js +102 -94
  11. package/min/common/index.js +1 -1
  12. package/min/common/index.js.gz +0 -0
  13. package/min/common/with-schemas/index.js +1 -1
  14. package/min/common/with-schemas/index.js.gz +0 -0
  15. package/min/index.js +1 -1
  16. package/min/index.js.gz +0 -0
  17. package/min/mergeable-store/index.js +1 -1
  18. package/min/mergeable-store/index.js.gz +0 -0
  19. package/min/mergeable-store/with-schemas/index.js +1 -1
  20. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  21. package/min/omni/index.js +1 -1
  22. package/min/omni/index.js.gz +0 -0
  23. package/min/omni/with-schemas/index.js +1 -1
  24. package/min/omni/with-schemas/index.js.gz +0 -0
  25. package/min/persisters/index.js +1 -1
  26. package/min/persisters/index.js.gz +0 -0
  27. package/min/persisters/persister-pglite/index.js +1 -1
  28. package/min/persisters/persister-pglite/index.js.gz +0 -0
  29. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  30. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  31. package/min/persisters/persister-postgres/index.js +1 -1
  32. package/min/persisters/persister-postgres/index.js.gz +0 -0
  33. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  34. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  35. package/min/persisters/with-schemas/index.js +1 -1
  36. package/min/persisters/with-schemas/index.js.gz +0 -0
  37. package/min/store/index.js +1 -1
  38. package/min/store/index.js.gz +0 -0
  39. package/min/store/with-schemas/index.js +1 -1
  40. package/min/store/with-schemas/index.js.gz +0 -0
  41. package/min/ui-react-inspector/index.js +1 -1
  42. package/min/ui-react-inspector/index.js.gz +0 -0
  43. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  44. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  45. package/min/with-schemas/index.js +1 -1
  46. package/min/with-schemas/index.js.gz +0 -0
  47. package/omni/index.js +148 -101
  48. package/omni/with-schemas/index.js +148 -101
  49. package/package.json +3 -3
  50. package/persisters/index.js +9 -9
  51. package/persisters/persister-durable-object-storage/index.js +12 -12
  52. package/persisters/persister-durable-object-storage/with-schemas/index.js +12 -12
  53. package/persisters/persister-pglite/index.js +11 -11
  54. package/persisters/persister-pglite/with-schemas/index.js +11 -11
  55. package/persisters/persister-postgres/index.js +11 -11
  56. package/persisters/persister-postgres/with-schemas/index.js +11 -11
  57. package/persisters/with-schemas/index.js +9 -9
  58. package/readme.md +2 -2
  59. package/releases.md +9 -10
  60. package/store/index.js +4 -4
  61. package/store/with-schemas/index.js +4 -4
  62. package/synchronizers/index.js +7 -7
  63. package/synchronizers/synchronizer-broadcast-channel/index.js +7 -7
  64. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +7 -7
  65. package/synchronizers/synchronizer-local/index.js +7 -7
  66. package/synchronizers/synchronizer-local/with-schemas/index.js +7 -7
  67. package/synchronizers/synchronizer-ws-client/index.js +7 -7
  68. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +7 -7
  69. package/synchronizers/synchronizer-ws-server/index.js +7 -7
  70. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +7 -7
  71. package/synchronizers/synchronizer-ws-server-durable-object/index.js +7 -7
  72. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +7 -7
  73. package/synchronizers/with-schemas/index.js +7 -7
  74. package/ui-react-inspector/index.js +1 -1
  75. package/ui-react-inspector/with-schemas/index.js +1 -1
  76. package/with-schemas/index.js +133 -86
@@ -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, time]) => stampNew(value, time);
360
- const stampCloneWithHash = ([value, time, hash]) => [value, time, hash];
361
- const stampNew = (value, time) => (time ? [value, time] : [value]);
362
- const stampNewWithHash = (value, time, hash) => [value, time, hash];
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 hashIdAndHash = (id, hash) => getHash(id + ':' + hash);
365
- const replaceTimeHash = (oldTime, newTime) =>
366
- newTime > oldTime ? (oldTime ? getHash(oldTime) : 0) ^ getHash(newTime) : 0;
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
- ((time1 ?? '') > (time2 ?? '') ? time1 : time2) ?? '';
370
- const stampUpdate = (stamp, time, hash) => {
371
- if (time > stamp[1]) {
372
- stamp[1] = time;
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 = (time = EMPTY_STRING) => stampNew(objNew(), time);
377
- const stampNewMap = (time = EMPTY_STRING) => [mapNew(), time, 0];
380
+ const stampNewObj = (hlc = EMPTY_STRING) => stampNew(objNew(), hlc);
381
+ const stampNewMap = (hlc = EMPTY_STRING) => [mapNew(), hlc, 0];
378
382
  const stampMapToObjWithHash = (
379
- [map, time, hash],
383
+ [map, hlc, hash],
380
384
  mapper = stampCloneWithHash,
381
- ) => [mapToObj(map, mapper), time, hash];
382
- const stampMapToObjWithoutHash = ([map, time], mapper = stampClone) =>
383
- stampNew(mapToObj(map, mapper), time);
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, incomingTablesTime = EMPTY_STRING, incomingTablesHash = 0],
1921
+ [tablesObj, incomingTablesHlc = EMPTY_STRING, incomingTablesHash = 0],
1918
1922
  values,
1919
1923
  ] = contentOrChanges;
1920
1924
  const [tablesStampMap, valuesStampMap] = contentStampMap;
1921
- const [tableStampMaps, oldTablesTime, oldTablesHash] = tablesStampMap;
1925
+ const [tableStampMaps, oldTablesHlc, oldTablesHash] = tablesStampMap;
1922
1926
  let tablesHash = isContent ? incomingTablesHash : oldTablesHash;
1923
- let tablesTime = incomingTablesTime;
1927
+ let tablesHlc = incomingTablesHlc;
1924
1928
  objForEach(
1925
1929
  tablesObj,
1926
1930
  (
1927
- [rowsObj, incomingTableTime = EMPTY_STRING, incomingTableHash = 0],
1931
+ [rowsObj, incomingTableHlc = EMPTY_STRING, incomingTableHash = 0],
1928
1932
  tableId,
1929
1933
  ) => {
1930
1934
  const tableStampMap = mapEnsure(tableStampMaps, tableId, stampNewMap);
1931
- const [rowStampMaps, oldTableTime, oldTableHash] = tableStampMap;
1935
+ const [rowStampMaps, oldTableHlc, oldTableHash] = tableStampMap;
1932
1936
  let tableHash = isContent ? incomingTableHash : oldTableHash;
1933
- let tableTime = incomingTableTime;
1937
+ let tableHlc = incomingTableHlc;
1934
1938
  objForEach(rowsObj, (row, rowId) => {
1935
- const [rowTime, oldRowHash, rowHash] = mergeCellsOrValues(
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
- : (oldRowHash ? hashIdAndHash(rowId, oldRowHash) : 0) ^
1944
- hashIdAndHash(rowId, rowHash);
1945
- tableTime = getLatestTime(tableTime, rowTime);
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
- : replaceTimeHash(oldTableTime, incomingTableTime);
1950
- stampUpdate(tableStampMap, incomingTableTime, tableHash);
1955
+ : replaceHlcHash(oldTableHlc, incomingTableHlc);
1956
+ stampUpdate(tableStampMap, incomingTableHlc, tableHash);
1951
1957
  tablesHash ^= isContent
1952
1958
  ? 0
1953
- : (oldTableHash ? hashIdAndHash(tableId, oldTableHash) : 0) ^
1954
- hashIdAndHash(tableId, tableStampMap[2]);
1955
- tablesTime = getLatestTime(tablesTime, tableTime);
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
- : replaceTimeHash(oldTablesTime, incomingTablesTime);
1961
- stampUpdate(tablesStampMap, incomingTablesTime, tablesHash);
1962
- const [valuesTime] = mergeCellsOrValues(
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(getLatestTime(tablesTime, valuesTime));
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
- incomingThingsTime = EMPTY_STRING,
1987
+ incomingThingsHlc = EMPTY_STRING,
1980
1988
  incomingThingsHash = 0,
1981
1989
  ] = things;
1982
- const [thingStampMaps, oldThingsTime, oldThingsHash] = thingsStampMap;
1983
- let thingsTime = incomingThingsTime;
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, thingTime = EMPTY_STRING, incomingThingHash = 0], thingId) => {
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 [, oldThingTime, oldThingHash] = thingStampMap;
1994
- if (!oldThingTime || thingTime > oldThingTime) {
2001
+ const [, oldThingHlc, oldThingHash] = thingStampMap;
2002
+ if (!oldThingHlc || thingHlc > oldThingHlc) {
1995
2003
  stampUpdate(
1996
2004
  thingStampMap,
1997
- thingTime,
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
- : hashIdAndHash(thingId, oldThingHash) ^
2007
- hashIdAndHash(thingId, thingStampMap[2]);
2008
- thingsTime = getLatestTime(thingsTime, thingTime);
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
- : replaceTimeHash(oldThingsTime, incomingThingsTime);
2015
- stampUpdate(thingsStampMap, incomingThingsTime, thingsHash);
2016
- return [thingsTime, oldThingsHash, thingsStampMap[2]];
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, tableTime, hash]) =>
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, tableTime],
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, rowTime, hash]) =>
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, rowTime])),
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, tablesTime]] = contentStampMap;
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, tableTime]) =>
2174
+ ([rowStampMaps, tableHlc]) =>
2167
2175
  ifNotUndefined(
2168
2176
  mapGet(rowStampMaps, rowId),
2169
- ([cellStampMaps, rowTime]) =>
2170
- mapForEach(cellStampMaps, (cellId, [cell, cellTime, hash]) =>
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(tableTime),
2182
+ stampNewObj(tableHlc),
2175
2183
  )[0],
2176
2184
  rowId,
2177
- () => stampNewObj(rowTime),
2178
- )[0][cellId] = [cell, cellTime])
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, tablesTime);
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, valuesTime]] = contentStampMap;
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, valuesTime);
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, tablesTime, tablesHash],
2219
- [valueStampMaps, valuesTime, valuesHash],
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, tableTime, tableHash]) => {
2234
+ ([rowStampMaps, tableHlc, tableHash]) => {
2227
2235
  const tableObj = {};
2228
2236
  collForEach(touchedTable, (touchedRow, rowId) =>
2229
2237
  ifNotUndefined(
2230
2238
  mapGet(rowStampMaps, rowId),
2231
- ([cellStampMaps, rowTime, rowHash]) => {
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, rowTime, rowHash);
2248
+ tableObj[rowId] = newStamp(rowObj, rowHlc, rowHash);
2241
2249
  },
2242
2250
  ),
2243
2251
  );
2244
- tablesObj[tableId] = newStamp(tableObj, tableTime, tableHash);
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, tablesTime, tablesHash),
2258
- newStamp(valuesObj, valuesTime, valuesHash),
2265
+ newStamp(tablesObj, tablesHlc, tablesHash),
2266
+ newStamp(valuesObj, valuesHlc, valuesHash),
2259
2267
  1,
2260
2268
  ];
2261
2269
  };