@northtalk/ts 0.8.0 → 0.9.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 (38) hide show
  1. package/{checker-Q4w7rLXk.js → checker-D74oYIhs.js} +2 -2
  2. package/debug.js +1 -1
  3. package/driver.js +1 -1
  4. package/{encoding-B7MCQ4ii.js → encoding-DzVFpg7k.js} +2 -2
  5. package/{engine-OL1BveVZ.js → engine-Bx8B63iQ.js} +6 -6
  6. package/{errors-VuwK669R.js → errors-CNc-xY_9.js} +1 -1
  7. package/{group-Ccuqwq12.js → group-CY4FKhzT.js} +8 -8
  8. package/{http-fetch--O27xjSW.js → http-fetch-DnpfiOWK.js} +2 -2
  9. package/http.js +4 -4
  10. package/index-CBuczWK0.d.ts +9 -0
  11. package/index.d.ts +3 -9
  12. package/index.js +15 -15
  13. package/{lean-D6DQfbqH.d.ts → lean-Bg_UTRj0.d.ts} +134 -5
  14. package/{lean-BjhQvHyr.js → lean-DTCTJUmR.js} +10 -10
  15. package/lean.d.ts +2 -3
  16. package/lean.js +15 -15
  17. package/{manifest-BeViDIoy.js → manifest-DVS1SEmN.js} +3 -3
  18. package/message-layer.js +2 -2
  19. package/notify.js +1 -1
  20. package/{objects-TarIKBL8.js → objects-OKVLH190.js} +1 -1
  21. package/{operations-BAELnqwf.js → operations-B3XaG7Ve.js} +113 -10
  22. package/package.json +1 -1
  23. package/{peer-capability-B8eKbljR.js → peer-capability-3etyPHs3.js} +4 -4
  24. package/peer.js +4 -4
  25. package/{readers-BG8g59qS.js → readers-G1lHqrPl.js} +1 -1
  26. package/{request-pump-binary-87klb6sX.js → request-pump-binary-VOPVqRZD.js} +4 -4
  27. package/{router-DXmPA-qi.js → router-Bdm4KiMG.js} +4 -4
  28. package/session.js +15 -15
  29. package/setup.js +5 -5
  30. package/sqlite.js +5 -5
  31. package/{store-DzpyWjt2.js → store-BTcyKBLg.js} +2 -2
  32. package/{store-capability-CxQJ_Huz.js → store-capability-CBJ6mUoH.js} +3 -3
  33. package/store.js +2 -2
  34. package/{user-capability-ClYd8Vln.js → user-capability-DNY2dyjq.js} +3 -3
  35. package/wasm.d.ts +2 -2
  36. package/wasm.js +13 -13
  37. package/{inline-grants-DmOdgSoK.js → zone-rules-DsCJtmlC.js} +88 -5
  38. package/manifest-l07K7nW-.d.ts +0 -124
@@ -1,5 +1,5 @@
1
1
 
2
- import { $ as smallCoefficient, $t as parseInstantText, At as multiply, B as mapWithEntry, Bt as checkInstant, C as extendList, Ct as digitsOf, D as instant, Dt as integerOf, Et as formatDec, F as listWithItem, Ft as withinLimits, G as patternValue, Gt as civilUs, H as num, I as literalDigits, It as DateRangeError, J as range, K as quantity, Kt as dayOfYear, L as map, Lt as US_PER_DAY, M as knownSize, Mt as powerInteger, N as list, Nt as roundRatio, O as instantOf, Ot as isInteger, P as listValues, Pt as subtract, Q as sliceText, Rt as US_PER_SECOND, S as displayText, St as digitCount$1, Tt as divide, Ut as civilOfDays, V as nothing, Vt as civilDays, W as ownedMapPairs, Wt as civilOfUs, Yt as isoWeek, Zt as parseCivil, _ as civilOf, _n as unitKinds, _t as unitText, an as isWhiteSpace, at as textStorage, b as dec, bt as compareDec, cn as scalarCount, ct as combine, d as bytes, dn as utf8Length, dt as ownUnit, en as weekday, et as smallDecimalNumber, f as bytesOf, ft as parseUnit, gt as unitEntry, h as canonicalNumber, hn as grammar, ht as toBase, in as generalCategory, it as text, j as knownContents, jt as negate, k as isDecimal, kt as mod, l as Value, ln as simpleFold, lt as fromBase, m as cacheSize, mt as sameDimension, nn as characterBoundaries, nt as smallInteger, o as invalidValue, on as lower, ot as trimWhiteSpace, p as cacheContents, pt as powerOf, q as quantityOf, rn as charactersAt, sn as normalizeNFC, st as UnitError, t as HostError, tn as assertScalarText, tt as smallExponent, u as bool, un as upper, ut as musicalKind, v as compareBytes, vt as ArithmeticError, wt as div, x as decimalParts, xt as decOf, y as concatText, yt as add, zt as addMonths } from "./errors-VuwK669R.js";
2
+ import { $ as smallCoefficient, $t as parseInstantText, At as multiply, B as mapWithEntry, Bt as checkInstant, C as extendList, Ct as digitsOf, D as instant, Dt as integerOf, Et as formatDec, F as listWithItem, Ft as withinLimits, G as patternValue, Gt as civilUs, H as num, I as literalDigits, It as DateRangeError, J as range, K as quantity, Kt as dayOfYear, L as map, Lt as US_PER_DAY, M as knownSize, Mt as powerInteger, N as list, Nt as roundRatio, O as instantOf, Ot as isInteger, P as listValues, Pt as subtract, Q as sliceText, Rt as US_PER_SECOND, S as displayText, St as digitCount$1, Tt as divide, Ut as civilOfDays, V as nothing, Vt as civilDays, W as ownedMapPairs, Wt as civilOfUs, Yt as isoWeek, Zt as parseCivil, _ as civilOf, _n as unitKinds, _t as unitText, an as isWhiteSpace, at as textStorage, b as dec, bt as compareDec, cn as scalarCount, ct as combine, d as bytes, dn as utf8Length, dt as ownUnit, en as weekday, et as smallDecimalNumber, f as bytesOf, ft as parseUnit, gt as unitEntry, h as canonicalNumber, hn as grammar, ht as toBase, in as generalCategory, it as text, j as knownContents, jt as negate, k as isDecimal, kt as mod, l as Value, ln as simpleFold, lt as fromBase, m as cacheSize, mt as sameDimension, nn as characterBoundaries, nt as smallInteger, o as invalidValue, on as lower, ot as trimWhiteSpace, p as cacheContents, pt as powerOf, q as quantityOf, rn as charactersAt, sn as normalizeNFC, st as UnitError, t as HostError, tn as assertScalarText, tt as smallExponent, u as bool, un as upper, ut as musicalKind, v as compareBytes, vt as ArithmeticError, wt as div, x as decimalParts, xt as decOf, y as concatText, yt as add, zt as addMonths } from "./errors-CNc-xY_9.js";
3
3
  //#region src/tasks.ts
