@agoric/swingset-liveslots 0.10.3-other-dev-3eb1a1d.0 → 0.10.3-other-dev-fbe72e7.0.fbe72e7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/package.json +26 -26
  2. package/src/boyd-gc.d.ts +12 -0
  3. package/src/boyd-gc.d.ts.map +1 -0
  4. package/src/cache.d.ts +71 -0
  5. package/src/cache.d.ts.map +1 -0
  6. package/src/capdata.d.ts +16 -0
  7. package/src/capdata.d.ts.map +1 -0
  8. package/src/capdata.js +16 -8
  9. package/src/collectionManager.d.ts +47 -0
  10. package/src/collectionManager.d.ts.map +1 -0
  11. package/src/collectionManager.js +1 -0
  12. package/src/facetiousness.d.ts +25 -0
  13. package/src/facetiousness.d.ts.map +1 -0
  14. package/src/index.d.ts +4 -0
  15. package/src/index.d.ts.map +1 -0
  16. package/src/kdebug.d.ts +7 -0
  17. package/src/kdebug.d.ts.map +1 -0
  18. package/src/liveslots.d.ts +42 -0
  19. package/src/liveslots.d.ts.map +1 -0
  20. package/src/liveslots.js +6 -4
  21. package/src/message.d.ts +49 -0
  22. package/src/message.d.ts.map +1 -0
  23. package/src/message.js +7 -3
  24. package/src/parseVatSlots.d.ts +125 -0
  25. package/src/parseVatSlots.d.ts.map +1 -0
  26. package/src/types.d.ts +81 -0
  27. package/src/types.d.ts.map +1 -0
  28. package/src/types.js +6 -5
  29. package/src/vatDataTypes.d.ts +170 -0
  30. package/src/vatDataTypes.d.ts.map +1 -0
  31. package/src/vatDataTypes.ts +272 -0
  32. package/src/vatstore-iterators.d.ts +4 -0
  33. package/src/vatstore-iterators.d.ts.map +1 -0
  34. package/src/vatstore-usage.md +198 -0
  35. package/src/virtualObjectManager.d.ts +44 -0
  36. package/src/virtualObjectManager.d.ts.map +1 -0
  37. package/src/virtualObjectManager.js +70 -14
  38. package/src/virtualReferences.d.ts +61 -0
  39. package/src/virtualReferences.d.ts.map +1 -0
  40. package/src/vpid-tracking.md +92 -0
  41. package/src/watchedPromises.d.ts +31 -0
  42. package/src/watchedPromises.d.ts.map +1 -0
  43. package/src/watchedPromises.js +19 -12
  44. package/test/collections.test.js +25 -4
  45. package/test/dummyMeterControl.d.ts +2 -0
  46. package/test/dummyMeterControl.d.ts.map +1 -0
  47. package/test/engine-gc.d.ts +3 -0
  48. package/test/engine-gc.d.ts.map +1 -0
  49. package/test/gc-and-finalize.d.ts +5 -0
  50. package/test/gc-and-finalize.d.ts.map +1 -0
  51. package/test/gc-helpers.js +2 -2
  52. package/test/handled-promises.test.js +529 -163
  53. package/test/initial-vrefs.test.js +12 -18
  54. package/test/liveslots-helpers.d.ts +64 -0
  55. package/test/liveslots-helpers.d.ts.map +1 -0
  56. package/test/liveslots-helpers.js +1 -0
  57. package/test/liveslots-real-gc.test.js +11 -9
  58. package/test/liveslots.test.js +3 -3
  59. package/test/storeGC/lifecycle.test.js +13 -12
  60. package/test/util.d.ts +25 -0
  61. package/test/util.d.ts.map +1 -0
  62. package/test/util.js +2 -2
  63. package/test/vat-util.d.ts +9 -0
  64. package/test/vat-util.d.ts.map +1 -0
  65. package/test/virtual-objects/state-shape.test.js +312 -221
  66. package/test/virtual-objects/virtualObjectGC.test.js +37 -36
  67. package/test/virtual-objects/virtualObjectManager.test.js +41 -63
  68. package/test/vo-test-harness.test.js +13 -9
  69. package/test/waitUntilQuiescent.d.ts +3 -0
  70. package/test/waitUntilQuiescent.d.ts.map +1 -0
  71. package/tools/fakeCollectionManager.d.ts +14 -0
  72. package/tools/fakeCollectionManager.d.ts.map +1 -0
  73. package/tools/fakeVirtualObjectManager.d.ts +32 -0
  74. package/tools/fakeVirtualObjectManager.d.ts.map +1 -0
  75. package/tools/fakeVirtualSupport.d.ts +278 -0
  76. package/tools/fakeVirtualSupport.d.ts.map +1 -0
  77. package/tools/prepare-strict-test-env.d.ts +37 -0
  78. package/tools/prepare-strict-test-env.d.ts.map +1 -0
  79. package/tools/prepare-test-env.d.ts +2 -0
  80. package/tools/prepare-test-env.d.ts.map +1 -0
  81. package/tools/setup-vat-data.d.ts +9 -0
  82. package/tools/setup-vat-data.d.ts.map +1 -0
  83. package/tools/setup-vat-data.js +0 -1
  84. package/tools/vo-test-harness.d.ts +33 -0
  85. package/tools/vo-test-harness.d.ts.map +1 -0
  86. package/tools/vo-test-harness.js +21 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Parse a vref string into its component parts:
