-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import-bundle): Support per-user source map caches
- Loading branch information
Showing
6 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/source-map-node-powers.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/source-map-node.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { whereEndoCache } from '@endo/where'; | ||
|
||
/** | ||
* @typedef {object} Process | ||
* @property {Record<string, string | undefined>} env | ||
* @property {string} platform | ||
*/ | ||
|
||
/** | ||
* @param {object} powers | ||
* @param {typeof import('node:url')} powers.url | ||
* @param {typeof import('node:os')} powers.os | ||
* @param {Process} powers.process | ||
*/ | ||
export const makeEndoSourceMapLocator = powers => { | ||
const { url, os, process } = powers; | ||
|
||
const home = os.userInfo().homedir; | ||
const cacheDirectory = whereEndoCache(process.platform, process.env, { | ||
home, | ||
}); | ||
const cacheLocation = url.pathToFileURL(cacheDirectory); | ||
|
||
/** | ||
* @param {object} details | ||
* @param {string} details.sha512 | ||
*/ | ||
const whereSourceMap = ({ sha512 }) => { | ||
const sha512Head = sha512.slice(0, 2); | ||
const sha512Tail = sha512.slice(2); | ||
return `${cacheLocation}/source-map/${sha512Head}/${sha512Tail}.map.json`; | ||
}; | ||
|
||
return whereSourceMap; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* global process */ | ||
import url from 'node:url'; | ||
import os from 'node:os'; | ||
import { makeEndoSourceMapLocator } from './source-map-node-powers.js'; | ||
|
||
export const computeSourceMapLocation = makeEndoSourceMapLocator({ | ||
url, | ||
os, | ||
process, | ||
}); |