@northtalk/ts 0.1.0 → 0.2.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 (54) hide show
  1. package/README.md +9 -5
  2. package/{encoding-DWlbPq-e.js → base64-DORMd3Hv.js} +197 -1368
  3. package/binary-value-CEmh60GC.d.ts +15 -0
  4. package/capabilities-CH0FkRMq.js +1301 -0
  5. package/checker-Dc1jl2WH.js +6657 -0
  6. package/core-DptnvQT9.d.ts +14 -0
  7. package/{debug-D8Z_u244.d.ts → debug-CQBxKnJB.d.ts} +1147 -780
  8. package/debug.d.ts +2 -1
  9. package/debug.js +2 -1
  10. package/driver.d.ts +16 -2
  11. package/driver.js +98 -20
  12. package/encoding-nlrpj-Pb.js +99 -0
  13. package/{engine-CgCMdGGd.js → engine-BGaJ9dAk.js} +7 -5
  14. package/{engine-BPFnHT9N.d.ts → engine-vbYInVYF.d.ts} +3 -3
  15. package/{errors-DHwz1Vho.js → errors-LYJZ_c8h.js} +91 -17
  16. package/{group-B4eyJKTA.js → group-B742gg4T.js} +1490 -7278
  17. package/{sqlite-capability-CrCej3Po.js → http-capability-CSTkw1Yt.js} +255 -5
  18. package/http.d.ts +59 -0
  19. package/http.js +465 -0
  20. package/index.d.ts +23 -17
  21. package/index.js +19 -12
  22. package/manifest-BscyH_rW.d.ts +70 -0
  23. package/{manifest-DKe2Je6Z.js → manifest-DjsxDSuB.js} +11 -90
  24. package/message-layer.d.ts +12 -0
  25. package/message-layer.js +4 -0
  26. package/notify.d.ts +2 -1
  27. package/notify.js +2 -1
  28. package/{objects-MeXIDDFo.d.ts → objects-DJ3QtCCs.d.ts} +23 -8
  29. package/objects-Db7IB5vQ.js +91 -0
  30. package/operation-promises-EgZXG5N_.js +23 -0
  31. package/package.json +9 -1
  32. package/readers-BFPuosPk.d.ts +25 -0
  33. package/{readers-DyjxJEkL.js → readers-CjJHKHvH.js} +6 -3
  34. package/request-pump-binary-DdY3X-yl.js +2246 -0
  35. package/{router-DHPJNvbt.js → router--71qvxtY.js} +8 -6
  36. package/{router-DpDpAJjz.d.ts → router-Zhrw5l__.d.ts} +6 -5
  37. package/session.d.ts +2 -1
  38. package/session.js +58 -24
  39. package/setup.d.ts +2 -1
  40. package/setup.js +8 -4
  41. package/{sha256-0jiTgVJu.js → sha256-B_kyYw3Z.js} +1 -0
  42. package/sqlite.d.ts +3 -4
  43. package/sqlite.js +6 -5
  44. package/{store-capability-CDoVafZL.js → store-capability-OZp4hXmj.js} +10 -7
  45. package/{store-DrYjcoru.js → store-hJrRULMx.js} +3 -2
  46. package/store.d.ts +3 -2
  47. package/store.js +3 -2
  48. package/{user-capability-Cv0oJhhv.js → user-capability-BK4Asg7D.js} +8 -5
  49. package/wasm.d.ts +42 -22
  50. package/wasm.js +330 -46
  51. package/core-eU5KaYkz.d.ts +0 -23
  52. package/readers-Oh4tO2dK.d.ts +0 -57
  53. package/sqlite-capability-C7-SYdD7.d.ts +0 -87
  54. package/user-capability-CLkDsrCX.d.ts +0 -40
