@northtalk/ts 0.9.0 → 0.10.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.
Files changed (51) hide show
  1. package/{binary-value-B93hEK7l.d.ts → binary-value-B8W4W_e1.d.ts} +1 -1
  2. package/{checker-D74oYIhs.js → checker-hkWO1UbN.js} +1 -1
  3. package/{core-BBPI6EhG.d.ts → core-Dwec7SRy.d.ts} +1 -1
  4. package/{debug-s6QIovKS.d.ts → debug-2yfUZYzF.d.ts} +7 -0
  5. package/debug.d.ts +1 -1
  6. package/{driver-D5yrK3Nu.d.ts → driver-CT-ksM-N.d.ts} +1 -1
  7. package/driver.d.ts +1 -1
  8. package/{encoding-DzVFpg7k.js → encoding-DlMqlP2Y.js} +1 -1
  9. package/{engine-Bx8B63iQ.js → engine-CxcONfhv.js} +4 -4
  10. package/{engine-Dy-BCoiw.d.ts → engine-DP_lqWfI.d.ts} +2 -2
  11. package/{group-CY4FKhzT.js → group--dcl0em8.js} +80 -21
  12. package/{http-fetch-DnpfiOWK.js → http-fetch-CLAeEXVi.js} +1 -1
  13. package/http.d.ts +1 -1
  14. package/http.js +2 -2
  15. package/index.d.ts +4 -4
  16. package/index.js +11 -11
  17. package/{lean-DTCTJUmR.js → lean-BtbKWkXA.js} +8 -8
  18. package/{lean-Bg_UTRj0.d.ts → lean-DU_muGpT.d.ts} +2 -2
  19. package/lean.d.ts +4 -4
  20. package/lean.js +11 -11
  21. package/{manifest-DVS1SEmN.js → manifest-CRpUahPt.js} +2 -2
  22. package/message-layer.d.ts +2 -2
  23. package/message-layer.js +1 -1
  24. package/notify.d.ts +1 -1
  25. package/notify.js +1 -1
  26. package/{objects-q0lnCK-4.d.ts → objects-DoyEohtr.d.ts} +1 -1
  27. package/{operations-B3XaG7Ve.js → operations-DrsedOvj.js} +3 -3
  28. package/package.json +1 -1
  29. package/{peer-capability-3etyPHs3.js → peer-capability-RMdN4OHj.js} +2 -2
  30. package/peer.d.ts +1 -1
  31. package/peer.js +2 -2
  32. package/{readers-AeB1bJ--.d.ts → readers-IhVpgXkj.d.ts} +1 -1
  33. package/{request-pump-binary-VOPVqRZD.js → request-pump-binary-P8m6kLfB.js} +229 -51
  34. package/{router-DXoJ_2Z4.d.ts → router-2vjYbqx3.d.ts} +2 -2
  35. package/{router-Bdm4KiMG.js → router-C_Fjc2as.js} +4 -4
  36. package/session.d.ts +2 -2
  37. package/session.js +17 -16
  38. package/setup.d.ts +2 -2
  39. package/setup.js +3 -3
  40. package/sha256-C5Lqj5U7.js +197 -0
  41. package/sqlite.d.ts +2 -2
  42. package/sqlite.js +3 -3
  43. package/{store-BTcyKBLg.js → store-_af2DPoK.js} +2 -2
  44. package/{store-capability-CBJ6mUoH.js → store-capability-Db6v_dw9.js} +2 -2
  45. package/store.d.ts +2 -2
  46. package/store.js +2 -2
  47. package/{user-capability-DNY2dyjq.js → user-capability-CzoLN3RK.js} +2 -2
  48. package/wasm.d.ts +4 -4
  49. package/wasm.js +84 -44
  50. package/{zone-rules-DsCJtmlC.js → zone-rules-Cn-f9u_Z.js} +3 -3
  51. package/sha256-9CGf5BS_.js +0 -168
package/session.js CHANGED
@@ -1,17 +1,17 @@
1
1
 
2
2
  import { H as num, J as range, L as map, P as listValues, Qt as parseInstant, V as nothing, i as ScriptError, it as text, l as Value, n as LoadError, nn as characterBoundaries, on as lower, pn as builtins, qt as formatInstant, t as HostError, u as bool } from "./errors-CNc-xY_9.js";
3
- import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group-CY4FKhzT.js";
3
+ import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group--dcl0em8.js";
4
4
  import { o as stateOf, t as defineObjectKind } from "./objects-OKVLH190.js";
