@ast-grep/napi 0.26.1 → 0.26.2

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 (3) hide show
  1. package/index.d.ts +15 -14
  2. package/index.js +39 -10
  3. package/package.json +10 -10
package/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface FileOption {
23
23
  paths: Array<string>
24
24
  languageGlobs: Record<string, Array<string>>
25
25
  }
26
- export function parseFiles(paths: Array<string> | FileOption, callback: (err: null | Error, result: SgRoot) => void): Promise<number>
26
+ export declare function parseFiles(paths: Array<string> | FileOption, callback: (err: null | Error, result: SgRoot) => void): Promise<number>
27
27
  export interface FindConfig {
28
28
  /** specify the file paths to recursively find files */
29
29
  paths: Array<string>
@@ -59,6 +59,7 @@ export const enum Lang {
59
59
  Ruby = 'Ruby',
60
60
  Rust = 'Rust',
61
61
  Scala = 'Scala',
62
+ Sql = 'Sql',
62
63
  Swift = 'Swift'
63
64
  }
64
65
  export interface Edit {
@@ -84,7 +85,7 @@ export interface Range {
84
85
  end: Pos
85
86
  }
86
87
  /** Parse a string to an ast-grep instance */
87
- export function parse(lang: Lang, src: string): SgRoot
88
+ export declare function parse(lang: Lang, src: string): SgRoot
88
89
  /**
89
90
  * Parse a string to an ast-grep instance asynchronously in threads.
90
91
  * It utilize multiple CPU cores when **concurrent processing sources**.
@@ -92,19 +93,19 @@ export function parse(lang: Lang, src: string): SgRoot
92
93
  * Please refer to libuv doc, nodejs' underlying runtime
93
94
  * for its default behavior and performance tuning tricks.
94
95
  */
95
- export function parseAsync(lang: Lang, src: string): Promise<SgRoot>
96
+ export declare function parseAsync(lang: Lang, src: string): Promise<SgRoot>
96
97
  /** Get the `kind` number from its string name. */
97
- export function kind(lang: Lang, kindName: string): number
98
+ export declare function kind(lang: Lang, kindName: string): number
98
99
  /** Compile a string to ast-grep Pattern. */
99
- export function pattern(lang: Lang, pattern: string): NapiConfig
100
+ export declare function pattern(lang: Lang, pattern: string): NapiConfig
100
101
  /**
101
102
  * Discover and parse multiple files in Rust.
102
103
  * `lang` specifies the language.
103
104
  * `config` specifies the file path and matcher.
104
105
  * `callback` will receive matching nodes found in a file.
105
106
  */
106
- export function findInFiles(lang: Lang, config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
107
- export class SgNode {
107
+ export declare function findInFiles(lang: Lang, config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
108
+ export declare class SgNode {
108
109
  range(): Range
109
110
  isLeaf(): boolean
110
111
  isNamed(): boolean
@@ -138,7 +139,7 @@ export class SgNode {
138
139
  commitEdits(edits: Array<Edit>): string
139
140
  }
140
141
  /** Represents the parsed tree of code. */
141
- export class SgRoot {
142
+ export declare class SgRoot {
142
143
  /** Returns the root SgNode of the ast-grep instance. */
143
144
  root(): SgNode
144
145
  /**
@@ -147,7 +148,7 @@ export class SgRoot {
147
148
  */
148
149
  filename(): string
149
150
  }
150
- export namespace html {
151
+ export declare namespace html {
151
152
  /** Parse a string to an ast-grep instance */
152
153
  export function parse(src: string): SgRoot
153
154
  /**
@@ -169,7 +170,7 @@ export namespace html {
169
170
  */
170
171
  export function findInFiles(config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
171
172
  }
172
- export namespace js {
173
+ export declare namespace js {
173
174
  /** Parse a string to an ast-grep instance */
174
175
  export function parse(src: string): SgRoot
175
176
  /**
@@ -191,7 +192,7 @@ export namespace js {
191
192
  */
192
193
  export function findInFiles(config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
193
194
  }
194
- export namespace jsx {
195
+ export declare namespace jsx {
195
196
  /** Parse a string to an ast-grep instance */
196
197
  export function parse(src: string): SgRoot
197
198
  /**
@@ -213,7 +214,7 @@ export namespace jsx {
213
214
  */
214
215
  export function findInFiles(config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
215
216
  }
216
- export namespace ts {
217
+ export declare namespace ts {
217
218
  /** Parse a string to an ast-grep instance */
218
219
  export function parse(src: string): SgRoot
219
220
  /**
@@ -235,7 +236,7 @@ export namespace ts {
235
236
  */
236
237
  export function findInFiles(config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
237
238
  }
238
- export namespace tsx {
239
+ export declare namespace tsx {
239
240
  /** Parse a string to an ast-grep instance */
240
241
  export function parse(src: string): SgRoot
241
242
  /**
@@ -257,7 +258,7 @@ export namespace tsx {
257
258
  */
258
259
  export function findInFiles(config: FindConfig, callback: (err: null | Error, result: SgNode[]) => void): Promise<number>
259
260
  }
260
- export namespace css {
261
+ export declare namespace css {
261
262
  /** Parse a string to an ast-grep instance */
262
263
  export function parse(src: string): SgRoot
263
264
  /**
package/index.js CHANGED
@@ -224,17 +224,32 @@ switch (platform) {
224
224
  }
225
225
  break
226
226
  case 'arm':
227
- localFileExisted = existsSync(
228
- join(__dirname, 'ast-grep-napi.linux-arm-gnueabihf.node')
229
- )
230
- try {
231
- if (localFileExisted) {
232
- nativeBinding = require('./ast-grep-napi.linux-arm-gnueabihf.node')
233
- } else {
234
- nativeBinding = require('@ast-grep/napi-linux-arm-gnueabihf')
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'ast-grep-napi.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./ast-grep-napi.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@ast-grep/napi-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'ast-grep-napi.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./ast-grep-napi.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@ast-grep/napi-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
235
252
  }
236
- } catch (e) {
237
- loadError = e
238
253
  }
239
254
  break
240
255
  case 'riscv64':
@@ -266,6 +281,20 @@ switch (platform) {
266
281
  }
267
282
  }
268
283
  break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'ast-grep-napi.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./ast-grep-napi.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('@ast-grep/napi-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
269
298
  default:
270
299
  throw new Error(`Unsupported architecture on Linux: ${arch}`)
271
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ast-grep/napi",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "Search and Rewrite code at large scale using precise AST pattern",
5
5
  "homepage": "https://ast-grep.github.io",
6
6
  "main": "index.js",
@@ -67,14 +67,14 @@
67
67
  }
68
68
  },
69
69
  "optionalDependencies": {
70
- "@ast-grep/napi-win32-x64-msvc": "0.26.1",
71
- "@ast-grep/napi-darwin-x64": "0.26.1",
72
- "@ast-grep/napi-linux-x64-gnu": "0.26.1",
73
- "@ast-grep/napi-win32-ia32-msvc": "0.26.1",
74
- "@ast-grep/napi-darwin-arm64": "0.26.1",
75
- "@ast-grep/napi-win32-arm64-msvc": "0.26.1",
76
- "@ast-grep/napi-linux-arm64-gnu": "0.26.1",
77
- "@ast-grep/napi-linux-arm64-musl": "0.26.1",
78
- "@ast-grep/napi-linux-x64-musl": "0.26.1"
70
+ "@ast-grep/napi-win32-x64-msvc": "0.26.2",
71
+ "@ast-grep/napi-darwin-x64": "0.26.2",
72
+ "@ast-grep/napi-linux-x64-gnu": "0.26.2",
73
+ "@ast-grep/napi-win32-ia32-msvc": "0.26.2",
74
+ "@ast-grep/napi-darwin-arm64": "0.26.2",
75
+ "@ast-grep/napi-win32-arm64-msvc": "0.26.2",
76
+ "@ast-grep/napi-linux-arm64-gnu": "0.26.2",
77
+ "@ast-grep/napi-linux-arm64-musl": "0.26.2",
78
+ "@ast-grep/napi-linux-x64-musl": "0.26.2"
79
79
  }
80
80
  }