@amalgm/shell 0.1.47 → 0.1.49
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/PURPOSE.md +26 -2
- package/dist/detection/runtime.d.ts +6 -2
- package/dist/detection/runtime.js +46 -18
- package/dist/detection/runtime.js.map +1 -1
- package/dist/files-register-host.js +6 -2
- package/dist/files-register-host.js.map +1 -1
- package/dist/user-ground-host.d.ts +9 -1
- package/dist/user-ground-host.js +404 -65
- package/dist/user-ground-host.js.map +1 -1
- package/package.json +2 -2
- package/dist/detection/journal-codec.d.ts +0 -3
- package/dist/detection/journal-codec.js +0 -34
- package/dist/detection/journal-codec.js.map +0 -1
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** Byte-exact JSON codec for the one durable mutation journal. */
|
|
2
|
-
import { stableJson } from "@amalgm/live";
|
|
3
|
-
const BYTES = "$amalgmBytesBase64";
|
|
4
|
-
const encodeValue = (value) => {
|
|
5
|
-
if (value instanceof Uint8Array) {
|
|
6
|
-
return { [BYTES]: Buffer.from(value).toString("base64") };
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(value))
|
|
9
|
-
return value.map(encodeValue);
|
|
10
|
-
if (value && typeof value === "object") {
|
|
11
|
-
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, encodeValue(child)]));
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
};
|
|
15
|
-
const decodeValue = (value) => {
|
|
16
|
-
if (Array.isArray(value))
|
|
17
|
-
return value.map(decodeValue);
|
|
18
|
-
if (value && typeof value === "object") {
|
|
19
|
-
const object = value;
|
|
20
|
-
if (Object.keys(object).length === 1 && typeof object[BYTES] === "string") {
|
|
21
|
-
const encoded = object[BYTES];
|
|
22
|
-
const bytes = Buffer.from(encoded, "base64");
|
|
23
|
-
if (bytes.toString("base64") !== encoded) {
|
|
24
|
-
throw new Error("mutation journal contains invalid byte encoding");
|
|
25
|
-
}
|
|
26
|
-
return new Uint8Array(bytes);
|
|
27
|
-
}
|
|
28
|
-
return Object.fromEntries(Object.entries(object).map(([key, child]) => [key, decodeValue(child)]));
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
};
|
|
32
|
-
export const encodeMutationOperation = (value) => stableJson(encodeValue(value));
|
|
33
|
-
export const decodeMutationOperation = (json) => decodeValue(JSON.parse(json));
|
|
34
|
-
//# sourceMappingURL=journal-codec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"journal-codec.js","sourceRoot":"","sources":["../../src/detection/journal-codec.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAEnC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAW,EAAE;IAC9C,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACxD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,KAAc,EAAW,EAAE;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE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