5
- import { Dt as shape, Et as operationDeclarations, H as textForm$1, U as waitUs, jt as validStaticMessageName, tt as functionHead, ut as compareText, x as integerValue, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
6
- import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-D74oYIhs.js";
7
- import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-DVS1SEmN.js";
5
+ import { Dt as shape, Et as operationDeclarations, H as textForm$1, U as waitUs, jt as validStaticMessageName, tt as functionHead, ut as compareText, x as integerValue, xt as defineValueCapability } from "./operations-DrsedOvj.js";
6
+ import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-hkWO1UbN.js";
7
+ import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-CRpUahPt.js";
8
8
  import { c as readDisplay, l as readOrderedJSON, r as decodeValue } from "./readers-G1lHqrPl.js";
9
- import { a as clockCapability, i as calendarCapability, n as quoteJSON, o as consoleCapability, t as encodeValue } from "./encoding-DzVFpg7k.js";
10
- import { n as localeCapability, t as userCapability } from "./user-capability-DNY2dyjq.js";
11
- import { r as storeCapability } from "./store-capability-CBJ6mUoH.js";
9
+ import { a as clockCapability, i as calendarCapability, n as quoteJSON, o as consoleCapability, t as encodeValue } from "./encoding-DlMqlP2Y.js";
10
+ import { n as localeCapability, t as userCapability } from "./user-capability-CzoLN3RK.js";
11
+ import { r as storeCapability } from "./store-capability-Db6v_dw9.js";
12
12
  import { buildSetupGroup, capabilityOperations, immutableSetup, shapeOf } from "./setup.js";
13
- import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
14
- import { i as memoryStores } from "./store-BTcyKBLg.js";
13
+ import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-CxcONfhv.js";
14
+ import { i as memoryStores } from "./store-_af2DPoK.js";
15
15
  //#region src/session/objects.ts
16
16
  const externalCollection = () => {
17
17
  throw new Error("external collection callback in replay");
@@ -502,16 +502,13 @@ var SessionObjects = class {
502
502
  }
503
503
  preload() {
504
504
  this.registrations();
505
- if (this.nextType() !== "setup") {
506
- if (this.replay?.length) malformed("missing setup");
507
- return {};
508
- }
505
+ if (this.nextType() !== "setup") return {};
509
506
  const e = this.consume("setup");
510
507
  return Object.fromEntries(Object.entries(recordObject(e.objects)).map(([name, o]) => [name, this.objectRef(o)]));
511
508
  }
512
509
  initial(bindings) {
513
510
  if (this.replay) return;
514
- if (!this.enabled) return;
511
+ if (!this.enabled || Object.keys(bindings).length === 0) return;
515
512
  this.emit({
516
513
  type: "setup",
517
514
  objects: Object.fromEntries(Object.entries(bindings).map(([k, o]) => [k, {
@@ -2731,12 +2728,16 @@ var SessionHost = class {
2731
2728
  if (word === "advance") {
2732
2729
  if (this.virtual === null) refuse("clock is real");
2733
2730
  let us;
2731
+ let negative;
2734
2732
  try {
2735
- us = waitUs(display(arg));
2733
+ const duration = display(arg);
2734
+ us = waitUs(duration);
2735
+ const amount = duration.asQuantityRef().number.toString();
2736
+ negative = amount.startsWith("-") && /[1-9]/.test(amount.split("e")[0]);
2736
2737
  } catch {
2737
2738
  return refuse("bad arguments");
2738
2739
  }
2739
- if (us < 0n) refuse("bad arguments");
2740
+ if (negative) refuse("bad arguments");
2740
2741
  this.virtual += us;
2741
2742
  return this.pump();
2742
2743
  }
package/setup.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { Qt as operationDeclarations } from "./debug-s6QIovKS.js";
3
- import { A as shapeOf, C as Setup, D as capabilityOperations, E as buildSetupGroup, M as tsCore, O as immutableSetup, S as OperationSpec, T as ShapeSpec, b as MissingCapabilityError, j as shapeSpec, k as musicalClockOf, w as SetupGroup, x as ObjectRefSpec, y as CaseCore } from "./objects-q0lnCK-4.js";
2
+ import { Qt as operationDeclarations } from "./debug-2yfUZYzF.js";
3
+ import { A as shapeOf, C as Setup, D as capabilityOperations, E as buildSetupGroup, M as tsCore, O as immutableSetup, S as OperationSpec, T as ShapeSpec, b as MissingCapabilityError, j as shapeSpec, k as musicalClockOf, w as SetupGroup, x as ObjectRefSpec, y as CaseCore } from "./objects-DoyEohtr.js";
4
4
  export { CaseCore, MissingCapabilityError, ObjectRefSpec, OperationSpec, Setup, SetupGroup, ShapeSpec, buildSetupGroup, capabilityOperations, immutableSetup, musicalClockOf, operationDeclarations, shapeOf, shapeSpec, tsCore };
package/setup.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
2
  import { n as LoadError } from "./errors-CNc-xY_9.js";
3
- import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group-CY4FKhzT.js";
3
+ import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group--dcl0em8.js";
4
4
  import { t as defineObjectKind } from "./objects-OKVLH190.js";
5
- import { Dt as shape, Et as operationDeclarations } from "./operations-B3XaG7Ve.js";
6
- import { r as MUSICAL_CLOCK } from "./encoding-DzVFpg7k.js";
5
+ import { Dt as shape, Et as operationDeclarations } from "./operations-DrsedOvj.js";
6
+ import { r as MUSICAL_CLOCK } from "./encoding-DlMqlP2Y.js";
7
7
  //#region src/setup.ts
8
8
  const tsCore = {
9
9
  compileLibrary,
@@ -0,0 +1,197 @@
1
+
2
+ //#region src/sha256.ts
3
+ const K = new Uint32Array([
4
+ 1116352408,
5
+ 1899447441,
6
+ 3049323471,
7
+ 3921009573,
8
+ 961987163,
9
+ 1508970993,
10
+ 2453635748,
11
+ 2870763221,
12
+ 3624381080,
13
+ 310598401,
14
+ 607225278,
15
+ 1426881987,
16
+ 1925078388,
17
+ 2162078206,
18
+ 2614888103,
19
+ 3248222580,
20
+ 3835390401,
21
+ 4022224774,
22
+ 264347078,
23
+ 604807628,
24
+ 770255983,
25
+ 1249150122,
26
+ 1555081692,
27
+ 1996064986,
28
+ 2554220882,
29
+ 2821834349,
30
+ 2952996808,
31
+ 3210313671,
32
+ 3336571891,
33
+ 3584528711,
34
+ 113926993,
35
+ 338241895,
36
+ 666307205,
37
+ 773529912,
38
+ 1294757372,
39
+ 1396182291,
40
+ 1695183700,
41
+ 1986661051,
42
+ 2177026350,
43
+ 2456956037,
44
+ 2730485921,
45
+ 2820302411,
46
+ 3259730800,
47
+ 3345764771,
48
+ 3516065817,
49
+ 3600352804,
50
+ 4094571909,
51
+ 275423344,
52
+ 430227734,
53
+ 506948616,
54
+ 659060556,
55
+ 883997877,
56
+ 958139571,
57
+ 1322822218,
58
+ 1537002063,
59
+ 1747873779,
60
+ 1955562222,
61
+ 2024104815,
62
+ 2227730452,
63
+ 2361852424,
64
+ 2428436474,
65
+ 2756734187,
66
+ 3204031479,
67
+ 3329325298
68
+ ]);
69
+ const rotr = (x, n) => x >>> n | x << 32 - n;
70
+ const initial = [
71
+ 1779033703,
72
+ 3144134277,
73
+ 1013904242,
74
+ 2773480762,
75
+ 1359893119,
76
+ 2600822924,
77
+ 528734635,
78
+ 1541459225
79
+ ];
80
+ const w = /* @__PURE__ */ new Uint32Array(64);
81
+ /** One 64-byte block of `view` at `block`, folded into `h`. */
82
+ const compress = (h, view, block) => {
83
+ for (let i = 0; i < 16; i++) w[i] = view.getUint32(block + i * 4);
84
+ for (let i = 16; i < 64; i++) {
85
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
86
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
87
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
88
+ }
89
+ let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
90
+ for (let i = 0; i < 64; i++) {
91
+ const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
92
+ const ch = e & f ^ ~e & g;
93
+ const t1 = hh + s1 + ch + K[i] + w[i] >>> 0;
94
+ const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
95
+ hh = g;
96
+ g = f;
97
+ f = e;
98
+ e = d + t1 >>> 0;
99
+ d = c;
100
+ c = b;
101
+ b = a;
102
+ a = t1 + t2 >>> 0;
103
+ }
104
+ h[0] = h[0] + a >>> 0;
105
+ h[1] = h[1] + b >>> 0;
106
+ h[2] = h[2] + c >>> 0;
107
+ h[3] = h[3] + d >>> 0;
108
+ h[4] = h[4] + e >>> 0;
109
+ h[5] = h[5] + f >>> 0;
110
+ h[6] = h[6] + g >>> 0;
111
+ h[7] = h[7] + hh >>> 0;
112
+ };
113
+ /** An incremental SHA-256: `update` with bytes, then `final` once. */
114
+ var Sha256 = class {
115
+ h = new Uint32Array(initial);
116
+ block = /* @__PURE__ */ new Uint8Array(64);
117
+ blockView = new DataView(this.block.buffer);
118
+ filled = 0;
119
+ length = 0;
120
+ done = false;
121
+ update(bytes) {
122
+ if (this.done) throw new Error("Sha256.update after final");
123
+ this.length += bytes.length;
124
+ let at = 0;
125
+ if (this.filled > 0) {
126
+ const take = Math.min(64 - this.filled, bytes.length);
127
+ this.block.set(bytes.subarray(0, take), this.filled);
128
+ this.filled += take;
129
+ at = take;
130
+ if (this.filled < 64) return this;
131
+ compress(this.h, this.blockView, 0);
132
+ this.filled = 0;
133
+ }
134
+ const whole = at + Math.floor((bytes.length - at) / 64) * 64;
135
+ if (whole > at) {
136
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
137
+ for (; at < whole; at += 64) compress(this.h, view, at);
138
+ }
139
+ this.block.set(bytes.subarray(at));
140
+ this.filled = bytes.length - at;
141
+ return this;
142
+ }
143
+ /** The 32-byte digest; the hash takes no more input after it. */
144
+ final() {
145
+ if (this.done) throw new Error("Sha256.final twice");
146
+ this.done = true;
147
+ return wordBytes(finish(this.h, this.block, this.filled, this.length));
148
+ }
149
+ };
150
+ /**
151
+ * Pads the last `filled` bytes of `tail`, of `length` bytes hashed in all,
152
+ * and compresses them into `h`, which it returns.
153
+ */
154
+ const finish = (h, tail, filled, length) => {
155
+ const padded = new Uint8Array(filled < 56 ? 64 : 128);
156
+ padded.set(tail.subarray(0, filled));
157
+ padded[filled] = 128;
158
+ const view = new DataView(padded.buffer);
159
+ view.setUint32(padded.length - 8, Math.floor(length / 536870912));
160
+ view.setUint32(padded.length - 4, length * 8 >>> 0);
161
+ for (let at = 0; at < padded.length; at += 64) compress(h, view, at);
162
+ return h;
163
+ };
164
+ /**
165
+ * All of `bytes` hashed at once, as the eight state words. Every Load hashes
166
+ * a code identity, so this skips `Sha256`'s block buffering (#2230).
167
+ */
168
+ const digest = (bytes) => {
169
+ const h = new Uint32Array(initial);
170
+ const whole = bytes.length - bytes.length % 64;
171
+ if (whole > 0) {
172
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
173
+ for (let at = 0; at < whole; at += 64) compress(h, view, at);
174
+ }
175
+ return finish(h, bytes.subarray(whole), bytes.length - whole, bytes.length);
176
+ };
177
+ const wordBytes = (h) => {
178
+ const out = /* @__PURE__ */ new Uint8Array(32);
179
+ const view = new DataView(out.buffer);
180
+ for (let i = 0; i < 8; i++) view.setUint32(i * 4, h[i]);
181
+ return out;
182
+ };
183
+ const encoder = new TextEncoder();
184
+ const hex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
185
+ /** The SHA-256 of `bytes`, as 32 bytes. */
186
+ const sha256Bytes = (bytes) => wordBytes(digest(bytes));
187
+ const sha256 = (input) => {
188
+ const h = digest(typeof input === "string" ? encoder.encode(input) : input);
189
+ let out = "";
190
+ for (let i = 0; i < 8; i++) {
191
+ const x = h[i];
192
+ out += hex[x >>> 24] + hex[x >>> 16 & 255] + hex[x >>> 8 & 255] + hex[x & 255];
193
+ }
194
+ return out;
195
+ };
196
+ //#endregion
197
+ export { sha256 as n, sha256Bytes as r, Sha256 as t };
package/sqlite.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { Wt as SegmentCoordinator, _n as SqlParams, bn as SqliteBinding, bt as Call, mn as StoreImpl, vn as SqlRows, xn as SqliteImpl } from "./debug-s6QIovKS.js";
3
- import { a as Stores, r as StoreQuotas } from "./engine-Dy-BCoiw.js";
2
+ import { Wt as SegmentCoordinator, _n as SqlParams, bn as SqliteBinding, bt as Call, mn as StoreImpl, vn as SqlRows, xn as SqliteImpl } from "./debug-2yfUZYzF.js";
3
+ import { a as Stores, r as StoreQuotas } from "./engine-DP_lqWfI.js";
4
4
  //#region src/sqlite/database.d.ts
5
5
  /** The table that keeps a database's Stores, which no `sqlite` Grant may use. */
6
6
  export declare const STORE_TABLE = "store";
package/sqlite.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
2
  import { b as dec, it as text, t as HostError } from "./errors-CNc-xY_9.js";
3
3
  import { r as decodeValue } from "./readers-G1lHqrPl.js";
4
- import { t as encodeValue } from "./encoding-DzVFpg7k.js";
5
- import { n as hostScriptError } from "./store-capability-CBJ6mUoH.js";
6
- import { r as Stores, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
4
+ import { t as encodeValue } from "./encoding-DlMqlP2Y.js";
5
+ import { n as hostScriptError } from "./store-capability-Db6v_dw9.js";
6
+ import { r as Stores, t as StoreContentsError } from "./engine-CxcONfhv.js";
7
7
  import { DatabaseSync } from "node:sqlite";
8
8
  //#region src/sqlite/scan.ts
9
9
  const isWordChar = (c) => /[\w$]/.test(c) || c.charCodeAt(0) > 127;
@@ -1,6 +1,6 @@
1
1
 
2
- import { ut as compareText } from "./operations-B3XaG7Ve.js";
3
- import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-Bx8B63iQ.js";
2
+ import { ut as compareText } from "./operations-DrsedOvj.js";
3
+ import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-CxcONfhv.js";
4
4
  //#region src/store/memory.ts
5
5
  /** A backend that keeps nothing outside the engine's own copy. */
6
6
  const memoryBackend = () => ({
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { L as map, V as nothing, i as ScriptError, it as text, t as HostError, u as bool } from "./errors-CNc-xY_9.js";
3
- import { Dt as shape, ft as errorMessages, i as arithmetic, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
3
+ import { Dt as shape, ft as errorMessages, i as arithmetic, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-DrsedOvj.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DlMqlP2Y.js";
5
5
  //#region src/store-capability.ts
6
6
  /** A Core-raised error as the Host sees it, with its catalogue message. */
7
7
  const hostScriptError = (code, fields) => {
package/store.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { n as RouterOptions } from "./router-DXoJ_2Z4.js";
3
- 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-Dy-BCoiw.js";
2
+ import { n as RouterOptions } from "./router-2vjYbqx3.js";
3
+ 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-DP_lqWfI.js";
4
4
  //#region src/store/memory.d.ts
5
5
  /** A backend that keeps nothing outside the engine's own copy. */
6
6
  export declare const memoryBackend: () => StoreBackend;
package/store.js CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
3
- import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-BTcyKBLg.js";
2
+ import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-CxcONfhv.js";
3
+ import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-_af2DPoK.js";
4
4
  export { StoreContentsError, StoreStateUnknownError, Stores, decodeContents, encodeContents, memoryBackend, memoryStores, sessionQuotas, sessionWatchLimits, webStorageBackend, webStorageStores };
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { Dt as integerOf, L as map, Ot as isInteger, it as text, t as HostError, u as bool, x as decimalParts } from "./errors-CNc-xY_9.js";
3
- import { Dt as shape, n as ScriptError, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
3
+ import { Dt as shape, n as ScriptError, xt as defineValueCapability } from "./operations-DrsedOvj.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DlMqlP2Y.js";
5
5
  //#region src/locale-tag.ts
6
6
  const grandfathered = /^(?:en-gb-oed|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)|sgn-(?:be-fr|be-nl|ch-de))$/i;
7
7
  const alpha = /^[a-z]+$/i;
package/wasm.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { $ as instant, $t as shape, At as FireOp, Bt as ReleaseHook, C as Report, Cn as LocaleImpl, Ct as ChargeRequest, Dn as Costs, Dt as EffectResult, E as RestoreResult, En as ConsoleImpl, Et as Cost, Fn as Library, Ft as Metering, G as RunStarted, Gt as SegmentGrant, H as RunAccounting, Hn as LimitName, Ht as ScopeDecl, It as Operation, J as Value, Jt as SuspendingOp, K as Decimal, Kt as SegmentLifecycle, Ln as LibrarySource, Lt as Operations, Mt as GrantContext, N as Settlement, Nt as ImmediateOp, On as MusicalClockImpl, Ot as ErrorDecl, Pt as LimitReached, Q as dec, Qt as operationDeclarations, R as Verdict, Rn as OperationRef, Rt as PlainArg, S as PumpedRequest, St as CapabilityDefiner, T as RestoreOptions, Tn as CalendarImpl, Tt as CoordinatedLifecycle, U as RunAncestry, Un as Limits, Ut as SegmentContext, V as CausalWork, Vt as ReleaseReason, W as RunDiscarded, Wn as Outcome, Wt as SegmentCoordinator, X as bytes, Xt as defineCapability, Y as bool, Yt as conforms, Z as civilDate, Zt as explain, _ as LoadOptions, _n as SqlParams, _t as PropDef, an as PeerImpl, ar as LoadError, at as quantity, b as PumpOptions, bn as SqliteBinding, bt as Call, cn as HttpClientImpl, cr as SendFailedReason, d as Counters, dt as nowMicros, en as Core, f as Decided, fn as UserImpl, ft as parseInstant, g as Inspection, gt as ObjectKindDef, h as GroupOptions, hn as add, ht as ObjectKind, ir as LoadDiagnostic, it as num, jt as Grant, kn as TimerImpl, kt as FieldShape, l as CancellationOptions, ln as HttpImpl, lt as text, m as EffectFailure, mn as StoreImpl, mt as ObjectElements, nn as Script, nr as HostError, nt as map, or as MailboxFull, ot as range, p as Deciding, pt as HostObject, q as Kind, qt as Shape, rn as Versions, rr as HostErrorCode, rt as nothing, sr as ScriptError, st as record, tn as Group, tt as list, u as CarryOver, un as HttpServerImpl, ut as formatInstant, v as Message, vn as SqlRows, w as Requested, wt as ChargeResult, x as PumpResult, xn as SqliteImpl, xt as CapabilityDef, y as PendingCall, yn as SqlValue, yt as GrantDecls, zt as PlainResult } from "./debug-s6QIovKS.js";
3
- import { A as FromValueOptions, C as handlersOf, F as talk, M as ToValueOptions, N as fromValue, P as toValue, S as ScriptWithHandlers, T as encodeJson, b as createGroup, d as exportManifest, f as zoneRules, h as inlineGrants, j as PlainValue, k as encodeValue, l as ManifestSpec, m as InlineOperation, p as InlineFunction, u as MessageDecl, v as CreateGroupOptions, w as decodeJson, x as Handlers, y as DrivenGroup } from "./lean-Bg_UTRj0.js";
4
- import { a as decodeValue, n as Json, o as readDisplay } from "./readers-AeB1bJ--.js";
5
- import { t as BinaryValueOptions } from "./binary-value-B93hEK7l.js";
2
+ import { $ as instant, $t as shape, At as FireOp, Bt as ReleaseHook, C as Report, Cn as LocaleImpl, Ct as ChargeRequest, Dn as Costs, Dt as EffectResult, E as RestoreResult, En as ConsoleImpl, Et as Cost, Fn as Library, Ft as Metering, G as RunStarted, Gt as SegmentGrant, H as RunAccounting, Hn as LimitName, Ht as ScopeDecl, It as Operation, J as Value, Jt as SuspendingOp, K as Decimal, Kt as SegmentLifecycle, Ln as LibrarySource, Lt as Operations, Mt as GrantContext, N as Settlement, Nt as ImmediateOp, On as MusicalClockImpl, Ot as ErrorDecl, Pt as LimitReached, Q as dec, Qt as operationDeclarations, R as Verdict, Rn as OperationRef, Rt as PlainArg, S as PumpedRequest, St as CapabilityDefiner, T as RestoreOptions, Tn as CalendarImpl, Tt as CoordinatedLifecycle, U as RunAncestry, Un as Limits, Ut as SegmentContext, V as CausalWork, Vt as ReleaseReason, W as RunDiscarded, Wn as Outcome, Wt as SegmentCoordinator, X as bytes, Xt as defineCapability, Y as bool, Yt as conforms, Z as civilDate, Zt as explain, _ as LoadOptions, _n as SqlParams, _t as PropDef, an as PeerImpl, ar as LoadError, at as quantity, b as PumpOptions, bn as SqliteBinding, bt as Call, cn as HttpClientImpl, cr as SendFailedReason, d as Counters, dt as nowMicros, en as Core, f as Decided, fn as UserImpl, ft as parseInstant, g as Inspection, gt as ObjectKindDef, h as GroupOptions, hn as add, ht as ObjectKind, ir as LoadDiagnostic, it as num, jt as Grant, kn as TimerImpl, kt as FieldShape, l as CancellationOptions, ln as HttpImpl, lt as text, m as EffectFailure, mn as StoreImpl, mt as ObjectElements, nn as Script, nr as HostError, nt as map, or as MailboxFull, ot as range, p as Deciding, pt as HostObject, q as Kind, qt as Shape, rn as Versions, rr as HostErrorCode, rt as nothing, sr as ScriptError, st as record, tn as Group, tt as list, u as CarryOver, un as HttpServerImpl, ut as formatInstant, v as Message, vn as SqlRows, w as Requested, wt as ChargeResult, x as PumpResult, xn as SqliteImpl, xt as CapabilityDef, y as PendingCall, yn as SqlValue, yt as GrantDecls, zt as PlainResult } from "./debug-2yfUZYzF.js";
3
+ import { A as FromValueOptions, C as handlersOf, F as talk, M as ToValueOptions, N as fromValue, P as toValue, S as ScriptWithHandlers, T as encodeJson, b as createGroup, d as exportManifest, f as zoneRules, h as inlineGrants, j as PlainValue, k as encodeValue, l as ManifestSpec, m as InlineOperation, p as InlineFunction, u as MessageDecl, v as CreateGroupOptions, w as decodeJson, x as Handlers, y as DrivenGroup } from "./lean-DU_muGpT.js";
4
+ import { a as decodeValue, n as Json, o as readDisplay } from "./readers-IhVpgXkj.js";
5
+ import { t as BinaryValueOptions } from "./binary-value-B8W4W_e1.js";
6
6
  //#region src/wasm/reactor.d.ts
7
7
  /** Text the reactor writes to stdout or stderr, such as a fatal error. */
8
8
  type Diagnostics = (line: string) => void;
package/wasm.js CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
2
  import { D as instant, G as patternValue, H as num, J as range, K as quantity, L as map, N as list, Qt as parseInstant, U as objectValue, V as nothing, X as requireArgs, Xt as nowMicros, Y as record, Z as requireValue, b as dec, c as Decimal, d as bytes, g as civilDate, i as ScriptError, it as text, l as Value, n as LoadError, o as invalidValue, qt as formatInstant, r as MailboxFull, s as sendFailed, t as HostError, u as bool, w as functionValue } from "./errors-CNc-xY_9.js";
3
3
  import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-OKVLH190.js";
4
- import { Dt as shape, Et as operationDeclarations, bt as defineCapability, gt as LimitReached, mt as limitDefaults, vt as conforms, wt as explain } from "./operations-B3XaG7Ve.js";
5
- import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-DVS1SEmN.js";
4
+ import { Dt as shape, Et as operationDeclarations, bt as defineCapability, gt as LimitReached, mt as limitDefaults, vt as conforms, wt as explain } from "./operations-DrsedOvj.js";
5
+ import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-CRpUahPt.js";
6
6
  import { n as trackOperation } from "./operation-promises-ClA1BTaS.js";
7
7
  import { n as toBase64, t as fromBase64 } from "./base64-CDO-a06R.js";
8
8
  import { a as fromJson, c as readDisplay, l as readOrderedJSON, n as JsonObject, o as isJsonNumber, r as decodeValue, s as isJsonObject, t as JsonNumber } from "./readers-G1lHqrPl.js";
9
- import { a as clockCapability, d as timerCapability, i as calendarCapability, l as isMusicalClock, n as quoteJSON, o as consoleCapability, p as standardChecks, r as MUSICAL_CLOCK, t as encodeValue, u as musicalClockCapability } from "./encoding-DzVFpg7k.js";
10
- import { a as peerKind, i as peerCapability } from "./peer-capability-3etyPHs3.js";
11
- import { a as httpCapability, c as toValue, i as handlersOf, l as talk, n as inlineGrants, o as sqliteCapability, r as createGroup, s as fromValue, t as zoneRules } from "./zone-rules-DsCJtmlC.js";
12
- import { o as decodeJson, s as encodeJson } from "./http-fetch-DnpfiOWK.js";
13
- import { n as localeCapability, t as userCapability } from "./user-capability-DNY2dyjq.js";
14
- import { r as storeCapability, t as add } from "./store-capability-CBJ6mUoH.js";
15
- import { a as encodeResult, c as isRequestPumpBinary, d as valueNode, i as encodeBinaryFrame, l as placeholderValues, n as decodeBinaryFrame, o as heldValue, r as decodeNeed, s as isBinaryNeed, t as callbacksFeature, u as requestPumpFeature } from "./request-pump-binary-VOPVqRZD.js";
9
+ import { a as clockCapability, d as timerCapability, i as calendarCapability, l as isMusicalClock, n as quoteJSON, o as consoleCapability, p as standardChecks, r as MUSICAL_CLOCK, t as encodeValue, u as musicalClockCapability } from "./encoding-DlMqlP2Y.js";
10
+ import { a as peerKind, i as peerCapability } from "./peer-capability-RMdN4OHj.js";
11
+ import { a as httpCapability, c as toValue, i as handlersOf, l as talk, n as inlineGrants, o as sqliteCapability, r as createGroup, s as fromValue, t as zoneRules } from "./zone-rules-Cn-f9u_Z.js";
12
+ import { o as decodeJson, s as encodeJson } from "./http-fetch-CLAeEXVi.js";
13
+ import { n as localeCapability, t as userCapability } from "./user-capability-CzoLN3RK.js";
14
+ import { r as storeCapability, t as add } from "./store-capability-Db6v_dw9.js";
15
+ import { a as encodeResult, c as isRequestPumpBinary, d as valueNode, f as envelopeJsonMessages, i as encodeBinaryFrame, l as placeholderValues, m as envelopeViews, n as decodeBinaryFrame, o as heldValue, p as envelopeMessages, r as decodeNeed, s as isBinaryNeed, t as callbacksFeature, u as requestPumpFeature } from "./request-pump-binary-P8m6kLfB.js";
16
16
  //#region src/wasm/wire.ts
17
17
  const raw = Symbol("raw JSON");
18
18
  const sep = Symbol("separator");
@@ -361,6 +361,53 @@ var Reactor = class {
361
361
  }
362
362
  };
363
363
  //#endregion
364
+ //#region src/wasm/envelope-json.ts
365
+ const fieldsOf = new Map([...envelopeMessages.filter((m) => m.layouts?.includes("json")).map((m) => [m.name, m.fields]), ...envelopeJsonMessages.map((m) => [m.name, m.fields])]);
366
+ /** Each view's fields by name, and its required ones. */
367
+ const views = new Map(envelopeViews.map((v) => [v.name, {
368
+ byName: new Map(v.fields.map((f) => [f.name, f])),
369
+ required: v.fields.filter((f) => f.required).map((f) => f.name)
370
+ }]));
371
+ /** A message's JSON fields, in catalogue order; absent fields are left out. */
372
+ const encodeJsonMessage = (m, record) => {
373
+ const given = record;
374
+ const out = {};
375
+ for (const f of fieldsOf.get(m)) if (f.name !== "ref" && f.name !== "group" && given[f.name] !== void 0) out[f.name] = given[f.name];
376
+ return out;
377
+ };
378
+ const uintOf = (j) => isJsonNumber(j) ? BigInt(j.source) : typeof j === "string" && /^\d+$/.test(j) ? BigInt(j) : void 0;
379
+ const decodeField = (f, j) => {
380
+ switch (f.kind) {
381
+ case "text":
382
+ case "instant": return textOf(j);
383
+ case "texts": return textsOf(j);
384
+ case "bool": return boolOf(j);
385
+ case "int": return intOf(j);
386
+ case "uint": return uintOf(j);
387
+ case "pairs": return listOf(j).map((p) => {
388
+ const [k, v] = listOf(p);
389
+ return [textOf(k) ?? "", v ?? null];
390
+ });
391
+ case "views": return listOf(j).map((x) => decodeView(f.view, x));
392
+ default: return j;
393
+ }
394
+ };
395
+ const decodeView = (name, j) => {
396
+ const { byName, required } = views.get(name);
397
+ const out = {};
398
+ for (const [k, v] of entriesOf(j)) {
399
+ const f = byName.get(k);
400
+ if (f) {
401
+ const decoded = decodeField(f, v);
402
+ if (decoded !== void 0) out[k] = decoded;
403
+ }
404
+ }
405
+ for (const k of required) if (!(k in out)) throw new InstanceLostError(`The ${name} reply lacks ${k}`);
406
+ return out;
407
+ };
408
+ /** A reply view read from its JSON, typed by the catalogue. */
409
+ const decodeJsonView = (view, j) => decodeView(view, j);
410
+ //#endregion
364
411
  //#region src/wasm/group.ts
365
412
  const key = (kind, id) => `${kind}\u0000${id}`;
366
413
  const isLimitReached = (error) => error instanceof Error && error.name === "LimitReached";
@@ -1054,19 +1101,20 @@ var WasmGroup = class {
1054
1101
  ...given,
1055
1102
  [MUSICAL_CLOCK]: this.#musicalClock
1056
1103
  } : given;
1057
- const ok = this.worker("load", {
1104
+ const load = {
1058
1105
  name: o.name,
1059
1106
  source: o.source,
1060
1107
  grants: this.#grantHandles(grants),
1061
1108
  grantsAsUsed: o.grantsAsUsed,
1062
- forbidSuspension: o.forbidSuspension || void 0,
1063
1109
  owner: o.owner ? this.#objectRef(o.owner) : void 0,
1064
1110
  objects: o.objects ? Object.fromEntries(Object.entries(o.objects).map(([n, h]) => [n, this.#objectRef(h)])) : void 0,
1065
1111
  limits: {
1066
1112
  ...limitDefaults,
1067
1113
  ...o.limits
1068
- }
1069
- });
1114
+ },
1115
+ forbidSuspension: o.forbidSuspension || void 0
1116
+ };
1117
+ const ok = this.worker("load", encodeJsonMessage("load", load));
1070
1118
  const name = textOf(field(ok, "script")) ?? o.name;
1071
1119
  this.#bindings.set(name, new Map(Object.entries(grants)));
1072
1120
  const script = new WasmScript(this, name);
@@ -1293,37 +1341,29 @@ var WasmGroup = class {
1293
1341
  return bytesOfFrame(field(this.worker("state-fingerprint"), "stateFingerprint"));
1294
1342
  }
1295
1343
  inspect() {
1296
- const ok = this.worker("inspect");
1297
- return { scripts: listOf(field(ok, "scripts")).map((s) => {
1298
- const disabled = textsOf(field(s, "disabledGrants"));
1299
- return {
1300
- name: textOf(field(s, "name")),
1301
- ...disabled.length ? { disabledGrants: disabled } : {},
1302
- ...field(s, "forbidSuspension") === true ? { forbidSuspension: true } : {},
1303
- vars: listOf(field(s, "vars")).map((pair) => {
1304
- const [name, v] = listOf(pair);
1305
- return [textOf(name), decode(this.#codec, v)];
1306
- }),
1307
- runs: listOf(field(s, "runs")).map((r) => {
1308
- const run = plain(r);
1309
- if (typeof run.until === "string") run.until = parseInstant(run.until);
1310
- return run;
1311
- }),
1312
- mailbox: listOf(field(s, "mailbox")).map((item) => {
1313
- const message = field(item, "message");
1314
- const limits = plain(field(message, "limits"));
1315
- return {
1316
- ...has(item, "delivery") ? { delivery: textOf(field(item, "delivery")) } : {},
1317
- ...has(item, "from") ? { from: textOf(field(item, "from")) } : {},
1318
- message: {
1319
- name: textOf(field(message, "name")),
1320
- args: listOf(field(message, "args")).map((a) => decode(this.#codec, a)),
1321
- ...limits ? { limits } : {}
1322
- }
1323
- };
1324
- })
1325
- };
1326
- }) };
1344
+ const ok = this.worker("inspect", encodeJsonMessage("inspect", {}));
1345
+ return { scripts: decodeJsonView("inspection", ok).scripts.map((s) => ({
1346
+ name: s.name,
1347
+ ...s.disabledGrants?.length ? { disabledGrants: [...s.disabledGrants] } : {},
1348
+ ...s.forbidSuspension ? { forbidSuspension: true } : {},
1349
+ vars: s.vars.map(([name, v]) => [name, decode(this.#codec, v)]),
1350
+ runs: s.runs.map((r) => ({
1351
+ id: r.id,
1352
+ status: r.status,
1353
+ handler: r.handler,
1354
+ ...r.wait !== void 0 ? { wait: r.wait } : {},
1355
+ ...r.until !== void 0 ? { until: parseInstant(r.until) } : {},
1356
+ ...r.calls ? { calls: [...r.calls] } : {}
1357
+ })),
1358
+ mailbox: s.mailbox.map((item) => ({
1359
+ ...item.delivery !== void 0 ? { delivery: item.delivery } : {},
1360
+ ...item.from !== void 0 ? { from: item.from } : {},
1361
+ message: {
1362
+ name: textOf(field(item.message, "name")),
1363
+ args: listOf(field(item.message, "args")).map((a) => decode(this.#codec, a))
1364
+ }
1365
+ }))
1366
+ })) };
1327
1367
  }
1328
1368
  settle(callId, s) {
1329
1369
  const pending = this.#restored.get(callId);
@@ -1,8 +1,8 @@
1
1
 
2
2
  import { D as instant, Dt as integerOf, H as num, K as quantity, L as map, N as list, Ot as isInteger, P as listValues, V as nothing, Y as record, Z as requireValue, b as dec, d as bytes, i as ScriptError, it as text, k as isDecimal, l as Value, o as invalidValue, t as HostError, u as bool, x as decimalParts } from "./errors-CNc-xY_9.js";
3
- import { Ct as expectedOf, Dt as shape, bt as defineCapability, jt as validStaticMessageName, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
5
- import { n as duplicateHeaderNames, r as fetchAnswerOk, s as encodeJson, t as checkFetch } from "./http-fetch-DnpfiOWK.js";
3
+ import { Ct as expectedOf, Dt as shape, bt as defineCapability, jt as validStaticMessageName, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-DrsedOvj.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DlMqlP2Y.js";
5
+ import { n as duplicateHeaderNames, r as fetchAnswerOk, s as encodeJson, t as checkFetch } from "./http-fetch-CLAeEXVi.js";
6
6
  import { asyncDispose, newDrivenGroup } from "./driver.js";
7
7
  //#region src/talk.ts
8
8
  const blank = /^[\t ]*$/;