4
4
  const runTask = (root) => {
5
5
  const stack = [root];
@@ -4625,6 +4625,11 @@ const costModel = {
4625
4625
  0,
4626
4626
  10,
4627
4627
  1
4628
+ ], [
4629
+ 10,
4630
+ 0,
4631
+ 2,
4632
+ 1
4628
4633
  ]],
4629
4634
  "alloc": [[
4630
4635
  1,
@@ -4640,6 +4645,11 @@ const costModel = {
4640
4645
  0,
4641
4646
  10,
4642
4647
  1
4648
+ ], [
4649
+ 10,
4650
+ 0,
4651
+ 2,
4652
+ 1
4643
4653
  ]],
4644
4654
  "alloc": [[
4645
4655
  1,
@@ -5828,7 +5838,7 @@ const makeCostRates = (measure) => [
5828
5838
  fuel: 0,
5829
5839
  alloc: 0
5830
5840
  }) => {
5831
- into.fuel = 10;
5841
+ into.fuel = 10 + Math.ceil(2 * (m.scanned ?? 0) / 1);
5832
5842
  into.alloc = Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1);
5833
5843
  return into;
5834
5844
  },
@@ -5836,7 +5846,7 @@ const makeCostRates = (measure) => [
5836
5846
  fuel: 0,
5837
5847
  alloc: 0
5838
5848
  }) => {
5839
- into.fuel = 10;
5849
+ into.fuel = 10 + Math.ceil(2 * (m.scanned ?? 0) / 1);
5840
5850
  into.alloc = Math.ceil(1 * (m.resultSize ?? measure(1, m.result)) / 1);
5841
5851
  return into;
5842
5852
  },
@@ -8435,12 +8445,83 @@ const dateField = (name, d) => {
8435
8445
  };
8436
8446
  return integerValue(field[name]);
8437
8447
  };
