@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.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var commander = require('commander');
|
|
5
|
-
var e = require('assert');
|
|
6
5
|
var pc = require('picocolors');
|
|
7
6
|
var prompts3 = require('prompts');
|
|
8
7
|
var fs = require('fs');
|
|
@@ -19,7 +18,6 @@ var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
19
18
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
20
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
20
|
|
|
22
|
-
var e__default = /*#__PURE__*/_interopDefault(e);
|
|
23
21
|
var pc__default = /*#__PURE__*/_interopDefault(pc);
|
|
24
22
|
var prompts3__default = /*#__PURE__*/_interopDefault(prompts3);
|
|
25
23
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
@@ -29,1036 +27,6 @@ var __export = (target, all) => {
|
|
|
29
27
|
for (var name in all)
|
|
30
28
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
29
|
};
|
|
32
|
-
function t(e3, t2) {
|
|
33
|
-
return `#compdef ${e3}
|
|
34
|
-
compdef _${e3} ${e3}
|
|
35
|
-
|
|
36
|
-
# zsh completion for ${e3} -*- shell-script -*-
|
|
37
|
-
|
|
38
|
-
__${e3}_debug() {
|
|
39
|
-
local file="$BASH_COMP_DEBUG_FILE"
|
|
40
|
-
if [[ -n \${file} ]]; then
|
|
41
|
-
echo "$*" >> "\${file}"
|
|
42
|
-
fi
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_${e3}() {
|
|
46
|
-
local shellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
47
|
-
local shellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
48
|
-
local shellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
49
|
-
local shellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
50
|
-
local shellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
51
|
-
local shellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
52
|
-
|
|
53
|
-
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
54
|
-
local -a completions
|
|
55
|
-
|
|
56
|
-
__${e3}_debug "\\n========= starting completion logic =========="
|
|
57
|
-
__${e3}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
|
|
58
|
-
|
|
59
|
-
# The user could have moved the cursor backwards on the command-line.
|
|
60
|
-
# We need to trigger completion from the $CURRENT location, so we need
|
|
61
|
-
# to truncate the command-line ($words) up to the $CURRENT location.
|
|
62
|
-
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
|
63
|
-
words=( "\${=words[1,CURRENT]}" )
|
|
64
|
-
__${e3}_debug "Truncated words[*]: \${words[*]},"
|
|
65
|
-
|
|
66
|
-
lastParam=\${words[-1]}
|
|
67
|
-
lastChar=\${lastParam[-1]}
|
|
68
|
-
__${e3}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
|
|
69
|
-
|
|
70
|
-
# For zsh, when completing a flag with an = (e.g., ${e3} -n=<TAB>)
|
|
71
|
-
# completions must be prefixed with the flag
|
|
72
|
-
setopt local_options BASH_REMATCH
|
|
73
|
-
if [[ "\${lastParam}" =~ '-.*=' ]]; then
|
|
74
|
-
# We are dealing with a flag with an =
|
|
75
|
-
flagPrefix="-P \${BASH_REMATCH}"
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
79
|
-
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
80
|
-
if [ "\${lastChar}" = "" ]; then
|
|
81
|
-
# If the last parameter is complete (there is a space following it)
|
|
82
|
-
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
83
|
-
__${e3}_debug "Adding extra empty parameter"
|
|
84
|
-
args_to_quote+=("")
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# Use Zsh's (q) flag to quote each argument safely for eval
|
|
88
|
-
local quoted_args=("\${(@q)args_to_quote}")
|
|
89
|
-
|
|
90
|
-
# Join the main command and the quoted arguments into a single string for eval
|
|
91
|
-
requestComp="${t2} complete -- \${quoted_args[*]}"
|
|
92
|
-
|
|
93
|
-
__${e3}_debug "About to call: eval \${requestComp}"
|
|
94
|
-
|
|
95
|
-
# Use eval to handle any environment variables and such
|
|
96
|
-
out=$(eval \${requestComp} 2>/dev/null)
|
|
97
|
-
__${e3}_debug "completion output: \${out}"
|
|
98
|
-
|
|
99
|
-
# Extract the directive integer following a : from the last line
|
|
100
|
-
local lastLine
|
|
101
|
-
while IFS='
|
|
102
|
-
' read -r line; do
|
|
103
|
-
lastLine=\${line}
|
|
104
|
-
done < <(printf "%s
|
|
105
|
-
" "\${out[@]}")
|
|
106
|
-
__${e3}_debug "last line: \${lastLine}"
|
|
107
|
-
|
|
108
|
-
if [ "\${lastLine[1]}" = : ]; then
|
|
109
|
-
directive=\${lastLine[2,-1]}
|
|
110
|
-
# Remove the directive including the : and the newline
|
|
111
|
-
local suffix
|
|
112
|
-
(( suffix=\${#lastLine}+2))
|
|
113
|
-
out=\${out[1,-$suffix]}
|
|
114
|
-
else
|
|
115
|
-
# There is no directive specified. Leave $out as is.
|
|
116
|
-
__${e3}_debug "No directive found. Setting to default"
|
|
117
|
-
directive=0
|
|
118
|
-
fi
|
|
119
|
-
|
|
120
|
-
__${e3}_debug "directive: \${directive}"
|
|
121
|
-
__${e3}_debug "completions: \${out}"
|
|
122
|
-
__${e3}_debug "flagPrefix: \${flagPrefix}"
|
|
123
|
-
|
|
124
|
-
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
|
125
|
-
__${e3}_debug "Completion received error. Ignoring completions."
|
|
126
|
-
return
|
|
127
|
-
fi
|
|
128
|
-
|
|
129
|
-
local activeHelpMarker="%"
|
|
130
|
-
local endIndex=\${#activeHelpMarker}
|
|
131
|
-
local startIndex=$((\${#activeHelpMarker}+1))
|
|
132
|
-
local hasActiveHelp=0
|
|
133
|
-
while IFS='
|
|
134
|
-
' read -r comp; do
|
|
135
|
-
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
136
|
-
if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
137
|
-
__${e3}_debug "ActiveHelp found: $comp"
|
|
138
|
-
comp="\${comp[$startIndex,-1]}"
|
|
139
|
-
if [ -n "$comp" ]; then
|
|
140
|
-
compadd -x "\${comp}"
|
|
141
|
-
__${e3}_debug "ActiveHelp will need delimiter"
|
|
142
|
-
hasActiveHelp=1
|
|
143
|
-
fi
|
|
144
|
-
continue
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
if [ -n "$comp" ]; then
|
|
148
|
-
# If requested, completions are returned with a description.
|
|
149
|
-
# The description is preceded by a TAB character.
|
|
150
|
-
# For zsh's _describe, we need to use a : instead of a TAB.
|
|
151
|
-
# We first need to escape any : as part of the completion itself.
|
|
152
|
-
comp=\${comp//:/\\:}
|
|
153
|
-
|
|
154
|
-
local tab="$(printf '\\t')"
|
|
155
|
-
comp=\${comp//$tab/:}
|
|
156
|
-
|
|
157
|
-
__${e3}_debug "Adding completion: \${comp}"
|
|
158
|
-
completions+=\${comp}
|
|
159
|
-
lastComp=$comp
|
|
160
|
-
fi
|
|
161
|
-
done < <(printf "%s
|
|
162
|
-
" "\${out[@]}")
|
|
163
|
-
|
|
164
|
-
# Add a delimiter after the activeHelp statements, but only if:
|
|
165
|
-
# - there are completions following the activeHelp statements, or
|
|
166
|
-
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
167
|
-
if [ $hasActiveHelp -eq 1 ]; then
|
|
168
|
-
if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
169
|
-
__${e3}_debug "Adding activeHelp delimiter"
|
|
170
|
-
compadd -x "--"
|
|
171
|
-
hasActiveHelp=0
|
|
172
|
-
fi
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
|
176
|
-
__${e3}_debug "Activating nospace."
|
|
177
|
-
noSpace="-S ''"
|
|
178
|
-
fi
|
|
179
|
-
|
|
180
|
-
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
181
|
-
__${e3}_debug "Activating keep order."
|
|
182
|
-
keepOrder="-V"
|
|
183
|
-
fi
|
|
184
|
-
|
|
185
|
-
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
|
186
|
-
# File extension filtering
|
|
187
|
-
local filteringCmd
|
|
188
|
-
filteringCmd='_files'
|
|
189
|
-
for filter in \${completions[@]}; do
|
|
190
|
-
if [ \${filter[1]} != '*' ]; then
|
|
191
|
-
# zsh requires a glob pattern to do file filtering
|
|
192
|
-
filter="\\*.$filter"
|
|
193
|
-
fi
|
|
194
|
-
filteringCmd+=" -g $filter"
|
|
195
|
-
done
|
|
196
|
-
filteringCmd+=" \${flagPrefix}"
|
|
197
|
-
|
|
198
|
-
__${e3}_debug "File filtering command: $filteringCmd"
|
|
199
|
-
_arguments '*:filename:'"$filteringCmd"
|
|
200
|
-
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
|
201
|
-
# File completion for directories only
|
|
202
|
-
local subdir
|
|
203
|
-
subdir="\${completions[1]}"
|
|
204
|
-
if [ -n "$subdir" ]; then
|
|
205
|
-
__${e3}_debug "Listing directories in $subdir"
|
|
206
|
-
pushd "\${subdir}" >/dev/null 2>&1
|
|
207
|
-
else
|
|
208
|
-
__${e3}_debug "Listing directories in ."
|
|
209
|
-
fi
|
|
210
|
-
|
|
211
|
-
local result
|
|
212
|
-
_arguments '*:dirname:_files -/'" \${flagPrefix}"
|
|
213
|
-
result=$?
|
|
214
|
-
if [ -n "$subdir" ]; then
|
|
215
|
-
popd >/dev/null 2>&1
|
|
216
|
-
fi
|
|
217
|
-
return $result
|
|
218
|
-
else
|
|
219
|
-
__${e3}_debug "Calling _describe"
|
|
220
|
-
if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
|
|
221
|
-
__${e3}_debug "_describe found some completions"
|
|
222
|
-
|
|
223
|
-
# Return the success of having called _describe
|
|
224
|
-
return 0
|
|
225
|
-
else
|
|
226
|
-
__${e3}_debug "_describe did not find completions."
|
|
227
|
-
__${e3}_debug "Checking if we should do file completion."
|
|
228
|
-
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
|
229
|
-
__${e3}_debug "deactivating file completion"
|
|
230
|
-
|
|
231
|
-
# Return 0 to indicate completion is finished and prevent zsh from
|
|
232
|
-
# trying other completion algorithms (which could cause hanging).
|
|
233
|
-
# We use NoFileComp directive to explicitly disable file completion.
|
|
234
|
-
return 0
|
|
235
|
-
else
|
|
236
|
-
# Perform file completion
|
|
237
|
-
__${e3}_debug "Activating file completion"
|
|
238
|
-
|
|
239
|
-
# We must return the result of this command, so it must be the
|
|
240
|
-
# last command, or else we must store its result to return it.
|
|
241
|
-
_arguments '*:filename:_files'" \${flagPrefix}"
|
|
242
|
-
fi
|
|
243
|
-
fi
|
|
244
|
-
fi
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
# don't run the completion function when being sourced or eval-ed
|
|
248
|
-
if [ "\${funcstack[1]}" = "_${e3}" ]; then
|
|
249
|
-
_${e3}
|
|
250
|
-
fi
|
|
251
|
-
`;
|
|
252
|
-
}
|
|
253
|
-
function n(e3, t2) {
|
|
254
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
255
|
-
return `# bash completion for ${e3}
|
|
256
|
-
|
|
257
|
-
# Define shell completion directives
|
|
258
|
-
readonly ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
259
|
-
readonly ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
260
|
-
readonly ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
261
|
-
readonly ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
262
|
-
readonly ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
263
|
-
readonly ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
264
|
-
|
|
265
|
-
# Function to debug completion
|
|
266
|
-
__${n2}_debug() {
|
|
267
|
-
if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
|
|
268
|
-
echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
|
|
269
|
-
fi
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
# Function to handle completions
|
|
273
|
-
__${n2}_complete() {
|
|
274
|
-
local cur prev words cword
|
|
275
|
-
_get_comp_words_by_ref -n "=:" cur prev words cword
|
|
276
|
-
|
|
277
|
-
local requestComp out directive
|
|
278
|
-
|
|
279
|
-
# Build the command to get completions
|
|
280
|
-
requestComp="${t2} complete -- \${words[@]:1}"
|
|
281
|
-
|
|
282
|
-
# Add an empty parameter if the last parameter is complete
|
|
283
|
-
if [[ -z "$cur" ]]; then
|
|
284
|
-
requestComp="$requestComp ''"
|
|
285
|
-
fi
|
|
286
|
-
|
|
287
|
-
# Get completions from the program
|
|
288
|
-
out=$(eval "$requestComp" 2>/dev/null)
|
|
289
|
-
|
|
290
|
-
# Extract directive if present
|
|
291
|
-
directive=0
|
|
292
|
-
if [[ "$out" == *:* ]]; then
|
|
293
|
-
directive=\${out##*:}
|
|
294
|
-
out=\${out%:*}
|
|
295
|
-
fi
|
|
296
|
-
|
|
297
|
-
# Process completions based on directive
|
|
298
|
-
if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
|
|
299
|
-
# Error, no completion
|
|
300
|
-
return
|
|
301
|
-
fi
|
|
302
|
-
|
|
303
|
-
# Apply directives
|
|
304
|
-
if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
|
|
305
|
-
compopt -o nospace
|
|
306
|
-
fi
|
|
307
|
-
if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
|
|
308
|
-
compopt -o nosort
|
|
309
|
-
fi
|
|
310
|
-
if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
|
|
311
|
-
compopt +o default
|
|
312
|
-
fi
|
|
313
|
-
|
|
314
|
-
# Handle file extension filtering
|
|
315
|
-
if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
|
|
316
|
-
local filter=""
|
|
317
|
-
for ext in $out; do
|
|
318
|
-
filter="$filter|$ext"
|
|
319
|
-
done
|
|
320
|
-
filter="\\.($filter)"
|
|
321
|
-
compopt -o filenames
|
|
322
|
-
COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
|
|
323
|
-
return
|
|
324
|
-
fi
|
|
325
|
-
|
|
326
|
-
# Handle directory filtering
|
|
327
|
-
if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
|
|
328
|
-
compopt -o dirnames
|
|
329
|
-
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
330
|
-
return
|
|
331
|
-
fi
|
|
332
|
-
|
|
333
|
-
# Process completions
|
|
334
|
-
local IFS=$'\\n'
|
|
335
|
-
local tab=$(printf '\\t')
|
|
336
|
-
|
|
337
|
-
# Parse completions with descriptions
|
|
338
|
-
local completions=()
|
|
339
|
-
while read -r comp; do
|
|
340
|
-
if [[ "$comp" == *$tab* ]]; then
|
|
341
|
-
# Split completion and description
|
|
342
|
-
local value=\${comp%%$tab*}
|
|
343
|
-
local desc=\${comp#*$tab}
|
|
344
|
-
completions+=("$value")
|
|
345
|
-
else
|
|
346
|
-
completions+=("$comp")
|
|
347
|
-
fi
|
|
348
|
-
done <<< "$out"
|
|
349
|
-
|
|
350
|
-
# Return completions
|
|
351
|
-
COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
# Register completion function
|
|
355
|
-
complete -F __${n2}_complete ${e3}
|
|
356
|
-
`;
|
|
357
|
-
}
|
|
358
|
-
function r(e3, t2) {
|
|
359
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
360
|
-
return `# fish completion for ${e3} -*- shell-script -*-
|
|
361
|
-
|
|
362
|
-
# Define shell completion directives
|
|
363
|
-
set -l ShellCompDirectiveError ${a.ShellCompDirectiveError}
|
|
364
|
-
set -l ShellCompDirectiveNoSpace ${a.ShellCompDirectiveNoSpace}
|
|
365
|
-
set -l ShellCompDirectiveNoFileComp ${a.ShellCompDirectiveNoFileComp}
|
|
366
|
-
set -l ShellCompDirectiveFilterFileExt ${a.ShellCompDirectiveFilterFileExt}
|
|
367
|
-
set -l ShellCompDirectiveFilterDirs ${a.ShellCompDirectiveFilterDirs}
|
|
368
|
-
set -l ShellCompDirectiveKeepOrder ${a.ShellCompDirectiveKeepOrder}
|
|
369
|
-
|
|
370
|
-
function __${n2}_debug
|
|
371
|
-
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
372
|
-
if test -n "$file"
|
|
373
|
-
echo "$argv" >> $file
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
function __${n2}_perform_completion
|
|
378
|
-
__${n2}_debug "Starting __${n2}_perform_completion"
|
|
379
|
-
|
|
380
|
-
# Extract all args except the completion flag
|
|
381
|
-
set -l args (string match -v -- "--completion=" (commandline -opc))
|
|
382
|
-
|
|
383
|
-
# Extract the current token being completed
|
|
384
|
-
set -l current_token (commandline -ct)
|
|
385
|
-
|
|
386
|
-
# Check if current token starts with a dash
|
|
387
|
-
set -l flag_prefix ""
|
|
388
|
-
if string match -q -- "-*" $current_token
|
|
389
|
-
set flag_prefix "--flag="
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
__${n2}_debug "Current token: $current_token"
|
|
393
|
-
__${n2}_debug "All args: $args"
|
|
394
|
-
|
|
395
|
-
# Call the completion program and get the results
|
|
396
|
-
set -l requestComp "${t2} complete -- $args"
|
|
397
|
-
__${n2}_debug "Calling $requestComp"
|
|
398
|
-
set -l results (eval $requestComp 2> /dev/null)
|
|
399
|
-
|
|
400
|
-
# Some programs may output extra empty lines after the directive.
|
|
401
|
-
# Let's ignore them or else it will break completion.
|
|
402
|
-
# Ref: https://github.com/spf13/cobra/issues/1279
|
|
403
|
-
for line in $results[-1..1]
|
|
404
|
-
if test (string sub -s 1 -l 1 -- $line) = ":"
|
|
405
|
-
# The directive
|
|
406
|
-
set -l directive (string sub -s 2 -- $line)
|
|
407
|
-
set -l directive_num (math $directive)
|
|
408
|
-
break
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
# No directive specified, use default
|
|
413
|
-
if not set -q directive_num
|
|
414
|
-
set directive_num 0
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
__${n2}_debug "Directive: $directive_num"
|
|
418
|
-
|
|
419
|
-
# Process completions based on directive
|
|
420
|
-
if test $directive_num -eq $ShellCompDirectiveError
|
|
421
|
-
# Error code. No completion.
|
|
422
|
-
__${n2}_debug "Received error directive: aborting."
|
|
423
|
-
return 1
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
# Filter out the directive (last line)
|
|
427
|
-
if test (count $results) -gt 0 -a (string sub -s 1 -l 1 -- $results[-1]) = ":"
|
|
428
|
-
set results $results[1..-2]
|
|
429
|
-
end
|
|
430
|
-
|
|
431
|
-
# No completions, let fish handle file completions unless forbidden
|
|
432
|
-
if test (count $results) -eq 0
|
|
433
|
-
if test $directive_num -ne $ShellCompDirectiveNoFileComp
|
|
434
|
-
__${n2}_debug "No completions, performing file completion"
|
|
435
|
-
return 1
|
|
436
|
-
end
|
|
437
|
-
__${n2}_debug "No completions, but file completion forbidden"
|
|
438
|
-
return 0
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
# Filter file extensions
|
|
442
|
-
if test $directive_num -eq $ShellCompDirectiveFilterFileExt
|
|
443
|
-
__${n2}_debug "File extension filtering"
|
|
444
|
-
set -l file_extensions
|
|
445
|
-
for item in $results
|
|
446
|
-
if test -n "$item" -a (string sub -s 1 -l 1 -- $item) != "-"
|
|
447
|
-
set -a file_extensions "*$item"
|
|
448
|
-
end
|
|
449
|
-
end
|
|
450
|
-
__${n2}_debug "File extensions: $file_extensions"
|
|
451
|
-
|
|
452
|
-
# Use the file extensions as completions
|
|
453
|
-
set -l completions
|
|
454
|
-
for ext in $file_extensions
|
|
455
|
-
# Get all files matching the extension
|
|
456
|
-
set -a completions (string replace -r '^.*/' '' -- $ext)
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
for item in $completions
|
|
460
|
-
echo -e "$item "
|
|
461
|
-
end
|
|
462
|
-
return 0
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
# Filter directories
|
|
466
|
-
if test $directive_num -eq $ShellCompDirectiveFilterDirs
|
|
467
|
-
__${n2}_debug "Directory filtering"
|
|
468
|
-
set -l dirs
|
|
469
|
-
for item in $results
|
|
470
|
-
if test -d "$item"
|
|
471
|
-
set -a dirs "$item/"
|
|
472
|
-
end
|
|
473
|
-
end
|
|
474
|
-
|
|
475
|
-
for item in $dirs
|
|
476
|
-
echo -e "$item "
|
|
477
|
-
end
|
|
478
|
-
return 0
|
|
479
|
-
end
|
|
480
|
-
|
|
481
|
-
# Process remaining completions
|
|
482
|
-
for item in $results
|
|
483
|
-
if test -n "$item"
|
|
484
|
-
# Check if the item has a description
|
|
485
|
-
if string match -q "* *" -- "$item"
|
|
486
|
-
set -l completion_parts (string split -- "$item")
|
|
487
|
-
set -l comp $completion_parts[1]
|
|
488
|
-
set -l desc $completion_parts[2]
|
|
489
|
-
|
|
490
|
-
# Add the completion and description
|
|
491
|
-
echo -e "$comp $desc"
|
|
492
|
-
else
|
|
493
|
-
# Add just the completion
|
|
494
|
-
echo -e "$item "
|
|
495
|
-
end
|
|
496
|
-
end
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
-
# If directive contains NoSpace, tell fish not to add a space after completion
|
|
500
|
-
if test (math "$directive_num & $ShellCompDirectiveNoSpace") -ne 0
|
|
501
|
-
return 2
|
|
502
|
-
end
|
|
503
|
-
|
|
504
|
-
return 0
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
# Set up the completion for the ${e3} command
|
|
508
|
-
complete -c ${e3} -f -a "(eval __${n2}_perform_completion)"
|
|
509
|
-
`;
|
|
510
|
-
}
|
|
511
|
-
function i(e3, t2) {
|
|
512
|
-
let n2 = e3.replace(/[-:]/g, `_`);
|
|
513
|
-
return `# powershell completion for ${e3} -*- shell-script -*-
|
|
514
|
-
|
|
515
|
-
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
516
|
-
function __${e3}_debug {
|
|
517
|
-
if ($env:BASH_COMP_DEBUG_FILE) {
|
|
518
|
-
"$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
filter __${e3}_escapeStringWithSpecialChars {
|
|
523
|
-
$_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
[scriptblock]$__${n2}CompleterBlock = {
|
|
527
|
-
param(
|
|
528
|
-
$WordToComplete,
|
|
529
|
-
$CommandAst,
|
|
530
|
-
$CursorPosition
|
|
531
|
-
)
|
|
532
|
-
|
|
533
|
-
# Get the current command line and convert into a string
|
|
534
|
-
$Command = $CommandAst.CommandElements
|
|
535
|
-
$Command = "$Command"
|
|
536
|
-
|
|
537
|
-
__${e3}_debug ""
|
|
538
|
-
__${e3}_debug "========= starting completion logic =========="
|
|
539
|
-
__${e3}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
|
|
540
|
-
|
|
541
|
-
# The user could have moved the cursor backwards on the command-line.
|
|
542
|
-
# We need to trigger completion from the $CursorPosition location, so we need
|
|
543
|
-
# to truncate the command-line ($Command) up to the $CursorPosition location.
|
|
544
|
-
# Make sure the $Command is longer then the $CursorPosition before we truncate.
|
|
545
|
-
# This happens because the $Command does not include the last space.
|
|
546
|
-
if ($Command.Length -gt $CursorPosition) {
|
|
547
|
-
$Command = $Command.Substring(0, $CursorPosition)
|
|
548
|
-
}
|
|
549
|
-
__${e3}_debug "Truncated command: $Command"
|
|
550
|
-
|
|
551
|
-
$ShellCompDirectiveError=${a.ShellCompDirectiveError}
|
|
552
|
-
$ShellCompDirectiveNoSpace=${a.ShellCompDirectiveNoSpace}
|
|
553
|
-
$ShellCompDirectiveNoFileComp=${a.ShellCompDirectiveNoFileComp}
|
|
554
|
-
$ShellCompDirectiveFilterFileExt=${a.ShellCompDirectiveFilterFileExt}
|
|
555
|
-
$ShellCompDirectiveFilterDirs=${a.ShellCompDirectiveFilterDirs}
|
|
556
|
-
$ShellCompDirectiveKeepOrder=${a.ShellCompDirectiveKeepOrder}
|
|
557
|
-
|
|
558
|
-
# Prepare the command to request completions for the program.
|
|
559
|
-
# Split the command at the first space to separate the program and arguments.
|
|
560
|
-
$Program, $Arguments = $Command.Split(" ", 2)
|
|
561
|
-
|
|
562
|
-
$QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
|
|
563
|
-
__${e3}_debug "QuotedArgs: $QuotedArgs"
|
|
564
|
-
|
|
565
|
-
$RequestComp = "& ${t2} complete '--' $QuotedArgs"
|
|
566
|
-
__${e3}_debug "RequestComp: $RequestComp"
|
|
567
|
-
|
|
568
|
-
# we cannot use $WordToComplete because it
|
|
569
|
-
# has the wrong values if the cursor was moved
|
|
570
|
-
# so use the last argument
|
|
571
|
-
if ($WordToComplete -ne "" ) {
|
|
572
|
-
$WordToComplete = $Arguments.Split(" ")[-1]
|
|
573
|
-
}
|
|
574
|
-
__${e3}_debug "New WordToComplete: $WordToComplete"
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
# Check for flag with equal sign
|
|
578
|
-
$IsEqualFlag = ($WordToComplete -Like "--*=*" )
|
|
579
|
-
if ( $IsEqualFlag ) {
|
|
580
|
-
__${e3}_debug "Completing equal sign flag"
|
|
581
|
-
# Remove the flag part
|
|
582
|
-
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
|
|
586
|
-
# If the last parameter is complete (there is a space following it)
|
|
587
|
-
# We add an extra empty parameter so we can indicate this to the go method.
|
|
588
|
-
__${e3}_debug "Adding extra empty parameter"
|
|
589
|
-
# PowerShell 7.2+ changed the way how the arguments are passed to executables,
|
|
590
|
-
# so for pre-7.2 or when Legacy argument passing is enabled we need to use
|
|
591
|
-
if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
|
|
592
|
-
($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
|
|
593
|
-
(($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
|
|
594
|
-
$PSNativeCommandArgumentPassing -eq 'Legacy')) {
|
|
595
|
-
$RequestComp="$RequestComp" + ' \`"\`"'
|
|
596
|
-
} else {
|
|
597
|
-
$RequestComp = "$RequestComp" + ' ""'
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
__${e3}_debug "Calling $RequestComp"
|
|
602
|
-
# First disable ActiveHelp which is not supported for Powershell
|
|
603
|
-
$env:ActiveHelp = 0
|
|
604
|
-
|
|
605
|
-
# call the command store the output in $out and redirect stderr and stdout to null
|
|
606
|
-
# $Out is an array contains each line per element
|
|
607
|
-
Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
|
|
608
|
-
|
|
609
|
-
# get directive from last line
|
|
610
|
-
[int]$Directive = $Out[-1].TrimStart(':')
|
|
611
|
-
if ($Directive -eq "") {
|
|
612
|
-
# There is no directive specified
|
|
613
|
-
$Directive = 0
|
|
614
|
-
}
|
|
615
|
-
__${e3}_debug "The completion directive is: $Directive"
|
|
616
|
-
|
|
617
|
-
# remove directive (last element) from out
|
|
618
|
-
$Out = $Out | Where-Object { $_ -ne $Out[-1] }
|
|
619
|
-
__${e3}_debug "The completions are: $Out"
|
|
620
|
-
|
|
621
|
-
if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
|
|
622
|
-
# Error code. No completion.
|
|
623
|
-
__${e3}_debug "Received error from custom completion go code"
|
|
624
|
-
return
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
$Longest = 0
|
|
628
|
-
[Array]$Values = $Out | ForEach-Object {
|
|
629
|
-
# Split the output in name and description
|
|
630
|
-
$Name, $Description = $_.Split("\`t", 2)
|
|
631
|
-
__${e3}_debug "Name: $Name Description: $Description"
|
|
632
|
-
|
|
633
|
-
# Look for the longest completion so that we can format things nicely
|
|
634
|
-
if ($Longest -lt $Name.Length) {
|
|
635
|
-
$Longest = $Name.Length
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
# Set the description to a one space string if there is none set.
|
|
639
|
-
# This is needed because the CompletionResult does not accept an empty string as argument
|
|
640
|
-
if (-Not $Description) {
|
|
641
|
-
$Description = " "
|
|
642
|
-
}
|
|
643
|
-
@{ Name = "$Name"; Description = "$Description" }
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
$Space = " "
|
|
648
|
-
if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
|
|
649
|
-
# remove the space here
|
|
650
|
-
__${e3}_debug "ShellCompDirectiveNoSpace is called"
|
|
651
|
-
$Space = ""
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
|
655
|
-
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
|
656
|
-
__${e3}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
|
657
|
-
|
|
658
|
-
# return here to prevent the completion of the extensions
|
|
659
|
-
return
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
$Values = $Values | Where-Object {
|
|
663
|
-
# filter the result
|
|
664
|
-
$_.Name -like "$WordToComplete*"
|
|
665
|
-
|
|
666
|
-
# Join the flag back if we have an equal sign flag
|
|
667
|
-
if ( $IsEqualFlag ) {
|
|
668
|
-
__${e3}_debug "Join the equal sign flag back to the completion value"
|
|
669
|
-
$_.Name = $Flag + "=" + $_.Name
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
# we sort the values in ascending order by name if keep order isn't passed
|
|
674
|
-
if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
|
|
675
|
-
$Values = $Values | Sort-Object -Property Name
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
|
|
679
|
-
__${e3}_debug "ShellCompDirectiveNoFileComp is called"
|
|
680
|
-
|
|
681
|
-
if ($Values.Length -eq 0) {
|
|
682
|
-
# Just print an empty string here so the
|
|
683
|
-
# shell does not start to complete paths.
|
|
684
|
-
# We cannot use CompletionResult here because
|
|
685
|
-
# it does not accept an empty string as argument.
|
|
686
|
-
""
|
|
687
|
-
return
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
# Get the current mode
|
|
692
|
-
$Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
|
|
693
|
-
__${e3}_debug "Mode: $Mode"
|
|
694
|
-
|
|
695
|
-
$Values | ForEach-Object {
|
|
696
|
-
|
|
697
|
-
# store temporary because switch will overwrite $_
|
|
698
|
-
$comp = $_
|
|
699
|
-
|
|
700
|
-
# PowerShell supports three different completion modes
|
|
701
|
-
# - TabCompleteNext (default windows style - on each key press the next option is displayed)
|
|
702
|
-
# - Complete (works like bash)
|
|
703
|
-
# - MenuComplete (works like zsh)
|
|
704
|
-
# You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
|
|
705
|
-
|
|
706
|
-
# CompletionResult Arguments:
|
|
707
|
-
# 1) CompletionText text to be used as the auto completion result
|
|
708
|
-
# 2) ListItemText text to be displayed in the suggestion list
|
|
709
|
-
# 3) ResultType type of completion result
|
|
710
|
-
# 4) ToolTip text for the tooltip with details about the object
|
|
711
|
-
|
|
712
|
-
switch ($Mode) {
|
|
713
|
-
|
|
714
|
-
# bash like
|
|
715
|
-
"Complete" {
|
|
716
|
-
|
|
717
|
-
if ($Values.Length -eq 1) {
|
|
718
|
-
__${e3}_debug "Only one completion left"
|
|
719
|
-
|
|
720
|
-
# insert space after value
|
|
721
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
722
|
-
|
|
723
|
-
} else {
|
|
724
|
-
# Add the proper number of spaces to align the descriptions
|
|
725
|
-
while($comp.Name.Length -lt $Longest) {
|
|
726
|
-
$comp.Name = $comp.Name + " "
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
# Check for empty description and only add parentheses if needed
|
|
730
|
-
if ($($comp.Description) -eq " " ) {
|
|
731
|
-
$Description = ""
|
|
732
|
-
} else {
|
|
733
|
-
$Description = " ($($comp.Description))"
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
# zsh like
|
|
741
|
-
"MenuComplete" {
|
|
742
|
-
# insert space after value
|
|
743
|
-
# MenuComplete will automatically show the ToolTip of
|
|
744
|
-
# the highlighted value at the bottom of the suggestions.
|
|
745
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
# TabCompleteNext and in case we get something unknown
|
|
749
|
-
Default {
|
|
750
|
-
# Like MenuComplete but we don't want to add a space here because
|
|
751
|
-
# the user need to press space anyway to get the completion.
|
|
752
|
-
# Description will not be shown because that's not possible with TabCompleteNext
|
|
753
|
-
[System.Management.Automation.CompletionResult]::new($($comp.Name | __${e3}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
Register-ArgumentCompleter -CommandName '${e3}' -ScriptBlock $__${n2}CompleterBlock
|
|
761
|
-
`;
|
|
762
|
-
}
|
|
763
|
-
var a = { ShellCompDirectiveError: 1, ShellCompDirectiveNoSpace: 2, ShellCompDirectiveNoFileComp: 4, ShellCompDirectiveFilterFileExt: 8, ShellCompDirectiveFilterDirs: 16, ShellCompDirectiveKeepOrder: 32, ShellCompDirectiveDefault: 0 };
|
|
764
|
-
var o = class {
|
|
765
|
-
name;
|
|
766
|
-
variadic;
|
|
767
|
-
command;
|
|
768
|
-
handler;
|
|
769
|
-
constructor(e3, t2, n2, r2 = false) {
|
|
770
|
-
this.command = e3, this.name = t2, this.handler = n2, this.variadic = r2;
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
var s = class {
|
|
774
|
-
value;
|
|
775
|
-
description;
|
|
776
|
-
command;
|
|
777
|
-
handler;
|
|
778
|
-
alias;
|
|
779
|
-
isBoolean;
|
|
780
|
-
constructor(e3, t2, n2, r2, i2, a2) {
|
|
781
|
-
this.command = e3, this.value = t2, this.description = n2, this.handler = r2, this.alias = i2, this.isBoolean = a2;
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
var c = class {
|
|
785
|
-
value;
|
|
786
|
-
description;
|
|
787
|
-
options = /* @__PURE__ */ new Map();
|
|
788
|
-
arguments = /* @__PURE__ */ new Map();
|
|
789
|
-
parent;
|
|
790
|
-
constructor(e3, t2) {
|
|
791
|
-
this.value = e3, this.description = t2;
|
|
792
|
-
}
|
|
793
|
-
option(e3, t2, n2, r2) {
|
|
794
|
-
let i2, a2, o3;
|
|
795
|
-
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);
|
|
796
|
-
let c3 = new s(this, e3, t2, i2, a2, o3);
|
|
797
|
-
return this.options.set(e3, c3), this;
|
|
798
|
-
}
|
|
799
|
-
argument(e3, t2, n2 = false) {
|
|
800
|
-
let r2 = new o(this, e3, t2, n2);
|
|
801
|
-
return this.arguments.set(e3, r2), this;
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
|
-
var l = class extends c {
|
|
805
|
-
commands = /* @__PURE__ */ new Map();
|
|
806
|
-
completions = [];
|
|
807
|
-
directive = a.ShellCompDirectiveDefault;
|
|
808
|
-
constructor() {
|
|
809
|
-
super(``, ``);
|
|
810
|
-
}
|
|
811
|
-
command(e3, t2) {
|
|
812
|
-
let n2 = new c(e3, t2);
|
|
813
|
-
return this.commands.set(e3, n2), n2;
|
|
814
|
-
}
|
|
815
|
-
stripOptions(e3) {
|
|
816
|
-
let t2 = [], n2 = 0;
|
|
817
|
-
for (; n2 < e3.length; ) {
|
|
818
|
-
let r2 = e3[n2];
|
|
819
|
-
if (r2.startsWith(`-`)) {
|
|
820
|
-
n2++;
|
|
821
|
-
let t3 = false, i2 = this.findOption(this, r2);
|
|
822
|
-
if (i2) t3 = i2.isBoolean ?? false;
|
|
823
|
-
else for (let [, e4] of this.commands) {
|
|
824
|
-
let n3 = this.findOption(e4, r2);
|
|
825
|
-
if (n3) {
|
|
826
|
-
t3 = n3.isBoolean ?? false;
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
!t3 && n2 < e3.length && !e3[n2].startsWith(`-`) && n2++;
|
|
831
|
-
} else t2.push(r2), n2++;
|
|
832
|
-
}
|
|
833
|
-
return t2;
|
|
834
|
-
}
|
|
835
|
-
matchCommand(e3) {
|
|
836
|
-
e3 = this.stripOptions(e3);
|
|
837
|
-
let t2 = [], n2 = [], r2 = null;
|
|
838
|
-
for (let i2 = 0; i2 < e3.length; i2++) {
|
|
839
|
-
let a2 = e3[i2];
|
|
840
|
-
t2.push(a2);
|
|
841
|
-
let o3 = this.commands.get(t2.join(` `));
|
|
842
|
-
if (o3) r2 = o3;
|
|
843
|
-
else {
|
|
844
|
-
n2 = e3.slice(i2, e3.length);
|
|
845
|
-
break;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
return [r2 || this, n2];
|
|
849
|
-
}
|
|
850
|
-
shouldCompleteFlags(e3, t2) {
|
|
851
|
-
if (t2.startsWith(`-`)) return true;
|
|
852
|
-
if (e3?.startsWith(`-`)) {
|
|
853
|
-
let t3 = this.findOption(this, e3);
|
|
854
|
-
if (!t3) {
|
|
855
|
-
for (let [, n2] of this.commands) if (t3 = this.findOption(n2, e3), t3) break;
|
|
856
|
-
}
|
|
857
|
-
return !(t3 && t3.isBoolean);
|
|
858
|
-
}
|
|
859
|
-
return false;
|
|
860
|
-
}
|
|
861
|
-
shouldCompleteCommands(e3) {
|
|
862
|
-
return !e3.startsWith(`-`);
|
|
863
|
-
}
|
|
864
|
-
handleFlagCompletion(e3, t2, n2, r2) {
|
|
865
|
-
let i2;
|
|
866
|
-
if (n2.includes(`=`)) {
|
|
867
|
-
let [e4] = n2.split(`=`);
|
|
868
|
-
i2 = e4;
|
|
869
|
-
} else if (r2?.startsWith(`-`)) {
|
|
870
|
-
let t3 = this.findOption(e3, r2);
|
|
871
|
-
t3 && !t3.isBoolean && (i2 = r2);
|
|
872
|
-
}
|
|
873
|
-
if (i2) {
|
|
874
|
-
let t3 = this.findOption(e3, i2);
|
|
875
|
-
if (t3?.handler) {
|
|
876
|
-
let n3 = [];
|
|
877
|
-
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions = n3;
|
|
878
|
-
}
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
if (n2.startsWith(`-`)) {
|
|
882
|
-
let t3 = n2.startsWith(`-`) && !n2.startsWith(`--`), r3 = n2.replace(/^-+/, ``);
|
|
883
|
-
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 });
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
findOption(e3, t2) {
|
|
887
|
-
let n2 = e3.options.get(t2);
|
|
888
|
-
if (n2 || (n2 = e3.options.get(t2.replace(/^-+/, ``)), n2)) return n2;
|
|
889
|
-
for (let [n3, r2] of e3.options) if (r2.alias && `-${r2.alias}` === t2) return r2;
|
|
890
|
-
}
|
|
891
|
-
handleCommandCompletion(e3, t2) {
|
|
892
|
-
let n2 = this.stripOptions(e3);
|
|
893
|
-
for (let [e4, r2] of this.commands) {
|
|
894
|
-
if (e4 === ``) continue;
|
|
895
|
-
let i2 = e4.split(` `);
|
|
896
|
-
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 });
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
handlePositionalCompletion(e3, t2) {
|
|
900
|
-
let n2 = e3.value.split(` `).length, r2 = Math.max(0, t2.length - n2), i2 = Array.from(e3.arguments.entries());
|
|
901
|
-
if (i2.length > 0) {
|
|
902
|
-
let t3;
|
|
903
|
-
if (r2 < i2.length) {
|
|
904
|
-
let [e4, n3] = i2[r2];
|
|
905
|
-
t3 = n3;
|
|
906
|
-
} else {
|
|
907
|
-
let e4 = i2[i2.length - 1][1];
|
|
908
|
-
e4.variadic && (t3 = e4);
|
|
909
|
-
}
|
|
910
|
-
if (t3 && t3.handler && typeof t3.handler == `function`) {
|
|
911
|
-
let n3 = [];
|
|
912
|
-
t3.handler.call(t3, (e4, t4) => n3.push({ value: e4, description: t4 }), e3.options), this.completions.push(...n3);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
complete(e3) {
|
|
917
|
-
this.directive = a.ShellCompDirectiveNoFileComp;
|
|
918
|
-
let t2 = /* @__PURE__ */ new Set();
|
|
919
|
-
this.completions.filter((e4) => t2.has(e4.value) ? false : (t2.add(e4.value), true)).filter((t3) => {
|
|
920
|
-
if (e3.includes(`=`)) {
|
|
921
|
-
let [, n2] = e3.split(`=`);
|
|
922
|
-
return t3.value.startsWith(n2);
|
|
923
|
-
}
|
|
924
|
-
return t3.value.startsWith(e3);
|
|
925
|
-
}).forEach((e4) => console.log(`${e4.value} ${e4.description ?? ``}`)), console.log(`:${this.directive}`);
|
|
926
|
-
}
|
|
927
|
-
parse(e3) {
|
|
928
|
-
this.completions = [];
|
|
929
|
-
let t2 = e3[e3.length - 1] === ``;
|
|
930
|
-
t2 && e3.pop();
|
|
931
|
-
let n2 = e3[e3.length - 1] || ``, r2 = e3.slice(0, -1);
|
|
932
|
-
t2 && (n2 !== `` && r2.push(n2), n2 = ``);
|
|
933
|
-
let [i2] = this.matchCommand(r2), a2 = r2[r2.length - 1];
|
|
934
|
-
if (this.shouldCompleteFlags(a2, n2)) this.handleFlagCompletion(i2, r2, n2, a2);
|
|
935
|
-
else {
|
|
936
|
-
if (a2?.startsWith(`-`) && n2 === `` && t2) {
|
|
937
|
-
let e4 = this.findOption(this, a2);
|
|
938
|
-
if (!e4) {
|
|
939
|
-
for (let [, t3] of this.commands) if (e4 = this.findOption(t3, a2), e4) break;
|
|
940
|
-
}
|
|
941
|
-
if (e4 && e4.isBoolean) {
|
|
942
|
-
this.complete(n2);
|
|
943
|
-
return;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
this.shouldCompleteCommands(n2) && this.handleCommandCompletion(r2, n2), i2 && i2.arguments.size > 0 && this.handlePositionalCompletion(i2, r2);
|
|
947
|
-
}
|
|
948
|
-
this.complete(n2);
|
|
949
|
-
}
|
|
950
|
-
setup(a2, o3, s3) {
|
|
951
|
-
switch (e__default.default(s3 === `zsh` || s3 === `bash` || s3 === `fish` || s3 === `powershell`, `Unsupported shell`), s3) {
|
|
952
|
-
case `zsh`: {
|
|
953
|
-
let e3 = t(a2, o3);
|
|
954
|
-
console.log(e3);
|
|
955
|
-
break;
|
|
956
|
-
}
|
|
957
|
-
case `bash`: {
|
|
958
|
-
let e3 = n(a2, o3);
|
|
959
|
-
console.log(e3);
|
|
960
|
-
break;
|
|
961
|
-
}
|
|
962
|
-
case `fish`: {
|
|
963
|
-
let e3 = r(a2, o3);
|
|
964
|
-
console.log(e3);
|
|
965
|
-
break;
|
|
966
|
-
}
|
|
967
|
-
case `powershell`: {
|
|
968
|
-
let e3 = i(a2, o3);
|
|
969
|
-
console.log(e3);
|
|
970
|
-
break;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
var u = new l();
|
|
976
|
-
var f = u;
|
|
977
|
-
|
|
978
|
-
// ../../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
|
|
979
|
-
function e2(e3 = `cli`) {
|
|
980
|
-
if (process.argv.indexOf(`--`) === -1) {
|
|
981
|
-
let t2 = `Error: You need to use -- to separate completion arguments.
|
|
982
|
-
Example: ${e3} complete -- <args>`;
|
|
983
|
-
console.error(t2), process.exit(1);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
// ../../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
|
|
988
|
-
var o2 = process.execPath;
|
|
989
|
-
var s2 = process.argv.slice(1);
|
|
990
|
-
var c2 = d(o2);
|
|
991
|
-
var l2 = s2.map(d);
|
|
992
|
-
var u2 = `${c2} ${process.execArgv.map(d).join(` `)} ${l2[0]}`;
|
|
993
|
-
function d(e3) {
|
|
994
|
-
return e3.includes(` `) ? `'${e3}'` : e3;
|
|
995
|
-
}
|
|
996
|
-
function f2(o3) {
|
|
997
|
-
let s3 = o3.name();
|
|
998
|
-
p(o3), m(o3), o3.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async (r2) => {
|
|
999
|
-
switch (r2) {
|
|
1000
|
-
case `zsh`: {
|
|
1001
|
-
let e3 = t(s3, u2);
|
|
1002
|
-
console.log(e3);
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
case `bash`: {
|
|
1006
|
-
let e3 = n(s3, u2);
|
|
1007
|
-
console.log(e3);
|
|
1008
|
-
break;
|
|
1009
|
-
}
|
|
1010
|
-
case `fish`: {
|
|
1011
|
-
let e3 = r(s3, u2);
|
|
1012
|
-
console.log(e3);
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
case `powershell`: {
|
|
1016
|
-
let t2 = i(s3, u2);
|
|
1017
|
-
console.log(t2);
|
|
1018
|
-
break;
|
|
1019
|
-
}
|
|
1020
|
-
case `debug`: {
|
|
1021
|
-
let e3 = /* @__PURE__ */ new Map();
|
|
1022
|
-
h(o3, ``, e3), console.log(`Collected commands:`);
|
|
1023
|
-
for (let [t2, n2] of e3.entries()) console.log(`- ${t2 || `<root>`}: ${n2.description() || `No description`}`);
|
|
1024
|
-
break;
|
|
1025
|
-
}
|
|
1026
|
-
default:
|
|
1027
|
-
console.error(`Unknown shell: ${r2}`), console.error(`Supported shells: zsh, bash, fish, powershell`), process.exit(1);
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
let c3 = o3.parse.bind(o3);
|
|
1031
|
-
return o3.parse = function(e3, t2) {
|
|
1032
|
-
let n2 = e3 || process.argv, i2 = n2.findIndex((e4) => e4 === `complete`), l3 = n2.findIndex((e4) => e4 === `--`);
|
|
1033
|
-
if (i2 !== -1 && l3 !== -1 && l3 > i2) {
|
|
1034
|
-
let e4 = n2.slice(l3 + 1);
|
|
1035
|
-
return e2(s3), f.parse(e4), o3;
|
|
1036
|
-
}
|
|
1037
|
-
return c3(e3, t2);
|
|
1038
|
-
}, f;
|
|
1039
|
-
}
|
|
1040
|
-
function p(e3) {
|
|
1041
|
-
for (let t2 of e3.options) {
|
|
1042
|
-
let e4 = t2.flags, n2 = e4.match(/^-([a-zA-Z]), --/)?.[1], i2 = e4.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1043
|
-
i2 && (n2 ? f.option(i2, t2.description || ``, n2) : f.option(i2, t2.description || ``));
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
function m(e3) {
|
|
1047
|
-
let t2 = /* @__PURE__ */ new Map();
|
|
1048
|
-
h(e3, ``, t2);
|
|
1049
|
-
for (let [e4, n2] of t2.entries()) {
|
|
1050
|
-
if (e4 === ``) continue;
|
|
1051
|
-
let t3 = f.command(e4, n2.description() || ``);
|
|
1052
|
-
for (let e5 of n2.options) {
|
|
1053
|
-
let n3 = e5.flags, r2 = n3.match(/^-([a-zA-Z]), --/)?.[1], i2 = n3.match(/--([a-zA-Z0-9-]+)/)?.[1];
|
|
1054
|
-
i2 && (r2 ? t3.option(i2, e5.description || ``, r2) : t3.option(i2, e5.description || ``));
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
function h(e3, t2, n2) {
|
|
1059
|
-
n2.set(t2, e3);
|
|
1060
|
-
for (let r2 of e3.commands) r2.name() !== `complete` && h(r2, t2 ? `${t2} ${r2.name()}` : r2.name(), n2);
|
|
1061
|
-
}
|
|
1062
30
|
|
|
1063
31
|
// src/utils/templates.ts
|
|
1064
32
|
var AGENTS = [
|
|
@@ -1081,9 +49,6 @@ var AGENT_NAMES = {
|
|
|
1081
49
|
ami: "Ami",
|
|
1082
50
|
"visual-edit": "Visual Edit"
|
|
1083
51
|
};
|
|
1084
|
-
AGENTS.filter((agent) => agent !== "ami").map(
|
|
1085
|
-
(agent) => `@react-grab/${agent}`
|
|
1086
|
-
);
|
|
1087
52
|
var NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" && (
|
|
1088
53
|
<Script
|
|
1089
54
|
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
@@ -2746,7 +1711,7 @@ ${BOLD}File: ${filePath}${RESET}`);
|
|
|
2746
1711
|
console.log(formatDiff(diff));
|
|
2747
1712
|
console.log("\u2500".repeat(60));
|
|
2748
1713
|
};
|
|
2749
|
-
var VERSION = "0.1.0-beta.
|
|
1714
|
+
var VERSION = "0.1.0-beta.7";
|
|
2750
1715
|
var configureMcp = (mcpClient, cwd, customPkg) => {
|
|
2751
1716
|
const mcpCommand = customPkg ? `npx -y ${customPkg} browser mcp` : `npx -y @react-grab/cli browser mcp`;
|
|
2752
1717
|
const mcpSpinner = spinner(`Installing MCP server for ${MCP_CLIENT_NAMES[mcpClient]}`).start();
|
|
@@ -2849,7 +1814,7 @@ var add = new commander.Command().name("add").alias("install").description("add
|
|
|
2849
1814
|
if (clientArg && !selectedAgent) {
|
|
2850
1815
|
logger.break();
|
|
2851
1816
|
logger.error(`Invalid skill agent: ${clientArg}`);
|
|
2852
|
-
logger.error(`Available agents: ${SKILL_AGENTS.map((
|
|
1817
|
+
logger.error(`Available agents: ${SKILL_AGENTS.map((a) => a.id).join(", ")}`);
|
|
2853
1818
|
logger.break();
|
|
2854
1819
|
process.exit(1);
|
|
2855
1820
|
}
|
|
@@ -2857,7 +1822,7 @@ var add = new commander.Command().name("add").alias("install").description("add
|
|
|
2857
1822
|
if (detectedAgents.length === 0) {
|
|
2858
1823
|
logger.break();
|
|
2859
1824
|
logger.warn("No supported agent folders detected.");
|
|
2860
|
-
logger.log("Supported agents: " + SKILL_AGENTS.map((
|
|
1825
|
+
logger.log("Supported agents: " + SKILL_AGENTS.map((a) => a.id).join(", "));
|
|
2861
1826
|
logger.break();
|
|
2862
1827
|
process.exit(0);
|
|
2863
1828
|
}
|
|
@@ -2883,7 +1848,7 @@ var add = new commander.Command().name("add").alias("install").description("add
|
|
|
2883
1848
|
if (!selectedAgent) {
|
|
2884
1849
|
logger.break();
|
|
2885
1850
|
logger.error("Please specify an agent with --client");
|
|
2886
|
-
logger.error(`Available agents: ${SKILL_AGENTS.map((
|
|
1851
|
+
logger.error(`Available agents: ${SKILL_AGENTS.map((a) => a.id).join(", ")}`);
|
|
2887
1852
|
logger.break();
|
|
2888
1853
|
process.exit(1);
|
|
2889
1854
|
}
|
|
@@ -2938,7 +1903,7 @@ var add = new commander.Command().name("add").alias("install").description("add
|
|
|
2938
1903
|
if (detectedAgents.length === 0) {
|
|
2939
1904
|
logger.break();
|
|
2940
1905
|
logger.warn("No supported agent folders detected.");
|
|
2941
|
-
logger.log("Supported agents: " + SKILL_AGENTS.map((
|
|
1906
|
+
logger.log("Supported agents: " + SKILL_AGENTS.map((a) => a.id).join(", "));
|
|
2942
1907
|
logger.break();
|
|
2943
1908
|
process.exit(0);
|
|
2944
1909
|
}
|
|
@@ -3504,7 +2469,7 @@ var createComponentHelper = (getActivePage2) => {
|
|
|
3504
2469
|
return single?.element || null;
|
|
3505
2470
|
}
|
|
3506
2471
|
const arr = result;
|
|
3507
|
-
return arr.map((
|
|
2472
|
+
return arr.map((m) => m.element);
|
|
3508
2473
|
},
|
|
3509
2474
|
{ name: componentName, nth }
|
|
3510
2475
|
);
|
|
@@ -4257,8 +3222,8 @@ function $constructor(name, initializer3, params) {
|
|
|
4257
3222
|
initializer3(inst, def);
|
|
4258
3223
|
const proto = _.prototype;
|
|
4259
3224
|
const keys = Object.keys(proto);
|
|
4260
|
-
for (let
|
|
4261
|
-
const k = keys[
|
|
3225
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3226
|
+
const k = keys[i];
|
|
4262
3227
|
if (!(k in inst)) {
|
|
4263
3228
|
inst[k] = proto[k].bind(inst);
|
|
4264
3229
|
}
|
|
@@ -4489,8 +3454,8 @@ function promiseAllObject(promisesObj) {
|
|
|
4489
3454
|
const promises = keys.map((key) => promisesObj[key]);
|
|
4490
3455
|
return Promise.all(promises).then((results) => {
|
|
4491
3456
|
const resolvedObj = {};
|
|
4492
|
-
for (let
|
|
4493
|
-
resolvedObj[keys[
|
|
3457
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3458
|
+
resolvedObj[keys[i]] = results[i];
|
|
4494
3459
|
}
|
|
4495
3460
|
return resolvedObj;
|
|
4496
3461
|
});
|
|
@@ -4498,7 +3463,7 @@ function promiseAllObject(promisesObj) {
|
|
|
4498
3463
|
function randomString(length = 10) {
|
|
4499
3464
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
4500
3465
|
let str = "";
|
|
4501
|
-
for (let
|
|
3466
|
+
for (let i = 0; i < length; i++) {
|
|
4502
3467
|
str += chars[Math.floor(Math.random() * chars.length)];
|
|
4503
3468
|
}
|
|
4504
3469
|
return str;
|
|
@@ -4526,10 +3491,10 @@ var allowsEval = cached(() => {
|
|
|
4526
3491
|
return false;
|
|
4527
3492
|
}
|
|
4528
3493
|
});
|
|
4529
|
-
function isPlainObject(
|
|
4530
|
-
if (isObject(
|
|
3494
|
+
function isPlainObject(o) {
|
|
3495
|
+
if (isObject(o) === false)
|
|
4531
3496
|
return false;
|
|
4532
|
-
const ctor =
|
|
3497
|
+
const ctor = o.constructor;
|
|
4533
3498
|
if (ctor === void 0)
|
|
4534
3499
|
return true;
|
|
4535
3500
|
if (typeof ctor !== "function")
|
|
@@ -4542,12 +3507,12 @@ function isPlainObject(o3) {
|
|
|
4542
3507
|
}
|
|
4543
3508
|
return true;
|
|
4544
3509
|
}
|
|
4545
|
-
function shallowClone(
|
|
4546
|
-
if (isPlainObject(
|
|
4547
|
-
return { ...
|
|
4548
|
-
if (Array.isArray(
|
|
4549
|
-
return [...
|
|
4550
|
-
return
|
|
3510
|
+
function shallowClone(o) {
|
|
3511
|
+
if (isPlainObject(o))
|
|
3512
|
+
return { ...o };
|
|
3513
|
+
if (Array.isArray(o))
|
|
3514
|
+
return [...o];
|
|
3515
|
+
return o;
|
|
4551
3516
|
}
|
|
4552
3517
|
function numKeys(data) {
|
|
4553
3518
|
let keyCount = 0;
|
|
@@ -4559,8 +3524,8 @@ function numKeys(data) {
|
|
|
4559
3524
|
return keyCount;
|
|
4560
3525
|
}
|
|
4561
3526
|
var getParsedType = (data) => {
|
|
4562
|
-
const
|
|
4563
|
-
switch (
|
|
3527
|
+
const t = typeof data;
|
|
3528
|
+
switch (t) {
|
|
4564
3529
|
case "undefined":
|
|
4565
3530
|
return "undefined";
|
|
4566
3531
|
case "string":
|
|
@@ -4599,7 +3564,7 @@ var getParsedType = (data) => {
|
|
|
4599
3564
|
}
|
|
4600
3565
|
return "object";
|
|
4601
3566
|
default:
|
|
4602
|
-
throw new Error(`Unknown data type: ${
|
|
3567
|
+
throw new Error(`Unknown data type: ${t}`);
|
|
4603
3568
|
}
|
|
4604
3569
|
};
|
|
4605
3570
|
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -4771,10 +3736,10 @@ function safeExtend(schema, shape) {
|
|
|
4771
3736
|
});
|
|
4772
3737
|
return clone(schema, def);
|
|
4773
3738
|
}
|
|
4774
|
-
function merge(
|
|
4775
|
-
const def = mergeDefs(
|
|
3739
|
+
function merge(a, b) {
|
|
3740
|
+
const def = mergeDefs(a._zod.def, {
|
|
4776
3741
|
get shape() {
|
|
4777
|
-
const _shape = { ...
|
|
3742
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
4778
3743
|
assignProp(this, "shape", _shape);
|
|
4779
3744
|
return _shape;
|
|
4780
3745
|
},
|
|
@@ -4784,7 +3749,7 @@ function merge(a2, b) {
|
|
|
4784
3749
|
checks: []
|
|
4785
3750
|
// delete existing checks
|
|
4786
3751
|
});
|
|
4787
|
-
return clone(
|
|
3752
|
+
return clone(a, def);
|
|
4788
3753
|
}
|
|
4789
3754
|
function partial(Class2, schema, mask) {
|
|
4790
3755
|
const currDef = schema._zod.def;
|
|
@@ -4858,8 +3823,8 @@ function required(Class2, schema, mask) {
|
|
|
4858
3823
|
function aborted(x, startIndex = 0) {
|
|
4859
3824
|
if (x.aborted === true)
|
|
4860
3825
|
return true;
|
|
4861
|
-
for (let
|
|
4862
|
-
if (x.issues[
|
|
3826
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
3827
|
+
if (x.issues[i]?.continue !== true) {
|
|
4863
3828
|
return true;
|
|
4864
3829
|
}
|
|
4865
3830
|
}
|
|
@@ -4906,8 +3871,8 @@ function getLengthableOrigin(input) {
|
|
|
4906
3871
|
return "unknown";
|
|
4907
3872
|
}
|
|
4908
3873
|
function parsedType(data) {
|
|
4909
|
-
const
|
|
4910
|
-
switch (
|
|
3874
|
+
const t = typeof data;
|
|
3875
|
+
switch (t) {
|
|
4911
3876
|
case "number": {
|
|
4912
3877
|
return Number.isNaN(data) ? "nan" : "number";
|
|
4913
3878
|
}
|
|
@@ -4924,7 +3889,7 @@ function parsedType(data) {
|
|
|
4924
3889
|
}
|
|
4925
3890
|
}
|
|
4926
3891
|
}
|
|
4927
|
-
return
|
|
3892
|
+
return t;
|
|
4928
3893
|
}
|
|
4929
3894
|
function issue(...args) {
|
|
4930
3895
|
const [iss, input, inst] = args;
|
|
@@ -4946,15 +3911,15 @@ function cleanEnum(obj) {
|
|
|
4946
3911
|
function base64ToUint8Array(base643) {
|
|
4947
3912
|
const binaryString = atob(base643);
|
|
4948
3913
|
const bytes = new Uint8Array(binaryString.length);
|
|
4949
|
-
for (let
|
|
4950
|
-
bytes[
|
|
3914
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
3915
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
4951
3916
|
}
|
|
4952
3917
|
return bytes;
|
|
4953
3918
|
}
|
|
4954
3919
|
function uint8ArrayToBase64(bytes) {
|
|
4955
3920
|
let binaryString = "";
|
|
4956
|
-
for (let
|
|
4957
|
-
binaryString += String.fromCharCode(bytes[
|
|
3921
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3922
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
4958
3923
|
}
|
|
4959
3924
|
return btoa(binaryString);
|
|
4960
3925
|
}
|
|
@@ -4972,8 +3937,8 @@ function hexToUint8Array(hex3) {
|
|
|
4972
3937
|
throw new Error("Invalid hex string length");
|
|
4973
3938
|
}
|
|
4974
3939
|
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
4975
|
-
for (let
|
|
4976
|
-
bytes[
|
|
3940
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
3941
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
4977
3942
|
}
|
|
4978
3943
|
return bytes;
|
|
4979
3944
|
}
|
|
@@ -5031,10 +3996,10 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5031
3996
|
fieldErrors._errors.push(mapper(issue2));
|
|
5032
3997
|
} else {
|
|
5033
3998
|
let curr = fieldErrors;
|
|
5034
|
-
let
|
|
5035
|
-
while (
|
|
5036
|
-
const el = issue2.path[
|
|
5037
|
-
const terminal =
|
|
3999
|
+
let i = 0;
|
|
4000
|
+
while (i < issue2.path.length) {
|
|
4001
|
+
const el = issue2.path[i];
|
|
4002
|
+
const terminal = i === issue2.path.length - 1;
|
|
5038
4003
|
if (!terminal) {
|
|
5039
4004
|
curr[el] = curr[el] || { _errors: [] };
|
|
5040
4005
|
} else {
|
|
@@ -5042,7 +4007,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5042
4007
|
curr[el]._errors.push(mapper(issue2));
|
|
5043
4008
|
}
|
|
5044
4009
|
curr = curr[el];
|
|
5045
|
-
|
|
4010
|
+
i++;
|
|
5046
4011
|
}
|
|
5047
4012
|
}
|
|
5048
4013
|
}
|
|
@@ -5068,10 +4033,10 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5068
4033
|
continue;
|
|
5069
4034
|
}
|
|
5070
4035
|
let curr = result;
|
|
5071
|
-
let
|
|
5072
|
-
while (
|
|
5073
|
-
const el = fullpath[
|
|
5074
|
-
const terminal =
|
|
4036
|
+
let i = 0;
|
|
4037
|
+
while (i < fullpath.length) {
|
|
4038
|
+
const el = fullpath[i];
|
|
4039
|
+
const terminal = i === fullpath.length - 1;
|
|
5075
4040
|
if (typeof el === "string") {
|
|
5076
4041
|
curr.properties ?? (curr.properties = {});
|
|
5077
4042
|
(_a2 = curr.properties)[el] ?? (_a2[el] = { errors: [] });
|
|
@@ -5084,7 +4049,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5084
4049
|
if (terminal) {
|
|
5085
4050
|
curr.errors.push(mapper(issue2));
|
|
5086
4051
|
}
|
|
5087
|
-
|
|
4052
|
+
i++;
|
|
5088
4053
|
}
|
|
5089
4054
|
}
|
|
5090
4055
|
}
|
|
@@ -5112,7 +4077,7 @@ function toDotPath(_path) {
|
|
|
5112
4077
|
}
|
|
5113
4078
|
function prettifyError(error48) {
|
|
5114
4079
|
const lines = [];
|
|
5115
|
-
const issues = [...error48.issues].sort((
|
|
4080
|
+
const issues = [...error48.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
5116
4081
|
for (const issue2 of issues) {
|
|
5117
4082
|
lines.push(`\u2716 ${issue2.message}`);
|
|
5118
4083
|
if (issue2.path?.length)
|
|
@@ -5129,9 +4094,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
5129
4094
|
throw new $ZodAsyncError();
|
|
5130
4095
|
}
|
|
5131
4096
|
if (result.issues.length) {
|
|
5132
|
-
const
|
|
5133
|
-
captureStackTrace(
|
|
5134
|
-
throw
|
|
4097
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
4098
|
+
captureStackTrace(e, _params?.callee);
|
|
4099
|
+
throw e;
|
|
5135
4100
|
}
|
|
5136
4101
|
return result.value;
|
|
5137
4102
|
};
|
|
@@ -5142,9 +4107,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
5142
4107
|
if (result instanceof Promise)
|
|
5143
4108
|
result = await result;
|
|
5144
4109
|
if (result.issues.length) {
|
|
5145
|
-
const
|
|
5146
|
-
captureStackTrace(
|
|
5147
|
-
throw
|
|
4110
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
4111
|
+
captureStackTrace(e, params?.callee);
|
|
4112
|
+
throw e;
|
|
5148
4113
|
}
|
|
5149
4114
|
return result.value;
|
|
5150
4115
|
};
|
|
@@ -6057,10 +5022,10 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
6057
5022
|
defineLazy(inst, "~standard", () => ({
|
|
6058
5023
|
validate: (value) => {
|
|
6059
5024
|
try {
|
|
6060
|
-
const
|
|
6061
|
-
return
|
|
5025
|
+
const r = safeParse(inst, value);
|
|
5026
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
6062
5027
|
} catch (_) {
|
|
6063
|
-
return safeParseAsync(inst, value).then((
|
|
5028
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
6064
5029
|
}
|
|
6065
5030
|
},
|
|
6066
5031
|
vendor: "zod",
|
|
@@ -6305,7 +5270,7 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
6305
5270
|
function isValidBase64URL(data) {
|
|
6306
5271
|
if (!base64url.test(data))
|
|
6307
5272
|
return false;
|
|
6308
|
-
const base643 = data.replace(/[-_]/g, (
|
|
5273
|
+
const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
6309
5274
|
const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
|
|
6310
5275
|
return isValidBase64(padded);
|
|
6311
5276
|
}
|
|
@@ -6581,16 +5546,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
6581
5546
|
}
|
|
6582
5547
|
payload.value = Array(input.length);
|
|
6583
5548
|
const proms = [];
|
|
6584
|
-
for (let
|
|
6585
|
-
const item = input[
|
|
5549
|
+
for (let i = 0; i < input.length; i++) {
|
|
5550
|
+
const item = input[i];
|
|
6586
5551
|
const result = def.element._zod.run({
|
|
6587
5552
|
value: item,
|
|
6588
5553
|
issues: []
|
|
6589
5554
|
}, ctx);
|
|
6590
5555
|
if (result instanceof Promise) {
|
|
6591
|
-
proms.push(result.then((result2) => handleArrayResult(result2, payload,
|
|
5556
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
6592
5557
|
} else {
|
|
6593
|
-
handleArrayResult(result, payload,
|
|
5558
|
+
handleArrayResult(result, payload, i);
|
|
6594
5559
|
}
|
|
6595
5560
|
}
|
|
6596
5561
|
if (proms.length) {
|
|
@@ -6634,20 +5599,20 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
6634
5599
|
const unrecognized = [];
|
|
6635
5600
|
const keySet = def.keySet;
|
|
6636
5601
|
const _catchall = def.catchall._zod;
|
|
6637
|
-
const
|
|
5602
|
+
const t = _catchall.def.type;
|
|
6638
5603
|
const isOptionalOut = _catchall.optout === "optional";
|
|
6639
5604
|
for (const key in input) {
|
|
6640
5605
|
if (keySet.has(key))
|
|
6641
5606
|
continue;
|
|
6642
|
-
if (
|
|
5607
|
+
if (t === "never") {
|
|
6643
5608
|
unrecognized.push(key);
|
|
6644
5609
|
continue;
|
|
6645
5610
|
}
|
|
6646
|
-
const
|
|
6647
|
-
if (
|
|
6648
|
-
proms.push(
|
|
5611
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
5612
|
+
if (r instanceof Promise) {
|
|
5613
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
6649
5614
|
} else {
|
|
6650
|
-
handlePropertyResult(
|
|
5615
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
6651
5616
|
}
|
|
6652
5617
|
}
|
|
6653
5618
|
if (unrecognized.length) {
|
|
@@ -6714,11 +5679,11 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
6714
5679
|
for (const key of value.keys) {
|
|
6715
5680
|
const el = shape[key];
|
|
6716
5681
|
const isOptionalOut = el._zod.optout === "optional";
|
|
6717
|
-
const
|
|
6718
|
-
if (
|
|
6719
|
-
proms.push(
|
|
5682
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
5683
|
+
if (r instanceof Promise) {
|
|
5684
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
6720
5685
|
} else {
|
|
6721
|
-
handlePropertyResult(
|
|
5686
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
6722
5687
|
}
|
|
6723
5688
|
}
|
|
6724
5689
|
if (!catchall) {
|
|
@@ -6833,7 +5798,7 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
6833
5798
|
return final;
|
|
6834
5799
|
}
|
|
6835
5800
|
}
|
|
6836
|
-
const nonaborted = results.filter((
|
|
5801
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
6837
5802
|
if (nonaborted.length === 1) {
|
|
6838
5803
|
final.value = nonaborted[0].value;
|
|
6839
5804
|
return nonaborted[0];
|
|
@@ -6848,18 +5813,18 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
6848
5813
|
}
|
|
6849
5814
|
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
6850
5815
|
$ZodType.init(inst, def);
|
|
6851
|
-
defineLazy(inst._zod, "optin", () => def.options.some((
|
|
6852
|
-
defineLazy(inst._zod, "optout", () => def.options.some((
|
|
5816
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
5817
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
6853
5818
|
defineLazy(inst._zod, "values", () => {
|
|
6854
|
-
if (def.options.every((
|
|
5819
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
6855
5820
|
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
6856
5821
|
}
|
|
6857
5822
|
return void 0;
|
|
6858
5823
|
});
|
|
6859
5824
|
defineLazy(inst._zod, "pattern", () => {
|
|
6860
|
-
if (def.options.every((
|
|
6861
|
-
const patterns = def.options.map((
|
|
6862
|
-
return new RegExp(`^(${patterns.map((
|
|
5825
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
5826
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
5827
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
6863
5828
|
}
|
|
6864
5829
|
return void 0;
|
|
6865
5830
|
});
|
|
@@ -6893,7 +5858,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
6893
5858
|
};
|
|
6894
5859
|
});
|
|
6895
5860
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
6896
|
-
const successes = results.filter((
|
|
5861
|
+
const successes = results.filter((r) => r.issues.length === 0);
|
|
6897
5862
|
if (successes.length === 1) {
|
|
6898
5863
|
final.value = successes[0].value;
|
|
6899
5864
|
return final;
|
|
@@ -6969,15 +5934,15 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
6969
5934
|
const disc = cached(() => {
|
|
6970
5935
|
const opts2 = def.options;
|
|
6971
5936
|
const map2 = /* @__PURE__ */ new Map();
|
|
6972
|
-
for (const
|
|
6973
|
-
const values =
|
|
5937
|
+
for (const o of opts2) {
|
|
5938
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
6974
5939
|
if (!values || values.size === 0)
|
|
6975
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(
|
|
5940
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
6976
5941
|
for (const v of values) {
|
|
6977
5942
|
if (map2.has(v)) {
|
|
6978
5943
|
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
6979
5944
|
}
|
|
6980
|
-
map2.set(v,
|
|
5945
|
+
map2.set(v, o);
|
|
6981
5946
|
}
|
|
6982
5947
|
}
|
|
6983
5948
|
return map2;
|
|
@@ -7027,19 +5992,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
|
|
|
7027
5992
|
return handleIntersectionResults(payload, left, right);
|
|
7028
5993
|
};
|
|
7029
5994
|
});
|
|
7030
|
-
function mergeValues(
|
|
7031
|
-
if (
|
|
7032
|
-
return { valid: true, data:
|
|
5995
|
+
function mergeValues(a, b) {
|
|
5996
|
+
if (a === b) {
|
|
5997
|
+
return { valid: true, data: a };
|
|
7033
5998
|
}
|
|
7034
|
-
if (
|
|
7035
|
-
return { valid: true, data:
|
|
5999
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
6000
|
+
return { valid: true, data: a };
|
|
7036
6001
|
}
|
|
7037
|
-
if (isPlainObject(
|
|
6002
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
7038
6003
|
const bKeys = Object.keys(b);
|
|
7039
|
-
const sharedKeys = Object.keys(
|
|
7040
|
-
const newObj = { ...
|
|
6004
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
6005
|
+
const newObj = { ...a, ...b };
|
|
7041
6006
|
for (const key of sharedKeys) {
|
|
7042
|
-
const sharedValue = mergeValues(
|
|
6007
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
7043
6008
|
if (!sharedValue.valid) {
|
|
7044
6009
|
return {
|
|
7045
6010
|
valid: false,
|
|
@@ -7050,13 +6015,13 @@ function mergeValues(a2, b) {
|
|
|
7050
6015
|
}
|
|
7051
6016
|
return { valid: true, data: newObj };
|
|
7052
6017
|
}
|
|
7053
|
-
if (Array.isArray(
|
|
7054
|
-
if (
|
|
6018
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
6019
|
+
if (a.length !== b.length) {
|
|
7055
6020
|
return { valid: false, mergeErrorPath: [] };
|
|
7056
6021
|
}
|
|
7057
6022
|
const newArray = [];
|
|
7058
|
-
for (let index = 0; index <
|
|
7059
|
-
const itemA =
|
|
6023
|
+
for (let index = 0; index < a.length; index++) {
|
|
6024
|
+
const itemA = a[index];
|
|
7060
6025
|
const itemB = b[index];
|
|
7061
6026
|
const sharedValue = mergeValues(itemA, itemB);
|
|
7062
6027
|
if (!sharedValue.valid) {
|
|
@@ -7097,7 +6062,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
7097
6062
|
result.issues.push(iss);
|
|
7098
6063
|
}
|
|
7099
6064
|
}
|
|
7100
|
-
const bothKeys = [...unrecKeys].filter(([,
|
|
6065
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
7101
6066
|
if (bothKeys.length && unrecIssue) {
|
|
7102
6067
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
7103
6068
|
}
|
|
@@ -7141,35 +6106,35 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
7141
6106
|
return payload;
|
|
7142
6107
|
}
|
|
7143
6108
|
}
|
|
7144
|
-
let
|
|
6109
|
+
let i = -1;
|
|
7145
6110
|
for (const item of items) {
|
|
7146
|
-
|
|
7147
|
-
if (
|
|
7148
|
-
if (
|
|
6111
|
+
i++;
|
|
6112
|
+
if (i >= input.length) {
|
|
6113
|
+
if (i >= optStart)
|
|
7149
6114
|
continue;
|
|
7150
6115
|
}
|
|
7151
6116
|
const result = item._zod.run({
|
|
7152
|
-
value: input[
|
|
6117
|
+
value: input[i],
|
|
7153
6118
|
issues: []
|
|
7154
6119
|
}, ctx);
|
|
7155
6120
|
if (result instanceof Promise) {
|
|
7156
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
6121
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
7157
6122
|
} else {
|
|
7158
|
-
handleTupleResult(result, payload,
|
|
6123
|
+
handleTupleResult(result, payload, i);
|
|
7159
6124
|
}
|
|
7160
6125
|
}
|
|
7161
6126
|
if (def.rest) {
|
|
7162
6127
|
const rest = input.slice(items.length);
|
|
7163
6128
|
for (const el of rest) {
|
|
7164
|
-
|
|
6129
|
+
i++;
|
|
7165
6130
|
const result = def.rest._zod.run({
|
|
7166
6131
|
value: el,
|
|
7167
6132
|
issues: []
|
|
7168
6133
|
}, ctx);
|
|
7169
6134
|
if (result instanceof Promise) {
|
|
7170
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
6135
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
7171
6136
|
} else {
|
|
7172
|
-
handleTupleResult(result, payload,
|
|
6137
|
+
handleTupleResult(result, payload, i);
|
|
7173
6138
|
}
|
|
7174
6139
|
}
|
|
7175
6140
|
}
|
|
@@ -7391,7 +6356,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
7391
6356
|
const values = getEnumValues(def.entries);
|
|
7392
6357
|
const valuesSet = new Set(values);
|
|
7393
6358
|
inst._zod.values = valuesSet;
|
|
7394
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((
|
|
6359
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
7395
6360
|
inst._zod.parse = (payload, _ctx) => {
|
|
7396
6361
|
const input = payload.value;
|
|
7397
6362
|
if (valuesSet.has(input)) {
|
|
@@ -7413,7 +6378,7 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
7413
6378
|
}
|
|
7414
6379
|
const values = new Set(def.values);
|
|
7415
6380
|
inst._zod.values = values;
|
|
7416
|
-
inst._zod.pattern = new RegExp(`^(${def.values.map((
|
|
6381
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
7417
6382
|
inst._zod.parse = (payload, _ctx) => {
|
|
7418
6383
|
const input = payload.value;
|
|
7419
6384
|
if (values.has(input)) {
|
|
@@ -7485,7 +6450,7 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
7485
6450
|
if (def.innerType._zod.optin === "optional") {
|
|
7486
6451
|
const result = def.innerType._zod.run(payload, ctx);
|
|
7487
6452
|
if (result instanceof Promise)
|
|
7488
|
-
return result.then((
|
|
6453
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
7489
6454
|
return handleOptionalResult(result, payload.value);
|
|
7490
6455
|
}
|
|
7491
6456
|
if (payload.value === void 0) {
|
|
@@ -7902,11 +6867,11 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
7902
6867
|
};
|
|
7903
6868
|
inst._zod.check = (payload) => {
|
|
7904
6869
|
const input = payload.value;
|
|
7905
|
-
const
|
|
7906
|
-
if (
|
|
7907
|
-
return
|
|
6870
|
+
const r = def.fn(input);
|
|
6871
|
+
if (r instanceof Promise) {
|
|
6872
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
7908
6873
|
}
|
|
7909
|
-
handleRefineResult(
|
|
6874
|
+
handleRefineResult(r, payload, input, inst);
|
|
7910
6875
|
return;
|
|
7911
6876
|
};
|
|
7912
6877
|
});
|
|
@@ -9746,17 +8711,17 @@ var error16 = () => {
|
|
|
9746
8711
|
number: { unit: "", shortLabel: "\u05E7\u05D8\u05DF", longLabel: "\u05D2\u05D3\u05D5\u05DC" }
|
|
9747
8712
|
// no unit
|
|
9748
8713
|
};
|
|
9749
|
-
const typeEntry = (
|
|
9750
|
-
const typeLabel = (
|
|
9751
|
-
const
|
|
9752
|
-
if (
|
|
9753
|
-
return
|
|
9754
|
-
return
|
|
9755
|
-
};
|
|
9756
|
-
const withDefinite = (
|
|
9757
|
-
const verbFor = (
|
|
9758
|
-
const
|
|
9759
|
-
const gender =
|
|
8714
|
+
const typeEntry = (t) => t ? TypeNames[t] : void 0;
|
|
8715
|
+
const typeLabel = (t) => {
|
|
8716
|
+
const e = typeEntry(t);
|
|
8717
|
+
if (e)
|
|
8718
|
+
return e.label;
|
|
8719
|
+
return t ?? TypeNames.unknown.label;
|
|
8720
|
+
};
|
|
8721
|
+
const withDefinite = (t) => `\u05D4${typeLabel(t)}`;
|
|
8722
|
+
const verbFor = (t) => {
|
|
8723
|
+
const e = typeEntry(t);
|
|
8724
|
+
const gender = e?.gender ?? "m";
|
|
9760
8725
|
return gender === "f" ? "\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA" : "\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA";
|
|
9761
8726
|
};
|
|
9762
8727
|
const getSizing = (origin) => {
|
|
@@ -13536,12 +12501,12 @@ var $ZodRegistry = class {
|
|
|
13536
12501
|
return this;
|
|
13537
12502
|
}
|
|
13538
12503
|
get(schema) {
|
|
13539
|
-
const
|
|
13540
|
-
if (
|
|
13541
|
-
const pm = { ...this.get(
|
|
12504
|
+
const p = schema._zod.parent;
|
|
12505
|
+
if (p) {
|
|
12506
|
+
const pm = { ...this.get(p) ?? {} };
|
|
13542
12507
|
delete pm.id;
|
|
13543
|
-
const
|
|
13544
|
-
return Object.keys(
|
|
12508
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
12509
|
+
return Object.keys(f).length ? f : void 0;
|
|
13545
12510
|
}
|
|
13546
12511
|
return this._map.get(schema);
|
|
13547
12512
|
}
|
|
@@ -15150,7 +14115,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
15150
14115
|
Object.assign(_json, file2);
|
|
15151
14116
|
} else {
|
|
15152
14117
|
Object.assign(_json, file2);
|
|
15153
|
-
_json.anyOf = mime.map((
|
|
14118
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
15154
14119
|
}
|
|
15155
14120
|
} else {
|
|
15156
14121
|
Object.assign(_json, file2);
|
|
@@ -15234,9 +14199,9 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
15234
14199
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
15235
14200
|
const def = schema._zod.def;
|
|
15236
14201
|
const isExclusive = def.inclusive === false;
|
|
15237
|
-
const options2 = def.options.map((x,
|
|
14202
|
+
const options2 = def.options.map((x, i) => process2(x, ctx, {
|
|
15238
14203
|
...params,
|
|
15239
|
-
path: [...params.path, isExclusive ? "oneOf" : "anyOf",
|
|
14204
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
15240
14205
|
}));
|
|
15241
14206
|
if (isExclusive) {
|
|
15242
14207
|
json2.oneOf = options2;
|
|
@@ -15246,7 +14211,7 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
15246
14211
|
};
|
|
15247
14212
|
var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
15248
14213
|
const def = schema._zod.def;
|
|
15249
|
-
const
|
|
14214
|
+
const a = process2(def.left, ctx, {
|
|
15250
14215
|
...params,
|
|
15251
14216
|
path: [...params.path, "allOf", 0]
|
|
15252
14217
|
});
|
|
@@ -15256,7 +14221,7 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
15256
14221
|
});
|
|
15257
14222
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
15258
14223
|
const allOf = [
|
|
15259
|
-
...isSimpleIntersection(
|
|
14224
|
+
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
15260
14225
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
15261
14226
|
];
|
|
15262
14227
|
json2.allOf = allOf;
|
|
@@ -15267,9 +14232,9 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
15267
14232
|
json2.type = "array";
|
|
15268
14233
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
15269
14234
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
15270
|
-
const prefixItems = def.items.map((x,
|
|
14235
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
15271
14236
|
...params,
|
|
15272
|
-
path: [...params.path, prefixPath,
|
|
14237
|
+
path: [...params.path, prefixPath, i]
|
|
15273
14238
|
}));
|
|
15274
14239
|
const rest = def.rest ? process2(def.rest, ctx, {
|
|
15275
14240
|
...params,
|
|
@@ -16344,9 +15309,9 @@ var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
|
16344
15309
|
inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx);
|
|
16345
15310
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
16346
15311
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
16347
|
-
const
|
|
16348
|
-
inst.minDate =
|
|
16349
|
-
inst.maxDate =
|
|
15312
|
+
const c = inst._zod.bag;
|
|
15313
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
15314
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
16350
15315
|
});
|
|
16351
15316
|
function date3(params) {
|
|
16352
15317
|
return _date(ZodDate, params);
|
|
@@ -17145,8 +16110,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
17145
16110
|
}
|
|
17146
16111
|
const type = schema.type;
|
|
17147
16112
|
if (Array.isArray(type)) {
|
|
17148
|
-
const typeSchemas = type.map((
|
|
17149
|
-
const typeSchema = { ...schema, type:
|
|
16113
|
+
const typeSchemas = type.map((t) => {
|
|
16114
|
+
const typeSchema = { ...schema, type: t };
|
|
17150
16115
|
return convertBaseSchema(typeSchema, ctx);
|
|
17151
16116
|
});
|
|
17152
16117
|
if (typeSchemas.length === 0) {
|
|
@@ -17299,8 +16264,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
17299
16264
|
zodSchema = schemasToIntersect[0];
|
|
17300
16265
|
} else {
|
|
17301
16266
|
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
17302
|
-
for (let
|
|
17303
|
-
result = z.intersection(result, schemasToIntersect[
|
|
16267
|
+
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
16268
|
+
result = z.intersection(result, schemasToIntersect[i]);
|
|
17304
16269
|
}
|
|
17305
16270
|
zodSchema = result;
|
|
17306
16271
|
}
|
|
@@ -17380,12 +16345,12 @@ function convertSchema(schema, ctx) {
|
|
|
17380
16345
|
let baseSchema = convertBaseSchema(schema, ctx);
|
|
17381
16346
|
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
17382
16347
|
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
17383
|
-
const options2 = schema.anyOf.map((
|
|
16348
|
+
const options2 = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
17384
16349
|
const anyOfUnion = z.union(options2);
|
|
17385
16350
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
17386
16351
|
}
|
|
17387
16352
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
17388
|
-
const options2 = schema.oneOf.map((
|
|
16353
|
+
const options2 = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
17389
16354
|
const oneOfUnion = z.xor(options2);
|
|
17390
16355
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
17391
16356
|
}
|
|
@@ -17395,8 +16360,8 @@ function convertSchema(schema, ctx) {
|
|
|
17395
16360
|
} else {
|
|
17396
16361
|
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
17397
16362
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
17398
|
-
for (let
|
|
17399
|
-
result = z.intersection(result, convertSchema(schema.allOf[
|
|
16363
|
+
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
16364
|
+
result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
17400
16365
|
}
|
|
17401
16366
|
baseSchema = result;
|
|
17402
16367
|
}
|
|
@@ -17735,7 +16700,7 @@ PERFORMANCE: Batch multiple actions in one execute call.`,
|
|
|
17735
16700
|
};
|
|
17736
16701
|
|
|
17737
16702
|
// src/commands/browser.ts
|
|
17738
|
-
var VERSION2 = "0.1.0-beta.
|
|
16703
|
+
var VERSION2 = "0.1.0-beta.7";
|
|
17739
16704
|
var printHeader = () => {
|
|
17740
16705
|
console.log(
|
|
17741
16706
|
`${pc__default.default.magenta("\u273F")} ${pc__default.default.bold("React Grab")} ${pc__default.default.gray(VERSION2)}`
|
|
@@ -18205,7 +17170,7 @@ browser.addCommand(status);
|
|
|
18205
17170
|
browser.addCommand(execute);
|
|
18206
17171
|
browser.addCommand(pages);
|
|
18207
17172
|
browser.addCommand(mcp);
|
|
18208
|
-
var VERSION3 = "0.1.0-beta.
|
|
17173
|
+
var VERSION3 = "0.1.0-beta.7";
|
|
18209
17174
|
var isMac = process.platform === "darwin";
|
|
18210
17175
|
var META_LABEL = isMac ? "Cmd" : "Win";
|
|
18211
17176
|
var ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -18239,17 +17204,17 @@ var BASE_KEYS = [
|
|
|
18239
17204
|
{ key: "ArrowDown", aliases: ["arrowdown", "down"] },
|
|
18240
17205
|
{ key: "ArrowLeft", aliases: ["arrowleft", "left"] },
|
|
18241
17206
|
{ key: "ArrowRight", aliases: ["arrowright", "right"] },
|
|
18242
|
-
...Array.from({ length: 12 }, (_,
|
|
18243
|
-
key: `F${
|
|
18244
|
-
aliases: [`f${
|
|
17207
|
+
...Array.from({ length: 12 }, (_, i) => ({
|
|
17208
|
+
key: `F${i + 1}`,
|
|
17209
|
+
aliases: [`f${i + 1}`]
|
|
18245
17210
|
})),
|
|
18246
|
-
...Array.from({ length: 26 }, (_,
|
|
18247
|
-
const letter = String.fromCharCode(97 +
|
|
17211
|
+
...Array.from({ length: 26 }, (_, i) => {
|
|
17212
|
+
const letter = String.fromCharCode(97 + i);
|
|
18248
17213
|
return { key: letter, aliases: [letter] };
|
|
18249
17214
|
}),
|
|
18250
|
-
...Array.from({ length: 10 }, (_,
|
|
18251
|
-
key: String(
|
|
18252
|
-
aliases: [String(
|
|
17215
|
+
...Array.from({ length: 10 }, (_, i) => ({
|
|
17216
|
+
key: String(i),
|
|
17217
|
+
aliases: [String(i)]
|
|
18253
17218
|
})),
|
|
18254
17219
|
{ key: "`", aliases: ["backtick", "grave", "`"] },
|
|
18255
17220
|
{ key: "-", aliases: ["minus", "dash", "-"] },
|
|
@@ -18336,7 +17301,7 @@ var generateSuggestions = (input) => {
|
|
|
18336
17301
|
}
|
|
18337
17302
|
}
|
|
18338
17303
|
if (!partial2) {
|
|
18339
|
-
const unusedMods = MODIFIERS.filter((
|
|
17304
|
+
const unusedMods = MODIFIERS.filter((m) => !modifiers.has(m));
|
|
18340
17305
|
for (const mod of unusedMods) {
|
|
18341
17306
|
for (const popularKey of POPULAR_KEYS) {
|
|
18342
17307
|
const combo = buildCombo(popularKey, modifiers, mod);
|
|
@@ -18643,7 +17608,7 @@ var configure = new commander.Command().name("configure").alias("config").descri
|
|
|
18643
17608
|
handleError(error48);
|
|
18644
17609
|
}
|
|
18645
17610
|
});
|
|
18646
|
-
var VERSION4 = "0.1.0-beta.
|
|
17611
|
+
var VERSION4 = "0.1.0-beta.7";
|
|
18647
17612
|
var REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
18648
17613
|
var DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
18649
17614
|
var promptSkillInstall = async (cwd) => {
|
|
@@ -18689,22 +17654,19 @@ var promptSkillInstall = async (cwd) => {
|
|
|
18689
17654
|
}
|
|
18690
17655
|
logger.break();
|
|
18691
17656
|
};
|
|
18692
|
-
var reportToCli =
|
|
18693
|
-
|
|
18694
|
-
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
|
|
18698
|
-
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
|
|
18702
|
-
|
|
18703
|
-
|
|
18704
|
-
|
|
18705
|
-
});
|
|
18706
|
-
} catch {
|
|
18707
|
-
}
|
|
17657
|
+
var reportToCli = (type, config2, error48) => {
|
|
17658
|
+
fetch(REPORT_URL, {
|
|
17659
|
+
method: "POST",
|
|
17660
|
+
headers: { "Content-Type": "application/json" },
|
|
17661
|
+
body: JSON.stringify({
|
|
17662
|
+
type,
|
|
17663
|
+
version: VERSION4,
|
|
17664
|
+
config: config2,
|
|
17665
|
+
error: error48 ? { message: error48.message, stack: error48.stack } : void 0,
|
|
17666
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17667
|
+
})
|
|
17668
|
+
}).catch(() => {
|
|
17669
|
+
});
|
|
18708
17670
|
};
|
|
18709
17671
|
var FRAMEWORK_NAMES = {
|
|
18710
17672
|
next: "Next.js",
|
|
@@ -19315,7 +18277,7 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
19315
18277
|
if (!isNonInteractive) {
|
|
19316
18278
|
await promptSkillInstall(cwd);
|
|
19317
18279
|
}
|
|
19318
|
-
|
|
18280
|
+
reportToCli("completed", {
|
|
19319
18281
|
framework: finalFramework,
|
|
19320
18282
|
packageManager: finalPackageManager,
|
|
19321
18283
|
router: finalNextRouterType,
|
|
@@ -19324,10 +18286,10 @@ var init = new commander.Command().name("init").description("initialize React Gr
|
|
|
19324
18286
|
});
|
|
19325
18287
|
} catch (error48) {
|
|
19326
18288
|
handleError(error48);
|
|
19327
|
-
|
|
18289
|
+
reportToCli("error", void 0, error48);
|
|
19328
18290
|
}
|
|
19329
18291
|
});
|
|
19330
|
-
var VERSION5 = "0.1.0-beta.
|
|
18292
|
+
var VERSION5 = "0.1.0-beta.7";
|
|
19331
18293
|
var remove = new commander.Command().name("remove").description("remove an agent integration").argument(
|
|
19332
18294
|
"[agent]",
|
|
19333
18295
|
"agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, visual-edit)"
|
|
@@ -19504,22 +18466,21 @@ var remove = new commander.Command().name("remove").description("remove an agent
|
|
|
19504
18466
|
handleError(error48);
|
|
19505
18467
|
}
|
|
19506
18468
|
});
|
|
19507
|
-
var
|
|
19508
|
-
|
|
19509
|
-
|
|
19510
|
-
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19520
|
-
var execSilent = (command) => {
|
|
18469
|
+
var uninstall = new commander.Command().name("uninstall").description("uninstall React Grab CLI globally").action(() => {
|
|
18470
|
+
console.log("Uninstalling React Grab CLI...");
|
|
18471
|
+
try {
|
|
18472
|
+
child_process.execSync("npm uninstall -g @react-grab/cli", { stdio: "inherit" });
|
|
18473
|
+
console.log("React Grab CLI has been uninstalled.");
|
|
18474
|
+
} catch {
|
|
18475
|
+
console.error("Failed to uninstall. Please try: npm uninstall -g @react-grab/cli");
|
|
18476
|
+
process.exit(1);
|
|
18477
|
+
}
|
|
18478
|
+
});
|
|
18479
|
+
var VERSION6 = "0.1.0-beta.7";
|
|
18480
|
+
var UPDATE_COMMAND = "npm install -g @react-grab/cli@latest";
|
|
18481
|
+
var getLatestVersion = () => {
|
|
19521
18482
|
try {
|
|
19522
|
-
return child_process.execSync(
|
|
18483
|
+
return child_process.execSync("npm view @react-grab/cli version", {
|
|
19523
18484
|
encoding: "utf-8",
|
|
19524
18485
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19525
18486
|
}).trim();
|
|
@@ -19527,47 +18488,22 @@ var execSilent = (command) => {
|
|
|
19527
18488
|
return null;
|
|
19528
18489
|
}
|
|
19529
18490
|
};
|
|
19530
|
-
var
|
|
19531
|
-
const output = execSilent("grab --version");
|
|
19532
|
-
if (!output) return null;
|
|
19533
|
-
const match = output.match(/(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)/);
|
|
19534
|
-
return match ? match[1] : null;
|
|
19535
|
-
};
|
|
19536
|
-
var getLatestVersion = () => execSilent("npm view grab version");
|
|
19537
|
-
var isPackageManagerInstalled = (manager) => execSilent(`${manager} --version`) !== null;
|
|
19538
|
-
var detectGlobalPackageManager = () => {
|
|
19539
|
-
const managers = ["pnpm", "yarn", "bun"];
|
|
19540
|
-
for (const manager of managers) {
|
|
19541
|
-
if (isPackageManagerInstalled(manager)) {
|
|
19542
|
-
return manager;
|
|
19543
|
-
}
|
|
19544
|
-
}
|
|
19545
|
-
return "npm";
|
|
19546
|
-
};
|
|
19547
|
-
var update = new commander.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) => {
|
|
18491
|
+
var update = new commander.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) => {
|
|
19548
18492
|
console.log(
|
|
19549
18493
|
`${pc__default.default.magenta("\u273F")} ${pc__default.default.bold("React Grab")} ${pc__default.default.gray(VERSION6)}`
|
|
19550
18494
|
);
|
|
19551
18495
|
console.log();
|
|
19552
18496
|
const checkSpinner = spinner("Checking for updates").start();
|
|
19553
|
-
const installedVersion = getInstalledVersion();
|
|
19554
18497
|
const latestVersion = getLatestVersion();
|
|
19555
18498
|
if (!latestVersion) {
|
|
19556
|
-
checkSpinner.fail("Failed to fetch latest version
|
|
18499
|
+
checkSpinner.fail("Failed to fetch latest version");
|
|
19557
18500
|
logger.break();
|
|
19558
18501
|
logger.error("Could not reach npm registry. Check your network connection.");
|
|
19559
18502
|
logger.break();
|
|
19560
18503
|
process.exit(1);
|
|
19561
18504
|
}
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
logger.break();
|
|
19565
|
-
logger.log(`Install it with: ${highlighter.info("npm install -g grab")}`);
|
|
19566
|
-
logger.break();
|
|
19567
|
-
process.exit(1);
|
|
19568
|
-
}
|
|
19569
|
-
checkSpinner.succeed(`Current version: ${highlighter.info(installedVersion)}`);
|
|
19570
|
-
if (installedVersion === latestVersion) {
|
|
18505
|
+
checkSpinner.succeed(`Current version: ${highlighter.info(VERSION6)}`);
|
|
18506
|
+
if (VERSION6 === latestVersion) {
|
|
19571
18507
|
logger.break();
|
|
19572
18508
|
logger.success(`You're already on the latest version (${latestVersion})`);
|
|
19573
18509
|
logger.break();
|
|
@@ -19576,17 +18512,16 @@ var update = new commander.Command().name("update").alias("upgrade").description
|
|
|
19576
18512
|
logger.log(`Latest version: ${highlighter.success(latestVersion)}`);
|
|
19577
18513
|
logger.break();
|
|
19578
18514
|
if (opts2.check) {
|
|
19579
|
-
logger.log(`Update available: ${
|
|
18515
|
+
logger.log(`Update available: ${VERSION6} \u2192 ${latestVersion}`);
|
|
19580
18516
|
logger.log(`Run ${highlighter.info("grab update")} to install the update.`);
|
|
19581
18517
|
logger.break();
|
|
19582
18518
|
process.exit(0);
|
|
19583
18519
|
}
|
|
19584
|
-
const packageManager = detectGlobalPackageManager();
|
|
19585
18520
|
if (!opts2.yes) {
|
|
19586
18521
|
const { shouldProceed } = await prompts3__default.default({
|
|
19587
18522
|
type: "confirm",
|
|
19588
18523
|
name: "shouldProceed",
|
|
19589
|
-
message: `Update
|
|
18524
|
+
message: `Update from ${VERSION6} to ${latestVersion}?`,
|
|
19590
18525
|
initial: true
|
|
19591
18526
|
});
|
|
19592
18527
|
if (!shouldProceed) {
|
|
@@ -19597,20 +18532,17 @@ var update = new commander.Command().name("update").alias("upgrade").description
|
|
|
19597
18532
|
}
|
|
19598
18533
|
}
|
|
19599
18534
|
logger.break();
|
|
19600
|
-
const updateSpinner = spinner(`Updating
|
|
18535
|
+
const updateSpinner = spinner(`Updating to ${latestVersion}`).start();
|
|
19601
18536
|
try {
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
19605
|
-
});
|
|
19606
|
-
updateSpinner.succeed(`Updated grab to ${latestVersion}`);
|
|
18537
|
+
child_process.execSync(UPDATE_COMMAND, { stdio: ["pipe", "pipe", "pipe"] });
|
|
18538
|
+
updateSpinner.succeed(`Updated to ${latestVersion}`);
|
|
19607
18539
|
logger.break();
|
|
19608
18540
|
logger.success("Update complete!");
|
|
19609
18541
|
logger.break();
|
|
19610
18542
|
} catch (error48) {
|
|
19611
|
-
updateSpinner.fail("Failed to update
|
|
18543
|
+
updateSpinner.fail("Failed to update");
|
|
19612
18544
|
logger.break();
|
|
19613
|
-
logger.error(`Update failed. Try manually: ${highlighter.info(
|
|
18545
|
+
logger.error(`Update failed. Try manually: ${highlighter.info(UPDATE_COMMAND)}`);
|
|
19614
18546
|
if (error48 instanceof Error && error48.message) {
|
|
19615
18547
|
logger.dim(error48.message);
|
|
19616
18548
|
}
|
|
@@ -19620,7 +18552,7 @@ var update = new commander.Command().name("update").alias("upgrade").description
|
|
|
19620
18552
|
});
|
|
19621
18553
|
|
|
19622
18554
|
// src/cli.ts
|
|
19623
|
-
var VERSION7 = "0.1.0-beta.
|
|
18555
|
+
var VERSION7 = "0.1.0-beta.7";
|
|
19624
18556
|
var VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
19625
18557
|
process.on("SIGINT", () => process.exit(0));
|
|
19626
18558
|
process.on("SIGTERM", () => process.exit(0));
|
|
@@ -19636,69 +18568,5 @@ program.addCommand(remove);
|
|
|
19636
18568
|
program.addCommand(configure);
|
|
19637
18569
|
program.addCommand(browser);
|
|
19638
18570
|
program.addCommand(update);
|
|
19639
|
-
|
|
19640
|
-
var initCommand = completion.commands.get("init");
|
|
19641
|
-
var initAgentOption = initCommand?.options.get("agent");
|
|
19642
|
-
if (initAgentOption) {
|
|
19643
|
-
initAgentOption.handler = (complete) => {
|
|
19644
|
-
for (const agent of AGENTS) {
|
|
19645
|
-
complete(agent, "");
|
|
19646
|
-
}
|
|
19647
|
-
};
|
|
19648
|
-
}
|
|
19649
|
-
var initKeyOption = initCommand?.options.get("key");
|
|
19650
|
-
if (initKeyOption) {
|
|
19651
|
-
initKeyOption.handler = (complete) => {
|
|
19652
|
-
complete("Meta+K", "Cmd+K / Win+K");
|
|
19653
|
-
complete("Ctrl+K", "Ctrl+K");
|
|
19654
|
-
complete("Space", "Spacebar");
|
|
19655
|
-
complete("Alt", "Option / Alt");
|
|
19656
|
-
};
|
|
19657
|
-
}
|
|
19658
|
-
var addCommand = completion.commands.get("add");
|
|
19659
|
-
var addAgentArg = addCommand?.arguments.get("agent");
|
|
19660
|
-
if (addAgentArg) {
|
|
19661
|
-
addAgentArg.handler = (complete) => {
|
|
19662
|
-
complete("skill", "Instructions for your agent to use the browser (recommended)");
|
|
19663
|
-
complete("mcp", "A server that provides browser tools to your agent");
|
|
19664
|
-
for (const agent of AGENTS) {
|
|
19665
|
-
complete(agent, "");
|
|
19666
|
-
}
|
|
19667
|
-
};
|
|
19668
|
-
}
|
|
19669
|
-
var addClientOption = addCommand?.options.get("client");
|
|
19670
|
-
if (addClientOption) {
|
|
19671
|
-
addClientOption.handler = (complete) => {
|
|
19672
|
-
for (const client of MCP_CLIENTS) {
|
|
19673
|
-
complete(client, "");
|
|
19674
|
-
}
|
|
19675
|
-
};
|
|
19676
|
-
}
|
|
19677
|
-
var removeCommand = completion.commands.get("remove");
|
|
19678
|
-
var removeAgentArg = removeCommand?.arguments.get("agent");
|
|
19679
|
-
if (removeAgentArg) {
|
|
19680
|
-
removeAgentArg.handler = (complete) => {
|
|
19681
|
-
for (const agent of AGENTS) {
|
|
19682
|
-
complete(agent, "");
|
|
19683
|
-
}
|
|
19684
|
-
};
|
|
19685
|
-
}
|
|
19686
|
-
var configureCommand = completion.commands.get("configure");
|
|
19687
|
-
var configureKeyOption = configureCommand?.options.get("key");
|
|
19688
|
-
if (configureKeyOption) {
|
|
19689
|
-
configureKeyOption.handler = (complete) => {
|
|
19690
|
-
complete("Meta+K", "Cmd+K / Win+K");
|
|
19691
|
-
complete("Ctrl+K", "Ctrl+K");
|
|
19692
|
-
complete("Space", "Spacebar");
|
|
19693
|
-
complete("Alt", "Option / Alt");
|
|
19694
|
-
complete("Ctrl+Shift+G", "Ctrl+Shift+G");
|
|
19695
|
-
};
|
|
19696
|
-
}
|
|
19697
|
-
var configureModeOption = configureCommand?.options.get("mode");
|
|
19698
|
-
if (configureModeOption) {
|
|
19699
|
-
configureModeOption.handler = (complete) => {
|
|
19700
|
-
complete("toggle", "Press to activate/deactivate");
|
|
19701
|
-
complete("hold", "Hold key to keep active");
|
|
19702
|
-
};
|
|
19703
|
-
}
|
|
18571
|
+
program.addCommand(uninstall);
|
|
19704
18572
|
program.parse();
|