@midsummer-ai/sdk 0.0.0-stage → 0.1.0-next.1723
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/LICENSE +177 -0
- package/README.md +4 -2
- package/agents/contract.d.mts +9 -0
- package/agents/contract.mjs +221 -0
- package/agents/index.d.mts +128 -0
- package/agents/index.mjs +203 -0
- package/agents/stand-in.d.mts +35 -0
- package/agents/stand-in.mjs +149 -0
- package/ai/contract.d.mts +10 -0
- package/ai/contract.mjs +77 -0
- package/ai/index.d.mts +94 -0
- package/ai/index.mjs +193 -0
- package/ai/stand-in.d.mts +7 -0
- package/ai/stand-in.mjs +41 -0
- package/build-SQ44jwSa.d.mts +41 -0
- package/client.d.mts +45 -0
- package/client.mjs +106 -0
- package/connection-BHjDaLYA.mjs +2009 -0
- package/contract.d.mts +10 -0
- package/contract.mjs +469 -0
- package/database/build.d.mts +2 -0
- package/database/build.mjs +579 -0
- package/database/client.d.mts +60 -0
- package/database/client.mjs +133 -0
- package/database/contract.d.mts +11 -0
- package/database/contract.mjs +164 -0
- package/database/errors.d.mts +23 -0
- package/database/errors.mjs +13 -0
- package/database/server.d.mts +3 -0
- package/database/server.mjs +320 -0
- package/database/stand-in.d.mts +99 -0
- package/database/stand-in.mjs +430 -0
- package/email/client.d.mts +34 -0
- package/email/client.mjs +131 -0
- package/email/contract.d.mts +11 -0
- package/email/contract.mjs +99 -0
- package/email/index.d.mts +74 -0
- package/email/index.mjs +59 -0
- package/email/smtp.d.mts +22 -0
- package/email/smtp.mjs +296 -0
- package/email/stand-in.d.mts +13 -0
- package/email/stand-in.mjs +51 -0
- package/index-DdoK0y7D.d.mts +192 -0
- package/index-sgdyoA2P.d.mts +212 -0
- package/index.d.mts +2 -0
- package/index.mjs +137 -0
- package/names-DfCBKupJ.mjs +115 -0
- package/package.json +152 -4
- package/predict-Drfm_8pO.mjs +179 -0
- package/queues/contract.d.mts +13 -0
- package/queues/contract.mjs +278 -0
- package/queues/index.d.mts +184 -0
- package/queues/index.mjs +126 -0
- package/queues/stand-in.d.mts +7 -0
- package/queues/stand-in.mjs +110 -0
- package/queues/wire.d.mts +9 -0
- package/queues/wire.mjs +199 -0
- package/s3.d.mts +43 -0
- package/s3.mjs +1003 -0
- package/schema-BF-Y1EVu.mjs +142 -0
- package/schema-DS8x1Dn8.mjs +115 -0
- package/schema-f7E9uzUn.d.mts +74 -0
- package/server-C7O7CICU.d.mts +182 -0
- package/socket.d.mts +67 -0
- package/socket.mjs +263 -0
- package/stand-in.d.mts +7 -0
- package/stand-in.mjs +185 -0
- package/store-BA8K-bAR.mjs +237 -0
- package/tabs-DEeMee7M.mjs +457 -0
- package/vector/contract.d.mts +10 -0
- package/vector/contract.mjs +635 -0
- package/vector/index.d.mts +2 -0
- package/vector/index.mjs +108 -0
- package/vector/stand-in.d.mts +11 -0
- package/vector/stand-in.mjs +169 -0
- package/vector/wire.d.mts +25 -0
- package/vector/wire.mjs +175 -0
- package/wire.d.mts +54 -0
- package/wire.mjs +731 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { t as Connection } from "./connection-BHjDaLYA.mjs";
|
|
2
|
+
//#region src/database/client/tabs.mjs
|
|
3
|
+
/** Argument index of the options that take a `tag` (a tab tags its own writes: the same tag after a handover). */
|
|
4
|
+
const TAGGED = {
|
|
5
|
+
set: 3,
|
|
6
|
+
take: 4,
|
|
7
|
+
mutation: 2
|
|
8
|
+
};
|
|
9
|
+
const CALLS = /* @__PURE__ */ new Set([
|
|
10
|
+
"get",
|
|
11
|
+
"set",
|
|
12
|
+
"take",
|
|
13
|
+
"mutation",
|
|
14
|
+
"query",
|
|
15
|
+
"range",
|
|
16
|
+
"upload",
|
|
17
|
+
"refreshDir",
|
|
18
|
+
"renew"
|
|
19
|
+
]);
|
|
20
|
+
/** The JSON options that open the shared Connection. */
|
|
21
|
+
const OPEN = [
|
|
22
|
+
"token",
|
|
23
|
+
"units",
|
|
24
|
+
"edges",
|
|
25
|
+
"home",
|
|
26
|
+
"q",
|
|
27
|
+
"silent",
|
|
28
|
+
"window",
|
|
29
|
+
"budgetMs",
|
|
30
|
+
"tables",
|
|
31
|
+
"cacheRows",
|
|
32
|
+
"subscribeAfter",
|
|
33
|
+
"subscribeWindowMs"
|
|
34
|
+
];
|
|
35
|
+
const rid = () => Math.random().toString(36).slice(2, 10);
|
|
36
|
+
const locks = () => typeof navigator !== "undefined" ? navigator.locks : void 0;
|
|
37
|
+
/** Holds Web Lock `name` until the returned release is called; resolves once granted. */
|
|
38
|
+
const hold = (name) => new Promise((granted) => {
|
|
39
|
+
locks().request(name, () => new Promise((release) => granted(release)));
|
|
40
|
+
});
|
|
41
|
+
const errorOf = (e) => ({
|
|
42
|
+
message: String(e?.message ?? e),
|
|
43
|
+
code: e?.code,
|
|
44
|
+
answer: e?.answer
|
|
45
|
+
});
|
|
46
|
+
const rebuild = (e) => Object.assign(new Error(e.message), e.code !== void 0 ? { code: e.code } : {}, e.answer !== void 0 ? { answer: e.answer } : {});
|
|
47
|
+
/** The side that owns the one Connection: answers tabs' calls, holds their watches, tells them the Connection's state. */
|
|
48
|
+
var TabsHost = class {
|
|
49
|
+
/** `local`: Connection options that cannot cross a port (store, functions, refresh). */
|
|
50
|
+
constructor(local = {}) {
|
|
51
|
+
this.local = local;
|
|
52
|
+
this.ready = null;
|
|
53
|
+
this.conn = null;
|
|
54
|
+
this.tabs = /* @__PURE__ */ new Map();
|
|
55
|
+
this.asks = /* @__PURE__ */ new Map();
|
|
56
|
+
}
|
|
57
|
+
/** One message from tab `tab`; `post` answers that tab. */
|
|
58
|
+
async handle(tab, msg, post) {
|
|
59
|
+
if (msg.hello) return this.hello(tab, msg.hello, post);
|
|
60
|
+
const t = this.tabs.get(tab);
|
|
61
|
+
if (!t) return;
|
|
62
|
+
if (msg.bye) {
|
|
63
|
+
this.drop(tab);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (msg.refreshed !== void 0) {
|
|
67
|
+
const ask = this.asks.get(msg.refreshed);
|
|
68
|
+
this.asks.delete(msg.refreshed);
|
|
69
|
+
if (ask) msg.error ? ask.fail(rebuild(msg.error)) : ask.ok(msg.token);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (msg.unsub !== void 0) {
|
|
73
|
+
t.subs.get(msg.unsub)?.();
|
|
74
|
+
t.subs.delete(msg.unsub);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let g;
|
|
78
|
+
try {
|
|
79
|
+
g = await this.open();
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (msg.id !== void 0) t.post({
|
|
82
|
+
id: msg.id,
|
|
83
|
+
error: errorOf(e)
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!this.tabs.has(tab)) return;
|
|
88
|
+
if (msg.sub !== void 0) {
|
|
89
|
+
if (t.subs.has(msg.id)) return;
|
|
90
|
+
const args = [...msg.args];
|
|
91
|
+
args[msg.at] = (view, meta) => t.post({
|
|
92
|
+
s: msg.id,
|
|
93
|
+
view,
|
|
94
|
+
meta: meta && typeof meta === "object" ? { stale: !!meta.stale } : void 0
|
|
95
|
+
});
|
|
96
|
+
t.subs.set(msg.id, g[msg.sub](...args));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (CALLS.has(msg.call)) try {
|
|
100
|
+
t.post({
|
|
101
|
+
id: msg.id,
|
|
102
|
+
value: await g[msg.call](...msg.args)
|
|
103
|
+
});
|
|
104
|
+
} catch (e) {
|
|
105
|
+
t.post({
|
|
106
|
+
id: msg.id,
|
|
107
|
+
error: errorOf(e)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
hello(tab, { url, opts, refresh }, post) {
|
|
112
|
+
const known = this.tabs.get(tab);
|
|
113
|
+
if (known) Object.assign(known, {
|
|
114
|
+
post,
|
|
115
|
+
refresh
|
|
116
|
+
});
|
|
117
|
+
else {
|
|
118
|
+
this.tabs.set(tab, {
|
|
119
|
+
post,
|
|
120
|
+
subs: /* @__PURE__ */ new Map(),
|
|
121
|
+
refresh
|
|
122
|
+
});
|
|
123
|
+
if (locks() && !this.self?.has(tab)) hold(`db-tab:${tab}`).then((release) => {
|
|
124
|
+
release();
|
|
125
|
+
this.drop(tab);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
this.first ??= {
|
|
129
|
+
url,
|
|
130
|
+
opts
|
|
131
|
+
};
|
|
132
|
+
this.open().then(() => post({ state: this.state() }), (e) => post({
|
|
133
|
+
state: null,
|
|
134
|
+
error: errorOf(e)
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
/** The Connection, opened by the first tab's options (again after a failed open). */
|
|
138
|
+
open() {
|
|
139
|
+
if (!this.ready) {
|
|
140
|
+
const { url, opts } = this.first;
|
|
141
|
+
const refresh = this.local.refresh ?? (opts.refresh ? () => this.askRefresh() : null);
|
|
142
|
+
this.ready = Connection.open(url, {
|
|
143
|
+
...opts,
|
|
144
|
+
...this.local,
|
|
145
|
+
refresh,
|
|
146
|
+
shape: "browser"
|
|
147
|
+
}).then((g) => {
|
|
148
|
+
this.conn = g;
|
|
149
|
+
const tell = () => {
|
|
150
|
+
const s = { state: this.state() };
|
|
151
|
+
for (const t of this.tabs.values()) t.post(s);
|
|
152
|
+
};
|
|
153
|
+
g.dirListeners.add(tell);
|
|
154
|
+
this.ticker = setInterval(tell, 1e3);
|
|
155
|
+
this.ticker.unref?.();
|
|
156
|
+
return g;
|
|
157
|
+
}, (e) => {
|
|
158
|
+
this.ready = null;
|
|
159
|
+
throw e;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return this.ready;
|
|
163
|
+
}
|
|
164
|
+
state() {
|
|
165
|
+
const g = this.conn;
|
|
166
|
+
return g ? {
|
|
167
|
+
dir: g.dir,
|
|
168
|
+
esc: g.esc,
|
|
169
|
+
token: g.token,
|
|
170
|
+
stats: { ...g.stats }
|
|
171
|
+
} : null;
|
|
172
|
+
}
|
|
173
|
+
/** A new token from a tab that has `refresh`. */
|
|
174
|
+
askRefresh() {
|
|
175
|
+
const t = [...this.tabs.values()].reverse().find((x) => x.refresh);
|
|
176
|
+
if (!t) return Promise.reject(/* @__PURE__ */ new Error("no tab can refresh the token"));
|
|
177
|
+
const id = rid();
|
|
178
|
+
return new Promise((ok, fail) => {
|
|
179
|
+
this.asks.set(id, {
|
|
180
|
+
ok,
|
|
181
|
+
fail
|
|
182
|
+
});
|
|
183
|
+
t.post({ refresh: id });
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/** A tab gone: its watches stop (a subscription other tabs share stays). */
|
|
187
|
+
drop(tab) {
|
|
188
|
+
const t = this.tabs.get(tab);
|
|
189
|
+
if (!t) return;
|
|
190
|
+
this.tabs.delete(tab);
|
|
191
|
+
for (const stop of t.subs.values()) stop();
|
|
192
|
+
}
|
|
193
|
+
close() {
|
|
194
|
+
clearInterval(this.ticker);
|
|
195
|
+
this.conn?.close();
|
|
196
|
+
return this.conn?.store?.close?.();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
var ConnectionTabs = class ConnectionTabs {
|
|
200
|
+
/** A Connection shared by every tab of this browser (see the top of this file); a plain Connection where tabs cannot share. */
|
|
201
|
+
static async connect(url, options) {
|
|
202
|
+
const shared = options.worker && typeof SharedWorker === "function";
|
|
203
|
+
if (!shared && !(locks() && typeof BroadcastChannel === "function")) return Connection.open(url, {
|
|
204
|
+
...options,
|
|
205
|
+
shape: "browser"
|
|
206
|
+
});
|
|
207
|
+
const t = new ConnectionTabs(url, options);
|
|
208
|
+
await t.start(shared);
|
|
209
|
+
return t;
|
|
210
|
+
}
|
|
211
|
+
constructor(url, options) {
|
|
212
|
+
this.url = url;
|
|
213
|
+
this.options = options;
|
|
214
|
+
this.name = options.name ?? new URL(url).host;
|
|
215
|
+
this.id = rid();
|
|
216
|
+
this.n = 0;
|
|
217
|
+
this.tagN = 0;
|
|
218
|
+
this.base = url.replace(/^ws/u, "http");
|
|
219
|
+
this.token = options.token ?? "";
|
|
220
|
+
this.units = 1;
|
|
221
|
+
this.dir = null;
|
|
222
|
+
this.calls = /* @__PURE__ */ new Map();
|
|
223
|
+
this.subs = /* @__PURE__ */ new Map();
|
|
224
|
+
this.link = null;
|
|
225
|
+
this.closed = false;
|
|
226
|
+
}
|
|
227
|
+
async start(shared) {
|
|
228
|
+
this.releaseTab = locks() ? await hold(`db-tab:${this.id}`) : null;
|
|
229
|
+
if (typeof addEventListener === "function") addEventListener("pagehide", () => this.post({ bye: true }));
|
|
230
|
+
const first = new Promise((ok, fail) => {
|
|
231
|
+
this.started = {
|
|
232
|
+
ok,
|
|
233
|
+
fail
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
if (shared) {
|
|
237
|
+
const sw = new SharedWorker(this.options.worker, {
|
|
238
|
+
type: "module",
|
|
239
|
+
name: `db:${this.name}`
|
|
240
|
+
});
|
|
241
|
+
this.port = sw.port;
|
|
242
|
+
this.port.onmessage = (e) => this.received(e.data);
|
|
243
|
+
this.port.start?.();
|
|
244
|
+
this.attach((m) => this.port.postMessage(m));
|
|
245
|
+
} else this.elect();
|
|
246
|
+
return first;
|
|
247
|
+
}
|
|
248
|
+
/** Leader mode: wait for the lock (then lead); meanwhile follow whoever leads. */
|
|
249
|
+
elect() {
|
|
250
|
+
this.channel = new BroadcastChannel(`db-tabs:${this.name}`);
|
|
251
|
+
this.channel.onmessage = (e) => this.heard(e.data);
|
|
252
|
+
locks().request(`db-leader:${this.name}`, () => this.lead());
|
|
253
|
+
this.channel.postMessage({ who: true });
|
|
254
|
+
}
|
|
255
|
+
heard(m) {
|
|
256
|
+
if (m.who && this.host) this.channel.postMessage({ leader: this.id });
|
|
257
|
+
else if (m.leader && m.leader !== this.leaderId && !this.host) {
|
|
258
|
+
this.leaderId = m.leader;
|
|
259
|
+
this.attach((msg) => this.channel.postMessage({
|
|
260
|
+
to: m.leader,
|
|
261
|
+
from: this.id,
|
|
262
|
+
msg
|
|
263
|
+
}));
|
|
264
|
+
} else if (m.to === this.id && m.msg) this.host ? this.host.handle(m.from, m.msg, (x) => this.channel.postMessage({
|
|
265
|
+
to: m.from,
|
|
266
|
+
from: this.id,
|
|
267
|
+
msg: x
|
|
268
|
+
})) : this.received(m.msg);
|
|
269
|
+
}
|
|
270
|
+
/** This tab leads: its own Connection, its own calls straight to it; the others are told. */
|
|
271
|
+
lead() {
|
|
272
|
+
if (this.closed) return void 0;
|
|
273
|
+
const { worker: _w, name: _n, ...local } = this.options;
|
|
274
|
+
this.host = new TabsHost(local);
|
|
275
|
+
this.host.self = /* @__PURE__ */ new Set([this.id]);
|
|
276
|
+
this.leaderId = this.id;
|
|
277
|
+
this.attach((msg) => this.host.handle(this.id, msg, (x) => queueMicrotask(() => this.received(x))));
|
|
278
|
+
this.channel.postMessage({ leader: this.id });
|
|
279
|
+
return new Promise((stepDown) => {
|
|
280
|
+
this.stepDown = stepDown;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/** A new owner of the Connection: hello, then every watch and unanswered call again (same ids, same tags). */
|
|
284
|
+
attach(link) {
|
|
285
|
+
this.link = link;
|
|
286
|
+
const o = this.options;
|
|
287
|
+
link({
|
|
288
|
+
hello: {
|
|
289
|
+
url: this.url,
|
|
290
|
+
opts: Object.fromEntries(OPEN.filter((k) => o[k] !== void 0).map((k) => [k, o[k]])),
|
|
291
|
+
refresh: !!o.refresh
|
|
292
|
+
},
|
|
293
|
+
tab: this.id
|
|
294
|
+
});
|
|
295
|
+
for (const s of this.subs.values()) link(s.msg);
|
|
296
|
+
for (const c of this.calls.values()) link(c.msg);
|
|
297
|
+
}
|
|
298
|
+
post(msg) {
|
|
299
|
+
this.link?.(msg);
|
|
300
|
+
}
|
|
301
|
+
received(m) {
|
|
302
|
+
if (m.state !== void 0) {
|
|
303
|
+
if (m.state) {
|
|
304
|
+
this.dir = m.state.dir;
|
|
305
|
+
this.esc = m.state.esc;
|
|
306
|
+
this.token = m.state.token;
|
|
307
|
+
this.stats = m.state.stats;
|
|
308
|
+
this.started?.ok();
|
|
309
|
+
} else this.started?.fail(rebuild(m.error));
|
|
310
|
+
this.started = null;
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (m.s !== void 0) {
|
|
314
|
+
this.subs.get(m.s)?.listener(m.view, m.meta);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (m.refresh !== void 0) {
|
|
318
|
+
Promise.resolve().then(() => this.options.refresh()).then((token) => this.post({
|
|
319
|
+
refreshed: m.refresh,
|
|
320
|
+
token
|
|
321
|
+
}), (e) => this.post({
|
|
322
|
+
refreshed: m.refresh,
|
|
323
|
+
error: errorOf(e)
|
|
324
|
+
}));
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const c = this.calls.get(m.id);
|
|
328
|
+
if (!c) return;
|
|
329
|
+
this.calls.delete(m.id);
|
|
330
|
+
if (m.error) c.fail(rebuild(m.error));
|
|
331
|
+
else c.ok(m.value);
|
|
332
|
+
}
|
|
333
|
+
call(name, args) {
|
|
334
|
+
if (TAGGED[name] !== void 0) {
|
|
335
|
+
const k = TAGGED[name];
|
|
336
|
+
args = [...args];
|
|
337
|
+
while (args.length < k) args.push(void 0);
|
|
338
|
+
args[k] = {
|
|
339
|
+
...args[k] ?? {},
|
|
340
|
+
tag: args[k]?.tag ?? `${this.id}:${this.tagN += 1}`
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const msg = {
|
|
344
|
+
id: this.n += 1,
|
|
345
|
+
call: name,
|
|
346
|
+
args
|
|
347
|
+
};
|
|
348
|
+
return new Promise((ok, fail) => {
|
|
349
|
+
this.calls.set(msg.id, {
|
|
350
|
+
msg,
|
|
351
|
+
ok,
|
|
352
|
+
fail
|
|
353
|
+
});
|
|
354
|
+
this.post(msg);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
sub(name, args, at, listener) {
|
|
358
|
+
const a = [...args];
|
|
359
|
+
a[at] = null;
|
|
360
|
+
const msg = {
|
|
361
|
+
id: this.n += 1,
|
|
362
|
+
sub: name,
|
|
363
|
+
args: a,
|
|
364
|
+
at
|
|
365
|
+
};
|
|
366
|
+
this.subs.set(msg.id, {
|
|
367
|
+
msg,
|
|
368
|
+
listener
|
|
369
|
+
});
|
|
370
|
+
this.post(msg);
|
|
371
|
+
return () => {
|
|
372
|
+
if (this.subs.delete(msg.id)) this.post({ unsub: msg.id });
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
get(...a) {
|
|
376
|
+
return this.call("get", a);
|
|
377
|
+
}
|
|
378
|
+
set(...a) {
|
|
379
|
+
return this.call("set", a);
|
|
380
|
+
}
|
|
381
|
+
take(...a) {
|
|
382
|
+
return this.call("take", a);
|
|
383
|
+
}
|
|
384
|
+
mutation(...a) {
|
|
385
|
+
return this.call("mutation", a);
|
|
386
|
+
}
|
|
387
|
+
query(...a) {
|
|
388
|
+
return this.call("query", a);
|
|
389
|
+
}
|
|
390
|
+
range(...a) {
|
|
391
|
+
return this.call("range", a);
|
|
392
|
+
}
|
|
393
|
+
upload(...a) {
|
|
394
|
+
return this.call("upload", a);
|
|
395
|
+
}
|
|
396
|
+
refreshDir() {
|
|
397
|
+
return this.call("refreshDir", []);
|
|
398
|
+
}
|
|
399
|
+
renew(reopen) {
|
|
400
|
+
return this.call("renew", [reopen]);
|
|
401
|
+
}
|
|
402
|
+
watch(q, unit, listener) {
|
|
403
|
+
return this.sub("watch", [q, unit], 2, listener);
|
|
404
|
+
}
|
|
405
|
+
watchRow(tb, id, listener) {
|
|
406
|
+
return this.sub("watchRow", [tb, id], 2, listener);
|
|
407
|
+
}
|
|
408
|
+
watchRange(tb, index, o, listener, options) {
|
|
409
|
+
return this.sub("watchRange", [
|
|
410
|
+
tb,
|
|
411
|
+
index,
|
|
412
|
+
o,
|
|
413
|
+
null,
|
|
414
|
+
options
|
|
415
|
+
], 3, listener);
|
|
416
|
+
}
|
|
417
|
+
watchQuery(name, args, options, listener) {
|
|
418
|
+
return this.sub("watchQuery", [
|
|
419
|
+
name,
|
|
420
|
+
args,
|
|
421
|
+
options
|
|
422
|
+
], 3, listener);
|
|
423
|
+
}
|
|
424
|
+
watchQueryAll(name, args, listener) {
|
|
425
|
+
return this.sub("watchQueryAll", [name, args], 2, listener);
|
|
426
|
+
}
|
|
427
|
+
everyUnit(q, onParts) {
|
|
428
|
+
return this.sub("everyUnit", [q], 1, onParts);
|
|
429
|
+
}
|
|
430
|
+
unitOf(id) {
|
|
431
|
+
return Connection.prototype.unitOf.call(this, id);
|
|
432
|
+
}
|
|
433
|
+
unitNames() {
|
|
434
|
+
return Connection.prototype.unitNames.call(this);
|
|
435
|
+
}
|
|
436
|
+
auth() {
|
|
437
|
+
return Connection.prototype.auth.call(this);
|
|
438
|
+
}
|
|
439
|
+
fileUrl(id) {
|
|
440
|
+
return Connection.prototype.fileUrl.call(this, id);
|
|
441
|
+
}
|
|
442
|
+
/** This tab leaves: its watches stop; a leader hands the Connection to the next tab (after its store is written). */
|
|
443
|
+
async close() {
|
|
444
|
+
if (this.closed) return;
|
|
445
|
+
this.closed = true;
|
|
446
|
+
this.post({ bye: true });
|
|
447
|
+
if (this.host) {
|
|
448
|
+
await this.host.close();
|
|
449
|
+
this.stepDown?.();
|
|
450
|
+
}
|
|
451
|
+
this.channel?.close();
|
|
452
|
+
this.port?.close?.();
|
|
453
|
+
this.releaseTab?.();
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
//#endregion
|
|
457
|
+
export { ConnectionTabs };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { g as VectorEngine, m as VectorControl } from "../index-DdoK0y7D.mjs";
|
|
2
|
+
//#region src/vector/contract.d.ts
|
|
3
|
+
interface VectorContractCase {
|
|
4
|
+
/** A line of the specification. */
|
|
5
|
+
readonly name: string;
|
|
6
|
+
run(engine: VectorEngine & VectorControl): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
declare const vectorContract: ReadonlyArray<VectorContractCase>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { VectorContractCase, vectorContract };
|