@@ -0,0 +1,70 @@
1
+
2
+ import { G as Decimal, Ot as Grant, Ut as Shape, mt as ObjectKind, q as Value, xn as Library } from "./debug-CQBxKnJB.js";
3
+ //#region src/talk.d.ts
4
+ /**
5
+ * Dedents NorthTalk source; rejects JS interpolation.
6
+ *
7
+ * Write NorthTalk's own interpolation as `\${…}` and its backticks as `` \` ``.
8
+ * Pass values as Request arguments instead of splicing them into source. The
9
+ * longest whitespace prefix shared by every non-blank line is removed, compared
10
+ * exactly, so tabs and spaces never match each other.
11
+ */
12
+ declare const talk: (strings: TemplateStringsArray, ...values: unknown[]) => string;
13
+ //#endregion
14
+ //#region src/plain.d.ts
15
+ /** Plain JS data, as `fromValue` writes it (ADR 0119). */
16
+ type PlainValue = null | boolean | string | Decimal | Uint8Array | Value | PlainValue[] | {
17
+ [key: string]: PlainValue;
18
+ } | Map<string, PlainValue>;
19
+ type ToValueOptions = {
20
+ /** `decimal` reads a JS number through `num`; the default refuses it. */
21
+ numbers?: 'refuse' | 'decimal';
22
+ };
23
+ type FromValueOptions = {
24
+ maps?: 'object' | 'map';
25
+ numbers?: 'decimal' | 'string';
26
+ };
27
+ /**
28
+ * Plain JS data to a Value by the named constructors (ADR 0119). Anything
29
+ * the table doesn't name, and cyclic data, throws `invalid value`.
30
+ */
31
+ declare const toValue: (plain: unknown, options?: ToValueOptions) => Value;
32
+ /** A Value as plain JS data (ADR 0119); kinds with no JS form stay Values. */
33
+ declare const fromValue: (v: Value, options?: FromValueOptions) => PlainValue;
34
+ //#endregion
35
+ //#region src/encoding.d.ts
36
+ /**
37
+ * A Message Layer adapter's own spelling of a Function Value or a Text
38
+ * Pattern, which the Value Encoding doesn't hold.
39
+ */
40
+ type AdapterEncoder = (v: Value) => string;
41
+ declare const encodeValue: (value: Value, adapter?: AdapterEncoder) => string;
42
+ //#endregion
43
+ //#region src/json.d.ts
44
+ /** Read exact decimal digits, NFC strings and insertion-ordered maps. */
45
+ declare const decodeJson: (source: string) => Value;
46
+ /** Compact JSON, with canonical numbers and chapter 7's string escapes. */
47
+ declare const encodeJson: (value: Value) => string;
48
+ //#endregion
49
+ //#region src/manifest.d.ts
50
+ type MessageDecl = {
51
+ args?: readonly Shape[];
52
+ description?: string;
53
+ /** NorthTalk source, each sending this message. */
54
+ examples?: readonly string[];
55
+ name: string;
56
+ receivers?: readonly ObjectKind[];
57
+ };
58
+ type ManifestSpec = {
59
+ grants: Readonly<Record<string, Grant<any>>>;
60
+ kind: string;
61
+ libraries?: readonly Library[];
62
+ messages?: readonly MessageDecl[];
63
+ objectKinds?: readonly ObjectKind[];
64
+ objects?: Readonly<Record<string, ObjectKind>>;
65
+ version: string;
66
+ };
67
+ /** Chapter 9's deterministic JSON file, ending in LF; never calls the Host. */
68
+ declare const exportManifest: (m: ManifestSpec) => string;
69
+ //#endregion
70
+ export { encodeJson as a, PlainValue as c, toValue as d, talk as f, decodeJson as i, ToValueOptions as l, MessageDecl as n, encodeValue as o, exportManifest as r, FromValueOptions as s, ManifestSpec as t, fromValue as u };
@@ -1,92 +1,12 @@
1
- import { N as objectValue, t as HostError } from "./errors-DHwz1Vho.js";
2
- import { n as quoteJSON, pt as languageVersion, ut as compareText } from "./encoding-DWlbPq-e.js";
3
- //#region src/objects.ts
4
- const elementCost = (cost, name) => {
5
- const c = cost;
6
- if (!c || typeof c !== "object" || !Number.isSafeInteger(c.fuel) || c.fuel < 0 || c.alloc !== void 0 && (!Number.isSafeInteger(c.alloc) || c.alloc < 0)) throw new HostError("invalid value", `Invalid or missing elements ${name}`);
7
- return Object.freeze({
8
- fuel: c.fuel,
9
- ...c.alloc === void 0 ? {} : { alloc: c.alloc }
10
- });
11
- };
12
- const elementShape = (shape) => {
13
- const s = shape;
14
- const kinds = s?.k === "object" ? [s.kind] : s?.k === "oneOf" && s.of.length && s.of.every((o) => o.k === "object") ? s.of.map((o) => o.kind) : null;
15
- if (!kinds || new Set(kinds).size !== kinds.length) throw new HostError("invalid value", "An Object Collection Shape must be an Object Shape or a choice of distinct ones");
16
- return s;
17
- };
18
- const objectElements = (e) => {
19
- if (e === void 0) return null;
20
- if (!e || typeof e.count !== "function" || typeof e.at !== "function" || typeof e.find !== "function") throw new HostError("invalid value", "An Object Collection needs count, at and find");
21
- return Object.freeze({
22
- shape: elementShape(e.shape),
23
- count: e.count,
24
- at: e.at,
25
- find: e.find,
26
- countCost: elementCost(e.countCost, "countCost"),
27
- atCost: elementCost(e.atCost, "atCost"),
28
- findCost: elementCost(e.findCost, "findCost")
29
- });
30
- };
31
- const kinds = /* @__PURE__ */ new Map();
32
- /** A restored handle uses the process's definition of its saved kind. */
33
- const objectKind = (name) => kinds.get(name);
34
- /** Define an Object Kind, once per process. */
35
- const defineObjectKind = (k) => {
36
- const kind = Object.freeze({
37
- name: k.name,
38
- parentKinds: Object.freeze([...k.parentKinds ?? []]),
39
- props: new Map(Object.entries(k.props)),
40
- elements: objectElements(k.elements)
41
- });
42
- kinds.set(kind.name, kind);
43
- return kind;
44
- };
45
- /** A new handle and its state, for the Group that makes it. */
46
- const makeObject = (kind, id, native) => {
47
- const state = {};
48
- const handle = Object.freeze({
49
- id,
50
- kind,
51
- native,
52
- value: objectValue({
53
- kind: kind.name,
54
- id,
55
- handle: state
56
- })
57
- });
58
- Object.assign(state, {
59
- disposed: false,
60
- handle,
61
- owner: null,
62
- parent: null
63
- });
64
- return state;
65
- };
66
- /** The Group's state of an object value. */
67
- const stateOf = (v) => v.asObjectRef()?.handle;
68
- /** Rebind native state while preserving every saved reference to this object. */
69
- const rebindObject = (state, native) => {
70
- const { kind, id } = state.handle;
71
- state.handle = Object.freeze({
72
- kind,
73
- id,
74
- native,
75
- value: objectValue({
76
- kind: kind.name,
77
- id,
78
- handle: state
79
- })
80
- });
81
- };
82
- /** Loading checks declarations without retaining Host callbacks in checked code. */
83
- const propertyChecks = (objects, owner) => {
84
- const props = (kind) => Object.fromEntries([...kind.props].map(([name, prop]) => [name, !!prop.set]));
85
- return {
86
- objectProperties: Object.fromEntries(Object.entries(objects).map(([name, object]) => [name, props(object.kind)])),
87
- ownerProperties: owner ? props(owner.kind) : void 0
88
- };
89
- };
1
+
2
+ import { st as compareText, ut as languageVersion } from "./base64-DORMd3Hv.js";
3
+ import { n as quoteJSON } from "./encoding-nlrpj-Pb.js";
4
+ //#region src/embedding.ts
5
+ /** request({ name, args }).result, for either Core's Script. */
6
+ const invoke = (script, name, args) => script.request({
7
+ name,
8
+ args
9
+ }).result;
90
10
  //#endregion
