@rcrsr/rill 0.15.0 → 0.17.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 +37 -21
- package/dist/ast-nodes.d.ts +2 -13
- package/dist/ast-nodes.js +0 -1
- package/dist/ast-unions.d.ts +0 -1
- package/dist/ast-unions.js +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/error-classes.d.ts +0 -1
- package/dist/error-classes.js +0 -1
- package/dist/error-formatter.d.ts +0 -1
- package/dist/error-formatter.js +0 -1
- package/dist/error-registry.d.ts +0 -1
- package/dist/error-registry.js +32 -1
- package/dist/ext/crypto/index.d.ts +3 -4
- package/dist/ext/crypto/index.js +66 -64
- package/dist/ext/exec/index.d.ts +3 -4
- package/dist/ext/exec/index.js +17 -12
- package/dist/ext/exec/runner.d.ts +0 -1
- package/dist/ext/exec/runner.js +0 -1
- package/dist/ext/fetch/index.d.ts +3 -4
- package/dist/ext/fetch/index.js +23 -49
- package/dist/ext/fetch/request.d.ts +0 -1
- package/dist/ext/fetch/request.js +0 -1
- package/dist/ext/fs/index.d.ts +3 -4
- package/dist/ext/fs/index.js +268 -266
- package/dist/ext/fs/sandbox.d.ts +0 -1
- package/dist/ext/fs/sandbox.js +0 -1
- package/dist/ext/kv/index.d.ts +3 -4
- package/dist/ext/kv/index.js +216 -215
- package/dist/ext/kv/store.d.ts +0 -1
- package/dist/ext/kv/store.js +2 -2
- package/dist/ext-parse-bridge.d.ts +10 -0
- package/dist/ext-parse-bridge.js +10 -0
- package/dist/generated/introspection-data.d.ts +1 -2
- package/dist/generated/introspection-data.js +385 -297
- package/dist/generated/version-data.d.ts +1 -2
- package/dist/generated/version-data.js +2 -3
- package/dist/highlight-map.d.ts +0 -1
- package/dist/highlight-map.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +14 -6
- package/dist/lexer/errors.d.ts +0 -1
- package/dist/lexer/errors.js +0 -1
- package/dist/lexer/helpers.d.ts +0 -1
- package/dist/lexer/helpers.js +0 -1
- package/dist/lexer/index.d.ts +0 -1
- package/dist/lexer/index.js +0 -1
- package/dist/lexer/operators.d.ts +0 -1
- package/dist/lexer/operators.js +0 -1
- package/dist/lexer/readers.d.ts +0 -1
- package/dist/lexer/readers.js +0 -1
- package/dist/lexer/state.d.ts +0 -1
- package/dist/lexer/state.js +0 -1
- package/dist/lexer/tokenizer.d.ts +0 -1
- package/dist/lexer/tokenizer.js +0 -1
- package/dist/parser/helpers.d.ts +0 -1
- package/dist/parser/helpers.js +0 -1
- package/dist/parser/index.d.ts +0 -1
- package/dist/parser/index.js +0 -1
- package/dist/parser/parser-collect.d.ts +0 -1
- package/dist/parser/parser-collect.js +0 -1
- package/dist/parser/parser-control.d.ts +0 -1
- package/dist/parser/parser-control.js +0 -1
- package/dist/parser/parser-expr.d.ts +0 -1
- package/dist/parser/parser-expr.js +0 -1
- package/dist/parser/parser-extract.d.ts +0 -1
- package/dist/parser/parser-extract.js +0 -1
- package/dist/parser/parser-functions.d.ts +0 -1
- package/dist/parser/parser-functions.js +0 -1
- package/dist/parser/parser-literals.d.ts +0 -1
- package/dist/parser/parser-literals.js +4 -2
- package/dist/parser/parser-script.d.ts +0 -1
- package/dist/parser/parser-script.js +0 -1
- package/dist/parser/parser-shape.d.ts +2 -3
- package/dist/parser/parser-shape.js +8 -52
- package/dist/parser/parser-types.d.ts +28 -2
- package/dist/parser/parser-types.js +76 -13
- package/dist/parser/parser-use.d.ts +0 -1
- package/dist/parser/parser-use.js +7 -2
- package/dist/parser/parser-variables.d.ts +0 -1
- package/dist/parser/parser-variables.js +0 -1
- package/dist/parser/parser.d.ts +0 -1
- package/dist/parser/parser.js +0 -1
- package/dist/parser/state.d.ts +0 -1
- package/dist/parser/state.js +0 -1
- package/dist/runtime/core/callable.d.ts +59 -20
- package/dist/runtime/core/callable.js +188 -39
- package/dist/runtime/core/context.d.ts +0 -12
- package/dist/runtime/core/context.js +77 -77
- package/dist/runtime/core/equals.d.ts +0 -1
- package/dist/runtime/core/equals.js +35 -3
- package/dist/runtime/core/eval/base.d.ts +0 -1
- package/dist/runtime/core/eval/base.js +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts +0 -1
- package/dist/runtime/core/eval/evaluator.js +0 -1
- package/dist/runtime/core/eval/index.d.ts +2 -3
- package/dist/runtime/core/eval/index.js +11 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/closures.js +92 -70
- package/dist/runtime/core/eval/mixins/collections.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/collections.js +9 -4
- package/dist/runtime/core/eval/mixins/control-flow.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js +196 -188
- package/dist/runtime/core/eval/mixins/core.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/core.js +2 -3
- package/dist/runtime/core/eval/mixins/expressions.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js +35 -28
- package/dist/runtime/core/eval/mixins/extraction.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js +8 -9
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/literals.js +6 -10
- package/dist/runtime/core/eval/mixins/types.d.ts +2 -1
- package/dist/runtime/core/eval/mixins/types.js +231 -261
- package/dist/runtime/core/eval/mixins/use.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/use.js +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/variables.js +16 -15
- package/dist/runtime/core/eval/types.d.ts +0 -1
- package/dist/runtime/core/eval/types.js +0 -1
- package/dist/runtime/core/execute.d.ts +0 -1
- package/dist/runtime/core/execute.js +0 -1
- package/dist/runtime/core/field-descriptor.d.ts +4 -5
- package/dist/runtime/core/field-descriptor.js +2 -2
- package/dist/runtime/core/introspection.d.ts +0 -1
- package/dist/runtime/core/introspection.js +6 -7
- package/dist/runtime/core/markers.d.ts +12 -0
- package/dist/runtime/core/markers.js +7 -0
- package/dist/runtime/core/resolvers.d.ts +0 -1
- package/dist/runtime/core/resolvers.js +0 -1
- package/dist/runtime/core/signals.d.ts +0 -1
- package/dist/runtime/core/signals.js +0 -1
- package/dist/runtime/core/type-registrations.d.ts +136 -0
- package/dist/runtime/core/type-registrations.js +749 -0
- package/dist/runtime/core/type-structures.d.ts +128 -0
- package/dist/runtime/core/type-structures.js +12 -0
- package/dist/runtime/core/types.d.ts +15 -4
- package/dist/runtime/core/types.js +0 -1
- package/dist/runtime/core/values.d.ts +88 -146
- package/dist/runtime/core/values.js +466 -470
- package/dist/runtime/ext/builtins.d.ts +0 -1
- package/dist/runtime/ext/builtins.js +125 -80
- package/dist/runtime/ext/extensions.d.ts +30 -125
- package/dist/runtime/ext/extensions.js +0 -94
- package/dist/runtime/ext/test-context.d.ts +28 -0
- package/dist/runtime/ext/test-context.js +154 -0
- package/dist/runtime/index.d.ts +22 -9
- package/dist/runtime/index.js +18 -5
- package/dist/signature-parser.d.ts +2 -3
- package/dist/signature-parser.js +19 -17
- package/dist/source-location.d.ts +0 -1
- package/dist/source-location.js +0 -1
- package/dist/token-types.d.ts +0 -1
- package/dist/token-types.js +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/value-types.d.ts +15 -12
- package/dist/value-types.js +0 -1
- package/package.json +2 -1
- package/dist/ast-nodes.d.ts.map +0 -1
- package/dist/ast-nodes.js.map +0 -1
- package/dist/ast-unions.d.ts.map +0 -1
- package/dist/ast-unions.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/error-classes.d.ts.map +0 -1
- package/dist/error-classes.js.map +0 -1
- package/dist/error-formatter.d.ts.map +0 -1
- package/dist/error-formatter.js.map +0 -1
- package/dist/error-registry.d.ts.map +0 -1
- package/dist/error-registry.js.map +0 -1
- package/dist/ext/crypto/index.d.ts.map +0 -1
- package/dist/ext/crypto/index.js.map +0 -1
- package/dist/ext/exec/index.d.ts.map +0 -1
- package/dist/ext/exec/index.js.map +0 -1
- package/dist/ext/exec/runner.d.ts.map +0 -1
- package/dist/ext/exec/runner.js.map +0 -1
- package/dist/ext/fetch/index.d.ts.map +0 -1
- package/dist/ext/fetch/index.js.map +0 -1
- package/dist/ext/fetch/request.d.ts.map +0 -1
- package/dist/ext/fetch/request.js.map +0 -1
- package/dist/ext/fs/index.d.ts.map +0 -1
- package/dist/ext/fs/index.js.map +0 -1
- package/dist/ext/fs/sandbox.d.ts.map +0 -1
- package/dist/ext/fs/sandbox.js.map +0 -1
- package/dist/ext/kv/index.d.ts.map +0 -1
- package/dist/ext/kv/index.js.map +0 -1
- package/dist/ext/kv/store.d.ts.map +0 -1
- package/dist/ext/kv/store.js.map +0 -1
- package/dist/generated/introspection-data.d.ts.map +0 -1
- package/dist/generated/introspection-data.js.map +0 -1
- package/dist/generated/version-data.d.ts.map +0 -1
- package/dist/generated/version-data.js.map +0 -1
- package/dist/highlight-map.d.ts.map +0 -1
- package/dist/highlight-map.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lexer/errors.d.ts.map +0 -1
- package/dist/lexer/errors.js.map +0 -1
- package/dist/lexer/helpers.d.ts.map +0 -1
- package/dist/lexer/helpers.js.map +0 -1
- package/dist/lexer/index.d.ts.map +0 -1
- package/dist/lexer/index.js.map +0 -1
- package/dist/lexer/operators.d.ts.map +0 -1
- package/dist/lexer/operators.js.map +0 -1
- package/dist/lexer/readers.d.ts.map +0 -1
- package/dist/lexer/readers.js.map +0 -1
- package/dist/lexer/state.d.ts.map +0 -1
- package/dist/lexer/state.js.map +0 -1
- package/dist/lexer/tokenizer.d.ts.map +0 -1
- package/dist/lexer/tokenizer.js.map +0 -1
- package/dist/parser/helpers.d.ts.map +0 -1
- package/dist/parser/helpers.js.map +0 -1
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/parser-collect.d.ts.map +0 -1
- package/dist/parser/parser-collect.js.map +0 -1
- package/dist/parser/parser-control.d.ts.map +0 -1
- package/dist/parser/parser-control.js.map +0 -1
- package/dist/parser/parser-expr.d.ts.map +0 -1
- package/dist/parser/parser-expr.js.map +0 -1
- package/dist/parser/parser-extract.d.ts.map +0 -1
- package/dist/parser/parser-extract.js.map +0 -1
- package/dist/parser/parser-functions.d.ts.map +0 -1
- package/dist/parser/parser-functions.js.map +0 -1
- package/dist/parser/parser-literals.d.ts.map +0 -1
- package/dist/parser/parser-literals.js.map +0 -1
- package/dist/parser/parser-script.d.ts.map +0 -1
- package/dist/parser/parser-script.js.map +0 -1
- package/dist/parser/parser-shape.d.ts.map +0 -1
- package/dist/parser/parser-shape.js.map +0 -1
- package/dist/parser/parser-types.d.ts.map +0 -1
- package/dist/parser/parser-types.js.map +0 -1
- package/dist/parser/parser-use.d.ts.map +0 -1
- package/dist/parser/parser-use.js.map +0 -1
- package/dist/parser/parser-variables.d.ts.map +0 -1
- package/dist/parser/parser-variables.js.map +0 -1
- package/dist/parser/parser.d.ts.map +0 -1
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/state.d.ts.map +0 -1
- package/dist/parser/state.js.map +0 -1
- package/dist/runtime/core/callable.d.ts.map +0 -1
- package/dist/runtime/core/callable.js.map +0 -1
- package/dist/runtime/core/context.d.ts.map +0 -1
- package/dist/runtime/core/context.js.map +0 -1
- package/dist/runtime/core/equals.d.ts.map +0 -1
- package/dist/runtime/core/equals.js.map +0 -1
- package/dist/runtime/core/eval/base.d.ts.map +0 -1
- package/dist/runtime/core/eval/base.js.map +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts.map +0 -1
- package/dist/runtime/core/eval/evaluator.js.map +0 -1
- package/dist/runtime/core/eval/index.d.ts.map +0 -1
- package/dist/runtime/core/eval/index.js.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.js.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.js.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js.map +0 -1
- package/dist/runtime/core/eval/mixins/core.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/core.js.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.js.map +0 -1
- package/dist/runtime/core/eval/mixins/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/types.js.map +0 -1
- package/dist/runtime/core/eval/mixins/use.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/use.js.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.js.map +0 -1
- package/dist/runtime/core/eval/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/types.js.map +0 -1
- package/dist/runtime/core/execute.d.ts.map +0 -1
- package/dist/runtime/core/execute.js.map +0 -1
- package/dist/runtime/core/field-descriptor.d.ts.map +0 -1
- package/dist/runtime/core/field-descriptor.js.map +0 -1
- package/dist/runtime/core/introspection.d.ts.map +0 -1
- package/dist/runtime/core/introspection.js.map +0 -1
- package/dist/runtime/core/resolvers.d.ts.map +0 -1
- package/dist/runtime/core/resolvers.js.map +0 -1
- package/dist/runtime/core/signals.d.ts.map +0 -1
- package/dist/runtime/core/signals.js.map +0 -1
- package/dist/runtime/core/types.d.ts.map +0 -1
- package/dist/runtime/core/types.js.map +0 -1
- package/dist/runtime/core/values.d.ts.map +0 -1
- package/dist/runtime/core/values.js.map +0 -1
- package/dist/runtime/ext/builtins.d.ts.map +0 -1
- package/dist/runtime/ext/builtins.js.map +0 -1
- package/dist/runtime/ext/extensions.d.ts.map +0 -1
- package/dist/runtime/ext/extensions.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/signature-parser.d.ts.map +0 -1
- package/dist/signature-parser.js.map +0 -1
- package/dist/source-location.d.ts.map +0 -1
- package/dist/source-location.js.map +0 -1
- package/dist/token-types.d.ts.map +0 -1
- package/dist/token-types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/value-types.d.ts.map +0 -1
- package/dist/value-types.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Structure Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the TypeStructure union (discriminated by `.kind`) and
|
|
5
|
+
* associated value interfaces. These types form the foundation for
|
|
6
|
+
* the type registration and dispatch system.
|
|
7
|
+
*
|
|
8
|
+
* The TypeStructure union mirrors the existing RillType union but uses
|
|
9
|
+
* `.kind` as its discriminator instead of `.type`, enabling future
|
|
10
|
+
* coexistence during migration.
|
|
11
|
+
*/
|
|
12
|
+
import type { RillTypeName } from '../../types.js';
|
|
13
|
+
import type { CallableMarker, FieldDescriptorMarker } from './markers.js';
|
|
14
|
+
/**
|
|
15
|
+
* Field definition - describes a single field in a structural type.
|
|
16
|
+
* Used by dict, tuple, ordered, and closure type descriptors.
|
|
17
|
+
* Default detection: `field.defaultValue !== undefined`.
|
|
18
|
+
*
|
|
19
|
+
* Uses TypeStructure (not RillType) for the field's type descriptor.
|
|
20
|
+
*/
|
|
21
|
+
export interface RillFieldDef {
|
|
22
|
+
name?: string | undefined;
|
|
23
|
+
type: TypeStructure;
|
|
24
|
+
defaultValue?: RillValue | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Structural type descriptor - describes the shape of a value in the type system.
|
|
28
|
+
* Discriminated by `.kind` (not `.type`).
|
|
29
|
+
*
|
|
30
|
+
* Includes all 12 built-in variants plus a catch-all for types without
|
|
31
|
+
* parameterized structure (e.g. iterator).
|
|
32
|
+
*/
|
|
33
|
+
export type TypeStructure = {
|
|
34
|
+
kind: 'number';
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'string';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'bool';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'vector';
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'type';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'any';
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'dict';
|
|
47
|
+
fields?: Record<string, RillFieldDef> | undefined;
|
|
48
|
+
valueType?: TypeStructure | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'list';
|
|
51
|
+
element?: TypeStructure | undefined;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'closure';
|
|
54
|
+
params?: RillFieldDef[] | undefined;
|
|
55
|
+
ret?: TypeStructure | undefined;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'tuple';
|
|
58
|
+
elements?: RillFieldDef[] | undefined;
|
|
59
|
+
valueType?: TypeStructure | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'ordered';
|
|
62
|
+
fields?: RillFieldDef[] | undefined;
|
|
63
|
+
valueType?: TypeStructure | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'union';
|
|
66
|
+
members: TypeStructure[];
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'iterator';
|
|
69
|
+
} | {
|
|
70
|
+
kind: string;
|
|
71
|
+
data?: unknown;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Tuple type - represents positional unpacked arguments for closure invocation.
|
|
75
|
+
* Created by the * (spread) operator from lists.
|
|
76
|
+
* Entries are positional only.
|
|
77
|
+
*
|
|
78
|
+
* Note: In Rill, "tuple" refers to fixed-size argument packing (like function signatures),
|
|
79
|
+
* while "list" refers to dynamic ordered collections ([1, 2, 3]).
|
|
80
|
+
*/
|
|
81
|
+
export interface RillTuple {
|
|
82
|
+
readonly __rill_tuple: true;
|
|
83
|
+
readonly entries: RillValue[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Ordered type - represents named key-value pairs with preserved insertion order.
|
|
87
|
+
* Created by the * (spread) operator from dicts.
|
|
88
|
+
* Entries may carry an optional third element (default value) when representing
|
|
89
|
+
* closure parameter reflection via `.^input`.
|
|
90
|
+
*/
|
|
91
|
+
export interface RillOrdered {
|
|
92
|
+
readonly __rill_ordered: true;
|
|
93
|
+
readonly entries: [string, RillValue, RillValue?][];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Vector type - represents dense numeric embeddings.
|
|
97
|
+
* Immutable Float32Array with associated model name.
|
|
98
|
+
*/
|
|
99
|
+
export interface RillVector {
|
|
100
|
+
readonly __rill_vector: true;
|
|
101
|
+
readonly data: Float32Array;
|
|
102
|
+
readonly model: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type value - represents a first-class type name at runtime.
|
|
106
|
+
* Created when a type name expression (e.g. `string`, `number`) is evaluated.
|
|
107
|
+
*/
|
|
108
|
+
export interface RillTypeValue {
|
|
109
|
+
readonly __rill_type: true;
|
|
110
|
+
readonly typeName: RillTypeName;
|
|
111
|
+
readonly structure: TypeStructure;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Iterator type - represents a lazy sequence.
|
|
115
|
+
* An iterator is a dict with:
|
|
116
|
+
* - done: boolean - whether iteration is complete
|
|
117
|
+
* - next: callable - function to get next iterator
|
|
118
|
+
* - value?: any - current value (absent when done)
|
|
119
|
+
*/
|
|
120
|
+
export interface RillIterator extends Record<string, RillValue> {
|
|
121
|
+
readonly done: boolean;
|
|
122
|
+
readonly next: CallableMarker;
|
|
123
|
+
readonly value?: RillValue;
|
|
124
|
+
}
|
|
125
|
+
/** Any value that can flow through Rill */
|
|
126
|
+
export type RillValue = string | number | boolean | null | RillValue[] | {
|
|
127
|
+
[key: string]: RillValue;
|
|
128
|
+
} | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Structure Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the TypeStructure union (discriminated by `.kind`) and
|
|
5
|
+
* associated value interfaces. These types form the foundation for
|
|
6
|
+
* the type registration and dispatch system.
|
|
7
|
+
*
|
|
8
|
+
* The TypeStructure union mirrors the existing RillType union but uses
|
|
9
|
+
* `.kind` as its discriminator instead of `.type`, enabling future
|
|
10
|
+
* coexistence during migration.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { RillTypeName } from '../../types.js';
|
|
8
8
|
import type { CallableFn, RillFunction } from './callable.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { TypeStructure, RillValue } from './values.js';
|
|
10
10
|
export type { NativeArray, NativePlainObject, NativeValue } from './values.js';
|
|
11
11
|
/** I/O callbacks for runtime operations */
|
|
12
12
|
export interface RuntimeCallbacks {
|
|
@@ -119,7 +119,7 @@ export interface RuntimeContext {
|
|
|
119
119
|
/** Named variables ($varname) - local to this scope */
|
|
120
120
|
readonly variables: Map<string, RillValue>;
|
|
121
121
|
/** Variable types - locked after first assignment (local to this scope) */
|
|
122
|
-
readonly variableTypes: Map<string, RillTypeName |
|
|
122
|
+
readonly variableTypes: Map<string, RillTypeName | TypeStructure>;
|
|
123
123
|
/** Built-in and user-defined functions (CallableFn for untyped, ApplicationCallable for typed) */
|
|
124
124
|
readonly functions: Map<string, CallableFn | import('./callable.js').ApplicationCallable>;
|
|
125
125
|
/** I/O callbacks */
|
|
@@ -158,9 +158,21 @@ export interface RuntimeContext {
|
|
|
158
158
|
/**
|
|
159
159
|
* Per-type method dictionaries: maps type name to a frozen dict of ApplicationCallable values.
|
|
160
160
|
* Keys: "string", "list", "dict", "number", "bool", "vector".
|
|
161
|
-
* Populated at context creation from
|
|
161
|
+
* Populated at context creation from type registrations; propagated to child contexts.
|
|
162
162
|
*/
|
|
163
163
|
readonly typeMethodDicts: ReadonlyMap<string, Readonly<Record<string, RillValue>>>;
|
|
164
|
+
/**
|
|
165
|
+
* Type names that reject type arguments in type constructors.
|
|
166
|
+
* Derived from BUILT_IN_TYPES registrations where isLeaf === true, plus 'any'.
|
|
167
|
+
* Used by type assertion/check evaluation to reject e.g. string(number).
|
|
168
|
+
*/
|
|
169
|
+
readonly leafTypes: ReadonlySet<string>;
|
|
170
|
+
/**
|
|
171
|
+
* Method names that handle their own receiver type checking with specific
|
|
172
|
+
* error messages. Generic RILL-R003 must not fire before the method body runs.
|
|
173
|
+
* Derived from registration method dicts at context creation.
|
|
174
|
+
*/
|
|
175
|
+
readonly unvalidatedMethodReceivers: ReadonlySet<string>;
|
|
164
176
|
/** Scheme-to-resolver map, populated from RuntimeOptions.resolvers (empty Map when absent) */
|
|
165
177
|
readonly resolvers: ReadonlyMap<string, SchemeResolver>;
|
|
166
178
|
/** Per-scheme config data, populated from RuntimeOptions.configurations.resolvers (empty Map when absent) */
|
|
@@ -255,4 +267,3 @@ export interface ExecutionStepper {
|
|
|
255
267
|
* This sets boundDict on each callable so they can access their container.
|
|
256
268
|
*/
|
|
257
269
|
export declare function bindDictCallables(value: RillValue): RillValue;
|
|
258
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -3,112 +3,30 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Core value types that flow through Rill programs.
|
|
5
5
|
* Public API for host applications.
|
|
6
|
-
*/
|
|
7
|
-
import type { RillTypeName } from '../../types.js';
|
|
8
|
-
interface CallableMarker {
|
|
9
|
-
readonly __type: 'callable';
|
|
10
|
-
}
|
|
11
|
-
interface FieldDescriptorMarker {
|
|
12
|
-
readonly __rill_field_descriptor: true;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Tuple type - represents positional unpacked arguments for closure invocation.
|
|
16
|
-
* Created by the * (spread) operator from lists.
|
|
17
|
-
* Entries are positional only.
|
|
18
6
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export interface RillTuple {
|
|
23
|
-
readonly __rill_tuple: true;
|
|
24
|
-
readonly entries: RillValue[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Ordered type - represents named key-value pairs with preserved insertion order.
|
|
28
|
-
* Created by the * (spread) operator from dicts.
|
|
29
|
-
*/
|
|
30
|
-
export interface RillOrdered {
|
|
31
|
-
readonly __rill_ordered: true;
|
|
32
|
-
readonly entries: [string, RillValue][];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Vector type - represents dense numeric embeddings.
|
|
36
|
-
* Immutable Float32Array with associated model name.
|
|
7
|
+
* Dispatch functions (inferType, formatValue, deepEquals, serializeValue,
|
|
8
|
+
* copyValue) re-export from type-registrations.ts protocol implementations.
|
|
37
9
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Used by RillTypeValue to carry type structure information at runtime.
|
|
46
|
-
*/
|
|
47
|
-
export type RillType = {
|
|
48
|
-
type: 'number';
|
|
49
|
-
} | {
|
|
50
|
-
type: 'string';
|
|
51
|
-
} | {
|
|
52
|
-
type: 'bool';
|
|
53
|
-
} | {
|
|
54
|
-
type: 'vector';
|
|
55
|
-
} | {
|
|
56
|
-
type: 'type';
|
|
57
|
-
} | {
|
|
58
|
-
type: 'any';
|
|
59
|
-
} | {
|
|
60
|
-
type: 'dict';
|
|
61
|
-
fields?: Record<string, RillFieldType>;
|
|
62
|
-
} | {
|
|
63
|
-
type: 'list';
|
|
64
|
-
element?: RillType;
|
|
65
|
-
} | {
|
|
66
|
-
type: 'closure';
|
|
67
|
-
params?: [string, RillType, RillValue?][];
|
|
68
|
-
ret?: RillType;
|
|
69
|
-
} | {
|
|
70
|
-
type: 'tuple';
|
|
71
|
-
elements?: [RillType, RillValue?][];
|
|
72
|
-
} | {
|
|
73
|
-
type: 'ordered';
|
|
74
|
-
fields?: [string, RillType, RillValue?][];
|
|
75
|
-
} | {
|
|
76
|
-
type: 'union';
|
|
77
|
-
members: RillType[];
|
|
10
|
+
import type { RillTypeName } from '../../types.js';
|
|
11
|
+
import type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure } from './type-structures.js';
|
|
12
|
+
export type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure, };
|
|
13
|
+
export type DictStructure = {
|
|
14
|
+
kind: 'dict';
|
|
15
|
+
fields?: Record<string, RillFieldDef>;
|
|
16
|
+
valueType?: TypeStructure;
|
|
78
17
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
export type RillFieldType = RillType | {
|
|
84
|
-
type: RillType;
|
|
85
|
-
defaultValue: RillValue;
|
|
18
|
+
export type TupleStructure = {
|
|
19
|
+
kind: 'tuple';
|
|
20
|
+
elements?: RillFieldDef[];
|
|
21
|
+
valueType?: TypeStructure;
|
|
86
22
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export declare function isFieldTypeWithDefault(fieldType: RillFieldType): fieldType is {
|
|
92
|
-
type: RillType;
|
|
93
|
-
defaultValue: RillValue;
|
|
23
|
+
export type OrderedStructure = {
|
|
24
|
+
kind: 'ordered';
|
|
25
|
+
fields?: RillFieldDef[];
|
|
26
|
+
valueType?: TypeStructure;
|
|
94
27
|
};
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
*/
|
|
98
|
-
export type RillStructuralType = RillType;
|
|
99
|
-
/**
|
|
100
|
-
* Type value - represents a first-class type name at runtime.
|
|
101
|
-
* Created when a type name expression (e.g. `string`, `number`) is evaluated.
|
|
102
|
-
*/
|
|
103
|
-
export interface RillTypeValue {
|
|
104
|
-
readonly __rill_type: true;
|
|
105
|
-
readonly typeName: RillTypeName;
|
|
106
|
-
readonly structure: RillType;
|
|
107
|
-
}
|
|
108
|
-
/** Any value that can flow through Rill */
|
|
109
|
-
export type RillValue = string | number | boolean | null | RillValue[] | {
|
|
110
|
-
[key: string]: RillValue;
|
|
111
|
-
} | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue;
|
|
28
|
+
/** @deprecated Use TypeStructure instead. */
|
|
29
|
+
export type RillType = TypeStructure;
|
|
112
30
|
/** Type guard for RillTuple (spread args) */
|
|
113
31
|
export declare function isTuple(value: RillValue): value is RillTuple;
|
|
114
32
|
/** Type guard for RillVector */
|
|
@@ -117,8 +35,12 @@ export declare function isVector(value: RillValue): value is RillVector;
|
|
|
117
35
|
export declare function isOrdered(value: RillValue): value is RillOrdered;
|
|
118
36
|
/** Type guard for RillTypeValue */
|
|
119
37
|
export declare function isTypeValue(value: RillValue): value is RillTypeValue;
|
|
120
|
-
/**
|
|
121
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Create ordered from entries array (named, preserves insertion order).
|
|
40
|
+
* Entries may be 2-element [name, value] or 3-element [name, value, default]
|
|
41
|
+
* tuples; the third element carries a default value for `.^input` reflection.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createOrdered(entries: [string, RillValue, RillValue?][]): RillOrdered;
|
|
122
44
|
/** Create tuple from entries array (positional, preserves order) */
|
|
123
45
|
export declare function createTuple(entries: RillValue[]): RillTuple;
|
|
124
46
|
/**
|
|
@@ -126,27 +48,48 @@ export declare function createTuple(entries: RillValue[]): RillTuple;
|
|
|
126
48
|
* @throws {Error} if data.length is 0 (zero-dimension vectors not allowed)
|
|
127
49
|
*/
|
|
128
50
|
export declare function createVector(data: Float32Array, model: string): RillVector;
|
|
129
|
-
/** Infer the Rill type from a runtime value */
|
|
130
|
-
export declare
|
|
51
|
+
/** Infer the Rill type from a runtime value. Delegates to type-registrations. */
|
|
52
|
+
export declare const inferType: (value: RillValue) => string;
|
|
131
53
|
/**
|
|
132
54
|
* Infer the element type for a homogeneous list.
|
|
133
|
-
* Empty arrays return {
|
|
55
|
+
* Empty arrays return { kind: 'any' }.
|
|
134
56
|
* Mixed types throw RILL-R002.
|
|
135
57
|
*/
|
|
136
|
-
export declare function inferElementType(elements: RillValue[]):
|
|
58
|
+
export declare function inferElementType(elements: RillValue[]): TypeStructure;
|
|
59
|
+
/**
|
|
60
|
+
* Return the most specific shared type for two TypeStructure values.
|
|
61
|
+
* Returns null when types are incompatible at the top level.
|
|
62
|
+
*
|
|
63
|
+
* Cascade priority:
|
|
64
|
+
* 1. Any-narrowing: if either side is `any`, return the other
|
|
65
|
+
* 2. Structural match: delegate to structureEquals; on true, return a
|
|
66
|
+
* 3. Recursive list: merge inner element types
|
|
67
|
+
* 3b. Uniform valueType: merge dict/tuple/ordered value types
|
|
68
|
+
* 4. Bare type fallback: same compound type but structural mismatch
|
|
69
|
+
* 5. Incompatible: different top-level types return null
|
|
70
|
+
*/
|
|
71
|
+
export declare function commonType(a: TypeStructure, b: TypeStructure): TypeStructure | null;
|
|
137
72
|
/** Compare two structural types for equality. */
|
|
138
|
-
export declare function
|
|
73
|
+
export declare function structureEquals(a: TypeStructure, b: TypeStructure): boolean;
|
|
74
|
+
/** @deprecated Use structureEquals instead. */
|
|
75
|
+
export declare const structuralTypeEquals: typeof structureEquals;
|
|
139
76
|
/** Infer the structural type descriptor for any Rill value. */
|
|
140
|
-
export declare function
|
|
77
|
+
export declare function inferStructure(value: RillValue): TypeStructure;
|
|
78
|
+
/** @deprecated Use inferStructure instead. */
|
|
79
|
+
export declare const inferStructuralType: typeof inferStructure;
|
|
141
80
|
/**
|
|
142
81
|
* Check if a value matches a structural type descriptor.
|
|
143
82
|
* Used for runtime type checking (`:?` operator).
|
|
144
83
|
*/
|
|
145
|
-
export declare function
|
|
146
|
-
/**
|
|
147
|
-
export declare
|
|
84
|
+
export declare function structureMatches(value: RillValue, type: TypeStructure): boolean;
|
|
85
|
+
/** @deprecated Use structureMatches instead. */
|
|
86
|
+
export declare const structuralTypeMatches: typeof structureMatches;
|
|
87
|
+
/** Build a closure param field definition from name, type, and optional default. */
|
|
88
|
+
export declare function paramToFieldDef(name: string, type: TypeStructure, defaultValue: RillValue | undefined): RillFieldDef;
|
|
148
89
|
/** Format a structural type descriptor as a human-readable string. */
|
|
149
|
-
export declare function
|
|
90
|
+
export declare function formatStructure(type: TypeStructure): string;
|
|
91
|
+
/** @deprecated Use formatStructure instead. */
|
|
92
|
+
export declare const formatStructuralType: typeof formatStructure;
|
|
150
93
|
/**
|
|
151
94
|
* Check if a value is of the expected type.
|
|
152
95
|
* Returns true if the value matches the expected type, false otherwise.
|
|
@@ -156,8 +99,8 @@ export declare function checkType(value: RillValue, expected: RillTypeName): boo
|
|
|
156
99
|
export declare function isTruthy(value: RillValue): boolean;
|
|
157
100
|
/** Check if a value is empty (inverse of truthy) */
|
|
158
101
|
export declare function isEmpty(value: RillValue): boolean;
|
|
159
|
-
/** Format a value for display */
|
|
160
|
-
export declare
|
|
102
|
+
/** Format a value for display. Delegates to type-registrations. */
|
|
103
|
+
export declare const formatValue: (value: RillValue) => string;
|
|
161
104
|
/**
|
|
162
105
|
* Recursive native (host-side) value type.
|
|
163
106
|
* Represents values that can cross the host/script boundary.
|
|
@@ -171,31 +114,25 @@ export type NativePlainObject = {
|
|
|
171
114
|
};
|
|
172
115
|
/** Structured result from toNative conversion */
|
|
173
116
|
export interface NativeResult {
|
|
174
|
-
/** Rill type name
|
|
117
|
+
/** Rill type name -- matches RillTypeName, or 'iterator' for lazy sequences */
|
|
175
118
|
rillTypeName: string;
|
|
176
119
|
/** Human-readable type signature, e.g. "string", "list(number)", "|x: number| :string" */
|
|
177
120
|
rillTypeSignature: string;
|
|
178
121
|
/** Native JS representation. Non-native types produce descriptor objects. */
|
|
179
122
|
value: NativeValue;
|
|
180
123
|
}
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
export declare function valueToJSON(value: RillValue): unknown;
|
|
124
|
+
/** Serialize a Rill value for JSON transport. Delegates to type-registrations. */
|
|
125
|
+
export declare const serializeValue: (value: RillValue) => unknown;
|
|
126
|
+
/** @deprecated Use serializeValue instead. */
|
|
127
|
+
export declare const valueToJSON: (value: RillValue) => unknown;
|
|
186
128
|
/**
|
|
187
129
|
* Convert a RillValue to a NativeResult for host consumption.
|
|
188
130
|
* Non-representable types (closures, vectors, type values, iterators) produce descriptor objects.
|
|
189
131
|
* Tuples convert to native arrays. Ordered values convert to plain objects.
|
|
190
132
|
*/
|
|
191
133
|
export declare function toNative(value: RillValue): NativeResult;
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
* - Primitives: value equality
|
|
195
|
-
* - Tuples: length + recursive element equality
|
|
196
|
-
* - Dicts: same keys + recursive value equality (order-independent)
|
|
197
|
-
*/
|
|
198
|
-
export declare function deepEquals(a: RillValue, b: RillValue): boolean;
|
|
134
|
+
/** Deep structural equality for all Rill values. Delegates to type-registrations. */
|
|
135
|
+
export declare const deepEquals: (a: RillValue, b: RillValue) => boolean;
|
|
199
136
|
/** Reserved dict method names that cannot be overridden */
|
|
200
137
|
export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries"];
|
|
201
138
|
/**
|
|
@@ -204,25 +141,26 @@ export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries
|
|
|
204
141
|
*/
|
|
205
142
|
export declare const anyTypeValue: RillTypeValue;
|
|
206
143
|
/**
|
|
207
|
-
* Convert a
|
|
208
|
-
* Uses the
|
|
144
|
+
* Convert a TypeStructure descriptor to a RillTypeValue.
|
|
145
|
+
* Uses the TypeStructure's `kind` field as the `typeName`.
|
|
209
146
|
* Falls back to 'any' for compound types that lack a direct RillTypeName mapping.
|
|
210
147
|
*/
|
|
211
|
-
export declare function
|
|
212
|
-
/**
|
|
213
|
-
export declare
|
|
148
|
+
export declare function structureToTypeValue(type: TypeStructure): RillTypeValue;
|
|
149
|
+
/** @deprecated Use structureToTypeValue instead. */
|
|
150
|
+
export declare const rillTypeToTypeValue: typeof structureToTypeValue;
|
|
214
151
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* - next: callable - function to get next iterator
|
|
219
|
-
* - value: any (only required when not done) - current element
|
|
152
|
+
* Check if a type is a collection (dict, ordered, tuple) with defined
|
|
153
|
+
* fields or elements. Used to decide if an empty collection can be
|
|
154
|
+
* synthesized and hydrated.
|
|
220
155
|
*/
|
|
221
|
-
export
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
156
|
+
export declare function hasCollectionFields(type: TypeStructure): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Create an empty collection value matching the given TypeStructure.
|
|
159
|
+
* Assumes the type is dict, ordered, or tuple.
|
|
160
|
+
*/
|
|
161
|
+
export declare function emptyForType(type: TypeStructure): RillValue;
|
|
162
|
+
/** Check if a key name is reserved */
|
|
163
|
+
export declare function isReservedMethod(name: string): boolean;
|
|
226
164
|
/**
|
|
227
165
|
* Type guard for Rill iterator (lazy sequence).
|
|
228
166
|
* An iterator is a dict with:
|
|
@@ -230,6 +168,10 @@ export interface RillIterator extends Record<string, RillValue> {
|
|
|
230
168
|
* - next: callable - function to get next iterator
|
|
231
169
|
* - value: any (only required when not done) - current element
|
|
232
170
|
*/
|
|
233
|
-
export declare function
|
|
234
|
-
|
|
235
|
-
|
|
171
|
+
export declare function isIterator(value: RillValue): value is RillIterator;
|
|
172
|
+
/** @deprecated Use isIterator instead. */
|
|
173
|
+
export declare const isRillIterator: typeof isIterator;
|
|
174
|
+
/** Copy a RillValue. Delegates to type-registrations. */
|
|
175
|
+
export declare const copyValue: (value: RillValue) => RillValue;
|
|
176
|
+
/** @deprecated Use copyValue instead. */
|
|
177
|
+
export declare const deepCopyRillValue: (value: RillValue) => RillValue;
|