@northtalk/ts 0.7.0 → 0.8.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 (56) hide show
  1. package/{binary-value-M8v567iA.d.ts → binary-value-B93hEK7l.d.ts} +1 -1
  2. package/{checker-Coml0Tf9.js → checker-Q4w7rLXk.js} +21 -16
  3. package/{core-D4qYURer.d.ts → core-BBPI6EhG.d.ts} +1 -1
  4. package/{debug-C_Ob5rkl.d.ts → debug-s6QIovKS.d.ts} +18 -3
  5. package/debug.d.ts +1 -1
  6. package/debug.js +1 -1
  7. package/{driver-CLi_OmyQ.d.ts → driver-D5yrK3Nu.d.ts} +1 -1
  8. package/driver.d.ts +1 -1
  9. package/driver.js +1 -1
  10. package/{encoding-BL2ECJmg.js → encoding-B7MCQ4ii.js} +2 -2
  11. package/{engine-BBNHy4-F.d.ts → engine-Dy-BCoiw.d.ts} +2 -2
  12. package/{engine-DhBk0lTt.js → engine-OL1BveVZ.js} +6 -6
  13. package/{errors-P3ga1I-9.js → errors-VuwK669R.js} +34 -3
  14. package/{group-BqccKTWz.js → group-Ccuqwq12.js} +122 -54
  15. package/{http-fetch-DA-NbFIM.js → http-fetch--O27xjSW.js} +2 -2
  16. package/http.d.ts +1 -1
  17. package/http.js +4 -4
  18. package/index.d.ts +12 -6
  19. package/index.js +15 -15
  20. package/{inline-grants-BT2nnfLA.js → inline-grants-DmOdgSoK.js} +4 -4
  21. package/{lean-BJmLobmd.js → lean-BjhQvHyr.js} +10 -10
  22. package/{lean-CFLJ9VrX.d.ts → lean-D6DQfbqH.d.ts} +10 -124
  23. package/lean.d.ts +6 -5
  24. package/lean.js +15 -15
  25. package/{manifest-37x-HSxH.js → manifest-BeViDIoy.js} +3 -3
  26. package/manifest-l07K7nW-.d.ts +124 -0
  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-DE6kRk0r.js → objects-TarIKBL8.js} +1 -1
  32. package/{objects-DVlpWsi0.d.ts → objects-q0lnCK-4.d.ts} +2 -1
  33. package/{operations-CGjDlkGU.js → operations-BAELnqwf.js} +62 -45
  34. package/package.json +1 -1
  35. package/{peer-capability-elnbQy-J.js → peer-capability-B8eKbljR.js} +7 -5
  36. package/peer.d.ts +8 -1
  37. package/peer.js +29 -12
  38. package/{readers-ChQ0e92c.d.ts → readers-AeB1bJ--.d.ts} +1 -1
  39. package/{readers-yMS1eAOp.js → readers-BG8g59qS.js} +1 -1
  40. package/{request-pump-binary-BS1J8DF2.js → request-pump-binary-87klb6sX.js} +9 -4
  41. package/{router-Bm7A2kjt.js → router-DXmPA-qi.js} +4 -4
  42. package/{router-D0rf5SkW.d.ts → router-DXoJ_2Z4.d.ts} +2 -2
  43. package/session.d.ts +2 -2
  44. package/session.js +12 -12
  45. package/setup.d.ts +2 -2
  46. package/setup.js +6 -5
  47. package/sqlite.d.ts +2 -2
  48. package/sqlite.js +5 -5
  49. package/{store-D80OlpyG.js → store-DzpyWjt2.js} +2 -2
  50. package/{store-capability-DBLlWaNO.js → store-capability-CxQJ_Huz.js} +3 -3
  51. package/store.d.ts +2 -2
  52. package/store.js +2 -2
  53. package/{user-capability-D6hGa3eF.js → user-capability-ClYd8Vln.js} +3 -3
  54. package/wasm.d.ts +5 -5
  55. package/wasm.js +15 -13
  56. package/index-CBuczWK0.d.ts +0 -9
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { J as Value } from "./debug-C_Ob5rkl.js";
2
+ import { J as Value } from "./debug-s6QIovKS.js";
3
3
  //#region src/binary-value.d.ts
