@flint.fyi/json-language 0.0.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 ADDED
@@ -0,0 +1,9 @@
1
+ <h1 align="center"><code>@flint.fyi/json-language</code></h1>
2
+
3
+ <p align="center">
4
+ [Experimental] JSON language for Flint.
5
+ ❤️‍🔥
6
+ </p>
7
+
8
+ This is an internal package for Flint.
9
+ Documentation will eventually be added.
@@ -0,0 +1,5 @@
1
+ import type { FileDiskData, LanguageFileDefinition } from "@flint.fyi/core";
2
+ import type { JsonFileServices } from "./language.ts";
3
+ import type { JsonNodesByName } from "./nodes.ts";
4
+ export declare function createTypeScriptJsonFile(data: FileDiskData): LanguageFileDefinition<JsonNodesByName, JsonFileServices>;
5
+ //# sourceMappingURL=createJsonFile.d.ts.map
@@ -0,0 +1,26 @@
1
+ import ts from "typescript";
2
+
3
+ //#region src/createJsonFile.ts
4
+ function createTypeScriptJsonFile(data) {
5
+ const sourceFile = ts.parseJsonText(data.filePathAbsolute, data.sourceText);
6
+ return {
7
+ about: data,
8
+ runVisitors(options, runtime) {
9
+ if (!runtime.visitors) return;
10
+ const { visitors } = runtime;
11
+ const fileServices = {
12
+ options,
13
+ sourceFile
14
+ };
15
+ const visit = (node) => {
16
+ visitors[ts.SyntaxKind[node.kind]]?.(node, fileServices);
17
+ node.forEachChild(visit);
18
+ };
19
+ sourceFile.forEachChild(visit);
20
+ }
21
+ };
22
+ }
23
+
24
+ //#endregion
25
+ export { createTypeScriptJsonFile };
26
+ //# sourceMappingURL=createJsonFile.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { JsonNodesByName } from "./nodes.js";
2
+ import { JsonFileServices, jsonLanguage } from "./language.js";
3
+ export { JsonFileServices, JsonNodesByName, jsonLanguage };
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { jsonLanguage } from "./language.js";
2
+
3
+ export { jsonLanguage };
@@ -0,0 +1,12 @@
1
+ import { JsonNodesByName } from "./nodes.js";
2
+ import * as _flint_fyi_core0 from "@flint.fyi/core";
3
+ import * as ts$1 from "typescript";
4
+
5
+ //#region src/language.d.ts
6
+ interface JsonFileServices {
7
+ sourceFile: ts$1.JsonSourceFile;
8
+ }
9
+ declare const jsonLanguage: _flint_fyi_core0.Language<JsonNodesByName, JsonFileServices>;
10
+ //#endregion
11
+ export { JsonFileServices, jsonLanguage };
12
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { createTypeScriptJsonFile } from "./createJsonFile.js";
2
+ import { createLanguage } from "@flint.fyi/core";
3
+ import fsSync from "node:fs";
4
+
5
+ //#region src/language.ts
6
+ const jsonLanguage = createLanguage({
7
+ about: { name: "JSON" },
8
+ createFileFactory: () => {
9
+ return {
10
+ prepareFromDisk: (data) => {
11
+ return { file: createTypeScriptJsonFile({
12
+ ...data,
13
+ sourceText: fsSync.readFileSync(data.filePathAbsolute, "utf8")
14
+ }) };
15
+ },
16
+ prepareFromVirtual: (data) => {
17
+ return { file: createTypeScriptJsonFile(data) };
18
+ }
19
+ };
20
+ }
21
+ });
22
+
23
+ //#endregion
24
+ export { jsonLanguage };
25
+ //# sourceMappingURL=language.js.map
package/lib/nodes.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import * as ts$1 from "typescript";
2
+
3
+ //#region src/nodes.d.ts
4
+ interface JsonNodesByName {
5
+ ArrayLiteralExpression: ts$1.ArrayLiteralExpression;
6
+ BooleanLiteral: ts$1.BooleanLiteral;
7
+ JsonMinusNumericLiteral: ts$1.JsonMinusNumericLiteral;
8
+ JsonObjectExpressionStatement: ts$1.JsonObjectExpressionStatement;
9
+ JsonSourceFile: ts$1.JsonSourceFile;
10
+ NullLiteral: ts$1.NullLiteral;
11
+ NumericLiteral: ts$1.NumericLiteral;
12
+ ObjectLiteralExpression: ts$1.ObjectLiteralExpression;
13
+ StringLiteral: ts$1.StringLiteral;
14
+ }
15
+ //#endregion
16
+ export { JsonNodesByName };
17
+ //# sourceMappingURL=nodes.d.ts.map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@flint.fyi/json-language",
3
+ "version": "0.0.0",
4
+ "description": "[Experimental] JSON language for Flint.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/flint-fyi/flint.git",
8
+ "directory": "packages/json-language"
9
+ },
10
+ "license": "MIT",
11
+ "author": {
12
+ "name": "JoshuaKGoldberg",
13
+ "email": "npm@joshuakgoldberg.com"
14
+ },
15
+ "sideEffects": false,
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "@flint.fyi/source": "./src/index.ts",
20
+ "default": "./lib/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "lib/",
25
+ "!lib/**/*.map"
26
+ ],
27
+ "scripts": {
28
+ "test": "vitest --typecheck --project json-language"
29
+ },
30
+ "dependencies": {
31
+ "@flint.fyi/core": "workspace:^",
32
+ "typescript": "^5.9.0 || ^6.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsdown": "0.19.0-beta.2",
36
+ "vitest": "4.0.15"
37
+ },
38
+ "engines": {
39
+ "node": ">=24.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "exports": {
44
+ ".": "./lib/index.js"
45
+ }
46
+ }
47
+ }