@lute-lang/runtime 0.0.0-stage → 0.39.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@lute-lang/runtime` — the Lute runtime for TypeScript hosts, in Effect
3
+ * (spec 0.39.0). Platform layers live in `@lute-lang/runtime/bun` and
4
+ * `@lute-lang/runtime/browser`.
5
+ */
6
+ export * as Bundle from "./Bundle.js";
7
+ export * as BundleSource from "./BundleSource.js";
8
+ export * as Contract from "./generated/Contract.js";
9
+ export * as Errors from "./Errors.js";
10
+ export * as InputLog from "./InputLog.js";
11
+ export * as LuteRuntime from "./LuteRuntime.js";
12
+ export * as LuteWasm from "./LuteWasm.js";
13
+ export * as Program from "./Program.js";
14
+ export * as Replay from "./Replay.js";
15
+ export * as Session from "./Session.js";
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ import {
2
+ LogEntry,
3
+ __export,
4
+ exports_Bundle,
5
+ exports_BundleSource,
6
+ exports_Contract,
7
+ exports_Errors,
8
+ exports_InputLog,
9
+ exports_LuteRuntime,
10
+ exports_LuteWasm,
11
+ exports_Program,
12
+ exports_Session
13
+ } from "./index-eqt12qy0.js";
14
+ // src/Replay.ts
15
+ var exports_Replay = {};
16
+ __export(exports_Replay, {
17
+ run: () => run,
18
+ parseLog: () => parseLog
19
+ });
20
+ import { Effect, Schema, Stream } from "effect";
21
+ var decodeLine = Schema.decodeUnknownEffect(Schema.fromJsonString(LogEntry));
22
+ var parseLog = (text) => Effect.forEach(text.split(`
23
+ `).filter((line) => line.trim().length > 0), (line) => decodeLine(line));
24
+ var run = (program, entries) => {
25
+ const [start, ...inputs] = entries;
26
+ const begun = start === undefined || "input" in start ? Effect.die(new Error("an input log starts with a seed or a snapshot")) : ("seed" in start) ? Effect.map(program.begin(start.seed), ({ state, output }) => ({ state, outputs: [output] })) : Effect.map(program.restore(start.snapshot), (state) => ({ state, outputs: [] }));
27
+ return Stream.unwrap(Effect.map(begun, ({ state, outputs }) => Stream.fromIterable(inputs).pipe(Stream.mapAccumEffect(() => state, (state2, entry) => ("input" in entry) ? Effect.map(program.step(state2, entry.input), (step) => [step.state, [step.output]]) : Effect.die(new Error("an input log has one seed or snapshot, at its start"))), Stream.prepend(outputs))));
28
+ };
29
+ export {
30
+ exports_Session as Session,
31
+ exports_Replay as Replay,
32
+ exports_Program as Program,
33
+ exports_LuteWasm as LuteWasm,
34
+ exports_LuteRuntime as LuteRuntime,
35
+ exports_InputLog as InputLog,
36
+ exports_Errors as Errors,
37
+ exports_Contract as Contract,
38
+ exports_BundleSource as BundleSource,
39
+ exports_Bundle as Bundle
40
+ };
@@ -0,0 +1,162 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The result of loading a bundle.
6
+ */
7
+ export class LoadResult {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ readonly ok: boolean;
12
+ readonly program: Program | undefined;
13
+ readonly rejected: string | undefined;
14
+ }
15
+
16
+ /**
17
+ * A loaded execution bundle.
18
+ */
19
+ export class Program {
20
+ private constructor();
21
+ free(): void;
22
+ [Symbol.dispose](): void;
23
+ /**
24
+ * Begin a run from a JSON seed.
25
+ */
26
+ begin(seed: string): StepResult;
27
+ /**
28
+ * The candidates of `occasion` (for `target`) in selection order, as a
29
+ * JSON array of `Candidate`.
30
+ */
31
+ candidates(state: State, occasion: string, target?: string | null): string;
32
+ /**
33
+ * The clock position, as `ClockAt` JSON or `null` without a clock.
34
+ */
35
+ clock(state: State): string;
36
+ /**
37
+ * The verdict of `beat` (for `member`), as `Candidate` JSON or `null`.
38
+ */
39
+ eligibility(state: State, beat: string, member?: string | null): string;
40
+ /**
41
+ * Load a `project.index.json` and an object mapping artifact paths to IR.
42
+ *
43
+ * Bundle decoding and validation failures are returned as a rejected value
44
+ * rather than escaping into JavaScript as an exception.
45
+ */
46
+ static load(index: string, artifacts: string): LoadResult;
47
+ /**
48
+ * Restore a state from a versioned snapshot JSON.
49
+ */
50
+ restore(snapshot: string): RestoreResult;
51
+ /**
52
+ * Serialize a state to its versioned snapshot JSON (keys sorted, the
53
+ * contract's canonical form).
54
+ */
55
+ snapshot(state: State): string;
56
+ /**
57
+ * Apply a JSON input without invalidating the supplied state handle.
58
+ */
59
+ step(state: State, input: string): StepResult;
60
+ /**
61
+ * Whether this state is terminal.
62
+ */
63
+ terminal(state: State): boolean;
64
+ /**
65
+ * The world view, as `WorldView` JSON (facts only when `with_facts`).
66
+ */
67
+ view(state: State, with_facts: boolean): string;
68
+ readonly fingerprint: string;
69
+ }
70
+
71
+ /**
72
+ * The result of restoring a snapshot.
73
+ */
74
+ export class RestoreResult {
75
+ private constructor();
76
+ free(): void;
77
+ [Symbol.dispose](): void;
78
+ readonly ok: boolean;
79
+ readonly rejected: string | undefined;
80
+ readonly state: State | undefined;
81
+ }
82
+
83
+ /**
84
+ * An opaque immutable state handle.
85
+ */
86
+ export class State {
87
+ private constructor();
88
+ free(): void;
89
+ [Symbol.dispose](): void;
90
+ }
91
+
92
+ /**
93
+ * The result of beginning or stepping a program.
94
+ */
95
+ export class StepResult {
96
+ private constructor();
97
+ free(): void;
98
+ [Symbol.dispose](): void;
99
+ readonly ok: boolean;
100
+ readonly output: string | undefined;
101
+ readonly rejected: string | undefined;
102
+ readonly state: State | undefined;
103
+ }
104
+
105
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
106
+
107
+ export interface InitOutput {
108
+ readonly memory: WebAssembly.Memory;
109
+ readonly __wbg_loadresult_free: (a: number, b: number) => void;
110
+ readonly __wbg_program_free: (a: number, b: number) => void;
111
+ readonly __wbg_restoreresult_free: (a: number, b: number) => void;
112
+ readonly __wbg_state_free: (a: number, b: number) => void;
113
+ readonly __wbg_stepresult_free: (a: number, b: number) => void;
114
+ readonly loadresult_ok: (a: number) => number;
115
+ readonly loadresult_program: (a: number) => number;
116
+ readonly loadresult_rejected: (a: number) => [number, number];
117
+ readonly program_begin: (a: number, b: number, c: number) => number;
118
+ readonly program_candidates: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
119
+ readonly program_clock: (a: number, b: number) => [number, number];
120
+ readonly program_eligibility: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
121
+ readonly program_fingerprint: (a: number) => [number, number];
122
+ readonly program_load: (a: number, b: number, c: number, d: number) => number;
123
+ readonly program_restore: (a: number, b: number, c: number) => number;
124
+ readonly program_snapshot: (a: number, b: number) => [number, number];
125
+ readonly program_step: (a: number, b: number, c: number, d: number) => number;
126
+ readonly program_terminal: (a: number, b: number) => number;
127
+ readonly program_view: (a: number, b: number, c: number) => [number, number];
128
+ readonly restoreresult_ok: (a: number) => number;
129
+ readonly restoreresult_rejected: (a: number) => [number, number];
130
+ readonly restoreresult_state: (a: number) => number;
131
+ readonly stepresult_ok: (a: number) => number;
132
+ readonly stepresult_output: (a: number) => [number, number];
133
+ readonly stepresult_rejected: (a: number) => [number, number];
134
+ readonly stepresult_state: (a: number) => number;
135
+ readonly __wbindgen_externrefs: WebAssembly.Table;
136
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
137
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
138
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
139
+ readonly __wbindgen_start: () => void;
140
+ }
141
+
142
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
143
+
144
+ /**
145
+ * Instantiates the given `module`, which can either be bytes or
146
+ * a precompiled `WebAssembly.Module`.
147
+ *
148
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
149
+ *
150
+ * @returns {InitOutput}
151
+ */
152
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
153
+
154
+ /**
155
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
156
+ * for everything else, calls `WebAssembly.instantiate` directly.
157
+ *
158
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
159
+ *
160
+ * @returns {Promise<InitOutput>}
161
+ */
162
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;