@northtalk/ts 0.3.0 → 0.5.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 (52) hide show
  1. package/README.md +1 -1
  2. package/{base64-DA7UgjG2.js → base64-Dtqaz_0A.js} +3 -3
  3. package/{binary-value-BcHcwVLO.d.ts → binary-value-B3knLdHD.d.ts} +1 -1
  4. package/{capabilities-BCw9uREe.js → capabilities-Bi5Qm6Fr.js} +10 -1
  5. package/{checker-Dmnm2SeU.js → checker-DMI4LiRm.js} +13 -5
  6. package/core-D_9OuTRE.d.ts +22 -0
  7. package/{debug-CY9x_Wsi.d.ts → debug-nN5tQ_p4.d.ts} +479 -45
  8. package/debug.d.ts +2 -2
  9. package/debug.js +1 -1
  10. package/{driver-CwmL5M32.d.ts → driver-Bf-7Roq6.d.ts} +1 -1
  11. package/driver.d.ts +1 -1
  12. package/driver.js +1 -1
  13. package/{encoding-BUhsrLPK.js → encoding-C3Q7pIC9.js} +2 -2
  14. package/{engine-Dj9My1qX.js → engine-BpdGfAND.js} +6 -6
  15. package/{engine-CCzaBIoi.d.ts → engine-CQqt4rTB.d.ts} +2 -2
  16. package/{errors-CPPJmAAh.js → errors-BKJES3Zu.js} +1 -1
  17. package/{group-CnpvKoLw.js → group-Bz2wh72R.js} +5917 -1391
  18. package/http.d.ts +1 -1
  19. package/http.js +3 -3
  20. package/index.d.ts +10 -6
  21. package/index.js +16 -15
  22. package/{inline-grants-Bvk-2aUL.js → inline-grants-Cx0Z9XAt.js} +25 -20
  23. package/{manifest-CeavwKxo.d.ts → manifest-DYAbIyQm.d.ts} +2 -2
  24. package/{manifest-BTwN3NiP.js → manifest-Dw-8Unmf.js} +124 -5
  25. package/message-layer.d.ts +2 -2
  26. package/message-layer.js +2 -2
  27. package/notify.d.ts +1 -1
  28. package/notify.js +1 -1
  29. package/{objects-CawjPfhl.js → objects-BC4fS0vq.js} +1 -1
  30. package/{objects-BdWn56Ia.d.ts → objects-BRcpeXwZ.d.ts} +11 -3
  31. package/package.json +1 -1
  32. package/{readers-C2YMRjC3.js → readers-B5e5bBrY.js} +2 -2
  33. package/{readers-DMCXzY3X.d.ts → readers-L90Hoa97.d.ts} +1 -1
  34. package/{request-pump-binary-Cp3RGZIJ.js → request-pump-binary-BjnyqXV5.js} +4 -4
  35. package/{router-BSREiSux.js → router-BCHEfs4x.js} +5 -5
  36. package/{router-BE5Tbbd7.d.ts → router-CBuMIl6i.d.ts} +2 -2
  37. package/session.d.ts +40 -2
  38. package/session.js +109 -27
  39. package/setup.d.ts +1 -1
  40. package/setup.js +4 -4
  41. package/sha256-9CGf5BS_.js +168 -0
  42. package/sqlite.d.ts +4 -4
  43. package/sqlite.js +26 -20
  44. package/{store-DwESnByX.js → store-DTQa0lyE.js} +2 -2
  45. package/{store-capability-BYghoYSd.js → store-capability-BxXgiRM7.js} +4 -4
  46. package/store.d.ts +2 -2
  47. package/store.js +2 -2
  48. package/{user-capability-kDFbi3sm.js → user-capability-5-IvCeZI.js} +5 -5
  49. package/wasm.d.ts +10 -6
  50. package/wasm.js +51 -27
  51. package/core-D902b5Nu.d.ts +0 -14
  52. package/sha256-B_kyYw3Z.js +0 -124
