@valbuild/core 0.13.7 → 0.13.8
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/declarations/src/expr/eval.d.ts +2 -1
- package/dist/{index-b861a6d2.esm.js → index-296cb2b6.esm.js} +4 -2
- package/dist/{index-2f65eaa1.cjs.dev.js → index-9663f28a.cjs.dev.js} +4 -2
- package/dist/{index-104b3b67.cjs.prod.js → index-b2270f8f.cjs.prod.js} +4 -2
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/src/expr/eval.test.ts +2 -5
- package/src/expr/eval.ts +7 -4
- package/src/expr/repl.ts +1 -5
- package/src/selector/selector.test.ts +1 -5
@@ -3,6 +3,7 @@ import { Source } from "../source";
|
|
3
3
|
import { result } from "../fp";
|
4
4
|
import { Path, SourceOrExpr } from "../selector";
|
5
5
|
import { SourcePath } from "../val";
|
6
|
+
import { Json } from "../Json";
|
6
7
|
export declare class EvalError {
|
7
8
|
readonly message: string;
|
8
9
|
readonly expr: Expr;
|
@@ -15,5 +16,5 @@ type LocalSelector<S extends Source> = {
|
|
15
16
|
[SourceOrExpr]: S;
|
16
17
|
[Path]: SourcePath | undefined;
|
17
18
|
};
|
18
|
-
export declare function evaluate(expr: Expr, source: (ref: string) =>
|
19
|
+
export declare function evaluate(expr: Expr, source: (ref: string) => Json, stack: readonly LocalSelector<Source>[][]): result.Result<LocalSelector<Source>, EvalError>;
|
19
20
|
export {};
|
@@ -844,7 +844,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
844
844
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
845
845
|
}
|
846
846
|
if (expr.children[1] instanceof StringLiteral) {
|
847
|
-
|
847
|
+
var _path = expr.children[1].value;
|
848
|
+
return newSelectorProxy(getSource(_path), _path);
|
848
849
|
} else {
|
849
850
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
850
851
|
}
|
@@ -911,7 +912,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
911
912
|
if (expr.children[0] instanceof Sym) {
|
912
913
|
if (expr.children[0].value === "val") {
|
913
914
|
if (expr.children[1] instanceof StringLiteral) {
|
914
|
-
|
915
|
+
var _path2 = expr.children[1].value;
|
916
|
+
return newSelectorProxy(getSource(_path2), _path2);
|
915
917
|
} else {
|
916
918
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
917
919
|
}
|
@@ -846,7 +846,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
846
846
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
847
847
|
}
|
848
848
|
if (expr.children[1] instanceof StringLiteral) {
|
849
|
-
|
849
|
+
var _path = expr.children[1].value;
|
850
|
+
return newSelectorProxy(getSource(_path), _path);
|
850
851
|
} else {
|
851
852
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
852
853
|
}
|
@@ -913,7 +914,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
913
914
|
if (expr.children[0] instanceof Sym) {
|
914
915
|
if (expr.children[0].value === "val") {
|
915
916
|
if (expr.children[1] instanceof StringLiteral) {
|
916
|
-
|
917
|
+
var _path2 = expr.children[1].value;
|
918
|
+
return newSelectorProxy(getSource(_path2), _path2);
|
917
919
|
} else {
|
918
920
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
919
921
|
}
|
@@ -846,7 +846,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
846
846
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
847
847
|
}
|
848
848
|
if (expr.children[1] instanceof StringLiteral) {
|
849
|
-
|
849
|
+
var _path = expr.children[1].value;
|
850
|
+
return newSelectorProxy(getSource(_path), _path);
|
850
851
|
} else {
|
851
852
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
852
853
|
}
|
@@ -913,7 +914,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
913
914
|
if (expr.children[0] instanceof Sym) {
|
914
915
|
if (expr.children[0].value === "val") {
|
915
916
|
if (expr.children[1] instanceof StringLiteral) {
|
916
|
-
|
917
|
+
var _path2 = expr.children[1].value;
|
918
|
+
return newSelectorProxy(getSource(_path2), _path2);
|
917
919
|
} else {
|
918
920
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
919
921
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('./index-9663f28a.cjs.dev.js');
|
6
6
|
var createClass = require('./createClass-a436dbfe.cjs.dev.js');
|
7
7
|
var result = require('./result-48320acd.cjs.dev.js');
|
8
8
|
var ops = require('./ops-87cdbafc.cjs.dev.js');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('./index-b2270f8f.cjs.prod.js');
|
6
6
|
var createClass = require('./createClass-de7426aa.cjs.prod.js');
|
7
7
|
var result = require('./result-26f67b40.cjs.prod.js');
|
8
8
|
var ops = require('./ops-ae4d1bc2.cjs.prod.js');
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { _ as _inherits, a as _createSuper, S as Schema, g as getValPath, n as newSelectorProxy, b as SourceOrExpr, E as Expr, I as ImageSchema, c as _objectSpread2, d as _defineProperty, V as VAL_EXTENSION, i as image, P as Path, e as createValPathOfItem, f as isSelector, h as isSerializedVal, j as file, k as isFile, F as FILE_REF_PROP, l as convertImageSource, m as getSchema, o as isVal } from './index-
|
2
|
-
export { F as FILE_REF_PROP, G as GenericSelector, S as Schema, V as VAL_EXTENSION, p as expr } from './index-
|
1
|
+
import { _ as _inherits, a as _createSuper, S as Schema, g as getValPath, n as newSelectorProxy, b as SourceOrExpr, E as Expr, I as ImageSchema, c as _objectSpread2, d as _defineProperty, V as VAL_EXTENSION, i as image, P as Path, e as createValPathOfItem, f as isSelector, h as isSerializedVal, j as file, k as isFile, F as FILE_REF_PROP, l as convertImageSource, m as getSchema, o as isVal } from './index-296cb2b6.esm.js';
|
2
|
+
export { F as FILE_REF_PROP, G as GenericSelector, S as Schema, V as VAL_EXTENSION, p as expr } from './index-296cb2b6.esm.js';
|
3
3
|
import { _ as _classCallCheck, a as _createClass, b as _typeof, c as _slicedToArray, d as _toConsumableArray } from './createClass-012eebbf.esm.js';
|
4
4
|
import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok } from './result-b96df128.esm.js';
|
5
5
|
import { P as PatchError } from './ops-6fae92a1.esm.js';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-9663f28a.cjs.dev.js');
|
6
6
|
require('../../dist/createClass-a436dbfe.cjs.dev.js');
|
7
7
|
require('../../dist/result-48320acd.cjs.dev.js');
|
8
8
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-b2270f8f.cjs.prod.js');
|
6
6
|
require('../../dist/createClass-de7426aa.cjs.prod.js');
|
7
7
|
require('../../dist/result-26f67b40.cjs.prod.js');
|
8
8
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { C as Call, E as Expr, N as NilSym, r as StringLiteral, s as StringTemplate, t as Sym, u as evaluate, q as parse } from '../../dist/index-
|
1
|
+
export { C as Call, E as Expr, N as NilSym, r as StringLiteral, s as StringTemplate, t as Sym, u as evaluate, q as parse } from '../../dist/index-296cb2b6.esm.js';
|
2
2
|
import '../../dist/createClass-012eebbf.esm.js';
|
3
3
|
import '../../dist/result-b96df128.esm.js';
|
package/package.json
CHANGED
package/src/expr/eval.test.ts
CHANGED
@@ -186,11 +186,8 @@ describe("eval", () => {
|
|
186
186
|
pipe(
|
187
187
|
evaluate(
|
188
188
|
parseRes.value,
|
189
|
-
(
|
190
|
-
return
|
191
|
-
sources[ref as keyof typeof sources],
|
192
|
-
ref as SourcePath
|
193
|
-
);
|
189
|
+
(path) => {
|
190
|
+
return sources[path as keyof typeof sources];
|
194
191
|
},
|
195
192
|
[]
|
196
193
|
),
|
package/src/expr/eval.ts
CHANGED
@@ -5,6 +5,7 @@ import { result } from "../fp";
|
|
5
5
|
import { Path, SourceOrExpr } from "../selector";
|
6
6
|
import { newSelectorProxy } from "../selector/SelectorProxy";
|
7
7
|
import { isSerializedVal, SourcePath } from "../val";
|
8
|
+
import { Json } from "../Json";
|
8
9
|
|
9
10
|
export class EvalError {
|
10
11
|
constructor(public readonly message: string, public readonly expr: Expr) {}
|
@@ -26,7 +27,7 @@ type LocalSelector<S extends Source> = {
|
|
26
27
|
const MAX_STACK_SIZE = 100; // an arbitrary semi-large number
|
27
28
|
function evaluateSync(
|
28
29
|
expr: Expr,
|
29
|
-
getSource: (
|
30
|
+
getSource: (path: string) => Json,
|
30
31
|
stack: readonly LocalSelector<Source>[][]
|
31
32
|
): LocalSelector<Source> {
|
32
33
|
// TODO: amount of evaluates should be limited?
|
@@ -48,7 +49,8 @@ function evaluateSync(
|
|
48
49
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
49
50
|
}
|
50
51
|
if (expr.children[1] instanceof StringLiteral) {
|
51
|
-
|
52
|
+
const path = expr.children[1].value as SourcePath;
|
53
|
+
return newSelectorProxy(getSource(path), path);
|
52
54
|
} else {
|
53
55
|
throw new EvalError(
|
54
56
|
"argument of 'val' must be a string literal",
|
@@ -148,7 +150,8 @@ function evaluateSync(
|
|
148
150
|
if (expr.children[0] instanceof Sym) {
|
149
151
|
if (expr.children[0].value === "val") {
|
150
152
|
if (expr.children[1] instanceof StringLiteral) {
|
151
|
-
|
153
|
+
const path = expr.children[1].value as SourcePath;
|
154
|
+
return newSelectorProxy(getSource(path), path);
|
152
155
|
} else {
|
153
156
|
throw new EvalError(
|
154
157
|
"argument of 'val' must be a string literal",
|
@@ -234,7 +237,7 @@ function evaluateSync(
|
|
234
237
|
|
235
238
|
export function evaluate(
|
236
239
|
expr: Expr,
|
237
|
-
source: (ref: string) =>
|
240
|
+
source: (ref: string) => Json,
|
238
241
|
stack: readonly LocalSelector<Source>[][]
|
239
242
|
): result.Result<LocalSelector<Source>, EvalError> {
|
240
243
|
try {
|
package/src/expr/repl.ts
CHANGED
@@ -289,11 +289,7 @@ describe("selector", () => {
|
|
289
289
|
const res = evaluate(
|
290
290
|
// @ts-expect-error TODO: fix this
|
291
291
|
input()[SourceOrExpr],
|
292
|
-
(
|
293
|
-
newSelectorProxy(
|
294
|
-
modules[ref as keyof typeof modules],
|
295
|
-
ref as SourcePath
|
296
|
-
),
|
292
|
+
(path) => modules[path as keyof typeof modules],
|
297
293
|
[]
|
298
294
|
);
|
299
295
|
if (result.isErr(res)) {
|