@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/wasm.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { An as Outcome, At as ImmediateOp, B as CausalWork, Bt as SegmentCoordinator, C as Requested, Cn as LibrarySource, Ct as Cost, Dt as FireOp, Et as FieldShape, Ft as PlainResult, G as Decimal, Gn as LoadError, Gt as defineCapability, H as RunAncestry, Hn as HostError, Ht as SegmentLifecycle, It as ReleaseHook, J as bool, Jn as SendFailedReason, Jt as Group, K as Kind, Kn as MailboxFull, Kt as shape, L as Verdict, Lt as ReleaseReason, M as Settlement, Mt as Operation, Nt as Operations, On as LimitName, Ot as Grant, Pt as PlainArg, Q as instant, Qt as HttpImpl, Rt as ScopeDecl, S as Report, St as CoordinatedLifecycle, T as RestoreResult, Tt as ErrorDecl, U as RunDiscarded, Un as HostErrorCode, Ut as Shape, V as RunAccounting, Vt as SegmentGrant, W as RunStarted, Wn as LoadDiagnostic, Wt as SuspendingOp, X as civilDate, Xt as Versions, Y as bytes, Yt as Script, Z as dec, _ as Message, an as SqlParams, at as range, b as PumpResult, bt as CapabilityDef, c as CancellationOptions, cn as SqliteBinding, ct as text, d as Decided, dn as LocaleImpl, dt as parseInstant, en as UserImpl, et as list, f as Deciding, ft as HostObject, g as LoadOptions, gn as TimerImpl, gt as PropDef, h as Inspection, hn as Costs, ht as ObjectKindDef, it as quantity, jt as LimitReached, kn as Limits, kt as GrantContext, l as CarryOver, ln as SqliteImpl, lt as formatInstant, m as GroupOptions, mn as ConsoleImpl, mt as ObjectKind, nn as StoreImpl, nt as nothing, on as SqlRows, ot as record, p as EffectFailure, pn as CalendarImpl, pt as ObjectElements, q as Value, qn as ScriptError, qt as Core, rn as add, rt as num, sn as SqlValue, tt as map, u as Counters, ut as nowMicros, v as PendingCall, vt as GrantDecls, w as RestoreOptions, wn as OperationRef, wt as EffectResult, x as PumpedRequest, xn as Library, xt as CapabilityDefiner, y as PumpOptions, yt as Call, zt as SegmentContext } from "./debug-CY9x_Wsi.js";
3
- import { _ as PlainValue, a as InlineOperation, b as toValue, c as DrivenGroup, d as ScriptWithHandlers, f as handlersOf, g as FromValueOptions, h as encodeValue, i as InlineFunction, l as createGroup, m as encodeJson, n as MessageDecl, o as inlineGrants, p as decodeJson, r as exportManifest, s as CreateGroupOptions, t as ManifestSpec, u as Handlers, v as ToValueOptions, x as talk, y as fromValue } from "./manifest-CeavwKxo.js";
4
- import { a as decodeValue, n as Json, o as readDisplay } from "./readers-DMCXzY3X.js";
5
- import { t as BinaryValueOptions } from "./binary-value-BcHcwVLO.js";
2
+ import { $ as instant, $t as Script, At as FireOp, Bt as ReleaseHook, C as Report, Ct as ChargeRequest, Dn as LibrarySource, Dt as EffectResult, E as RestoreResult, Et as Cost, Ft as Metering, G as RunStarted, Gt as SegmentGrant, H as RunAccounting, Ht as ScopeDecl, It as Operation, J as Value, Jn as LoadDiagnostic, Jt as SuspendingOp, K as Decimal, Kn as HostError, Kt as SegmentLifecycle, Lt as Operations, Mn as LimitName, Mt as GrantContext, N as Settlement, Nn as Limits, Nt as ImmediateOp, On as OperationRef, Ot as ErrorDecl, Pn as Outcome, Pt as LimitReached, Q as dec, Qn as SendFailedReason, Qt as Group, R as Verdict, Rt as PlainArg, S as PumpedRequest, St as CapabilityDefiner, T as RestoreOptions, Tn as Library, Tt as CoordinatedLifecycle, U as RunAncestry, Ut as SegmentContext, V as CausalWork, Vt as ReleaseReason, W as RunDiscarded, Wt as SegmentCoordinator, X as bytes, Xn as MailboxFull, Xt as shape, Y as bool, Yn as LoadError, Yt as defineCapability, Z as civilDate, Zn as ScriptError, Zt as Core, _ as LoadOptions, _n as CalendarImpl, _t as PropDef, at as quantity, b as PumpOptions, bn as TimerImpl, bt as Call, d as Counters, dn as SqlValue, dt as nowMicros, en as Versions, f as Decided, fn as SqliteBinding, ft as parseInstant, g as Inspection, gt as ObjectKindDef, h as GroupOptions, hn as LocaleImpl, ht as ObjectKind, in as UserImpl, it as num, jt as Grant, kt as FieldShape, l as CancellationOptions, ln as SqlParams, lt as text, m as EffectFailure, mt as ObjectElements, nn as HttpImpl, nt as map, on as StoreImpl, ot as range, p as Deciding, pn as SqliteImpl, pt as HostObject, q as Kind, qn as HostErrorCode, qt as Shape, rt as nothing, sn as add, st as record, tt as list, u as CarryOver, un as SqlRows, ut as formatInstant, v as Message, vn as ConsoleImpl, w as Requested, wt as ChargeResult, x as PumpResult, xt as CapabilityDef, y as PendingCall, yn as Costs, yt as GrantDecls, zt as PlainResult } from "./debug-nN5tQ_p4.js";
3
+ import { _ as PlainValue, a as InlineOperation, b as toValue, c as DrivenGroup, d as ScriptWithHandlers, f as handlersOf, g as FromValueOptions, h as encodeValue, i as InlineFunction, l as createGroup, m as encodeJson, n as MessageDecl, o as inlineGrants, p as decodeJson, r as exportManifest, s as CreateGroupOptions, t as ManifestSpec, u as Handlers, v as ToValueOptions, x as talk, y as fromValue } from "./manifest-DYAbIyQm.js";
4
+ import { a as decodeValue, n as Json, o as readDisplay } from "./readers-L90Hoa97.js";
5
+ import { t as BinaryValueOptions } from "./binary-value-B3knLdHD.js";
6
6
  //#region src/wasm/reactor.d.ts
