@northtalk/ts 0.5.1 → 0.7.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 (58) hide show
  1. package/{binary-value-xvJoGg0C.d.ts → binary-value-M8v567iA.d.ts} +1 -1
  2. package/{checker-CUhn2XaM.js → checker-Coml0Tf9.js} +581 -71
  3. package/{core-BuTAYRm-.d.ts → core-D4qYURer.d.ts} +1 -1
  4. package/{debug-DRhMZAxw.d.ts → debug-C_Ob5rkl.d.ts} +137 -12
  5. package/debug.d.ts +1 -1
  6. package/debug.js +1 -1
  7. package/{driver-CHDcuqUy.d.ts → driver-CLi_OmyQ.d.ts} +1 -1
  8. package/driver.d.ts +1 -1
  9. package/driver.js +1 -1
  10. package/encoding-BL2ECJmg.js +338 -0
  11. package/{engine-Cc3yofGM.d.ts → engine-BBNHy4-F.d.ts} +2 -2
  12. package/{engine-CXf5FCwi.js → engine-DhBk0lTt.js} +6 -6
  13. package/{errors-D11zizZg.js → errors-P3ga1I-9.js} +124 -21
  14. package/{group-BflSou2n.js → group-BqccKTWz.js} +406 -75
  15. package/{http-fetch-DFwVIOQg.js → http-fetch-DA-NbFIM.js} +2 -2
  16. package/http.d.ts +1 -1
  17. package/http.js +5 -5
  18. package/index-CBuczWK0.d.ts +9 -0
  19. package/index.d.ts +6 -12
  20. package/index.js +15 -14
  21. package/{inline-grants-XbX9HL_w.js → inline-grants-BT2nnfLA.js} +4 -5
  22. package/{lean-BebPaTMK.js → lean-BJmLobmd.js} +13 -8
  23. package/{lean-CjWVuOrC.d.ts → lean-CFLJ9VrX.d.ts} +155 -6
  24. package/lean.d.ts +5 -6
  25. package/lean.js +15 -14
  26. package/{manifest-CCfpn0kC.js → manifest-37x-HSxH.js} +4 -3
  27. package/message-layer.d.ts +2 -2
  28. package/message-layer.js +2 -2
  29. package/notify.d.ts +1 -1
  30. package/notify.js +1 -1
  31. package/{objects-DmUc0lha.js → objects-DE6kRk0r.js} +1 -1
  32. package/{objects-DC6HjzBY.d.ts → objects-DVlpWsi0.d.ts} +11 -3
  33. package/{operations-DnCcztkZ.js → operations-CGjDlkGU.js} +73 -15
  34. package/package.json +5 -1
  35. package/peer-capability-elnbQy-J.js +149 -0
  36. package/peer.d.ts +173 -0
  37. package/peer.js +542 -0
  38. package/{readers-MmyZ_d0w.d.ts → readers-ChQ0e92c.d.ts} +1 -1
  39. package/{readers-CsvlahLi.js → readers-yMS1eAOp.js} +1 -1
  40. package/{request-pump-binary-oqjWFqZA.js → request-pump-binary-BS1J8DF2.js} +4 -4
  41. package/{router-BZ-aYeXA.js → router-Bm7A2kjt.js} +4 -4
  42. package/{router-D56rSkU8.d.ts → router-D0rf5SkW.d.ts} +2 -2
  43. package/session.d.ts +2 -2
  44. package/session.js +65 -17
  45. package/setup.d.ts +3 -2
  46. package/setup.js +13 -16
  47. package/sqlite.d.ts +2 -2
  48. package/sqlite.js +5 -5
  49. package/{store-DHlo6fP5.js → store-D80OlpyG.js} +2 -2
  50. package/store-capability-DBLlWaNO.js +187 -0
  51. package/store.d.ts +2 -2
  52. package/store.js +2 -2
  53. package/{user-capability-BcRQyyEw.js → user-capability-D6hGa3eF.js} +3 -4
  54. package/wasm.d.ts +16 -7
  55. package/wasm.js +52 -23
  56. package/encoding-RUuES_e4.js +0 -99
  57. package/manifest-DVrx-pT2.d.ts +0 -122
  58. package/store-capability-BrUUAwVS.js +0 -389
package/wasm.js CHANGED
@@ -1,17 +1,18 @@
1
1
 