8438
- const offsetOf = (name, v) => {
8448
+ const fixedOffsetUs = (v) => {
8439
8449
  const q = v.asQuantityRef();
8440
8450
  const seconds = q && sameDimension(q.unit, SECONDS) ? inBase(q) : void 0;
8441
8451
  const whole = seconds && isInteger(seconds) ? integerOf(seconds) : void 0;
8442
- if (whole === void 0 || whole % 60n !== 0n || whole >= 86400n || whole <= -86400n) throw outOfDomain(name, v);
8443
- return whole * US_PER_SECOND;
8452
+ return whole === void 0 || whole % 60n !== 0n || whole >= 86400n || whole <= -86400n ? void 0 : whole * US_PER_SECOND;
8453
+ };
8454
+ const offsetOf = (name, v) => {
8455
+ const us = fixedOffsetUs(v);
8456
+ if (us === void 0) throw outOfDomain(name, v);
8457
+ return us;
8458
+ };
8459
+ const exactKeys = (v, keys) => v.kind === "map" && v.mapSize === keys.length && keys.every((k) => v.hasKey(k));
8460
+ /** `scanned` is the number of changes, whenever `changes` is a list, so a
8461
+ * malformed map is charged as a well-formed one of its length would be. */
8462
+ const zoneRulesOf = (name, v, measure) => {
8463
+ const bad = () => outOfDomain(name, v);
8464
+ if (!exactKeys(v, [
8465
+ "zone",
8466
+ "until",
8467
+ "changes"
8468
+ ])) throw bad();
8469
+ const zone = v.get("zone").asText();
8470
+ const until = v.get("until").asInstant();
8471
+ const changes = v.get("changes");
8472
+ if (changes.kind === "list") measure.scanned = changes.length;
8473
+ if (zone === void 0 || until === void 0 || changes.kind !== "list" || changes.length === 0) throw bad();
8474
+ const starts = [];
8475
+ const offsets = [];
8476
+ for (let i = 1; i <= changes.length; i++) {
8477
+ const change = changes.index(i);
8478
+ if (!exactKeys(change, ["at", "offset"])) throw bad();
8479
+ const at = change.get("at").asInstant();
8480
+ const offset = fixedOffsetUs(change.get("offset"));
8481
+ if (at === void 0 || offset === void 0 || starts.length > 0 && at <= starts.at(-1)) throw bad();
8482
+ starts.push(at);
8483
+ offsets.push(offset);
8484
+ }
8485
+ if (starts.at(-1) >= until) throw bad();
8486
+ return {
8487
+ zone,
8488
+ starts,
8489
+ offsets,
8490
+ until
8491
+ };
8492
+ };
8493
+ const outsideWindow = (rules, us) => us < rules.starts[0] || us >= rules.until;
8494
+ /** The offset in effect at the Instant `us`, inside the window. */
8495
+ const zoneOffsetAt = (rules, us) => {
8496
+ let k = 0;
8497
+ while (k + 1 < rules.starts.length && rules.starts[k + 1] <= us) k++;
8498
+ return rules.offsets[k];
8499
+ };
8500
+ const DISAMBIGUATIONS = [
8501
+ "compatible",
8502
+ "earlier",
8503
+ "later",
8504
+ "reject"
8505
+ ];
8506
+ /** The Instant at which the zone's wall clock reads `local`, a Civil Date's
8507
+ * microseconds read as if at UTC, resolving a gap or overlap. */
8508
+ const zoneInstant = (rules, civil, local, disambiguation) => {
8509
+ for (const o of rules.offsets) if (outsideWindow(rules, local - o)) throw outOfRange("zone", civil);
8510
+ const { starts, offsets, until } = rules;
8511
+ const candidates = [];
8512
+ for (let k = 0; k < starts.length; k++) {
8513
+ const t = local - offsets[k];
8514
+ if (starts[k] <= t && t < (starts[k + 1] ?? until)) candidates.push(t);
8515
+ }
8516
+ if (candidates.length === 1) return candidates[0];
8517
+ if (disambiguation === "reject") throw new ScriptError("ambiguous time", [["civil", civil], ["zone", text(rules.zone)]]);
8518
+ if (candidates.length > 1) return disambiguation === "later" ? candidates.reduce((a, b) => a > b ? a : b) : candidates.reduce((a, b) => a < b ? a : b);
8519
+ for (let j = 1; j < starts.length; j++) {
8520
+ const o1 = offsets[j - 1];
8521
+ const o2 = offsets[j];
8522
+ if (local - o2 < starts[j] && starts[j] <= local - o1) return disambiguation === "earlier" ? local - o2 : local - o1;
8523
+ }
8524
+ throw new Error("a Civil Date with no candidate lies in no gap");
8444
8525
  };
8445
8526
  const unary = {
8446
8527
  sqrt,
@@ -8702,15 +8783,36 @@ const builtin = (name, args, measure = {}) => {
8702
8783
  case "hasTime": return { result: dateField(name, x) };
8703
8784
  case "toCivil": {
8704
8785
  if (x.kind !== "instant") throw wrongKind("instant", x);
8705
- const offset = offsetOf(name, y);
8706
- return { result: inRangeDate(() => civilOf(civilOfUs(x.asInstant() + offset))) };
8786
+ const i = x.asInstant();
8787
+ let offset;
8788
+ if (y.kind === "map") {
8789
+ const rules = zoneRulesOf(name, y, measure);
8790
+ if (outsideWindow(rules, i)) throw outOfRange("zone", x);
8791
+ offset = zoneOffsetAt(rules, i);
8792
+ } else offset = offsetOf(name, y);
8793
+ return {
8794
+ result: inRangeDate(() => civilOf(civilOfUs(i + offset))),
8795
+ scanned: measure.scanned
8796
+ };
8707
8797
  }
8708
8798
  case "toInstant": {
8709
8799
  const c = x.civilRef();
8710
8800
  if (!c) throw wrongKind("civil date", x);
8711
8801
  if (c.us === null) throw outOfDomain(name, x);
8712
- const offset = offsetOf(name, y);
8713
- return { result: inRangeDate(() => instantOf(checkInstant(civilUs(c) - offset))) };
8802
+ const how = z ?? nothing;
8803
+ if (y.kind !== "map") {
8804
+ const offset = offsetOf(name, y);
8805
+ if (how.kind !== "nothing") throw outOfDomain(name, how);
8806
+ return { result: inRangeDate(() => instantOf(checkInstant(civilUs(c) - offset))) };
8807
+ }
8808
+ const rules = zoneRulesOf(name, y, measure);
8809
+ const word = how.kind === "nothing" ? "compatible" : how.asText();
8810
+ if (word === void 0 || !DISAMBIGUATIONS.includes(word)) throw outOfDomain(name, how);
8811
+ const local = civilUs(c);
8812
+ return {
8813
+ result: inRangeDate(() => instantOf(checkInstant(zoneInstant(rules, x, local, word)))),
8814
+ scanned: measure.scanned
8815
+ };
8714
8816
  }
8715
8817
  case "abs":
8716
8818
  case "floor":
@@ -8758,6 +8860,7 @@ const builtin = (name, args, measure = {}) => {
8758
8860
  const builtinDefaults = {
8759
8861
  round: [num(0), text("half up")],
8760
8862
  bitShiftLeft: [nothing],
8863
+ toInstant: [nothing],
8761
8864
  fromFloat64: [text("big")],
8762
8865
  fromFloat32: [text("big")],
8763
8866
  toFloat64: [text("big")],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@northtalk/ts",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "NorthTalk, a readable scripting language for embedding: the TS Core, its Session Host and Standard Capabilities.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,8 +1,8 @@
1
1
 
2
- import { P as listValues, V as nothing, b as dec, it as text, t as HostError } from "./errors-VuwK669R.js";
3
- import { t as defineObjectKind } from "./objects-TarIKBL8.js";
4
- import { Dt as shape, kt as validComputedMessageName, n as ScriptError, xt as defineValueCapability } from "./operations-BAELnqwf.js";
5
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-B7MCQ4ii.js";
2
+ import { P as listValues, V as nothing, b as dec, it as text, t as HostError } from "./errors-CNc-xY_9.js";
3
+ import { t as defineObjectKind } from "./objects-OKVLH190.js";
4
+ import { Dt as shape, kt as validComputedMessageName, n as ScriptError, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
5
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
6
6
  //#region src/peer-capability.ts
7
7
  /** The Core-fixed Object Kind of a Peer: no properties, no collection. */
8
8
  const PEER_KIND = "peer";
package/peer.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
- import { H as num, L as map, N as list, V as nothing, i as ScriptError, it as text } from "./errors-VuwK669R.js";
2
+ import { H as num, L as map, N as list, V as nothing, i as ScriptError, it as text } from "./errors-CNc-xY_9.js";
3
3
  import { n as toBase64, t as fromBase64 } from "./base64-CDO-a06R.js";
4
- import { r as decodeValue } from "./readers-BG8g59qS.js";
5
- import { t as encodeValue } from "./encoding-B7MCQ4ii.js";
6
- import { a as peerKind } from "./peer-capability-B8eKbljR.js";
4
+ import { r as decodeValue } from "./readers-G1lHqrPl.js";
5
+ import { t as encodeValue } from "./encoding-DzVFpg7k.js";
6
+ import { a as peerKind } from "./peer-capability-3etyPHs3.js";
7
7
  //#region src/peer-message-port.ts
8
8
  /** The largest frame a link sends or reads, in UTF-8 bytes. */
9
9
  const MAX_FRAME$1 = 16777216;
@@ -1,5 +1,5 @@
1
1
 
2
- import { D as instant, E as hiddenCodePoint, J as range, K as quantity, L as map, P as listValues, Qt as parseInstant, V as nothing, b as dec, f as bytesOf, g as civilDate, it as text, l as Value, o as invalidValue, tn as assertScalarText, u as bool } from "./errors-VuwK669R.js";
2
+ import { D as instant, E as hiddenCodePoint, J as range, K as quantity, L as map, P as listValues, Qt as parseInstant, V as nothing, b as dec, f as bytesOf, g as civilDate, it as text, l as Value, o as invalidValue, tn as assertScalarText, u as bool } from "./errors-CNc-xY_9.js";
3
3
  import { t as fromBase64 } from "./base64-CDO-a06R.js";
4
4
  //#region src/readers.ts
5
5
  var Reader = class {
@@ -1,9 +1,9 @@
1
1
 
2
- import { D as instant, G as patternValue, H as num, J as range, K as quantity, L as map, P as listValues, Qt as parseInstant, U as objectValue, V as nothing, b as dec, d as bytes, g as civilDate, it as text, l as Value, o as invalidValue, qt as formatInstant, sn as normalizeNFC, u as bool, w as functionValue } from "./errors-VuwK669R.js";
3
- import { g as decodeUtf8, ot as patternSource } from "./operations-BAELnqwf.js";
4
- import { _ as viewSource, t as checkSource } from "./checker-Q4w7rLXk.js";
2
+ import { D as instant, G as patternValue, H as num, J as range, K as quantity, L as map, P as listValues, Qt as parseInstant, U as objectValue, V as nothing, b as dec, d as bytes, g as civilDate, it as text, l as Value, o as invalidValue, qt as formatInstant, sn as normalizeNFC, u as bool, w as functionValue } from "./errors-CNc-xY_9.js";
3
+ import { g as decodeUtf8, ot as patternSource } from "./operations-B3XaG7Ve.js";
4
+ import { _ as viewSource, t as checkSource } from "./checker-D74oYIhs.js";
5
5
  import { n as toBase64 } from "./base64-CDO-a06R.js";
6
- import { a as fromJson, n as JsonObject, o as isJsonNumber, s as isJsonObject, t as JsonNumber } from "./readers-BG8g59qS.js";
6
+ import { a as fromJson, n as JsonObject, o as isJsonNumber, s as isJsonObject, t as JsonNumber } from "./readers-G1lHqrPl.js";
7
7
  //#region src/binary-value.ts
8
8
  const coreErrors = /* @__PURE__ */ new WeakSet();
9
9
  const max = 2n ** 64n;
@@ -1,9 +1,9 @@
1
1
 
2
- import { L as map, P as listValues, i as ScriptError, it as text, t as HostError, u as bool } from "./errors-VuwK669R.js";
3
- import { Q as sizeOf, ut as compareText } from "./operations-BAELnqwf.js";
4
- import { t as encodeValue } from "./encoding-B7MCQ4ii.js";
2
+ import { L as map, P as listValues, i as ScriptError, it as text, t as HostError, u as bool } from "./errors-CNc-xY_9.js";
3
+ import { Q as sizeOf, ut as compareText } from "./operations-B3XaG7Ve.js";
4
+ import { t as encodeValue } from "./encoding-DzVFpg7k.js";
5
5
  import { n as sha256 } from "./sha256-9CGf5BS_.js";
6
- import { n as hostScriptError } from "./store-capability-CxQJ_Huz.js";
6
+ import { n as hostScriptError } from "./store-capability-CBJ6mUoH.js";
7
7
  //#region src/notify/router.ts
8
8
  /**
9
9
  * Whether a commit changed a key's value: compared by the bytes of the Value
package/session.js CHANGED
@@ -1,17 +1,17 @@
1
1
 
2
- import { H as num, J as range, L as map, P as listValues, Qt as parseInstant, V as nothing, i as ScriptError, it as text, l as Value, n as LoadError, nn as characterBoundaries, on as lower, pn as builtins, qt as formatInstant, t as HostError, u as bool } from "./errors-VuwK669R.js";
3
- import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group-Ccuqwq12.js";
4
- import { o as stateOf, t as defineObjectKind } from "./objects-TarIKBL8.js";
5
- import { Dt as shape, Et as operationDeclarations, H as textForm$1, U as waitUs, jt as validStaticMessageName, tt as functionHead, ut as compareText, x as integerValue, xt as defineValueCapability } from "./operations-BAELnqwf.js";
6
- import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-Q4w7rLXk.js";
7
- import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-BeViDIoy.js";
8
- import { c as readDisplay, l as readOrderedJSON, r as decodeValue } from "./readers-BG8g59qS.js";
9
- import { a as clockCapability, i as calendarCapability, n as quoteJSON, o as consoleCapability, t as encodeValue } from "./encoding-B7MCQ4ii.js";
10
- import { n as localeCapability, t as userCapability } from "./user-capability-ClYd8Vln.js";
11
- import { r as storeCapability } from "./store-capability-CxQJ_Huz.js";
2
+ import { H as num, J as range, L as map, P as listValues, Qt as parseInstant, V as nothing, i as ScriptError, it as text, l as Value, n as LoadError, nn as characterBoundaries, on as lower, pn as builtins, qt as formatInstant, t as HostError, u as bool } from "./errors-CNc-xY_9.js";
3
+ import { C as registeredStdlib, T as stdlibSource, a as recordLine, h as defaultLimits, i as restore, l as compileLibrary, o as traceValue } from "./group-CY4FKhzT.js";
4
+ import { o as stateOf, t as defineObjectKind } from "./objects-OKVLH190.js";
5
+ import { Dt as shape, Et as operationDeclarations, H as textForm$1, U as waitUs, jt as validStaticMessageName, tt as functionHead, ut as compareText, x as integerValue, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
6
+ import { _ as viewSource, c as parseSource, f as declarationDocs, h as leadingDoc, m as functionDoc, s as parseEntry, t as checkSource } from "./checker-D74oYIhs.js";
7
+ import { n as exportManifest, o as shapeData, t as canonicalJSON } from "./manifest-DVS1SEmN.js";
8
+ import { c as readDisplay, l as readOrderedJSON, r as decodeValue } from "./readers-G1lHqrPl.js";
9
+ import { a as clockCapability, i as calendarCapability, n as quoteJSON, o as consoleCapability, t as encodeValue } from "./encoding-DzVFpg7k.js";
10
+ import { n as localeCapability, t as userCapability } from "./user-capability-DNY2dyjq.js";
11
+ import { r as storeCapability } from "./store-capability-CBJ6mUoH.js";
12
12
  import { buildSetupGroup, capabilityOperations, immutableSetup, shapeOf } from "./setup.js";
13
- import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-OL1BveVZ.js";
14
- import { i as memoryStores } from "./store-DzpyWjt2.js";
13
+ import { a as encodeContents, i as decodeContents, o as sessionQuotas, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
14
+ import { i as memoryStores } from "./store-BTcyKBLg.js";
15
15
  //#region src/session/objects.ts
16
16
  const externalCollection = () => {
17
17
  throw new Error("external collection callback in replay");
@@ -1227,11 +1227,11 @@ const builtinDocs = {
1227
1227
  },
1228
1228
  "toCivil": {
1229
1229
  "call": "toCivil(i, offset)",
1230
- "gives": "The date-time on the wall clock at `offset` from UTC at the Instant `i`"
1230
+ "gives": "The date-time on the wall clock at the Instant `i`, at `offset` from UTC or under the Zone Rules `offset`"
1231
1231
  },
1232
1232
  "toInstant": {
1233
- "call": "toInstant(c, offset)",
1234
- "gives": "The Instant at which the wall clock at `offset` from UTC reads the date-time `c`"
1233
+ "call": "toInstant(c, offset, disambiguation = nothing)",
1234
+ "gives": "The Instant at which the wall clock, at `offset` from UTC or under the Zone Rules `offset`, reads the date-time `c`"
1235
1235
  },
1236
1236
  "pi": {
1237
1237
  "call": "3.141592653589793238462643383279503",
package/setup.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
- import { n as LoadError } from "./errors-VuwK669R.js";
3
- import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group-Ccuqwq12.js";
4
- import { t as defineObjectKind } from "./objects-TarIKBL8.js";
5
- import { Dt as shape, Et as operationDeclarations } from "./operations-BAELnqwf.js";
6
- import { r as MUSICAL_CLOCK } from "./encoding-B7MCQ4ii.js";
2
+ import { n as LoadError } from "./errors-CNc-xY_9.js";
3
+ import { i as restore, l as compileLibrary, r as newGroup, u as replacementLibraries } from "./group-CY4FKhzT.js";
4
+ import { t as defineObjectKind } from "./objects-OKVLH190.js";
5
+ import { Dt as shape, Et as operationDeclarations } from "./operations-B3XaG7Ve.js";
6
+ import { r as MUSICAL_CLOCK } from "./encoding-DzVFpg7k.js";
7
7
  //#region src/setup.ts
8
8
  const tsCore = {
9
9
  compileLibrary,
package/sqlite.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
- import { b as dec, it as text, t as HostError } from "./errors-VuwK669R.js";
3
- import { r as decodeValue } from "./readers-BG8g59qS.js";
4
- import { t as encodeValue } from "./encoding-B7MCQ4ii.js";
5
- import { n as hostScriptError } from "./store-capability-CxQJ_Huz.js";
6
- import { r as Stores, t as StoreContentsError } from "./engine-OL1BveVZ.js";
2
+ import { b as dec, it as text, t as HostError } from "./errors-CNc-xY_9.js";
3
+ import { r as decodeValue } from "./readers-G1lHqrPl.js";
4
+ import { t as encodeValue } from "./encoding-DzVFpg7k.js";
5
+ import { n as hostScriptError } from "./store-capability-CBJ6mUoH.js";
6
+ import { r as Stores, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
7
7
  import { DatabaseSync } from "node:sqlite";
8
8
  //#region src/sqlite/scan.ts
9
9
  const isWordChar = (c) => /[\w$]/.test(c) || c.charCodeAt(0) > 127;
@@ -1,6 +1,6 @@
1
1
 
2
- import { ut as compareText } from "./operations-BAELnqwf.js";
3
- import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-OL1BveVZ.js";
2
+ import { ut as compareText } from "./operations-B3XaG7Ve.js";
3
+ import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, r as Stores, s as sessionWatchLimits } from "./engine-Bx8B63iQ.js";
4
4
  //#region src/store/memory.ts
5
5
  /** A backend that keeps nothing outside the engine's own copy. */
6
6
  const memoryBackend = () => ({
@@ -1,7 +1,7 @@
1
1
 
2
- import { L as map, V as nothing, i as ScriptError, it as text, t as HostError, u as bool } from "./errors-VuwK669R.js";
3
- import { Dt as shape, ft as errorMessages, i as arithmetic, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-BAELnqwf.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-B7MCQ4ii.js";
2
+ import { L as map, V as nothing, i as ScriptError, it as text, t as HostError, u as bool } from "./errors-CNc-xY_9.js";
3
+ import { Dt as shape, ft as errorMessages, i as arithmetic, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
5
5
  //#region src/store-capability.ts
6
6
  /** A Core-raised error as the Host sees it, with its catalogue message. */
7
7
  const hostScriptError = (code, fields) => {
package/store.js CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-OL1BveVZ.js";
3
- import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-DzpyWjt2.js";
2
+ import { a as encodeContents, i as decodeContents, n as StoreStateUnknownError, o as sessionQuotas, r as Stores, s as sessionWatchLimits, t as StoreContentsError } from "./engine-Bx8B63iQ.js";
3
+ import { i as memoryStores, n as webStorageStores, r as memoryBackend, t as webStorageBackend } from "./store-BTcyKBLg.js";
4
4
  export { StoreContentsError, StoreStateUnknownError, Stores, decodeContents, encodeContents, memoryBackend, memoryStores, sessionQuotas, sessionWatchLimits, webStorageBackend, webStorageStores };
@@ -1,7 +1,7 @@
1
1
 
2
- import { Dt as integerOf, L as map, Ot as isInteger, it as text, t as HostError, u as bool, x as decimalParts } from "./errors-VuwK669R.js";
3
- import { Dt as shape, n as ScriptError, xt as defineValueCapability } from "./operations-BAELnqwf.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-B7MCQ4ii.js";
2
+ import { Dt as integerOf, L as map, Ot as isInteger, it as text, t as HostError, u as bool, x as decimalParts } from "./errors-CNc-xY_9.js";
3
+ import { Dt as shape, n as ScriptError, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
5
5
  //#region src/locale-tag.ts
6
6
  const grandfathered = /^(?:en-gb-oed|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)|sgn-(?:be-fr|be-nl|ch-de))$/i;
7
7
  const alpha = /^[a-z]+$/i;
package/wasm.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.disposable" />
2
2
  import { $ as instant, $t as shape, At as FireOp, Bt as ReleaseHook, C as Report, Cn as LocaleImpl, Ct as ChargeRequest, Dn as Costs, Dt as EffectResult, E as RestoreResult, En as ConsoleImpl, Et as Cost, Fn as Library, Ft as Metering, G as RunStarted, Gt as SegmentGrant, H as RunAccounting, Hn as LimitName, Ht as ScopeDecl, It as Operation, J as Value, Jt as SuspendingOp, K as Decimal, Kt as SegmentLifecycle, Ln as LibrarySource, Lt as Operations, Mt as GrantContext, N as Settlement, Nt as ImmediateOp, On as MusicalClockImpl, Ot as ErrorDecl, Pt as LimitReached, Q as dec, Qt as operationDeclarations, R as Verdict, Rn as OperationRef, Rt as PlainArg, S as PumpedRequest, St as CapabilityDefiner, T as RestoreOptions, Tn as CalendarImpl, Tt as CoordinatedLifecycle, U as RunAncestry, Un as Limits, Ut as SegmentContext, V as CausalWork, Vt as ReleaseReason, W as RunDiscarded, Wn as Outcome, Wt as SegmentCoordinator, X as bytes, Xt as defineCapability, Y as bool, Yt as conforms, Z as civilDate, Zt as explain, _ as LoadOptions, _n as SqlParams, _t as PropDef, an as PeerImpl, ar as LoadError, at as quantity, b as PumpOptions, bn as SqliteBinding, bt as Call, cn as HttpClientImpl, cr as SendFailedReason, d as Counters, dt as nowMicros, en as Core, f as Decided, fn as UserImpl, ft as parseInstant, g as Inspection, gt as ObjectKindDef, h as GroupOptions, hn as add, ht as ObjectKind, ir as LoadDiagnostic, it as num, jt as Grant, kn as TimerImpl, kt as FieldShape, l as CancellationOptions, ln as HttpImpl, lt as text, m as EffectFailure, mn as StoreImpl, mt as ObjectElements, nn as Script, nr as HostError, nt as map, or as MailboxFull, ot as range, p as Deciding, pt as HostObject, q as Kind, qt as Shape, rn as Versions, rr as HostErrorCode, rt as nothing, sr as ScriptError, st as record, tn as Group, tt as list, u as CarryOver, un as HttpServerImpl, ut as formatInstant, v as Message, vn as SqlRows, w as Requested, wt as ChargeResult, x as PumpResult, xn as SqliteImpl, xt as CapabilityDef, y as PendingCall, yn as SqlValue, yt as GrantDecls, zt as PlainResult } from "./debug-s6QIovKS.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-l07K7nW-.js";
3
+ import { A as FromValueOptions, C as handlersOf, F as talk, M as ToValueOptions, N as fromValue, P as toValue, S as ScriptWithHandlers, T as encodeJson, b as createGroup, d as exportManifest, f as zoneRules, h as inlineGrants, j as PlainValue, k as encodeValue, l as ManifestSpec, m as InlineOperation, p as InlineFunction, u as MessageDecl, v as CreateGroupOptions, w as decodeJson, x as Handlers, y as DrivenGroup } from "./lean-Bg_UTRj0.js";
4
4
  import { a as decodeValue, n as Json, o as readDisplay } from "./readers-AeB1bJ--.js";
5
5
  import { t as BinaryValueOptions } from "./binary-value-B93hEK7l.js";
6
6
  //#region src/wasm/reactor.d.ts
@@ -253,4 +253,4 @@ export declare const defaultLimits: Readonly<{
253
253
  cleanupBudget: number;
254
254
  }>;
255
255
  //#endregion
256
- 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 HttpClientImpl, type HttpImpl, type HttpServerImpl, 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 MusicalClockImpl, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PeerImpl, 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, conforms, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, explain, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
256
+ 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 HttpClientImpl, type HttpImpl, type HttpServerImpl, 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 MusicalClockImpl, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operation, type OperationRef, type Operations, type Outcome, type PeerImpl, 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, conforms, createGroup, dec, decodeJson, decodeValue, encodeJson, encodeValue, explain, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue, zoneRules };
package/wasm.js CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
- import { D as instant, G as patternValue, H as num, J as range, K as quantity, L as map, N as list, Qt as parseInstant, U as objectValue, V as nothing, X as requireArgs, Xt as nowMicros, Y as record, Z as requireValue, b as dec, c as Decimal, d as bytes, g as civilDate, i as ScriptError, it as text, l as Value, n as LoadError, o as invalidValue, qt as formatInstant, r as MailboxFull, s as sendFailed, t as HostError, u as bool, w as functionValue } from "./errors-VuwK669R.js";
3
- import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-TarIKBL8.js";
4
- import { Dt as shape, Et as operationDeclarations, bt as defineCapability, gt as LimitReached, mt as limitDefaults, vt as conforms, wt as explain } from "./operations-BAELnqwf.js";
5
- import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-BeViDIoy.js";
2
+ import { D as instant, G as patternValue, H as num, J as range, K as quantity, L as map, N as list, Qt as parseInstant, U as objectValue, V as nothing, X as requireArgs, Xt as nowMicros, Y as record, Z as requireValue, b as dec, c as Decimal, d as bytes, g as civilDate, i as ScriptError, it as text, l as Value, n as LoadError, o as invalidValue, qt as formatInstant, r as MailboxFull, s as sendFailed, t as HostError, u as bool, w as functionValue } from "./errors-CNc-xY_9.js";
3
+ import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-OKVLH190.js";
4
+ import { Dt as shape, Et as operationDeclarations, bt as defineCapability, gt as LimitReached, mt as limitDefaults, vt as conforms, wt as explain } from "./operations-B3XaG7Ve.js";
5
+ import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-DVS1SEmN.js";
6
6
  import { n as trackOperation } from "./operation-promises-ClA1BTaS.js";
7
7
  import { n as toBase64, t as fromBase64 } from "./base64-CDO-a06R.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-BG8g59qS.js";
9
- import { a as clockCapability, d as timerCapability, i as calendarCapability, l as isMusicalClock, n as quoteJSON, o as consoleCapability, p as standardChecks, r as MUSICAL_CLOCK, t as encodeValue, u as musicalClockCapability } from "./encoding-B7MCQ4ii.js";
10
- import { a as peerKind, i as peerCapability } from "./peer-capability-B8eKbljR.js";
11
- import { a as sqliteCapability, c as talk, i as httpCapability, n as createGroup, o as fromValue, r as handlersOf, s as toValue, t as inlineGrants } from "./inline-grants-DmOdgSoK.js";
12
- import { o as decodeJson, s as encodeJson } from "./http-fetch--O27xjSW.js";
13
- import { n as localeCapability, t as userCapability } from "./user-capability-ClYd8Vln.js";
14
- import { r as storeCapability, t as add } from "./store-capability-CxQJ_Huz.js";
15
- 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-87klb6sX.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-G1lHqrPl.js";
9
+ import { a as clockCapability, d as timerCapability, i as calendarCapability, l as isMusicalClock, n as quoteJSON, o as consoleCapability, p as standardChecks, r as MUSICAL_CLOCK, t as encodeValue, u as musicalClockCapability } from "./encoding-DzVFpg7k.js";
10
+ import { a as peerKind, i as peerCapability } from "./peer-capability-3etyPHs3.js";
11
+ import { a as httpCapability, c as toValue, i as handlersOf, l as talk, n as inlineGrants, o as sqliteCapability, r as createGroup, s as fromValue, t as zoneRules } from "./zone-rules-DsCJtmlC.js";
12
+ import { o as decodeJson, s as encodeJson } from "./http-fetch-DnpfiOWK.js";
13
+ import { n as localeCapability, t as userCapability } from "./user-capability-DNY2dyjq.js";
14
+ import { r as storeCapability, t as add } from "./store-capability-CBJ6mUoH.js";
15
+ 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-VOPVqRZD.js";
16
16
  //#region src/wasm/wire.ts
17
17
  const raw = Symbol("raw JSON");
18
18
  const sep = Symbol("separator");
@@ -1795,4 +1795,4 @@ const createCore = async (o = {}) => new WasmCore(await compile(o.wasm ?? new UR
1795
1795
  /** Chapter 9's default Limits, which the reactor shares. */
1796
1796
  const defaultLimits = Object.freeze({ ...limitDefaults });
1797
1797
  //#endregion
1798
- export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, conforms, createCore, createGroup, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, explain, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
1798
+ export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, conforms, createCore, createGroup, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, explain, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, operationDeclarations, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue, zoneRules };
@@ -1,8 +1,8 @@
1
1
 
2
- import { Dt as integerOf, H as num, L as map, Ot as isInteger, P as listValues, V as nothing, Y as record, Z as requireValue, b as dec, d as bytes, i as ScriptError, it as text, k as isDecimal, l as Value, o as invalidValue, t as HostError, u as bool, x as decimalParts } from "./errors-VuwK669R.js";
3
- import { Ct as expectedOf, Dt as shape, bt as defineCapability, jt as validStaticMessageName, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-BAELnqwf.js";
4
- import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-B7MCQ4ii.js";
5
- import { n as duplicateHeaderNames, r as fetchAnswerOk, s as encodeJson, t as checkFetch } from "./http-fetch--O27xjSW.js";
2
+ import { D as instant, Dt as integerOf, H as num, K as quantity, L as map, N as list, Ot as isInteger, P as listValues, V as nothing, Y as record, Z as requireValue, b as dec, d as bytes, i as ScriptError, it as text, k as isDecimal, l as Value, o as invalidValue, t as HostError, u as bool, x as decimalParts } from "./errors-CNc-xY_9.js";
3
+ import { Ct as expectedOf, Dt as shape, bt as defineCapability, jt as validStaticMessageName, kt as validComputedMessageName, n as ScriptError$1, xt as defineValueCapability } from "./operations-B3XaG7Ve.js";
4
+ import { c as fixed, f as registerStandardChecks, s as costOf } from "./encoding-DzVFpg7k.js";
5
+ import { n as duplicateHeaderNames, r as fetchAnswerOk, s as encodeJson, t as checkFetch } from "./http-fetch-DnpfiOWK.js";
6
6
  import { asyncDispose, newDrivenGroup } from "./driver.js";
7
7
  //#region src/talk.ts
8
8
  const blank = /^[\t ]*$/;
@@ -577,4 +577,87 @@ const inlineGrants = (capabilities) => Object.fromEntries(Object.entries(capabil
577
577
  return [name, defineCapability(name, ops).grant("all", void 0)];
578
578
  }));
579
579
  //#endregion
580
- export { sqliteCapability as a, talk as c, httpCapability as i, createGroup as n, fromValue as o, handlersOf as r, toValue as s, inlineGrants as t };
580
+ //#region src/zone-rules.ts
581
+ const SECOND = 1e3;
582
+ const STEP = 21600 * SECOND;
583
+ const formatIn = (zone) => {
584
+ try {
585
+ return new Intl.DateTimeFormat("en-US", {
586
+ timeZone: zone,
587
+ hourCycle: "h23",
588
+ era: "short",
589
+ year: "numeric",
590
+ month: "numeric",
591
+ day: "numeric",
592
+ hour: "numeric",
593
+ minute: "numeric",
594
+ second: "numeric"
595
+ });
596
+ } catch {
597
+ throw new HostError("invalid value", `zoneRules: unknown zone ${zone}`);
598
+ }
599
+ };
600
+ /** The zone's offset from UTC at `ms`, a whole second, in seconds. */
601
+ const offsetAt = (format, ms) => {
602
+ const parts = {};
603
+ for (const p of format.formatToParts(new Date(ms))) parts[p.type] = p.value;
604
+ const year = parts.era === "BC" ? 1 - Number(parts.year) : Number(parts.year);
605
+ const wall = /* @__PURE__ */ new Date(0);
606
+ wall.setUTCFullYear(year, Number(parts.month) - 1, Number(parts.day));
607
+ wall.setUTCHours(Number(parts.hour), Number(parts.minute), Number(parts.second));
608
+ return (wall.getTime() - ms) / SECOND;
609
+ };
610
+ /** `ms` rounded down to a whole second. */
611
+ const second = (ms) => Math.floor(ms / SECOND) * SECOND;
612
+ const instantOfMs = (ms) => instant(BigInt(ms) * 1000n);
613
+ /**
614
+ * Zone Rules for the IANA zone `zone` from `from` up to `until`, exclusive,
615
+ * as an ordinary map (chapter 7): the offset in effect at `from`, then each
616
+ * Instant in the window where the offset changes. An unknown zone, an empty
617
+ * window, or an offset that isn't a whole number of minutes, as in local mean
618
+ * time before a zone adopted standard time, throws invalid value.
619
+ */
620
+ const zoneRules = (zone, from, until) => {
621
+ const start = from.getTime();
622
+ const end = until.getTime();
623
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start >= end) throw new HostError("invalid value", "zoneRules: an empty window");
624
+ const format = formatIn(zone);
625
+ const offset = (ms) => {
626
+ const o = offsetAt(format, second(ms));
627
+ if (o % 60 !== 0) throw new HostError("invalid value", `zoneRules: ${zone} is ${o} s from UTC at ${new Date(ms).toISOString()}, not whole minutes`);
628
+ return o;
629
+ };
630
+ const changes = [];
631
+ const change = (at, o) => changes.push(record({
632
+ at: instantOfMs(at),
633
+ offset: quantity(num(o), "s")
634
+ }));
635
+ let current = offset(start);
636
+ change(start, current);
637
+ let at = start;
638
+ const last = second(end - 1);
639
+ while (at < last) {
640
+ const next = Math.min(at + STEP, last);
641
+ if (offset(next) === current) {
642
+ at = next;
643
+ continue;
644
+ }
645
+ let low = second(at);
646
+ let high = next;
647
+ while (high - low > SECOND) {
648
+ const mid = second(low + (high - low) / 2);
649
+ if (offset(mid) === current) low = mid;
650
+ else high = mid;
651
+ }
652
+ current = offset(high);
653
+ change(Math.max(high, start), current);
654
+ at = high;
655
+ }
656
+ return record({
657
+ zone: text(zone),
658
+ until: instantOfMs(end),
659
+ changes: list(...changes)
660
+ });
661
+ };
662
+ //#endregion
663
+ export { httpCapability as a, toValue as c, handlersOf as i, talk as l, inlineGrants as n, sqliteCapability as o, createGroup as r, fromValue as s, zoneRules as t };