@lspeasy/core 2.1.2 → 2.1.3

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 (123) hide show
  1. package/dist/index.d.ts +44 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +44 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/jsonrpc/framing.d.ts +28 -3
  6. package/dist/jsonrpc/framing.d.ts.map +1 -1
  7. package/dist/jsonrpc/framing.js +28 -3
  8. package/dist/jsonrpc/framing.js.map +1 -1
  9. package/dist/jsonrpc/messages.d.ts +105 -8
  10. package/dist/jsonrpc/messages.d.ts.map +1 -1
  11. package/dist/jsonrpc/messages.js +36 -0
  12. package/dist/jsonrpc/messages.js.map +1 -1
  13. package/dist/jsonrpc/reader.js.map +1 -1
  14. package/dist/jsonrpc/writer.js.map +1 -1
  15. package/dist/middleware/compose.d.ts +22 -0
  16. package/dist/middleware/compose.d.ts.map +1 -1
  17. package/dist/middleware/compose.js +22 -0
  18. package/dist/middleware/compose.js.map +1 -1
  19. package/dist/middleware/pipeline.d.ts +22 -0
  20. package/dist/middleware/pipeline.d.ts.map +1 -1
  21. package/dist/middleware/pipeline.js +22 -0
  22. package/dist/middleware/pipeline.js.map +1 -1
  23. package/dist/middleware/scoped.d.ts +28 -0
  24. package/dist/middleware/scoped.d.ts.map +1 -1
  25. package/dist/middleware/scoped.js +28 -0
  26. package/dist/middleware/scoped.js.map +1 -1
  27. package/dist/middleware/typed.d.ts +30 -0
  28. package/dist/middleware/typed.d.ts.map +1 -1
  29. package/dist/middleware/typed.js +30 -0
  30. package/dist/middleware/typed.js.map +1 -1
  31. package/dist/middleware/types.d.ts +173 -0
  32. package/dist/middleware/types.d.ts.map +1 -1
  33. package/dist/protocol/capabilities.d.ts +78 -12
  34. package/dist/protocol/capabilities.d.ts.map +1 -1
  35. package/dist/protocol/capabilities.js +78 -12
  36. package/dist/protocol/capabilities.js.map +1 -1
  37. package/dist/protocol/capability-methods.d.ts +70 -2
  38. package/dist/protocol/capability-methods.d.ts.map +1 -1
  39. package/dist/protocol/capability-methods.js +8 -0
  40. package/dist/protocol/capability-methods.js.map +1 -1
  41. package/dist/protocol/dynamic-registration.d.ts +34 -2
  42. package/dist/protocol/dynamic-registration.d.ts.map +1 -1
  43. package/dist/protocol/dynamic-registration.js +16 -2
  44. package/dist/protocol/dynamic-registration.js.map +1 -1
  45. package/dist/protocol/enums.js +40 -80
  46. package/dist/protocol/enums.js.map +1 -1
  47. package/dist/protocol/infer.d.ts +92 -4
  48. package/dist/protocol/infer.d.ts.map +1 -1
  49. package/dist/protocol/infer.js +46 -4
  50. package/dist/protocol/infer.js.map +1 -1
  51. package/dist/protocol/namespaces.d.ts +327 -327
  52. package/dist/protocol/namespaces.d.ts.map +1 -1
  53. package/dist/protocol/partial-results.d.ts +6 -0
  54. package/dist/protocol/partial-results.d.ts.map +1 -1
  55. package/dist/protocol/partial.d.ts +12 -3
  56. package/dist/protocol/partial.d.ts.map +1 -1
  57. package/dist/protocol/partial.js +12 -3
  58. package/dist/protocol/partial.js.map +1 -1
  59. package/dist/protocol/progress.d.ts +34 -4
  60. package/dist/protocol/progress.d.ts.map +1 -1
  61. package/dist/protocol/progress.js +34 -4
  62. package/dist/protocol/progress.js.map +1 -1
  63. package/dist/protocol/schemas.d.ts +4 -1
  64. package/dist/protocol/schemas.d.ts.map +1 -1
  65. package/dist/protocol/schemas.js +4 -1
  66. package/dist/protocol/schemas.js.map +1 -1
  67. package/dist/protocol/watching.d.ts +18 -7
  68. package/dist/protocol/watching.d.ts.map +1 -1
  69. package/dist/protocol/watching.js +14 -3
  70. package/dist/protocol/watching.js.map +1 -1
  71. package/dist/protocol/workspace.d.ts +10 -2
  72. package/dist/protocol/workspace.d.ts.map +1 -1
  73. package/dist/protocol/workspace.js +10 -2
  74. package/dist/protocol/workspace.js.map +1 -1
  75. package/dist/transport/dedicated-worker.js.map +1 -1
  76. package/dist/transport/events.js.map +1 -1
  77. package/dist/transport/ipc.js.map +1 -1
  78. package/dist/transport/shared-worker.js.map +1 -1
  79. package/dist/transport/stdio.js.map +1 -1
  80. package/dist/transport/tcp.js.map +1 -1
  81. package/dist/transport/transport.d.ts +91 -10
  82. package/dist/transport/transport.d.ts.map +1 -1
  83. package/dist/transport/websocket.d.ts +120 -19
  84. package/dist/transport/websocket.d.ts.map +1 -1
  85. package/dist/transport/websocket.js +95 -8
  86. package/dist/transport/websocket.js.map +1 -1
  87. package/dist/transport/worker-types.d.ts +16 -2
  88. package/dist/transport/worker-types.d.ts.map +1 -1
  89. package/dist/transport/worker-types.js +12 -2
  90. package/dist/transport/worker-types.js.map +1 -1
  91. package/dist/utils/cancellation.d.ts +75 -5
  92. package/dist/utils/cancellation.d.ts.map +1 -1
  93. package/dist/utils/cancellation.js +29 -1
  94. package/dist/utils/cancellation.js.map +1 -1
  95. package/dist/utils/capability-guard.d.ts +32 -1
  96. package/dist/utils/capability-guard.d.ts.map +1 -1
  97. package/dist/utils/capability-guard.js +32 -1
  98. package/dist/utils/capability-guard.js.map +1 -1
  99. package/dist/utils/disposable-event-emitter.d.ts +11 -0
  100. package/dist/utils/disposable-event-emitter.d.ts.map +1 -1
  101. package/dist/utils/disposable-event-emitter.js +11 -0
  102. package/dist/utils/disposable-event-emitter.js.map +1 -1
  103. package/dist/utils/disposable.d.ts +42 -3
  104. package/dist/utils/disposable.d.ts.map +1 -1
  105. package/dist/utils/disposable.js +34 -2
  106. package/dist/utils/disposable.js.map +1 -1
  107. package/dist/utils/document.d.ts +78 -3
  108. package/dist/utils/document.d.ts.map +1 -1
  109. package/dist/utils/document.js +73 -3
  110. package/dist/utils/document.js.map +1 -1
  111. package/dist/utils/errors.d.ts +87 -10
  112. package/dist/utils/errors.d.ts.map +1 -1
  113. package/dist/utils/errors.js +87 -10
  114. package/dist/utils/errors.js.map +1 -1
  115. package/dist/utils/handler-registry.js.map +1 -1
  116. package/dist/utils/logger.d.ts +79 -4
  117. package/dist/utils/logger.d.ts.map +1 -1
  118. package/dist/utils/logger.js +64 -5
  119. package/dist/utils/logger.js.map +1 -1
  120. package/dist/utils/pending-request-tracker.d.ts.map +1 -1
  121. package/dist/utils/pending-request-tracker.js.map +1 -1
  122. package/dist/utils/transport-attachment.js.map +1 -1
  123. package/package.json +5 -6