3
+ * {
4
+ * type: STRING, // 'object', 'device', 'promise'
5
+ * allocatedByVat: BOOL, // true=>allocated by vat, false=>by the kernel
6
+ * id: Nat,
7
+ * subid: Nat,
8
+ * baseRef: STRING,
9
+ * facet: Nat,
10
+ * virtual: BOOL, // true=>vref designates a "merely virtual" object (not durable, not ephemeral)
11
+ * durable: BOOL, // designates a durable (not merely virtual, not ephemeral)
12
+ * }
13
+ *
14
+ * A vref string can take one of the forms:
15
+ *
16
+ * T-N
17
+ * T+N
18
+ * T+DN/I
19
+ * T+DN/I:F
20
+ *
21
+ * Where:
22
+ *
23
+ * T is a single character encoding the type of entity being referenced: 'd'
24
+ * for 'device', 'o' for 'object', or 'p' for 'promise'. One of the string
25
+ * values 'device', 'object', or 'promise' is returned as the `type`
26
+ * property of the result.
27
+ *
28
+ * '+' or '-' encodes who allocated the reference: '-' for the kernel
29
+ * (typically an import) or '+ for the vat (typically an export). This is
30
+ * returned in the `allocatedByVat` property of the result as a boolean.
31
+ *
32
+ * D is the durability status: for object exports ("o+"), this will
33
+ * be the letter 'd' for durable objects, the letter 'v' for
34
+ * non-durable ("merely virtual") objects, or empty for
35
+ * "Remotable" (ephemeral) objects. It is empty for object
36
+ * imports ("o-"), and both both imports and exports of all other
37
+ * types (promises, devices)
38
+ *
39
+ * N is a decimal integer representing the identity of the referenced entity.
40
+ * This is returned in the `id` property of the result as a BigInt.
41
+ *
42
+ * I if present (only allowed if T is 'o') is a decimal integer representing
43
+ * the instance id of the referenced object. In this case N denotes a
44
+ * category of objects that share a common shape, either one of the store
45
+ * types or a virtual object kind, and I indicates which instance of that
46
+ * category is being referred to. If present this is returned as the
47
+ * `subid` property of the result as a BigInt.
48
+ *
49
+ * F if present (only allowed if I is also present) is a decimal integer
50
+ * referencing a facet of the referenced object. In this case N/I denotes
51
+ * a particular object instance and F indicates which of several possible
52
+ * facets of that instance is being addressed. If present this is returned
53
+ * in the `facet` property of the result as a BigInt.
54
+ *
55
+ * The `baseRef` property of the result is `vref` stripped of any facet indicator.
56
+ *
57
+ * A "vref" identifies an entity visible to vat code to which messages may be
58
+ * sent and which may be compared for equality to other such entities. Let's
59
+ * call such an entity an "addressable object".
60
+ *
61
+ * A "baseRef" designates an entity that is managed by LiveSlots, both as a unit
62
+ * of garbage collection specifically and as a unit of memory management more
63
+ * generally. Such an entity may be a promise or remotable object or imported
64
+ * presence, all of which will always be JavaScript objects in memory, or it may
65
+ * be a virtual object or collection, which can be in memory or on disk or both.
66
+ * Let's call such an entity a "base object". In most cases this is one and the
67
+ * same with the addressable object that the vref designates, but in the case of
68
+ * a faceted object it is the cohort record as a whole rather than any particular
69
+ * individual facet.
70
+ *
71
+ * XXX TODO: The previous comment suggests some renaming is warranted:
72
+ *
73
+ * In the current implementation, a vref string may only include decimal digits,
74
+ * the letters 'd'/'o'/'p'/'v', and the punctuation characters '+', '-', '/',
75
+ * and ':'. Future evolution of the vref syntax might add more characters to
76
+ * this set, but the characters '|' and ',' are permanently excluded: '|' is
77
+ * used (notably by the collection manager) as delimiter in vatstore keys that
78
+ * include vrefs, and ',' is used as a separator in lists of vrefs.
79
+ *
80
+ * `slotToVal` maps a baseRef to a base object (actually to a weakRef that
81
+ * points to a base object)
82
+ * `getValForSlot` maps a baseRef to a base object, or to undefined if it is not
83
+ * resident in memory
84
+ * `convertSlotToVal` maps a vref to to an addressable object, loading it from
85
+ * disk if necessary
86
+ *
87
+ * `valToSlot` maps an addressable object to a vref
88
+ * `getSlotForVal` maps an addressable object to a vref
89
+ * `convertValToSlot` maps an addressable object to a vref, generating a new
90
+ * vref if necessary
91
+ *
92
+ * @param {string} vref The string to be parsed, as described above.
93
+ *
94
+ * @returns {*} a vref components descriptor corresponding to the vref string
95
+ * parameter, assuming it is syntactically well formed.
96
+ *
97
+ * @throws if the given vref string is syntactically incorrect.
98
+ */
99
+ export function parseVatSlot(vref: string): any;
100
+ /**
101
+ * Generate a vat slot reference string given a type, ownership, and id.
102
+ *
103
+ * @param {'object'|'device'|'promise'} type The type
104
+ * @param {boolean} allocatedByVat Flag: true=>vat allocated, false=>kernel allocated
105
+ * @param {number | bigint} id The id, a Nat.
106
+ *
107
+ * @returns {string} the corresponding vat slot reference string.
108
+ *
109
+ * @throws if type is not one of the above known types.
110
+ */
111
+ export function makeVatSlot(type: "object" | "device" | "promise", allocatedByVat: boolean, id: number | bigint): string;
112
+ export function makeBaseRef(kindID: any, id: any, isDurable: any): string;
113
+ /**
114
+ * Assert function to ensure that a vat slot reference string refers to a
115
+ * slot of a given type.
116
+ *
117
+ * @param {string} type The vat slot type desired, a string.
118
+ * @param {string} vatSlot The vat slot reference string being tested
119
+ *
120
+ * @throws if vatSlot is not of the given type or is malformed.
121
+ *
122
+ * @returns {void}
123
+ */
124
+ export function insistVatType(type: string, vatSlot: string): void;
125
+ //# sourceMappingURL=parseVatSlots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseVatSlots.d.ts","sourceRoot":"","sources":["parseVatSlots.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,mCAPW,MAAM,GAEJ,GAAC,CA4Db;AAED;;;;;;;;;;GAUG;AACH,kCARW,QAAQ,GAAC,QAAQ,GAAC,SAAS,kBAC3B,OAAO,MACP,MAAM,GAAG,MAAM,GAEb,MAAM,CAsBlB;AAED,0EAEC;AAED;;;;;;;;;;GAUG;AACH,oCAPW,MAAM,WACN,MAAM,GAIJ,IAAI,CAKhB"}
package/src/types.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ export type makeLiveSlots = () => any;
2
+ /**
3
+ * The MeterControl object gives liveslots a mechanism to disable metering for certain GC-sensitive
4
+ * regions of code. Only the XS worker can actually do metering, but we track the enabled/disabled
5
+ * status on all workers, so that the assertions can be exercised more thoroughly (via non-XS unit
6
+ * tests). MeterControl.isMeteringDisabled()===false does not mean metering is happening, it just
7
+ * means that MeterControl isn't disabling it.
8
+ */
9
+ export type MeterControl = {
10
+ /**
11
+ * Ask whether metering is currently disabled.
12
+ */
13
+ isMeteringDisabled: () => boolean;
14
+ assertIsMetered: any;
15
+ assertNotMetered: any;
16
+ /**
17
+ * Run a callback outside metering
18
+ */
19
+ runWithoutMetering: any;
20
+ /**
21
+ * Run an async callback outside metering
22
+ */
23
+ runWithoutMeteringAsync: any;
24
+ /**
25
+ * Wrap a callback with runWithoutMetering
26
+ */
27
+ unmetered: any;
28
+ };
29
+ export type LiveSlotsOptions = {
30
+ enableDisavow?: boolean | undefined;
31
+ relaxDurabilityRules?: boolean | undefined;
32
+ /**
33
+ * somewhat misnamed; this actually
34
+ * relates to *arbitrary* changes (per #10200, a non-true value still permits
35
+ * backwards-compatible addition of new optional fields)
36
+ */
37
+ allowStateShapeChanges?: boolean | undefined;
38
+ };
39
+ export type SwingSetCapData = import("@endo/marshal").CapData<string>;
40
+ export type Message = {
41
+ methargs: SwingSetCapData;
42
+ result: string | undefined | null;
43
+ };
44
+ export type VatDeliveryMessage = [tag: "message", target: string, msg: Message];
45
+ export type VatOneResolution = [vpid: string, isReject: boolean, data: SwingSetCapData];
46
+ export type VatDeliveryNotify = [tag: "notify", resolutions: VatOneResolution[]];
47
+ export type VatDeliveryDropExports = [tag: "dropExports", vrefs: string[]];
48
+ export type VatDeliveryRetireExports = [tag: "retireExports", vrefs: string[]];
49
+ export type VatDeliveryRetireImports = [tag: "retireImports", vrefs: string[]];
50
+ export type VatDeliveryChangeVatOptions = [tag: "changeVatOptions", options: Record<string, unknown>];
51
+ export type VatDeliveryStartVat = [tag: "startVat", vatParameters: SwingSetCapData];
52
+ export type VatDeliveryStopVat = [tag: "stopVat", disconnectObject: SwingSetCapData];
53
+ export type VatDeliveryBringOutYourDead = [tag: "bringOutYourDead"];
54
+ export type VatDeliveryObject = VatDeliveryMessage | VatDeliveryNotify | VatDeliveryDropExports | VatDeliveryRetireExports | VatDeliveryRetireImports | VatDeliveryChangeVatOptions | VatDeliveryStartVat | VatDeliveryStopVat | VatDeliveryBringOutYourDead;
55
+ export type MeterConsumption = {
56
+ compute: number;
57
+ };
58
+ export type VatDeliveryResult = [tag: "ok", results: any, usage: MeterConsumption | null] | [tag: "error", message: string, usage: MeterConsumption | null];
59
+ export type VatSyscallSend = [tag: "send", target: string, msg: Message];
60
+ export type VatSyscallCallNow = [tag: "callNow", target: string, method: string, args: SwingSetCapData];
61
+ export type VatSyscallSubscribe = [tag: "subscribe", vpid: string];
62
+ export type VatSyscallResolve = [tag: "resolve", resolutions: VatOneResolution[]];
63
+ export type VatSyscallExit = [tag: "exit", isFailure: boolean, info: SwingSetCapData];
64
+ export type VatSyscallVatstoreGet = [tag: "vatstoreGet", key: string];
65
+ export type VatSyscallVatstoreGetNextKey = [tag: "vatstoreGetNextKey", priorKey: string];
66
+ export type VatSyscallVatstoreSet = [tag: "vatstoreSet", key: string, data: string];
67
+ export type VatSyscallVatstoreDelete = [tag: "vatstoreDelete", key: string];
68
+ export type VatSyscallDropImports = [tag: "dropImports", slots: string[]];
69
+ export type VatSyscallRetireImports = [tag: "retireImports", slots: string[]];
70
+ export type VatSyscallRetireExports = [tag: "retireExports", slots: string[]];
71
+ export type VatSyscallAbandonExports = [tag: "abandonExports", slots: string[]];
72
+ export type VatSyscallObject = VatSyscallSend | VatSyscallCallNow | VatSyscallSubscribe | VatSyscallResolve | VatSyscallExit | VatSyscallVatstoreGet | VatSyscallVatstoreGetNextKey | VatSyscallVatstoreSet | VatSyscallVatstoreDelete | VatSyscallDropImports | VatSyscallRetireImports | VatSyscallRetireExports | VatSyscallAbandonExports;
73
+ export type VatSyscallResultOk = [tag: "ok", data: SwingSetCapData | string | string[] | null];
74
+ export type VatSyscallResultError = [tag: "error", err: string];
75
+ export type VatSyscallResult = VatSyscallResultOk | VatSyscallResultError;
76
+ export type VatSyscallHandler = (vso: VatSyscallObject) => VatSyscallResult;
77
+ export type PromiseWatcher<V, A extends any[] = unknown[]> = {
78
+ onFulfilled?: (value: V, ...args: A) => void;
79
+ onRejected?: (reason: unknown, ...args: A) => void;
80
+ };
81
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;;;;;;;;;;wBAec,MAAM,OAAO;qBACb,GAAC;sBACD,GAAC;;;;wBACD,GAAC;;;;6BACD,GAAC;;;;eACD,GAAC;;;;;;;;;;;;8BAWF,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC;sBAEvC;IACK,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CACpC;iCACF,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;+BAC9C,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAE;gCACzD,CAAC,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAE;qCACjD,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;uCACtC,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;uCACxC,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;0CACxC,CAAC,GAAG,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EA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AAG,EAAE,MAAM,CAAE;oCACrC,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;sCACtC,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;sCACxC,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;uCACxC,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,CAAE;+BAEzC,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,GAC9D,iBAAiB,GAAG,cAAc,GAAG,qBAAqB,GAAG,4BAA4B,GACzF,qBAAqB,GAAG,wBAAwB,GAAG,qBAAqB,GACxE,uBAAuB,GAAG,uBAAuB,GAAG,wBAAwB;iCAGtE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAE;oCAC9D,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAE;+BAC5B,kBAAkB,GAAG,qBAAqB;gCAE1C,CAAC,GAAG,EAAE,gBAAgB,KAAK,gBAAgB;2BAK5C,CAAC,EACQ,CAAC,SAAT,GAAG,EAAG,gBACN;IAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAAC"}
package/src/types.js CHANGED
@@ -22,11 +22,12 @@ export {};
22
22
  */
