From fe8ad369d2e58d262999c699d2dad6651bc12b70 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Tue, 17 Oct 2023 17:28:38 -0500 Subject: [PATCH] fix(exo): mark exoClassKit facets Remotable --- packages/exo/src/exo-makers.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/exo/src/exo-makers.js b/packages/exo/src/exo-makers.js index 5d2ca8a8c9..5ab3ca7fb0 100644 --- a/packages/exo/src/exo-makers.js +++ b/packages/exo/src/exo-makers.js @@ -145,6 +145,16 @@ export const defineExoClass = ( }; harden(defineExoClass); +/** + * @template {Record} F + * @typedef {{ [K in keyof F]: FarFacet }} FarFacets + */ + +/** + * @template {Methods} F + * @typedef {{ [M in keyof F]: F[M] } & import('@endo/eventual-send').RemotableBrand<{}, F>} FarFacet + */ + /** * @template {(...args: any[]) => any} I init function * @template {Record} F facet methods @@ -153,9 +163,9 @@ harden(defineExoClass); * [M in keyof F[K]]: import("@endo/patterns").MethodGuard; * }> } | undefined} interfaceGuardKit * @param {I} init - * @param {F & ThisType<{ facets: F, state: ReturnType }> } methodsKit - * @param {FarClassOptions,F>>} [options] - * @returns {(...args: Parameters) => F} + * @param {F & ThisType<{ facets: FarFacets, state: ReturnType }> } methodsKit + * @param {FarClassOptions,FarFacets>>} [options] + * @returns {(...args: Parameters) => FarFacets} */ export const defineExoClassKit = ( tag, @@ -186,15 +196,15 @@ export const defineExoClassKit = ( // Be careful not to freeze the state record const state = seal(init(...args)); // Don't freeze context until we add facets - /** @type {KitContext,F>} */ - const context = { state, facets: {} }; + /** @type {{ state: ReturnType, facets: FarFacets }} */ + const context = { state, facets: /** @type {FarFacets} */ ({}) }; instanceCount += 1; const facets = objectMap(prototypeKit, (proto, facetName) => { const self = makeSelf(proto, instanceCount); contextMapKit[facetName].set(self, context); return self; }); - context.facets = facets; + context.facets = /** @type {typeof context.facets} */ (facets); // Be careful not to freeze the state record freeze(context); if (finish) {