@@ -1,23 +1,66 @@
1
1
  import type { DidChangeTextDocumentParams, Range } from 'vscode-languageserver-protocol';
2
2
  /**
3
- * Tracks per-document versions for change notifications.
3
+ * Tracks monotonically increasing version numbers for open text documents.
4
+ *
5
+ * @remarks
6
+ * The LSP spec requires `DidChangeTextDocumentParams.textDocument.version` to
7
+ * increment with every change notification. Use `DocumentVersionTracker` to
8
+ * manage version numbers centrally rather than maintaining ad-hoc counters in
9
+ * each document model.
10
+ *
11
+ * @useWhen
12
+ * You are building an LSP client that sends `textDocument/didChange`
13
+ * notifications and need to track per-document version counters.
14
+ *
15
+ * @never
16
+ * NEVER send a `textDocument/didChange` with the same version number as a
17
+ * previous change for the same document. The server may reject the change as
18
+ * a no-op or apply it out of order, causing text state desync.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { DocumentVersionTracker, createIncrementalDidChangeParams } from '@lspeasy/core';
23
+ *
24
+ * const tracker = new DocumentVersionTracker();
25
+ * tracker.open('file:///src/main.ts');
26
+ *
27
+ * const params = createIncrementalDidChangeParams(
28
+ * 'file:///src/main.ts',
29
+ * [{ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } }, text: 'hello' }],
30
+ * { tracker }
31
+ * );
32
+ * await client.sendNotification('textDocument/didChange', params);
33
+ * ```
34
+ *
35
+ * @category Document
4
36
  */