2
- import { Bt as formatInstant, G as record, Gt as parseInstant, H as quantity, K as requireArgs, L as nothing, N as map, Q as text, R as num, S as functionValue, T as instant, Ut as nowMicros, V as patternValue, W as range, c as Decimal, d as bytes, i as ScriptError, k as list, l as Value, m as civilDate, n as LoadError, o as invalidValue, q as requireValue, r as MailboxFull, s as sendFailed, t as HostError, u as bool, v as dec, z as objectValue } from "./errors-D11zizZg.js";
3
- import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-DmUc0lha.js";
4
- import { _t as defineCapability, ht as LimitReached, pt as limitDefaults, xt as shape } from "./operations-DnCcztkZ.js";
5
- import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-CCfpn0kC.js";
2
+ import { G as record, H as quantity, Jt as parseInstant, K as requireArgs, Kt as nowMicros, L as nothing, N as map, R as num, S as functionValue, T as instant, Ut as formatInstant, V as patternValue, W as range, c as Decimal, d as bytes, et as text, i as ScriptError, k as list, l as Value, m as civilDate, n as LoadError, o as invalidValue, q as requireValue, r as MailboxFull, s as sendFailed, t as HostError, u as bool, v as dec, z as objectValue } from "./errors-P3ga1I-9.js";
3
+ import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-DE6kRk0r.js";
4
+ import { Tt as shape, gt as LimitReached, mt as limitDefaults, wt as operationDeclarations, yt as defineCapability } from "./operations-CGjDlkGU.js";
5
+ import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-37x-HSxH.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
- 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-CsvlahLi.js";
9
- import { i as standardChecks, n as quoteJSON, t as encodeValue } from "./encoding-RUuES_e4.js";
10
- import { a as sqliteCapability, c as talk, i as httpCapability, n as createGroup, o as fromValue, r as handlersOf, s as toValue, t as inlineGrants } from "./inline-grants-XbX9HL_w.js";
11
- import { o as decodeJson, s as encodeJson } from "./http-fetch-DFwVIOQg.js";
12
- import { n as localeCapability, t as userCapability } from "./user-capability-BcRQyyEw.js";
13
- import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BrUUAwVS.js";
14
- 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-oqjWFqZA.js";
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-yMS1eAOp.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-BL2ECJmg.js";
10
+ import { a as peerKind, i as peerCapability } from "./peer-capability-elnbQy-J.js";
11
+ import { a as sqliteCapability, c as talk, i as httpCapability, n as createGroup, o as fromValue, r as handlersOf, s as toValue, t as inlineGrants } from "./inline-grants-BT2nnfLA.js";
12
+ import { o as decodeJson, s as encodeJson } from "./http-fetch-DA-NbFIM.js";
13
+ import { n as localeCapability, t as userCapability } from "./user-capability-D6hGa3eF.js";
14
+ import { r as storeCapability, t as add } from "./store-capability-DBLlWaNO.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-BS1J8DF2.js";
15
16
  //#region src/wasm/wire.ts
16
17
  const raw = Symbol("raw JSON");
17
18
  const sep = Symbol("separator");
@@ -375,6 +376,7 @@ const scriptError = (error) => {
375
376
  const textMessage = message.kind === "text";
376
377
  return new ScriptError(error.get("code").asText() ?? "", textMessage ? message.asText() : "", map(error.entries().filter(([k]) => k !== "code" && !(k === "message" && textMessage))));
377
378
  };
379
+ const errorMaps = /* @__PURE__ */ new WeakMap();
378
380
  /** A handle for calls addressed to one Script. */
