@flint.fyi/json-language 0.16.1 → 0.16.3

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.
@@ -0,0 +1,8 @@
1
+ import { JsonNode, JsonSourceFile } from "./nodes.js";
2
+ import { CharacterReportRange } from "@flint.fyi/core";
3
+
4
+ //#region src/getJsonNodeRange.d.ts
5
+ declare function getJsonNodeRange(node: JsonNode, sourceFile: JsonSourceFile): CharacterReportRange;
6
+ //#endregion
7
+ export { getJsonNodeRange };
8
+ //# sourceMappingURL=getJsonNodeRange.d.ts.map
@@ -0,0 +1,11 @@
1
+ //#region src/getJsonNodeRange.ts
2
+ function getJsonNodeRange(node, sourceFile) {
3
+ return {
4
+ begin: node.getStart(sourceFile),
5
+ end: node.getEnd()
6
+ };
7
+ }
8
+ //#endregion
9
+ export { getJsonNodeRange };
10
+
11
+ //# sourceMappingURL=getJsonNodeRange.js.map
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { JsonNodeVisitors, JsonNodesByName } from "./nodes.js";
1
+ import { JsonMinusNumericLiteral, JsonNode, JsonNodeName, JsonNodeVisitors, JsonNodesByName, JsonObjectExpression, JsonObjectExpressionStatement, JsonSourceFile } from "./nodes.js";
2
+ import { getJsonNodeRange } from "./getJsonNodeRange.js";
2
3
  import { JsonFileServices, jsonLanguage } from "./language.js";
3
- export { JsonFileServices, JsonNodeVisitors, JsonNodesByName, jsonLanguage };
4
+ export { JsonFileServices, JsonMinusNumericLiteral, JsonNode, JsonNodeName, JsonNodeVisitors, JsonNodesByName, JsonObjectExpression, JsonObjectExpressionStatement, JsonSourceFile, getJsonNodeRange, jsonLanguage };
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
+ import { getJsonNodeRange } from "./getJsonNodeRange.js";
1
2
  import { jsonLanguage } from "./language.js";
2
-
3
- export { jsonLanguage };
3
+ export { getJsonNodeRange, jsonLanguage };
package/lib/language.d.ts CHANGED
@@ -1,22 +1,11 @@
1
- import { JsonNodesByName } from "./nodes.js";
2
- import * as _flint_fyi_core0 from "@flint.fyi/core";
3
- import * as ts from "typescript";
1
+ import { JsonNodeVisitors, JsonSourceFile } from "./nodes.js";
2
+ import { Language } from "@flint.fyi/core";
4
3
 
5
4
  //#region src/language.d.ts
6
5
  interface JsonFileServices {
7
- sourceFile: ts.JsonSourceFile;
6
+ sourceFile: JsonSourceFile;
8
7
  }
9
- declare const jsonLanguage: _flint_fyi_core0.Language<_flint_fyi_core0.Simplify<JsonNodesByName & {
10
- "ArrayLiteralExpression:exit"?: ts.ArrayLiteralExpression;
11
- "BooleanLiteral:exit"?: ts.BooleanLiteral;
12
- "JsonMinusNumericLiteral:exit"?: ts.JsonMinusNumericLiteral;
13
- "JsonObjectExpressionStatement:exit"?: ts.JsonObjectExpressionStatement;
14
- "JsonSourceFile:exit"?: ts.JsonSourceFile;
15
- "NullLiteral:exit"?: ts.NullLiteral;
16
- "NumericLiteral:exit"?: ts.NumericLiteral;
17
- "ObjectLiteralExpression:exit"?: ts.ObjectLiteralExpression;
18
- "StringLiteral:exit"?: ts.StringLiteral;
19
- }>, JsonFileServices>;
8
+ declare const jsonLanguage: Language<JsonNodeVisitors, JsonFileServices>;
20
9
  //#endregion
21
10
  export { JsonFileServices, jsonLanguage };
22
11
  //# sourceMappingURL=language.d.ts.map
package/lib/language.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createLanguage } from "@flint.fyi/core";
2
2
  import * as ts from "typescript";
3
-
4
3
  //#region src/language.ts
