@panproto/core 0.5.0 → 0.6.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/README.md +40 -10
- package/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/migration.d.ts +5 -3
- package/dist/migration.d.ts.map +1 -1
- package/dist/msgpack.d.ts.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm.d.ts +4 -0
- package/dist/wasm.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -63,6 +63,10 @@ async function loadWasm(input) {
|
|
|
63
63
|
validate_instance: glue.validate_instance,
|
|
64
64
|
instance_to_json: glue.instance_to_json,
|
|
65
65
|
json_to_instance: glue.json_to_instance,
|
|
66
|
+
json_to_instance_with_root: glue.json_to_instance_with_root,
|
|
67
|
+
lift_json: glue.lift_json,
|
|
68
|
+
get_json: glue.get_json,
|
|
69
|
+
put_json: glue.put_json,
|
|
66
70
|
instance_element_count: glue.instance_element_count,
|
|
67
71
|
lens_from_combinators: glue.lens_from_combinators,
|
|
68
72
|
check_lens_laws: glue.check_lens_laws,
|
|
@@ -155,7 +159,14 @@ function packSchemaOps(ops) {
|
|
|
155
159
|
return encode(ops);
|
|
156
160
|
}
|
|
157
161
|
function packMigrationMapping(mapping) {
|
|
158
|
-
return encode(
|
|
162
|
+
return encode({
|
|
163
|
+
vertex_map: mapping.vertex_map,
|
|
164
|
+
edge_map: Array.from(mapping.edge_map.entries()),
|
|
165
|
+
hyper_edge_map: mapping.hyper_edge_map,
|
|
166
|
+
label_map: Array.from(mapping.label_map.entries()),
|
|
167
|
+
resolver: Array.from(mapping.resolver.entries()),
|
|
168
|
+
hyper_resolver: []
|
|
169
|
+
});
|
|
159
170
|
}
|
|
160
171
|
function renameField(oldName, newName) {
|
|
161
172
|
return { type: "rename-field", old: oldName, new: newName };
|
|
@@ -1116,6 +1127,10 @@ class CompiledMigration {
|
|
|
1116
1127
|
get _handle() {
|
|
1117
1128
|
return this.#handle;
|
|
1118
1129
|
}
|
|
1130
|
+
/** The WASM module. Internal use only. */
|
|
1131
|
+
get _wasm() {
|
|
1132
|
+
return this.#wasm;
|
|
1133
|
+
}
|
|
1119
1134
|
/** The migration specification used to build this migration. */
|
|
1120
1135
|
get spec() {
|
|
1121
1136
|
return this.#spec;
|
|
@@ -1123,22 +1138,22 @@ class CompiledMigration {
|
|
|
1123
1138
|
/**
|
|
1124
1139
|
* Transform a record using this migration (forward direction).
|
|
1125
1140
|
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1141
|
+
* Accepts either a raw JS object (which will be msgpack-encoded) or
|
|
1142
|
+
* an `Instance` (whose pre-encoded bytes are passed directly to WASM).
|
|
1128
1143
|
*
|
|
1129
|
-
* @param record - The input record to transform
|
|
1144
|
+
* @param record - The input record or Instance to transform
|
|
1130
1145
|
* @returns The transformed record
|
|
1131
1146
|
* @throws {@link WasmError} if the WASM call fails
|
|
1132
1147
|
*/
|
|
1133
1148
|
lift(record) {
|
|
1134
|
-
const inputBytes = packToWasm(record);
|
|
1149
|
+
const inputBytes = record && typeof record === "object" && "_bytes" in record ? record._bytes : packToWasm(record);
|
|
1135
1150
|
try {
|
|
1136
1151
|
const outputBytes = this.#wasm.exports.lift_record(
|
|
1137
1152
|
this.#handle.id,
|
|
1138
1153
|
inputBytes
|
|
1139
1154
|
);
|
|
1140
1155
|
const data = unpackFromWasm(outputBytes);
|
|
1141
|
-
return { data };
|
|
1156
|
+
return { data, _rawBytes: outputBytes };
|
|
1142
1157
|
} catch (error) {
|
|
1143
1158
|
throw new WasmError(
|
|
1144
1159
|
`lift_record failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1157,7 +1172,7 @@ class CompiledMigration {
|
|
|
1157
1172
|
* @throws {@link WasmError} if the WASM call fails
|
|
1158
1173
|
*/
|
|
1159
1174
|
get(record) {
|
|
1160
|
-
const inputBytes = packToWasm(record);
|
|
1175
|
+
const inputBytes = record && typeof record === "object" && "_bytes" in record ? record._bytes : packToWasm(record);
|
|
1161
1176
|
try {
|
|
1162
1177
|
const outputBytes = this.#wasm.exports.get_record(
|
|
1163
1178
|
this.#handle.id,
|
|
@@ -1184,7 +1199,7 @@ class CompiledMigration {
|
|
|
1184
1199
|
* @throws {@link WasmError} if the WASM call fails
|
|
1185
1200
|
*/
|
|
1186
1201
|
put(view, complement) {
|
|
1187
|
-
const viewBytes = packToWasm(view);
|
|
1202
|
+
const viewBytes = view && typeof view === "object" && "_bytes" in view ? view._bytes : packToWasm(view);
|
|
1188
1203
|
try {
|
|
1189
1204
|
const outputBytes = this.#wasm.exports.put_record(
|
|
1190
1205
|
this.#handle.id,
|