@likec4/language-services 1.51.0 → 1.52.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.
@@ -146,6 +146,23 @@ Please specify a project folder`);
146
146
  sib.dispose();
147
147
  };
148
148
  }
149
+ /**
150
+ * Formats documents and returns a map of document URI → formatted source text.
151
+ *
152
+ * Target selection uses union semantics:
153
+ * - Omit both `projects` and `documentUris` to format **all** documents.
154
+ * - Provide `projects` to include all documents from those projects.
155
+ * - Provide `documentUris` to include specific documents.
156
+ * - Provide both to format the **union** (deduplicated).
157
+ */
158
+ async format(options) {
159
+ const { projects, ...rest } = options ?? {};
160
+ const formatOptions = {
161
+ ...rest,
162
+ ...projects && { projectIds: projects.map((p) => this.projectsManager.ensureProjectId(p)) }
163
+ };
164
+ return await this.languageServices.format(formatOptions);
165
+ }
149
166
  async dispose() {
150
167
  await this.languageServices.dispose();
151
168
  }
@@ -81,9 +81,40 @@ declare class LikeC4 {
81
81
  * @returns a function to dispose the listener
82
82
  */
83
83
  onModelUpdate(listener: () => void): () => void;
84
+ /**
85
+ * Formats documents and returns a map of document URI → formatted source text.
86
+ *
87
+ * Target selection uses union semantics:
88
+ * - Omit both `projects` and `documentUris` to format **all** documents.
89
+ * - Provide `projects` to include all documents from those projects.
90
+ * - Provide `documentUris` to include specific documents.
91
+ * - Provide both to format the **union** (deduplicated).
92
+ */
93
+ format(options?: LikeC4FormatOptions): Promise<Map<string, string>>;
84
94
  dispose(): Promise<void>;
85
95
  [Symbol.asyncDispose](): Promise<void>;
86
96
  }
97
+ /**
98
+ * Options for {@link LikeC4.format}.
99
+ *
100
+ * Same as {@link FormatOptions} but uses project name strings instead of {@link ProjectId}.
101
+ */
102
+ interface LikeC4FormatOptions {
103
+ /** Include all documents from these projects (by name). */
104
+ projects?: ReadonlyArray<string>;
105
+ /** Include these specific documents (by URI string). */
106
+ documentUris?: ReadonlyArray<string>;
107
+ /** Size of a tab in spaces (default: 2). */
108
+ tabSize?: number;
109
+ /** Prefer spaces over tabs (default: true). */
110
+ insertSpaces?: boolean;
111
+ /** Trim trailing whitespace on a line. */
112
+ trimTrailingWhitespace?: boolean;
113
+ /** Insert a newline character at the end of the file if one does not exist. */
114
+ insertFinalNewline?: boolean;
115
+ /** Trim all newlines after the final newline at the end of the file. */
116
+ trimFinalNewlines?: boolean;
117
+ }
87
118
  //#endregion
88
119
  //#region src/common/options.d.ts
89
120
  interface InitOptions {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-services",
3
3
  "description": "LikeC4 Language Services",
4
- "version": "1.51.0",
4
+ "version": "1.52.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -78,24 +78,24 @@
78
78
  "std-env": "^3.10.0",
79
79
  "type-fest": "^4.41.0",
80
80
  "vscode-languageserver-types": "3.17.5",
81
- "@likec4/config": "1.51.0",
82
- "@likec4/generators": "1.51.0",
83
- "@likec4/core": "1.51.0",
81
+ "@likec4/config": "1.52.0",
82
+ "@likec4/core": "1.52.0",
83
+ "@likec4/generators": "1.52.0",
84
84
  "@likec4/icons": "1.46.4",
85
- "@likec4/layouts": "1.51.0",
86
- "@likec4/language-server": "1.51.0",
87
- "@likec4/log": "1.51.0"
85
+ "@likec4/language-server": "1.52.0",
86
+ "@likec4/layouts": "1.52.0",
87
+ "@likec4/log": "1.52.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/node": "~22.19.11",
91
91
  "obuild": "^0.4.31",
92
92
  "oxlint": "1.43.0",
93
93
  "tsx": "4.21.0",
94
- "turbo": "2.8.12",
94
+ "turbo": "2.8.13",
95
95
  "typescript": "5.9.3",
96
96
  "vitest": "4.0.18",
97
97
  "@likec4/devops": "1.42.0",
98
- "@likec4/tsconfig": "1.51.0"
98
+ "@likec4/tsconfig": "1.52.0"
99
99
  },
100
100
  "scripts": {
101
101
  "typecheck": "tsc -b --verbose",