7
7
  /** Text the reactor writes to stdout or stderr, such as a fatal error. */
8
8
  type Diagnostics = (line: string) => void;
@@ -173,6 +173,8 @@ export declare class WasmGroup implements Group {
173
173
  pump(now: bigint, o?: PumpOptions): PumpResult;
174
174
  save(): Uint8Array;
175
175
  fingerprint(): Uint8Array;
176
+ /** The State Fingerprint (ADR 0142): the Group's save without its save id. */
177
+ stateFingerprint(): Uint8Array;
176
178
  inspect(): Inspection;
177
179
  settle(callId: string, s: Settlement): Call<unknown> | undefined;
178
180
  /** @internal */
@@ -208,13 +210,15 @@ export declare class WasmCore implements Core {
208
210
  timerCapability: (impl: TimerImpl, costs: Costs) => CapabilityDef<unknown>;
209
211
  consoleCapability: (impl: ConsoleImpl, costs: Costs) => CapabilityDef<unknown>;
210
212
  storeCapability: (impl: StoreImpl, costs: Costs) => CapabilityDef<string>;
211
- sqliteCapability: (impl: SqliteImpl, costs: Costs, perRow: number) => CapabilityDef<SqliteBinding>;
213
+ sqliteCapability: (impl: SqliteImpl, costs: Costs, perStep: number) => CapabilityDef<SqliteBinding>;
212
214
  userCapability: (impl: UserImpl, costs: Costs) => CapabilityDef<unknown>;
213
215
  httpCapability: (impl: HttpImpl, costs: Costs) => CapabilityDef<unknown>;
214
216
  defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
215
217
  /** Checked in a guest the Core keeps; each Group's guest compiles it again when added. */
216
218
  compileLibrary(src: LibrarySource, imports?: Library[], declarations?: GrantDecls): Library;
217
219
  newGroup(o: GroupOptions): WasmGroup;
220
+ /** A save's State Fingerprint, without restoring it (ADR 0142). */
221
+ stateFingerprint(save: Uint8Array): Uint8Array;
218
222
  restore(save: Uint8Array, o: RestoreOptions): {
219
223
  group: WasmGroup;
220
224
  result: RestoreResult;
@@ -240,4 +244,4 @@ export declare const defaultLimits: Readonly<{
240
244
  cleanupBudget: number;
241
245
  }>;
242
246
  //#endregion
243
- export { type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ConsoleImpl, type CoordinatedLifecycle, type Core, type CoreOptions, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type DrivenGroup, type EffectFailure, type EffectResult, type ErrorDecl, type FieldShape, type FireOp, type FromValueOptions, type Grant, type GrantContext, type GrantDecls, type Group, type GroupOptions, type Handlers, HostError, type HostErrorCode, type HostObject, type HttpImpl, type ImmediateOp, type InlineFunction, type InlineOperation, type Inspection, type Kind, type Library, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, type RunAccounting, type RunAncestry, type RunDiscarded, type RunStarted, type ScopeDecl, type Script, ScriptError, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SendFailedReason, type Settlement, type Shape, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StoreImpl, type SuspendingOp, type TimerImpl, type ToValueOptions, type UserImpl, Value, type Verdict, type Versions, type WasmSource, add, bool, bytes, civilDate, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
247
+ export { type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ChargeRequest, type ChargeResult, type ConsoleImpl, type CoordinatedLifecycle, type Core, type CoreOptions, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type DrivenGroup, type EffectFailure, type EffectResult, type ErrorDecl, type FieldShape, type FireOp, type FromValueOptions, type Grant, type GrantContext, type GrantDecls, type Group, type GroupOptions, type Handlers, HostError, type HostErrorCode, type HostObject, type HttpImpl, type ImmediateOp, type InlineFunction, type InlineOperation, type Inspection, type Kind, type Library, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type Metering, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, type RunAccounting, type RunAncestry, type RunDiscarded, type RunStarted, type ScopeDecl, type Script, ScriptError, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SendFailedReason, type Settlement, type Shape, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StoreImpl, type SuspendingOp, type TimerImpl, type ToValueOptions, type UserImpl, Value, type Verdict, type Versions, type WasmSource, add, bool, bytes, civilDate, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
package/wasm.js CHANGED
@@ -1,16 +1,16 @@
1
1
 
2
- import { G as record, Gt as formatInstant, H as quantity, Jt as nowMicros, K as requireArgs, L as nothing, N as map, Q as text, R as num, S as functionValue, T as instant, V as patternValue, W as range, Xt as parseInstant, 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-CPPJmAAh.js";
3
- import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-CawjPfhl.js";
4
- import { i as defineCapability, t as LimitReached, u as shape } from "./capabilities-BCw9uREe.js";
5
- import { mt as limitDefaults, n as toBase64, t as fromBase64 } from "./base64-DA7UgjG2.js";
2
+ import { G as record, H as quantity, K as requireArgs, Kt as formatInstant, L as nothing, N as map, Q as text, R as num, S as functionValue, T as instant, V as patternValue, W as range, Yt as nowMicros, Zt as parseInstant, 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-BKJES3Zu.js";
3
+ import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-BC4fS0vq.js";
4
+ import { i as defineCapability, t as LimitReached, u as shape } from "./capabilities-Bi5Qm6Fr.js";
5
+ import { ht as limitDefaults, n as toBase64, t as fromBase64 } from "./base64-Dtqaz_0A.js";
6
+ import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-Dw-8Unmf.js";
6
7
  import { n as trackOperation } from "./operation-promises-ClA1BTaS.js";
7
- 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-C2YMRjC3.js";
8
- import { i as standardChecks, n as quoteJSON, t as encodeValue } from "./encoding-BUhsrLPK.js";
9
- import { a as shapeData, i as operationData, n as exportManifest, o as invoke } from "./manifest-BTwN3NiP.js";
10
- import { a as sqliteCapability, c as fromValue, i as httpCapability, l as toValue, n as createGroup, o as decodeJson, r as handlersOf, s as encodeJson, t as inlineGrants, u as talk } from "./inline-grants-Bvk-2aUL.js";
11
- import { n as localeCapability, t as userCapability } from "./user-capability-kDFbi3sm.js";
12
- import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BYghoYSd.js";
13
- 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-Cp3RGZIJ.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-B5e5bBrY.js";
9
+ import { i as standardChecks, n as quoteJSON, t as encodeValue } from "./encoding-C3Q7pIC9.js";
10
+ import { a as sqliteCapability, c as fromValue, i as httpCapability, l as toValue, n as createGroup, o as decodeJson, r as handlersOf, s as encodeJson, t as inlineGrants, u as talk } from "./inline-grants-Cx0Z9XAt.js";
11
+ import { n as localeCapability, t as userCapability } from "./user-capability-5-IvCeZI.js";
12
+ import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BxXgiRM7.js";
13
+ 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-BjnyqXV5.js";
14
14
  //#region src/wasm/wire.ts
15
15
  const raw = Symbol("raw JSON");
16
16
  const sep = Symbol("separator");
@@ -461,6 +461,8 @@ var WasmGroup = class {
461
461
  #decisions = /* @__PURE__ */ new Map();
462
462
  #runs = /* @__PURE__ */ new Map();
463
463
  #calls = /* @__PURE__ */ new Map();
464
+ /** Each queued charge request's future, until a Pump reports it. */
465
+ #charges = /* @__PURE__ */ new Map();
464
466
  #failureDetails = /* @__PURE__ */ new Map();
465
467
  #propertyDetails = [];
466
468
  #effectDetails = /* @__PURE__ */ new Map();
@@ -586,6 +588,7 @@ var WasmGroup = class {
586
588
  now: parseInstant(textOf(field(need, "now"))),
587
589
  signal: pending.abort.signal,
588
590
  charge,
591
+ requestCharge: (fuel) => this.#requestCharge(id, fuel),
589
592
  answer: (v, late) => this.#settleCall(id, pending, "answer", {
590
593
  value: encode(this.#codec, v),
591
594
  fuel: late?.fuel
@@ -593,6 +596,21 @@ var WasmGroup = class {
593
596
  fail: (e) => this.#settleCall(id, pending, "fail", { error: e instanceof ScriptError ? this.#failure(e) : void 0 })
594
597
  });
595
598
  }
599
+ #requestCharge(call, fuel) {
600
+ const ok = this.send("request-charge", {
601
+ call,
602
+ fuel: Number.isSafeInteger(fuel) ? fuel : "invalid"
603
+ });
604
+ const id = textOf(field(ok, "request"));
605
+ const result = new Promise((resolve) => {
606
+ this.#charges.set(id, resolve);
607
+ });
608
+ this.#ready();
609
+ return {
610
+ id,
611
+ result
612
+ };
613
+ }
596
614
  #settleCall(id, pending, m, fields) {
597
615
  if (pending.starting) {
598
616
  if (!pending.queued) {
@@ -638,27 +656,19 @@ var WasmGroup = class {
638
656
  }
639
657
  const automatic = boolOf(field(need, "automatic")) ?? false;
640
658
  const left = intOf(field(need, "fuelLeft"));
641
- let starting = true, charged = 0, reached = false;
642
- const charge = (fuel) => {
643
- if (!starting || automatic) throw new HostError("invalid value", "Charge only while starting");
644
- if (!Number.isSafeInteger(fuel) || fuel < 0) throw new HostError("invalid value", "Fuel must be a whole number");
645
- if (reached || left !== void 0 && charged + fuel > left) {
646
- reached = true;
647
- throw new LimitReached("the Run can’t cover this charge");
648
- }
649
- charged += fuel;
650
- };
659
+ const meter = new CallMeter((fuel, charged) => left === void 0 || charged + fuel <= left);
651
660
  const pending = {
652
661
  abort: new AbortController(),
653
662
  live: true,
654
663
  starting: true
655
664
  };
656
- const call = this.#callOf(need, grant, pending, charge);
665
+ const call = this.#callOf(need, grant, pending, meter.charge);
657
666
  const out = {};
658
667
  try {
659
668
  out.charged = 0;
660
- const result = this.#invoke(op, call, args, pending);
661
- if (reached) out.limit = true;
669
+ const invoke = () => this.#invoke(op, call, args, pending);
670
+ const result = automatic ? invoke() : meter.starting(invoke);
671
+ if (meter.refused) out.limit = true;
662
672
  else if (op.mode === "suspending") out.started = true;
663
673
  else if (op.mode === "fire-and-forget") out.done = true;
664
674
  else try {
@@ -667,7 +677,7 @@ var WasmGroup = class {
667
677
  out.hostError = detailOf(error);
668
678
  }
669
679
  } catch (error) {
670
- if (reached || isLimitReached(error)) out.limit = true;
680
+ if (meter.refused || isLimitReached(error)) out.limit = true;
671
681
  else if (error instanceof ScriptError) try {
672
682
  out.fail = this.#failure(error);
673
683
  } catch (encodeError) {
@@ -675,10 +685,9 @@ var WasmGroup = class {
675
685
  }
676
686
  else out.hostError = detailOf(error);
677
687
  } finally {
678
- starting = false;
679
688
  pending.starting = false;
680
689
  }
681
- out.charged = charged;
690
+ out.charged = meter.charged;
682
691
  if (typeof out.hostError === "string") this.#failureDetails.set(id, out.hostError);
683
692
  if (op.mode === "suspending" && out.started) {
684
693
  if (pending.live) this.#calls.set(id, pending);
@@ -878,6 +887,10 @@ var WasmGroup = class {
878
887
  const unhandled = new Set(rows.flatMap((r) => r.kind === "unhandled" ? [r.delivery] : []));
879
888
  for (const r of rows) {
880
889
  switch (r.kind) {
890
+ case "charge result":
891
+ this.#charges.get(r.request)?.(r);
892
+ this.#charges.delete(r.request);
893
+ break;
881
894
  case "run started":
882
895
  if (r.delivery) this.#runs.set(r.run, r.delivery);
883
896
  break;
@@ -1252,6 +1265,10 @@ var WasmGroup = class {
1252
1265
  fingerprint() {
1253
1266
  return bytesOfFrame(field(this.worker("fingerprint"), "fingerprint"));
1254
1267
  }
1268
+ /** The State Fingerprint (ADR 0142): the Group's save without its save id. */
1269
+ stateFingerprint() {
1270
+ return bytesOfFrame(field(this.worker("state-fingerprint"), "stateFingerprint"));
1271
+ }
1255
1272
  inspect() {
1256
1273
  const ok = this.worker("inspect");
1257
1274
  return { scripts: listOf(field(ok, "scripts")).map((s) => {
@@ -1320,6 +1337,7 @@ var WasmGroup = class {
1320
1337
  save: bytesFrame(save),
1321
1338
  libraries: o.libraries.map((l) => bytesFrame(l.identity)),
1322
1339
  mismatch: o.onMismatch,
1340
+ keepMailbox: o.keepMailbox,
1323
1341
  trace: !!o.trace
1324
1342
  });
1325
1343
  } finally {
@@ -1353,6 +1371,7 @@ var WasmGroup = class {
1353
1371
  return {
1354
1372
  reports: this.#reports(ok),
1355
1373
  variablesOnly: boolOf(field(ok, "variablesOnly")) ?? false,
1374
+ reloaded: textsOf(field(ok, "reloaded")),
1356
1375
  pending,
1357
1376
  discardedRuns: textsOf(field(ok, "discardedRuns")),
1358
1377
  disposed: listOf(field(ok, "disposed")).map((d) => textsOf(d)),
@@ -1718,6 +1737,11 @@ var WasmCore = class {
1718
1737
  newGroup(o) {
1719
1738
  return new WasmGroup(this.#groupCore, o);
1720
1739
  }
1740
+ /** A save's State Fingerprint, without restoring it (ADR 0142). */
1741
+ stateFingerprint(save) {
1742
+ const ok = this.#libraries.exchange("save-state-fingerprint", { save: bytesFrame(save) });
1743
+ return bytesOfFrame(field(ok, "stateFingerprint"));
1744
+ }
1721
1745
  restore(save, o) {
1722
1746
  const group = new WasmGroup(this.#groupCore, o, {
1723
1747
  save,
@@ -1,14 +0,0 @@
1
- /// <reference lib="esnext.disposable" />
2
- import { En as compileLibrary, R as newGroup, _t as defineObjectKind, qt as Core, z as restore } from "./debug-CY9x_Wsi.js";
3
- //#region src/core.d.ts
4
- /** The TS Core: the embedding interface's Core, with its Groups typed as TsGroup. */
5
- type TsCore = Omit<Core, 'compileLibrary' | 'defineObjectKind' | 'newGroup' | 'restore'> & {
6
- compileLibrary: typeof compileLibrary;
7
- defineObjectKind: typeof defineObjectKind;
8
- newGroup: typeof newGroup;
9
- restore: typeof restore;
10
- };
11
- /** Return the process-wide Core, also used by the free-function helpers. */
12
- declare const createCore: () => TsCore;
13
- //#endregion
14
- export { createCore as n, TsCore as t };
@@ -1,124 +0,0 @@
1
-
2
- //#region src/sha256.ts
3
- const K = new Uint32Array([
4
- 1116352408,
5
- 1899447441,
6
- 3049323471,
7
- 3921009573,
8
- 961987163,
9
- 1508970993,
10
- 2453635748,
11
- 2870763221,
12
- 3624381080,
13
- 310598401,
14
- 607225278,
15
- 1426881987,
16
- 1925078388,
17
- 2162078206,
18
- 2614888103,
19
- 3248222580,
20
- 3835390401,
21
- 4022224774,
22
- 264347078,
23
- 604807628,
24
- 770255983,
25
- 1249150122,
26
- 1555081692,
27
- 1996064986,
28
- 2554220882,
29
- 2821834349,
30
- 2952996808,
31
- 3210313671,
32
- 3336571891,
33
- 3584528711,
34
- 113926993,
35
- 338241895,
36
- 666307205,
37
- 773529912,
38
- 1294757372,
39
- 1396182291,
40
- 1695183700,
41
- 1986661051,
42
- 2177026350,
43
- 2456956037,
44
- 2730485921,
45
- 2820302411,
46
- 3259730800,
47
- 3345764771,
48
- 3516065817,
49
- 3600352804,
50
- 4094571909,
51
- 275423344,
52
- 430227734,
53
- 506948616,
54
- 659060556,
55
- 883997877,
56
- 958139571,
57
- 1322822218,
58
- 1537002063,
59
- 1747873779,
60
- 1955562222,
61
- 2024104815,
62
- 2227730452,
63
- 2361852424,
64
- 2428436474,
65
- 2756734187,
66
- 3204031479,
67
- 3329325298
68
- ]);
69
- const rotr = (x, n) => x >>> n | x << 32 - n;
70
- const sha256 = (input) => {
71
- const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
72
- const length = bytes.length;
73
- const padded = new Uint8Array(Math.ceil((length + 9) / 64) * 64);
74
- padded.set(bytes);
75
- padded[length] = 128;
76
- const view = new DataView(padded.buffer);
77
- view.setUint32(padded.length - 8, Math.floor(length / 536870912));
78
- view.setUint32(padded.length - 4, length * 8 >>> 0);
79
- const h = new Uint32Array([
80
- 1779033703,
81
- 3144134277,
82
- 1013904242,
83
- 2773480762,
84
- 1359893119,
85
- 2600822924,
86
- 528734635,
87
- 1541459225
88
- ]);
89
- const w = /* @__PURE__ */ new Uint32Array(64);
90
- for (let block = 0; block < padded.length; block += 64) {
91
- for (let i = 0; i < 16; i++) w[i] = view.getUint32(block + i * 4);
92
- for (let i = 16; i < 64; i++) {
93
- const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
94
- const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
95
- w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
96
- }
97
- let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
98
- for (let i = 0; i < 64; i++) {
99
- const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
100
- const ch = e & f ^ ~e & g;
101
- const t1 = hh + s1 + ch + K[i] + w[i] >>> 0;
102
- const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
103
- hh = g;
104
- g = f;
105
- f = e;
106
- e = d + t1 >>> 0;
107
- d = c;
108
- c = b;
109
- b = a;
110
- a = t1 + t2 >>> 0;
111
- }
112
- h[0] = h[0] + a >>> 0;
113
- h[1] = h[1] + b >>> 0;
114
- h[2] = h[2] + c >>> 0;
115
- h[3] = h[3] + d >>> 0;
116
- h[4] = h[4] + e >>> 0;
117
- h[5] = h[5] + f >>> 0;
118
- h[6] = h[6] + g >>> 0;
119
- h[7] = h[7] + hh >>> 0;
120
- }
121
- return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
122
- };
123
- //#endregion
124
- export { sha256 as t };