@rslint/core 0.5.3 → 0.6.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.
Files changed (74) hide show
  1. package/bin/rslint.cjs +21 -4
  2. package/dist/0~engine.js +406 -0
  3. package/dist/34.js +33 -0
  4. package/dist/browser.d.ts +52 -39
  5. package/dist/browser.js +42 -74
  6. package/dist/cli.d.ts +3 -2
  7. package/dist/cli.js +1051 -93
  8. package/dist/config-loader.d.ts +45 -14
  9. package/dist/config-loader.js +95 -59
  10. package/dist/eslint-plugin/612.js +43 -0
  11. package/dist/eslint-plugin/index.d.ts +892 -0
  12. package/dist/eslint-plugin/index.js +26692 -0
  13. package/dist/eslint-plugin/lint-worker.js +26225 -0
  14. package/dist/eslint-plugin/types.d.ts +23 -0
  15. package/dist/eslint-plugin/types.js +1 -0
  16. package/dist/index.d.ts +626 -19
  17. package/dist/index.js +598 -15
  18. package/dist/service.d.ts +360 -30
  19. package/dist/service.js +19 -34
  20. package/package.json +27 -11
  21. package/dist/browser.d.ts.map +0 -1
  22. package/dist/cli.d.ts.map +0 -1
  23. package/dist/config-loader.d.ts.map +0 -1
  24. package/dist/configs/import.d.ts +0 -6
  25. package/dist/configs/import.d.ts.map +0 -1
  26. package/dist/configs/import.js +0 -7
  27. package/dist/configs/index.d.ts +0 -47
  28. package/dist/configs/index.d.ts.map +0 -1
  29. package/dist/configs/index.js +0 -36
  30. package/dist/configs/javascript.d.ts +0 -6
  31. package/dist/configs/javascript.d.ts.map +0 -1
  32. package/dist/configs/javascript.js +0 -72
  33. package/dist/configs/jest.d.ts +0 -7
  34. package/dist/configs/jest.d.ts.map +0 -1
  35. package/dist/configs/jest.js +0 -35
  36. package/dist/configs/jsx-a11y.d.ts +0 -6
  37. package/dist/configs/jsx-a11y.d.ts.map +0 -1
  38. package/dist/configs/jsx-a11y.js +0 -135
  39. package/dist/configs/promise.d.ts +0 -6
  40. package/dist/configs/promise.d.ts.map +0 -1
  41. package/dist/configs/promise.js +0 -20
  42. package/dist/configs/react-hooks.d.ts +0 -6
  43. package/dist/configs/react-hooks.d.ts.map +0 -1
  44. package/dist/configs/react-hooks.js +0 -24
  45. package/dist/configs/react.d.ts +0 -6
  46. package/dist/configs/react.d.ts.map +0 -1
  47. package/dist/configs/react.js +0 -31
  48. package/dist/configs/typescript.d.ts +0 -9
  49. package/dist/configs/typescript.d.ts.map +0 -1
  50. package/dist/configs/typescript.js +0 -122
  51. package/dist/configs/unicorn.d.ts +0 -8
  52. package/dist/configs/unicorn.d.ts.map +0 -1
  53. package/dist/configs/unicorn.js +0 -161
  54. package/dist/define-config.d.ts +0 -110
  55. package/dist/define-config.d.ts.map +0 -1
  56. package/dist/define-config.js +0 -6
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/node.d.ts +0 -31
  59. package/dist/node.d.ts.map +0 -1
  60. package/dist/node.js +0 -116
  61. package/dist/service.d.ts.map +0 -1
  62. package/dist/tsconfig.build.tsbuildinfo +0 -1
  63. package/dist/types.d.ts +0 -342
  64. package/dist/types.d.ts.map +0 -1
  65. package/dist/types.js +0 -1
  66. package/dist/utils/args.d.ts +0 -19
  67. package/dist/utils/args.d.ts.map +0 -1
  68. package/dist/utils/args.js +0 -101
  69. package/dist/utils/config-discovery.d.ts +0 -47
  70. package/dist/utils/config-discovery.d.ts.map +0 -1
  71. package/dist/utils/config-discovery.js +0 -238
  72. package/dist/worker.d.ts +0 -2
  73. package/dist/worker.d.ts.map +0 -1
  74. package/dist/worker.js +0 -114
