@endo/compartment-mapper
Advanced tools
| export * from "./src/types-external.js"; | ||
| export { makeFunctorFromMap } from "./src/bundle-lite.js"; | ||
| //# sourceMappingURL=functor-lite.d.ts.map |
| {"version":3,"file":"functor-lite.d.ts","sourceRoot":"","sources":["functor-lite.js"],"names":[],"mappings":""} |
| // eslint-disable-next-line import/export -- just types | ||
| export * from './src/types-external.js'; | ||
| export { makeFunctorFromMap } from './src/bundle-lite.js'; |
| export * from "./src/types-external.js"; | ||
| export { makeFunctor } from "./src/bundle.js"; | ||
| //# sourceMappingURL=functor.d.ts.map |
| {"version":3,"file":"functor.d.ts","sourceRoot":"","sources":["functor.js"],"names":[],"mappings":""} |
| // eslint-disable-next-line import/export -- just types | ||
| export * from './src/types-external.js'; | ||
| export { makeFunctor } from './src/bundle.js'; |
| export * from "./src/types-external.js"; | ||
| export { makeScriptFromMap } from "./src/bundle-lite.js"; | ||
| //# sourceMappingURL=script-lite.d.ts.map |
| {"version":3,"file":"script-lite.d.ts","sourceRoot":"","sources":["script-lite.js"],"names":[],"mappings":""} |
| // eslint-disable-next-line import/export -- just types | ||
| export * from './src/types-external.js'; | ||
| export { makeScriptFromMap } from './src/bundle-lite.js'; |
| export * from "./src/types-external.js"; | ||
| export { makeScript } from "./src/bundle.js"; | ||
| //# sourceMappingURL=script.d.ts.map |
| {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["script.js"],"names":[],"mappings":""} |
| // eslint-disable-next-line import/export -- just types | ||
| export * from './src/types-external.js'; | ||
| export { makeScript } from './src/bundle.js'; |
| export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>; | ||
| export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>; | ||
| /** | ||
| * The bundler kit defines a language-specific behavior for injecting a module | ||
| * into a bundle. | ||
| * Each module must allocate cells for its imports and exports, link those cells | ||
| * to the cells of dependencies, and provide both the linker and evaluation behavior | ||
| * for the module. | ||
| * The linker behavior gets injected in a lexical scope with the linker runtime | ||
| * and has access to the cells of all modules, whereas the evaluation behavior | ||
| * gets injected in the generated script's top level lexical scope, so has | ||
| * no accidental visibility into the linkage runtime. | ||
| * | ||
| * For example, JSON modules produce a single "default" cell ("getCells"): | ||
| * | ||
| * { default: cell('default') }, | ||
| * | ||
| * Then, the JSON gets injected verbatim for the evaluation behavior ("getFunctor"). | ||
| * The linker simply sets the cell to the value. | ||
| * | ||
| * functors[0]['default'].set(modules[0]); | ||
| * | ||
| * For an ECMAScript or CommonJS module, the evaluation behavior is a function | ||
| * that the linker runtime can call to inject it with the cells it needs by | ||
| * the names it sees for them. | ||
| */ | ||
| export type BundlerKit = { | ||
| /** | ||
| * Produces a JavaScript string consisting of | ||
| * a function expression followed by a comma delimiter that will be evaluated in | ||
| * a lexical scope with no free variables except the globals. | ||
| * In the generated bundle runtime, the function will receive an environment | ||
| * record: a record mapping every name of the corresponding module's internal | ||
| * namespace to a "cell" it can use to get, set, or observe the linked | ||
| * variable. | ||
| */ | ||
| getFunctor: () => string; | ||
| /** | ||
| * Produces a JavaScript string consisting of | ||
| * a JavaScript object and a trailing comma. | ||
| * The string is evaluated in the linker runtime's lexical context. | ||
| */ | ||
| getCells: () => string; | ||
| /** | ||
| * Produces a JavaScript string, | ||
| * a statement that effects the module's evaluation behavior using the cells | ||
| * it imports and exports and the evaluated "functor". | ||
| */ | ||
| getFunctorCall: () => string; | ||
| /** | ||
| * Produces a JavaScript string | ||
| * that may include statements that bind the cells reexported by this module. | ||
| */ | ||
| getReexportsWiring: () => string; | ||
| }; | ||
| export type BundleModule<SpecificModuleSource extends unknown> = { | ||
| key: string; | ||
| exit: string; | ||
| compartmentName: string; | ||
| moduleSpecifier: string; | ||
| sourceDirname: string; | ||
| parser: string; | ||
| record: StaticModuleType & SpecificModuleSource; | ||
| resolvedImports: Record<string, string>; | ||
| indexedImports: Record<string, number>; | ||
| bytes: Uint8Array; | ||
| index: number; | ||
| bundlerKit: BundlerKit; | ||
| }; | ||
| export type BundleExit = { | ||
| exit: string; | ||
| index: number; | ||
| bundlerKit: BundlerKit; | ||
| indexedImports: Record<string, number>; | ||
| resolvedImports: Record<string, string>; | ||
| }; | ||
| export type GetBundlerKit<SpecificModuleSource extends unknown> = (module: BundleModule<SpecificModuleSource>, params: { | ||
| useEvaluate?: boolean | undefined; | ||
| sourceUrlPrefix?: string | undefined; | ||
| }) => BundlerKit; | ||
| export type BundlerSupport<SpecificModuleSource extends unknown> = { | ||
| runtime: string; | ||
| getBundlerKit: GetBundlerKit<SpecificModuleSource>; | ||
| }; | ||
| import type { ReadFn } from './types.js'; | ||
| import type { ReadPowers } from './types.js'; | ||
| import type { MaybeReadPowers } from './types.js'; | ||
| import type { CompartmentMapDescriptor } from './types.js'; | ||
| import type { BundleOptions } from './types.js'; | ||
| import type { StaticModuleType } from 'ses'; | ||
| //# sourceMappingURL=bundle-lite.d.ts.map |
| {"version":3,"file":"bundle-lite.d.ts","sourceRoot":"","sources":["bundle-lite.js"],"names":[],"mappings":"AA4TO,+CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,wBAAwB,wCAEtB,OAAO,CAAC,MAAM,CAAC,CAgV3B;AAQM,8CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,wBAAwB,wCAEtB,OAAO,CAAC,MAAM,CAAC,CAW3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA/mBa,MAAM,MAAM;;;;;;cAOZ,MAAM,MAAM;;;;;;oBAGZ,MAAM,MAAM;;;;;wBAGZ,MAAM,MAAM;;yBAKH,oBAAoB,SAA9B,OAAS;SAER,MAAM;UACN,MAAM;qBACN,MAAM;qBACN,MAAM;mBACN,MAAM;YACN,MAAM;YACN,gBAAgB,GAAG,oBAAoB;qBACvC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;WACtB,UAAU;WACV,MAAM;gBACN,UAAU;;;UAKV,MAAM;WACN,MAAM;gBACN,UAAU;oBACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;qBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAIb,oBAAoB,SAA9B,OAAS,aAEX,YAAY,CAAC,oBAAoB,CAAC,UAE1C;IAAyB,WAAW;IACZ,eAAe;CACvC,KAAU,UAAU;2BAIA,oBAAoB,SAA9B,OAAS;aAER,MAAM;mBACN,aAAa,CAAC,oBAAoB,CAAC;;4BArFvC,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;8CAAZ,YAAY;mCAAZ,YAAY;sCAVZ,KAAK"} |
| /* eslint no-shadow: 0 */ | ||
| /** | ||
| * @import { | ||
| * StaticModuleType, | ||
| * PrecompiledStaticModuleInterface | ||
| * } from 'ses' | ||
| * @import { | ||
| * BundleOptions, | ||
| * CompartmentDescriptor, | ||
| * CompartmentMapDescriptor, | ||
| * CompartmentSources, | ||
| * MaybeReadPowers, | ||
| * ReadFn, | ||
| * ReadPowers, | ||
| * Sources, | ||
| * } from './types.js' | ||
| */ | ||
| /** | ||
| * The bundler kit defines a language-specific behavior for injecting a module | ||
| * into a bundle. | ||
| * Each module must allocate cells for its imports and exports, link those cells | ||
| * to the cells of dependencies, and provide both the linker and evaluation behavior | ||
| * for the module. | ||
| * The linker behavior gets injected in a lexical scope with the linker runtime | ||
| * and has access to the cells of all modules, whereas the evaluation behavior | ||
| * gets injected in the generated script's top level lexical scope, so has | ||
| * no accidental visibility into the linkage runtime. | ||
| * | ||
| * For example, JSON modules produce a single "default" cell ("getCells"): | ||
| * | ||
| * { default: cell('default') }, | ||
| * | ||
| * Then, the JSON gets injected verbatim for the evaluation behavior ("getFunctor"). | ||
| * The linker simply sets the cell to the value. | ||
| * | ||
| * functors[0]['default'].set(modules[0]); | ||
| * | ||
| * For an ECMAScript or CommonJS module, the evaluation behavior is a function | ||
| * that the linker runtime can call to inject it with the cells it needs by | ||
| * the names it sees for them. | ||
| * | ||
| * @typedef {object} BundlerKit | ||
| * @property {() => string} getFunctor Produces a JavaScript string consisting of | ||
| * a function expression followed by a comma delimiter that will be evaluated in | ||
| * a lexical scope with no free variables except the globals. | ||
| * In the generated bundle runtime, the function will receive an environment | ||
| * record: a record mapping every name of the corresponding module's internal | ||
| * namespace to a "cell" it can use to get, set, or observe the linked | ||
| * variable. | ||
| * @property {() => string} getCells Produces a JavaScript string consisting of | ||
| * a JavaScript object and a trailing comma. | ||
| * The string is evaluated in the linker runtime's lexical context. | ||
| * @property {() => string} getFunctorCall Produces a JavaScript string, | ||
| * a statement that effects the module's evaluation behavior using the cells | ||
| * it imports and exports and the evaluated "functor". | ||
| * @property {() => string} getReexportsWiring Produces a JavaScript string | ||
| * that may include statements that bind the cells reexported by this module. | ||
| */ | ||
| /** | ||
| * @template {unknown} SpecificModuleSource | ||
| * @typedef {object} BundleModule | ||
| * @property {string} key | ||
| * @property {string} exit | ||
| * @property {string} compartmentName | ||
| * @property {string} moduleSpecifier | ||
| * @property {string} sourceDirname | ||
| * @property {string} parser | ||
| * @property {StaticModuleType & SpecificModuleSource} record | ||
| * @property {Record<string, string>} resolvedImports | ||
| * @property {Record<string, number>} indexedImports | ||
| * @property {Uint8Array} bytes | ||
| * @property {number} index | ||
| * @property {BundlerKit} bundlerKit | ||
| */ | ||
| /** | ||
| * @typedef {object} BundleExit | ||
| * @property {string} exit | ||
| * @property {number} index | ||
| * @property {BundlerKit} bundlerKit | ||
| * @property {Record<string, number>} indexedImports | ||
| * @property {Record<string, string>} resolvedImports | ||
| */ | ||
| /** | ||
| * @template {unknown} SpecificModuleSource | ||
| * @callback GetBundlerKit | ||
| * @param {BundleModule<SpecificModuleSource>} module | ||
| * @param {object} params | ||
| * @param {boolean} [params.useEvaluate] | ||
| * @param {string} [params.sourceUrlPrefix] | ||
| * @returns {BundlerKit} | ||
| */ | ||
| /** | ||
| * @template {unknown} SpecificModuleSource | ||
| * @typedef {object} BundlerSupport | ||
| * @property {string} runtime | ||
| * @property {GetBundlerKit<SpecificModuleSource>} getBundlerKit | ||
| */ | ||
| import { resolve } from './node-module-specifier.js'; | ||
| import { link } from './link.js'; | ||
| import { makeImportHookMaker } from './import-hook.js'; | ||
| import { defaultParserForLanguage } from './archive-parsers.js'; | ||
| import mjsSupport from './bundle-mjs.js'; | ||
| import cjsSupport from './bundle-cjs.js'; | ||
| import jsonSupport from './bundle-json.js'; | ||
| const { quote: q } = assert; | ||
| /** | ||
| * @param {BundleExit} source | ||
| * @returns {BundlerKit} | ||
| */ | ||
| const makeCjsExitBundlerKit = ({ exit, index }) => ({ | ||
| getFunctor: () => `\ | ||
| null, | ||
| `, | ||
| getCells: () => `\ | ||
| namespaceCells(tryRequire(${JSON.stringify(exit)})), | ||
| `, | ||
| getReexportsWiring: () => '', | ||
| getFunctorCall: () => ``, | ||
| }); | ||
| /** | ||
| * Produces a list of modules in the order they should be evaluated, and | ||
| * a side-table for following aliases. | ||
| * The modules are produce in topological postorder, such that the entry | ||
| * module appears last. | ||
| * The post-order traversal does not revisit modules that appear in cycles. | ||
| * | ||
| * Synthesizes a unique key for each module and translates | ||
| * each module's imports to their corresponding keys. | ||
| * Some import keys are aliased to other keys, such that walking from | ||
| * key to value in the aliases side table will eventually arrive at | ||
| * the key of a module that is present in the modules list. | ||
| * | ||
| * The first modules are place-holders for the modules that exit | ||
| * the compartment map to the host's module system. | ||
| * | ||
| * @param {Record<string, CompartmentDescriptor>} compartmentDescriptors | ||
| * @param {Record<string, CompartmentSources>} compartmentSources | ||
| * @param {string} entryCompartmentName | ||
| * @param {string} entryModuleSpecifier | ||
| * @param {Array<string>} exitModuleSpecifiers | ||
| */ | ||
| const sortedModules = ( | ||
| compartmentDescriptors, | ||
| compartmentSources, | ||
| entryCompartmentName, | ||
| entryModuleSpecifier, | ||
| exitModuleSpecifiers, | ||
| ) => { | ||
| /** @type {BundleModule<unknown>[]} */ | ||
| const modules = []; | ||
| /** @type {Map<string, string>} aliaes */ | ||
| const aliases = new Map(); | ||
| /** @type {Set<string>} seen */ | ||
| const seen = new Set(); | ||
| for (const exit of exitModuleSpecifiers) { | ||
| modules.push({ | ||
| key: exit, | ||
| exit, | ||
| // @ts-expect-error | ||
| index: undefined, | ||
| // @ts-expect-error | ||
| bundlerKit: null, | ||
| }); | ||
| } | ||
| /** | ||
| * @param {string} compartmentName | ||
| * @param {string} moduleSpecifier | ||
| */ | ||
| const recur = (compartmentName, moduleSpecifier) => { | ||
| const key = `${compartmentName}#${moduleSpecifier}`; | ||
| if (seen.has(key)) { | ||
| return key; | ||
| } | ||
| seen.add(key); | ||
| const source = compartmentSources[compartmentName][moduleSpecifier]; | ||
| if (source !== undefined) { | ||
| const { record, parser, deferredError, bytes, sourceDirname, exit } = | ||
| source; | ||
| if (exit !== undefined) { | ||
| return exit; | ||
| } | ||
| assert( | ||
| bytes !== undefined, | ||
| `No bytes for ${moduleSpecifier} in ${compartmentName}`, | ||
| ); | ||
| assert( | ||
| parser !== undefined, | ||
| `No parser for ${moduleSpecifier} in ${compartmentName}`, | ||
| ); | ||
| assert( | ||
| sourceDirname !== undefined, | ||
| `No sourceDirname for ${moduleSpecifier} in ${compartmentName}`, | ||
| ); | ||
| if (deferredError) { | ||
| throw Error( | ||
| `Cannot bundle: encountered deferredError ${deferredError}`, | ||
| ); | ||
| } | ||
| if (record) { | ||
| const { imports = [], reexports = [] } = | ||
| /** @type {PrecompiledStaticModuleInterface} */ (record); | ||
| const resolvedImports = Object.create(null); | ||
| for (const importSpecifier of [...imports, ...reexports]) { | ||
| // If we ever support another module resolution algorithm, that | ||
| // should be indicated in the compartment descriptor by name and the | ||
| // corresponding behavior selected here. | ||
| const resolvedSpecifier = resolve(importSpecifier, moduleSpecifier); | ||
| resolvedImports[importSpecifier] = recur( | ||
| compartmentName, | ||
| resolvedSpecifier, | ||
| ); | ||
| } | ||
| modules.push({ | ||
| key, | ||
| compartmentName, | ||
| moduleSpecifier, | ||
| sourceDirname, | ||
| parser, | ||
| record, | ||
| resolvedImports, | ||
| bytes, | ||
| // @ts-expect-error | ||
| index: undefined, | ||
| // @ts-expect-error | ||
| bundlerKit: null, | ||
| }); | ||
| return key; | ||
| } | ||
| } else { | ||
| const descriptor = | ||
| compartmentDescriptors[compartmentName].modules[moduleSpecifier]; | ||
| if (descriptor) { | ||
| const { | ||
| compartment: aliasCompartmentName, | ||
| module: aliasModuleSpecifier, | ||
| } = descriptor; | ||
| if ( | ||
| aliasCompartmentName !== undefined && | ||
| aliasModuleSpecifier !== undefined | ||
| ) { | ||
| const aliasKey = recur(aliasCompartmentName, aliasModuleSpecifier); | ||
| aliases.set(key, aliasKey); | ||
| return aliasKey; | ||
| } | ||
| } | ||
| } | ||
| throw Error( | ||
| `Cannot bundle: cannot follow module import ${moduleSpecifier} in compartment ${compartmentName}`, | ||
| ); | ||
| }; | ||
| recur(entryCompartmentName, entryModuleSpecifier); | ||
| return { modules, aliases }; | ||
| }; | ||
| /** @type {Record<string, BundlerSupport<unknown>>} */ | ||
| const bundlerSupportForLanguage = { | ||
| 'pre-mjs-json': mjsSupport, | ||
| 'pre-cjs-json': cjsSupport, | ||
| json: jsonSupport, | ||
| }; | ||
| /** @param {string} language */ | ||
| const getRuntime = language => | ||
| bundlerSupportForLanguage[language] | ||
| ? bundlerSupportForLanguage[language].runtime | ||
| : `/*unknown language:${language}*/`; | ||
| /** | ||
| * @param {BundleModule<unknown>} module | ||
| * @param {object} params | ||
| * @param {boolean} [params.useEvaluate] | ||
| * @param {string} [params.sourceUrlPrefix] | ||
| */ | ||
| const getBundlerKitForModule = (module, params) => { | ||
| const language = module.parser; | ||
| assert(language !== undefined); | ||
| if (bundlerSupportForLanguage[language] === undefined) { | ||
| const warning = `/*unknown language:${language}*/`; | ||
| // each item is a function to avoid creating more in-memory copies of the source text etc. | ||
| /** @type {BundlerKit} */ | ||
| return { | ||
| getFunctor: () => `(()=>{${warning}}),`, | ||
| getCells: () => `{${warning}},`, | ||
| getFunctorCall: () => warning, | ||
| getReexportsWiring: () => '', | ||
| }; | ||
| } | ||
| const { getBundlerKit } = bundlerSupportForLanguage[language]; | ||
| return getBundlerKit(module, params); | ||
| }; | ||
| /** | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {CompartmentMapDescriptor} compartmentMap | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeFunctorFromMap = async ( | ||
| readPowers, | ||
| compartmentMap, | ||
| options, | ||
| ) => { | ||
| const { | ||
| moduleTransforms, | ||
| searchSuffixes, | ||
| sourceMapHook = undefined, | ||
| useEvaluate = false, | ||
| sourceUrlPrefix = undefined, | ||
| format = undefined, | ||
| parserForLanguage: parserForLanguageOption = {}, | ||
| } = options || {}; | ||
| /** @type {((module: BundleExit) => BundlerKit) | undefined} */ | ||
| let makeExitBundlerKit; | ||
| if (format === 'cjs') { | ||
| makeExitBundlerKit = makeCjsExitBundlerKit; | ||
| } | ||
| const parserForLanguage = Object.freeze( | ||
| Object.assign( | ||
| Object.create(null), | ||
| defaultParserForLanguage, | ||
| parserForLanguageOption, | ||
| ), | ||
| ); | ||
| const bundlerKitParams = { | ||
| useEvaluate, | ||
| sourceUrlPrefix, | ||
| }; | ||
| const { | ||
| compartments, | ||
| entry: { compartment: entryCompartmentName, module: entryModuleSpecifier }, | ||
| } = compartmentMap; | ||
| /** @type {string[]} */ | ||
| const exitModuleSpecifiers = []; | ||
| /** @type {Sources} */ | ||
| const sources = Object.create(null); | ||
| /** | ||
| * @param {string} moduleSpecifier | ||
| * @param {string} compartmentName | ||
| */ | ||
| const exitModuleImportHook = | ||
| format !== undefined | ||
| ? /** | ||
| * @param {string} moduleSpecifier | ||
| * @param {string} compartmentName | ||
| */ | ||
| async (moduleSpecifier, compartmentName) => { | ||
| const compartmentSources = | ||
| sources[compartmentName] || Object.create(null); | ||
| sources[compartmentName] = compartmentSources; | ||
| compartmentSources[moduleSpecifier] = { | ||
| exit: moduleSpecifier, | ||
| }; | ||
| exitModuleSpecifiers.push(moduleSpecifier); | ||
| return { imports: [], exports: [], execute() {} }; | ||
| } | ||
| : undefined; | ||
| const makeImportHook = makeImportHookMaker(readPowers, entryCompartmentName, { | ||
| archiveOnly: true, | ||
| sources, | ||
| compartmentDescriptors: compartments, | ||
| searchSuffixes, | ||
| entryCompartmentName, | ||
| entryModuleSpecifier, | ||
| sourceMapHook, | ||
| importHook: exitModuleImportHook, | ||
| }); | ||
| // Induce importHook to record all the necessary modules to import the given module specifier. | ||
| const { compartment } = link(compartmentMap, { | ||
| resolve, | ||
| makeImportHook, | ||
| moduleTransforms, | ||
| parserForLanguage, | ||
| }); | ||
| await compartment.load(entryModuleSpecifier); | ||
| const { modules, aliases } = sortedModules( | ||
| compartmentMap.compartments, | ||
| sources, | ||
| entryCompartmentName, | ||
| entryModuleSpecifier, | ||
| exitModuleSpecifiers, | ||
| ); | ||
| // Create an index of modules so we can resolve import specifiers to the | ||
| // index of the corresponding functor. | ||
| const modulesByKey = Object.create(null); | ||
| for (let index = 0; index < modules.length; index += 1) { | ||
| const module = modules[index]; | ||
| module.index = index; | ||
| modulesByKey[module.key] = module; | ||
| } | ||
| const parsersInUse = new Set(); | ||
| for (const module of modules) { | ||
| if (module.exit !== undefined) { | ||
| if (makeExitBundlerKit === undefined) { | ||
| // makeExitBundlerKit must have been provided to makeImportHookMaker for any modules with an exit property to have been created. | ||
| throw TypeError('Unreachable'); | ||
| } | ||
| module.bundlerKit = makeExitBundlerKit(module); | ||
| } else { | ||
| module.indexedImports = Object.fromEntries( | ||
| Object.entries(module.resolvedImports).map(([importSpecifier, key]) => { | ||
| // UNTIL https://github.com/endojs/endo/issues/1514 | ||
| // Prefer: key = aliases.get(key) ?? key; | ||
| const alias = aliases.get(key); | ||
| if (alias != null) { | ||
| key = alias; | ||
| } | ||
| const module = modulesByKey[key]; | ||
| if (module === undefined) { | ||
| throw new Error( | ||
| `Unable to locate module for key ${q(key)} import specifier ${q( | ||
| importSpecifier, | ||
| )}`, | ||
| ); | ||
| } | ||
| const { index } = module; | ||
| return [importSpecifier, index]; | ||
| }), | ||
| ); | ||
| parsersInUse.add(module.parser); | ||
| module.bundlerKit = getBundlerKitForModule(module, bundlerKitParams); | ||
| } | ||
| } | ||
| // Some bundles appeal to the host module system appropriate to their format | ||
| // like `require` for bundles used as CommonJS modules. | ||
| // Each module in the modules array is constructed by a language-specific bundler kit, | ||
| // and in the case of an exit module, is a bundler kit made with | ||
| // makeExitBundlerKit, like makeCjsExitBundlerKit. | ||
| // This will generate a module initialization runtime that in turn needs this | ||
| // namespaceCells utility function to take a host module exports namespace | ||
| // and turn it into a bank of cells for importing and exporting the | ||
| // properties of the module exports namespace object. | ||
| const exitNamespaces = | ||
| exitModuleSpecifiers.length === 0 | ||
| ? '' | ||
| : `\ | ||
| const namespaceCells = namespace => fromEntries( | ||
| getOwnPropertyNames(namespace) | ||
| .map(name => [name, { | ||
| get() { | ||
| return get(namespace, name); | ||
| }, | ||
| set() { | ||
| throw new TypeError('Non-writable export'); | ||
| }, | ||
| observe(observer) { | ||
| observer(get(namespace, name)); | ||
| }, | ||
| enumerable: true, | ||
| }]) | ||
| ); | ||
| `; | ||
| // The linkage runtime creates a cell for every value exported by any of the | ||
| // bundled modules. | ||
| // The interface of a cell is very much like a getter/setter property | ||
| // deescriptor, and additionally has a method for registering an observer to | ||
| // notice when a variable is changed in its originating module, to support | ||
| // live bindings. | ||
| // Each module language defines its own behavior for the generation of its | ||
| // exported cells. | ||
| // After all cells are allocated, each language gets a second opportunity | ||
| // to introduce bindings for cells that the module re-exports from another | ||
| // module, but does not itself own. | ||
| const runtimeLinkageCells = `\ | ||
| const cell = (name, value = undefined) => { | ||
| const observers = []; | ||
| return freeze({ | ||
| get: freeze(() => { | ||
| return value; | ||
| }), | ||
| set: freeze((newValue) => { | ||
| value = newValue; | ||
| for (let i = 0; i < observers.length; i += 1) { | ||
| const observe = observers[i]; | ||
| observe(value); | ||
| } | ||
| }), | ||
| observe: freeze((observe) => { | ||
| observers.push(observe); | ||
| observe(value); | ||
| }), | ||
| enumerable: true, | ||
| }); | ||
| }; | ||
| const cells = [ | ||
| ${''.concat(...modules.map(m => m.bundlerKit.getCells()))}\ | ||
| ]; | ||
| ${''.concat(...modules.map(m => m.bundlerKit.getReexportsWiring()))}\ | ||
| `; | ||
| // The linker runtime includes a parallel array of module exports namespace | ||
| // objects for each bundled module, for each respective index of the module | ||
| // functors array. | ||
| // Each namespace has a special '*' property for the namespace object itself, | ||
| // which is what modules obtain with `import * as x from 'x'` notation. | ||
| const moduleNamespaces = `\ | ||
| const namespaces = cells.map(cells => freeze(create(null, { | ||
| ...cells, | ||
| // Make this appear like an ESM module namespace object. | ||
| [Symbol.toStringTag]: { | ||
| value: 'Module', | ||
| writable: false, | ||
| enumerable: false, | ||
| configurable: false, | ||
| }, | ||
| }))); | ||
| for (let index = 0; index < namespaces.length; index += 1) { | ||
| cells[index]['*'] = cell('*', namespaces[index]); | ||
| } | ||
| `; | ||
| // Each language in use within the bundle has an opportunity to inject | ||
| // utilities into the bundle runtime that it can use in the shared lexical | ||
| // scope of module execution. | ||
| // CommonJS in particular injects a utility function here, if the script | ||
| // entrains any CommonJS modules. | ||
| const languageRuntimeExtensions = `\ | ||
| ${''.concat(...Array.from(parsersInUse).map(parser => getRuntime(parser)))}\ | ||
| `; | ||
| // This section of the linker runtime causes each of the modules to execute | ||
| // in topological order, using a language-specific calling convention to | ||
| // link its imports and exports to other modules. | ||
| const moduleExecutionRuntime = `\ | ||
| ${''.concat(...modules.map(m => m.bundlerKit.getFunctorCall()))}\ | ||
| `; | ||
| // The linker runtime receives an array of language-specific representations | ||
| // of each module, which in the simplest case is just a function and a | ||
| // runtime initialization calling convention (a functor). | ||
| // Then, in the style of partial application, it receives runtime options. | ||
| // When driven by makeScript, the script will statically apply the options, | ||
| // but with makeFunctor, the runtime must evaluate and apply runtime options. | ||
| // Scripts are suitable for injection with <script> tags on the web, whereas | ||
| // functors require use of an evaluator at runtime. | ||
| const linkerRuntime = `functors => options => { | ||
| 'use strict'; | ||
| const { | ||
| Map, | ||
| Object, | ||
| ReferenceError, | ||
| Reflect, | ||
| TypeError, | ||
| } = globalThis; | ||
| const { | ||
| create, | ||
| defineProperties, | ||
| defineProperty, | ||
| freeze, | ||
| fromEntries, | ||
| getOwnPropertyDescriptors, | ||
| getOwnPropertyNames, | ||
| keys, | ||
| } = Object; | ||
| const { get, set } = Reflect; | ||
| const { | ||
| ${ | ||
| !useEvaluate | ||
| ? '' | ||
| : `\ | ||
| evaluate = eval, | ||
| sourceUrlPrefix = ${JSON.stringify(sourceUrlPrefix)}, | ||
| ` | ||
| }\ | ||
| ${ | ||
| format !== 'cjs' | ||
| ? '' | ||
| : `\ | ||
| require: tryRequire = typeof require === 'function' ? require : specifier => { | ||
| throw new TypeError('Cannot import host module: ' + specifier); | ||
| }, | ||
| ` | ||
| }\ | ||
| } = options || {}; | ||
| ${ | ||
| !useEvaluate | ||
| ? '' | ||
| : `\ | ||
| const evaluateSource = (source, sourceUrl) => { | ||
| return evaluate(source + '\\n//# sourceURL=' + sourceUrlPrefix + sourceUrl + '\\n'); | ||
| };` | ||
| }\ | ||
| ${exitNamespaces}\ | ||
| ${runtimeLinkageCells}\ | ||
| ${moduleNamespaces}\ | ||
| ${languageRuntimeExtensions}\ | ||
| ${moduleExecutionRuntime}\ | ||
| return cells[cells.length - 1]['*'].get(); | ||
| }`; | ||
| // An array of language-specific representations of each bundled module, | ||
| // which in the simplest case is a function that must be initialized by the | ||
| // linkage runtime using a calling convention. | ||
| // We pass this array into the linkage runtime rather than embedding it in | ||
| // the linkage runtime in order to assure that the runtime's lexical context | ||
| // doesn't overshadow each module's lexical scope. | ||
| const moduleFunctors = `[ | ||
| ${''.concat( | ||
| ...modules.map( | ||
| (m, index) => `\ | ||
| // === ${index}. ${m.sourceDirname} ${m.moduleSpecifier} === | ||
| ${m.bundlerKit.getFunctor()}`, | ||
| ), | ||
| )}\ | ||
| ]`; | ||
| // Functors partially apply the linker runtime. | ||
| // Scripts go on to apply static options and execute immediately. | ||
| return `(${linkerRuntime})(${moduleFunctors})`; | ||
| }; | ||
| /** | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {CompartmentMapDescriptor} compartmentMap | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeScriptFromMap = async ( | ||
| readPowers, | ||
| compartmentMap, | ||
| options, | ||
| ) => { | ||
| // Functors partially apply the linker runtime. | ||
| // Scripts go on to apply static options and execute immediately. | ||
| const functor = await makeFunctorFromMap(readPowers, compartmentMap, options); | ||
| return `${functor}()`; | ||
| }; |
| import type { Language, LanguageForExtension } from './compartment-map-schema.js'; | ||
| import type { LogOptions } from './external.js'; | ||
| import type { PackageDescriptor } from './internal.js'; | ||
| export type CommonDependencyDescriptors = Record<string, { | ||
| spec: string; | ||
| alias: string; | ||
| }>; | ||
| export type GraphPackageOptions = { | ||
| preferredPackageLogicalPathMap?: Map<string, string[]>; | ||
| logicalPath?: string[]; | ||
| commonDependencyDescriptors?: CommonDependencyDescriptors; | ||
| } & LogOptions; | ||
| export type GraphPackagesOptions = LogOptions; | ||
| export type GatherDependencyOptions = { | ||
| childLogicalPath?: string[]; | ||
| /** | ||
| * If `true` the dependency is optional | ||
| */ | ||
| optional?: boolean; | ||
| /** | ||
| * Dependencies added to _all_ packages | ||
| */ | ||
| commonDependencyDescriptors?: CommonDependencyDescriptors; | ||
| } & LogOptions; | ||
| export interface Node { | ||
| /** | ||
| * Informative compartment label based on the package name and version (if available) | ||
| */ | ||
| label: string; | ||
| /** | ||
| * Package name | ||
| */ | ||
| name: string; | ||
| path: Array<string>; | ||
| logicalPath: Array<string>; | ||
| /** | ||
| * `true` if the package's {@link PackageDescriptor} has an `exports` field | ||
| */ | ||
| explicitExports: boolean; | ||
| internalAliases: Record<string, string>; | ||
| externalAliases: Record<string, string>; | ||
| /** | ||
| * The name of the original package's parent directory, for reconstructing | ||
| * a sourceURL that is likely to converge with the original location in an IDE. | ||
| */ | ||
| sourceDirname: string; | ||
| /** | ||
| * An object whose keys are the thing being imported, and the values are the | ||
| * names of the matching module (relative to the containing package's root; | ||
| * i.e. the URL that was used as the key of graph). | ||
| * | ||
| * The values are the keys of other {@link Node Nodes} in the {@link Graph}. | ||
| */ | ||
| dependencyLocations: Record<string, string>; | ||
| parsers: LanguageForExtension; | ||
| types: Record<string, Language>; | ||
| } | ||
| /** | ||
| * The graph is an intermediate object model that the functions of this module | ||
| * build by exploring the `node_modules` tree dropped by tools like npm and | ||
| * consumed by tools like Node.js. | ||
| * This gets translated finally into a compartment map. | ||
| */ | ||
| export type Graph = Record<string, Node>; | ||
| export interface LanguageOptions { | ||
| commonjsLanguageForExtension: LanguageForExtension; | ||
| moduleLanguageForExtension: LanguageForExtension; | ||
| workspaceCommonjsLanguageForExtension: LanguageForExtension; | ||
| workspaceModuleLanguageForExtension: LanguageForExtension; | ||
| languages: Set<string>; | ||
| } | ||
| /** | ||
| * Object result of `findPackage()` | ||
| */ | ||
| export interface PackageDetails { | ||
| packageLocation: string; | ||
| packageDescriptor: PackageDescriptor; | ||
| } | ||
| //# sourceMappingURL=node-modules.d.ts.map |
| {"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAChC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,C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E,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;CACtC"} |
| import type { | ||
| Language, | ||
| LanguageForExtension, | ||
| } from './compartment-map-schema.js'; | ||
| import type { LogOptions } from './external.js'; | ||
| import type { PackageDescriptor } from './internal.js'; | ||
| export type CommonDependencyDescriptors = Record< | ||
| string, | ||
| { spec: string; alias: string } | ||
| >; | ||
| export type GraphPackageOptions = { | ||
| preferredPackageLogicalPathMap?: Map<string, string[]>; | ||
| logicalPath?: string[]; | ||
| commonDependencyDescriptors?: CommonDependencyDescriptors; | ||
| } & LogOptions; | ||
| export type GraphPackagesOptions = LogOptions; | ||
| export type GatherDependencyOptions = { | ||
| childLogicalPath?: string[]; | ||
| /** | ||
| * If `true` the dependency is optional | ||
| */ | ||
| optional?: boolean; | ||
| /** | ||
| * Dependencies added to _all_ packages | ||
| */ | ||
| commonDependencyDescriptors?: CommonDependencyDescriptors; | ||
| } & LogOptions; | ||
| export interface Node { | ||
| /** | ||
| * Informative compartment label based on the package name and version (if available) | ||
| */ | ||
| label: string; | ||
| /** | ||
| * Package name | ||
| */ | ||
| name: string; | ||
| path: Array<string>; | ||
| logicalPath: Array<string>; | ||
| /** | ||
| * `true` if the package's {@link PackageDescriptor} has an `exports` field | ||
| */ | ||
| explicitExports: boolean; | ||
| internalAliases: Record<string, string>; | ||
| externalAliases: Record<string, string>; | ||
| /** | ||
| * The name of the original package's parent directory, for reconstructing | ||
| * a sourceURL that is likely to converge with the original location in an IDE. | ||
| */ | ||
| sourceDirname: string; | ||
| /** | ||
| * An object whose keys are the thing being imported, and the values are the | ||
| * names of the matching module (relative to the containing package's root; | ||
| * i.e. the URL that was used as the key of graph). | ||
| * | ||
| * The values are the keys of other {@link Node Nodes} in the {@link Graph}. | ||
| */ | ||
| dependencyLocations: Record<string, string>; | ||
| parsers: LanguageForExtension; | ||
| types: Record<string, Language>; | ||
| } | ||
| /** | ||
| * The graph is an intermediate object model that the functions of this module | ||
| * build by exploring the `node_modules` tree dropped by tools like npm and | ||
| * consumed by tools like Node.js. | ||
| * This gets translated finally into a compartment map. | ||
| */ | ||
| export type Graph = Record<string, Node>; | ||
| export interface LanguageOptions { | ||
| commonjsLanguageForExtension: LanguageForExtension; | ||
| moduleLanguageForExtension: LanguageForExtension; | ||
| workspaceCommonjsLanguageForExtension: LanguageForExtension; | ||
| workspaceModuleLanguageForExtension: LanguageForExtension; | ||
| languages: Set<string>; | ||
| } | ||
| /** | ||
| * Object result of `findPackage()` | ||
| */ | ||
| export interface PackageDetails { | ||
| packageLocation: string; | ||
| packageDescriptor: PackageDescriptor; | ||
| } |
+1
-1
| export * from "./src/types-external.js"; | ||
| export { makeBundle, writeBundle } from "./src/bundle.js"; | ||
| export { makeScript as makeBundle, writeScript as writeBundle } from "./src/bundle.js"; | ||
| //# sourceMappingURL=bundle.d.ts.map |
+4
-1
| // eslint-disable-next-line import/export -- just types | ||
| export * from './src/types-external.js'; | ||
| export { makeBundle, writeBundle } from './src/bundle.js'; | ||
| export { | ||
| makeScript as makeBundle, | ||
| writeScript as writeBundle, | ||
| } from './src/bundle.js'; |
+1
-1
@@ -7,3 +7,3 @@ export * from "./src/types-external.js"; | ||
| export { parseArchive, loadArchive, importArchive } from "./src/import-archive.js"; | ||
| export { makeBundle, writeBundle } from "./src/bundle.js"; | ||
| export { makeScript as makeBundle, writeScript as writeBundle } from "./src/bundle.js"; | ||
| //# sourceMappingURL=index.d.ts.map |
+4
-1
@@ -19,2 +19,5 @@ // eslint-disable-next-line import/export -- just types | ||
| export { compartmentMapForNodeModules } from './src/node-modules.js'; | ||
| export { makeBundle, writeBundle } from './src/bundle.js'; | ||
| export { | ||
| makeScript as makeBundle, | ||
| writeScript as writeBundle, | ||
| } from './src/bundle.js'; |
+8
-4
| { | ||
| "name": "@endo/compartment-mapper", | ||
| "version": "1.5.0", | ||
| "version": "1.6.0", | ||
| "description": "The compartment mapper assembles Node applications in a sandbox", | ||
@@ -42,2 +42,6 @@ "keywords": [ | ||
| "./bundle.js": "./bundle.js", | ||
| "./functor.js": "./functor.js", | ||
| "./functor-lite.js": "./functor-lite.js", | ||
| "./script.js": "./script.js", | ||
| "./script-lite.js": "./script-lite.js", | ||
| "./node-powers.js": "./node-powers.js", | ||
@@ -61,6 +65,6 @@ "./node-modules.js": "./node-modules.js", | ||
| "@endo/cjs-module-analyzer": "^1.0.9", | ||
| "@endo/module-source": "^1.2.0", | ||
| "@endo/module-source": "^1.3.0", | ||
| "@endo/trampoline": "^1.0.3", | ||
| "@endo/zip": "^1.0.9", | ||
| "ses": "^1.11.0" | ||
| "ses": "^1.12.0" | ||
| }, | ||
@@ -119,3 +123,3 @@ "devDependencies": { | ||
| }, | ||
| "gitHead": "e0683e0bfdbfc84351af332c9e78813d7b67ef89" | ||
| "gitHead": "9b6784831d37db948cdd61f6da1f3489e8f97906" | ||
| } |
+278
-111
@@ -14,4 +14,6 @@ # Compartment mapper | ||
| The `importLocation` function runs a compartmentalized application off the file | ||
| system. | ||
| ## Evaluating an application from a file system | ||
| The `importLocation` function evaluates a compartmentalized application off the | ||
| file system. | ||
| The `globals` are properties to add to the `globalThis` in the global scope | ||
@@ -24,2 +26,3 @@ of the application's main package compartment. | ||
| import fs from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import { importLocation } from "@endo/compartment-mapper"; | ||
@@ -29,15 +32,11 @@ | ||
| const modules = { fs }; | ||
| const globals = { console }; | ||
| const read = async location => fs.promises.readFile(fileURLToPath(location)); | ||
| const read = async location => | ||
| fs.promises.readFile(new URL(location).pathname); | ||
| const { namespace } = await importLocation( | ||
| const { namespace: moduleExports } = await importLocation( | ||
| read, | ||
| moduleLocation, | ||
| moduleSpecifier, | ||
| { | ||
| globals, | ||
| modules | ||
| } | ||
| globals: { console }, | ||
| modules: { fs }, | ||
| }, | ||
| ); | ||
@@ -52,32 +51,37 @@ ``` | ||
| not import any powerful modules like `fs`. | ||
| The user must provide `read` and `write` functions from whatever IO powers they | ||
| have. These powers can be provided as individual functions or as objects | ||
| carrying functions. `ReadPowers` has optional functions which can be used to | ||
| unlock compatibility features. When `fileURLToPath` is available, `__dirname` | ||
| and `__filename` will be provided to CJS modules. If `requireResolve` is | ||
| available, it will be called whenever a CJS module calls `require.resolve()`. | ||
| The caller must provide read powers in the first argument as either a ReadPowers | ||
| object or as a standalone `read` function. ReadPowers has optional functions | ||
| which can be used to unlock compatibility features. When `fileURLToPath` is | ||
| available, `__dirname` and `__filename` will be provided to CJS modules. When | ||
| `requireResolve` is available, it will be called whenever a CJS module calls | ||
| [`require.resolve()`]. | ||
| ```js | ||
| ```ts | ||
| type ReadPowers = { | ||
| read: (location: string) => Promise<Uint8Array>, | ||
| canonical: (location: string) => Promise<string>, | ||
| computeSha512: { (bytes: Uint8Array) => string }?, | ||
| fileURLToPath: { (url: string | URL) => string }?, | ||
| pathToFileURL: { (path: string) => URL }?, | ||
| requireResolve: { (from: string, request: string, options?: {}) => string }? | ||
| computeSha512?: (bytes: Uint8Array) => string, | ||
| fileURLToPath?: (location: string | URL) => string, | ||
| pathToFileURL?: (path: string) => URL, | ||
| requireResolve?: ( | ||
| fromLocation: string, | ||
| specifier: string, | ||
| options?: { paths?: string[] }, | ||
| ) => string | ||
| } | ||
| ``` | ||
| > TODO | ||
| > | ||
| > A future version will allow application authors to distribute their choices | ||
| > of globals and built-in modules to third-party packages within the | ||
| > [!NOTE] | ||
| > TODO: A future version will allow application authors to distribute their | ||
| > choices of globals and built-in modules to third-party packages within the | ||
| > application, as with [LavaMoat]. | ||
| The `importLocation` function uses `loadLocation`. | ||
| Using `loadLocation` directly allows for deferred execution or multiple runs | ||
| with different globals or modules in the same process. | ||
| Calling `loadLocation` returns an `Application` object with an | ||
| The `importLocation` function internally uses `loadLocation`. | ||
| Use `loadLocation` to defer execution or evaluate multiple times with varying | ||
| globals or modules in the same process. | ||
| `loadLocation` returns an Application object with an | ||
| `import({ globals?, modules? })` method. | ||
| ## Writing an application archive | ||
| Use `writeArchive` to capture an application in an archival format. | ||
@@ -88,20 +92,21 @@ Archives are `zip` files with a `compartment-map.json` manifest file. | ||
| import fs from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import { writeArchive } from "@endo/compartment-mapper"; | ||
| const read = async location => | ||
| fs.promises.readFile(new URL(location).pathname); | ||
| const read = async location => fs.promises.readFile(fileURLToPath(location)); | ||
| const write = async (location, content) => | ||
| fs.promises.writeFile(new URL(location).pathname, content); | ||
| fs.promises.writeFile(fileURLToPath(location), content); | ||
| await writeArchive( | ||
| write, | ||
| read, | ||
| new URL('app.zip', import.meta.url).toString(), // the archive to write | ||
| new URL('app.js', import.meta.url).toString() // the application to capture | ||
| ); | ||
| const moduleSpecifier = new URL('app.js', import.meta.url).toString(); | ||
| const archiveLocation = new URL('app.zip', import.meta.url).toString(); | ||
| // Write to `archiveLocation`. | ||
| await writeArchive(write, read, archiveLocation, moduleSpecifier); | ||
| ``` | ||
| The `writeArchive` function uses `makeArchive`. | ||
| The `writeArchive` function internally uses `makeArchive`. | ||
| Using `makeArchive` directly gives you the archive bytes. | ||
| ## Evaluating an application from an archive | ||
| Use `importArchive` to run an application from an archive. | ||
@@ -112,2 +117,3 @@ Note the similarity to `importLocation`. | ||
| import fs from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
| import { importArchive } from "@endo/compartment-mapper"; | ||
@@ -117,28 +123,192 @@ | ||
| const modules = { fs }; | ||
| const globals = { console }; | ||
| const read = async location => fs.promises.readFile(fileURLToPath(location)); | ||
| const read = async location => | ||
| fs.promises.readFile(new URL(location).pathname); | ||
| const { namespace } = await importArchive( | ||
| const { namespace: moduleExports } = await importArchive( | ||
| read, | ||
| archiveLocation, | ||
| { | ||
| globals, | ||
| modules | ||
| } | ||
| globals: { console }, | ||
| modules: { fs }, | ||
| }, | ||
| ); | ||
| ``` | ||
| The `importArchive` function composes `loadArchive` and `parseArchive`. | ||
| The `importArchive` function internally composes `loadArchive` and | ||
| `parseArchive`. | ||
| Use `loadArchive` to defer execution or run multiple times with varying | ||
| globals. | ||
| globals or modules in the same process. | ||
| Use `parseArchive` to construct a runner from the bytes of an archive. | ||
| The `loadArchive` and `parseArchive` functions return an `Application` | ||
| object with an `import({ globals?, modules? })` method. | ||
| `loadArchive` and `parseArchive` return an Application object with an | ||
| `import({ globals?, modules? })` method. | ||
| `loadArchive` and `parseArchive` do not run the archived program, | ||
| so they can be used to check the hash of a program without running it. | ||
| `loadArchive` and `parseArchive` do not run the archived application, | ||
| so they can be used to safely check its hash. | ||
| # Script bundles | ||
| From `@endo/compartment-mapper/script.js`, the `makeScript` function is similar | ||
| to `makeArchive` but generates a string of JavaScript suitable for `eval` or | ||
| embedding in a web page with a `<script>`. | ||
| Endo uses this "bundle" format to bootstrap an environment up to the point it | ||
| can call `importArchive`, so bundles are at least suitable for creating a | ||
| script that subsumes `ses`, `@endo/compartment-mapper/import-archive.js`, and | ||
| other parts of Endo, but is not as feature-complete as `importArchive`. | ||
| ```js | ||
| import url from "url"; | ||
| import fs from "fs"; | ||
| import { makeScript } from "@endo/compartment-mapper/script.js"; | ||
| import { makeReadPowers } from "@endo/compartment-mapper/node-powers.js"; | ||
| const readPowers = makeReadPowers({ fs, url }); | ||
| const options = {}; // if any | ||
| const script = await makeScript(readPowers, moduleSpecifier, options); | ||
| ``` | ||
| The script is suitable for evaluating as a script in a web environment. | ||
| The script is in UTF-8 format and uses non-ASCII characters, so may require | ||
| headers or tags to specify the encoding. | ||
| ```html | ||
| <meta charset="utf-8"> | ||
| <script src="script.js"></script> | ||
| ``` | ||
| Evaluation of `script` returns the emulated exports namespace of the entry | ||
| module. | ||
| ```js | ||
| const script = await makeScript(readPowers, moduleSpecifier, options); | ||
| // This one weird trick evaluates your script in global scope instead of | ||
| // lexical scope. | ||
| const globalEval = eval; | ||
| const moduleExports = globalEval(script); | ||
| ``` | ||
| Scripts can include ESM, CJS, and JSON modules, but no other module languages | ||
| like bytes or text. | ||
| > [!WARNING] | ||
| > Scripts do not support [live | ||
| > bindings](https://developer.mozilla.org/en-US/docs/Glossary/Binding), dynamic | ||
| > `import`, or `import.meta`. | ||
| > Scripts do not isolate modules to a compartment. | ||
| `makeScript` accepts all the options of `makeArchive` and: | ||
| - `sourceUrlPrefix` (string, default `""`): | ||
| Specifies a prefix to occur on each module's `sourceURL` comment, as injected | ||
| at runtime. | ||
| Should generally end with `/` if non-empty. | ||
| This can improve stack traces. | ||
| - `format` (`"cjs"` or `undefined`, default `undefined`): | ||
| By default, `makeBundle` generates a bundle that can be evaluated in any | ||
| context. | ||
| By specifying `"cjs"`, the bundle can assume there is a host CommonJS | ||
| `require` function available for resolving modules that exit the bundle. | ||
| The default is `require` on `globalThis`. | ||
| The `require` function can be overridden with a curried runtime option. | ||
| - `useEvaluate` (boolean, default `false`): | ||
| Disabled by default, for bundles that may be embedded on a web page with a | ||
| `no-unsafe-eval` Content Security Policy. | ||
| Enable for any environment that can use `eval` or other suitable evaluator | ||
| (like a Hardened JavaScript `Compartment`). | ||
| By default and when `useEvaluate` is explicitly `false`, the text of a module | ||
| includes an array of module evaluator functions. | ||
| > [!WARNING] | ||
| > Example is illustrative and neither a compatibility guarantee nor even | ||
| > precise. | ||
| ```js | ||
| (modules => options => { | ||
| /* ...linker runtime... */ | ||
| for (const module of modules) { | ||
| module(/* linking convention */); | ||
| } | ||
| )([ | ||
| // 1. bundle ./dependency.js | ||
| function () { /* ... */ }, | ||
| // 2. bundle ./dependent.js | ||
| function () { /* ... */ }, | ||
| ])(/* runtime options */) | ||
| ``` | ||
| Each of these functions is generated by [Endo's emulation of a JavaScript | ||
| `ModuleSource` | ||
| constructor](https://github.com/endojs/endo/blob/master/packages/module-source/DESIGN.md), | ||
| which we use elsewhere in the Compartment Mapper to emulate Compartment | ||
| module systems at runtime, as in the Compartment Mapper's own `importArchive`. | ||
| With `useEvaluate`, the script instead embeds the text for each module as a | ||
| string, along with a package-relative source URL, and uses an `eval` function | ||
| to produce the corresponding `function`. | ||
| ```js | ||
| (modules => options => { | ||
| /* ...linker runtime... */ | ||
| for (const [module, sourceURL] of modules) { | ||
| evalWithSourceURL(module, sourceURL)(/* linking convention */); | ||
| } | ||
| )([ | ||
| // 1. bundle ./dependency.js | ||
| ["(function () { /* ... */ })", "bundle/dependency.js"], | ||
| // 2. bundle ./dependent.js | ||
| ["(function () { /* ... */ })", "bundle/dependent.js"], | ||
| ])(/* runtime options */) | ||
| ``` | ||
| With `useEvaluate`, the bundle will instead capture a string for | ||
| each module function and use an indirect `eval` to revive them. | ||
| This can make the file locations and line numbers in stack traces more | ||
| useful. | ||
| From `@endo/compartment-mapper/script-lite.js`, the `makeScriptFromMap` takes | ||
| a compartment map, like that generated by `mapNodeModules` in | ||
| `@endo/compartment-mapper/node-modules.js` instead of the entry module's | ||
| location. | ||
| The `-lite.js` modules, in general, do not entrain a specific compartment | ||
| mapper. | ||
| # Functor bundles | ||
| From `@endo/compartment-mapper/functor.js`, the `makeFunctor` function is similar | ||
| to `makeScript` but generates a string of JavaScript suitable for `eval` but *not* | ||
| suitable for embedding as a script. But, the completion value of the script | ||
| is a function that accepts runtime options and returns the entry module's emulated | ||
| module exports namespace, adding a level of indirection. | ||
| In this example, we use a Hardened JavaScript `Compartment` to confine the | ||
| execution of the functor and its modules. | ||
| ```js | ||
| const functorScript = await makeFunctor(readPowers, moduleSpecifier, options); | ||
| const compartment = new Compartment(); | ||
| const moduleExports = compartment.evaluate(functorScript)({ | ||
| require, | ||
| evaluate: compartment.evaluate, | ||
| sourceUrlPrefix: 'file:///Users/you/project/', | ||
| }); | ||
| ``` | ||
| The functor runtime options include: | ||
| - `evaluate`: for functors made with `useEvaluate`, | ||
| specifies a function to use to evaluate each module. | ||
| The default evaluator is indirect `eval`. | ||
| - `require`: for functors made with `format` of `"cjs"`, provides the behavior | ||
| for `require` calls that exit the bundle to the host environment. | ||
| Defaults to the `require` in lexical scope. | ||
| - `sourceUrlPrefix`: specifies a prefix to occur on each module's `sourceURL` comment, | ||
| as injected at runtime. | ||
| Overrides the `sourceUrlPrefix` provided to `makeFunctor`, if any. | ||
| From `@endo/compartment-mapper/functor-lite.js`, the `makeFunctorFromMap` takes | ||
| a compartment map, like that generated by `mapNodeModules` in | ||
| `@endo/compartment-mapper/node-modules.js` instead of the entry module's | ||
| location. | ||
| The `-lite.js` modules, in general, do not entrain a specific compartment | ||
| mapper. | ||
| # Package Descriptors | ||
@@ -174,3 +344,3 @@ | ||
| The `exports` property describes [package entry points][] and can be influenced | ||
| The `exports` property describes [package entry points] and can be influenced | ||
| by build _conditions_. | ||
@@ -188,9 +358,7 @@ Currently, the only conditions supported by the compartment mapper are | ||
| > TODO | ||
| > | ||
| > A future version may also respect the `imports` property. | ||
| > [!NOTE] | ||
| > TODO: A future version may also respect the `imports` property. | ||
| > TODO | ||
| > | ||
| > A future version may also respect wildcard patterns in `exports` and | ||
| > [!NOTE] | ||
| > TODO: A future version may also respect wildcard patterns in `exports` and | ||
| > `imports`. | ||
@@ -207,6 +375,5 @@ | ||
| > TODO | ||
| > | ||
| > The compartment mapper does not yet do anything with the `files` globs but a | ||
| > future version of the compartment mapper will collect these in archives. | ||
| > [!NOTE] | ||
| > TODO: The compartment mapper does not yet do anything with the `files` globs | ||
| > but a future version of the compartment mapper will collect these in archives. | ||
| > The compartment mapper should eventually provide the means for any | ||
@@ -219,18 +386,18 @@ > compartment to access its own files using an attenuated `fs` module or | ||
| Officially beginning with Node.js 14, Node.js treats `.mjs` files as ECMAScript | ||
| modules and `.cjs` files as CommonJS modules. | ||
| Node.js version 14 or greater treats `.mjs` files as ECMAScript modules and | ||
| `.cjs` files as CommonJS modules. | ||
| The `.js` extension indicates a CommonJS module by default, to maintain | ||
| backward compatibility. | ||
| However, packages that have a `type` property that explicitly says `module` | ||
| will treat a `.js` file as an ECMAScript module. | ||
| However, packages with `type` "module" will treat a `.js` file as an ECMAScript | ||
| module. | ||
| Many Node.js applications using CommonJS modules expect to be able to `require` | ||
| a JSON file like `package.json`. | ||
| The compartment mapper supports loading JSON modules from any type of module. | ||
| As of Node.js 14, Node does not support importing JSON using ECMAScript | ||
| `import` directives, so using this feature may limit compatibility with the | ||
| Node.js platform. | ||
| The compartment mapper therefore supports loading JSON modules from any type of | ||
| module, but using this feature may limit compatibility with the Node.js platform | ||
| (in which importing a JSON module requires [import attributes] including | ||
| `type: "json"`). | ||
| The compartment mapper supports loading CommonJS modules from ECMAScript | ||
| modules as well as ECMAScript modules importing CommonJS modules. | ||
| modules as well as loading ECMAScript modules from CommonJS modules. | ||
| This presumes that the CommonJS modules exclusively use `require` calls with a | ||
@@ -240,5 +407,4 @@ single string argument, where `require` is not lexically bound, to declare | ||
| dependencies can be loaded before any module executes. | ||
| As of Node.js 14, Node does not support loading ECMAScript modules from | ||
| CommonJS modules, so using this feature may limit compatibility with the | ||
| Node.js platform. | ||
| Use of this feature may limit compatibility with the Node.js platform, which did | ||
| not support loading ECMAScript modules from CommonJS modules until version 22. | ||
@@ -260,4 +426,4 @@ The compartment mapper supports language plugins. | ||
| the `parserForLanguage` option supported by many functions. | ||
| See `src/types/external.ts` for the type and expected behavior for | ||
| parsers. | ||
| See [src/types/external.ts](./src/types/external.ts) for the type and expected | ||
| behavior of parsers. | ||
@@ -272,5 +438,5 @@ These language identifiers are keys for the `moduleTransforms` and | ||
| For any package that has `type` set to `"module"` in its `package.json`, | ||
| For any package that has `type` set to "module" in its `package.json`, | ||
| `moduleLangaugeForExtension` will precede `languageForExtension`. | ||
| Packages with `type` set to `"commonjs"` or simply not set, | ||
| For any packages with `type` set to "commonjs" or simply not set, | ||
| `commonjsLanguageForExtension` will precede `languageForExtension`. | ||
@@ -296,10 +462,8 @@ This provides an hook for mapping TypeScript's `.ts` to either `.cts` or | ||
| > TODO | ||
| > | ||
| > The compartment mapper may elect to respect some properties specified for | ||
| > import maps. | ||
| > [!NOTE] | ||
| > TODO: The compartment mapper may elect to respect some properties specified | ||
| > for import maps. | ||
| > TODO | ||
| > | ||
| > A future version of the compartment mapper may add support for | ||
| > [!NOTE] | ||
| > TODO: A future version of the compartment mapper may add support for | ||
| > source-to-source translation in the scope of a package or compartment. | ||
@@ -318,6 +482,6 @@ > This would be expressed in `package.json` using a property like | ||
| > TODO | ||
| > | ||
| > The compartment mapper may also add support for compartment map plugins that | ||
| > would recognize packages in `devDependencies` that need to introduce globals. | ||
| > [!NOTE] | ||
| > TODO: The compartment mapper may also add support for compartment map plugins | ||
| > that would recognize packages in `devDependencies` that need to introduce | ||
| > globals. | ||
| > For example, _packages_ that use JSX and a virtual DOM would be able to add a | ||
@@ -363,15 +527,16 @@ > module-to-module translator and endow the compartment with the `h` the | ||
| Each of the workflows the compartment mapper executes a portion of one sequence | ||
| Each workflow of the compartment mapper executes a portion of a sequence | ||
| of underlying internals. | ||
| * search (`search.js`): Scan the parent directories of a given `moduleLocation` | ||
| until successfully finding and reading a `package.json` for the containing | ||
| application. | ||
| * map compartments from Node.js packages (`node-modules.js`): Find and gather | ||
| all the `package.json` files for the application's transitive dependencies. | ||
| * search ([search.js](./src/search.js)): Scan the parent directories of a given | ||
| `moduleSpecifier` until successfully finding and reading a `package.json` for | ||
| the containing application. | ||
| * map compartments from Node.js packages | ||
| ([node-modules.js](./src/node-modules.js)): Find and gather all the | ||
| `package.json` files for the application's transitive dependencies. | ||
| Use these to construct a compartment map describing how to construct a | ||
| `Compartment` for each application package and how to link the modules each | ||
| exports in the compartments that import them. | ||
| * load compartments (`archive.js`): Using `compartment.load`, or | ||
| implicitly through `compartment.import`, create a module graph for the | ||
| * load compartments ([archive.js](./src/archive.js)): Using `compartment.load`, | ||
| or implicitly through `compartment.import`, create a module graph for the | ||
| application's entire working set. | ||
@@ -381,4 +546,5 @@ When creating an archive, this does not execute any of the modules. | ||
| records the text of every module the main module needed. | ||
| * import modules (`import.js`, `import-archive.js`): Actually execute the | ||
| working set. | ||
| * import modules ([import.js](./src/import.js), | ||
| [import-archive.js](./src/import-archive.js)): Actually execute the working | ||
| set. | ||
@@ -470,3 +636,3 @@ Around this sequence, we can enter late or depart early to store or retrieve an | ||
| // The default is a single frozen realm that has no name. | ||
| realm: RealmName? // TODO | ||
| realm?: RealmName // TODO | ||
| }; | ||
@@ -493,6 +659,6 @@ | ||
| // same compartment, or given by the user. | ||
| compartment: CompartmentName?, | ||
| compartment?: CompartmentName, | ||
| // The name of the module in the foreign compartment's | ||
| // module namespace: | ||
| module: ExternalModuleSpecifier?, | ||
| module?: ExternalModuleSpecifier, | ||
| }; | ||
@@ -617,11 +783,12 @@ | ||
| > TODO | ||
| > | ||
| > Endo policy support is intended to reach parity with LavaMoat's policy.json. | ||
| > [!NOTE] | ||
| > TODO: Endo policy support is intended to reach parity with LavaMoat's | ||
| > policy.json. | ||
| > Policy generation may be ported to Endo. | ||
| [LavaMoat]: https://github.com/LavaMoat/lavamoat | ||
| [Compartments]: ../ses/README.md#compartment | ||
| [Policy Demo]: ./demo/policy/README.md | ||
| [import attributes]: https://nodejs.org/docs/latest/api/esm.html#import-attributes | ||
| [package entry points]: https://nodejs.org/api/esm.html#esm_package_entry_points | ||
| [`require.resolve()`]: https://nodejs.org/docs/latest/api/modules.html#requireresolverequest-options |
@@ -179,3 +179,3 @@ /* Provides functions to create an archive (zip file with a | ||
| entryModuleSpecifier, | ||
| exitModuleImportHook: consolidatedExitModuleImportHook, | ||
| importHook: consolidatedExitModuleImportHook, | ||
| sourceMapHook, | ||
@@ -182,0 +182,0 @@ }); |
@@ -6,4 +6,4 @@ declare const _default: BundlerSupport<CjsModuleSource>; | ||
| }; | ||
| import type { BundlerSupport } from './bundle.js'; | ||
| import type { BundlerSupport } from './bundle-lite.js'; | ||
| import type { VirtualModuleSource } from 'ses'; | ||
| //# sourceMappingURL=bundle-cjs.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bundle-cjs.d.ts","sourceRoot":"","sources":["bundle-cjs.js"],"names":[],"mappings":"wBA4DW,eAAe,eAAe,CAAC;;8BAvD5B,mBAAmB,GAAG;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC;oCAFtB,aAAa;yCADR,KAAK"} | ||
| {"version":3,"file":"bundle-cjs.d.ts","sourceRoot":"","sources":["bundle-cjs.js"],"names":[],"mappings":"wBAyEW,eAAe,eAAe,CAAC;;8BApE5B,mBAAmB,GAAG;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC;oCAFtB,kBAAkB;yCADb,KAAK"} |
+57
-28
| /* Provides CommonJS support for `bundle.js`. */ | ||
| /** @import {VirtualModuleSource} from 'ses' */ | ||
| /** @import {BundlerSupport} from './bundle.js' */ | ||
| /** @import {BundlerSupport} from './bundle-lite.js' */ | ||
| /** @typedef {VirtualModuleSource & {cjsFunctor: string}} CjsModuleSource */ | ||
| import { join } from './node-module-specifier.js'; | ||
| /** quotes strings */ | ||
@@ -24,23 +26,30 @@ const q = JSON.stringify; | ||
| const runtime = `\ | ||
| function wrapCjsFunctor(num) { | ||
| function wrapCjsFunctor(index, functor) { | ||
| /* eslint-disable no-undef */ | ||
| return ({ imports = {} }) => { | ||
| const moduleCells = cells[num]; | ||
| const cModule = Object.freeze( | ||
| Object.defineProperty({}, 'exports', moduleCells.default), | ||
| const moduleCells = cells[index]; | ||
| const cModule = freeze( | ||
| defineProperty({}, 'exports', moduleCells.default), | ||
| ); | ||
| // TODO: specifier not found handling | ||
| const requireImpl = specifier => cells[imports[specifier]].default.get(); | ||
| functors[num](Object.freeze(requireImpl), cModule.exports, cModule); | ||
| functor(freeze(requireImpl), cModule.exports, cModule); | ||
| // Update all named cells from module.exports. | ||
| Object.keys(moduleCells) | ||
| .filter(k => k !== 'default' && k !== '*') | ||
| .map(k => moduleCells[k].set(cModule.exports[k])); | ||
| const names = keys(moduleCells); | ||
| for (let i = 0; i < names.length; i += 1) { | ||
| const name = names[i]; | ||
| if (name !== 'default' && name !== '*') { | ||
| moduleCells[name].set(cModule.exports[name]); | ||
| } | ||
| } | ||
| // Add new named cells from module.exports. | ||
| Object.keys(cModule.exports) | ||
| .filter(k => k !== 'default' && k !== '*') | ||
| .filter(k => moduleCells[k] === undefined) | ||
| .map(k => (moduleCells[k] = cell(k, cModule.exports[k]))); | ||
| const exportNames = keys(cModule.exports); | ||
| for (let i = 0; i < exportNames.length; i += 1) { | ||
| const name = exportNames[i]; | ||
| if (name !== 'default' && name !== '*' && moduleCells[name] === undefined) { | ||
| moduleCells[name] = cell(name, cModule.exports[name]); | ||
| } | ||
| } | ||
| // Update the star cell from all cells. | ||
| const starExports = Object.create(null, { | ||
| const starExports = create(null, { | ||
| // Make this appear like an ESM module namespace object. | ||
@@ -54,6 +63,10 @@ [Symbol.toStringTag]: { | ||
| }); | ||
| Object.keys(moduleCells) | ||
| .filter(k => k !== '*') | ||
| .map(k => Object.defineProperty(starExports, k, moduleCells[k])); | ||
| moduleCells['*'].set(Object.freeze(starExports)); | ||
| const allNames = keys(moduleCells); | ||
| for (let i = 0; i < allNames.length; i += 1) { | ||
| const name = allNames[i]; | ||
| if (name !== '*') { | ||
| defineProperty(starExports, name, moduleCells[name]); | ||
| } | ||
| } | ||
| moduleCells['*'].set(freeze(starExports)); | ||
| }; | ||
@@ -66,13 +79,23 @@ /* eslint-enable no-undef */ | ||
| runtime, | ||
| getBundlerKit({ | ||
| index, | ||
| indexedImports, | ||
| record: { cjsFunctor, exports: exportsList = {} }, | ||
| }) { | ||
| getBundlerKit( | ||
| { | ||
| index, | ||
| indexedImports, | ||
| moduleSpecifier, | ||
| sourceDirname, | ||
| record: { cjsFunctor, exports: exportsList = {} }, | ||
| }, | ||
| { useEvaluate = false }, | ||
| ) { | ||
| const importsMap = JSON.stringify(indexedImports); | ||
| let functor = cjsFunctor; | ||
| if (useEvaluate) { | ||
| const sourceUrl = join(sourceDirname, moduleSpecifier); | ||
| functor = JSON.stringify([functor, sourceUrl]); | ||
| } | ||
| return { | ||
| getFunctor: () => `\ | ||
| // === functors[${index}] === | ||
| ${cjsFunctor}, | ||
| ${functor}, | ||
| `, | ||
@@ -85,7 +108,13 @@ getCells: () => `\ | ||
| getReexportsWiring: () => '', | ||
| getFunctorCall: () => `\ | ||
| wrapCjsFunctor(${index})({imports: ${importsMap}}); | ||
| `, | ||
| getFunctorCall: () => { | ||
| let functorExpression = `functors[${index}]`; | ||
| if (useEvaluate) { | ||
| functorExpression = `evaluateSource(...${functorExpression})`; | ||
| } | ||
| return `\ | ||
| wrapCjsFunctor(${index}, ${functorExpression})({imports: ${importsMap}}); | ||
| `; | ||
| }, | ||
| }; | ||
| }, | ||
| }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bundle-json.d.ts","sourceRoot":"","sources":["bundle-json.js"],"names":[],"mappings":";;IAME;;;;;;;;;MAgBC"} | ||
| {"version":3,"file":"bundle-json.d.ts","sourceRoot":"","sources":["bundle-json.js"],"names":[],"mappings":";;IAME;;;;;;;;;MAeC"} |
@@ -12,4 +12,3 @@ /* Provides JSON support for `bundle.js`. */ | ||
| getFunctor: () => `\ | ||
| // === functors[${index}] === | ||
| (set) => set(${json}), | ||
| ${json}, | ||
| `, | ||
@@ -21,3 +20,3 @@ getCells: () => `\ | ||
| getFunctorCall: () => `\ | ||
| functors[${index}](cells[${index}].default.set); | ||
| cells[${index}].default.set(functors[${index}]); | ||
| `, | ||
@@ -24,0 +23,0 @@ }; |
@@ -1,6 +0,6 @@ | ||
| export const runtime: "function observeImports(map, importName, importIndex) {\n for (const [name, observers] of map.get(importName)) {\n const cell = cells[importIndex][name];\n if (cell === undefined) {\n throw new ReferenceError(`Cannot import name ${name}`);\n }\n for (const observer of observers) {\n cell.observe(observer);\n }\n }\n}\n"; | ||
| export const runtime: "function observeImports(map, importName, importIndex) {\n for (const [name, observers] of map.get(importName)) {\n const cell = cells[importIndex][name];\n if (cell === undefined) {\n throw new ReferenceError(`Cannot import name ${name} (has ${Object.getOwnPropertyNames(cells[importIndex]).join(', ')})`);\n }\n for (const observer of observers) {\n cell.observe(observer);\n }\n }\n}\n"; | ||
| declare const _default: BundlerSupport<PrecompiledModuleSource>; | ||
| export default _default; | ||
| import type { PrecompiledModuleSource } from 'ses'; | ||
| import type { BundlerSupport } from './bundle.js'; | ||
| import type { BundlerSupport } from './bundle-lite.js'; | ||
| //# sourceMappingURL=bundle-mjs.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bundle-mjs.d.ts","sourceRoot":"","sources":["bundle-mjs.js"],"names":[],"mappings":"AAsCA,oXAYE;wBAES,eAAe,uBAAuB,CAAC;;6CAlDP,KAAK;oCACd,aAAa"} | ||
| {"version":3,"file":"bundle-mjs.d.ts","sourceRoot":"","sources":["bundle-mjs.js"],"names":[],"mappings":"AAwCA,ubAYE;wBAES,eAAe,uBAAuB,CAAC;;6CApDP,KAAK;oCACd,kBAAkB"} |
+36
-19
| /* Provides ESM support for `bundle.js`. */ | ||
| /** @import {PrecompiledModuleSource} from 'ses' */ | ||
| /** @import {BundlerSupport} from './bundle.js' */ | ||
| /** @import {BundlerSupport} from './bundle-lite.js' */ | ||
| import { join } from './node-module-specifier.js'; | ||
| /** quotes strings */ | ||
@@ -44,3 +46,3 @@ const q = JSON.stringify; | ||
| if (cell === undefined) { | ||
| throw new ReferenceError(\`Cannot import name \${name}\`); | ||
| throw new ReferenceError(\`Cannot import name \${name} (has \${Object.getOwnPropertyNames(cells[importIndex]).join(', ')})\`); | ||
| } | ||
@@ -57,17 +59,26 @@ for (const observer of observers) { | ||
| runtime, | ||
| getBundlerKit({ | ||
| index, | ||
| indexedImports, | ||
| record: { | ||
| __syncModuleProgram__, | ||
| __fixedExportMap__ = {}, | ||
| __liveExportMap__ = {}, | ||
| __reexportMap__ = {}, | ||
| reexports, | ||
| getBundlerKit( | ||
| { | ||
| index, | ||
| indexedImports, | ||
| moduleSpecifier, | ||
| sourceDirname, | ||
| record: { | ||
| __syncModuleProgram__, | ||
| __fixedExportMap__ = {}, | ||
| __liveExportMap__ = {}, | ||
| __reexportMap__ = {}, | ||
| reexports, | ||
| }, | ||
| }, | ||
| }) { | ||
| { useEvaluate = false }, | ||
| ) { | ||
| let functor = __syncModuleProgram__; | ||
| if (useEvaluate) { | ||
| const sourceUrl = join(sourceDirname, moduleSpecifier); | ||
| functor = JSON.stringify([functor, sourceUrl]); | ||
| } | ||
| return { | ||
| getFunctor: () => `\ | ||
| // === functors[${index}] === | ||
| ${__syncModuleProgram__}, | ||
| ${functor}, | ||
| `, | ||
@@ -84,3 +95,3 @@ getCells: () => `\ | ||
| importSpecifier => `\ | ||
| Object.defineProperties(cells[${index}], Object.getOwnPropertyDescriptors(cells[${indexedImports[importSpecifier]}])); | ||
| defineProperties(cells[${index}], getOwnPropertyDescriptors(cells[${indexedImports[importSpecifier]}])); | ||
| `, | ||
@@ -92,3 +103,3 @@ ); | ||
| mappings.push(` | ||
| Object.defineProperties(cells[${index}], {${namedReexportsToProcess.map( | ||
| defineProperties(cells[${index}], {${namedReexportsToProcess.map( | ||
| ([specifier, renames]) => { | ||
@@ -107,4 +118,9 @@ return renames.map( | ||
| }, | ||
| getFunctorCall: () => `\ | ||
| functors[${index}]({ | ||
| getFunctorCall: () => { | ||
| let functorExpression = `functors[${index}]`; | ||
| if (useEvaluate) { | ||
| functorExpression = `evaluateSource(...${functorExpression})`; | ||
| } | ||
| return `\ | ||
| ${functorExpression}({ | ||
| imports(entries) { | ||
@@ -128,5 +144,6 @@ const map = new Map(entries); | ||
| }); | ||
| `, | ||
| `; | ||
| }, | ||
| }; | ||
| }, | ||
| }; |
+48
-10
@@ -1,3 +0,30 @@ | ||
| export function makeBundle(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: ArchiveOptions | undefined): Promise<string>; | ||
| export function writeBundle(write: WriteFn, read: ReadFn, bundleLocation: string, moduleLocation: string, options?: ArchiveOptions | undefined): Promise<void>; | ||
| export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>; | ||
| export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>; | ||
| export function makeFunctor(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: BundleOptions | undefined): Promise<string>; | ||
| export function makeScript(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: BundleOptions | undefined): Promise<string>; | ||
| export function writeScript(write: WriteFn, read: ReadFn, bundleLocation: string, moduleLocation: string, options?: BundleOptions | undefined): Promise<void>; | ||
| /** | ||
| * The bundler kit defines a language-specific behavior for injecting a module | ||
| * into a bundle. | ||
| * Each module must allocate cells for its imports and exports, link those cells | ||
| * to the cells of dependencies, and provide both the linker and evaluation behavior | ||
| * for the module. | ||
| * The linker behavior gets injected in a lexical scope with the linker runtime | ||
| * and has access to the cells of all modules, whereas the evaluation behavior | ||
| * gets injected in the generated script's top level lexical scope, so has | ||
| * no accidental visibility into the linkage runtime. | ||
| * | ||
| * For example, JSON modules produce a single "default" cell ("getCells"): | ||
| * | ||
| * { default: cell('default') }, | ||
| * | ||
| * Then, the JSON gets injected verbatim for the evaluation behavior ("getFunctor"). | ||
| * The linker simply sets the cell to the value. | ||
| * | ||
| * functors[0]['default'].set(modules[0]); | ||
| * | ||
| * For an ECMAScript or CommonJS module, the evaluation behavior is a function | ||
| * that the linker runtime can call to inject it with the cells it needs by | ||
| * the names it sees for them. | ||
| */ | ||
| export type BundlerKit = { | ||
@@ -17,11 +44,9 @@ /** | ||
| * a JavaScript object and a trailing comma. | ||
| * The string is evaluated in a lexical context with a `cell` maker, the `cells` | ||
| * array of every module's internal environment record. | ||
| * The string is evaluated in the linker runtime's lexical context. | ||
| */ | ||
| getCells: () => string; | ||
| /** | ||
| * Produces a JavaScript string may | ||
| * be a statement that calls this module's functor with the calling convention | ||
| * appropriate for its language, injecting whatever cells it needs to link to | ||
| * other module namespaces. | ||
| * Produces a JavaScript string, | ||
| * a statement that effects the module's evaluation behavior using the cells | ||
| * it imports and exports and the evaluated "functor". | ||
| */ | ||
@@ -37,4 +62,6 @@ getFunctorCall: () => string; | ||
| key: string; | ||
| exit: string; | ||
| compartmentName: string; | ||
| moduleSpecifier: string; | ||
| sourceDirname: string; | ||
| parser: string; | ||
@@ -48,3 +75,13 @@ record: StaticModuleType & SpecificModuleSource; | ||
| }; | ||
| export type GetBundlerKit<SpecificModuleSource extends unknown> = (module: BundleModule<SpecificModuleSource>) => BundlerKit; | ||
| export type BundleExit = { | ||
| exit: string; | ||
| index: number; | ||
| bundlerKit: BundlerKit; | ||
| indexedImports: Record<string, number>; | ||
| resolvedImports: Record<string, string>; | ||
| }; | ||
| export type GetBundlerKit<SpecificModuleSource extends unknown> = (module: BundleModule<SpecificModuleSource>, params: { | ||
| useEvaluate?: boolean | undefined; | ||
| sourceUrlPrefix?: string | undefined; | ||
| }) => BundlerKit; | ||
| export type BundlerSupport<SpecificModuleSource extends unknown> = { | ||
@@ -57,5 +94,6 @@ runtime: string; | ||
| import type { MaybeReadPowers } from './types.js'; | ||
| import type { ArchiveOptions } from './types.js'; | ||
| import type { CompartmentMapDescriptor } from './types.js'; | ||
| import type { BundleOptions } from './types.js'; | ||
| import type { WriteFn } from './types.js'; | ||
| import type { StaticModuleType } from 'ses'; | ||
| //# sourceMappingURL=bundle.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["bundle.js"],"names":[],"mappings":"AAsOO,uCALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,yCAEJ,OAAO,CAAC,MAAM,CAAC,CAgN3B;AASM,mCANI,OAAO,QACP,MAAM,kBACN,MAAM,kBACN,MAAM,uDAahB;;;;;;;;;;;gBAlba,MAAM,MAAM;;;;;;;cAOZ,MAAM,MAAM;;;;;;;oBAIZ,MAAM,MAAM;;;;;wBAIZ,MAAM,MAAM;;yBAKH,oBAAoB,SAA9B,OAAS;SAER,MAAM;qBACN,MAAM;qBACN,MAAM;YACN,MAAM;YACN,gBAAgB,GAAG,oBAAo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AU;WACV,MAAM;gBACN,UAAU;;;UAKV,MAAM;WACN,MAAM;gBACN,UAAU;oBACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;qBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAIb,oBAAoB,SAA9B,OAAS,aAEX,YAAY,CAAC,oBAAoB,CAAC,UAE1C;IAAyB,WAAW;IACZ,eAAe;CACvC,KAAU,UAAU;2BAIA,oBAAoB,SAA9B,OAAS;aAER,MAAM;mBACN,aAAa,CAAC,oBAAoB,CAAC;;4BArFvC,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;8CAAZ,YAAY;mCAAZ,YAAY;6BAAZ,YAAY;sCAXZ,KAAK"} |
+391
-125
@@ -9,4 +9,5 @@ /* eslint no-shadow: 0 */ | ||
| * @import { | ||
| * ArchiveOptions, | ||
| * BundleOptions, | ||
| * CompartmentDescriptor, | ||
| * CompartmentMapDescriptor, | ||
| * CompartmentSources, | ||
@@ -22,2 +23,25 @@ * MaybeReadPowers, | ||
| /** | ||
| * The bundler kit defines a language-specific behavior for injecting a module | ||
| * into a bundle. | ||
| * Each module must allocate cells for its imports and exports, link those cells | ||
| * to the cells of dependencies, and provide both the linker and evaluation behavior | ||
| * for the module. | ||
| * The linker behavior gets injected in a lexical scope with the linker runtime | ||
| * and has access to the cells of all modules, whereas the evaluation behavior | ||
| * gets injected in the generated script's top level lexical scope, so has | ||
| * no accidental visibility into the linkage runtime. | ||
| * | ||
| * For example, JSON modules produce a single "default" cell ("getCells"): | ||
| * | ||
| * { default: cell('default') }, | ||
| * | ||
| * Then, the JSON gets injected verbatim for the evaluation behavior ("getFunctor"). | ||
| * The linker simply sets the cell to the value. | ||
| * | ||
| * functors[0]['default'].set(modules[0]); | ||
| * | ||
| * For an ECMAScript or CommonJS module, the evaluation behavior is a function | ||
| * that the linker runtime can call to inject it with the cells it needs by | ||
| * the names it sees for them. | ||
| * | ||
| * @typedef {object} BundlerKit | ||
@@ -33,8 +57,6 @@ * @property {() => string} getFunctor Produces a JavaScript string consisting of | ||
| * a JavaScript object and a trailing comma. | ||
| * The string is evaluated in a lexical context with a `cell` maker, the `cells` | ||
| * array of every module's internal environment record. | ||
| * @property {() => string} getFunctorCall Produces a JavaScript string may | ||
| * be a statement that calls this module's functor with the calling convention | ||
| * appropriate for its language, injecting whatever cells it needs to link to | ||
| * other module namespaces. | ||
| * The string is evaluated in the linker runtime's lexical context. | ||
| * @property {() => string} getFunctorCall Produces a JavaScript string, | ||
| * a statement that effects the module's evaluation behavior using the cells | ||
| * it imports and exports and the evaluated "functor". | ||
| * @property {() => string} getReexportsWiring Produces a JavaScript string | ||
@@ -48,4 +70,6 @@ * that may include statements that bind the cells reexported by this module. | ||
| * @property {string} key | ||
| * @property {string} exit | ||
| * @property {string} compartmentName | ||
| * @property {string} moduleSpecifier | ||
| * @property {string} sourceDirname | ||
| * @property {string} parser | ||
@@ -61,5 +85,17 @@ * @property {StaticModuleType & SpecificModuleSource} record | ||
| /** | ||
| * @typedef {object} BundleExit | ||
| * @property {string} exit | ||
| * @property {number} index | ||
| * @property {BundlerKit} bundlerKit | ||
| * @property {Record<string, number>} indexedImports | ||
| * @property {Record<string, string>} resolvedImports | ||
| */ | ||
| /** | ||
| * @template {unknown} SpecificModuleSource | ||
| * @callback GetBundlerKit | ||
| * @param {BundleModule<SpecificModuleSource>} module | ||
| * @param {object} params | ||
| * @param {boolean} [params.useEvaluate] | ||
| * @param {string} [params.sourceUrlPrefix] | ||
| * @returns {BundlerKit} | ||
@@ -76,9 +112,6 @@ */ | ||
| import { resolve } from './node-module-specifier.js'; | ||
| import { compartmentMapForNodeModules } from './node-modules.js'; | ||
| import { search } from './search.js'; | ||
| import { mapNodeModules } from './node-modules.js'; | ||
| import { link } from './link.js'; | ||
| import { unpackReadPowers } from './powers.js'; | ||
| import { makeImportHookMaker } from './import-hook.js'; | ||
| import { defaultParserForLanguage } from './archive-parsers.js'; | ||
| import { parseLocatedJson } from './json.js'; | ||
@@ -94,2 +127,32 @@ import mjsSupport from './bundle-mjs.js'; | ||
| /** | ||
| * @param {BundleExit} source | ||
| * @returns {BundlerKit} | ||
| */ | ||
| const makeCjsExitBundlerKit = ({ exit, index }) => ({ | ||
| getFunctor: () => `\ | ||
| null, | ||
| `, | ||
| getCells: () => `\ | ||
| namespaceCells(tryRequire(${JSON.stringify(exit)})), | ||
| `, | ||
| getReexportsWiring: () => '', | ||
| getFunctorCall: () => ``, | ||
| }); | ||
| /** | ||
| * Produces a list of modules in the order they should be evaluated, and | ||
| * a side-table for following aliases. | ||
| * The modules are produce in topological postorder, such that the entry | ||
| * module appears last. | ||
| * The post-order traversal does not revisit modules that appear in cycles. | ||
| * | ||
| * Synthesizes a unique key for each module and translates | ||
| * each module's imports to their corresponding keys. | ||
| * Some import keys are aliased to other keys, such that walking from | ||
| * key to value in the aliases side table will eventually arrive at | ||
| * the key of a module that is present in the modules list. | ||
| * | ||
| * The first modules are place-holders for the modules that exit | ||
| * the compartment map to the host's module system. | ||
| * | ||
| * @param {Record<string, CompartmentDescriptor>} compartmentDescriptors | ||
@@ -99,2 +162,3 @@ * @param {Record<string, CompartmentSources>} compartmentSources | ||
| * @param {string} entryModuleSpecifier | ||
| * @param {Array<string>} exitModuleSpecifiers | ||
| */ | ||
@@ -106,2 +170,3 @@ const sortedModules = ( | ||
| entryModuleSpecifier, | ||
| exitModuleSpecifiers, | ||
| ) => { | ||
@@ -115,2 +180,13 @@ /** @type {BundleModule<unknown>[]} */ | ||
| for (const exit of exitModuleSpecifiers) { | ||
| modules.push({ | ||
| key: exit, | ||
| exit, | ||
| // @ts-expect-error | ||
| index: undefined, | ||
| // @ts-expect-error | ||
| bundlerKit: null, | ||
| }); | ||
| } | ||
| /** | ||
@@ -129,3 +205,7 @@ * @param {string} compartmentName | ||
| if (source !== undefined) { | ||
| const { record, parser, deferredError, bytes } = source; | ||
| const { record, parser, deferredError, bytes, sourceDirname, exit } = | ||
| source; | ||
| if (exit !== undefined) { | ||
| return exit; | ||
| } | ||
| assert( | ||
@@ -139,2 +219,6 @@ bytes !== undefined, | ||
| ); | ||
| assert( | ||
| sourceDirname !== undefined, | ||
| `No sourceDirname for ${moduleSpecifier} in ${compartmentName}`, | ||
| ); | ||
| if (deferredError) { | ||
@@ -164,2 +248,3 @@ throw Error( | ||
| moduleSpecifier, | ||
| sourceDirname, | ||
| parser, | ||
@@ -219,4 +304,9 @@ record, | ||
| /** @param {BundleModule<unknown>} module */ | ||
| const getBundlerKitForModule = module => { | ||
| /** | ||
| * @param {BundleModule<unknown>} module | ||
| * @param {object} params | ||
| * @param {boolean} [params.useEvaluate] | ||
| * @param {string} [params.sourceUrlPrefix] | ||
| */ | ||
| const getBundlerKitForModule = (module, params) => { | ||
| const language = module.parser; | ||
@@ -236,3 +326,3 @@ assert(language !== undefined); | ||
| const { getBundlerKit } = bundlerSupportForLanguage[language]; | ||
| return getBundlerKit(module); | ||
| return getBundlerKit(module, params); | ||
| }; | ||
@@ -242,29 +332,28 @@ | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {string} moduleLocation | ||
| * @param {ArchiveOptions} [options] | ||
| * @param {CompartmentMapDescriptor} compartmentMap | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeBundle = async (readPowers, moduleLocation, options) => { | ||
| const { read } = unpackReadPowers(readPowers); | ||
| export const makeFunctorFromMap = async ( | ||
| readPowers, | ||
| compartmentMap, | ||
| options, | ||
| ) => { | ||
| const { | ||
| moduleTransforms, | ||
| dev, | ||
| tags: tagsOption, | ||
| conditions: conditionsOption = tagsOption, | ||
| syncModuleTransforms, | ||
| searchSuffixes, | ||
| commonDependencies, | ||
| sourceMapHook = undefined, | ||
| useEvaluate = false, | ||
| sourceUrlPrefix = undefined, | ||
| format = undefined, | ||
| parserForLanguage: parserForLanguageOption = {}, | ||
| languageForExtension: languageForExtensionOption = {}, | ||
| commonjsLanguageForExtension: commonjsLanguageForExtensionOption = {}, | ||
| moduleLanguageForExtension: moduleLanguageForExtensionOption = {}, | ||
| workspaceLanguageForExtension: workspaceLanguageForExtensionOption = {}, | ||
| workspaceCommonjsLanguageForExtension: | ||
| workspaceCommonjsLanguageForExtensionOption = {}, | ||
| workspaceModuleLanguageForExtension: | ||
| workspaceModuleLanguageForExtensionOption = {}, | ||
| } = options || {}; | ||
| const conditions = new Set(conditionsOption); | ||
| /** @type {((module: BundleExit) => BundlerKit) | undefined} */ | ||
| let makeExitBundlerKit; | ||
| if (format === 'cjs') { | ||
| makeExitBundlerKit = makeCjsExitBundlerKit; | ||
| } | ||
| const parserForLanguage = Object.freeze( | ||
@@ -277,56 +366,8 @@ Object.assign( | ||
| ); | ||
| const languageForExtension = Object.freeze( | ||
| Object.assign(Object.create(null), languageForExtensionOption), | ||
| ); | ||
| const commonjsLanguageForExtension = Object.freeze( | ||
| Object.assign(Object.create(null), commonjsLanguageForExtensionOption), | ||
| ); | ||
| const moduleLanguageForExtension = Object.freeze( | ||
| Object.assign(Object.create(null), moduleLanguageForExtensionOption), | ||
| ); | ||
| const workspaceLanguageForExtension = Object.freeze( | ||
| Object.assign(Object.create(null), workspaceLanguageForExtensionOption), | ||
| ); | ||
| const workspaceCommonjsLanguageForExtension = Object.freeze( | ||
| Object.assign( | ||
| Object.create(null), | ||
| workspaceCommonjsLanguageForExtensionOption, | ||
| ), | ||
| ); | ||
| const workspaceModuleLanguageForExtension = Object.freeze( | ||
| Object.assign( | ||
| Object.create(null), | ||
| workspaceModuleLanguageForExtensionOption, | ||
| ), | ||
| ); | ||
| const { | ||
| packageLocation, | ||
| packageDescriptorText, | ||
| packageDescriptorLocation, | ||
| moduleSpecifier, | ||
| } = await search(readPowers, moduleLocation); | ||
| const bundlerKitParams = { | ||
| useEvaluate, | ||
| sourceUrlPrefix, | ||
| }; | ||
| const packageDescriptor = parseLocatedJson( | ||
| packageDescriptorText, | ||
| packageDescriptorLocation, | ||
| ); | ||
| const compartmentMap = await compartmentMapForNodeModules( | ||
| read, | ||
| packageLocation, | ||
| conditions, | ||
| packageDescriptor, | ||
| moduleSpecifier, | ||
| { | ||
| dev, | ||
| commonDependencies, | ||
| languageForExtension, | ||
| commonjsLanguageForExtension, | ||
| moduleLanguageForExtension, | ||
| workspaceLanguageForExtension, | ||
| workspaceCommonjsLanguageForExtension, | ||
| workspaceModuleLanguageForExtension, | ||
| }, | ||
| ); | ||
| const { | ||
@@ -336,6 +377,31 @@ compartments, | ||
| } = compartmentMap; | ||
| /** @type {string[]} */ | ||
| const exitModuleSpecifiers = []; | ||
| /** @type {Sources} */ | ||
| const sources = Object.create(null); | ||
| const makeImportHook = makeImportHookMaker(read, packageLocation, { | ||
| /** | ||
| * @param {string} moduleSpecifier | ||
| * @param {string} compartmentName | ||
| */ | ||
| const exitModuleImportHook = | ||
| format !== undefined | ||
| ? /** | ||
| * @param {string} moduleSpecifier | ||
| * @param {string} compartmentName | ||
| */ | ||
| async (moduleSpecifier, compartmentName) => { | ||
| const compartmentSources = | ||
| sources[compartmentName] || Object.create(null); | ||
| sources[compartmentName] = compartmentSources; | ||
| compartmentSources[moduleSpecifier] = { | ||
| exit: moduleSpecifier, | ||
| }; | ||
| exitModuleSpecifiers.push(moduleSpecifier); | ||
| return { imports: [], exports: [], execute() {} }; | ||
| } | ||
| : undefined; | ||
| const makeImportHook = makeImportHookMaker(readPowers, entryCompartmentName, { | ||
| archiveOnly: true, | ||
| sources, | ||
@@ -347,2 +413,3 @@ compartmentDescriptors: compartments, | ||
| sourceMapHook, | ||
| importHook: exitModuleImportHook, | ||
| }); | ||
@@ -355,2 +422,3 @@ | ||
| moduleTransforms, | ||
| syncModuleTransforms, | ||
| parserForLanguage, | ||
@@ -365,2 +433,3 @@ }); | ||
| entryModuleSpecifier, | ||
| exitModuleSpecifiers, | ||
| ); | ||
@@ -378,39 +447,83 @@ | ||
| for (const module of modules) { | ||
| module.indexedImports = Object.fromEntries( | ||
| Object.entries(module.resolvedImports).map(([importSpecifier, key]) => { | ||
| // UNTIL https://github.com/endojs/endo/issues/1514 | ||
| // Prefer: key = aliases.get(key) ?? key; | ||
| const alias = aliases.get(key); | ||
| if (alias != null) { | ||
| key = alias; | ||
| } | ||
| const module = modulesByKey[key]; | ||
| if (module === undefined) { | ||
| throw new Error( | ||
| `Unable to locate module for key ${q(key)} import specifier ${q( | ||
| importSpecifier, | ||
| )} in ${q(module.moduleSpecifier)} of compartment ${q( | ||
| module.compartmentName, | ||
| )}`, | ||
| ); | ||
| } | ||
| const { index } = module; | ||
| return [importSpecifier, index]; | ||
| }), | ||
| ); | ||
| parsersInUse.add(module.parser); | ||
| module.bundlerKit = getBundlerKitForModule(module); | ||
| if (module.exit !== undefined) { | ||
| if (makeExitBundlerKit === undefined) { | ||
| // makeExitBundlerKit must have been provided to makeImportHookMaker for any modules with an exit property to have been created. | ||
| throw TypeError('Unreachable'); | ||
| } | ||
| module.bundlerKit = makeExitBundlerKit(module); | ||
| } else { | ||
| module.indexedImports = Object.fromEntries( | ||
| Object.entries(module.resolvedImports).map(([importSpecifier, key]) => { | ||
| // UNTIL https://github.com/endojs/endo/issues/1514 | ||
| // Prefer: key = aliases.get(key) ?? key; | ||
| const alias = aliases.get(key); | ||
| if (alias != null) { | ||
| key = alias; | ||
| } | ||
| const module = modulesByKey[key]; | ||
| if (module === undefined) { | ||
| throw new Error( | ||
| `Unable to locate module for key ${q(key)} import specifier ${q( | ||
| importSpecifier, | ||
| )}`, | ||
| ); | ||
| } | ||
| const { index } = module; | ||
| return [importSpecifier, index]; | ||
| }), | ||
| ); | ||
| parsersInUse.add(module.parser); | ||
| module.bundlerKit = getBundlerKitForModule(module, bundlerKitParams); | ||
| } | ||
| } | ||
| const bundle = `\ | ||
| 'use strict'; | ||
| (functors => { | ||
| // Some bundles appeal to the host module system appropriate to their format | ||
| // like `require` for bundles used as CommonJS modules. | ||
| // Each module in the modules array is constructed by a language-specific bundler kit, | ||
| // and in the case of an exit module, is a bundler kit made with | ||
| // makeExitBundlerKit, like makeCjsExitBundlerKit. | ||
| // This will generate a module initialization runtime that in turn needs this | ||
| // namespaceCells utility function to take a host module exports namespace | ||
| // and turn it into a bank of cells for importing and exporting the | ||
| // properties of the module exports namespace object. | ||
| const exitNamespaces = | ||
| exitModuleSpecifiers.length === 0 | ||
| ? '' | ||
| : `\ | ||
| const namespaceCells = namespace => fromEntries( | ||
| getOwnPropertyNames(namespace) | ||
| .map(name => [name, { | ||
| get() { | ||
| return get(namespace, name); | ||
| }, | ||
| set() { | ||
| throw new TypeError('Non-writable export'); | ||
| }, | ||
| observe(observer) { | ||
| observer(get(namespace, name)); | ||
| }, | ||
| enumerable: true, | ||
| }]) | ||
| ); | ||
| `; | ||
| // The linkage runtime creates a cell for every value exported by any of the | ||
| // bundled modules. | ||
| // The interface of a cell is very much like a getter/setter property | ||
| // deescriptor, and additionally has a method for registering an observer to | ||
| // notice when a variable is changed in its originating module, to support | ||
| // live bindings. | ||
| // Each module language defines its own behavior for the generation of its | ||
| // exported cells. | ||
| // After all cells are allocated, each language gets a second opportunity | ||
| // to introduce bindings for cells that the module re-exports from another | ||
| // module, but does not itself own. | ||
| const runtimeLinkageCells = `\ | ||
| const cell = (name, value = undefined) => { | ||
| const observers = []; | ||
| return Object.freeze({ | ||
| get: Object.freeze(() => { | ||
| return freeze({ | ||
| get: freeze(() => { | ||
| return value; | ||
| }), | ||
| set: Object.freeze((newValue) => { | ||
| set: freeze((newValue) => { | ||
| value = newValue; | ||
@@ -421,3 +534,3 @@ for (const observe of observers) { | ||
| }), | ||
| observe: Object.freeze((observe) => { | ||
| observe: freeze((observe) => { | ||
| observers.push(observe); | ||
@@ -435,4 +548,11 @@ observe(value); | ||
| ${''.concat(...modules.map(m => m.bundlerKit.getReexportsWiring()))}\ | ||
| `; | ||
| const namespaces = cells.map(cells => Object.freeze(Object.create(null, { | ||
| // The linker runtime includes a parallel array of module exports namespace | ||
| // objects for each bundled module, for each respective index of the module | ||
| // functors array. | ||
| // Each namespace has a special '*' property for the namespace object itself, | ||
| // which is what modules obtain with `import * as x from 'x'` notation. | ||
| const moduleNamespaces = `\ | ||
| const namespaces = cells.map(cells => freeze(create(null, { | ||
| ...cells, | ||
@@ -451,15 +571,161 @@ // Make this appear like an ESM module namespace object. | ||
| } | ||
| `; | ||
| ${''.concat(...Array.from(parsersInUse).map(parser => getRuntime(parser)))} | ||
| // Each language in use within the bundle has an opportunity to inject | ||
| // utilities into the bundle runtime that it can use in the shared lexical | ||
| // scope of module execution. | ||
| // CommonJS in particular injects a utility function here, if the script | ||
| // entrains any CommonJS modules. | ||
| const languageRuntimeExtensions = `\ | ||
| ${''.concat(...Array.from(parsersInUse).map(parser => getRuntime(parser)))}\ | ||
| `; | ||
| // This section of the linker runtime causes each of the modules to execute | ||
| // in topological order, using a language-specific calling convention to | ||
| // link its imports and exports to other modules. | ||
| const moduleExecutionRuntime = `\ | ||
| ${''.concat(...modules.map(m => m.bundlerKit.getFunctorCall()))}\ | ||
| `; | ||
| // The linker runtime receives an array of language-specific representations | ||
| // of each module, which in the simplest case is just a function and a | ||
| // runtime initialization calling convention (a functor). | ||
| // Then, in the style of partial application, it receives runtime options. | ||
| // When driven by makeScript, the script will statically apply the options, | ||
| // but with makeFunctor, the runtime must evaluate and apply runtime options. | ||
| // Scripts are suitable for injection with <script> tags on the web, whereas | ||
| // functors require use of an evaluator at runtime. | ||
| const linkerRuntime = `functors => options => { | ||
| 'use strict'; | ||
| const { | ||
| Map, | ||
| Object, | ||
| ReferenceError, | ||
| Reflect, | ||
| TypeError, | ||
| } = globalThis; | ||
| const { | ||
| create, | ||
| defineProperties, | ||
| defineProperty, | ||
| freeze, | ||
| fromEntries, | ||
| getOwnPropertyDescriptors, | ||
| getOwnPropertyNames, | ||
| keys, | ||
| } = Object; | ||
| const { get, set } = Reflect; | ||
| const { | ||
| ${ | ||
| !useEvaluate | ||
| ? '' | ||
| : `\ | ||
| evaluate = eval, | ||
| sourceUrlPrefix = ${JSON.stringify(sourceUrlPrefix)}, | ||
| ` | ||
| }\ | ||
| ${ | ||
| format !== 'cjs' | ||
| ? '' | ||
| : `\ | ||
| require: tryRequire = typeof require === 'function' ? require : specifier => { | ||
| throw new TypeError('Cannot import host module: ' + specifier); | ||
| }, | ||
| ` | ||
| }\ | ||
| } = options || {}; | ||
| ${ | ||
| !useEvaluate | ||
| ? '' | ||
| : `\ | ||
| const evaluateSource = (source, sourceUrl) => { | ||
| return evaluate(source + '\\n//# sourceURL=' + sourceUrlPrefix + sourceUrl + '\\n'); | ||
| };` | ||
| }\ | ||
| ${exitNamespaces}\ | ||
| ${runtimeLinkageCells}\ | ||
| ${moduleNamespaces}\ | ||
| ${languageRuntimeExtensions}\ | ||
| ${moduleExecutionRuntime}\ | ||
| return cells[cells.length - 1]['*'].get(); | ||
| })([${''.concat(...modules.map(m => m.bundlerKit.getFunctor()))}]); | ||
| `; | ||
| }`; | ||
| return bundle; | ||
| // An array of language-specific representations of each bundled module, | ||
| // which in the simplest case is a function that must be initialized by the | ||
| // linkage runtime using a calling convention. | ||
| // We pass this array into the linkage runtime rather than embedding it in | ||
| // the linkage runtime in order to assure that the runtime's lexical context | ||
| // doesn't overshadow each module's lexical scope. | ||
| const moduleFunctors = `[ | ||
| ${''.concat( | ||
| ...modules.map( | ||
| (m, index) => `\ | ||
| // === ${index}. ${m.sourceDirname} ${m.moduleSpecifier} === | ||
| ${m.bundlerKit.getFunctor()}`, | ||
| ), | ||
| )}\ | ||
| ]`; | ||
| // Functors partially apply the linker runtime. | ||
| // Scripts go on to apply static options and execute immediately. | ||
| return `(${linkerRuntime})(${moduleFunctors})`; | ||
| }; | ||
| /** | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {CompartmentMapDescriptor} compartmentMap | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeScriptFromMap = async ( | ||
| readPowers, | ||
| compartmentMap, | ||
| options, | ||
| ) => { | ||
| // Functors partially apply the linker runtime. | ||
| // Scripts go on to apply static options and execute immediately. | ||
| const functor = await makeFunctorFromMap(readPowers, compartmentMap, options); | ||
| return `${functor}()`; | ||
| }; | ||
| /** | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {string} moduleLocation | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeFunctor = async (readPowers, moduleLocation, options) => { | ||
| const compartmentMap = await mapNodeModules( | ||
| readPowers, | ||
| moduleLocation, | ||
| options, | ||
| ); | ||
| return makeFunctorFromMap(readPowers, compartmentMap, options); | ||
| }; | ||
| /** | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
| * @param {string} moduleLocation | ||
| * @param {BundleOptions} [options] | ||
| * @returns {Promise<string>} | ||
| */ | ||
| export const makeScript = async (readPowers, moduleLocation, options) => { | ||
| const compartmentMap = await mapNodeModules( | ||
| readPowers, | ||
| moduleLocation, | ||
| options, | ||
| ); | ||
| return makeScriptFromMap(readPowers, compartmentMap, options); | ||
| }; | ||
| /** | ||
| * @param {WriteFn} write | ||
@@ -469,5 +735,5 @@ * @param {ReadFn} read | ||
| * @param {string} moduleLocation | ||
| * @param {ArchiveOptions} [options] | ||
| * @param {BundleOptions} [options] | ||
| */ | ||
| export const writeBundle = async ( | ||
| export const writeScript = async ( | ||
| write, | ||
@@ -479,5 +745,5 @@ read, | ||
| ) => { | ||
| const bundleString = await makeBundle(read, moduleLocation, options); | ||
| const bundleString = await makeScript(read, moduleLocation, options); | ||
| const bundleBytes = textEncoder.encode(bundleString); | ||
| await write(bundleLocation, bundleBytes); | ||
| }; |
@@ -126,3 +126,3 @@ /** | ||
| entryModuleSpecifier, | ||
| exitModuleImportHook: consolidatedExitModuleImportHook, | ||
| importHook: consolidatedExitModuleImportHook, | ||
| sourceMapHook, | ||
@@ -129,0 +129,0 @@ }); |
+3
-16
@@ -9,3 +9,3 @@ /** | ||
| */ | ||
| export function makeImportNowHookMaker(readPowers: ReadNowPowers, baseLocation: string, { sources, compartmentDescriptors, computeSha512, searchSuffixes, sourceMapHook, exitModuleImportNowHook, }: MakeImportNowHookMakerOptions): ImportNowHookMaker; | ||
| export function makeImportNowHookMaker(readPowers: ReadNowPowers, baseLocation: string, { sources, compartmentDescriptors, computeSha512, searchSuffixes, archiveOnly, sourceMapHook, importNowHook: exitModuleImportNowHook, }: MakeImportNowHookMakerOptions): ImportNowHookMaker; | ||
| export function exitModuleImportHookMaker({ modules, exitModuleImportHook, entryCompartmentName, }: { | ||
@@ -16,13 +16,3 @@ modules?: Record<string, any> | undefined; | ||
| }): ExitModuleImportHook | undefined; | ||
| export function makeImportHookMaker(readPowers: ReadFn | ReadPowers, baseLocation: string, { sources, compartmentDescriptors, archiveOnly, computeSha512, searchSuffixes, sourceMapHook, entryCompartmentName, entryModuleSpecifier, exitModuleImportHook, }: { | ||
| sources?: Sources | undefined; | ||
| compartmentDescriptors?: Record<string, CompartmentDescriptor> | undefined; | ||
| archiveOnly?: boolean | undefined; | ||
| computeSha512?: HashFn | undefined; | ||
| searchSuffixes?: string[] | undefined; | ||
| entryCompartmentName: string; | ||
| entryModuleSpecifier: string; | ||
| exitModuleImportHook?: ExitModuleImportHook | undefined; | ||
| sourceMapHook?: SourceMapHook | undefined; | ||
| }): ImportHookMaker; | ||
| export function makeImportHookMaker(readPowers: ReadFn | ReadPowers, baseLocation: string, { sources, compartmentDescriptors, archiveOnly, computeSha512, searchSuffixes, sourceMapHook, entryCompartmentName, entryModuleSpecifier, importHook: exitModuleImportHook, }: MakeImportHookMakerOptions): ImportHookMaker; | ||
| import type { ReadNowPowers } from './types.js'; | ||
@@ -34,7 +24,4 @@ import type { MakeImportNowHookMakerOptions } from './types.js'; | ||
| import type { ReadPowers } from './types.js'; | ||
| import type { Sources } from './types.js'; | ||
| import type { CompartmentDescriptor } from './types.js'; | ||
| import type { HashFn } from './types.js'; | ||
| import type { SourceMapHook } from './types.js'; | ||
| import type { MakeImportHookMakerOptions } from './types.js'; | ||
| import type { ImportHookMaker } from './types.js'; | ||
| //# sourceMappingURL=import-hook.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"import-hook.d.ts","sourceRoot":"","sources":["import-hook.js"],"names":[],"mappings":"AA2lBA;;;;;;;GAOG;AACH,mDALW,aAAa,gBACb,MAAM,+GACN,6BAA6B,GAC3B,kBAAkB,CAuJ9B;AA5jBM,oGALJ;IAAqC,OAAO;IACN,oBAAoB;IACnC,oBAAoB,EAAnC,MAAM;CACd,GAAU,oBAAoB,GAAC,SAAS,CA8B1C;AA4MM,gDApBI,MAAM,GAAC,UAAU,gBACjB,MAAM,qKAEd;IAA0B,OAAO;IACuB,sBAAsB;IACpD,WAAW;IACZ,aAAa;IACN,cAAc;IAOtB,oBAAoB,EAApC,MAAM;IACU,oBAAoB,EAApC,MAAM;IACyB,oBAAoB;IAC3B,aAAa;CAC7C,GAAU,eAAe,CAuL3B;mCAtjBS,YAAY;mDAAZ,YAAY;wCAAZ,YAAY;0CAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;6BAAZ,YAAY;2CAAZ,YAAY;4BAAZ,YAAY;mCAAZ,YAAY;qCAAZ,YAAY"} | ||
| {"version":3,"file":"import-hook.d.ts","sourceRoot":"","sources":["import-hook.js"],"names":[],"mappings":"AAklBA;;;;;;;GAOG;AACH,mDALW,aAAa,gBACb,MAAM,2IACN,6BAA6B,GAC3B,kBAAkB,CAyJ9B;AApjBM,oGALJ;IAAqC,OAAO;IACN,oBAAoB;IACnC,oBAAoB,EAAnC,MAAM;CACd,GAAU,oBAAoB,GAAC,SAAS,CA8B1C;AAiMM,gDALI,MAAM,GAAC,UAAU,gBACjB,MAAM,iLACN,0BAA0B,GACxB,eAAe,CAwL3B;mCA5iBS,YAAY;mDAAZ,YAAY;wCAAZ,YAAY;0CAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;gDAAZ,YAAY;qCAAZ,YAAY"} |
+11
-18
@@ -28,2 +28,3 @@ /** | ||
| * ImportNowHookMaker, | ||
| * MakeImportHookMakerOptions, | ||
| * MakeImportNowHookMakerOptions, | ||
@@ -271,2 +272,3 @@ * ModuleDescriptor, | ||
| readPowers, | ||
| archiveOnly, | ||
| sourceMapHook, | ||
@@ -277,2 +279,3 @@ strictlyRequiredForCompartment, | ||
| ) { | ||
| const { sourceDirname } = compartmentDescriptor; | ||
| for (const candidateSpecifier of candidates) { | ||
@@ -333,2 +336,3 @@ const candidateModuleDescriptor = moduleDescriptors[candidateSpecifier]; | ||
| readPowers, | ||
| archiveOnly, | ||
| sourceMapHook: | ||
@@ -385,2 +389,3 @@ sourceMapHook && | ||
| sourceLocation: moduleLocation, | ||
| sourceDirname, | ||
| parser, | ||
@@ -408,18 +413,3 @@ bytes: transformedBytes, | ||
| * @param {string} baseLocation | ||
| * @param {object} options | ||
| * @param {Sources} [options.sources] | ||
| * @param {Record<string, CompartmentDescriptor>} [options.compartmentDescriptors] | ||
| * @param {boolean} [options.archiveOnly] | ||
| * @param {HashFn} [options.computeSha512] | ||
| * @param {Array<string>} [options.searchSuffixes] - Suffixes to search if the | ||
| * unmodified specifier is not found. | ||
| * Pass [] to emulate Node.js' strict behavior. | ||
| * The default handles Node.js' CommonJS behavior. | ||
| * Unlike Node.js, the Compartment Mapper lifts CommonJS up, more like a | ||
| * bundler, and does not attempt to vary the behavior of resolution depending | ||
| * on the language of the importing module. | ||
| * @param {string} options.entryCompartmentName | ||
| * @param {string} options.entryModuleSpecifier | ||
| * @param {ExitModuleImportHook} [options.exitModuleImportHook] | ||
| * @param {SourceMapHook} [options.sourceMapHook] | ||
| * @param {MakeImportHookMakerOptions} options | ||
| * @returns {ImportHookMaker} | ||
@@ -439,3 +429,3 @@ */ | ||
| entryModuleSpecifier, | ||
| exitModuleImportHook = undefined, | ||
| importHook: exitModuleImportHook = undefined, | ||
| }, | ||
@@ -585,2 +575,3 @@ ) => { | ||
| readPowers, | ||
| archiveOnly, | ||
| sourceMapHook, | ||
@@ -628,4 +619,5 @@ strictlyRequiredForCompartment, | ||
| searchSuffixes = nodejsConventionSearchSuffixes, | ||
| archiveOnly = false, | ||
| sourceMapHook = undefined, | ||
| exitModuleImportNowHook, | ||
| importNowHook: exitModuleImportNowHook = undefined, | ||
| }, | ||
@@ -732,2 +724,3 @@ ) { | ||
| readPowers, | ||
| archiveOnly, | ||
| sourceMapHook, | ||
@@ -734,0 +727,0 @@ strictlyRequiredForCompartment, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"import-lite.d.ts","sourceRoot":"","sources":["import-lite.js"],"names":[],"mappings":";;;;;;;AAuEG,wCACQ,aAAa,kBACb,wBAAwB,iDAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;AAGE,wCACQ,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;AA0JM,0CANI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,gDAEtB,OAAO,CAAC,UAAU,CAAC,CAU/B;mCAtNS,YAAY;8CAAZ,YAAY;+CAAZ,YAAY;iCAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;2CAAZ,YAAY;gCAAZ,YAAY"} | ||
| {"version":3,"file":"import-lite.d.ts","sourceRoot":"","sources":["import-lite.js"],"names":[],"mappings":";;;;;;;AAuEG,wCACQ,aAAa,kBACb,wBAAwB,iDAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;AAGE,wCACQ,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;AA4JM,0CANI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,gDAEtB,OAAO,CAAC,UAAU,CAAC,CAU/B;mCAxNS,YAAY;8CAAZ,YAAY;+CAAZ,YAAY;iCAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;2CAAZ,YAAY;gCAAZ,YAAY"} |
@@ -172,3 +172,3 @@ /** | ||
| entryModuleSpecifier, | ||
| exitModuleImportHook: compartmentExitModuleImportHook, | ||
| importHook: compartmentExitModuleImportHook, | ||
| }, | ||
@@ -192,5 +192,7 @@ ); | ||
| { | ||
| entryCompartmentName, | ||
| entryModuleSpecifier, | ||
| compartmentDescriptors: compartmentMap.compartments, | ||
| searchSuffixes, | ||
| exitModuleImportNowHook, | ||
| importNowHook: exitModuleImportNowHook, | ||
| }, | ||
@@ -197,0 +199,0 @@ ); |
@@ -1,54 +0,11 @@ | ||
| export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string, conditionsOption: Set<string>, packageDescriptor: object, moduleSpecifier: string, options?: CompartmentMapForNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>; | ||
| export function mapNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: MapNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>; | ||
| /** | ||
| * The graph is an intermediate object model that the functions of this module | ||
| * build by exploring the `node_modules` tree dropped by tools like npm and | ||
| * consumed by tools like Node.js. | ||
| * This gets translated finally into a compartment map. | ||
| */ | ||
| export type Graph = Record<string, Node>; | ||
| export type Node = { | ||
| label: string; | ||
| name: string; | ||
| path: Array<string>; | ||
| logicalPath: Array<string>; | ||
| explicitExports: boolean; | ||
| internalAliases: Record<string, string>; | ||
| externalAliases: Record<string, string>; | ||
| /** | ||
| * - from module name to | ||
| * location in storage. | ||
| */ | ||
| dependencyLocations: Record<string, string>; | ||
| /** | ||
| * - the parser for | ||
| * modules based on their extension. | ||
| */ | ||
| parsers: LanguageForExtension; | ||
| /** | ||
| * - the parser for specific | ||
| * modules. | ||
| */ | ||
| types: Record<string, Language>; | ||
| }; | ||
| export type LanguageOptions = { | ||
| commonjsLanguageForExtension: LanguageForExtension; | ||
| moduleLanguageForExtension: LanguageForExtension; | ||
| workspaceCommonjsLanguageForExtension: LanguageForExtension; | ||
| workspaceModuleLanguageForExtension: LanguageForExtension; | ||
| languages: Set<string>; | ||
| }; | ||
| export type CommonDependencyDescriptors = Record<string, { | ||
| spec: string; | ||
| alias: string; | ||
| }>; | ||
| export type ReadDescriptorFn = (packageLocation: string) => Promise<object>; | ||
| export function basename(location: string): string; | ||
| export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string, conditionsOption: Set<string>, packageDescriptor: PackageDescriptor, moduleSpecifier: string, options?: CompartmentMapForNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>; | ||
| export function mapNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, { tags, conditions, log, ...otherOptions }?: MapNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>; | ||
| import type { ReadFn } from './types.js'; | ||
| import type { ReadPowers } from './types.js'; | ||
| import type { MaybeReadPowers } from './types.js'; | ||
| import type { PackageDescriptor } from './types.js'; | ||
| import type { CompartmentMapForNodeModulesOptions } from './types.js'; | ||
| import type { CompartmentMapDescriptor } from './types.js'; | ||
| import type { MapNodeModulesOptions } from './types.js'; | ||
| import type { LanguageForExtension } from './types.js'; | ||
| import type { Language } from './types.js'; | ||
| //# sourceMappingURL=node-modules.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.js"],"names":[],"mappings":"AAs2BO,yDARI,MAAM,GAAG,UAAU,GAAG,eAAe,mBACrC,MAAM,oBACN,GAAG,CAAC,MAAM,CAAC,qBACX,MAAM,mBACN,MAAM,8DAEJ,OAAO,CAAC,wBAAwB,CAAC,CA+D7C;AAQM,2CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,gDAEJ,OAAO,CAAC,wBAAwB,CAAC,CA6B7C;;;;;;;oBA/5BY,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;;WAKnB,MAAM;UACN,MAAM;UACN,KAAK,CAAC,MAAM,CAAC;iBACb,KAAK,CAAC,MAAM,CAAC;qBACb,OAAO;qBACP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;qBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;yBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;aAEtB,oBAAoB;;;;;WAEpB,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC;;;kCAMxB,oBAAoB;gCACpB,oBAAoB;2CACpB,oBAAoB;yCACpB,oBAAoB;eACpB,GAAG,CAAC,MAAM,CAAC;;0CAIZ,MAAM,CAAC,MAAM,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;iDA+E/C,MAAM,KACJ,OAAO,CAAC,MAAM,CAAC;4BAvHlB,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;yDAAZ,YAAY;8CAAZ,YAAY;2CAAZ,YAAY;0CAAZ,YAAY;8BAAZ,YAAY"} | ||
| {"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.js"],"names":[],"mappings":"AAiFO,mCAHI,MAAM,GACJ,MAAM,CAYlB;AAuwBM,yDATI,MAAM,GAAG,UAAU,GAAG,eAAe,mBACrC,MAAM,oBACN,GAAG,CAAC,MAAM,CAAC,qBACX,iBAAiB,mBACjB,MAAM,8DAEJ,OAAO,CAAC,wBAAwB,CAAC,CAkE7C;AAaM,2CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,mFAEJ,OAAO,CAAC,wBAAwB,CAAC,CA0B7C;4BAz6BS,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;uCAAZ,YAAY;yDAAZ,YAAY;8CAAZ,YAAY;2CAAZ,YAAY"} |
+121
-121
@@ -20,3 +20,2 @@ /** | ||
| * CompartmentMapForNodeModulesOptions, | ||
| * Language, | ||
| * LanguageForExtension, | ||
@@ -26,50 +25,21 @@ * MapNodeModulesOptions, | ||
| * MaybeReadPowers, | ||
| * ModuleDescriptor, | ||
| * PackageDescriptor, | ||
| * ReadDescriptorFn, | ||
| * ReadFn, | ||
| * ReadPowers, | ||
| * ScopeDescriptor, | ||
| * SomePackagePolicy, | ||
| * SomePolicy, | ||
| * } from './types.js' | ||
| * @import { | ||
| * Graph, | ||
| * Node, | ||
| * LanguageOptions, | ||
| * CommonDependencyDescriptors, | ||
| * GatherDependencyOptions, | ||
| * GraphPackageOptions, | ||
| * GraphPackagesOptions, | ||
| * PackageDetails, | ||
| * } from './types/node-modules.js' | ||
| */ | ||
| /** | ||
| * The graph is an intermediate object model that the functions of this module | ||
| * build by exploring the `node_modules` tree dropped by tools like npm and | ||
| * consumed by tools like Node.js. | ||
| * This gets translated finally into a compartment map. | ||
| * | ||
| * @typedef {Record<string, Node>} Graph | ||
| */ | ||
| /** | ||
| * @typedef {object} Node | ||
| * @property {string} label | ||
| * @property {string} name | ||
| * @property {Array<string>} path | ||
| * @property {Array<string>} logicalPath | ||
| * @property {boolean} explicitExports | ||
| * @property {Record<string, string>} internalAliases | ||
| * @property {Record<string, string>} externalAliases | ||
| * @property {Record<string, string>} dependencyLocations - from module name to | ||
| * location in storage. | ||
| * @property {LanguageForExtension} parsers - the parser for | ||
| * modules based on their extension. | ||
| * @property {Record<string, Language>} types - the parser for specific | ||
| * modules. | ||
| */ | ||
| /** | ||
| * @typedef {object} LanguageOptions | ||
| * @property {LanguageForExtension} commonjsLanguageForExtension | ||
| * @property {LanguageForExtension} moduleLanguageForExtension | ||
| * @property {LanguageForExtension} workspaceCommonjsLanguageForExtension | ||
| * @property {LanguageForExtension} workspaceModuleLanguageForExtension | ||
| * @property {Set<string>} languages | ||
| */ | ||
| /** | ||
| * @typedef {Record<string, {spec: string, alias: string}>} CommonDependencyDescriptors | ||
| */ | ||
| import { pathCompare } from './compartment-map.js'; | ||
@@ -96,2 +66,7 @@ import { inferExportsAndAliases } from './infer-exports.js'; | ||
| /** | ||
| * Default logger that does nothing. | ||
| */ | ||
| const noop = () => {}; | ||
| /** | ||
| * @param {string} rel - a relative URL | ||
@@ -105,2 +80,3 @@ * @param {string} abs - a fully qualified URL | ||
| // Exported for testing: | ||
| /** | ||
@@ -110,4 +86,7 @@ * @param {string} location | ||
| */ | ||
| const basename = location => { | ||
| const { pathname } = new URL(location); | ||
| export const basename = location => { | ||
| let { pathname } = new URL(location); | ||
| if (pathname.endsWith('/')) { | ||
| pathname = pathname.slice(0, -1); | ||
| } | ||
| const index = pathname.lastIndexOf('/'); | ||
@@ -153,13 +132,8 @@ if (index < 0) { | ||
| /** | ||
| * @callback ReadDescriptorFn | ||
| * @param {string} packageLocation | ||
| * @returns {Promise<object>} | ||
| */ | ||
| /** | ||
| * findPackage behaves as Node.js to find third-party modules by searching | ||
| * `findPackage` behaves as Node.js to find third-party modules by searching | ||
| * parent to ancestor directories for a `node_modules` directory that contains | ||
| * the name. | ||
| * | ||
| * Node.js does not actually require these to be packages, but in practice, | ||
| * these are the locations that pakcage managers drop a package so Node.js can | ||
| * these are the locations that package managers drop a package so Node.js can | ||
| * find it efficiently. | ||
@@ -171,6 +145,3 @@ * | ||
| * @param {string} name | ||
| * @returns {Promise<{ | ||
| * packageLocation: string, | ||
| * packageDescriptor: object, | ||
| * } | undefined>} | ||
| * @returns {Promise<PackageDetails|undefined>} | ||
| */ | ||
@@ -208,2 +179,3 @@ const findPackage = async (readDescriptor, canonical, directory, name) => { | ||
| /** @satisfies {LanguageForExtension} */ | ||
| const defaultLanguageForExtension = /** @type {const} */ ({ | ||
@@ -216,5 +188,9 @@ mjs: 'mjs', | ||
| }); | ||
| /** @satisfies {LanguageForExtension} */ | ||
| const defaultCommonjsLanguageForExtension = /** @type {const} */ ({ | ||
| js: 'cjs', | ||
| }); | ||
| /** @satisfies {LanguageForExtension} */ | ||
| const defaultModuleLanguageForExtension = /** @type {const} */ ({ | ||
@@ -225,3 +201,3 @@ js: 'mjs', | ||
| /** | ||
| * @param {object} descriptor | ||
| * @param {PackageDescriptor} descriptor | ||
| * @param {string} location | ||
@@ -291,3 +267,3 @@ * @param {LanguageOptions} languageOptions | ||
| /** | ||
| * graphPackage and gatherDependency are mutually recursive functions that | ||
| * `graphPackage` and {@link gatherDependency} are mutually recursive functions that | ||
| * gather the metadata for a package and its transitive dependencies. | ||
@@ -303,12 +279,8 @@ * The keys of the graph are the locations of the package descriptors. | ||
| * @param {Graph} graph | ||
| * @param {object} packageDetails | ||
| * @param {string} packageDetails.packageLocation | ||
| * @param {object} packageDetails.packageDescriptor | ||
| * @param {PackageDetails} packageDetails | ||
| * @param {Set<string>} conditions | ||
| * @param {boolean | undefined} dev | ||
| * @param {CommonDependencyDescriptors} commonDependencyDescriptors | ||
| * @param {LanguageOptions} languageOptions | ||
| * @param {boolean} strict | ||
| * @param {Map<string, Array<string>>} preferredPackageLogicalPathMap | ||
| * @param {Array<string>} logicalPath | ||
| * @param {GraphPackageOptions} options | ||
| * @returns {Promise<undefined>} | ||
@@ -324,7 +296,10 @@ */ | ||
| dev, | ||
| commonDependencyDescriptors, | ||
| languageOptions, | ||
| strict, | ||
| preferredPackageLogicalPathMap = new Map(), | ||
| logicalPath = [], | ||
| { | ||
| commonDependencyDescriptors = {}, | ||
| preferredPackageLogicalPathMap = new Map(), | ||
| logicalPath = [], | ||
| log = noop, | ||
| } = {}, | ||
| ) => { | ||
@@ -337,16 +312,15 @@ if (graph[packageLocation] !== undefined) { | ||
| if (packageDescriptor.name !== name) { | ||
| console.warn( | ||
| `Package named ${q( | ||
| name, | ||
| )} does not match location ${packageLocation} got (${q( | ||
| packageDescriptor.name, | ||
| )})`, | ||
| ); | ||
| log('Package name does not match location', { | ||
| name, | ||
| packageDescriptorName: packageDescriptor.name, | ||
| packageLocation, | ||
| }); | ||
| } | ||
| const result = {}; | ||
| graph[packageLocation] = /** @type {Node} */ (result); | ||
| const result = /** @type {Node} */ ({}); | ||
| graph[packageLocation] = result; | ||
| /** @type {Record<string, string>} */ | ||
| /** @type {Node['dependencyLocations']} */ | ||
| const dependencyLocations = {}; | ||
| /** @type {ReturnType<typeof gatherDependency>[]} */ | ||
| const children = []; | ||
@@ -404,5 +378,8 @@ const optionals = new Set(); | ||
| strict, | ||
| childLogicalPath, | ||
| optional, | ||
| commonDependencyDescriptors, | ||
| { | ||
| childLogicalPath, | ||
| optional, | ||
| commonDependencyDescriptors, | ||
| log, | ||
| }, | ||
| ), | ||
@@ -413,5 +390,9 @@ ); | ||
| const { version = '', exports: exportsDescriptor } = packageDescriptor; | ||
| /** @type {Record<string, Language>} */ | ||
| /** @type {Node['types']} */ | ||
| const types = {}; | ||
| /** | ||
| * @param {string} path | ||
| * @returns {Promise<PackageDescriptor>} | ||
| */ | ||
| const readDescriptorUpwards = async path => { | ||
@@ -424,5 +405,5 @@ const location = resolveLocation(path, packageLocation); | ||
| /** @type {Record<string, string>} */ | ||
| /** @type {Node['externalAliases']} */ | ||
| const externalAliases = {}; | ||
| /** @type {Record<string, string>} */ | ||
| /** @type {Node['internalAliases']} */ | ||
| const internalAliases = {}; | ||
@@ -444,2 +425,4 @@ | ||
| const sourceDirname = basename(packageLocation); | ||
| Object.assign(result, { | ||
@@ -449,2 +432,3 @@ name, | ||
| label: `${name}${version ? `-v${version}` : ''}`, | ||
| sourceDirname, | ||
| explicitExports: exportsDescriptor !== undefined, | ||
@@ -501,2 +485,4 @@ externalAliases, | ||
| /** | ||
| * Adds information for the dependency of the package at `packageLocation` to the `graph` object. | ||
| * | ||
| * @param {ReadDescriptorFn} readDescriptor | ||
@@ -511,6 +497,5 @@ * @param {CanonicalFn} canonical | ||
| * @param {LanguageOptions} languageOptions | ||
| * @param {boolean} strict | ||
| * @param {Array<string>} [childLogicalPath] | ||
| * @param {boolean} [optional] - whether the dependency is optional | ||
| * @param {object} [commonDependencyDescriptors] - dependencies to be added to all packages | ||
| * @param {boolean} strict - If `true`, a missing dependency will throw an exception | ||
| * @param {GatherDependencyOptions} options | ||
| * @returns {Promise<void>} | ||
| */ | ||
@@ -528,5 +513,8 @@ const gatherDependency = async ( | ||
| strict, | ||
| childLogicalPath = [], | ||
| optional = false, | ||
| commonDependencyDescriptors = undefined, | ||
| { | ||
| childLogicalPath = [], | ||
| optional = false, | ||
| commonDependencyDescriptors = {}, | ||
| log = noop, | ||
| } = {}, | ||
| ) => { | ||
@@ -564,7 +552,10 @@ const dependency = await findPackage( | ||
| false, | ||
| commonDependencyDescriptors, | ||
| languageOptions, | ||
| strict, | ||
| preferredPackageLogicalPathMap, | ||
| childLogicalPath, | ||
| { | ||
| commonDependencyDescriptors, | ||
| preferredPackageLogicalPathMap, | ||
| logicalPath: childLogicalPath, | ||
| log, | ||
| }, | ||
| ); | ||
@@ -574,9 +565,4 @@ }; | ||
| /** | ||
| * graphPackages returns a graph whose keys are nominally URLs, one per | ||
| * package, with values that are label: (an informative Compartment name, built | ||
| * as ${name}@${version}), dependencies: (a list of URLs), and exports: (an | ||
| * object whose keys are the thing being imported, and the values are the names | ||
| * of the matching module, relative to the containing package's root, that is, | ||
| * the URL that was used as the key of graph). | ||
| * The URLs in dependencies will all exist as other keys of graph. | ||
| * Resolves with a {@link Graph} representing the packages for which | ||
| * {@link CompartmentDescriptor CompartmentDescriptors} will be created. | ||
| * | ||
@@ -587,9 +573,12 @@ * @param {MaybeReadFn} maybeRead | ||
| * @param {Set<string>} conditions | ||
| * @param {object} mainPackageDescriptor - the parsed contents of the main | ||
| * package.json, which was already read when searching for the package.json. | ||
| * @param {boolean|undefined} dev - whether to use devDependencies from this package (and | ||
| * only this package). | ||
| * @param {Record<string,string>} commonDependencies - dependencies to be added to all packages | ||
| * @param {PackageDescriptor} mainPackageDescriptor - the parsed contents of the | ||
| * main `package.json`, which was already read when searching for the | ||
| * `package.json`. | ||
| * @param {boolean|undefined} dev - whether to use devDependencies from this | ||
| * package (and only this package). | ||
| * @param {Record<string,string>} commonDependencies - dependencies to be added | ||
| * to all packages | ||
| * @param {LanguageOptions} languageOptions | ||
| * @param {boolean} strict | ||
| * @param {GraphPackagesOptions} options | ||
| */ | ||
@@ -606,2 +595,3 @@ const graphPackages = async ( | ||
| strict, | ||
| { log = noop } = {}, | ||
| ) => { | ||
@@ -611,3 +601,3 @@ const memo = create(null); | ||
| * @param {string} packageLocation | ||
| * @returns {Promise<object>} | ||
| * @returns {Promise<PackageDescriptor>} | ||
| */ | ||
@@ -663,5 +653,8 @@ const readDescriptor = packageLocation => | ||
| dev, | ||
| commonDependencyDescriptors, | ||
| languageOptions, | ||
| strict, | ||
| { | ||
| commonDependencyDescriptors, | ||
| log, | ||
| }, | ||
| ); | ||
@@ -672,4 +665,4 @@ return graph; | ||
| /** | ||
| * translateGraph converts the graph returned by graph packages (above) into a | ||
| * compartment map. | ||
| * `translateGraph` converts the graph returned by graph packages (above) into a | ||
| * {@link CompartmentMapDescriptor compartment map}. | ||
| * | ||
@@ -691,3 +684,3 @@ * @param {string} entryPackageLocation | ||
| ) => { | ||
| /** @type {Record<string, CompartmentDescriptor>} */ | ||
| /** @type {CompartmentMapDescriptor['compartments']} */ | ||
| const compartments = Object.create(null); | ||
@@ -709,2 +702,3 @@ | ||
| label, | ||
| sourceDirname, | ||
| dependencyLocations, | ||
@@ -715,5 +709,5 @@ internalAliases, | ||
| } = graph[dependeeLocation]; | ||
| /** @type {Record<string, ModuleDescriptor>} */ | ||
| /** @type {CompartmentDescriptor['modules']} */ | ||
| const moduleDescriptors = Object.create(null); | ||
| /** @type {Record<string, ScopeDescriptor>} */ | ||
| /** @type {CompartmentDescriptor['scopes']} */ | ||
| const scopes = Object.create(null); | ||
@@ -805,2 +799,3 @@ | ||
| location: dependeeLocation, | ||
| sourceDirname, | ||
| modules: moduleDescriptors, | ||
@@ -899,6 +894,7 @@ scopes, | ||
| * @param {Set<string>} conditionsOption | ||
| * @param {object} packageDescriptor | ||
| * @param {PackageDescriptor} packageDescriptor | ||
| * @param {string} moduleSpecifier | ||
| * @param {CompartmentMapForNodeModulesOptions} [options] | ||
| * @returns {Promise<CompartmentMapDescriptor>} | ||
| * @deprecated Use {@link mapNodeModules} instead. | ||
| */ | ||
@@ -918,2 +914,3 @@ export const compartmentMapForNodeModules = async ( | ||
| strict = false, | ||
| log = noop, | ||
| } = options; | ||
@@ -940,2 +937,3 @@ const { maybeRead, canonical } = unpackReadPowers(readPowers); | ||
| strict, | ||
| { log }, | ||
| ); | ||
@@ -971,2 +969,7 @@ | ||
| /** | ||
| * Creates a {@link CompartmentMapDescriptor} from the module at | ||
| * `moduleLocation`, considering dependencies found in `node_modules`. | ||
| * | ||
| * Locates the {@link PackageDescriptor} for the module at `moduleLocation` | ||
| * | ||
| * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers | ||
@@ -980,6 +983,4 @@ * @param {string} moduleLocation | ||
| moduleLocation, | ||
| options = {}, | ||
| { tags = new Set(), conditions = tags, log = noop, ...otherOptions } = {}, | ||
| ) => { | ||
| const { tags = new Set(), conditions = tags, ...otherOptions } = options; | ||
| const { | ||
@@ -990,7 +991,6 @@ packageLocation, | ||
| moduleSpecifier, | ||
| } = await search(readPowers, moduleLocation); | ||
| } = await search(readPowers, moduleLocation, { log }); | ||
| const packageDescriptor = parseLocatedJson( | ||
| packageDescriptorText, | ||
| packageDescriptorLocation, | ||
| const packageDescriptor = /** @type {PackageDescriptor} */ ( | ||
| parseLocatedJson(packageDescriptorText, packageDescriptorLocation) | ||
| ); | ||
@@ -1004,4 +1004,4 @@ | ||
| moduleSpecifier, | ||
| otherOptions, | ||
| { log, ...otherOptions }, | ||
| ); | ||
| }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"parse-archive-cjs.d.ts","sourceRoot":"","sources":["parse-archive-cjs.js"],"names":[],"mappings":"AAkBA,sBAAsB;AACtB,8BADW,OAAO,CA6ChB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BA5DzB,YAAY"} | ||
| {"version":3,"file":"parse-archive-cjs.d.ts","sourceRoot":"","sources":["parse-archive-cjs.js"],"names":[],"mappings":"AAkBA,sBAAsB;AACtB,8BADW,OAAO,CAkDhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BAjEzB,YAAY"} |
@@ -25,5 +25,8 @@ /** | ||
| _packageLocation, | ||
| options = {}, | ||
| ) => { | ||
| const source = textDecoder.decode(bytes); | ||
| const { archiveOnly = false } = options; | ||
| const { | ||
@@ -39,3 +42,3 @@ requires: imports, | ||
| const cjsWrappedSource = `(function (require, exports, module, __filename, __dirname) { ${source} //*/\n})\n`; | ||
| let cjsFunctor = `(function (require, exports, module, __filename, __dirname) { 'use strict'; ${source} //*/\n})\n`; | ||
@@ -47,7 +50,9 @@ const pre = textEncoder.encode( | ||
| reexports, | ||
| source: cjsWrappedSource, | ||
| source: cjsFunctor, | ||
| }), | ||
| ); | ||
| const cjsFunctor = `${cjsWrappedSource}//# sourceURL=${location}\n`; | ||
| if (!archiveOnly) { | ||
| cjsFunctor = `${cjsFunctor}//# sourceURL=${location}\n`; | ||
| } | ||
@@ -54,0 +59,0 @@ return { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AAwCO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,CAmIH;gCApNqC,YAAY;4BAAZ,YAAY"} | ||
| {"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AAwCO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,CA2HH;gCA5MqC,YAAY;4BAAZ,YAAY"} |
@@ -138,13 +138,4 @@ /** | ||
| let finalExports = originalExports; | ||
| const module = { exports: originalExports }; | ||
| const module = freeze({ | ||
| get exports() { | ||
| return finalExports; | ||
| }, | ||
| set exports(value) { | ||
| finalExports = value; | ||
| }, | ||
| }); | ||
| /** @param {string} importSpecifier */ | ||
@@ -196,2 +187,3 @@ const require = importSpecifier => { | ||
| const afterExecute = () => { | ||
| const finalExports = module.exports; // in case it's a getter, only call it once | ||
| const exportsHaveBeenOverwritten = finalExports !== originalExports; | ||
@@ -198,0 +190,0 @@ // Promotes keys from redefined module.export to top level namespace for import * |
+1
-1
@@ -44,3 +44,3 @@ /** | ||
| const functor = compartment.evaluate( | ||
| `(function (require, exports, module, __filename, __dirname) { ${source} //*/\n})\n//# sourceURL=${location}`, | ||
| `(function (require, exports, module, __filename, __dirname) { 'use strict'; ${source} })\n`, | ||
| ); | ||
@@ -47,0 +47,0 @@ |
+2
-2
@@ -17,6 +17,6 @@ /** @module Provides language behavior (a parser) for importing ESM. */ | ||
| ) => { | ||
| const { sourceMap, sourceMapHook } = options; | ||
| const { sourceMap, sourceMapHook, archiveOnly = false } = options; | ||
| const source = textDecoder.decode(bytes); | ||
| const record = new ModuleSource(source, { | ||
| sourceUrl, | ||
| sourceUrl: archiveOnly ? undefined : sourceUrl, | ||
| sourceMap, | ||
@@ -23,0 +23,0 @@ sourceMapUrl: sourceUrl, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.js"],"names":[],"mappings":"AAgCA;;GAEG;AACH,sDAAuD;AAyDhD,gEAFM,KAAK,CAAC,MAAM,CAAC,CAezB;AA0BM,qDAJI,gBAAgB,iBAChB,aAAa,GACX,OAAO,CASnB;;;;;;;;;AAKE,+CACQ,gBAAgB,UAChB,UAAU,GACR,iBAAiB,CAC7B;;;;;;;;;AAKE,+CACQ,gBAAgB,oCAEd,iBAAiB,GAAC,SAAS,CACvC;AAkFM,8DAJI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,0BAC3B,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GACnC,2BAA2B,CA0CvC;AAoDM,6CARI,MAAM,WACN,MAAM,iBACN,aAAa,eACb,2BAA2B,eAC3B,KAAK,cAAS,SACd,MAAM,GACJ,IAAI,CAgDhB;AA2BM,+CAJI,MAAM,yBACN,qBAAqB,sEAiC/B;AAgDM,+CANI,MAAM,wBACN,OAAO,KAAK,EAAE,+BAA+B,UAC7C,aAAa,eACb,2BAA2B,GACzB,OAAO,CAAC,OAAO,KAAK,EAAE,+BAA+B,CAAC,CAyBlE;;;;;;;;;;;;;;4BAveS,YAAY;sCAAZ,YAAY;mCAAZ,YAAY;gCAAZ,YAAY;uCAAZ,YAAY;2CAAZ,YAAY;iDAAZ,YAAY"} | ||
| {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.js"],"names":[],"mappings":"AAgCA;;GAEG;AACH,sDAAuD;AAyDhD,gEAFM,KAAK,CAAC,MAAM,CAAC,CAezB;AA0BM,qDAJI,gBAAgB,iBAChB,aAAa,GACX,OAAO,CASnB;;;;;;;;;AAKE,+CACQ,gBAAgB,UAChB,UAAU,GACR,iBAAiB,CAC7B;;;;;;;;;AAKE,+CACQ,gBAAgB,oCAEd,iBAAiB,GAAC,SAAS,CACvC;AAkFM,8DAJI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,0BAC3B,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GACnC,2BAA2B,CAuCvC;AAoDM,6CARI,MAAM,WACN,MAAM,iBACN,aAAa,eACb,2BAA2B,eAC3B,KAAK,cAAS,SACd,MAAM,GACJ,IAAI,CAgDhB;AA2BM,+CAJI,MAAM,yBACN,qBAAqB,sEAiC/B;AAgDM,+CANI,MAAM,wBACN,OAAO,KAAK,EAAE,+BAA+B,UAC7C,aAAa,eACb,2BAA2B,GACzB,OAAO,CAAC,OAAO,KAAK,EAAE,+BAA+B,CAAC,CAyBlE;;;;;;;;;;;;;;4BApeS,YAAY;sCAAZ,YAAY;mCAAZ,YAAY;gCAAZ,YAAY;uCAAZ,YAAY;2CAAZ,YAAY;iDAAZ,YAAY"} |
+4
-7
@@ -243,2 +243,3 @@ /** | ||
| ) => { | ||
| /** @type {DeferredAttenuatorsProvider['import']} */ | ||
| let importAttenuator; | ||
@@ -259,7 +260,2 @@ let defaultAttenuator; | ||
| // time of the import function being called. | ||
| /** | ||
| * | ||
| * @param {string} attenuatorSpecifier | ||
| * @returns {Promise<Attenuator>} | ||
| */ | ||
| importAttenuator = async attenuatorSpecifier => { | ||
@@ -272,4 +268,5 @@ if (!attenuatorSpecifier) { | ||
| } | ||
| const { namespace } = | ||
| await compartments[ATTENUATORS_COMPARTMENT].import(attenuatorSpecifier); | ||
| const { namespace } = await compartments[ATTENUATORS_COMPARTMENT].import( | ||
| /** @type {string} */ (attenuatorSpecifier), | ||
| ); | ||
| return namespace; | ||
@@ -276,0 +273,0 @@ }; |
+6
-12
@@ -1,16 +0,10 @@ | ||
| export function searchDescriptor<T>(location: string, maybeReadDescriptor: (location: string) => Promise<T | undefined>): Promise<{ | ||
| data: T; | ||
| directory: string; | ||
| location: string; | ||
| packageDescriptorLocation: string; | ||
| }>; | ||
| export function search(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string): Promise<{ | ||
| packageLocation: string; | ||
| packageDescriptorLocation: string; | ||
| packageDescriptorText: string; | ||
| moduleSpecifier: string; | ||
| }>; | ||
| export function searchDescriptor<T>(location: string, maybeReadDescriptor: MaybeReadDescriptorFn<T>, { log: _log }?: SearchDescriptorOptions): Promise<SearchDescriptorResult<T>>; | ||
| export function search(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, { log }?: import("./types.js").LogOptions | undefined): Promise<SearchResult>; | ||
| import type { MaybeReadDescriptorFn } from './types.js'; | ||
| import type { SearchDescriptorOptions } from './types.js'; | ||
| import type { SearchDescriptorResult } from './types.js'; | ||
| import type { ReadFn } from './types.js'; | ||
| import type { ReadPowers } from './types.js'; | ||
| import type { MaybeReadPowers } from './types.js'; | ||
| import type { SearchResult } from './types.js'; | ||
| //# sourceMappingURL=search.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"AAwCO,iCALM,CAAC,YACH,MAAM,uBACN,CAAC,QAAQ,EAAC,MAAM,KAAG,OAAO,CAAC,CAAC,GAAC,SAAS,CAAC,GACrC,OAAO,CAAC;IAAC,IAAI,EAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,yBAAyB,EAAE,MAAM,CAAA;CAAC,CAAC,CA0BpG;AAoCM,mCATI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,GACJ,OAAO,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAoBJ;4BA5GS,YAAY;gCAAZ,YAAY;qCAAZ,YAAY"} | ||
| {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"AAmDO,iCANM,CAAC,YACH,MAAM,uBACN,sBAAsB,CAAC,CAAC,kBACxB,uBAAuB,GACrB,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CA8B9C;AAgCM,mCALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,0DAEJ,OAAO,CAAC,YAAY,CAAC,CA0BjC;2CAxHS,YAAY;6CAAZ,YAAY;4CAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;kCAAZ,YAAY"} |
+29
-12
@@ -11,2 +11,7 @@ /** | ||
| * MaybeReadPowers, | ||
| * SearchOptions, | ||
| * SearchResult, | ||
| * SearchDescriptorResult, | ||
| * MaybeReadDescriptorFn, | ||
| * SearchDescriptorOptions, | ||
| * } from './types.js' | ||
@@ -22,2 +27,7 @@ */ | ||
| /** | ||
| * Default logger that does nothing | ||
| */ | ||
| const noop = () => {}; | ||
| const decoder = new TextDecoder(); | ||
@@ -40,6 +50,11 @@ | ||
| * @param {string} location | ||
| * @param {(location:string)=>Promise<T|undefined>} maybeReadDescriptor | ||
| * @returns {Promise<{data:T, directory: string, location:string, packageDescriptorLocation: string}>} | ||
| * @param {MaybeReadDescriptorFn<T>} maybeReadDescriptor | ||
| * @param {SearchDescriptorOptions} options | ||
| * @returns {Promise<SearchDescriptorResult<T>>} | ||
| */ | ||
| export const searchDescriptor = async (location, maybeReadDescriptor) => { | ||
| export const searchDescriptor = async ( | ||
| location, | ||
| maybeReadDescriptor, | ||
| { log: _log = noop } = {}, | ||
| ) => { | ||
| await null; | ||
@@ -97,13 +112,15 @@ let directory = resolveLocation('./', location); | ||
| * @param {string} moduleLocation | ||
| * @returns {Promise<{ | ||
| * packageLocation: string, | ||
| * packageDescriptorLocation: string, | ||
| * packageDescriptorText: string, | ||
| * moduleSpecifier: string, | ||
| * }>} | ||
| * @param {SearchOptions} [options] | ||
| * @returns {Promise<SearchResult>} | ||
| */ | ||
| export const search = async (readPowers, moduleLocation) => { | ||
| export const search = async ( | ||
| readPowers, | ||
| moduleLocation, | ||
| { log = noop } = {}, | ||
| ) => { | ||
| const { data, directory, location, packageDescriptorLocation } = | ||
| await searchDescriptor(moduleLocation, loc => | ||
| maybeReadDescriptorDefault(readPowers, loc), | ||
| await searchDescriptor( | ||
| moduleLocation, | ||
| loc => maybeReadDescriptorDefault(readPowers, loc), | ||
| { log }, | ||
| ); | ||
@@ -110,0 +127,0 @@ |
@@ -32,2 +32,7 @@ /** | ||
| label: string; | ||
| /** | ||
| * name of the parent directory of the package from which the compartment is derived, | ||
| * for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace. | ||
| */ | ||
| sourceDirname?: string; | ||
| /** shortest path of dependency names to this compartment */ | ||
@@ -34,0 +39,0 @@ path?: Array<string>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"compartment-map-schema.d.ts","sourceRoot":"","sources":["compartment-map-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,KAAK,CAAC,MA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AiB,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,MAAM,GACN,cAAc,GACd,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"} |
@@ -38,2 +38,7 @@ /** | ||
| label: string; | ||
| /** | ||
| * name of the parent directory of the package from which the compartment is derived, | ||
| * for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace. | ||
| */ | ||
| sourceDirname?: string; | ||
| /** shortest path of dependency names to this compartment */ | ||
@@ -40,0 +45,0 @@ path?: Array<string>; |
+112
-8
@@ -5,3 +5,3 @@ /** | ||
| import type { FinalStaticModuleType, StaticModuleType, ThirdPartyStaticModuleInterface, Transform } from 'ses'; | ||
| import type { CompartmentMapDescriptor, CompartmentDescriptor, Language, LanguageForExtension } from './compartment-map-schema.js'; | ||
| import type { CompartmentDescriptor, CompartmentMapDescriptor, Language, LanguageForExtension } from './compartment-map-schema.js'; | ||
| import type { HashFn, ReadFn, ReadPowers } from './powers.js'; | ||
@@ -29,3 +29,15 @@ /** | ||
| export type LoadArchiveOptions = ParseArchiveOptions; | ||
| export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy & PolicyOption; | ||
| /** | ||
| * Options having an optional `log` property. | ||
| */ | ||
| export interface LogOptions { | ||
| /** | ||
| * A logger (for logging) | ||
| */ | ||
| log?: LogFn; | ||
| } | ||
| /** | ||
| * Options for `mapNodeModules()` | ||
| */ | ||
| export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy & PolicyOption & LogOptions; | ||
| type MapNodeModulesOptionsOmitPolicy = Partial<{ | ||
@@ -89,6 +101,31 @@ /** @deprecated renamed `conditions` to be consistent with Node.js */ | ||
| export type CompartmentMapForNodeModulesOptions = Omit<MapNodeModulesOptions, 'conditions' | 'tags'>; | ||
| export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption; | ||
| export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption & LogOptions; | ||
| export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions & ModuleTransformsOption & ImportingOptions & ExitModuleImportHookOption & LinkingOptions; | ||
| export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions & SyncModuleTransformsOption & SyncImportingOptions & ExitModuleImportNowHookOption; | ||
| export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> & ArchiveLiteOptions; | ||
| export type BundleOptions = ArchiveOptions & { | ||
| /** | ||
| * Format of the bundle for purposes of importing modules from the surrounding | ||
| * environment. | ||
| * The default can be CommonJS or ESM but depends on neither `require` nor `import` | ||
| * for external modules, but errors early if the entrained modules need to import | ||
| * a host module. | ||
| * Specifying `cjs` makes `require` available for modules outside the bundle | ||
| * (exits to the import graph). | ||
| */ | ||
| format?: 'cjs'; | ||
| /** | ||
| * Evaluates individual module functors in-place so stack traces represent | ||
| * original source locations better. | ||
| * The resulting script cannot be used on a web page with a no-unsafe-eval | ||
| * Content Security Policy. | ||
| */ | ||
| useEvaluate?: boolean; | ||
| /** | ||
| * A prefix for the sourceURL comment in each module format that supports | ||
| * sourceURL comments. | ||
| * Requires `useEvaluate` for effect. | ||
| */ | ||
| sourceUrlPrefix?: string; | ||
| }; | ||
| export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> & SyncArchiveLiteOptions; | ||
@@ -98,3 +135,3 @@ /** | ||
| */ | ||
| export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions; | ||
| export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions & LogOptions; | ||
| /** | ||
@@ -104,4 +141,13 @@ * Options for `importLocation()` necessary (but not sufficient--see | ||
| */ | ||
| export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions; | ||
| export type ImportLocationOptions = ArchiveOptions & ExecuteOptions; | ||
| export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions & LogOptions; | ||
| /** | ||
| * Options for `importLocation()` without dynamic require support | ||
| */ | ||
| export type ImportLocationOptions = ArchiveOptions & ExecuteOptions & LogOptions; | ||
| export type ComputeSha512Option = { | ||
| /** | ||
| * For computing integrity hashes for module descriptors based on captured sources. | ||
| */ | ||
| computeSha512?: HashFn; | ||
| }; | ||
| export type SearchSuffixesOption = { | ||
@@ -125,5 +171,13 @@ /** | ||
| export type ExitModuleImportHookOption = { | ||
| /** | ||
| * For obtaining module descriptors for modules that must be provided | ||
| * by the eventual runtime execution environment, asynchronously. | ||
| */ | ||
| importHook?: ExitModuleImportHook; | ||
| }; | ||
| export type ExitModuleImportNowHookOption = { | ||
| /** | ||
| * For obtaining module descriptors for modules that must be provided | ||
| * by the eventual runtime execution environment, synchronusly. | ||
| */ | ||
| importNowHook?: ExitModuleImportNowHook; | ||
@@ -143,2 +197,29 @@ }; | ||
| }; | ||
| export type ArchiveOnlyOption = { | ||
| /** | ||
| * Whether to prepare to create an archive or script bundle for execution | ||
| * elsewhere or elsewhen, as opposed to preparing to execute immediately. | ||
| * | ||
| * This has several practical effects. | ||
| * | ||
| * Archives expect to exit to potentially different host modules than the current | ||
| * host, but cannot instantiate those modules. | ||
| * For example, when preparing a bundle for execution in Node.js from within a | ||
| * web page, exiting to `node:fs` is appropriate but cannot be instantiated. | ||
| * So, the import hook will make a note of the exit and provide a stub module | ||
| * that throws an error if it is imported. | ||
| * | ||
| * Also, importing a module graph off a local medium immediately should | ||
| * inject a fully qualified source location into the module source, | ||
| * but sources loaded for an archive must not capture the original source | ||
| * location, but give the runtime an opportunity to inject a sourceURL. | ||
| * | ||
| * Also, the linker does not apply attenuations to the global environment | ||
| * if it is preparing to write an archive or script bundle. | ||
| * | ||
| * This option does not generally surface to users, but is set by the scenario, | ||
| * off for `importLocation`, on for `makeArchive` and `makeScript`. | ||
| */ | ||
| archiveOnly?: boolean; | ||
| }; | ||
| export type PolicyOption = { | ||
@@ -208,6 +289,25 @@ policy?: any; | ||
| deferredError: string; | ||
| /** package-relative location */ | ||
| /** | ||
| * package-relative location. | ||
| * Not suitable for capture in an archive or bundle since it varies from host | ||
| * to host and would frustrate integrity hash checks. | ||
| */ | ||
| location: string; | ||
| /** fully qualified location */ | ||
| sourceLocation: string; | ||
| /** | ||
| * directory name of the original source. | ||
| * This is safe to capture in a compartment map because it is _unlikely_ to | ||
| * vary between hosts. | ||
| * Package managers tend to drop a package in a consistently named location. | ||
| * If entry package is in a workspace, git enforces consistency. | ||
| * If entry package is the root of a repository, we rely on the developer | ||
| * to name the package consistently and suffer an inconsistent integrity hash | ||
| * otherwise. | ||
| * We do not currently capture this property in a compartment map because the | ||
| * schema validator currently (2024) deployed to Agoric blockchains does not | ||
| * tolerate compartment maps with unknown properties. | ||
| * https://github.com/endojs/endo/issues/2671 | ||
| */ | ||
| sourceDirname: string; | ||
| bytes: Uint8Array; | ||
@@ -286,3 +386,3 @@ /** in lowercase base-16 (hexadecimal) */ | ||
| compartmentDescriptor: CompartmentDescriptor; | ||
| }> | ||
| }> & ArchiveOnlyOption | ||
| ]; | ||
@@ -307,3 +407,7 @@ /** | ||
| export type ParserForLanguage = Record<Language | string, ParserImplementation>; | ||
| /** | ||
| * Generic logging function accepted by various functions. | ||
| */ | ||
| export type LogFn = (message: string, ...args: any[]) => void; | ||
| export {}; | ||
| //# sourceMappingURL=external.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["external.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,+BAA+B,EAC/B,SAAS,EACV,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC,GACA,aAAa,GACb,0BAA0B,CAAC;AAE7B,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,yBAAyB,CAAC;IACjD,wBAAwB,EAAE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||
| CompartmentDescriptor, | ||
| CompartmentMapDescriptor, | ||
| CompartmentDescriptor, | ||
| Language, | ||
@@ -52,4 +52,19 @@ LanguageForExtension, | ||
| /** | ||
| * Options having an optional `log` property. | ||
| */ | ||
| export interface LogOptions { | ||
| /** | ||
| * A logger (for logging) | ||
| */ | ||
| log?: LogFn; | ||
| } | ||
| /** | ||
| * Options for `mapNodeModules()` | ||
| */ | ||
| export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy & | ||
| PolicyOption; | ||
| PolicyOption & | ||
| LogOptions; | ||
| type MapNodeModulesOptionsOmitPolicy = Partial<{ | ||
@@ -120,3 +135,4 @@ /** @deprecated renamed `conditions` to be consistent with Node.js */ | ||
| LinkingOptions & | ||
| PolicyOption; | ||
| PolicyOption & | ||
| LogOptions; | ||
@@ -137,2 +153,28 @@ export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions & | ||
| export type BundleOptions = ArchiveOptions & { | ||
| /** | ||
| * Format of the bundle for purposes of importing modules from the surrounding | ||
| * environment. | ||
| * The default can be CommonJS or ESM but depends on neither `require` nor `import` | ||
| * for external modules, but errors early if the entrained modules need to import | ||
| * a host module. | ||
| * Specifying `cjs` makes `require` available for modules outside the bundle | ||
| * (exits to the import graph). | ||
| */ | ||
| format?: 'cjs'; | ||
| /** | ||
| * Evaluates individual module functors in-place so stack traces represent | ||
| * original source locations better. | ||
| * The resulting script cannot be used on a web page with a no-unsafe-eval | ||
| * Content Security Policy. | ||
| */ | ||
| useEvaluate?: boolean; | ||
| /** | ||
| * A prefix for the sourceURL comment in each module format that supports | ||
| * sourceURL comments. | ||
| * Requires `useEvaluate` for effect. | ||
| */ | ||
| sourceUrlPrefix?: string; | ||
| }; | ||
| export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> & | ||
@@ -144,3 +186,5 @@ SyncArchiveLiteOptions; | ||
| */ | ||
| export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions; | ||
| export type LoadLocationOptions = ArchiveOptions & | ||
| SyncArchiveOptions & | ||
| LogOptions; | ||
@@ -151,5 +195,12 @@ /** | ||
| */ | ||
| export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions; | ||
| export type SyncImportLocationOptions = SyncArchiveOptions & | ||
| ExecuteOptions & | ||
| LogOptions; | ||
| export type ImportLocationOptions = ArchiveOptions & ExecuteOptions; | ||
| /** | ||
| * Options for `importLocation()` without dynamic require support | ||
| */ | ||
| export type ImportLocationOptions = ArchiveOptions & | ||
| ExecuteOptions & | ||
| LogOptions; | ||
@@ -159,2 +210,9 @@ // //////////////////////////////////////////////////////////////////////////////// | ||
| export type ComputeSha512Option = { | ||
| /** | ||
| * For computing integrity hashes for module descriptors based on captured sources. | ||
| */ | ||
| computeSha512?: HashFn; | ||
| }; | ||
| export type SearchSuffixesOption = { | ||
@@ -181,2 +239,6 @@ /** | ||
| export type ExitModuleImportHookOption = { | ||
| /** | ||
| * For obtaining module descriptors for modules that must be provided | ||
| * by the eventual runtime execution environment, asynchronously. | ||
| */ | ||
| importHook?: ExitModuleImportHook; | ||
@@ -186,2 +248,6 @@ }; | ||
| export type ExitModuleImportNowHookOption = { | ||
| /** | ||
| * For obtaining module descriptors for modules that must be provided | ||
| * by the eventual runtime execution environment, synchronusly. | ||
| */ | ||
| importNowHook?: ExitModuleImportNowHook; | ||
@@ -206,2 +272,30 @@ }; | ||
| export type ArchiveOnlyOption = { | ||
| /** | ||
| * Whether to prepare to create an archive or script bundle for execution | ||
| * elsewhere or elsewhen, as opposed to preparing to execute immediately. | ||
| * | ||
| * This has several practical effects. | ||
| * | ||
| * Archives expect to exit to potentially different host modules than the current | ||
| * host, but cannot instantiate those modules. | ||
| * For example, when preparing a bundle for execution in Node.js from within a | ||
| * web page, exiting to `node:fs` is appropriate but cannot be instantiated. | ||
| * So, the import hook will make a note of the exit and provide a stub module | ||
| * that throws an error if it is imported. | ||
| * | ||
| * Also, importing a module graph off a local medium immediately should | ||
| * inject a fully qualified source location into the module source, | ||
| * but sources loaded for an archive must not capture the original source | ||
| * location, but give the runtime an opportunity to inject a sourceURL. | ||
| * | ||
| * Also, the linker does not apply attenuations to the global environment | ||
| * if it is preparing to write an archive or script bundle. | ||
| * | ||
| * This option does not generally surface to users, but is set by the scenario, | ||
| * off for `importLocation`, on for `makeArchive` and `makeScript`. | ||
| */ | ||
| archiveOnly?: boolean; | ||
| }; | ||
| export type PolicyOption = { | ||
@@ -302,6 +396,25 @@ policy?: any; | ||
| deferredError: string; | ||
| /** package-relative location */ | ||
| /** | ||
| * package-relative location. | ||
| * Not suitable for capture in an archive or bundle since it varies from host | ||
| * to host and would frustrate integrity hash checks. | ||
| */ | ||
| location: string; | ||
| /** fully qualified location */ | ||
| sourceLocation: string; | ||
| /** | ||
| * directory name of the original source. | ||
| * This is safe to capture in a compartment map because it is _unlikely_ to | ||
| * vary between hosts. | ||
| * Package managers tend to drop a package in a consistently named location. | ||
| * If entry package is in a workspace, git enforces consistency. | ||
| * If entry package is the root of a repository, we rely on the developer | ||
| * to name the package consistently and suffer an inconsistent integrity hash | ||
| * otherwise. | ||
| * We do not currently capture this property in a compartment map because the | ||
| * schema validator currently (2024) deployed to Agoric blockchains does not | ||
| * tolerate compartment maps with unknown properties. | ||
| * https://github.com/endojs/endo/issues/2671 | ||
| */ | ||
| sourceDirname: string; | ||
| bytes: Uint8Array; | ||
@@ -416,3 +529,4 @@ /** in lowercase base-16 (hexadecimal) */ | ||
| compartmentDescriptor: CompartmentDescriptor; | ||
| }>, | ||
| }> & | ||
| ArchiveOnlyOption, | ||
| ]; | ||
@@ -441,1 +555,6 @@ | ||
| export type ParserForLanguage = Record<Language | string, ParserImplementation>; | ||
| /** | ||
| * Generic logging function accepted by various functions. | ||
| */ | ||
| export type LogFn = (message: string, ...args: any[]) => void; |
+85
-13
@@ -7,5 +7,5 @@ /** | ||
| import type { CompartmentDescriptor, Language, LanguageForExtension, LanguageForModuleSpecifier, ModuleDescriptor } from './compartment-map-schema.js'; | ||
| import type { HashFn, MaybeReadFn, MaybeReadNowFn, ReadFn, ReadPowers } from './powers.js'; | ||
| import type { MaybeReadFn, MaybeReadNowFn, ReadFn, ReadPowers } from './powers.js'; | ||
| import type { DeferredAttenuatorsProvider } from './policy.js'; | ||
| import type { AsyncParseFn, CompartmentSources, ExecuteOptions, ExitModuleImportNowHook, ModuleTransforms, ParseFn, ParserForLanguage, SearchSuffixesOption, SourceMapHook, SourceMapHookOption, Sources, SyncModuleTransforms } from './external.js'; | ||
| import type { ArchiveOnlyOption, AsyncParseFn, CompartmentSources, ComputeSha512Option, ExecuteOptions, ExitModuleImportHookOption, ExitModuleImportNowHookOption, LogOptions, ModuleTransforms, ParseFn, ParserForLanguage, SearchSuffixesOption, SourceMapHook, SourceMapHookOption, Sources, SyncModuleTransforms } from './external.js'; | ||
| export type LinkOptions = { | ||
@@ -18,5 +18,4 @@ resolve?: ResolveHook; | ||
| syncModuleTransforms?: SyncModuleTransforms; | ||
| archiveOnly?: boolean; | ||
| __native__?: boolean; | ||
| } & ExecuteOptions; | ||
| } & ArchiveOnlyOption & ExecuteOptions; | ||
| export type LinkResult = { | ||
@@ -30,8 +29,16 @@ compartment: Compartment; | ||
| export type ShouldDeferError = (language: Language | undefined) => boolean; | ||
| export type MakeImportNowHookMakerOptions = Partial<{ | ||
| sources: Sources; | ||
| compartmentDescriptors: Record<string, CompartmentDescriptor>; | ||
| computeSha512: HashFn; | ||
| exitModuleImportNowHook: ExitModuleImportNowHook; | ||
| }> & SearchSuffixesOption & SourceMapHookOption; | ||
| export type MakeImportHookMakersOptions = { | ||
| entryCompartmentName: string; | ||
| entryModuleSpecifier: string; | ||
| /** | ||
| * For depositing captured sources. | ||
| */ | ||
| sources?: Sources; | ||
| /** | ||
| * For depositing captured compartment descriptors. | ||
| */ | ||
| compartmentDescriptors?: Record<string, CompartmentDescriptor>; | ||
| } & ComputeSha512Option & SearchSuffixesOption & ArchiveOnlyOption & SourceMapHookOption; | ||
| export type MakeImportHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportHookOption; | ||
| export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportNowHookOption; | ||
| export type ImportHookMaker = (params: { | ||
@@ -78,5 +85,7 @@ packageLocation: string; | ||
| packageSources: CompartmentSources; | ||
| /** Function to compute SHA-512 hash */ | ||
| computeSha512?: HashFn; | ||
| readPowers: ReadPowers | ReadFn; | ||
| /** | ||
| * Whether to embed a sourceURL in applicable compiled sources. | ||
| * Should be false for archives and bundles, but true for runtime. | ||
| */ | ||
| sourceMapHook?: SourceMapHook; | ||
@@ -88,3 +97,3 @@ /** | ||
| strictlyRequiredForCompartment: (compartmentName: string) => Set<string>; | ||
| }; | ||
| } & ComputeSha512Option & ArchiveOnlyOption; | ||
| type SyncChooseModuleDescriptorOperators = { | ||
@@ -166,3 +175,66 @@ /** | ||
| }; | ||
| /** | ||
| * Options for `search()` | ||
| */ | ||
| export type SearchOptions = LogOptions; | ||
| /** | ||
| * Object fulfilled from `search()` | ||
| */ | ||
| export interface SearchResult { | ||
| packageLocation: string; | ||
| packageDescriptorLocation: string; | ||
| packageDescriptorText: string; | ||
| moduleSpecifier: string; | ||
| } | ||
| /** | ||
| * Object fulfilled from `searchDescriptor()` | ||
| * | ||
| * @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc. | ||
| */ | ||
| export interface SearchDescriptorResult<T> { | ||
| data: T; | ||
| directory: string; | ||
| location: string; | ||
| packageDescriptorLocation: string; | ||
| } | ||
| /** | ||
| * Options for `searchDescriptor()` | ||
| */ | ||
| export type SearchDescriptorOptions = LogOptions; | ||
| /** | ||
| * A power to read a package descriptor | ||
| * @template T Format of package descriptor | ||
| */ | ||
| export type ReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T>; | ||
| /** | ||
| * A power to _maybe_ read a package descriptor | ||
| * @template T Format of package descriptor | ||
| */ | ||
| export type MaybeReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T | undefined>; | ||
| /** | ||
| * The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk | ||
| */ | ||
| export interface PackageDescriptor { | ||
| /** | ||
| * TODO: In reality, this is optional, but `graphPackage` does not consider it to be. This will need to be fixed once support for "anonymous" packages lands; see https://github.com/endojs/endo/pull/2664 | ||
| */ | ||
| name: string; | ||
| version?: string; | ||
| /** | ||
| * TODO: Update with proper type when this field is handled. | ||
| */ | ||
| exports?: unknown; | ||
| type?: 'module' | 'commonjs'; | ||
| dependencies?: Record<string, string>; | ||
| devDependencies?: Record<string, string>; | ||
| peerDependencies?: Record<string, string>; | ||
| optionalDependencies?: Record<string, string>; | ||
| bundleDependencies?: string[]; | ||
| peerDependenciesMeta?: Record<string, { | ||
| optional?: boolean; | ||
| [k: string]: unknown; | ||
| }>; | ||
| [k: string]: unknown; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=internal.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,cAAc,EACd,MAAM,EACN,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,OAAO,EACP,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB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AC,CAAC,GAAG,iBAAiB,IAAI,CACpD,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,iBAAiB,IAAI,CACzD,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAC3B,MAAM,EACN;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAC7C,CAAC;IAEF,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"} |
+106
-13
@@ -17,3 +17,2 @@ /** | ||
| import type { | ||
| HashFn, | ||
| MaybeReadFn, | ||
@@ -26,6 +25,10 @@ MaybeReadNowFn, | ||
| import type { | ||
| ArchiveOnlyOption, | ||
| AsyncParseFn, | ||
| CompartmentSources, | ||
| ComputeSha512Option, | ||
| ExecuteOptions, | ||
| ExitModuleImportNowHook, | ||
| ExitModuleImportHookOption, | ||
| ExitModuleImportNowHookOption, | ||
| LogOptions, | ||
| ModuleTransforms, | ||
@@ -48,5 +51,5 @@ ParseFn, | ||
| syncModuleTransforms?: SyncModuleTransforms; | ||
| archiveOnly?: boolean; | ||
| __native__?: boolean; | ||
| } & ExecuteOptions; | ||
| } & ArchiveOnlyOption & | ||
| ExecuteOptions; | ||
@@ -67,11 +70,23 @@ export type LinkResult = { | ||
| export type MakeImportNowHookMakerOptions = Partial<{ | ||
| sources: Sources; | ||
| compartmentDescriptors: Record<string, CompartmentDescriptor>; | ||
| computeSha512: HashFn; | ||
| exitModuleImportNowHook: ExitModuleImportNowHook; | ||
| }> & | ||
| export type MakeImportHookMakersOptions = { | ||
| entryCompartmentName: string; | ||
| entryModuleSpecifier: string; | ||
| /** | ||
| * For depositing captured sources. | ||
| */ | ||
| sources?: Sources; | ||
| /** | ||
| * For depositing captured compartment descriptors. | ||
| */ | ||
| compartmentDescriptors?: Record<string, CompartmentDescriptor>; | ||
| } & ComputeSha512Option & | ||
| SearchSuffixesOption & | ||
| ArchiveOnlyOption & | ||
| SourceMapHookOption; | ||
| export type MakeImportHookMakerOptions = MakeImportHookMakersOptions & | ||
| ExitModuleImportHookOption; | ||
| export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions & | ||
| ExitModuleImportNowHookOption; | ||
| export type ImportHookMaker = (params: { | ||
@@ -125,5 +140,7 @@ packageLocation: string; | ||
| packageSources: CompartmentSources; | ||
| /** Function to compute SHA-512 hash */ | ||
| computeSha512?: HashFn; | ||
| readPowers: ReadPowers | ReadFn; | ||
| /** | ||
| * Whether to embed a sourceURL in applicable compiled sources. | ||
| * Should be false for archives and bundles, but true for runtime. | ||
| */ | ||
| sourceMapHook?: SourceMapHook; | ||
@@ -135,3 +152,4 @@ /** | ||
| strictlyRequiredForCompartment: (compartmentName: string) => Set<string>; | ||
| }; | ||
| } & ComputeSha512Option & | ||
| ArchiveOnlyOption; | ||
@@ -224,1 +242,76 @@ type SyncChooseModuleDescriptorOperators = { | ||
| }; | ||
| /** | ||
| * Options for `search()` | ||
| */ | ||
| export type SearchOptions = LogOptions; | ||
| /** | ||
| * Object fulfilled from `search()` | ||
| */ | ||
| export interface SearchResult { | ||
| packageLocation: string; | ||
| packageDescriptorLocation: string; | ||
| packageDescriptorText: string; | ||
| moduleSpecifier: string; | ||
| } | ||
| /** | ||
| * Object fulfilled from `searchDescriptor()` | ||
| * | ||
| * @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc. | ||
| */ | ||
| export interface SearchDescriptorResult<T> { | ||
| data: T; | ||
| directory: string; | ||
| location: string; | ||
| packageDescriptorLocation: string; | ||
| } | ||
| /** | ||
| * Options for `searchDescriptor()` | ||
| */ | ||
| export type SearchDescriptorOptions = LogOptions; | ||
| /** | ||
| * A power to read a package descriptor | ||
| * @template T Format of package descriptor | ||
| */ | ||
| export type ReadDescriptorFn<T = PackageDescriptor> = ( | ||
| location: string, | ||
| ) => Promise<T>; | ||
| /** | ||
| * A power to _maybe_ read a package descriptor | ||
| * @template T Format of package descriptor | ||
| */ | ||
| export type MaybeReadDescriptorFn<T = PackageDescriptor> = ( | ||
| location: string, | ||
| ) => Promise<T | undefined>; | ||
| /** | ||
| * The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk | ||
| */ | ||
| export interface PackageDescriptor { | ||
| /** | ||
| * TODO: In reality, this is optional, but `graphPackage` does not consider it to be. This will need to be fixed once support for "anonymous" packages lands; see https://github.com/endojs/endo/pull/2664 | ||
| */ | ||
| name: string; | ||
| version?: string; | ||
| /** | ||
| * TODO: Update with proper type when this field is handled. | ||
| */ | ||
| exports?: unknown; | ||
| type?: 'module' | 'commonjs'; | ||
| dependencies?: Record<string, string>; | ||
| devDependencies?: Record<string, string>; | ||
| peerDependencies?: Record<string, string>; | ||
| optionalDependencies?: Record<string, string>; | ||
| bundleDependencies?: string[]; | ||
| peerDependenciesMeta?: Record< | ||
| string, | ||
| { optional?: boolean; [k: string]: unknown } | ||
| >; | ||
| [k: string]: unknown; | ||
| } |
@@ -18,6 +18,6 @@ /** | ||
| */ | ||
| export type UrlInterface = { | ||
| fileURLToPath: (location: string | URL) => string; | ||
| pathToFileURL: (location: string) => URL; | ||
| }; | ||
| export interface UrlInterface { | ||
| fileURLToPath: typeof import('node:url').fileURLToPath; | ||
| pathToFileURL: typeof import('node:url').pathToFileURL; | ||
| } | ||
| /** | ||
@@ -24,0 +24,0 @@ * The portion of the "node:path" module needed to support dynamic-require for |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"node-powers.d.ts","sourceRoot":"","sources":["node-powers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,gCAAgC;AAChC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;KACrD,CAAC;IACF,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,UAAU,CAAC;CAChD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,KAAK,MAAM,CAAC;IAClD,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC3C,CAAC;AAE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Q,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;KACpC,CAAC;CACH,CAAC"} |
@@ -22,6 +22,6 @@ /** | ||
| */ | ||
| export type UrlInterface = { | ||
| fileURLToPath: (location: string | URL) => string; | ||
| pathToFileURL: (location: string) => URL; | ||
| }; | ||
| export interface UrlInterface { | ||
| fileURLToPath: typeof import('node:url').fileURLToPath; | ||
| pathToFileURL: typeof import('node:url').pathToFileURL; | ||
| } | ||
@@ -28,0 +28,0 @@ /** |
@@ -55,4 +55,4 @@ /** | ||
| export type HashFn = (bytes: Uint8Array) => string; | ||
| export type FileURLToPathFn = (location: string | URL) => string; | ||
| export type PathToFileURLFn = (location: string) => URL; | ||
| export type FileURLToPathFn = typeof import('node:url').fileURLToPath; | ||
| export type PathToFileURLFn = typeof import('node:url').pathToFileURL; | ||
| export type RequireResolveFn = (fromLocation: string, specifier: string, options?: { | ||
@@ -59,0 +59,0 @@ paths?: string[]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"powers.d.ts","sourceRoot":"","sources":["powers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG;IACzC,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC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ClB,GACD,SAAS,KACV,GAAG,CAAC;AAET,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,WAAW,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;AAInD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC"} |
@@ -72,5 +72,5 @@ /** | ||
| export type FileURLToPathFn = (location: string | URL) => string; | ||
| export type FileURLToPathFn = typeof import('node:url').fileURLToPath; | ||
| export type PathToFileURLFn = (location: string) => URL; | ||
| export type PathToFileURLFn = typeof import('node:url').pathToFileURL; | ||
@@ -77,0 +77,0 @@ export type RequireResolveFn = ( |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
485335
15.82%217
9.05%11580
15.47%774
27.51%20
33.33%Updated
Updated