@soda-gql/lsp 0.12.6 → 0.13.1

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/bin.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_server = require('./server-BZEiUZua.cjs');
2
+ const require_server = require('./server-DsJ1bZ7i.cjs');
3
3
 
4
4
  //#region packages/lsp/src/bin.ts
5
5
  /**
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as createLspServer } from "./server-6n4IOnC9.mjs";
2
+ import { t as createLspServer } from "./server-CqOUHwDk.mjs";
3
3
 
4
4
  //#region packages/lsp/src/bin.ts
5
5
  /**
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_server = require('./server-BZEiUZua.cjs');
1
+ const require_server = require('./server-DsJ1bZ7i.cjs');
2
2
 
3
3
  exports.createDocumentManager = require_server.createDocumentManager;
4
4
  exports.createLspServer = require_server.createLspServer;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as createDocumentManager, i as lspErrors, n as createSchemaResolver, o as preprocessFragmentArgs, r as createPositionMapper, t as createLspServer } from "./server-6n4IOnC9.mjs";
1
+ import { a as createDocumentManager, i as lspErrors, n as createSchemaResolver, o as preprocessFragmentArgs, r as createPositionMapper, t as createLspServer } from "./server-CqOUHwDk.mjs";
2
2
 
3
3
  export { createDocumentManager, createLspServer, createPositionMapper, createSchemaResolver, lspErrors, preprocessFragmentArgs };
@@ -1,11 +1,11 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
3
  import { createSwcSpanConverter } from "@soda-gql/common";
4
- import { detectBaseIndent, reindent, walkAndExtract } from "@soda-gql/common/template-extraction";
4
+ import { formatTemplatesInSource, walkAndExtract } from "@soda-gql/common/template-extraction";
5
5
  import { TypeInfo, buildASTSchema, concatAST, getNamedType, isTypeDefinitionNode, parse, print, visit, visitWithTypeInfo } from "graphql";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { dirname, resolve, sep } from "node:path";
8
- import { hashSchema } from "@soda-gql/codegen";
8
+ import { hashSchema } from "@soda-gql/tools/codegen";
9
9
  import { err, ok } from "neverthrow";
10
10
  import { findAllConfigFiles, findConfigFile, loadConfig } from "@soda-gql/config";
11
11
  import { DidChangeWatchedFilesNotification, FileChangeType, ProposedFeatures, TextDocumentSyncKind, TextDocuments, createConnection } from "vscode-languageserver/node";
@@ -3538,33 +3538,14 @@ const handleFormatting = (input) => {
3538
3538
  const { templates, tsSource, formatGraphql } = input;
3539
3539
  const format = formatGraphql ?? defaultFormatGraphql;
3540
3540
  const tsLineOffsets = computeLineOffsets(tsSource);
3541
- const edits = [];
3542
- for (const template of templates) {
3543
- let formatted;
3544
- try {
3545
- formatted = format(template.content);
3546
- } catch {
3547
- continue;
3548
- }
3549
- if (formatted === template.content) {
3550
- continue;
3551
- }
3552
- const baseIndent = detectBaseIndent(tsSource, template.contentRange.start);
3553
- const reindented = reindent(formatted, baseIndent, template.content);
3554
- if (reindented === template.content) {
3555
- continue;
3556
- }
3557
- const start = offsetToPosition(tsLineOffsets, template.contentRange.start);
3558
- const end = offsetToPosition(tsLineOffsets, template.contentRange.end);
3559
- edits.push({
3560
- range: {
3561
- start,
3562
- end
3563
- },
3564
- newText: reindented
3565
- });
3566
- }
3567
- return edits;
3541
+ const templateEdits = formatTemplatesInSource(templates, tsSource, format);
3542
+ return templateEdits.map((edit) => ({
3543
+ range: {
3544
+ start: offsetToPosition(tsLineOffsets, edit.start),
3545
+ end: offsetToPosition(tsLineOffsets, edit.end)
3546
+ },
3547
+ newText: edit.newText
3548
+ }));
3568
3549
  };
3569
3550
 
3570
3551
  //#endregion
@@ -4170,4 +4151,4 @@ const positionToOffset = (source, position) => {
4170
4151
 
4171
4152
  //#endregion
4172
4153
  export { createDocumentManager as a, lspErrors as i, createSchemaResolver as n, preprocessFragmentArgs as o, createPositionMapper as r, createLspServer as t };
4173
- //# sourceMappingURL=server-6n4IOnC9.mjs.map
4154
+ //# sourceMappingURL=server-CqOUHwDk.mjs.map