@ast-grep/napi 0.22.3 → 0.22.4

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 (2) hide show
  1. package/index.d.ts +10 -0
  2. package/package.json +9 -9
package/index.d.ts CHANGED
@@ -26,6 +26,14 @@ export const enum FrontEndLanguage {
26
26
  Css = 3,
27
27
  TypeScript = 4
28
28
  }
29
+ export interface Edit {
30
+ /** The position of the edit */
31
+ position: number
32
+ /** The length of the text to be deleted */
33
+ deletedLength: number
34
+ /** The text to be inserted */
35
+ insertedText: string
36
+ }
29
37
  export interface Pos {
30
38
  /** line number starting from 0 */
31
39
  line: number
@@ -87,6 +95,8 @@ export class SgNode {
87
95
  nextAll(): Array<SgNode>
88
96
  prev(): SgNode | null
89
97
  prevAll(): Array<SgNode>
98
+ replace(text: string): Edit
99
+ commitEdits(edits: Array<Edit>): string
90
100
  }
91
101
  /** Represents the parsed tree of code. */
92
102
  export class SgRoot {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ast-grep/napi",
3
- "version": "0.22.3",
3
+ "version": "0.22.4",
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",
@@ -66,13 +66,13 @@
66
66
  }
67
67
  },
68
68
  "optionalDependencies": {
69
- "@ast-grep/napi-win32-x64-msvc": "0.22.3",
70
- "@ast-grep/napi-darwin-x64": "0.22.3",
71
- "@ast-grep/napi-linux-x64-gnu": "0.22.3",
72
- "@ast-grep/napi-win32-ia32-msvc": "0.22.3",
73
- "@ast-grep/napi-darwin-arm64": "0.22.3",
74
- "@ast-grep/napi-win32-arm64-msvc": "0.22.3",
75
- "@ast-grep/napi-linux-arm64-gnu": "0.22.3",
76
- "@ast-grep/napi-linux-x64-musl": "0.22.3"
69
+ "@ast-grep/napi-win32-x64-msvc": "0.22.4",
70
+ "@ast-grep/napi-darwin-x64": "0.22.4",
71
+ "@ast-grep/napi-linux-x64-gnu": "0.22.4",
72
+ "@ast-grep/napi-win32-ia32-msvc": "0.22.4",
73
+ "@ast-grep/napi-darwin-arm64": "0.22.4",
74
+ "@ast-grep/napi-win32-arm64-msvc": "0.22.4",
75
+ "@ast-grep/napi-linux-arm64-gnu": "0.22.4",
76
+ "@ast-grep/napi-linux-x64-musl": "0.22.4"
77
77
  }
78
78
  }