91
11
  //#region src/manifest.ts
92
12
  const shapeData = (shape) => {
@@ -114,6 +34,7 @@ const operationData = (name, op) => ({
114
34
  name,
115
35
  mode: op.mode,
116
36
  args: (op.args ?? []).map(shapeData),
37
+ ...op.labels?.length ? { labels: [...op.labels] } : {},
117
38
  ...op.result ? { result: shapeData(op.result) } : {},
118
39
  cost: {
119
40
  fuel: op.cost.fuel,
@@ -205,4 +126,4 @@ const exportManifest = (m) => `${canonicalJSON({
205
126
  }))
206
127
  })}\n`;
207
128
  //#endregion
208
- export { shapeData as a, objectKind as c, stateOf as d, operationData as i, propertyChecks as l, exportManifest as n, defineObjectKind as o, grantData as r, makeObject as s, canonicalJSON as t, rebindObject as u };
129
+ export { shapeData as a, operationData as i, exportManifest as n, invoke as o, grantData as r, canonicalJSON as t };
@@ -0,0 +1,12 @@
1
+
2
+ import { i as JsonObject, n as Json, r as JsonNumber, s as readOrderedJSON } from "./readers-BFPuosPk.js";
3
+ import { n as decodeBinaryValue, r as encodeBinaryValue, t as BinaryValueOptions } from "./binary-value-CEmh60GC.js";
4
+ //#region src/request-pump-binary.d.ts
5
+ export declare const requestPumpFeature: "request-pump-fields-v1";
6
+ export declare const callbacksFeature: "callbacks-fields-v1";
7
+ /** True before any attempt to interpret a frame as UTF-8 or JSON. */
8
+ export declare const isRequestPumpBinary: (bytes: Uint8Array) => boolean;
9
+ export declare const encodeBinaryFrame: (frame: Json, o?: BinaryValueOptions) => ArrayBuffer;
10
+ export declare const decodeBinaryFrame: (buffer: ArrayBuffer, o?: BinaryValueOptions) => Json;
11
+ //#endregion
12
+ export { type BinaryValueOptions, type Json, JsonNumber, JsonObject, decodeBinaryValue, encodeBinaryValue, readOrderedJSON };
@@ -0,0 +1,4 @@
1
+
2
+ import { l as readOrderedJSON, n as JsonObject, t as JsonNumber } from "./readers-CjJHKHvH.js";
3
+ import { c as isRequestPumpBinary, f as decodeBinaryValue, i as encodeBinaryFrame, n as decodeBinaryFrame, p as encodeBinaryValue, t as callbacksFeature, u as requestPumpFeature } from "./request-pump-binary-DdY3X-yl.js";
4
+ export { JsonNumber, JsonObject, callbacksFeature, decodeBinaryFrame, decodeBinaryValue, encodeBinaryFrame, encodeBinaryValue, isRequestPumpBinary, readOrderedJSON, requestPumpFeature };
package/notify.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { a as changed, i as WatchLimits, n as RouterOptions, o as createRouter, r as RoutingResult, t as NotificationRouter } from "./router-DpDpAJjz.js";
1
+
2
+ import { a as changed, i as WatchLimits, n as RouterOptions, o as createRouter, r as RoutingResult, t as NotificationRouter } from "./router-Zhrw5l__.js";
2
3
  export { type NotificationRouter, type RouterOptions, type RoutingResult, type WatchLimits, changed, createRouter };
package/notify.js CHANGED
@@ -1 +1,2 @@
1
- export { t as changed, n as createRouter } from "./router-DHPJNvbt.js";
1
+
2
+ export { t as changed, n as createRouter } from "./router--71qvxtY.js";
@@ -1,5 +1,5 @@
1
- import { Ct as HostObject, E as Script, Et as ObjectKindDef, Gt as ScopeDecl, I as compileLibrary, L as replacementLibraries, Rt as Grant, S as Report, T as RestoreResult, Tt as ObjectKind, Xt as Shape, at as Value, g as Inspection, h as GroupOptions, j as Library, jt as CapabilityDef, kt as GrantDecls, m as Group, rn as LoadError, t as DebugController, w as RestoreOptions, z as Limits } from "./debug-D8Z_u244.js";
2
- import { i as SqliteBinding, l as CalendarImpl, s as LocaleImpl } from "./sqlite-capability-C7-SYdD7.js";
1
+
2
+ import { A as SessionControls, Dn as replacementLibraries, E as RunEvent, En as compileLibrary, F as TsRestoreOptions, Gn as LoadError, I as TsScript, N as TsGroup, Ot as Grant, P as TsGroupOptions, Rt as ScopeDecl, S as Report, T as RestoreResult, Ut as Shape, bt as CapabilityDef, cn as SqliteBinding, dn as LocaleImpl, ft as HostObject, h as Inspection, ht as ObjectKindDef, j as SessionPort, kn as Limits, mt as ObjectKind, pn as CalendarImpl, q as Value, t as DebugController, vt as GrantDecls, xn as Library } from "./debug-CQBxKnJB.js";
3
3
  //#region src/setup.d.ts
4
4
  type ShapeSpec = string | {
5
5
  quantity: string;
@@ -38,6 +38,8 @@ type OperationSpec = {
38
38
  shape: ShapeSpec;
39
39
  }[];
40
40
  }[];
41
+ /** Argument Labels, one per argument after the first (ADR 0115). */
42
+ labels?: string[];
41
43
  maxPending?: number;
42
44
  mode: 'immediate' | 'suspending' | 'fire-and-forget';
43
45
  name: string;
@@ -138,11 +140,11 @@ declare const operationDeclarations: (capabilities: ReadonlyMap<string, Capabili
138
140
  type CaseCore = {
139
141
  compileLibrary: typeof compileLibrary;
140
142
  defineObjectKind<N>(k: ObjectKindDef<N>): ObjectKind<N>;
141
- newGroup(o: GroupOptions): Group;
143
+ newGroup(o: TsGroupOptions): TsGroup;
142
144
  /** The Host's Libraries after a replacement, its dependents recompiled. */
143
145
  replacementLibraries: typeof replacementLibraries;
144
- restore(bytes: Uint8Array, o: RestoreOptions): {
145
- group: Group;
146
+ restore(bytes: Uint8Array, o: TsRestoreOptions): {
147
+ group: TsGroup;
146
148
  result: RestoreResult;
147
149
  };
148
150
  };
@@ -154,9 +156,9 @@ declare const immutableSetup: (setup: Setup) => Setup;
154
156
  type SetupGroup = {
155
157
  declarations: GrantDecls;
156
158
  grants: Map<string, Record<string, Grant<unknown>>>;
157
- group: Group;
159
+ group: TsGroup;
158
160
  libraries: Map<string, Library | LoadError>;
159
- load(group: Group, name: string, objects?: Record<string, HostObject>): Script;
161
+ load(group: TsGroup, name: string, objects?: Record<string, HostObject>): TsScript;
160
162
  };
161
163
  /** Make a Group whose Scripts are loaded only when the Host requests them. */
162
164
  declare const buildSetupGroup: (setup: Setup, capabilities: ReadonlyMap<string, CapabilityDef<unknown>>, options: {
@@ -164,6 +166,7 @@ declare const buildSetupGroup: (setup: Setup, capabilities: ReadonlyMap<string,
164
166
  name: string;
165
167
  readSource?(file: string): string;
166
168
  resolveObject?(kind: string, id: string): HostObject | undefined;
169
+ session?: SessionPort;
167
170
  trace?(line: string): void;
168
171
  withCoordinator?<T>(name: string | undefined, make: () => T): T;
169
172
  }) => SetupGroup;
@@ -292,6 +295,7 @@ type Mock = {
292
295
  declare class SessionHost {
293
296
  private readonly env;
294
297
  private group;
298
+ private controls;
295
299
  private objectSession;
296
300
  private objectBindings;
297
301
  private script;
@@ -556,12 +560,17 @@ type Envelope = Record<string, unknown> & {
556
560
  type: string;
557
561
  };
558
562
  declare const parseEnvelope: (source: string) => Envelope;
563
+ /** A Session port that keeps the controls its Group connects. */
564
+ type GroupPort = SessionPort & {
565
+ controls: SessionControls | null;
566
+ };
559
567
  /** Host adapters use this context for object registration and external actions. */
560
568
  declare class SessionObjects {
561
569
  private readonly record;
562
570
  private readonly recorded?;
563
571
  private enabled;
564
572
  private group;
573
+ private reply;
565
574
  readonly items: TranscriptItem[];
566
575
  private kinds;
567
576
  private declarations;
@@ -577,7 +586,13 @@ declare class SessionObjects {
577
586
  private traceSaves;
578
587
  private queuedTraceActions;
579
588
  constructor(record: (item: TranscriptItem) => void, recorded?: readonly TranscriptItem[] | undefined, enabled?: boolean);
580
- attach(group: Group): void;
589
+ /**
590
+ * A port to build or restore the next Group with. Its controls only count
591
+ * once `attach` adopts the Group, since a restore can still fail after the
592
+ * Core connects it.
593
+ */
594
+ port(runs?: (e: RunEvent) => void): GroupPort;
595
+ attach(group: TsGroup, port: GroupPort): void;
581
596
  private next;
582
597
  private consume;
583
598
  private emit;
@@ -0,0 +1,91 @@
1
+
2
+ import { I as objectValue, t as HostError } from "./errors-LYJZ_c8h.js";
3
+ //#region src/objects.ts
4
+ const elementCost = (cost, name) => {
5
+ const c = cost;
6
+ if (!c || typeof c !== "object" || !Number.isSafeInteger(c.fuel) || c.fuel < 0 || c.alloc !== void 0 && (!Number.isSafeInteger(c.alloc) || c.alloc < 0)) throw new HostError("invalid value", `Invalid or missing elements ${name}`);
7
+ return Object.freeze({
8
+ fuel: c.fuel,
9
+ ...c.alloc === void 0 ? {} : { alloc: c.alloc }
10
+ });
11
+ };
12
+ const elementShape = (shape) => {
13
+ const s = shape;
14
+ const kinds = s?.k === "object" ? [s.kind] : s?.k === "oneOf" && s.of.length && s.of.every((o) => o.k === "object") ? s.of.map((o) => o.kind) : null;
15
+ if (!kinds || new Set(kinds).size !== kinds.length) throw new HostError("invalid value", "An Object Collection Shape must be an Object Shape or a choice of distinct ones");
16
+ return s;
17
+ };
18
+ const objectElements = (e) => {
19
+ if (e === void 0) return null;
20
+ if (!e || typeof e.count !== "function" || typeof e.at !== "function" || typeof e.find !== "function") throw new HostError("invalid value", "An Object Collection needs count, at and find");
21
+ return Object.freeze({
22
+ shape: elementShape(e.shape),
23
+ count: e.count,
24
+ at: e.at,
25
+ find: e.find,
26
+ countCost: elementCost(e.countCost, "countCost"),
27
+ atCost: elementCost(e.atCost, "atCost"),
28
+ findCost: elementCost(e.findCost, "findCost")
29
+ });
30
+ };
31
+ const kinds = /* @__PURE__ */ new Map();
32
+ /** A restored handle uses the process's definition of its saved kind. */
33
+ const objectKind = (name) => kinds.get(name);
34
+ /** Define an Object Kind, once per process. */
35
+ const defineObjectKind = (k) => {
36
+ const kind = Object.freeze({
37
+ name: k.name,
38
+ parentKinds: Object.freeze([...k.parentKinds ?? []]),
39
+ props: new Map(Object.entries(k.props)),
40
+ elements: objectElements(k.elements)
41
+ });
42
+ kinds.set(kind.name, kind);
43
+ return kind;
44
+ };
45
+ /** A new handle and its state, for the Group that makes it. */
46
+ const makeObject = (kind, id, native) => {
47
+ const state = {};
48
+ const handle = Object.freeze({
49
+ id,
50
+ kind,
51
+ native,
52
+ value: objectValue({
53
+ kind: kind.name,
54
+ id,
55
+ handle: state
56
+ })
57
+ });
58
+ Object.assign(state, {
59
+ disposed: false,
60
+ handle,
61
+ owner: null,
62
+ parent: null
63
+ });
64
+ return state;
65
+ };
66
+ /** The Group's state of an object value. */
67
+ const stateOf = (v) => v.asObjectRef()?.handle;
68
+ /** Rebind native state while preserving every saved reference to this object. */
69
+ const rebindObject = (state, native) => {
70
+ const { kind, id } = state.handle;
71
+ state.handle = Object.freeze({
72
+ kind,
73
+ id,
74
+ native,
75
+ value: objectValue({
76
+ kind: kind.name,
77
+ id,
78
+ handle: state
79
+ })
80
+ });
81
+ };
82
+ /** Loading checks declarations without retaining Host callbacks in checked code. */
83
+ const propertyChecks = (objects, owner) => {
84
+ const props = (kind) => Object.fromEntries([...kind.props].map(([name, prop]) => [name, !!prop.set]));
85
+ return {
86
+ objectProperties: Object.fromEntries(Object.entries(objects).map(([name, object]) => [name, props(object.kind)])),
87
+ ownerProperties: owner ? props(owner.kind) : void 0
88
+ };
89
+ };
90
+ //#endregion
91
+ export { rebindObject as a, propertyChecks as i, makeObject as n, stateOf as o, objectKind as r, defineObjectKind as t };
@@ -0,0 +1,23 @@
1
+
2
+ //#region src/operation-promises.ts
3
+ const pending = /* @__PURE__ */ new WeakMap();
4
+ /** Tracks forwarding too, so the final answer/failure is queued before completion. */
5
+ const trackOperation = (group, result) => {
6
+ let operations = pending.get(group);
7
+ if (!operations) {
8
+ operations = /* @__PURE__ */ new Set();
9
+ pending.set(group, operations);
10
+ }
11
+ const done = () => {
12
+ operations.delete(completed);
13
+ };
14
+ const completed = result.then(done, done);
15
+ operations.add(completed);
16
+ };
17
+ /** Includes abandoned calls whose Host work is still finishing. */
18
+ const waitForOperations = async (group) => {
19
+ const operations = pending.get(group);
20
+ while (operations?.size) await Promise.all(operations);
21
+ };
22
+ //#endregion
23
+ export { waitForOperations as n, trackOperation as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@northtalk/ts",
3
- "version": "0.1.0",
3
+ "version": "0.2.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",
@@ -27,6 +27,10 @@
27
27
  "types": "./index.d.ts",
28
28
  "default": "./index.js"
29
29
  },
30
+ "./message-layer": {
31
+ "types": "./message-layer.d.ts",
32
+ "default": "./message-layer.js"
33
+ },
30
34
  "./session": {
31
35
  "types": "./session.d.ts",
32
36
  "default": "./session.js"
@@ -43,6 +47,10 @@
43
47
  "types": "./sqlite.d.ts",
44
48
  "default": "./sqlite.js"
45
49
  },
50
+ "./http": {
51
+ "types": "./http.d.ts",
52
+ "default": "./http.js"
53
+ },
46
54
  "./setup": {
47
55
  "types": "./setup.d.ts",
48
56
  "default": "./setup.js"
@@ -0,0 +1,25 @@
1
+
2
+ import { q as Value } from "./debug-CQBxKnJB.js";
3
+ //#region src/readers.d.ts
4
+ /** Finds the Host Object a reader names by its kind and id, or none. */
5
+ type ObjectResolver = (kind: string, id: string) => {
6
+ readonly value: Value;
7
+ } | Value | null | undefined;
8
+ type FunctionResolver = (display: string) => Value | undefined;
9
+ declare const readDisplay: (source: string, resolve?: ObjectResolver, resolveFunction?: FunctionResolver) => Value;
10
+ type Json = null | boolean | string | JsonNumber | Json[] | JsonObject;
11
+ declare class JsonNumber {
12
+ readonly source: string;
13
+ readonly kind = "number";
14
+ constructor(source: string);
15
+ }
16
+ declare class JsonObject {
17
+ readonly pairs: [string, Json][];
18
+ readonly kind = "object";
19
+ constructor(pairs: [string, Json][]);
20
+ }
21
+ declare const decodeValue: (source: string, resolve?: ObjectResolver, functionResolve?: (handle: string) => Value) => Value;
22
+ /** Parse raw, ordered JSON, rejecting duplicate keys before tag interpretation. */
23
+ declare const readOrderedJSON: (source: string) => Json;
24
+ //#endregion
25
+ export { decodeValue as a, JsonObject as i, Json as n, readDisplay as o, JsonNumber as r, readOrderedJSON as s, FunctionResolver as t };
@@ -1,5 +1,6 @@
1
- import { E as listValues, F as quantity, Gt as parseInstant, L as range, S as instant, V as text, a as invalidValue, at as assertScalarText, c as bool, f as civilDate, h as dec, j as nothing, k as map, s as Value, u as bytesOf, x as hiddenCodePoint } from "./errors-DHwz1Vho.js";
2
- import { s as fromBase64 } from "./encoding-DWlbPq-e.js";
1
+
2
+ import { B as range, C as hiddenCodePoint, K as text, M as map, P as nothing, Qt as parseInstant, R as quantity, _ as dec, f as bytesOf, k as listValues, l as Value, m as civilDate, o as invalidValue, u as bool, ut as assertScalarText, w as instant } from "./errors-LYJZ_c8h.js";
3
+ import { t as fromBase64 } from "./base64-DORMd3Hv.js";
3
4
  //#region src/readers.ts
4
5
  var Reader = class {
5
6
  source;
@@ -219,6 +220,8 @@ var JsonObject = class {
219
220
  this.pairs = pairs;
220
221
  }
221
222
  };
223
+ const isJsonObject = (j) => typeof j === "object" && j !== null && !Array.isArray(j) && j.kind === "object";
224
+ const isJsonNumber = (j) => typeof j === "object" && j !== null && !Array.isArray(j) && j.kind === "number";
222
225
  const plainRun = /[^\u0000-\u001f"\\]+/y;
223
226
  var JsonReader = class extends Reader {
224
227
  whitespace() {
@@ -476,4 +479,4 @@ const readOrderedJSON = (source) => {
476
479
  return value;
477
480
  };
478
481
  //#endregion
479
- export { readOrderedJSON as a, readDisplay as i, decodeValueMembers as n, fromJson as r, decodeValue as t };
482
+ export { fromJson as a, readDisplay as c, decodeValueMembers as i, readOrderedJSON as l, JsonObject as n, isJsonNumber as o, decodeValue as r, isJsonObject as s, JsonNumber as t };