@agoric/network 0.1.1-orchestration-dev-096c4e8.0 → 0.1.1-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.
package/src/router.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @import {Endpoint, Port, Protocol, ProtocolHandler} from './types.js';
3
+ * @import {PromiseVow, Remote, VowTools} from '@agoric/vow';
4
+ */
1
5
  /**
2
6
  * @template T
3
7
  * @typedef {object} Router A delimited string router implementation
@@ -13,7 +17,7 @@ export const RouterI: import("@endo/patterns").InterfaceGuard<{
13
17
  register: import("@endo/patterns").MethodGuard;
14
18
  unregister: import("@endo/patterns").MethodGuard;
15
19
  }>;
16
- export function prepareRouter<T>(zone: import('@agoric/base-zone').Zone): () => import("@endo/exo/src/exo-makers.js").Guarded<{
20
+ export function prepareRouter<T>(zone: import("@agoric/base-zone").Zone): () => import("@endo/exo").Guarded<{
17
21
  /** @param {Endpoint} addr */
18
22
  getRoutes(addr: Endpoint): [string, T][];
19
23
  /**
@@ -27,35 +31,19 @@ export function prepareRouter<T>(zone: import('@agoric/base-zone').Zone): () =>
27
31
  */
28
32
  unregister(prefix: string, route: T): void;
29
33
  }>;