4
4
  type BinaryValueOptions = {
5
5
  coreErrors?: boolean;
@@ -1,6 +1,6 @@
1
1
 
2
- import { M as literalDigits, cn as builtins, ct as parseUnit, dn as libraryExports, fn as unitKinds, ft as unitEntry, ln as diagnosticCodes, pn as units, pt as unitText, rn as normalizeNFC, rt as UnitError, un as grammar } from "./errors-P3ga1I-9.js";
3
- import { At as Lexer, Mt as runTask, _t as acceptsArgumentCount, jt as RESERVED } from "./operations-CGjDlkGU.js";
2
+ import { I as literalDigits, _n as unitKinds, _t as unitText, ft as parseUnit, gn as libraryExports, gt as unitEntry, hn as grammar, mn as diagnosticCodes, pn as builtins, sn as normalizeNFC, st as UnitError, vn as units } from "./errors-VuwK669R.js";
3
+ import { Mt as Lexer, Nt as RESERVED, Pt as runTask, _t as acceptsArgumentCount } from "./operations-BAELnqwf.js";
4
4
  //#region src/constructs.ts
5
5
  /** Chapter 3's kind names. */
6
6
  const kindNames = /* @__PURE__ */ new Set([
@@ -3097,13 +3097,14 @@ const firstLeaf = (e) => {
3097
3097
  while (!isLeaf(current)) current = current.children[0];
3098
3098
  return current;
3099
3099
  };
3100
+ const isJoin = (n) => n.rule === "Wait" && word(n.children[1], "for") && word(n.children[2], "all");
3100
3101
  const WAITING_RULES = /* @__PURE__ */ new Set([
3101
3102
  "Send",
3102
3103
  "AskTell",
3103
3104
  "OperationLine",
3104
3105
  "SimpleStatement"
3105
3106
  ]);
3106
- const factsOf = (root, report, lambdas) => {
3107
+ const factsOf = (root, report, lambdas, forbid) => {
3107
3108
  const facts = {
3108
3109
  commands: [],
3109
3110
  calls: [],
@@ -3111,17 +3112,18 @@ const factsOf = (root, report, lambdas) => {
3111
3112
  };
3112
3113
  const work = root.children.flatMap((c) => c.kind === "node" ? [{
3113
3114
  node: c,
3114
- cleanup: false
3115
+ cleanup: false,
3116
+ join: false
3115
3117
  }] : []);
3116
3118
  while (work.length) {
3117
- const { node, cleanup } = work.pop();
3119
+ const { node, cleanup, join } = work.pop();
3118
3120
  if (node.rule === "Lambda") {
3119
3121
  lambdas.push(node);
3120
3122
  continue;
3121
3123
  }
3122
3124
  const point = (leaf) => {
3123
3125
  facts.points.push(leaf);
3124
- if (cleanup) report("can't suspend here", leaf);
3126
+ if (cleanup || forbid) report("can't suspend here", leaf);
3125
3127
  };
3126
3128
  const waits = WAITING_RULES.has(node.rule) && has(node, "AndWait");
3127
3129
  switch (node.rule) {
@@ -3130,11 +3132,11 @@ const factsOf = (root, report, lambdas) => {
3130
3132
  break;
3131
3133
  case "Send":
3132
3134
  if (has(node, "ResultTarget") && !waits) report("missing and wait", firstLeaf(node));
3133
- if (waits) point(firstLeaf(node));
3135
+ if (waits && !join) point(firstLeaf(node));
3134
3136
  break;
3135
3137
  case "AskTell":
3136
3138
  case "OperationLine":
3137
- if (waits) point(firstLeaf(node));
3139
+ if (waits && !join) point(firstLeaf(node));
3138
3140
  break;
3139
3141
  case "SimpleStatement": {
3140
3142
  const [head] = node.children;
@@ -3148,7 +3150,7 @@ const factsOf = (root, report, lambdas) => {
3148
3150
  binding,
3149
3151
  name: head,
3150
3152
  wait: waits,
3151
- restricted: cleanup
3153
+ restricted: cleanup || forbid
3152
3154
  });
3153
3155
  if (waits && cleanup) report("can't suspend here", head);
3154
3156
  } else if (has(node, "ResultTarget") && !waits && !hostCommands.has(node)) report("missing and wait", head);
@@ -3161,7 +3163,7 @@ const factsOf = (root, report, lambdas) => {
3161
3163
  if (name?.kind === "name" && (name.binding?.kind === "function" || name.binding?.kind === "handler")) facts.calls.push({
3162
3164
  binding: name.binding,
3163
3165
  name,
3164
- restricted: cleanup
3166
+ restricted: cleanup || forbid
3165
3167
  });
3166
3168
  break;
3167
3169
  }
@@ -3172,7 +3174,8 @@ const factsOf = (root, report, lambdas) => {
3172
3174
  const inFinally = cleanup || word(node.children[i - 1], "finally") || recoveryBody(node, i);
3173
3175
  work.push({
3174
3176
  node: child,
3175
- cleanup: inFinally
3177
+ cleanup: inFinally,
3178
+ join: join || isJoin(node)
3176
3179
  });
3177
3180
  }
3178
3181
  }
@@ -3181,9 +3184,11 @@ const factsOf = (root, report, lambdas) => {
3181
3184
  };
3182
3185
  /**
3183
3186
  * Check a unit's Suspension Points, and give whether each of its Handlers
3184
- * may suspend, by name, for the Libraries that export them.
3187
+ * may suspend, by name, for the Libraries that export them. With `forbid`,
3188
+ * every Suspension Point, and every call to a Handler that may reach one, is
3189
+ * `can't suspend here`.
3185
3190
  */
3186
- const checkSuspension = (root, imported, reportTo) => {
3191
+ const checkSuspension = (root, imported, reportTo, forbid = false) => {
3187
3192
  const seen = /* @__PURE__ */ new Set();
3188
3193
  const report = (code, at) => {
3189
3194
  if (!seen.has(at)) {
@@ -3202,7 +3207,7 @@ const checkSuspension = (root, imported, reportTo) => {
3202
3207
  bodies.push({
3203
3208
  kind: node.rule === "Handler" ? "handler" : "function",
3204
3209
  name: named ? firstLeaf(named).text : node.rule === "Handler" ? "any message" : "",
3205
- facts: factsOf(node, report, lambdas)
3210
+ facts: factsOf(node, report, lambdas, forbid)
3206
3211
  });
3207
3212
  }
3208
3213
  }
@@ -3210,7 +3215,7 @@ const checkSuspension = (root, imported, reportTo) => {
3210
3215
  while (lambdas.length) bodies.push({
3211
3216
  kind: "lambda",
3212
3217
  name: "",
3213
- facts: factsOf(lambdas.pop(), report, lambdas)
3218
+ facts: factsOf(lambdas.pop(), report, lambdas, forbid)
3214
3219
  });
3215
3220
  const may = /* @__PURE__ */ new Map();
3216
3221
  for (const b of bodies) if (b.kind === "handler") may.set(b.name, (may.get(b.name) ?? false) || b.facts.points.length > 0);
@@ -7339,7 +7344,7 @@ const checkParsed = (syntax, options) => {
7339
7344
  const existing = options.existing?.[binding.name];
7340
7345
  return (binding.kind === "handler" && existing?.handler ? existing.handler : existing)?.maySuspend === true || typeof exp === "object" && exp.maySuspend === true;
7341
7346
  };
7342
- const may = checkSuspension(root, importedSuspension, reportAt);
7347
+ const may = checkSuspension(root, importedSuspension, reportAt, options.forbidSuspension === true);
7343
7348
  checkDecisions(root, (binding) => binding.importedFrom ? importedSuspension(binding) : may.get(binding.name) ?? false, reportAt);
7344
7349
  diagnostics.sort((a, b) => a.span.start - b.span.start || diagnosticCodes.indexOf(a.code) - diagnosticCodes.indexOf(b.code));
7345
7350
  return {
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { B as restore, Qt as Core, Rn as compileLibrary, vt as defineObjectKind, z as newGroup } from "./debug-C_Ob5rkl.js";
2
+ import { B as restore, Bn as compileLibrary, en as Core, vt as defineObjectKind, z as newGroup } from "./debug-s6QIovKS.js";
3
3
  //#region src/save-format.d.ts
4
4
  /**
5
5
  * A save's State Fingerprint (ADR 0142), read from its header and frames
@@ -2182,7 +2182,9 @@ declare const peerKind: ObjectKind<unknown>;
2182
2182
  * `expose` hears `null` for an unnamed exposure. `unexpose` hears a name or
2183
2183
  * a Peer. `post` and `call` hear the Peer, the Selector and the arguments,
2184
2184
  * which may hold Peers. `caller` gives the Caller Identity recorded for
2185
- * `call.delivery`, or Nothing.
2185
+ * `call.delivery`, or Nothing. The optional `release` is the Grant release
2186
+ * hook, for withdrawing the exposures a Grant made when it stops being
2187
+ * effective.
2186
2188
  */
2187
2189
  type PeerImpl = {
2188
2190
  call(call: Call<unknown>, peer: HostObject, message: string, args: Value[]): void;
@@ -2191,6 +2193,7 @@ type PeerImpl = {
2191
2193
  expose(call: Call<unknown>, name?: string): void;
2192
2194
  post(call: Call<unknown>, peer: HostObject, message: string, args: Value[]): void;
2193
2195
  reach(call: Call<unknown>, address: string): void;
2196
+ release?(context: GrantContext<unknown>): void;
2194
2197
  unexpose(call: Call<unknown>, exposure: string | HostObject): void;
2195
2198
  };
2196
2199
  /**
@@ -2609,6 +2612,10 @@ declare function defineCapability<B>(): CapabilityDefiner<B>;
2609
2612
  * by their names, or a map from the name each is granted under.
2610
2613
  */
2611
2614
  declare const operationDeclarations: (capabilities: ReadonlyMap<string, CapabilityDef<unknown>> | Iterable<CapabilityDef<unknown>>) => GrantDecls;
2615
+ /** True exactly when `v` fits `s`, with a Capability argument's acceptance (ADR 0176). */
2616
+ declare const conforms: (v: Value, s: Shape) => boolean;
2617
+ /** The `explain` Built-in's report for `v` against `s` (ADR 0176). */
2618
+ declare const explain: (v: Value, s: Shape) => Value;
2612
2619
  //#endregion
2613
2620
  //#region src/effects.d.ts
2614
2621
  type OperationMode = 'immediate' | 'suspending' | 'fire-and-forget';
@@ -2964,6 +2971,8 @@ type TsRestoreOptions = RestoreOptions & {
2964
2971
  session?: SessionPort;
2965
2972
  };
2966
2973
  type LoadOptions = {
2974
+ /** Refuse any possible Suspension Point as `can't suspend here`; kept by Reload, Extend, Library replacement and restore (ADR 0178). */
2975
+ forbidSuspension?: boolean;
2967
2976
  /** Its Grants, by the name the Script uses for each. */
2968
2977
  grants?: Readonly<Record<string, Grant<any>>>;
2969
2978
  /** Keep only Operations used by this source and its Libraries. */
@@ -3195,6 +3204,7 @@ type MessageView = {
3195
3204
  type Inspection = {
3196
3205
  scripts: {
3197
3206
  disabledGrants?: string[];
3207
+ forbidSuspension?: true;
3198
3208
  mailbox: MessageView[];
3199
3209
  name: string;
3200
3210
  runs: RunView[];
@@ -3264,6 +3274,8 @@ declare class TsGroup implements Group {
3264
3274
  private accounting;
3265
3275
  private discardReason;
3266
3276
  private inputs;
3277
+ private urgentInputs;
3278
+ private chargeInputs;
3267
3279
  private deliveries;
3268
3280
  private broadcasts;
3269
3281
  /**
@@ -3323,7 +3335,7 @@ declare class TsGroup implements Group {
3323
3335
  private evaluationHost;
3324
3336
  private advanceDebugPump;
3325
3337
  private attachSession;
3326
- /** Worker. A Fingerprint covers code, declarations and limits, never state. */
3338
+ /** Worker. A Fingerprint covers code, declarations, limits and `forbidSuspension`, never state. */
3327
3339
  fingerprint(): Uint8Array;
3328
3340
  save(o?: SaveOptions): Uint8Array;
3329
3341
  /** Worker. Refused as a save would be, but writes no Trace record. */
@@ -3388,6 +3400,7 @@ declare class TsGroup implements Group {
3388
3400
  private queueRevoke;
3389
3401
  private applyInput;
3390
3402
  private runsOf;
3403
+ private findRun;
3391
3404
  private forgetWait;
3392
3405
  private cancelRunning;
3393
3406
  /**
@@ -3412,6 +3425,8 @@ declare class TsGroup implements Group {
3412
3425
  private dropStoppedMailbox;
3413
3426
  private acceptDelivery;
3414
3427
  private recordRefusal;
3428
+ private pushInput;
3429
+ private setInputs;
3415
3430
  private landUrgentInputs;
3416
3431
  constructor(options: TsGroupOptions);
3417
3432
  script(name: string): TsScript | undefined;
@@ -3663,4 +3678,4 @@ declare class DebugController {
3663
3678
  enter(pause: DebugPause): void;
3664
3679
  }
3665
3680
  //#endregion
3666
- export { instant as $, waitUs as $n, Group as $t, ScriptSources as A, consoleCapability as An, Mode as Ar, FireOp as At, restore as B, LimitName as Bn, ReleaseHook as Bt, Report as C, CalendarImpl as Cn, SemanticName as Cr, ChargeRequest as Ct, RunEvent as D, TimerImpl as Dn, SemanticTree as Dr, EffectResult as Dt, RestoreResult as E, MusicalClockImpl as En, SemanticToken as Er, Cost as Et, TsGroupOptions as F, LibrarySource as Fn, SyntaxNode as Fr, Metering as Ft, RunStarted as G, Script$1 as Gn, SegmentGrant as Gt, RunAccounting as H, Outcome as Hn, ScopeDecl as Ht, TsRestoreOptions as I, OperationRef as In, SyntaxRule as Ir, Operation as It, Value as J, defaultLimits as Jn, SuspendingOp as Jt, Decimal as K, UnitLoadError as Kn, SegmentLifecycle as Kt, TsScript as L, codeIdentity as Ln, Trivia as Lr, Operations as Lt, SessionPort as M, timerCapability as Mn, Token as Mr, GrantContext as Mt, Settlement as N, Library as Nn, SyntaxElement as Nr, ImmediateOp as Nt, SaveOptions as O, calendarCapability as On, SourceSpan as Or, ErrorDecl as Ot, TsGroup as P, LibraryOptions as Pn, SyntaxErrorCode as Pr, LimitReached as Pt, dec as Q, canConvert as Qn, Core as Qt, Verdict as R, compileLibrary as Rn, syntaxSelector as Rr, PlainArg as Rt, PumpedRequest as S, localeCapability as Sn, SemanticElement as Sr, CapabilityDefiner as St, RestoreOptions as T, Costs as Tn, SemanticScope as Tr, CoordinatedLifecycle as Tt, RunAncestry as U, Run as Un, SegmentContext as Ut, CausalWork as V, Limits as Vn, ReleaseReason as Vt, RunDiscarded as W, RunRecord as Wn, SegmentCoordinator as Wt, bytes as X, loadScript as Xn, operationDeclarations as Xt, bool as Y, deliver as Yn, defineCapability as Yt, civilDate as Z, NotImplementedError as Zn, shape as Zt, LoadOptions as _, SqlValue as _n, BindingKind as _r, PropDef as _t, DebugPause as a, peerKind as an, ScriptError as ar, quantity as at, PumpOptions as b, sqliteCapability as bn, LibraryExport as br, Call as bt, RepeatedEffect as c, HttpServerImpl as cn, BodyKind as cr, sourceForm as ct, Counters as d, userCapability as dn, EventEntry as dr, nowMicros as dt, Script as en, HostError as er, isReadable as et, Decided as f, StoreImpl as fn, Instruction as fr, parseInstant as ft, Inspection as g, SqlRows as gn, Binding as gr, ObjectKindDef as gt, GroupOptions as h, SqlParams as hn, disassemble as hr, ObjectKind as ht, DebugInstruction as i, peerCapability as in, MailboxFull as ir, num as it, SessionControls as j, musicalClockCapability as jn, TokType as jr, Grant as jt, ScriptCodeRequest as k, clockCapability as kn, Lexer as kr, FieldShape as kt, CancellationOptions as l, httpCapability as ln, CodeUnit as lr, text as lt, EffectFailure as m, storeCapability as mn, UnwindEntry as mr, ObjectElements as mt, DebugEvaluation as n, coreVersions as nn, LoadDiagnostic as nr, map as nt, DebugSnapshot as o, HttpClientImpl as on, SendFailedReason as or, range as ot, Deciding as p, add as pn, Operand as pr, HostObject as pt, Kind as q, callFunction as qn, Shape as qt, DebugFrame as r, PeerImpl as rn, LoadError as rr, nothing as rt, DebugSource as s, HttpImpl as sn, Body as sr, record as st, DebugController as t, Versions as tn, HostErrorCode as tr, list as tt, CarryOver as u, UserImpl as un, EventBranch as ur, formatInstant as ut, Message as v, SqliteBinding as vn, ExportKind as vr, defineObjectKind as vt, Requested as w, ConsoleImpl as wn, SemanticNode as wr, ChargeResult as wt, PumpResult as x, LocaleImpl as xn, NameRole as xr, CapabilityDef as xt, PendingCall as y, SqliteImpl as yn, FunctionContract as yr, GrantDecls as yt, newGroup as z, replacementLibraries as zn, syntaxText as zr, PlainResult as zt };
3681
+ export { instant as $, NotImplementedError as $n, shape as $t, ScriptSources as A, calendarCapability as An, SourceSpan as Ar, FireOp as At, restore as B, compileLibrary as Bn, syntaxSelector as Br, ReleaseHook as Bt, Report as C, LocaleImpl as Cn, NameRole as Cr, ChargeRequest as Ct, RunEvent as D, Costs as Dn, SemanticScope as Dr, EffectResult as Dt, RestoreResult as E, ConsoleImpl as En, SemanticNode as Er, Cost as Et, TsGroupOptions as F, Library as Fn, SyntaxElement as Fr, Metering as Ft, RunStarted as G, Run as Gn, SegmentGrant as Gt, RunAccounting as H, LimitName as Hn, ScopeDecl as Ht, TsRestoreOptions as I, LibraryOptions as In, SyntaxErrorCode as Ir, Operation as It, Value as J, UnitLoadError as Jn, SuspendingOp as Jt, Decimal as K, RunRecord as Kn, SegmentLifecycle as Kt, TsScript as L, LibrarySource as Ln, SyntaxNode as Lr, Operations as Lt, SessionPort as M, consoleCapability as Mn, Mode as Mr, GrantContext as Mt, Settlement as N, musicalClockCapability as Nn, TokType as Nr, ImmediateOp as Nt, SaveOptions as O, MusicalClockImpl as On, SemanticToken as Or, ErrorDecl as Ot, TsGroup as P, timerCapability as Pn, Token as Pr, LimitReached as Pt, dec as Q, loadScript as Qn, operationDeclarations as Qt, Verdict as R, OperationRef as Rn, SyntaxRule as Rr, PlainArg as Rt, PumpedRequest as S, sqliteCapability as Sn, LibraryExport as Sr, CapabilityDefiner as St, RestoreOptions as T, CalendarImpl as Tn, SemanticName as Tr, CoordinatedLifecycle as Tt, RunAncestry as U, Limits as Un, SegmentContext as Ut, CausalWork as V, replacementLibraries as Vn, syntaxText as Vr, ReleaseReason as Vt, RunDiscarded as W, Outcome as Wn, SegmentCoordinator as Wt, bytes as X, defaultLimits as Xn, defineCapability as Xt, bool as Y, callFunction as Yn, conforms as Yt, civilDate as Z, deliver as Zn, explain as Zt, LoadOptions as _, SqlParams as _n, disassemble as _r, PropDef as _t, DebugPause as a, PeerImpl as an, LoadError as ar, quantity as at, PumpOptions as b, SqliteBinding as bn, ExportKind as br, Call as bt, RepeatedEffect as c, HttpClientImpl as cn, SendFailedReason as cr, sourceForm as ct, Counters as d, httpCapability as dn, CodeUnit as dr, nowMicros as dt, Core as en, canConvert as er, isReadable as et, Decided as f, UserImpl as fn, EventBranch as fr, parseInstant as ft, Inspection as g, storeCapability as gn, UnwindEntry as gr, ObjectKindDef as gt, GroupOptions as h, add as hn, Operand as hr, ObjectKind as ht, DebugInstruction as i, coreVersions as in, LoadDiagnostic as ir, num as it, SessionControls as j, clockCapability as jn, Lexer as jr, Grant as jt, ScriptCodeRequest as k, TimerImpl as kn, SemanticTree as kr, FieldShape as kt, CancellationOptions as l, HttpImpl as ln, Body as lr, text as lt, EffectFailure as m, StoreImpl as mn, Instruction as mr, ObjectElements as mt, DebugEvaluation as n, Script as nn, HostError as nr, map as nt, DebugSnapshot as o, peerCapability as on, MailboxFull as or, range as ot, Deciding as p, userCapability as pn, EventEntry as pr, HostObject as pt, Kind as q, Script$1 as qn, Shape as qt, DebugFrame as r, Versions as rn, HostErrorCode as rr, nothing as rt, DebugSource as s, peerKind as sn, ScriptError as sr, record as st, DebugController as t, Group as tn, waitUs as tr, list as tt, CarryOver as u, HttpServerImpl as un, BodyKind as ur, formatInstant as ut, Message as v, SqlRows as vn, Binding as vr, defineObjectKind as vt, Requested as w, localeCapability as wn, SemanticElement as wr, ChargeResult as wt, PumpResult as x, SqliteImpl as xn, FunctionContract as xr, CapabilityDef as xt, PendingCall as y, SqlValue as yn, BindingKind as yr, GrantDecls as yt, newGroup as z, codeIdentity as zn, Trivia as zr, PlainResult as zt };
package/debug.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { a as DebugPause, c as RepeatedEffect, ct as sourceForm, et as isReadable, i as DebugInstruction, n as DebugEvaluation, o as DebugSnapshot, r as DebugFrame, s as DebugSource, t as DebugController } from "./debug-C_Ob5rkl.js";
2
+ import { a as DebugPause, c as RepeatedEffect, ct as sourceForm, et as isReadable, i as DebugInstruction, n as DebugEvaluation, o as DebugSnapshot, r as DebugFrame, s as DebugSource, t as DebugController } from "./debug-s6QIovKS.js";
3
3
  export { type DebugController, type DebugEvaluation, type DebugFrame, type DebugInstruction, type DebugPause, type DebugSnapshot, type DebugSource, type RepeatedEffect, isReadable, sourceForm };
package/debug.js CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- export { O as isReadable, $ as sourceForm } from "./errors-P3ga1I-9.js";
2
+ export { A as isReadable, rt as sourceForm } from "./errors-VuwK669R.js";
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { $t as Group, b as PumpOptions, h as GroupOptions, x as PumpResult } from "./debug-C_Ob5rkl.js";
2
+ import { b as PumpOptions, h as GroupOptions, tn as Group, x as PumpResult } from "./debug-s6QIovKS.js";
3
3
  //#region src/operation-promises.d.ts
4
4
  /** A suspending call whose Host `run` Promise has not settled. */
5
5
  type PendingOperation = {
package/driver.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { a as autoDrive, i as asyncDispose, n as Drive, o as newDrivenGroup, r as DrivenGroupOptions, s as PendingOperation, t as AutoDriveOptions } from "./driver-CLi_OmyQ.js";
2
+ import { a as autoDrive, i as asyncDispose, n as Drive, o as newDrivenGroup, r as DrivenGroupOptions, s as PendingOperation, t as AutoDriveOptions } from "./driver-D5yrK3Nu.js";
3
3
  export { AutoDriveOptions, Drive, DrivenGroupOptions, type PendingOperation, asyncDispose, autoDrive, newDrivenGroup };
package/driver.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { Kt as nowMicros } from "./errors-P3ga1I-9.js";
2
+ import { Xt as nowMicros } from "./errors-VuwK669R.js";
3
3
  import { r as waitForOperations, t as pendingOperations } from "./operation-promises-ClA1BTaS.js";
4
4
  //#region src/driver.ts
5
5
  /** Creates a Group on `core` ready to drive queued Inputs from the Host's event loop. */
@@ -1,6 +1,6 @@
1
1
 
2
- import { T as instant, et as text, o as invalidValue, q as requireValue, t as HostError } from "./errors-P3ga1I-9.js";
3
- import { bt as defineValueCapability, n as ScriptError } from "./operations-CGjDlkGU.js";
2
+ import { D as instant, Z as requireValue, it as text, o as invalidValue, t as HostError } from "./errors-VuwK669R.js";
3
+ import { n as ScriptError, xt as defineValueCapability } from "./operations-BAELnqwf.js";
4
4
  import { n as toBase64 } from "./base64-CDO-a06R.js";
5
5
  //#region src/standard-capability-checks.ts
6
6
  const checks = /* @__PURE__ */ new WeakMap();
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { Dt as EffectResult, J as Value, Mt as GrantContext, Ut as SegmentContext, bt as Call, fn as StoreImpl } from "./debug-C_Ob5rkl.js";
3
- import { i as WatchLimits, n as RouterOptions, t as NotificationRouter } from "./router-D0rf5SkW.js";
2
+ import { Dt as EffectResult, J as Value, Mt as GrantContext, Ut as SegmentContext, bt as Call, mn as StoreImpl } from "./debug-s6QIovKS.js";
3
+ import { i as WatchLimits, n as RouterOptions, t as NotificationRouter } from "./router-DXoJ_2Z4.js";
4
4
  //#region src/store/engine.d.ts
5
5
  /** A Store's limits, each counted by logical size (chapter 8). */
6
6
  type StoreQuotas = {
@@ -1,10 +1,10 @@
1
1
 
2
- import { A as listValues, L as nothing, et as text, o as invalidValue, v as dec } from "./errors-P3ga1I-9.js";
3
- import { Q as sizeOf, ut as compareText } from "./operations-CGjDlkGU.js";
4
- import { i as decodeValueMembers } from "./readers-yMS1eAOp.js";
5
- import { n as quoteJSON, t as encodeValue } from "./encoding-BL2ECJmg.js";
6
- import { n as hostScriptError, t as add } from "./store-capability-DBLlWaNO.js";
7
- import { n as createRouter, t as changed } from "./router-Bm7A2kjt.js";
2
+ import { P as listValues, V as nothing, b as dec, it as text, o as invalidValue } from "./errors-VuwK669R.js";
3
+ import { Q as sizeOf, ut as compareText } from "./operations-BAELnqwf.js";
4
+ import { i as decodeValueMembers } from "./readers-BG8g59qS.js";
5
+ import { n as quoteJSON, t as encodeValue } from "./encoding-B7MCQ4ii.js";
6
+ import { n as hostScriptError, t as add } from "./store-capability-CxQJ_Huz.js";
7
+ import { n as createRouter, t as changed } from "./router-DXmPA-qi.js";
8
8
  //#region src/store/engine.ts
9
9
  /** The Session Store's quotas (chapter 12, The Session Store). */
10
10
  const sessionQuotas = Object.freeze({
@@ -2567,6 +2567,20 @@ const characterJoinEnd = (s) => {
2567
2567
  };
2568
2568
  const asciiOnly = /^[\u0000-\u007f]*$/;
2569
2569
  const isASCII = (s) => asciiOnly.test(s);
2570
+ /** The UTF-8 byte count of `s`, as TextEncoder would encode it, unallocated. */
2571
+ const utf8Length = (s) => {
2572
+ let bytes = s.length;
2573
+ for (let i = 0; i < s.length; i++) {
2574
+ const c = s.charCodeAt(i);
2575
+ if (c < 128) continue;
2576
+ if (c < 2048) bytes += 1;
2577
+ else if (c >= 55296 && c <= 56319 && (s.charCodeAt(i + 1) & 64512) === 56320) {
2578
+ bytes += 2;
2579
+ i++;
2580
+ } else bytes += 2;
2581
+ }
2582
+ return bytes;
2583
+ };
2570
2584
  /** Slices `s` at Character boundaries from characterBoundaries. */
2571
2585
  const charactersAt = (s, boundaries) => {
2572
2586
  const result = new Array(boundaries.length - 1);
@@ -2648,7 +2662,6 @@ const lower = (s) => {
2648
2662
  };
2649
2663
  //#endregion
2650
2664
  //#region src/text-storage.ts
2651
- const encoder = new TextEncoder();
2652
2665
  const headOf = (text, boundaries) => {
2653
2666
  const end = characterJoinEnd(text);
2654
2667
  let count = 1;
@@ -2674,7 +2687,7 @@ var TextStorage = class TextStorage {
2674
2687
  this.#utf8 = ascii ? text.length : void 0;
2675
2688
  }
2676
2689
  get utf8Length() {
2677
- return this.#utf8 ??= encoder.encode(this.text).length;
2690
+ return this.#utf8 ??= utf8Length(this.text);
2678
2691
  }
2679
2692
  get characterCount() {
2680
2693
  if (this.#count === void 0) {
@@ -3449,6 +3462,14 @@ let isDecimal;
3449
3462
  let ownedMapPairs;
3450
3463
  /** Internal: immutable Text storage and its cached derived facts. */
3451
3464
  let textStorage;
3465
+ /**
3466
+ * Internal: a Value's cached logical size and contents (costs.ts), or -1
3467
+ * before either is known. Caching never changes what the Value is.
3468
+ */
3469
+ let knownSize;
3470
+ let knownContents;
3471
+ let cacheSize;
3472
+ let cacheContents;
3452
3473
  let textValue;
3453
3474
  var Decimal = class Decimal {
3454
3475
  #canonical;
@@ -3492,6 +3513,8 @@ var Decimal = class Decimal {
3492
3513
  var Value = class Value {
3493
3514
  #data;
3494
3515
  #kind;
3516
+ #size = -1;
3517
+ #contents = -1;
3495
3518
  constructor(token, kind, payload) {
3496
3519
  if (token !== valueToken) invalidValue("Use a named Value constructor");
3497
3520
  this.#kind = kind;
@@ -3502,6 +3525,14 @@ var Value = class Value {
3502
3525
  makeValue = (kind, payload) => new Value(valueToken, kind, payload);
3503
3526
  ownedMapPairs = (value) => value.#kind === "map" ? value.#data.pairs() : void 0;
3504
3527
  textStorage = (value) => value.#data;
3528
+ knownSize = (value) => value.#size;
3529
+ knownContents = (value) => value.#contents;
3530
+ cacheSize = (value, size) => {
3531
+ value.#size = size;
3532
+ };
3533
+ cacheContents = (value, contents) => {
3534
+ value.#contents = contents;
3535
+ };
3505
3536
  textValue = (storage) => makeValue("text", storage);
3506
3537
  editListValue = (current, i, value) => makeValue("list", current.#data.set(i, value));
3507
3538
  editMapValue = (current, key, value) => {
@@ -4243,4 +4274,4 @@ var ScriptError = class extends Error {
4243
4274
  const sendFailed = (reason, error) => new ScriptError("send failed", `No answer came: the receiver's Run ended ${reason}`, map([["reason", text(reason)], ...error ? [["error", error]] : []]));
4244
4275
  const hostDetail = (error) => error instanceof Error ? `${error.name}: ${error.message}` : `the Host threw ${typeof error === "symbol" ? error.toString() : String(error)}`;
4245
4276
  //#endregion
4246
- export { sourceForm as $, charactersAt as $t, listValues as A, subtract as At, ownedMapPairs as B, civilOfUs as Bt, functionsBelongTo as C, integerOf as Ct, isDecimal as D, negate as Dt, instantOf as E, multiply as Et, mapOfLayout as F, addMonths as Ft, record as G, isoWeek as Gt, quantity as H, dayOfYear as Ht, mapWithEntry as I, checkInstant as It, sliceText as J, parseInstant as Jt, requireArgs as K, nowMicros as Kt, nothing as L, civilDays as Lt, literalDigits as M, DateRangeError as Mt, map as N, US_PER_DAY as Nt, isReadable as O, powerInteger as Ot, mapLayout as P, US_PER_SECOND as Pt, smallInteger as Q, characterBoundaries as Qt, num as R, civilFromFields as Rt, functionValue as S, formatDec as St, instant as T, mod as Tt, quantityOf as U, formatInstant as Ut, patternValue as V, civilUs as Vt, range as W, isInstant as Wt, smallDecimalNumber as X, weekday as Xt, smallCoefficient as Y, parseInstantText as Yt, smallExponent as Z, assertScalarText as Zt, concatText as _, decOf as _t, hostDetail as a, simpleFold as an, fromBase as at, displayText as b, div as bt, Decimal as c, builtins as cn, parseUnit as ct, bytes as d, libraryExports as dn, toBase as dt, generalCategory as en, text as et, bytesOf as f, unitKinds as fn, unitEntry as ft, compareBytes as g, compareDec as gt, civilOf as h, add as ht, ScriptError as i, scalarCount as in, combine as it, listWithItem as j, withinLimits as jt, list as k, roundRatio as kt, Value as l, diagnosticCodes as ln, powerOf as lt, civilDate as m, ArithmeticError as mt, LoadError as n, lower as nn, trimWhiteSpace as nt, invalidValue as o, upper as on, musicalKind as ot, canonicalNumber as p, units as pn, unitText as pt, requireValue as q, parseCivil as qt, MailboxFull as r, normalizeNFC as rn, UnitError as rt, sendFailed as s, unicodeVersion as sn, ownUnit as st, HostError as t, isWhiteSpace as tn, textStorage as tt, bool as u, grammar as un, sameDimension as ut, dec as v, digitCount as vt, hiddenCodePoint as w, isInteger as wt, extendList as x, divide as xt, decimalParts as y, digitsOf as yt, objectValue as z, civilOfDays as zt };
4277
+ export { smallCoefficient as $, parseInstantText as $t, isReadable as A, multiply as At, mapWithEntry as B, checkInstant as Bt, extendList as C, digitsOf as Ct, instant as D, integerOf as Dt, hiddenCodePoint as E, formatDec as Et, listWithItem as F, withinLimits as Ft, patternValue as G, civilUs as Gt, num as H, civilFromFields as Ht, literalDigits as I, DateRangeError as It, range as J, isInstant as Jt, quantity as K, dayOfYear as Kt, map as L, US_PER_DAY as Lt, knownSize as M, powerInteger as Mt, list as N, roundRatio as Nt, instantOf as O, isInteger as Ot, listValues as P, subtract as Pt, sliceText as Q, parseInstant as Qt, mapLayout as R, US_PER_SECOND as Rt, displayText as S, digitCount as St, functionsBelongTo as T, divide as Tt, objectValue as U, civilOfDays as Ut, nothing as V, civilDays as Vt, ownedMapPairs as W, civilOfUs as Wt, requireArgs as X, nowMicros as Xt, record as Y, isoWeek as Yt, requireValue as Z, parseCivil as Zt, civilOf as _, unitKinds as _n, unitText as _t, hostDetail as a, isWhiteSpace as an, textStorage as at, dec as b, compareDec as bt, Decimal as c, scalarCount as cn, combine as ct, bytes as d, utf8Length as dn, ownUnit as dt, weekday as en, smallDecimalNumber as et, bytesOf as f, unicodeVersion as fn, parseUnit as ft, civilDate as g, libraryExports as gn, unitEntry as gt, canonicalNumber as h, grammar as hn, toBase as ht, ScriptError as i, generalCategory as in, text as it, knownContents as j, negate as jt, isDecimal as k, mod as kt, Value as l, simpleFold as ln, fromBase as lt, cacheSize as m, diagnosticCodes as mn, sameDimension as mt, LoadError as n, characterBoundaries as nn, smallInteger as nt, invalidValue as o, lower as on, trimWhiteSpace as ot, cacheContents as p, builtins as pn, powerOf as pt, quantityOf as q, formatInstant as qt, MailboxFull as r, charactersAt as rn, sourceForm as rt, sendFailed as s, normalizeNFC as sn, UnitError as st, HostError as t, assertScalarText as tn, smallExponent as tt, bool as u, upper as un, musicalKind as ut, compareBytes as v, units as vn, ArithmeticError as vt, functionValue as w, div as wt, decimalParts as x, decOf as xt, concatText as y, add as yt, mapOfLayout as z, addMonths as zt };