@corsa-bind/napi 0.14.0 → 0.16.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/dist/index.mjs CHANGED
@@ -1,249 +1,13 @@
1
- import * as nativeModule from "../index.js";
1
+ import { binding } from "./binding.mjs";
2
+ import { CorsaApiClient } from "./api_client.mjs";
3
+ import { CorsaDistributedOrchestrator } from "./distributed_orchestrator.mjs";
4
+ import { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText } from "./native_utils.mjs";
5
+ import { CorsaVirtualDocument } from "./virtual_document.mjs";
2
6
  //#region index.ts
3
- const binding = "default" in nativeModule ? nativeModule.default : nativeModule;
4
- function fromJson(value) {
5
- return JSON.parse(value);
6
- }
7
- function toJson(value) {
8
- return JSON.stringify(value ?? null);
9
- }
10
- function isUnsafeAssignment(input) {
11
- return binding.isUnsafeAssignment(toJson(input));
12
- }
13
- function isUnsafeReturn(input) {
14
- return binding.isUnsafeReturn(toJson(input));
15
- }
16
- function runNativeLintRule(ruleName, node) {
17
- return fromJson(binding.runNativeLintRule(ruleName, toJson(node)));
18
- }
19
- function nativeLintRuleMetas() {
20
- return fromJson(binding.nativeLintRuleMetasJson());
21
- }
22
- function classifyTypeText(text) {
23
- return binding.classifyTypeText(text);
24
- }
25
- function splitTopLevelTypeText(text, delimiter) {
26
- return binding.splitTopLevelTypeText(text, delimiter);
27
- }
28
- function splitTypeText(text) {
29
- return binding.splitTypeText(text);
30
- }
31
- function isStringLikeTypeTexts(typeTexts) {
32
- return binding.isStringLikeTypeTexts([...typeTexts]);
33
- }
34
- function isNumberLikeTypeTexts(typeTexts) {
35
- return binding.isNumberLikeTypeTexts([...typeTexts]);
36
- }
37
- function isBigIntLikeTypeTexts(typeTexts) {
38
- return binding.isBigIntLikeTypeTexts([...typeTexts]);
39
- }
40
- function isAnyLikeTypeTexts(typeTexts) {
41
- return binding.isAnyLikeTypeTexts([...typeTexts]);
42
- }
43
- function isUnknownLikeTypeTexts(typeTexts) {
44
- return binding.isUnknownLikeTypeTexts([...typeTexts]);
45
- }
46
- function isArrayLikeTypeTexts(typeTexts) {
47
- return binding.isArrayLikeTypeTexts([...typeTexts]);
48
- }
49
- function isStringArrayLikeTypeTexts(typeTexts) {
50
- return binding.isStringArrayLikeTypeTexts([...typeTexts]);
51
- }
52
- function isPromiseLikeTypeTexts(typeTexts, propertyNames = []) {
53
- return binding.isPromiseLikeTypeTexts([...typeTexts], [...propertyNames]);
54
- }
55
- function isErrorLikeTypeTexts(typeTexts, propertyNames = []) {
56
- return binding.isErrorLikeTypeTexts([...typeTexts], [...propertyNames]);
57
- }
58
- const Utils = Object.freeze({
59
- classifyTypeText,
60
- splitTopLevelTypeText,
61
- splitTypeText,
62
- isStringLikeTypeTexts,
63
- isNumberLikeTypeTexts,
64
- isBigIntLikeTypeTexts,
65
- isAnyLikeTypeTexts,
66
- isUnknownLikeTypeTexts,
67
- isArrayLikeTypeTexts,
68
- isStringArrayLikeTypeTexts,
69
- isPromiseLikeTypeTexts,
70
- isErrorLikeTypeTexts
71
- });
72
- var CorsaApiClient = class CorsaApiClient {
73
- #inner;
74
- constructor(inner) {
75
- this.#inner = inner;
76
- }
77
- static spawn(options) {
78
- return new CorsaApiClient(binding.CorsaApiClient.spawn(toJson(options)));
79
- }
80
- static async spawnAsync(options) {
81
- return new CorsaApiClient(await binding.spawnCorsaApiClientAsync(toJson(options)));
82
- }
83
- initialize() {
84
- return fromJson(this.#inner.initializeJson());
85
- }
86
- async initializeAsync() {
87
- return fromJson(await this.#inner.initializeJsonAsync());
88
- }
89
- parseConfigFile(file) {
90
- return fromJson(this.#inner.parseConfigFileJson(file));
91
- }
92
- async parseConfigFileAsync(file) {
93
- return fromJson(await this.#inner.parseConfigFileJsonAsync(file));
94
- }
95
- updateSnapshot(params) {
96
- return fromJson(this.#inner.updateSnapshotJson(params ? toJson(params) : void 0));
97
- }
98
- async updateSnapshotAsync(params) {
99
- return fromJson(await this.#inner.updateSnapshotJsonAsync(params ? toJson(params) : void 0));
100
- }
101
- getSourceFile(snapshot, project, file) {
102
- return this.#inner.getSourceFile(snapshot, project, file) ?? null;
103
- }
104
- async getSourceFileAsync(snapshot, project, file) {
105
- return await this.#inner.getSourceFileAsync(snapshot, project, file) ?? null;
106
- }
107
- getStringType(snapshot, project) {
108
- return fromJson(this.#inner.getStringTypeJson(snapshot, project));
109
- }
110
- async getStringTypeAsync(snapshot, project) {
111
- return fromJson(await this.#inner.getStringTypeJsonAsync(snapshot, project));
112
- }
113
- getTypeAtPosition(snapshot, project, file, position) {
114
- return fromJson(this.#inner.getTypeAtPositionJson(snapshot, project, file, position)) ?? void 0;
115
- }
116
- async getTypeAtPositionAsync(snapshot, project, file, position) {
117
- return fromJson(await this.#inner.getTypeAtPositionJsonAsync(snapshot, project, file, position)) ?? void 0;
118
- }
119
- getSymbolAtPosition(snapshot, project, file, position) {
120
- return fromJson(this.#inner.getSymbolAtPositionJson(snapshot, project, file, position)) ?? void 0;
121
- }
122
- async getSymbolAtPositionAsync(snapshot, project, file, position) {
123
- return fromJson(await this.#inner.getSymbolAtPositionJsonAsync(snapshot, project, file, position)) ?? void 0;
124
- }
125
- getTypeArguments(snapshot, project, typeHandle, objectFlags) {
126
- return fromJson(this.#inner.getTypeArgumentsJson(snapshot, project, typeHandle, objectFlags));
127
- }
128
- async getTypeArgumentsAsync(snapshot, project, typeHandle, objectFlags) {
129
- return fromJson(await this.#inner.getTypeArgumentsJsonAsync(snapshot, project, typeHandle, objectFlags));
130
- }
131
- getTypeOfSymbol(snapshot, project, symbol) {
132
- return fromJson(this.#inner.getTypeOfSymbolJson(snapshot, project, symbol)) ?? void 0;
133
- }
134
- async getTypeOfSymbolAsync(snapshot, project, symbol) {
135
- return fromJson(await this.#inner.getTypeOfSymbolJsonAsync(snapshot, project, symbol)) ?? void 0;
136
- }
137
- getDeclaredTypeOfSymbol(snapshot, project, symbol) {
138
- return fromJson(this.#inner.getDeclaredTypeOfSymbolJson(snapshot, project, symbol)) ?? void 0;
139
- }
140
- async getDeclaredTypeOfSymbolAsync(snapshot, project, symbol) {
141
- return fromJson(await this.#inner.getDeclaredTypeOfSymbolJsonAsync(snapshot, project, symbol)) ?? void 0;
142
- }
143
- typeToString(snapshot, project, typeHandle, location, flags) {
144
- return this.#inner.typeToString(snapshot, project, typeHandle, location, flags);
145
- }
146
- async typeToStringAsync(snapshot, project, typeHandle, location, flags) {
147
- return this.#inner.typeToStringAsync(snapshot, project, typeHandle, location, flags);
148
- }
149
- callJson(method, params) {
150
- return fromJson(this.#inner.callJson(method, params ? toJson(params) : void 0));
151
- }
152
- async callJsonAsync(method, params) {
153
- return fromJson(await this.#inner.callJsonAsync(method, params ? toJson(params) : void 0));
154
- }
155
- callBinary(method, params) {
156
- return this.#inner.callBinary(method, params ? toJson(params) : void 0) ?? null;
157
- }
158
- async callBinaryAsync(method, params) {
159
- return await this.#inner.callBinaryAsync(method, params ? toJson(params) : void 0) ?? null;
160
- }
161
- releaseHandle(handle) {
162
- this.#inner.releaseHandle(handle);
163
- }
164
- async releaseHandleAsync(handle) {
165
- await this.#inner.releaseHandleAsync(handle);
166
- }
167
- close() {
168
- this.#inner.close();
169
- }
170
- async closeAsync() {
171
- await this.#inner.closeAsync();
172
- }
173
- };
174
- var CorsaVirtualDocument = class CorsaVirtualDocument {
175
- #inner;
176
- constructor(inner) {
177
- this.#inner = inner;
178
- }
179
- static untitled(path, languageId, text) {
180
- return new CorsaVirtualDocument(binding.CorsaVirtualDocument.untitled(path, languageId, text));
181
- }
182
- static inMemory(authority, path, languageId, text) {
183
- return new CorsaVirtualDocument(binding.CorsaVirtualDocument.inMemory(authority, path, languageId, text));
184
- }
185
- get uri() {
186
- return this.#inner.uri;
187
- }
188
- get languageId() {
189
- return this.#inner.languageId;
190
- }
191
- get version() {
192
- return this.#inner.version;
193
- }
194
- get text() {
195
- return this.#inner.text;
196
- }
197
- state() {
198
- return fromJson(this.#inner.stateJson());
199
- }
200
- replace(text) {
201
- this.#inner.replace(text);
202
- }
203
- applyChanges(changes) {
204
- return fromJson(this.#inner.applyChangesJson(toJson(changes)));
205
- }
206
- };
207
- var CorsaDistributedOrchestrator = class {
208
- #inner;
209
- constructor(nodeIds) {
210
- this.#inner = new binding.CorsaDistributedOrchestrator(nodeIds);
211
- }
212
- campaign(nodeId) {
213
- return this.#inner.campaign(nodeId);
214
- }
215
- leaderId() {
216
- return this.#inner.leaderId() ?? void 0;
217
- }
218
- state() {
219
- const value = this.#inner.stateJson();
220
- return value ? fromJson(value) : void 0;
221
- }
222
- nodeState(nodeId) {
223
- const value = this.#inner.nodeStateJson(nodeId);
224
- return value ? fromJson(value) : void 0;
225
- }
226
- document(nodeId, uri) {
227
- const value = this.#inner.documentJson(nodeId, uri);
228
- return value ? fromJson(value) : void 0;
229
- }
230
- openVirtualDocument(document) {
231
- return fromJson(this.#inner.openVirtualDocumentJson(this.requireLeader(), toJson(document)));
232
- }
233
- changeVirtualDocument(uri, changes) {
234
- return fromJson(this.#inner.changeVirtualDocumentJson(this.requireLeader(), uri, toJson(changes)));
235
- }
236
- closeVirtualDocument(uri) {
237
- this.#inner.closeVirtualDocument(this.requireLeader(), uri);
238
- }
239
- requireLeader() {
240
- const leaderId = this.leaderId();
241
- if (!leaderId) throw new Error("raft leader has not been elected");
242
- return leaderId;
243
- }
244
- };
7
+ /** Native binding version reported by the compiled napi module. */
245
8
  const version = binding.version;
9
+ var ts_default = binding;
246
10
  //#endregion
247
- export { CorsaApiClient, CorsaDistributedOrchestrator, CorsaVirtualDocument, Utils, classifyTypeText, binding as default, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText, version };
11
+ export { CorsaApiClient, CorsaDistributedOrchestrator, CorsaVirtualDocument, Utils, classifyTypeText, ts_default as default, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText, version };
248
12
 
249
13
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["#inner"],"sources":["../ts/index.ts"],"sourcesContent":["import * as nativeModule from \"../index.js\";\n\nimport type {\n ApiClientOptions,\n ConfigResponse,\n InitializeResponse,\n NativeLintDiagnostic,\n NativeLintNode,\n NativeLintRuleMeta,\n SymbolResponse,\n TypeTextKind,\n TypeResponse,\n UnsafeTypeFlowInput,\n UpdateSnapshotParams,\n UpdateSnapshotResponse,\n VirtualChange,\n VirtualDocumentState,\n} from \"./types\";\n\nconst binding = (\n \"default\" in nativeModule ? nativeModule.default : nativeModule\n) as typeof import(\"../index.js\");\n\ntype NativeApiClient = InstanceType<typeof binding.CorsaApiClient>;\ntype NativeDistributedOrchestrator = InstanceType<typeof binding.CorsaDistributedOrchestrator>;\ntype NativeVirtualDocument = InstanceType<typeof binding.CorsaVirtualDocument>;\n\nfunction fromJson<T>(value: string): T {\n return JSON.parse(value) as T;\n}\n\nfunction toJson(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n\nexport function isUnsafeAssignment(input: UnsafeTypeFlowInput): boolean {\n return binding.isUnsafeAssignment(toJson(input));\n}\n\nexport function isUnsafeReturn(input: UnsafeTypeFlowInput): boolean {\n return binding.isUnsafeReturn(toJson(input));\n}\n\nexport function runNativeLintRule(ruleName: string, node: NativeLintNode): NativeLintDiagnostic[] {\n return fromJson(binding.runNativeLintRule(ruleName, toJson(node)));\n}\n\nexport function nativeLintRuleMetas(): NativeLintRuleMeta[] {\n return fromJson(binding.nativeLintRuleMetasJson());\n}\n\nexport function classifyTypeText(text?: string): TypeTextKind {\n return binding.classifyTypeText(text) as TypeTextKind;\n}\n\nexport function splitTopLevelTypeText(text: string, delimiter: string): string[] {\n return binding.splitTopLevelTypeText(text, delimiter);\n}\n\nexport function splitTypeText(text: string): string[] {\n return binding.splitTypeText(text);\n}\n\nexport function isStringLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isStringLikeTypeTexts([...typeTexts]);\n}\n\nexport function isNumberLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isNumberLikeTypeTexts([...typeTexts]);\n}\n\nexport function isBigIntLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isBigIntLikeTypeTexts([...typeTexts]);\n}\n\nexport function isAnyLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isAnyLikeTypeTexts([...typeTexts]);\n}\n\nexport function isUnknownLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isUnknownLikeTypeTexts([...typeTexts]);\n}\n\nexport function isArrayLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isArrayLikeTypeTexts([...typeTexts]);\n}\n\nexport function isStringArrayLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isStringArrayLikeTypeTexts([...typeTexts]);\n}\n\nexport function isPromiseLikeTypeTexts(\n typeTexts: readonly string[],\n propertyNames: readonly string[] = [],\n): boolean {\n return binding.isPromiseLikeTypeTexts([...typeTexts], [...propertyNames]);\n}\n\nexport function isErrorLikeTypeTexts(\n typeTexts: readonly string[],\n propertyNames: readonly string[] = [],\n): boolean {\n return binding.isErrorLikeTypeTexts([...typeTexts], [...propertyNames]);\n}\n\nexport const Utils = Object.freeze({\n classifyTypeText,\n splitTopLevelTypeText,\n splitTypeText,\n isStringLikeTypeTexts,\n isNumberLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isAnyLikeTypeTexts,\n isUnknownLikeTypeTexts,\n isArrayLikeTypeTexts,\n isStringArrayLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isErrorLikeTypeTexts,\n});\n\nexport class CorsaApiClient {\n readonly #inner: NativeApiClient;\n\n private constructor(inner: NativeApiClient) {\n this.#inner = inner;\n }\n\n static spawn(options: ApiClientOptions): CorsaApiClient {\n return new CorsaApiClient(binding.CorsaApiClient.spawn(toJson(options)));\n }\n\n static async spawnAsync(options: ApiClientOptions): Promise<CorsaApiClient> {\n return new CorsaApiClient(await binding.spawnCorsaApiClientAsync(toJson(options)));\n }\n\n initialize(): InitializeResponse {\n return fromJson(this.#inner.initializeJson());\n }\n\n async initializeAsync(): Promise<InitializeResponse> {\n return fromJson(await this.#inner.initializeJsonAsync());\n }\n\n parseConfigFile(file: string): ConfigResponse {\n return fromJson(this.#inner.parseConfigFileJson(file));\n }\n\n async parseConfigFileAsync(file: string): Promise<ConfigResponse> {\n return fromJson(await this.#inner.parseConfigFileJsonAsync(file));\n }\n\n updateSnapshot(params?: UpdateSnapshotParams): UpdateSnapshotResponse {\n return fromJson(this.#inner.updateSnapshotJson(params ? toJson(params) : undefined));\n }\n\n async updateSnapshotAsync(params?: UpdateSnapshotParams): Promise<UpdateSnapshotResponse> {\n return fromJson(await this.#inner.updateSnapshotJsonAsync(params ? toJson(params) : undefined));\n }\n\n getSourceFile(snapshot: string, project: string, file: string): Uint8Array | null {\n return this.#inner.getSourceFile(snapshot, project, file) ?? null;\n }\n\n async getSourceFileAsync(\n snapshot: string,\n project: string,\n file: string,\n ): Promise<Uint8Array | null> {\n return (await this.#inner.getSourceFileAsync(snapshot, project, file)) ?? null;\n }\n\n getStringType(snapshot: string, project: string): TypeResponse {\n return fromJson(this.#inner.getStringTypeJson(snapshot, project));\n }\n\n async getStringTypeAsync(snapshot: string, project: string): Promise<TypeResponse> {\n return fromJson(await this.#inner.getStringTypeJsonAsync(snapshot, project));\n }\n\n getTypeAtPosition(\n snapshot: string,\n project: string,\n file: string,\n position: number,\n ): TypeResponse | undefined {\n return (\n fromJson<TypeResponse | null>(\n this.#inner.getTypeAtPositionJson(snapshot, project, file, position),\n ) ?? undefined\n );\n }\n\n async getTypeAtPositionAsync(\n snapshot: string,\n project: string,\n file: string,\n position: number,\n ): Promise<TypeResponse | undefined> {\n return (\n fromJson<TypeResponse | null>(\n await this.#inner.getTypeAtPositionJsonAsync(snapshot, project, file, position),\n ) ?? undefined\n );\n }\n\n getSymbolAtPosition(\n snapshot: string,\n project: string,\n file: string,\n position: number,\n ): SymbolResponse | undefined {\n return (\n fromJson<SymbolResponse | null>(\n this.#inner.getSymbolAtPositionJson(snapshot, project, file, position),\n ) ?? undefined\n );\n }\n\n async getSymbolAtPositionAsync(\n snapshot: string,\n project: string,\n file: string,\n position: number,\n ): Promise<SymbolResponse | undefined> {\n return (\n fromJson<SymbolResponse | null>(\n await this.#inner.getSymbolAtPositionJsonAsync(snapshot, project, file, position),\n ) ?? undefined\n );\n }\n\n getTypeArguments(\n snapshot: string,\n project: string,\n typeHandle: string,\n objectFlags?: number,\n ): TypeResponse[] {\n return fromJson(this.#inner.getTypeArgumentsJson(snapshot, project, typeHandle, objectFlags));\n }\n\n async getTypeArgumentsAsync(\n snapshot: string,\n project: string,\n typeHandle: string,\n objectFlags?: number,\n ): Promise<TypeResponse[]> {\n return fromJson(\n await this.#inner.getTypeArgumentsJsonAsync(snapshot, project, typeHandle, objectFlags),\n );\n }\n\n getTypeOfSymbol(snapshot: string, project: string, symbol: string): TypeResponse | undefined {\n return (\n fromJson<TypeResponse | null>(this.#inner.getTypeOfSymbolJson(snapshot, project, symbol)) ??\n undefined\n );\n }\n\n async getTypeOfSymbolAsync(\n snapshot: string,\n project: string,\n symbol: string,\n ): Promise<TypeResponse | undefined> {\n return (\n fromJson<TypeResponse | null>(\n await this.#inner.getTypeOfSymbolJsonAsync(snapshot, project, symbol),\n ) ?? undefined\n );\n }\n\n getDeclaredTypeOfSymbol(\n snapshot: string,\n project: string,\n symbol: string,\n ): TypeResponse | undefined {\n return (\n fromJson<TypeResponse | null>(\n this.#inner.getDeclaredTypeOfSymbolJson(snapshot, project, symbol),\n ) ?? undefined\n );\n }\n\n async getDeclaredTypeOfSymbolAsync(\n snapshot: string,\n project: string,\n symbol: string,\n ): Promise<TypeResponse | undefined> {\n return (\n fromJson<TypeResponse | null>(\n await this.#inner.getDeclaredTypeOfSymbolJsonAsync(snapshot, project, symbol),\n ) ?? undefined\n );\n }\n\n typeToString(\n snapshot: string,\n project: string,\n typeHandle: string,\n location?: string,\n flags?: number,\n ): string {\n return this.#inner.typeToString(snapshot, project, typeHandle, location, flags);\n }\n\n async typeToStringAsync(\n snapshot: string,\n project: string,\n typeHandle: string,\n location?: string,\n flags?: number,\n ): Promise<string> {\n return this.#inner.typeToStringAsync(snapshot, project, typeHandle, location, flags);\n }\n\n callJson<T>(method: string, params?: unknown): T {\n return fromJson(this.#inner.callJson(method, params ? toJson(params) : undefined));\n }\n\n async callJsonAsync<T>(method: string, params?: unknown): Promise<T> {\n return fromJson(await this.#inner.callJsonAsync(method, params ? toJson(params) : undefined));\n }\n\n callBinary(method: string, params?: unknown): Uint8Array | null {\n return this.#inner.callBinary(method, params ? toJson(params) : undefined) ?? null;\n }\n\n async callBinaryAsync(method: string, params?: unknown): Promise<Uint8Array | null> {\n return (await this.#inner.callBinaryAsync(method, params ? toJson(params) : undefined)) ?? null;\n }\n\n releaseHandle(handle: string): void {\n this.#inner.releaseHandle(handle);\n }\n\n async releaseHandleAsync(handle: string): Promise<void> {\n await this.#inner.releaseHandleAsync(handle);\n }\n\n close(): void {\n this.#inner.close();\n }\n\n async closeAsync(): Promise<void> {\n await this.#inner.closeAsync();\n }\n}\n\nexport class CorsaVirtualDocument {\n readonly #inner: NativeVirtualDocument;\n\n private constructor(inner: NativeVirtualDocument) {\n this.#inner = inner;\n }\n\n static untitled(path: string, languageId: string, text: string): CorsaVirtualDocument {\n return new CorsaVirtualDocument(binding.CorsaVirtualDocument.untitled(path, languageId, text));\n }\n\n static inMemory(\n authority: string,\n path: string,\n languageId: string,\n text: string,\n ): CorsaVirtualDocument {\n return new CorsaVirtualDocument(\n binding.CorsaVirtualDocument.inMemory(authority, path, languageId, text),\n );\n }\n\n get uri(): string {\n return this.#inner.uri;\n }\n\n get languageId(): string {\n return this.#inner.languageId;\n }\n\n get version(): number {\n return this.#inner.version;\n }\n\n get text(): string {\n return this.#inner.text;\n }\n\n state(): VirtualDocumentState {\n return fromJson(this.#inner.stateJson());\n }\n\n replace(text: string): void {\n this.#inner.replace(text);\n }\n\n applyChanges(changes: VirtualChange[]): unknown[] {\n return fromJson(this.#inner.applyChangesJson(toJson(changes)));\n }\n}\n\nexport class CorsaDistributedOrchestrator {\n readonly #inner: NativeDistributedOrchestrator;\n\n constructor(nodeIds: string[]) {\n this.#inner = new binding.CorsaDistributedOrchestrator(nodeIds);\n }\n\n campaign(nodeId: string): number {\n return this.#inner.campaign(nodeId);\n }\n\n leaderId(): string | undefined {\n return this.#inner.leaderId() ?? undefined;\n }\n\n state<T>(): T | undefined {\n const value = this.#inner.stateJson();\n return value ? fromJson<T>(value) : undefined;\n }\n\n nodeState<T>(nodeId: string): T | undefined {\n const value = this.#inner.nodeStateJson(nodeId);\n return value ? fromJson<T>(value) : undefined;\n }\n\n document(nodeId: string, uri: string): VirtualDocumentState | undefined {\n const value = this.#inner.documentJson(nodeId, uri);\n return value ? fromJson<VirtualDocumentState>(value) : undefined;\n }\n\n openVirtualDocument(document: VirtualDocumentState): VirtualDocumentState {\n return fromJson(this.#inner.openVirtualDocumentJson(this.requireLeader(), toJson(document)));\n }\n\n changeVirtualDocument(uri: string, changes: VirtualChange[]): VirtualDocumentState {\n return fromJson(\n this.#inner.changeVirtualDocumentJson(this.requireLeader(), uri, toJson(changes)),\n );\n }\n\n closeVirtualDocument(uri: string): void {\n this.#inner.closeVirtualDocument(this.requireLeader(), uri);\n }\n\n private requireLeader(): string {\n const leaderId = this.leaderId();\n if (!leaderId) {\n throw new Error(\"raft leader has not been elected\");\n }\n return leaderId;\n }\n}\n\nexport default binding;\nexport const version = binding.version;\nexport type * from \"./types\";\n"],"mappings":";;AAmBA,MAAM,UACJ,aAAa,eAAe,aAAa,UAAU;AAOrD,SAAS,SAAY,OAAkB;CACrC,OAAO,KAAK,MAAM,MAAM;;AAG1B,SAAS,OAAO,OAAwB;CACtC,OAAO,KAAK,UAAU,SAAS,KAAK;;AAGtC,SAAgB,mBAAmB,OAAqC;CACtE,OAAO,QAAQ,mBAAmB,OAAO,MAAM,CAAC;;AAGlD,SAAgB,eAAe,OAAqC;CAClE,OAAO,QAAQ,eAAe,OAAO,MAAM,CAAC;;AAG9C,SAAgB,kBAAkB,UAAkB,MAA8C;CAChG,OAAO,SAAS,QAAQ,kBAAkB,UAAU,OAAO,KAAK,CAAC,CAAC;;AAGpE,SAAgB,sBAA4C;CAC1D,OAAO,SAAS,QAAQ,yBAAyB,CAAC;;AAGpD,SAAgB,iBAAiB,MAA6B;CAC5D,OAAO,QAAQ,iBAAiB,KAAK;;AAGvC,SAAgB,sBAAsB,MAAc,WAA6B;CAC/E,OAAO,QAAQ,sBAAsB,MAAM,UAAU;;AAGvD,SAAgB,cAAc,MAAwB;CACpD,OAAO,QAAQ,cAAc,KAAK;;AAGpC,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;AAGtD,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;AAGtD,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;AAGtD,SAAgB,mBAAmB,WAAuC;CACxE,OAAO,QAAQ,mB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1C,MAAM,QAAQ,KAAKA,OAAO,cAAc,OAAO;EAC/C,OAAO,QAAQ,SAAY,MAAM,GAAG,KAAA;;CAGtC,SAAS,QAAgB,KAA+C;EACtE,MAAM,QAAQ,KAAKA,OAAO,aAAa,QAAQ,IAAI;EACnD,OAAO,QAAQ,SAA+B,MAAM,GAAG,KAAA;;CAGzD,oBAAoB,UAAsD;EACxE,OAAO,SAAS,KAAKA,OAAO,wBAAwB,KAAK,eAAe,EAAE,OAAO,SAAS,CAAC,CAAC;;CAG9F,sBAAsB,KAAa,SAAgD;EACjF,OAAO,SACL,KAAKA,OAAO,0BAA0B,KAAK,eAAe,EAAE,KAAK,OAAO,QAAQ,CAAC,CAClF;;CAGH,qBAAqB,KAAmB;EACtC,KAAKA,OAAO,qBAAqB,KAAK,eAAe,EAAE,IAAI;;CAG7D,gBAAgC;EAC9B,MAAM,WAAW,KAAK,UAAU;EAChC,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,mCAAmC;EAErD,OAAO;;;AAKX,MAAa,UAAU,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../ts/index.ts"],"sourcesContent":["import { binding } from \"./binding\";\n\nexport { CorsaApiClient } from \"./api_client\";\nexport { CorsaDistributedOrchestrator } from \"./distributed_orchestrator\";\nexport * from \"./native_utils\";\nexport { CorsaVirtualDocument } from \"./virtual_document\";\n\n/** Native binding version reported by the compiled napi module. */\nexport const version = binding.version;\n\nexport default binding;\nexport type * from \"./types\";\n"],"mappings":";;;;;;;AAQA,MAAa,UAAU,QAAQ;AAE/B,IAAA,aAAe"}
@@ -0,0 +1,14 @@
1
+ import { version as version$1 } from "./index.mjs";
2
+ import { binding } from "./binding.mjs";
3
+ import { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, NativeLintDiagnostic, NativeLintFix, NativeLintNode, NativeLintRange, NativeLintRuleMeta, NativeLintSuggestion, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SymbolResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState } from "./types.mjs";
4
+ import { CorsaApiClient } from "./api_client.mjs";
5
+ import { CorsaDistributedOrchestrator } from "./distributed_orchestrator.mjs";
6
+ import { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText } from "./native_utils.mjs";
7
+ import { CorsaVirtualDocument } from "./virtual_document.mjs";
8
+
9
+ //#region index.d.ts
10
+ /** Native binding version reported by the compiled napi module. */
11
+ declare const version: typeof version$1;
12
+ //#endregion
13
+ export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, CorsaApiClient, CorsaDistributedOrchestrator, CorsaVirtualDocument, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, NativeLintDiagnostic, NativeLintFix, NativeLintNode, NativeLintRange, NativeLintRuleMeta, NativeLintSuggestion, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SymbolResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, Utils, VirtualChange, VirtualDocumentState, classifyTypeText, binding as default, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText, version };
14
+ //# sourceMappingURL=index2.d.mts.map
package/dist/json.mjs ADDED
@@ -0,0 +1,18 @@
1
+ //#region json.ts
2
+ /** Parses a JSON payload returned by the native binding into a typed value. */
3
+ function fromJson(value) {
4
+ return JSON.parse(value);
5
+ }
6
+ /**
7
+ * Serializes optional request parameters for native methods.
8
+ *
9
+ * Native endpoints expect a JSON string even for omitted payloads, so `undefined`
10
+ * is normalized to JSON `null` before crossing the napi boundary.
11
+ */
12
+ function toJson(value) {
13
+ return JSON.stringify(value ?? null);
14
+ }
15
+ //#endregion
16
+ export { fromJson, toJson };
17
+
18
+ //# sourceMappingURL=json.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.mjs","names":[],"sources":["../ts/json.ts"],"sourcesContent":["/** Parses a JSON payload returned by the native binding into a typed value. */\nexport function fromJson<T>(value: string): T {\n return JSON.parse(value) as T;\n}\n\n/**\n * Serializes optional request parameters for native methods.\n *\n * Native endpoints expect a JSON string even for omitted payloads, so `undefined`\n * is normalized to JSON `null` before crossing the napi boundary.\n */\nexport function toJson(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";;AACA,SAAgB,SAAY,OAAkB;CAC5C,OAAO,KAAK,MAAM,MAAM;;;;;;;;AAS1B,SAAgB,OAAO,OAAwB;CAC7C,OAAO,KAAK,UAAU,SAAS,KAAK"}
@@ -0,0 +1,53 @@
1
+ import { NativeLintDiagnostic, NativeLintNode, NativeLintRuleMeta, TypeTextKind, UnsafeTypeFlowInput } from "./types.mjs";
2
+
3
+ //#region native_utils.d.ts
4
+ /** Runs the Rust unsafe-assignment classifier against serialized type-flow data. */
5
+ declare function isUnsafeAssignment(input: UnsafeTypeFlowInput): boolean;
6
+ /** Runs the Rust unsafe-return classifier against serialized type-flow data. */
7
+ declare function isUnsafeReturn(input: UnsafeTypeFlowInput): boolean;
8
+ /** Executes a native lint rule implementation and returns normalized diagnostics. */
9
+ declare function runNativeLintRule(ruleName: string, node: NativeLintNode): NativeLintDiagnostic[];
10
+ /** Lists rule metadata exposed by the Rust-backed native rule registry. */
11
+ declare function nativeLintRuleMetas(): NativeLintRuleMeta[];
12
+ /** Classifies a TypeScript type string into the Rust fast-path type categories. */
13
+ declare function classifyTypeText(text?: string): TypeTextKind;
14
+ /** Splits a type string by a top-level delimiter while respecting nested syntax. */
15
+ declare function splitTopLevelTypeText(text: string, delimiter: string): string[];
16
+ /** Splits a union/intersection-like type string into top-level constituents. */
17
+ declare function splitTypeText(text: string): string[];
18
+ /** Returns whether any supplied type text is string-like. */
19
+ declare function isStringLikeTypeTexts(typeTexts: readonly string[]): boolean;
20
+ /** Returns whether any supplied type text is number-like. */
21
+ declare function isNumberLikeTypeTexts(typeTexts: readonly string[]): boolean;
22
+ /** Returns whether any supplied type text is bigint-like. */
23
+ declare function isBigIntLikeTypeTexts(typeTexts: readonly string[]): boolean;
24
+ /** Returns whether any supplied type text is `any`-like. */
25
+ declare function isAnyLikeTypeTexts(typeTexts: readonly string[]): boolean;
26
+ /** Returns whether any supplied type text is `unknown`-like. */
27
+ declare function isUnknownLikeTypeTexts(typeTexts: readonly string[]): boolean;
28
+ /** Returns whether any supplied type text represents an array-like value. */
29
+ declare function isArrayLikeTypeTexts(typeTexts: readonly string[]): boolean;
30
+ /** Returns whether any supplied type text represents an array of strings. */
31
+ declare function isStringArrayLikeTypeTexts(typeTexts: readonly string[]): boolean;
32
+ /** Returns whether type text plus property names looks Promise-like. */
33
+ declare function isPromiseLikeTypeTexts(typeTexts: readonly string[], propertyNames?: readonly string[]): boolean;
34
+ /** Returns whether type text plus property names looks Error-like. */
35
+ declare function isErrorLikeTypeTexts(typeTexts: readonly string[], propertyNames?: readonly string[]): boolean;
36
+ /** Namespaced utility export matching the previous public API shape. */
37
+ declare const Utils: Readonly<{
38
+ classifyTypeText: typeof classifyTypeText;
39
+ splitTopLevelTypeText: typeof splitTopLevelTypeText;
40
+ splitTypeText: typeof splitTypeText;
41
+ isStringLikeTypeTexts: typeof isStringLikeTypeTexts;
42
+ isNumberLikeTypeTexts: typeof isNumberLikeTypeTexts;
43
+ isBigIntLikeTypeTexts: typeof isBigIntLikeTypeTexts;
44
+ isAnyLikeTypeTexts: typeof isAnyLikeTypeTexts;
45
+ isUnknownLikeTypeTexts: typeof isUnknownLikeTypeTexts;
46
+ isArrayLikeTypeTexts: typeof isArrayLikeTypeTexts;
47
+ isStringArrayLikeTypeTexts: typeof isStringArrayLikeTypeTexts;
48
+ isPromiseLikeTypeTexts: typeof isPromiseLikeTypeTexts;
49
+ isErrorLikeTypeTexts: typeof isErrorLikeTypeTexts;
50
+ }>;
51
+ //#endregion
52
+ export { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText };
53
+ //# sourceMappingURL=native_utils.d.mts.map
@@ -0,0 +1,86 @@
1
+ import { binding } from "./binding.mjs";
2
+ import { fromJson, toJson } from "./json.mjs";
3
+ //#region native_utils.ts
4
+ /** Runs the Rust unsafe-assignment classifier against serialized type-flow data. */
5
+ function isUnsafeAssignment(input) {
6
+ return binding.isUnsafeAssignment(toJson(input));
7
+ }
8
+ /** Runs the Rust unsafe-return classifier against serialized type-flow data. */
9
+ function isUnsafeReturn(input) {
10
+ return binding.isUnsafeReturn(toJson(input));
11
+ }
12
+ /** Executes a native lint rule implementation and returns normalized diagnostics. */
13
+ function runNativeLintRule(ruleName, node) {
14
+ return fromJson(binding.runNativeLintRule(ruleName, toJson(node)));
15
+ }
16
+ /** Lists rule metadata exposed by the Rust-backed native rule registry. */
17
+ function nativeLintRuleMetas() {
18
+ return fromJson(binding.nativeLintRuleMetasJson());
19
+ }
20
+ /** Classifies a TypeScript type string into the Rust fast-path type categories. */
21
+ function classifyTypeText(text) {
22
+ return binding.classifyTypeText(text);
23
+ }
24
+ /** Splits a type string by a top-level delimiter while respecting nested syntax. */
25
+ function splitTopLevelTypeText(text, delimiter) {
26
+ return binding.splitTopLevelTypeText(text, delimiter);
27
+ }
28
+ /** Splits a union/intersection-like type string into top-level constituents. */
29
+ function splitTypeText(text) {
30
+ return binding.splitTypeText(text);
31
+ }
32
+ /** Returns whether any supplied type text is string-like. */
33
+ function isStringLikeTypeTexts(typeTexts) {
34
+ return binding.isStringLikeTypeTexts([...typeTexts]);
35
+ }
36
+ /** Returns whether any supplied type text is number-like. */
37
+ function isNumberLikeTypeTexts(typeTexts) {
38
+ return binding.isNumberLikeTypeTexts([...typeTexts]);
39
+ }
40
+ /** Returns whether any supplied type text is bigint-like. */
41
+ function isBigIntLikeTypeTexts(typeTexts) {
42
+ return binding.isBigIntLikeTypeTexts([...typeTexts]);
43
+ }
44
+ /** Returns whether any supplied type text is `any`-like. */
45
+ function isAnyLikeTypeTexts(typeTexts) {
46
+ return binding.isAnyLikeTypeTexts([...typeTexts]);
47
+ }
48
+ /** Returns whether any supplied type text is `unknown`-like. */
49
+ function isUnknownLikeTypeTexts(typeTexts) {
50
+ return binding.isUnknownLikeTypeTexts([...typeTexts]);
51
+ }
52
+ /** Returns whether any supplied type text represents an array-like value. */
53
+ function isArrayLikeTypeTexts(typeTexts) {
54
+ return binding.isArrayLikeTypeTexts([...typeTexts]);
55
+ }
56
+ /** Returns whether any supplied type text represents an array of strings. */
57
+ function isStringArrayLikeTypeTexts(typeTexts) {
58
+ return binding.isStringArrayLikeTypeTexts([...typeTexts]);
59
+ }
60
+ /** Returns whether type text plus property names looks Promise-like. */
61
+ function isPromiseLikeTypeTexts(typeTexts, propertyNames = []) {
62
+ return binding.isPromiseLikeTypeTexts([...typeTexts], [...propertyNames]);
63
+ }
64
+ /** Returns whether type text plus property names looks Error-like. */
65
+ function isErrorLikeTypeTexts(typeTexts, propertyNames = []) {
66
+ return binding.isErrorLikeTypeTexts([...typeTexts], [...propertyNames]);
67
+ }
68
+ /** Namespaced utility export matching the previous public API shape. */
69
+ const Utils = Object.freeze({
70
+ classifyTypeText,
71
+ splitTopLevelTypeText,
72
+ splitTypeText,
73
+ isStringLikeTypeTexts,
74
+ isNumberLikeTypeTexts,
75
+ isBigIntLikeTypeTexts,
76
+ isAnyLikeTypeTexts,
77
+ isUnknownLikeTypeTexts,
78
+ isArrayLikeTypeTexts,
79
+ isStringArrayLikeTypeTexts,
80
+ isPromiseLikeTypeTexts,
81
+ isErrorLikeTypeTexts
82
+ });
83
+ //#endregion
84
+ export { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, nativeLintRuleMetas, runNativeLintRule, splitTopLevelTypeText, splitTypeText };
85
+
86
+ //# sourceMappingURL=native_utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native_utils.mjs","names":[],"sources":["../ts/native_utils.ts"],"sourcesContent":["import { binding } from \"./binding\";\nimport { fromJson, toJson } from \"./json\";\n\nimport type {\n NativeLintDiagnostic,\n NativeLintNode,\n NativeLintRuleMeta,\n TypeTextKind,\n UnsafeTypeFlowInput,\n} from \"./types\";\n\n/** Runs the Rust unsafe-assignment classifier against serialized type-flow data. */\nexport function isUnsafeAssignment(input: UnsafeTypeFlowInput): boolean {\n return binding.isUnsafeAssignment(toJson(input));\n}\n\n/** Runs the Rust unsafe-return classifier against serialized type-flow data. */\nexport function isUnsafeReturn(input: UnsafeTypeFlowInput): boolean {\n return binding.isUnsafeReturn(toJson(input));\n}\n\n/** Executes a native lint rule implementation and returns normalized diagnostics. */\nexport function runNativeLintRule(ruleName: string, node: NativeLintNode): NativeLintDiagnostic[] {\n return fromJson(binding.runNativeLintRule(ruleName, toJson(node)));\n}\n\n/** Lists rule metadata exposed by the Rust-backed native rule registry. */\nexport function nativeLintRuleMetas(): NativeLintRuleMeta[] {\n return fromJson(binding.nativeLintRuleMetasJson());\n}\n\n/** Classifies a TypeScript type string into the Rust fast-path type categories. */\nexport function classifyTypeText(text?: string): TypeTextKind {\n return binding.classifyTypeText(text) as TypeTextKind;\n}\n\n/** Splits a type string by a top-level delimiter while respecting nested syntax. */\nexport function splitTopLevelTypeText(text: string, delimiter: string): string[] {\n return binding.splitTopLevelTypeText(text, delimiter);\n}\n\n/** Splits a union/intersection-like type string into top-level constituents. */\nexport function splitTypeText(text: string): string[] {\n return binding.splitTypeText(text);\n}\n\n/** Returns whether any supplied type text is string-like. */\nexport function isStringLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isStringLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text is number-like. */\nexport function isNumberLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isNumberLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text is bigint-like. */\nexport function isBigIntLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isBigIntLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text is `any`-like. */\nexport function isAnyLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isAnyLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text is `unknown`-like. */\nexport function isUnknownLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isUnknownLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text represents an array-like value. */\nexport function isArrayLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isArrayLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether any supplied type text represents an array of strings. */\nexport function isStringArrayLikeTypeTexts(typeTexts: readonly string[]): boolean {\n return binding.isStringArrayLikeTypeTexts([...typeTexts]);\n}\n\n/** Returns whether type text plus property names looks Promise-like. */\nexport function isPromiseLikeTypeTexts(\n typeTexts: readonly string[],\n propertyNames: readonly string[] = [],\n): boolean {\n return binding.isPromiseLikeTypeTexts([...typeTexts], [...propertyNames]);\n}\n\n/** Returns whether type text plus property names looks Error-like. */\nexport function isErrorLikeTypeTexts(\n typeTexts: readonly string[],\n propertyNames: readonly string[] = [],\n): boolean {\n return binding.isErrorLikeTypeTexts([...typeTexts], [...propertyNames]);\n}\n\n/** Namespaced utility export matching the previous public API shape. */\nexport const Utils = Object.freeze({\n classifyTypeText,\n splitTopLevelTypeText,\n splitTypeText,\n isStringLikeTypeTexts,\n isNumberLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isAnyLikeTypeTexts,\n isUnknownLikeTypeTexts,\n isArrayLikeTypeTexts,\n isStringArrayLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isErrorLikeTypeTexts,\n});\n"],"mappings":";;;;AAYA,SAAgB,mBAAmB,OAAqC;CACtE,OAAO,QAAQ,mBAAmB,OAAO,MAAM,CAAC;;;AAIlD,SAAgB,eAAe,OAAqC;CAClE,OAAO,QAAQ,eAAe,OAAO,MAAM,CAAC;;;AAI9C,SAAgB,kBAAkB,UAAkB,MAA8C;CAChG,OAAO,SAAS,QAAQ,kBAAkB,UAAU,OAAO,KAAK,CAAC,CAAC;;;AAIpE,SAAgB,sBAA4C;CAC1D,OAAO,SAAS,QAAQ,yBAAyB,CAAC;;;AAIpD,SAAgB,iBAAiB,MAA6B;CAC5D,OAAO,QAAQ,iBAAiB,KAAK;;;AAIvC,SAAgB,sBAAsB,MAAc,WAA6B;CAC/E,OAAO,QAAQ,sBAAsB,MAAM,UAAU;;;AAIvD,SAAgB,cAAc,MAAwB;CACpD,OAAO,QAAQ,cAAc,KAAK;;;AAIpC,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;;AAItD,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;;AAItD,SAAgB,sBAAsB,WAAuC;CAC3E,OAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;;AAItD,SAAgB,mBAAmB,WAAuC;CACxE,OAAO,QAAQ,mBAAmB,CAAC,GAAG,UAAU,CAAC;;;AAInD,SAAgB,uBAAuB,WAAuC;CAC5E,OAAO,QAAQ,uBAAuB,CAAC,GAAG,UAAU,CAAC;;;AAIvD,SAAgB,qBAAqB,WAAuC;CAC1E,OAAO,QAAQ,qBAAqB,CAAC,GAAG,UAAU,CAAC;;;AAIrD,SAAgB,2BAA2B,WAAuC;CAChF,OAAO,QAAQ,2BAA2B,CAAC,GAAG,UAAU,CAAC;;;AAI3D,SAAgB,uBACd,WACA,gBAAmC,EAAE,EAC5B;CACT,OAAO,QAAQ,uBAAuB,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,cAAc,CAAC;;;AAI3E,SAAgB,qBACd,WACA,gBAAmC,EAAE,EAC5B;CACT,OAAO,QAAQ,qBAAqB,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,cAAc,CAAC;;;AAIzE,MAAa,QAAQ,OAAO,OAAO;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { VirtualChange, VirtualDocumentState } from "./types.mjs";
2
+
3
+ //#region virtual_document.d.ts
4
+ /** Mutable in-memory document used to drive LSP overlays without touching disk. */
5
+ declare class CorsaVirtualDocument {
6
+ #private;
7
+ private constructor();
8
+ /** Creates an untitled virtual document with an editor-like URI. */
9
+ static untitled(path: string, languageId: string, text: string): CorsaVirtualDocument;
10
+ /** Creates an in-memory virtual document under the supplied URI authority. */
11
+ static inMemory(authority: string, path: string, languageId: string, text: string): CorsaVirtualDocument;
12
+ /** Canonical document URI consumed by LSP overlay APIs. */
13
+ get uri(): string;
14
+ /** LSP language id associated with the virtual document. */
15
+ get languageId(): string;
16
+ /** Monotonic version incremented whenever text changes. */
17
+ get version(): number;
18
+ /** Current full document text. */
19
+ get text(): string;
20
+ /** Returns the serializable document state for orchestrator or LSP APIs. */
21
+ state(): VirtualDocumentState;
22
+ /** Replaces the entire virtual document text. */
23
+ replace(text: string): void;
24
+ /** Applies LSP-style incremental changes and returns generated change events. */
25
+ applyChanges(changes: VirtualChange[]): unknown[];
26
+ }
27
+ //#endregion
28
+ export { CorsaVirtualDocument };
29
+ //# sourceMappingURL=virtual_document.d.mts.map
@@ -0,0 +1,50 @@
1
+ import { binding } from "./binding.mjs";
2
+ import { fromJson, toJson } from "./json.mjs";
3
+ //#region virtual_document.ts
4
+ /** Mutable in-memory document used to drive LSP overlays without touching disk. */
5
+ var CorsaVirtualDocument = class CorsaVirtualDocument {
6
+ #inner;
7
+ constructor(inner) {
8
+ this.#inner = inner;
9
+ }
10
+ /** Creates an untitled virtual document with an editor-like URI. */
11
+ static untitled(path, languageId, text) {
12
+ return new CorsaVirtualDocument(binding.CorsaVirtualDocument.untitled(path, languageId, text));
13
+ }
14
+ /** Creates an in-memory virtual document under the supplied URI authority. */
15
+ static inMemory(authority, path, languageId, text) {
16
+ return new CorsaVirtualDocument(binding.CorsaVirtualDocument.inMemory(authority, path, languageId, text));
17
+ }
18
+ /** Canonical document URI consumed by LSP overlay APIs. */
19
+ get uri() {
20
+ return this.#inner.uri;
21
+ }
22
+ /** LSP language id associated with the virtual document. */
23
+ get languageId() {
24
+ return this.#inner.languageId;
25
+ }
26
+ /** Monotonic version incremented whenever text changes. */
27
+ get version() {
28
+ return this.#inner.version;
29
+ }
30
+ /** Current full document text. */
31
+ get text() {
32
+ return this.#inner.text;
33
+ }
34
+ /** Returns the serializable document state for orchestrator or LSP APIs. */
35
+ state() {
36
+ return fromJson(this.#inner.stateJson());
37
+ }
38
+ /** Replaces the entire virtual document text. */
39
+ replace(text) {
40
+ this.#inner.replace(text);
41
+ }
42
+ /** Applies LSP-style incremental changes and returns generated change events. */
43
+ applyChanges(changes) {
44
+ return fromJson(this.#inner.applyChangesJson(toJson(changes)));
45
+ }
46
+ };
47
+ //#endregion
48
+ export { CorsaVirtualDocument };
49
+
50
+ //# sourceMappingURL=virtual_document.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual_document.mjs","names":["#inner"],"sources":["../ts/virtual_document.ts"],"sourcesContent":["import { binding } from \"./binding\";\nimport { fromJson, toJson } from \"./json\";\n\nimport type { NativeVirtualDocument } from \"./binding\";\nimport type { VirtualChange, VirtualDocumentState } from \"./types\";\n\n/** Mutable in-memory document used to drive LSP overlays without touching disk. */\nexport class CorsaVirtualDocument {\n readonly #inner: NativeVirtualDocument;\n\n private constructor(inner: NativeVirtualDocument) {\n this.#inner = inner;\n }\n\n /** Creates an untitled virtual document with an editor-like URI. */\n static untitled(path: string, languageId: string, text: string): CorsaVirtualDocument {\n return new CorsaVirtualDocument(binding.CorsaVirtualDocument.untitled(path, languageId, text));\n }\n\n /** Creates an in-memory virtual document under the supplied URI authority. */\n static inMemory(\n authority: string,\n path: string,\n languageId: string,\n text: string,\n ): CorsaVirtualDocument {\n return new CorsaVirtualDocument(\n binding.CorsaVirtualDocument.inMemory(authority, path, languageId, text),\n );\n }\n\n /** Canonical document URI consumed by LSP overlay APIs. */\n get uri(): string {\n return this.#inner.uri;\n }\n\n /** LSP language id associated with the virtual document. */\n get languageId(): string {\n return this.#inner.languageId;\n }\n\n /** Monotonic version incremented whenever text changes. */\n get version(): number {\n return this.#inner.version;\n }\n\n /** Current full document text. */\n get text(): string {\n return this.#inner.text;\n }\n\n /** Returns the serializable document state for orchestrator or LSP APIs. */\n state(): VirtualDocumentState {\n return fromJson(this.#inner.stateJson());\n }\n\n /** Replaces the entire virtual document text. */\n replace(text: string): void {\n this.#inner.replace(text);\n }\n\n /** Applies LSP-style incremental changes and returns generated change events. */\n applyChanges(changes: VirtualChange[]): unknown[] {\n return fromJson(this.#inner.applyChangesJson(toJson(changes)));\n }\n}\n"],"mappings":";;;;AAOA,IAAa,uBAAb,MAAa,qBAAqB;CAChC;CAEA,YAAoB,OAA8B;EAChD,KAAKA,SAAS;;;CAIhB,OAAO,SAAS,MAAc,YAAoB,MAAoC;EACpF,OAAO,IAAI,qBAAqB,QAAQ,qBAAqB,SAAS,MAAM,YAAY,KAAK,CAAC;;;CAIhG,OAAO,SACL,WACA,MACA,YACA,MACsB;EACtB,OAAO,IAAI,qBACT,QAAQ,qBAAqB,SAAS,WAAW,MAAM,YAAY,KAAK,CACzE;;;CAIH,IAAI,MAAc;EAChB,OAAO,KAAKA,OAAO;;;CAIrB,IAAI,aAAqB;EACvB,OAAO,KAAKA,OAAO;;;CAIrB,IAAI,UAAkB;EACpB,OAAO,KAAKA,OAAO;;;CAIrB,IAAI,OAAe;EACjB,OAAO,KAAKA,OAAO;;;CAIrB,QAA8B;EAC5B,OAAO,SAAS,KAAKA,OAAO,WAAW,CAAC;;;CAI1C,QAAQ,MAAoB;EAC1B,KAAKA,OAAO,QAAQ,KAAK;;;CAI3B,aAAa,SAAqC;EAChD,OAAO,SAAS,KAAKA,OAAO,iBAAiB,OAAO,QAAQ,CAAC,CAAC"}