@agoric/internal 0.3.3-dev-f00912e.0 → 0.3.3-dev-b2bff24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.3.3-dev-f00912e.0+f00912e",
3
+ "version": "0.3.3-dev-b2bff24.0+b2bff24",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,8 +20,9 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-f00912e.0+f00912e",
23
+ "@agoric/base-zone": "0.1.1-dev-b2bff24.0+b2bff24",
24
24
  "@endo/common": "^1.2.10",
25
+ "@endo/compartment-mapper": "^1.6.0",
25
26
  "@endo/errors": "^1.2.10",
26
27
  "@endo/far": "^1.1.11",
27
28
  "@endo/init": "^1.1.9",
@@ -35,7 +36,7 @@
35
36
  "jessie.js": "^0.3.4"
36
37
  },
37
38
  "devDependencies": {
38
- "@agoric/cosmic-proto": "0.4.1-dev-f00912e.0+f00912e",
39
+ "@agoric/cosmic-proto": "0.4.1-dev-b2bff24.0+b2bff24",
39
40
  "@endo/exo": "^1.5.9",
40
41
  "@endo/init": "^1.1.9",
41
42
  "@fast-check/ava": "^2.0.1",
@@ -62,5 +63,5 @@
62
63
  "typeCoverage": {
63
64
  "atLeast": 92.65
64
65
  },
65
- "gitHead": "f00912ef7f95b1fa938cce60ba2ee24f1b6af048"
66
+ "gitHead": "b2bff2406b336cd5e1dcd865c295bae93629e6c1"
66
67
  }
@@ -0,0 +1,2 @@
1
+ export function getSpecifier(fileUrl: string): Promise<string>;
2
+ //# sourceMappingURL=module-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-utils.d.ts","sourceRoot":"","sources":["module-utils.js"],"names":[],"mappings":"AAaO,sCAHI,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAc3B"}
@@ -0,0 +1,27 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { search } from '@endo/compartment-mapper';
4
+ import { Fail } from '@endo/errors';
5
+
6
+ /**
7
+ * Given a file URL, return a deep import specifier that starts with the
8
+ * specifier for its containing module (e.g., the deep import specifier for this
9
+ * file is expected to be "@agoric/internal/src/module-utils.js").
10
+ *
11
+ * @param {string} fileUrl
12
+ * @returns {Promise<string>}
13
+ */
14
+ export const getSpecifier = async fileUrl => {
15
+ // eslint-disable-next-line no-new
16
+ new URL(fileUrl); // validates fileUrl
17
+ const read = async location => {
18
+ const path = fileURLToPath(new URL(location, fileUrl));
19
+ return readFile(path);
20
+ };
21
+ const searchResult = await search(read, fileUrl);
22
+ const { packageDescriptorText, moduleSpecifier } = searchResult;
23
+ const { name } = JSON.parse(packageDescriptorText);
24
+ name || Fail`containing package must have a name`;
25
+ return `${name}/${moduleSpecifier.replace(/^\.\//, '')}`;
26
+ };
27
+ harden(getSpecifier);