package/bin/rslint.cjs CHANGED
@@ -6,16 +6,33 @@ const os = require('node:os');
6
6
  const fs = require('node:fs');
7
7
 
8
8
  function getBinPath() {
9
+ // dev / local `build:bin` output sits next to this script
9
10
  if (fs.existsSync(path.resolve(__dirname, './rslint'))) {
10
11
  return path.resolve(__dirname, './rslint');
11
12
  }
12
13
  if (fs.existsSync(path.resolve(__dirname, './rslint.exe'))) {
13
14
  return path.resolve(__dirname, './rslint.exe');
14
15
  }
15
- let platformKey = `${process.platform}-${os.arch()}`;
16
-
17
- return require.resolve(
18
- `@rslint/${platformKey}/rslint${process.platform === 'win32' ? '.exe' : ''}`,
16
+ // published: the Go binary lives in the @rslint/native-{tuple} subpackage,
17
+ // reached via its `./bin` export. npm installs only the subpackage matching
18
+ // the host os/cpu/libc, so on linux we just try gnu then musl and use
19
+ // whichever got installed no libc sniffing (Go binaries are static, the
20
+ // gnu/musl distinction doesn't matter to them).
21
+ const arch = os.arch();
22
+ const tuples =
23
+ process.platform === 'linux'
24
+ ? [`linux-${arch}-gnu`, `linux-${arch}-musl`]
25
+ : process.platform === 'win32'
26
+ ? [`win32-${arch}-msvc`]
27
+ : [`${process.platform}-${arch}`];
28
+ for (const tuple of tuples) {
29
+ try {
30
+ return require.resolve(`@rslint/native-${tuple}/bin`);
31
+ } catch {}
32
+ }
33
+ throw new Error(
34
+ `rslint: no native binary for ${process.platform}-${arch} ` +
35
+ `(looked for @rslint/native-{${tuples.join(',')}})`,
19
36
  );
20
37
  }
21
38
 
@@ -0,0 +1,406 @@
1
+ import { spawn } from "node:child_process";
2
+ const RESPONSE_KIND = 'response';
3
+ const ERROR_KIND = 'error';
4
+ const HEADER_BYTES = 4;
5
+ const MAX_FRAME_BYTES = 268435456;
6
+ class IpcClient {
7
+ input;
8
+ output;
9
+ pending = new Map();
10
+ notificationHandlers = new Map();
11
+ inboundHandler = null;
12
+ chunks = [];
13
+ bufferedBytes = 0;
14
+ nextId = 1;
15
+ closed = false;
16
+ started = false;
17
+ constructor(input, output, opts = {}){
18
+ this.input = input;
19
+ this.output = output;
20
+ }
21
+ setInboundHandler(handler) {
22
+ this.inboundHandler = handler;
23
+ }
24
+ registerNotification(kind, handler) {
25
+ this.notificationHandlers.set(kind, handler);
26
+ }
27
+ start() {
28
+ if (this.started) return;
29
+ this.started = true;
30
+ this.input.on('data', this.onChunk);
31
+ this.input.on('end', this.onEnd);
32
+ this.input.on('error', this.onStreamError);
33
+ this.output.on('error', this.onOutputError);
34
+ this.output.on('close', this.onOutputClose);
35
+ this.output.on('finish', this.onOutputClose);
36
+ }
37
+ close() {
38
+ if (this.closed) return;
39
+ this.closed = true;
40
+ this.input.off('data', this.onChunk);
41
+ this.input.off('end', this.onEnd);
42
+ this.input.off('error', this.onStreamError);
43
+ this.output.off('error', this.onOutputError);
44
+ this.output.off('close', this.onOutputClose);
45
+ this.output.off('finish', this.onOutputClose);
46
+ const err = new Error('IpcClient: closed');
47
+ for (const [, p] of this.pending)p.reject(err);
48
+ this.pending.clear();
49
+ }
50
+ async sendRequest(kind, data) {
51
+ if (this.closed) throw new Error('IpcClient: cannot sendRequest on closed client');
52
+ const id = this.nextId++;
53
+ const frame = encodeFrame({
54
+ kind,
55
+ id,
56
+ data
57
+ });
58
+ const promise = new Promise((resolve, reject)=>{
59
+ this.pending.set(id, {
60
+ resolve: resolve,
61
+ reject
62
+ });
63
+ });
64
+ this.writeFrameNow(frame);
65
+ return promise;
66
+ }
67
+ sendNotification(kind, data) {
68
+ if (this.closed) throw new Error('IpcClient: cannot sendNotification on closed client');
69
+ const frame = encodeFrame({
70
+ kind,
71
+ id: 0,
72
+ data
73
+ });
74
+ this.writeFrameNow(frame);
75
+ }
76
+ sendResponse(reqId, data) {
77
+ if (this.closed) return;
78
+ this.writeFrameNow(encodeFrame({
79
+ kind: 'response',
80
+ id: reqId,
81
+ data
82
+ }));
83
+ }
84
+ sendErrorResponse(reqId, message) {
85
+ if (this.closed) return;
86
+ this.writeFrameNow(encodeFrame({
87
+ kind: 'error',
88
+ id: reqId,
89
+ data: {
90
+ message
91
+ }
92
+ }));
93
+ }
94
+ writeFrameNow(frame) {
95
+ try {
96
+ this.output.write(frame);
97
+ } catch (err) {
98
+ this.onOutputError(err);
99
+ }
100
+ }
101
+ onOutputError = (err)=>{
102
+ if (this.closed) return;
103
+ process.stderr.write(`rslint: output write error: ${err.message}\n`);
104
+ const wrapped = new Error(`IpcClient: output write failed: ${err.message}`);
105
+ for (const [, p] of this.pending)p.reject(wrapped);
106
+ this.pending.clear();
107
+ this.closed = true;
108
+ this.input.off('data', this.onChunk);
109
+ this.input.off('end', this.onEnd);
110
+ this.input.off('error', this.onStreamError);
111
+ this.output.off('error', this.onOutputError);
112
+ this.output.off('close', this.onOutputClose);
113
+ this.output.off('finish', this.onOutputClose);
114
+ };
115
+ onOutputClose = ()=>{
116
+ if (this.closed) return;
117
+ const err = new Error('IpcClient: output stream closed before response received');
118
+ for (const [, p] of this.pending)p.reject(err);
119
+ this.pending.clear();
120
+ this.closed = true;
121
+ this.input.off('data', this.onChunk);
122
+ this.input.off('end', this.onEnd);
123
+ this.input.off('error', this.onStreamError);
124
+ this.output.off('error', this.onOutputError);
125
+ this.output.off('close', this.onOutputClose);
126
+ this.output.off('finish', this.onOutputClose);
127
+ };
128
+ onChunk = (chunk)=>{
129
+ this.chunks.push(chunk);
130
+ this.bufferedBytes += chunk.length;
131
+ while(this.bufferedBytes >= HEADER_BYTES){
132
+ const len = this.peekHeaderLen();
133
+ if (len > MAX_FRAME_BYTES) return void this.onStreamError(new Error(`ipc-client: frame length ${len} exceeds cap ${MAX_FRAME_BYTES} (likely stream desync). Connection will be closed.`));
134
+ if (this.bufferedBytes < HEADER_BYTES + len) break;
135
+ const frame = this.consumeFront(HEADER_BYTES + len);
136
+ const body = frame.subarray(HEADER_BYTES);
137
+ let msg;
138
+ try {
139
+ msg = JSON.parse(body.toString('utf8'));
140
+ } catch (err) {
141
+ process.stderr.write(`rslint: malformed JSON in frame (len=${len}): ${err.message}\n`);
142
+ continue;
143
+ }
144
+ this.dispatch(msg);
145
+ }
146
+ };
147
+ peekHeaderLen() {
148
+ const first = this.chunks[0];
149
+ if (first.length >= HEADER_BYTES) return first.readUInt32LE(0);
150
+ let len = 0;
151
+ let seen = 0;
152
+ for (const c of this.chunks){
153
+ for(let i = 0; i < c.length && seen < HEADER_BYTES; i++, seen++)len |= c[i] << 8 * seen;
154
+ if (seen >= HEADER_BYTES) break;
155
+ }
156
+ return len >>> 0;
157
+ }
158
+ consumeFront(n) {
159
+ this.bufferedBytes -= n;
160
+ const first = this.chunks[0];
161
+ if (first.length === n) {
162
+ this.chunks.shift();
163
+ return first;
164
+ }
165
+ if (first.length > n) {
166
+ const frame = first.subarray(0, n);
167
+ this.chunks[0] = Buffer.from(first.subarray(n));
168
+ return frame;
169
+ }
170
+ const parts = [];
171
+ let need = n;
172
+ while(need > 0){
173
+ const c = this.chunks[0];
174
+ if (c.length <= need) {
175
+ parts.push(c);
176
+ need -= c.length;
177
+ this.chunks.shift();
178
+ } else {
179
+ parts.push(c.subarray(0, need));
180
+ this.chunks[0] = Buffer.from(c.subarray(need));
181
+ need = 0;
182
+ }
183
+ }
184
+ return Buffer.concat(parts, n);
185
+ }
186
+ onEnd = ()=>{
187
+ if (this.closed) return;
188
+ this.closed = true;
189
+ const err = new Error('IpcClient: peer closed input stream');
190
+ for (const [, p] of this.pending)p.reject(err);
191
+ this.pending.clear();
192
+ this.input.off('data', this.onChunk);
193
+ this.input.off('end', this.onEnd);
194
+ this.input.off('error', this.onStreamError);
195
+ this.output.off('error', this.onOutputError);
196
+ this.output.off('close', this.onOutputClose);
197
+ this.output.off('finish', this.onOutputClose);
198
+ };
199
+ onStreamError = (err)=>{
200
+ process.stderr.write(`rslint: stream error: ${err.message}\n`);
201
+ this.onEnd();
202
+ };
203
+ dispatch(msg) {
204
+ if (msg.kind === RESPONSE_KIND || msg.kind === ERROR_KIND) return void this.routeResponse(msg);
205
+ if (0 === msg.id) return void this.dispatchNotification(msg);
206
+ this.dispatchInboundRequest(msg);
207
+ }
208
+ routeResponse(msg) {
209
+ const p = this.pending.get(msg.id);
210
+ if (!p) return void process.stderr.write(`rslint: orphan response id=${msg.id} kind=${msg.kind}\n`);
211
+ this.pending.delete(msg.id);
212
+ if (msg.kind === ERROR_KIND) {
213
+ const data = msg.data;
214
+ p.reject(new Error(`peer error: ${data?.message ?? '(no message)'}`));
215
+ return;
216
+ }
217
+ p.resolve(msg);
218
+ }
219
+ dispatchNotification(msg) {
220
+ const handler = this.notificationHandlers.get(msg.kind);
221
+ if (!handler) return void process.stderr.write(`rslint: unhandled notification kind=${msg.kind}\n`);
222
+ runSafely(async ()=>handler(msg), `notification:${msg.kind}`);
223
+ }
224
+ dispatchInboundRequest(msg) {
225
+ const handler = this.inboundHandler;
226
+ if (!handler) return void this.sendErrorResponse(msg.id, `no inbound handler registered (kind=${msg.kind})`);
227
+ (async ()=>{
228
+ try {
229
+ const result = await handler(msg);
230
+ this.sendResponse(msg.id, result);
231
+ } catch (err) {
232
+ const message = err instanceof Error ? err.message : String(err);
233
+ this.sendErrorResponse(msg.id, message);
234
+ }
235
+ })();
236
+ }
237
+ }
238
+ function encodeFrame(msg) {
239
+ const body = Buffer.from(JSON.stringify(msg), 'utf8');
240
+ const out = Buffer.allocUnsafe(HEADER_BYTES + body.length);
241
+ out.writeUInt32LE(body.length, 0);
242
+ body.copy(out, HEADER_BYTES);
243
+ return out;
244
+ }
245
+ async function runSafely(fn, tag) {
246
+ try {
247
+ const ret = fn();
248
+ if (ret instanceof Promise) await ret;
249
+ } catch (err) {
250
+ const message = err instanceof Error ? err.message : String(err);
251
+ process.stderr.write(`rslint: handler ${tag} threw: ${message}\n`);
252
+ }
253
+ }
254
+ const SIGNAL_EXIT_CODES = {
255
+ SIGHUP: 129,
256
+ SIGINT: 130,
257
+ SIGQUIT: 131,
258
+ SIGTERM: 143,
259
+ SIGKILL: 137
260
+ };
261
+ async function runEngine(opts) {
262
+ const stdout = opts.stdout ?? process.stdout;
263
+ const stderr = opts.stderr ?? process.stderr;
264
+ const child = spawn(opts.binPath, opts.goArgs, {
265
+ stdio: [
266
+ 'pipe',
267
+ 'pipe',
268
+ 'inherit'
269
+ ],
270
+ cwd: opts.cwd ?? process.cwd()
271
+ });
272
+ const childExit = new Promise((resolve)=>{
273
+ let resolved = false;
274
+ const settle = (code)=>{
275
+ if (!resolved) {
276
+ resolved = true;
277
+ resolve({
278
+ code
279
+ });
280
+ }
281
+ };
282
+ child.once('error', (err)=>{
283
+ stderr.write(`rslint: Go spawn/runtime error: ${err.message}\n`);
284
+ settle(2);
285
+ });
286
+ child.once('exit', (code, signal)=>{
287
+ settle(null != code ? code : null != signal ? SIGNAL_EXIT_CODES[signal] ?? 128 : 1);
288
+ });
289
+ });
290
+ const raceWithExit = async (task)=>Promise.race([
291
+ task.then((value)=>({
292
+ kind: 'task',
293
+ value
294
+ })),
295
+ childExit.then((state)=>({
296
+ kind: 'exit',
297
+ state
298
+ }))
299
+ ]);
300
+ if (!child.stdin || !child.stdout) {
301
+ safeKillGo(child);
302
+ throw new Error('engine: Go child process missing stdin/stdout');
303
+ }
304
+ const ipc = new IpcClient(child.stdout, child.stdin);
305
+ let pluginHost = null;
306
+ const pluginConfigs = opts.pluginConfigs ?? [];
307
+ if (pluginConfigs.length > 0) {
308
+ const pluginEntry = './eslint-plugin/index.js';
309
+ try {
310
+ const mod = await import(pluginEntry);
311
+ pluginHost = await mod.createPluginLintHost(pluginConfigs, (rec)=>stderr.write(`[rslint:plugin] ${rec.text}\n`), opts.runtime?.singleThreaded);
312
+ } catch (err) {
313
+ const msg = err instanceof Error ? err.message : String(err);
314
+ stderr.write(`rslint: failed to start ESLint-plugin worker: ${msg}\n`);
315
+ safeKillGo(child);
316
+ return 2;
317
+ }
318
+ }
319
+ const onSignal = ()=>{
320
+ safeKillGo(child);
321
+ pluginHost?.shutdown();
322
+ };
323
+ process.on('SIGINT', onSignal);
324
+ process.on('SIGTERM', onSignal);
325
+ process.on('SIGHUP', onSignal);
326
+ const removeSignalHandlers = ()=>{
327
+ process.off('SIGINT', onSignal);
328
+ process.off('SIGTERM', onSignal);
329
+ process.off('SIGHUP', onSignal);
330
+ };
331
+ try {
332
+ ipc.setInboundHandler(async (msg)=>{
333
+ switch(msg.kind){
334
+ case 'shutdown':
335
+ return {
336
+ ok: true
337
+ };
338
+ case 'pluginLint':
339
+ return pluginHost ? pluginHost.lint(msg.data) : {
340
+ results: []
341
+ };
342
+ default:
343
+ throw new Error(`engine: unexpected inbound kind '${msg.kind}'`);
344
+ }
345
+ });
346
+ ipc.registerNotification('output', (msg)=>{
347
+ const text = msg.data?.text;
348
+ if (null != text) stdout.write(text);
349
+ });
350
+ ipc.start();
351
+ {
352
+ let outcome;
353
+ try {
354
+ outcome = await raceWithExit(ipc.sendRequest('init', {
355
+ ...opts.extraInit ?? {},
356
+ configs: opts.configs,
357
+ eslintPlugins: opts.eslintPluginEntries,
358
+ runtime: {
359
+ forceColor: opts.runtime?.forceColor,
360
+ singleThreaded: opts.runtime?.singleThreaded
361
+ }
362
+ }));
363
+ } catch {
364
+ safeKillGo(child);
365
+ const state = await childExit;
366
+ if (0 === state.code) return 0;
367
+ stderr.write(`rslint: init failed (Go exited ${state.code})\n`);
368
+ return state.code;
369
+ }
370
+ if ('exit' === outcome.kind) return outcome.state.code;
371
+ const data = outcome.value.data;
372
+ const ok = 'object' == typeof data && null !== data && 'ok' in data && true === data.ok;
373
+ if (!ok) {
374
+ stderr.write(`rslint: Go rejected init: ${JSON.stringify(outcome.value.data)}\n`);
375
+ safeKillGo(child);
376
+ await childExit;
377
+ return 2;
378
+ }
379
+ }
380
+ const finalExit = await childExit;
381
+ ipc.close();
382
+ return finalExit.code;
383
+ } finally{
384
+ removeSignalHandlers();
385
+ await pluginHost?.shutdown();
386
+ }
387
+ }
388
+ const KILL_GRACE_MS = 5000;
389
+ function safeKillGo(child) {
390
+ try {
391
+ if (child.killed) return;
392
+ child.kill('SIGTERM');
393
+ } catch {
394
+ return;
395
+ }
396
+ const killTimer = setTimeout(()=>{
397
+ if (null == child.exitCode && null == child.signalCode) try {
398
+ child.kill('SIGKILL');
399
+ } catch {}
400
+ }, KILL_GRACE_MS);
401
+ if ('function' == typeof killTimer.unref) killTimer.unref();
402
+ child.once('exit', ()=>{
403
+ clearTimeout(killTimer);
404
+ });
405
+ }
406
+ export { runEngine };
package/dist/34.js ADDED
@@ -0,0 +1,33 @@
1
+ const NATIVE_PLUGINS = [
2
+ "@typescript-eslint",
3
+ 'import',
4
+ 'jest',
5
+ 'jsx-a11y',
6
+ 'promise',
7
+ 'react',
8
+ 'react-hooks',
9
+ 'unicorn'
10
+ ];
11
+ const NATIVE_PLUGIN_DECL_ALIASES = [
12
+ 'eslint-plugin-import',
13
+ 'eslint-plugin-jest',
14
+ 'eslint-plugin-jsx-a11y',
15
+ 'eslint-plugin-promise',
16
+ 'eslint-plugin-react-hooks',
17
+ 'eslint-plugin-unicorn'
18
+ ];
19
+ const NATIVE_PLUGIN_RESERVED_NAMES = new Set([
20
+ ...NATIVE_PLUGINS,
21
+ ...NATIVE_PLUGIN_DECL_ALIASES
22
+ ]);
23
+ function defineConfig(config) {
24
+ return config;
25
+ }
26
+ function globalIgnores(ignorePatterns) {
27
+ if (!Array.isArray(ignorePatterns)) throw new TypeError('ignorePatterns must be an array');
28
+ if (0 === ignorePatterns.length) throw new TypeError('ignorePatterns must contain at least one pattern');
29
+ return {
30
+ ignores: ignorePatterns
31
+ };
32
+ }
33
+ export { NATIVE_PLUGIN_RESERVED_NAMES, defineConfig, globalIgnores };
package/dist/browser.d.ts CHANGED
@@ -1,39 +1,52 @@
1
- import type { RslintServiceInterface, RSlintOptions } from './types.js';
2
- /**
3
- * Browser implementation of RslintService using web workers
4
- */
5
- export declare class BrowserRslintService implements RslintServiceInterface {
6
- private nextMessageId;
7
- private readonly pendingMessages;
8
- private worker!;
9
- private readonly workerUrl;
10
- private chunks;
11
- private chunkSize;
12
- private expectedSize;
13
- constructor(options: RSlintOptions & {
14
- workerUrl: string;
15
- wasmUrl: string;
16
- });
17
- private ensureWorker;
18
- /**
19
- * Handle incoming binary data chunks
20
- */
21
- private handlePacket;
22
- /**
23
- * Combine multiple Uint8Array chunks into a single Uint8Array
24
- */
25
- private combineChunks;
26
- /**
27
- * Send a message to the worker
28
- */
29
- sendMessage(kind: string, data: any): Promise<any>;
30
- /**
31
- * Handle messages from the worker
32
- */
33
- private handleResponse;
34
- /**
35
- * Terminate the worker
36
- */
37
- terminate(): void;
38
- }
39
- //# sourceMappingURL=browser.d.ts.map
1
+ /**
2
+ * Browser implementation of RslintService using web workers
3
+ */
4
+ export declare class BrowserRslintService implements RslintServiceInterface {
5
+ private nextMessageId;
6
+ private readonly pendingMessages;
7
+ private worker;
8
+ private readonly workerUrl;
9
+ private chunks;
10
+ private chunkSize;
11
+ private expectedSize;
12
+ constructor(options: RSlintOptions & {
13
+ workerUrl: string;
14
+ wasmUrl: string;
15
+ });
16
+ /**
17
+ * Initialize the web worker
18
+ */
19
+ private ensureWorker;
20
+ /**
21
+ * Handle incoming binary data chunks
22
+ */
23
+ private handlePacket;
24
+ /**
25
+ * Combine multiple Uint8Array chunks into a single Uint8Array
26
+ */
27
+ private combineChunks;
28
+ /**
29
+ * Send a message to the worker
30
+ */
31
+ sendMessage(kind: string, data: any): Promise<any>;
32
+ /**
33
+ * Handle messages from the worker
34
+ */
35
+ private handleResponse;
36
+ /**
37
+ * Terminate the worker
38
+ */
39
+ terminate(): void;
40
+ }
41
+
42
+ declare interface RSlintOptions {
43
+ rslintPath?: string;
44
+ workingDirectory?: string;
45
+ }
46
+
47
+ declare interface RslintServiceInterface {
48
+ sendMessage(kind: string, data: any): Promise<any>;
49
+ terminate(): void;
50
+ }
51
+
52
+ export { }