@automerge/automerge
Advanced tools
Comparing version 2.1.6 to 2.1.7-sync-changes-preview-1
@@ -66,3 +66,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
} | ||
function import_value(value, textV2) { | ||
function import_value(value, textV2, path) { | ||
switch (typeof value) { | ||
@@ -126,3 +126,3 @@ case "object": | ||
default: | ||
throw new RangeError(`Unsupported type of value: ${typeof value}`); | ||
throw new RangeError(`Unsupported type ${typeof value} for path ${printPath(path)}`); | ||
} | ||
@@ -187,3 +187,3 @@ } | ||
} | ||
const [value, datatype] = import_value(val, textV2); | ||
const [value, datatype] = import_value(val, textV2, [...path, key]); | ||
switch (datatype) { | ||
@@ -297,3 +297,3 @@ case "list": { | ||
} | ||
const [value, datatype] = import_value(val, textV2); | ||
const [value, datatype] = import_value(val, textV2, [...path, index]); | ||
switch (datatype) { | ||
@@ -491,3 +491,3 @@ case "list": { | ||
fill(val, start, end) { | ||
const [value, datatype] = import_value(val, textV2); | ||
const [value, datatype] = import_value(val, textV2, [...path, start]); | ||
const length = context.length(objectId); | ||
@@ -575,3 +575,15 @@ start = parseListIndex(start || 0); | ||
} | ||
const values = vals.map(val => import_value(val, textV2)); | ||
const values = vals.map((val, index) => { | ||
try { | ||
return import_value(val, textV2, [...path]); | ||
} | ||
catch (e) { | ||
if (e instanceof RangeError) { | ||
throw new RangeError(`${e.message} at index ${index} in the input`); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
for (const [value, datatype] of values) { | ||
@@ -823,1 +835,20 @@ switch (datatype) { | ||
} | ||
function printPath(path) { | ||
// print the path as a json pointer | ||
const jsonPointerComponents = path.map(component => { | ||
// if its a number just turn it into a string | ||
if (typeof component === "number") { | ||
return component.toString(); | ||
} | ||
else if (typeof component === "string") { | ||
// otherwise we have to escape `/` and `~` characters | ||
return component.replace(/~/g, "~0").replace(/\//g, "~1"); | ||
} | ||
}); | ||
if (path.length === 0) { | ||
return ""; | ||
} | ||
else { | ||
return "/" + jsonPointerComponents.join("/"); | ||
} | ||
} |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "2.1.6", | ||
"version": "2.1.7-sync-changes-preview-1", | ||
"description": "Javascript implementation of automerge, backed by @automerge/automerge-wasm", | ||
@@ -74,5 +74,5 @@ "homepage": "https://github.com/automerge/automerge/tree/main/javascript", | ||
"dependencies": { | ||
"@automerge/automerge-wasm": "^0.4.0", | ||
"@automerge/automerge-wasm": "0.5.0-sync-changes-preview-1", | ||
"uuid": "^9.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
422080
13466
1
+ Added@automerge/automerge-wasm@0.5.0-sync-changes-preview-1(transitive)
- Removed@automerge/automerge-wasm@0.4.0(transitive)
Updated@automerge/automerge-wasm@0.5.0-sync-changes-preview-1