@northtalk/ts 0.2.0 → 0.4.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 (55) hide show
  1. package/README.md +16 -14
  2. package/{base64-DORMd3Hv.js → base64-Dtqaz_0A.js} +880 -409
  3. package/{binary-value-CEmh60GC.d.ts → binary-value-Bb6HPDtM.d.ts} +2 -2
  4. package/{capabilities-CH0FkRMq.js → capabilities-Bi5Qm6Fr.js} +39 -20
  5. package/{checker-Dc1jl2WH.js → checker-DMI4LiRm.js} +321 -112
  6. package/core-BzGUgjL6.d.ts +22 -0
  7. package/{debug-CQBxKnJB.d.ts → debug-C72o2pZy.d.ts} +506 -50
  8. package/debug.d.ts +3 -3
  9. package/debug.js +1 -1
  10. package/driver-ClV_UDEK.d.ts +63 -0
  11. package/driver.d.ts +2 -40
  12. package/driver.js +24 -4
  13. package/{encoding-nlrpj-Pb.js → encoding-C3Q7pIC9.js} +2 -2
  14. package/{engine-BGaJ9dAk.js → engine-BpdGfAND.js} +6 -6
  15. package/{engine-vbYInVYF.d.ts → engine-Dtby_FkE.d.ts} +3 -3
  16. package/{errors-LYJZ_c8h.js → errors-BKJES3Zu.js} +1060 -751
  17. package/{group-B742gg4T.js → group-vuUL2tq-.js} +6526 -1725
  18. package/http.d.ts +2 -2
  19. package/http.js +3 -3
  20. package/index-ByF5j53i.d.ts +779 -0
  21. package/index.d.ts +6 -651
  22. package/index.js +23 -15
  23. package/{http-capability-CSTkw1Yt.js → inline-grants-Cx0Z9XAt.js} +109 -24
  24. package/manifest-Dw-8Unmf.js +256 -0
  25. package/message-layer.d.ts +3 -3
  26. package/message-layer.js +2 -2
  27. package/notify.d.ts +2 -2
  28. package/notify.js +1 -1
  29. package/{objects-Db7IB5vQ.js → objects-BC4fS0vq.js} +1 -1
  30. package/{objects-DJ3QtCCs.d.ts → objects-Dnqor7Gn.d.ts} +12 -4
  31. package/{operation-promises-EgZXG5N_.js → operation-promises-ClA1BTaS.js} +10 -5
  32. package/package.json +2 -2
  33. package/{readers-CjJHKHvH.js → readers-B5e5bBrY.js} +2 -2
  34. package/{readers-BFPuosPk.d.ts → readers-DAFVvvq4.d.ts} +2 -2
  35. package/{request-pump-binary-DdY3X-yl.js → request-pump-binary-BjnyqXV5.js} +4 -4
  36. package/{router--71qvxtY.js → router-BCHEfs4x.js} +5 -5
  37. package/{router-Zhrw5l__.d.ts → router-BspOCPA0.d.ts} +3 -3
  38. package/session.d.ts +41 -3
  39. package/session.js +260 -179
  40. package/setup.d.ts +2 -2
  41. package/setup.js +4 -4
  42. package/sha256-9CGf5BS_.js +168 -0
  43. package/sqlite.d.ts +5 -5
  44. package/sqlite.js +27 -21
  45. package/{store-hJrRULMx.js → store-DTQa0lyE.js} +2 -2
  46. package/{store-capability-OZp4hXmj.js → store-capability-BxXgiRM7.js} +4 -4
  47. package/store.d.ts +3 -3
  48. package/store.js +2 -2
  49. package/{user-capability-BK4Asg7D.js → user-capability-5-IvCeZI.js} +5 -5
  50. package/wasm.d.ts +12 -8
  51. package/wasm.js +67 -39
  52. package/core-DptnvQT9.d.ts +0 -14
  53. package/manifest-BscyH_rW.d.ts +0 -70
  54. package/manifest-DjsxDSuB.js +0 -129
  55. package/sha256-B_kyYw3Z.js +0 -124
@@ -1,5 +1,5 @@
1
-
2
- import { q as Value } from "./debug-CQBxKnJB.js";
1
+ /// <reference lib="esnext.disposable" />
2
+ import { J as Value } from "./debug-C72o2pZy.js";
3
3
  //#region src/binary-value.d.ts
