@rcrsr/rill 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -8
- package/dist/check/config.d.ts +20 -0
- package/dist/check/config.d.ts.map +1 -0
- package/dist/check/config.js +151 -0
- package/dist/check/config.js.map +1 -0
- package/dist/check/fixer.d.ts +39 -0
- package/dist/check/fixer.d.ts.map +1 -0
- package/dist/check/fixer.js +119 -0
- package/dist/check/fixer.js.map +1 -0
- package/dist/check/index.d.ts +10 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +21 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/rules/anti-patterns.d.ts +65 -0
- package/dist/check/rules/anti-patterns.d.ts.map +1 -0
- package/dist/check/rules/anti-patterns.js +427 -0
- package/dist/check/rules/anti-patterns.js.map +1 -0
- package/dist/check/rules/closures.d.ts +66 -0
- package/dist/check/rules/closures.d.ts.map +1 -0
- package/dist/check/rules/closures.js +373 -0
- package/dist/check/rules/closures.js.map +1 -0
- package/dist/check/rules/collections.d.ts +90 -0
- package/dist/check/rules/collections.d.ts.map +1 -0
- package/dist/check/rules/collections.js +373 -0
- package/dist/check/rules/collections.js.map +1 -0
- package/dist/check/rules/conditionals.d.ts +41 -0
- package/dist/check/rules/conditionals.d.ts.map +1 -0
- package/dist/check/rules/conditionals.js +106 -0
- package/dist/check/rules/conditionals.js.map +1 -0
- package/dist/check/rules/flow.d.ts +46 -0
- package/dist/check/rules/flow.d.ts.map +1 -0
- package/dist/check/rules/flow.js +206 -0
- package/dist/check/rules/flow.js.map +1 -0
- package/dist/check/rules/formatting.d.ts +133 -0
- package/dist/check/rules/formatting.d.ts.map +1 -0
- package/dist/check/rules/formatting.js +639 -0
- package/dist/check/rules/formatting.js.map +1 -0
- package/dist/check/rules/helpers.d.ts +26 -0
- package/dist/check/rules/helpers.d.ts.map +1 -0
- package/dist/check/rules/helpers.js +66 -0
- package/dist/check/rules/helpers.js.map +1 -0
- package/dist/check/rules/index.d.ts +21 -0
- package/dist/check/rules/index.d.ts.map +1 -0
- package/dist/check/rules/index.js +78 -0
- package/dist/check/rules/index.js.map +1 -0
- package/dist/check/rules/loops.d.ts +70 -0
- package/dist/check/rules/loops.d.ts.map +1 -0
- package/dist/check/rules/loops.js +227 -0
- package/dist/check/rules/loops.js.map +1 -0
- package/dist/check/rules/naming.d.ts +21 -0
- package/dist/check/rules/naming.d.ts.map +1 -0
- package/dist/check/rules/naming.js +167 -0
- package/dist/check/rules/naming.js.map +1 -0
- package/dist/check/rules/strings.d.ts +28 -0
- package/dist/check/rules/strings.d.ts.map +1 -0
- package/dist/check/rules/strings.js +80 -0
- package/dist/check/rules/strings.js.map +1 -0
- package/dist/check/rules/types.d.ts +41 -0
- package/dist/check/rules/types.d.ts.map +1 -0
- package/dist/check/rules/types.js +162 -0
- package/dist/check/rules/types.js.map +1 -0
- package/dist/check/types.d.ts +106 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +6 -0
- package/dist/check/types.js.map +1 -0
- package/dist/check/validator.d.ts +18 -0
- package/dist/check/validator.d.ts.map +1 -0
- package/dist/check/validator.js +88 -0
- package/dist/check/validator.js.map +1 -0
- package/dist/check/visitor.d.ts +33 -0
- package/dist/check/visitor.d.ts.map +1 -0
- package/dist/check/visitor.js +243 -0
- package/dist/check/visitor.js.map +1 -0
- package/dist/cli-check.d.ts +43 -0
- package/dist/cli-check.d.ts.map +1 -0
- package/dist/cli-check.js +356 -0
- package/dist/cli-check.js.map +1 -0
- package/dist/cli-eval.d.ts +15 -0
- package/dist/cli-eval.d.ts.map +1 -0
- package/dist/cli-eval.js +120 -0
- package/dist/cli-eval.js.map +1 -0
- package/dist/cli-exec.d.ts +49 -0
- package/dist/cli-exec.d.ts.map +1 -0
- package/dist/cli-exec.js +191 -0
- package/dist/cli-exec.js.map +1 -0
- package/dist/cli-module-loader.d.ts +19 -0
- package/dist/cli-module-loader.d.ts.map +1 -0
- package/dist/cli-module-loader.js +83 -0
- package/dist/cli-module-loader.js.map +1 -0
- package/dist/cli-shared.d.ts +36 -0
- package/dist/cli-shared.d.ts.map +1 -0
- package/dist/cli-shared.js +101 -0
- package/dist/cli-shared.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexer/readers.d.ts +1 -1
- package/dist/lexer/readers.d.ts.map +1 -1
- package/dist/lexer/readers.js +62 -32
- package/dist/lexer/readers.js.map +1 -1
- package/dist/lexer/tokenizer.d.ts.map +1 -1
- package/dist/lexer/tokenizer.js +5 -6
- package/dist/lexer/tokenizer.js.map +1 -1
- package/dist/parser/index.js +1 -1
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/parser-expr.js +23 -5
- package/dist/parser/parser-expr.js.map +1 -1
- package/dist/parser/parser-functions.d.ts +2 -2
- package/dist/parser/parser-functions.d.ts.map +1 -1
- package/dist/parser/parser-functions.js +2 -1
- package/dist/parser/parser-functions.js.map +1 -1
- package/dist/parser/parser-literals.js +2 -2
- package/dist/parser/parser-literals.js.map +1 -1
- package/dist/parser/parser-script.js +9 -7
- package/dist/parser/parser-script.js.map +1 -1
- package/dist/parser/parser-variables.js +4 -3
- package/dist/parser/parser-variables.js.map +1 -1
- package/dist/runtime/core/callable.d.ts +5 -6
- package/dist/runtime/core/callable.d.ts.map +1 -1
- package/dist/runtime/core/callable.js.map +1 -1
- package/dist/runtime/core/context.d.ts.map +1 -1
- package/dist/runtime/core/context.js +19 -32
- package/dist/runtime/core/context.js.map +1 -1
- package/dist/runtime/core/equals.js +1 -1
- package/dist/runtime/core/equals.js.map +1 -1
- package/dist/runtime/core/eval/evaluator.d.ts +78 -0
- package/dist/runtime/core/eval/evaluator.d.ts.map +1 -1
- package/dist/runtime/core/eval/evaluator.js +78 -0
- package/dist/runtime/core/eval/evaluator.js.map +1 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -1
- package/dist/runtime/core/eval/mixins/closures.js +9 -1
- package/dist/runtime/core/eval/mixins/closures.js.map +1 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +1 -1
- package/dist/runtime/core/eval/mixins/variables.js +143 -2
- package/dist/runtime/core/eval/mixins/variables.js.map +1 -1
- package/dist/runtime/core/types.d.ts +15 -2
- package/dist/runtime/core/types.d.ts.map +1 -1
- package/dist/runtime/core/types.js.map +1 -1
- package/dist/runtime/ext/extensions.d.ts +51 -0
- package/dist/runtime/ext/extensions.d.ts.map +1 -0
- package/dist/runtime/ext/extensions.js +67 -0
- package/dist/runtime/ext/extensions.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -4
- package/dist/types.js.map +1 -1
- package/docs/00_INDEX.md +1 -0
- package/docs/01_guide.md +3 -3
- package/docs/02_types.md +8 -10
- package/docs/03_variables.md +10 -0
- package/docs/04_operators.md +3 -3
- package/docs/05_control-flow.md +21 -0
- package/docs/07_collections.md +2 -0
- package/docs/10_parsing.md +9 -9
- package/docs/11_reference.md +1 -1
- package/docs/12_examples.md +36 -62
- package/docs/14_host-integration.md +116 -111
- package/docs/15_grammar.ebnf +1 -5
- package/docs/16_conventions.md +3 -4
- package/docs/17_cli-tools.md +184 -0
- package/docs/99_llm-reference.txt +46 -5
- package/package.json +13 -4
- package/dist/demo.d.ts +0 -6
- package/dist/demo.d.ts.map +0 -1
- package/dist/demo.js +0 -121
- package/dist/demo.js.map +0 -1
- package/dist/lexer.d.ts +0 -19
- package/dist/lexer.d.ts.map +0 -1
- package/dist/lexer.js +0 -344
- package/dist/lexer.js.map +0 -1
- package/dist/parser/arithmetic.d.ts +0 -16
- package/dist/parser/arithmetic.d.ts.map +0 -1
- package/dist/parser/arithmetic.js +0 -128
- package/dist/parser/arithmetic.js.map +0 -1
- package/dist/parser/boolean.d.ts +0 -15
- package/dist/parser/boolean.d.ts.map +0 -1
- package/dist/parser/boolean.js +0 -20
- package/dist/parser/boolean.js.map +0 -1
- package/dist/parser/control-flow.d.ts +0 -56
- package/dist/parser/control-flow.d.ts.map +0 -1
- package/dist/parser/control-flow.js +0 -167
- package/dist/parser/control-flow.js.map +0 -1
- package/dist/parser/expressions.d.ts +0 -23
- package/dist/parser/expressions.d.ts.map +0 -1
- package/dist/parser/expressions.js +0 -950
- package/dist/parser/expressions.js.map +0 -1
- package/dist/parser/extraction.d.ts +0 -48
- package/dist/parser/extraction.d.ts.map +0 -1
- package/dist/parser/extraction.js +0 -279
- package/dist/parser/extraction.js.map +0 -1
- package/dist/parser/functions.d.ts +0 -20
- package/dist/parser/functions.d.ts.map +0 -1
- package/dist/parser/functions.js +0 -96
- package/dist/parser/functions.js.map +0 -1
- package/dist/parser/literals.d.ts +0 -37
- package/dist/parser/literals.d.ts.map +0 -1
- package/dist/parser/literals.js +0 -373
- package/dist/parser/literals.js.map +0 -1
- package/dist/parser/script.d.ts +0 -14
- package/dist/parser/script.d.ts.map +0 -1
- package/dist/parser/script.js +0 -196
- package/dist/parser/script.js.map +0 -1
- package/dist/parser/variables.d.ts +0 -10
- package/dist/parser/variables.d.ts.map +0 -1
- package/dist/parser/variables.js +0 -215
- package/dist/parser/variables.js.map +0 -1
- package/dist/runtime/ast-equals.d.ts +0 -13
- package/dist/runtime/ast-equals.d.ts.map +0 -1
- package/dist/runtime/ast-equals.js +0 -447
- package/dist/runtime/ast-equals.js.map +0 -1
- package/dist/runtime/builtins.d.ts +0 -13
- package/dist/runtime/builtins.d.ts.map +0 -1
- package/dist/runtime/builtins.js +0 -180
- package/dist/runtime/builtins.js.map +0 -1
- package/dist/runtime/callable.d.ts +0 -88
- package/dist/runtime/callable.d.ts.map +0 -1
- package/dist/runtime/callable.js +0 -98
- package/dist/runtime/callable.js.map +0 -1
- package/dist/runtime/context.d.ts +0 -13
- package/dist/runtime/context.d.ts.map +0 -1
- package/dist/runtime/context.js +0 -73
- package/dist/runtime/context.js.map +0 -1
- package/dist/runtime/core/evaluate.d.ts +0 -42
- package/dist/runtime/core/evaluate.d.ts.map +0 -1
- package/dist/runtime/core/evaluate.debug.js +0 -1251
- package/dist/runtime/core/evaluate.js +0 -1913
- package/dist/runtime/core/evaluate.js.map +0 -1
- package/dist/runtime/evaluate.d.ts +0 -32
- package/dist/runtime/evaluate.d.ts.map +0 -1
- package/dist/runtime/evaluate.js +0 -1111
- package/dist/runtime/evaluate.js.map +0 -1
- package/dist/runtime/execute.d.ts +0 -26
- package/dist/runtime/execute.d.ts.map +0 -1
- package/dist/runtime/execute.js +0 -121
- package/dist/runtime/execute.js.map +0 -1
- package/dist/runtime/signals.d.ts +0 -19
- package/dist/runtime/signals.d.ts.map +0 -1
- package/dist/runtime/signals.js +0 -26
- package/dist/runtime/signals.js.map +0 -1
- package/dist/runtime/types.d.ts +0 -169
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/types.js +0 -50
- package/dist/runtime/types.js.map +0 -1
- package/dist/runtime/values.d.ts +0 -50
- package/dist/runtime/values.d.ts.map +0 -1
- package/dist/runtime/values.js +0 -209
- package/dist/runtime/values.js.map +0 -1
- package/dist/runtime.d.ts +0 -254
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -2014
- package/dist/runtime.js.map +0 -1
package/dist/cli-exec.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI Execution Entry Point
|
|
4
|
+
*
|
|
5
|
+
* Implements main(), parseArgs(), and executeScript() for rill-exec and rill-eval binaries.
|
|
6
|
+
* Handles file execution, stdin input, and module loading.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'fs/promises';
|
|
9
|
+
import * as fsSync from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import * as yaml from 'yaml';
|
|
12
|
+
import { parse, execute, createRuntimeContext } from './index.js';
|
|
13
|
+
import { formatOutput, formatError, determineExitCode } from './cli-shared.js';
|
|
14
|
+
import { loadModule } from './cli-module-loader.js';
|
|
15
|
+
/**
|
|
16
|
+
* Parse command-line arguments into structured command
|
|
17
|
+
*
|
|
18
|
+
* @param argv - Raw command-line arguments (typically process.argv.slice(2))
|
|
19
|
+
* @returns Parsed command object
|
|
20
|
+
*/
|
|
21
|
+
export function parseArgs(argv) {
|
|
22
|
+
// Check for --help or --version flags in any position
|
|
23
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
24
|
+
return { mode: 'help' };
|
|
25
|
+
}
|
|
26
|
+
if (argv.includes('--version') || argv.includes('-v')) {
|
|
27
|
+
return { mode: 'version' };
|
|
28
|
+
}
|
|
29
|
+
// Check for unknown flags
|
|
30
|
+
for (const arg of argv) {
|
|
31
|
+
if (arg.startsWith('--') && arg !== '--help' && arg !== '--version') {
|
|
32
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
33
|
+
}
|
|
34
|
+
if (arg.startsWith('-') && arg !== '-' && arg !== '-h' && arg !== '-v') {
|
|
35
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Determine mode from first positional argument
|
|
39
|
+
const firstArg = argv[0];
|
|
40
|
+
if (!firstArg) {
|
|
41
|
+
throw new Error('Missing file argument');
|
|
42
|
+
}
|
|
43
|
+
// Eval mode is not supported in rill-exec (only rill-eval)
|
|
44
|
+
// This function is shared but context determines valid modes
|
|
45
|
+
if (firstArg === '-e') {
|
|
46
|
+
if (!argv[1]) {
|
|
47
|
+
throw new Error('Missing expression after -e');
|
|
48
|
+
}
|
|
49
|
+
return { mode: 'eval', expression: argv[1] };
|
|
50
|
+
}
|
|
51
|
+
// Exec mode (file or stdin)
|
|
52
|
+
const file = firstArg;
|
|
53
|
+
const args = argv.slice(1);
|
|
54
|
+
return { mode: 'exec', file, args };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Execute a Rill script file with arguments and module support
|
|
58
|
+
*
|
|
59
|
+
* @param file - File path or '-' for stdin
|
|
60
|
+
* @param args - Command-line arguments to pass as $ pipe value
|
|
61
|
+
* @param options - Execution options
|
|
62
|
+
* @returns Execution result with value and variables
|
|
63
|
+
* @throws Error if file not found or execution fails
|
|
64
|
+
*/
|
|
65
|
+
export async function executeScript(file, args, options) {
|
|
66
|
+
// Read source from file or stdin
|
|
67
|
+
let source;
|
|
68
|
+
let scriptPath;
|
|
69
|
+
if (file === '-' || options?.stdin) {
|
|
70
|
+
// Read from stdin (must use sync API for stdin)
|
|
71
|
+
source = fsSync.readFileSync(0, 'utf-8');
|
|
72
|
+
scriptPath = path.resolve(process.cwd(), '<stdin>');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Check if file exists
|
|
76
|
+
try {
|
|
77
|
+
await fs.access(file);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new Error(`File not found: ${file}`);
|
|
81
|
+
}
|
|
82
|
+
// Read from file
|
|
83
|
+
source = await fs.readFile(file, 'utf-8');
|
|
84
|
+
scriptPath = path.resolve(file);
|
|
85
|
+
}
|
|
86
|
+
// Parse the script
|
|
87
|
+
const ast = parse(source);
|
|
88
|
+
// Extract frontmatter for use: declarations
|
|
89
|
+
const frontmatter = ast.frontmatter
|
|
90
|
+
? (yaml.parse(ast.frontmatter.content) ?? {})
|
|
91
|
+
: {};
|
|
92
|
+
// Load modules if use: declarations exist
|
|
93
|
+
const variables = {};
|
|
94
|
+
if (frontmatter['use'] && Array.isArray(frontmatter['use'])) {
|
|
95
|
+
const cache = new Map();
|
|
96
|
+
for (const entry of frontmatter['use']) {
|
|
97
|
+
if (typeof entry === 'object' && entry !== null) {
|
|
98
|
+
const [name, modulePath] = Object.entries(entry)[0];
|
|
99
|
+
variables[name] = await loadModule(modulePath, scriptPath, cache);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Create runtime context with modules
|
|
104
|
+
const ctx = createRuntimeContext({
|
|
105
|
+
variables,
|
|
106
|
+
callbacks: {
|
|
107
|
+
onLog: (value) => console.log(formatOutput(value)),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
// Set pipe value to arguments (string array)
|
|
111
|
+
ctx.pipeValue = args;
|
|
112
|
+
// Execute the script
|
|
113
|
+
return await execute(ast, ctx);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Entry point for rill-exec and rill-eval binaries
|
|
117
|
+
*
|
|
118
|
+
* Parses command-line arguments, executes scripts, and handles errors.
|
|
119
|
+
* Writes results to stdout and errors to stderr.
|
|
120
|
+
* Sets process.exit(1) on any error.
|
|
121
|
+
*/
|
|
122
|
+
export async function main() {
|
|
123
|
+
try {
|
|
124
|
+
const parsed = parseArgs(process.argv.slice(2));
|
|
125
|
+
switch (parsed.mode) {
|
|
126
|
+
case 'help':
|
|
127
|
+
console.log(`Usage:
|
|
128
|
+
rill-exec <script.rill> [args...] Execute a Rill script file
|
|
129
|
+
rill-exec - Read script from stdin
|
|
130
|
+
rill-exec --help Show this help message
|
|
131
|
+
rill-exec --version Show version information
|
|
132
|
+
|
|
133
|
+
Arguments:
|
|
134
|
+
args are passed to the script as a list of strings in $ (pipe value)
|
|
135
|
+
|
|
136
|
+
Examples:
|
|
137
|
+
rill-exec script.rill
|
|
138
|
+
rill-exec script.rill arg1 arg2
|
|
139
|
+
echo "log(\\"hello\\")" | rill-exec -`);
|
|
140
|
+
return;
|
|
141
|
+
case 'version': {
|
|
142
|
+
// Read version from package.json
|
|
143
|
+
const packageJsonPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), '../package.json');
|
|
144
|
+
try {
|
|
145
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
|
|
146
|
+
console.log(packageJson.version);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
console.log('0.1.0'); // Fallback version
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
case 'eval':
|
|
154
|
+
// This shouldn't happen in rill-exec, but handle it anyway
|
|
155
|
+
console.error('Eval mode not supported in rill-exec. Use rill-eval instead.');
|
|
156
|
+
process.exit(1);
|
|
157
|
+
return;
|
|
158
|
+
case 'exec': {
|
|
159
|
+
// Execute mode
|
|
160
|
+
const result = await executeScript(parsed.file, parsed.args);
|
|
161
|
+
const { code, message } = determineExitCode(result.value);
|
|
162
|
+
// Output message if present, otherwise output the result value
|
|
163
|
+
if (message !== undefined) {
|
|
164
|
+
console.log(message);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log(formatOutput(result.value));
|
|
168
|
+
}
|
|
169
|
+
// Exit with computed code
|
|
170
|
+
process.exit(code);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
if (err instanceof Error) {
|
|
176
|
+
console.error(formatError(err));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.error(formatError(new Error(String(err))));
|
|
180
|
+
}
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Only run main if not in test environment
|
|
185
|
+
const shouldRunMain = process.env['NODE_ENV'] !== 'test' &&
|
|
186
|
+
!process.env['VITEST'] &&
|
|
187
|
+
!process.env['VITEST_WORKER_ID'];
|
|
188
|
+
if (shouldRunMain) {
|
|
189
|
+
main();
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=cli-exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-exec.js","sourceRoot":"","sources":["../src/cli-exec.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,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
|
5
|
+
* See docs/13_modules.md for module convention specification.
|
|
6
|
+
*/
|
|
7
|
+
import type { RillValue } from './runtime/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Load a module and its dependencies recursively.
|
|
10
|
+
*
|
|
11
|
+
* @param specifier - Module path (relative or absolute)
|
|
12
|
+
* @param fromPath - Path of the importing file
|
|
13
|
+
* @param cache - Module cache keyed by canonical path
|
|
14
|
+
* @param chain - Set of paths in current import chain for circular detection
|
|
15
|
+
* @returns Dict of exported values
|
|
16
|
+
* @throws Error if module not found or circular dependency detected
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadModule(specifier: string, fromPath: string, cache: Map<string, Record<string, RillValue>>, chain?: Set<string>): Promise<Record<string, RillValue>>;
|
|
19
|
+
//# sourceMappingURL=cli-module-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module-loader.d.ts","sourceRoot":"","sources":["../src/cli-module-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAC7C,KAAK,GAAE,GAAG,CAAC,MAAM,CAAa,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAuEpC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Module Loader
|
|
3
|
+
*
|
|
4
|
+
* Implements module loading for the Rill CLI with circular dependency detection.
|
|
5
|
+
* See docs/13_modules.md for module convention specification.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs/promises';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import * as yaml from 'yaml';
|
|
10
|
+
import { parse } from './parser/index.js';
|
|
11
|
+
import { execute, createRuntimeContext } from './runtime/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Load a module and its dependencies recursively.
|
|
14
|
+
*
|
|
15
|
+
* @param specifier - Module path (relative or absolute)
|
|
16
|
+
* @param fromPath - Path of the importing file
|
|
17
|
+
* @param cache - Module cache keyed by canonical path
|
|
18
|
+
* @param chain - Set of paths in current import chain for circular detection
|
|
19
|
+
* @returns Dict of exported values
|
|
20
|
+
* @throws Error if module not found or circular dependency detected
|
|
21
|
+
*/
|
|
22
|
+
export async function loadModule(specifier, fromPath, cache, chain = new Set()) {
|
|
23
|
+
// Resolve to absolute canonical path
|
|
24
|
+
const absolutePath = path.resolve(path.dirname(fromPath), specifier);
|
|
25
|
+
// Check for circular dependency
|
|
26
|
+
if (chain.has(absolutePath)) {
|
|
27
|
+
const cycle = [...chain, absolutePath].join(' -> ');
|
|
28
|
+
throw new Error(`Circular dependency detected: ${cycle}`);
|
|
29
|
+
}
|
|
30
|
+
// Return cached module if already loaded
|
|
31
|
+
if (cache.has(absolutePath)) {
|
|
32
|
+
return cache.get(absolutePath);
|
|
33
|
+
}
|
|
34
|
+
// Check if module file exists
|
|
35
|
+
try {
|
|
36
|
+
await fs.access(absolutePath);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new Error(`Module not found: ${specifier}`);
|
|
40
|
+
}
|
|
41
|
+
// Add to chain to detect cycles in dependencies
|
|
42
|
+
chain.add(absolutePath);
|
|
43
|
+
try {
|
|
44
|
+
// Load and parse module source
|
|
45
|
+
const source = await fs.readFile(absolutePath, 'utf-8');
|
|
46
|
+
const ast = parse(source);
|
|
47
|
+
// Extract frontmatter (yaml.parse returns null for empty content)
|
|
48
|
+
const frontmatter = ast.frontmatter
|
|
49
|
+
? (yaml.parse(ast.frontmatter.content) ?? {})
|
|
50
|
+
: {};
|
|
51
|
+
// Resolve dependencies first
|
|
52
|
+
const imports = {};
|
|
53
|
+
if (frontmatter['use'] && Array.isArray(frontmatter['use'])) {
|
|
54
|
+
for (const entry of frontmatter['use']) {
|
|
55
|
+
if (typeof entry === 'object' && entry !== null) {
|
|
56
|
+
const [name, depPath] = Object.entries(entry)[0];
|
|
57
|
+
imports[name] = await loadModule(depPath, absolutePath, cache, chain);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Execute module with dependencies
|
|
62
|
+
const ctx = createRuntimeContext({ variables: imports });
|
|
63
|
+
const result = await execute(ast, ctx);
|
|
64
|
+
// Extract exports
|
|
65
|
+
const exports = {};
|
|
66
|
+
const exportList = frontmatter['export'];
|
|
67
|
+
if (Array.isArray(exportList)) {
|
|
68
|
+
for (const name of exportList) {
|
|
69
|
+
if (typeof name === 'string' && result.variables[name] !== undefined) {
|
|
70
|
+
exports[name] = result.variables[name];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Cache and return
|
|
75
|
+
cache.set(absolutePath, exports);
|
|
76
|
+
return exports;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
// Remove from chain after processing
|
|
80
|
+
chain.delete(absolutePath);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=cli-module-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module-loader.js","sourceRoot":"","sources":["../src/cli-module-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGnE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,SAA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C;YAAS,CAAC;QACT,qCAAqC;QACrC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Shared Utilities
|
|
3
|
+
* Common formatting functions for CLI tools
|
|
4
|
+
*/
|
|
5
|
+
import type { RillValue } from './runtime/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Convert execution result to human-readable string
|
|
8
|
+
*
|
|
9
|
+
* @param value - The value to format
|
|
10
|
+
* @returns Formatted string representation
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatOutput(value: RillValue): string;
|
|
13
|
+
/**
|
|
14
|
+
* Format error for stderr output
|
|
15
|
+
*
|
|
16
|
+
* @param err - The error to format
|
|
17
|
+
* @returns Formatted error message
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatError(err: Error): string;
|
|
20
|
+
/**
|
|
21
|
+
* Determine exit code from script result
|
|
22
|
+
*
|
|
23
|
+
* Implements exit code semantics per language spec:
|
|
24
|
+
* - true / non-empty string: exit 0
|
|
25
|
+
* - false / empty string: exit 1
|
|
26
|
+
* - [0, "message"]: exit 0 with message
|
|
27
|
+
* - [1, "message"]: exit 1 with message
|
|
28
|
+
*
|
|
29
|
+
* @param value - The script return value
|
|
30
|
+
* @returns Exit code and optional message
|
|
31
|
+
*/
|
|
32
|
+
export declare function determineExitCode(value: RillValue): {
|
|
33
|
+
code: number;
|
|
34
|
+
message?: string;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=cli-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-shared.d.ts","sourceRoot":"","sources":["../src/cli-shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAQrD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAkC9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAgCA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Shared Utilities
|
|
3
|
+
* Common formatting functions for CLI tools
|
|
4
|
+
*/
|
|
5
|
+
import { isCallable } from './runtime/index.js';
|
|
6
|
+
import { ParseError, RuntimeError } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Convert execution result to human-readable string
|
|
9
|
+
*
|
|
10
|
+
* @param value - The value to format
|
|
11
|
+
* @returns Formatted string representation
|
|
12
|
+
*/
|
|
13
|
+
export function formatOutput(value) {
|
|
14
|
+
if (value === null)
|
|
15
|
+
return 'null';
|
|
16
|
+
if (typeof value === 'string')
|
|
17
|
+
return value;
|
|
18
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
19
|
+
return String(value);
|
|
20
|
+
}
|
|
21
|
+
if (isCallable(value))
|
|
22
|
+
return '[closure]';
|
|
23
|
+
return JSON.stringify(value, null, 2);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format error for stderr output
|
|
27
|
+
*
|
|
28
|
+
* @param err - The error to format
|
|
29
|
+
* @returns Formatted error message
|
|
30
|
+
*/
|
|
31
|
+
export function formatError(err) {
|
|
32
|
+
if (err instanceof ParseError) {
|
|
33
|
+
const location = err.location;
|
|
34
|
+
if (location) {
|
|
35
|
+
return `Parse error at line ${location.line}: ${err.message.replace(/ at \d+:\d+$/, '')}`;
|
|
36
|
+
}
|
|
37
|
+
return `Parse error: ${err.message}`;
|
|
38
|
+
}
|
|
39
|
+
if (err instanceof RuntimeError) {
|
|
40
|
+
const location = err.location;
|
|
41
|
+
const baseMessage = err.message.replace(/ at \d+:\d+$/, '');
|
|
42
|
+
if (location) {
|
|
43
|
+
return `Runtime error at line ${location.line}: ${baseMessage} (${err.code})`;
|
|
44
|
+
}
|
|
45
|
+
return `Runtime error: ${baseMessage} (${err.code})`;
|
|
46
|
+
}
|
|
47
|
+
// Handle file not found errors (ENOENT)
|
|
48
|
+
if (err instanceof Error &&
|
|
49
|
+
'code' in err &&
|
|
50
|
+
err.code === 'ENOENT' &&
|
|
51
|
+
'path' in err) {
|
|
52
|
+
return `File not found: ${err.path}`;
|
|
53
|
+
}
|
|
54
|
+
// Handle module errors
|
|
55
|
+
if (err.message.includes('Cannot find module')) {
|
|
56
|
+
return `Module error: ${err.message}`;
|
|
57
|
+
}
|
|
58
|
+
return err.message;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Determine exit code from script result
|
|
62
|
+
*
|
|
63
|
+
* Implements exit code semantics per language spec:
|
|
64
|
+
* - true / non-empty string: exit 0
|
|
65
|
+
* - false / empty string: exit 1
|
|
66
|
+
* - [0, "message"]: exit 0 with message
|
|
67
|
+
* - [1, "message"]: exit 1 with message
|
|
68
|
+
*
|
|
69
|
+
* @param value - The script return value
|
|
70
|
+
* @returns Exit code and optional message
|
|
71
|
+
*/
|
|
72
|
+
export function determineExitCode(value) {
|
|
73
|
+
// Handle tuple format: [code, message]
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
if (value.length >= 2) {
|
|
76
|
+
const code = value[0];
|
|
77
|
+
const message = value[1];
|
|
78
|
+
// Validate code is 0 or 1
|
|
79
|
+
if (typeof code === 'number' && (code === 0 || code === 1)) {
|
|
80
|
+
// Return with message if provided as string
|
|
81
|
+
if (typeof message === 'string' && message !== '') {
|
|
82
|
+
return { code, message };
|
|
83
|
+
}
|
|
84
|
+
return { code };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Non-conforming array: treat as truthy (exit 0)
|
|
88
|
+
return { code: 0 };
|
|
89
|
+
}
|
|
90
|
+
// Boolean values
|
|
91
|
+
if (typeof value === 'boolean') {
|
|
92
|
+
return { code: value ? 0 : 1 };
|
|
93
|
+
}
|
|
94
|
+
// String values
|
|
95
|
+
if (typeof value === 'string') {
|
|
96
|
+
return { code: value === '' ? 1 : 0 };
|
|
97
|
+
}
|
|
98
|
+
// All other values (number, dict, closure, etc.) are truthy: exit 0
|
|
99
|
+
return { code: 0 };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=cli-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-shared.js","sourceRoot":"","sources":["../src/cli-shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAU;IACpC,IAAI,GAAG,YAAY,UAAU,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,uBAAuB,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,OA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;YAC1B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC3D,4CAA4C;gBAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;oBAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC3B,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,iDAAiD;QACjD,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACrB,CAAC;IAED,iBAAiB;IACjB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC,CAAC;IAED,gBAAgB;IAChB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,CAAC;IAED,oEAAoE;IACpE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACrB,CAAC"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|
package/dist/cli.js
CHANGED
|
@@ -2,23 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Rill CLI - Run rill scripts from the command line
|
|
4
4
|
*
|
|
5
|
+
* @deprecated Use rill-exec or rill-eval commands instead. This file will be removed in v1.0.
|
|
6
|
+
*
|
|
5
7
|
* Usage:
|
|
6
8
|
* npx tsx src/cli.ts <script.rill>
|
|
7
9
|
* npx tsx src/cli.ts -e "code"
|
|
8
10
|
* echo "code" | npx tsx src/cli.ts -
|
|
9
11
|
*/
|
|
10
12
|
import * as fs from 'fs';
|
|
11
|
-
import { createRuntimeContext, execute, parse
|
|
12
|
-
|
|
13
|
-
if (value === null)
|
|
14
|
-
return 'null';
|
|
15
|
-
if (typeof value === 'string')
|
|
16
|
-
return value;
|
|
17
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
18
|
-
return String(value);
|
|
19
|
-
}
|
|
20
|
-
return JSON.stringify(value, null, 2);
|
|
21
|
-
}
|
|
13
|
+
import { createRuntimeContext, execute, parse } from './index.js';
|
|
14
|
+
import { formatOutput } from './cli-shared.js';
|
|
22
15
|
async function run(source) {
|
|
23
16
|
const ctx = createRuntimeContext({
|
|
24
17
|
callbacks: {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,KAAK,UAAU,GAAG,CAAC,MAAc;IAC/B,MAAM,GAAG,GAAG,oBAAoB,CAAC;QAC/B,SAAS,EAAE;YACT,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SACnD;KACF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,GAAG,GAAG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,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
export { LexerError, tokenize } from './lexer/index.js';
|
|
6
6
|
export { parse, parseWithRecovery } from './parser/index.js';
|
|
7
7
|
export type { ParseResult, ErrorNode } from './types.js';
|
|
8
|
-
export { type ApplicationCallable, BreakSignal, callable, type CallableFn, type CaptureEvent, createRuntimeContext, createStepper, type ErrorEvent, execute, type ExecutionResult, type ExecutionStepper, type HostCallEvent, type HostFunctionDefinition, type HostFunctionParam, type FunctionReturnEvent, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, type ObservabilityCallbacks, RESERVED_DICT_METHODS, ReturnSignal, type RillTuple, type RillCallable, type RillValue, type RuntimeCallable, type RuntimeCallbacks, type RuntimeContext, type RuntimeOptions, type ScriptCallable, type StepEndEvent, type StepResult, type StepStartEvent, validateHostFunctionArgs, } from './runtime/index.js';
|
|
8
|
+
export { type ApplicationCallable, BreakSignal, callable, type CallableFn, type CaptureEvent, createRuntimeContext, createStepper, emitExtensionEvent, type ErrorEvent, execute, type ExecutionResult, type ExecutionStepper, type ExtensionEvent, type ExtensionFactory, type ExtensionResult, type HostCallEvent, type HostFunctionDefinition, type HostFunctionParam, type FunctionReturnEvent, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, type ObservabilityCallbacks, prefixFunctions, RESERVED_DICT_METHODS, ReturnSignal, type RillTuple, type RillCallable, type RillValue, type RuntimeCallable, type RuntimeCallbacks, type RuntimeContext, type RuntimeOptions, type ScriptCallable, type StepEndEvent, type StepResult, type StepStartEvent, validateHostFunctionArgs, } from './runtime/index.js';
|
|
9
9
|
export * from './types.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EACxB,WAAW,EACX,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,oBAAoB,EACpB,aAAa,EACb,KAAK,UAAU,EACf,OAAO,EACP,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,qBAAqB,EACrB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EACxB,WAAW,EACX,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,KAAK,UAAU,EACf,OAAO,EACP,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { LexerError, tokenize } from './lexer/index.js';
|
|
6
6
|
export { parse, parseWithRecovery } from './parser/index.js';
|
|
7
|
-
export { BreakSignal, callable, createRuntimeContext, createStepper, execute, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, RESERVED_DICT_METHODS, ReturnSignal, validateHostFunctionArgs, } from './runtime/index.js';
|
|
7
|
+
export { BreakSignal, callable, createRuntimeContext, createStepper, emitExtensionEvent, execute, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, prefixFunctions, RESERVED_DICT_METHODS, ReturnSignal, validateHostFunctionArgs, } from './runtime/index.js';
|
|
8
8
|
export * from './types.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAEL,WAAW,EACX,QAAQ,EAGR,oBAAoB,EACpB,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAEL,WAAW,EACX,QAAQ,EAGR,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAElB,OAAO,EAUP,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAEhB,eAAe,EACf,qBAAqB,EACrB,YAAY,EAYZ,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/lexer/readers.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { Token } from '../types.js';
|
|
6
6
|
import { type LexerState } from './state.js';
|
|
7
7
|
export declare function readString(state: LexerState): Token;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function readTripleQuoteString(state: LexerState): Token;
|
|
9
9
|
export declare function readNumber(state: LexerState): Token;
|
|
10
10
|
export declare function readIdentifier(state: LexerState): Token;
|
|
11
11
|
export declare function readVariable(state: LexerState): Token;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readers.d.ts","sourceRoot":"","sources":["../../src/lexer/readers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"readers.d.ts","sourceRoot":"","sources":["../../src/lexer/readers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAUzC,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAwBpB,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAoCnD;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAkF9D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAgBnD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAUvD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAiBrD"}
|