@agoric/swingset-liveslots
Advanced tools
Comparing version 0.10.3-dev-74be420.0 to 0.10.3-dev-74fc45b.0
{ | ||
"name": "@agoric/swingset-liveslots", | ||
"version": "0.10.3-dev-74be420.0+74be420", | ||
"version": "0.10.3-dev-74fc45b.0+74fc45b", | ||
"description": "SwingSet ocap support layer", | ||
@@ -17,27 +17,28 @@ "type": "module", | ||
"lint:types": "tsc", | ||
"lint:eslint": "eslint ." | ||
"lint:eslint": "eslint .", | ||
"prepack": "tsc --build tsconfig.build.json", | ||
"postpack": "git clean -f ':!src/types-index.d.ts' '*.d.ts*' '*.tsbuildinfo'" | ||
}, | ||
"dependencies": { | ||
"@agoric/internal": "0.3.3-dev-74be420.0+74be420", | ||
"@agoric/store": "0.9.3-dev-74be420.0+74be420", | ||
"@endo/env-options": "^1.1.6", | ||
"@endo/errors": "^1.2.5", | ||
"@endo/eventual-send": "^1.2.5", | ||
"@endo/exo": "^1.5.3", | ||
"@endo/far": "^1.1.5", | ||
"@endo/init": "^1.1.4", | ||
"@endo/marshal": "^1.5.3", | ||
"@endo/nat": "^5.0.10", | ||
"@endo/pass-style": "^1.4.3", | ||
"@endo/patterns": "^1.4.3", | ||
"@endo/promise-kit": "^1.1.5" | ||
"@agoric/internal": "0.3.3-dev-74fc45b.0+74fc45b", | ||
"@agoric/store": "0.9.3-dev-74fc45b.0+74fc45b", | ||
"@endo/env-options": "^1.1.8", | ||
"@endo/errors": "^1.2.9", | ||
"@endo/eventual-send": "^1.3.0", | ||
"@endo/exo": "^1.5.8", | ||
"@endo/far": "^1.1.10", | ||
"@endo/init": "^1.1.8", | ||
"@endo/marshal": "^1.6.3", | ||
"@endo/nat": "^5.0.14", | ||
"@endo/pass-style": "^1.4.8", | ||
"@endo/patterns": "^1.4.8", | ||
"@endo/promise-kit": "^1.1.9" | ||
}, | ||
"devDependencies": { | ||
"@agoric/kmarshal": "0.1.1-dev-74be420.0+74be420", | ||
"@agoric/kmarshal": "0.1.1-dev-74fc45b.0+74fc45b", | ||
"ava": "^5.3.0" | ||
}, | ||
"files": [ | ||
"src/**/*.js", | ||
"src/**/*.d.ts", | ||
"test/**/*.js", | ||
"src", | ||
"test", | ||
"tools", | ||
@@ -63,4 +64,3 @@ "exported.js" | ||
], | ||
"timeout": "20m", | ||
"workerThreads": false | ||
"timeout": "20m" | ||
}, | ||
@@ -71,5 +71,5 @@ "publishConfig": { | ||
"typeCoverage": { | ||
"atLeast": 75.1 | ||
"atLeast": 75.2 | ||
}, | ||
"gitHead": "74be420fcca6eb43ebd8e85f574e6c06949e2642" | ||
"gitHead": "74fc45b3588986de37f6a84347058592dc1d529b" | ||
} |
@@ -149,3 +149,2 @@ import { assert, q, Fail } from '@endo/errors'; | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateMapStore, | ||
@@ -157,3 +156,2 @@ durable: false, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateWeakMapStore, | ||
@@ -165,3 +163,2 @@ durable: false, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateSetStore, | ||
@@ -173,3 +170,2 @@ durable: false, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateWeakSetStore, | ||
@@ -181,3 +177,2 @@ durable: false, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateMapStore, | ||
@@ -189,3 +184,2 @@ durable: true, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateWeakMapStore, | ||
@@ -197,3 +191,2 @@ durable: true, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateSetStore, | ||
@@ -205,3 +198,2 @@ durable: true, | ||
kindID: 0, | ||
// eslint-disable-next-line no-use-before-define | ||
reanimator: reanimateWeakSetStore, | ||
@@ -229,3 +221,2 @@ durable: true, | ||
storeKindInfo[kind].reanimator, | ||
// eslint-disable-next-line no-use-before-define | ||
deleteCollection, | ||
@@ -325,3 +316,2 @@ storeKindInfo[kind].durable, | ||
const encodeRemotable = remotable => { | ||
// eslint-disable-next-line no-use-before-define | ||
const ordinal = getOrdinal(remotable); | ||
@@ -328,0 +318,0 @@ ordinal !== undefined || Fail`no ordinal for ${remotable}`; |
@@ -14,3 +14,2 @@ /// <reference types="@agoric/store/exported.js" /> | ||
export * from './types.js'; | ||
export * from './vatDataTypes.js'; | ||
export * from './types-index.js'; |
@@ -158,6 +158,4 @@ import { annotateError, assert, Fail, makeError, X } from '@endo/errors'; | ||
if (virtual || durable) { | ||
// eslint-disable-next-line no-use-before-define | ||
vrm.setExportStatus(vref, 'reachable'); | ||
} else { | ||
// eslint-disable-next-line no-use-before-define | ||
const remotable = requiredValForSlot(vref); | ||
@@ -187,3 +185,2 @@ exportedRemotables.add(remotable); | ||
// we're in the COLLECTED state, or FINALIZED after a re-introduction | ||
// eslint-disable-next-line no-use-before-define | ||
addToPossiblyDeadSet(baseRef); | ||
@@ -214,7 +211,5 @@ slotToVal.delete(baseRef); | ||
if (disavowedPresences.has(o)) { | ||
// eslint-disable-next-line no-use-before-define | ||
exitVatWithFailure(disavowalError); | ||
throw disavowalError; | ||
} | ||
// eslint-disable-next-line no-use-before-define | ||
return queueMessage(slot, prop, args, returnedP); | ||
@@ -228,3 +223,2 @@ }, | ||
if (disavowedPresences.has(o)) { | ||
// eslint-disable-next-line no-use-before-define | ||
exitVatWithFailure(disavowalError); | ||
@@ -301,3 +295,2 @@ throw disavowalError; | ||
} | ||
// eslint-disable-next-line no-use-before-define | ||
return queueMessage(vpid, prop, args, returnedP); | ||
@@ -355,3 +348,2 @@ }, | ||
function allocateExportID() { | ||
// eslint-disable-next-line no-use-before-define | ||
return vrm.allocateNextID('exportID'); | ||
@@ -361,3 +353,2 @@ } | ||
function allocateCollectionID() { | ||
// eslint-disable-next-line no-use-before-define | ||
return vrm.allocateNextID('collectionID'); | ||
@@ -367,3 +358,2 @@ } | ||
function allocatePromiseID() { | ||
// eslint-disable-next-line no-use-before-define | ||
const promiseID = vrm.allocateNextID('promiseID'); | ||
@@ -396,6 +386,4 @@ return makeVatSlot('promise', true, promiseID); | ||
// kernel isn't surprised by a spurious resolution. | ||
// eslint-disable-next-line no-use-before-define | ||
const p = requiredValForSlot(vpid); | ||
// if (!knownResolutions.has(p)) { // TODO really? | ||
// eslint-disable-next-line no-use-before-define | ||
followForKernel(vpid, p); | ||
@@ -412,3 +400,2 @@ return true; | ||
// eslint-disable-next-line no-use-before-define | ||
const m = makeMarshal(convertValToSlot, convertSlotToVal, { | ||
@@ -426,3 +413,2 @@ marshalName: `liveSlots:${forVatID}`, | ||
const unmeteredUnserialize = meterControl.unmetered(m.unserialize); | ||
// eslint-disable-next-line no-use-before-define | ||
const unmeteredConvertSlotToVal = meterControl.unmetered(convertSlotToVal); | ||
@@ -472,3 +458,2 @@ | ||
requiredValForSlot, | ||
// eslint-disable-next-line no-use-before-define | ||
registerValue, | ||
@@ -486,6 +471,4 @@ m.serialize, | ||
allocateCollectionID, | ||
// eslint-disable-next-line no-use-before-define | ||
convertValToSlot, | ||
unmeteredConvertSlotToVal, | ||
// eslint-disable-next-line no-use-before-define | ||
registerValue, | ||
@@ -502,3 +485,2 @@ m.serialize, | ||
collectionManager, | ||
// eslint-disable-next-line no-use-before-define | ||
convertValToSlot, | ||
@@ -533,3 +515,2 @@ convertSlotToVal: unmeteredConvertSlotToVal, | ||
if (disavowedPresences.has(val)) { | ||
// eslint-disable-next-line no-use-before-define | ||
exitVatWithFailure(disavowalError); | ||
@@ -704,3 +685,2 @@ throw disavowalError; // cannot reference a disavowed object | ||
const [priorRejected, priorRes] = priorResolution; | ||
// eslint-disable-next-line no-use-before-define | ||
collect(slot, priorRejected, priorRes); | ||
@@ -991,3 +971,2 @@ } | ||
// exported promise | ||
// eslint-disable-next-line no-use-before-define | ||
followForKernel(resultVPID, p); | ||
@@ -1269,3 +1248,2 @@ } | ||
valToSlot, | ||
// eslint-disable-next-line no-use-before-define | ||
afterDispatchActions, | ||
@@ -1362,3 +1340,3 @@ }); | ||
* @param {import('./types.js').VatDeliveryObject} delivery | ||
* @returns {void | Promise<void>} | ||
* @returns {undefined | ReturnType<startVat>} | ||
*/ | ||
@@ -1365,0 +1343,0 @@ function dispatchToUserspace(delivery) { |
@@ -8,9 +8,3 @@ /** | ||
*/ | ||
import type { | ||
MapStore, | ||
SetStore, | ||
StoreOptions, | ||
WeakMapStore, | ||
WeakSetStore, | ||
} from '@agoric/store'; | ||
import type { MapStore, SetStore, StoreOptions, WeakMapStore, WeakSetStore } from '@agoric/store'; | ||
import type { Amplify, IsInstance, ReceivePower, StateShape } from '@endo/exo'; | ||
@@ -21,56 +15,30 @@ import type { RemotableObject } from '@endo/pass-style'; | ||
import type { makeWatchedPromiseManager } from './watchedPromises.js'; | ||
// TODO should be moved into @endo/patterns and eventually imported here | ||
// instead of this local definition. | ||
export type InterfaceGuardKit = Record<string, InterfaceGuard>; | ||
export type { MapStore, Pattern }; | ||
// This needs `any` values. If they were `unknown`, code that uses Baggage | ||
// would need explicit runtime checks or casts for every fetch, which is | ||
// onerous. | ||
export type Baggage = MapStore<string, any>; | ||
type WatchedPromisesManager = ReturnType<typeof makeWatchedPromiseManager>; | ||
type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest] | ||
? Rest | ||
: []; | ||
// used to omit the 'context' parameter | ||
type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R | ||
? (...args: P) => R | ||
: never; | ||
// The type of a passable local object with methods. | ||
// An internal helper to avoid having to repeat `O`. | ||
type PrimaryRemotable<O> = O & RemotableObject & RemotableBrand<{}, O>; | ||
type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never; | ||
type PrimaryRemotable<O> = O & RemotableObject & RemotableBrand<object, O>; | ||
export type KindFacet<O> = PrimaryRemotable<{ | ||
[K in keyof O]: OmitFirstArg<O[K]>; // omit the 'context' parameter | ||
[K in keyof O]: OmitFirstArg<O[K]>; | ||
}>; | ||
export type KindFacets<B> = { | ||
[FacetKey in keyof B]: KindFacet<B[FacetKey]>; | ||
[FacetKey in keyof B]: KindFacet<B[FacetKey]>; | ||
}; | ||
export type KindContext<S, F> = { state: S; self: KindFacet<F> }; | ||
export type MultiKindContext<S, B> = { state: S; facets: KindFacets<B> }; | ||
export type PlusContext<C, M extends (...args: any[]) => any> = ( | ||
c: C, | ||
...args: Parameters<M> | ||
) => ReturnType<M>; | ||
export type FunctionsPlusContext< | ||
C, | ||
O extends Record<string, (...args: any[]) => any>, | ||
> = { | ||
[K in keyof O]: PlusContext<C, O[K]>; | ||
export type KindContext<S, F> = { | ||
state: S; | ||
self: KindFacet<F>; | ||
}; | ||
export type MultiKindContext<S, B> = { | ||
state: S; | ||
facets: KindFacets<B>; | ||
}; | ||
export type PlusContext<C, M extends (...args: any[]) => any> = (c: C, ...args: Parameters<M>) => ReturnType<M>; | ||
export type FunctionsPlusContext<C, O extends Record<string, (...args: any[]) => any>> = { | ||
[K in keyof O]: PlusContext<C, O[K]>; | ||
}; | ||
declare class DurableKindHandleClass { | ||
private descriptionTag: string; | ||
private descriptionTag; | ||
} | ||
export type DurableKindHandle = DurableKindHandleClass; | ||
/** | ||
@@ -82,198 +50,124 @@ * Grab bag of options that can be provided to `defineDurableKind` and its | ||
export type DefineKindOptions<C> = { | ||
/** | ||
* If provided, the `finish` function will be called after the instance is | ||
* made and internally registered, but before it is returned. The finish | ||
* function is to do any post-intantiation initialization that should be | ||
* done before exposing the object to its clients. | ||
*/ | ||
finish?: (context: C) => void; | ||
/** | ||
* If provided, it describes the shape of all state records of instances | ||
* of this kind. | ||
*/ | ||
stateShape?: StateShape; | ||
/** | ||
* If a `receiveAmplifier` function is provided to an exo class kit definition, | ||
* it will be called with an `Amplify` function. If provided to the definition | ||
* of a normal exo or exo class, the definition will throw, since only | ||
* exo kits can be amplified. | ||
* An `Amplify` function is a function that takes a facet instance of | ||
* this class kit as an argument, in which case it will return the facets | ||
* record, giving access to all the facet instances of the same cohort. | ||
*/ | ||
receiveAmplifier?: ReceivePower<Amplify>; | ||
/** | ||
* If a `receiveInstanceTester` function is provided, it will be called | ||
* during the definition of the exo class or exo class kit with an | ||
* `IsInstance` function. The first argument of `IsInstance` | ||
* is the value to be tested. When it may be a facet instance of an | ||
* exo class kit, the optional second argument, if provided, is | ||
* a `facetName`. In that case, the function tests only if the first | ||
* argument is an instance of that facet of the associated exo class kit. | ||
*/ | ||
receiveInstanceTester?: ReceivePower<IsInstance>; | ||
// TODO properties above are identical to those in FarClassOptions. | ||
// These are the only options that should be exposed by | ||
// vat-data's public virtual/durable exo APIs. This DefineKindOptions | ||
// should explicitly be a subtype, where the methods below are only for | ||
// internal use, i.e., below the exo level. | ||
/** | ||
* As a kind option, intended for internal use only. | ||
* Meaningful to `makeScalarBigMapStore` and its siblings. These maker | ||
* fuctions will make either virtual or durable stores, depending on | ||
* this flag. Defaults to off, making virtual but not durable collections. | ||
* | ||
* Generally, durable collections are provided with `provideDurableMapStore` | ||
* and its sibling, which use this flag internally. If you do not make | ||
* durable collections by other means, you can consider this as | ||
* intended for internal use only. | ||
*/ | ||
durable?: boolean; | ||
/** | ||
* Intended for internal use only. | ||
* Should the raw methods receive their `context` argument as their first | ||
* argument or as their `this` binding? For `defineDurableKind` and its | ||
* siblings (including `prepareSingleton`), this defaults to off, meaning that | ||
* their behavior methods receive `context` as their first argument. | ||
* `prepareExoClass` and its siblings (including `prepareExo`) use | ||
* this flag internally to indicate that their methods receive `context` | ||
* as their `this` binding. | ||
*/ | ||
thisfulMethods?: boolean; | ||
/** | ||
* Intended for internal use only. | ||
* Only applicable if this is a class kind. A class kit kind should use | ||
* `interfaceGuardKit` instead. | ||
* | ||
* If an `interfaceGuard` is provided, then the raw methods passed alongside | ||
* it are wrapped by a function that first checks that this method's guard | ||
* pattern is satisfied before calling the raw method. | ||
* | ||
* In `defineDurableKind` and its siblings, this defaults to `undefined`. | ||
* Exo classes use this internally to protect their raw class methods | ||
* using the provided interface. | ||
* In absence, an exo is protected anyway, while a bare kind is | ||
* not (detected by `!thisfulMethods`), | ||
*/ | ||
interfaceGuard?: InterfaceGuard; | ||
/** | ||
* Intended for internal use only. | ||
* Only applicable if this is a class kit kind. A class kind should use | ||
* `interfaceGuard` instead. | ||
* | ||
* If an `interfaceGuardKit` is provided, then each member of the | ||
* interfaceGuardKit is used to guard the corresponding facet of the | ||
* class kit. | ||
* | ||
* In `defineDurableKindMulti` and its siblings, this defaults to `undefined`. | ||
* Exo class kits use this internally to protect their facets. | ||
* In absence, an exo is protected anyway, while a bare kind is | ||
* not (detected by `!thisfulMethods`), | ||
*/ | ||
interfaceGuardKit?: InterfaceGuardKit; | ||
/** | ||
* If provided, the `finish` function will be called after the instance is | ||
* made and internally registered, but before it is returned. The finish | ||
* function is to do any post-intantiation initialization that should be | ||
* done before exposing the object to its clients. | ||
*/ | ||
finish?: (context: C) => void; | ||
/** | ||
* If provided, it describes the shape of all state records of instances | ||
* of this kind. | ||
*/ | ||
stateShape?: StateShape; | ||
/** | ||
* If a `receiveAmplifier` function is provided to an exo class kit definition, | ||
* it will be called with an `Amplify` function. If provided to the definition | ||
* of a normal exo or exo class, the definition will throw, since only | ||
* exo kits can be amplified. | ||
* An `Amplify` function is a function that takes a facet instance of | ||
* this class kit as an argument, in which case it will return the facets | ||
* record, giving access to all the facet instances of the same cohort. | ||
*/ | ||
receiveAmplifier?: ReceivePower<Amplify>; | ||
/** | ||
* If a `receiveInstanceTester` function is provided, it will be called | ||
* during the definition of the exo class or exo class kit with an | ||
* `IsInstance` function. The first argument of `IsInstance` | ||
* is the value to be tested. When it may be a facet instance of an | ||
* exo class kit, the optional second argument, if provided, is | ||
* a `facetName`. In that case, the function tests only if the first | ||
* argument is an instance of that facet of the associated exo class kit. | ||
*/ | ||
receiveInstanceTester?: ReceivePower<IsInstance>; | ||
/** | ||
* As a kind option, intended for internal use only. | ||
* Meaningful to `makeScalarBigMapStore` and its siblings. These maker | ||
* fuctions will make either virtual or durable stores, depending on | ||
* this flag. Defaults to off, making virtual but not durable collections. | ||
* | ||
* Generally, durable collections are provided with `provideDurableMapStore` | ||
* and its sibling, which use this flag internally. If you do not make | ||
* durable collections by other means, you can consider this as | ||
* intended for internal use only. | ||
*/ | ||
durable?: boolean; | ||
/** | ||
* Intended for internal use only. | ||
* Should the raw methods receive their `context` argument as their first | ||
* argument or as their `this` binding? For `defineDurableKind` and its | ||
* siblings (including `prepareSingleton`), this defaults to off, meaning that | ||
* their behavior methods receive `context` as their first argument. | ||
* `prepareExoClass` and its siblings (including `prepareExo`) use | ||
* this flag internally to indicate that their methods receive `context` | ||
* as their `this` binding. | ||
*/ | ||
thisfulMethods?: boolean; | ||
/** | ||
* Intended for internal use only. | ||
* Only applicable if this is a class kind. A class kit kind should use | ||
* `interfaceGuardKit` instead. | ||
* | ||
* If an `interfaceGuard` is provided, then the raw methods passed alongside | ||
* it are wrapped by a function that first checks that this method's guard | ||
* pattern is satisfied before calling the raw method. | ||
* | ||
* In `defineDurableKind` and its siblings, this defaults to `undefined`. | ||
* Exo classes use this internally to protect their raw class methods | ||
* using the provided interface. | ||
* In absence, an exo is protected anyway, while a bare kind is | ||
* not (detected by `!thisfulMethods`), | ||
*/ | ||
interfaceGuard?: InterfaceGuard; | ||
/** | ||
* Intended for internal use only. | ||
* Only applicable if this is a class kit kind. A class kind should use | ||
* `interfaceGuard` instead. | ||
* | ||
* If an `interfaceGuardKit` is provided, then each member of the | ||
* interfaceGuardKit is used to guard the corresponding facet of the | ||
* class kit. | ||
* | ||
* In `defineDurableKindMulti` and its siblings, this defaults to `undefined`. | ||
* Exo class kits use this internally to protect their facets. | ||
* In absence, an exo is protected anyway, while a bare kind is | ||
* not (detected by `!thisfulMethods`), | ||
*/ | ||
interfaceGuardKit?: InterfaceGuardKit; | ||
}; | ||
export type VatData = { | ||
// virtual kinds | ||
/** @deprecated Use defineVirtualExoClass instead */ | ||
defineKind: <P extends Array<any>, S, F>( | ||
tag: string, | ||
init: (...args: P) => S, | ||
facet: F, | ||
options?: DefineKindOptions<KindContext<S, F>>, | ||
) => (...args: P) => KindFacet<F>; | ||
/** @deprecated Use defineVirtualExoClassKit instead */ | ||
defineKindMulti: <P extends Array<any>, S, B>( | ||
tag: string, | ||
init: (...args: P) => S, | ||
behavior: B, | ||
options?: DefineKindOptions<MultiKindContext<S, B>>, | ||
) => (...args: P) => KindFacets<B>; | ||
// durable kinds | ||
makeKindHandle: (descriptionTag: string) => DurableKindHandle; | ||
/** @deprecated Use defineDurableExoClass instead */ | ||
defineDurableKind: <P extends Array<any>, S, F>( | ||
kindHandle: DurableKindHandle, | ||
init: (...args: P) => S, | ||
facet: F, | ||
options?: DefineKindOptions<KindContext<S, F>>, | ||
) => (...args: P) => KindFacet<F>; | ||
/** @deprecated Use defineDurableExoClassKit instead */ | ||
defineDurableKindMulti: <P extends Array<any>, S, B>( | ||
kindHandle: DurableKindHandle, | ||
init: (...args: P) => S, | ||
behavior: B, | ||
options?: DefineKindOptions<MultiKindContext<S, B>>, | ||
) => (...args: P) => KindFacets<B>; | ||
providePromiseWatcher: WatchedPromisesManager['providePromiseWatcher']; | ||
watchPromise: WatchedPromisesManager['watchPromise']; | ||
makeScalarBigMapStore: <K, V>( | ||
label: string, | ||
options?: StoreOptions, | ||
) => MapStore<K, V>; | ||
makeScalarBigWeakMapStore: <K, V>( | ||
label: string, | ||
options?: StoreOptions, | ||
) => WeakMapStore<K, V>; | ||
makeScalarBigSetStore: <K>( | ||
label: string, | ||
options?: StoreOptions, | ||
) => SetStore<K>; | ||
makeScalarBigWeakSetStore: <K>( | ||
label: string, | ||
options?: StoreOptions, | ||
) => WeakSetStore<K>; | ||
canBeDurable: (specimen: unknown) => boolean; | ||
/** @deprecated Use defineVirtualExoClass instead */ | ||
defineKind: <P extends Array<any>, S, F>(tag: string, init: (...args: P) => S, facet: F, options?: DefineKindOptions<KindContext<S, F>>) => (...args: P) => KindFacet<F>; | ||
/** @deprecated Use defineVirtualExoClassKit instead */ | ||
defineKindMulti: <P extends Array<any>, S, B>(tag: string, init: (...args: P) => S, behavior: B, options?: DefineKindOptions<MultiKindContext<S, B>>) => (...args: P) => KindFacets<B>; | ||
makeKindHandle: (descriptionTag: string) => DurableKindHandle; | ||
/** @deprecated Use defineDurableExoClass instead */ | ||
defineDurableKind: <P extends Array<any>, S, F>(kindHandle: DurableKindHandle, init: (...args: P) => S, facet: F, options?: DefineKindOptions<KindContext<S, F>>) => (...args: P) => KindFacet<F>; | ||
/** @deprecated Use defineDurableExoClassKit instead */ | ||
defineDurableKindMulti: <P extends Array<any>, S, B>(kindHandle: DurableKindHandle, init: (...args: P) => S, behavior: B, options?: DefineKindOptions<MultiKindContext<S, B>>) => (...args: P) => KindFacets<B>; | ||
providePromiseWatcher: WatchedPromisesManager['providePromiseWatcher']; | ||
watchPromise: WatchedPromisesManager['watchPromise']; | ||
makeScalarBigMapStore: <K, V>(label: string, options?: StoreOptions) => MapStore<K, V>; | ||
makeScalarBigWeakMapStore: <K, V>(label: string, options?: StoreOptions) => WeakMapStore<K, V>; | ||
makeScalarBigSetStore: <K>(label: string, options?: StoreOptions) => SetStore<K>; | ||
makeScalarBigWeakSetStore: <K>(label: string, options?: StoreOptions) => WeakSetStore<K>; | ||
canBeDurable: (specimen: unknown) => boolean; | ||
}; | ||
// The JSDoc is repeated here and at the function definition so it appears | ||
// in IDEs where it's used, regardless of type resolution. | ||
export interface PickFacet { | ||
/** | ||
* When making a multi-facet kind, it's common to pick one facet to | ||
* expose. E.g., | ||
* | ||
* const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self; | ||
* | ||
* This helper reduces the duplication: | ||
* | ||
* const makeFoo = pickFacet(makeFooBase, 'self'); | ||
*/ | ||
<M extends (...args: any[]) => any, F extends keyof ReturnType<M>>( | ||
maker: M, | ||
facetName: F, | ||
): (...args: Parameters<M>) => ReturnType<M>[F]; | ||
/** | ||
* When making a multi-facet kind, it's common to pick one facet to | ||
* expose. E.g., | ||
* | ||
* const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self; | ||
* | ||
* This helper reduces the duplication: | ||
* | ||
* const makeFoo = pickFacet(makeFooBase, 'self'); | ||
*/ | ||
<M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(maker: M, facetName: F): (...args: Parameters<M>) => ReturnType<M>[F]; | ||
} | ||
/** @deprecated Use prepareExoClass instead */ | ||
export type PrepareKind = <P extends Array<any>, S, F>( | ||
baggage: Baggage, | ||
tag: string, | ||
init: (...args: P) => S, | ||
facet: F, | ||
options?: DefineKindOptions<KindContext<S, F>>, | ||
) => (...args: P) => KindFacet<F>; | ||
export type PrepareKind = <P extends Array<any>, S, F>(baggage: Baggage, tag: string, init: (...args: P) => S, facet: F, options?: DefineKindOptions<KindContext<S, F>>) => (...args: P) => KindFacet<F>; | ||
/** @deprecated Use prepareExoClassKit instead */ | ||
export type PrepareKindMulti = <P extends Array<any>, S, B>( | ||
baggage: Baggage, | ||
tag: string, | ||
init: (...args: P) => S, | ||
behavior: B, | ||
options?: DefineKindOptions<MultiKindContext<S, B>>, | ||
) => (...args: P) => KindFacets<B>; | ||
export type PrepareKindMulti = <P extends Array<any>, S, B>(baggage: Baggage, tag: string, init: (...args: P) => S, behavior: B, options?: DefineKindOptions<MultiKindContext<S, B>>) => (...args: P) => KindFacets<B>; | ||
//# sourceMappingURL=vatDataTypes.d.ts.map |
/* global globalThis */ | ||
/* eslint-disable no-use-before-define, jsdoc/require-returns-type */ | ||
/* eslint-disable jsdoc/require-returns-type */ | ||
@@ -4,0 +4,0 @@ import { environmentOptionsListHas } from '@endo/env-options'; |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable no-use-before-define, jsdoc/require-returns-type */ | ||
/* eslint-disable jsdoc/require-returns-type */ | ||
@@ -3,0 +3,0 @@ import { assert, Fail } from '@endo/errors'; |
@@ -238,2 +238,15 @@ // @ts-check | ||
promiseRegistrations.init(vpid, p); | ||
// pseudoThen registers a settlement callback that will remove | ||
// this promise from promiseRegistrations and | ||
// watchedPromiseTable. To avoid triggering | ||
// https://github.com/Agoric/agoric-sdk/issues/10757 and | ||
// preventing slotToVal cleanup, the `pseudoThen()` should | ||
// precede `maybeExportPromise()`. This isn't foolproof, but | ||
// does mitigate in advance of a proper fix. See #10756 for | ||
// details of this particular mitigation, and #10757 for the | ||
// deeper bug. | ||
pseudoThen(p, vpid); | ||
// Ensure that this vat's promises are rejected at termination. | ||
@@ -243,5 +256,2 @@ if (maybeExportPromise(vpid)) { | ||
} | ||
promiseRegistrations.init(vpid, p); | ||
pseudoThen(p, vpid); | ||
} | ||
@@ -248,0 +258,0 @@ }); |
@@ -5,3 +5,3 @@ import test from 'ava'; | ||
import { Far } from '@endo/marshal'; | ||
import { M, provideLazy as provide } from '@agoric/store'; | ||
import { M } from '@agoric/store'; | ||
import { makePromiseKit } from '@endo/promise-kit'; | ||
@@ -14,2 +14,3 @@ // Disabled to avoid circular dependencies. | ||
import { makeResolve, makeReject } from './util.js'; | ||
import { makeExoUtils } from './exo-utils.js'; | ||
@@ -19,71 +20,2 @@ // eslint-disable-next-line no-unused-vars | ||
// Paritally duplicates @agoric/vat-data to avoid circular dependencies. | ||
const makeExoUtils = VatData => { | ||
const { defineDurableKind, makeKindHandle, watchPromise } = VatData; | ||
const provideKindHandle = (baggage, kindName) => | ||
provide(baggage, `${kindName}_kindHandle`, () => makeKindHandle(kindName)); | ||
const emptyRecord = harden({}); | ||
const initEmpty = () => emptyRecord; | ||
const defineDurableExoClass = ( | ||
kindHandle, | ||
interfaceGuard, | ||
init, | ||
methods, | ||
options, | ||
) => | ||
defineDurableKind(kindHandle, init, methods, { | ||
...options, | ||
thisfulMethods: true, | ||
interfaceGuard, | ||
}); | ||
const prepareExoClass = ( | ||
baggage, | ||
kindName, | ||
interfaceGuard, | ||
init, | ||
methods, | ||
options = undefined, | ||
) => | ||
defineDurableExoClass( | ||
provideKindHandle(baggage, kindName), | ||
interfaceGuard, | ||
init, | ||
methods, | ||
options, | ||
); | ||
const prepareExo = ( | ||
baggage, | ||
kindName, | ||
interfaceGuard, | ||
methods, | ||
options = undefined, | ||
) => { | ||
const makeSingleton = prepareExoClass( | ||
baggage, | ||
kindName, | ||
interfaceGuard, | ||
initEmpty, | ||
methods, | ||
options, | ||
); | ||
return provide(baggage, `the_${kindName}`, () => makeSingleton()); | ||
}; | ||
return { | ||
defineDurableKind, | ||
makeKindHandle, | ||
watchPromise, | ||
provideKindHandle, | ||
defineDurableExoClass, | ||
prepareExoClass, | ||
prepareExo, | ||
}; | ||
}; | ||
// cf. packages/SwingSet/test/vat-durable-promise-watcher.js | ||
@@ -90,0 +22,0 @@ const buildPromiseWatcherRootObject = (vatPowers, vatParameters, baggage) => { |
@@ -1,2 +0,2 @@ | ||
/* global process */ | ||
/* eslint-env node */ | ||
@@ -3,0 +3,0 @@ // put this in a separate module, so we can make it happen before |
@@ -130,4 +130,4 @@ // @ts-nocheck | ||
t.deepEqual(log.splice(0), [ | ||
`get idCounters => undefined`, | ||
`get kindIDID => undefined`, | ||
`get idCounters => undefined`, | ||
`set kindIDID 1`, | ||
@@ -207,4 +207,4 @@ `set vom.vkind.2.descriptor {"kindID":"2","tag":"multithing"}`, | ||
// t4-0: 'thing-4' 300 0 | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `get kindIDID => undefined`); | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `set kindIDID 1`); | ||
@@ -473,4 +473,4 @@ t.is(log.shift(), `set vom.vkind.2.descriptor {"kindID":"2","tag":"thing"}`); | ||
// t2-0: 'thing-2' 100 0 | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `get kindIDID => undefined`); | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `set kindIDID 1`); | ||
@@ -655,4 +655,4 @@ t.is( | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `get kindIDID => undefined`); | ||
t.is(log.shift(), `get idCounters => undefined`); | ||
t.is(log.shift(), `set kindIDID 1`); | ||
@@ -659,0 +659,0 @@ const skit = [ |
@@ -26,2 +26,3 @@ import { makeVirtualObjectManager } from '../src/virtualObjectManager.js'; | ||
canBeDurable, | ||
insistAllDurableKindsReconnected, | ||
} = makeVirtualObjectManager( | ||
@@ -47,2 +48,3 @@ fakeStuff.syscall, | ||
canBeDurable, | ||
insistAllDurableKindsReconnected, | ||
VirtualObjectAwareWeakMap, | ||
@@ -49,0 +51,0 @@ VirtualObjectAwareWeakSet, |
@@ -31,8 +31,10 @@ /* global globalThis */ | ||
class FakeWeakRef { | ||
#target; | ||
constructor(target) { | ||
this.target = target; | ||
this.#target = target; | ||
} | ||
deref() { | ||
return this.target; // strong ref | ||
return this.#target; // strong ref | ||
} | ||
@@ -45,2 +47,3 @@ } | ||
assert(!vrm, 'vrm already configured'); | ||
vrmToUse.initializeIDCounters(); | ||
vrm = vrmToUse; | ||
@@ -179,2 +182,3 @@ } | ||
// keep strong references. | ||
const WeakRefForSlot = weak ? RealWeakRef : FakeWeakRef; | ||
const valToSlot = new WeakMap(); | ||
@@ -189,3 +193,3 @@ const slotToVal = new Map(); | ||
const d = slotToVal.get(slot); | ||
return d && (weak ? d.deref() : d); | ||
return d && d.deref(); | ||
} | ||
@@ -200,3 +204,3 @@ | ||
function setValForSlot(slot, val) { | ||
slotToVal.set(slot, weak ? new RealWeakRef(val) : val); | ||
slotToVal.set(slot, new WeakRefForSlot(val)); | ||
} | ||
@@ -238,3 +242,2 @@ | ||
} | ||
// eslint-disable-next-line no-use-before-define | ||
registerEntry(baseRef, val, facet !== undefined); | ||
@@ -284,2 +287,3 @@ if (!result) { | ||
allocateExportID, | ||
allocatePromiseID, | ||
allocateCollectionID, | ||
@@ -349,3 +353,3 @@ getSlotForVal, | ||
* @param {boolean} [options.relaxDurabilityRules] | ||
* @param {Map<any, any>} [options.fakeStore] | ||
* @param {Map<string, string>} [options.fakeStore] | ||
* @param {WeakMapConstructor} [options.WeakMap] | ||
@@ -352,0 +356,0 @@ * @param {WeakSetConstructor} [options.WeakSet] |
@@ -15,3 +15,5 @@ // @ts-check | ||
/** @type {ReturnType<makeFakeVirtualStuff>} */ | ||
/** @typedef {ReturnType<typeof makeFakeVirtualStuff>} FakeVomKit */ | ||
/** @type {FakeVomKit} */ | ||
let fakeVomKit; | ||
@@ -48,6 +50,18 @@ | ||
export const reincarnate = (options = {}) => { | ||
const { fakeStore = new Map(), fakeVomKit: fvk } = options; | ||
/** | ||
* @typedef {import("@agoric/internal").Simplify< | ||
* Omit<NonNullable<Parameters<typeof makeFakeVirtualStuff>[0]>, 'WeakMap' | 'WeakSet'> & | ||
* { fakeVomKit: FakeVomKit; fakeStore: Map<string, string> } | ||
* >} ReincarnateOptions | ||
*/ | ||
if (options.fakeVomKit) { | ||
/** | ||
* | ||
* @param {Partial<ReincarnateOptions>} options | ||
* @returns {Omit<ReincarnateOptions, 'fakeVomKit'>} | ||
*/ | ||
export const flushIncarnation = (options = {}) => { | ||
const { fakeVomKit: fvk = fakeVomKit, ...fakeStuffOptions } = options; | ||
if (fvk) { | ||
fvk.vom.flushStateCache(); | ||
@@ -58,5 +72,18 @@ fvk.cm.flushSchemaCache(); | ||
// Clone previous fakeStore (if any) to avoid mutations from previous incarnation | ||
const fakeStore = new Map(options.fakeStore); | ||
return { ...fakeStuffOptions, fakeStore }; | ||
}; | ||
/** | ||
* | ||
* @param {Partial<ReincarnateOptions>} options | ||
* @returns {ReincarnateOptions} | ||
*/ | ||
export const reincarnate = (options = {}) => { | ||
const clonedIncarnation = flushIncarnation(options); | ||
fakeVomKit = makeFakeVirtualStuff({ | ||
...options, | ||
fakeStore, | ||
...clonedIncarnation, | ||
WeakMap, | ||
@@ -71,3 +98,3 @@ WeakSet, | ||
return { ...options, fakeStore, fakeVomKit }; | ||
return { ...clonedIncarnation, fakeVomKit }; | ||
}; |
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
850421
141
20045
Updated@endo/env-options@^1.1.8
Updated@endo/errors@^1.2.9
Updated@endo/eventual-send@^1.3.0
Updated@endo/exo@^1.5.8
Updated@endo/far@^1.1.10
Updated@endo/init@^1.1.8
Updated@endo/marshal@^1.6.3
Updated@endo/nat@^5.0.14
Updated@endo/pass-style@^1.4.8
Updated@endo/patterns@^1.4.8
Updated@endo/promise-kit@^1.1.9