@agoric/swingset-xsnap-supervisor 0.9.1-dev-6e51de2.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/src/index.js ADDED
@@ -0,0 +1,31 @@
1
+ import fs from 'fs';
2
+ import { bundlePaths, hashPaths } from './paths.js';
3
+
4
+ const read = (name, path) => {
5
+ return fs.promises.readFile(path, { encoding: 'utf-8' }).catch(err => {
6
+ console.error(`unable to read supervisor ${name} at ${path}`);
7
+ console.error(
8
+ `perhaps run 'yarn build' in @agoric/swingset-xsnap-supervisor`,
9
+ );
10
+ throw err;
11
+ });
12
+ };
13
+
14
+ /**
15
+ *
16
+ * @returns { Promise<string> }
17
+ */
18
+ export const getSupervisorBundleSHA256 = async () => {
19
+ const path = hashPaths.supervisor;
20
+ return read('hash', path).then(data => data.trim());
21
+ };
22
+
23
+ /**
24
+ *
25
+ * @typedef {{ moduleFormat: string, source: string, sourceMap: [string] }} Bundle
26
+ * @returns { Promise<Bundle> }
27
+ */
28
+ export const getSupervisorBundle = async () => {
29
+ const path = bundlePaths.supervisor;
30
+ return read('bundle', path).then(bundleString => JSON.parse(bundleString));
31
+ };
package/src/paths.js ADDED
@@ -0,0 +1,15 @@
1
+ // define these here, in one place, so both the builder and the
2
+ // client-facing API can see the same paths
3
+
4
+ export const bundlePaths = {
5
+ supervisor: new URL('../dist/supervisor.bundle', import.meta.url).pathname,
6
+ };
7
+
8
+ export const hashPaths = {
9
+ supervisor: new URL('../dist/supervisor.bundle.sha256', import.meta.url)
10
+ .pathname,
11
+ };
12
+
13
+ export const entryPaths = {
14
+ supervisor: new URL('../lib/entry.js', import.meta.url).pathname,
15
+ };