@gql.tada/cli-utils 1.2.0 → 1.2.1-canary-e42804ea2a1e64b58239cd45b152b047b9afcd17

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/chunks/index-chunk.js +1050 -558
  3. package/dist/chunks/index-chunk.js.map +1 -1
  4. package/dist/chunks/index-chunk.mjs +919 -425
  5. package/dist/chunks/index-chunk.mjs.map +1 -1
  6. package/dist/chunks/svelte-chunk.js +53 -51
  7. package/dist/chunks/svelte-chunk.js.map +1 -1
  8. package/dist/chunks/svelte-chunk.mjs +58 -56
  9. package/dist/chunks/svelte-chunk.mjs.map +1 -1
  10. package/dist/chunks/thread-chunk.js +97 -130
  11. package/dist/chunks/thread-chunk.js.map +1 -1
  12. package/dist/chunks/thread-chunk.mjs +94 -106
  13. package/dist/chunks/thread-chunk.mjs.map +1 -1
  14. package/dist/chunks/thread-chunk2.js +46 -82
  15. package/dist/chunks/thread-chunk2.js.map +1 -1
  16. package/dist/chunks/thread-chunk2.mjs +44 -59
  17. package/dist/chunks/thread-chunk2.mjs.map +1 -1
  18. package/dist/chunks/thread-chunk3.js +45 -50
  19. package/dist/chunks/thread-chunk3.js.map +1 -1
  20. package/dist/chunks/thread-chunk3.mjs +45 -50
  21. package/dist/chunks/thread-chunk3.mjs.map +1 -1
  22. package/dist/chunks/vue-chunk.js +18 -15
  23. package/dist/chunks/vue-chunk.js.map +1 -1
  24. package/dist/chunks/vue-chunk.mjs +18 -15
  25. package/dist/chunks/vue-chunk.mjs.map +1 -1
  26. package/dist/gql-tada-cli.js +58 -49
  27. package/dist/gql-tada-cli.js.map +1 -1
  28. package/dist/gql-tada-cli.mjs +656 -647
  29. package/dist/gql-tada-cli.mjs.map +1 -1
  30. package/package.json +2 -3
  31. package/dist/chunks/project-chunk.js +0 -63
  32. package/dist/chunks/project-chunk.js.map +0 -1
  33. package/dist/chunks/project-chunk.mjs +0 -65
  34. package/dist/chunks/project-chunk.mjs.map +0 -1
@@ -1,90 +1,75 @@
1
- import * as e from "node:path";
1
+ import e from "typescript";
2
2
 
3
- import { TypeFormatFlags as i, ts as r, Project as a, ScriptKind as t, TypeFlags as n } from "ts-morph";
3
+ import { e as a, p as r } from "./index-chunk.mjs";
4
4
 