5
37
  export declare class DocumentVersionTracker {
6
38
  private readonly versions;
7
39
  /**
8
40
  * Starts tracking a document URI with an optional initial version.
41
+ *
42
+ * @param uri - The document URI to start tracking.
43
+ * @param initialVersion - Starting version number (defaults to `0`).
9
44
  */
10
45
  open(uri: string, initialVersion?: number): void;
11
46
  /**
12
47
  * Increments and returns the next document version.
48
+ *
49
+ * @param uri - The document URI to increment.
50
+ * @returns The incremented version number.
13
51
  */
14
52
  nextVersion(uri: string): number;
15
53
  /**
16
54
  * Returns the current tracked version, if any.
55
+ *
56
+ * @param uri - The document URI to query.
57
+ * @returns The current version number, or `undefined` if the document is not tracked.
17
58
  */
18
59
  currentVersion(uri: string): number | undefined;
19
60
  /**
20
61
  * Stops tracking a document URI.
62
+ *
63
+ * @param uri - The document URI to stop tracking.
21
64
  */
22
65
  close(uri: string): void;
23
66
  }
@@ -25,23 +68,55 @@ export declare class DocumentVersionTracker {
25
68
  * Source of version information for helper constructors.
26
69
  */
27
70
  export interface VersionSource {
71
+ /** Explicit version number to use; takes precedence over `tracker`. */
28
72
  version?: number;
73
+ /** A `DocumentVersionTracker` instance to auto-increment the version. */
29
74
  tracker?: DocumentVersionTracker;
30
75
  }
31
76
  /**
32
77
  * Represents a single incremental text document change.
33
78
  */
34
79
  export interface IncrementalChange {
80
+ /** The range in the document that was replaced. */
35
81
  range: Range;
82
+ /** The new text that replaced the range. */
36
83
  text: string;
84
+ /** Optional deprecated length of the replaced range, used by some servers for backwards compat. */
37
85
  rangeLength?: number;
38
86
  }
39
87
  /**
40
- * Creates incremental didChange params from one or more range edits.
88
+ * Builds `DidChangeTextDocumentParams` for an incremental (range-based)
89
+ * document change notification.
90
+ *
91
+ * @remarks
92
+ * Use when the client tracks individual edits (e.g. single-character
93
+ * insertions, deletions) rather than sending the full document text on each
94
+ * change. Requires the server to have `textDocumentSync.change = Incremental`.
95
+ *
96
+ * @param uri - The document URI.
97
+ * @param changes - One or more range-based text changes.
98
+ * @param source - Either an explicit `version` number or a `tracker` instance.
99
+ * @returns A `DidChangeTextDocumentParams` ready to send.
100
+ * @throws If neither `version` nor `tracker` is provided.
101
+ *
102
+ * @category Document
41
103
  */
42
104
  export declare function createIncrementalDidChangeParams(uri: string, changes: IncrementalChange[], source: VersionSource): DidChangeTextDocumentParams;
43
105
  /**
44
- * Creates full-document didChange params for full text replacement.
106
+ * Builds `DidChangeTextDocumentParams` for a full-document text replacement.
107
+ *
108
+ * @remarks
109
+ * Use when the server only supports full-text synchronisation
110
+ * (`textDocumentSync.change = Full`) or when tracking individual edits is
111
+ * impractical (e.g. clipboard paste of a large file).
112
+ *
113
+ * @param uri - The document URI.
114
+ * @param text - The complete new document text.
115
+ * @param source - Either an explicit `version` number or a `tracker` instance.
116
+ * @returns A `DidChangeTextDocumentParams` ready to send.
117
+ * @throws If neither `version` nor `tracker` is provided.
118
+ *
119
+ * @category Document
45
120
  */
46
121
  export declare function createFullDidChangeParams(uri: string, text: string, source: VersionSource): DidChangeTextDocumentParams;
47
122
  //# sourceMappingURL=document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/utils/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,KAAK,EAGN,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAEtD;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,IAAI,CAElD;IAED;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/B;IAED;;OAEG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9C;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEvB;CACF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqBD;;GAEG;AACH,wB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M,EACX,OAAO,EAAE,iBAAiB,EAAE,EAC5B,MAAM,EAAE,aAAa,GACpB,2BAA2B,CAY7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,GACpB,2BAA2B,CAQ7B"}
@@ -1,16 +1,54 @@
1
1
  /**
2
- * Tracks per-document versions for change notifications.
2
+ * Tracks monotonically increasing version numbers for open text documents.
3
+ *
4
+ * @remarks
5
+ * The LSP spec requires `DidChangeTextDocumentParams.textDocument.version` to
6
+ * increment with every change notification. Use `DocumentVersionTracker` to
7
+ * manage version numbers centrally rather than maintaining ad-hoc counters in
8
+ * each document model.
9
+ *
10
+ * @useWhen
11
+ * You are building an LSP client that sends `textDocument/didChange`
12
+ * notifications and need to track per-document version counters.
13
+ *
14
+ * @never
15
+ * NEVER send a `textDocument/didChange` with the same version number as a
16
+ * previous change for the same document. The server may reject the change as
17
+ * a no-op or apply it out of order, causing text state desync.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { DocumentVersionTracker, createIncrementalDidChangeParams } from '@lspeasy/core';
22
+ *
23
+ * const tracker = new DocumentVersionTracker();
24
+ * tracker.open('file:///src/main.ts');
25
+ *
26
+ * const params = createIncrementalDidChangeParams(
27
+ * 'file:///src/main.ts',
28
+ * [{ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } }, text: 'hello' }],
29
+ * { tracker }
30
+ * );
31
+ * await client.sendNotification('textDocument/didChange', params);
32
+ * ```
33
+ *
34
+ * @category Document
3
35
  */
4
36
  export class DocumentVersionTracker {
5
37
  versions = new Map();
6
38
  /**
7
39
  * Starts tracking a document URI with an optional initial version.
40
+ *
41
+ * @param uri - The document URI to start tracking.
42
+ * @param initialVersion - Starting version number (defaults to `0`).
8
43
  */
9
44
  open(uri, initialVersion = 0) {
10
45
  this.versions.set(uri, initialVersion);
11
46
  }
12
47
  /**
13
48
  * Increments and returns the next document version.
49
+ *
50
+ * @param uri - The document URI to increment.
51
+ * @returns The incremented version number.
14
52
  */
15
53
  nextVersion(uri) {
16
54
  const current = this.versions.get(uri) ?? 0;
@@ -20,12 +58,17 @@ export class DocumentVersionTracker {
20
58
  }
21
59
  /**
22
60
  * Returns the current tracked version, if any.
61
+ *
62
+ * @param uri - The document URI to query.
63
+ * @returns The current version number, or `undefined` if the document is not tracked.
23
64
  */
24
65
  currentVersion(uri) {
25
66
  return this.versions.get(uri);
26
67
  }
27
68
  /**
28
69
  * Stops tracking a document URI.
70
+ *
71
+ * @param uri - The document URI to stop tracking.
29
72
  */
30
73
  close(uri) {
31
74
  this.versions.delete(uri);
@@ -47,7 +90,21 @@ function createIdentifier(uri, version) {
47
90
  };
48
91
  }
49
92
  /**
50
- * Creates incremental didChange params from one or more range edits.
93
+ * Builds `DidChangeTextDocumentParams` for an incremental (range-based)
94
+ * document change notification.
95
+ *
96
+ * @remarks
97
+ * Use when the client tracks individual edits (e.g. single-character
98
+ * insertions, deletions) rather than sending the full document text on each
99
+ * change. Requires the server to have `textDocumentSync.change = Incremental`.
100
+ *
101
+ * @param uri - The document URI.
102
+ * @param changes - One or more range-based text changes.
103
+ * @param source - Either an explicit `version` number or a `tracker` instance.
104
+ * @returns A `DidChangeTextDocumentParams` ready to send.
105
+ * @throws If neither `version` nor `tracker` is provided.
106
+ *
107
+ * @category Document
51
108
  */
52
109
  export function createIncrementalDidChangeParams(uri, changes, source) {
53
110
  const version = resolveVersion(uri, source);
@@ -62,7 +119,20 @@ export function createIncrementalDidChangeParams(uri, changes, source) {
62
119
  };
63
120
  }
64
121
  /**
65
- * Creates full-document didChange params for full text replacement.
122
+ * Builds `DidChangeTextDocumentParams` for a full-document text replacement.
123
+ *
124
+ * @remarks
125
+ * Use when the server only supports full-text synchronisation
126
+ * (`textDocumentSync.change = Full`) or when tracking individual edits is
127
+ * impractical (e.g. clipboard paste of a large file).
128
+ *
129
+ * @param uri - The document URI.
130
+ * @param text - The complete new document text.
131
+ * @param source - Either an explicit `version` number or a `tracker` instance.
132
+ * @returns A `DidChangeTextDocumentParams` ready to send.
133
+ * @throws If neither `version` nor `tracker` is provided.
134
+ *
135
+ * @category Document
66
136
  */
67
137
  export function createFullDidChangeParams(uri, text, source) {
68
138
  const version = resolveVersion(uri, source);
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/utils/document.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtD;;OAEG;IACH,IAAI,CAAC,GAAW,EAAE,cAAc,GAAW,CAAC,EAAQ;QAClD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAAA,CACxC;IAED;;OAEG;IACH,WAAW,CAAC,GAAW,EAAU;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAAA,CACb;IAED;;OAEG;IACH,cAAc,CAAC,GAAW,EAAsB;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAC/B;IAED;;OAEG;IACH,KAAK,CAAC,GAAW,EAAQ;QACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAAA,CAC3B;CACF;AAmBD,SAAS,cAAc,CAAC,GAAW,EAAE,MAAqB,EAAU;IAClE,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,MAAM,CAAC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,GAAG,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAqC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChF,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,YAAY,EAAE,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC;QAC5C,cAAc;KACf,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EACX,IAAY,EACZ,MAAqB;IAErB,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAqC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpE,OAAO;QACL,YAAY,EAAE,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC;QAC5C,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -2,7 +2,18 @@
2
2
  * LSP and JSON-RPC error codes
3
3
  */
4
4
  /**
5
- * JSON-RPC 2.0 error codes
5
+ * Numeric error codes defined by JSON-RPC 2.0 and the LSP specification.
6
+ *
7
+ * @remarks
8
+ * Use these constants when throwing `ResponseError` from request handlers
9
+ * so clients can programmatically distinguish error types.
10
+ *
11
+ * Ranges:
12
+ * - `-32700` to `-32600`: JSON-RPC 2.0 standard errors
13
+ * - `-32899` to `-32800`: LSP-reserved range
14
+ * - `-32099` to `-32000`: Application-defined errors
15
+ *
16
+ * @category Errors
6
17
  */
7
18
  export declare const JSONRPCErrorCode: {
8
19
  readonly ParseError: -32700;
@@ -23,14 +34,54 @@ export declare const JSONRPCErrorCode: {
23
34
  */
24
35
  export declare const ErrorMessage: Record<number, string>;
25
36
  /**
26
- * LSP Response Error
37
+ * An `Error` subclass that maps to a JSON-RPC 2.0 error response.
38
+ *
39
+ * @remarks
40
+ * Throw a `ResponseError` from any request handler to send a structured error
41
+ * response to the client. The framework catches it and converts it to the wire
42
+ * format automatically.
43
+ *
44
+ * Use the static factory methods (`ResponseError.invalidParams()`, etc.) for
45
+ * the standard JSON-RPC / LSP error codes rather than constructing raw codes.
46
+ *
47
+ * @useWhen
48
+ * A request handler needs to reject with a machine-readable error code that
49
+ * the client can act on (e.g. respond with `MethodNotFound` when a capability
50
+ * was not declared, or `InvalidParams` when schema validation fails).
51
+ *
52
+ * @avoidWhen
53
+ * You want to log a server-side error without sending an error to the client —
54
+ * throw a plain `Error` and handle it via `server.onError()` instead.
55
+ *
56
+ * @never
57
+ * NEVER throw `ResponseError` with a code outside the defined ranges without
58
+ * documenting it. Undocumented codes are opaque to clients and tools.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { ResponseError, JSONRPCErrorCode } from '@lspeasy/core';
63
+ * import { LSPServer } from '@lspeasy/server';
64
+ *
65
+ * const server = new LSPServer();
66
+ * server.onRequest('textDocument/hover', async (params) => {
67
+ * const doc = getDocument(params.textDocument.uri);
68
+ * if (!doc) {
69
+ * throw ResponseError.invalidParams(`Unknown document: ${params.textDocument.uri}`);
70
+ * }
71
+ * return computeHover(doc, params.position);
72
+ * });
73
+ * ```
74
+ *
75
+ * @category Errors
27
76
  */
28
77
  export declare class ResponseError extends Error {
29
78
  readonly code: number;
30
79
  readonly data?: unknown;
31
80
  constructor(code: number, message: string, data?: unknown);
32
81
  /**
33
- * Convert to JSON-RPC error object
82
+ * Serializes to the JSON-RPC wire format (`{ code, message, data? }`).
83
+ *
84
+ * @returns A plain object suitable for embedding in an `ErrorResponseMessage`.
34
85
  */
35
86
  toJSON(): {
36
87
  code: number;
@@ -38,31 +89,57 @@ export declare class ResponseError extends Error {
38
89
  data: unknown;
39
90
  };
40
91
  /**
41
- * Create a parse error
92
+ * Create a parse error.
93
+ *
94
+ * @param message - Optional override for the default error message.
95
+ * @param data - Optional machine-readable error details.
96
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.ParseError}.
42
97
  */
43
98
  static parseError(message?: string, data?: unknown): ResponseError;
44
99
  /**
45
- * Create an invalid request error
100
+ * Create an invalid request error.
101
+ *
102
+ * @param message - Optional override for the default error message.
103
+ * @param data - Optional machine-readable error details.
104
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InvalidRequest}.
46
105
  */
47
106
  static invalidRequest(message?: string, data?: unknown): ResponseError;
48
107
  /**
49
- * Create a method not found error
108
+ * Create a method not found error.
109
+ *
110
+ * @param method - The method name that was not found.
111
+ * @param data - Optional machine-readable error details.
112
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.MethodNotFound}.
50
113
  */
51
114
  static methodNotFound(method: string, data?: unknown): ResponseError;
52
115
  /**
53
- * Create an invalid params error
116
+ * Create an invalid params error.
117
+ *
118
+ * @param message - Optional override for the default error message.
119
+ * @param data - Optional machine-readable error details.
120
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InvalidParams}.
54
121
  */
55
122
  static invalidParams(message?: string, data?: unknown): ResponseError;
56
123
  /**
57
- * Create an internal error
124
+ * Create an internal error.
125
+ *
126
+ * @param message - Optional override for the default error message.
127
+ * @param data - Optional machine-readable error details.
128
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InternalError}.
58
129
  */
59
130
  static internalError(message?: string, data?: unknown): ResponseError;
60
131
  /**
61
- * Create a server not initialized error
132
+ * Create a server not initialized error.
133
+ *
134
+ * @param data - Optional machine-readable error details.
135
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.ServerNotInitialized}.
62
136
  */
63
137
  static serverNotInitialized(data?: unknown): ResponseError;
64
138
  /**
65
- * Create a request cancelled error
139
+ * Create a request cancelled error.
140
+ *
141
+ * @param data - Optional machine-readable error details.
142
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.RequestCancelled}.
66
143
  */
67
144
  static requestCancelled(data?: unknown): ResponseError;
68
145
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Aa,CAEnE;IAED;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAMpE;IAED;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAMpE;IAED;;;;;OAKG;IACH,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAMzD;IAED;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAMrD;CACF"}
@@ -2,7 +2,18 @@
2
2
  * LSP and JSON-RPC error codes
3
3
  */
4
4
  /**
5
- * JSON-RPC 2.0 error codes
5
+ * Numeric error codes defined by JSON-RPC 2.0 and the LSP specification.
6
+ *
7
+ * @remarks
8
+ * Use these constants when throwing `ResponseError` from request handlers
9
+ * so clients can programmatically distinguish error types.
10
+ *
11
+ * Ranges:
12
+ * - `-32700` to `-32600`: JSON-RPC 2.0 standard errors
13
+ * - `-32899` to `-32800`: LSP-reserved range
14
+ * - `-32099` to `-32000`: Application-defined errors
15
+ *
16
+ * @category Errors
6
17
  */
7
18
  export const JSONRPCErrorCode = {
8
19
  // Standard JSON-RPC 2.0 errors
@@ -37,7 +48,45 @@ export const ErrorMessage = {
37
48
  [JSONRPCErrorCode.ServerCancelled]: 'Server cancelled'
38
49
  };
39
50
  /**
40
- * LSP Response Error
51
+ * An `Error` subclass that maps to a JSON-RPC 2.0 error response.
52
+ *
53
+ * @remarks
54
+ * Throw a `ResponseError` from any request handler to send a structured error
55
+ * response to the client. The framework catches it and converts it to the wire
56
+ * format automatically.
57
+ *
58
+ * Use the static factory methods (`ResponseError.invalidParams()`, etc.) for
59
+ * the standard JSON-RPC / LSP error codes rather than constructing raw codes.
60
+ *
61
+ * @useWhen
62
+ * A request handler needs to reject with a machine-readable error code that
63
+ * the client can act on (e.g. respond with `MethodNotFound` when a capability
64
+ * was not declared, or `InvalidParams` when schema validation fails).
65
+ *
66
+ * @avoidWhen
67
+ * You want to log a server-side error without sending an error to the client —
68
+ * throw a plain `Error` and handle it via `server.onError()` instead.
69
+ *
70
+ * @never
71
+ * NEVER throw `ResponseError` with a code outside the defined ranges without
72
+ * documenting it. Undocumented codes are opaque to clients and tools.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { ResponseError, JSONRPCErrorCode } from '@lspeasy/core';
77
+ * import { LSPServer } from '@lspeasy/server';
78
+ *
79
+ * const server = new LSPServer();
80
+ * server.onRequest('textDocument/hover', async (params) => {
81
+ * const doc = getDocument(params.textDocument.uri);
82
+ * if (!doc) {
83
+ * throw ResponseError.invalidParams(`Unknown document: ${params.textDocument.uri}`);
84
+ * }
85
+ * return computeHover(doc, params.position);
86
+ * });
87
+ * ```
88
+ *
89
+ * @category Errors
41
90
  */
42
91
  export class ResponseError extends Error {
43
92
  code;
@@ -49,7 +98,9 @@ export class ResponseError extends Error {
49
98
  this.name = 'ResponseError';
50
99
  }
51
100
  /**
52
- * Convert to JSON-RPC error object
101
+ * Serializes to the JSON-RPC wire format (`{ code, message, data? }`).
102
+ *
103
+ * @returns A plain object suitable for embedding in an `ErrorResponseMessage`.
53
104
  */
54
105
  toJSON() {
55
106
  return {
@@ -59,43 +110,69 @@ export class ResponseError extends Error {
59
110
  };
60
111
  }
61
112
  /**
62
- * Create a parse error
113
+ * Create a parse error.
114
+ *
115
+ * @param message - Optional override for the default error message.
116
+ * @param data - Optional machine-readable error details.
117
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.ParseError}.
63
118
  */
64
119
  static parseError(message, data) {
65
120
  return new ResponseError(JSONRPCErrorCode.ParseError, message ?? ErrorMessage[JSONRPCErrorCode.ParseError] ?? 'Parse error', data);
66
121
  }
67
122
  /**
68
- * Create an invalid request error
123
+ * Create an invalid request error.
124
+ *
125
+ * @param message - Optional override for the default error message.
126
+ * @param data - Optional machine-readable error details.
127
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InvalidRequest}.
69
128
  */
70
129
  static invalidRequest(message, data) {
71
130
  return new ResponseError(JSONRPCErrorCode.InvalidRequest, message ?? ErrorMessage[JSONRPCErrorCode.InvalidRequest] ?? 'Invalid request', data);
72
131
  }
73
132
  /**
74
- * Create a method not found error
133
+ * Create a method not found error.
134
+ *
135
+ * @param method - The method name that was not found.
136
+ * @param data - Optional machine-readable error details.
137
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.MethodNotFound}.
75
138
  */
76
139
  static methodNotFound(method, data) {
77
140
  return new ResponseError(JSONRPCErrorCode.MethodNotFound, `Method not found: ${method}`, data);
78
141
  }
79
142
  /**
80
- * Create an invalid params error
143
+ * Create an invalid params error.
144
+ *
145
+ * @param message - Optional override for the default error message.
146
+ * @param data - Optional machine-readable error details.
147
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InvalidParams}.
81
148
  */
82
149
  static invalidParams(message, data) {
83
150
  return new ResponseError(JSONRPCErrorCode.InvalidParams, message ?? ErrorMessage[JSONRPCErrorCode.InvalidParams] ?? 'Invalid params', data);
84
151
  }
85
152
  /**
86
- * Create an internal error
153
+ * Create an internal error.
154
+ *
155
+ * @param message - Optional override for the default error message.
156
+ * @param data - Optional machine-readable error details.
157
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.InternalError}.
87
158
  */
88
159
  static internalError(message, data) {
89
160
  return new ResponseError(JSONRPCErrorCode.InternalError, message ?? ErrorMessage[JSONRPCErrorCode.InternalError] ?? 'Internal error', data);
90
161
  }
91
162
  /**
92
- * Create a server not initialized error
163
+ * Create a server not initialized error.
164
+ *
165
+ * @param data - Optional machine-readable error details.
166
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.ServerNotInitialized}.
93
167
  */
94
168
  static serverNotInitialized(data) {
95
169
  return new ResponseError(JSONRPCErrorCode.ServerNotInitialized, ErrorMessage[JSONRPCErrorCode.ServerNotInitialized] ?? 'Server not initialized', data);
96
170
  }
97
171
  /**
98
- * Create a request cancelled error
172
+ * Create a request cancelled error.
173
+ *
174
+ * @param data - Optional machine-readable error details.
175
+ * @returns A `ResponseError` with code {@link JSONRPCErrorCode.RequestCancelled}.
99
176
  */
100
177
  static requestCancelled(data) {
101
178
  return new ResponseError(JSONRPCErrorCode.RequestCancelled, ErrorMessage[JSONRPCErrorCode.RequestCancelled] ?? 'Request cancelled', data);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,+BAA+B;IAC/B,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;IAErB,mDAAmD;IACnD,oBAAoB,EAAE,CAAC,KAAK;IAC5B,gBAAgB,EAAE,CAAC,KAAK;IAExB,qDAAqD;IACrD,gBAAgB,EAAE,CAAC,KAAK;IACxB,cAAc,EAAE,CAAC,KAAK;IACtB,gBAAgB,EAAE,CAAC,KAAK;IACxB,eAAe,EAAE,CAAC,KAAK;IACvB,eAAe,EAAE,CAAC,KAAK;CACf,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC5C,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACpD,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,kBAAkB;IACrD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAClD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAClD,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,EAAE,6C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