@elaraai/east 1.0.84 → 1.0.85
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/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +48 -0
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/ast_to_ir.coerce_to.spec.js +4 -4
- package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -1
- package/dist/src/ast_to_ir.d.ts +6 -1
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +20 -7
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +52 -0
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/codegen/canonical.d.ts +37 -0
- package/dist/src/codegen/canonical.d.ts.map +1 -0
- package/dist/src/codegen/canonical.js +208 -0
- package/dist/src/codegen/canonical.js.map +1 -0
- package/dist/src/codegen/codegen.spec.js +132 -201
- package/dist/src/codegen/codegen.spec.js.map +1 -1
- package/dist/src/codegen/printer.d.ts.map +1 -1
- package/dist/src/codegen/printer.js +142 -24
- package/dist/src/codegen/printer.js.map +1 -1
- package/dist/src/codegen/spellings.d.ts +4 -1
- package/dist/src/codegen/spellings.d.ts.map +1 -1
- package/dist/src/codegen/spellings.js +5 -1
- package/dist/src/codegen/spellings.js.map +1 -1
- package/dist/src/compile/builtins/index.d.ts.map +1 -1
- package/dist/src/compile/builtins/index.js +2 -0
- package/dist/src/compile/builtins/index.js.map +1 -1
- package/dist/src/compile/builtins/primitives.d.ts.map +1 -1
- package/dist/src/compile/builtins/primitives.js +2 -1
- package/dist/src/compile/builtins/primitives.js.map +1 -1
- package/dist/src/compile/builtins/query.d.ts +10 -0
- package/dist/src/compile/builtins/query.d.ts.map +1 -0
- package/dist/src/compile/builtins/query.js +5 -0
- package/dist/src/compile/builtins/query.js.map +1 -0
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +2 -1
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/index.d.ts +75 -47
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +31 -0
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/libs/datetime.d.ts +20 -20
- package/dist/src/expr/libs/datetime.d.ts.map +1 -1
- package/dist/src/expr/libs/datetime.js +208 -167
- package/dist/src/expr/libs/datetime.js.map +1 -1
- package/dist/src/expr/libs/float.d.ts +15 -15
- package/dist/src/expr/libs/float.d.ts.map +1 -1
- package/dist/src/expr/libs/float.js +298 -267
- package/dist/src/expr/libs/float.js.map +1 -1
- package/dist/src/expr/libs/integer.d.ts +12 -12
- package/dist/src/expr/libs/integer.d.ts.map +1 -1
- package/dist/src/expr/libs/integer.js +219 -194
- package/dist/src/expr/libs/integer.js.map +1 -1
- package/dist/src/expr/libs/lazy.d.ts +28 -0
- package/dist/src/expr/libs/lazy.d.ts.map +1 -0
- package/dist/src/expr/libs/lazy.js +55 -0
- package/dist/src/expr/libs/lazy.js.map +1 -0
- package/dist/src/expr/libs/lazy.spec.d.ts +6 -0
- package/dist/src/expr/libs/lazy.spec.d.ts.map +1 -0
- package/dist/src/expr/libs/lazy.spec.js +102 -0
- package/dist/src/expr/libs/lazy.spec.js.map +1 -0
- package/dist/src/expr/query.d.ts +60 -0
- package/dist/src/expr/query.d.ts.map +1 -0
- package/dist/src/expr/query.js +84 -0
- package/dist/src/expr/query.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +4 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +9 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/location.d.ts +22 -0
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +31 -0
- package/dist/src/location.js.map +1 -1
- package/dist/src/naming.d.ts +5 -3
- package/dist/src/naming.d.ts.map +1 -1
- package/dist/src/naming.js.map +1 -1
- package/dist/src/portable.spec.d.ts +6 -0
- package/dist/src/portable.spec.d.ts.map +1 -0
- package/dist/src/portable.spec.js +181 -0
- package/dist/src/portable.spec.js.map +1 -0
- package/dist/src/query/evaluate.d.ts +98 -0
- package/dist/src/query/evaluate.d.ts.map +1 -0
- package/dist/src/query/evaluate.js +193 -0
- package/dist/src/query/evaluate.js.map +1 -0
- package/dist/src/query/index.d.ts +17 -0
- package/dist/src/query/index.d.ts.map +1 -0
- package/dist/src/query/index.js +17 -0
- package/dist/src/query/index.js.map +1 -0
- package/dist/src/query/jq/catalog.d.ts +174 -0
- package/dist/src/query/jq/catalog.d.ts.map +1 -0
- package/dist/src/query/jq/catalog.js +1740 -0
- package/dist/src/query/jq/catalog.js.map +1 -0
- package/dist/src/query/jq/check.d.ts +210 -0
- package/dist/src/query/jq/check.d.ts.map +1 -0
- package/dist/src/query/jq/check.js +2261 -0
- package/dist/src/query/jq/check.js.map +1 -0
- package/dist/src/query/jq/complete.d.ts +89 -0
- package/dist/src/query/jq/complete.d.ts.map +1 -0
- package/dist/src/query/jq/complete.js +320 -0
- package/dist/src/query/jq/complete.js.map +1 -0
- package/dist/src/query/jq/describe.d.ts +53 -0
- package/dist/src/query/jq/describe.d.ts.map +1 -0
- package/dist/src/query/jq/describe.js +149 -0
- package/dist/src/query/jq/describe.js.map +1 -0
- package/dist/src/query/jq/lex.d.ts +118 -0
- package/dist/src/query/jq/lex.d.ts.map +1 -0
- package/dist/src/query/jq/lex.js +371 -0
- package/dist/src/query/jq/lex.js.map +1 -0
- package/dist/src/query/jq/literals.d.ts +49 -0
- package/dist/src/query/jq/literals.d.ts.map +1 -0
- package/dist/src/query/jq/literals.js +78 -0
- package/dist/src/query/jq/literals.js.map +1 -0
- package/dist/src/query/jq/messages.d.ts +126 -0
- package/dist/src/query/jq/messages.d.ts.map +1 -0
- package/dist/src/query/jq/messages.js +172 -0
- package/dist/src/query/jq/messages.js.map +1 -0
- package/dist/src/query/jq/parse.d.ts +70 -0
- package/dist/src/query/jq/parse.d.ts.map +1 -0
- package/dist/src/query/jq/parse.js +1013 -0
- package/dist/src/query/jq/parse.js.map +1 -0
- package/dist/src/query/jq/print.d.ts +59 -0
- package/dist/src/query/jq/print.d.ts.map +1 -0
- package/dist/src/query/jq/print.js +587 -0
- package/dist/src/query/jq/print.js.map +1 -0
- package/dist/src/query/jq/shapes.d.ts +345 -0
- package/dist/src/query/jq/shapes.d.ts.map +1 -0
- package/dist/src/query/jq/shapes.js +584 -0
- package/dist/src/query/jq/shapes.js.map +1 -0
- package/dist/src/query/jq/spans.d.ts +133 -0
- package/dist/src/query/jq/spans.d.ts.map +1 -0
- package/dist/src/query/jq/spans.js +195 -0
- package/dist/src/query/jq/spans.js.map +1 -0
- package/dist/src/query/jq/split.d.ts +334 -0
- package/dist/src/query/jq/split.d.ts.map +1 -0
- package/dist/src/query/jq/split.js +2108 -0
- package/dist/src/query/jq/split.js.map +1 -0
- package/dist/src/query/jq/strftime.d.ts +20 -0
- package/dist/src/query/jq/strftime.d.ts.map +1 -0
- package/dist/src/query/jq/strftime.js +65 -0
- package/dist/src/query/jq/strftime.js.map +1 -0
- package/dist/src/query/jq/summary.d.ts +139 -0
- package/dist/src/query/jq/summary.d.ts.map +1 -0
- package/dist/src/query/jq/summary.js +222 -0
- package/dist/src/query/jq/summary.js.map +1 -0
- package/dist/src/query/jq/translate-builtins.d.ts +21 -0
- package/dist/src/query/jq/translate-builtins.d.ts.map +1 -0
- package/dist/src/query/jq/translate-builtins.js +1873 -0
- package/dist/src/query/jq/translate-builtins.js.map +1 -0
- package/dist/src/query/jq/translate.d.ts +627 -0
- package/dist/src/query/jq/translate.d.ts.map +1 -0
- package/dist/src/query/jq/translate.js +3364 -0
- package/dist/src/query/jq/translate.js.map +1 -0
- package/dist/src/query/types.d.ts +505 -0
- package/dist/src/query/types.d.ts.map +1 -0
- package/dist/src/query/types.js +231 -0
- package/dist/src/query/types.js.map +1 -0
- package/dist/src/runner_exec.d.ts +134 -0
- package/dist/src/runner_exec.d.ts.map +1 -0
- package/dist/src/runner_exec.js +371 -0
- package/dist/src/runner_exec.js.map +1 -0
- package/dist/src/runner_exec.spec.d.ts +6 -0
- package/dist/src/runner_exec.spec.d.ts.map +1 -0
- package/dist/src/runner_exec.spec.js +198 -0
- package/dist/src/runner_exec.spec.js.map +1 -0
- package/dist/src/runner_io.d.ts +370 -0
- package/dist/src/runner_io.d.ts.map +1 -0
- package/dist/src/runner_io.js +563 -0
- package/dist/src/runner_io.js.map +1 -0
- package/dist/src/runner_io.spec.d.ts +6 -0
- package/dist/src/runner_io.spec.d.ts.map +1 -0
- package/dist/src/runner_io.spec.js +224 -0
- package/dist/src/runner_io.spec.js.map +1 -0
- package/dist/src/runner_merge.d.ts +95 -0
- package/dist/src/runner_merge.d.ts.map +1 -0
- package/dist/src/runner_merge.js +238 -0
- package/dist/src/runner_merge.js.map +1 -0
- package/dist/src/runner_protocol.d.ts +11 -4
- package/dist/src/runner_protocol.d.ts.map +1 -1
- package/dist/src/runner_protocol.js +11 -4
- package/dist/src/runner_protocol.js.map +1 -1
- package/dist/src/serialization/beast2/index.d.ts +1 -1
- package/dist/src/serialization/beast2/index.d.ts.map +1 -1
- package/dist/src/serialization/beast2/index.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.d.ts +10 -6
- package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.js +10 -6
- package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/frames.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/frames.spec.js +42 -0
- package/dist/src/serialization/beast2/v5/frames.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/index.spec.js +108 -0
- package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts +12 -7
- package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.js +16 -6
- package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.spec.js +159 -18
- package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.d.ts +110 -21
- package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.js +153 -42
- package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
- package/dist/src/serialization/beast2/v5/weight.d.ts +36 -0
- package/dist/src/serialization/beast2/v5/weight.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/weight.js +238 -0
- package/dist/src/serialization/beast2/v5/weight.js.map +1 -0
- package/dist/src/serialization/crc32.d.ts +38 -0
- package/dist/src/serialization/crc32.d.ts.map +1 -0
- package/dist/src/serialization/crc32.js +70 -0
- package/dist/src/serialization/crc32.js.map +1 -0
- package/dist/src/serialization/crc32.spec.d.ts +6 -0
- package/dist/src/serialization/crc32.spec.d.ts.map +1 -0
- package/dist/src/serialization/crc32.spec.js +92 -0
- package/dist/src/serialization/crc32.spec.js.map +1 -0
- package/dist/src/serialization/east-inferred.spec.js +4 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +134 -110
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/east.spec.js +185 -4
- package/dist/src/serialization/east.spec.js.map +1 -1
- package/dist/src/serialization/east_text.d.ts +25 -0
- package/dist/src/serialization/east_text.d.ts.map +1 -0
- package/dist/src/serialization/east_text.js +29 -0
- package/dist/src/serialization/east_text.js.map +1 -0
- package/dist/src/serialization/index.d.ts +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +7 -6
- package/dist/src/types.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* What a unit reads and writes: the files it names, through a {@link UnitIO}.
|
|
7
|
+
*
|
|
8
|
+
* `executeUnit` (`runner_exec.ts`) does a unit's work over a UnitIO rather
|
|
9
|
+
* than over a file system, so one implementation runs wherever a unit's files
|
|
10
|
+
* are: east-node's `exec` hands it this machine's files, and a browser an
|
|
11
|
+
* {@link InMemoryUnitIO} holding the unit and every file it names. A UnitIO is
|
|
12
|
+
* addressed by the paths the unit names, and reads and writes synchronously,
|
|
13
|
+
* since a compiled East body reads its lazily opened inputs without awaiting.
|
|
14
|
+
*
|
|
15
|
+
* The readers here load what a run unit names through a UnitIO: its program,
|
|
16
|
+
* by its file's extension, and its inputs, each decoded whole or opened lazily
|
|
17
|
+
* over its file as the unit's `decode` says, a manifest's segments read from
|
|
18
|
+
* the files beside it (see `runner_protocol.ts`). A unit whose host places
|
|
19
|
+
* segments as they are read (`fetch`) has its UnitIO asked for each segment
|
|
20
|
+
* file before it is read.
|
|
21
|
+
*/
|
|
22
|
+
import { type EastTypeValue } from "./type_of_type.js";
|
|
23
|
+
import { AsyncEastIR, EastIR } from "./eastir.js";
|
|
24
|
+
import type { Unit, UnitDecode } from "./runner_protocol.js";
|
|
25
|
+
/**
|
|
26
|
+
* The files a unit's work reads and writes, by the paths the unit names.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* A relative path is relative to the unit, as the runner protocol has it; a
|
|
30
|
+
* host that resolves the unit's paths first ({@link resolveUnitPaths}) hands
|
|
31
|
+
* the IO absolute ones. Every method is synchronous: a lazily opened input is
|
|
32
|
+
* read from inside compiled East code, which does not await.
|
|
33
|
+
*
|
|
34
|
+
* `executeUnit` works over any implementation. east-node's is this machine's
|
|
35
|
+
* files; {@link InMemoryUnitIO} holds a unit and its files in memory, for a
|
|
36
|
+
* host with no file system — a browser's Web Worker.
|
|
37
|
+
*/
|
|
38
|
+
export interface UnitIO {
|
|
39
|
+
/**
|
|
40
|
+
* Reads a whole file.
|
|
41
|
+
*
|
|
42
|
+
* @param path - the file
|
|
43
|
+
* @returns its bytes
|
|
44
|
+
* @throws {Error} When there is no file at `path`.
|
|
45
|
+
*/
|
|
46
|
+
read(path: string): Uint8Array;
|
|
47
|
+
/**
|
|
48
|
+
* Reads a file's size.
|
|
49
|
+
*
|
|
50
|
+
* @param path - the file
|
|
51
|
+
* @returns its size in bytes
|
|
52
|
+
* @throws {Error} When there is no file at `path`; a directory is none.
|
|
53
|
+
*/
|
|
54
|
+
size(path: string): number;
|
|
55
|
+
/**
|
|
56
|
+
* Reads a range of a file.
|
|
57
|
+
*
|
|
58
|
+
* @param path - the file
|
|
59
|
+
* @param offset - the first byte's offset
|
|
60
|
+
* @param length - how many bytes to read
|
|
61
|
+
* @returns the `length` bytes from `offset`, fewer only where the file ends
|
|
62
|
+
* first
|
|
63
|
+
* @throws {Error} When there is no file at `path`.
|
|
64
|
+
*/
|
|
65
|
+
readRange(path: string, offset: number, length: number): Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
* Makes a staged manifest's segment file there to read. When it is absent
|
|
68
|
+
* and the unit says its host places segments as they are read (`fetch`), the
|
|
69
|
+
* host is asked for it — in the runner protocol, by creating
|
|
70
|
+
* `<segment file>.want` — and this returns once the host has placed it.
|
|
71
|
+
* Otherwise an absent segment stays absent, and reading it fails as reading
|
|
72
|
+
* any absent file does.
|
|
73
|
+
*
|
|
74
|
+
* @param path - the segment's file, `<manifest>.segments/<hash>.beast2`
|
|
75
|
+
* @param fetch - whether the unit's host places segments as they are read
|
|
76
|
+
* @throws {Error} When the host says why it cannot place the segment.
|
|
77
|
+
*/
|
|
78
|
+
segment(path: string, fetch: boolean): void;
|
|
79
|
+
/**
|
|
80
|
+
* Lists a directory.
|
|
81
|
+
*
|
|
82
|
+
* @param path - the directory
|
|
83
|
+
* @returns the names of the files and directories directly in it
|
|
84
|
+
* @throws {Error} When there is no directory at `path`.
|
|
85
|
+
*/
|
|
86
|
+
list(path: string): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Makes a directory, and any parent it lacks. A directory already there is
|
|
89
|
+
* left as it is.
|
|
90
|
+
*
|
|
91
|
+
* @param path - the directory
|
|
92
|
+
* @throws {Error} When a file is where the directory, or a parent of it,
|
|
93
|
+
* would be.
|
|
94
|
+
*/
|
|
95
|
+
makeDirectory(path: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* Writes a whole file, replacing whatever file was there.
|
|
98
|
+
*
|
|
99
|
+
* @param path - the file, whose directory must be there
|
|
100
|
+
* @param bytes - its bytes
|
|
101
|
+
* @throws {Error} When the file's directory is not there, or a directory is
|
|
102
|
+
* at `path`.
|
|
103
|
+
*/
|
|
104
|
+
write(path: string, bytes: Uint8Array): void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A {@link UnitIO} holding a unit and every file it names in memory: the IO a
|
|
108
|
+
* host with no file system gives `executeUnit`, a browser's Web Worker among
|
|
109
|
+
* them.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* Files are held by their paths, normalized (`./a/../b` is `b`), and a
|
|
113
|
+
* directory is there when a held file is in it or it was made. Writes copy the
|
|
114
|
+
* bytes they are given, so the files an execution writes are the IO's own,
|
|
115
|
+
* and {@link files} holds them once it is done — a host collects the unit's
|
|
116
|
+
* outputs from there.
|
|
117
|
+
*
|
|
118
|
+
* The IO holds every file the unit names, segments included, so it never asks
|
|
119
|
+
* a host for a segment: {@link segment} has nothing to do, and a segment that
|
|
120
|
+
* is not held is read as any absent file, and fails at once.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const io = new InMemoryUnitIO([
|
|
125
|
+
* ["unit.beast2", encodeBeast2For(UnitType)(unit)],
|
|
126
|
+
* ["program.beast2", encodeEastIR(program)],
|
|
127
|
+
* ["x.beast2", encodeBeast2For(IntegerType)(7n)],
|
|
128
|
+
* ]);
|
|
129
|
+
* const result = await executeUnit(unit, io, { platforms: () => [] });
|
|
130
|
+
* io.files.get("out.beast2"); // the output the unit names, as its runner wrote it
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare class InMemoryUnitIO implements UnitIO {
|
|
134
|
+
private readonly held;
|
|
135
|
+
/** Every directory there is: both roots, each held file's parents, and each
|
|
136
|
+
* one made. */
|
|
137
|
+
private readonly directories;
|
|
138
|
+
/**
|
|
139
|
+
* @param files - the unit and every file it names, by the paths the unit
|
|
140
|
+
* names them by
|
|
141
|
+
*/
|
|
142
|
+
constructor(files?: Iterable<readonly [string, Uint8Array]>);
|
|
143
|
+
/** Every file the IO holds, by its normalized path: the files it was given,
|
|
144
|
+
* and those written since. */
|
|
145
|
+
get files(): ReadonlyMap<string, Uint8Array>;
|
|
146
|
+
/** @inheritDoc */
|
|
147
|
+
read(path: string): Uint8Array;
|
|
148
|
+
/** @inheritDoc */
|
|
149
|
+
size(path: string): number;
|
|
150
|
+
/** @inheritDoc */
|
|
151
|
+
readRange(path: string, offset: number, length: number): Uint8Array;
|
|
152
|
+
/** Every segment is held already, so there is none to ask for. */
|
|
153
|
+
segment(_path: string, _fetch: boolean): void;
|
|
154
|
+
/** @inheritDoc */
|
|
155
|
+
list(path: string): string[];
|
|
156
|
+
/** @inheritDoc */
|
|
157
|
+
makeDirectory(path: string): void;
|
|
158
|
+
/** @inheritDoc */
|
|
159
|
+
write(path: string, bytes: Uint8Array): void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Resolves every path a unit names — its program, inputs, parts, outputs,
|
|
163
|
+
* functions, the files an intake reads and writes, and its result — keeping
|
|
164
|
+
* the rest of the unit as it is.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* What east-c's `east_unit_read` does as it reads a unit: a host whose unit
|
|
168
|
+
* names paths relative to the unit file resolves them against that file's
|
|
169
|
+
* directory once, so its UnitIO and its messages see the paths the files are
|
|
170
|
+
* at.
|
|
171
|
+
*
|
|
172
|
+
* @param unit - the unit
|
|
173
|
+
* @param resolve - resolves one path the unit names
|
|
174
|
+
* @returns the unit, naming every file by its resolved path
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* const unit = decodeBeast2For(UnitType)(readFileSync(unitPath));
|
|
179
|
+
* const base = dirname(resolve(unitPath));
|
|
180
|
+
* const resolved = resolveUnitPaths(unit, (path) => resolve(base, path));
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function resolveUnitPaths(unit: Unit, resolve: (path: string) => string): Unit;
|
|
184
|
+
/** The encodings a file a unit names can hold, told apart by its extension. */
|
|
185
|
+
export type UnitFileFormat = "beast2" | "east" | "json";
|
|
186
|
+
/**
|
|
187
|
+
* The encoding a file a unit names holds, by its extension: `.beast2` or
|
|
188
|
+
* `.beast` a beast2 blob, `.east` East text, `.json` JSON.
|
|
189
|
+
*
|
|
190
|
+
* @param path - the file
|
|
191
|
+
* @returns its encoding
|
|
192
|
+
* @throws {Error} When the extension is none of those, naming it.
|
|
193
|
+
*/
|
|
194
|
+
export declare function unitFileFormat(path: string): UnitFileFormat;
|
|
195
|
+
/**
|
|
196
|
+
* Loads a unit's program: an IR file holding an East function or async
|
|
197
|
+
* function, in any encoding a unit may name ({@link unitFileFormat}).
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* A beast2 program carries its source map, so an error it raises names where
|
|
201
|
+
* its source was written; East text and JSON carry none.
|
|
202
|
+
*
|
|
203
|
+
* @param io - the unit's files
|
|
204
|
+
* @param path - the program's file
|
|
205
|
+
* @returns the program, ready to compile
|
|
206
|
+
* @throws {Error} When the extension is not one a unit may name, the file
|
|
207
|
+
* cannot be read or decoded as IR, or the IR is not a function.
|
|
208
|
+
*/
|
|
209
|
+
export declare function loadUnitProgram(io: UnitIO, path: string): EastIR<any[], any> | AsyncEastIR<any[], any>;
|
|
210
|
+
/**
|
|
211
|
+
* A staged manifest's segment file: `<manifest>.segments/<hash>.beast2`, the
|
|
212
|
+
* layout every runner's opener reads and a store takes in by linking.
|
|
213
|
+
*
|
|
214
|
+
* @param manifest - the manifest's file
|
|
215
|
+
* @param hash - the segment's SHA-256, as the manifest names it
|
|
216
|
+
* @returns the segment's file
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
export declare function segmentPath(manifest: string, hash: string): string;
|
|
220
|
+
/**
|
|
221
|
+
* Reads exactly `length` bytes of a file from `offset`, failing a range the
|
|
222
|
+
* file ends inside, as a positioned reader does.
|
|
223
|
+
*
|
|
224
|
+
* @param io - the unit's files
|
|
225
|
+
* @param path - the file
|
|
226
|
+
* @param offset - the first byte's offset
|
|
227
|
+
* @param length - how many bytes to read
|
|
228
|
+
* @returns the bytes
|
|
229
|
+
* @throws {Error} When the file ends before the range does.
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
export declare function readUnitRange(io: UnitIO, path: string, offset: number, length: number): Uint8Array;
|
|
233
|
+
/**
|
|
234
|
+
* The bytes an input {@link openUnitInputLazy} opened has read so far: its
|
|
235
|
+
* geometry (tail and head), every fence it probed and each segment frame it
|
|
236
|
+
* decoded, across its file and, for a manifest, every segment file it read.
|
|
237
|
+
*
|
|
238
|
+
* @param value - an input's value
|
|
239
|
+
* @returns the byte count, or `undefined` for a value not opened lazily
|
|
240
|
+
*/
|
|
241
|
+
export declare function lazyInputBytesRead(value: unknown): number | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* The bytes an input stands for: the collection a manifest names — the
|
|
244
|
+
* manifest and every segment file — or any other file's own size.
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* What a runner's verbose account weighs an input at. A manifest is a few
|
|
248
|
+
* dozen bytes per segment whatever the collection weighs, so its file's size
|
|
249
|
+
* would say nothing of what the input holds. The manifest is recognised
|
|
250
|
+
* through ranged reads, so a large blob is never read to learn that it is not
|
|
251
|
+
* one.
|
|
252
|
+
*
|
|
253
|
+
* @param io - the unit's files
|
|
254
|
+
* @param path - the input's file
|
|
255
|
+
* @returns the byte count
|
|
256
|
+
* @throws {Error} When the extension is not one a unit may name, or there is
|
|
257
|
+
* no file at `path`.
|
|
258
|
+
*/
|
|
259
|
+
export declare function unitInputBytes(io: UnitIO, path: string): number;
|
|
260
|
+
/**
|
|
261
|
+
* Loads an input decoded whole, and frozen: deeply immutable from
|
|
262
|
+
* construction, a mutating builtin throwing the uniform copy-first error, and
|
|
263
|
+
* compared by value under East `Is`, as every task input is.
|
|
264
|
+
*
|
|
265
|
+
* @remarks
|
|
266
|
+
* A beast2 file is self-describing; a manifest is the collection it names,
|
|
267
|
+
* its segments spliced from the files beside it, each asked for first when the
|
|
268
|
+
* unit's host places segments as they are read. East text and JSON decode as
|
|
269
|
+
* `type`.
|
|
270
|
+
*
|
|
271
|
+
* @param io - the unit's files
|
|
272
|
+
* @param path - the input's file
|
|
273
|
+
* @param type - the parameter's type
|
|
274
|
+
* @param fetch - whether the unit's host places segments as they are read
|
|
275
|
+
* @returns the input's value
|
|
276
|
+
* @throws {Error} When the extension is not one a unit may name, or the file,
|
|
277
|
+
* or a segment its manifest names, cannot be read or decoded.
|
|
278
|
+
*/
|
|
279
|
+
export declare function loadUnitInput(io: UnitIO, path: string, type: EastTypeValue, fetch: boolean): unknown;
|
|
280
|
+
/** How a unit's inputs are read, beyond the unit itself. */
|
|
281
|
+
export interface UnitInputOptions {
|
|
282
|
+
/** Whether the unit's host places segments as they are read: the unit's
|
|
283
|
+
* `fetch`. */
|
|
284
|
+
fetch: boolean;
|
|
285
|
+
/** The host's resident memory now, in bytes: what a lazily opened input
|
|
286
|
+
* weighs a read of it whole by (`beast2LazyStats`), and what an input
|
|
287
|
+
* decoded whole is said to add. Without it, both come to 0. */
|
|
288
|
+
resident?: () => number;
|
|
289
|
+
/** The decoded weight, in bytes, each lazily opened input's pager keeps of
|
|
290
|
+
* the segments its keyed and index reads decode (v5/SPEC.md, "The pager's
|
|
291
|
+
* cache"): 256 MiB without it. A runner sets it from
|
|
292
|
+
* `EAST_PAGED_CACHE_BYTES`, as east-c's pager reads that variable, so a
|
|
293
|
+
* test runs every runner in the one-segment mode alike. */
|
|
294
|
+
cacheBytes?: number;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Opens an input lazily, frozen, when it can be: a beast2 v5 collection blob
|
|
298
|
+
* carrying a segment index, or a manifest over its segment files. Its size,
|
|
299
|
+
* iteration and keyed reads are served a segment at a time; any other
|
|
300
|
+
* operation reads it whole, once, when it first needs it, to the eager value's
|
|
301
|
+
* exact semantics.
|
|
302
|
+
*
|
|
303
|
+
* @remarks
|
|
304
|
+
* The file is never read whole: the value pages segment frames from it through
|
|
305
|
+
* ranged reads, and a manifest's segments are read from their own files, each
|
|
306
|
+
* asked for as it is first read when the unit's host places segments as they
|
|
307
|
+
* are read. A unit whose host does not, and whose manifest names a segment not
|
|
308
|
+
* there, is refused here, so its input decodes whole and fails there.
|
|
309
|
+
*
|
|
310
|
+
* Frozen is what makes a lazy open safe for any nested element shape, since a
|
|
311
|
+
* frozen value cannot be written through; an element holding a Ref or a
|
|
312
|
+
* function still cannot be, and is refused ({@link isBeast2LazySafe}).
|
|
313
|
+
*
|
|
314
|
+
* @param io - the unit's files
|
|
315
|
+
* @param path - the input's file
|
|
316
|
+
* @param options - the unit's `fetch`, the host's resident-memory gauge, and
|
|
317
|
+
* the decoded weight the input's pager keeps
|
|
318
|
+
* @returns the lazy collection value, or `undefined` when the input cannot be
|
|
319
|
+
* opened lazily — another encoding, a version 4 or index-less blob, a root
|
|
320
|
+
* that is no collection, segments that alias one another, an unsafe element
|
|
321
|
+
* shape, or a file that is not there — for the caller to decode it whole
|
|
322
|
+
*/
|
|
323
|
+
export declare function openUnitInputLazy(io: UnitIO, path: string, options: UnitInputOptions): unknown | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* What a runner hears of its inputs as they open: the account `-v` gives of
|
|
326
|
+
* each.
|
|
327
|
+
*/
|
|
328
|
+
export interface UnitInputReport {
|
|
329
|
+
/**
|
|
330
|
+
* Input `index` opened lazily.
|
|
331
|
+
*
|
|
332
|
+
* @param index - the input's position
|
|
333
|
+
*/
|
|
334
|
+
openedLazily(index: number): void;
|
|
335
|
+
/**
|
|
336
|
+
* Input `index` was decoded whole before the program ran.
|
|
337
|
+
*
|
|
338
|
+
* @param index - the input's position
|
|
339
|
+
* @param residentBytes - what its decode added to resident memory, by the
|
|
340
|
+
* host's gauge: 0 without one, and below 0 when memory freed across the
|
|
341
|
+
* decode left the host smaller
|
|
342
|
+
*/
|
|
343
|
+
decodedWhole(index: number, residentBytes: number): void;
|
|
344
|
+
}
|
|
345
|
+
/** How a program's inputs open: the unit's `fetch`, the host's gauge, and who
|
|
346
|
+
* hears how each opened. */
|
|
347
|
+
export interface UnitInputsOptions extends UnitInputOptions {
|
|
348
|
+
/** Hears how each input opened; without it, nothing is measured for it. */
|
|
349
|
+
report?: UnitInputReport;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Opens a program's inputs as the unit's `decode` says, every one frozen.
|
|
353
|
+
*
|
|
354
|
+
* @remarks
|
|
355
|
+
* With `lazy`, each collection input opens lazily whatever it weighs
|
|
356
|
+
* ({@link openUnitInputLazy}); one that cannot, and every input with `whole`,
|
|
357
|
+
* is decoded whole before the program runs ({@link loadUnitInput}), what that
|
|
358
|
+
* added to resident memory measured for a report.
|
|
359
|
+
*
|
|
360
|
+
* @param io - the unit's files
|
|
361
|
+
* @param paths - the input files, in parameter order
|
|
362
|
+
* @param types - the parameters' types
|
|
363
|
+
* @param decode - how the collection inputs are read
|
|
364
|
+
* @param options - the unit's `fetch`, the host's gauge, the decoded weight a
|
|
365
|
+
* lazy input's pager keeps, and the report
|
|
366
|
+
* @returns the inputs, in parameter order
|
|
367
|
+
* @throws {Error} When an input decoded whole cannot be read or decoded.
|
|
368
|
+
*/
|
|
369
|
+
export declare function openUnitInputs(io: UnitIO, paths: readonly string[], types: readonly EastTypeValue[], decode: UnitDecode, options: UnitInputsOptions): unknown[];
|
|
370
|
+
//# sourceMappingURL=runner_io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner_io.d.ts","sourceRoot":"","sources":["../../src/runner_io.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmBlD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAwB,MAAM,sBAAsB,CAAC;AAEnF;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC/B;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B;;;;;;;;;OASG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IACpE;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAA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