@corsa-bind/napi 0.3.1 → 0.4.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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState } from "./types.mjs";
1
+ import { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SymbolResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState } from "./types.mjs";
2
2
  import * as ___index_js0 from "../index.js";
3
3
 
4
4
  //#region index.d.ts
@@ -38,6 +38,11 @@ declare class CorsaApiClient {
38
38
  updateSnapshot(params?: UpdateSnapshotParams): UpdateSnapshotResponse;
39
39
  getSourceFile(snapshot: string, project: string, file: string): Uint8Array | null;
40
40
  getStringType(snapshot: string, project: string): TypeResponse;
41
+ getTypeAtPosition(snapshot: string, project: string, file: string, position: number): TypeResponse | undefined;
42
+ getSymbolAtPosition(snapshot: string, project: string, file: string, position: number): SymbolResponse | undefined;
43
+ getTypeArguments(snapshot: string, project: string, typeHandle: string, objectFlags?: number): TypeResponse[];
44
+ getTypeOfSymbol(snapshot: string, project: string, symbol: string): TypeResponse | undefined;
45
+ getDeclaredTypeOfSymbol(snapshot: string, project: string, symbol: string): TypeResponse | undefined;
41
46
  typeToString(snapshot: string, project: string, typeHandle: string, location?: string, flags?: number): string;
42
47
  callJson<T>(method: string, params?: unknown): T;
43
48
  callBinary(method: string, params?: unknown): Uint8Array | null;
@@ -72,5 +77,5 @@ declare class CorsaDistributedOrchestrator {
72
77
  }
73
78
  declare const version: typeof ___index_js0.version;
74
79
  //#endregion
75
- export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, CorsaApiClient, CorsaApiClient as TsgoApiClient, CorsaDistributedOrchestrator, CorsaDistributedOrchestrator as TsgoDistributedOrchestrator, CorsaVirtualDocument, CorsaVirtualDocument as TsgoVirtualDocument, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, Utils, VirtualChange, VirtualDocumentState, classifyTypeText, binding as default, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, splitTopLevelTypeText, splitTypeText, version };
80
+ export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, CorsaApiClient, CorsaApiClient as TsgoApiClient, CorsaDistributedOrchestrator, CorsaDistributedOrchestrator as TsgoDistributedOrchestrator, CorsaVirtualDocument, CorsaVirtualDocument as TsgoVirtualDocument, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, 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, isStringLikeTypeTexts, isUnknownLikeTypeTexts, isUnsafeAssignment, isUnsafeReturn, splitTopLevelTypeText, splitTypeText, version };
76
81
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -82,6 +82,21 @@ var CorsaApiClient = class CorsaApiClient {
82
82
  getStringType(snapshot, project) {
83
83
  return fromJson(this.#inner.getStringTypeJson(snapshot, project));
84
84
  }
85
+ getTypeAtPosition(snapshot, project, file, position) {
86
+ return fromJson(this.#inner.getTypeAtPositionJson(snapshot, project, file, position)) ?? void 0;
87
+ }
88
+ getSymbolAtPosition(snapshot, project, file, position) {
89
+ return fromJson(this.#inner.getSymbolAtPositionJson(snapshot, project, file, position)) ?? void 0;
90
+ }
91
+ getTypeArguments(snapshot, project, typeHandle, objectFlags) {
92
+ return fromJson(this.#inner.getTypeArgumentsJson(snapshot, project, typeHandle, objectFlags));
93
+ }
94
+ getTypeOfSymbol(snapshot, project, symbol) {
95
+ return fromJson(this.#inner.getTypeOfSymbolJson(snapshot, project, symbol)) ?? void 0;
96
+ }
97
+ getDeclaredTypeOfSymbol(snapshot, project, symbol) {
98
+ return fromJson(this.#inner.getDeclaredTypeOfSymbolJson(snapshot, project, symbol)) ?? void 0;
99
+ }
85
100
  typeToString(snapshot, project, typeHandle, location, flags) {
86
101
  return this.#inner.typeToString(snapshot, project, typeHandle, location, flags);
87
102
  }
@@ -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 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.TsgoApiClient>;\ntype NativeDistributedOrchestrator = InstanceType<typeof binding.TsgoDistributedOrchestrator>;\ntype NativeVirtualDocument = InstanceType<typeof binding.TsgoVirtualDocument>;\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 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 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 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.TsgoApiClient.spawn(toJson(options)));\n }\n\n initialize(): InitializeResponse {\n return fromJson(this.#inner.initializeJson());\n }\n\n parseConfigFile(file: string): ConfigResponse {\n return fromJson(this.#inner.parseConfigFileJson(file));\n }\n\n updateSnapshot(params?: UpdateSnapshotParams): UpdateSnapshotResponse {\n return fromJson(this.#inner.updateSnapshotJson(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 getStringType(snapshot: string, project: string): TypeResponse {\n return fromJson(this.#inner.getStringTypeJson(snapshot, project));\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 callJson<T>(method: string, params?: unknown): T {\n return fromJson(this.#inner.callJson(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 releaseHandle(handle: string): void {\n this.#inner.releaseHandle(handle);\n }\n\n close(): void {\n this.#inner.close();\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.TsgoVirtualDocument.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.TsgoVirtualDocument.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.TsgoDistributedOrchestrator(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 {\n CorsaApiClient as TsgoApiClient,\n CorsaDistributedOrchestrator as TsgoDistributedOrchestrator,\n CorsaVirtualDocument as TsgoVirtualDocument,\n};\n\nexport default binding;\nexport const version = binding.version;\nexport type * from \"./types\";\n"],"mappings":";;AAeA,MAAM,UACJ,aAAa,eAAe,aAAa,UAAU;AAOrD,SAAS,SAAY,OAAkB;AACrC,QAAO,KAAK,MAAM,MAAM;;AAG1B,SAAS,OAAO,OAAwB;AACtC,QAAO,KAAK,UAAU,SAAS,KAAK;;AAGtC,SAAgB,mBAAmB,OAAqC;AACtE,QAAO,QAAQ,mBAAmB,OAAO,MAAM,CAAC;;AAGlD,SAAgB,eAAe,OAAqC;AAClE,QAAO,QAAQ,eAAe,OAAO,MAAM,CAAC;;AAG9C,SAAgB,iBAAiB,MAA6B;AAC5D,QAAO,QAAQ,iBAAiB,KAAK;;AAGvC,SAAgB,sBAAsB,MAAc,WAA6B;AAC/E,QAAO,QAAQ,sBAAsB,MAAM,UAAU;;AAGvD,SAAgB,cAAc,MAAwB;AACpD,QAAO,QAAQ,cAAc,KAAK;;AAGpC,SAAgB,sBAAsB,WAAuC;AAC3E,QAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;AAGtD,SAAgB,sBAAsB,WAAuC;AAC3E,QAAO,QAAQ,sBAAsB,CAAC,GAAG,UAAU,CAAC;;AAGtD,SAAgB,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AGhE,SAAS,QAAwB;AAC/B,SAAO,MAAA,MAAY,SAAS,OAAO;;CAGrC,WAA+B;AAC7B,SAAO,MAAA,MAAY,UAAU,IAAI,KAAA;;CAGnC,QAA0B;EACxB,MAAM,QAAQ,MAAA,MAAY,WAAW;AACrC,SAAO,QAAQ,SAAY,MAAM,GAAG,KAAA;;CAGtC,UAAa,QAA+B;EAC1C,MAAM,QAAQ,MAAA,MAAY,cAAc,OAAO;AAC/C,SAAO,QAAQ,SAAY,MAAM,GAAG,KAAA;;CAGtC,SAAS,QAAgB,KAA+C;EACtE,MAAM,QAAQ,MAAA,MAAY,aAAa,QAAQ,IAAI;AACnD,SAAO,QAAQ,SAA+B,MAAM,GAAG,KAAA;;CAGzD,oBAAoB,UAAsD;AACxE,SAAO,SAAS,MAAA,MAAY,wBAAwB,KAAK,eAAe,EAAE,OAAO,SAAS,CAAC,CAAC;;CAG9F,sBAAsB,KAAa,SAAgD;AACjF,SAAO,SACL,MAAA,MAAY,0BAA0B,KAAK,eAAe,EAAE,KAAK,OAAO,QAAQ,CAAC,CAClF;;CAGH,qBAAqB,KAAmB;AACtC,QAAA,MAAY,qBAAqB,KAAK,eAAe,EAAE,IAAI;;CAG7D,gBAAgC;EAC9B,MAAM,WAAW,KAAK,UAAU;AAChC,MAAI,CAAC,SACH,OAAM,IAAI,MAAM,mCAAmC;AAErD,SAAO;;;AAWX,MAAa,UAAU,QAAQ"}
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 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.TsgoApiClient>;\ntype NativeDistributedOrchestrator = InstanceType<typeof binding.TsgoDistributedOrchestrator>;\ntype NativeVirtualDocument = InstanceType<typeof binding.TsgoVirtualDocument>;\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 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 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 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.TsgoApiClient.spawn(toJson(options)));\n }\n\n initialize(): InitializeResponse {\n return fromJson(this.#inner.initializeJson());\n }\n\n parseConfigFile(file: string): ConfigResponse {\n return fromJson(this.#inner.parseConfigFileJson(file));\n }\n\n updateSnapshot(params?: UpdateSnapshotParams): UpdateSnapshotResponse {\n return fromJson(this.#inner.updateSnapshotJson(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 getStringType(snapshot: string, project: string): TypeResponse {\n return fromJson(this.#inner.getStringTypeJson(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 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 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 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 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 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 callJson<T>(method: string, params?: unknown): T {\n return fromJson(this.#inner.callJson(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 releaseHandle(handle: string): void {\n this.#inner.releaseHandle(handle);\n }\n\n close(): void {\n this.#inner.close();\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.TsgoVirtualDocument.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.TsgoVirtualDocument.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.TsgoDistributedOrchestrator(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 {\n CorsaApiClient as TsgoApiClient,\n CorsaDistributedOrchestrator as TsgoDistributedOrchestrator,\n CorsaVirtualDocument as TsgoVirtualDocument,\n};\n\nexport default binding;\nexport const version = binding.version;\nexport type * from \"./types\";\n"],"mappings":";;AAgBA,MAAM,UACJ,aAAa,eAAe,aAAa,UAAU;AAOrD,SAAS,SAAY,OAAkB;AACrC,QAAO,KAAK,MAAM,MAAM;;AAG1B,SAAS,OAAO,OAAwB;AACtC,QAAO,KAAK,UAAU,SAAS,KAAK;;AAGtC,SAAgB,mBAAmB,OAAqC;AACtE,QAAO,QAAQ,mB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M,GAAG,KAAA;;CAGtC,UAAa,QAA+B;EAC1C,MAAM,QAAQ,MAAA,MAAY,cAAc,OAAO;AAC/C,SAAO,QAAQ,SAAY,MAAM,GAAG,KAAA;;CAGtC,SAAS,QAAgB,KAA+C;EACtE,MAAM,QAAQ,MAAA,MAAY,aAAa,QAAQ,IAAI;AACnD,SAAO,QAAQ,SAA+B,MAAM,GAAG,KAAA;;CAGzD,oBAAoB,UAAsD;AACxE,SAAO,SAAS,MAAA,MAAY,wBAAwB,KAAK,eAAe,EAAE,OAAO,SAAS,CAAC,CAAC;;CAG9F,sBAAsB,KAAa,SAAgD;AACjF,SAAO,SACL,MAAA,MAAY,0BAA0B,KAAK,eAAe,EAAE,KAAK,OAAO,QAAQ,CAAC,CAClF;;CAGH,qBAAqB,KAAmB;AACtC,QAAA,MAAY,qBAAqB,KAAK,eAAe,EAAE,IAAI;;CAG7D,gBAAgC;EAC9B,MAAM,WAAW,KAAK,UAAU;AAChC,MAAI,CAAC,SACH,OAAM,IAAI,MAAM,mCAAmC;AAErD,SAAO;;;AAWX,MAAa,UAAU,QAAQ"}
package/dist/types.d.mts CHANGED
@@ -52,6 +52,14 @@ interface TypeResponse {
52
52
  symbol?: string;
53
53
  texts: string[];
54
54
  }
55
+ interface SymbolResponse {
56
+ id: string;
57
+ name: string;
58
+ flags: number;
59
+ checkFlags: number;
60
+ declarations: string[];
61
+ valueDeclaration?: string;
62
+ }
55
63
  interface OverlayUpdate {
56
64
  document: DocumentIdentifier;
57
65
  text: string;
@@ -129,5 +137,5 @@ interface VirtualDocumentState {
129
137
  text: string;
130
138
  }
131
139
  //#endregion
132
- export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState };
140
+ export { ApiClientOptions, ApiMode, CapabilitiesResponse, ConfigResponse, DiagnosticsCapabilities, DocumentIdentifier, EditorCapabilities, FileChangeSummary, FileChanges, FileDiagnosticsResponse, InitializeResponse, OverlayCapabilities, OverlayChanges, OverlayUpdate, ProjectDiagnosticsResponse, ProjectResponse, RuntimeCapabilities, SnapshotDiagnosticsResponse, SymbolResponse, TypeResponse, TypeTextKind, UnsafeTypeFlowInput, UpdateSnapshotParams, UpdateSnapshotResponse, VirtualChange, VirtualDocumentState };
133
141
  //# sourceMappingURL=types.d.mts.map
package/index.d.ts CHANGED
@@ -40,6 +40,16 @@ export declare class TsgoApiClient {
40
40
  getSourceFile(snapshot: string, project: string, file: string): Buffer | null
41
41
  /** Resolves the intrinsic string type for a project. */
42
42
  getStringTypeJson(snapshot: string, project: string): string
43
+ /** Resolves the checker type visible at a file position. */
44
+ getTypeAtPositionJson(snapshot: string, project: string, file: string, position: number): string
45
+ /** Resolves the checker symbol visible at a file position. */
46
+ getSymbolAtPositionJson(snapshot: string, project: string, file: string, position: number): string
47
+ /** Resolves type arguments for type-reference objects and returns [] otherwise. */
48
+ getTypeArgumentsJson(snapshot: string, project: string, typeHandle: string, objectFlags?: number | undefined | null): string
49
+ /** Resolves the apparent checker type of a symbol. */
50
+ getTypeOfSymbolJson(snapshot: string, project: string, symbol: string): string
51
+ /** Resolves the declared checker type of a symbol. */
52
+ getDeclaredTypeOfSymbolJson(snapshot: string, project: string, symbol: string): string
43
53
  /** Renders a type back to a string representation. */
44
54
  typeToString(snapshot: string, project: string, typeHandle: string, location?: string | undefined | null, flags?: number | undefined | null): string
45
55
  /** Sends an arbitrary JSON endpoint request. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsa-bind/napi",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Native Node.js bindings for corsa and typescript-go stdio workflows",
5
5
  "homepage": "https://github.com/ubugeeei/corsa-bind/tree/main/src/bindings/nodejs/corsa_node",
6
6
  "bugs": {
@@ -46,13 +46,13 @@
46
46
  "node": ">=22"
47
47
  },
48
48
  "optionalDependencies": {
49
- "@corsa-bind/napi-win32-x64-msvc": "0.3.1",
50
- "@corsa-bind/napi-darwin-x64": "0.3.1",
51
- "@corsa-bind/napi-linux-x64-gnu": "0.3.1",
52
- "@corsa-bind/napi-darwin-arm64": "0.3.1",
53
- "@corsa-bind/napi-win32-arm64-msvc": "0.3.1",
54
- "@corsa-bind/napi-linux-x64-musl": "0.3.1",
55
- "@corsa-bind/napi-linux-arm64-gnu": "0.3.1",
56
- "@corsa-bind/napi-linux-arm64-musl": "0.3.1"
49
+ "@corsa-bind/napi-win32-x64-msvc": "0.4.0",
50
+ "@corsa-bind/napi-darwin-x64": "0.4.0",
51
+ "@corsa-bind/napi-linux-x64-gnu": "0.4.0",
52
+ "@corsa-bind/napi-darwin-arm64": "0.4.0",
53
+ "@corsa-bind/napi-win32-arm64-msvc": "0.4.0",
54
+ "@corsa-bind/napi-linux-x64-musl": "0.4.0",
55
+ "@corsa-bind/napi-linux-arm64-gnu": "0.4.0",
56
+ "@corsa-bind/napi-linux-arm64-musl": "0.4.0"
57
57
  }
58
58
  }