@northtalk/ts 0.4.0 → 0.5.1

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 (70) hide show
  1. package/README.md +11 -0
  2. package/base64-CDO-a06R.js +29 -0
  3. package/{binary-value-Bb6HPDtM.d.ts → binary-value-xvJoGg0C.d.ts} +1 -1
  4. package/{checker-DMI4LiRm.js → checker-CUhn2XaM.js} +4 -4
  5. package/{core-BzGUgjL6.d.ts → core-BuTAYRm-.d.ts} +1 -1
  6. package/{debug-C72o2pZy.d.ts → debug-DRhMZAxw.d.ts} +28 -8
  7. package/debug.d.ts +1 -1
  8. package/debug.js +1 -1
  9. package/{driver-ClV_UDEK.d.ts → driver-CHDcuqUy.d.ts} +1 -1
  10. package/driver.d.ts +1 -1
  11. package/driver.js +1 -1
  12. package/{encoding-C3Q7pIC9.js → encoding-RUuES_e4.js} +2 -2
  13. package/{engine-BpdGfAND.js → engine-CXf5FCwi.js} +6 -6
  14. package/{engine-Dtby_FkE.d.ts → engine-Cc3yofGM.d.ts} +2 -2
  15. package/{errors-BKJES3Zu.js → errors-D11zizZg.js} +1580 -1481
  16. package/{group-vuUL2tq-.js → group-BflSou2n.js} +66 -44
  17. package/http-fetch-DFwVIOQg.js +517 -0
  18. package/http.d.ts +39 -2
  19. package/http.js +189 -6
  20. package/index.d.ts +13 -5
  21. package/index.js +36 -49
  22. package/{inline-grants-Cx0Z9XAt.js → inline-grants-XbX9HL_w.js} +72 -304
  23. package/lean-BebPaTMK.js +47 -0
  24. package/{index-ByF5j53i.d.ts → lean-CjWVuOrC.d.ts} +86 -124
  25. package/lean.d.ts +8 -0
  26. package/lean.js +15 -0
  27. package/{manifest-Dw-8Unmf.js → manifest-CCfpn0kC.js} +3 -4
  28. package/manifest-DVrx-pT2.d.ts +122 -0
  29. package/message-layer.d.ts +2 -2
  30. package/message-layer.js +2 -2
  31. package/notify.d.ts +1 -1
  32. package/notify.js +1 -1
  33. package/{objects-Dnqor7Gn.d.ts → objects-DC6HjzBY.d.ts} +1 -1
  34. package/{objects-BC4fS0vq.js → objects-DmUc0lha.js} +1 -1
  35. package/{base64-Dtqaz_0A.js → operations-DnCcztkZ.js} +1632 -32
  36. package/package.json +36 -2
  37. package/{readers-B5e5bBrY.js → readers-CsvlahLi.js} +2 -2
  38. package/{readers-DAFVvvq4.d.ts → readers-MmyZ_d0w.d.ts} +1 -1
  39. package/{request-pump-binary-BjnyqXV5.js → request-pump-binary-oqjWFqZA.js} +5 -4
  40. package/{router-BCHEfs4x.js → router-BZ-aYeXA.js} +4 -4
  41. package/{router-BspOCPA0.d.ts → router-D56rSkU8.d.ts} +2 -2
  42. package/session.d.ts +2 -2
  43. package/session.js +54 -15
  44. package/setup.d.ts +1 -1
  45. package/setup.js +4 -4
  46. package/sqlite.d.ts +2 -2
  47. package/sqlite.js +5 -5
  48. package/stdlib/bytes.d.ts +6 -0
  49. package/stdlib/bytes.js +11 -0
  50. package/stdlib/date.d.ts +6 -0
  51. package/stdlib/date.js +11 -0
  52. package/stdlib/json.d.ts +6 -0
  53. package/stdlib/json.js +11 -0
  54. package/stdlib/list.d.ts +6 -0
  55. package/stdlib/list.js +10 -0
  56. package/stdlib/map.d.ts +6 -0
  57. package/stdlib/map.js +10 -0
  58. package/stdlib/text.d.ts +6 -0
  59. package/stdlib/text.js +10 -0
  60. package/stdlib/units.d.ts +6 -0
  61. package/stdlib/units.js +10 -0
  62. package/stdlib-registry-BwitI3Ox.d.ts +18 -0
  63. package/{store-DTQa0lyE.js → store-DHlo6fP5.js} +2 -2
  64. package/{store-capability-BxXgiRM7.js → store-capability-BrUUAwVS.js} +3 -4
  65. package/store.d.ts +2 -2
  66. package/store.js +2 -2
  67. package/{user-capability-5-IvCeZI.js → user-capability-BcRQyyEw.js} +4 -5
  68. package/wasm.d.ts +5 -5
  69. package/wasm.js +13 -11
  70. package/capabilities-Bi5Qm6Fr.js +0 -1320
package/http.js CHANGED
@@ -1,9 +1,187 @@
1
1
 
