@visulima/vis 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +96 -0
  5. package/dist/packem_chunks/CONFIG_FILES.js +3 -3
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/cargo-plan.js +3 -0
  9. package/dist/packem_chunks/catalog.js +46 -46
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +138 -138
  12. package/dist/packem_chunks/composer-projects.js +2 -0
  13. package/dist/packem_chunks/dart-plan.js +1 -0
  14. package/dist/packem_chunks/dart-projects.js +1 -0
  15. package/dist/packem_chunks/dispatch.js +1 -1
  16. package/dist/packem_chunks/fix.js +8 -8
  17. package/dist/packem_chunks/gem-plan.js +2 -0
  18. package/dist/packem_chunks/gem-projects.js +1 -0
  19. package/dist/packem_chunks/git.js +5 -5
  20. package/dist/packem_chunks/go-plan.js +1 -0
  21. package/dist/packem_chunks/go-projects.js +2 -0
  22. package/dist/packem_chunks/gradle-plan.js +1 -0
  23. package/dist/packem_chunks/handler.js +1 -1
  24. package/dist/packem_chunks/handler10.js +3 -3
  25. package/dist/packem_chunks/handler11.js +1 -1
  26. package/dist/packem_chunks/handler12.js +2 -2
  27. package/dist/packem_chunks/handler13.js +1 -1
  28. package/dist/packem_chunks/handler14.js +1 -1
  29. package/dist/packem_chunks/handler15.js +1 -1
  30. package/dist/packem_chunks/handler16.js +1 -1
  31. package/dist/packem_chunks/handler17.js +1 -1
  32. package/dist/packem_chunks/handler18.js +1 -1
  33. package/dist/packem_chunks/handler19.js +1 -1
  34. package/dist/packem_chunks/handler2.js +1 -1
  35. package/dist/packem_chunks/handler20.js +2 -2
  36. package/dist/packem_chunks/handler21.js +1 -1
  37. package/dist/packem_chunks/handler22.js +1 -1
  38. package/dist/packem_chunks/handler23.js +1 -1
  39. package/dist/packem_chunks/handler24.js +1 -1
  40. package/dist/packem_chunks/handler26.js +1 -1
  41. package/dist/packem_chunks/handler27.js +1 -1
  42. package/dist/packem_chunks/handler28.js +1 -1
  43. package/dist/packem_chunks/handler29.js +1 -1
  44. package/dist/packem_chunks/handler3.js +1 -1
  45. package/dist/packem_chunks/handler30.js +1 -1
  46. package/dist/packem_chunks/handler39.js +6 -6
  47. package/dist/packem_chunks/handler4.js +3 -3
  48. package/dist/packem_chunks/handler5.js +1 -1
  49. package/dist/packem_chunks/handler50.js +1 -1
  50. package/dist/packem_chunks/handler51.js +1 -1
  51. package/dist/packem_chunks/handler53.js +1 -1
  52. package/dist/packem_chunks/handler54.js +2 -2
  53. package/dist/packem_chunks/handler55.js +1 -1
  54. package/dist/packem_chunks/handler58.js +2 -2
  55. package/dist/packem_chunks/handler59.js +1 -1
  56. package/dist/packem_chunks/handler6.js +5 -5
  57. package/dist/packem_chunks/handler60.js +8 -8
  58. package/dist/packem_chunks/handler61.js +1 -1
  59. package/dist/packem_chunks/handler62.js +16 -16
  60. package/dist/packem_chunks/handler63.js +2 -2
  61. package/dist/packem_chunks/handler64.js +1 -1
  62. package/dist/packem_chunks/handler65.js +4 -4
  63. package/dist/packem_chunks/handler66.js +2 -2
  64. package/dist/packem_chunks/handler67.js +3 -3
  65. package/dist/packem_chunks/handler68.js +2 -2
  66. package/dist/packem_chunks/handler69.js +3 -3
  67. package/dist/packem_chunks/handler7.js +1 -1
  68. package/dist/packem_chunks/handler70.js +4 -4
  69. package/dist/packem_chunks/handler71.js +5 -5
  70. package/dist/packem_chunks/handler72.js +2 -2
  71. package/dist/packem_chunks/handler73.js +87 -86
  72. package/dist/packem_chunks/handler74.js +1 -1
  73. package/dist/packem_chunks/handler75.js +33 -33
  74. package/dist/packem_chunks/handler76.js +6 -6
  75. package/dist/packem_chunks/handler77.js +2 -2
  76. package/dist/packem_chunks/handler78.js +19 -19
  77. package/dist/packem_chunks/handler8.js +1 -1
  78. package/dist/packem_chunks/handler9.js +1 -1
  79. package/dist/packem_chunks/heal-accept.js +1 -1
  80. package/dist/packem_chunks/heal.js +1 -1
  81. package/dist/packem_chunks/help-command.js +1 -1
  82. package/dist/packem_chunks/hex-plan.js +3 -0
  83. package/dist/packem_chunks/hex-projects.js +1 -0
  84. package/dist/packem_chunks/index2.js +52 -42
  85. package/dist/packem_chunks/index4.js +58 -802
  86. package/dist/packem_chunks/index5.js +802 -7
  87. package/dist/packem_chunks/index6.js +7 -58
  88. package/dist/packem_chunks/keys-refresh.js +1 -1
  89. package/dist/packem_chunks/lean.js +1 -1
  90. package/dist/packem_chunks/list.js +2 -2
  91. package/dist/packem_chunks/loader.js +1 -1
  92. package/dist/packem_chunks/maven-plan.js +1 -0
  93. package/dist/packem_chunks/maven-projects.js +1 -0
  94. package/dist/packem_chunks/nuget-plan.js +1 -0
  95. package/dist/packem_chunks/nuget-projects.js +1 -0
  96. package/dist/packem_chunks/orchestrator.js +33 -33
  97. package/dist/packem_chunks/prune.js +1 -1
  98. package/dist/packem_chunks/python-plan.js +3 -0
  99. package/dist/packem_chunks/python-projects.js +1 -0
  100. package/dist/packem_chunks/security.js +1 -1
  101. package/dist/packem_chunks/snapshot.js +2 -2
  102. package/dist/packem_chunks/status.js +1 -1
  103. package/dist/packem_chunks/swift-projects.js +1 -0
  104. package/dist/packem_chunks/sync.js +3 -2
  105. package/dist/packem_chunks/sync2.js +1 -1
  106. package/dist/packem_chunks/tripwire.js +2 -2
  107. package/dist/packem_chunks/ts-loader.js +5 -5
  108. package/dist/packem_chunks/verify-lockfile.js +2 -2
  109. package/dist/packem_chunks/version-resolver.js +3 -3
  110. package/dist/packem_chunks/zig-plan.js +1 -0
  111. package/dist/packem_chunks/zig-projects.js +1 -0
  112. package/dist/packem_shared/{affected-selection-M7riOi5-.js → affected-selection-BzIbfpA1.js} +1 -1
  113. package/dist/packem_shared/{affected-shas-CAwpSPmP.js → affected-shas-B2V84O0g.js} +1 -1
  114. package/dist/packem_shared/{ai-analysis-DSQQDFU9.js → ai-analysis-Cfj24UAy.js} +1 -1
  115. package/dist/packem_shared/{ai-fix-BTm1Z5og.js → ai-fix-DeRUtT-s.js} +1 -1
  116. package/dist/packem_shared/{augment-CBv1hwMR.js → augment-B9kSZuvW.js} +1 -1
  117. package/dist/packem_shared/{bin-Cbs_ix6l.js → bin-D9TsVhq2.js} +1 -1
  118. package/dist/packem_shared/build-scripts-CEDx_nJp.js +1 -0
  119. package/dist/packem_shared/{command-runtime-BD-4UmPB.js → command-runtime-p4IXiIf6.js} +1 -1
  120. package/dist/packem_shared/composer-DR3D-Psb.js +1 -0
  121. package/dist/packem_shared/dart-pubspec-BK_cK2EP.js +2 -0
  122. package/dist/packem_shared/dependency-scan-B8jroa1D.js +1 -0
  123. package/dist/packem_shared/{docker-1jgKW5Wd.js → docker-DXqV-07f.js} +3 -3
  124. package/dist/packem_shared/ecosystem-gate-1M3wnsTr.js +6 -0
  125. package/dist/packem_shared/failure-log-D2x5BT8S.js +2 -0
  126. package/dist/packem_shared/formatBytes-BHAzNIrn-CrusHOew.js +4 -0
  127. package/dist/packem_shared/gemspec-K7N05xxc.js +3 -0
  128. package/dist/packem_shared/go-modules-BsVqtyeC.js +1 -0
  129. package/dist/packem_shared/gradle-build-CHZDHyjI.js +8 -0
  130. package/dist/packem_shared/index-BO8qIogg.js +1 -0
  131. package/dist/packem_shared/index-BzhrR_iC.js +22 -0
  132. package/dist/packem_shared/{index-Cq-J2MdB.js → index-CNYv9D8g.js} +1 -1
  133. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-K2xhg6sV.js → isAccessibleSync-DYKTrrvc-C-_5cgwu.js} +1 -1
  134. package/dist/packem_shared/lifecycle-D6PMPor-.js +2 -0
  135. package/dist/packem_shared/lockfile-CiUtEbnt.js +1 -0
  136. package/dist/packem_shared/manifests-Du4yKlf_.js +1 -0
  137. package/dist/packem_shared/maven-pom-B0KG9kJQ.js +1 -0
  138. package/dist/packem_shared/{min-release-age-Da4V046o.js → min-release-age-JViyQuBM.js} +7 -7
  139. package/dist/packem_shared/missing-package-json-DnHMxRnG.js +1 -0
  140. package/dist/packem_shared/mix-project-RYvdZp3_.js +2 -0
  141. package/dist/packem_shared/multi-eco-lockfiles-CUUxUjHK.js +1 -0
  142. package/dist/packem_shared/{native-config-sync-CEB0rWlk.js → native-config-sync-TdTWjVgI.js} +1 -1
  143. package/dist/packem_shared/nuget-project-RApYSW_y.js +4 -0
  144. package/dist/packem_shared/{osv-bloom-BRacgzs7.js → osv-bloom-BCAX5ARR.js} +1 -1
  145. package/dist/packem_shared/package-version-DUcG-b7S.js +4 -0
  146. package/dist/packem_shared/packument-CyGSNquL.js +1 -0
  147. package/dist/packem_shared/pm-runner-CMSml1Bj.js +1 -0
  148. package/dist/packem_shared/{project-name-filter-zrdrEQbu.js → project-name-filter--bq-FL2f.js} +1 -1
  149. package/dist/packem_shared/{provenance-CFPT_FQA.js → provenance-DyF0b6KX.js} +1 -1
  150. package/dist/packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js +1 -0
  151. package/dist/packem_shared/registry-keys-DwB3ZXS_.js +1 -0
  152. package/dist/packem_shared/{resolve-explicit-opfIkxoY.js → resolve-explicit-BjCEm0s-.js} +1 -1
  153. package/dist/packem_shared/resolve-runtime-CNiHcVtx.js +1 -0
  154. package/dist/packem_shared/run-file-UBukWaha.js +1 -0
  155. package/dist/packem_shared/runtime-check-1U8HrQd9.js +1 -0
  156. package/dist/packem_shared/s1ngularity-YfmkD_AH.js +1 -0
  157. package/dist/packem_shared/{scan-progress-BGB9hIrD.js → scan-progress-C_zaZjyY.js} +2 -2
  158. package/dist/packem_shared/{selectors-CjIZ3gy2.js → selectors-edwcgNl3.js} +1 -1
  159. package/dist/packem_shared/{signatures-DpqZVmmU.js → signatures-CL3ckp_Y.js} +1 -1
  160. package/dist/packem_shared/spinner-DuB0K0Am.js +1 -0
  161. package/dist/packem_shared/swift-package-B6X5kzQE.js +1 -0
  162. package/dist/packem_shared/{tabs-Dz6xVpfX.js → tabs-RZd_e1M0.js} +1 -1
  163. package/dist/packem_shared/{target-merge-hsawesT4.js → target-merge-DVJl-7Qz.js} +1 -1
  164. package/dist/packem_shared/target-options-DsHFmRZH.js +1 -0
  165. package/dist/packem_shared/toolchain-BRdpaAC4.js +5 -0
  166. package/dist/packem_shared/typosquats-8u0drCqQ.js +1 -0
  167. package/dist/packem_shared/{use-measured-height-BPQg2q_p.js → use-measured-height-DWkDV9Dj.js} +1 -1
  168. package/dist/packem_shared/verify-B_MblU_Q.js +1 -0
  169. package/dist/packem_shared/{vis-update-app-D9KWJ9Ir.js → vis-update-app-D73C__fx.js} +1 -1
  170. package/dist/packem_shared/{vis-user-error-Bdg9NRuJ.js → vis-user-error-Cpg2FqA4.js} +1 -1
  171. package/dist/packem_shared/watch-CcTketln.js +1 -0
  172. package/dist/packem_shared/watch-loop-qRn0IHPG.js +11 -0
  173. package/dist/packem_shared/{writeFileSync-DJoHk3Ks-O9zOKqeM.js → writeFileSync-DJoHk3Ks-BPRoepNw.js} +1 -1
  174. package/dist/packem_shared/zig-manifest-P7ydLEOa.js +7 -0
  175. package/dist/release/plugin-sdk.d.ts +1 -1
  176. package/dist/release/types.d.ts +133 -7
  177. package/dist/runtime/preload.js +1 -1
  178. package/index.d.ts +204 -204
  179. package/index.js +52 -52
  180. package/package.json +11 -11
  181. package/schemas/vis-config.schema.json +265 -5
  182. package/schemas/vis-release-config.schema.json +132 -5
  183. package/dist/packem_shared/advisories-BSpzRIXP.js +0 -1
  184. package/dist/packem_shared/build-scripts-BIgkWVgY.js +0 -1
  185. package/dist/packem_shared/cyclonedx-CT1rtKxV.js +0 -4
  186. package/dist/packem_shared/dependency-scan-W9b2X0a1.js +0 -1
  187. package/dist/packem_shared/failure-log-B91LvYWw.js +0 -2
  188. package/dist/packem_shared/formatBytes-BHAzNIrn-CLYsxlUj.js +0 -4
  189. package/dist/packem_shared/index-CVBR-Kit.js +0 -22
  190. package/dist/packem_shared/index-onibYJkv.js +0 -1
  191. package/dist/packem_shared/lifecycle-DDJzp-4H.js +0 -2
  192. package/dist/packem_shared/lockfile-Bi1mw9jJ.js +0 -1
  193. package/dist/packem_shared/manifests-D671Sb1T.js +0 -1
  194. package/dist/packem_shared/missing-package-json-CMoHdvmj.js +0 -1
  195. package/dist/packem_shared/package-version-C5EPMgRw.js +0 -4
  196. package/dist/packem_shared/packument-DuEV-qSE.js +0 -1
  197. package/dist/packem_shared/path-CxEa27Rz-pjheKk6v.js +0 -1
  198. package/dist/packem_shared/pm-runner-9L6ocnu2.js +0 -1
  199. package/dist/packem_shared/readJsonSync-CbryXYxN-BxKjDZnF.js +0 -1
  200. package/dist/packem_shared/registry-keys-C3EsP_s4.js +0 -1
  201. package/dist/packem_shared/resolve-runtime-lJ5L9gU4.js +0 -1
  202. package/dist/packem_shared/run-file-DZff6GqY.js +0 -1
  203. package/dist/packem_shared/runtime-check-DAbveBr_.js +0 -1
  204. package/dist/packem_shared/s1ngularity-DTvrfWIM.js +0 -1
  205. package/dist/packem_shared/spinner-BVCEMm3G.js +0 -1
  206. package/dist/packem_shared/target-options-Bxb0Y5qa.js +0 -1
  207. package/dist/packem_shared/toolchain-887JoquG.js +0 -5
  208. package/dist/packem_shared/typosquats-Xv6dN4sr.js +0 -1
  209. package/dist/packem_shared/verify-BLoaI7En.js +0 -1
  210. package/dist/packem_shared/watch-BTZw2Y8Q.js +0 -1
  211. package/dist/packem_shared/watch-loop-Cjh2wlUl.js +0 -11