30
- export function prepareRouterProtocol(zone: import('@agoric/base-zone').Zone, powers: ReturnType<(zone: import("@agoric/base-zone").Zone, powers?: {
31
- isRetryableReason?: ((reason: any) => boolean) | undefined;
32
- watchPromise?: ((p: PromiseLike<any>, watcher: import("@agoric/vow/src/watch-promise.js").PromiseWatcher, ...args: unknown[]) => void) | undefined;
33
- } | undefined) => {
34
- when: <T = any, TResult1 = import("@agoric/vow/src/E.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow/src/E.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
35
- watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = T_1>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: unknown) => import("@agoric/vow").Vow<TResult1_1 | TResult2_1>;
36
- makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
37
- }>, E?: ((<T_3>(x: T_3) => import("@endo/eventual-send/src/E.js").ECallableOrMethods<import("@endo/eventual-send").RemoteFunctions<T_3>>) & {
38
- readonly get: <T_1>(x: T_1) => import("@endo/eventual-send/src/E.js").EGetters<import("@endo/eventual-send").LocalRecord<T_1>>;
39
- readonly resolve: {
40
- (): Promise<void>;
41
- <T_2>(value: T_2): Promise<Awaited<T_2>>;
42
- <T_3>(value: T_3 | PromiseLike<T_3>): Promise<Awaited<T_3>>;
43
- };
44
- readonly sendOnly: <T_4>(x: T_4) => import("@endo/eventual-send/src/E.js").ESendOnlyCallableOrMethods<import("@endo/eventual-send").RemoteFunctions<T_4>>;
45
- readonly when: <T_5, U = T_5>(x: T_5 | PromiseLike<T_5>, onfulfilled?: ((value: T_5) => import("@endo/eventual-send").ERef<U>) | undefined, onrejected?: ((reason: any) => import("@endo/eventual-send").ERef<U>) | undefined) => Promise<U>;
46
- }) | undefined): () => import("@endo/exo/src/exo-makers.js").Guarded<{
34
+ export function prepareRouterProtocol(zone: import("@agoric/base-zone").Zone, powers: import("./network.js").Powers, E?: typeof defaultE): () => import("@endo/exo").Guarded<{
47
35
  /**
48
36
  * @param {string[]} paths
49
- * @param {ProtocolHandler} protocolHandler
37
+ * @param {Remote<ProtocolHandler>} protocolHandler
50
38
  */
51
- registerProtocolHandler(paths: string[], protocolHandler: ProtocolHandler): void;
39
+ registerProtocolHandler(paths: string[], protocolHandler: Remote<ProtocolHandler>): void;
52
40
  /**
53
41
  * @param {string} prefix
54
- * @param {ProtocolHandler} protocolHandler
42
+ * @param {Remote<ProtocolHandler>} protocolHandler
55
43
  */
56
- unregisterProtocolHandler(prefix: string, protocolHandler: ProtocolHandler): void;
44
+ unregisterProtocolHandler(prefix: string, protocolHandler: Remote<ProtocolHandler>): void;
57
45
  /** @param {Endpoint} localAddr */
58
- bind(localAddr: Endpoint): Promise<Port | import("@agoric/vow").Vow<Port>>;
46
+ bindPort(localAddr: Endpoint): Promise<Port | import("@agoric/vow").Vow<Port>>;
59
47
  }>;
60
48
  /**
61
49
  * A delimited string router implementation
@@ -78,8 +66,14 @@ export type Router<T> = {
78
66
  unregister: (prefix: string, route: T) => void;
79
67
  };
80
68
  export type RouterProtocol = {
81
- bind: (prefix: string) => PromiseVow<Port>;
69
+ bindPort: (prefix: string) => PromiseVow<Port>;
82
70
  registerProtocolHandler: (paths: string[], protocolHandler: ProtocolHandler) => void;
83
71
  unregisterProtocolHandler: (prefix: string, protocolHandler: ProtocolHandler) => void;
84
72
  };
73
+ import type { Endpoint } from './types.js';
74
+ import { E as defaultE } from '@endo/far';
75
+ import type { ProtocolHandler } from './types.js';
76
+ import type { Remote } from '@agoric/vow';
77
+ import type { Port } from './types.js';
78
+ import type { PromiseVow } from '@agoric/vow';
85
79
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AAEH;;;;GAIG;AAMI,uCAFI,OAAO,mBAAmB,EAAE,IAAI;IAiBrC,6BAA6B;oBAAjB,QAAQ;IAyBpB;;;OAGG;qBAFQ,MAAM;IAMjB;;;OAGG;uBAFQ,MAAM;GAYtB;AAgBM,4CAJI,OAAO,mBAAmB,EAAE,IAAI,UAChC;;;;;;;EAAiD;;;;;;;;;;IAoCtD;;;OAGG;mCAFQ,MAAM,EAAE,mBACR,eAAe;IAY1B;;;OAGG;sCAFQ,MAAM,mBACN,eAAe;IAc1B,kCAAkC;oBAAtB,QAAQ;GAUzB;;;;;;;;;sBAvKoB,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE;;;;;uBAEtB,MAAM,SAAS,CAAC,KAAK,IAAI;;;;;yBAEzB,MAAM,SAAS,CAAC,KAAK,IAAI;;;mBA8EzB,MAAM,KAAK,WAAW,IAAI,CAAC;qCAC5B,MAAM,EAAE,mBAAmB,eAAe,KAAK,IAAI;wCAClD,MAAM,mBAAmB,eAAe,KAAK,IAAI"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"AAWA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH;;;;GAIG;AAMI,8BAHM,CAAC,QACH,OAAO,mBAAmB,EAAE,IAAI;IAiBrC,6BAA6B;oBAAjB,QAAQ;IAyBpB;;;OAGG;qBAFQ,MAAM,SACN,CAAC;IAKZ;;;OAGG;uBAFQ,MAAM,SACN,CAAC;GAWjB;AAgBM,4CAJI,OAAO,mBAAmB,EAAE,IAAI,UAChC,OAAO,cAAc,EAAE,MAAM,MAC7B,OAAO,QAAQ;IAmCpB;;;OAGG;mCAFQ,MAAM,EAAE,mBACR,OAAO,eAAe,CAAC;IAYlC;;;OAGG;sCAFQ,MAAM,mBACN,OAAO,eAAe,CAAC;IAclC,kCAAkC;wBAAtB,QAAQ;GAUzB;;;;mBAzKY,CAAC;;;;;eAEA,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE;;;;;cAE/B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;;;gBAElC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;cA8ElC,CAAC,MAAM,EAAE,MAAM,KAAK,WAAW,IAAI,CAAC;6BACpC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI;+BAC3D,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI;;8BA3FZ,YAAY;8BAN1C,WAAW;qCAMmB,YAAY;4BACzB,aAAa;0BADA,YAAY;gCACzB,aAAa"}
package/src/router.js CHANGED
@@ -1,15 +1,18 @@
1
1
  // @ts-check
2
+
3
+ /// <reference types="@agoric/store/exported.js" />
4
+ /// <reference path="./types.js" />
5
+
6
+ import { Fail } from '@endo/errors';
2
7
  import { E as defaultE } from '@endo/far';
3
8
  import { M } from '@endo/patterns';
4
- import { Fail } from '@agoric/assert';
5
- import {
6
- ENDPOINT_SEPARATOR,
7
- Shape,
8
- prepareNetworkProtocol,
9
- } from './network.js';
10
-
11
- import '@agoric/store/exported.js';
12
- /// <reference path="./types.js" />
9
+ import { ENDPOINT_SEPARATOR, prepareNetworkProtocol } from './network.js';
10
+ import { Shape } from './shapes.js';
11
+
12
+ /**
13
+ * @import {Endpoint, Port, Protocol, ProtocolHandler} from './types.js';
14
+ * @import {PromiseVow, Remote, VowTools} from '@agoric/vow';
15
+ */
13
16
 
14
17
  /**
15
18
  * @template T
@@ -59,7 +62,7 @@ export const prepareRouter = zone => {
59
62
  ret.push([prefix, this.state.prefixToRoute.get(prefix)]);
60
63
  }
61
64
  // Trim off the last value (after the slash).
62
- const defaultPrefix = prefix.substr(
65
+ const defaultPrefix = prefix.slice(
63
66
  0,
64
67
  prefix.lastIndexOf(ENDPOINT_SEPARATOR) + 1,
65
68
  );
@@ -96,7 +99,7 @@ export const prepareRouter = zone => {
96
99
 
97
100
  /**
98
101
  * @typedef {object} RouterProtocol
99
- * @property {(prefix: string) => PromiseVow<Port>} bind
102
+ * @property {(prefix: string) => PromiseVow<Port>} bindPort
100
103
  * @property {(paths: string[], protocolHandler: ProtocolHandler) => void} registerProtocolHandler
101
104
  * @property {(prefix: string, protocolHandler: ProtocolHandler) => void} unregisterProtocolHandler
102
105
  */
@@ -105,7 +108,7 @@ export const prepareRouter = zone => {
105
108
  * Create a router that behaves like a Protocol.
106
109
  *
107
110
  * @param {import('@agoric/base-zone').Zone} zone
108
- * @param {ReturnType<import('@agoric/vow').prepareVowTools>} powers
111
+ * @param {import('./network.js').Powers} powers
109
112
  * @param {typeof defaultE} [E] Eventual sender
110
113
  */
111
114
  export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
@@ -122,7 +125,7 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
122
125
  M.remotable(),
123
126
  ).returns(),
124
127
  unregisterProtocolHandler: M.call(M.string(), M.remotable()).returns(),
125
- bind: M.callWhen(Shape.Endpoint).returns(Shape.Vow$(Shape.Port)),
128
+ bindPort: M.callWhen(Shape.Endpoint).returns(Shape.Vow$(Shape.Port)),
126
129
  }),