package/README.md CHANGED
@@ -32,7 +32,7 @@ A Host can create a Group ready to pump from the event loop with `newDrivenGroup
32
32
  | Import | Holds |
33
33
  | ----------------------------- | ------------------------------------------------------------------------------------------------------------ |
34
34
  | `@northtalk/ts` | Values, Groups, Scripts, Libraries, Capabilities, Object Kinds, save and restore, and the parser and checker |
35
- | `@northtalk/ts/session` | The Session Host, for a REPL or playground, and Session Transcripts |
35
+ | `@northtalk/ts/session` | The Session Host, for a REPL, and Session Transcripts |
36
36
  | `@northtalk/ts/driver` | `newDrivenGroup` and `autoDrive`, which pump a Group from the event loop |
37
37
  | `@northtalk/ts/store` | The Store Standard Capability |
38
38
  | `@northtalk/ts/notify` | The Store notification router |
@@ -1,6 +1,6 @@
1
1
 
2
- import { $ as textStorage, $t as assertScalarText, A as listValues, At as negate, B as ownedMapPairs, Bt as civilDays, Ct as div, Dt as isInteger, E as instantOf, Et as integerOf, Ft as DateRangeError, H as quantity, Ht as civilOfUs, I as mapWithEntry, It as US_PER_DAY, J as sliceText, L as nothing, Lt as US_PER_SECOND, M as literalDigits, Mt as roundRatio, N as map, Nt as subtract, Ot as mod, Pt as withinLimits, Q as text, Qt as weekday, R as num, Rt as addMonths, St as digitsOf, Tt as formatDec, U as quantityOf, Ut as civilUs, V as patternValue, Vt as civilOfDays, W as range, Wt as dayOfYear, X as smallNumber, Y as smallInteger, Yt as parseCivil, Zt as parseInstantText, _ as concatText, _t as ArithmeticError, an as normalizeNFC, at as parseUnit, b as displayText, bt as decOf, cn as upper, ct as toBase, en as characterBoundaries, et as trimWhiteSpace, f as bytesOf, g as compareBytes, h as civilOf, in as lower, it as ownUnit, j as listWithItem, jt as powerInteger, k as list, kt as multiply, nn as generalCategory, nt as combine, on as scalarCount, ot as powerOf, p as canonicalNumber, qt as isoWeek, rn as isWhiteSpace, rt as fromBase, sn as simpleFold, st as sameDimension, tn as charactersAt, tt as UnitError, u as bool, ut as unitText, v as dec, vt as add, wt as divide, x as extendList, xt as digitCount$1, y as decimalParts, yt as compareDec, zt as checkInstant } from "./errors-CPPJmAAh.js";
3
- import { _ as runTask, d as shapeDiagnostics, l as pathValue, o as diagnosticRecord, r as decodeShape } from "./capabilities-BCw9uREe.js";
2
+ import { $ as textStorage, $t as weekday, A as listValues, At as negate, B as ownedMapPairs, Bt as civilDays, Ct as div, Dt as isInteger, E as instantOf, Et as integerOf, Ft as DateRangeError, Gt as dayOfYear, H as quantity, Ht as civilOfDays, I as mapWithEntry, It as US_PER_DAY, J as sliceText, Jt as isoWeek, L as nothing, Lt as US_PER_SECOND, M as literalDigits, Mt as roundRatio, N as map, Nt as subtract, Ot as mod, Pt as withinLimits, Q as text, Qt as parseInstantText, R as num, Rt as addMonths, St as digitsOf, Tt as formatDec, U as quantityOf, Ut as civilOfUs, V as patternValue, W as range, Wt as civilUs, X as smallNumber, Xt as parseCivil, Y as smallInteger, _ as concatText, _t as ArithmeticError, an as lower, at as parseUnit, b as displayText, bt as decOf, cn as simpleFold, ct as toBase, en as assertScalarText, et as trimWhiteSpace, f as bytesOf, g as compareBytes, h as civilOf, in as isWhiteSpace, it as ownUnit, j as listWithItem, jt as powerInteger, k as list, kt as multiply, ln as upper, nn as charactersAt, nt as combine, on as normalizeNFC, ot as powerOf, p as canonicalNumber, rn as generalCategory, rt as fromBase, sn as scalarCount, st as sameDimension, tn as characterBoundaries, tt as UnitError, u as bool, ut as unitText, v as dec, vt as add, wt as divide, x as extendList, xt as digitCount$1, y as decimalParts, yt as compareDec, zt as checkInstant } from "./errors-BKJES3Zu.js";
3
+ import { _ as runTask, d as shapeDiagnostics, l as pathValue, o as diagnosticRecord, r as decodeShape } from "./capabilities-Bi5Qm6Fr.js";
4
4
  //#region src/generated/machine.ts
5
5
  const instructions = [
6
6
  {
@@ -7089,4 +7089,4 @@ const fromBase64 = (s) => {
7089
7089
  return toBase64(out) === s ? out : void 0;
7090
7090
  };
7091
7091
  //#endregion
7092
- export { arityOf as $, matchesOf as A, smallOf as B, integerValue as C, makePatternValue as D, keyText as E, property as F, cacheBuild as G, textForm as H, randomBound as I, keysContents as J, charge as K, search as L, negated as M, outOfRange as N, makeRange as O, prepareConversion as P, sizeOf as Q, setKey as R, hasKey as S, isKind as T, waitUs as U, splice as V, wrongKind as W, rateOf as X, partSize as Y, resetMeasured as Z, convert as _, appendTo as a, numberText as at, equals as b, builtinDefaults as c, splicesOf as ct, chunkDelete as d, costModel as dt, disassemble as et, chunkGet as f, errorMessages as ft, concat as g, comparison as h, reservedErrorKeys as ht, ScriptError as i, capturesOf$1 as it, member as j, matchCaptures as k, byteOf as l, textDisplay as lt, chunkThere as m, limitDefaults as mt, toBase64 as n, instructionSpec as nt, arithmetic as o, patternSource as ot, chunkSet as p, languageVersion as pt, fixedRates as q, NotImplementedError as r, opcodes as rt, builtin as s, quantityText as st, fromBase64 as t, functionHead as tt, canConvert as u, compareText as ut, decodeUtf8 as v, isEmpty as w, getKey as x, deleteKey as y, smallArithmetic as z };
7092
+ export { sizeOf as $, matchesOf as A, smallOf as B, integerValue as C, makePatternValue as D, keyText as E, property as F, wrongKind as G, subjectText as H, randomBound as I, fixedRates as J, cacheBuild as K, search as L, negated as M, outOfRange as N, makeRange as O, prepareConversion as P, resetMeasured as Q, setKey as R, hasKey as S, isKind as T, textForm as U, splice as V, waitUs as W, partSize as X, keysContents as Y, rateOf as Z, convert as _, appendTo as a, capturesOf$1 as at, equals as b, builtinDefaults as c, quantityText as ct, chunkDelete as d, compareText as dt, arityOf as et, chunkGet as f, costModel as ft, concat as g, reservedErrorKeys as gt, comparison as h, limitDefaults as ht, ScriptError as i, opcodes as it, member as j, matchCaptures as k, byteOf as l, splicesOf as lt, chunkThere as m, languageVersion as mt, toBase64 as n, functionHead as nt, arithmetic as o, numberText as ot, chunkSet as p, errorMessages as pt, charge as q, NotImplementedError as r, instructionSpec as rt, builtin as s, patternSource as st, fromBase64 as t, disassemble as tt, canConvert as u, textDisplay as ut, decodeUtf8 as v, isEmpty as w, getKey as x, deleteKey as y, smallArithmetic as z };
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { q as Value } from "./debug-CY9x_Wsi.js";
2
+ import { J as Value } from "./debug-nN5tQ_p4.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 { $t as assertScalarText, 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, 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-CPPJmAAh.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];
@@ -1140,6 +1140,14 @@ const hasHooks = (lifecycle) => !!lifecycle && typeof lifecycle === "object" &&
1140
1140
  "commit",
1141
1141
  "rollback"
1142
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
+ };
1143
1151
  /**
1144
1152
  * Define a Capability whose Host functions take and return Values. The
1145
1153
  * standard Capabilities and replay Stubs use this form.
@@ -1163,6 +1171,7 @@ const defineValueCapability = (name, ops, lifecycle, release) => {
1163
1171
  if (op.description !== void 0 && typeof op.description !== "string") invalidValue("description must be text");
1164
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");
1165
1173
  const metadata = op;
1174
+ checkMetering(metadata);
1166
1175
  if (metadata.segmentBound !== void 0 && typeof metadata.segmentBound !== "boolean") invalidValue("segmentBound must be Boolean");
1167
1176
  if (metadata.segmentBound && (op.mode !== "immediate" || !lifecycle)) invalidValue("Segment-bound Operations require immediate mode and lifecycle hooks");
1168
1177
  const scope = metadata.scope;
@@ -1,6 +1,6 @@
1
1
 
2
- import { M as literalDigits, an as normalizeNFC, at as parseUnit, dt as builtins, ft as diagnosticCodes, gt as units, lt as unitEntry, mt as libraryExports, pt as grammar, tt as UnitError, ut as unitText } from "./errors-CPPJmAAh.js";
3
- import { _ as runTask, g as RESERVED, h as Lexer, n as acceptsArgumentCount } from "./capabilities-BCw9uREe.js";
2
+ import { M as literalDigits, at as parseUnit, dt as builtins, ft as diagnosticCodes, gt as units, lt as unitEntry, mt as libraryExports, on as normalizeNFC, pt as grammar, tt as UnitError, ut as unitText } from "./errors-BKJES3Zu.js";
3
+ import { _ as runTask, g as RESERVED, h as Lexer, n as acceptsArgumentCount } from "./capabilities-Bi5Qm6Fr.js";
4
4
  //#region src/constructs.ts
5
5
  /** Chapter 3's kind names. */
6
6
  const kindNames = /* @__PURE__ */ new Set([
@@ -2092,9 +2092,12 @@ const leadingDoc = (entry) => {
2092
2092
  * for any other value. A Lambda's is empty, and a stale Function Value keeps
2093
2093
  * its code's documentation, through save and restore too.
2094
2094
  */
2095
- const functionDoc = (value) => {
2095
+ const functionDoc = (value, retained) => {
2096
2096
  const fn = value.asFunction();
2097
- return fn ? codeDoc(fn.code) : null;
2097
+ if (!fn) return null;
2098
+ const doc = codeDoc(fn.code);
2099
+ const stale = fn.code;
2100
+ return doc || !stale.unit || !stale.head?.name ? doc : retained?.get(stale.unit)?.get(stale.head.name) ?? "";
2098
2101
  };
2099
2102
  const codeDoc = (code) => {
2100
2103
  const c = code;
@@ -3261,8 +3264,13 @@ var Parser = class Parser {
3261
3264
  }
3262
3265
  fail(t, expected) {
3263
3266
  if (t.t === "error") this.lexicalFailure(t);
3267
+ if (this.unitWithoutNumber(t)) throw new ParseError(t, "unit without number", `a Unit follows only a number: write \`x as ${t.v}\`, \`x * 1 ${t.v}\`, or the Unit in the Constant`);
3264
3268
  throw new ParseError(t, "unexpected token", `expected ${expected}, found ${t.t === "nl" ? "end of line" : t.t === "eof" ? "end of source" : `\`${t.v}\``}`);
3265
3269
  }
3270
+ unitWithoutNumber(t) {
3271
+ const p = this.prev;
3272
+ return t.t === "word" && unitEntry(t.v) !== void 0 && p !== null && p.line === t.line && (this.isName(p) || p.t === "op" && (p.v === ")" || p.v === "]"));
3273
+ }
3266
3274
  at(t, n) {
3267
3275
  if (n.line === void 0) {
3268
3276
  n.line = t.line;
@@ -6855,4 +6863,4 @@ const checkSource = (source, options = {}) => checkParsedSource(parseSource(sour
6855
6863
  /** Internal compilation path; public semantic trees retain all productions. */
6856
6864
  const checkSourceForLoad = (source, options = {}) => checkParsedSource(parseSourceForLoad(source), options);
6857
6865
  //#endregion
6858
- export { checkDecisionCalls as _, syntaxText as a, parseSource as c, operationUses as d, codeDoc as f, leadingDoc as g, functionDoc as h, syntaxSelector as i, parseSourceRecovering as l, declarationStart as m, checkSourceForLoad as n, ParseError as o, declarationDocs as p, checkSyntax as r, parseEntry as s, checkSource as t, checkEffectCall as u, viewSource as v };
6866
+ export { viewSource as _, syntaxText as a, parseSource as c, operationUses as d, declarationDocs as f, checkDecisionCalls as g, leadingDoc as h, syntaxSelector as i, parseSourceRecovering as l, functionDoc as m, checkSourceForLoad as n, ParseError as o, declarationStart as p, checkSyntax as r, parseEntry as s, checkSource as t, checkEffectCall as u, kindNames as v };
@@ -0,0 +1,22 @@
1
+ /// <reference lib="esnext.disposable" />
2
+ import { An as compileLibrary, B as restore, Zt as Core, vt as defineObjectKind, z as newGroup } from "./debug-nN5tQ_p4.js";
3
+ //#region src/save-format.d.ts
4
+ /**
5
+ * A save's State Fingerprint (ADR 0142), read from its header and frames
6
+ * without hashing its known sections' bodies, once the body digest checks.
7
+ */
8
+ declare const stateFingerprint: (bytes: Uint8Array) => Uint8Array;
9
+ //#endregion
10
+ //#region src/core.d.ts
11
+ /** The TS Core: the embedding interface's Core, with its Groups typed as TsGroup. */
12
+ type TsCore = Omit<Core, 'compileLibrary' | 'defineObjectKind' | 'newGroup' | 'restore' | 'stateFingerprint'> & {
13
+ compileLibrary: typeof compileLibrary;
14
+ defineObjectKind: typeof defineObjectKind;
15
+ newGroup: typeof newGroup;
16
+ restore: typeof restore;
17
+ stateFingerprint: typeof stateFingerprint;
18
+ };
19
+ /** Return the process-wide Core, also used by the free-function helpers. */
20
+ declare const createCore: () => TsCore;
21
+ //#endregion
22
+ export { createCore as n, TsCore as t };