@spader/spall-tui 1.0.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/App.js +3636 -0
- package/dist/App.js.map +39 -0
- package/dist/bash-nbhfht5r.scm +56 -0
- package/dist/c-4zy7d3fw.scm +81 -0
- package/dist/c_sharp-tb7n62t2.scm +212 -0
- package/dist/cpp-stxr9ffp.scm +77 -0
- package/dist/css-b1p1h6ys.scm +76 -0
- package/dist/dart-t89b32ej.scm +13 -0
- package/dist/elisp-ax9wx1b9.scm +72 -0
- package/dist/elixir-77300bss.scm +223 -0
- package/dist/elm-k2q5knqb.scm +76 -0
- package/dist/embedded_template-k7ypjkba.scm +12 -0
- package/dist/go-9wx8m64k.scm +123 -0
- package/dist/html-g95aq3vw.scm +13 -0
- package/dist/index.js +3635 -0
- package/dist/index.js.map +39 -0
- package/dist/java-wasz6t7a.scm +149 -0
- package/dist/javascript-cswtymww.scm +204 -0
- package/dist/json-pf4aw8w1.scm +16 -0
- package/dist/kotlin-m6cj2y7m.scm +380 -0
- package/dist/lib/git.js +117 -0
- package/dist/lib/git.js.map +10 -0
- package/dist/lua-7h6jk3pd.scm +204 -0
- package/dist/objc-6yjdwy1z.scm +216 -0
- package/dist/ocaml-jfj520qk.scm +148 -0
- package/dist/parsers/index.d.ts +8 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/php-bds7v5h1.scm +203 -0
- package/dist/python-k2cbtg72.scm +137 -0
- package/dist/ql-qs2vxbeq.scm +154 -0
- package/dist/ruby-3ybh5bp2.scm +154 -0
- package/dist/rust-edtnatpk.scm +161 -0
- package/dist/scala-91f2sb1z.scm +260 -0
- package/dist/src/App.d.ts +6 -0
- package/dist/src/App.d.ts.map +1 -0
- package/dist/src/Review.d.ts +6 -0
- package/dist/src/Review.d.ts.map +1 -0
- package/dist/src/components/CommandPalette.d.ts +2 -0
- package/dist/src/components/CommandPalette.d.ts.map +1 -0
- package/dist/src/components/DiffPanel.d.ts +16 -0
- package/dist/src/components/DiffPanel.d.ts.map +1 -0
- package/dist/src/components/EditorPanel.d.ts +9 -0
- package/dist/src/components/EditorPanel.d.ts.map +1 -0
- package/dist/src/components/ErrorFallback.d.ts +6 -0
- package/dist/src/components/ErrorFallback.d.ts.map +1 -0
- package/dist/src/components/HalfLineShadow.d.ts +18 -0
- package/dist/src/components/HalfLineShadow.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +7 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/sidebar/CommentList.d.ts +10 -0
- package/dist/src/components/sidebar/CommentList.d.ts.map +1 -0
- package/dist/src/components/sidebar/FileList.d.ts +13 -0
- package/dist/src/components/sidebar/FileList.d.ts.map +1 -0
- package/dist/src/components/sidebar/PatchList.d.ts +14 -0
- package/dist/src/components/sidebar/PatchList.d.ts.map +1 -0
- package/dist/src/components/sidebar/ProjectStatus.d.ts +7 -0
- package/dist/src/components/sidebar/ProjectStatus.d.ts.map +1 -0
- package/dist/src/components/sidebar/Section.d.ts +12 -0
- package/dist/src/components/sidebar/Section.d.ts.map +1 -0
- package/dist/src/components/sidebar/ServerStatus.d.ts +2 -0
- package/dist/src/components/sidebar/ServerStatus.d.ts.map +1 -0
- package/dist/src/components/sidebar/index.d.ts +7 -0
- package/dist/src/components/sidebar/index.d.ts.map +1 -0
- package/dist/src/context/command.d.ts +10 -0
- package/dist/src/context/command.d.ts.map +1 -0
- package/dist/src/context/dialog.d.ts +11 -0
- package/dist/src/context/dialog.d.ts.map +1 -0
- package/dist/src/context/exit.d.ts +10 -0
- package/dist/src/context/exit.d.ts.map +1 -0
- package/dist/src/context/review.d.ts +47 -0
- package/dist/src/context/review.d.ts.map +1 -0
- package/dist/src/context/server.d.ts +10 -0
- package/dist/src/context/server.d.ts.map +1 -0
- package/dist/src/context/sidebar.d.ts +13 -0
- package/dist/src/context/sidebar.d.ts.map +1 -0
- package/dist/src/context/theme.d.ts +47 -0
- package/dist/src/context/theme.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/diff.d.ts +24 -0
- package/dist/src/lib/diff.d.ts.map +1 -0
- package/dist/src/lib/git.d.ts +15 -0
- package/dist/src/lib/git.d.ts.map +1 -0
- package/dist/src/lib/keybind.d.ts +23 -0
- package/dist/src/lib/keybind.d.ts.map +1 -0
- package/dist/src/lib/tree.d.ts +39 -0
- package/dist/src/lib/tree.d.ts.map +1 -0
- package/dist/src/store/comment.d.ts +20 -0
- package/dist/src/store/comment.d.ts.map +1 -0
- package/dist/src/store/db.d.ts +6 -0
- package/dist/src/store/db.d.ts.map +1 -0
- package/dist/src/store/index.d.ts +7 -0
- package/dist/src/store/index.d.ts.map +1 -0
- package/dist/src/store/patch.d.ts +22 -0
- package/dist/src/store/patch.d.ts.map +1 -0
- package/dist/src/store/repo.d.ts +8 -0
- package/dist/src/store/repo.d.ts.map +1 -0
- package/dist/src/store/review.d.ts +18 -0
- package/dist/src/store/review.d.ts.map +1 -0
- package/dist/store/index.js +303 -0
- package/dist/store/index.js.map +14 -0
- package/dist/swift-a4tt704b.scm +336 -0
- package/dist/toml-hcqfz0bg.scm +53 -0
- package/dist/tsx-c3k3mmc9.scm +239 -0
- package/dist/typescript-hz4pg6ze.scm +239 -0
- package/dist/vue-xbeea1aj.scm +9 -0
- package/dist/yaml-mbfb25g0.scm +79 -0
- package/dist/zig-ds3q8m26.scm +283 -0
- package/package.json +74 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
;; Based on the nvim-treesitter highlighting, which is under the Apache license.
|
|
2
|
+
;; See https://github.com/nvim-treesitter/nvim-treesitter/blob/f8ab59861eed4a1c168505e3433462ed800f2bae/queries/kotlin/highlights.scm
|
|
3
|
+
;;
|
|
4
|
+
;; The only difference in this file is that queries using #lua-match?
|
|
5
|
+
;; have been removed.
|
|
6
|
+
|
|
7
|
+
;;; Identifiers
|
|
8
|
+
|
|
9
|
+
(simple_identifier) @variable
|
|
10
|
+
|
|
11
|
+
; `it` keyword inside lambdas
|
|
12
|
+
; FIXME: This will highlight the keyword outside of lambdas since tree-sitter
|
|
13
|
+
; does not allow us to check for arbitrary nestation
|
|
14
|
+
((simple_identifier) @variable.builtin
|
|
15
|
+
(#eq? @variable.builtin "it"))
|
|
16
|
+
|
|
17
|
+
; `field` keyword inside property getter/setter
|
|
18
|
+
; FIXME: This will highlight the keyword outside of getters and setters
|
|
19
|
+
; since tree-sitter does not allow us to check for arbitrary nestation
|
|
20
|
+
((simple_identifier) @variable.builtin
|
|
21
|
+
(#eq? @variable.builtin "field"))
|
|
22
|
+
|
|
23
|
+
; `this` this keyword inside classes
|
|
24
|
+
(this_expression) @variable.builtin
|
|
25
|
+
|
|
26
|
+
; `super` keyword inside classes
|
|
27
|
+
(super_expression) @variable.builtin
|
|
28
|
+
|
|
29
|
+
(class_parameter
|
|
30
|
+
(simple_identifier) @property)
|
|
31
|
+
|
|
32
|
+
(class_body
|
|
33
|
+
(property_declaration
|
|
34
|
+
(variable_declaration
|
|
35
|
+
(simple_identifier) @property)))
|
|
36
|
+
|
|
37
|
+
; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties
|
|
38
|
+
(_
|
|
39
|
+
(navigation_suffix
|
|
40
|
+
(simple_identifier) @property))
|
|
41
|
+
|
|
42
|
+
(enum_entry
|
|
43
|
+
(simple_identifier) @constant)
|
|
44
|
+
|
|
45
|
+
(type_identifier) @type
|
|
46
|
+
|
|
47
|
+
((type_identifier) @type.builtin
|
|
48
|
+
(#any-of? @type.builtin
|
|
49
|
+
"Byte"
|
|
50
|
+
"Short"
|
|
51
|
+
"Int"
|
|
52
|
+
"Long"
|
|
53
|
+
"UByte"
|
|
54
|
+
"UShort"
|
|
55
|
+
"UInt"
|
|
56
|
+
"ULong"
|
|
57
|
+
"Float"
|
|
58
|
+
"Double"
|
|
59
|
+
"Boolean"
|
|
60
|
+
"Char"
|
|
61
|
+
"String"
|
|
62
|
+
"Array"
|
|
63
|
+
"ByteArray"
|
|
64
|
+
"ShortArray"
|
|
65
|
+
"IntArray"
|
|
66
|
+
"LongArray"
|
|
67
|
+
"UByteArray"
|
|
68
|
+
"UShortArray"
|
|
69
|
+
"UIntArray"
|
|
70
|
+
"ULongArray"
|
|
71
|
+
"FloatArray"
|
|
72
|
+
"DoubleArray"
|
|
73
|
+
"BooleanArray"
|
|
74
|
+
"CharArray"
|
|
75
|
+
"Map"
|
|
76
|
+
"Set"
|
|
77
|
+
"List"
|
|
78
|
+
"EmptyMap"
|
|
79
|
+
"EmptySet"
|
|
80
|
+
"EmptyList"
|
|
81
|
+
"MutableMap"
|
|
82
|
+
"MutableSet"
|
|
83
|
+
"MutableList"
|
|
84
|
+
))
|
|
85
|
+
|
|
86
|
+
(package_header
|
|
87
|
+
. (identifier)) @namespace
|
|
88
|
+
|
|
89
|
+
(import_header
|
|
90
|
+
"import" @include)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
; TODO: Seperate labeled returns/breaks/continue/super/this
|
|
94
|
+
; Must be implemented in the parser first
|
|
95
|
+
(label) @label
|
|
96
|
+
|
|
97
|
+
;;; Function definitions
|
|
98
|
+
|
|
99
|
+
(function_declaration
|
|
100
|
+
. (simple_identifier) @function)
|
|
101
|
+
|
|
102
|
+
(getter
|
|
103
|
+
("get") @function.builtin)
|
|
104
|
+
(setter
|
|
105
|
+
("set") @function.builtin)
|
|
106
|
+
|
|
107
|
+
(primary_constructor) @constructor
|
|
108
|
+
(secondary_constructor
|
|
109
|
+
("constructor") @constructor)
|
|
110
|
+
|
|
111
|
+
(constructor_invocation
|
|
112
|
+
(user_type
|
|
113
|
+
(type_identifier) @constructor))
|
|
114
|
+
|
|
115
|
+
(anonymous_initializer
|
|
116
|
+
("init") @constructor)
|
|
117
|
+
|
|
118
|
+
(parameter
|
|
119
|
+
(simple_identifier) @parameter)
|
|
120
|
+
|
|
121
|
+
(parameter_with_optional_type
|
|
122
|
+
(simple_identifier) @parameter)
|
|
123
|
+
|
|
124
|
+
; lambda parameters
|
|
125
|
+
(lambda_literal
|
|
126
|
+
(lambda_parameters
|
|
127
|
+
(variable_declaration
|
|
128
|
+
(simple_identifier) @parameter)))
|
|
129
|
+
|
|
130
|
+
;;; Function calls
|
|
131
|
+
|
|
132
|
+
; function()
|
|
133
|
+
(call_expression
|
|
134
|
+
. (simple_identifier) @function)
|
|
135
|
+
|
|
136
|
+
; object.function() or object.property.function()
|
|
137
|
+
(call_expression
|
|
138
|
+
(navigation_expression
|
|
139
|
+
(navigation_suffix
|
|
140
|
+
(simple_identifier) @function) . ))
|
|
141
|
+
|
|
142
|
+
(call_expression
|
|
143
|
+
. (simple_identifier) @function.builtin
|
|
144
|
+
(#any-of? @function.builtin
|
|
145
|
+
"arrayOf"
|
|
146
|
+
"arrayOfNulls"
|
|
147
|
+
"byteArrayOf"
|
|
148
|
+
"shortArrayOf"
|
|
149
|
+
"intArrayOf"
|
|
150
|
+
"longArrayOf"
|
|
151
|
+
"ubyteArrayOf"
|
|
152
|
+
"ushortArrayOf"
|
|
153
|
+
"uintArrayOf"
|
|
154
|
+
"ulongArrayOf"
|
|
155
|
+
"floatArrayOf"
|
|
156
|
+
"doubleArrayOf"
|
|
157
|
+
"booleanArrayOf"
|
|
158
|
+
"charArrayOf"
|
|
159
|
+
"emptyArray"
|
|
160
|
+
"mapOf"
|
|
161
|
+
"setOf"
|
|
162
|
+
"listOf"
|
|
163
|
+
"emptyMap"
|
|
164
|
+
"emptySet"
|
|
165
|
+
"emptyList"
|
|
166
|
+
"mutableMapOf"
|
|
167
|
+
"mutableSetOf"
|
|
168
|
+
"mutableListOf"
|
|
169
|
+
"print"
|
|
170
|
+
"println"
|
|
171
|
+
"error"
|
|
172
|
+
"TODO"
|
|
173
|
+
"run"
|
|
174
|
+
"runCatching"
|
|
175
|
+
"repeat"
|
|
176
|
+
"lazy"
|
|
177
|
+
"lazyOf"
|
|
178
|
+
"enumValues"
|
|
179
|
+
"enumValueOf"
|
|
180
|
+
"assert"
|
|
181
|
+
"check"
|
|
182
|
+
"checkNotNull"
|
|
183
|
+
"require"
|
|
184
|
+
"requireNotNull"
|
|
185
|
+
"with"
|
|
186
|
+
"suspend"
|
|
187
|
+
"synchronized"
|
|
188
|
+
))
|
|
189
|
+
|
|
190
|
+
;;; Literals
|
|
191
|
+
|
|
192
|
+
[
|
|
193
|
+
(line_comment)
|
|
194
|
+
(multiline_comment)
|
|
195
|
+
(shebang_line)
|
|
196
|
+
] @comment
|
|
197
|
+
|
|
198
|
+
(real_literal) @float
|
|
199
|
+
[
|
|
200
|
+
(integer_literal)
|
|
201
|
+
(long_literal)
|
|
202
|
+
(hex_literal)
|
|
203
|
+
(bin_literal)
|
|
204
|
+
(unsigned_literal)
|
|
205
|
+
] @number
|
|
206
|
+
|
|
207
|
+
[
|
|
208
|
+
(null_literal) ; should be highlighted the same as booleans
|
|
209
|
+
(boolean_literal)
|
|
210
|
+
] @boolean
|
|
211
|
+
|
|
212
|
+
(character_literal) @character
|
|
213
|
+
|
|
214
|
+
(string_literal) @string
|
|
215
|
+
|
|
216
|
+
(character_escape_seq) @string.escape
|
|
217
|
+
|
|
218
|
+
; There are 3 ways to define a regex
|
|
219
|
+
; - "[abc]?".toRegex()
|
|
220
|
+
(call_expression
|
|
221
|
+
(navigation_expression
|
|
222
|
+
((string_literal) @string.regex)
|
|
223
|
+
(navigation_suffix
|
|
224
|
+
((simple_identifier) @_function
|
|
225
|
+
(#eq? @_function "toRegex")))))
|
|
226
|
+
|
|
227
|
+
; - Regex("[abc]?")
|
|
228
|
+
(call_expression
|
|
229
|
+
((simple_identifier) @_function
|
|
230
|
+
(#eq? @_function "Regex"))
|
|
231
|
+
(call_suffix
|
|
232
|
+
(value_arguments
|
|
233
|
+
(value_argument
|
|
234
|
+
(string_literal) @string.regex))))
|
|
235
|
+
|
|
236
|
+
; - Regex.fromLiteral("[abc]?")
|
|
237
|
+
(call_expression
|
|
238
|
+
(navigation_expression
|
|
239
|
+
((simple_identifier) @_class
|
|
240
|
+
(#eq? @_class "Regex"))
|
|
241
|
+
(navigation_suffix
|
|
242
|
+
((simple_identifier) @_function
|
|
243
|
+
(#eq? @_function "fromLiteral"))))
|
|
244
|
+
(call_suffix
|
|
245
|
+
(value_arguments
|
|
246
|
+
(value_argument
|
|
247
|
+
(string_literal) @string.regex))))
|
|
248
|
+
|
|
249
|
+
;;; Keywords
|
|
250
|
+
|
|
251
|
+
(type_alias "typealias" @keyword)
|
|
252
|
+
[
|
|
253
|
+
(class_modifier)
|
|
254
|
+
(member_modifier)
|
|
255
|
+
(function_modifier)
|
|
256
|
+
(property_modifier)
|
|
257
|
+
(platform_modifier)
|
|
258
|
+
(variance_modifier)
|
|
259
|
+
(parameter_modifier)
|
|
260
|
+
(visibility_modifier)
|
|
261
|
+
(reification_modifier)
|
|
262
|
+
(inheritance_modifier)
|
|
263
|
+
]@keyword
|
|
264
|
+
|
|
265
|
+
[
|
|
266
|
+
"val"
|
|
267
|
+
"var"
|
|
268
|
+
"enum"
|
|
269
|
+
"class"
|
|
270
|
+
"object"
|
|
271
|
+
"interface"
|
|
272
|
+
; "typeof" ; NOTE: It is reserved for future use
|
|
273
|
+
] @keyword
|
|
274
|
+
|
|
275
|
+
("fun") @keyword.function
|
|
276
|
+
|
|
277
|
+
(jump_expression) @keyword.return
|
|
278
|
+
|
|
279
|
+
[
|
|
280
|
+
"if"
|
|
281
|
+
"else"
|
|
282
|
+
"when"
|
|
283
|
+
] @conditional
|
|
284
|
+
|
|
285
|
+
[
|
|
286
|
+
"for"
|
|
287
|
+
"do"
|
|
288
|
+
"while"
|
|
289
|
+
] @repeat
|
|
290
|
+
|
|
291
|
+
[
|
|
292
|
+
"try"
|
|
293
|
+
"catch"
|
|
294
|
+
"throw"
|
|
295
|
+
"finally"
|
|
296
|
+
] @exception
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
(annotation
|
|
300
|
+
"@" @attribute (use_site_target)? @attribute)
|
|
301
|
+
(annotation
|
|
302
|
+
(user_type
|
|
303
|
+
(type_identifier) @attribute))
|
|
304
|
+
(annotation
|
|
305
|
+
(constructor_invocation
|
|
306
|
+
(user_type
|
|
307
|
+
(type_identifier) @attribute)))
|
|
308
|
+
|
|
309
|
+
(file_annotation
|
|
310
|
+
"@" @attribute "file" @attribute ":" @attribute)
|
|
311
|
+
(file_annotation
|
|
312
|
+
(user_type
|
|
313
|
+
(type_identifier) @attribute))
|
|
314
|
+
(file_annotation
|
|
315
|
+
(constructor_invocation
|
|
316
|
+
(user_type
|
|
317
|
+
(type_identifier) @attribute)))
|
|
318
|
+
|
|
319
|
+
;;; Operators & Punctuation
|
|
320
|
+
|
|
321
|
+
[
|
|
322
|
+
"!"
|
|
323
|
+
"!="
|
|
324
|
+
"!=="
|
|
325
|
+
"="
|
|
326
|
+
"=="
|
|
327
|
+
"==="
|
|
328
|
+
">"
|
|
329
|
+
">="
|
|
330
|
+
"<"
|
|
331
|
+
"<="
|
|
332
|
+
"||"
|
|
333
|
+
"&&"
|
|
334
|
+
"+"
|
|
335
|
+
"++"
|
|
336
|
+
"+="
|
|
337
|
+
"-"
|
|
338
|
+
"--"
|
|
339
|
+
"-="
|
|
340
|
+
"*"
|
|
341
|
+
"*="
|
|
342
|
+
"/"
|
|
343
|
+
"/="
|
|
344
|
+
"%"
|
|
345
|
+
"%="
|
|
346
|
+
"?."
|
|
347
|
+
"?:"
|
|
348
|
+
"!!"
|
|
349
|
+
"is"
|
|
350
|
+
"!is"
|
|
351
|
+
"in"
|
|
352
|
+
"!in"
|
|
353
|
+
"as"
|
|
354
|
+
"as?"
|
|
355
|
+
".."
|
|
356
|
+
"->"
|
|
357
|
+
] @operator
|
|
358
|
+
|
|
359
|
+
[
|
|
360
|
+
"(" ")"
|
|
361
|
+
"[" "]"
|
|
362
|
+
"{" "}"
|
|
363
|
+
] @punctuation.bracket
|
|
364
|
+
|
|
365
|
+
[
|
|
366
|
+
"."
|
|
367
|
+
","
|
|
368
|
+
";"
|
|
369
|
+
":"
|
|
370
|
+
"::"
|
|
371
|
+
] @punctuation.delimiter
|
|
372
|
+
|
|
373
|
+
; NOTE: `interpolated_identifier`s can be highlighted in any way
|
|
374
|
+
(string_literal
|
|
375
|
+
"$" @punctuation.special
|
|
376
|
+
(interpolated_identifier) @none)
|
|
377
|
+
(string_literal
|
|
378
|
+
"${" @punctuation.special
|
|
379
|
+
(interpolated_expression) @none
|
|
380
|
+
"}" @punctuation.special)
|
package/dist/lib/git.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/lib/git.ts
|
|
18
|
+
var {$ } = globalThis.Bun;
|
|
19
|
+
var Git;
|
|
20
|
+
((Git) => {
|
|
21
|
+
async function root(startPath) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await $`git -C ${startPath} rev-parse --show-toplevel`.quiet();
|
|
24
|
+
return result.stdout.toString().trim() || null;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
Git.root = root;
|
|
30
|
+
async function head(repoPath) {
|
|
31
|
+
try {
|
|
32
|
+
const result = await $`git -C ${repoPath} rev-parse HEAD`.quiet();
|
|
33
|
+
return result.stdout.toString().trim() || null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Git.head = head;
|
|
39
|
+
async function diff(repoPath) {
|
|
40
|
+
const e = await entries(repoPath);
|
|
41
|
+
return e.map((x) => x.content).join(`
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
Git.diff = diff;
|
|
45
|
+
async function hash(repoPath) {
|
|
46
|
+
const trackedResult = await $`git -C ${repoPath} diff HEAD --name-only --relative`.quiet();
|
|
47
|
+
const untrackedResult = await $`git -C ${repoPath} ls-files --others --exclude-standard`.quiet();
|
|
48
|
+
const combined = trackedResult.stdout.toString() + "\x00" + untrackedResult.stdout.toString();
|
|
49
|
+
return Number(Bun.hash(combined));
|
|
50
|
+
}
|
|
51
|
+
Git.hash = hash;
|
|
52
|
+
async function entries(repoPath) {
|
|
53
|
+
const context = 0;
|
|
54
|
+
const result = [];
|
|
55
|
+
const filesResult = await $`git -C ${repoPath} diff -U${context} HEAD --name-only --relative`.quiet();
|
|
56
|
+
const filesOutput = filesResult.stdout.toString().trim();
|
|
57
|
+
const trackedFiles = filesOutput ? filesOutput.split(`
|
|
58
|
+
`).filter(Boolean) : [];
|
|
59
|
+
const deletedResult = await $`git -C ${repoPath} diff -U${context} HEAD --name-only --diff-filter=D --relative`.quiet();
|
|
60
|
+
const deletedOutput = deletedResult.stdout.toString().trim();
|
|
61
|
+
const deletedFiles = new Set(deletedOutput ? deletedOutput.split(`
|
|
62
|
+
`).filter(Boolean) : []);
|
|
63
|
+
for (const file of trackedFiles) {
|
|
64
|
+
const diffResult = await $`git -C ${repoPath} diff -U${context} HEAD -- ${file}`.quiet();
|
|
65
|
+
const content = diffResult.stdout.toString();
|
|
66
|
+
const isDeleted = deletedFiles.has(file);
|
|
67
|
+
result.push({ file, content, isNew: false, isDeleted });
|
|
68
|
+
}
|
|
69
|
+
const untrackedResult = await $`git -C ${repoPath} ls-files --others --exclude-standard`.quiet();
|
|
70
|
+
const untrackedOutput = untrackedResult.stdout.toString().trim();
|
|
71
|
+
const untrackedFiles = untrackedOutput ? untrackedOutput.split(`
|
|
72
|
+
`).filter(Boolean) : [];
|
|
73
|
+
for (const file of untrackedFiles) {
|
|
74
|
+
const fileContent = await Bun.file(`${repoPath}/${file}`).text();
|
|
75
|
+
const lines2 = fileContent.split(`
|
|
76
|
+
`);
|
|
77
|
+
const diffLines = lines2.map((line) => `+${line}`);
|
|
78
|
+
const content = `diff --git a/${file} b/${file}
|
|
79
|
+
new file mode 100644
|
|
80
|
+
--- /dev/null
|
|
81
|
+
+++ b/${file}
|
|
82
|
+
@@ -0,0 +1,${lines2.length} @@
|
|
83
|
+
${diffLines.join(`
|
|
84
|
+
`)}`;
|
|
85
|
+
result.push({ file, content, isNew: true, isDeleted: false });
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
Git.entries = entries;
|
|
90
|
+
function lines(diffContent) {
|
|
91
|
+
if (!diffContent)
|
|
92
|
+
return 0;
|
|
93
|
+
const allLines = diffContent.split(`
|
|
94
|
+
`);
|
|
95
|
+
let count = 0;
|
|
96
|
+
let inHunk = false;
|
|
97
|
+
for (const line of allLines) {
|
|
98
|
+
if (line.startsWith("@@")) {
|
|
99
|
+
inHunk = true;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!inHunk)
|
|
103
|
+
continue;
|
|
104
|
+
const firstChar = line[0];
|
|
105
|
+
if (firstChar === " " || firstChar === "+" || firstChar === "-") {
|
|
106
|
+
count++;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return count;
|
|
110
|
+
}
|
|
111
|
+
Git.lines = lines;
|
|
112
|
+
})(Git ||= {});
|
|
113
|
+
export {
|
|
114
|
+
Git
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
//# debugId=37F73B57425D535164756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/git.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { $ } from \"bun\";\n\nexport namespace Git {\n export interface Entry {\n file: string;\n content: string;\n isNew: boolean;\n isDeleted: boolean;\n }\n\n export async function root(startPath: string): Promise<string | null> {\n try {\n const result =\n await $`git -C ${startPath} rev-parse --show-toplevel`.quiet();\n return result.stdout.toString().trim() || null;\n } catch {\n return null;\n }\n }\n\n export async function head(repoPath: string): Promise<string | null> {\n try {\n const result = await $`git -C ${repoPath} rev-parse HEAD`.quiet();\n return result.stdout.toString().trim() || null;\n } catch {\n return null;\n }\n }\n\n export async function diff(repoPath: string): Promise<string> {\n const e = await entries(repoPath);\n return e.map((x) => x.content).join(\"\\n\");\n }\n\n export async function hash(repoPath: string): Promise<number> {\n const trackedResult =\n await $`git -C ${repoPath} diff HEAD --name-only --relative`.quiet();\n const untrackedResult =\n await $`git -C ${repoPath} ls-files --others --exclude-standard`.quiet();\n const combined =\n trackedResult.stdout.toString() +\n \"\\0\" +\n untrackedResult.stdout.toString();\n return Number(Bun.hash(combined));\n }\n\n export async function entries(repoPath: string): Promise<Entry[]> {\n const context = 0\n const result: Entry[] = [];\n const filesResult =\n await $`git -C ${repoPath} diff -U${context} HEAD --name-only --relative`.quiet();\n const filesOutput = filesResult.stdout.toString().trim();\n const trackedFiles = filesOutput\n ? filesOutput.split(\"\\n\").filter(Boolean)\n : [];\n\n const deletedResult =\n await $`git -C ${repoPath} diff -U${context} HEAD --name-only --diff-filter=D --relative`.quiet();\n const deletedOutput = deletedResult.stdout.toString().trim();\n const deletedFiles = new Set(\n deletedOutput ? deletedOutput.split(\"\\n\").filter(Boolean) : [],\n );\n\n for (const file of trackedFiles) {\n const diffResult =\n await $`git -C ${repoPath} diff -U${context} HEAD -- ${file}`.quiet();\n const content = diffResult.stdout.toString();\n const isDeleted = deletedFiles.has(file);\n result.push({ file, content, isNew: false, isDeleted });\n }\n\n const untrackedResult =\n await $`git -C ${repoPath} ls-files --others --exclude-standard`.quiet();\n const untrackedOutput = untrackedResult.stdout.toString().trim();\n const untrackedFiles = untrackedOutput\n ? untrackedOutput.split(\"\\n\").filter(Boolean)\n : [];\n\n for (const file of untrackedFiles) {\n const fileContent = await Bun.file(`${repoPath}/${file}`).text();\n const lines = fileContent.split(\"\\n\");\n const diffLines = lines.map((line) => `+${line}`);\n const content = `diff --git a/${file} b/${file}\nnew file mode 100644\n--- /dev/null\n+++ b/${file}\n@@ -0,0 +1,${lines.length} @@\n${diffLines.join(\"\\n\")}`;\n result.push({ file, content, isNew: true, isDeleted: false });\n }\n\n return result;\n }\n\n export function lines(diffContent: string): number {\n if (!diffContent) return 0;\n const allLines = diffContent.split(\"\\n\");\n let count = 0;\n let inHunk = false;\n for (const line of allLines) {\n if (line.startsWith(\"@@\")) {\n inHunk = true;\n continue;\n }\n if (!inHunk) continue;\n const firstChar = line[0];\n if (firstChar === \" \" || firstChar === \"+\" || firstChar === \"-\") {\n count++;\n }\n }\n return count;\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAEO,IAAU;AAAA,CAAV,CAAU,QAAV;AAAA,EAQL,eAAsB,IAAI,CAAC,WAA2C;AAAA,IACpE,IAAI;AAAA,MACF,MAAM,SACJ,MAAM,WAAW,sCAAsC,MAAM;AAAA,MAC/D,OAAO,OAAO,OAAO,SAAS,EAAE,KAAK,KAAK;AAAA,MAC1C,MAAM;AAAA,MACN,OAAO;AAAA;AAAA;AAAA,EANX,IAAsB;AAAA,EAUtB,eAAsB,IAAI,CAAC,UAA0C;AAAA,IACnE,IAAI;AAAA,MACF,MAAM,SAAS,MAAM,WAAW,0BAA0B,MAAM;AAAA,MAChE,OAAO,OAAO,OAAO,SAAS,EAAE,KAAK,KAAK;AAAA,MAC1C,MAAM;AAAA,MACN,OAAO;AAAA;AAAA;AAAA,EALX,IAAsB;AAAA,EAStB,eAAsB,IAAI,CAAC,UAAmC;AAAA,IAC5D,MAAM,IAAI,MAAM,QAAQ,QAAQ;AAAA,IAChC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAAA,CAAI;AAAA;AAAA,EAF1C,IAAsB;AAAA,EAKtB,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|
|
9
|
+
] @keyword
|
|
10
|
+
|
|
11
|
+
(label_statement) @label
|
|
12
|
+
|
|
13
|
+
(break_statement) @keyword
|
|
14
|
+
|
|
15
|
+
(do_statement
|
|
16
|
+
[
|
|
17
|
+
"do"
|
|
18
|
+
"end"
|
|
19
|
+
] @keyword)
|
|
20
|
+
|
|
21
|
+
(while_statement
|
|
22
|
+
[
|
|
23
|
+
"while"
|
|
24
|
+
"do"
|
|
25
|
+
"end"
|
|
26
|
+
] @repeat)
|
|
27
|
+
|
|
28
|
+
(repeat_statement
|
|
29
|
+
[
|
|
30
|
+
"repeat"
|
|
31
|
+
"until"
|
|
32
|
+
] @repeat)
|
|
33
|
+
|
|
34
|
+
(if_statement
|
|
35
|
+
[
|
|
36
|
+
"if"
|
|
37
|
+
"elseif"
|
|
38
|
+
"else"
|
|
39
|
+
"then"
|
|
40
|
+
"end"
|
|
41
|
+
] @conditional)
|
|
42
|
+
|
|
43
|
+
(elseif_statement
|
|
44
|
+
[
|
|
45
|
+
"elseif"
|
|
46
|
+
"then"
|
|
47
|
+
"end"
|
|
48
|
+
] @conditional)
|
|
49
|
+
|
|
50
|
+
(else_statement
|
|
51
|
+
[
|
|
52
|
+
"else"
|
|
53
|
+
"end"
|
|
54
|
+
] @conditional)
|
|
55
|
+
|
|
56
|
+
(for_statement
|
|
57
|
+
[
|
|
58
|
+
"for"
|
|
59
|
+
"do"
|
|
60
|
+
"end"
|
|
61
|
+
] @repeat)
|
|
62
|
+
|
|
63
|
+
(function_declaration
|
|
64
|
+
[
|
|
65
|
+
"function"
|
|
66
|
+
"end"
|
|
67
|
+
] @keyword.function)
|
|
68
|
+
|
|
69
|
+
(function_definition
|
|
70
|
+
[
|
|
71
|
+
"function"
|
|
72
|
+
"end"
|
|
73
|
+
] @keyword.function)
|
|
74
|
+
|
|
75
|
+
; Operators
|
|
76
|
+
(binary_expression
|
|
77
|
+
operator: _ @operator)
|
|
78
|
+
|
|
79
|
+
(unary_expression
|
|
80
|
+
operator: _ @operator)
|
|
81
|
+
|
|
82
|
+
"=" @operator
|
|
83
|
+
|
|
84
|
+
[
|
|
85
|
+
"and"
|
|
86
|
+
"not"
|
|
87
|
+
"or"
|
|
88
|
+
] @keyword.operator
|
|
89
|
+
|
|
90
|
+
; Punctuations
|
|
91
|
+
[
|
|
92
|
+
";"
|
|
93
|
+
":"
|
|
94
|
+
","
|
|
95
|
+
"."
|
|
96
|
+
] @punctuation.delimiter
|
|
97
|
+
|
|
98
|
+
; Brackets
|
|
99
|
+
[
|
|
100
|
+
"("
|
|
101
|
+
")"
|
|
102
|
+
"["
|
|
103
|
+
"]"
|
|
104
|
+
"{"
|
|
105
|
+
"}"
|
|
106
|
+
] @punctuation.bracket
|
|
107
|
+
|
|
108
|
+
; Variables
|
|
109
|
+
(identifier) @variable
|
|
110
|
+
|
|
111
|
+
((identifier) @variable.builtin
|
|
112
|
+
(#eq? @variable.builtin "self"))
|
|
113
|
+
|
|
114
|
+
(variable_list
|
|
115
|
+
(attribute
|
|
116
|
+
"<" @punctuation.bracket
|
|
117
|
+
(identifier) @attribute
|
|
118
|
+
">" @punctuation.bracket))
|
|
119
|
+
|
|
120
|
+
; Constants
|
|
121
|
+
((identifier) @constant
|
|
122
|
+
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
123
|
+
|
|
124
|
+
(vararg_expression) @constant
|
|
125
|
+
|
|
126
|
+
(nil) @constant.builtin
|
|
127
|
+
|
|
128
|
+
[
|
|
129
|
+
(false)
|
|
130
|
+
(true)
|
|
131
|
+
] @boolean
|
|
132
|
+
|
|
133
|
+
; Tables
|
|
134
|
+
(field
|
|
135
|
+
name: (identifier) @field)
|
|
136
|
+
|
|
137
|
+
(dot_index_expression
|
|
138
|
+
field: (identifier) @field)
|
|
139
|
+
|
|
140
|
+
(table_constructor
|
|
141
|
+
[
|
|
142
|
+
"{"
|
|
143
|
+
"}"
|
|
144
|
+
] @constructor)
|
|
145
|
+
|
|
146
|
+
; Functions
|
|
147
|
+
(parameters
|
|
148
|
+
(identifier) @parameter)
|
|
149
|
+
|
|
150
|
+
(function_declaration
|
|
151
|
+
name: [
|
|
152
|
+
(identifier) @function
|
|
153
|
+
(dot_index_expression
|
|
154
|
+
field: (identifier) @function)
|
|
155
|
+
])
|
|
156
|
+
|
|
157
|
+
(function_declaration
|
|
158
|
+
name: (method_index_expression
|
|
159
|
+
method: (identifier) @method))
|
|
160
|
+
|
|
161
|
+
(assignment_statement
|
|
162
|
+
(variable_list
|
|
163
|
+
.
|
|
164
|
+
name: [
|
|
165
|
+
(identifier) @function
|
|
166
|
+
(dot_index_expression
|
|
167
|
+
field: (identifier) @function)
|
|
168
|
+
])
|
|
169
|
+
(expression_list
|
|
170
|
+
.
|
|
171
|
+
value: (function_definition)))
|
|
172
|
+
|
|
173
|
+
(table_constructor
|
|
174
|
+
(field
|
|
175
|
+
name: (identifier) @function
|
|
176
|
+
value: (function_definition)))
|
|
177
|
+
|
|
178
|
+
(function_call
|
|
179
|
+
name: [
|
|
180
|
+
(identifier) @function.call
|
|
181
|
+
(dot_index_expression
|
|
182
|
+
field: (identifier) @function.call)
|
|
183
|
+
(method_index_expression
|
|
184
|
+
method: (identifier) @method.call)
|
|
185
|
+
])
|
|
186
|
+
|
|
187
|
+
(function_call
|
|
188
|
+
(identifier) @function.builtin
|
|
189
|
+
(#any-of? @function.builtin
|
|
190
|
+
; built-in functions in Lua 5.1
|
|
191
|
+
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
|
|
192
|
+
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require"
|
|
193
|
+
"select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"))
|
|
194
|
+
|
|
195
|
+
; Others
|
|
196
|
+
(comment) @comment
|
|
197
|
+
|
|
198
|
+
(hash_bang_line) @preproc
|
|
199
|
+
|
|
200
|
+
(number) @number
|
|
201
|
+
|
|
202
|
+
(string) @string
|
|
203
|
+
|
|
204
|
+
(escape_sequence) @string.escape
|