@northtalk/ts 0.0.0-stage → 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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/UNICODE-LICENSE.txt +39 -0
  4. package/base64-DORMd3Hv.js +6621 -0
  5. package/binary-value-CEmh60GC.d.ts +15 -0
  6. package/capabilities-CH0FkRMq.js +1301 -0
  7. package/checker-Dc1jl2WH.js +6657 -0
  8. package/core-DptnvQT9.d.ts +14 -0
  9. package/debug-CQBxKnJB.d.ts +3065 -0
  10. package/debug.d.ts +3 -0
  11. package/debug.js +2 -0
  12. package/driver.d.ts +41 -0
  13. package/driver.js +152 -0
  14. package/encoding-nlrpj-Pb.js +99 -0
  15. package/engine-BGaJ9dAk.js +326 -0
  16. package/engine-vbYInVYF.d.ts +86 -0
  17. package/errors-LYJZ_c8h.js +3735 -0
  18. package/group-B742gg4T.js +10170 -0
  19. package/http-capability-CSTkw1Yt.js +728 -0
  20. package/http.d.ts +59 -0
  21. package/http.js +465 -0
  22. package/index.d.ts +651 -0
  23. package/index.js +44 -0
  24. package/manifest-BscyH_rW.d.ts +70 -0
  25. package/manifest-DjsxDSuB.js +129 -0
  26. package/message-layer.d.ts +12 -0
  27. package/message-layer.js +4 -0
  28. package/notify.d.ts +3 -0
  29. package/notify.js +2 -0
  30. package/objects-DJ3QtCCs.d.ts +640 -0
  31. package/objects-Db7IB5vQ.js +91 -0
  32. package/operation-promises-EgZXG5N_.js +23 -0
  33. package/package.json +70 -4
  34. package/readers-BFPuosPk.d.ts +25 -0
  35. package/readers-CjJHKHvH.js +482 -0
  36. package/request-pump-binary-DdY3X-yl.js +2246 -0
  37. package/router--71qvxtY.js +343 -0
  38. package/router-Zhrw5l__.d.ts +55 -0
  39. package/session.d.ts +9 -0
  40. package/session.js +3510 -0
  41. package/setup.d.ts +3 -0
  42. package/setup.js +193 -0
  43. package/sha256-B_kyYw3Z.js +124 -0
  44. package/sqlite.d.ts +74 -0
  45. package/sqlite.js +529 -0
  46. package/store-capability-OZp4hXmj.js +390 -0
  47. package/store-hJrRULMx.js +60 -0
  48. package/store.d.ts +21 -0
  49. package/store.js +4 -0
  50. package/user-capability-BK4Asg7D.js +276 -0
  51. package/wasm.d.ts +243 -0
  52. package/wasm.js +1737 -0
