@agoric/base-zone
Advanced tools
Comparing version
{ | ||
"name": "@agoric/base-zone", | ||
"version": "0.1.1-dev-de9b2e7.0+de9b2e7", | ||
"version": "0.1.1-dev-deb9254.0.deb9254", | ||
"description": "Allocation zone abstraction library and heap implementation", | ||
@@ -10,11 +10,11 @@ "type": "module", | ||
"build": "exit 0", | ||
"prepack": "tsc --build tsconfig.build.json", | ||
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'", | ||
"prepack": "yarn run -T tsc --build tsconfig.build.json", | ||
"postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'", | ||
"test": "ava", | ||
"test:c8": "c8 --all $C8_OPTIONS ava", | ||
"test:c8": "c8 --all ${C8_OPTIONS:-} ava", | ||
"test:xs": "exit 0", | ||
"lint-fix": "yarn lint:eslint --fix", | ||
"lint": "run-s --continue-on-error lint:*", | ||
"lint:types": "tsc", | ||
"lint:eslint": "eslint ." | ||
"lint": "yarn run -T run-s --continue-on-error 'lint:*'", | ||
"lint:types": "yarn run -T tsc", | ||
"lint:eslint": "yarn run -T eslint ." | ||
}, | ||
@@ -31,13 +31,13 @@ "exports": { | ||
"dependencies": { | ||
"@agoric/store": "0.9.3-dev-de9b2e7.0+de9b2e7", | ||
"@endo/common": "^1.2.9", | ||
"@endo/errors": "^1.2.9", | ||
"@endo/exo": "^1.5.8", | ||
"@endo/far": "^1.1.10", | ||
"@endo/pass-style": "^1.4.8", | ||
"@endo/patterns": "^1.4.8" | ||
"@agoric/store": "0.9.3-dev-deb9254.0.deb9254", | ||
"@endo/common": "^1.2.13", | ||
"@endo/errors": "^1.2.13", | ||
"@endo/exo": "^1.5.12", | ||
"@endo/far": "^1.1.14", | ||
"@endo/pass-style": "^1.6.3", | ||
"@endo/patterns": "^1.7.0" | ||
}, | ||
"devDependencies": { | ||
"@endo/init": "^1.1.8", | ||
"@endo/ses-ava": "^1.2.9", | ||
"@endo/init": "^1.1.12", | ||
"@endo/ses-ava": "^1.3.2", | ||
"ava": "^5.3.0" | ||
@@ -49,3 +49,3 @@ }, | ||
"engines": { | ||
"node": "^18.12 || ^20.9" | ||
"node": "^20.9 || ^22.11" | ||
}, | ||
@@ -63,5 +63,5 @@ "ava": { | ||
"typeCoverage": { | ||
"atLeast": 91.4 | ||
"atLeast": 93.22 | ||
}, | ||
"gitHead": "de9b2e7ca244a6d131f2e4206aeee76f814382e4" | ||
"gitHead": "deb925452d895eb79883a35785f3b4b046644963" | ||
} |
@@ -1,2 +0,4 @@ | ||
export function prepareRevocableMakerKit<U = any>(zone: import("@agoric/base-zone").Zone, uKindName: string, uMethodNames: (string | symbol)[], options?: RevocableKitOptions): RevocableMakerKit<U>; | ||
export function prepareRevocableMakerKit<U = any>(zone: import("@agoric/base-zone").Zone, uKindName: string, uMethodNames: PropertyKey[], options?: RevocableKitOptions<U>): RevocableMakerKit<U>; | ||
export type MakeRevocable<U = any> = (underlying: U) => Partial<U>; | ||
export type MakeRevocableKit<U = any> = (underlying: U) => RevocableKit<U>; | ||
export type RevocableMakerKit<U = any> = { | ||
@@ -7,3 +9,4 @@ revoke: (revocable: U) => boolean; | ||
*/ | ||
makeRevocable: (underlying: U) => U; | ||
makeRevocable: MakeRevocable<U>; | ||
makeRevocableKit: MakeRevocableKit<U>; | ||
}; | ||
@@ -18,3 +21,3 @@ export type RevokerFacet = { | ||
*/ | ||
revocable: U; | ||
revocable: Partial<U>; | ||
}; | ||
@@ -38,3 +41,3 @@ export type RevocableKitThis<U = any> = { | ||
*/ | ||
extraMethodGuards?: Record<string | symbol, import("@endo/patterns").MethodGuard> | undefined; | ||
extraMethodGuards?: Record<PropertyKey, import("@endo/patterns").MethodGuard> | undefined; | ||
/** | ||
@@ -44,4 +47,4 @@ * Extra methods adding behavior only to the revocable caretaker, and | ||
*/ | ||
extraMethods?: Record<string | symbol, (this: RevocableKitThis<U>, ...args: any[]) => any> | undefined; | ||
extraMethods?: Record<PropertyKey, (this: RevocableKitThis<U>, ...args: any[]) => any> | undefined; | ||
}; | ||
//# sourceMappingURL=prepare-revocable.d.ts.map |
@@ -1,13 +0,33 @@ | ||
import { Fail, q } from '@endo/errors'; | ||
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js'; | ||
import { M } from '@endo/patterns'; | ||
import { wrapperMethods } from './prepare-attenuator.js'; | ||
/** @import {Amplify} from '@endo/exo'; */ | ||
// This revocable kit implementation provides for both attenuation and | ||
// revocation, since both can be provided at the cost of one level of | ||
// indirection. But if you just need attenuation without revocation, better to | ||
// use the attenuator implementation in prepare-attenuator.js. | ||
// Please co-maintain these two modules. | ||
/** | ||
* @template [U=any] | ||
* @callback MakeRevocable | ||
* @param {U} underlying | ||
* @returns {Partial<U>} | ||
*/ | ||
/** | ||
* @template [U=any] | ||
* @callback MakeRevocableKit | ||
* @param {U} underlying | ||
* @returns {RevocableKit<U>} | ||
*/ | ||
/** | ||
* @template [U=any] | ||
* @typedef {object} RevocableMakerKit | ||
* @property {(revocable: U) => boolean} revoke | ||
* @property {(underlying: U) => U} makeRevocable | ||
* @property {MakeRevocable<U>} makeRevocable | ||
* Forwards to the underlying exo object, until revoked | ||
* @property {MakeRevocableKit<U>} makeRevocableKit | ||
*/ | ||
@@ -24,3 +44,3 @@ | ||
* @property {RevokerFacet} revoker | ||
* @property {U} revocable | ||
* @property {Partial<U>} revocable | ||
* Forwards to the underlying exo object, until revoked | ||
@@ -43,3 +63,3 @@ */ | ||
* @property {Record< | ||
* string|symbol, | ||
* PropertyKey, | ||
* import('@endo/patterns').MethodGuard | ||
@@ -51,3 +71,3 @@ * >} [extraMethodGuards] | ||
* @property {Record< | ||
* string|symbol, | ||
* PropertyKey, | ||
* (this: RevocableKitThis<U>, ...args: any[]) => any | ||
@@ -67,6 +87,6 @@ * >} [extraMethods] | ||
* The `kindName` of the underlying exo class | ||
* @param {(string|symbol)[]} uMethodNames | ||
* @param {PropertyKey[]} uMethodNames | ||
* The method names of the underlying exo class that should be represented | ||
* by transparently-forwarding methods of the revocable caretaker. | ||
* @param {RevocableKitOptions} [options] | ||
* @param {RevocableKitOptions<U>} [options] | ||
* @returns {RevocableMakerKit<U>} | ||
@@ -82,4 +102,4 @@ */ | ||
uInterfaceName = uKindName, | ||
extraMethodGuards = undefined, | ||
extraMethods = undefined, | ||
extraMethodGuards = {}, | ||
extraMethods = {}, | ||
} = options; | ||
@@ -90,11 +110,5 @@ const RevocableIKit = harden({ | ||
}), | ||
revocable: M.interface( | ||
`${uInterfaceName}_revocable`, | ||
{ | ||
...extraMethodGuards, | ||
}, | ||
{ | ||
defaultGuards: 'raw', | ||
}, | ||
), | ||
revocable: M.interface(`${uInterfaceName}_revocable`, extraMethodGuards, { | ||
defaultGuards: 'raw', | ||
}), | ||
}); | ||
@@ -110,5 +124,3 @@ | ||
RevocableIKit, | ||
underlying => ({ | ||
underlying, | ||
}), | ||
underlying => ({ underlying }), | ||
{ | ||
@@ -125,26 +137,6 @@ revoker: { | ||
}, | ||
revocable: { | ||
...fromUniqueEntries( | ||
uMethodNames.map(name => [ | ||
name, | ||
{ | ||
// Use concise method syntax for exo methods | ||
[name](...args) { | ||
// @ts-expect-error normal exo-this typing confusion | ||
const { underlying } = this.state; | ||
underlying !== undefined || | ||
Fail`${q(revocableKindName)} revoked`; | ||
return underlying[name](...args); | ||
}, | ||
// @ts-expect-error using possible symbol as index type | ||
}[name], | ||
]), | ||
), | ||
...extraMethods, | ||
}, | ||
revocable: wrapperMethods(revocableKindName, uMethodNames, extraMethods), | ||
}, | ||
{ | ||
stateShape: { | ||
underlying: M.opt(M.remotable('underlying')), | ||
}, | ||
stateShape: { underlying: M.opt(M.remotable('underlying')) }, | ||
receiveAmplifier: amp => { | ||
@@ -157,8 +149,5 @@ amplifier = amp; | ||
/** | ||
* @param {U} underlying | ||
* @returns {U} | ||
* @type {MakeRevocable} | ||
*/ | ||
const makeRevocable = underlying => | ||
// @ts-expect-error some confusion about UU vs Guarded<U> I think | ||
makeRevocableKit(underlying).revocable; | ||
const makeRevocable = underlying => makeRevocableKit(underlying).revocable; | ||
@@ -181,4 +170,6 @@ /** | ||
makeRevocable, | ||
/** @type {MakeRevocableKit} */ | ||
makeRevocableKit, | ||
}); | ||
}; | ||
harden(prepareRevocableMakerKit); |
export * from "./src/prepare-revocable.js"; | ||
export * from "./src/prepare-attenuator.js"; | ||
//# sourceMappingURL=zone-helpers.d.ts.map |
export * from './src/prepare-revocable.js'; | ||
export * from './src/prepare-attenuator.js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
61015
22.05%49
8.89%1205
29.85%0
-100%+ Added
Updated
Updated
Updated
Updated
Updated
Updated