4
4
  type BinaryValueOptions = {
5
5
  coreErrors?: boolean;
@@ -1,5 +1,5 @@
1
1
 
2
- import { E as isDecimal, F as num, J as UnitError, K as text, M as map, P as nothing, Q as parseUnit, _ as dec, ct as unitKinds, d as bytes, k as listValues, l as Value, nt as unitEntry, o as invalidValue, ot as grammar, rt as unitText, t as HostError, u as bool, ut as assertScalarText, w as instant } from "./errors-LYJZ_c8h.js";
2
+ import { A as listValues, D as isDecimal, L as nothing, N as map, Q as text, R as num, T as instant, at as parseUnit, d as bytes, en as assertScalarText, ht as unitKinds, l as Value, lt as unitEntry, o as invalidValue, pt as grammar, t as HostError, tt as UnitError, u as bool, ut as unitText, v as dec } from "./errors-BKJES3Zu.js";
3
3
  //#region src/tasks.ts
4
4
  const runTask = (root) => {
5
5
  const stack = [root];
@@ -74,7 +74,22 @@ var Lexer = class {
74
74
  if (src[i] === "\n" || src[i] === "\r" && src[i + 1] !== "\n") this.lineStarts.push(i + 1);
75
75
  }
76
76
  }
77
+ lastLine = 0;
77
78
  where(pos) {
79
+ const starts = this.lineStarts;
80
+ let lo = this.lastLine;
81
+ if (!(starts[lo] <= pos && (lo + 1 === starts.length || pos < starts[lo + 1]))) {
82
+ lo = this.findLine(pos);
83
+ this.lastLine = lo;
84
+ }
85
+ const start = starts[lo];
86
+ const col = pos - start + 1 - (this.surrogateOffsets.length ? this.surrogatesBefore(pos) - this.surrogatesBefore(start) : 0);
87
+ return {
88
+ line: lo + 1,
89
+ col
90
+ };
91
+ }
92
+ findLine(pos) {
78
93
  let lo = 0;
79
94
  let hi = this.lineStarts.length - 1;
80
95
  while (lo < hi) {
@@ -82,12 +97,7 @@ var Lexer = class {
82
97
  if (this.lineStarts[mid] <= pos) lo = mid;
83
98
  else hi = mid - 1;
84
99
  }
85
- const start = this.lineStarts[lo];
86
- const col = pos - start + 1 - (this.surrogatesBefore(pos) - this.surrogatesBefore(start));
87
- return {
88
- line: lo + 1,
89
- col
90
- };
100
+ return lo;
91
101
  }
92
102
  surrogatesBefore(pos) {
93
103
  let lo = 0;
@@ -99,17 +109,19 @@ var Lexer = class {
99
109
  }
100
110
  return lo;
101
111
  }
102
- tok(t, v, pos, end, spaceBefore, mode, code) {
112
+ tok(t, v, pos, end, spaceBefore, mode, code, leadingTrivia = []) {
113
+ const { line, col } = this.where(pos);
103
114
  return {
104
115
  kind: "token",
105
116
  raw: this.src.slice(pos, end),
106
- leadingTrivia: [],
117
+ leadingTrivia,
107
118
  t,
108
119
  v,
109
120
  code,
110
121
  pos,
111
122
  end,
112
- ...this.where(pos),
123
+ line,
124
+ col,
113
125
  spaceBefore,
114
126
  mode
115
127
  };
@@ -119,12 +131,14 @@ var Lexer = class {
119
131
  let pos = start;
120
132
  const trivia = [];
121
133
  const add = (kind, from) => {
134
+ const { line, col } = this.where(from);
122
135
  trivia.push({
123
136
  kind,
124
137
  pos: from,
125
138
  end: pos,
126
139
  raw: s.slice(from, pos),
127
- ...this.where(from)
140
+ line,
141
+ col
128
142
  });
129
143
  };
130
144
  if (pos === 0 && s.charCodeAt(0) === 65279) {
@@ -341,10 +355,7 @@ var Lexer = class {
341
355
  const s = this.src;
342
356
  const { pos, trivia } = this.trivia(start);
343
357
  const sp = pos > start || pos === 0 || s[pos - 1] === "\n" || s[pos - 1] === "\r";
344
- const T = (t, v, len = v.length, code) => ({
345
- ...this.tok(t, v, pos, pos + len, sp, mode, code),
346
- leadingTrivia: trivia
347
- });
358
+ const T = (t, v, len = v.length, code) => this.tok(t, v, pos, pos + len, sp, mode, code, trivia);
348
359
  if (pos >= s.length) return T("eof", "", 0);
349
360
  const c = s[pos];
350
361
  const rest = s.slice(pos);
@@ -368,10 +379,7 @@ var Lexer = class {
368
379
  let i = pos + 1;
369
380
  while (i < s.length && s[i] !== "\"" && s[i] !== "\n" && s[i] !== "\r") i++;
370
381
  if (s[i] !== "\"") return T("error", "text has no closing quote on its line", i - pos, "unterminated text");
371
- return {
372
- ...this.tok("str", s.slice(pos + 1, i), pos, i + 1, sp, mode),
373
- leadingTrivia: trivia
374
- };
382
+ return this.tok("str", s.slice(pos + 1, i), pos, i + 1, sp, mode, void 0, trivia);
375
383
  }
376
384
  if (/\d/.test(c)) return T("num", NUMBER.exec(rest)[0]);
377
385
  if (/[A-Z_a-z]/.test(c)) return T("word", NAME.exec(rest)[0]);
@@ -416,6 +424,8 @@ const validMessageSelector = (message, arity) => {
416
424
  return name(first) && first !== "all" && !reserved.has(first) && parts.every(validArgumentLabel);
417
425
  };
418
426
  const validComputedMessageName = (message, arity) => message.includes(":") ? validMessageSelector(message, arity) : name(message) && message !== "all" && !reserved.has(message);
427
+ /** A Name or full Selector a static `send` could write, its arity from its colons. */
428
+ const validStaticMessageName = (message) => validComputedMessageName(message, message.split(":").length - 1);
419
429
  //#endregion
420
430
  //#region src/capabilities.ts
421
431
  /** Only a suffix of directly Optional argument Shapes can be omitted. */
@@ -1130,6 +1140,14 @@ const hasHooks = (lifecycle) => !!lifecycle && typeof lifecycle === "object" &&
1130
1140
  "commit",
1131
1141
  "rollback"
1132
1142
  ].every((phase) => typeof lifecycle[phase] === "function");
1143
+ const checkMetering = (op) => {
1144
+ if (op.metering === void 0) return;
1145
+ if (op.metering === "read-only") {
1146
+ if (op.mode === "fire-and-forget" || op.segmentBound || op.scope) invalidValue("read-only metering needs an immediate or suspending Operation without scope or segmentBound");
1147
+ } else if (op.metering === "segment-bound") {
1148
+ if (op.mode !== "immediate" || op.segmentBound !== true) invalidValue("segment-bound metering needs an immediate segmentBound Operation");
1149
+ } else invalidValue("metering must be read-only or segment-bound");
1150
+ };
1133
1151
  /**
1134
1152
  * Define a Capability whose Host functions take and return Values. The
1135
1153
  * standard Capabilities and replay Stubs use this form.
@@ -1153,6 +1171,7 @@ const defineValueCapability = (name, ops, lifecycle, release) => {
1153
1171
  if (op.description !== void 0 && typeof op.description !== "string") invalidValue("description must be text");
1154
1172
  if (op.examples !== void 0 && (!Array.isArray(op.examples) || [...op.examples].some((example) => typeof example !== "string"))) invalidValue("examples must be a list of text");
1155
1173
  const metadata = op;
1174
+ checkMetering(metadata);
1156
1175
  if (metadata.segmentBound !== void 0 && typeof metadata.segmentBound !== "boolean") invalidValue("segmentBound must be Boolean");
1157
1176
  if (metadata.segmentBound && (op.mode !== "immediate" || !lifecycle)) invalidValue("Segment-bound Operations require immediate mode and lifecycle hooks");
1158
1177
  const scope = metadata.scope;
@@ -1298,4 +1317,4 @@ function defineCapability(...input) {
1298
1317
  return input.length === 0 ? defineTyped : defineTyped(...input);
1299
1318
  }
1300
1319
  //#endregion
1301
- export { defineValueCapability as a, mismatch as c, shapeDiagnostics as d, validComputedMessageName as f, runTask as g, RESERVED as h, defineCapability as i, pathValue as l, Lexer as m, acceptsArgumentCount as n, diagnosticRecord as o, validMessageSelector as p, decodeShape as r, expectedOf as s, LimitReached as t, shape as u };
1320
+ export { runTask as _, defineValueCapability as a, mismatch as c, shapeDiagnostics as d, validComputedMessageName as f, RESERVED as g, Lexer as h, defineCapability as i, pathValue as l, validStaticMessageName as m, acceptsArgumentCount as n, diagnosticRecord as o, validMessageSelector as p, decodeShape as r, expectedOf as s, LimitReached as t, shape as u };