@northtalk/ts 0.4.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.
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { J as Value } from "./debug-C72o2pZy.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
  /// <reference lib="esnext.disposable" />
2
- import { An as compileLibrary, B as restore, Zt as Core, vt as defineObjectKind, z as newGroup } from "./debug-C72o2pZy.js";
2
+ import { An as compileLibrary, B as restore, Zt as Core, vt as defineObjectKind, z as newGroup } from "./debug-nN5tQ_p4.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
@@ -2901,6 +2901,8 @@ type ScriptSources = {
2901
2901
  };
2902
2902
  type RestoreOptions = GroupOptions & {
2903
2903
  grants(script: string, name: string): Grant<unknown> | undefined;
2904
+ /** With "reload changed", keep each changed Script's mailbox, as Reload's keepMailbox does; ignored otherwise. */
2905
+ keepMailbox?: boolean;
2904
2906
  libraries: readonly Library[];
2905
2907
  onMismatch: 'reject' | 'variables only' | 'reload changed';
2906
2908
  resolve(kind: string, id: string): {
@@ -3378,6 +3380,8 @@ declare class TsGroup implements Group {
3378
3380
  private releaseParked;
3379
3381
  /** A Script's Persistent State: its Script Variables and the messages it holds. */
3380
3382
  private persistentState;
3383
+ /** The logical size of a Script's queued messages, without its Runs. */
3384
+ private mailboxSize;
3381
3385
  /** Worker, and the Host Input `vars`: the Group, read without changing it. */
3382
3386
  private waitView;
3383
3387
  /** A Run's calls and sends that a Rewind leaves done (ADR 0068). */
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-C72o2pZy.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-nN5tQ_p4.js";
3
3
  export { type DebugController, type DebugEvaluation, type DebugFrame, type DebugInstruction, type DebugPause, type DebugSnapshot, type DebugSource, type RepeatedEffect, isReadable, sourceForm };
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { Qt as Group, b as PumpOptions, h as GroupOptions, x as PumpResult } from "./debug-C72o2pZy.js";
2
+ import { Qt as Group, b as PumpOptions, h as GroupOptions, x as PumpResult } from "./debug-nN5tQ_p4.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-ClV_UDEK.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-Bf-7Roq6.js";
3
3
  export { AutoDriveOptions, Drive, DrivenGroupOptions, type PendingOperation, asyncDispose, autoDrive, newDrivenGroup };
@@ -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, on as StoreImpl } from "./debug-C72o2pZy.js";
3
- import { i as WatchLimits, n as RouterOptions, t as NotificationRouter } from "./router-BspOCPA0.js";
2
+ import { Dt as EffectResult, J as Value, Mt as GrantContext, Ut as SegmentContext, bt as Call, on as StoreImpl } from "./debug-nN5tQ_p4.js";
3
+ import { i as WatchLimits, n as RouterOptions, t as NotificationRouter } from "./router-CBuMIl6i.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 = {
@@ -11480,6 +11480,7 @@ var TsGroup = class TsGroup {
11480
11480
  const restoreLine = (result) => recordLine("restore", [], [
11481
11481
  ["from", saveId],
11482
11482
  ["mismatch", o.onMismatch === "variables only" ? "variables-only" : o.onMismatch === "reload changed" ? "reload-changed" : null],
11483
+ ["mailbox", o.keepMailbox ? "keep" : null],
11483
11484
  ["unbound", unbound.length ? idList(unbound) : null],
11484
11485
  ["withheld", withheld.length ? idList(withheld) : null],
11485
11486
  ["fingerprint", savedFingerprint],
@@ -11523,7 +11524,8 @@ var TsGroup = class TsGroup {
11523
11524
  partial,
11524
11525
  changed,
11525
11526
  variablesOnly,
11526
- result
11527
+ result,
11528
+ keepMailbox: partial && !!o.keepMailbox
11527
11529
  });
11528
11530
  group.flushAccounting(result.reports);
11529
11531
  emitting = true;
@@ -11630,7 +11632,7 @@ var TsGroup = class TsGroup {
11630
11632
  }
11631
11633
  /** Publishes a save's state in the restored Group. */
11632
11634
  applyState(state, o) {
11633
- const { result, variablesOnly, partial, changed } = o;
11635
+ const { result, variablesOnly, partial, changed, keepMailbox } = o;
11634
11636
  const objects = [...this.objects.values()];
11635
11637
  const g = state.group;
11636
11638
  this.deliveries = g.deliveries;
@@ -11954,12 +11956,12 @@ var TsGroup = class TsGroup {
11954
11956
  }
11955
11957
  const abandoned = [];
11956
11958
  for (const [script, variables] of carried) {
11957
- const ended = this.reloadRestored(script);
11959
+ const ended = this.reloadRestored(script, keepMailbox);
11958
11960
  result.discardedRuns.push(...ended.runs);
11959
11961
  result.droppedMessages.push(...ended.messages);
11960
11962
  abandoned.push(...ended.pendingCalls);
11961
11963
  script.loaded.variables = variables;
11962
- if (script.loaded.variablesSize() > script.limits.persistentState) throw new HostError("state too large");
11964
+ if (script.loaded.variablesSize() + this.mailboxSize(script) > script.limits.persistentState) throw new HostError("state too large");
11963
11965
  }
11964
11966
  result.abandonedCalls = abandoned.sort(compareCallIds);
11965
11967
  result.pending = this.pendingOperations();
@@ -12804,9 +12806,10 @@ var TsGroup = class TsGroup {
12804
12806
  * runs: this Script's Grants, Segments and scopes were never live here.
12805
12807
  * Its open Decision recipients are discarded, reported at the first Pump.
12806
12808
  */
12807
- reloadRestored(s) {
12809
+ reloadRestored(s, keepMailbox) {
12808
12810
  const runs = this.runsOf(s);
12809
- const messages = s.queue.filter((q) => !("run" in q));
12811
+ const mailbox = s.queue.filter((q) => !("run" in q));
12812
+ const messages = keepMailbox ? [] : mailbox;
12810
12813
  const pendingCalls = [];
12811
12814
  for (const r of runs) {
12812
12815
  this.accumulateRunCosts(s, r.run);
@@ -12815,7 +12818,7 @@ var TsGroup = class TsGroup {
12815
12818
  this.discardDecision(r.delivery, s.name, r.id);
12816
12819
  }
12817
12820
  for (const d of messages) this.discardDecision(d, s.name);
12818
- s.queue = [];
12821
+ s.queue = keepMailbox ? mailbox : [];
12819
12822
  if (!s.stopped) this.reportStop(s, "reload", runs, messages, pendingCalls, null);
12820
12823
  s.stopped = false;
12821
12824
  delete s.stopReason;
@@ -13017,7 +13020,7 @@ var TsGroup = class TsGroup {
13017
13020
  writeDiagnostics(error) {
13018
13021
  if (error instanceof LoadError) for (const d of error.diagnostics) this.trace?.(recordLine("diag", [d.unit], [["code", JSON.stringify(d.code)], ["pos", `${d.line}:${d.col}`]]));
13019
13022
  }
13020
- replacement(s, source, carry, libraries = this.libraries, extensions = []) {
13023
+ replacement(s, source, carry, libraries = this.libraries, extensions = [], keepMailbox = false) {
13021
13024
  const grants = availableGrants(s);
13022
13025
  const p = prepare("script", s.name, source, libraries, Object.keys(s.objects), declarationsOf(grants), void 0, propertyChecks(s.objects, s.owner?.handle));
13023
13026
  const loaded = this.loadPrepared(s.name, p, s.limits);
@@ -13048,7 +13051,7 @@ var TsGroup = class TsGroup {
13048
13051
  if (old >= 0) loaded.variables[i] = variables[old];
13049
13052
  }
13050
13053
  }
13051
- if ((carry === "carry variables" || extensions.length > 0) && loaded.variablesSize() > s.limits.persistentState) {
13054
+ if ((carry === "carry variables" || extensions.length > 0 || keepMailbox) && loaded.variablesSize() + (keepMailbox ? this.mailboxSize(s) : 0) > s.limits.persistentState) {
13052
13055
  this.trace?.(recordLine("refused", [], [["code", JSON.stringify("state too large")]]));
13053
13056
  throw new HostError("state too large");
13054
13057
  }
@@ -13071,7 +13074,7 @@ var TsGroup = class TsGroup {
13071
13074
  ["source", displayText(source)],
13072
13075
  ["identity", p.identity]
13073
13076
  ], true));
13074
- const replacement = this.replacement(s, source, carry);
13077
+ const replacement = this.replacement(s, source, carry, this.libraries, [], keepMailbox);
13075
13078
  return this.replaceScripts([{
13076
13079
  s,
13077
13080
  ...replacement
@@ -14729,7 +14732,13 @@ var TsGroup = class TsGroup {
14729
14732
  persistentState(s, skip = 0) {
14730
14733
  let total = s.loaded.variablesSize();
14731
14734
  for (const r of [...s.suspended, ...s.parked]) total += r.run.size();
14732
- for (const item of s.queue.slice(skip)) total += "run" in item ? item.run.size() : partSize("message", 0, item.args.reduce((sum, v) => sum + sizeOf(v), 0) + (item.fn ? sizeOf(item.fn) : 0));
14735
+ for (const item of s.queue.slice(skip)) total += "run" in item ? item.run.size() : messageSize(item);
14736
+ return total;
14737
+ }
14738
+ /** The logical size of a Script's queued messages, without its Runs. */
14739
+ mailboxSize(s) {
14740
+ let total = 0;
14741
+ for (const item of s.queue) if (!("run" in item)) total += messageSize(item);
14733
14742
  return total;
14734
14743
  }
14735
14744
  /** Worker, and the Host Input `vars`: the Group, read without changing it. */
@@ -14966,6 +14975,7 @@ const messageFields = (m) => {
14966
14975
  ];
14967
14976
  };
14968
14977
  const newGroup = (o) => new TsGroup(o);
14978
+ const messageSize = (d) => partSize("message", 0, d.args.reduce((sum, v) => sum + sizeOf(v), 0) + (d.fn ? sizeOf(d.fn) : 0));
14969
14979
  const restore = (bytes, options) => TsGroup.restore(bytes, options);
14970
14980
  //#endregion
14971
14981
  export { lowerTree as S, deliver as _, recordLine as a, compileSource as b, codeIdentity as c, stdlibSources as d, Run as f, defaultLimits as g, callFunction as h, restore as i, compileLibrary as l, UnitLoadError as m, TsScript as n, traceValue as o, Script as p, newGroup as r, stateFingerprint$1 as s, TsGroup as t, replacementLibraries as u, loadScript as v, exportsOf as x, LoweringError as y };
package/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { J as Value, Qt as Group, gt as ObjectKindDef, ht as ObjectKind, nn as HttpImpl, x as PumpResult } from "./debug-C72o2pZy.js";
2
+ import { J as Value, Qt as Group, gt as ObjectKindDef, ht as ObjectKind, nn as HttpImpl, x as PumpResult } from "./debug-nN5tQ_p4.js";
3
3
  //#region src/http/router.d.ts
4
4
  /** The largest request body the router reads by default: 1 MiB. */
5
5
  export declare const HTTP_DEFAULT_MAX_BODY_BYTES: number;