@agoric/base-zone
Advanced tools
Comparing version 0.1.1-dev-4e00bdd.0 to 0.1.1-dev-4e588de.0
{ | ||
"name": "@agoric/base-zone", | ||
"version": "0.1.1-dev-4e00bdd.0+4e00bdd", | ||
"version": "0.1.1-dev-4e588de.0+4e588de", | ||
"description": "Allocation zone abstraction library and heap implementation", | ||
@@ -11,5 +11,5 @@ "type": "module", | ||
"prepack": "tsc --build tsconfig.build.json", | ||
"postpack": "git clean -f '*.d.ts*'", | ||
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'", | ||
"test": "ava", | ||
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js", | ||
"test:c8": "c8 --all $C8_OPTIONS ava", | ||
"test:xs": "exit 0", | ||
@@ -31,12 +31,13 @@ "lint-fix": "yarn lint:eslint --fix", | ||
"dependencies": { | ||
"@agoric/store": "0.9.3-dev-4e00bdd.0+4e00bdd", | ||
"@endo/common": "^1.1.0", | ||
"@endo/exo": "^1.2.1", | ||
"@endo/far": "^1.0.4", | ||
"@endo/pass-style": "^1.2.0", | ||
"@endo/patterns": "^1.2.0" | ||
"@agoric/store": "0.9.3-dev-4e588de.0+4e588de", | ||
"@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" | ||
}, | ||
"devDependencies": { | ||
"@endo/init": "^1.0.4", | ||
"@endo/ses-ava": "^1.1.2", | ||
"@endo/init": "^1.1.8", | ||
"@endo/ses-ava": "^1.2.9", | ||
"ava": "^5.3.0" | ||
@@ -52,3 +53,3 @@ }, | ||
"files": [ | ||
"test/**/test-*.js" | ||
"test/**/*.test.*" | ||
], | ||
@@ -62,5 +63,5 @@ "require": [ | ||
"typeCoverage": { | ||
"atLeast": 89.25 | ||
"atLeast": 91.4 | ||
}, | ||
"gitHead": "4e00bdd5205b0f60759668bd8b5baacc289f04bd" | ||
"gitHead": "4e588deeeee83704a5de69f3914ded0605dc1dc0" | ||
} |
@@ -8,3 +8,2 @@ /* eslint-disable import/export */ | ||
// @ts-expect-error TS1383: Only named exports may use 'export type'. | ||
export type * from './types.js'; |
@@ -1,2 +0,2 @@ | ||
export function makeHeapZone(baseLabel?: string | undefined): import('./types.js').Zone; | ||
export function makeHeapZone(baseLabel?: string): import("./types.js").Zone; | ||
//# sourceMappingURL=heap.d.ts.map |
// @ts-check | ||
// @jessie-check | ||
import { Far } from '@endo/far'; | ||
import { Far, isPassable } from '@endo/pass-style'; | ||
import { makeExo, defineExoClass, defineExoClassKit } from '@endo/exo'; | ||
@@ -15,3 +15,3 @@ import { | ||
import { agoricVatDataKeys as keys } from './keys.js'; | ||
import { isPassable } from './is-passable.js'; | ||
import { watchPromise } from './watch-promise.js'; | ||
@@ -54,2 +54,3 @@ /** | ||
makeOnce, | ||
watchPromise, | ||
detached: detachedHeapStores.detached, | ||
@@ -56,0 +57,0 @@ isStorable: detachedHeapStores.isStorable, |
@@ -5,2 +5,3 @@ export * from "./exports.js"; | ||
export * from "./is-passable.js"; | ||
export * from "./watch-promise.js"; | ||
//# sourceMappingURL=index.d.ts.map |
// @jessie-check | ||
/// <reference types="@agoric/store/exported.js" /> | ||
// eslint-disable-next-line import/export | ||
@@ -10,1 +12,2 @@ export * from './exports.js'; | ||
export * from './is-passable.js'; | ||
export * from './watch-promise.js'; |
@@ -1,2 +0,2 @@ | ||
export function isPassable(specimen: any): specimen is any; | ||
export function isPassable(specimen: any): specimen is Passable; | ||
//# sourceMappingURL=is-passable.d.ts.map |
@@ -1,23 +0,8 @@ | ||
import { passStyleOf } from '@endo/pass-style'; | ||
import { isPassable as realIsPassable } from '@endo/pass-style'; | ||
/** | ||
* Is `specimen` Passable? This returns true iff `passStyleOf(specimen)` | ||
* returns a string. This returns `false` iff `passStyleOf(specimen)` throws. | ||
* Under no normal circumstance should `isPassable(specimen)` throw. | ||
* | ||
* TODO implement an isPassable that does not rely on try/catch, and | ||
* move it to @endo/pass-style. | ||
* This implementation is just a standin until then | ||
* | ||
* @deprecated Import `isPassable` directly from `@endo/pass-style` | ||
* @param {any} specimen | ||
* @returns {specimen is Passable} | ||
*/ | ||
export const isPassable = specimen => { | ||
try { | ||
// In fact, it never returns undefined. It either returns a | ||
// string or throws. | ||
return passStyleOf(specimen) !== undefined; | ||
} catch (_) { | ||
return false; | ||
} | ||
}; | ||
export const isPassable = specimen => realIsPassable(specimen); |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export const agoricVatDataKeys: import('./types.js').KeyMakers; | ||
export const agoricVatDataKeys: import("./types.js").KeyMakers; | ||
//# sourceMappingURL=keys.d.ts.map |
@@ -1,5 +0,5 @@ | ||
export function makeOnceKit(debugName: string, stores: import('./types.js').Stores, backingStore?: any): { | ||
export function makeOnceKit(debugName: string, stores: import("./types.js").Stores, backingStore?: import("@agoric/swingset-liveslots").MapStore<string, any>): { | ||
makeOnce: <V>(key: string, maker: (key: string) => V) => V; | ||
wrapProvider: <T extends (key: string, ...rest: unknown[]) => any>(provider: T, labelToKeys?: ((label: string) => string[]) | undefined) => T; | ||
wrapProvider: <T extends (key: string, ...rest: any[]) => any>(provider: T, labelToKeys?: (label: string) => string[]) => T; | ||
}; | ||
//# sourceMappingURL=make-once.d.ts.map |
// @ts-check | ||
const { Fail } = assert; | ||
import { Fail } from '@endo/errors'; | ||
@@ -38,3 +38,3 @@ /** @param {string} label */ | ||
* | ||
* @template {(key: string, ...rest: unknown[]) => any} T | ||
* @template {(key: string, ...rest: any[]) => any} T | ||
* @param {T} provider | ||
@@ -41,0 +41,0 @@ * @param {(label: string) => string[]} [labelToKeys] |
@@ -1,7 +0,14 @@ | ||
export function prepareRevocableKit<U extends unknown = any>(zone: import('@agoric/base-zone').Zone, uKindName: string, uMethodNames: (string | symbol)[], options?: RevocableKitOptions<any> | undefined): (underlying: U) => RevocableKit<U>; | ||
export type Revoker = { | ||
export function prepareRevocableMakerKit<U = any>(zone: import("@agoric/base-zone").Zone, uKindName: string, uMethodNames: (string | symbol)[], options?: RevocableKitOptions): RevocableMakerKit<U>; | ||
export type RevocableMakerKit<U = any> = { | ||
revoke: (revocable: U) => boolean; | ||
/** | ||
* Forwards to the underlying exo object, until revoked | ||
*/ | ||
makeRevocable: (underlying: U) => U; | ||
}; | ||
export type RevokerFacet = { | ||
revoke: () => boolean; | ||
}; | ||
export type RevocableKit<U extends unknown = any> = { | ||
revoker: Revoker; | ||
export type RevocableKit<U = any> = { | ||
revoker: RevokerFacet; | ||
/** | ||
@@ -18,3 +25,3 @@ * Forwards to the underlying exo object, until revoked | ||
}; | ||
export type RevocableKitOptions<U extends unknown = any> = { | ||
export type RevocableKitOptions<U = any> = { | ||
/** | ||
@@ -21,0 +28,0 @@ * The `interfaceName` of the underlying interface guard. |
@@ -0,8 +1,17 @@ | ||
import { Fail, q } from '@endo/errors'; | ||
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js'; | ||
import { M } from '@endo/patterns'; | ||
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js'; | ||
const { Fail, quote: q } = assert; | ||
/** @import {Amplify} from '@endo/exo'; */ | ||
/** | ||
* @typedef {object} Revoker | ||
* @template [U=any] | ||
* @typedef {object} RevocableMakerKit | ||
* @property {(revocable: U) => boolean} revoke | ||
* @property {(underlying: U) => U} makeRevocable | ||
* Forwards to the underlying exo object, until revoked | ||
*/ | ||
/** | ||
* @typedef {object} RevokerFacet | ||
* @property {() => boolean} revoke | ||
@@ -12,5 +21,5 @@ */ | ||
/** | ||
* @template {any} [U=any] | ||
* @template [U=any] | ||
* @typedef {object} RevocableKit | ||
* @property {Revoker} revoker | ||
* @property {RevokerFacet} revoker | ||
* @property {U} revocable | ||
@@ -28,3 +37,3 @@ * Forwards to the underlying exo object, until revoked | ||
/** | ||
* @template {any} [U=any] | ||
* @template [U=any] | ||
* @typedef {object} RevocableKitOptions | ||
@@ -53,4 +62,3 @@ * @property {string} [uInterfaceName] | ||
* | ||
* @deprecated Change to `prepareRevocableMakerKit` once #8977 happens | ||
* @template {any} [U=any] | ||
* @template [U=any] | ||
* @param {import('@agoric/base-zone').Zone} zone | ||
@@ -63,5 +71,5 @@ * @param {string} uKindName | ||
* @param {RevocableKitOptions} [options] | ||
* @returns {(underlying: U) => RevocableKit<U>} | ||
* @returns {RevocableMakerKit<U>} | ||
*/ | ||
export const prepareRevocableKit = ( | ||
export const prepareRevocableMakerKit = ( | ||
zone, | ||
@@ -94,2 +102,5 @@ uKindName, | ||
/** @type {Amplify<any>} */ | ||
let amplifier; | ||
const makeRevocableKit = zone.exoClassKit( | ||
@@ -136,9 +147,34 @@ revocableKindName, | ||
}, | ||
receiveAmplifier: amp => { | ||
amplifier = amp; | ||
}, | ||
}, | ||
); | ||
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error | ||
// @ts-ignore parameter confusion | ||
return makeRevocableKit; | ||
/** | ||
* @param {U} underlying | ||
* @returns {U} | ||
*/ | ||
const makeRevocable = underlying => | ||
// @ts-expect-error some confusion about UU vs Guarded<U> I think | ||
makeRevocableKit(underlying).revocable; | ||
/** | ||
* @param {U} revocable | ||
* @returns {boolean} | ||
*/ | ||
const revoke = revocable => { | ||
/** @type {RevocableKit<U>} */ | ||
const facets = amplifier(revocable); | ||
if (facets === undefined) { | ||
return false; | ||
} | ||
return facets.revoker.revoke(); | ||
}; | ||
return harden({ | ||
revoke, | ||
makeRevocable, | ||
}); | ||
}; | ||
harden(prepareRevocableKit); | ||
harden(prepareRevocableMakerKit); |
@@ -1,9 +0,3 @@ | ||
export type KeyCategories = 'exoClass' | 'exoClassKit' | 'exo' | 'store' | 'zone'; | ||
export type KeyMakers = { | ||
exoClass: (label: string) => string[]; | ||
exoClassKit: (label: string) => string[]; | ||
exo: (label: string) => string[]; | ||
store: (label: string) => string[]; | ||
zone: (label: string) => string[]; | ||
}; | ||
export type KeyCategories = "exoClass" | "exoClassKit" | "exo" | "store" | "zone"; | ||
export type KeyMakers = Record<KeyCategories, (label: string) => string[]>; | ||
/** | ||
@@ -35,2 +29,6 @@ * A bag of methods for creating defensible objects and | ||
subZone: (label: string, options?: StoreOptions) => Zone; | ||
/** | ||
* register a promise watcher created by this zone | ||
*/ | ||
watchPromise: typeof watchPromise; | ||
}; | ||
@@ -53,11 +51,11 @@ export type Stores = { | ||
*/ | ||
setStore: <K_1>(label: string, options?: StoreOptions) => SetStore<K_1>; | ||
setStore: <K>(label: string, options?: StoreOptions) => SetStore<K>; | ||
/** | ||
* provide a WeakMap-like store named `label` in the zone | ||
*/ | ||
weakMapStore: <K_2, V_1>(label: string, options?: StoreOptions) => WeakMapStore<K_2, V_1>; | ||
weakMapStore: <K, V>(label: string, options?: StoreOptions) => WeakMapStore<K, V>; | ||
/** | ||
* provide a WeakSet-like store named `label` in the zone | ||
*/ | ||
weakSetStore: <K_3>(label: string, options?: StoreOptions) => WeakSetStore<K_3>; | ||
weakSetStore: <K>(label: string, options?: StoreOptions) => WeakSetStore<K>; | ||
}; | ||
@@ -67,2 +65,3 @@ import { makeExo } from '@endo/exo'; | ||
import { defineExoClassKit } from '@endo/exo'; | ||
import { watchPromise } from './watch-promise.js'; | ||
//# sourceMappingURL=types.d.ts.map |
// eslint-disable-next-line no-unused-vars | ||
import { makeExo, defineExoClass, defineExoClassKit } from '@endo/exo'; | ||
// eslint-disable-next-line no-unused-vars | ||
import { watchPromise } from './watch-promise.js'; | ||
// Ensure this is a module. | ||
export {}; | ||
/** | ||
* @import {Key} from '@endo/patterns'; | ||
* @import {Passable} from '@endo/pass-style'; | ||
*/ | ||
/** @typedef {'exoClass' | 'exoClassKit' | 'exo' | 'store' | 'zone'} KeyCategories */ | ||
@@ -19,2 +29,3 @@ /** @typedef {Record<KeyCategories, (label: string) => string[]>} KeyMakers */ | ||
* @property {(label: string, options?: StoreOptions) => Zone} subZone create a new Zone that can be passed to untrusted consumers without exposing the storage of the parent zone | ||
* @property {typeof watchPromise} watchPromise register a promise watcher created by this zone | ||
*/ | ||
@@ -26,5 +37,5 @@ | ||
* @property {(specimen: unknown) => boolean} isStorable return true if the specimen can be stored in the zone, whether as exo-object state or in a store | ||
* @property {<K,V>(label: string, options?: StoreOptions) => MapStore<K, V>} mapStore provide a Map-like store named `label` in the zone | ||
* @property {<K, V>(label: string, options?: StoreOptions) => MapStore<K, V>} mapStore provide a Map-like store named `label` in the zone | ||
* @property {<K>(label: string, options?: StoreOptions) => SetStore<K>} setStore provide a Set-like store named `label` in the zone | ||
* @property {<K,V>( | ||
* @property {<K, V>( | ||
* label: string, options?: StoreOptions) => WeakMapStore<K, V> | ||
@@ -31,0 +42,0 @@ * } weakMapStore provide a WeakMap-like store named `label` in the zone |
// This file can contain .js-specific Typescript compiler config. | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"maxNodeModuleJsDepth": 2, | ||
}, | ||
"compilerOptions": {}, | ||
"include": [ | ||
@@ -8,0 +6,0 @@ "*.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
49497
45
918
7
+ Added@endo/errors@^1.2.9
Updated@endo/common@^1.2.9
Updated@endo/exo@^1.5.8
Updated@endo/far@^1.1.10
Updated@endo/pass-style@^1.4.8
Updated@endo/patterns@^1.4.8