4
+ const kindOverrides = new Map([[ts.SyntaxKind.SourceFile, "JsonSourceFile"]]);
5
5
  const jsonLanguage = createLanguage({
6
6
  about: { name: "JSON" },
7
7
  createFileFactory: () => {
@@ -20,7 +20,7 @@ const jsonLanguage = createLanguage({
20
20
  ...file.services
21
21
  };
22
22
  const visit = (node) => {
23
- const key = ts.SyntaxKind[node.kind];
23
+ const key = kindOverrides.get(node.kind) ?? ts.SyntaxKind[node.kind];
24
24
  visitors[key]?.(node, visitorServices);
25
25
  node.forEachChild(visit);
26
26
  visitors[`${key}:exit`]?.(node, visitorServices);
@@ -28,7 +28,7 @@ const jsonLanguage = createLanguage({
28
28
  visit(file.services.sourceFile);
29
29
  }
30
30
  });
31
-
32
31
  //#endregion
33
32
  export { jsonLanguage };
33
+
34
34
  //# sourceMappingURL=language.js.map
package/lib/nodes.d.ts CHANGED
@@ -1,19 +1,33 @@
1
1
  import { WithExitKeys } from "@flint.fyi/core";
2
2
  import * as ts from "typescript";
3
+ import { AST } from "@flint.fyi/typescript-language";
3
4
 
4
5
  //#region src/nodes.d.ts
6
+ type JsonMinusNumericLiteral = Omit<AST.PrefixUnaryExpression, "operand" | "operator"> & {
7
+ readonly operand: AST.NumericLiteral;
8
+ readonly operator: ts.SyntaxKind.MinusToken;
9
+ };
10
+ type JsonNode = JsonNodesByName[JsonNodeName];
11
+ type JsonNodeName = keyof JsonNodesByName;
5
12
  interface JsonNodesByName {
6
- ArrayLiteralExpression: ts.ArrayLiteralExpression;
7
- BooleanLiteral: ts.BooleanLiteral;
8
- JsonMinusNumericLiteral: ts.JsonMinusNumericLiteral;
9
- JsonObjectExpressionStatement: ts.JsonObjectExpressionStatement;
10
- JsonSourceFile: ts.JsonSourceFile;
11
- NullLiteral: ts.NullLiteral;
12
- NumericLiteral: ts.NumericLiteral;
13
- ObjectLiteralExpression: ts.ObjectLiteralExpression;
14
- StringLiteral: ts.StringLiteral;
13
+ ArrayLiteralExpression: AST.ArrayLiteralExpression;
14
+ BooleanLiteral: AST.BooleanLiteral;
15
+ JsonMinusNumericLiteral: JsonMinusNumericLiteral;
16
+ JsonObjectExpressionStatement: JsonObjectExpressionStatement;
17
+ JsonSourceFile: JsonSourceFile;
18
+ NullLiteral: AST.NullLiteral;
19
+ NumericLiteral: AST.NumericLiteral;
20
+ ObjectLiteralExpression: AST.ObjectLiteralExpression;
21
+ StringLiteral: AST.StringLiteral;
15
22
  }
16
23
  type JsonNodeVisitors = WithExitKeys<JsonNodesByName>;
24
+ type JsonObjectExpression = AST.ArrayLiteralExpression | AST.BooleanLiteral | AST.NullLiteral | AST.NumericLiteral | AST.ObjectLiteralExpression | AST.StringLiteral | JsonMinusNumericLiteral;
25
+ type JsonObjectExpressionStatement = Omit<AST.ExpressionStatement, "expression"> & {
26
+ readonly expression: JsonObjectExpression;
27
+ };
28
+ type JsonSourceFile = Omit<AST.SourceFile, "statements"> & {
29
+ readonly statements: ts.NodeArray<JsonObjectExpressionStatement>;
30
+ };
17
31
  //#endregion
18
- export { JsonNodeVisitors, JsonNodesByName };
32
+ export { JsonMinusNumericLiteral, JsonNode, JsonNodeName, JsonNodeVisitors, JsonNodesByName, JsonObjectExpression, JsonObjectExpressionStatement, JsonSourceFile };
19
33
  //# sourceMappingURL=nodes.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flint.fyi/json-language",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "description": "[Experimental] JSON language for Flint.",
5
5
  "homepage": "https://flint.fyi",
6
6
  "repository": {
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "author": {
13
- "name": "JoshuaKGoldberg",
14
- "email": "npm@joshuakgoldberg.com"
13
+ "name": "Flint Team",
14
+ "url": "https://flint.fyi/team"
15
15
  },
16
16
  "sideEffects": false,
17
17
  "type": "module",
@@ -24,11 +24,12 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "typescript": "^5.9.0 || ^6.0.0",
27
- "@flint.fyi/core": "^0.20.0"
27
+ "@flint.fyi/core": "^0.22.0",
28
+ "@flint.fyi/typescript-language": "^0.18.2"
28
29
  },
29
30
  "devDependencies": {
30
- "tsdown": "0.20.1",
31
- "vitest": "4.0.15"
31
+ "tsdown": "0.21.0",
32
+ "vitest": "4.1.0"
32
33
  },
33
34
  "engines": {
34
35
  "node": ">=24.0.0"
@@ -37,6 +38,6 @@
37
38
  "access": "public"
38
39
  },
39
40
  "scripts": {
40
- "test": "vitest --typecheck --project json-language"
41
+ "test": "vitest --project json-language"
41
42
  }
42
43
  }