@opencode/codemode 0.0.0-dev-19918 → 0.0.0-dev-19921
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.
|
@@ -28,21 +28,27 @@ const loopExit = (result, labels) => {
|
|
|
28
28
|
return result;
|
|
29
29
|
return undefined;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
// Native engines name the callee (`search(...).catch is not a function`), including call chains. Returns
|
|
32
|
+
// undefined when a link cannot be named, so a chain is either named completely or not at all.
|
|
33
|
+
const calleeDescription = (node) => {
|
|
34
|
+
if (node?.type === "Identifier")
|
|
35
|
+
return node.name;
|
|
36
|
+
if (node?.type === "CallExpression") {
|
|
37
|
+
const target = calleeDescription(node.callee);
|
|
38
|
+
return target === undefined ? undefined : `${target}(...)`;
|
|
39
|
+
}
|
|
40
|
+
if (node?.type !== "MemberExpression")
|
|
41
|
+
return undefined;
|
|
42
|
+
const property = node.property;
|
|
43
|
+
const key = !node.computed && property.type === "Identifier"
|
|
44
|
+
? property.name
|
|
45
|
+
: property.type === "Literal" && typeof property.value === "string"
|
|
46
|
+
? property.value
|
|
47
|
+
: undefined;
|
|
48
|
+
if (key === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
const object = calleeDescription(node.object);
|
|
51
|
+
return object === undefined ? undefined : `${object}.${key}`;
|
|
46
52
|
};
|
|
47
53
|
// OrdinaryHasInstance: walk the left operand's chain looking for the constructor's `prototype`.
|
|
48
54
|
const instanceofValue = (lhs, rhs, node) => {
|
|
@@ -1026,7 +1032,7 @@ class Frame {
|
|
|
1026
1032
|
// `new` itself is supported, so a non-constructible callee is a TypeError like JS rather than
|
|
1027
1033
|
// unsupported syntax. Built-ins like Number are real constructors in JS, so do not claim
|
|
1028
1034
|
// otherwise; say `new` is unsupported for them and point at the plain call.
|
|
1029
|
-
const name = calleeDescription(node.callee);
|
|
1035
|
+
const name = calleeDescription(node.callee) ?? "The called value";
|
|
1030
1036
|
const message = callee instanceof Fn
|
|
1031
1037
|
? `${name} cannot be constructed: user-defined constructors and classes are not supported. Call it as a function that returns a plain object instead.`
|
|
1032
1038
|
: callee instanceof Native
|
|
@@ -1313,7 +1319,7 @@ class Frame {
|
|
|
1313
1319
|
if (callable instanceof Native) {
|
|
1314
1320
|
return yield* self.native(() => callable.call(thisValue, args), node);
|
|
1315
1321
|
}
|
|
1316
|
-
throw typeError(`${calleeDescription(callee)} is not a function.`, callee ?? node);
|
|
1322
|
+
throw typeError(`${calleeDescription(callee) ?? "The called value"} is not a function.`, callee ?? node);
|
|
1317
1323
|
});
|
|
1318
1324
|
}
|
|
1319
1325
|
// Built-ins throw without a location, synchronously or inside their Effect; the call site supplies it.
|
|
@@ -52,9 +52,10 @@ export const uriError = failure("URIError");
|
|
|
52
52
|
export const supportedSyntaxMessage = "This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, this, getters/setters, tagged templates, BigInt, and custom Symbols. Use plain functions and data objects instead.";
|
|
53
53
|
export const unsupportedSyntax = (kind, node) => new PendingThrow("SyntaxError", `Syntax '${kind}' is not supported. ${supportedSyntaxMessage}`, node, "UnsupportedSyntax", [supportedSyntaxMessage]);
|
|
54
54
|
export const isRecord = (value) => typeof value === "object" && value !== null;
|
|
55
|
+
// Acorn lines are 1-based and its columns are 0-based. Diagnostics use 1-based columns of the submitted source.
|
|
55
56
|
export const sourceLocation = (node) => ({
|
|
56
|
-
line:
|
|
57
|
-
column:
|
|
57
|
+
line: node.loc?.start.line ?? 1,
|
|
58
|
+
column: (node.loc?.start.column ?? 0) + 1,
|
|
58
59
|
});
|
|
59
60
|
export const formatLocation = (node) => {
|
|
60
61
|
if (!node?.loc)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/codemode",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-19921",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|