127
130
  () => {
128
131
  /** @type {Router<Protocol>} */
@@ -131,7 +134,7 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
131
134
  /** @type {MapStore<string, Protocol>} */
132
135
  const protocols = detached.mapStore('prefix');
133
136
 
134
- /** @type {MapStore<string, ProtocolHandler>} */
137
+ /** @type {MapStore<string, Remote<ProtocolHandler>>} */
135
138
  const protocolHandlers = detached.mapStore('prefix');
136
139
 
137
140
  return {
@@ -143,7 +146,7 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
143
146
  {
144
147
  /**
145
148
  * @param {string[]} paths
146
- * @param {ProtocolHandler} protocolHandler
149
+ * @param {Remote<ProtocolHandler>} protocolHandler
147
150
  */
148
151
  registerProtocolHandler(paths, protocolHandler) {
149
152
  const protocol = makeNetworkProtocol(protocolHandler);
@@ -157,13 +160,13 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
157
160
  // Needs to account for multiple paths.
158
161
  /**
159
162
  * @param {string} prefix
160
- * @param {ProtocolHandler} protocolHandler
163
+ * @param {Remote<ProtocolHandler>} protocolHandler
161
164
  */
162
165
  unregisterProtocolHandler(prefix, protocolHandler) {
163
166
  const ph = this.state.protocolHandlers.get(prefix);
164
167
  ph === protocolHandler ||
165
168
  Fail`Protocol handler is not registered at prefix ${prefix}`;
166
- // TODO: unmap protocol hanlders to their corresponding protocol
169
+ // TODO: unmap protocol handlers to their corresponding protocol
167
170
  // e.g. using a map
168
171
  // before unregistering
169
172
  // @ts-expect-error note FIXME above
@@ -172,10 +175,10 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
172
175
  this.state.protocolHandlers.delete(prefix);
173
176
  },
174
177
  /** @param {Endpoint} localAddr */
175
- async bind(localAddr) {
178
+ async bindPort(localAddr) {
176
179
  const [route] = this.state.router.getRoutes(localAddr);
177
180
  route !== undefined || Fail`No registered router for ${localAddr}`;
178
- return E(route[1]).bind(localAddr);
181
+ return E(route[1]).bindPort(localAddr);
179
182
  },
180
183
  },
181
184
  );
@@ -0,0 +1,118 @@
1
+ export const SendOptionsShape: import("@endo/patterns").Matcher;
2
+ export namespace Shape {
3
+ export namespace ConnectionI {
4
+ let connection: import("@endo/patterns").InterfaceGuard<{
5
+ send: import("@endo/patterns").MethodGuard;
6
+ close: import("@endo/patterns").MethodGuard;
7
+ getLocalAddress: import("@endo/patterns").MethodGuard;
8
+ getRemoteAddress: import("@endo/patterns").MethodGuard;
9
+ }>;
10
+ let openConnectionAckWatcher: import("@endo/patterns").InterfaceGuard<{
11
+ onFulfilled: import("@endo/patterns").MethodGuard;
12
+ }>;
13
+ let rethrowUnlessMissingWatcher: import("@endo/patterns").InterfaceGuard<{
14
+ onRejected: import("@endo/patterns").MethodGuard;
15
+ }>;
16
+ let sinkWatcher: import("@endo/patterns").InterfaceGuard<{
17
+ onFulfilled: import("@endo/patterns").MethodGuard;
18
+ }>;
19
+ }
20
+ export namespace InboundAttemptI {
21
+ export let inboundAttempt: import("@endo/patterns").InterfaceGuard<{
22
+ accept: import("@endo/patterns").MethodGuard;
23
+ getLocalAddress: import("@endo/patterns").MethodGuard;
24
+ getRemoteAddress: import("@endo/patterns").MethodGuard;
25
+ close: import("@endo/patterns").MethodGuard;
26
+ }>;
27
+ export let inboundAttemptAcceptWatcher: import("@endo/patterns").InterfaceGuard<{
28
+ onFulfilled: import("@endo/patterns").MethodGuard;
29
+ }>;
30
+ let rethrowUnlessMissingWatcher_1: import("@endo/patterns").InterfaceGuard<{
31
+ onRejected: import("@endo/patterns").MethodGuard;
32
+ }>;
33
+ export { rethrowUnlessMissingWatcher_1 as rethrowUnlessMissingWatcher };
34
+ let sinkWatcher_1: import("@endo/patterns").InterfaceGuard<{
35
+ onFulfilled: import("@endo/patterns").MethodGuard;
36
+ }>;
37
+ export { sinkWatcher_1 as sinkWatcher };
38
+ }
39
+ export namespace PortI {
40
+ export let port: import("@endo/patterns").InterfaceGuard<{
41
+ getLocalAddress: import("@endo/patterns").MethodGuard;
42
+ addListener: import("@endo/patterns").MethodGuard;
43
+ connect: import("@endo/patterns").MethodGuard;
44
+ removeListener: import("@endo/patterns").MethodGuard;
45
+ revoke: import("@endo/patterns").MethodGuard;
46
+ }>;
47
+ export let portAddListenerWatcher: import("@endo/patterns").InterfaceGuard<{
48
+ onFulfilled: import("@endo/patterns").MethodGuard;
49
+ }>;
50
+ export let portRemoveListenerWatcher: import("@endo/patterns").InterfaceGuard<{
51
+ onFulfilled: import("@endo/patterns").MethodGuard;
52
+ }>;
53
+ export let portConnectWatcher: import("@endo/patterns").InterfaceGuard<{
54
+ onFulfilled: import("@endo/patterns").MethodGuard;
55
+ }>;
56
+ export let portRevokeWatcher: import("@endo/patterns").InterfaceGuard<{
57
+ onFulfilled: import("@endo/patterns").MethodGuard;
58
+ }>;
59
+ export let portRevokeCleanupWatcher: import("@endo/patterns").InterfaceGuard<{
60
+ onFulfilled: import("@endo/patterns").MethodGuard;
61
+ }>;
62
+ let rethrowUnlessMissingWatcher_2: import("@endo/patterns").InterfaceGuard<{
63
+ onRejected: import("@endo/patterns").MethodGuard;
64
+ }>;
65
+ export { rethrowUnlessMissingWatcher_2 as rethrowUnlessMissingWatcher };
66
+ let sinkWatcher_2: import("@endo/patterns").InterfaceGuard<{
67
+ onFulfilled: import("@endo/patterns").MethodGuard;
68
+ onRejected: import("@endo/patterns").MethodGuard;
69
+ }>;
70
+ export { sinkWatcher_2 as sinkWatcher };
71
+ }
72
+ export namespace ProtocolHandlerI {
73
+ export let protocolHandler: import("@endo/patterns").InterfaceGuard<{
74
+ onCreate: import("@endo/patterns").MethodGuard;
75
+ generatePortID: import("@endo/patterns").MethodGuard;
76
+ onBind: import("@endo/patterns").MethodGuard;
77
+ onListen: import("@endo/patterns").MethodGuard;
78
+ onListenRemove: import("@endo/patterns").MethodGuard;
79
+ onInstantiate: import("@endo/patterns").MethodGuard;
80
+ onConnect: import("@endo/patterns").MethodGuard;
81
+ onRevoke: import("@endo/patterns").MethodGuard;
82
+ }>;
83
+ export let protocolHandlerAcceptWatcher: import("@endo/patterns").InterfaceGuard<{
84
+ onFulfilled: import("@endo/patterns").MethodGuard;
85
+ }>;
86
+ export let protocolHandlerInstantiateWatcher: import("@endo/patterns").InterfaceGuard<{
87
+ onFulfilled: import("@endo/patterns").MethodGuard;
88
+ }>;
89
+ export let protocolHandlerConnectWatcher: import("@endo/patterns").InterfaceGuard<{
90
+ onFulfilled: import("@endo/patterns").MethodGuard;
91
+ }>;
92
+ let rethrowUnlessMissingWatcher_3: import("@endo/patterns").InterfaceGuard<{
93
+ onRejected: import("@endo/patterns").MethodGuard;
94
+ }>;
95
+ export { rethrowUnlessMissingWatcher_3 as rethrowUnlessMissingWatcher };
96
+ }
97
+ export let ProtocolImplI: import("@endo/patterns").InterfaceGuard<{
98
+ bindPort: import("@endo/patterns").MethodGuard;
99
+ inbound: import("@endo/patterns").MethodGuard;
100
+ outbound: import("@endo/patterns").MethodGuard;
101
+ }>;
102
+ export function Vow$(shape: any): import("@endo/patterns").Matcher;
103
+ export let AttemptDescription: import("@endo/patterns").Matcher;
104
+ export { SendOptionsShape as Opts };
105
+ export let Data: import("@endo/patterns").Matcher;
106
+ export let Bytes: import("@endo/patterns").Matcher;
107
+ export let Endpoint: import("@endo/patterns").Matcher;
108
+ export let Vow: import("@endo/patterns").Matcher;
109
+ export let ConnectionHandler: import("@endo/patterns").Matcher;
110
+ export let Connection: import("@endo/patterns").Matcher;
111
+ export let InboundAttempt: import("@endo/patterns").Matcher;
112
+ export let Listener: import("@endo/patterns").Matcher;
113
+ export let ListenHandler: import("@endo/patterns").Matcher;
114
+ export let Port: import("@endo/patterns").Matcher;
115
+ export let ProtocolHandler: import("@endo/patterns").Matcher;
116
+ export let ProtocolImpl: import("@endo/patterns").Matcher;
117
+ }
118
+ //# sourceMappingURL=shapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["shapes.js"],"names":[],"mappings":"AA2BA,gEAGE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIM,mEAAgC"}
package/src/shapes.js ADDED
@@ -0,0 +1,196 @@
1
+ // @ts-check
2
+ import { M } from '@endo/patterns';
3
+
4
+ const Shape1 = /** @type {const} */ ({
5
+ /**
6
+ * Data is string | Buffer | ArrayBuffer
7
+ * but only string is passable
8
+ */
9
+ Data: M.string(),
10
+ Bytes: M.string(),
11
+ Endpoint: M.string(),
12
+ Vow: M.tagged(
13
+ 'Vow',
14
+ harden({
15
+ vowV0: M.remotable('VowV0'),
16
+ }),
17
+ ),
18
+ ConnectionHandler: M.remotable('ConnectionHandler'),
19
+ Connection: M.remotable('Connection'),
20
+ InboundAttempt: M.remotable('InboundAttempt'),
21
+ Listener: M.remotable('Listener'),
22
+ ListenHandler: M.remotable('ListenHandler'),
23
+ Port: M.remotable('Port'),
24
+ ProtocolHandler: M.remotable('ProtocolHandler'),
25
+ ProtocolImpl: M.remotable('ProtocolImpl'),
26
+ });
27
+
28
+ export const SendOptionsShape = M.splitRecord(
29
+ {},
30
+ { relativeTimeoutNs: M.bigint() },
31
+ );
32
+
33
+ const Shape2 = /** @type {const} */ ({
34
+ ...Shape1,
35
+ Vow$: shape => M.or(shape, Shape1.Vow),
36
+ AttemptDescription: M.splitRecord(
37
+ { handler: Shape1.ConnectionHandler },
38
+ { remoteAddress: Shape1.Endpoint, localAddress: Shape1.Endpoint },
39
+ ),
40
+ Opts: SendOptionsShape,
41
+ });
42
+
43
+ export const Shape = /** @type {const} */ harden({
44
+ ...Shape2,
45
+ ConnectionI: {
46
+ connection: M.interface('Connection', {
47
+ send: M.callWhen(Shape2.Data)
48
+ .optional(Shape2.Opts)
49
+ .returns(Shape2.Vow$(Shape2.Bytes)),
50
+ close: M.callWhen().returns(Shape2.Vow$(M.undefined())),
51
+ getLocalAddress: M.call().returns(Shape2.Endpoint),
52
+ getRemoteAddress: M.call().returns(Shape2.Endpoint),
53
+ }),
54
+ openConnectionAckWatcher: M.interface('OpenConnectionAckWatcher', {
55
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
56
+ }),
57
+ rethrowUnlessMissingWatcher: M.interface('RethrowUnlessMissingWatcher', {
58
+ onRejected: M.call(M.any()).rest(M.any()).returns(M.any()),
59
+ }),
60
+ sinkWatcher: M.interface('SinkWatcher', {
61
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(),
62
+ }),
63
+ },
64
+ InboundAttemptI: {
65
+ inboundAttempt: M.interface('InboundAttempt', {
66
+ accept: M.callWhen(Shape2.AttemptDescription).returns(
67
+ Shape2.Vow$(Shape2.Connection),
68
+ ),
69
+ getLocalAddress: M.call().returns(Shape2.Endpoint),
70
+ getRemoteAddress: M.call().returns(Shape2.Endpoint),
71
+ close: M.callWhen().returns(Shape2.Vow$(M.undefined())),
72
+ }),
73
+ inboundAttemptAcceptWatcher: M.interface('InboundAttemptAcceptWatcher', {
74
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
75
+ }),
76
+ rethrowUnlessMissingWatcher: M.interface('RethrowUnlessMissingWatcher', {
77
+ onRejected: M.call(M.any()).rest(M.any()).returns(M.any()),
78
+ }),
79
+ sinkWatcher: M.interface('SinkWatcher', {
80
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(),
81
+ }),
82
+ },
83
+ PortI: {
84
+ port: M.interface('Port', {
85
+ getLocalAddress: M.call().returns(Shape2.Endpoint),
86
+ addListener: M.callWhen(Shape2.Listener).returns(
87
+ Shape2.Vow$(M.undefined()),
88
+ ),
89
+ connect: M.callWhen(Shape2.Endpoint)
90
+ .optional(Shape2.ConnectionHandler)
91
+ .returns(Shape2.Vow$(Shape2.Connection)),
92
+ removeListener: M.callWhen(Shape2.Listener).returns(
93
+ Shape2.Vow$(M.undefined()),
94
+ ),
95
+ revoke: M.callWhen().returns(Shape2.Vow$(M.undefined())),
96
+ }),
97
+ portAddListenerWatcher: M.interface('PortAddListenerWatcher', {
98
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
99
+ }),
100
+ portRemoveListenerWatcher: M.interface('PortRemoveListenerWatcher', {
101
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
102
+ }),
103
+ portConnectWatcher: M.interface('PortConnectWatcher', {
104
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
105
+ }),
106
+ portRevokeWatcher: M.interface('PortRevokeWatcher', {
107
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
108
+ }),
109
+ portRevokeCleanupWatcher: M.interface('PortRevokeCleanupWatcher', {
110
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
111
+ }),
112
+ rethrowUnlessMissingWatcher: M.interface('RethrowUnlessMissingWatcher', {
113
+ onRejected: M.call(M.any()).rest(M.any()).returns(M.any()),
114
+ }),
115
+ sinkWatcher: M.interface('SinkWatcher', {
116
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(),
117
+ onRejected: M.call(M.any()).rest(M.any()).returns(M.any()),
118
+ }),
119
+ },
120
+ ProtocolHandlerI: {
121
+ protocolHandler: M.interface('ProtocolHandler', {
122
+ onCreate: M.callWhen(M.remotable(), Shape2.ProtocolHandler).returns(
123
+ Shape2.Vow$(M.undefined()),
124
+ ),
125
+ generatePortID: M.callWhen(
126
+ Shape2.Endpoint,
127
+ Shape2.ProtocolHandler,
128
+ ).returns(Shape2.Vow$(M.string())),
129
+ onBind: M.callWhen(
130
+ Shape2.Port,
131
+ Shape2.Endpoint,
132
+ Shape2.ProtocolHandler,
133
+ ).returns(Shape2.Vow$(M.undefined())),
134
+ onListen: M.callWhen(
135
+ Shape2.Port,
136
+ Shape2.Endpoint,
137
+ Shape2.ListenHandler,
138
+ Shape2.ProtocolHandler,
139
+ ).returns(Shape2.Vow$(M.undefined())),
140
+ onListenRemove: M.callWhen(
141
+ Shape2.Port,
142
+ Shape2.Endpoint,
143
+ Shape2.ListenHandler,
144
+ Shape2.ProtocolHandler,
145
+ ).returns(Shape2.Vow$(M.undefined())),
146
+ onInstantiate: M.callWhen(
147
+ Shape2.Port,
148
+ Shape2.Endpoint,
149
+ Shape2.Endpoint,
150
+ Shape2.ProtocolHandler,
151
+ ).returns(Shape2.Vow$(Shape2.Endpoint)),
152
+ onConnect: M.callWhen(
153
+ Shape2.Port,
154
+ Shape2.Endpoint,
155
+ Shape2.Endpoint,
156
+ Shape2.ConnectionHandler,
157
+ Shape2.ProtocolHandler,
158
+ ).returns(Shape2.Vow$(Shape2.AttemptDescription)),
159
+ onRevoke: M.callWhen(
160
+ Shape2.Port,
161
+ Shape2.Endpoint,
162
+ Shape2.ProtocolHandler,
163
+ ).returns(Shape2.Vow$(M.undefined())),
164
+ }),
165
+ protocolHandlerAcceptWatcher: M.interface('ProtocolHandlerAcceptWatcher', {
166
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
167
+ }),
168
+ protocolHandlerInstantiateWatcher: M.interface(
169
+ 'ProtocolHandlerInstantiateWatcher',
170
+ {
171
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
172
+ },
173
+ ),
174
+ protocolHandlerConnectWatcher: M.interface(
175
+ 'ProtocolHandlerConnectWatcher',
176
+ {
177
+ onFulfilled: M.call(M.any()).rest(M.any()).returns(M.any()),
178
+ },
179
+ ),
180
+ rethrowUnlessMissingWatcher: M.interface('RethrowUnlessMissingWatcher', {
181
+ onRejected: M.call(M.any()).rest(M.any()).returns(M.any()),
182
+ }),
183
+ },
184
+
185
+ ProtocolImplI: M.interface('ProtocolImpl', {
186
+ bindPort: M.callWhen(Shape2.Endpoint).returns(Shape2.Vow$(Shape2.Port)),
187
+ inbound: M.callWhen(Shape2.Endpoint, Shape2.Endpoint).returns(
188
+ Shape2.Vow$(Shape2.InboundAttempt),
189
+ ),
190
+ outbound: M.callWhen(
191
+ Shape2.Port,
192
+ Shape2.Endpoint,
193
+ Shape2.ConnectionHandler,
194
+ ).returns(Shape2.Vow$(Shape2.Connection)),
195
+ }),
196
+ });