379
381
  var WasmScript = class {
380
382
  group;
@@ -475,8 +477,14 @@ var WasmGroup = class {
475
477
  /** Answers given while their call was starting, sent once the exchange ends. */
476
478
  #deferred = [];
477
479
  #codec;
480
+ /** The Group's musical clock, granted to every Script as `musical-clock`. */
481
+ #musicalClock;
478
482
  /** @internal Made by WasmCore. */
479
483
  constructor(core, o, restoring) {
484
+ if (o.musicalClock !== void 0) {
485
+ if (!isMusicalClock(o.musicalClock)) throw new HostError("invalid value", "A musical clock comes from musicalClockCapability");
486
+ this.#musicalClock = o.musicalClock.grant("all", void 0);
487
+ }
480
488
  this.#core = core;
481
489
  this.name = o.name;
482
490
  this.#trace = o.trace;
@@ -810,7 +818,7 @@ var WasmGroup = class {
810
818
  return {
811
819
  grants: listOf(field(need, "grants")).map((pair) => {
812
820
  const [script, name] = textsOf(pair);
813
- const grant = o.grants(script, name);
821
+ const grant = name === "musical-clock" ? this.#musicalClock : o.grants(script, name);
814
822
  if (!grant) return null;
815
823
  let scripts = this.#bindings.get(script);
816
824
  if (!scripts) {
@@ -836,7 +844,11 @@ var WasmGroup = class {
836
844
  switch (r.kind) {
837
845
  case "run end": {
838
846
  if (has(j, "result")) r.result = value("result");
839
- if (has(j, "error")) r.error = scriptError(value("error"));
847
+ if (has(j, "error")) {
848
+ const error = value("error");
849
+ errorMaps.set(r, error);
850
+ r.error = scriptError(error);
851
+ }
840
852
  const effect = r.effect;
841
853
  if (effect) {
842
854
  const detail = this.#effectDetails.get(`${effect.segment}/${effect.phase}`);
@@ -850,6 +862,7 @@ var WasmGroup = class {
850
862
  break;
851
863
  }
852
864
  case "unhandled": {
865
+ if (!r.delivery) delete r.delivery;
853
866
  const message = field(j, "message");
854
867
  r.message = {
855
868
  name: textOf(field(message, "name")),
@@ -885,7 +898,7 @@ var WasmGroup = class {
885
898
  #reports(ok) {
886
899
  const rows = listOf(field(ok, "reports")).map((j) => this.#report(j));
887
900
  for (const id of textsOf(field(ok, "gone"))) this.#settle(id, void 0, sendFailed("function gone"));
888
- const unhandled = new Set(rows.flatMap((r) => r.kind === "unhandled" ? [r.delivery] : []));
901
+ const unhandled = new Set(rows.flatMap((r) => r.kind === "unhandled" && r.delivery ? [r.delivery] : []));
889
902
  for (const r of rows) {
890
903
  switch (r.kind) {
891
904
  case "charge result":
@@ -900,7 +913,7 @@ var WasmGroup = class {
900
913
  if (r.climbed || !r.delivery) break;
901
914
  if (unhandled.has(r.delivery)) this.#settle(r.delivery, void 0, sendFailed("unhandled"));
902
915
  else if (r.outcome === "completed") this.#settle(r.delivery, r.result ?? nothing);
903
- else this.#settle(r.delivery, void 0, sendFailed(r.outcome));
916
+ else this.#settle(r.delivery, void 0, sendFailed(r.outcome, r.outcome === "errored" ? errorMaps.get(r) : null));
904
917
  break;
905
918
  case "run discarded":
906
919
  if (r.reason !== "rewind") {
@@ -910,7 +923,7 @@ var WasmGroup = class {
910
923
  this.#runs.delete(r.run);
911
924
  break;
912
925
  case "unhandled":
913
- this.#settle(r.delivery, void 0, sendFailed("unhandled"));
926
+ if (r.delivery) this.#settle(r.delivery, void 0, sendFailed("unhandled"));
914
927
  break;
915
928
  case "stop":
916
929
  for (const id of r.droppedMessages) this.#settle(id, void 0, sendFailed("stopped"));
@@ -1035,7 +1048,12 @@ var WasmGroup = class {
1035
1048
  }
1036
1049
  load(o) {
1037
1050
  this.#session.syncKinds();
1038
- const grants = o.grants ?? {};
1051
+ const given = o.grants ?? {};
1052
+ if (Object.hasOwn(given, "musical-clock")) throw new HostError("invalid value", `${MUSICAL_CLOCK} is the Group's own Grant name`);
1053
+ const grants = this.#musicalClock ? {
1054
+ ...given,
1055
+ [MUSICAL_CLOCK]: this.#musicalClock
1056
+ } : given;
1039
1057
  const ok = this.worker("load", {
1040
1058
  name: o.name,
1041
1059
  source: o.source,
@@ -1058,11 +1076,12 @@ var WasmGroup = class {
1058
1076
  this.#core.install(this.#session, l);
1059
1077
  this.worker("add-library", { identity: bytesFrame(l.identity) });
1060
1078
  }
1061
- replaceLibrary(l, carry) {
1079
+ replaceLibrary(l, carry, o) {
1062
1080
  this.#core.install(this.#session, l);
1063
1081
  return this.lifecycle("replace-library", {
1064
1082
  identity: bytesFrame(l.identity),
1065
- carry
1083
+ carry,
1084
+ keepMailbox: o?.keepMailbox
1066
1085
  });
1067
1086
  }
1068
1087
  /** @internal Reload and Library replacement end Runs and settle their futures. */
@@ -1071,12 +1090,14 @@ var WasmGroup = class {
1071
1090
  this.#ready();
1072
1091
  return reports;
1073
1092
  }
1074
- object(kind, id, native) {
1093
+ object(kind, id, native, o) {
1075
1094
  if (this.#objects.has(key(kind.name, id))) throw new HostError("duplicate object id", `${kind.name} ${id}`);
1095
+ const parent = o?.parent ? this.#held(o.parent) : void 0;
1076
1096
  this.#session.syncKinds();
1077
1097
  this.send("object", {
1078
1098
  kind: kind.name,
1079
- id
1099
+ id,
1100
+ ...parent ? { parent } : {}
1080
1101
  });
1081
1102
  const state = makeObject(kind, id, native);
1082
1103
  this.#objects.set(key(kind.name, id), state);
@@ -1534,7 +1555,8 @@ var Session = class {
1534
1555
  })),
1535
1556
  segmentLifecycle: segmentBound(def) || void 0,
1536
1557
  release: def.release ? true : void 0,
1537
- standard: isStandard(def) ? def.name : void 0
1558
+ standard: isStandard(def) && !isMusicalClock(def) ? def.name : void 0,
1559
+ musicalClock: isMusicalClock(def) || void 0
1538
1560
  });
1539
1561
  this.#definitions.set(def, handle);
1540
1562
  return handle;
@@ -1688,6 +1710,13 @@ var WasmCore = class {
1688
1710
  sqliteCapability = sqliteCapability;
1689
1711
  userCapability = userCapability;
1690
1712
  httpCapability = httpCapability;
1713
+ musicalClockCapability = musicalClockCapability;
1714
+ peerCapability = peerCapability;
1715
+ peerKind = this.#known(peerKind);
1716
+ #known(kind) {
1717
+ this.#kinds.push(kind);
1718
+ return kind;
1719
+ }
1691
1720
  defineObjectKind(k) {
1692
1721
  const kind = defineObjectKind(k);
1693
1722
  const at = this.#kinds.findIndex((known) => known.name === kind.name);
@@ -1764,4 +1793,4 @@ const createCore = async (o = {}) => new WasmCore(await compile(o.wasm ?? new UR
1764
1793
  /** Chapter 9's default Limits, which the reactor shares. */
1765
1794
  const defaultLimits = Object.freeze({ ...limitDefaults });
1766
1795
  //#endregion
1767
- export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, createCore, createGroup, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
1796
+ export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, createCore, createGroup, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
@@ -1,99 +0,0 @@
1
-
2
- import { o as invalidValue, q as requireValue } from "./errors-D11zizZg.js";
3
- import { n as toBase64 } from "./base64-CDO-a06R.js";
4
- //#region src/standard-capability-checks.ts
5
- const checks = /* @__PURE__ */ new WeakMap();
6
- const registerStandardChecks = (op, rules) => {
7
- checks.set(op, rules);
8
- };
9
- const standardChecks = (op) => checks.get(op);
10
- //#endregion
11
- //#region src/encoding.ts
12
- /** The spec's JSON string form: every U+0000..U+001F uses lowercase \u00xx. */
13
- const quoteJSON = (s) => "\"" + s.replaceAll(/[\u0000-\u001f"\\]/g, (ch) => ch === "\"" ? String.raw`\"` : ch === "\\" ? "\\\\" : String.raw`\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`) + "\"";
14
- const encodeValue = (value, adapter) => {
15
- requireValue(value);
16
- const pending = [value];
17
- const output = [];
18
- while (pending.length) {
19
- const next = pending.pop();
20
- if (typeof next === "string") {
21
- output.push(next);
22
- continue;
23
- }
24
- switch (next.kind) {
25
- case "nothing":
26
- output.push("null");
27
- break;
28
- case "boolean":
29
- output.push(next.asBool() ? "true" : "false");
30
- break;
31
- case "text":
32
- output.push(quoteJSON(next.asText()));
33
- break;
34
- case "number": {
35
- const canonical = next.asDecimal().toString();
36
- output.push(!canonical.includes(".") && BigInt(canonical) > -(2n ** 53n) && BigInt(canonical) < 2n ** 53n ? canonical : `{"$dec":${quoteJSON(canonical)}}`);
37
- break;
38
- }
39
- case "instant":
40
- output.push(`{"$instant":${quoteJSON(next.toString())}}`);
41
- break;
42
- case "civil date":
43
- output.push(`{"$date":${quoteJSON(next.toString())}}`);
44
- break;
45
- case "object": {
46
- const o = next.asObjectRef();
47
- output.push(`{"$object":[${quoteJSON(o.kind)},${quoteJSON(o.id)}]}`);
48
- break;
49
- }
50
- case "bytes":
51
- output.push(`{"$bytes":${quoteJSON(toBase64(next.bytesView()))}}`);
52
- break;
53
- case "quantity": {
54
- const q = next.asQuantity();
55
- output.push(`{"$quantity":[${quoteJSON(q.number.toString())},${quoteJSON(q.unit)}]}`);
56
- break;
57
- }
58
- case "range": {
59
- const { from, to } = next.asRange();
60
- output.push("{\"$range\":[");
61
- pending.push("]}", to, ",", from);
62
- break;
63
- }
64
- case "list":
65
- output.push("[");
66
- pending.push("]");
67
- for (let i = next.length; i >= 1; i--) {
68
- if (i < next.length) pending.push(",");
69
- pending.push(next.index(i));
70
- }
71
- break;
72
- case "map": {
73
- const entries = next.entries();
74
- const tagged = entries.some(([k]) => k.startsWith("$"));
75
- output.push(tagged ? "{\"$map\":[" : "{");
76
- pending.push(tagged ? "]}" : "}");
77
- for (let i = entries.length - 1; i >= 0; i--) {
78
- const [k, v] = entries[i];
79
- if (i < entries.length - 1) pending.push(",");
80
- if (tagged) pending.push("]", v, `[${quoteJSON(k)},`);
81
- else pending.push(v, `${quoteJSON(k)}:`);
82
- }
83
- break;
84
- }
85
- case "function":
86
- case "pattern":
87
- if (adapter) {
88
- output.push(adapter(next));
89
- break;
90
- }
91
- invalidValue(`The Value Encoding of a ${next.kind} isn't implemented yet`);
92
- break;
93
- default: invalidValue(`The Value Encoding of a ${next.kind} isn't implemented yet`);
94
- }
95
- }
96
- return output.join("");
97
- };
98
- //#endregion
99
- export { standardChecks as i, quoteJSON as n, registerStandardChecks as r, encodeValue as t };
@@ -1,122 +0,0 @@
1
- /// <reference lib="esnext.disposable" />
2
- import { $t as Script, Dn as Library, J as Value, K as Decimal, Qt as Group, Zt as Core, _ as LoadOptions, ht as ObjectKind, jt as Grant, qt as Shape } from "./debug-DRhMZAxw.js";
3
- import { n as Drive, r as DrivenGroupOptions } from "./driver-CHDcuqUy.js";
4
- //#region src/talk.d.ts
5
- /**
6
- * Dedents NorthTalk source; rejects JS interpolation.
7
- *
8
- * Write NorthTalk's own interpolation as `\${…}` and its backticks as `` \` ``.
9
- * Pass values as Request arguments instead of splicing them into source. The
10
- * longest whitespace prefix shared by every non-blank line is removed, compared
11
- * exactly, so tabs and spaces never match each other.
12
- */
13
- declare const talk: (strings: TemplateStringsArray, ...values: unknown[]) => string;
14
- //#endregion
15
- //#region src/plain.d.ts
16
- /** Plain JS data, as `fromValue` writes it (ADR 0119). */
17
- type PlainValue = null | boolean | string | Decimal | Uint8Array | Value | PlainValue[] | {
18
- [key: string]: PlainValue;
19
- } | Map<string, PlainValue>;
20
- type ToValueOptions = {
21
- /**
22
- * `integer` reads safe integers through `num`; `decimal` uses `num` for
23
- * any JS number. The default refuses JS numbers.
24
- */
25
- numbers?: 'refuse' | 'integer' | 'decimal';
26
- };
27
- type FromValueOptions = {
28
- maps?: 'object' | 'map';
29
- numbers?: 'decimal' | 'string';
30
- };
31
- /**
32
- * Plain JS data to a Value by the named constructors (ADR 0119). Anything
33
- * the table doesn't name, and cyclic data, throws `invalid value`.
34
- */
35
- declare const toValue: (plain: unknown, options?: ToValueOptions) => Value;
36
- /** A Value as plain JS data (ADR 0119); kinds with no JS form stay Values. */
37
- declare const fromValue: (v: Value, options?: FromValueOptions) => PlainValue;
38
- //#endregion
39
- //#region src/encoding.d.ts
40
- /**
41
- * A Message Layer adapter's own spelling of a Function Value or a Text
42
- * Pattern, which the Value Encoding doesn't hold.
43
- */
44
- type AdapterEncoder = (v: Value) => string;
45
- declare const encodeValue: (value: Value, adapter?: AdapterEncoder) => string;
46
- //#endregion
47
- //#region src/json.d.ts
48
- /** Read exact decimal digits, NFC strings and insertion-ordered maps. */
49
- declare const decodeJson: (source: string) => Value;
50
- /** Compact JSON, with canonical numbers and chapter 7's string escapes. */
51
- declare const encodeJson: (value: Value) => string;
52
- //#endregion
53
- //#region src/handlers.d.ts
54
- /** Untyped Handler calls accept safe-integer JS numbers and plain data. */
55
- type Handlers = {
56
- [name: string]: (...args: (PlainValue | number | bigint)[]) => Promise<PlainValue>;
57
- };
58
- /** The Host supplies T without runtime checking of its arguments or results. */
59
- type ScriptWithHandlers<T = Handlers> = Script & {
60
- readonly handlers: T;
61
- };
62
- /**
63
- * Calls invoke with integer-mode toValue arguments and default fromValue answers.
64
- * The Script's existing driver or Host Pump loop still runs the Requests.
65
- * Promise hooks, symbols and non-message properties read as undefined.
66
- */
67
- declare const handlersOf: <T = Handlers>(script: Script) => T;
68
- //#endregion
69
- //#region src/group-helper.d.ts
70
- /** A Group whose driver closes explicitly or at the end of an `await using` scope. */
71
- type DrivenGroup = Omit<Group, 'load'> & Pick<Drive, 'close' | typeof Symbol.asyncDispose> & {
72
- load<T = Handlers>(o: LoadOptions): ScriptWithHandlers<T>;
73
- };
74
- /** The Zig Host Adapter requires its asynchronously created Core. */
75
- type CreateGroupOptions = DrivenGroupOptions & {
76
- core: Core;
77
- };
78
- /** Creates a driven Group on the supplied Core; close has the driver's shutdown semantics. */
79
- declare const createGroup: (o: CreateGroupOptions) => DrivenGroup;
80
- //#endregion
81
- //#region src/inline-grants.d.ts
82
- /** Argument and result types are supplied by the Host, without runtime checking. */
83
- type InlineFunction = (...args: never[]) => unknown;
84
- type InlineOperation = InlineFunction | {
85
- arity?: number;
86
- fn: InlineFunction;
87
- } | {
88
- arity?: number;
89
- async: InlineFunction;
90
- maxPendingMs?: number;
91
- };
92
- /**
93
- * Defines one Capability per key and grants all its Operations. Arguments use
94
- * default fromValue; results use integer-mode toValue. Arity is fn.length unless
95
- * overridden, including for async functions, which also receive a final signal.
96
- */
97
- declare const inlineGrants: (capabilities: Readonly<Record<string, Readonly<Record<string, InlineOperation>>>>) => Record<string, Grant<void>>;
98
- //#endregion
99
- //#region src/manifest.d.ts
100
- type MessageDecl = {
101
- args?: readonly Shape[];
102
- description?: string;
103
- /** NorthTalk source, each sending this message. */
104
- examples?: readonly string[];
105
- name: string;
106
- receivers?: readonly ObjectKind[];
107
- };
108
- type ManifestSpec = {
109
- grants: Readonly<Record<string, Grant<any>>>;
110
- kind: string;
111
- libraries?: readonly Library[];
112
- messages?: readonly MessageDecl[];
113
- objectKinds?: readonly ObjectKind[];
114
- objects?: Readonly<Record<string, ObjectKind>>;
115
- /** The Owner Kind: one of objectKinds, the kind of `me` for tooling. */
116
- ownerKind?: ObjectKind;
117
- version: string;
118
- };
119
- /** Chapter 9's deterministic JSON file, ending in LF; never calls the Host. */
120
- declare const exportManifest: (m: ManifestSpec) => string;
121
- //#endregion
122
- export { PlainValue as _, InlineOperation as a, toValue as b, DrivenGroup as c, ScriptWithHandlers as d, handlersOf as f, FromValueOptions as g, encodeValue as h, InlineFunction as i, createGroup as l, encodeJson as m, MessageDecl as n, inlineGrants as o, decodeJson as p, exportManifest as r, CreateGroupOptions as s, ManifestSpec as t, Handlers as u, ToValueOptions as v, talk as x, fromValue as y };