2
- import { A as listValues, N as map, Q as text, R as num, d as bytes, i as ScriptError, t as HostError, u as bool } from "./errors-BKJES3Zu.js";
3
- import { t as defineObjectKind } from "./objects-BC4fS0vq.js";
4
- import { u as shape } from "./capabilities-Bi5Qm6Fr.js";
2
+ import { A as listValues, N as map, Q as text, R as num, d as bytes, i as ScriptError, t as HostError, u as bool } from "./errors-D11zizZg.js";
3
+ import { t as defineObjectKind } from "./objects-DmUc0lha.js";
4
+ import { xt as shape } from "./operations-DnCcztkZ.js";
5
+ import { a as parseFetchUrl, i as fetchOrigin } from "./http-fetch-DFwVIOQg.js";
5
6
  import { Buffer } from "node:buffer";
6
- import { createServer } from "node:http";
7
+ import { createServer, request } from "node:http";
8
+ import { request as request$1 } from "node:https";
9
+ //#region src/http/fetch.ts
10
+ /** The largest response body `fetch` reads by default: 8 MiB. */
11
+ const HTTP_FETCH_DEFAULT_MAX_BODY_BYTES = 8388608;
12
+ /** The most response header bytes `fetch` reads by default: 64 KiB. */
13
+ const HTTP_FETCH_DEFAULT_MAX_HEADER_BYTES = 65536;
14
+ /** The origins as `scheme://host:port`, or throws `invalid value`. */
15
+ const httpFetchOrigins = (origins) => {
16
+ if (origins === "any") return "any";
17
+ if (!Array.isArray(origins)) throw new HostError("invalid value", "A fetch binding's origins are 'any' or a list of origins");
18
+ const out = /* @__PURE__ */ new Set();
19
+ for (const origin of origins) {
20
+ const u = typeof origin === "string" && !/:\/\/[^]*[#/?]/.test(origin) ? parseFetchUrl(origin) : void 0;
21
+ if (!u) throw new HostError("invalid value", `Not an origin: ${String(origin)}`);
22
+ out.add(fetchOrigin(u));
23
+ }
24
+ return out;
25
+ };
26
+ const failure = (code, message, data) => new ScriptError(code, message, data);
27
+ const responseHeaders = (raw) => {
28
+ const headers = /* @__PURE__ */ new Map();
29
+ for (let i = 0; i + 1 < raw.length; i += 2) {
30
+ const name = raw[i].toLowerCase();
31
+ headers.set(name, [...headers.get(name) ?? [], raw[i + 1]]);
32
+ }
33
+ return map([...headers].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, vs]) => [k, k === "set-cookie" ? listValues(vs.map((v) => text(v))) : text(vs.join(", "))]));
34
+ };
35
+ const headerBytes = (raw) => {
36
+ let n = 0;
37
+ for (let i = 0; i + 1 < raw.length; i += 2) n += Buffer.byteLength(raw[i]) + Buffer.byteLength(raw[i + 1]) + 4;
38
+ return n;
39
+ };
40
+ /** `fetch` for `httpCapability`, alone or beside the router's server Operations. */
41
+ const createHttpFetch = (o = {}) => {
42
+ const fixed = typeof o.origins === "function" ? void 0 : httpFetchOrigins(o.origins ?? []);
43
+ const maxBody = o.maxBodyBytes ?? 8388608;
44
+ const maxHeader = o.maxHeaderBytes ?? 65536;
45
+ for (const [name, n] of [["maxBodyBytes", maxBody], ["maxHeaderBytes", maxHeader]]) if (!Number.isSafeInteger(n) || n < 0) throw new HostError("invalid value", `${name} must be a whole number`);
46
+ const log = o.log ?? (() => {});
47
+ const allowed = (binding, origin) => {
48
+ let set = fixed;
49
+ if (!set) {
50
+ const given = o.origins(binding);
51
+ set = httpFetchOrigins(given ?? []);
52
+ }
53
+ return set === "any" || set.has(origin);
54
+ };
55
+ return { fetch: (call, url, request$2) => {
56
+ const u = parseFetchUrl(url);
57
+ const origin = fetchOrigin(u);
58
+ let ok;
59
+ try {
60
+ ok = allowed(call.binding, origin);
61
+ } catch (error) {
62
+ log(`fetch ${url}: ${error instanceof Error ? error.message : error}`);
63
+ ok = false;
64
+ }
65
+ if (!ok) {
66
+ call.fail(failure("bad address", `${origin} isn't allowed`));
67
+ return;
68
+ }
69
+ const method = request$2.get("method").asText();
70
+ const headers = {};
71
+ const named = /* @__PURE__ */ new Set();
72
+ for (const [name, value] of request$2.get("headers").entries()) {
73
+ named.add(name.toLowerCase());
74
+ headers[name] = value.kind === "text" ? value.asText() : Array.from({ length: value.length }, (_, i) => value.index(i + 1).asText());
75
+ }
76
+ let body;
77
+ const given = request$2.get("body");
78
+ const json = request$2.get("json");
79
+ if (given.kind === "text") {
80
+ body = Buffer.from(given.asText(), "utf8");
81
+ if (!named.has("content-type")) headers["content-type"] = "text/plain; charset=utf-8";
82
+ } else if (given.kind === "bytes") body = given.asBytes();
83
+ else if (json.kind === "text") {
84
+ body = Buffer.from(json.asText(), "utf8");
85
+ if (!named.has("content-type")) headers["content-type"] = "application/json";
86
+ }
87
+ if (!named.has("accept-encoding")) headers["accept-encoding"] = "identity";
88
+ if (body) headers["content-length"] = String(body.length);
89
+ let settled = false;
90
+ let req;
91
+ const abort = () => {
92
+ settled = true;
93
+ req?.destroy();
94
+ };
95
+ const settle = (f) => {
96
+ if (settled) return;
97
+ settled = true;
98
+ call.signal.removeEventListener("abort", abort);
99
+ f();
100
+ req?.destroy();
101
+ };
102
+ const networkError = (why) => settle(() => {
103
+ log(`fetch ${url}: ${why}`);
104
+ call.fail(failure("network error", why));
105
+ });
106
+ const tooLarge = (field, limit) => settle(() => call.fail(failure("response too large", `The response's ${field} pass ${limit} bytes`, map([["field", text(field)], ["limit", num(limit)]]))));
107
+ if (call.signal.aborted) return;
108
+ call.signal.addEventListener("abort", abort, { once: true });
109
+ const onResponse = (res) => {
110
+ const status = res.statusCode ?? 0;
111
+ if (status < 200 || status > 599) {
112
+ networkError(`status ${status}`);
113
+ return;
114
+ }
115
+ let seen = headerBytes(res.rawHeaders);
116
+ if (seen > maxHeader) {
117
+ tooLarge("headers", maxHeader);
118
+ return;
119
+ }
120
+ const chunks = [];
121
+ let size = 0;
122
+ res.on("data", (chunk) => {
123
+ size += chunk.length;
124
+ if (size > maxBody) {
125
+ tooLarge("body", maxBody);
126
+ return;
127
+ }
128
+ chunks.push(chunk);
129
+ });
130
+ res.on("end", () => {
131
+ seen += headerBytes(res.rawTrailers);
132
+ if (seen > maxHeader) {
133
+ tooLarge("headers", maxHeader);
134
+ return;
135
+ }
136
+ if (!res.complete) {
137
+ networkError("the response ended early");
138
+ return;
139
+ }
140
+ settle(() => call.answer(map([
141
+ ["status", num(status)],
142
+ ["headers", responseHeaders(res.rawHeaders)],
143
+ ["body", bytes(new Uint8Array(Buffer.concat(chunks)))]
144
+ ])));
145
+ });
146
+ res.on("aborted", () => networkError("the response was cut off"));
147
+ res.on("error", (e) => networkError(e.message));
148
+ res.on("close", () => {
149
+ if (!res.complete) networkError("the connection closed early");
150
+ });
151
+ };
152
+ const target = `${u.path}${u.query === void 0 ? "" : `?${u.query}`}`;
153
+ const hostname = u.host.startsWith("[") ? u.host.slice(1, -1) : u.host;
154
+ try {
155
+ req = (u.scheme === "https" ? request$1 : request)({
156
+ hostname,
157
+ port: u.port,
158
+ path: target,
159
+ method,
160
+ headers,
161
+ agent: false,
162
+ maxHeaderSize: maxHeader + 16384,
163
+ ...u.scheme === "https" ? {
164
+ rejectUnauthorized: true,
165
+ ...o.ca ? { ca: o.ca } : {}
166
+ } : {}
167
+ });
168
+ } catch (error) {
169
+ networkError(error instanceof Error ? error.message : String(error));
170
+ return;
171
+ }
172
+ req.on("response", onResponse);
173
+ req.on("upgrade", (_res, socket) => {
174
+ socket.destroy();
175
+ networkError("the server switched protocols");
176
+ });
177
+ req.on("error", (e) => {
178
+ if (e.code === "HPE_HEADER_OVERFLOW") tooLarge("headers", maxHeader);
179
+ else networkError(e.message);
180
+ });
181
+ req.end(body);
182
+ } };
183
+ };
184
+ //#endregion
7
185
  //#region src/http/router.ts