5
- import { init as o } from "@0no-co/graphqlsp/api";
6
-
7
- import { e as l, l as s, g as d } from "./index-chunk.mjs";
8
-
9
- var f = l((async function* _runTurbo(i) {
10
- o({
11
- typescript: r
12
- });
13
- var l = e.dirname(i.configPath);
14
- var f = new a({
15
- tsConfigFilePath: i.configPath,
16
- skipAddingFilesFromTsConfig: !0
5
+ var i = a((async function* _runTurbo(a) {
6
+ var i = r(a);
7
+ i.addSourceFile({
8
+ fileId: "__gql-tada-override__.d.ts",
9
+ sourceText: n,
10
+ scriptKind: e.ScriptKind.TS
17
11
  });
18
- var u = f.createSourceFile("__gql-tada-override__.d.ts", p, {
19
- overwrite: !0,
20
- scriptKind: t.TS
21
- });
22
- if (u._markAsInProject) {
23
- u._markAsInProject();
24
- }
25
- f.addSourceFilesFromTsConfig(i.configPath);
26
- var g = await s(l, f, r);
27
- if (g) {
12
+ var l = i.createExternalFiles();
13
+ if (l.length) {
28
14
  yield {
29
15
  kind: "EXTERNAL_WARNING"
30
16
  };
17
+ await i.addVirtualFiles(l);
31
18
  }
32
- var m = f.getSourceFiles().filter((r => {
33
- var a = e.resolve(l, r.getFilePath());
34
- return !e.relative(i.rootPath, a).startsWith("..");
35
- }));
19
+ var o = i.build();
20
+ var s = o.getSourceFiles();
36
21
  yield {
37
22
  kind: "FILE_COUNT",
38
- fileCount: m.length
23
+ fileCount: s.length
39
24
  };
40
- var v = f.getTypeChecker().compilerObject;
41
- for (var {compilerNode: h} of m) {
42
- var y = h.fileName;
43
- var T = {};
44
- var S = [];
45
- var A = findAllCallExpressions(h, i.pluginConfig);
46
- for (var C of A) {
47
- var N = v.getTypeAtLocation(C);
48
- var _ = v.getTypeAtLocation(C.arguments[0]);
49
- if (!N.symbol || "TadaDocumentNode" !== N.symbol.getEscapedName()) {
50
- var F = d(h, C.getStart(), void 0, g);
51
- y = F.file;
52
- S.push({
25
+ var d = o.program.getTypeChecker();
26
+ for (var p of s) {
27
+ var u = p.fileName;
28
+ var g = {};
29
+ var c = [];
30
+ var f = findAllCallExpressions(p, a.pluginConfig);
31
+ for (var m of f) {
32
+ var y = d.getTypeAtLocation(m);
33
+ var T = d.getTypeAtLocation(m.arguments[0]);
34
+ if (!y.symbol || "TadaDocumentNode" !== y.symbol.getEscapedName()) {
35
+ var F = o.getSourcePosition(p, m.getStart());
36
+ u = F.fileName;
37
+ c.push({
53
38
  message: 'The discovered document is not of type "TadaDocumentNode".\nIf this is unexpected, please file an issue describing your case.',
54
- file: F.file,
39
+ file: F.fileName,
55
40
  line: F.line,
56
41
  col: F.col
57
42
  });
58
43
  continue;
59
44
  }
60
- T["value" in _ && "string" == typeof _.value && 0 == (_.flags & n.StringLiteral) ? JSON.stringify(_.value) : v.typeToString(_, C, c)] = v.typeToString(N, C, c);
45
+ g["value" in T && "string" == typeof T.value && 0 == (T.flags & e.TypeFlags.StringLiteral) ? JSON.stringify(T.value) : d.typeToString(T, m, t)] = d.typeToString(y, m, t);
61
46
  }
62
47
  yield {
63
48
  kind: "FILE_TURBO",
64
- filePath: y,
65
- cache: T,
66
- warnings: S
49
+ filePath: u,
50
+ cache: g,
51
+ warnings: c
67
52
  };
68
53
  }
69
54
  }));
70
55
 
71
- var c = i.NoTruncation | i.NoTypeReduction | i.InTypeAlias | i.UseFullyQualifiedType | i.GenerateNamesForShadowedTypeParams | i.UseAliasDefinedOutsideCurrentScope | i.AllowUniqueESSymbolType | i.WriteTypeArgumentsOfSignature;
56
+ var t = e.TypeFormatFlags.NoTruncation | e.TypeFormatFlags.NoTypeReduction | e.TypeFormatFlags.InTypeAlias | e.TypeFormatFlags.UseFullyQualifiedType | e.TypeFormatFlags.GenerateNamesForShadowedTypeParams | e.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | e.TypeFormatFlags.AllowUniqueESSymbolType | e.TypeFormatFlags.WriteTypeArgumentsOfSignature;
72
57
 
73
- var p = "\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n".trim();
58
+ var n = "\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n".trim();
74
59
 
75
- function findAllCallExpressions(e, i) {
76
- var a = [];
77
- var t = new Set([ i.template, "graphql", "gql" ].filter(Boolean));
78
- !function find(e) {
79
- if (r.isCallExpression(e) && t.has(e.expression.getText())) {
80
- a.push(e);
60
+ function findAllCallExpressions(a, r) {
61
+ var i = [];
62
+ var t = new Set([ r.template, "graphql", "gql" ].filter(Boolean));
63
+ !function find(a) {
64
+ if (e.isCallExpression(a) && t.has(a.expression.getText())) {
65
+ i.push(a);
81
66
  return;
82
67
  } else {
83
- r.forEachChild(e, find);
68
+ e.forEachChild(a, find);
84
69
  }
85
- }(e);
86
- return a;
70
+ }(a);
71
+ return i;
87
72
  }
88
73
 
89
- export { f as runTurbo };
74
+ export { i as runTurbo };
90
75
  //# sourceMappingURL=thread-chunk2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-chunk2.mjs","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import * as path from 'node:path';\nimport { Project, TypeFormatFlags, TypeFlags, ScriptKind, ts } from 'ts-morph';\n\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\nimport { init } from '@0no-co/graphqlsp/api';\n\nimport { getFilePosition, loadVirtualCode } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { TurboSignal, TurboWarning } from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n init({ typescript: ts });\n\n const projectPath = path.dirname(params.configPath);\n const project = new Project({\n tsConfigFilePath: params.configPath,\n skipAddingFilesFromTsConfig: true,\n });\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n const overrideFile = project.createSourceFile(\n '__gql-tada-override__.d.ts',\n DECLARATION_OVERRIDE,\n {\n overwrite: true,\n scriptKind: ScriptKind.TS,\n }\n );\n if (overrideFile._markAsInProject) overrideFile._markAsInProject();\n\n project.addSourceFilesFromTsConfig(params.configPath);\n\n const getVirtualPosition = await loadVirtualCode(projectPath, project, ts);\n if (!!getVirtualPosition) {\n yield { kind: 'EXTERNAL_WARNING' };\n }\n\n // Filter source files by whether they're under the relevant root path\n const sourceFiles = project.getSourceFiles().filter((sourceFile) => {\n const filePath = path.resolve(projectPath, sourceFile.getFilePath());\n const relative = path.relative(params.rootPath, filePath);\n return !relative.startsWith('..');\n });\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = project.getTypeChecker().compilerObject;\n for (const { compilerNode: sourceFile } of sourceFiles) {\n let filePath = sourceFile.fileName;\n const cache: Record<string, string> = {};\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, params.pluginConfig);\n for (const call of calls) {\n const returnType = checker.getTypeAtLocation(call);\n const argumentType = checker.getTypeAtLocation(call.arguments[0]);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n const position = getFilePosition(\n sourceFile,\n call.getStart(),\n undefined,\n getVirtualPosition\n );\n filePath = position.file;\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.file,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const key: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, call, BUILDER_FLAGS);\n cache[key] = checker.typeToString(returnType, call, BUILDER_FLAGS);\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n cache,\n warnings,\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: TypeFormatFlags =\n TypeFormatFlags.NoTruncation |\n TypeFormatFlags.NoTypeReduction |\n TypeFormatFlags.InTypeAlias |\n TypeFormatFlags.UseFullyQualifiedType |\n TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n TypeFormatFlags.AllowUniqueESSymbolType |\n TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n\nfunction findAllCallExpressions(\n sourceFile: ts.SourceFile,\n config: GraphQLSPConfig\n): Array<ts.CallExpression> {\n const result: ts.CallExpression[] = [];\n const templates = new Set([config.template, 'graphql', 'gql'].filter(Boolean));\n function find(node: ts.Node) {\n if (ts.isCallExpression(node) && templates.has(node.expression.getText())) {\n result.push(node);\n return;\n } else {\n ts.forEachChild(node, find);\n }\n }\n find(sourceFile);\n return result;\n}\n"],"names":["runTurbo","expose","async","_runTurbo","params","init","typescript","ts","projectPath","path","dirname","configPath","project","Project","tsConfigFilePath","skipAddingFilesFromTsConfig","overrideFile","createSourceFile","DECLARATION_OVERRIDE","overwrite","scriptKind","ScriptKind","TS","_markAsInProject","addSourceFilesFromTsConfig","getVirtualPosition","loadVirtualCode","kind","sourceFiles","getSourceFiles","filter","sourceFile","filePath","resolve","getFilePath","relative","rootPath","startsWith","fileCount","length","checker","getTypeChecker","compilerObject","compilerNode","fileName","cache","warnings","calls","findAllCallExpressions","pluginConfig","call","returnType","getTypeAtLocation","argumentType","arguments","symbol","getEscapedName","position","getFilePosition","getStart","undefined","file","push","message","line","col","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature","trim","config","result","templates","Set","template","Boolean","find","node","isCallExpression","has","expression","getText","forEachChild"],"mappings":";;;;;;;;IA2GaA,IAAWC,GA1FxBC,gBAAgBC,UAAUC;EACxBC,EAAK;IAAEC,YAAYC;;EAEnB,IAAMC,IAAcC,EAAKC,QAAQN,EAAOO;EACxC,IAAMC,IAAU,IAAIC,EAAQ;IAC1BC,kBAAkBV,EAAOO;IACzBI,8BAA6B;;EAM/B,IAAMC,IAAeJ,EAAQK,iBAC3B,8BACAC,GACA;IACEC,YAAW;IACXC,YAAYC,EAAWC;;EAG3B,IAAIN,EAAaO;IAAkBP,EAAaO;;EAEhDX,EAAQY,2BAA2BpB,EAAOO;EAE1C,IAAMc,UAA2BC,EAAgBlB,GAAaI,GAASL;EACvE,IAAMkB;UACE;MAAEE,MAAM;;;EAIhB,IAAMC,IAAchB,EAAQiB,iBAAiBC,QAAQC;IACnD,IAAMC,IAAWvB,EAAKwB,QAAQzB,GAAauB,EAAWG;IAEtD,QADiBzB,EAAK0B,SAAS/B,EAAOgC,UAAUJ,GAC/BK,WAAW;AAAK;QAG7B;IACJV,MAAM;IACNW,WAAWV,EAAYW;;EAGzB,IAAMC,IAAU5B,EAAQ6B,iBAAiBC;EACzC,KAAK,KAAQC,cAAcZ,MAAgBH,GAAa;IACtD,IAAII,IAAWD,EAAWa;IAC1B,IAAMC,IAAgC,CAAA;IACtC,IAAMC,IAA2B;IAEjC,IAAMC,IAAQC,uBAAuBjB,GAAY3B,EAAO6C;IACxD,KAAK,IAAMC,KAAQH,GAAO;MACxB,IAAMI,IAAaX,EAAQY,kBAAkBF;MAC7C,IAAMG,IAAeb,EAAQY,kBAAkBF,EAAKI,UAAU;MAG9D,KAAKH,EAAWI,UAAiD,uBAAvCJ,EAAWI,OAAOC,kBAAyC;QACnF,IAAMC,IAAWC,EACf3B,GACAmB,EAAKS,iBACLC,GACAnC;QAEFO,IAAWyB,EAASI;QACpBf,EAASgB,KAAK;UACZC,SACG;UAEHF,MAAMJ,EAASI;UACfG,MAAMP,EAASO;UACfC,KAAKR,EAASQ;;QAEhB;AACF;MAQApB,EALE,WAAWQ,KACmB,mBAAvBA,EAAaa,SAC+B,MAAlDb,EAAac,QAAQC,EAAUC,iBAC5BC,KAAKC,UAAUlB,EAAaa,SAC5B1B,EAAQgC,aAAanB,GAAcH,GAAMuB,MAClCjC,EAAQgC,aAAarB,GAAYD,GAAMuB;AACtD;UAEM;MACJ9C,MAAM;MACNK;MACAa;MACAC;;AAEJ;AACF;;AAIA,IAAM2B,IACJC,EAAgBC,eAChBD,EAAgBE,kBAChBF,EAAgBG,cAChBH,EAAgBI,wBAChBJ,EAAgBK,qCAChBL,EAAgBM,qCAChBN,EAAgBO,0BAChBP,EAAgBQ;;AAElB,IAAMhE,IAAwB,gJAO5BiE;;AAEF,SAASnC,uBACPjB,GACAqD;EAEA,IAAMC,IAA8B;EACpC,IAAMC,IAAY,IAAIC,IAAI,EAACH,EAAOI,UAAU,WAAW,QAAO1D,OAAO2D;GACrE,SAASC,KAAKC;IACZ,IAAIpF,EAAGqF,iBAAiBD,MAASL,EAAUO,IAAIF,EAAKG,WAAWC,YAAY;MACzEV,EAAOvB,KAAK6B;MACZ;AACF;MACEpF,EAAGyF,aAAaL,GAAMD;;AAE1B,GACAA,CAAK3D;EACL,OAAOsD;AACT;;"}
1
+ {"version":3,"file":"thread-chunk2.mjs","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { TurboSignal, TurboWarning } from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const cache: Record<string, string> = {};\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, params.pluginConfig);\n for (const call of calls) {\n const returnType = checker.getTypeAtLocation(call);\n const argumentType = checker.getTypeAtLocation(call.arguments[0]);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n const position = container.getSourcePosition(sourceFile, call.getStart());\n filePath = position.fileName;\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const key: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, call, BUILDER_FLAGS);\n cache[key] = checker.typeToString(returnType, call, BUILDER_FLAGS);\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n cache,\n warnings,\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n\nfunction findAllCallExpressions(\n sourceFile: ts.SourceFile,\n config: GraphQLSPConfig\n): Array<ts.CallExpression> {\n const result: ts.CallExpression[] = [];\n const templates = new Set([config.template, 'graphql', 'gql'].filter(Boolean));\n function find(node: ts.Node) {\n if (ts.isCallExpression(node) && templates.has(node.expression.getText())) {\n result.push(node);\n return;\n } else {\n ts.forEachChild(node, find);\n }\n }\n find(sourceFile);\n return result;\n}\n"],"names":["runTurbo","expose","async","_runTurbo","params","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ts","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","sourceFiles","getSourceFiles","fileCount","checker","program","getTypeChecker","sourceFile","filePath","fileName","cache","warnings","calls","findAllCallExpressions","pluginConfig","call","returnType","getTypeAtLocation","argumentType","arguments","symbol","getEscapedName","position","getSourcePosition","getStart","push","message","file","line","col","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature","trim","config","result","templates","Set","template","filter","Boolean","find","node","isCallExpression","has","expression","getText","forEachChild"],"mappings":";;;;IAoFaA,IAAWC,GAtExBC,gBAAgBC,UAAUC;EACxB,IAAMC,IAAUC,EAAeF;EAK/BC,EAAQE,cAAc;IACpBC,QAAQ;IACRC,YAAYC;IACZC,YAAYC,EAAGC,WAAWC;;EAG5B,IAAMC,IAAgBV,EAAQW;EAC9B,IAAID,EAAcE,QAAQ;UAClB;MAAEC,MAAM;;UACRb,EAAQc,gBAAgBJ;AAChC;EAEA,IAAMK,IAAYf,EAAQgB;EAC1B,IAAMC,IAAcF,EAAUG;QAExB;IACJL,MAAM;IACNM,WAAWF,EAAYL;;EAGzB,IAAMQ,IAAUL,EAAUM,QAAQC;EAClC,KAAK,IAAMC,KAAcN,GAAa;IACpC,IAAIO,IAAWD,EAAWE;IAC1B,IAAMC,IAAgC,CAAA;IACtC,IAAMC,IAA2B;IAEjC,IAAMC,IAAQC,uBAAuBN,GAAYxB,EAAO+B;IACxD,KAAK,IAAMC,KAAQH,GAAO;MACxB,IAAMI,IAAaZ,EAAQa,kBAAkBF;MAC7C,IAAMG,IAAed,EAAQa,kBAAkBF,EAAKI,UAAU;MAG9D,KAAKH,EAAWI,UAAiD,uBAAvCJ,EAAWI,OAAOC,kBAAyC;QACnF,IAAMC,IAAWvB,EAAUwB,kBAAkBhB,GAAYQ,EAAKS;QAC9DhB,IAAWc,EAASb;QACpBE,EAASc,KAAK;UACZC,SACG;UAEHC,MAAML,EAASb;UACfmB,MAAMN,EAASM;UACfC,KAAKP,EAASO;;QAEhB;AACF;MAQAnB,EALE,WAAWQ,KACmB,mBAAvBA,EAAaY,SACkC,MAArDZ,EAAaa,QAAQxC,EAAGyC,UAAUC,iBAC/BC,KAAKC,UAAUjB,EAAaY,SAC5B1B,EAAQgC,aAAalB,GAAcH,GAAMsB,MAClCjC,EAAQgC,aAAapB,GAAYD,GAAMsB;AACtD;UAEM;MACJxC,MAAM;MACNW;MACAE;MACAC;;AAEJ;AACF;;AAIA,IAAM0B,IACJ9C,EAAG+C,gBAAgBC,eACnBhD,EAAG+C,gBAAgBE,kBACnBjD,EAAG+C,gBAAgBG,cACnBlD,EAAG+C,gBAAgBI,wBACnBnD,EAAG+C,gBAAgBK,qCACnBpD,EAAG+C,gBAAgBM,qCACnBrD,EAAG+C,gBAAgBO,0BACnBtD,EAAG+C,gBAAgBQ;;AAErB,IAAMzD,IAAwB,gJAO5B0D;;AAEF,SAASlC,uBACPN,GACAyC;EAEA,IAAMC,IAA8B;EACpC,IAAMC,IAAY,IAAIC,IAAI,EAACH,EAAOI,UAAU,WAAW,QAAOC,OAAOC;GACrE,SAASC,KAAKC;IACZ,IAAIjE,EAAGkE,iBAAiBD,MAASN,EAAUQ,IAAIF,EAAKG,WAAWC,YAAY;MACzEX,EAAOxB,KAAK+B;MACZ;AACF;MACEjE,EAAGsE,aAAaL,GAAMD;;AAE1B,GACAA,CAAKhD;EACL,OAAO0C;AACT;;"}
@@ -1,25 +1,23 @@
1
- var e = require("node:path");
1
+ var e = require("typescript");
2
2
 
3
- var r = require("ts-morph");
3
+ var r = require("node:path");
4
4
 
5
- var i = require("@gql.tada/internal");
5
+ var a = require("@gql.tada/internal");
6
6
 
7
- var t = require("@0no-co/graphqlsp/api");
7
+ var i = require("@0no-co/graphqlsp/api");
8
8
 
9
- var a = require("./index-chunk.js");
10
-
11
- var n = require("./project-chunk.js");
9
+ var n = require("./index-chunk.js");
12
10
 
13
11
  function _interopNamespaceDefault(e) {
14
12
  var r = Object.create(null);
15
13
  if (e) {
16
- Object.keys(e).forEach((function(i) {
17
- if ("default" !== i) {
18
- var t = Object.getOwnPropertyDescriptor(e, i);
19
- Object.defineProperty(r, i, t.get ? t : {
14
+ Object.keys(e).forEach((function(a) {
15
+ if ("default" !== a) {
16
+ var i = Object.getOwnPropertyDescriptor(e, a);
17
+ Object.defineProperty(r, a, i.get ? i : {
20
18
  enumerable: !0,
21
19
  get: function() {
22
- return e[i];
20
+ return e[a];
23
21
  }
24
22
  });
25
23
  }
@@ -29,60 +27,57 @@ function _interopNamespaceDefault(e) {
29
27
  return r;
30
28
  }
31
29
 
32
- var o = _interopNamespaceDefault(e);
30
+ var t = _interopNamespaceDefault(r);
33
31
 
34
- var s = a.expose((async function* _runDiagnostics(e) {
35
- t.init({
36
- typescript: r.ts
37
- });
38
- var s = o.dirname(e.configPath);
39
- var l = i.load({
40
- origin: e.pluginConfig.schema,
41
- rootPath: s
32
+ var o = n.expose((async function* _runDiagnostics(r) {
33
+ var o = t.dirname(r.configPath);
34
+ var l = a.load({
35
+ origin: r.pluginConfig.schema,
36
+ rootPath: o
42
37
  });
43
- var c = new r.Project({
44
- tsConfigFilePath: e.configPath
45
- });
46
- var f = await a.loadVirtualCode(s, c, r.ts);
47
- if (f) {
38
+ var s = n.programFactory(r);
39
+ var g = s.createExternalFiles();
40
+ if (g.length) {
48
41
  yield {
49
42
  kind: "EXTERNAL_WARNING"
50
43
  };
44
+ await s.addVirtualFiles(g);
51
45
  }
52
- var g = n.createPluginInfo(c, e.pluginConfig, s, f);
46
+ var c = s.build();
47
+ var f = c.buildPluginInfo(r.pluginConfig);
53
48
  var u = {
54
49
  current: (await l.load()).schema,
55
50
  version: 1
56
51
  };
57
- var v = c.getSourceFiles().filter((r => {
58
- var i = o.resolve(s, r.getFilePath());
59
- return !o.relative(e.rootPath, i).startsWith("..");
60
- }));
52
+ var v = c.getSourceFiles();
61
53
  yield {
62
54
  kind: "FILE_COUNT",
63
55
  fileCount: v.length
64
56
  };
65
- for (var {compilerNode: p} of v) {
66
- var d = p.fileName;
67
- var h = t.getGraphQLDiagnostics(d, u, g);
68
- var m = [];
69
- if (h && h.length) {
70
- for (var y of h) {
57
+ for (var d of v) {
58
+ var p = d.fileName;
59
+ var m = i.getGraphQLDiagnostics(p, u, f);
60
+ var h = [];
61
+ if (m && m.length) {
62
+ for (var y of m) {
71
63
  if (!("messageText" in y) || "string" != typeof y.messageText || !y.file) {
72
64
  continue;
73
65
  }
74
- var P = "info";
75
- if (y.category === r.ts.DiagnosticCategory.Error) {
76
- P = "error";
77
- } else if (y.category === r.ts.DiagnosticCategory.Warning) {
78
- P = "warn";
66
+ var N = "info";
67
+ if (y.category === e.DiagnosticCategory.Error) {
68
+ N = "error";
69
+ } else if (y.category === e.DiagnosticCategory.Warning) {
70
+ N = "warn";
79
71
  }
80
- var C = a.getFilePosition(p, y.start, y.length, f);
81
- d = C.file;
82
- m.push({
83
- severity: P,
72
+ var C = c.getSourcePosition(d, {
73
+ start: y.start || 1,
74
+ length: y.length || 1
75
+ });
76
+ p = C.fileName;
77
+ h.push({
78
+ severity: N,
84
79
  message: y.messageText,
85
- file: C.file,
80
+ file: C.fileName,
86
81
  line: C.line,
87
82
  col: C.col,
88
83
  endLine: C.endLine,
@@ -92,11 +87,11 @@ var s = a.expose((async function* _runDiagnostics(e) {
92
87
  }
93
88
  yield {
94
89
  kind: "FILE_DIAGNOSTICS",
95
- filePath: d,
96
- messages: m
90
+ filePath: p,
91
+ messages: h
97
92
  };
98
93
  }
99
94
  }));
100
95
 
101
- exports.runDiagnostics = s;
96
+ exports.runDiagnostics = o;
102
97
  //# sourceMappingURL=thread-chunk3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-chunk3.js","sources":["../../src/commands/check/thread.ts"],"sourcesContent":["import * as path from 'node:path';\nimport { Project, ts } from 'ts-morph';\n\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\nimport { load } from '@gql.tada/internal';\nimport { init, getGraphQLDiagnostics } from '@0no-co/graphqlsp/api';\n\nimport { createPluginInfo, getFilePosition, loadVirtualCode } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { Severity, DiagnosticMessage, DiagnosticSignal } from './types';\n\nexport interface DiagnosticsParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runDiagnostics(\n params: DiagnosticsParams\n): AsyncIterableIterator<DiagnosticSignal> {\n init({ typescript: ts });\n const projectPath = path.dirname(params.configPath);\n const loader = load({ origin: params.pluginConfig.schema, rootPath: projectPath });\n const project = new Project({ tsConfigFilePath: params.configPath });\n\n const getVirtualPosition = await loadVirtualCode(projectPath, project, ts);\n if (!!getVirtualPosition) {\n yield { kind: 'EXTERNAL_WARNING' };\n }\n\n const pluginInfo = createPluginInfo(\n project,\n params.pluginConfig,\n projectPath,\n getVirtualPosition\n );\n const loadResult = await loader.load();\n const schemaRef = { current: loadResult.schema, version: 1 };\n\n // Filter source files by whether they're under the relevant root path\n const sourceFiles = project.getSourceFiles().filter((sourceFile) => {\n const filePath = path.resolve(projectPath, sourceFile.getFilePath());\n const relative = path.relative(params.rootPath, filePath);\n return !relative.startsWith('..');\n });\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n for (const { compilerNode: sourceFile } of sourceFiles) {\n let filePath = sourceFile.fileName;\n const diagnostics = getGraphQLDiagnostics(filePath, schemaRef, pluginInfo);\n const messages: DiagnosticMessage[] = [];\n\n if (diagnostics && diagnostics.length) {\n for (const diagnostic of diagnostics) {\n if (\n !('messageText' in diagnostic) ||\n typeof diagnostic.messageText !== 'string' ||\n !diagnostic.file\n ) {\n continue;\n }\n let severity: Severity = 'info';\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n severity = 'error';\n } else if (diagnostic.category === ts.DiagnosticCategory.Warning) {\n severity = 'warn';\n }\n const position = getFilePosition(\n sourceFile,\n diagnostic.start,\n diagnostic.length,\n getVirtualPosition\n );\n filePath = position.file;\n messages.push({\n severity,\n message: diagnostic.messageText,\n file: position.file,\n line: position.line,\n col: position.col,\n endLine: position.endLine,\n endColumn: position.endColumn,\n });\n }\n }\n\n yield {\n kind: 'FILE_DIAGNOSTICS',\n filePath,\n messages,\n };\n }\n}\n\nexport const runDiagnostics = expose(_runDiagnostics);\n"],"names":["runDiagnostics","expose","async","_runDiagnostics","params","init","typescript","ts","projectPath","path","dirname","configPath","loader","load","origin","pluginConfig","schema","rootPath","project","Project","tsConfigFilePath","getVirtualPosition","loadVirtualCode","kind","pluginInfo","createPluginInfo","schemaRef","current","version","sourceFiles","getSourceFiles","filter","sourceFile","filePath","resolve","getFilePath","relative","startsWith","fileCount","length","compilerNode","fileName","diagnostics","getGraphQLDiagnostics","messages","diagnostic","messageText","file","severity","category","DiagnosticCategory","Error","Warning","position","getFilePosition","start","push","message","line","col","endLine","endColumn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmGaA,IAAiBC,EAAMA,QAjFpCC,gBAAgBC,gBACdC;EAEAC,OAAK;IAAEC,YAAYC,EAAAA;;EACnB,IAAMC,IAAcC,EAAKC,QAAQN,EAAOO;EACxC,IAAMC,IAASC,EAAAA,KAAK;IAAEC,QAAQV,EAAOW,aAAaC;IAAQC,UAAUT;;EACpE,IAAMU,IAAU,IAAIC,UAAQ;IAAEC,kBAAkBhB,EAAOO;;EAEvD,IAAMU,UAA2BC,EAAeA,gBAACd,GAAaU,GAASX,EAAEA;EACzE,IAAMc;UACE;MAAEE,MAAM;;;EAGhB,IAAMC,IAAaC,EAAAA,iBACjBP,GACAd,EAAOW,cACPP,GACAa;EAGF,IAAMK,IAAY;IAAEC,gBADKf,EAAOC,QACQG;IAAQY,SAAS;;EAGzD,IAAMC,IAAcX,EAAQY,iBAAiBC,QAAQC;IACnD,IAAMC,IAAWxB,EAAKyB,QAAQ1B,GAAawB,EAAWG;IAEtD,QADiB1B,EAAK2B,SAAShC,EAAOa,UAAUgB,GAC/BI,WAAW;AAAK;QAG7B;IACJd,MAAM;IACNe,WAAWT,EAAYU;;EAGzB,KAAK,KAAQC,cAAcR,MAAgBH,GAAa;IACtD,IAAII,IAAWD,EAAWS;IAC1B,IAAMC,IAAcC,EAAqBA,sBAACV,GAAUP,GAAWF;IAC/D,IAAMoB,IAAgC;IAEtC,IAAIF,KAAeA,EAAYH;MAC7B,KAAK,IAAMM,KAAcH,GAAa;QACpC,MACI,iBAAiBG,MACe,mBAA3BA,EAAWC,gBACjBD,EAAWE;UAEZ;;QAEF,IAAIC,IAAqB;QACzB,IAAIH,EAAWI,aAAa1C,KAAG2C,mBAAmBC;UAChDH,IAAW;eACN,IAAIH,EAAWI,aAAa1C,EAAAA,GAAG2C,mBAAmBE;UACvDJ,IAAW;;QAEb,IAAMK,IAAWC,EAAeA,gBAC9BtB,GACAa,EAAWU,OACXV,EAAWN,QACXlB;QAEFY,IAAWoB,EAASN;QACpBH,EAASY,KAAK;UACZR;UACAS,SAASZ,EAAWC;UACpBC,MAAMM,EAASN;UACfW,MAAML,EAASK;UACfC,KAAKN,EAASM;UACdC,SAASP,EAASO;UAClBC,WAAWR,EAASQ;;AAExB;;UAGI;MACJtC,MAAM;MACNU;MACAW;;AAEJ;AACF;;"}
1
+ {"version":3,"file":"thread-chunk3.js","sources":["../../src/commands/check/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\n\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\nimport { load } from '@gql.tada/internal';\nimport { getGraphQLDiagnostics } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { Severity, DiagnosticMessage, DiagnosticSignal } from './types';\n\nexport interface DiagnosticsParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runDiagnostics(\n params: DiagnosticsParams\n): AsyncIterableIterator<DiagnosticSignal> {\n const projectPath = path.dirname(params.configPath);\n const loader = load({ origin: params.pluginConfig.schema, rootPath: projectPath });\n const factory = programFactory(params);\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const loadResult = await loader.load();\n const schemaRef = { current: loadResult.schema, version: 1 };\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const diagnostics = getGraphQLDiagnostics(filePath, schemaRef, pluginInfo);\n const messages: DiagnosticMessage[] = [];\n\n if (diagnostics && diagnostics.length) {\n for (const diagnostic of diagnostics) {\n if (\n !('messageText' in diagnostic) ||\n typeof diagnostic.messageText !== 'string' ||\n !diagnostic.file\n ) {\n continue;\n }\n let severity: Severity = 'info';\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n severity = 'error';\n } else if (diagnostic.category === ts.DiagnosticCategory.Warning) {\n severity = 'warn';\n }\n const span = { start: diagnostic.start || 1, length: diagnostic.length || 1 };\n const position = container.getSourcePosition(sourceFile, span);\n filePath = position.fileName;\n messages.push({\n severity,\n message: diagnostic.messageText,\n file: position.fileName,\n line: position.line,\n col: position.col,\n endLine: position.endLine,\n endColumn: position.endColumn,\n });\n }\n }\n\n yield {\n kind: 'FILE_DIAGNOSTICS',\n filePath,\n messages,\n };\n }\n}\n\nexport const runDiagnostics = expose(_runDiagnostics);\n"],"names":["runDiagnostics","expose","async","_runDiagnostics","params","projectPath","path","dirname","configPath","loader","load","origin","pluginConfig","schema","rootPath","factory","programFactory","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","schemaRef","current","version","sourceFiles","getSourceFiles","fileCount","sourceFile","filePath","fileName","diagnostics","getGraphQLDiagnostics","messages","diagnostic","messageText","file","severity","category","ts","DiagnosticCategory","Error","Warning","position","getSourcePosition","start","push","message","line","col","endLine","endColumn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqFaA,IAAiBC,EAAMA,QAnEpCC,gBAAgBC,gBACdC;EAEA,IAAMC,IAAcC,EAAKC,QAAQH,EAAOI;EACxC,IAAMC,IAASC,EAAAA,KAAK;IAAEC,QAAQP,EAAOQ,aAAaC;IAAQC,UAAUT;;EACpE,IAAMU,IAAUC,iBAAeZ;EAE/B,IAAMa,IAAgBF,EAAQG;EAC9B,IAAID,EAAcE,QAAQ;UAClB;MAAEC,MAAM;;UACRL,EAAQM,gBAAgBJ;AAChC;EAEA,IAAMK,IAAYP,EAAQQ;EAC1B,IAAMC,IAAaF,EAAUG,gBAAgBrB,EAAOQ;EAEpD,IAAMc,IAAY;IAAEC,gBADKlB,EAAOC,QACQG;IAAQe,SAAS;;EACzD,IAAMC,IAAcP,EAAUQ;QAExB;IACJV,MAAM;IACNW,WAAWF,EAAYV;;EAGzB,KAAK,IAAMa,KAAcH,GAAa;IACpC,IAAII,IAAWD,EAAWE;IAC1B,IAAMC,IAAcC,EAAqBA,sBAACH,GAAUP,GAAWF;IAC/D,IAAMa,IAAgC;IAEtC,IAAIF,KAAeA,EAAYhB;MAC7B,KAAK,IAAMmB,KAAcH,GAAa;QACpC,MACI,iBAAiBG,MACe,mBAA3BA,EAAWC,gBACjBD,EAAWE;UAEZ;;QAEF,IAAIC,IAAqB;QACzB,IAAIH,EAAWI,aAAaC,EAAGC,mBAAmBC;UAChDJ,IAAW;eACN,IAAIH,EAAWI,aAAaC,EAAGC,mBAAmBE;UACvDL,IAAW;;QAGb,IAAMM,IAAWzB,EAAU0B,kBAAkBhB,GADhC;UAAEiB,OAAOX,EAAWW,SAAS;UAAG9B,QAAQmB,EAAWnB,UAAU;;QAE1Ec,IAAWc,EAASb;QACpBG,EAASa,KAAK;UACZT;UACAU,SAASb,EAAWC;UACpBC,MAAMO,EAASb;UACfkB,MAAML,EAASK;UACfC,KAAKN,EAASM;UACdC,SAASP,EAASO;UAClBC,WAAWR,EAASQ;;AAExB;;UAGI;MACJnC,MAAM;MACNa;MACAI;;AAEJ;AACF;;"}
@@ -1,81 +1,76 @@
1
- import * as e from "node:path";
1
+ import e from "typescript";
2
2
 
3
- import { ts as r, Project as i } from "ts-morph";
3
+ import * as i from "node:path";
4
4
 
5
5
  import { load as a } from "@gql.tada/internal";
6
6
 
7
- import { init as o, getGraphQLDiagnostics as t } from "@0no-co/graphqlsp/api";
7
+ import { getGraphQLDiagnostics as r } from "@0no-co/graphqlsp/api";
8
8
 
9
- import { e as n, l as s, g as l } from "./index-chunk.mjs";
9
+ import { e as n, p as o } from "./index-chunk.mjs";
10
10
 
11
- import { c as f } from "./project-chunk.mjs";
12
-
13
- var g = n((async function* _runDiagnostics(n) {
14
- o({
15
- typescript: r
16
- });
17
- var g = e.dirname(n.configPath);
18
- var m = a({
11
+ var t = n((async function* _runDiagnostics(n) {
12
+ var t = i.dirname(n.configPath);
13
+ var l = a({
19
14
  origin: n.pluginConfig.schema,
20
- rootPath: g
15
+ rootPath: t
21
16
  });
22
- var c = new i({
23
- tsConfigFilePath: n.configPath
24
- });
25
- var p = await s(g, c, r);
26
- if (p) {
17
+ var s = o(n);
18
+ var g = s.createExternalFiles();
19
+ if (g.length) {
27
20
  yield {
28
21
  kind: "EXTERNAL_WARNING"
29
22
  };
23
+ await s.addVirtualFiles(g);
30
24
  }
31
- var v = f(c, n.pluginConfig, g, p);
32
- var h = {
33
- current: (await m.load()).schema,
25
+ var f = s.build();
26
+ var m = f.buildPluginInfo(n.pluginConfig);
27
+ var c = {
28
+ current: (await l.load()).schema,
34
29
  version: 1
35
30
  };
36
- var d = c.getSourceFiles().filter((r => {
37
- var i = e.resolve(g, r.getFilePath());
38
- return !e.relative(n.rootPath, i).startsWith("..");
39
- }));
31
+ var d = f.getSourceFiles();
40
32
  yield {
41
33
  kind: "FILE_COUNT",
42
34
  fileCount: d.length
43
35
  };
44
- for (var {compilerNode: u} of d) {
45
- var y = u.fileName;
46
- var C = t(y, h, v);
47
- var N = [];
48
- if (C && C.length) {
49
- for (var P of C) {
50
- if (!("messageText" in P) || "string" != typeof P.messageText || !P.file) {
36
+ for (var v of d) {
37
+ var p = v.fileName;
38
+ var u = r(p, c, m);
39
+ var h = [];
40
+ if (u && u.length) {
41
+ for (var y of u) {
42
+ if (!("messageText" in y) || "string" != typeof y.messageText || !y.file) {
51
43
  continue;
52
44
  }
53
- var T = "info";
54
- if (P.category === r.DiagnosticCategory.Error) {
55
- T = "error";
56
- } else if (P.category === r.DiagnosticCategory.Warning) {
57
- T = "warn";
45
+ var C = "info";
46
+ if (y.category === e.DiagnosticCategory.Error) {
47
+ C = "error";
48
+ } else if (y.category === e.DiagnosticCategory.Warning) {
49
+ C = "warn";
58
50
  }
59
- var k = l(u, P.start, P.length, p);
60
- y = k.file;
61
- N.push({
62
- severity: T,
63
- message: P.messageText,
64
- file: k.file,
65
- line: k.line,
66
- col: k.col,
67
- endLine: k.endLine,
68
- endColumn: k.endColumn
51
+ var N = f.getSourcePosition(v, {
52
+ start: y.start || 1,
53
+ length: y.length || 1
54
+ });
55
+ p = N.fileName;
56
+ h.push({
57
+ severity: C,
58
+ message: y.messageText,
59
+ file: N.fileName,
60
+ line: N.line,
61
+ col: N.col,
62
+ endLine: N.endLine,
63
+ endColumn: N.endColumn
69
64
  });
70
65
  }
71
66
  }
72
67
  yield {
73
68
  kind: "FILE_DIAGNOSTICS",
74
- filePath: y,
75
- messages: N
69
+ filePath: p,
70
+ messages: h
76
71
  };
77
72
  }
78
73
  }));
79
74
 
80
- export { g as runDiagnostics };
75
+ export { t as runDiagnostics };
81
76
  //# sourceMappingURL=thread-chunk3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-chunk3.mjs","sources":["../../src/commands/check/thread.ts"],"sourcesContent":["import * as path from 'node:path';\nimport { Project, ts } from 'ts-morph';\n\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\nimport { load } from '@gql.tada/internal';\nimport { init, getGraphQLDiagnostics } from '@0no-co/graphqlsp/api';\n\nimport { createPluginInfo, getFilePosition, loadVirtualCode } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { Severity, DiagnosticMessage, DiagnosticSignal } from './types';\n\nexport interface DiagnosticsParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runDiagnostics(\n params: DiagnosticsParams\n): AsyncIterableIterator<DiagnosticSignal> {\n init({ typescript: ts });\n const projectPath = path.dirname(params.configPath);\n const loader = load({ origin: params.pluginConfig.schema, rootPath: projectPath });\n const project = new Project({ tsConfigFilePath: params.configPath });\n\n const getVirtualPosition = await loadVirtualCode(projectPath, project, ts);\n if (!!getVirtualPosition) {\n yield { kind: 'EXTERNAL_WARNING' };\n }\n\n const pluginInfo = createPluginInfo(\n project,\n params.pluginConfig,\n projectPath,\n getVirtualPosition\n );\n const loadResult = await loader.load();\n const schemaRef = { current: loadResult.schema, version: 1 };\n\n // Filter source files by whether they're under the relevant root path\n const sourceFiles = project.getSourceFiles().filter((sourceFile) => {\n const filePath = path.resolve(projectPath, sourceFile.getFilePath());\n const relative = path.relative(params.rootPath, filePath);\n return !relative.startsWith('..');\n });\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n for (const { compilerNode: sourceFile } of sourceFiles) {\n let filePath = sourceFile.fileName;\n const diagnostics = getGraphQLDiagnostics(filePath, schemaRef, pluginInfo);\n const messages: DiagnosticMessage[] = [];\n\n if (diagnostics && diagnostics.length) {\n for (const diagnostic of diagnostics) {\n if (\n !('messageText' in diagnostic) ||\n typeof diagnostic.messageText !== 'string' ||\n !diagnostic.file\n ) {\n continue;\n }\n let severity: Severity = 'info';\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n severity = 'error';\n } else if (diagnostic.category === ts.DiagnosticCategory.Warning) {\n severity = 'warn';\n }\n const position = getFilePosition(\n sourceFile,\n diagnostic.start,\n diagnostic.length,\n getVirtualPosition\n );\n filePath = position.file;\n messages.push({\n severity,\n message: diagnostic.messageText,\n file: position.file,\n line: position.line,\n col: position.col,\n endLine: position.endLine,\n endColumn: position.endColumn,\n });\n }\n }\n\n yield {\n kind: 'FILE_DIAGNOSTICS',\n filePath,\n messages,\n };\n }\n}\n\nexport const runDiagnostics = expose(_runDiagnostics);\n"],"names":["runDiagnostics","expose","async","_runDiagnostics","params","init","typescript","ts","projectPath","path","dirname","configPath","loader","load","origin","pluginConfig","schema","rootPath","project","Project","tsConfigFilePath","getVirtualPosition","loadVirtualCode","kind","pluginInfo","createPluginInfo","schemaRef","current","version","sourceFiles","getSourceFiles","filter","sourceFile","filePath","resolve","getFilePath","relative","startsWith","fileCount","length","compilerNode","fileName","diagnostics","getGraphQLDiagnostics","messages","diagnostic","messageText","file","severity","category","DiagnosticCategory","Error","Warning","position","getFilePosition","start","push","message","line","col","endLine","endColumn"],"mappings":";;;;;;;;;;;;IAmGaA,IAAiBC,GAjF9BC,gBAAgBC,gBACdC;EAEAC,EAAK;IAAEC,YAAYC;;EACnB,IAAMC,IAAcC,EAAKC,QAAQN,EAAOO;EACxC,IAAMC,IAASC,EAAK;IAAEC,QAAQV,EAAOW,aAAaC;IAAQC,UAAUT;;EACpE,IAAMU,IAAU,IAAIC,EAAQ;IAAEC,kBAAkBhB,EAAOO;;EAEvD,IAAMU,UAA2BC,EAAgBd,GAAaU,GAASX;EACvE,IAAMc;UACE;MAAEE,MAAM;;;EAGhB,IAAMC,IAAaC,EACjBP,GACAd,EAAOW,cACPP,GACAa;EAGF,IAAMK,IAAY;IAAEC,gBADKf,EAAOC,QACQG;IAAQY,SAAS;;EAGzD,IAAMC,IAAcX,EAAQY,iBAAiBC,QAAQC;IACnD,IAAMC,IAAWxB,EAAKyB,QAAQ1B,GAAawB,EAAWG;IAEtD,QADiB1B,EAAK2B,SAAShC,EAAOa,UAAUgB,GAC/BI,WAAW;AAAK;QAG7B;IACJd,MAAM;IACNe,WAAWT,EAAYU;;EAGzB,KAAK,KAAQC,cAAcR,MAAgBH,GAAa;IACtD,IAAII,IAAWD,EAAWS;IAC1B,IAAMC,IAAcC,EAAsBV,GAAUP,GAAWF;IAC/D,IAAMoB,IAAgC;IAEtC,IAAIF,KAAeA,EAAYH;MAC7B,KAAK,IAAMM,KAAcH,GAAa;QACpC,MACI,iBAAiBG,MACe,mBAA3BA,EAAWC,gBACjBD,EAAWE;UAEZ;;QAEF,IAAIC,IAAqB;QACzB,IAAIH,EAAWI,aAAa1C,EAAG2C,mBAAmBC;UAChDH,IAAW;eACN,IAAIH,EAAWI,aAAa1C,EAAG2C,mBAAmBE;UACvDJ,IAAW;;QAEb,IAAMK,IAAWC,EACftB,GACAa,EAAWU,OACXV,EAAWN,QACXlB;QAEFY,IAAWoB,EAASN;QACpBH,EAASY,KAAK;UACZR;UACAS,SAASZ,EAAWC;UACpBC,MAAMM,EAASN;UACfW,MAAML,EAASK;UACfC,KAAKN,EAASM;UACdC,SAASP,EAASO;UAClBC,WAAWR,EAASQ;;AAExB;;UAGI;MACJtC,MAAM;MACNU;MACAW;;AAEJ;AACF;;"}
1
+ {"version":3,"file":"thread-chunk3.mjs","sources":["../../src/commands/check/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport * as path from 'node:path';\n\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\nimport { load } from '@gql.tada/internal';\nimport { getGraphQLDiagnostics } from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { Severity, DiagnosticMessage, DiagnosticSignal } from './types';\n\nexport interface DiagnosticsParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runDiagnostics(\n params: DiagnosticsParams\n): AsyncIterableIterator<DiagnosticSignal> {\n const projectPath = path.dirname(params.configPath);\n const loader = load({ origin: params.pluginConfig.schema, rootPath: projectPath });\n const factory = programFactory(params);\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const pluginInfo = container.buildPluginInfo(params.pluginConfig);\n const loadResult = await loader.load();\n const schemaRef = { current: loadResult.schema, version: 1 };\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const diagnostics = getGraphQLDiagnostics(filePath, schemaRef, pluginInfo);\n const messages: DiagnosticMessage[] = [];\n\n if (diagnostics && diagnostics.length) {\n for (const diagnostic of diagnostics) {\n if (\n !('messageText' in diagnostic) ||\n typeof diagnostic.messageText !== 'string' ||\n !diagnostic.file\n ) {\n continue;\n }\n let severity: Severity = 'info';\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n severity = 'error';\n } else if (diagnostic.category === ts.DiagnosticCategory.Warning) {\n severity = 'warn';\n }\n const span = { start: diagnostic.start || 1, length: diagnostic.length || 1 };\n const position = container.getSourcePosition(sourceFile, span);\n filePath = position.fileName;\n messages.push({\n severity,\n message: diagnostic.messageText,\n file: position.fileName,\n line: position.line,\n col: position.col,\n endLine: position.endLine,\n endColumn: position.endColumn,\n });\n }\n }\n\n yield {\n kind: 'FILE_DIAGNOSTICS',\n filePath,\n messages,\n };\n }\n}\n\nexport const runDiagnostics = expose(_runDiagnostics);\n"],"names":["runDiagnostics","expose","async","_runDiagnostics","params","projectPath","path","dirname","configPath","loader","load","origin","pluginConfig","schema","rootPath","factory","programFactory","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","pluginInfo","buildPluginInfo","schemaRef","current","version","sourceFiles","getSourceFiles","fileCount","sourceFile","filePath","fileName","diagnostics","getGraphQLDiagnostics","messages","diagnostic","messageText","file","severity","category","ts","DiagnosticCategory","Error","Warning","position","getSourcePosition","start","push","message","line","col","endLine","endColumn"],"mappings":";;;;;;;;;;IAqFaA,IAAiBC,GAnE9BC,gBAAgBC,gBACdC;EAEA,IAAMC,IAAcC,EAAKC,QAAQH,EAAOI;EACxC,IAAMC,IAASC,EAAK;IAAEC,QAAQP,EAAOQ,aAAaC;IAAQC,UAAUT;;EACpE,IAAMU,IAAUC,EAAeZ;EAE/B,IAAMa,IAAgBF,EAAQG;EAC9B,IAAID,EAAcE,QAAQ;UAClB;MAAEC,MAAM;;UACRL,EAAQM,gBAAgBJ;AAChC;EAEA,IAAMK,IAAYP,EAAQQ;EAC1B,IAAMC,IAAaF,EAAUG,gBAAgBrB,EAAOQ;EAEpD,IAAMc,IAAY;IAAEC,gBADKlB,EAAOC,QACQG;IAAQe,SAAS;;EACzD,IAAMC,IAAcP,EAAUQ;QAExB;IACJV,MAAM;IACNW,WAAWF,EAAYV;;EAGzB,KAAK,IAAMa,KAAcH,GAAa;IACpC,IAAII,IAAWD,EAAWE;IAC1B,IAAMC,IAAcC,EAAsBH,GAAUP,GAAWF;IAC/D,IAAMa,IAAgC;IAEtC,IAAIF,KAAeA,EAAYhB;MAC7B,KAAK,IAAMmB,KAAcH,GAAa;QACpC,MACI,iBAAiBG,MACe,mBAA3BA,EAAWC,gBACjBD,EAAWE;UAEZ;;QAEF,IAAIC,IAAqB;QACzB,IAAIH,EAAWI,aAAaC,EAAGC,mBAAmBC;UAChDJ,IAAW;eACN,IAAIH,EAAWI,aAAaC,EAAGC,mBAAmBE;UACvDL,IAAW;;QAGb,IAAMM,IAAWzB,EAAU0B,kBAAkBhB,GADhC;UAAEiB,OAAOX,EAAWW,SAAS;UAAG9B,QAAQmB,EAAWnB,UAAU;;QAE1Ec,IAAWc,EAASb;QACpBG,EAASa,KAAK;UACZT;UACAU,SAASb,EAAWC;UACpBC,MAAMO,EAASb;UACfkB,MAAML,EAASK;UACfC,KAAKN,EAASM;UACdC,SAASP,EAASO;UAClBC,WAAWR,EAASQ;;AAExB;;UAGI;MACJnC,MAAM;MACNa;MACAI;;AAEJ;AACF;;"}
@@ -1,6 +1,8 @@
1
- var e = require("@vue/language-core");
1
+ var e = require("typescript");
2
2
 
3
- var r = require("@vue/compiler-dom");
3
+ var r = require("@vue/language-core");
4
+
5
+ var t = require("@vue/compiler-dom");
4
6
 
5
7
  function _interopNamespaceDefault(e) {
6
8
  var r = Object.create(null);
@@ -21,31 +23,32 @@ function _interopNamespaceDefault(e) {
21
23
  return r;
22
24
  }
23
25
 
24
- var t = _interopNamespaceDefault(e);
25
-
26
26
  var a = _interopNamespaceDefault(r);
27
27
 
28
- var o = t.VueGeneratedCode || t.VirtualCode;
28
+ var o = _interopNamespaceDefault(t);
29
+
30
+ var i = a.VueGeneratedCode || a.VirtualCode;
29
31
 
30
- var i = t.resolveVueCompilerOptions({});
32
+ var u = a.resolveVueCompilerOptions({});
31
33
 
32
- var u;
34
+ var n;
33
35
 
34
- exports.createVirtualCode = (r, t, n) => {
35
- if (!u) {
36
- u = e.getDefaultVueLanguagePlugins({
36
+ exports.transform = t => {
37
+ if (!n) {
38
+ n = r.getDefaultVueLanguagePlugins({
37
39
  modules: {
38
- typescript: n,
39
- "@vue/compiler-dom": a
40
+ typescript: e,
41
+ "@vue/compiler-dom": o
40
42
  },
41
43
  compilerOptions: {},
42
44
  codegenStack: !1,
43
45
  globalTypesHolder: void 0,
44
- vueCompilerOptions: i
46
+ vueCompilerOptions: u
45
47
  });
46
48
  }
47
- var c = new o(r, "vue", t, i, u, n, !1);
48
- for (var l of e.forEachEmbeddedCode(c)) {
49
+ var a = e.ScriptSnapshot.fromString(t.getFullText());
50
+ var p = new i(t.fileName, "vue", a, u, n, e, !1);
51
+ for (var l of r.forEachEmbeddedCode(p)) {
49
52
  if (l.id.startsWith("script_")) {
50
53
  return l;
51
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vue-chunk.js","sources":["../../src/ts/virtualCode/vue.ts"],"sourcesContent":["import type { VirtualCode } from '@vue/language-core';\nimport { forEachEmbeddedCode, getDefaultVueLanguagePlugins } from '@vue/language-core';\nimport * as vueCompilerDOM from '@vue/compiler-dom';\nimport * as vue from '@vue/language-core';\n\nimport type { CreateVirtualCode } from './types';\n\nconst VueVirtualCode =\n vue.VueGeneratedCode || ((vue as any).VirtualCode as typeof vue.VueGeneratedCode);\n\nconst vueCompilerOptions = vue.resolveVueCompilerOptions({});\n\nlet plugins: ReturnType<typeof getDefaultVueLanguagePlugins> | undefined;\n\nexport const createVirtualCode: CreateVirtualCode = (\n fileId,\n snapshot,\n ts\n): VirtualCode | undefined => {\n if (!plugins) {\n plugins = getDefaultVueLanguagePlugins({\n modules: {\n typescript: ts,\n '@vue/compiler-dom': vueCompilerDOM,\n },\n compilerOptions: {},\n codegenStack: false,\n globalTypesHolder: undefined,\n vueCompilerOptions,\n });\n }\n\n const root = new VueVirtualCode(fileId, 'vue', snapshot, vueCompilerOptions, plugins, ts, false);\n for (const code of forEachEmbeddedCode(root)) if (code.id.startsWith('script_')) return code;\n};\n"],"names":["VueVirtualCode","vue","VueGeneratedCode","VirtualCode","vueCompilerOptions","resolveVueCompilerOptions","plugins","createVirtualCode","fileId","snapshot","ts","getDefaultVueLanguagePlugins","modules","typescript","vueCompilerDOM","compilerOptions","codegenStack","globalTypesHolder","undefined","root","code","forEachEmbeddedCode","id","startsWith"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,IACJC,EAAIC,oBAAsBD,EAAYE;;AAExC,IAAMC,IAAqBH,EAAII,0BAA0B,CAAA;;AAEzD,IAAIC;;4BAEgDC,CAClDC,GACAC,GACAC;EAEA,KAAKJ;IACHA,IAAUK,EAAAA,6BAA6B;MACrCC,SAAS;QACPC,YAAYH;QACZ,qBAAqBI;;MAEvBC,iBAAiB,CAAE;MACnBC,eAAc;MACdC,wBAAmBC;MACnBd;;;EAIJ,IAAMe,IAAO,IAAInB,EAAeQ,GAAQ,OAAOC,GAAUL,GAAoBE,GAASI,IAAI;EAC1F,KAAK,IAAMU,KAAQC,sBAAoBF;IAAO,IAAIC,EAAKE,GAAGC,WAAW;MAAY,OAAOH;;;AAAI"}
1
+ {"version":3,"file":"vue-chunk.js","sources":["../../src/ts/transformers/vue.ts"],"sourcesContent":["import ts from 'typescript';\nimport type { VirtualCode } from '@vue/language-core';\nimport { forEachEmbeddedCode, getDefaultVueLanguagePlugins } from '@vue/language-core';\nimport * as vueCompilerDOM from '@vue/compiler-dom';\nimport * as vue from '@vue/language-core';\n\nconst VueVirtualCode =\n vue.VueGeneratedCode || ((vue as any).VirtualCode as typeof vue.VueGeneratedCode);\n\nconst vueCompilerOptions = vue.resolveVueCompilerOptions({});\n\nlet plugins: ReturnType<typeof getDefaultVueLanguagePlugins> | undefined;\n\nexport const transform = (sourceFile: ts.SourceFile): VirtualCode | undefined => {\n if (!plugins) {\n plugins = getDefaultVueLanguagePlugins({\n modules: {\n typescript: ts,\n '@vue/compiler-dom': vueCompilerDOM,\n },\n compilerOptions: {},\n codegenStack: false,\n globalTypesHolder: undefined,\n vueCompilerOptions,\n });\n }\n\n const snapshot = ts.ScriptSnapshot.fromString(sourceFile.getFullText());\n const root = new VueVirtualCode(\n sourceFile.fileName,\n 'vue',\n snapshot,\n vueCompilerOptions,\n plugins,\n ts,\n false\n );\n for (const code of forEachEmbeddedCode(root)) if (code.id.startsWith('script_')) return code;\n};\n"],"names":["VueVirtualCode","vue","VueGeneratedCode","VirtualCode","vueCompilerOptions","resolveVueCompilerOptions","plugins","sourceFile","getDefaultVueLanguagePlugins","modules","typescript","ts","vueCompilerDOM","compilerOptions","codegenStack","globalTypesHolder","undefined","snapshot","ScriptSnapshot","fromString","getFullText","root","fileName","code","forEachEmbeddedCode","id","startsWith"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,IACJC,EAAIC,oBAAsBD,EAAYE;;AAExC,IAAMC,IAAqBH,EAAII,0BAA0B,CAAA;;AAEzD,IAAIC;;oBAEsBC;EACxB,KAAKD;IACHA,IAAUE,EAAAA,6BAA6B;MACrCC,SAAS;QACPC,YAAYC;QACZ,qBAAqBC;;MAEvBC,iBAAiB,CAAE;MACnBC,eAAc;MACdC,wBAAmBC;MACnBZ;;;EAIJ,IAAMa,IAAWN,EAAGO,eAAeC,WAAWZ,EAAWa;EACzD,IAAMC,IAAO,IAAIrB,EACfO,EAAWe,UACX,OACAL,GACAb,GACAE,GACAK,IACA;EAEF,KAAK,IAAMY,KAAQC,sBAAoBH;IAAO,IAAIE,EAAKE,GAAGC,WAAW;MAAY,OAAOH;;;AAAI"}