@@ -1,802 +1,58 @@
1
- import{createRequire as _}from"node:module";let u;const $=t=>(u??=_(import.meta.url))(t),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[i,e]=p.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return p.getBuiltinModule(t)}return $(t)},f=h("node:assert");function g(t,i){return`#compdef ${t}
2
- compdef _${t} ${t}
3
-
4
- # zsh completion for ${t} -*- shell-script -*-
5
-
6
- __${t}_debug() {
7
- local file="$BASH_COMP_DEBUG_FILE"
8
- if [[ -n \${file} ]]; then
9
- echo "$*" >> "\${file}"
10
- fi
11
- }
12
-
13
- _${t}() {
14
- local shellCompDirectiveError=${n.ShellCompDirectiveError}
15
- local shellCompDirectiveNoSpace=${n.ShellCompDirectiveNoSpace}
16
- local shellCompDirectiveNoFileComp=${n.ShellCompDirectiveNoFileComp}
17
- local shellCompDirectiveFilterFileExt=${n.ShellCompDirectiveFilterFileExt}
18
- local shellCompDirectiveFilterDirs=${n.ShellCompDirectiveFilterDirs}
19
- local shellCompDirectiveKeepOrder=${n.ShellCompDirectiveKeepOrder}
20
-
21
- local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
22
- local -a completions
23
-
24
- __${t}_debug "\\n========= starting completion logic =========="
25
- __${t}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
26
-
27
- # The user could have moved the cursor backwards on the command-line.
28
- # We need to trigger completion from the $CURRENT location, so we need
29
- # to truncate the command-line ($words) up to the $CURRENT location.
30
- # (We cannot use $CURSOR as its value does not work when a command is an alias.)
31
- words=( "\${=words[1,CURRENT]}" )
32
- __${t}_debug "Truncated words[*]: \${words[*]},"
33
-
34
- lastParam=\${words[-1]}
35
- lastChar=\${lastParam[-1]}
36
- __${t}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
37
-
38
- # For zsh, when completing a flag with an = (e.g., ${t} -n=<TAB>)
39
- # completions must be prefixed with the flag
40
- setopt local_options BASH_REMATCH
41
- if [[ "\${lastParam}" =~ '-.*=' ]]; then
42
- # We are dealing with a flag with an =
43
- flagPrefix="-P \${BASH_REMATCH}"
44
- fi
45
-
46
- # Prepare the command to obtain completions, ensuring arguments are quoted for eval
47
- local -a args_to_quote=("\${(@)words[2,-1]}")
48
- if [ "\${lastChar}" = "" ] && [ "\${args_to_quote[-1]}" != "" ]; then
49
- # If the last parameter is complete (there is a space following it)
50
- # We add an extra empty parameter so we can indicate this to the go completion code.
51
- __${t}_debug "Adding extra empty parameter"
52
- args_to_quote+=("")
53
- fi
54
-
55
- # Use Zsh's (q) flag to quote each argument safely for eval
56
- local quoted_args=("\${(@q)args_to_quote}")
57
-
58
- # Join the main command and the quoted arguments into a single string for eval
59
- requestComp="${i} complete -- \${quoted_args[*]}"
60
-
61
- __${t}_debug "About to call: eval \${requestComp}"
62
-
63
- # Use eval to handle any environment variables and such
64
- out=$(eval \${requestComp} 2>/dev/null)
65
- __${t}_debug "completion output: \${out}"
66
-
67
- # Extract the directive integer following a : from the last line
68
- local lastLine
69
- while IFS='
70
- ' read -r line; do
71
- lastLine=\${line}
72
- done < <(printf "%s
73
- " "\${out[@]}")
74
- __${t}_debug "last line: \${lastLine}"
75
-
76
- if [ "\${lastLine[1]}" = : ]; then
77
- directive=\${lastLine[2,-1]}
78
- # Remove the directive including the : and the newline
79
- local suffix
80
- (( suffix=\${#lastLine}+2))
81
- out=\${out[1,-$suffix]}
82
- else
83
- # There is no directive specified. Leave $out as is.
84
- __${t}_debug "No directive found. Setting to default"
85
- directive=0
86
- fi
87
-
88
- __${t}_debug "directive: \${directive}"
89
- __${t}_debug "completions: \${out}"
90
- __${t}_debug "flagPrefix: \${flagPrefix}"
91
-
92
- if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
93
- __${t}_debug "Completion received error. Ignoring completions."
94
- return
95
- fi
96
-
97
- local activeHelpMarker="%"
98
- local endIndex=\${#activeHelpMarker}
99
- local startIndex=$((\${#activeHelpMarker}+1))
100
- local hasActiveHelp=0
101
- while IFS='
102
- ' read -r comp; do
103
- # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
104
- if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
105
- __${t}_debug "ActiveHelp found: $comp"
106
- comp="\${comp[$startIndex,-1]}"
107
- if [ -n "$comp" ]; then
108
- compadd -x "\${comp}"
109
- __${t}_debug "ActiveHelp will need delimiter"
110
- hasActiveHelp=1
111
- fi
112
- continue
113
- fi
114
-
115
- if [ -n "$comp" ]; then
116
- # If requested, completions are returned with a description.
117
- # The description is preceded by a TAB character.
118
- # For zsh's _describe, we need to use a : instead of a TAB.
119
- # We first need to escape any : as part of the completion itself.
120
- comp=\${comp//:/\\:}
121
-
122
- local tab="$(printf '\\t')"
123
- comp=\${comp//$tab/:}
124
-
125
- __${t}_debug "Adding completion: \${comp}"
126
- completions+=\${comp}
127
- lastComp=$comp
128
- fi
129
- done < <(printf "%s
130
- " "\${out[@]}")
131
-
132
- # Add a delimiter after the activeHelp statements, but only if:
133
- # - there are completions following the activeHelp statements, or
134
- # - file completion will be performed (so there will be choices after the activeHelp)
135
- if [ $hasActiveHelp -eq 1 ]; then
136
- if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
137
- __${t}_debug "Adding activeHelp delimiter"
138
- compadd -x "--"
139
- hasActiveHelp=0
140
- fi
141
- fi
142
-
143
- if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
144
- __${t}_debug "Activating nospace."
145
- noSpace="-S ''"
146
- fi
147
-
148
- if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
149
- __${t}_debug "Activating keep order."
150
- keepOrder="-V"
151
- fi
152
-
153
- if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
154
- # File extension filtering
155
- local filteringCmd
156
- filteringCmd='_files'
157
- for filter in \${completions[@]}; do
158
- if [ \${filter[1]} != '*' ]; then
159
- # zsh requires a glob pattern to do file filtering
160
- filter="\\*.$filter"
161
- fi
162
- filteringCmd+=" -g $filter"
163
- done
164
- filteringCmd+=" \${flagPrefix}"
165
-
166
- __${t}_debug "File filtering command: $filteringCmd"
167
- _arguments '*:filename:'"$filteringCmd"
168
- elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
169
- # File completion for directories only
170
- local subdir
171
- subdir="\${completions[1]}"
172
- if [ -n "$subdir" ]; then
173
- __${t}_debug "Listing directories in $subdir"
174
- pushd "\${subdir}" >/dev/null 2>&1
175
- else
176
- __${t}_debug "Listing directories in ."
177
- fi
178
-
179
- local result
180
- _arguments '*:dirname:_files -/'" \${flagPrefix}"
181
- result=$?
182
- if [ -n "$subdir" ]; then
183
- popd >/dev/null 2>&1
184
- fi
185
- return $result
186
- else
187
- __${t}_debug "Calling _describe"
188
- if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
189
- __${t}_debug "_describe found some completions"
190
-
191
- # Return the success of having called _describe
192
- return 0
193
- else
194
- __${t}_debug "_describe did not find completions."
195
- __${t}_debug "Checking if we should do file completion."
196
- if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
197
- __${t}_debug "deactivating file completion"
198
-
199
- # Return 0 to indicate completion is finished and prevent zsh from
200
- # trying other completion algorithms (which could cause hanging).
201
- # We use NoFileComp directive to explicitly disable file completion.
202
- return 0
203
- else
204
- # Perform file completion
205
- __${t}_debug "Activating file completion"
206
-
207
- # We must return the result of this command, so it must be the
208
- # last command, or else we must store its result to return it.
209
- _arguments '*:filename:_files'" \${flagPrefix}"
210
- fi
211
- fi
212
- fi
213
- }
214
-
215
- # don't run the completion function when being sourced or eval-ed
216
- if [ "\${funcstack[1]}" = "_${t}" ]; then
217
- _${t}
218
- fi
219
- `}function v(t,i){let e=t.replace(/[-:]/g,"_");return`# bash completion for ${t}
220
-
221
- # Define shell completion directives
222
- readonly ShellCompDirectiveError=${n.ShellCompDirectiveError}
223
- readonly ShellCompDirectiveNoSpace=${n.ShellCompDirectiveNoSpace}
224
- readonly ShellCompDirectiveNoFileComp=${n.ShellCompDirectiveNoFileComp}
225
- readonly ShellCompDirectiveFilterFileExt=${n.ShellCompDirectiveFilterFileExt}
226
- readonly ShellCompDirectiveFilterDirs=${n.ShellCompDirectiveFilterDirs}
227
- readonly ShellCompDirectiveKeepOrder=${n.ShellCompDirectiveKeepOrder}
228
-
229
- # Function to debug completion
230
- __${e}_debug() {
231
- if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
232
- echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
233
- fi
234
- }
235
-
236
- # Function to handle completions
237
- __${e}_complete() {
238
- local cur prev words cword
239
- _get_comp_words_by_ref -n "=:" cur prev words cword
240
-
241
- local requestComp out directive
242
-
243
- # Build the command to get completions
244
- requestComp="${i} complete -- \${words[@]:1}"
245
-
246
- # Add an empty parameter if the last parameter is complete
247
- if [[ -z "$cur" ]]; then
248
- requestComp="$requestComp ''"
249
- fi
250
-
251
- # Get completions from the program
252
- out=$(eval "$requestComp" 2>/dev/null)
253
-
254
- # Extract directive if present
255
- directive=0
256
- if [[ "$out" == *:* ]]; then
257
- directive=\${out##*:}
258
- out=\${out%:*}
259
- fi
260
-
261
- # Process completions based on directive
262
- if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
263
- # Error, no completion
264
- return
265
- fi
266
-
267
- # Apply directives
268
- if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
269
- compopt -o nospace
270
- fi
271
- if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
272
- compopt -o nosort
273
- fi
274
- if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
275
- compopt +o default
276
- fi
277
-
278
- # Handle file extension filtering
279
- if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
280
- local filter=""
281
- for ext in $out; do
282
- filter="$filter|$ext"
283
- done
284
- filter="\\.($filter)"
285
- compopt -o filenames
286
- COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
287
- return
288
- fi
289
-
290
- # Handle directory filtering
291
- if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
292
- compopt -o dirnames
293
- COMPREPLY=( $(compgen -d -- "$cur") )
294
- return
295
- fi
296
-
297
- # Process completions
298
- local IFS=$'\\n'
299
- local tab=$(printf '\\t')
300
-
301
- # Parse completions with descriptions
302
- local completions=()
303
- while read -r comp; do
304
- if [[ "$comp" == *$tab* ]]; then
305
- # Split completion and description
306
- local value=\${comp%%$tab*}
307
- local desc=\${comp#*$tab}
308
- completions+=("$value")
309
- else
310
- completions+=("$comp")
311
- fi
312
- done <<< "$out"
313
-
314
- # Return completions
315
- COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
316
- }
317
-
318
- # Register completion function
319
- complete -F __${e}_complete ${t}
320
- `}function C(t,i){let e=t.replace(/[-:]/g,"_"),o=n.ShellCompDirectiveError,l=n.ShellCompDirectiveNoSpace,r=n.ShellCompDirectiveNoFileComp,s=n.ShellCompDirectiveFilterFileExt,a=n.ShellCompDirectiveFilterDirs;return`# fish completion for ${t} -*- shell-script -*-
321
-
322
- function __${e}_debug
323
- set -l file "$BASH_COMP_DEBUG_FILE"
324
- if test -n "$file"
325
- echo "$argv" >> $file
326
- end
327
- end
328
-
329
- function __${e}_perform_completion
330
- __${e}_debug "Starting __${e}_perform_completion"
331
-
332
- # Extract all args except the last one
333
- set -l args (commandline -opc)
334
- # Extract the token currently being completed (may be empty on a trailing space)
335
- set -l lastArg (commandline -ct)
336
-
337
- __${e}_debug "args: $args"
338
- __${e}_debug "last arg: $lastArg"
339
-
340
- # Pass each arg as its own token (no string join/eval, which would collapse multi-segment paths); quote "$lastArg" so an empty trailing token is still sent.
341
- __${e}_debug "Calling ${i} complete -- $args[2..-1] $lastArg"
342
- set -l results (${i} complete -- $args[2..-1] "$lastArg" 2> /dev/null)
343
-
344
- # Some programs may output extra empty lines after the directive.
345
- # Let's ignore them or else it will break completion.
346
- # Ref: https://github.com/spf13/cobra/issues/1279
347
- for line in $results[-1..1]
348
- if test (string trim -- $line) = ""
349
- # Found an empty line, remove it
350
- set results $results[1..-2]
351
- else
352
- # Found non-empty line, we have our proper output
353
- break
354
- end
355
- end
356
-
357
- set -l comps $results[1..-2]
358
- set -l directiveLine $results[-1]
359
-
360
- # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
361
- # completions must be prefixed with the flag
362
- set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
363
-
364
- __${e}_debug "Comps: $comps"
365
- __${e}_debug "DirectiveLine: $directiveLine"
366
- __${e}_debug "flagPrefix: $flagPrefix"
367
-
368
- for comp in $comps
369
- printf "%s%s\\n" "$flagPrefix" "$comp"
370
- end
371
-
372
- printf "%s\\n" "$directiveLine"
373
- end
374
-
375
- # This function limits calls to __${e}_perform_completion, by caching the result
376
- function __${e}_perform_completion_once
377
- __${e}_debug "Starting __${e}_perform_completion_once"
378
-
379
- if test -n "$__${e}_perform_completion_once_result"
380
- __${e}_debug "Seems like a valid result already exists, skipping __${e}_perform_completion"
381
- return 0
382
- end
383
-
384
- set --global __${e}_perform_completion_once_result (__${e}_perform_completion)
385
- if test -z "$__${e}_perform_completion_once_result"
386
- __${e}_debug "No completions, probably due to a failure"
387
- return 1
388
- end
389
-
390
- __${e}_debug "Performed completions and set __${e}_perform_completion_once_result"
391
- return 0
392
- end
393
-
394
- # This function is used to clear the cached result after completions are run
395
- function __${e}_clear_perform_completion_once_result
396
- __${e}_debug ""
397
- __${e}_debug "========= clearing previously set __${e}_perform_completion_once_result variable =========="
398
- set --erase __${e}_perform_completion_once_result
399
- __${e}_debug "Successfully erased the variable __${e}_perform_completion_once_result"
400
- end
401
-
402
- function __${e}_requires_order_preservation
403
- __${e}_debug ""
404
- __${e}_debug "========= checking if order preservation is required =========="
405
-
406
- __${e}_perform_completion_once
407
- if test -z "$__${e}_perform_completion_once_result"
408
- __${e}_debug "Error determining if order preservation is required"
409
- return 1
410
- end
411
-
412
- set -l directive (string sub --start 2 $__${e}_perform_completion_once_result[-1])
413
- __${e}_debug "Directive is: $directive"
414
-
415
- set -l shellCompDirectiveKeepOrder ${n.ShellCompDirectiveKeepOrder}
416
- set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
417
- __${e}_debug "Keeporder is: $keeporder"
418
-
419
- if test $keeporder -ne 0
420
- __${e}_debug "This does require order preservation"
421
- return 0
422
- end
423
-
424
- __${e}_debug "This doesn't require order preservation"
425
- return 1
426
- end
427
-
428
- # This function does two things:
429
- # - Obtain the completions and store them in the global __${e}_comp_results
430
- # - Return false if file completion should be performed
431
- function __${e}_prepare_completions
432
- __${e}_debug ""
433
- __${e}_debug "========= starting completion logic =========="
434
-
435
- # Start fresh
436
- set --erase __${e}_comp_results
437
-
438
- __${e}_perform_completion_once
439
- __${e}_debug "Completion results: $__${e}_perform_completion_once_result"
440
-
441
- if test -z "$__${e}_perform_completion_once_result"
442
- __${e}_debug "No completion, probably due to a failure"
443
- # Might as well do file completion, in case it helps
444
- return 1
445
- end
446
-
447
- set -l directive (string sub --start 2 $__${e}_perform_completion_once_result[-1])
448
- set --global __${e}_comp_results $__${e}_perform_completion_once_result[1..-2]
449
-
450
- __${e}_debug "Completions are: $__${e}_comp_results"
451
- __${e}_debug "Directive is: $directive"
452
-
453
- set -l shellCompDirectiveError ${o}
454
- set -l shellCompDirectiveNoSpace ${l}
455
- set -l shellCompDirectiveNoFileComp ${r}
456
- set -l shellCompDirectiveFilterFileExt ${s}
457
- set -l shellCompDirectiveFilterDirs ${a}
458
-
459
- if test -z "$directive"
460
- set directive 0
461
- end
462
-
463
- set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
464
- if test $compErr -eq 1
465
- __${e}_debug "Received error directive: aborting."
466
- # Might as well do file completion, in case it helps
467
- return 1
468
- end
469
-
470
- set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
471
- set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
472
- if test $filefilter -eq 1; or test $dirfilter -eq 1
473
- __${e}_debug "File extension filtering or directory filtering not supported"
474
- # Do full file completion instead
475
- return 1
476
- end
477
-
478
- set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
479
- set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
480
-
481
- __${e}_debug "nospace: $nospace, nofiles: $nofiles"
482
-
483
- # If we want to prevent a space, or if file completion is NOT disabled,
484
- # we need to count the number of valid completions.
485
- # To do so, we will filter on prefix as the completions we have received
486
- # may not already be filtered so as to allow fish to match on different
487
- # criteria than the prefix.
488
- if test $nospace -ne 0; or test $nofiles -eq 0
489
- set -l prefix (commandline -t | string escape --style=regex)
490
- __${e}_debug "prefix: $prefix"
491
-
492
- set -l completions (string match -r -- "^$prefix.*" $__${e}_comp_results)
493
- set --global __${e}_comp_results $completions
494
- __${e}_debug "Filtered completions are: $__${e}_comp_results"
495
-
496
- # Important not to quote the variable for count to work
497
- set -l numComps (count $__${e}_comp_results)
498
- __${e}_debug "numComps: $numComps"
499
-
500
- if test $numComps -eq 1; and test $nospace -ne 0
501
- # We must first split on \\t to get rid of the descriptions to be
502
- # able to check what the actual completion will be.
503
- # We don't need descriptions anyway since there is only a single
504
- # real completion which the shell will expand immediately.
505
- set -l split (string split --max 1 "\\t" $__${e}_comp_results[1])
506
-
507
- # Fish won't add a space if the completion ends with any
508
- # of the following characters: @=/:.,
509
- set -l lastChar (string sub -s -1 -- $split)
510
- if not string match -r -q "[@=/:.,]" -- "$lastChar"
511
- # In other cases, to support the "nospace" directive we trick the shell
512
- # by outputting an extra, longer completion.
513
- __${e}_debug "Adding second completion to perform nospace directive"
514
- set --global __${e}_comp_results $split[1] $split[1].
515
- __${e}_debug "Completions are now: $__${e}_comp_results"
516
- end
517
- end
518
-
519
- if test $numComps -eq 0; and test $nofiles -eq 0
520
- # To be consistent with bash and zsh, we only trigger file
521
- # completion when there are no other completions
522
- __${e}_debug "Requesting file completion"
523
- return 1
524
- end
525
- end
526
-
527
- return 0
528
- end
529
-
530
- # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
531
- # so we can properly delete any completions provided by another script.
532
- # Only do this if the program can be found, or else fish may print some errors; besides,
533
- # the existing completions will only be loaded if the program can be found.
534
- if type -q "${t}"
535
- # The space after the program name is essential to trigger completion for the program
536
- # and not completion of the program name itself.
537
- # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
538
- complete --do-complete "${t} " > /dev/null 2>&1
539
- end
540
-
541
- # Remove any pre-existing completions for the program since we will be handling all of them.
542
- complete -c ${t} -e
543
-
544
- # This will get called after the two calls below and clear the cached result
545
- complete -c ${t} -n '__${e}_clear_perform_completion_once_result'
546
- # The call to __${e}_prepare_completions will setup __${e}_comp_results
547
- # which provides the program's completion choices.
548
- # If this doesn't require order preservation, we don't use the -k flag
549
- complete -c ${t} -n 'not __${e}_requires_order_preservation && __${e}_prepare_completions' -f -a '$__${e}_comp_results'
550
- # Otherwise we use the -k flag
551
- complete -k -c ${t} -n '__${e}_requires_order_preservation && __${e}_prepare_completions' -f -a '$__${e}_comp_results'
552
- `}function b(t,i){let e=t.replace(/[-:]/g,"_");return`# powershell completion for ${t} -*- shell-script -*-
553
-
554
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
555
- function __${t}_debug {
556
- if ($env:BASH_COMP_DEBUG_FILE) {
557
- "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
558
- }
559
- }
560
-
561
- filter __${t}_escapeStringWithSpecialChars {
562
- $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
563
- }
564
-
565
- [scriptblock]$__${e}CompleterBlock = {
566
- param(
567
- $WordToComplete,
568
- $CommandAst,
569
- $CursorPosition
570
- )
571
-
572
- # Get the current command line and convert into a string
573
- $Command = $CommandAst.CommandElements
574
- $Command = "$Command"
575
-
576
- __${t}_debug ""
577
- __${t}_debug "========= starting completion logic =========="
578
- __${t}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
579
-
580
- # The user could have moved the cursor backwards on the command-line.
581
- # We need to trigger completion from the $CursorPosition location, so we need
582
- # to truncate the command-line ($Command) up to the $CursorPosition location.
583
- # Make sure the $Command is longer then the $CursorPosition before we truncate.
584
- # This happens because the $Command does not include the last space.
585
- if ($Command.Length -gt $CursorPosition) {
586
- $Command = $Command.Substring(0, $CursorPosition)
587
- }
588
- __${t}_debug "Truncated command: $Command"
589
-
590
- $ShellCompDirectiveError=${n.ShellCompDirectiveError}
591
- $ShellCompDirectiveNoSpace=${n.ShellCompDirectiveNoSpace}
592
- $ShellCompDirectiveNoFileComp=${n.ShellCompDirectiveNoFileComp}
593
- $ShellCompDirectiveFilterFileExt=${n.ShellCompDirectiveFilterFileExt}
594
- $ShellCompDirectiveFilterDirs=${n.ShellCompDirectiveFilterDirs}
595
- $ShellCompDirectiveKeepOrder=${n.ShellCompDirectiveKeepOrder}
596
-
597
- # Prepare the command to request completions for the program.
598
- # Split the command at the first space to separate the program and arguments.
599
- $Program, $Arguments = $Command.Split(" ", 2)
600
-
601
- $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
602
- __${t}_debug "QuotedArgs: $QuotedArgs"
603
-
604
- $RequestComp = "& ${i} complete '--' $QuotedArgs"
605
- __${t}_debug "RequestComp: $RequestComp"
606
-
607
- # we cannot use $WordToComplete because it
608
- # has the wrong values if the cursor was moved
609
- # so use the last argument
610
- if ($WordToComplete -ne "" ) {
611
- $WordToComplete = $Arguments.Split(" ")[-1]
612
- }
613
- __${t}_debug "New WordToComplete: $WordToComplete"
614
-
615
-
616
- # Check for flag with equal sign
617
- $IsEqualFlag = ($WordToComplete -Like "--*=*" )
618
- if ( $IsEqualFlag ) {
619
- __${t}_debug "Completing equal sign flag"
620
- # Remove the flag part
621
- $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
622
- }
623
- $HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
624
- __${t}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
625
-
626
- if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
627
- # If the last parameter is complete (there is a space following it)
628
- # We add an extra empty parameter so we can indicate this to the go method.
629
- __${t}_debug "Adding extra empty parameter"
630
- # PowerShell 7.2+ changed the way how the arguments are passed to executables,
631
- # so for pre-7.2 or when Legacy argument passing is enabled we need to use
632
- if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
633
- ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
634
- (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
635
- $PSNativeCommandArgumentPassing -eq 'Legacy')) {
636
- $RequestComp="$RequestComp" + ' \`"\`"'
637
- } else {
638
- $RequestComp = "$RequestComp" + ' ""'
639
- }
640
- }
641
-
642
- __${t}_debug "Calling $RequestComp"
643
- # First disable ActiveHelp which is not supported for Powershell
644
- $env:ActiveHelp = 0
645
-
646
- # call the command store the output in $out and redirect stderr and stdout to null
647
- # $Out is an array contains each line per element
648
- Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
649
-
650
- # get directive from last line
651
- [int]$Directive = $Out[-1].TrimStart(':')
652
- if ($Directive -eq "") {
653
- # There is no directive specified
654
- $Directive = 0
655
- }
656
- __${t}_debug "The completion directive is: $Directive"
657
-
658
- # remove directive (last element) from out
659
- $Out = $Out | Where-Object { $_ -ne $Out[-1] }
660
- __${t}_debug "The completions are: $Out"
661
-
662
- if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
663
- # Error code. No completion.
664
- __${t}_debug "Received error from custom completion go code"
665
- return
666
- }
667
-
668
- $Longest = 0
669
- [Array]$Values = $Out | ForEach-Object {
670
- # Split the output in name and description
671
- $Name, $Description = $_.Split("\`t", 2)
672
- __${t}_debug "Name: $Name Description: $Description"
673
-
674
- # Look for the longest completion so that we can format things nicely
675
- if ($Longest -lt $Name.Length) {
676
- $Longest = $Name.Length
677
- }
678
-
679
- # Set the description to a one space string if there is none set.
680
- # This is needed because the CompletionResult does not accept an empty string as argument
681
- if (-Not $Description) {
682
- $Description = " "
683
- }
684
- @{ Name = "$Name"; Description = "$Description" }
685
- }
686
-
687
-
688
- $Space = " "
689
- if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
690
- # remove the space here
691
- __${t}_debug "ShellCompDirectiveNoSpace is called"
692
- $Space = ""
693
- }
694
-
695
- if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
696
- (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
697
- __${t}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
698
-
699
- # return here to prevent the completion of the extensions
700
- return
701
- }
702
-
703
- $Values = $Values | Where-Object {
704
- # filter the result
705
- $_.Name -like "$WordToComplete*"
706
-
707
- # Join the flag back if we have an equal sign flag
708
- if ( $IsEqualFlag ) {
709
- __${t}_debug "Join the equal sign flag back to the completion value"
710
- $_.Name = $Flag + "=" + $_.Name
711
- }
712
- }
713
-
714
- # we sort the values in ascending order by name if keep order isn't passed
715
- if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
716
- $Values = $Values | Sort-Object -Property Name
717
- }
718
-
719
- if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
720
- __${t}_debug "ShellCompDirectiveNoFileComp is called"
721
-
722
- if ($Values.Length -eq 0) {
723
- # Just print an empty string here so the
724
- # shell does not start to complete paths.
725
- # We cannot use CompletionResult here because
726
- # it does not accept an empty string as argument.
727
- ""
728
- return
729
- }
730
- }
731
-
732
- # Get the current mode
733
- $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
734
- __${t}_debug "Mode: $Mode"
735
-
736
- $Values | ForEach-Object {
737
-
738
- # store temporary because switch will overwrite $_
739
- $comp = $_
740
-
741
- # PowerShell supports three different completion modes
742
- # - TabCompleteNext (default windows style - on each key press the next option is displayed)
743
- # - Complete (works like bash)
744
- # - MenuComplete (works like zsh)
745
- # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
746
-
747
- # CompletionResult Arguments:
748
- # 1) CompletionText text to be used as the auto completion result
749
- # 2) ListItemText text to be displayed in the suggestion list
750
- # 3) ResultType type of completion result
751
- # 4) ToolTip text for the tooltip with details about the object
752
-
753
- switch ($Mode) {
754
-
755
- # bash like
756
- "Complete" {
757
-
758
- if ($Values.Length -eq 1) {
759
- __${t}_debug "Only one completion left"
760
-
761
- # insert space after value
762
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
763
-
764
- } else {
765
- # Add the proper number of spaces to align the descriptions
766
- while($comp.Name.Length -lt $Longest) {
767
- $comp.Name = $comp.Name + " "
768
- }
769
-
770
- # Check for empty description and only add parentheses if needed
771
- if ($($comp.Description) -eq " " ) {
772
- $Description = ""
773
- } else {
774
- $Description = " ($($comp.Description))"
775
- }
776
-
777
- [System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
778
- }
779
- }
780
-
781
- # zsh like
782
- "MenuComplete" {
783
- # insert space after value
784
- # MenuComplete will automatically show the ToolTip of
785
- # the highlighted value at the bottom of the suggestions.
786
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
787
- }
788
-
789
- # TabCompleteNext and in case we get something unknown
790
- Default {
791
- # Like MenuComplete but we don't want to add a space here because
792
- # the user need to press space anyway to get the completion.
793
- # Description will not be shown because that's not possible with TabCompleteNext
794
- [System.Management.Automation.CompletionResult]::new($($comp.Name | __${t}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
795
- }
796
- }
797
-
798
- }
799
- }
800
-
801
- Register-ArgumentCompleter -CommandName '${t}' -ScriptBlock $__${e}CompleterBlock
802
- `}const n={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,ShellCompDirectiveDefault:0};var w=class{name;variadic;command;handler;constructor(t,i,e,o=!1){this.command=t,this.name=i,this.handler=e,this.variadic=o}},D=class{value;description;command;handler;alias;isBoolean;constructor(t,i,e,o,l,r){this.command=t,this.value=i,this.description=e,this.handler=o,this.alias=l,this.isBoolean=r}},m=class{value;description;options=new Map;arguments=new Map;parent;constructor(t,i){this.value=t,this.description=i}option(t,i,e,o){let l,r,s;typeof e=="function"?(l=e,r=o,s=!1):typeof e=="string"?(l=void 0,r=e,s=!0):(l=void 0,r=void 0,s=!0);let a=new D(this,t,i,l,r,s);return this.options.set(t,a),this}argument(t,i,e=!1){let o=new w(this,t,i,e);return this.arguments.set(t,o),this}},S=class extends m{commands=new Map;completions=[];directive=n.ShellCompDirectiveDefault;constructor(){super("","")}command(t,i){let e=new m(t,i);return this.commands.set(t,e),e}stripOptions(t){let i=[],e=0;for(;e<t.length;){let o=t[e];if(o.startsWith("-")){e++;let l=!1,r=this.findOption(this,o);if(r)l=r.isBoolean??!1;else for(let[,s]of this.commands){let a=this.findOption(s,o);if(a){l=a.isBoolean??!1;break}}!l&&e<t.length&&!t[e].startsWith("-")&&e++}else i.push(o),e++}return i}matchCommand(t){t=this.stripOptions(t);let i=[],e=[],o=null;for(let l=0;l<t.length;l++){let r=t[l];i.push(r);let s=this.commands.get(i.join(" "));if(s)o=s;else{e=t.slice(l,t.length);break}}return[o||this,e]}shouldCompleteFlags(t,i){if(i.startsWith("-"))return!0;if(t?.startsWith("-")){let e=this.findOption(this,t);if(!e){for(let[,o]of this.commands)if(e=this.findOption(o,t),e)break}return!(e&&e.isBoolean)}return!1}shouldCompleteCommands(t){return!t.startsWith("-")}handleFlagCompletion(t,i,e,o){let l;if(e.includes("=")){let[r]=e.split("=");l=r}else if(o?.startsWith("-")){let r=this.findOption(t,o);r&&!r.isBoolean&&(l=o)}if(l){let r=this.findOption(t,l);if(r?.handler){let s=[];r.handler.call(r,(a,c)=>s.push({value:a,description:c}),t.options),this.completions=s}return}if(e.startsWith("-")){let r=e.startsWith("-")&&!e.startsWith("--"),s=e.replace(/^-+/,"");for(let[a,c]of t.options)r&&c.alias&&`-${c.alias}`.startsWith(e)?this.completions.push({value:`-${c.alias}`,description:c.description}):!r&&a.startsWith(s)&&this.completions.push({value:`--${a}`,description:c.description})}}findOption(t,i){let e=t.options.get(i);if(e||(e=t.options.get(i.replace(/^-+/,"")),e))return e;for(let[o,l]of t.options)if(l.alias&&`-${l.alias}`===i)return l}handleCommandCompletion(t,i){let e=this.stripOptions(t);for(let[o,l]of this.commands){if(o==="")continue;let r=o.split(" ");r.slice(0,e.length).every((s,a)=>s===e[a])&&r[e.length]?.startsWith(i)&&this.completions.push({value:r[e.length],description:l.description})}}handlePositionalCompletion(t,i){let e=this.stripOptions(i),o=t.value.split(" ").length,l=Math.max(0,e.length-o),r=Array.from(t.arguments.entries());if(r.length>0){let s;if(l<r.length){let[a,c]=r[l];s=c}else{let a=r[r.length-1][1];a.variadic&&(s=a)}if(s&&s.handler&&typeof s.handler=="function"){let a=[];s.handler.call(s,(c,d)=>a.push({value:c,description:d}),t.options),this.completions.push(...a)}}}complete(t){this.directive=n.ShellCompDirectiveNoFileComp;let i=new Set;this.completions.filter(e=>i.has(e.value)?!1:(i.add(e.value),!0)).filter(e=>{if(t.includes("=")){let[,o]=t.split("=");return e.value.startsWith(o)}return e.value.startsWith(t)}).forEach(e=>console.log(`${e.value} ${e.description??""}`)),console.log(`:${this.directive}`)}parse(t){this.completions=[];let i=t[t.length-1]==="";i&&t.pop();let e=t[t.length-1]||"",o=t.slice(0,-1);i&&(e!==""&&o.push(e),e="");let[l]=this.matchCommand(o),r=o[o.length-1];this.shouldCompleteFlags(r,e)?this.handleFlagCompletion(l,o,e,r):(this.shouldCompleteCommands(e)&&this.handleCommandCompletion(o,e),l&&l.arguments.size>0&&this.handlePositionalCompletion(l,o)),this.complete(e)}setup(t,i,e){switch(f(e==="zsh"||e==="bash"||e==="fish"||e==="powershell","Unsupported shell"),e){case"zsh":{let o=g(t,i);console.log(o);break}case"bash":{let o=v(t,i);console.log(o);break}case"fish":{let o=C(t,i);console.log(o);break}case"powershell":{let o=b(t,i);console.log(o);break}}}};const y=new S;export{w as Argument,m as Command,D as Option,S as RootCommand,n as ShellCompDirective,y as default};
1
+ /*!
2
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
3
+ * SPDX-License-Identifier: BSD-3-Clause
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this
9
+ * list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ * this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ * 3. Neither the name of the copyright holder nor the names of its contributors
14
+ * may be used to endorse or promote products derived from this software without
15
+ * specific prior written permission.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */function B(e,l){let i=e.slice(0,l).split(/\r?\n/);return[i.length,i.pop().length+1]}function L(e,l,i){let n=e.split(/\r?\n/),a="",s=(Math.log10(l+1)|0)+1;for(let r=l-1;r<=l+1;r++){let f=n[r-1];f&&(a+=r.toString().padEnd(s," "),a+=": ",a+=f,a+=`
28
+ `,r===l&&(a+=" ".repeat(s+i+2),a+=`^
29
+ `))}return a}class u extends Error{line;column;codeblock;constructor(l,i){const[n,a]=B(i.toml,i.ptr),s=L(i.toml,n,a);super(`Invalid TOML document: ${l}
30
+
31
+ ${s}`,i),this.line=n,this.column=a,this.codeblock=s}static x(l,i,n){throw new u(l,{toml:i.s,ptr:n??i.p})}}function I(e){let l=e.p,i=e.s.charCodeAt(e.p++),n=i,a=i===39,s=i===e.s.charCodeAt(e.p)&&i===e.s.charCodeAt(e.p+1);s&&((i=e.s.charCodeAt(e.p+=2))===10?e.p++:i===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let r="",f=e.p,t=0;for(;e.p<e.s.length;e.p++)if(i=e.s.charCodeAt(e.p),s&&(i===10||i===13&&e.s.charCodeAt(e.p+1)===10))t=t&&3;else if(i<32&&i!==9||i===127)u.x("control characters are not allowed in strings",e);else if((!t||t===3)&&i===n&&(!s||e.s.charCodeAt(e.p+1)===n&&e.s.charCodeAt(e.p+2)===n)){if(s&&(e.s.charCodeAt(e.p+3)===n&&e.p++,e.s.charCodeAt(e.p+3)===n&&e.p++),!t){let o=e.s.slice(f,e.p);r=r?r+o:o}return e.p+=s?3:1,r}else if(!t)!a&&i===92&&(r+=e.s.slice(f,f=e.p),t=1);else if(t===1)if(i===120||i===117||i===85){let o=e.p++-1,p=0,d=i===120?2:i===117?4:8;for(let m=0;m<d;m++,e.p++){let A=e.s.charCodeAt(e.p),y=A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1;y<0&&u.x("invalid non-hex character in unicode escape",e),p=p<<4|y}(p<0||p>1114111||p>=55296&&p<=57343)&&u.x("invalid unicode escape",e,o),r+=String.fromCodePoint(p),f=e.p--,t=0}else s&&(i===32||i===9)?t=2:(i===98?r+="\b":i===116?r+=" ":i===110?r+=`
32
+ `:i===102?r+="\f":i===114?r+="\r":i===101?r+="\x1B":i===34?r+='"':i===92?r+="\\":u.x("unrecognised escape sequence",e),f=e.p+1,t=0);else i!==32&&i!==9&&(t===2&&u.x("invalid escape: only line-ending whitespace may be escaped",e,f),t=!a&&i===92?1:0,f=e.p);u.x("unfinished string",e,l)}/*!
33
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ *
36
+ * Redistribution and use in source and binary forms, with or without
37
+ * modification, are permitted provided that the following conditions are met:
38
+ *
39
+ * 1. Redistributions of source code must retain the above copyright notice, this
40
+ * list of conditions and the following disclaimer.
41
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
42
+ * this list of conditions and the following disclaimer in the
43
+ * documentation and/or other materials provided with the distribution.
44
+ * 3. Neither the name of the copyright holder nor the names of its contributors
45
+ * may be used to endorse or promote products derived from this software without
46
+ * specific prior written permission.
47
+ *
48
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
49
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
52
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
+ */let Z=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class C extends Date{#i=!1;#l=!1;#e=null;constructor(l,i,n){let a=!0,s=!0,r="Z",f;if(typeof l=="string")if(i)e:{if(i<3){if(+l.slice(11,13)>23){l="";break e}i===2?(r=null,l+="Z"):(f=l.charCodeAt(l.length-1))!==90&&f!==122&&(r=l.slice(l.length-6)),n&&(l=l.slice(0,10)+"T"+l.slice(11))}else i===4&&(l=+l.slice(0,2)>23?"":`0000-01-01T${l}Z`);a=i!==4,s=i!==3}else{let t=l.match(Z);t?(t[1]||(a=!1,l=`0000-01-01T${l}`),s=!!t[2],s&&l[10]===" "&&(l=l.replace(" ","T")),t[2]&&+t[2]>23?l="":(r=t[3]||null,!r&&s&&(l+="Z"))):l=""}super(l),isNaN(this.getTime())||(this.#i=a,this.#l=s,this.#e=r)}isDateTime(){return this.#i&&this.#l}isLocal(){return!this.#i||!this.#l||!this.#e}isDate(){return this.#i&&!this.#l}isTime(){return this.#l&&!this.#i}isValid(){return this.#i||this.#l}toISOString(){let l=super.toISOString();if(this.isDate())return l.slice(0,10);if(this.isTime())return l.slice(11,23);if(this.#e===null)return l.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return l;let i=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return i=this.#e[0]==="-"?i:-i,new Date(this.getTime()-i*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(l,i="Z"){let n=new C(l);return n.#e=i,n}static wrapAsLocalDateTime(l){let i=new C(l);return i.#e=null,i}static wrapAsLocalDate(l){let i=new C(l);return i.#l=!1,i.#e=null,i}static wrapAsLocalTime(l){let i=new C(l);return i.#i=!1,i.#e=null,i}}function h(e,l=10){return l===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+l}function k(e,l){return e===32||e===9||e===10||e===13||l&&(e===l||e===44)||e===35}function O(e,l){let i=e.p,n=e.s.charCodeAt(e.p);if(n===91||n===123){e.d--||u.x("document contains excessively nested structures. aborting.",e);let a=n===91?V(e):P(e);return e.d++,a}return n===34||n===39?I(e):n===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&u.x("invalid value",e,i),e.p++,!0):n===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&u.x("invalid value",e,i),e.p++,!1):n===43||n===45?w(e,e.p,e.s.charCodeAt(++e.p),44-n,l):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?E(e,n,l):e.s.charCodeAt(e.p+2)===58?N(e,n,l):w(e,e.p,n,0,l)}function w(e,l,i,n,a){let s=i,r=0,f=!1;if(s===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&u.x("invalid value",e,l),e.p++,(n||1)/0;if(s===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&u.x("invalid value",e,l),e.p++,NaN;if(s===48){if(++e.p>=e.s.length||k(s=e.s.charCodeAt(e.p),a))return e.bi===!0?0n:0;if(!n){if(s===120)return v(e,l,16,a);if(s===98)return v(e,l,2,a);if(s===111)return v(e,l,8,a)}s===46?r=2:s===101||s===69?r=4:u.x("illegal leading zero",e,l)}else h(s)||u.x("invalid value",e,l);for(;++e.p<e.s.length&&(s=e.s.charCodeAt(e.p),!k(s,a));)r||(r=1),s===95?(r&1||u.x("illegal underscore",e),r+=11,f=!0):r===1&&s===46?r=2:(r===1||r===3)&&(s===101||s===69)?r=4:r===4&&(s===43||s===45)||(h(s)?r>9?r-=11:r&1||r++:u.x("illegal character in numeric literal",e));if(!r){let o=(i-48)*(n||1);return e.bi===!0?BigInt(o):o}r&1||u.x("unfinished numeric value",e,l);let t=e.s.slice(l,e.p);return f&&(t=t.replaceAll("_","")),r>1?parseFloat(t):S(e,t,10,l)}function v(e,l,i,n){let a,s=1;for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!k(a,n));)a===95?(s&1&&u.x("illegal underscore",e),s=3):h(a,i)?s&1&&s--:u.x("illegal character in numeric literal",e);s&1&&u.x("unfinished numeric value",e);let r=e.s.slice(l+2,e.p);return s&&(r=r.replaceAll("_","")),S(e,r,i,l)}function S(e,l,i,n){if(e.bi!==!0)e:{let a=parseInt(l,i);if(!Number.isSafeInteger(a)){if(e.bi)break e;u.x("integer value cannot be represented losslessly",e,n)}return a}return BigInt(i===10?l:(i===2?"0b":i===8?"0o":"0x")+l)}function E(e,l,i){let n=e.p++,a;if(!h(l)||!h(e.s.charCodeAt(e.p++))||!h(e.s.charCodeAt(e.p++))||!h(e.s.charCodeAt(e.p++)))return w(e,e.p=n,l,0,i);if(e.p+=5,h(e.s.charCodeAt(e.p++))||u.x("invalid date-time: date part is malformed",e,n),e.p>=e.s.length||((l=e.s.charCodeAt(e.p))!==32||(a=!0,!h(e.s.charCodeAt(e.p+1))))&&l!==84&&l!==116){let r=e.s.slice(n,e.p);return b(e,r,3,!1,n)}if(e.s.charCodeAt(e.p+=3)!==58&&u.x("invalid date-time: time part is malformed",e,n),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;h(e.s.charCodeAt(++e.p)););if(l=e.s.charCodeAt(e.p)){if(l===90||l===122){let r=e.s.slice(n,++e.p);return b(e,r,1,a,n,"[+00:00]")}if(l===43||l===45){let r=e.s.slice(n,e.p+=6);return b(e,r,1,a,n,!e.ld&&"["+e.s.slice(e.p-6,e.p)+"]")}}let s=e.s.slice(n,e.p);return b(e,s,2,a,n)}function N(e,l,i){let n=e.p;if(!h(l)||!h(e.s.charCodeAt(++e.p)))return w(e,--e.p,l,0,i);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;h(e.s.charCodeAt(++e.p)););let a=e.s.slice(n,e.p);return b(e,a,4,!1,n)}function b(e,l,i,n,a,s){if(e.ld){let r=new C(l,i,n);return r.isValid()||u.x("invalid date",e,a),r}try{switch(s&&(l+=s),i){case 1:return Temporal.ZonedDateTime.from(l);case 2:return Temporal.PlainDateTime.from(l);case 3:return Temporal.PlainDate.from(l);case 4:return Temporal.PlainTime.from(l)}}catch(r){u.x(r instanceof Error?r.message:""+r,e,a)}}function _(e){for(;e.p<e.s.length;e.p++){let l=e.s.charCodeAt(e.p);if(l===10)break;if(l===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(l<32&&l!==9||l===127)&&u.x("control characters are not allowed in comments",e)}}function g(e,l,i){let n;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((n=e.s.charCodeAt(e.p))===32||n===9||!l&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(i||n!==35)break;_(e)}}function T(e,l=61){let i,n=0,a=[],s,r=e.s.charCodeAt(i=e.p);do{if(r===l)return n||u.x("unexpected end of key",e),n===1&&a.push(e.s.slice(s,e.p)),e.p++,a;r===46?(n||u.x("illegal empty bare key",e),n===1&&a.push(e.s.slice(s,e.p)),n=0):!n&&(r===34||r===39)?(r===e.s.charCodeAt(e.p+1)&&r===e.s.charCodeAt(e.p+2)&&u.x("illegal quoted key: multiline strings are not allowed",e),a.push(I(e)),n=2,e.p--):r===32||r===9?n===1&&(a.push(e.s.slice(s,e.p)),n=2):n===2||r<48&&r!==45||r>57&&r<65||r>90&&r<97&&r!==95||r>122?u.x("illegal character in key",e):n||(n=1,s=e.p)}while(r=e.s.charCodeAt(++e.p));u.x("incomplete key-value: cannot find end of key",e,i)}function P(e){let l=e.p++,i=Object.create(null),n=new Set,a;for(;e.p<e.s.length;){if(g(e),(a=e.s.charCodeAt(e.p))===125)return e.p++,i;let s,r=i,f=!1,t=e.p,o=T(e);for(let d=0;d<o.length;d++){d&&(r=f?r[s]:r[s]=Object.create(null)),s=o[d],(f=Object.hasOwn(r,s))&&(typeof r[s]!="object"||n.has(r[s]))&&u.x("trying to redefine an already defined value",e,t);let m=s==="__proto__";if(e.uk&&(m||s==="constructor")){r=e.uk!==1&&u.x("document contains an unsafe property",e,t);break}!f&&m&&Object.defineProperty(r,s,{enumerable:!0,configurable:!0,writable:!0})}f&&u.x("trying to redefine an already defined value",e,t),g(e,!0,!0);let p=O(e,125);if(r&&typeof(r[s]=p)=="object"&&n.add(p),g(e),(a=e.s.charCodeAt(e.p++))===125)return i;a!==44&&u.x("expected comma or end of structure",e,e.p-1)}u.x("unfinished table",e,l)}function V(e){let l=e.p++,i=[],n;for(;e.p<e.s.length;){if(g(e),(n=e.s.charCodeAt(e.p))===93)return e.p++,i;if(i.push(O(e,93)),g(e),(n=e.s.charCodeAt(e.p++))===93)return i;n!==44&&u.x("expected comma or end of structure",e,e.p-1)}u.x("unfinished array",e,l)}function D(e,l,i,n,a){let s=i,r=n,f,t=!1,o;for(let p=0;p<l.length;p++){if(p){if(s=t?s[f]:s[f]=Object.create(null),r=(o=r[f]).c,a===0&&(o.t===1||o.t===2))return null;if(o.t===2){let d=s.length-1;s=s[d],r=r[d].c}}if(f=l[p],(t=Object.hasOwn(s,f))&&r[f]?.t===0&&r[f]?.d)return null;if(!t){let d=f==="__proto__";if(e.uk&&(d||f==="constructor"))return!1;d&&(Object.defineProperty(s,f,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(r,f,{enumerable:!0,configurable:!0,writable:!0})),r[f]={t:p<l.length-1&&a===2?3:a,d:!1,i:0,c:Object.create(null)}}}if(o=r[f],o.t!==a&&!(a===1&&o.t===3)||(a===2&&(o.d||(o.d=!0,s[f]=[]),s[f].push(s=Object.create(null)),o.c[o.i++]=o={t:1,d:!1,i:0,c:Object.create(null)}),o.d))return null;if(o.d=!0,a===1)s=t?s[f]:s[f]=Object.create(null);else if(a===0&&t)return null;return[f,s,o.c]}function j(e,l,i){(l===null||e.uk===2)&&u.x(l===null?"trying to redefine an already defined table or value":"document contains an unsafe property",e,i)}function $(e,l={}){let i={s:e,p:0,d:l.maxDepth??1e3,bi:l.integersAsBigInt??!1,ld:l.useLegacyDate??!0,uk:l.unsafeKeyBehaviour==="throw"?2:l.unsafeKeyBehaviour==="drop"?1:0},n=Object.create(null),a=Object.create(null),s,r=!1,f=n,t=a;for(e.charCodeAt(0)===65279&&i.p++,g(i);i.p<e.length;){if(e.charCodeAt(i.p)===91){let o=e.charCodeAt(++i.p)===91;s=i.p+=+o,r=!1;let p=T(i,93);o&&(e.charCodeAt(i.p)!==93&&u.x("expected end of table array declaration",i),i.p++);let d=D(i,p,n,a,o?2:1);d?(t=d[2],f=d[1]):(j(i,d,s),r=!0)}else{s=i.p;let o=T(i),p=D(i,o,f,t,0);!p&&!r&&j(i,p,s),g(i,!0,!0);let d=O(i,void 0);p&&!r&&(p[1][p[0]]=d)}g(i,!0),i.p<e.length&&(s=e.charCodeAt(i.p))!==10&&(s!==13||e.charCodeAt(i.p+1)!==10)&&u.x("each key-value declaration must be followed by an end-of-line",i),g(i)}return n}export{C as TomlDate,u as TomlError,$ as parse};