@recordtimelabel/core 0.1.9 → 0.1.10

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 (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/index.js +23 -11
package/README.md CHANGED
@@ -20,7 +20,7 @@ During local development an app can consume a sibling checkout with:
20
20
  For release builds, consume a fixed npm package, git tag, or private registry version so builds do not depend on a sibling folder path. The current published release is:
21
21
 
22
22
  ```json
23
- "@recordtimelabel/core": "0.1.9"
23
+ "@recordtimelabel/core": "0.1.10"
24
24
  ```
25
25
 
26
26
  If this checkout's `package.json` is ahead of the published version, publish the new package before updating consumers to that version.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recordtimelabel/core",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "description": "Shared RecordTimeLabel data model, merge logic, operations, and sync engine.",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -5,7 +5,7 @@ const REQUIRED_FOLDERS = [
5
5
  { id: DEFAULT_FOLDER_ID, name: 'Uncategorized' }
6
6
  ];
7
7
 
8
- export const RECORD_TIMELABEL_CORE_VERSION = '0.1.9';
8
+ export const RECORD_TIMELABEL_CORE_VERSION = '0.1.10';
9
9
 
10
10
  export const OPERATION_TYPES = Object.freeze({
11
11
  RECORD_CREATE: 'record.create',
@@ -1275,22 +1275,34 @@ export const buildFirestoreV2DocumentsFromState = (state = {}, options = {}) =>
1275
1275
  };
1276
1276
 
1277
1277
  const canonicalizeFirestoreV2DocumentValue = (value) => {
1278
+ if (value === null) {
1279
+ return ['null'];
1280
+ }
1278
1281
  if (Array.isArray(value)) {
1279
- return value.map((entry) => canonicalizeFirestoreV2DocumentValue(entry));
1282
+ return ['array', value.map((entry) => canonicalizeFirestoreV2DocumentValue(entry))];
1280
1283
  }
1281
1284
  if (value instanceof Date) {
1282
- return value.toISOString();
1285
+ const timestamp = value.getTime();
1286
+ return ['date', Number.isNaN(timestamp) ? 'invalid' : value.toISOString()];
1287
+ }
1288
+
1289
+ const valueType = typeof value;
1290
+ if (valueType === 'number') {
1291
+ if (Number.isNaN(value)) return ['number', 'NaN'];
1292
+ if (value === Infinity) return ['number', 'Infinity'];
1293
+ if (value === -Infinity) return ['number', '-Infinity'];
1294
+ return ['number', value];
1283
1295
  }
1284
- if (!value || typeof value !== 'object') {
1285
- return value;
1296
+ if (valueType !== 'object') {
1297
+ return [valueType, valueType === 'bigint' ? value.toString() : value];
1286
1298
  }
1287
1299
 
1288
- return Object.keys(value)
1289
- .sort()
1290
- .reduce((result, key) => {
1291
- result[key] = canonicalizeFirestoreV2DocumentValue(value[key]);
1292
- return result;
1293
- }, {});
1300
+ return [
1301
+ 'object',
1302
+ Object.keys(value)
1303
+ .sort()
1304
+ .map((key) => [key, canonicalizeFirestoreV2DocumentValue(value[key])])
1305
+ ];
1294
1306
  };
1295
1307
 
1296
1308
  const areFirestoreV2DocumentValuesEqual = (left, right) => (