@@ -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 };
@@ -0,0 +1,129 @@
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;
10
+ //#endregion
11
+ //#region src/manifest.ts
12
+ const shapeData = (shape) => {
13
+ switch (shape.k) {
14
+ case "any": return "any";
15
+ case "value": return "value";
16
+ case "kind": return shape.kind;
17
+ case "object": return { object: shape.kind };
18
+ case "quantity": return { quantity: shape.unit };
19
+ case "unitKind": return { unitKind: shape.kind };
20
+ case "list": return { list: shapeData(shape.of) };
21
+ case "oneOf": return { oneOf: shape.of.map(shapeData) };
22
+ case "optional": return { optional: shapeData(shape.of) };
23
+ case "map": return {
24
+ map: shape.fields.map((f) => ({
25
+ key: f.key,
26
+ shape: shapeData(f.shape),
27
+ ...f.optional ? { optional: true } : {}
28
+ })),
29
+ ...shape.open ? { open: true } : {}
30
+ };
31
+ }
32
+ };
33
+ const operationData = (name, op) => ({
34
+ name,
35
+ mode: op.mode,
36
+ args: (op.args ?? []).map(shapeData),
37
+ ...op.labels?.length ? { labels: [...op.labels] } : {},
38
+ ...op.result ? { result: shapeData(op.result) } : {},
39
+ cost: {
40
+ fuel: op.cost.fuel,
41
+ alloc: op.cost.alloc ?? 0
42
+ },
43
+ ...op.mode === "suspending" && op.maxPendingMs !== void 0 ? { maxPending: op.maxPendingMs } : {},
44
+ ...op.errors === void 0 ? {} : { errors: [...op.errors].sort((a, b) => compareText(a.code, b.code)).map((e) => ({
45
+ code: e.code,
46
+ fields: Object.entries(e.fields ?? {}).map(([key, f]) => ({
47
+ key,
48
+ shape: shapeData("shape" in f ? f.shape : f),
49
+ ..."shape" in f ? { optional: true } : {}
50
+ }))
51
+ })) },
52
+ ...op.mode === "immediate" && op.scope ? { scope: "opens" in op.scope ? {
53
+ opens: op.scope.opens,
54
+ abandon: op.scope.abandon
55
+ } : { closes: op.scope.closes } } : {},
56
+ ...op.mode === "immediate" && op.segmentBound ? { segmentBound: true } : {},
57
+ ...op.command ? { command: true } : {}
58
+ });
59
+ const grantData = (grant, operation = operationData) => ({
60
+ capability: grant.capability.name,
61
+ operations: [...grant.ops].sort(compareText).map((name) => operation(name, grant.capability.operations.get(name)))
62
+ });
63
+ /** Operation Data plus the manifest-only documentation fields. */
64
+ const documentedOperation = (name, op) => ({
65
+ ...operationData(name, op),
66
+ ...op.description ? { description: op.description } : {},
67
+ ...op.examples?.length ? { examples: op.examples } : {}
68
+ });
69
+ const canonicalJSON = (value) => {
70
+ if (typeof value === "string") return quoteJSON(value);
71
+ if (Array.isArray(value)) return `[${value.map(canonicalJSON).join(",")}]`;
72
+ if (value && typeof value === "object") return `{${Object.entries(value).map(([k, v]) => `${quoteJSON(k)}:${canonicalJSON(v)}`).join(",")}}`;
73
+ return JSON.stringify(value);
74
+ };
75
+ const byName = (values) => [...values].sort((a, b) => compareText(a.name, b.name));
76
+ const costData = (cost) => ({
77
+ fuel: cost?.fuel ?? 0,
78
+ alloc: cost?.alloc ?? 0
79
+ });
80
+ const needsData = (needs) => [...needs].sort((a, b) => compareText(a.capability, b.capability) || compareText(a.operation, b.operation)).map(({ capability, operation }) => ({
81
+ capability,
82
+ operation
83
+ }));
84
+ /** Chapter 9's deterministic JSON file, ending in LF; never calls the Host. */
85
+ const exportManifest = (m) => `${canonicalJSON({
86
+ kind: m.kind,
87
+ version: m.version,
88
+ language: languageVersion,
89
+ grants: Object.entries(m.grants).sort(([a], [b]) => compareText(a, b)).map(([name, grant]) => ({
90
+ name,
91
+ ...grantData(grant, documentedOperation)
92
+ })),
93
+ libraries: byName(m.libraries ?? []).map((l) => ({
94
+ name: l.name,
95
+ version: l.version,
96
+ source: l.source,
97
+ needs: needsData(l.needs)
98
+ })),
99
+ messages: byName(m.messages ?? []).map((message) => ({
100
+ name: message.name,
101
+ args: (message.args ?? []).map(shapeData),
102
+ receivers: byName(message.receivers ?? []).map((kind) => kind.name),
103
+ ...message.description ? { description: message.description } : {},
104
+ ...message.examples?.length ? { examples: message.examples } : {}
105
+ })),
106
+ objectKinds: byName(m.objectKinds ?? []).map((kind) => ({
107
+ name: kind.name,
108
+ props: [...kind.props].sort(([a], [b]) => compareText(a, b)).map(([name, prop]) => ({
109
+ name,
110
+ shape: prop.shape ? shapeData(prop.shape) : "value",
111
+ readOnly: !prop.set,
112
+ getCost: costData(prop.getCost),
113
+ setCost: costData(prop.setCost)
114
+ })),
115
+ parentKinds: [...kind.parentKinds].sort(compareText),
116
+ ...kind.elements ? { elements: {
117
+ shape: shapeData(kind.elements.shape),
118
+ countCost: costData(kind.elements.countCost),
119
+ atCost: costData(kind.elements.atCost),
120
+ findCost: costData(kind.elements.findCost)
121
+ } } : {}
122
+ })),
123
+ objects: Object.entries(m.objects ?? {}).sort(([a], [b]) => compareText(a, b)).map(([name, kind]) => ({
124
+ name,
125
+ kind: kind.name
126
+ }))
127
+ })}\n`;
128
+ //#endregion
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 ADDED
@@ -0,0 +1,3 @@
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";
3
+ export { type NotificationRouter, type RouterOptions, type RoutingResult, type WatchLimits, changed, createRouter };
package/notify.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { t as changed, n as createRouter } from "./router--71qvxtY.js";