@react-grab/cli 0.1.0-beta.6 → 0.1.0-beta.8
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/cli.cjs +205 -1337
- package/dist/cli.js +205 -1336
- package/package.json +2 -3
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import e from 'assert';
|
|
4
3
|
import pc from 'picocolors';
|
|
5
4
|
import prompts3 from 'prompts';
|
|
6
5
|
import { existsSync, readFileSync, writeFileSync, accessSync, constants, readdirSync } from 'fs';
|
|
@@ -19,1036 +18,6 @@ var __export = (target, all) => {
|
|
|
19
18
|
for (var name in all)
|
|
20
19
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
20
|
};
|
|
22
|
-
function t(e3, t2) {
|
|
23
|
-
return `#compdef ${e3}
|
|
24
|
-
compdef _${e3} ${e3}
|
|
25
|
-
|
|
26
|
-
# zsh completion for ${e3} -*- shell-script -*-
|
|
27
|
-
|
|
28
|
-
__${e3}_debug() {
|
|
29
|
-
local file="$BASH_COMP_DEBUG_FILE"
|
|
30
|
-
if [[ -n \${file} ]]; then
|
|
31
|
-
echo "$*" >> "\${file}"
|
|
32
|
-
fi
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_${e3}() {
|
|
36
|
-
local shellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
37
|
-
local shellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
38
|
-
local shellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
39
|
-
local shellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
40
|
-
local shellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
41
|
-
local shellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
42
|
-
|
|
43
|
-
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
44
|
-
local -a completions
|
|
45
|
-
|
|
46
|
-
__${e3}_debug "\\n========= starting completion logic =========="
|
|
47
|
-
__${e3}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
|
|
48
|
-
|
|
49
|
-
# The user could have moved the cursor backwards on the command-line.
|
|
50
|
-
# We need to trigger completion from the $CURRENT location, so we need
|
|
51
|
-
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
52
|
-
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
53
|
-
words=( "\${=words[1,CURRENT]}" )
|
|
54
|
-
__${e3}_debug "Truncated words[*]: \${words[*]},"
|
|
55
|
-
|
|
56
|
-
lastParam=\${words[-1]}
|
|
57
|
-
lastChar=\${lastParam[-1]}
|
|
58
|
-
__${e3}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
|
|
59
|
-
|
|
60
|
-
# For zsh, when completing a flag with an = (e.g., ${e3} -n=<TAB>)
|
|
61
|
-
# completions must be prefixed with the flag
|
|
62
|
-
setopt local_options BASH_REMATCH
|
|
63
|
-
if [[ "\${lastParam}" =~ '-.*=' ]]; then
|
|
64
|
-
# We are dealing with a flag with an =
|
|
65
|
-
flagPrefix="-P \${BASH_REMATCH}"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
69
|
-
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
70
|
-
if [ "\${lastChar}" = "" ]; then
|
|
71
|
-
# If the last parameter is complete (there is a space following it)
|
|
72
|
-
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
73
|
-
__${e3}_debug "Adding extra empty parameter"
|
|
74
|
-
args_to_quote+=("")
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
78
|
-
local quoted_args=("\${(@q)args_to_quote}")
|
|
79
|
-
|
|
80
|
-
# Join the main command and the quoted arguments into a single string for eval
|
|
81
|
-
requestComp="${t2} complete -- \${quoted_args[*]}"
|
|
82
|
-
|
|
83
|
-
__${e3}_debug "About to call: eval \${requestComp}"
|
|
84
|
-
|
|
85
|
-
# Use eval to handle any environment variables and such
|
|
86
|
-
out=$(eval \${requestComp} 2>/dev/null)
|
|
87
|
-
__${e3}_debug "completion output: \${out}"
|
|
88
|
-
|
|
89
|
-
# Extract the directive integer following a : from the last line
|
|
90
|
-
local lastLine
|
|
91
|
-
while IFS='
|
|
92
|
-
' read -r line; do
|
|
93
|
-
lastLine=\${line}
|
|
94
|
-
done < <(printf "%s
|
|
95
|
-
" "\${out[@]}")
|
|
96
|
-
__${e3}_debug "last line: \${lastLine}"
|
|
97
|
-
|
|
98
|
-
if [ "\${lastLine[1]}" = : ]; then
|
|
99
|
-
directive=\${lastLine[2,-1]}
|
|
100
|
-
# Remove the directive including the : and the newline
|
|
101
|
-
local suffix
|
|
102
|
-
(( suffix=\${#lastLine}+2))
|
|
103
|
-
out=\${out[1,-$suffix]}
|
|
104
|
-
else
|
|
105
|
-
# There is no directive specified. Leave $out as is.
|
|
106
|
-
__${e3}_debug "No directive found. Setting to default"
|
|
107
|
-
directive=0
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
__${e3}_debug "directive: \${directive}"
|
|
111
|
-
__${e3}_debug "completions: \${out}"
|
|
112
|
-
__${e3}_debug "flagPrefix: \${flagPrefix}"
|
|
113
|
-
|
|
114
|
-
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
115
|
-
__${e3}_debug "Completion received error. Ignoring completions."
|
|
116
|
-
return
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
|
-
local activeHelpMarker="%"
|
|
120
|
-
local endIndex=\${#activeHelpMarker}
|
|
121
|
-
local startIndex=$((\${#activeHelpMarker}+1))
|
|
122
|
-
local hasActiveHelp=0
|
|
123
|
-
while IFS='
|
|
124
|
-
' read -r comp; do
|
|
125
|
-
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
126
|
-
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
127
|
-
__${e3}_debug "ActiveHelp found: $comp"
|
|
128
|
-
comp="\${comp[$startIndex,-1]}"
|
|
129
|
-
if [ -n "$comp" ]; then
|
|
130
|
-
compadd -x "\${comp}"
|
|
131
|
-
__${e3}_debug "ActiveHelp will need delimiter"
|
|
132
|
-
hasActiveHelp=1
|
|
133
|
-
fi
|
|
134
|
-
continue
|
|
135
|
-
fi
|
|
136
|
-
|
|
137
|
-
if [ -n "$comp" ]; then
|
|
138
|
-
# If requested, completions are returned with a description.
|
|
139
|
-
# The description is preceded by a TAB character.
|
|
140
|
-
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
141
|
-
# We first need to escape any : as part of the completion itself.
|
|
142
|
-
comp=\${comp//:/\\:}
|
|
143
|
-
|
|
144
|
-
local tab="$(printf '\\t')"
|
|
145
|
-
comp=\${comp//$tab/:}
|
|
146
|
-
|
|
147
|
-
__${e3}_debug "Adding completion: \${comp}"
|
|
148
|
-
completions+=\${comp}
|
|
149
|
-
lastComp=$comp
|
|
150
|
-
fi
|
|
151
|
-
done < <(printf "%s
|
|
152
|
-
" "\${out[@]}")
|
|
153
|
-
|
|
154
|
-
# Add a delimiter after the activeHelp statements, but only if:
|
|
155
|
-
# - there are completions following the activeHelp statements, or
|
|
156
|
-
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
157
|
-
if [ $hasActiveHelp -eq 1 ]; then
|
|
158
|
-
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
159
|
-
__${e3}_debug "Adding activeHelp delimiter"
|
|
160
|
-
compadd -x "--"
|
|
161
|
-
hasActiveHelp=0
|
|
162
|
-
fi
|
|
163
|
-
fi
|
|
164
|
-
|
|
165
|
-
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
166
|
-
__${e3}_debug "Activating nospace."
|
|
167
|
-
noSpace="-S ''"
|
|
168
|
-
fi
|
|
169
|
-
|
|
170
|
-
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
171
|
-
__${e3}_debug "Activating keep order."
|
|
172
|
-
keepOrder="-V"
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
176
|
-
# File extension filtering
|
|
177
|
-
local filteringCmd
|
|
178
|
-
filteringCmd='_files'
|
|
179
|
-
for filter in \${completions[@]}; do
|
|
180
|
-
if [ \${filter[1]} != '*' ]; then
|
|
181
|
-
# zsh requires a glob pattern to do file filtering
|
|
182
|
-
filter="\\*.$filter"
|
|
183
|
-
fi
|
|
184
|
-
filteringCmd+=" -g $filter"
|
|
185
|
-
done
|
|
186
|
-
filteringCmd+=" \${flagPrefix}"
|
|
187
|
-
|
|
188
|
-
__${e3}_debug "File filtering command: $filteringCmd"
|
|
189
|
-
_arguments '*:filename:'"$filteringCmd"
|
|
190
|
-
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
191
|
-
# File completion for directories only
|
|
192
|
-
local subdir
|
|
193
|
-
subdir="\${completions[1]}"
|
|
194
|
-
if [ -n "$subdir" ]; then
|
|
195
|
-
__${e3}_debug "Listing directories in $subdir"
|
|
196
|
-
pushd "\${subdir}" >/dev/null 2>&1
|
|
197
|
-
else
|
|
198
|
-
__${e3}_debug "Listing directories in ."
|
|
199
|
-
fi
|
|
200
|
-
|
|
201
|
-
local result
|
|
202
|
-
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
203
|
-
result=$?
|
|
204
|
-
if [ -n "$subdir" ]; then
|
|
205
|
-
popd >/dev/null 2>&1
|
|
206
|
-
fi
|
|
207
|
-
return $result
|
|
208
|
-
else
|
|
209
|
-
__${e3}_debug "Calling _describe"
|
|
210
|
-
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
211
|
-
__${e3}_debug "_describe found some completions"
|
|
212
|
-
|
|
213
|
-
# Return the success of having called _describe
|
|
214
|
-
return 0
|
|
215
|
-
else
|
|
216
|
-
__${e3}_debug "_describe did not find completions."
|
|
217
|
-
__${e3}_debug "Checking if we should do file completion."
|
|
218
|
-
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
219
|
-
__${e3}_debug "deactivating file completion"
|
|
220
|
-
|
|
221
|
-
# Return 0 to indicate completion is finished and prevent zsh from
|
|
222
|
-
# trying other completion algorithms (which could cause hanging).
|
|
223
|
-
# We use NoFileComp directive to explicitly disable file completion.
|
|
224
|
-
return 0
|
|
225
|
-
else
|
|
226
|
-
# Perform file completion
|
|
227
|
-
__${e3}_debug "Activating file completion"
|
|
228
|
-
|
|
229
|
-
# We must return the result of this command, so it must be the
|
|
230
|
-
# last command, or else we must store its result to return it.
|
|
231
|
-
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
232
|
-
fi
|
|
233
|
-
fi
|
|
234
|
-
fi
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
# don't run the completion function when being sourced or eval-ed
|
|
238
|
-
if [ "\${funcstack[1]}" = "_${e3}" ]; then
|
|
239
|
-
_${e3}
|
|
240
|
-
fi
|
|
241
|
-
`;
|
|
242
|
-
}
|
|
243
|
-
function n(e3, t2) {
|
|
244
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
245
|
-
return `# bash completion for ${e3}
|
|
246
|
-
|
|
247
|
-
# Define shell completion directives
|
|
248
|
-
readonly ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
249
|
-
readonly ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
250
|
-
readonly ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
251
|
-
readonly ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
252
|
-
readonly ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
253
|
-
readonly ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
254
|
-
|
|
255
|
-
# Function to debug completion
|
|
256
|
-
__${n2}_debug() {
|
|
257
|
-
if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
258
|
-
echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
|
|
259
|
-
fi
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
# Function to handle completions
|
|
263
|
-
__${n2}_complete() {
|
|
264
|
-
local cur prev words cword
|
|
265
|
-
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
266
|
-
|
|
267
|
-
local requestComp out directive
|
|
268
|
-
|
|
269
|
-
# Build the command to get completions
|
|
270
|
-
requestComp="${t2} complete -- \${words[@]:1}"
|
|
271
|
-
|
|
272
|
-
# Add an empty parameter if the last parameter is complete
|
|
273
|
-
if [[ -z "$cur" ]]; then
|
|
274
|
-
requestComp="$requestComp ''"
|
|
275
|
-
fi
|
|
276
|
-
|
|
277
|
-
# Get completions from the program
|
|
278
|
-
out=$(eval "$requestComp" 2>/dev/null)
|
|
279
|
-
|
|
280
|
-
# Extract directive if present
|
|
281
|
-
directive=0
|
|
282
|
-
if [[ "$out" == *:* ]]; then
|
|
283
|
-
directive=\${out##*:}
|
|
284
|
-
out=\${out%:*}
|
|
285
|
-
fi
|
|
286
|
-
|
|
287
|
-
# Process completions based on directive
|
|
288
|
-
if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
|
|
289
|
-
# Error, no completion
|
|
290
|
-
return
|
|
291
|
-
fi
|
|
292
|
-
|
|
293
|
-
# Apply directives
|
|
294
|
-
if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
|
|
295
|
-
compopt -o nospace
|
|
296
|
-
fi
|
|
297
|
-
if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
|
|
298
|
-
compopt -o nosort
|
|
299
|
-
fi
|
|
300
|
-
if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
|
|
301
|
-
compopt +o default
|
|
302
|
-
fi
|
|
303
|
-
|
|
304
|
-
# Handle file extension filtering
|
|
305
|
-
if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
|
|
306
|
-
local filter=""
|
|
307
|
-
for ext in $out; do
|
|
308
|
-
filter="$filter|$ext"
|
|
309
|
-
done
|
|
310
|
-
filter="\\.($filter)"
|
|
311
|
-
compopt -o filenames
|
|
312
|
-
COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
|
|
313
|
-
return
|
|
314
|
-
fi
|
|
315
|
-
|
|
316
|
-
# Handle directory filtering
|
|
317
|
-
if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
|
|
318
|
-
compopt -o dirnames
|
|
319
|
-
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
320
|
-
return
|
|
321
|
-
fi
|
|
322
|
-
|
|
323
|
-
# Process completions
|
|
324
|
-
local IFS=$'\\n'
|
|
325
|
-
local tab=$(printf '\\t')
|
|
326
|
-
|
|
327
|
-
# Parse completions with descriptions
|
|
328
|
-
local completions=()
|
|
329
|
-
while read -r comp; do
|
|
330
|
-
if [[ "$comp" == *$tab* ]]; then
|
|
331
|
-
# Split completion and description
|
|
332
|
-
local value=\${comp%%$tab*}
|
|
333
|
-
local desc=\${comp#*$tab}
|
|
334
|
-
completions+=("$value")
|
|
335
|
-
else
|
|
336
|
-
completions+=("$comp")
|
|
337
|
-
fi
|
|
338
|
-
done <<< "$out"
|
|
339
|
-
|
|
340
|
-
# Return completions
|
|
341
|
-
COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
# Register completion function
|
|
345
|
-
complete -F __${n2}_complete ${e3}
|
|
346
|
-
`;
|
|
347
|
-
}
|
|
348
|
-
function r(e3, t2) {
|
|
349
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
350
|
-
return `# fish completion for ${e3} -*- shell-script -*-
|
|
351
|
-
|
|
352
|
-
# Define shell completion directives
|
|
353
|
-
set -l ShellCompDirectiveError ${a.ShellCompDirectiveError}
|
|
354
|
-
set -l ShellCompDirectiveNoSpace ${a.ShellCompDirectiveNoSpace}
|
|
355
|
-
set -l ShellCompDirectiveNoFileComp ${a.ShellCompDirectiveNoFileComp}
|
|
356
|
-
set -l ShellCompDirectiveFilterFileExt ${a.ShellCompDirectiveFilterFileExt}
|
|
357
|
-
set -l ShellCompDirectiveFilterDirs ${a.ShellCompDirectiveFilterDirs}
|
|
358
|
-
set -l ShellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
359
|
-
|
|
360
|
-
function __${n2}_debug
|
|
361
|
-
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
362
|
-
if test -n "$file"
|
|
363
|
-
echo "$argv" >> $file
|
|
364
|
-
end
|
|
365
|
-
end
|
|
366
|
-
|
|
367
|
-
function __${n2}_perform_completion
|
|
368
|
-
__${n2}_debug "Starting __${n2}_perform_completion"
|
|
369
|
-
|
|
370
|
-
# Extract all args except the completion flag
|
|
371
|
-
set -l args (string match -v -- "--completion=" (commandline -opc))
|
|
372
|
-
|
|
373
|
-
# Extract the current token being completed
|
|
374
|
-
set -l current_token (commandline -ct)
|
|
375
|
-
|
|
376
|
-
# Check if current token starts with a dash
|
|
377
|
-
set -l flag_prefix ""
|
|
378
|
-
if string match -q -- "-*" $current_token
|
|
379
|
-
set flag_prefix "--flag="
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
__${n2}_debug "Current token: $current_token"
|
|
383
|
-
__${n2}_debug "All args: $args"
|
|
384
|
-
|
|
385
|
-
# Call the completion program and get the results
|
|
386
|
-
set -l requestComp "${t2} complete -- $args"
|
|
387
|
-
__${n2}_debug "Calling $requestComp"
|
|
388
|
-
set -l results (eval $requestComp 2> /dev/null)
|
|
389
|
-
|
|
390
|
-
# Some programs may output extra empty lines after the directive.
|
|
391
|
-
# Let's ignore them or else it will break completion.
|
|
392
|
-
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
393
|
-
for line in $results[-1..1]
|
|
394
|
-
if test (string sub -s 1 -l 1 -- $line) = ":"
|
|
395
|
-
# The directive
|
|
396
|
-
set -l directive (string sub -s 2 -- $line)
|
|
397
|
-
set -l directive_num (math $directive)
|
|
398
|
-
break
|
|
399
|
-
end
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
# No directive specified, use default
|
|
403
|
-
if not set -q directive_num
|
|
404
|
-
set directive_num 0
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
__${n2}_debug "Directive: $directive_num"
|
|
408
|
-
|
|
409
|
-
# Process completions based on directive
|
|
410
|
-
if test $directive_num -eq $ShellCompDirectiveError
|
|
411
|
-
# Error code. No completion.
|
|
412
|
-
__${n2}_debug "Received error directive: aborting."
|
|
413
|
-
return 1
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
# Filter out the directive (last line)
|
|
417
|
-
if test (count $results) -gt 0 -a (string sub -s 1 -l 1 -- $results[-1]) = ":"
|
|
418
|
-
set results $results[1..-2]
|
|
419
|
-
end
|
|
420
|
-
|
|
421
|
-
# No completions, let fish handle file completions unless forbidden
|
|
422
|
-
if test (count $results) -eq 0
|
|
423
|
-
if test $directive_num -ne $ShellCompDirectiveNoFileComp
|
|
424
|
-
__${n2}_debug "No completions, performing file completion"
|
|
425
|
-
return 1
|
|
426
|
-
end
|
|
427
|
-
__${n2}_debug "No completions, but file completion forbidden"
|
|
428
|
-
return 0
|
|
429
|
-
end
|
|
430
|
-
|
|
431
|
-
# Filter file extensions
|
|
432
|
-
if test $directive_num -eq $ShellCompDirectiveFilterFileExt
|
|
433
|
-
__${n2}_debug "File extension filtering"
|
|
434
|
-
set -l file_extensions
|
|
435
|
-
for item in $results
|
|
436
|
-
if test -n "$item" -a (string sub -s 1 -l 1 -- $item) != "-"
|
|
437
|
-
set -a file_extensions "*$item"
|
|
438
|
-
end
|
|
439
|
-
end
|
|
440
|
-
__${n2}_debug "File extensions: $file_extensions"
|
|
441
|
-
|
|
442
|
-
# Use the file extensions as completions
|
|
443
|
-
set -l completions
|
|
444
|
-
for ext in $file_extensions
|
|
445
|
-
# Get all files matching the extension
|
|
446
|
-
set -a completions (string replace -r '^.*/' '' -- $ext)
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
for item in $completions
|
|
450
|
-
echo -e "$item "
|
|
451
|
-
end
|
|
452
|
-
return 0
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
# Filter directories
|
|
456
|
-
if test $directive_num -eq $ShellCompDirectiveFilterDirs
|
|
457
|
-
__${n2}_debug "Directory filtering"
|
|
458
|
-
set -l dirs
|
|
459
|
-
for item in $results
|
|
460
|
-
if test -d "$item"
|
|
461
|
-
set -a dirs "$item/"
|
|
462
|
-
end
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
for item in $dirs
|
|
466
|
-
echo -e "$item "
|
|
467
|
-
end
|
|
468
|
-
return 0
|
|
469
|
-
end
|
|
470
|
-
|
|
471
|
-
# Process remaining completions
|
|
472
|
-
for item in $results
|
|
473
|
-
if test -n "$item"
|
|
474
|
-
# Check if the item has a description
|
|
475
|
-
if string match -q "* *" -- "$item"
|
|
476
|
-
set -l completion_parts (string split -- "$item")
|
|
477
|
-
set -l comp $completion_parts[1]
|
|
478
|
-
set -l desc $completion_parts[2]
|
|
479
|
-
|
|
480
|
-
# Add the completion and description
|
|
481
|
-
echo -e "$comp $desc"
|
|
482
|
-
else
|
|
483
|
-
# Add just the completion
|
|
484
|
-
echo -e "$item "
|
|
485
|
-
end
|
|
486
|
-
end
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
# If directive contains NoSpace, tell fish not to add a space after completion
|
|
490
|
-
if test (math "$directive_num & $ShellCompDirectiveNoSpace") -ne 0
|
|
491
|
-
return 2
|
|
492
|
-
end
|
|
493
|
-
|
|
494
|
-
return 0
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
# Set up the completion for the ${e3} command
|
|
498
|
-
complete -c ${e3} -f -a "(eval __${n2}_perform_completion)"
|
|
499
|
-
`;
|
|
500
|
-
}
|
|
501
|
-
function i(e3, t2) {
|
|
502
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
503
|
-
return `# powershell completion for ${e3} -*- shell-script -*-
|
|
504
|
-
|
|
505
|
-
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
506
|
-
function __${e3}_debug {
|
|
507
|
-
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
508
|
-
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
filter __${e3}_escapeStringWithSpecialChars {
|
|
513
|
-
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
[scriptblock]$__${n2}CompleterBlock = {
|
|
517
|
-
param(
|
|
518
|
-
$WordToComplete,
|
|
519
|
-
$CommandAst,
|
|
520
|
-
$CursorPosition
|
|
521
|
-
)
|
|
522
|
-
|
|
523
|
-
# Get the current command line and convert into a string
|
|
524
|
-
$Command = $CommandAst.CommandElements
|
|
525
|
-
$Command = "$Command"
|
|
526
|
-
|
|
527
|
-
__${e3}_debug ""
|
|
528
|
-
__${e3}_debug "========= starting completion logic =========="
|
|
529
|
-
__${e3}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
530
|
-
|
|
531
|
-
# The user could have moved the cursor backwards on the command-line.
|
|
532
|
-
# We need to trigger completion from the $CursorPosition location, so we need
|
|
533
|
-
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
534
|
-
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
535
|
-
# This happens because the $Command does not include the last space.
|
|
536
|
-
if ($Command.Length -gt $CursorPosition) {
|
|
537
|
-
$Command = $Command.Substring(0, $CursorPosition)
|
|
538
|
-
}
|
|
539
|
-
__${e3}_debug "Truncated command: $Command"
|
|
540
|
-
|
|
541
|
-
$ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
542
|
-
$ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
543
|
-
$ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
544
|
-
$ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
545
|
-
$ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
546
|
-
$ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
547
|
-
|
|
548
|
-
# Prepare the command to request completions for the program.
|
|
549
|
-
# Split the command at the first space to separate the program and arguments.
|
|
550
|
-
$Program, $Arguments = $Command.Split(" ", 2)
|
|
551
|
-
|
|
552
|
-
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
553
|
-
__${e3}_debug "QuotedArgs: $QuotedArgs"
|
|
554
|
-
|
|
555
|
-
$RequestComp = "& ${t2} complete '--' $QuotedArgs"
|
|
556
|
-
__${e3}_debug "RequestComp: $RequestComp"
|
|
557
|
-
|
|
558
|
-
# we cannot use $WordToComplete because it
|
|
559
|
-
# has the wrong values if the cursor was moved
|
|
560
|
-
# so use the last argument
|
|
561
|
-
if ($WordToComplete -ne "" ) {
|
|
562
|
-
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
563
|
-
}
|
|
564
|
-
__${e3}_debug "New WordToComplete: $WordToComplete"
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
# Check for flag with equal sign
|
|
568
|
-
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
569
|
-
if ( $IsEqualFlag ) {
|
|
570
|
-
__${e3}_debug "Completing equal sign flag"
|
|
571
|
-
# Remove the flag part
|
|
572
|
-
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
576
|
-
# If the last parameter is complete (there is a space following it)
|
|
577
|
-
# We add an extra empty parameter so we can indicate this to the go method.
|
|
578
|
-
__${e3}_debug "Adding extra empty parameter"
|
|
579
|
-
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
580
|
-
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
581
|
-
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
582
|
-
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
583
|
-
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
584
|
-
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
585
|
-
$RequestComp="$RequestComp" + ' \`"\`"'
|
|
586
|
-
} else {
|
|
587
|
-
$RequestComp = "$RequestComp" + ' ""'
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
__${e3}_debug "Calling $RequestComp"
|
|
592
|
-
# First disable ActiveHelp which is not supported for Powershell
|
|
593
|
-
$env:ActiveHelp = 0
|
|
594
|
-
|
|
595
|
-
# call the command store the output in $out and redirect stderr and stdout to null
|
|
596
|
-
# $Out is an array contains each line per element
|
|
597
|
-
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
598
|
-
|
|
599
|
-
# get directive from last line
|
|
600
|
-
[int]$Directive = $Out[-1].TrimStart(':')
|
|
601
|
-
if ($Directive -eq "") {
|
|
602
|
-
# There is no directive specified
|
|
603
|
-
$Directive = 0
|
|
604
|
-
}
|
|
605
|
-
__${e3}_debug "The completion directive is: $Directive"
|
|
606
|
-
|
|
607
|
-
# remove directive (last element) from out
|
|
608
|
-
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
609
|
-
__${e3}_debug "The completions are: $Out"
|
|
610
|
-
|
|
611
|
-
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
612
|
-
# Error code. No completion.
|
|
613
|
-
__${e3}_debug "Received error from custom completion go code"
|
|
614
|
-
return
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
$Longest = 0
|
|
618
|
-
[Array]$Values = $Out | ForEach-Object {
|
|
619
|
-
# Split the output in name and description
|
|
620
|
-
$Name, $Description = $_.Split("\`t", 2)
|
|
621
|
-
__${e3}_debug "Name: $Name Description: $Description"
|
|
622
|
-
|
|
623
|
-
# Look for the longest completion so that we can format things nicely
|
|
624
|
-
if ($Longest -lt $Name.Length) {
|
|
625
|
-
$Longest = $Name.Length
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
# Set the description to a one space string if there is none set.
|
|
629
|
-
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
630
|
-
if (-Not $Description) {
|
|
631
|
-
$Description = " "
|
|
632
|
-
}
|
|
633
|
-
@{ Name = "$Name"; Description = "$Description" }
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
$Space = " "
|
|
638
|
-
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
639
|
-
# remove the space here
|
|
640
|
-
__${e3}_debug "ShellCompDirectiveNoSpace is called"
|
|
641
|
-
$Space = ""
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
645
|
-
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
646
|
-
__${e3}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
647
|
-
|
|
648
|
-
# return here to prevent the completion of the extensions
|
|
649
|
-
return
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
$Values = $Values | Where-Object {
|
|
653
|
-
# filter the result
|
|
654
|
-
$_.Name -like "$WordToComplete*"
|
|
655
|
-
|
|
656
|
-
# Join the flag back if we have an equal sign flag
|
|
657
|
-
if ( $IsEqualFlag ) {
|
|
658
|
-
__${e3}_debug "Join the equal sign flag back to the completion value"
|
|
659
|
-
$_.Name = $Flag + "=" + $_.Name
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
# we sort the values in ascending order by name if keep order isn't passed
|
|
664
|
-
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
665
|
-
$Values = $Values | Sort-Object -Property Name
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
669
|
-
__${e3}_debug "ShellCompDirectiveNoFileComp is called"
|
|
670
|
-
|
|
671
|
-
if ($Values.Length -eq 0) {
|
|
672
|
-
# Just print an empty string here so the
|
|
673
|
-
# shell does not start to complete paths.
|
|
674
|
-
# We cannot use CompletionResult here because
|
|
675
|
-
# it does not accept an empty string as argument.
|
|
676
|
-
""
|
|
677
|
-
return
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
# Get the current mode
|
|
682
|
-
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
683
|
-
__${e3}_debug "Mode: $Mode"
|
|
684
|
-
|
|
685
|
-
$Values | ForEach-Object {
|
|
686
|
-
|
|
687
|
-
# store temporary because switch will overwrite $_
|
|
688
|
-
$comp = $_
|
|
689
|
-
|
|
690
|
-
# PowerShell supports three different completion modes
|
|
691
|
-
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
692
|
-
# - Complete (works like bash)
|
|
693
|
-
# - MenuComplete (works like zsh)
|
|
694
|
-
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
695
|
-
|
|
696
|
-
# CompletionResult Arguments:
|
|
697
|
-
# 1) CompletionText text to be used as the auto completion result
|
|
698
|
-
# 2) ListItemText text to be displayed in the suggestion list
|
|
699
|
-
# 3) ResultType type of completion result
|
|
700
|
-
# 4) ToolTip text for the tooltip with details about the object
|
|
701
|
-
|
|
702
|
-
switch ($Mode) {
|
|
703
|
-
|
|
704
|
-
# bash like
|
|
705
|
-
"Complete" {
|
|
706
|
-
|
|
707
|
-
if ($Values.Length -eq 1) {
|
|
708
|
-
__${e3}_debug "Only one completion left"
|
|
709
|
-
|
|
710
|
-
# insert space after value
|
|
711
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
712
|
-
|
|
713
|
-
} else {
|
|
714
|
-
# Add the proper number of spaces to align the descriptions
|
|
715
|
-
while($comp.Name.Length -lt $Longest) {
|
|
716
|
-
$comp.Name = $comp.Name + " "
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
# Check for empty description and only add parentheses if needed
|
|
720
|
-
if ($($comp.Description) -eq " " ) {
|
|
721
|
-
$Description = ""
|
|
722
|
-
} else {
|
|
723
|
-
$Description = " ($($comp.Description))"
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
# zsh like
|
|
731
|
-
"MenuComplete" {
|
|
732
|
-
# insert space after value
|
|
733
|
-
# MenuComplete will automatically show the ToolTip of
|
|
734
|
-
# the highlighted value at the bottom of the suggestions.
|
|
735
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
# TabCompleteNext and in case we get something unknown
|
|
739
|
-
Default {
|
|
740
|
-
# Like MenuComplete but we don't want to add a space here because
|
|
741
|
-
# the user need to press space anyway to get the completion.
|
|
742
|
-
# Description will not be shown because that's not possible with TabCompleteNext
|
|
743
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
Register-ArgumentCompleter -CommandName '${e3}' -ScriptBlock $__${n2}CompleterBlock
|
|
751
|
-
`;
|
|
752
|
-
}
|
|
753
|
-
var a = { ShellCompDirectiveError: 1, ShellCompDirectiveNoSpace: 2, ShellCompDirectiveNoFileComp: 4, ShellCompDirectiveFilterFileExt: 8, ShellCompDirectiveFilterDirs: 16, ShellCompDirectiveKeepOrder: 32, ShellCompDirectiveDefault: 0 };
|
|
754
|
-
var o = class {
|
|
755
|
-
name;
|
|
756
|
-
variadic;
|
|
757
|
-
command;
|
|
758
|
-
handler;
|
|
759
|
-
constructor(e3, t2, n2, r2 = false) {
|
|
760
|
-
this.command = e3, this.name = t2, this.handler = n2, this.variadic = r2;
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
var s = class {
|
|
764
|
-
value;
|
|
765
|
-
description;
|
|
766
|
-
command;
|
|
767
|
-
handler;
|
|
768
|
-
alias;
|
|
769
|
-
isBoolean;
|
|
770
|
-
constructor(e3, t2, n2, r2, i2, a2) {
|
|
771
|
-
this.command = e3, this.value = t2, this.description = n2, this.handler = r2, this.alias = i2, this.isBoolean = a2;
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
var c = class {
|
|
775
|
-
value;
|
|
776
|
-
description;
|
|
777
|
-
options = /* @__PURE__ */ new Map();
|
|
778
|
-
arguments = /* @__PURE__ */ new Map();
|
|
779
|
-
parent;
|
|
780
|
-
constructor(e3, t2) {
|
|
781
|
-
this.value = e3, this.description = t2;
|
|
782
|
-
}
|
|
783
|
-
option(e3, t2, n2, r2) {
|
|
784
|
-
let i2, a2, o3;
|
|
785
|
-
typeof n2 == `function` ? (i2 = n2, a2 = r2, o3 = false) : typeof n2 == `string` ? (i2 = void 0, a2 = n2, o3 = true) : (i2 = void 0, a2 = void 0, o3 = true);
|
|
786
|
-
let c3 = new s(this, e3, t2, i2, a2, o3);
|
|
787
|
-
return this.options.set(e3, c3), this;
|
|
788
|
-
}
|
|
789
|
-
argument(e3, t2, n2 = false) {
|
|
790
|
-
let r2 = new o(this, e3, t2, n2);
|
|
791
|
-
return this.arguments.set(e3, r2), this;
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
var l = class extends c {
|
|
795
|
-
commands = /* @__PURE__ */ new Map();
|
|
796
|
-
completions = [];
|
|
797
|
-
directive = a.ShellCompDirectiveDefault;
|
|
798
|
-
constructor() {
|
|
799
|
-
super(``, ``);
|
|
800
|
-
}
|
|
801
|
-
command(e3, t2) {
|
|
802
|
-
let n2 = new c(e3, t2);
|
|
803
|
-
return this.commands.set(e3, n2), n2;
|
|
804
|
-
}
|
|
805
|
-
stripOptions(e3) {
|
|
806
|
-
let t2 = [], n2 = 0;
|
|
807
|
-
for (; n2 < e3.length; ) {
|
|
808
|
-
let r2 = e3[n2];
|
|
809
|
-
if (r2.startsWith(`-`)) {
|
|
810
|
-
n2++;
|
|
811
|
-
let t3 = false, i2 = this.findOption(this, r2);
|
|
812
|
-
if (i2) t3 = i2.isBoolean ?? false;
|
|
813
|
-
else for (let [, e4] of this.commands) {
|
|
814
|
-
let n3 = this.findOption(e4, r2);
|
|
815
|
-
if (n3) {
|
|
816
|
-
t3 = n3.isBoolean ?? false;
|
|
817
|
-
break;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
!t3 && n2 < e3.length && !e3[n2].startsWith(`-`) && n2++;
|
|
821
|
-
} else t2.push(r2), n2++;
|
|
822
|
-
}
|
|
823
|
-
return t2;
|
|
824
|
-
}
|
|
825
|
-
matchCommand(e3) {
|
|
826
|
-
e3 = this.stripOptions(e3);
|
|
827
|
-
let t2 = [], n2 = [], r2 = null;
|
|
828
|
-
for (let i2 = 0; i2 < e3.length; i2++) {
|
|
829
|
-
let a2 = e3[i2];
|
|
830
|
-
t2.push(a2);
|
|
831
|
-
let o3 = this.commands.get(t2.join(` `));
|
|
832
|
-
if (o3) r2 = o3;
|
|
833
|
-
else {
|
|
834
|
-
n2 = e3.slice(i2, e3.length);
|
|
835
|
-
break;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
return [r2 || this, n2];
|
|
839
|
-
}
|
|
840
|
-
shouldCompleteFlags(e3, t2) {
|
|
841
|
-
if (t2.startsWith(`-`)) return true;
|
|
842
|
-
if (e3?.startsWith(`-`)) {
|
|
843
|
-
let t3 = this.findOption(this, e3);
|
|
844
|
-
if (!t3) {
|
|
845
|
-
for (let [, n2] of this.commands) if (t3 = this.findOption(n2, e3), t3) break;
|
|
846
|
-
}
|
|
847
|
-
return !(t3 && t3.isBoolean);
|
|
848
|
-
}
|
|
849
|
-
return false;
|
|
850
|
-
}
|
|
851
|
-
shouldCompleteCommands(e3) {
|
|
852
|
-
return !e3.startsWith(`-`);
|
|
853
|
-
}
|
|
854
|
-
handleFlagCompletion(e3, t2, n2, r2) {
|
|
855
|
-
let i2;
|
|
856
|
-
if (n2.includes(`=`)) {
|
|
857
|
-
let [e4] = n2.split(`=`);
|
|
858
|
-
i2 = e4;
|
|
859
|
-
} else if (r2?.startsWith(`-`)) {
|
|
860
|
-
let t3 = this.findOption(e3, r2);
|
|
861
|
-
t3 && !t3.isBoolean && (i2 = r2);
|
|
862
|
-
}
|
|
863
|
-
if (i2) {
|
|
864
|
-
let t3 = this.findOption(e3, i2);
|
|
865
|
-
if (t3?.handler) {
|
|
866
|
-
let n3 = [];
|
|
867
|
-
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions = n3;
|
|
868
|
-
}
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
if (n2.startsWith(`-`)) {
|
|
872
|
-
let t3 = n2.startsWith(`-`) && !n2.startsWith(`--`), r3 = n2.replace(/^-+/, ``);
|
|
873
|
-
for (let [i3, a2] of e3.options) t3 && a2.alias && `-${a2.alias}`.startsWith(n2) ? this.completions.push({ value: `-${a2.alias}`, description: a2.description }) : !t3 && i3.startsWith(r3) && this.completions.push({ value: `--${i3}`, description: a2.description });
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
findOption(e3, t2) {
|
|
877
|
-
let n2 = e3.options.get(t2);
|
|
878
|
-
if (n2 || (n2 = e3.options.get(t2.replace(/^-+/, ``)), n2)) return n2;
|
|
879
|
-
for (let [n3, r2] of e3.options) if (r2.alias && `-${r2.alias}` === t2) return r2;
|
|
880
|
-
}
|
|
881
|
-
handleCommandCompletion(e3, t2) {
|
|
882
|
-
let n2 = this.stripOptions(e3);
|
|
883
|
-
for (let [e4, r2] of this.commands) {
|
|
884
|
-
if (e4 === ``) continue;
|
|
885
|
-
let i2 = e4.split(` `);
|
|
886
|
-
i2.slice(0, n2.length).every((e5, t3) => e5 === n2[t3]) && i2[n2.length]?.startsWith(t2) && this.completions.push({ value: i2[n2.length], description: r2.description });
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
handlePositionalCompletion(e3, t2) {
|
|
890
|
-
let n2 = e3.value.split(` `).length, r2 = Math.max(0, t2.length - n2), i2 = Array.from(e3.arguments.entries());
|
|
891
|
-
if (i2.length > 0) {
|
|
892
|
-
let t3;
|
|
893
|
-
if (r2 < i2.length) {
|
|
894
|
-
let [e4, n3] = i2[r2];
|
|
895
|
-
t3 = n3;
|
|
896
|
-
} else {
|
|
897
|
-
let e4 = i2[i2.length - 1][1];
|
|
898
|
-
e4.variadic && (t3 = e4);
|
|
899
|
-
}
|
|
900
|
-
if (t3 && t3.handler && typeof t3.handler == `function`) {
|
|
901
|
-
let n3 = [];
|
|
902
|
-
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions.push(...n3);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
complete(e3) {
|
|
907
|
-
this.directive = a.ShellCompDirectiveNoFileComp;
|
|
908
|
-
let t2 = /* @__PURE__ */ new Set();
|
|
909
|
-
this.completions.filter((e4) => t2.has(e4.value) ? false : (t2.add(e4.value), true)).filter((t3) => {
|
|
910
|
-
if (e3.includes(`=`)) {
|
|
911
|
-
let [, n2] = e3.split(`=`);
|
|
912
|
-
return t3.value.startsWith(n2);
|
|
913
|
-
}
|
|
914
|
-
return t3.value.startsWith(e3);
|
|
915
|
-
}).forEach((e4) => console.log(`${e4.value} ${e4.description ?? ``}`)), console.log(`:${this.directive}`);
|
|
916
|
-
}
|
|
917
|
-
parse(e3) {
|
|
918
|
-
this.completions = [];
|
|
919
|
-
let t2 = e3[e3.length - 1] === ``;
|
|
920
|
-
t2 && e3.pop();
|
|
921
|
-
let n2 = e3[e3.length - 1] || ``, r2 = e3.slice(0, -1);
|
|
922
|
-
t2 && (n2 !== `` && r2.push(n2), n2 = ``);
|
|
923
|
-
let [i2] = this.matchCommand(r2), a2 = r2[r2.length - 1];
|
|
924
|
-
if (this.shouldCompleteFlags(a2, n2)) this.handleFlagCompletion(i2, r2, n2, a2);
|
|
925
|
-
else {
|
|
926
|
-
if (a2?.startsWith(`-`) && n2 === `` && t2) {
|
|
927
|
-
let e4 = this.findOption(this, a2);
|
|
928
|
-
if (!e4) {
|
|
929
|
-
for (let [, t3] of this.commands) if (e4 = this.findOption(t3, a2), e4) break;
|
|
930
|
-
}
|
|
931
|
-
if (e4 && e4.isBoolean) {
|
|
932
|
-
this.complete(n2);
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
this.shouldCompleteCommands(n2) && this.handleCommandCompletion(r2, n2), i2 && i2.arguments.size > 0 && this.handlePositionalCompletion(i2, r2);
|
|
937
|
-
}
|
|
938
|
-
this.complete(n2);
|
|
939
|
-
}
|
|
940
|
-
setup(a2, o3, s3) {
|
|
941
|
-
switch (e(s3 === `zsh` || s3 === `bash` || s3 === `fish` || s3 === `powershell`, `Unsupported shell`), s3) {
|
|
942
|
-
case `zsh`: {
|
|
943
|
-
let e3 = t(a2, o3);
|
|
944
|
-
console.log(e3);
|
|
945
|
-
break;
|
|
946
|
-
}
|
|
947
|
-
case `bash`: {
|
|
948
|
-
let e3 = n(a2, o3);
|
|
949
|
-
console.log(e3);
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
case `fish`: {
|
|
953
|
-
let e3 = r(a2, o3);
|
|
954
|
-
console.log(e3);
|
|
955
|
-
break;
|
|
956
|
-
}
|
|
957
|
-
case `powershell`: {
|
|
958
|
-
let e3 = i(a2, o3);
|
|
959
|
-
console.log(e3);
|
|
960
|
-
break;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
var u = new l();
|
|
966
|
-
var f = u;
|
|
967
|
-
|
|
968
|
-
// ../../node_modules/.pnpm/@bomb.sh+tab@0.0.11_cac@6.7.14_citty@0.1.6_commander@14.0.2/node_modules/@bomb.sh/tab/dist/shared-BE1U9MBi.js
|
|
969
|
-
function e2(e3 = `cli`) {
|
|
970
|
-
if (process.argv.indexOf(`--`) === -1) {
|
|
971
|
-
let t2 = `Error: You need to use -- to separate completion arguments.
|
|
972
|
-
Example: ${e3} complete -- <args>`;
|
|
973
|
-
console.error(t2), process.exit(1);
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
// ../../node_modules/.pnpm/@bomb.sh+tab@0.0.11_cac@6.7.14_citty@0.1.6_commander@14.0.2/node_modules/@bomb.sh/tab/dist/commander.js
|
|
978
|
-
var o2 = process.execPath;
|
|
979
|
-
var s2 = process.argv.slice(1);
|
|
980
|
-
var c2 = d(o2);
|
|
981
|
-
var l2 = s2.map(d);
|
|
982
|
-
var u2 = `${c2} ${process.execArgv.map(d).join(` `)} ${l2[0]}`;
|
|
983
|
-
function d(e3) {
|
|
984
|
-
return e3.includes(` `) ? `'${e3}'` : e3;
|
|
985
|
-
}
|
|
986
|
-
function f2(o3) {
|
|
987
|
-
let s3 = o3.name();
|
|
988
|
-
p(o3), m(o3), o3.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async (r2) => {
|
|
989
|
-
switch (r2) {
|
|
990
|
-
case `zsh`: {
|
|
991
|
-
let e3 = t(s3, u2);
|
|
992
|
-
console.log(e3);
|
|
993
|
-
break;
|
|
994
|
-
}
|
|
995
|
-
case `bash`: {
|
|
996
|
-
let e3 = n(s3, u2);
|
|
997
|
-
console.log(e3);
|
|
998
|
-
break;
|
|
999
|
-
}
|
|
1000
|
-
case `fish`: {
|
|
1001
|
-
let e3 = r(s3, u2);
|
|
1002
|
-
console.log(e3);
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
case `powershell`: {
|
|
1006
|
-
let t2 = i(s3, u2);
|
|
1007
|
-
console.log(t2);
|
|
1008
|
-
break;
|
|
1009
|
-
}
|
|
1010
|
-
case `debug`: {
|
|
1011
|
-
let e3 = /* @__PURE__ */ new Map();
|
|
1012
|
-
h(o3, ``, e3), console.log(`Collected commands:`);
|
|
1013
|
-
for (let [t2, n2] of e3.entries()) console.log(`- ${t2 || `<root>`}: ${n2.description() || `No description`}`);
|
|
1014
|
-
break;
|
|
1015
|
-
}
|
|
1016
|
-
default:
|
|
1017
|
-
console.error(`Unknown shell: ${r2}`), console.error(`Supported shells: zsh, bash, fish, powershell`), process.exit(1);
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
let c3 = o3.parse.bind(o3);
|
|
1021
|
-
return o3.parse = function(e3, t2) {
|
|
1022
|
-
let n2 = e3 || process.argv, i2 = n2.findIndex((e4) => e4 === `complete`), l3 = n2.findIndex((e4) => e4 === `--`);
|
|
1023
|
-
if (i2 !== -1 && l3 !== -1 && l3 > i2) {
|
|
1024
|
-
let e4 = n2.slice(l3 + 1);
|
|
1025
|
-
return e2(s3), f.parse(e4), o3;
|
|
1026
|
-
}
|
|
1027
|
-
return c3(e3, t2);
|
|
1028
|
-
}, f;
|
|
1029
|
-
}
|
|
1030
|
-
function p(e3) {
|
|
1031
|
-
for (let t2 of e3.options) {
|
|
1032
|
-
let e4 = t2.flags, n2 = e4.match(/^-([a-zA-Z]), --/)?.[1], i2 = e4.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1033
|
-
i2 && (n2 ? f.option(i2, t2.description || ``, n2) : f.option(i2, t2.description || ``));
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
function m(e3) {
|
|
1037
|
-
let t2 = /* @__PURE__ */ new Map();
|
|
1038
|
-
h(e3, ``, t2);
|
|
1039
|
-
for (let [e4, n2] of t2.entries()) {
|
|
1040
|
-
if (e4 === ``) continue;
|
|
1041
|
-
let t3 = f.command(e4, n2.description() || ``);
|
|
1042
|
-
for (let e5 of n2.options) {
|
|
1043
|
-
let n3 = e5.flags, r2 = n3.match(/^-([a-zA-Z]), --/)?.[1], i2 = n3.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1044
|
-
i2 && (r2 ? t3.option(i2, e5.description || ``, r2) : t3.option(i2, e5.description || ``));
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
function h(e3, t2, n2) {
|
|
1049
|
-
n2.set(t2, e3);
|
|
1050
|
-
for (let r2 of e3.commands) r2.name() !== `complete` && h(r2, t2 ? `${t2} ${r2.name()}` : r2.name(), n2);
|
|
1051
|
-
}
|
|
1052
21
|
|
|
1053
22
|
// src/utils/templates.ts
|
|
1054
23
|
var AGENTS = [
|
|
@@ -1071,9 +40,6 @@ var AGENT_NAMES = {
|
|
|
1071
40
|
ami: "Ami",
|
|
1072
41
|
"visual-edit": "Visual Edit"
|
|
1073
42
|
};
|
|
1074
|
-
AGENTS.filter((agent) => agent !== "ami").map(
|
|
1075
|
-
(agent) => `@react-grab/${agent}`
|
|
1076
|
-
);
|
|
1077
43
|
var NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" && (
|
|
1078
44
|
<Script
|
|
1079
45
|
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
@@ -2736,7 +1702,7 @@ ${BOLD}File: ${filePath}${RESET}`);
|
|
|
2736
1702
|
console.log(formatDiff(diff));
|
|
2737
1703
|
console.log("\u2500".repeat(60));
|
|
2738
1704
|
};
|
|
2739
|
-
var VERSION = "0.1.0-beta.
|
|
1705
|
+
var VERSION = "0.1.0-beta.7";
|
|
2740
1706
|
var configureMcp = (mcpClient, cwd, customPkg) => {
|
|
2741
1707
|
const mcpCommand = customPkg ? `npx -y ${customPkg} browser mcp` : `npx -y @react-grab/cli browser mcp`;
|
|
2742
1708
|
const mcpSpinner = spinner(`Installing MCP server for ${MCP_CLIENT_NAMES[mcpClient]}`).start();
|
|
@@ -2839,7 +1805,7 @@ var add = new Command().name("add").alias("install").description("add browser au
|
|
|
2839
1805
|
if (clientArg && !selectedAgent) {
|
|
2840
1806
|
logger.break();
|
|
2841
1807
|
logger.error(`Invalid skill agent: ${clientArg}`);
|
|
2842
|
-
logger.error(`Available agents: ${SKILL_AGENTS.map((
|
|
1808
|
+
logger.error(`Available agents: ${SKILL_AGENTS.map((a) => a.id).join(", ")}`);
|
|
2843
1809
|
logger.break();
|
|
2844
1810
|
process.exit(1);
|
|
2845
1811
|
}
|
|
@@ -2847,7 +1813,7 @@ var add = new Command().name("add").alias("install").description("add browser au
|
|
|
2847
1813
|
if (detectedAgents.length === 0) {
|
|
2848
1814
|
logger.break();
|
|
2849
1815
|
logger.warn("No supported agent folders detected.");
|
|
2850
|
-
logger.log("Supported agents: " + SKILL_AGENTS.map((
|
|
1816
|
+
logger.log("Supported agents: " + SKILL_AGENTS.map((a) => a.id).join(", "));
|
|
2851
1817
|
logger.break();
|
|
2852
1818
|
process.exit(0);
|
|
2853
1819
|
}
|
|
@@ -2873,7 +1839,7 @@ var add = new Command().name("add").alias("install").description("add browser au
|
|
|
2873
1839
|
if (!selectedAgent) {
|
|
2874
1840
|
logger.break();
|
|
2875
1841
|
logger.error("Please specify an agent with --client");
|
|
2876
|
-
logger.error(`Available agents: ${SKILL_AGENTS.map((
|
|
1842
|
+
logger.error(`Available agents: ${SKILL_AGENTS.map((a) => a.id).join(", ")}`);
|
|
2877
1843
|
logger.break();
|
|
2878
1844
|
process.exit(1);
|
|
2879
1845
|
}
|
|
@@ -2928,7 +1894,7 @@ var add = new Command().name("add").alias("install").description("add browser au
|
|
|
2928
1894
|
if (detectedAgents.length === 0) {
|
|
2929
1895
|
logger.break();
|
|
2930
1896
|
logger.warn("No supported agent folders detected.");
|
|
2931
|
-
logger.log("Supported agents: " + SKILL_AGENTS.map((
|
|
1897
|
+
logger.log("Supported agents: " + SKILL_AGENTS.map((a) => a.id).join(", "));
|
|
2932
1898
|
logger.break();
|
|
2933
1899
|
process.exit(0);
|
|
2934
1900
|
}
|
|
@@ -3494,7 +2460,7 @@ var createComponentHelper = (getActivePage2) => {
|
|
|
3494
2460
|
return single?.element || null;
|
|
3495
2461
|
}
|
|
3496
2462
|
const arr = result;
|
|
3497
|
-
return arr.map((
|
|
2463
|
+
return arr.map((m) => m.element);
|
|
3498
2464
|
},
|
|
3499
2465
|
{ name: componentName, nth }
|
|
3500
2466
|
);
|
|
@@ -4247,8 +3213,8 @@ function $constructor(name, initializer3, params) {
|
|
|
4247
3213
|
initializer3(inst, def);
|
|
4248
3214
|
const proto = _.prototype;
|
|
4249
3215
|
const keys = Object.keys(proto);
|
|
4250
|
-
for (let
|
|
4251
|
-
const k = keys[
|
|
3216
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3217
|
+
const k = keys[i];
|
|
4252
3218
|
if (!(k in inst)) {
|
|
4253
3219
|
inst[k] = proto[k].bind(inst);
|
|
4254
3220
|
}
|
|
@@ -4479,8 +3445,8 @@ function promiseAllObject(promisesObj) {
|
|
|
4479
3445
|
const promises = keys.map((key) => promisesObj[key]);
|
|
4480
3446
|
return Promise.all(promises).then((results) => {
|
|
4481
3447
|
const resolvedObj = {};
|
|
4482
|
-
for (let
|
|
4483
|
-
resolvedObj[keys[
|
|
3448
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3449
|
+
resolvedObj[keys[i]] = results[i];
|
|
4484
3450
|
}
|
|
4485
3451
|
return resolvedObj;
|
|
4486
3452
|
});
|
|
@@ -4488,7 +3454,7 @@ function promiseAllObject(promisesObj) {
|
|
|
4488
3454
|
function randomString(length = 10) {
|
|
4489
3455
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
4490
3456
|
let str = "";
|
|
4491
|
-
for (let
|
|
3457
|
+
for (let i = 0; i < length; i++) {
|
|
4492
3458
|
str += chars[Math.floor(Math.random() * chars.length)];
|
|
4493
3459
|
}
|
|
4494
3460
|
return str;
|
|
@@ -4516,10 +3482,10 @@ var allowsEval = cached(() => {
|
|
|
4516
3482
|
return false;
|
|
4517
3483
|
}
|
|
4518
3484
|
});
|
|
4519
|
-
function isPlainObject(
|
|
4520
|
-
if (isObject(
|
|
3485
|
+
function isPlainObject(o) {
|
|
3486
|
+
if (isObject(o) === false)
|
|
4521
3487
|
return false;
|
|
4522
|
-
const ctor =
|
|
3488
|
+
const ctor = o.constructor;
|
|
4523
3489
|
if (ctor === void 0)
|
|
4524
3490
|
return true;
|
|
4525
3491
|
if (typeof ctor !== "function")
|
|
@@ -4532,12 +3498,12 @@ function isPlainObject(o3) {
|
|
|
4532
3498
|
}
|
|
4533
3499
|
return true;
|
|
4534
3500
|
}
|
|
4535
|
-
function shallowClone(
|
|
4536
|
-
if (isPlainObject(
|
|
4537
|
-
return { ...
|
|
4538
|
-
if (Array.isArray(
|
|
4539
|
-
return [...
|
|
4540
|
-
return
|
|
3501
|
+
function shallowClone(o) {
|
|
3502
|
+
if (isPlainObject(o))
|
|
3503
|
+
return { ...o };
|
|
3504
|
+
if (Array.isArray(o))
|
|
3505
|
+
return [...o];
|
|
3506
|
+
return o;
|
|
4541
3507
|
}
|
|
4542
3508
|
function numKeys(data) {
|
|
4543
3509
|
let keyCount = 0;
|
|
@@ -4549,8 +3515,8 @@ function numKeys(data) {
|
|
|
4549
3515
|
return keyCount;
|
|
4550
3516
|
}
|
|
4551
3517
|
var getParsedType = (data) => {
|
|
4552
|
-
const
|
|
4553
|
-
switch (
|
|
3518
|
+
const t = typeof data;
|
|
3519
|
+
switch (t) {
|
|
4554
3520
|
case "undefined":
|
|
4555
3521
|
return "undefined";
|
|
4556
3522
|
case "string":
|
|
@@ -4589,7 +3555,7 @@ var getParsedType = (data) => {
|
|
|
4589
3555
|
}
|
|
4590
3556
|
return "object";
|
|
4591
3557
|
default:
|
|
4592
|
-
throw new Error(`Unknown data type: ${
|
|
3558
|
+
throw new Error(`Unknown data type: ${t}`);
|
|
4593
3559
|
}
|
|
4594
3560
|
};
|
|
4595
3561
|
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -4761,10 +3727,10 @@ function safeExtend(schema, shape) {
|
|
|
4761
3727
|
});
|
|
4762
3728
|
return clone(schema, def);
|
|
4763
3729
|
}
|
|
4764
|
-
function merge(
|
|
4765
|
-
const def = mergeDefs(
|
|
3730
|
+
function merge(a, b) {
|
|
3731
|
+
const def = mergeDefs(a._zod.def, {
|
|
4766
3732
|
get shape() {
|
|
4767
|
-
const _shape = { ...
|
|
3733
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
4768
3734
|
assignProp(this, "shape", _shape);
|
|
4769
3735
|
return _shape;
|
|
4770
3736
|
},
|
|
@@ -4774,7 +3740,7 @@ function merge(a2, b) {
|
|
|
4774
3740
|
checks: []
|
|
4775
3741
|
// delete existing checks
|
|
4776
3742
|
});
|
|
4777
|
-
return clone(
|
|
3743
|
+
return clone(a, def);
|
|
4778
3744
|
}
|
|
4779
3745
|
function partial(Class2, schema, mask) {
|
|
4780
3746
|
const currDef = schema._zod.def;
|
|
@@ -4848,8 +3814,8 @@ function required(Class2, schema, mask) {
|
|
|
4848
3814
|
function aborted(x, startIndex = 0) {
|
|
4849
3815
|
if (x.aborted === true)
|
|
4850
3816
|
return true;
|
|
4851
|
-
for (let
|
|
4852
|
-
if (x.issues[
|
|
3817
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
3818
|
+
if (x.issues[i]?.continue !== true) {
|
|
4853
3819
|
return true;
|
|
4854
3820
|
}
|
|
4855
3821
|
}
|
|
@@ -4896,8 +3862,8 @@ function getLengthableOrigin(input) {
|
|
|
4896
3862
|
return "unknown";
|
|
4897
3863
|
}
|
|
4898
3864
|
function parsedType(data) {
|
|
4899
|
-
const
|
|
4900
|
-
switch (
|
|
3865
|
+
const t = typeof data;
|
|
3866
|
+
switch (t) {
|
|
4901
3867
|
case "number": {
|
|
4902
3868
|
return Number.isNaN(data) ? "nan" : "number";
|
|
4903
3869
|
}
|
|
@@ -4914,7 +3880,7 @@ function parsedType(data) {
|
|
|
4914
3880
|
}
|
|
4915
3881
|
}
|
|
4916
3882
|
}
|
|
4917
|
-
return
|
|
3883
|
+
return t;
|
|
4918
3884
|
}
|
|
4919
3885
|
function issue(...args) {
|
|
4920
3886
|
const [iss, input, inst] = args;
|
|
@@ -4936,15 +3902,15 @@ function cleanEnum(obj) {
|
|
|
4936
3902
|
function base64ToUint8Array(base643) {
|
|
4937
3903
|
const binaryString = atob(base643);
|
|
4938
3904
|
const bytes = new Uint8Array(binaryString.length);
|
|
4939
|
-
for (let
|
|
4940
|
-
bytes[
|
|
3905
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
3906
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
4941
3907
|
}
|
|
4942
3908
|
return bytes;
|
|
4943
3909
|
}
|
|
4944
3910
|
function uint8ArrayToBase64(bytes) {
|
|
4945
3911
|
let binaryString = "";
|
|
4946
|
-
for (let
|
|
4947
|
-
binaryString += String.fromCharCode(bytes[
|
|
3912
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3913
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
4948
3914
|
}
|
|
4949
3915
|
return btoa(binaryString);
|
|
4950
3916
|
}
|
|
@@ -4962,8 +3928,8 @@ function hexToUint8Array(hex3) {
|
|
|
4962
3928
|
throw new Error("Invalid hex string length");
|
|
4963
3929
|
}
|
|
4964
3930
|
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
4965
|
-
for (let
|
|
4966
|
-
bytes[
|
|
3931
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
3932
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
4967
3933
|
}
|
|
4968
3934
|
return bytes;
|
|
4969
3935
|
}
|
|
@@ -5021,10 +3987,10 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5021
3987
|
fieldErrors._errors.push(mapper(issue2));
|
|
5022
3988
|
} else {
|
|
5023
3989
|
let curr = fieldErrors;
|
|
5024
|
-
let
|
|
5025
|
-
while (
|
|
5026
|
-
const el = issue2.path[
|
|
5027
|
-
const terminal =
|
|
3990
|
+
let i = 0;
|
|
3991
|
+
while (i < issue2.path.length) {
|
|
3992
|
+
const el = issue2.path[i];
|
|
3993
|
+
const terminal = i === issue2.path.length - 1;
|
|
5028
3994
|
if (!terminal) {
|
|
5029
3995
|
curr[el] = curr[el] || { _errors: [] };
|
|
5030
3996
|
} else {
|
|
@@ -5032,7 +3998,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5032
3998
|
curr[el]._errors.push(mapper(issue2));
|
|
5033
3999
|
}
|
|
5034
4000
|
curr = curr[el];
|
|
5035
|
-
|
|
4001
|
+
i++;
|
|
5036
4002
|
}
|
|
5037
4003
|
}
|
|
5038
4004
|
}
|
|
@@ -5058,10 +4024,10 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5058
4024
|
continue;
|
|
5059
4025
|
}
|
|
5060
4026
|
let curr = result;
|
|
5061
|
-
let
|
|
5062
|
-
while (
|
|
5063
|
-
const el = fullpath[
|
|
5064
|
-
const terminal =
|
|
4027
|
+
let i = 0;
|
|
4028
|
+
while (i < fullpath.length) {
|
|
4029
|
+
const el = fullpath[i];
|
|
4030
|
+
const terminal = i === fullpath.length - 1;
|
|
5065
4031
|
if (typeof el === "string") {
|
|
5066
4032
|
curr.properties ?? (curr.properties = {});
|
|
5067
4033
|
(_a2 = curr.properties)[el] ?? (_a2[el] = { errors: [] });
|
|
@@ -5074,7 +4040,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5074
4040
|
if (terminal) {
|
|
5075
4041
|
curr.errors.push(mapper(issue2));
|
|
5076
4042
|
}
|
|
5077
|
-
|
|
4043
|
+
i++;
|
|
5078
4044
|
}
|
|
5079
4045
|
}
|
|
5080
4046
|
}
|
|
@@ -5102,7 +4068,7 @@ function toDotPath(_path) {
|
|
|
5102
4068
|
}
|
|
5103
4069
|
function prettifyError(error48) {
|
|
5104
4070
|
const lines = [];
|
|
5105
|
-
const issues = [...error48.issues].sort((
|
|
4071
|
+
const issues = [...error48.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
5106
4072
|
for (const issue2 of issues) {
|
|
5107
4073
|
lines.push(`\u2716 ${issue2.message}`);
|
|
5108
4074
|
if (issue2.path?.length)
|
|
@@ -5119,9 +4085,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
5119
4085
|
throw new $ZodAsyncError();
|
|
5120
4086
|
}
|
|
5121
4087
|
if (result.issues.length) {
|
|
5122
|
-
const
|
|
5123
|
-
captureStackTrace(
|
|
5124
|
-
throw
|
|
4088
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
4089
|
+
captureStackTrace(e, _params?.callee);
|
|
4090
|
+
throw e;
|
|
5125
4091
|
}
|
|
5126
4092
|
return result.value;
|
|
5127
4093
|
};
|
|
@@ -5132,9 +4098,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
5132
4098
|
if (result instanceof Promise)
|
|
5133
4099
|
result = await result;
|
|
5134
4100
|
if (result.issues.length) {
|
|
5135
|
-
const
|
|
5136
|
-
captureStackTrace(
|
|
5137
|
-
throw
|
|
4101
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
4102
|
+
captureStackTrace(e, params?.callee);
|
|
4103
|
+
throw e;
|
|
5138
4104
|
}
|
|
5139
4105
|
return result.value;
|
|
5140
4106
|
};
|
|
@@ -6047,10 +5013,10 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
6047
5013
|
defineLazy(inst, "~standard", () => ({
|
|
6048
5014
|
validate: (value) => {
|
|
6049
5015
|
try {
|
|
6050
|
-
const
|
|
6051
|
-
return
|
|
5016
|
+
const r = safeParse(inst, value);
|
|
5017
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
6052
5018
|
} catch (_) {
|
|
6053
|
-
return safeParseAsync(inst, value).then((
|
|
5019
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
6054
5020
|
}
|
|
6055
5021
|
},
|
|
6056
5022
|
vendor: "zod",
|
|
@@ -6295,7 +5261,7 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
6295
5261
|
function isValidBase64URL(data) {
|
|
6296
5262
|
if (!base64url.test(data))
|
|
6297
5263
|
return false;
|
|
6298
|
-
const base643 = data.replace(/[-_]/g, (
|
|
5264
|
+
const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
6299
5265
|
const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
|
|
6300
5266
|
return isValidBase64(padded);
|
|
6301
5267
|
}
|
|
@@ -6571,16 +5537,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
6571
5537
|
}
|
|
6572
5538
|
payload.value = Array(input.length);
|
|
6573
5539
|
const proms = [];
|
|
6574
|
-
for (let
|
|
6575
|
-
const item = input[
|
|
5540
|
+
for (let i = 0; i < input.length; i++) {
|
|
5541
|
+
const item = input[i];
|
|
6576
5542
|
const result = def.element._zod.run({
|
|
6577
5543
|
value: item,
|
|
6578
5544
|
issues: []
|
|
6579
5545
|
}, ctx);
|
|
6580
5546
|
if (result instanceof Promise) {
|
|
6581
|
-
proms.push(result.then((result2) => handleArrayResult(result2, payload,
|
|
5547
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
6582
5548
|
} else {
|
|
6583
|
-
handleArrayResult(result, payload,
|
|
5549
|
+
handleArrayResult(result, payload, i);
|
|
6584
5550
|
}
|
|
6585
5551
|
}
|
|
6586
5552
|
if (proms.length) {
|
|
@@ -6624,20 +5590,20 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
6624
5590
|
const unrecognized = [];
|
|
6625
5591
|
const keySet = def.keySet;
|
|
6626
5592
|
const _catchall = def.catchall._zod;
|
|
6627
|
-
const
|
|
5593
|
+
const t = _catchall.def.type;
|
|
6628
5594
|
const isOptionalOut = _catchall.optout === "optional";
|
|
6629
5595
|
for (const key in input) {
|
|
6630
5596
|
if (keySet.has(key))
|
|
6631
5597
|
continue;
|
|
6632
|
-
if (
|
|
5598
|
+
if (t === "never") {
|
|
6633
5599
|
unrecognized.push(key);
|
|
6634
5600
|
continue;
|
|
6635
5601
|
}
|
|
6636
|
-
const
|
|
6637
|
-
if (
|
|
6638
|
-
proms.push(
|
|
5602
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
5603
|
+
if (r instanceof Promise) {
|
|
5604
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
6639
5605
|
} else {
|
|
6640
|
-
handlePropertyResult(
|
|
5606
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
6641
5607
|
}
|
|
6642
5608
|
}
|
|
6643
5609
|
if (unrecognized.length) {
|
|
@@ -6704,11 +5670,11 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
6704
5670
|
for (const key of value.keys) {
|
|
6705
5671
|
const el = shape[key];
|
|
6706
5672
|
const isOptionalOut = el._zod.optout === "optional";
|
|
6707
|
-
const
|
|
6708
|
-
if (
|
|
6709
|
-
proms.push(
|
|
5673
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
5674
|
+
if (r instanceof Promise) {
|
|
5675
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
6710
5676
|
} else {
|
|
6711
|
-
handlePropertyResult(
|
|
5677
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
6712
5678
|
}
|
|
6713
5679
|
}
|
|
6714
5680
|
if (!catchall) {
|
|
@@ -6823,7 +5789,7 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
6823
5789
|
return final;
|
|
6824
5790
|
}
|
|
6825
5791
|
}
|
|
6826
|
-
const nonaborted = results.filter((
|
|
5792
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
6827
5793
|
if (nonaborted.length === 1) {
|
|
6828
5794
|
final.value = nonaborted[0].value;
|
|
6829
5795
|
return nonaborted[0];
|
|
@@ -6838,18 +5804,18 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
6838
5804
|
}
|
|
6839
5805
|
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
6840
5806
|
$ZodType.init(inst, def);
|
|
6841
|
-
defineLazy(inst._zod, "optin", () => def.options.some((
|
|
6842
|
-
defineLazy(inst._zod, "optout", () => def.options.some((
|
|
5807
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
5808
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
6843
5809
|
defineLazy(inst._zod, "values", () => {
|
|
6844
|
-
if (def.options.every((
|
|
5810
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
6845
5811
|
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
6846
5812
|
}
|
|
6847
5813
|
return void 0;
|
|
6848
5814
|
});
|
|
6849
5815
|
defineLazy(inst._zod, "pattern", () => {
|
|
6850
|
-
if (def.options.every((
|
|
6851
|
-
const patterns = def.options.map((
|
|
6852
|
-
return new RegExp(`^(${patterns.map((
|
|
5816
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
5817
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
5818
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
6853
5819
|
}
|
|
6854
5820
|
return void 0;
|
|
6855
5821
|
});
|
|
@@ -6883,7 +5849,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
6883
5849
|
};
|
|
6884
5850
|
});
|
|
6885
5851
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
6886
|
-
const successes = results.filter((
|
|
5852
|
+
const successes = results.filter((r) => r.issues.length === 0);
|
|
6887
5853
|
if (successes.length === 1) {
|
|
6888
5854
|
final.value = successes[0].value;
|
|
6889
5855
|
return final;
|
|
@@ -6959,15 +5925,15 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
6959
5925
|
const disc = cached(() => {
|
|
6960
5926
|
const opts2 = def.options;
|
|
6961
5927
|
const map2 = /* @__PURE__ */ new Map();
|
|
6962
|
-
for (const
|
|
6963
|
-
const values =
|
|
5928
|
+
for (const o of opts2) {
|
|
5929
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
6964
5930
|
if (!values || values.size === 0)
|
|
6965
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(
|
|
5931
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
6966
5932
|
for (const v of values) {
|
|
6967
5933
|
if (map2.has(v)) {
|
|
6968
5934
|
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
6969
5935
|
}
|
|
6970
|
-
map2.set(v,
|
|
5936
|
+
map2.set(v, o);
|
|
6971
5937
|
}
|
|
6972
5938
|
}
|
|
6973
5939
|
return map2;
|
|
@@ -7017,19 +5983,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
|
|
|
7017
5983
|
return handleIntersectionResults(payload, left, right);
|
|
7018
5984
|
};
|
|
7019
5985
|
});
|
|
7020
|
-
function mergeValues(
|
|
7021
|
-
if (
|
|
7022
|
-
return { valid: true, data:
|
|
5986
|
+
function mergeValues(a, b) {
|
|
5987
|
+
if (a === b) {
|
|
5988
|
+
return { valid: true, data: a };
|
|
7023
5989
|
}
|
|
7024
|
-
if (
|
|
7025
|
-
return { valid: true, data:
|
|
5990
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
5991
|
+
return { valid: true, data: a };
|
|
7026
5992
|
}
|
|
7027
|
-
if (isPlainObject(
|
|
5993
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
7028
5994
|
const bKeys = Object.keys(b);
|
|
7029
|
-
const sharedKeys = Object.keys(
|
|
7030
|
-
const newObj = { ...
|
|
5995
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
5996
|
+
const newObj = { ...a, ...b };
|
|
7031
5997
|
for (const key of sharedKeys) {
|
|
7032
|
-
const sharedValue = mergeValues(
|
|
5998
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
7033
5999
|
if (!sharedValue.valid) {
|
|
7034
6000
|
return {
|
|
7035
6001
|
valid: false,
|
|
@@ -7040,13 +6006,13 @@ function mergeValues(a2, b) {
|
|
|
7040
6006
|
}
|
|
7041
6007
|
return { valid: true, data: newObj };
|
|
7042
6008
|
}
|
|
7043
|
-
if (Array.isArray(
|
|
7044
|
-
if (
|
|
6009
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
6010
|
+
if (a.length !== b.length) {
|
|
7045
6011
|
return { valid: false, mergeErrorPath: [] };
|
|
7046
6012
|
}
|
|
7047
6013
|
const newArray = [];
|
|
7048
|
-
for (let index = 0; index <
|
|
7049
|
-
const itemA =
|
|
6014
|
+
for (let index = 0; index < a.length; index++) {
|
|
6015
|
+
const itemA = a[index];
|
|
7050
6016
|
const itemB = b[index];
|
|
7051
6017
|
const sharedValue = mergeValues(itemA, itemB);
|
|
7052
6018
|
if (!sharedValue.valid) {
|
|
@@ -7087,7 +6053,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
7087
6053
|
result.issues.push(iss);
|
|
7088
6054
|
}
|
|
7089
6055
|
}
|
|
7090
|
-
const bothKeys = [...unrecKeys].filter(([,
|
|
6056
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
7091
6057
|
if (bothKeys.length && unrecIssue) {
|
|
7092
6058
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
7093
6059
|
}
|
|
@@ -7131,35 +6097,35 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
7131
6097
|
return payload;
|
|
7132
6098
|
}
|
|
7133
6099
|
}
|
|
7134
|
-
let
|
|
6100
|
+
let i = -1;
|
|
7135
6101
|
for (const item of items) {
|
|
7136
|
-
|
|
7137
|
-
if (
|
|
7138
|
-
if (
|
|
6102
|
+
i++;
|
|
6103
|
+
if (i >= input.length) {
|
|
6104
|
+
if (i >= optStart)
|
|
7139
6105
|
continue;
|
|
7140
6106
|
}
|
|
7141
6107
|
const result = item._zod.run({
|
|
7142
|
-
value: input[
|
|
6108
|
+
value: input[i],
|
|
7143
6109
|
issues: []
|
|
7144
6110
|
}, ctx);
|
|
7145
6111
|
if (result instanceof Promise) {
|
|
7146
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
6112
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
7147
6113
|
} else {
|
|
7148
|
-
handleTupleResult(result, payload,
|
|
6114
|
+
handleTupleResult(result, payload, i);
|
|
7149
6115
|
}
|
|
7150
6116
|
}
|
|
7151
6117
|
if (def.rest) {
|
|
7152
6118
|
const rest = input.slice(items.length);
|
|
7153
6119
|
for (const el of rest) {
|
|
7154
|
-
|
|
6120
|
+
i++;
|
|
7155
6121
|
const result = def.rest._zod.run({
|
|
7156
6122
|
value: el,
|
|
7157
6123
|
issues: []
|
|
7158
6124
|
}, ctx);
|
|
7159
6125
|
if (result instanceof Promise) {
|
|
7160
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
6126
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
7161
6127
|
} else {
|
|
7162
|
-
handleTupleResult(result, payload,
|
|
6128
|
+
handleTupleResult(result, payload, i);
|
|
7163
6129
|
}
|
|
7164
6130
|
}
|
|
7165
6131
|
}
|
|
@@ -7381,7 +6347,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
7381
6347
|
const values = getEnumValues(def.entries);
|
|
7382
6348
|
const valuesSet = new Set(values);
|
|
7383
6349
|
inst._zod.values = valuesSet;
|
|
7384
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((
|
|
6350
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
7385
6351
|
inst._zod.parse = (payload, _ctx) => {
|
|
7386
6352
|
const input = payload.value;
|
|
7387
6353
|
if (valuesSet.has(input)) {
|
|
@@ -7403,7 +6369,7 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
7403
6369
|
}
|
|
7404
6370
|
const values = new Set(def.values);
|
|
7405
6371
|
inst._zod.values = values;
|
|
7406
|
-
inst._zod.pattern = new RegExp(`^(${def.values.map((
|
|
6372
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
7407
6373
|
inst._zod.parse = (payload, _ctx) => {
|
|
7408
6374
|
const input = payload.value;
|
|
7409
6375
|
if (values.has(input)) {
|
|
@@ -7475,7 +6441,7 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
7475
6441
|
if (def.innerType._zod.optin === "optional") {
|
|
7476
6442
|
const result = def.innerType._zod.run(payload, ctx);
|
|
7477
6443
|
if (result instanceof Promise)
|
|
7478
|
-
return result.then((
|
|
6444
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
7479
6445
|
return handleOptionalResult(result, payload.value);
|
|
7480
6446
|
}
|
|
7481
6447
|
if (payload.value === void 0) {
|
|
@@ -7892,11 +6858,11 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
7892
6858
|
};
|
|
7893
6859
|
inst._zod.check = (payload) => {
|
|
7894
6860
|
const input = payload.value;
|
|
7895
|
-
const
|
|
7896
|
-
if (
|
|
7897
|
-
return
|
|
6861
|
+
const r = def.fn(input);
|
|
6862
|
+
if (r instanceof Promise) {
|
|
6863
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
7898
6864
|
}
|
|
7899
|
-
handleRefineResult(
|
|
6865
|
+
handleRefineResult(r, payload, input, inst);
|
|
7900
6866
|
return;
|
|
7901
6867
|
};
|
|
7902
6868
|
});
|
|
@@ -9736,17 +8702,17 @@ var error16 = () => {
|
|
|
9736
8702
|
number: { unit: "", shortLabel: "\u05E7\u05D8\u05DF", longLabel: "\u05D2\u05D3\u05D5\u05DC" }
|
|
9737
8703
|
// no unit
|
|
9738
8704
|
};
|
|
9739
|
-
const typeEntry = (
|
|
9740
|
-
const typeLabel = (
|
|
9741
|
-
const
|
|
9742
|
-
if (
|
|
9743
|
-
return
|
|
9744
|
-
return
|
|
9745
|
-
};
|
|
9746
|
-
const withDefinite = (
|
|
9747
|
-
const verbFor = (
|
|
9748
|
-
const
|
|
9749
|
-
const gender =
|
|
8705
|
+
const typeEntry = (t) => t ? TypeNames[t] : void 0;
|
|
8706
|
+
const typeLabel = (t) => {
|
|
8707
|
+
const e = typeEntry(t);
|
|
8708
|
+
if (e)
|
|
8709
|
+
return e.label;
|
|
8710
|
+
return t ?? TypeNames.unknown.label;
|
|
8711
|
+
};
|
|
8712
|
+
const withDefinite = (t) => `\u05D4${typeLabel(t)}`;
|
|
8713
|
+
const verbFor = (t) => {
|
|
8714
|
+
const e = typeEntry(t);
|
|
8715
|
+
const gender = e?.gender ?? "m";
|
|
9750
8716
|
return gender === "f" ? "\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA" : "\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA";
|
|
9751
8717
|
};
|
|
9752
8718
|
const getSizing = (origin) => {
|
|
@@ -13526,12 +12492,12 @@ var $ZodRegistry = class {
|
|
|
13526
12492
|
return this;
|
|
13527
12493
|
}
|
|
13528
12494
|
get(schema) {
|
|
13529
|
-
const
|
|
13530
|
-
if (
|
|
13531
|
-
const pm = { ...this.get(
|
|
12495
|
+
const p = schema._zod.parent;
|
|
12496
|
+
if (p) {
|
|
12497
|
+
const pm = { ...this.get(p) ?? {} };
|
|
13532
12498
|
delete pm.id;
|
|
13533
|
-
const
|
|
13534
|
-
return Object.keys(
|
|
12499
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
12500
|
+
return Object.keys(f).length ? f : void 0;
|
|
13535
12501
|
}
|
|
13536
12502
|
return this._map.get(schema);
|
|
13537
12503
|
}
|
|
@@ -15140,7 +14106,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
15140
14106
|
Object.assign(_json, file2);
|
|
15141
14107
|
} else {
|
|
15142
14108
|
Object.assign(_json, file2);
|
|
15143
|
-
_json.anyOf = mime.map((
|
|
14109
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
15144
14110
|
}
|
|
15145
14111
|
} else {
|
|
15146
14112
|
Object.assign(_json, file2);
|
|
@@ -15224,9 +14190,9 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
15224
14190
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
15225
14191
|
const def = schema._zod.def;
|
|
15226
14192
|
const isExclusive = def.inclusive === false;
|
|
15227
|
-
const options2 = def.options.map((x,
|
|
14193
|
+
const options2 = def.options.map((x, i) => process2(x, ctx, {
|
|
15228
14194
|
...params,
|
|
15229
|
-
path: [...params.path, isExclusive ? "oneOf" : "anyOf",
|
|
14195
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
15230
14196
|
}));
|
|
15231
14197
|
if (isExclusive) {
|
|
15232
14198
|
json2.oneOf = options2;
|
|
@@ -15236,7 +14202,7 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
15236
14202
|
};
|
|
15237
14203
|
var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
15238
14204
|
const def = schema._zod.def;
|
|
15239
|
-
const
|
|
14205
|
+
const a = process2(def.left, ctx, {
|
|
15240
14206
|
...params,
|
|
15241
14207
|
path: [...params.path, "allOf", 0]
|
|
15242
14208
|
});
|
|
@@ -15246,7 +14212,7 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
15246
14212
|
});
|
|
15247
14213
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
15248
14214
|
const allOf = [
|
|
15249
|
-
...isSimpleIntersection(
|
|
14215
|
+
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
15250
14216
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
15251
14217
|
];
|
|
15252
14218
|
json2.allOf = allOf;
|
|
@@ -15257,9 +14223,9 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
15257
14223
|
json2.type = "array";
|
|
15258
14224
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
15259
14225
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
15260
|
-
const prefixItems = def.items.map((x,
|
|
14226
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
15261
14227
|
...params,
|
|
15262
|
-
path: [...params.path, prefixPath,
|
|
14228
|
+
path: [...params.path, prefixPath, i]
|
|
15263
14229
|
}));
|
|
15264
14230
|
const rest = def.rest ? process2(def.rest, ctx, {
|
|
15265
14231
|
...params,
|
|
@@ -16334,9 +15300,9 @@ var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
|
16334
15300
|
inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx);
|
|
16335
15301
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
16336
15302
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
16337
|
-
const
|
|
16338
|
-
inst.minDate =
|
|
16339
|
-
inst.maxDate =
|
|
15303
|
+
const c = inst._zod.bag;
|
|
15304
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
15305
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
16340
15306
|
});
|
|
16341
15307
|
function date3(params) {
|
|
16342
15308
|
return _date(ZodDate, params);
|
|
@@ -17135,8 +16101,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
17135
16101
|
}
|
|
17136
16102
|
const type = schema.type;
|
|
17137
16103
|
if (Array.isArray(type)) {
|
|
17138
|
-
const typeSchemas = type.map((
|
|
17139
|
-
const typeSchema = { ...schema, type:
|
|
16104
|
+
const typeSchemas = type.map((t) => {
|
|
16105
|
+
const typeSchema = { ...schema, type: t };
|
|
17140
16106
|
return convertBaseSchema(typeSchema, ctx);
|
|
17141
16107
|
});
|
|
17142
16108
|
if (typeSchemas.length === 0) {
|
|
@@ -17289,8 +16255,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
17289
16255
|
zodSchema = schemasToIntersect[0];
|
|
17290
16256
|
} else {
|
|
17291
16257
|
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
17292
|
-
for (let
|
|
17293
|
-
result = z.intersection(result, schemasToIntersect[
|
|
16258
|
+
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
16259
|
+
result = z.intersection(result, schemasToIntersect[i]);
|
|
17294
16260
|
}
|
|
17295
16261
|
zodSchema = result;
|
|
17296
16262
|
}
|
|
@@ -17370,12 +16336,12 @@ function convertSchema(schema, ctx) {
|
|
|
17370
16336
|
let baseSchema = convertBaseSchema(schema, ctx);
|
|
17371
16337
|
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
17372
16338
|
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
17373
|
-
const options2 = schema.anyOf.map((
|
|
16339
|
+
const options2 = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
17374
16340
|
const anyOfUnion = z.union(options2);
|
|
17375
16341
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
17376
16342
|
}
|
|
17377
16343
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
17378
|
-
const options2 = schema.oneOf.map((
|
|
16344
|
+
const options2 = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
17379
16345
|
const oneOfUnion = z.xor(options2);
|
|
17380
16346
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
17381
16347
|
}
|
|
@@ -17385,8 +16351,8 @@ function convertSchema(schema, ctx) {
|
|
|
17385
16351
|
} else {
|
|
17386
16352
|
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
17387
16353
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
17388
|
-
for (let
|
|
17389
|
-
result = z.intersection(result, convertSchema(schema.allOf[
|
|
16354
|
+
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
16355
|
+
result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
17390
16356
|
}
|
|
17391
16357
|
baseSchema = result;
|
|
17392
16358
|
}
|
|
@@ -17725,7 +16691,7 @@ PERFORMANCE: Batch multiple actions in one execute call.`,
|
|
|
17725
16691
|
};
|
|
17726
16692
|
|
|
17727
16693
|
// src/commands/browser.ts
|
|
17728
|
-
var VERSION2 = "0.1.0-beta.
|
|
16694
|
+
var VERSION2 = "0.1.0-beta.7";
|
|
17729
16695
|
var printHeader = () => {
|
|
17730
16696
|
console.log(
|
|
17731
16697
|
`${pc.magenta("\u273F")} ${pc.bold("React Grab")} ${pc.gray(VERSION2)}`
|
|
@@ -18195,7 +17161,7 @@ browser.addCommand(status);
|
|
|
18195
17161
|
browser.addCommand(execute);
|
|
18196
17162
|
browser.addCommand(pages);
|
|
18197
17163
|
browser.addCommand(mcp);
|
|
18198
|
-
var VERSION3 = "0.1.0-beta.
|
|
17164
|
+
var VERSION3 = "0.1.0-beta.7";
|
|
18199
17165
|
var isMac = process.platform === "darwin";
|
|
18200
17166
|
var META_LABEL = isMac ? "Cmd" : "Win";
|
|
18201
17167
|
var ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -18229,17 +17195,17 @@ var BASE_KEYS = [
|
|
|
18229
17195
|
{ key: "ArrowDown", aliases: ["arrowdown", "down"] },
|
|
18230
17196
|
{ key: "ArrowLeft", aliases: ["arrowleft", "left"] },
|
|
18231
17197
|
{ key: "ArrowRight", aliases: ["arrowright", "right"] },
|
|
18232
|
-
...Array.from({ length: 12 }, (_,
|
|
18233
|
-
key: `F${
|
|
18234
|
-
aliases: [`f${
|
|
17198
|
+
...Array.from({ length: 12 }, (_, i) => ({
|
|
17199
|
+
key: `F${i + 1}`,
|
|
17200
|
+
aliases: [`f${i + 1}`]
|
|
18235
17201
|
})),
|
|
18236
|
-
...Array.from({ length: 26 }, (_,
|
|
18237
|
-
const letter = String.fromCharCode(97 +
|
|
17202
|
+
...Array.from({ length: 26 }, (_, i) => {
|
|
17203
|
+
const letter = String.fromCharCode(97 + i);
|
|
18238
17204
|
return { key: letter, aliases: [letter] };
|
|
18239
17205
|
}),
|
|
18240
|
-
...Array.from({ length: 10 }, (_,
|
|
18241
|
-
key: String(
|
|
18242
|
-
aliases: [String(
|
|
17206
|
+
...Array.from({ length: 10 }, (_, i) => ({
|
|
17207
|
+
key: String(i),
|
|
17208
|
+
aliases: [String(i)]
|
|
18243
17209
|
})),
|
|
18244
17210
|
{ key: "`", aliases: ["backtick", "grave", "`"] },
|
|
18245
17211
|
{ key: "-", aliases: ["minus", "dash", "-"] },
|
|
@@ -18326,7 +17292,7 @@ var generateSuggestions = (input) => {
|
|
|
18326
17292
|
}
|
|
18327
17293
|
}
|
|
18328
17294
|
if (!partial2) {
|
|
18329
|
-
const unusedMods = MODIFIERS.filter((
|
|
17295
|
+
const unusedMods = MODIFIERS.filter((m) => !modifiers.has(m));
|
|
18330
17296
|
for (const mod of unusedMods) {
|
|
18331
17297
|
for (const popularKey of POPULAR_KEYS) {
|
|
18332
17298
|
const combo = buildCombo(popularKey, modifiers, mod);
|
|
@@ -18633,7 +17599,7 @@ var configure = new Command().name("configure").alias("config").description("con
|
|
|
18633
17599
|
handleError(error48);
|
|
18634
17600
|
}
|
|
18635
17601
|
});
|
|
18636
|
-
var VERSION4 = "0.1.0-beta.
|
|
17602
|
+
var VERSION4 = "0.1.0-beta.7";
|
|
18637
17603
|
var REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
18638
17604
|
var DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
18639
17605
|
var promptSkillInstall = async (cwd) => {
|
|
@@ -18679,22 +17645,19 @@ var promptSkillInstall = async (cwd) => {
|
|
|
18679
17645
|
}
|
|
18680
17646
|
logger.break();
|
|
18681
17647
|
};
|
|
18682
|
-
var reportToCli =
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
|
|
18694
|
-
|
|
18695
|
-
});
|
|
18696
|
-
} catch {
|
|
18697
|
-
}
|
|
17648
|
+
var reportToCli = (type, config2, error48) => {
|
|
17649
|
+
fetch(REPORT_URL, {
|
|
17650
|
+
method: "POST",
|
|
17651
|
+
headers: { "Content-Type": "application/json" },
|
|
17652
|
+
body: JSON.stringify({
|
|
17653
|
+
type,
|
|
17654
|
+
version: VERSION4,
|
|
17655
|
+
config: config2,
|
|
17656
|
+
error: error48 ? { message: error48.message, stack: error48.stack } : void 0,
|
|
17657
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17658
|
+
})
|
|
17659
|
+
}).catch(() => {
|
|
17660
|
+
});
|
|
18698
17661
|
};
|
|
18699
17662
|
var FRAMEWORK_NAMES = {
|
|
18700
17663
|
next: "Next.js",
|
|
@@ -19305,7 +18268,7 @@ var init = new Command().name("init").description("initialize React Grab in your
|
|
|
19305
18268
|
if (!isNonInteractive) {
|
|
19306
18269
|
await promptSkillInstall(cwd);
|
|
19307
18270
|
}
|
|
19308
|
-
|
|
18271
|
+
reportToCli("completed", {
|
|
19309
18272
|
framework: finalFramework,
|
|
19310
18273
|
packageManager: finalPackageManager,
|
|
19311
18274
|
router: finalNextRouterType,
|
|
@@ -19314,10 +18277,10 @@ var init = new Command().name("init").description("initialize React Grab in your
|
|
|
19314
18277
|
});
|
|
19315
18278
|
} catch (error48) {
|
|
19316
18279
|
handleError(error48);
|
|
19317
|
-
|
|
18280
|
+
reportToCli("error", void 0, error48);
|
|
19318
18281
|
}
|
|
19319
18282
|
});
|
|
19320
|
-
var VERSION5 = "0.1.0-beta.
|
|
18283
|
+
var VERSION5 = "0.1.0-beta.7";
|
|
19321
18284
|
var remove = new Command().name("remove").description("remove an agent integration").argument(
|
|
19322
18285
|
"[agent]",
|
|
19323
18286
|
"agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, visual-edit)"
|
|
@@ -19494,22 +18457,21 @@ var remove = new Command().name("remove").description("remove an agent integrati
|
|
|
19494
18457
|
handleError(error48);
|
|
19495
18458
|
}
|
|
19496
18459
|
});
|
|
19497
|
-
var
|
|
19498
|
-
|
|
19499
|
-
|
|
19500
|
-
|
|
19501
|
-
|
|
19502
|
-
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19509
|
-
|
|
19510
|
-
var execSilent = (command) => {
|
|
18460
|
+
var uninstall = new Command().name("uninstall").description("uninstall React Grab CLI globally").action(() => {
|
|
18461
|
+
console.log("Uninstalling React Grab CLI...");
|
|
18462
|
+
try {
|
|
18463
|
+
execSync("npm uninstall -g @react-grab/cli", { stdio: "inherit" });
|
|
18464
|
+
console.log("React Grab CLI has been uninstalled.");
|
|
18465
|
+
} catch {
|
|
18466
|
+
console.error("Failed to uninstall. Please try: npm uninstall -g @react-grab/cli");
|
|
18467
|
+
process.exit(1);
|
|
18468
|
+
}
|
|
18469
|
+
});
|
|
18470
|
+
var VERSION6 = "0.1.0-beta.7";
|
|
18471
|
+
var UPDATE_COMMAND = "npm install -g @react-grab/cli@latest";
|
|
18472
|
+
var getLatestVersion = () => {
|
|
19511
18473
|
try {
|
|
19512
|
-
return execSync(
|
|
18474
|
+
return execSync("npm view @react-grab/cli version", {
|
|
19513
18475
|
encoding: "utf-8",
|
|
19514
18476
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19515
18477
|
}).trim();
|
|
@@ -19517,47 +18479,22 @@ var execSilent = (command) => {
|
|
|
19517
18479
|
return null;
|
|
19518
18480
|
}
|
|
19519
18481
|
};
|
|
19520
|
-
var
|
|
19521
|
-
const output = execSilent("grab --version");
|
|
19522
|
-
if (!output) return null;
|
|
19523
|
-
const match = output.match(/(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)/);
|
|
19524
|
-
return match ? match[1] : null;
|
|
19525
|
-
};
|
|
19526
|
-
var getLatestVersion = () => execSilent("npm view grab version");
|
|
19527
|
-
var isPackageManagerInstalled = (manager) => execSilent(`${manager} --version`) !== null;
|
|
19528
|
-
var detectGlobalPackageManager = () => {
|
|
19529
|
-
const managers = ["pnpm", "yarn", "bun"];
|
|
19530
|
-
for (const manager of managers) {
|
|
19531
|
-
if (isPackageManagerInstalled(manager)) {
|
|
19532
|
-
return manager;
|
|
19533
|
-
}
|
|
19534
|
-
}
|
|
19535
|
-
return "npm";
|
|
19536
|
-
};
|
|
19537
|
-
var update = new Command().name("update").alias("upgrade").description("update grab to the latest version").option("-y, --yes", "skip confirmation prompts", false).option("--check", "only check for updates, don't install", false).action(async (opts2) => {
|
|
18482
|
+
var update = new Command().name("update").alias("upgrade").description("update React Grab CLI to the latest version").option("-y, --yes", "skip confirmation prompts", false).option("--check", "only check for updates, don't install", false).action(async (opts2) => {
|
|
19538
18483
|
console.log(
|
|
19539
18484
|
`${pc.magenta("\u273F")} ${pc.bold("React Grab")} ${pc.gray(VERSION6)}`
|
|
19540
18485
|
);
|
|
19541
18486
|
console.log();
|
|
19542
18487
|
const checkSpinner = spinner("Checking for updates").start();
|
|
19543
|
-
const installedVersion = getInstalledVersion();
|
|
19544
18488
|
const latestVersion = getLatestVersion();
|
|
19545
18489
|
if (!latestVersion) {
|
|
19546
|
-
checkSpinner.fail("Failed to fetch latest version
|
|
18490
|
+
checkSpinner.fail("Failed to fetch latest version");
|
|
19547
18491
|
logger.break();
|
|
19548
18492
|
logger.error("Could not reach npm registry. Check your network connection.");
|
|
19549
18493
|
logger.break();
|
|
19550
18494
|
process.exit(1);
|
|
19551
18495
|
}
|
|
19552
|
-
|
|
19553
|
-
|
|
19554
|
-
logger.break();
|
|
19555
|
-
logger.log(`Install it with: ${highlighter.info("npm install -g grab")}`);
|
|
19556
|
-
logger.break();
|
|
19557
|
-
process.exit(1);
|
|
19558
|
-
}
|
|
19559
|
-
checkSpinner.succeed(`Current version: ${highlighter.info(installedVersion)}`);
|
|
19560
|
-
if (installedVersion === latestVersion) {
|
|
18496
|
+
checkSpinner.succeed(`Current version: ${highlighter.info(VERSION6)}`);
|
|
18497
|
+
if (VERSION6 === latestVersion) {
|
|
19561
18498
|
logger.break();
|
|
19562
18499
|
logger.success(`You're already on the latest version (${latestVersion})`);
|
|
19563
18500
|
logger.break();
|
|
@@ -19566,17 +18503,16 @@ var update = new Command().name("update").alias("upgrade").description("update g
|
|
|
19566
18503
|
logger.log(`Latest version: ${highlighter.success(latestVersion)}`);
|
|
19567
18504
|
logger.break();
|
|
19568
18505
|
if (opts2.check) {
|
|
19569
|
-
logger.log(`Update available: ${
|
|
18506
|
+
logger.log(`Update available: ${VERSION6} \u2192 ${latestVersion}`);
|
|
19570
18507
|
logger.log(`Run ${highlighter.info("grab update")} to install the update.`);
|
|
19571
18508
|
logger.break();
|
|
19572
18509
|
process.exit(0);
|
|
19573
18510
|
}
|
|
19574
|
-
const packageManager = detectGlobalPackageManager();
|
|
19575
18511
|
if (!opts2.yes) {
|
|
19576
18512
|
const { shouldProceed } = await prompts3({
|
|
19577
18513
|
type: "confirm",
|
|
19578
18514
|
name: "shouldProceed",
|
|
19579
|
-
message: `Update
|
|
18515
|
+
message: `Update from ${VERSION6} to ${latestVersion}?`,
|
|
19580
18516
|
initial: true
|
|
19581
18517
|
});
|
|
19582
18518
|
if (!shouldProceed) {
|
|
@@ -19587,20 +18523,17 @@ var update = new Command().name("update").alias("upgrade").description("update g
|
|
|
19587
18523
|
}
|
|
19588
18524
|
}
|
|
19589
18525
|
logger.break();
|
|
19590
|
-
const updateSpinner = spinner(`Updating
|
|
18526
|
+
const updateSpinner = spinner(`Updating to ${latestVersion}`).start();
|
|
19591
18527
|
try {
|
|
19592
|
-
|
|
19593
|
-
|
|
19594
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
19595
|
-
});
|
|
19596
|
-
updateSpinner.succeed(`Updated grab to ${latestVersion}`);
|
|
18528
|
+
execSync(UPDATE_COMMAND, { stdio: ["pipe", "pipe", "pipe"] });
|
|
18529
|
+
updateSpinner.succeed(`Updated to ${latestVersion}`);
|
|
19597
18530
|
logger.break();
|
|
19598
18531
|
logger.success("Update complete!");
|
|
19599
18532
|
logger.break();
|
|
19600
18533
|
} catch (error48) {
|
|
19601
|
-
updateSpinner.fail("Failed to update
|
|
18534
|
+
updateSpinner.fail("Failed to update");
|
|
19602
18535
|
logger.break();
|
|
19603
|
-
logger.error(`Update failed. Try manually: ${highlighter.info(
|
|
18536
|
+
logger.error(`Update failed. Try manually: ${highlighter.info(UPDATE_COMMAND)}`);
|
|
19604
18537
|
if (error48 instanceof Error && error48.message) {
|
|
19605
18538
|
logger.dim(error48.message);
|
|
19606
18539
|
}
|
|
@@ -19610,7 +18543,7 @@ var update = new Command().name("update").alias("upgrade").description("update g
|
|
|
19610
18543
|
});
|
|
19611
18544
|
|
|
19612
18545
|
// src/cli.ts
|
|
19613
|
-
var VERSION7 = "0.1.0-beta.
|
|
18546
|
+
var VERSION7 = "0.1.0-beta.7";
|
|
19614
18547
|
var VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
19615
18548
|
process.on("SIGINT", () => process.exit(0));
|
|
19616
18549
|
process.on("SIGTERM", () => process.exit(0));
|
|
@@ -19626,69 +18559,5 @@ program.addCommand(remove);
|
|
|
19626
18559
|
program.addCommand(configure);
|
|
19627
18560
|
program.addCommand(browser);
|
|
19628
18561
|
program.addCommand(update);
|
|
19629
|
-
|
|
19630
|
-
var initCommand = completion.commands.get("init");
|
|
19631
|
-
var initAgentOption = initCommand?.options.get("agent");
|
|
19632
|
-
if (initAgentOption) {
|
|
19633
|
-
initAgentOption.handler = (complete) => {
|
|
19634
|
-
for (const agent of AGENTS) {
|
|
19635
|
-
complete(agent, "");
|
|
19636
|
-
}
|
|
19637
|
-
};
|
|
19638
|
-
}
|
|
19639
|
-
var initKeyOption = initCommand?.options.get("key");
|
|
19640
|
-
if (initKeyOption) {
|
|
19641
|
-
initKeyOption.handler = (complete) => {
|
|
19642
|
-
complete("Meta+K", "Cmd+K / Win+K");
|
|
19643
|
-
complete("Ctrl+K", "Ctrl+K");
|
|
19644
|
-
complete("Space", "Spacebar");
|
|
19645
|
-
complete("Alt", "Option / Alt");
|
|
19646
|
-
};
|
|
19647
|
-
}
|
|
19648
|
-
var addCommand = completion.commands.get("add");
|
|
19649
|
-
var addAgentArg = addCommand?.arguments.get("agent");
|
|
19650
|
-
if (addAgentArg) {
|
|
19651
|
-
addAgentArg.handler = (complete) => {
|
|
19652
|
-
complete("skill", "Instructions for your agent to use the browser (recommended)");
|
|
19653
|
-
complete("mcp", "A server that provides browser tools to your agent");
|
|
19654
|
-
for (const agent of AGENTS) {
|
|
19655
|
-
complete(agent, "");
|
|
19656
|
-
}
|
|
19657
|
-
};
|
|
19658
|
-
}
|
|
19659
|
-
var addClientOption = addCommand?.options.get("client");
|
|
19660
|
-
if (addClientOption) {
|
|
19661
|
-
addClientOption.handler = (complete) => {
|
|
19662
|
-
for (const client of MCP_CLIENTS) {
|
|
19663
|
-
complete(client, "");
|
|
19664
|
-
}
|
|
19665
|
-
};
|
|
19666
|
-
}
|
|
19667
|
-
var removeCommand = completion.commands.get("remove");
|
|
19668
|
-
var removeAgentArg = removeCommand?.arguments.get("agent");
|
|
19669
|
-
if (removeAgentArg) {
|
|
19670
|
-
removeAgentArg.handler = (complete) => {
|
|
19671
|
-
for (const agent of AGENTS) {
|
|
19672
|
-
complete(agent, "");
|
|
19673
|
-
}
|
|
19674
|
-
};
|
|
19675
|
-
}
|
|
19676
|
-
var configureCommand = completion.commands.get("configure");
|
|
19677
|
-
var configureKeyOption = configureCommand?.options.get("key");
|
|
19678
|
-
if (configureKeyOption) {
|
|
19679
|
-
configureKeyOption.handler = (complete) => {
|
|
19680
|
-
complete("Meta+K", "Cmd+K / Win+K");
|
|
19681
|
-
complete("Ctrl+K", "Ctrl+K");
|
|
19682
|
-
complete("Space", "Spacebar");
|
|
19683
|
-
complete("Alt", "Option / Alt");
|
|
19684
|
-
complete("Ctrl+Shift+G", "Ctrl+Shift+G");
|
|
19685
|
-
};
|
|
19686
|
-
}
|
|
19687
|
-
var configureModeOption = configureCommand?.options.get("mode");
|
|
19688
|
-
if (configureModeOption) {
|
|
19689
|
-
configureModeOption.handler = (complete) => {
|
|
19690
|
-
complete("toggle", "Press to activate/deactivate");
|
|
19691
|
-
complete("hold", "Hold key to keep active");
|
|
19692
|
-
};
|
|
19693
|
-
}
|
|
18562
|
+
program.addCommand(uninstall);
|
|
19694
18563
|
program.parse();
|