23
23
 
24
24
  /**
25
- * @typedef {{
26
- * enableDisavow?: boolean,
27
- * relaxDurabilityRules?: boolean,
28
- * allowStateShapeChanges?: boolean,
29
- * }} LiveSlotsOptions
25
+ * @typedef {object} LiveSlotsOptions
26
+ * @property {boolean} [enableDisavow]
27
+ * @property {boolean} [relaxDurabilityRules]
28
+ * @property {boolean} [allowStateShapeChanges] somewhat misnamed; this actually
29
+ * relates to *arbitrary* changes (per #10200, a non-true value still permits
30
+ * backwards-compatible addition of new optional fields)
30
31
  *
31
32
  * @typedef {import('@endo/marshal').CapData<string>} SwingSetCapData
32
33
  *
@@ -0,0 +1,170 @@
1
+ /**
2
+ * @file Types for vat-data
3
+ *
4
+ * Facet is a single object with methods.
5
+ * Behavior is a description when defining a kind of what facets it will have.
6
+ * For the non-multi defineKind, there is just one facet so it doesn't have a key.
7
+ */
8
+ import type { MapStore, SetStore, StoreOptions, WeakMapStore, WeakSetStore } from '@agoric/store';
9
+ import type { Amplify, IsInstance, ReceivePower, StateShape } from '@endo/exo';
10
+ import type { RemotableObject } from '@endo/pass-style';
11
+ import type { RemotableBrand } from '@endo/eventual-send';
12
+ import type { InterfaceGuard, Pattern } from '@endo/patterns';
13
+ import type { makeWatchedPromiseManager } from './watchedPromises.js';
14
+ export type InterfaceGuardKit = Record<string, InterfaceGuard>;
15
+ export type { MapStore, Pattern };
16
+ export type Baggage = MapStore<string, any>;
17
+ type WatchedPromisesManager = ReturnType<typeof makeWatchedPromiseManager>;
18
+ type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
19
+ type PrimaryRemotable<O> = O & RemotableObject & RemotableBrand<object, O>;
20
+ export type KindFacet<O> = PrimaryRemotable<{
21
+ [K in keyof O]: OmitFirstArg<O[K]>;
22
+ }>;
23
+ export type KindFacets<B> = {
24
+ [FacetKey in keyof B]: KindFacet<B[FacetKey]>;
25
+ };
26
+ export type KindContext<S, F> = {
27
+ state: S;
28
+ self: KindFacet<F>;
29
+ };
30
+ export type MultiKindContext<S, B> = {
31
+ state: S;
32
+ facets: KindFacets<B>;
33
+ };
34
+ export type PlusContext<C, M extends (...args: any[]) => any> = (c: C, ...args: Parameters<M>) => ReturnType<M>;
35
+ export type FunctionsPlusContext<C, O extends Record<string, (...args: any[]) => any>> = {
36
+ [K in keyof O]: PlusContext<C, O[K]>;
37
+ };
38
+ declare class DurableKindHandleClass {
39
+ private descriptionTag;
40
+ }
41
+ export type DurableKindHandle = DurableKindHandleClass;
42
+ /**
43
+ * Grab bag of options that can be provided to `defineDurableKind` and its
44
+ * siblings. Not all options are meaningful in all contexts. See the
45
+ * doc-comments on each option.
46
+ */
47
+ export type DefineKindOptions<C> = {
48
+ /**
49
+ * If provided, the `finish` function will be called after the instance is
50
+ * made and internally registered, but before it is returned. The finish
51
+ * function is to do any post-intantiation initialization that should be
52
+ * done before exposing the object to its clients.
53
+ */
54
+ finish?: (context: C) => void;
55
+ /**
56
+ * If provided, it describes the shape of all state records of instances
57
+ * of this kind.
58
+ */
59
+ stateShape?: StateShape;
60
+ /**
61
+ * If a `receiveAmplifier` function is provided to an exo class kit definition,
62
+ * it will be called with an `Amplify` function. If provided to the definition
63
+ * of a normal exo or exo class, the definition will throw, since only
64
+ * exo kits can be amplified.
65
+ * An `Amplify` function is a function that takes a facet instance of
66
+ * this class kit as an argument, in which case it will return the facets
67
+ * record, giving access to all the facet instances of the same cohort.
68
+ */
69
+ receiveAmplifier?: ReceivePower<Amplify>;
70
+ /**
71
+ * If a `receiveInstanceTester` function is provided, it will be called
72
+ * during the definition of the exo class or exo class kit with an
73
+ * `IsInstance` function. The first argument of `IsInstance`
74
+ * is the value to be tested. When it may be a facet instance of an
75
+ * exo class kit, the optional second argument, if provided, is
76
+ * a `facetName`. In that case, the function tests only if the first
77
+ * argument is an instance of that facet of the associated exo class kit.
78
+ */
79
+ receiveInstanceTester?: ReceivePower<IsInstance>;
80
+ /**
81
+ * As a kind option, intended for internal use only.
82
+ * Meaningful to `makeScalarBigMapStore` and its siblings. These maker
83
+ * fuctions will make either virtual or durable stores, depending on
84
+ * this flag. Defaults to off, making virtual but not durable collections.
85
+ *
86
+ * Generally, durable collections are provided with `provideDurableMapStore`
87
+ * and its sibling, which use this flag internally. If you do not make
88
+ * durable collections by other means, you can consider this as
89
+ * intended for internal use only.
90
+ */
91
+ durable?: boolean;
92
+ /**
93
+ * Intended for internal use only.
94
+ * Should the raw methods receive their `context` argument as their first
95
+ * argument or as their `this` binding? For `defineDurableKind` and its
96
+ * siblings (including `prepareSingleton`), this defaults to off, meaning that
97
+ * their behavior methods receive `context` as their first argument.
98
+ * `prepareExoClass` and its siblings (including `prepareExo`) use
99
+ * this flag internally to indicate that their methods receive `context`
100
+ * as their `this` binding.
101
+ */
102
+ thisfulMethods?: boolean;
103
+ /**
104
+ * Intended for internal use only.
105
+ * Only applicable if this is a class kind. A class kit kind should use
106
+ * `interfaceGuardKit` instead.
107
+ *
108
+ * If an `interfaceGuard` is provided, then the raw methods passed alongside
109
+ * it are wrapped by a function that first checks that this method's guard
110
+ * pattern is satisfied before calling the raw method.
111
+ *
112
+ * In `defineDurableKind` and its siblings, this defaults to `undefined`.
113
+ * Exo classes use this internally to protect their raw class methods
114
+ * using the provided interface.
115
+ * In absence, an exo is protected anyway, while a bare kind is
116
+ * not (detected by `!thisfulMethods`),
117
+ */
118
+ interfaceGuard?: InterfaceGuard;
119
+ /**
120
+ * Intended for internal use only.
121
+ * Only applicable if this is a class kit kind. A class kind should use
122
+ * `interfaceGuard` instead.
123
+ *
124
+ * If an `interfaceGuardKit` is provided, then each member of the
125
+ * interfaceGuardKit is used to guard the corresponding facet of the
126
+ * class kit.
127
+ *
128
+ * In `defineDurableKindMulti` and its siblings, this defaults to `undefined`.
129
+ * Exo class kits use this internally to protect their facets.
130
+ * In absence, an exo is protected anyway, while a bare kind is
131
+ * not (detected by `!thisfulMethods`),
132
+ */
133
+ interfaceGuardKit?: InterfaceGuardKit;
134
+ };
135
+ export type VatData = {
136
+ /** @deprecated Use defineVirtualExoClass instead */
137
+ defineKind: <P extends Array<any>, S, F>(tag: string, init: (...args: P) => S, facet: F, options?: DefineKindOptions<KindContext<S, F>>) => (...args: P) => KindFacet<F>;
138
+ /** @deprecated Use defineVirtualExoClassKit instead */
139
+ defineKindMulti: <P extends Array<any>, S, B>(tag: string, init: (...args: P) => S, behavior: B, options?: DefineKindOptions<MultiKindContext<S, B>>) => (...args: P) => KindFacets<B>;
140
+ makeKindHandle: (descriptionTag: string) => DurableKindHandle;
141
+ /** @deprecated Use defineDurableExoClass instead */
142
+ defineDurableKind: <P extends Array<any>, S, F>(kindHandle: DurableKindHandle, init: (...args: P) => S, facet: F, options?: DefineKindOptions<KindContext<S, F>>) => (...args: P) => KindFacet<F>;
143
+ /** @deprecated Use defineDurableExoClassKit instead */
144
+ defineDurableKindMulti: <P extends Array<any>, S, B>(kindHandle: DurableKindHandle, init: (...args: P) => S, behavior: B, options?: DefineKindOptions<MultiKindContext<S, B>>) => (...args: P) => KindFacets<B>;
145
+ providePromiseWatcher: WatchedPromisesManager['providePromiseWatcher'];
146
+ watchPromise: WatchedPromisesManager['watchPromise'];
147
+ makeScalarBigMapStore: <K, V>(label: string, options?: StoreOptions) => MapStore<K, V>;
148
+ makeScalarBigWeakMapStore: <K, V>(label: string, options?: StoreOptions) => WeakMapStore<K, V>;
149
+ makeScalarBigSetStore: <K>(label: string, options?: StoreOptions) => SetStore<K>;
150
+ makeScalarBigWeakSetStore: <K>(label: string, options?: StoreOptions) => WeakSetStore<K>;
151
+ canBeDurable: (specimen: unknown) => boolean;
152
+ };
153
+ export interface PickFacet {
154
+ /**
155
+ * When making a multi-facet kind, it's common to pick one facet to
156
+ * expose. E.g.,
157
+ *
158
+ * const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self;
159
+ *
160
+ * This helper reduces the duplication:
161
+ *
162
+ * const makeFoo = pickFacet(makeFooBase, 'self');
163
+ */
164
+ <M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(maker: M, facetName: F): (...args: Parameters<M>) => ReturnType<M>[F];
165
+ }
166
+ /** @deprecated Use prepareExoClass instead */
167
+ 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>;
168
+ /** @deprecated Use prepareExoClassKit instead */
169
+ 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>;
170
+ //# sourceMappingURL=vatDataTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vatDataTypes.d.ts","sourceRoot":"","sources":["vatDataTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAItE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC/D,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAKlC,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAG3E,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GAClE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACjB,KAAK,CAAC;AAIV,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,GA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