8
186
  /** The largest request body the router reads by default: 1 MiB. */
9
187
  const HTTP_DEFAULT_MAX_BODY_BYTES = 1048576;
@@ -441,7 +619,12 @@ const createHttpHost = (o = {}) => {
441
619
  await Promise.all(closing);
442
620
  };
443
621
  return {
444
- impl: {
622
+ impl: o.fetch ? {
623
+ serve,
624
+ unserve,
625
+ respond,
626
+ ...createHttpFetch(o.fetch)
627
+ } : {
445
628
  serve,
446
629
  unserve,
447
630
  respond
@@ -462,4 +645,4 @@ const createHttpHost = (o = {}) => {
462
645
  };
463
646
  };
464
647
  //#endregion
465
- export { HTTP_DEFAULT_MAX_BODY_BYTES, createHttpHost, requestFields };
648
+ export { HTTP_DEFAULT_MAX_BODY_BYTES, HTTP_FETCH_DEFAULT_MAX_BODY_BYTES, HTTP_FETCH_DEFAULT_MAX_HEADER_BYTES, createHttpFetch, createHttpHost, httpFetchOrigins, requestFields };
package/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  /// <reference lib="esnext.disposable" />
2
- import { $ as instant, $n as Body, $t as Script$1, A as ScriptSources, An as compileLibrary, Ar as syntaxSelector, At as FireOp, B as restore, Bn as defaultLimits, Bt as ReleaseHook, C as Report, Cn as consoleCapability, Cr as TokType, Ct as ChargeRequest, Dn as LibrarySource, Dr as SyntaxNode, Dt as EffectResult, E as RestoreResult, En as LibraryOptions, Er as SyntaxErrorCode, Et as Cost, Fn as Run, Ft as Metering, G as RunStarted, Gn as waitUs, Gt as SegmentGrant, H as RunAccounting, Hn as loadScript, Ht as ScopeDecl, In as RunRecord, It as Operation, J as Value, Jn as LoadDiagnostic, Jt as SuspendingOp, K as Decimal, Kn as HostError, Kt as SegmentLifecycle, L as TsScript, Ln as Script, Lt as Operations, Mn as LimitName, Mt as GrantContext, N as Settlement, Nn as Limits, Nt as ImmediateOp, O as SaveOptions, On as OperationRef, Or as SyntaxRule, Ot as ErrorDecl, P as TsGroup, Pn as Outcome, Pt as LimitReached, Q as dec, Qn as SendFailedReason, Qt as Group, R as Verdict, Rn as UnitLoadError, Rt as PlainArg, S as PumpedRequest, Sn as clockCapability, Sr as Mode, St as CapabilityDefiner, T as RestoreOptions, Tn as Library, Tr as SyntaxElement, Tt as CoordinatedLifecycle, U as RunAncestry, Un as NotImplementedError, Ut as SegmentContext, V as CausalWork, Vn as deliver, Vt as ReleaseReason, W as RunDiscarded, Wn as canConvert, 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, _r as SemanticScope, _t as PropDef, an as userCapability, ar as Operand, at as quantity, b as PumpOptions, bn as TimerImpl, br as SourceSpan, bt as Call, cn as storeCapability, cr as Binding, d as Counters, dn as SqlValue, dr as FunctionContract, dt as nowMicros, en as Versions, er as BodyKind, f as Decided, fn as SqliteBinding, fr as LibraryExport, ft as parseInstant, g as Inspection, gn as localeCapability, gr as SemanticNode, gt as ObjectKindDef, h as GroupOptions, hn as LocaleImpl, hr as SemanticName, ht as ObjectKind, in as UserImpl, ir as Instruction, it as num, jr as syntaxText, jt as Grant, k as ScriptCodeRequest, kn as codeIdentity, kr as Trivia, kt as FieldShape, l as CancellationOptions, ln as SqlParams, lr as BindingKind, lt as text, m as EffectFailure, mn as sqliteCapability, mr as SemanticElement, mt as ObjectElements, nn as HttpImpl, nr as EventBranch, nt as map, on as StoreImpl, or as UnwindEntry, ot as range, p as Deciding, pn as SqliteImpl, pr as NameRole, pt as HostObject, q as Kind, qn as HostErrorCode, qt as Shape, rn as httpCapability, rr as EventEntry, rt as nothing, sn as add, sr as disassemble, st as record, tn as coreVersions, tr as CodeUnit, tt as list, u as CarryOver, un as SqlRows, ur as ExportKind, ut as formatInstant, v as Message, vn as ConsoleImpl, vr as SemanticToken, vt as defineObjectKind, w as Requested, wn as timerCapability, wr as Token, wt as ChargeResult, x as PumpResult, xn as calendarCapability, xr as Lexer, xt as CapabilityDef, y as PendingCall, yn as Costs, yr as SemanticTree, yt as GrantDecls, z as newGroup, zn as callFunction, zt as PlainResult } from "./debug-C72o2pZy.js";
3
- import { A as ToValueOptions, B as checkSyntax, C as handlersOf, D as encodeValue, E as kindNames, F as CheckResult, G as RecoveringParseResult, H as EntryResult, I as Diagnostic, J as parseSource, K as RecoveryDiagnostic, L as DiagnosticCode, M as toValue, N as talk, O as FromValueOptions, P as CheckOptions, Q as units, R as SemanticResult, S as ScriptWithHandlers, T as encodeJson, U as ParseError, V as EntryKind, W as ParseResult, X as builtins, Y as parseSourceRecovering, Z as grammar, _ as createGroup, a as CompileResult, c as exportsOf, d as MessageDecl, f as exportManifest, g as CreateGroupOptions, h as inlineGrants, i as CompileOptions, j as fromValue, k as PlainValue, l as lowerTree, m as InlineOperation, n as declarationStart, o as LoweringError, p as InlineFunction, q as parseEntry, r as stdlibSources, s as compileSource, t as validMessageSelector, u as ManifestSpec, w as decodeJson, x as Handlers, y as DrivenGroup, z as checkSource } from "./index-ByF5j53i.js";
4
- import { n as createCore, t as TsCore } from "./core-BzGUgjL6.js";
5
- import { a as decodeValue, o as readDisplay, t as FunctionResolver } from "./readers-DAFVvvq4.js";
6
- export { type Binding, type BindingKind, type Body, type BodyKind, type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ChargeRequest, type ChargeResult, type CheckOptions, type CheckResult, type CodeUnit, type CompileOptions, type CompileResult, Script as CompiledScript, type ConsoleImpl, type CoordinatedLifecycle, type Core, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type Diagnostic, type DiagnosticCode, type DrivenGroup, type EffectFailure, type EffectResult, type EntryKind, type EntryResult, type ErrorDecl, type EventBranch, type EventEntry, type ExportKind, type FieldShape, type FireOp, type FromValueOptions, type FunctionContract, type FunctionResolver, 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 Instruction, type Kind, Lexer, type Library, type LibraryExport, type LibraryOptions, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, LoweringError, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type Metering, type Mode, type NameRole, NotImplementedError, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operand, type Operation, type OperationRef, type Operations, type Outcome, ParseError, type ParseResult, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type RecoveringParseResult, type RecoveryDiagnostic, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, Run, type RunAccounting, type RunAncestry, type RunDiscarded, type RunRecord, type RunStarted, type SaveOptions, type ScopeDecl, type Script$1 as Script, type ScriptCodeRequest, ScriptError, type ScriptSources, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SemanticElement, type SemanticName, type SemanticNode, type SemanticResult, type SemanticScope, type SemanticToken, type SemanticTree, type SendFailedReason, type Settlement, type Shape, type SourceSpan, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StoreImpl, type SuspendingOp, type SyntaxElement, type SyntaxErrorCode, type SyntaxNode, type SyntaxRule, type TimerImpl, type ToValueOptions, type TokType, type Token, type Trivia, type TsCore, TsGroup, TsScript, UnitLoadError, type UnwindEntry, type UserImpl, Value, type Verdict, type Versions, add, bool, builtins, bytes, calendarCapability, callFunction, canConvert, checkSource, checkSyntax, civilDate, clockCapability, codeIdentity, compileLibrary, compileSource, consoleCapability, coreVersions, createCore, createGroup, dec, declarationStart, decodeJson, decodeValue, defaultLimits, defineCapability, defineObjectKind, deliver, disassemble, encodeJson, encodeValue, exportManifest, exportsOf, formatInstant, fromValue, grammar, handlersOf, httpCapability, inlineGrants, instant, kindNames, list, loadScript, localeCapability, lowerTree, map, newGroup, nothing, nowMicros, num, parseEntry, parseInstant, parseSource, parseSourceRecovering, quantity, range, readDisplay, record, restore, shape, sqliteCapability, stdlibSources, storeCapability, syntaxSelector, syntaxText, talk, text, timerCapability, toValue, units, userCapability, validMessageSelector, waitUs };
2
+ import { $ as instant, $n as ScriptError, $t as Script$1, A as ScriptSources, An as OperationRef, Ar as SyntaxRule, At as FireOp, B as restore, Bn as UnitLoadError, Bt as ReleaseHook, C as Report, Cn as calendarCapability, Cr as Lexer, Ct as ChargeRequest, Dn as Library, Dr as SyntaxElement, Dt as EffectResult, E as RestoreResult, En as timerCapability, Er as Token, Et as Cost, Fn as Limits, Ft as Metering, G as RunStarted, Gn as NotImplementedError, Gt as SegmentGrant, H as RunAccounting, Hn as defaultLimits, Ht as ScopeDecl, In as Outcome, It as Operation, J as Value, Jn as HostError, Jt as SuspendingOp, K as Decimal, Kn as canConvert, Kt as SegmentLifecycle, L as TsScript, Ln as Run, Lt as Operations, Mn as compileLibrary, Mr as syntaxSelector, Mt as GrantContext, N as Settlement, Nr as syntaxText, Nt as ImmediateOp, O as SaveOptions, On as LibraryOptions, Or as SyntaxErrorCode, Ot as ErrorDecl, P as TsGroup, Pn as LimitName, Pt as LimitReached, Q as dec, Qn as MailboxFull, Qt as Group, R as Verdict, Rn as RunRecord, Rt as PlainArg, S as PumpedRequest, Sn as TimerImpl, Sr as SourceSpan, St as CapabilityDefiner, T as RestoreOptions, Tn as consoleCapability, Tr as TokType, Tt as CoordinatedLifecycle, U as RunAncestry, Un as deliver, Ut as SegmentContext, V as CausalWork, Vn as callFunction, Vt as ReleaseReason, W as RunDiscarded, Wn as loadScript, Wt as SegmentCoordinator, X as bytes, Xn as LoadDiagnostic, Xt as shape, Y as bool, Yn as HostErrorCode, Yt as defineCapability, Z as civilDate, Zn as LoadError, Zt as Core, _ as LoadOptions, _n as LocaleImpl, _r as SemanticName, _t as PropDef, an as httpCapability, ar as EventEntry, at as quantity, b as PumpOptions, bn as ConsoleImpl, br as SemanticToken, bt as Call, cn as StoreImpl, cr as UnwindEntry, d as Counters, dn as SqlParams, dr as BindingKind, dt as nowMicros, en as Versions, er as SendFailedReason, f as Decided, fn as SqlRows, fr as ExportKind, ft as parseInstant, g as Inspection, gn as sqliteCapability, gr as SemanticElement, gt as ObjectKindDef, h as GroupOptions, hn as SqliteImpl, hr as NameRole, ht as ObjectKind, in as HttpServerImpl, ir as EventBranch, it as num, jn as codeIdentity, jr as Trivia, jt as Grant, k as ScriptCodeRequest, kn as LibrarySource, kr as SyntaxNode, kt as FieldShape, l as CancellationOptions, ln as add, lr as disassemble, lt as text, m as EffectFailure, mn as SqliteBinding, mr as LibraryExport, mt as ObjectElements, nn as HttpClientImpl, nr as BodyKind, nt as map, on as UserImpl, or as Instruction, ot as range, p as Deciding, pn as SqlValue, pr as FunctionContract, pt as HostObject, q as Kind, qn as waitUs, qt as Shape, rn as HttpImpl, rr as CodeUnit, rt as nothing, sn as userCapability, sr as Operand, st as record, tn as coreVersions, tr as Body, tt as list, u as CarryOver, un as storeCapability, ur as Binding, ut as formatInstant, v as Message, vn as localeCapability, vr as SemanticNode, vt as defineObjectKind, w as Requested, wn as clockCapability, wr as Mode, wt as ChargeResult, x as PumpResult, xn as Costs, xr as SemanticTree, xt as CapabilityDef, y as PendingCall, yn as CalendarImpl, yr as SemanticScope, yt as GrantDecls, z as newGroup, zn as Script, zt as PlainResult } from "./debug-DRhMZAxw.js";
3
+ import { n as registerStdlib, r as stdlibNames, t as StdlibLibrary } from "./stdlib-registry-BwitI3Ox.js";
4
+ import { A as units, C as RecoveringParseResult, D as parseSourceRecovering, E as parseSource, O as builtins, S as ParseResult, T as parseEntry, _ as checkSource, a as LoweringError, b as EntryResult, c as lowerTree, d as kindNames, f as CheckOptions, g as SemanticResult, h as DiagnosticCode, i as CompileResult, k as grammar, l as CreateGroupOptions, m as Diagnostic, n as declarationStart, o as compileSource, p as CheckResult, r as CompileOptions, s as exportsOf, t as validMessageSelector, u as createGroup, v as checkSyntax, w as RecoveryDiagnostic, x as ParseError, y as EntryKind } from "./lean-CjWVuOrC.js";
5
+ 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, m as encodeJson, n as MessageDecl, o as inlineGrants, p as decodeJson, r as exportManifest, t as ManifestSpec, u as Handlers, v as ToValueOptions, x as talk, y as fromValue } from "./manifest-DVrx-pT2.js";
6
+ import { n as createCore, t as TsCore } from "./core-BuTAYRm-.js";
7
+ import { a as decodeValue, o as readDisplay, t as FunctionResolver } from "./readers-MmyZ_d0w.js";
8
+ //#region src/generated/stdlib.d.ts
9
+ /** Every stdlib Library. */
10
+ export declare const allStdlib: readonly StdlibLibrary[];
11
+ /** Every stdlib Library's source, by name. */
12
+ export declare const stdlibSources: Record<string, string>;
13
+ //#endregion
14
+ export { type Binding, type BindingKind, type Body, type BodyKind, type CalendarImpl, type Call, type CancellationOptions, type CapabilityDef, type CapabilityDefiner, type CarryOver, type CausalWork, type ChargeRequest, type ChargeResult, type CheckOptions, type CheckResult, type CodeUnit, type CompileOptions, type CompileResult, Script as CompiledScript, type ConsoleImpl, type CoordinatedLifecycle, type Core, type Cost, type Costs, type Counters, type CreateGroupOptions, type Decided, type Deciding, Decimal, type Diagnostic, type DiagnosticCode, type DrivenGroup, type EffectFailure, type EffectResult, type EntryKind, type EntryResult, type ErrorDecl, type EventBranch, type EventEntry, type ExportKind, type FieldShape, type FireOp, type FromValueOptions, type FunctionContract, type FunctionResolver, 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 Instruction, type Kind, Lexer, type Library, type LibraryExport, type LibraryOptions, type LibrarySource, type LimitName, LimitReached, type Limits, type LoadDiagnostic, LoadError, type LoadOptions, type LocaleImpl, LoweringError, MailboxFull, type ManifestSpec, type Message, type MessageDecl, type Metering, type Mode, type NameRole, NotImplementedError, type ObjectElements, type ObjectKind, type ObjectKindDef, type Operand, type Operation, type OperationRef, type Operations, type Outcome, ParseError, type ParseResult, type PendingCall, type PlainArg, type PlainResult, type PlainValue, type PropDef, type PumpOptions, type PumpResult, type PumpedRequest, type RecoveringParseResult, type RecoveryDiagnostic, type ReleaseHook, type ReleaseReason, type Report, type Requested, type RestoreOptions, type RestoreResult, Run, type RunAccounting, type RunAncestry, type RunDiscarded, type RunRecord, type RunStarted, type SaveOptions, type ScopeDecl, type Script$1 as Script, type ScriptCodeRequest, ScriptError, type ScriptSources, type ScriptWithHandlers, type SegmentContext, type SegmentCoordinator, type SegmentGrant, type SegmentLifecycle, type SemanticElement, type SemanticName, type SemanticNode, type SemanticResult, type SemanticScope, type SemanticToken, type SemanticTree, type SendFailedReason, type Settlement, type Shape, type SourceSpan, type SqlParams, type SqlRows, type SqlValue, type SqliteBinding, type SqliteImpl, type StdlibLibrary, type StoreImpl, type SuspendingOp, type SyntaxElement, type SyntaxErrorCode, type SyntaxNode, type SyntaxRule, type TimerImpl, type ToValueOptions, type TokType, type Token, type Trivia, type TsCore, TsGroup, TsScript, UnitLoadError, type UnwindEntry, type UserImpl, Value, type Verdict, type Versions, add, bool, builtins, bytes, calendarCapability, callFunction, canConvert, checkSource, checkSyntax, civilDate, clockCapability, codeIdentity, compileLibrary, compileSource, consoleCapability, coreVersions, createCore, createGroup, dec, declarationStart, decodeJson, decodeValue, defaultLimits, defineCapability, defineObjectKind, deliver, disassemble, encodeJson, encodeValue, exportManifest, exportsOf, formatInstant, fromValue, grammar, handlersOf, httpCapability, inlineGrants, instant, kindNames, list, loadScript, localeCapability, lowerTree, map, newGroup, nothing, nowMicros, num, parseEntry, parseInstant, parseSource, parseSourceRecovering, quantity, range, readDisplay, record, registerStdlib, restore, shape, sqliteCapability, stdlibNames, storeCapability, syntaxSelector, syntaxText, talk, text, timerCapability, toValue, units, userCapability, validMessageSelector, waitUs };
package/index.js CHANGED
@@ -1,52 +1,39 @@
1
1
 
2
- import { G as record, H as quantity, Kt as formatInstant, L as nothing, N as map, Q as text, R as num, T as instant, W as range, Yt as nowMicros, Zt as parseInstant, c as Decimal, d as bytes, dt as builtins, gt as units, i as ScriptError, k as list, l as Value, m as civilDate, n as LoadError, pt as grammar, r as MailboxFull, t as HostError, u as bool, un as unicodeVersion, v as dec } from "./errors-BKJES3Zu.js";
3
- import { t as defineObjectKind } from "./objects-BC4fS0vq.js";
4
- import { h as Lexer, i as defineCapability, p as validMessageSelector, t as LimitReached, u as shape } from "./capabilities-Bi5Qm6Fr.js";
5
- import { a as syntaxText, c as parseSource, i as syntaxSelector, l as parseSourceRecovering, o as ParseError, p as declarationStart, r as checkSyntax, s as parseEntry, t as checkSource, v as kindNames } from "./checker-DMI4LiRm.js";
6
- import { W as waitUs, ft as costModel, mt as languageVersion, r as NotImplementedError, tt as disassemble, u as canConvert } from "./base64-Dtqaz_0A.js";
7
- import { S as lowerTree, _ as deliver, b as compileSource, c as codeIdentity, d as stdlibSources, f as Run, g as defaultLimits, h as callFunction, i as restore, l as compileLibrary, m as UnitLoadError, n as TsScript, p as Script, r as newGroup, s as stateFingerprint, t as TsGroup, v as loadScript, x as exportsOf, y as LoweringError } from "./group-vuUL2tq-.js";
8
- import { n as exportManifest } from "./manifest-Dw-8Unmf.js";
9
- import { c as readDisplay, r as decodeValue } from "./readers-B5e5bBrY.js";
10
- import { t as encodeValue } from "./encoding-C3Q7pIC9.js";
11
- import { a as sqliteCapability, c as fromValue, i as httpCapability, l as toValue, n as createGroup$1, o as decodeJson, r as handlersOf, s as encodeJson, t as inlineGrants, u as talk } from "./inline-grants-Cx0Z9XAt.js";
12
- import { n as localeCapability, t as userCapability } from "./user-capability-5-IvCeZI.js";
13
- import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BxXgiRM7.js";
14
- //#region src/versions.ts
15
- const coreVersions = Object.freeze({
16
- language: languageVersion,
17
- costModel: String(costModel.version),
18
- unicode: unicodeVersion,
19
- core: "ts/0.4.0",
20
- saveFormat: String(1)
21
- });
2
+ import { text as text$1 } from "./stdlib/text.js";
3
+ import { bytes as bytes$1 } from "./stdlib/bytes.js";
4
+ import { date } from "./stdlib/date.js";
5
+ import { json } from "./stdlib/json.js";
6
+ import { list as list$1 } from "./stdlib/list.js";
7
+ import { map as map$1 } from "./stdlib/map.js";
8
+ import { units as units$1 } from "./stdlib/units.js";
9
+ import { Bt as formatInstant, G as record, Gt as parseInstant, H as quantity, L as nothing, N as map, Q as text, R as num, T as instant, Ut as nowMicros, W as range, an as builtins, c as Decimal, d as bytes, i as ScriptError, k as list, l as Value, m as civilDate, n as LoadError, r as MailboxFull, sn as grammar, t as HostError, u as bool, un as units, v as dec } from "./errors-D11zizZg.js";
10
+ import { S as registerStdlib, _ as loadScript, b as exportsOf, c as codeIdentity, d as Run, f as Script, g as deliver, h as defaultLimits, i as restore, l as compileLibrary, m as callFunction, n as TsScript, p as UnitLoadError, r as newGroup, t as TsGroup, v as LoweringError, w as stdlibNames, x as lowerTree, y as compileSource } from "./group-BflSou2n.js";
11
+ import { t as defineObjectKind } from "./objects-DmUc0lha.js";
12
+ import { $ as disassemble, Ct as validMessageSelector, H as waitUs, Tt as Lexer, _t as defineCapability, c as canConvert, ht as LimitReached, t as NotImplementedError, xt as shape } from "./operations-DnCcztkZ.js";
13
+ import { a as syntaxText, c as parseSource, i as syntaxSelector, l as parseSourceRecovering, o as ParseError, p as declarationStart, r as checkSyntax, s as parseEntry, t as checkSource, v as kindNames } from "./checker-CUhn2XaM.js";
14
+ import { n as exportManifest } from "./manifest-CCfpn0kC.js";
15
+ import { c as readDisplay, r as decodeValue } from "./readers-CsvlahLi.js";
16
+ import { t as encodeValue } from "./encoding-RUuES_e4.js";
17
+ import { a as sqliteCapability, c as talk, i as httpCapability, o as fromValue, r as handlersOf, s as toValue, t as inlineGrants } from "./inline-grants-XbX9HL_w.js";
18
+ import { o as decodeJson, s as encodeJson } from "./http-fetch-DFwVIOQg.js";
19
+ import { n as createCore, r as coreVersions, t as createGroup } from "./lean-BebPaTMK.js";
20
+ import { n as localeCapability, t as userCapability } from "./user-capability-BcRQyyEw.js";
21
+ import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BrUUAwVS.js";
22
+ //#region src/generated/stdlib.ts
23
+ /** Every stdlib Library. */
24
+ const allStdlib = [
25
+ bytes$1,
26
+ date,
27
+ json,
28
+ list$1,
29
+ map$1,
30
+ text$1,
31
+ units$1
32
+ ];
33
+ /** Every stdlib Library's source, by name. */
34
+ const stdlibSources = Object.fromEntries(allStdlib.map((l) => [l.name, l.source]));
22
35
  //#endregion
23
- //#region src/core.ts
24
- const core = Object.freeze({
25
- defineCapability,
26
- defineObjectKind,
27
- clockCapability,
28
- calendarCapability,
29
- localeCapability,
30
- timerCapability,
31
- consoleCapability,
32
- storeCapability,
33
- sqliteCapability,
34
- userCapability,
35
- httpCapability,
36
- compileLibrary,
37
- newGroup,
38
- restore,
39
- stateFingerprint,
40
- versions: coreVersions
41
- });
42
- /** Return the process-wide Core, also used by the free-function helpers. */
43
- const createCore = () => core;
36
+ //#region src/index.ts
37
+ registerStdlib(...allStdlib);
44
38
  //#endregion
45
- //#region src/create-group.ts
46
- /** Creates a driven Group that supports `await using` and explicit close(reason). */
47
- const createGroup = (o) => createGroup$1({
48
- ...o,
49
- core: o.core ?? createCore()
50
- });
51
- //#endregion
52
- export { Script as CompiledScript, Decimal, HostError, Lexer, LimitReached, LoadError, LoweringError, MailboxFull, NotImplementedError, ParseError, Run, ScriptError, TsGroup, TsScript, UnitLoadError, Value, add, bool, builtins, bytes, calendarCapability, callFunction, canConvert, checkSource, checkSyntax, civilDate, clockCapability, codeIdentity, compileLibrary, compileSource, consoleCapability, coreVersions, createCore, createGroup, dec, declarationStart, decodeJson, decodeValue, defaultLimits, defineCapability, defineObjectKind, deliver, disassemble, encodeJson, encodeValue, exportManifest, exportsOf, formatInstant, fromValue, grammar, handlersOf, httpCapability, inlineGrants, instant, kindNames, list, loadScript, localeCapability, lowerTree, map, newGroup, nothing, nowMicros, num, parseEntry, parseInstant, parseSource, parseSourceRecovering, quantity, range, readDisplay, record, restore, shape, sqliteCapability, stdlibSources, storeCapability, syntaxSelector, syntaxText, talk, text, timerCapability, toValue, units, userCapability, validMessageSelector, waitUs };
39
+ export { Script as CompiledScript, Decimal, HostError, Lexer, LimitReached, LoadError, LoweringError, MailboxFull, NotImplementedError, ParseError, Run, ScriptError, TsGroup, TsScript, UnitLoadError, Value, add, allStdlib, bool, builtins, bytes, calendarCapability, callFunction, canConvert, checkSource, checkSyntax, civilDate, clockCapability, codeIdentity, compileLibrary, compileSource, consoleCapability, coreVersions, createCore, createGroup, dec, declarationStart, decodeJson, decodeValue, defaultLimits, defineCapability, defineObjectKind, deliver, disassemble, encodeJson, encodeValue, exportManifest, exportsOf, formatInstant, fromValue, grammar, handlersOf, httpCapability, inlineGrants, instant, kindNames, list, loadScript, localeCapability, lowerTree, map, newGroup, nothing, nowMicros, num, parseEntry, parseInstant, parseSource, parseSourceRecovering, quantity, range, readDisplay, record, registerStdlib, restore, shape, sqliteCapability, stdlibNames, stdlibSources, storeCapability, syntaxSelector, syntaxText, talk, text, timerCapability, toValue, units, userCapability, validMessageSelector, waitUs };