@northtalk/ts 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +55 -2
- package/UNICODE-LICENSE.txt +39 -0
- package/core-eU5KaYkz.d.ts +23 -0
- package/debug-D8Z_u244.d.ts +2698 -0
- package/debug.d.ts +2 -0
- package/debug.js +1 -0
- package/driver.d.ts +27 -0
- package/driver.js +74 -0
- package/encoding-DWlbPq-e.js +7792 -0
- package/engine-BPFnHT9N.d.ts +86 -0
- package/engine-CgCMdGGd.js +324 -0
- package/errors-DHwz1Vho.js +3661 -0
- package/group-B4eyJKTA.js +15958 -0
- package/index.d.ts +645 -0
- package/index.js +37 -0
- package/manifest-DKe2Je6Z.js +208 -0
- package/notify.d.ts +2 -0
- package/notify.js +1 -0
- package/objects-MeXIDDFo.d.ts +625 -0
- package/package.json +62 -4
- package/readers-DyjxJEkL.js +479 -0
- package/readers-Oh4tO2dK.d.ts +57 -0
- package/router-DHPJNvbt.js +341 -0
- package/router-DpDpAJjz.d.ts +54 -0
- package/session.d.ts +8 -0
- package/session.js +3476 -0
- package/setup.d.ts +2 -0
- package/setup.js +189 -0
- package/sha256-0jiTgVJu.js +123 -0
- package/sqlite-capability-C7-SYdD7.d.ts +87 -0
- package/sqlite-capability-CrCej3Po.js +478 -0
- package/sqlite.d.ts +75 -0
- package/sqlite.js +528 -0
- package/store-DrYjcoru.js +59 -0
- package/store-capability-CDoVafZL.js +387 -0
- package/store.d.ts +20 -0
- package/store.js +3 -0
- package/user-capability-CLkDsrCX.d.ts +40 -0
- package/user-capability-Cv0oJhhv.js +273 -0
- package/wasm.d.ts +223 -0
- package/wasm.js +1453 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { S as instant, V as text, c as bool, i as ScriptError, j as nothing, k as map, t as HostError } from "./errors-DHwz1Vho.js";
|
|
2
|
+
import { a as validComputedMessageName, f as arithmetic, ft as errorMessages, r as registerStandardChecks, u as ScriptError$1, vt as defineCapability, xt as shape } from "./encoding-DWlbPq-e.js";
|
|
3
|
+
//#region src/standard-capabilities.ts
|
|
4
|
+
const costOf = (costs, name) => {
|
|
5
|
+
const cost = costs && Object.hasOwn(costs, name) ? costs[name] : void 0;
|
|
6
|
+
if (!cost || !Number.isSafeInteger(cost.fuel) || cost.fuel < 0 || cost.alloc !== void 0 && (!Number.isSafeInteger(cost.alloc) || cost.alloc < 0)) throw new HostError("invalid value", `Invalid or missing cost for ${name}`);
|
|
7
|
+
return Object.freeze({
|
|
8
|
+
fuel: cost.fuel,
|
|
9
|
+
...cost.alloc === void 0 ? {} : { alloc: cost.alloc }
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
const fixed = (capability) => {
|
|
13
|
+
for (const op of capability.operations.values()) {
|
|
14
|
+
Object.freeze(op.args);
|
|
15
|
+
Object.freeze(op.errors);
|
|
16
|
+
Object.freeze(op);
|
|
17
|
+
}
|
|
18
|
+
return capability;
|
|
19
|
+
};
|
|
20
|
+
const instantShape = Object.freeze({
|
|
21
|
+
k: "kind",
|
|
22
|
+
kind: "instant"
|
|
23
|
+
});
|
|
24
|
+
const textShape$1 = Object.freeze({
|
|
25
|
+
k: "kind",
|
|
26
|
+
kind: "text"
|
|
27
|
+
});
|
|
28
|
+
const valueShape = Object.freeze({ k: "value" });
|
|
29
|
+
const dataListShape = Object.freeze({
|
|
30
|
+
k: "list",
|
|
31
|
+
of: Object.freeze({ k: "any" })
|
|
32
|
+
});
|
|
33
|
+
/** The Pump's Clock reading; there is no Host clock implementation. */
|
|
34
|
+
const clockCapability = (costs) => fixed(defineCapability("clock", { now: {
|
|
35
|
+
mode: "immediate",
|
|
36
|
+
args: [],
|
|
37
|
+
result: instantShape,
|
|
38
|
+
errors: [],
|
|
39
|
+
cost: costOf(costs, "now"),
|
|
40
|
+
do: (call) => instant(call.now)
|
|
41
|
+
} }));
|
|
42
|
+
/** The Host owns durable timers, scoped by Script and name. */
|
|
43
|
+
const timerCapability = (impl, costs) => {
|
|
44
|
+
if (!impl || typeof impl.schedule !== "function" || typeof impl.cancel !== "function") throw new HostError("invalid value", "Timer needs Schedule and Cancel");
|
|
45
|
+
return fixed(defineCapability("timer", {
|
|
46
|
+
schedule: {
|
|
47
|
+
mode: "fire-and-forget",
|
|
48
|
+
args: [
|
|
49
|
+
textShape$1,
|
|
50
|
+
instantShape,
|
|
51
|
+
textShape$1,
|
|
52
|
+
dataListShape
|
|
53
|
+
],
|
|
54
|
+
errors: [],
|
|
55
|
+
cost: costOf(costs, "schedule"),
|
|
56
|
+
fire: (call, name, at, message, args) => impl.schedule(call, name.asText(), at, message.asText(), args)
|
|
57
|
+
},
|
|
58
|
+
cancel: {
|
|
59
|
+
mode: "fire-and-forget",
|
|
60
|
+
args: [textShape$1],
|
|
61
|
+
errors: [],
|
|
62
|
+
cost: costOf(costs, "cancel"),
|
|
63
|
+
fire: (call, name) => impl.cancel(call, name.asText())
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
/** The Host shows Values in text form and answers read with a line of text. */
|
|
68
|
+
const consoleCapability = (impl, costs) => {
|
|
69
|
+
if (!impl || typeof impl.write !== "function" || typeof impl.read !== "function") throw new HostError("invalid value", "Console needs Write and Read");
|
|
70
|
+
return fixed(defineCapability("console", {
|
|
71
|
+
write: {
|
|
72
|
+
mode: "fire-and-forget",
|
|
73
|
+
args: [valueShape],
|
|
74
|
+
errors: [],
|
|
75
|
+
cost: costOf(costs, "write"),
|
|
76
|
+
fire: (call, value) => impl.write(call, value)
|
|
77
|
+
},
|
|
78
|
+
read: {
|
|
79
|
+
mode: "suspending",
|
|
80
|
+
args: [],
|
|
81
|
+
result: textShape$1,
|
|
82
|
+
errors: [],
|
|
83
|
+
maxPendingMs: 2147483647,
|
|
84
|
+
cost: costOf(costs, "read"),
|
|
85
|
+
start: (call) => impl.read(call)
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
const civilShape = Object.freeze({
|
|
90
|
+
k: "kind",
|
|
91
|
+
kind: "civil date"
|
|
92
|
+
});
|
|
93
|
+
const optionalTextShape = Object.freeze({
|
|
94
|
+
k: "optional",
|
|
95
|
+
of: textShape$1
|
|
96
|
+
});
|
|
97
|
+
const secondsShape = Object.freeze({
|
|
98
|
+
k: "quantity",
|
|
99
|
+
unit: "s"
|
|
100
|
+
});
|
|
101
|
+
const disambiguations = /* @__PURE__ */ new Set([
|
|
102
|
+
"compatible",
|
|
103
|
+
"earlier",
|
|
104
|
+
"later",
|
|
105
|
+
"reject"
|
|
106
|
+
]);
|
|
107
|
+
const zoneText = (value) => value?.asText();
|
|
108
|
+
const calendarError = (code, data) => data.get("zone").kind === "text" && (code === "unknown zone" || code === "ambiguous time" && data.get("civil").kind === "civil date");
|
|
109
|
+
const checkToInstant = (args) => {
|
|
110
|
+
const civil = args[0];
|
|
111
|
+
const disambiguation = zoneText(args[1]);
|
|
112
|
+
const bad = !("hour" in civil.asCivilDate()) ? civil : args.length === 3 && disambiguation !== void 0 && !disambiguations.has(disambiguation) ? args[1] : void 0;
|
|
113
|
+
if (bad) throw new ScriptError$1("out of domain", [["function", text("toInstant")], ["value", bad]], true);
|
|
114
|
+
};
|
|
115
|
+
/** The Host owns zone data; the Grant binding supplies its default zone. */
|
|
116
|
+
const calendarCapability = (impl, costs) => {
|
|
117
|
+
for (const name of [
|
|
118
|
+
"today",
|
|
119
|
+
"now",
|
|
120
|
+
"toCivil",
|
|
121
|
+
"toInstant",
|
|
122
|
+
"offset",
|
|
123
|
+
"zone"
|
|
124
|
+
]) if (!impl || typeof impl[name] !== "function") throw new HostError("invalid value", `Calendar needs ${name}`);
|
|
125
|
+
const unknownZone = [{
|
|
126
|
+
code: "unknown zone",
|
|
127
|
+
fields: { zone: textShape$1 }
|
|
128
|
+
}];
|
|
129
|
+
const operations = {
|
|
130
|
+
today: {
|
|
131
|
+
mode: "immediate",
|
|
132
|
+
args: [optionalTextShape],
|
|
133
|
+
result: civilShape,
|
|
134
|
+
errors: unknownZone,
|
|
135
|
+
cost: costOf(costs, "today"),
|
|
136
|
+
do: (call, zone) => impl.today(call, zoneText(zone))
|
|
137
|
+
},
|
|
138
|
+
now: {
|
|
139
|
+
mode: "immediate",
|
|
140
|
+
args: [optionalTextShape],
|
|
141
|
+
result: civilShape,
|
|
142
|
+
errors: unknownZone,
|
|
143
|
+
cost: costOf(costs, "now"),
|
|
144
|
+
do: (call, zone) => impl.now(call, zoneText(zone))
|
|
145
|
+
},
|
|
146
|
+
toCivil: {
|
|
147
|
+
mode: "immediate",
|
|
148
|
+
args: [instantShape, optionalTextShape],
|
|
149
|
+
result: civilShape,
|
|
150
|
+
errors: unknownZone,
|
|
151
|
+
cost: costOf(costs, "toCivil"),
|
|
152
|
+
do: (call, value, zone) => impl.toCivil(call, value, zoneText(zone))
|
|
153
|
+
},
|
|
154
|
+
toInstant: {
|
|
155
|
+
mode: "immediate",
|
|
156
|
+
args: [
|
|
157
|
+
civilShape,
|
|
158
|
+
optionalTextShape,
|
|
159
|
+
optionalTextShape
|
|
160
|
+
],
|
|
161
|
+
result: instantShape,
|
|
162
|
+
errors: [...unknownZone, {
|
|
163
|
+
code: "ambiguous time",
|
|
164
|
+
fields: {
|
|
165
|
+
civil: civilShape,
|
|
166
|
+
zone: textShape$1
|
|
167
|
+
}
|
|
168
|
+
}],
|
|
169
|
+
cost: costOf(costs, "toInstant"),
|
|
170
|
+
do: (call, ...args) => {
|
|
171
|
+
const second = zoneText(args[1]);
|
|
172
|
+
const isZone = args.length === 2 && second !== void 0 && !disambiguations.has(second);
|
|
173
|
+
return impl.toInstant(call, args[0], isZone ? "compatible" : second ?? "compatible", isZone ? second : zoneText(args[2]));
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
offset: {
|
|
177
|
+
mode: "immediate",
|
|
178
|
+
args: [instantShape, optionalTextShape],
|
|
179
|
+
result: secondsShape,
|
|
180
|
+
errors: unknownZone,
|
|
181
|
+
cost: costOf(costs, "offset"),
|
|
182
|
+
do: (call, value, zone) => impl.offset(call, value, zoneText(zone))
|
|
183
|
+
},
|
|
184
|
+
zone: {
|
|
185
|
+
mode: "immediate",
|
|
186
|
+
args: [optionalTextShape],
|
|
187
|
+
result: textShape$1,
|
|
188
|
+
errors: unknownZone,
|
|
189
|
+
cost: costOf(costs, "zone"),
|
|
190
|
+
do: (call, zone) => impl.zone(call, zoneText(zone))
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
for (const [name, op] of Object.entries(operations)) registerStandardChecks(op, {
|
|
194
|
+
error: calendarError,
|
|
195
|
+
...name === "toInstant" ? { arguments: checkToInstant } : {},
|
|
196
|
+
...[
|
|
197
|
+
"today",
|
|
198
|
+
"now",
|
|
199
|
+
"toCivil"
|
|
200
|
+
].includes(name) ? { result: (value) => !("hour" in value.asCivilDate()) === (name === "today") } : {}
|
|
201
|
+
});
|
|
202
|
+
return fixed(defineCapability("calendar", operations));
|
|
203
|
+
};
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/store-capability.ts
|
|
206
|
+
/** A Core-raised error as the Host sees it, with its catalogue message. */
|
|
207
|
+
const hostScriptError = (code, fields) => {
|
|
208
|
+
const message = (errorMessages[code] ?? code).replaceAll(/{(\w+)}/g, (_, name) => {
|
|
209
|
+
const field = fields.find(([k]) => k === name);
|
|
210
|
+
return field ? field[1].toString() : `{${name}}`;
|
|
211
|
+
});
|
|
212
|
+
return new ScriptError(code, message, map(fields.map(([k, v]) => [k, v])));
|
|
213
|
+
};
|
|
214
|
+
/** The `+` rules outside any Run, uncharged (chapter 9, Adding). */
|
|
215
|
+
const add = (a, b) => {
|
|
216
|
+
try {
|
|
217
|
+
return arithmetic("add", a, b);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
throw error instanceof ScriptError$1 ? hostScriptError(error.code, error.fields) : error;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const textShape = shape.text;
|
|
223
|
+
const keyShape = textShape;
|
|
224
|
+
const amountShape = shape.oneOf(shape.number, {
|
|
225
|
+
k: "kind",
|
|
226
|
+
kind: "quantity"
|
|
227
|
+
});
|
|
228
|
+
const OPERATIONS = [
|
|
229
|
+
"get",
|
|
230
|
+
"set",
|
|
231
|
+
"delete",
|
|
232
|
+
"keys",
|
|
233
|
+
"increment",
|
|
234
|
+
"swap",
|
|
235
|
+
"watch",
|
|
236
|
+
"unwatch"
|
|
237
|
+
];
|
|
238
|
+
const isText = (data, field) => data.get(field).kind === "text";
|
|
239
|
+
const errorFields = {
|
|
240
|
+
"can't store": (data) => isText(data, "kind"),
|
|
241
|
+
"store full": (data) => [
|
|
242
|
+
"size",
|
|
243
|
+
"keys",
|
|
244
|
+
"value"
|
|
245
|
+
].includes(data.get("limit").asText() ?? ""),
|
|
246
|
+
"store busy": (data) => isText(data, "key"),
|
|
247
|
+
"watch limit": (data) => [
|
|
248
|
+
"watches",
|
|
249
|
+
"size",
|
|
250
|
+
"pending"
|
|
251
|
+
].includes(data.get("limit").asText() ?? ""),
|
|
252
|
+
"wrong kind": (data) => isText(data, "expected") && isText(data, "got") && data.entries().some(([k]) => k === "value"),
|
|
253
|
+
"incompatible units": (data) => isText(data, "left") && isText(data, "right"),
|
|
254
|
+
overflow: (data) => isText(data, "operator")
|
|
255
|
+
};
|
|
256
|
+
const checkKey = (args) => {
|
|
257
|
+
if (args[0].asText() === "") throw new ScriptError$1("invalid key", [], true);
|
|
258
|
+
};
|
|
259
|
+
const effectiveMessage = (args) => args[2]?.asText() ?? "storeChanged";
|
|
260
|
+
const checkUnwatch = (args) => {
|
|
261
|
+
if (args[0].asText() === "") throw new ScriptError$1("invalid watch", [["field", text("name")]], true);
|
|
262
|
+
};
|
|
263
|
+
const checkWatch = (args) => {
|
|
264
|
+
checkUnwatch(args);
|
|
265
|
+
const message = effectiveMessage(args);
|
|
266
|
+
if (message.includes(":") || !validComputedMessageName(message, 1)) throw new ScriptError$1("invalid watch", [["field", text("message")]], true);
|
|
267
|
+
};
|
|
268
|
+
const argumentChecks = {
|
|
269
|
+
watch: checkWatch,
|
|
270
|
+
unwatch: checkUnwatch
|
|
271
|
+
};
|
|
272
|
+
const errors = (...codes) => codes.map((code) => ({ code }));
|
|
273
|
+
const writes = [
|
|
274
|
+
"can't store",
|
|
275
|
+
"store full",
|
|
276
|
+
"store busy"
|
|
277
|
+
];
|
|
278
|
+
const key = (args) => args[0].asText();
|
|
279
|
+
/** The Store is the Host's; the Grant binding names it, and `impl` coordinates every binding. */
|
|
280
|
+
const storeCapability = (impl, costs) => {
|
|
281
|
+
for (const name of [
|
|
282
|
+
...OPERATIONS,
|
|
283
|
+
"begin",
|
|
284
|
+
"commit",
|
|
285
|
+
"rollback",
|
|
286
|
+
"release"
|
|
287
|
+
]) if (!impl || typeof impl[name] !== "function") throw new HostError("invalid value", `Store needs ${name}`);
|
|
288
|
+
const operations = {
|
|
289
|
+
watch: {
|
|
290
|
+
mode: "immediate",
|
|
291
|
+
args: [
|
|
292
|
+
textShape,
|
|
293
|
+
textShape,
|
|
294
|
+
shape.optional(textShape)
|
|
295
|
+
],
|
|
296
|
+
result: shape.nothing,
|
|
297
|
+
errors: errors("watch limit"),
|
|
298
|
+
cost: costOf(costs, "watch"),
|
|
299
|
+
do: (call, ...args) => {
|
|
300
|
+
impl.watch(call, key(args), args[1].asText(), effectiveMessage(args));
|
|
301
|
+
return nothing;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
unwatch: {
|
|
305
|
+
mode: "immediate",
|
|
306
|
+
args: [textShape],
|
|
307
|
+
result: shape.nothing,
|
|
308
|
+
errors: [],
|
|
309
|
+
cost: costOf(costs, "unwatch"),
|
|
310
|
+
do: (call, ...args) => {
|
|
311
|
+
impl.unwatch(call, key(args));
|
|
312
|
+
return nothing;
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
get: {
|
|
316
|
+
mode: "immediate",
|
|
317
|
+
args: [keyShape, shape.optional(shape.any)],
|
|
318
|
+
result: shape.any,
|
|
319
|
+
errors: [],
|
|
320
|
+
cost: costOf(costs, "get"),
|
|
321
|
+
do: (call, ...args) => impl.get(call, key(args), args[1])
|
|
322
|
+
},
|
|
323
|
+
set: {
|
|
324
|
+
mode: "immediate",
|
|
325
|
+
args: [keyShape, shape.any],
|
|
326
|
+
result: shape.nothing,
|
|
327
|
+
errors: errors(...writes),
|
|
328
|
+
cost: costOf(costs, "set"),
|
|
329
|
+
segmentBound: true,
|
|
330
|
+
do: (call, ...args) => {
|
|
331
|
+
impl.set(call, key(args), args[1]);
|
|
332
|
+
return nothing;
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
delete: {
|
|
336
|
+
mode: "immediate",
|
|
337
|
+
args: [keyShape],
|
|
338
|
+
result: shape.nothing,
|
|
339
|
+
errors: errors("store busy"),
|
|
340
|
+
cost: costOf(costs, "delete"),
|
|
341
|
+
segmentBound: true,
|
|
342
|
+
do: (call, ...args) => {
|
|
343
|
+
impl.delete(call, key(args));
|
|
344
|
+
return nothing;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
keys: {
|
|
348
|
+
mode: "immediate",
|
|
349
|
+
args: [shape.optional(textShape)],
|
|
350
|
+
result: shape.listOf(textShape),
|
|
351
|
+
errors: [],
|
|
352
|
+
cost: costOf(costs, "keys"),
|
|
353
|
+
do: (call, prefix) => impl.keys(call, prefix?.asText())
|
|
354
|
+
},
|
|
355
|
+
increment: {
|
|
356
|
+
mode: "immediate",
|
|
357
|
+
args: [keyShape, shape.optional(amountShape)],
|
|
358
|
+
result: amountShape,
|
|
359
|
+
errors: errors("wrong kind", "incompatible units", "overflow", "store full", "store busy"),
|
|
360
|
+
cost: costOf(costs, "increment"),
|
|
361
|
+
segmentBound: true,
|
|
362
|
+
do: (call, ...args) => impl.increment(call, key(args), args[1])
|
|
363
|
+
},
|
|
364
|
+
swap: {
|
|
365
|
+
mode: "immediate",
|
|
366
|
+
args: [
|
|
367
|
+
keyShape,
|
|
368
|
+
shape.any,
|
|
369
|
+
shape.any
|
|
370
|
+
],
|
|
371
|
+
result: shape.bool,
|
|
372
|
+
errors: errors(...writes),
|
|
373
|
+
cost: costOf(costs, "swap"),
|
|
374
|
+
segmentBound: true,
|
|
375
|
+
do: (call, ...args) => bool(impl.swap(call, key(args), args[1], args[2]))
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const coordinator = impl;
|
|
379
|
+
const capability = defineCapability("store", operations, { coordinator: () => coordinator }, (context) => impl.release(context));
|
|
380
|
+
for (const [name, op] of capability.operations) registerStandardChecks(op, {
|
|
381
|
+
error: (code, data) => Boolean(op.errors?.some((e) => e.code === code) && errorFields[code]?.(data)),
|
|
382
|
+
...name === "keys" ? {} : { arguments: argumentChecks[name] ?? checkKey }
|
|
383
|
+
});
|
|
384
|
+
return fixed(capability);
|
|
385
|
+
};
|
|
386
|
+
//#endregion
|
|
387
|
+
export { clockCapability as a, fixed as c, calendarCapability as i, timerCapability as l, hostScriptError as n, consoleCapability as o, storeCapability as r, costOf as s, add as t };
|
package/store.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { n as RouterOptions } from "./router-DpDpAJjz.js";
|
|
2
|
+
import { a as Stores, c as sessionQuotas, i as StoreStateUnknownError, l as sessionWatchLimits, n as StoreContentsError, o as decodeContents, r as StoreQuotas, s as encodeContents, t as StoreBackend } from "./engine-BPFnHT9N.js";
|
|
3
|
+
//#region src/store/memory.d.ts
|
|
4
|
+
/** A backend that keeps nothing outside the engine's own copy. */
|
|
5
|
+
export declare const memoryBackend: () => StoreBackend;
|
|
6
|
+
/**
|
|
7
|
+
* Stores kept only in memory, each starting empty. `admitted` is told after
|
|
8
|
+
* each Notification a Group admits.
|
|
9
|
+
*/
|
|
10
|
+
export declare const memoryStores: (quotas: StoreQuotas, admitted?: RouterOptions["admitted"]) => Stores;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/store/web-storage.d.ts
|
|
13
|
+
/** The part of the Web Storage `Storage` interface a Store uses. */
|
|
14
|
+
type WebStorage = Pick<Storage, 'getItem' | 'removeItem' | 'setItem'>;
|
|
15
|
+
/** Each Store under the item `prefix` + its name. */
|
|
16
|
+
export declare const webStorageBackend: (storage: WebStorage, prefix?: string) => StoreBackend;
|
|
17
|
+
/** Stores kept in Web Storage, under items named `prefix` + the Store's name. */
|
|
18
|
+
export declare const webStorageStores: (storage: WebStorage, quotas: StoreQuotas, prefix?: string) => Stores;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { type StoreBackend, StoreContentsError, type StoreQuotas, StoreStateUnknownError, Stores, type WebStorage, decodeContents, encodeContents, sessionQuotas, sessionWatchLimits };
|
package/store.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-CgCMdGGd.js";
|
|
2
|
+
import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-DrYjcoru.js";
|
|
3
|
+
export { StoreContentsError, StoreStateUnknownError, Stores, decodeContents, encodeContents, memoryBackend, memoryStores, sessionQuotas, sessionWatchLimits, webStorageBackend, webStorageStores };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { At as Call, Yt as SegmentLifecycle, at as Value, jt as CapabilityDef, zt as GrantContext } from "./debug-D8Z_u244.js";
|
|
2
|
+
import { d as Costs } from "./sqlite-capability-C7-SYdD7.js";
|
|
3
|
+
//#region src/store-capability.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The binding is the Store's name. `set`, `delete`, `increment` and `swap`
|
|
6
|
+
* act on the calling Segment's pending writes, to every Store it writes,
|
|
7
|
+
* which `commit` applies together and `rollback` discards (chapter 7,
|
|
8
|
+
* ADR 0062). The implementation is the Segment Coordinator of every binding,
|
|
9
|
+
* so its hooks see each enrolled Store's Grant (ADR 0069). Watch registrations
|
|
10
|
+
* are final at the call, independent of the participant, and release drops
|
|
11
|
+
* their owner when the named Grant stops being effective (ADR 0061).
|
|
12
|
+
*/
|
|
13
|
+
type StoreImpl = SegmentLifecycle<string> & {
|
|
14
|
+
delete(call: Call<string>, key: string): void;
|
|
15
|
+
get(call: Call<string>, key: string, fallback?: Value): Value;
|
|
16
|
+
increment(call: Call<string>, key: string, by?: Value): Value;
|
|
17
|
+
keys(call: Call<string>, prefix?: string): Value;
|
|
18
|
+
release(context: GrantContext<string>): void;
|
|
19
|
+
set(call: Call<string>, key: string, value: Value): void;
|
|
20
|
+
swap(call: Call<string>, key: string, expected: Value, replacement: Value): boolean;
|
|
21
|
+
unwatch(call: Call<string>, name: string): void;
|
|
22
|
+
watch(call: Call<string>, name: string, prefix: string, message: string): void;
|
|
23
|
+
};
|
|
24
|
+
/** The `+` rules outside any Run, uncharged (chapter 9, Adding). */
|
|
25
|
+
declare const add: (a: Value, b: Value) => Value;
|
|
26
|
+
/** The Store is the Host's; the Grant binding names it, and `impl` coordinates every binding. */
|
|
27
|
+
declare const storeCapability: (impl: StoreImpl, costs: Costs) => CapabilityDef<string>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/user-capability.d.ts
|
|
30
|
+
/** An omitted prompt, default or title is "". */
|
|
31
|
+
type UserImpl = {
|
|
32
|
+
choose(call: Call<unknown>, items: readonly string[], prompt: string, multiple: boolean): void;
|
|
33
|
+
confirm(call: Call<unknown>, message: string): void;
|
|
34
|
+
enter(call: Call<unknown>, message: string, fallback: string): void;
|
|
35
|
+
notify(call: Call<unknown>, message: string, title: string): void;
|
|
36
|
+
};
|
|
37
|
+
/** Optional for Hosts. The binding is ignored. */
|
|
38
|
+
declare const userCapability: (impl: UserImpl, costs: Costs) => CapabilityDef<unknown>;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { storeCapability as a, add as i, userCapability as n, StoreImpl as r, UserImpl as t };
|