@northtalk/ts 0.2.0 → 0.4.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.
- package/README.md +16 -14
- package/{base64-DORMd3Hv.js → base64-Dtqaz_0A.js} +880 -409
- package/{binary-value-CEmh60GC.d.ts → binary-value-Bb6HPDtM.d.ts} +2 -2
- package/{capabilities-CH0FkRMq.js → capabilities-Bi5Qm6Fr.js} +39 -20
- package/{checker-Dc1jl2WH.js → checker-DMI4LiRm.js} +321 -112
- package/core-BzGUgjL6.d.ts +22 -0
- package/{debug-CQBxKnJB.d.ts → debug-C72o2pZy.d.ts} +506 -50
- package/debug.d.ts +3 -3
- package/debug.js +1 -1
- package/driver-ClV_UDEK.d.ts +63 -0
- package/driver.d.ts +2 -40
- package/driver.js +24 -4
- package/{encoding-nlrpj-Pb.js → encoding-C3Q7pIC9.js} +2 -2
- package/{engine-BGaJ9dAk.js → engine-BpdGfAND.js} +6 -6
- package/{engine-vbYInVYF.d.ts → engine-Dtby_FkE.d.ts} +3 -3
- package/{errors-LYJZ_c8h.js → errors-BKJES3Zu.js} +1060 -751
- package/{group-B742gg4T.js → group-vuUL2tq-.js} +6526 -1725
- package/http.d.ts +2 -2
- package/http.js +3 -3
- package/index-ByF5j53i.d.ts +779 -0
- package/index.d.ts +6 -651
- package/index.js +23 -15
- package/{http-capability-CSTkw1Yt.js → inline-grants-Cx0Z9XAt.js} +109 -24
- package/manifest-Dw-8Unmf.js +256 -0
- package/message-layer.d.ts +3 -3
- package/message-layer.js +2 -2
- package/notify.d.ts +2 -2
- package/notify.js +1 -1
- package/{objects-Db7IB5vQ.js → objects-BC4fS0vq.js} +1 -1
- package/{objects-DJ3QtCCs.d.ts → objects-Dnqor7Gn.d.ts} +12 -4
- package/{operation-promises-EgZXG5N_.js → operation-promises-ClA1BTaS.js} +10 -5
- package/package.json +2 -2
- package/{readers-CjJHKHvH.js → readers-B5e5bBrY.js} +2 -2
- package/{readers-BFPuosPk.d.ts → readers-DAFVvvq4.d.ts} +2 -2
- package/{request-pump-binary-DdY3X-yl.js → request-pump-binary-BjnyqXV5.js} +4 -4
- package/{router--71qvxtY.js → router-BCHEfs4x.js} +5 -5
- package/{router-Zhrw5l__.d.ts → router-BspOCPA0.d.ts} +3 -3
- package/session.d.ts +41 -3
- package/session.js +260 -179
- package/setup.d.ts +2 -2
- package/setup.js +4 -4
- package/sha256-9CGf5BS_.js +168 -0
- package/sqlite.d.ts +5 -5
- package/sqlite.js +27 -21
- package/{store-hJrRULMx.js → store-DTQa0lyE.js} +2 -2
- package/{store-capability-OZp4hXmj.js → store-capability-BxXgiRM7.js} +4 -4
- package/store.d.ts +3 -3
- package/store.js +2 -2
- package/{user-capability-BK4Asg7D.js → user-capability-5-IvCeZI.js} +5 -5
- package/wasm.d.ts +12 -8
- package/wasm.js +67 -39
- package/core-DptnvQT9.d.ts +0 -14
- package/manifest-BscyH_rW.d.ts +0 -70
- package/manifest-DjsxDSuB.js +0 -129
- package/sha256-B_kyYw3Z.js +0 -124
package/wasm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-
|
|
4
|
-
import { i as defineCapability, t as LimitReached, u as shape } from "./capabilities-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as fromValue, i as
|
|
11
|
-
import { n as localeCapability, t as userCapability } from "./user-capability-
|
|
12
|
-
import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-
|
|
13
|
-
import { a as encodeResult, c as isRequestPumpBinary, d as valueNode, i as encodeBinaryFrame, l as placeholderValues, n as decodeBinaryFrame, o as heldValue, r as decodeNeed, s as isBinaryNeed, t as callbacksFeature, u as requestPumpFeature } from "./request-pump-binary-
|
|
2
|
+
import { G as record, H as quantity, K as requireArgs, Kt as formatInstant, L as nothing, N as map, Q as text, R as num, S as functionValue, T as instant, V as patternValue, W as range, Yt as nowMicros, Zt as parseInstant, c as Decimal, d as bytes, i as ScriptError, k as list, l as Value, m as civilDate, n as LoadError, o as invalidValue, q as requireValue, r as MailboxFull, s as sendFailed, t as HostError, u as bool, v as dec, z as objectValue } from "./errors-BKJES3Zu.js";
|
|
3
|
+
import { a as rebindObject, n as makeObject, t as defineObjectKind } from "./objects-BC4fS0vq.js";
|
|
4
|
+
import { i as defineCapability, t as LimitReached, u as shape } from "./capabilities-Bi5Qm6Fr.js";
|
|
5
|
+
import { ht as limitDefaults, n as toBase64, t as fromBase64 } from "./base64-Dtqaz_0A.js";
|
|
6
|
+
import { c as CallMeter, i as operationData, n as exportManifest, o as shapeData, s as invoke } from "./manifest-Dw-8Unmf.js";
|
|
7
|
+
import { n as trackOperation } from "./operation-promises-ClA1BTaS.js";
|
|
8
|
+
import { a as fromJson, c as readDisplay, l as readOrderedJSON, n as JsonObject, o as isJsonNumber, r as decodeValue, s as isJsonObject, t as JsonNumber } from "./readers-B5e5bBrY.js";
|
|
9
|
+
import { i as standardChecks, n as quoteJSON, t as encodeValue } from "./encoding-C3Q7pIC9.js";
|
|
10
|
+
import { a as sqliteCapability, c as fromValue, i as httpCapability, l as toValue, n as createGroup, o as decodeJson, r as handlersOf, s as encodeJson, t as inlineGrants, u as talk } from "./inline-grants-Cx0Z9XAt.js";
|
|
11
|
+
import { n as localeCapability, t as userCapability } from "./user-capability-5-IvCeZI.js";
|
|
12
|
+
import { a as clockCapability, i as calendarCapability, l as timerCapability, o as consoleCapability, r as storeCapability, t as add } from "./store-capability-BxXgiRM7.js";
|
|
13
|
+
import { a as encodeResult, c as isRequestPumpBinary, d as valueNode, i as encodeBinaryFrame, l as placeholderValues, n as decodeBinaryFrame, o as heldValue, r as decodeNeed, s as isBinaryNeed, t as callbacksFeature, u as requestPumpFeature } from "./request-pump-binary-BjnyqXV5.js";
|
|
14
14
|
//#region src/wasm/wire.ts
|
|
15
15
|
const raw = Symbol("raw JSON");
|
|
16
16
|
const sep = Symbol("separator");
|
|
@@ -398,7 +398,7 @@ var WasmScript = class {
|
|
|
398
398
|
requestPump(m, now, o) {
|
|
399
399
|
return this.group.combined("request-pump", () => ({
|
|
400
400
|
to: { script: this.name },
|
|
401
|
-
message: this.group.messageFrame(m)
|
|
401
|
+
message: this.group.messageFrame(m, "requestPump")
|
|
402
402
|
}), now, o);
|
|
403
403
|
}
|
|
404
404
|
/** Queued. A Request for the answer only; use `request` for its id or a signal. */
|
|
@@ -461,6 +461,8 @@ var WasmGroup = class {
|
|
|
461
461
|
#decisions = /* @__PURE__ */ new Map();
|
|
462
462
|
#runs = /* @__PURE__ */ new Map();
|
|
463
463
|
#calls = /* @__PURE__ */ new Map();
|
|
464
|
+
/** Each queued charge request's future, until a Pump reports it. */
|
|
465
|
+
#charges = /* @__PURE__ */ new Map();
|
|
464
466
|
#failureDetails = /* @__PURE__ */ new Map();
|
|
465
467
|
#propertyDetails = [];
|
|
466
468
|
#effectDetails = /* @__PURE__ */ new Map();
|
|
@@ -586,6 +588,7 @@ var WasmGroup = class {
|
|
|
586
588
|
now: parseInstant(textOf(field(need, "now"))),
|
|
587
589
|
signal: pending.abort.signal,
|
|
588
590
|
charge,
|
|
591
|
+
requestCharge: (fuel) => this.#requestCharge(id, fuel),
|
|
589
592
|
answer: (v, late) => this.#settleCall(id, pending, "answer", {
|
|
590
593
|
value: encode(this.#codec, v),
|
|
591
594
|
fuel: late?.fuel
|
|
@@ -593,6 +596,21 @@ var WasmGroup = class {
|
|
|
593
596
|
fail: (e) => this.#settleCall(id, pending, "fail", { error: e instanceof ScriptError ? this.#failure(e) : void 0 })
|
|
594
597
|
});
|
|
595
598
|
}
|
|
599
|
+
#requestCharge(call, fuel) {
|
|
600
|
+
const ok = this.send("request-charge", {
|
|
601
|
+
call,
|
|
602
|
+
fuel: Number.isSafeInteger(fuel) ? fuel : "invalid"
|
|
603
|
+
});
|
|
604
|
+
const id = textOf(field(ok, "request"));
|
|
605
|
+
const result = new Promise((resolve) => {
|
|
606
|
+
this.#charges.set(id, resolve);
|
|
607
|
+
});
|
|
608
|
+
this.#ready();
|
|
609
|
+
return {
|
|
610
|
+
id,
|
|
611
|
+
result
|
|
612
|
+
};
|
|
613
|
+
}
|
|
596
614
|
#settleCall(id, pending, m, fields) {
|
|
597
615
|
if (pending.starting) {
|
|
598
616
|
if (!pending.queued) {
|
|
@@ -638,27 +656,19 @@ var WasmGroup = class {
|
|
|
638
656
|
}
|
|
639
657
|
const automatic = boolOf(field(need, "automatic")) ?? false;
|
|
640
658
|
const left = intOf(field(need, "fuelLeft"));
|
|
641
|
-
|
|
642
|
-
const charge = (fuel) => {
|
|
643
|
-
if (!starting || automatic) throw new HostError("invalid value", "Charge only while starting");
|
|
644
|
-
if (!Number.isSafeInteger(fuel) || fuel < 0) throw new HostError("invalid value", "Fuel must be a whole number");
|
|
645
|
-
if (reached || left !== void 0 && charged + fuel > left) {
|
|
646
|
-
reached = true;
|
|
647
|
-
throw new LimitReached("the Run can’t cover this charge");
|
|
648
|
-
}
|
|
649
|
-
charged += fuel;
|
|
650
|
-
};
|
|
659
|
+
const meter = new CallMeter((fuel, charged) => left === void 0 || charged + fuel <= left);
|
|
651
660
|
const pending = {
|
|
652
661
|
abort: new AbortController(),
|
|
653
662
|
live: true,
|
|
654
663
|
starting: true
|
|
655
664
|
};
|
|
656
|
-
const call = this.#callOf(need, grant, pending, charge);
|
|
665
|
+
const call = this.#callOf(need, grant, pending, meter.charge);
|
|
657
666
|
const out = {};
|
|
658
667
|
try {
|
|
659
668
|
out.charged = 0;
|
|
660
|
-
const
|
|
661
|
-
|
|
669
|
+
const invoke = () => this.#invoke(op, call, args, pending);
|
|
670
|
+
const result = automatic ? invoke() : meter.starting(invoke);
|
|
671
|
+
if (meter.refused) out.limit = true;
|
|
662
672
|
else if (op.mode === "suspending") out.started = true;
|
|
663
673
|
else if (op.mode === "fire-and-forget") out.done = true;
|
|
664
674
|
else try {
|
|
@@ -667,7 +677,7 @@ var WasmGroup = class {
|
|
|
667
677
|
out.hostError = detailOf(error);
|
|
668
678
|
}
|
|
669
679
|
} catch (error) {
|
|
670
|
-
if (
|
|
680
|
+
if (meter.refused || isLimitReached(error)) out.limit = true;
|
|
671
681
|
else if (error instanceof ScriptError) try {
|
|
672
682
|
out.fail = this.#failure(error);
|
|
673
683
|
} catch (encodeError) {
|
|
@@ -675,10 +685,9 @@ var WasmGroup = class {
|
|
|
675
685
|
}
|
|
676
686
|
else out.hostError = detailOf(error);
|
|
677
687
|
} finally {
|
|
678
|
-
starting = false;
|
|
679
688
|
pending.starting = false;
|
|
680
689
|
}
|
|
681
|
-
out.charged = charged;
|
|
690
|
+
out.charged = meter.charged;
|
|
682
691
|
if (typeof out.hostError === "string") this.#failureDetails.set(id, out.hostError);
|
|
683
692
|
if (op.mode === "suspending" && out.started) {
|
|
684
693
|
if (pending.live) this.#calls.set(id, pending);
|
|
@@ -696,7 +705,7 @@ var WasmGroup = class {
|
|
|
696
705
|
op.start(call, ...args);
|
|
697
706
|
return;
|
|
698
707
|
}
|
|
699
|
-
trackOperation(this, op.run(call, ...args).then((v) => call.answer(v)).catch((error) => call.fail(error)));
|
|
708
|
+
trackOperation(this, call, op.run(call, ...args).then((v) => call.answer(v)).catch((error) => call.fail(error)));
|
|
700
709
|
return;
|
|
701
710
|
}
|
|
702
711
|
}
|
|
@@ -878,6 +887,10 @@ var WasmGroup = class {
|
|
|
878
887
|
const unhandled = new Set(rows.flatMap((r) => r.kind === "unhandled" ? [r.delivery] : []));
|
|
879
888
|
for (const r of rows) {
|
|
880
889
|
switch (r.kind) {
|
|
890
|
+
case "charge result":
|
|
891
|
+
this.#charges.get(r.request)?.(r);
|
|
892
|
+
this.#charges.delete(r.request);
|
|
893
|
+
break;
|
|
881
894
|
case "run started":
|
|
882
895
|
if (r.delivery) this.#runs.set(r.run, r.delivery);
|
|
883
896
|
break;
|
|
@@ -933,7 +946,8 @@ var WasmGroup = class {
|
|
|
933
946
|
else waiting.resolve(value);
|
|
934
947
|
}
|
|
935
948
|
/** @internal Message data shared with the Script combined operation. */
|
|
936
|
-
messageFrame(m) {
|
|
949
|
+
messageFrame(m, call) {
|
|
950
|
+
requireArgs(m.args ?? [], `${call}('${m.name}')`, m.name);
|
|
937
951
|
return {
|
|
938
952
|
name: m.name,
|
|
939
953
|
args: encodeAll(this.#codec, m.args ?? []),
|
|
@@ -954,7 +968,7 @@ var WasmGroup = class {
|
|
|
954
968
|
queue(m, fields, message) {
|
|
955
969
|
const ok = this.send(m, {
|
|
956
970
|
...fields,
|
|
957
|
-
...message ? { message: this.messageFrame(message) } : {}
|
|
971
|
+
...message ? { message: this.messageFrame(message, m) } : {}
|
|
958
972
|
});
|
|
959
973
|
this.#ready();
|
|
960
974
|
return textOf(field(ok, "delivery")) ?? textOf(field(ok, "broadcast"));
|
|
@@ -1088,15 +1102,18 @@ var WasmGroup = class {
|
|
|
1088
1102
|
requestPump(to, m, now, o) {
|
|
1089
1103
|
return this.combined("request-pump", () => ({
|
|
1090
1104
|
to: this.#target(to),
|
|
1091
|
-
message: this.messageFrame(m)
|
|
1105
|
+
message: this.messageFrame(m, "requestPump")
|
|
1092
1106
|
}), now, o);
|
|
1093
1107
|
}
|
|
1094
1108
|
callPump(fn, args, now, o) {
|
|
1095
|
-
return this.combined("call-pump", () =>
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1109
|
+
return this.combined("call-pump", () => {
|
|
1110
|
+
requireArgs(args, "callPump");
|
|
1111
|
+
return {
|
|
1112
|
+
fn: encode(this.#codec, fn),
|
|
1113
|
+
args: encodeAll(this.#codec, args),
|
|
1114
|
+
limits: o?.limits ? { ...o.limits } : void 0
|
|
1115
|
+
};
|
|
1116
|
+
}, now, o);
|
|
1100
1117
|
}
|
|
1101
1118
|
/** @internal Shared by Script and Object targets. No fallback on old guests. */
|
|
1102
1119
|
combined(m, fields, now, o) {
|
|
@@ -1216,6 +1233,7 @@ var WasmGroup = class {
|
|
|
1216
1233
|
return this.decision({ broadcast: true }, m, o);
|
|
1217
1234
|
}
|
|
1218
1235
|
call(fn, args, o) {
|
|
1236
|
+
requireArgs(args, "call");
|
|
1219
1237
|
const id = this.queue("call", {
|
|
1220
1238
|
fn: encode(this.#codec, fn),
|
|
1221
1239
|
args: encodeAll(this.#codec, args),
|
|
@@ -1247,6 +1265,10 @@ var WasmGroup = class {
|
|
|
1247
1265
|
fingerprint() {
|
|
1248
1266
|
return bytesOfFrame(field(this.worker("fingerprint"), "fingerprint"));
|
|
1249
1267
|
}
|
|
1268
|
+
/** The State Fingerprint (ADR 0142): the Group's save without its save id. */
|
|
1269
|
+
stateFingerprint() {
|
|
1270
|
+
return bytesOfFrame(field(this.worker("state-fingerprint"), "stateFingerprint"));
|
|
1271
|
+
}
|
|
1250
1272
|
inspect() {
|
|
1251
1273
|
const ok = this.worker("inspect");
|
|
1252
1274
|
return { scripts: listOf(field(ok, "scripts")).map((s) => {
|
|
@@ -1348,6 +1370,7 @@ var WasmGroup = class {
|
|
|
1348
1370
|
return {
|
|
1349
1371
|
reports: this.#reports(ok),
|
|
1350
1372
|
variablesOnly: boolOf(field(ok, "variablesOnly")) ?? false,
|
|
1373
|
+
reloaded: textsOf(field(ok, "reloaded")),
|
|
1351
1374
|
pending,
|
|
1352
1375
|
discardedRuns: textsOf(field(ok, "discardedRuns")),
|
|
1353
1376
|
disposed: listOf(field(ok, "disposed")).map((d) => textsOf(d)),
|
|
@@ -1713,6 +1736,11 @@ var WasmCore = class {
|
|
|
1713
1736
|
newGroup(o) {
|
|
1714
1737
|
return new WasmGroup(this.#groupCore, o);
|
|
1715
1738
|
}
|
|
1739
|
+
/** A save's State Fingerprint, without restoring it (ADR 0142). */
|
|
1740
|
+
stateFingerprint(save) {
|
|
1741
|
+
const ok = this.#libraries.exchange("save-state-fingerprint", { save: bytesFrame(save) });
|
|
1742
|
+
return bytesOfFrame(field(ok, "stateFingerprint"));
|
|
1743
|
+
}
|
|
1716
1744
|
restore(save, o) {
|
|
1717
1745
|
const group = new WasmGroup(this.#groupCore, o, {
|
|
1718
1746
|
save,
|
|
@@ -1734,4 +1762,4 @@ const createCore = async (o = {}) => new WasmCore(await compile(o.wasm ?? new UR
|
|
|
1734
1762
|
/** Chapter 9's default Limits, which the reactor shares. */
|
|
1735
1763
|
const defaultLimits = Object.freeze({ ...limitDefaults });
|
|
1736
1764
|
//#endregion
|
|
1737
|
-
export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, createCore, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
|
|
1765
|
+
export { Decimal, HostError, InstanceLostError, LimitReached, LoadError, MailboxFull, ScriptError, Value, WasmCore, WasmGroup, WasmScript, add, bool, bytes, civilDate, createCore, createGroup, dec, decodeJson, decodeValue, defaultLimits, encodeJson, encodeValue, exportManifest, formatInstant, fromValue, handlersOf, inlineGrants, instant, list, map, nothing, nowMicros, num, parseInstant, quantity, range, readDisplay, record, shape, talk, text, toValue };
|
package/core-DptnvQT9.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { En as compileLibrary, R as newGroup, _t as defineObjectKind, qt as Core, z as restore } from "./debug-CQBxKnJB.js";
|
|
3
|
-
//#region src/core.d.ts
|
|
4
|
-
/** The TS Core: the embedding interface's Core, with its Groups typed as TsGroup. */
|
|
5
|
-
type TsCore = Omit<Core, 'compileLibrary' | 'defineObjectKind' | 'newGroup' | 'restore'> & {
|
|
6
|
-
compileLibrary: typeof compileLibrary;
|
|
7
|
-
defineObjectKind: typeof defineObjectKind;
|
|
8
|
-
newGroup: typeof newGroup;
|
|
9
|
-
restore: typeof restore;
|
|
10
|
-
};
|
|
11
|
-
/** Return the process-wide Core, also used by the free-function helpers. */
|
|
12
|
-
declare const createCore: () => TsCore;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { createCore as n, TsCore as t };
|
package/manifest-BscyH_rW.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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 };
|
package/manifest-DjsxDSuB.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
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 };
|
package/sha256-B_kyYw3Z.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/sha256.ts
|
|
3
|
-
const K = new Uint32Array([
|
|
4
|
-
1116352408,
|
|
5
|
-
1899447441,
|
|
6
|
-
3049323471,
|
|
7
|
-
3921009573,
|
|
8
|
-
961987163,
|
|
9
|
-
1508970993,
|
|
10
|
-
2453635748,
|
|
11
|
-
2870763221,
|
|
12
|
-
3624381080,
|
|
13
|
-
310598401,
|
|
14
|
-
607225278,
|
|
15
|
-
1426881987,
|
|
16
|
-
1925078388,
|
|
17
|
-
2162078206,
|
|
18
|
-
2614888103,
|
|
19
|
-
3248222580,
|
|
20
|
-
3835390401,
|
|
21
|
-
4022224774,
|
|
22
|
-
264347078,
|
|
23
|
-
604807628,
|
|
24
|
-
770255983,
|
|
25
|
-
1249150122,
|
|
26
|
-
1555081692,
|
|
27
|
-
1996064986,
|
|
28
|
-
2554220882,
|
|
29
|
-
2821834349,
|
|
30
|
-
2952996808,
|
|
31
|
-
3210313671,
|
|
32
|
-
3336571891,
|
|
33
|
-
3584528711,
|
|
34
|
-
113926993,
|
|
35
|
-
338241895,
|
|
36
|
-
666307205,
|
|
37
|
-
773529912,
|
|
38
|
-
1294757372,
|
|
39
|
-
1396182291,
|
|
40
|
-
1695183700,
|
|
41
|
-
1986661051,
|
|
42
|
-
2177026350,
|
|
43
|
-
2456956037,
|
|
44
|
-
2730485921,
|
|
45
|
-
2820302411,
|
|
46
|
-
3259730800,
|
|
47
|
-
3345764771,
|
|
48
|
-
3516065817,
|
|
49
|
-
3600352804,
|
|
50
|
-
4094571909,
|
|
51
|
-
275423344,
|
|
52
|
-
430227734,
|
|
53
|
-
506948616,
|
|
54
|
-
659060556,
|
|
55
|
-
883997877,
|
|
56
|
-
958139571,
|
|
57
|
-
1322822218,
|
|
58
|
-
1537002063,
|
|
59
|
-
1747873779,
|
|
60
|
-
1955562222,
|
|
61
|
-
2024104815,
|
|
62
|
-
2227730452,
|
|
63
|
-
2361852424,
|
|
64
|
-
2428436474,
|
|
65
|
-
2756734187,
|
|
66
|
-
3204031479,
|
|
67
|
-
3329325298
|
|
68
|
-
]);
|
|
69
|
-
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
70
|
-
const sha256 = (input) => {
|
|
71
|
-
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
72
|
-
const length = bytes.length;
|
|
73
|
-
const padded = new Uint8Array(Math.ceil((length + 9) / 64) * 64);
|
|
74
|
-
padded.set(bytes);
|
|
75
|
-
padded[length] = 128;
|
|
76
|
-
const view = new DataView(padded.buffer);
|
|
77
|
-
view.setUint32(padded.length - 8, Math.floor(length / 536870912));
|
|
78
|
-
view.setUint32(padded.length - 4, length * 8 >>> 0);
|
|
79
|
-
const h = new Uint32Array([
|
|
80
|
-
1779033703,
|
|
81
|
-
3144134277,
|
|
82
|
-
1013904242,
|
|
83
|
-
2773480762,
|
|
84
|
-
1359893119,
|
|
85
|
-
2600822924,
|
|
86
|
-
528734635,
|
|
87
|
-
1541459225
|
|
88
|
-
]);
|
|
89
|
-
const w = /* @__PURE__ */ new Uint32Array(64);
|
|
90
|
-
for (let block = 0; block < padded.length; block += 64) {
|
|
91
|
-
for (let i = 0; i < 16; i++) w[i] = view.getUint32(block + i * 4);
|
|
92
|
-
for (let i = 16; i < 64; i++) {
|
|
93
|
-
const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
|
|
94
|
-
const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
|
|
95
|
-
w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
|
|
96
|
-
}
|
|
97
|
-
let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
|
|
98
|
-
for (let i = 0; i < 64; i++) {
|
|
99
|
-
const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
100
|
-
const ch = e & f ^ ~e & g;
|
|
101
|
-
const t1 = hh + s1 + ch + K[i] + w[i] >>> 0;
|
|
102
|
-
const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
103
|
-
hh = g;
|
|
104
|
-
g = f;
|
|
105
|
-
f = e;
|
|
106
|
-
e = d + t1 >>> 0;
|
|
107
|
-
d = c;
|
|
108
|
-
c = b;
|
|
109
|
-
b = a;
|
|
110
|
-
a = t1 + t2 >>> 0;
|
|
111
|
-
}
|
|
112
|
-
h[0] = h[0] + a >>> 0;
|
|
113
|
-
h[1] = h[1] + b >>> 0;
|
|
114
|
-
h[2] = h[2] + c >>> 0;
|
|
115
|
-
h[3] = h[3] + d >>> 0;
|
|
116
|
-
h[4] = h[4] + e >>> 0;
|
|
117
|
-
h[5] = h[5] + f >>> 0;
|
|
118
|
-
h[6] = h[6] + g >>> 0;
|
|
119
|
-
h[7] = h[7] + hh >>> 0;
|
|
120
|
-
}
|
|
121
|
-
return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
|
|
122
|
-
};
|
|
123
|
-
//#endregion
|
|
124
|
-
export { sha256 as t };
|