@pellux/goodvibes-sdk 0.24.0 → 0.25.1

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 (198) hide show
  1. package/dist/_internal/platform/agents/orchestrator.d.ts +2 -0
  2. package/dist/_internal/platform/agents/orchestrator.d.ts.map +1 -1
  3. package/dist/_internal/platform/agents/orchestrator.js +38 -0
  4. package/dist/_internal/platform/automation/delivery-manager.d.ts +5 -0
  5. package/dist/_internal/platform/automation/delivery-manager.d.ts.map +1 -1
  6. package/dist/_internal/platform/automation/delivery-manager.js +14 -1
  7. package/dist/_internal/platform/automation/manager-runtime.d.ts +5 -0
  8. package/dist/_internal/platform/automation/manager-runtime.d.ts.map +1 -1
  9. package/dist/_internal/platform/automation/manager-runtime.js +32 -0
  10. package/dist/_internal/platform/channels/plugin-registry.d.ts +6 -0
  11. package/dist/_internal/platform/channels/plugin-registry.d.ts.map +1 -1
  12. package/dist/_internal/platform/channels/plugin-registry.js +17 -4
  13. package/dist/_internal/platform/channels/route-manager.d.ts +7 -0
  14. package/dist/_internal/platform/channels/route-manager.d.ts.map +1 -1
  15. package/dist/_internal/platform/channels/route-manager.js +41 -3
  16. package/dist/_internal/platform/channels/surface-registry.d.ts +3 -1
  17. package/dist/_internal/platform/channels/surface-registry.d.ts.map +1 -1
  18. package/dist/_internal/platform/channels/surface-registry.js +16 -17
  19. package/dist/_internal/platform/config/schema-types.d.ts +1 -1
  20. package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
  21. package/dist/_internal/platform/control-plane/gateway.d.ts +5 -0
  22. package/dist/_internal/platform/control-plane/gateway.d.ts.map +1 -1
  23. package/dist/_internal/platform/control-plane/gateway.js +69 -4
  24. package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
  25. package/dist/_internal/platform/daemon/facade-composition.js +2 -0
  26. package/dist/_internal/platform/daemon/facade.d.ts.map +1 -1
  27. package/dist/_internal/platform/daemon/facade.js +3 -1
  28. package/dist/_internal/platform/daemon/service-manager.d.ts +5 -0
  29. package/dist/_internal/platform/daemon/service-manager.d.ts.map +1 -1
  30. package/dist/_internal/platform/daemon/service-manager.js +29 -0
  31. package/dist/_internal/platform/integrations/delivery.d.ts +5 -1
  32. package/dist/_internal/platform/integrations/delivery.d.ts.map +1 -1
  33. package/dist/_internal/platform/integrations/delivery.js +8 -1
  34. package/dist/_internal/platform/integrations/notifier.d.ts +5 -1
  35. package/dist/_internal/platform/integrations/notifier.d.ts.map +1 -1
  36. package/dist/_internal/platform/integrations/notifier.js +6 -3
  37. package/dist/_internal/platform/intelligence/lsp/service.d.ts.map +1 -1
  38. package/dist/_internal/platform/intelligence/lsp/service.js +18 -9
  39. package/dist/_internal/platform/permissions/manager.d.ts +3 -1
  40. package/dist/_internal/platform/permissions/manager.d.ts.map +1 -1
  41. package/dist/_internal/platform/permissions/manager.js +9 -5
  42. package/dist/_internal/platform/providers/anthropic-vertex.d.ts.map +1 -1
  43. package/dist/_internal/platform/providers/anthropic-vertex.js +135 -2
  44. package/dist/_internal/platform/runtime/emitters/routes.d.ts +5 -0
  45. package/dist/_internal/platform/runtime/emitters/routes.d.ts.map +1 -1
  46. package/dist/_internal/platform/runtime/emitters/routes.js +3 -0
  47. package/dist/_internal/platform/runtime/events/contracts/automation-route.d.ts +1 -0
  48. package/dist/_internal/platform/runtime/events/contracts/automation-route.d.ts.map +1 -1
  49. package/dist/_internal/platform/runtime/events/contracts/automation-route.js +7 -0
  50. package/dist/_internal/platform/runtime/events/contracts.d.ts +1 -1
  51. package/dist/_internal/platform/runtime/events/contracts.d.ts.map +1 -1
  52. package/dist/_internal/platform/runtime/events/contracts.js +3 -2
  53. package/dist/_internal/platform/runtime/events/routes.d.ts +5 -0
  54. package/dist/_internal/platform/runtime/events/routes.d.ts.map +1 -1
  55. package/dist/_internal/platform/runtime/feature-flags/flags.d.ts.map +1 -1
  56. package/dist/_internal/platform/runtime/feature-flags/flags.js +17 -21
  57. package/dist/_internal/platform/runtime/feature-flags/gates.d.ts +7 -0
  58. package/dist/_internal/platform/runtime/feature-flags/gates.d.ts.map +1 -0
  59. package/dist/_internal/platform/runtime/feature-flags/gates.js +38 -0
  60. package/dist/_internal/platform/runtime/feature-flags/index.d.ts +2 -0
  61. package/dist/_internal/platform/runtime/feature-flags/index.d.ts.map +1 -1
  62. package/dist/_internal/platform/runtime/feature-flags/index.js +1 -0
  63. package/dist/_internal/platform/runtime/mcp/index.d.ts +2 -1
  64. package/dist/_internal/platform/runtime/mcp/index.d.ts.map +1 -1
  65. package/dist/_internal/platform/runtime/mcp/index.js +4 -1
  66. package/dist/_internal/platform/runtime/permissions/index.d.ts +20 -1
  67. package/dist/_internal/platform/runtime/permissions/index.d.ts.map +1 -1
  68. package/dist/_internal/platform/runtime/permissions/index.js +27 -1
  69. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts +6 -0
  70. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts.map +1 -1
  71. package/dist/_internal/platform/runtime/permissions/policy-loader.js +7 -2
  72. package/dist/_internal/platform/runtime/plugins/index.d.ts +2 -1
  73. package/dist/_internal/platform/runtime/plugins/index.d.ts.map +1 -1
  74. package/dist/_internal/platform/runtime/plugins/index.js +4 -1
  75. package/dist/_internal/platform/runtime/services.d.ts +1 -0
  76. package/dist/_internal/platform/runtime/services.d.ts.map +1 -1
  77. package/dist/_internal/platform/runtime/services.js +21 -5
  78. package/dist/_internal/platform/runtime/shell-command-ops.d.ts +2 -0
  79. package/dist/_internal/platform/runtime/shell-command-ops.d.ts.map +1 -1
  80. package/dist/_internal/platform/runtime/shell-command-ops.js +4 -1
  81. package/dist/_internal/platform/runtime/tasks/index.d.ts +2 -1
  82. package/dist/_internal/platform/runtime/tasks/index.d.ts.map +1 -1
  83. package/dist/_internal/platform/runtime/tasks/index.js +2 -2
  84. package/dist/_internal/platform/runtime/tasks/manager.d.ts +5 -1
  85. package/dist/_internal/platform/runtime/tasks/manager.d.ts.map +1 -1
  86. package/dist/_internal/platform/runtime/tasks/manager.js +30 -1
  87. package/dist/_internal/platform/runtime/telemetry/index.d.ts +9 -3
  88. package/dist/_internal/platform/runtime/telemetry/index.d.ts.map +1 -1
  89. package/dist/_internal/platform/runtime/telemetry/index.js +7 -4
  90. package/dist/_internal/platform/runtime/tools/index.d.ts.map +1 -1
  91. package/dist/_internal/platform/runtime/tools/index.js +4 -1
  92. package/dist/_internal/platform/runtime/tools/types.d.ts +6 -0
  93. package/dist/_internal/platform/runtime/tools/types.d.ts.map +1 -1
  94. package/dist/_internal/platform/security/token-audit.d.ts +7 -0
  95. package/dist/_internal/platform/security/token-audit.d.ts.map +1 -1
  96. package/dist/_internal/platform/security/token-audit.js +6 -2
  97. package/dist/_internal/platform/state/mode-manager.d.ts +7 -0
  98. package/dist/_internal/platform/state/mode-manager.d.ts.map +1 -1
  99. package/dist/_internal/platform/state/mode-manager.js +25 -0
  100. package/dist/_internal/platform/tools/index.d.ts +4 -0
  101. package/dist/_internal/platform/tools/index.d.ts.map +1 -1
  102. package/dist/_internal/platform/tools/index.js +37 -23
  103. package/dist/_internal/platform/tools/shared/overflow.d.ts +3 -0
  104. package/dist/_internal/platform/tools/shared/overflow.d.ts.map +1 -1
  105. package/dist/_internal/platform/tools/shared/overflow.js +6 -2
  106. package/dist/_internal/platform/version.js +1 -1
  107. package/dist/_internal/platform/watchers/registry.d.ts +6 -0
  108. package/dist/_internal/platform/watchers/registry.d.ts.map +1 -1
  109. package/dist/_internal/platform/watchers/registry.js +35 -0
  110. package/package.json +9 -8
  111. package/vendor/bash-language-server/CHANGELOG.md +453 -0
  112. package/vendor/bash-language-server/GOODVIBES_PATCH.md +22 -0
  113. package/vendor/bash-language-server/README.md +230 -0
  114. package/vendor/bash-language-server/out/analyser.d.ts +187 -0
  115. package/vendor/bash-language-server/out/analyser.js +782 -0
  116. package/vendor/bash-language-server/out/analyser.js.map +1 -0
  117. package/vendor/bash-language-server/out/builtins.d.ts +2 -0
  118. package/vendor/bash-language-server/out/builtins.js +71 -0
  119. package/vendor/bash-language-server/out/builtins.js.map +1 -0
  120. package/vendor/bash-language-server/out/cli.d.ts +3 -0
  121. package/vendor/bash-language-server/out/cli.js +74 -0
  122. package/vendor/bash-language-server/out/cli.js.map +1 -0
  123. package/vendor/bash-language-server/out/config.d.ts +88 -0
  124. package/vendor/bash-language-server/out/config.js +96 -0
  125. package/vendor/bash-language-server/out/config.js.map +1 -0
  126. package/vendor/bash-language-server/out/executables.d.ts +19 -0
  127. package/vendor/bash-language-server/out/executables.js +86 -0
  128. package/vendor/bash-language-server/out/executables.js.map +1 -0
  129. package/vendor/bash-language-server/out/parser.d.ts +2 -0
  130. package/vendor/bash-language-server/out/parser.js +36 -0
  131. package/vendor/bash-language-server/out/parser.js.map +1 -0
  132. package/vendor/bash-language-server/out/reserved-words.d.ts +2 -0
  133. package/vendor/bash-language-server/out/reserved-words.js +33 -0
  134. package/vendor/bash-language-server/out/reserved-words.js.map +1 -0
  135. package/vendor/bash-language-server/out/server.d.ts +56 -0
  136. package/vendor/bash-language-server/out/server.js +756 -0
  137. package/vendor/bash-language-server/out/server.js.map +1 -0
  138. package/vendor/bash-language-server/out/shellcheck/config.d.ts +5 -0
  139. package/vendor/bash-language-server/out/shellcheck/config.js +17 -0
  140. package/vendor/bash-language-server/out/shellcheck/config.js.map +1 -0
  141. package/vendor/bash-language-server/out/shellcheck/directive.d.ts +18 -0
  142. package/vendor/bash-language-server/out/shellcheck/directive.js +62 -0
  143. package/vendor/bash-language-server/out/shellcheck/directive.js.map +1 -0
  144. package/vendor/bash-language-server/out/shellcheck/index.d.ts +22 -0
  145. package/vendor/bash-language-server/out/shellcheck/index.js +229 -0
  146. package/vendor/bash-language-server/out/shellcheck/index.js.map +1 -0
  147. package/vendor/bash-language-server/out/shellcheck/types.d.ts +175 -0
  148. package/vendor/bash-language-server/out/shellcheck/types.js +35 -0
  149. package/vendor/bash-language-server/out/shellcheck/types.js.map +1 -0
  150. package/vendor/bash-language-server/out/shfmt/index.d.ts +18 -0
  151. package/vendor/bash-language-server/out/shfmt/index.js +151 -0
  152. package/vendor/bash-language-server/out/shfmt/index.js.map +1 -0
  153. package/vendor/bash-language-server/out/snippets.d.ts +2 -0
  154. package/vendor/bash-language-server/out/snippets.js +671 -0
  155. package/vendor/bash-language-server/out/snippets.js.map +1 -0
  156. package/vendor/bash-language-server/out/types.d.ts +13 -0
  157. package/vendor/bash-language-server/out/types.js +12 -0
  158. package/vendor/bash-language-server/out/types.js.map +1 -0
  159. package/vendor/bash-language-server/out/util/array.d.ts +14 -0
  160. package/vendor/bash-language-server/out/util/array.js +36 -0
  161. package/vendor/bash-language-server/out/util/array.js.map +1 -0
  162. package/vendor/bash-language-server/out/util/async.d.ts +13 -0
  163. package/vendor/bash-language-server/out/util/async.js +24 -0
  164. package/vendor/bash-language-server/out/util/async.js.map +1 -0
  165. package/vendor/bash-language-server/out/util/declarations.d.ts +88 -0
  166. package/vendor/bash-language-server/out/util/declarations.js +295 -0
  167. package/vendor/bash-language-server/out/util/declarations.js.map +1 -0
  168. package/vendor/bash-language-server/out/util/discriminate.d.ts +1 -0
  169. package/vendor/bash-language-server/out/util/discriminate.js +7 -0
  170. package/vendor/bash-language-server/out/util/discriminate.js.map +1 -0
  171. package/vendor/bash-language-server/out/util/fs.d.ts +6 -0
  172. package/vendor/bash-language-server/out/util/fs.js +73 -0
  173. package/vendor/bash-language-server/out/util/fs.js.map +1 -0
  174. package/vendor/bash-language-server/out/util/logger.d.ts +35 -0
  175. package/vendor/bash-language-server/out/util/logger.js +105 -0
  176. package/vendor/bash-language-server/out/util/logger.js.map +1 -0
  177. package/vendor/bash-language-server/out/util/lsp.d.ts +5 -0
  178. package/vendor/bash-language-server/out/util/lsp.js +13 -0
  179. package/vendor/bash-language-server/out/util/lsp.js.map +1 -0
  180. package/vendor/bash-language-server/out/util/platform.d.ts +1 -0
  181. package/vendor/bash-language-server/out/util/platform.js +7 -0
  182. package/vendor/bash-language-server/out/util/platform.js.map +1 -0
  183. package/vendor/bash-language-server/out/util/sh.d.ts +16 -0
  184. package/vendor/bash-language-server/out/util/sh.js +132 -0
  185. package/vendor/bash-language-server/out/util/sh.js.map +1 -0
  186. package/vendor/bash-language-server/out/util/shebang.d.ts +10 -0
  187. package/vendor/bash-language-server/out/util/shebang.js +53 -0
  188. package/vendor/bash-language-server/out/util/shebang.js.map +1 -0
  189. package/vendor/bash-language-server/out/util/sourcing.d.ts +15 -0
  190. package/vendor/bash-language-server/out/util/sourcing.js +182 -0
  191. package/vendor/bash-language-server/out/util/sourcing.js.map +1 -0
  192. package/vendor/bash-language-server/out/util/tree-sitter.d.ts +22 -0
  193. package/vendor/bash-language-server/out/util/tree-sitter.js +110 -0
  194. package/vendor/bash-language-server/out/util/tree-sitter.js.map +1 -0
  195. package/vendor/bash-language-server/package.json +52 -0
  196. package/vendor/bash-language-server/parser.info +2 -0
  197. package/vendor/bash-language-server/tree-sitter-bash.wasm +0 -0
  198. package/scripts/postinstall-patch-minimatch.mjs +0 -285
@@ -0,0 +1,13 @@
1
+ import * as LSP from 'vscode-languageserver/node';
2
+ export declare enum CompletionItemDataType {
3
+ Builtin = 0,
4
+ Executable = 1,
5
+ ReservedWord = 2,
6
+ Symbol = 3,
7
+ Snippet = 4
8
+ }
9
+ export interface BashCompletionItem extends LSP.CompletionItem {
10
+ data: {
11
+ type: CompletionItemDataType;
12
+ };
13
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompletionItemDataType = void 0;
4
+ var CompletionItemDataType;
5
+ (function (CompletionItemDataType) {
6
+ CompletionItemDataType[CompletionItemDataType["Builtin"] = 0] = "Builtin";
7
+ CompletionItemDataType[CompletionItemDataType["Executable"] = 1] = "Executable";
8
+ CompletionItemDataType[CompletionItemDataType["ReservedWord"] = 2] = "ReservedWord";
9
+ CompletionItemDataType[CompletionItemDataType["Symbol"] = 3] = "Symbol";
10
+ CompletionItemDataType[CompletionItemDataType["Snippet"] = 4] = "Snippet";
11
+ })(CompletionItemDataType || (exports.CompletionItemDataType = CompletionItemDataType = {}));
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,yEAAO,CAAA;IACP,+EAAU,CAAA;IACV,mFAAY,CAAA;IACZ,uEAAM,CAAA;IACN,yEAAO,CAAA;AACT,CAAC,EANW,sBAAsB,sCAAtB,sBAAsB,QAMjC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Flatten a 2-dimensional array into a 1-dimensional one.
3
+ */
4
+ export declare function flattenArray<T>(nestedArray: T[][]): T[];
5
+ /**
6
+ * Remove all duplicates from the list.
7
+ * Doesn't preserve ordering.
8
+ */
9
+ export declare function uniq<A>(a: A[]): A[];
10
+ /**
11
+ * Removed all duplicates from the list based on the hash function.
12
+ * First element matching the hash function wins.
13
+ */
14
+ export declare function uniqueBasedOnHash<A extends Record<string, any>>(list: A[], elementToHash: (a: A) => string, __result?: A[]): A[];
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenArray = flattenArray;
4
+ exports.uniq = uniq;
5
+ exports.uniqueBasedOnHash = uniqueBasedOnHash;
6
+ /**
7
+ * Flatten a 2-dimensional array into a 1-dimensional one.
8
+ */
9
+ function flattenArray(nestedArray) {
10
+ return nestedArray.reduce((acc, array) => [...acc, ...array], []);
11
+ }
12
+ /**
13
+ * Remove all duplicates from the list.
14
+ * Doesn't preserve ordering.
15
+ */
16
+ function uniq(a) {
17
+ return Array.from(new Set(a));
18
+ }
19
+ /**
20
+ * Removed all duplicates from the list based on the hash function.
21
+ * First element matching the hash function wins.
22
+ */
23
+ function uniqueBasedOnHash(list, elementToHash, __result = []) {
24
+ const result = [];
25
+ const hashSet = new Set();
26
+ list.forEach((element) => {
27
+ const hash = elementToHash(element);
28
+ if (hashSet.has(hash)) {
29
+ return;
30
+ }
31
+ hashSet.add(hash);
32
+ result.push(element);
33
+ });
34
+ return result;
35
+ }
36
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/util/array.ts"],"names":[],"mappings":";;AAGA,oCAEC;AAMD,oBAEC;AAMD,8CAkBC;AArCD;;GAEG;AACH,SAAgB,YAAY,CAAI,WAAkB;IAChD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;AACnE,CAAC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAI,CAAM;IAC5B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/B,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,IAAS,EACT,aAA+B,EAC/B,WAAgB,EAAE;IAElB,MAAM,MAAM,GAAgB,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IAEjC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAM;QACR,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A collection of async utilities.
3
+ * If we ever need to add anything fancy, then https://github.com/vscode-shellcheck/vscode-shellcheck/blob/master/src/utils/async.ts
4
+ * is a good place to look.
5
+ */
6
+ type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
7
+ /**
8
+ * Debounce a function call by a given amount of time. Only the last call
9
+ * will be resolved.
10
+ * Inspired by https://gist.github.com/ca0v/73a31f57b397606c9813472f7493a940
11
+ */
12
+ export declare const debounce: <F extends (...args: any[]) => any>(func: F, waitForMs: number) => (...args: Parameters<F>) => Promise<UnwrapPromise<ReturnType<F>>>;
13
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * A collection of async utilities.
4
+ * If we ever need to add anything fancy, then https://github.com/vscode-shellcheck/vscode-shellcheck/blob/master/src/utils/async.ts
5
+ * is a good place to look.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.debounce = void 0;
9
+ /**
10
+ * Debounce a function call by a given amount of time. Only the last call
11
+ * will be resolved.
12
+ * Inspired by https://gist.github.com/ca0v/73a31f57b397606c9813472f7493a940
13
+ */
14
+ const debounce = (func, waitForMs) => {
15
+ let timeout = null;
16
+ return (...args) => new Promise((resolve) => {
17
+ if (timeout) {
18
+ clearTimeout(timeout);
19
+ }
20
+ timeout = setTimeout(() => resolve(func(...args)), waitForMs);
21
+ });
22
+ };
23
+ exports.debounce = debounce;
24
+ //# sourceMappingURL=async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/util/async.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;;;GAIG;AACI,MAAM,QAAQ,GAAG,CACtB,IAAO,EACP,SAAiB,EACjB,EAAE;IACF,IAAI,OAAO,GAAyC,IAAI,CAAA;IAExD,OAAO,CAAC,GAAG,IAAmB,EAAyC,EAAE,CACvE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACtB,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC;QAED,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAdY,QAAA,QAAQ,YAcpB"}
@@ -0,0 +1,88 @@
1
+ import * as LSP from 'vscode-languageserver/node';
2
+ import * as Parser from 'web-tree-sitter';
3
+ export type GlobalDeclarations = {
4
+ [word: string]: LSP.SymbolInformation;
5
+ };
6
+ export type Declarations = {
7
+ [word: string]: LSP.SymbolInformation[];
8
+ };
9
+ /**
10
+ * Returns declarations (functions or variables) from a given root node
11
+ * that would be available after sourcing the file. This currently does
12
+ * not include global variables defined inside if statements or functions
13
+ * as we do not do any flow tracing.
14
+ *
15
+ * Will only return one declaration per symbol name – the latest definition.
16
+ * This behavior is consistent with how Bash behaves, but differs between
17
+ * LSP servers.
18
+ *
19
+ * Used when finding declarations for sourced files and to get declarations
20
+ * for the entire workspace.
21
+ */
22
+ export declare function getGlobalDeclarations({ tree, uri, }: {
23
+ tree: Parser.Tree;
24
+ uri: string;
25
+ }): GlobalDeclarations;
26
+ /**
27
+ * Returns all declarations (functions or variables) from a given tree.
28
+ * This includes local variables.
29
+ */
30
+ export declare function getAllDeclarationsInTree({ tree, uri, }: {
31
+ tree: Parser.Tree;
32
+ uri: string;
33
+ }): LSP.SymbolInformation[];
34
+ /**
35
+ * Returns declarations available for the given file and location.
36
+ * The heuristics used is a simplification compared to bash behaviour,
37
+ * but deemed good enough, compared to the complexity of flow tracing.
38
+ *
39
+ * Used when getting declarations for the current scope.
40
+ */
41
+ export declare function getLocalDeclarations({ node, rootNode, uri, }: {
42
+ node: Parser.SyntaxNode | null;
43
+ rootNode: Parser.SyntaxNode;
44
+ uri: string;
45
+ }): Declarations;
46
+ export type FindDeclarationParams = {
47
+ /**
48
+ * The node where the search will start.
49
+ */
50
+ baseNode: Parser.SyntaxNode;
51
+ symbolInfo: {
52
+ position: LSP.Position;
53
+ uri: string;
54
+ word: string;
55
+ kind: LSP.SymbolKind;
56
+ };
57
+ otherInfo: {
58
+ /**
59
+ * The current URI being searched.
60
+ */
61
+ currentUri: string;
62
+ /**
63
+ * The line (LSP semantics) or row (tree-sitter semantics) at which to stop
64
+ * searching.
65
+ */
66
+ boundary: LSP.uinteger;
67
+ };
68
+ };
69
+ /**
70
+ * Searches for the original declaration of `symbol`. Global semantics here
71
+ * means that the symbol is not local to a function, hence, `baseNode` should
72
+ * either be a `subshell` or a `program` and `symbolInfo` should contain data
73
+ * about a variable or a function.
74
+ */
75
+ export declare function findDeclarationUsingGlobalSemantics({ baseNode, symbolInfo: { position, uri, word, kind }, otherInfo: { currentUri, boundary }, }: FindDeclarationParams): {
76
+ declaration: Parser.SyntaxNode | null | undefined;
77
+ continueSearching: boolean;
78
+ };
79
+ /**
80
+ * Searches for the original declaration of `symbol`. Local semantics here
81
+ * means that the symbol is local to a function, hence, `baseNode` should
82
+ * be the `compound_statement` of a `function_definition` and `symbolInfo`
83
+ * should contain data about a variable.
84
+ */
85
+ export declare function findDeclarationUsingLocalSemantics({ baseNode, symbolInfo: { position, word }, otherInfo: { boundary }, }: FindDeclarationParams): {
86
+ declaration: Parser.SyntaxNode | null | undefined;
87
+ continueSearching: boolean;
88
+ };
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGlobalDeclarations = getGlobalDeclarations;
4
+ exports.getAllDeclarationsInTree = getAllDeclarationsInTree;
5
+ exports.getLocalDeclarations = getLocalDeclarations;
6
+ exports.findDeclarationUsingGlobalSemantics = findDeclarationUsingGlobalSemantics;
7
+ exports.findDeclarationUsingLocalSemantics = findDeclarationUsingLocalSemantics;
8
+ const LSP = require("vscode-languageserver/node");
9
+ const TreeSitterUtil = require("./tree-sitter");
10
+ const TREE_SITTER_TYPE_TO_LSP_KIND = {
11
+ // These keys are using underscores as that's the naming convention in tree-sitter.
12
+ environment_variable_assignment: LSP.SymbolKind.Variable,
13
+ function_definition: LSP.SymbolKind.Function,
14
+ variable_assignment: LSP.SymbolKind.Variable,
15
+ };
16
+ const GLOBAL_DECLARATION_LEAF_NODE_TYPES = new Set([
17
+ 'if_statement',
18
+ 'function_definition',
19
+ ]);
20
+ /**
21
+ * Returns declarations (functions or variables) from a given root node
22
+ * that would be available after sourcing the file. This currently does
23
+ * not include global variables defined inside if statements or functions
24
+ * as we do not do any flow tracing.
25
+ *
26
+ * Will only return one declaration per symbol name – the latest definition.
27
+ * This behavior is consistent with how Bash behaves, but differs between
28
+ * LSP servers.
29
+ *
30
+ * Used when finding declarations for sourced files and to get declarations
31
+ * for the entire workspace.
32
+ */
33
+ function getGlobalDeclarations({ tree, uri, }) {
34
+ const globalDeclarations = {};
35
+ TreeSitterUtil.forEach(tree.rootNode, (node) => {
36
+ const followChildren = !GLOBAL_DECLARATION_LEAF_NODE_TYPES.has(node.type);
37
+ const symbol = getDeclarationSymbolFromNode({ node, uri });
38
+ if (symbol) {
39
+ const word = symbol.name;
40
+ globalDeclarations[word] = symbol;
41
+ }
42
+ return followChildren;
43
+ });
44
+ return globalDeclarations;
45
+ }
46
+ /**
47
+ * Returns all declarations (functions or variables) from a given tree.
48
+ * This includes local variables.
49
+ */
50
+ function getAllDeclarationsInTree({ tree, uri, }) {
51
+ const symbols = [];
52
+ TreeSitterUtil.forEach(tree.rootNode, (node) => {
53
+ const symbol = getDeclarationSymbolFromNode({ node, uri });
54
+ if (symbol) {
55
+ symbols.push(symbol);
56
+ }
57
+ });
58
+ return symbols;
59
+ }
60
+ /**
61
+ * Returns declarations available for the given file and location.
62
+ * The heuristics used is a simplification compared to bash behaviour,
63
+ * but deemed good enough, compared to the complexity of flow tracing.
64
+ *
65
+ * Used when getting declarations for the current scope.
66
+ */
67
+ function getLocalDeclarations({ node, rootNode, uri, }) {
68
+ const declarations = {};
69
+ // Bottom up traversal to capture all local and scoped declarations
70
+ const walk = (node) => {
71
+ // NOTE: there is also node.walk
72
+ if (node) {
73
+ for (const childNode of node.children) {
74
+ let symbol = null;
75
+ // local variables
76
+ if (childNode.type === 'declaration_command') {
77
+ const variableAssignmentNode = childNode.children.filter((child) => child.type === 'variable_assignment')[0];
78
+ if (variableAssignmentNode) {
79
+ symbol = nodeToSymbolInformation({
80
+ node: variableAssignmentNode,
81
+ uri,
82
+ });
83
+ }
84
+ }
85
+ else if (childNode.type === 'for_statement') {
86
+ const variableNode = childNode.child(1);
87
+ if (variableNode && variableNode.type === 'variable_name') {
88
+ symbol = LSP.SymbolInformation.create(variableNode.text, LSP.SymbolKind.Variable, TreeSitterUtil.range(variableNode), uri);
89
+ }
90
+ }
91
+ else {
92
+ symbol = getDeclarationSymbolFromNode({ node: childNode, uri });
93
+ }
94
+ if (symbol) {
95
+ if (!declarations[symbol.name]) {
96
+ declarations[symbol.name] = [];
97
+ }
98
+ declarations[symbol.name].push(symbol);
99
+ }
100
+ }
101
+ walk(node.parent);
102
+ }
103
+ };
104
+ walk(node);
105
+ // Top down traversal to add missing global variables from within functions
106
+ Object.entries(getAllGlobalVariableDeclarations({
107
+ rootNode,
108
+ uri,
109
+ })).map(([name, symbols]) => {
110
+ if (!declarations[name]) {
111
+ declarations[name] = symbols;
112
+ }
113
+ });
114
+ return declarations;
115
+ }
116
+ function getAllGlobalVariableDeclarations({ uri, rootNode, }) {
117
+ const declarations = {};
118
+ TreeSitterUtil.forEach(rootNode, (node) => {
119
+ var _a;
120
+ if (node.type === 'variable_assignment' &&
121
+ // exclude local variables
122
+ ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) !== 'declaration_command') {
123
+ const symbol = nodeToSymbolInformation({ node, uri });
124
+ if (symbol) {
125
+ if (!declarations[symbol.name]) {
126
+ declarations[symbol.name] = [];
127
+ }
128
+ declarations[symbol.name].push(symbol);
129
+ }
130
+ }
131
+ return;
132
+ });
133
+ return declarations;
134
+ }
135
+ function nodeToSymbolInformation({ node, uri, }) {
136
+ var _a, _b;
137
+ const named = node.firstNamedChild;
138
+ if (named === null) {
139
+ return null;
140
+ }
141
+ const containerName = ((_b = (_a = TreeSitterUtil.findParent(node, (p) => p.type === 'function_definition')) === null || _a === void 0 ? void 0 : _a.firstNamedChild) === null || _b === void 0 ? void 0 : _b.text) || '';
142
+ const kind = TREE_SITTER_TYPE_TO_LSP_KIND[node.type];
143
+ return LSP.SymbolInformation.create(named.text, kind || LSP.SymbolKind.Variable, TreeSitterUtil.range(node), uri, containerName);
144
+ }
145
+ function getDeclarationSymbolFromNode({ node, uri, }) {
146
+ var _a, _b;
147
+ if (TreeSitterUtil.isDefinition(node)) {
148
+ return nodeToSymbolInformation({ node, uri });
149
+ }
150
+ else if (node.type === 'command' && node.text.startsWith(': ')) {
151
+ // : does argument expansion and retains the side effects.
152
+ // A common usage is to define default values of environment variables, e.g. : "${VARIABLE:="default"}".
153
+ const variableNode = (_b = (_a = node.namedChildren
154
+ .find((c) => c.type === 'string')) === null || _a === void 0 ? void 0 : _a.namedChildren.find((c) => c.type === 'expansion')) === null || _b === void 0 ? void 0 : _b.namedChildren.find((c) => c.type === 'variable_name');
155
+ if (variableNode) {
156
+ return LSP.SymbolInformation.create(variableNode.text, LSP.SymbolKind.Variable, TreeSitterUtil.range(variableNode), uri);
157
+ }
158
+ }
159
+ return null;
160
+ }
161
+ /**
162
+ * Searches for the original declaration of `symbol`. Global semantics here
163
+ * means that the symbol is not local to a function, hence, `baseNode` should
164
+ * either be a `subshell` or a `program` and `symbolInfo` should contain data
165
+ * about a variable or a function.
166
+ */
167
+ function findDeclarationUsingGlobalSemantics({ baseNode, symbolInfo: { position, uri, word, kind }, otherInfo: { currentUri, boundary }, }) {
168
+ let declaration;
169
+ let continueSearching = false;
170
+ TreeSitterUtil.forEach(baseNode, (n) => {
171
+ var _a, _b, _c;
172
+ if ((declaration && !continueSearching) ||
173
+ n.startPosition.row > boundary ||
174
+ (n.type === 'subshell' && !n.equals(baseNode))) {
175
+ return false;
176
+ }
177
+ // `declaration_command`s are handled separately from `variable_assignment`s
178
+ // because `declaration_command`s can declare variables without defining
179
+ // them, while `variable_assignment`s require both declaration and
180
+ // definition, so, there can be `variable_name`s within
181
+ // `declaration_command`s that are not children of `variable_assignment`s.
182
+ if (kind === LSP.SymbolKind.Variable && n.type === 'declaration_command') {
183
+ const functionDefinition = TreeSitterUtil.findParentOfType(n, 'function_definition');
184
+ const isLocalDeclaration = !!functionDefinition &&
185
+ ((_a = functionDefinition.lastChild) === null || _a === void 0 ? void 0 : _a.type) === 'compound_statement' &&
186
+ ['local', 'declare', 'typeset'].includes((_b = n.firstChild) === null || _b === void 0 ? void 0 : _b.text) &&
187
+ (baseNode.type !== 'subshell' ||
188
+ baseNode.startPosition.row < functionDefinition.startPosition.row);
189
+ for (const v of n.descendantsOfType('variable_name')) {
190
+ if (v.text !== word ||
191
+ TreeSitterUtil.findParentOfType(v, ['simple_expansion', 'expansion'])) {
192
+ continue;
193
+ }
194
+ if (isLocalDeclaration) {
195
+ // Update boundary since any other instance below `n` can now be
196
+ // considered local to a function or out of scope.
197
+ boundary = n.startPosition.row;
198
+ break;
199
+ }
200
+ if (uri !== currentUri || !isDefinedVariableInExpression(n, v, position)) {
201
+ declaration = v;
202
+ continueSearching = false;
203
+ break;
204
+ }
205
+ }
206
+ // This return is important as it makes sure that the next if statement
207
+ // only catches `variable_assignment`s outside of `declaration_command`s.
208
+ return false;
209
+ }
210
+ if (kind === LSP.SymbolKind.Variable &&
211
+ (['variable_assignment', 'for_statement'].includes(n.type) ||
212
+ (n.type === 'command' && n.text.includes(':=')))) {
213
+ const definedVariable = n.descendantsOfType('variable_name').at(0);
214
+ const definedVariableInExpression = uri === currentUri &&
215
+ n.type === 'variable_assignment' &&
216
+ !!definedVariable &&
217
+ isDefinedVariableInExpression(n, definedVariable, position);
218
+ if ((definedVariable === null || definedVariable === void 0 ? void 0 : definedVariable.text) === word && !definedVariableInExpression) {
219
+ declaration = definedVariable;
220
+ continueSearching = baseNode.type === 'subshell' && n.type === 'command';
221
+ // The original declaration could be inside a `for_statement`, so only
222
+ // return false when the original declaration is found.
223
+ return false;
224
+ }
225
+ return true;
226
+ }
227
+ if (kind === LSP.SymbolKind.Variable &&
228
+ TreeSitterUtil.isVariableInReadCommand(n) &&
229
+ n.text === word) {
230
+ declaration = n;
231
+ continueSearching = false;
232
+ return false;
233
+ }
234
+ if (kind === LSP.SymbolKind.Function &&
235
+ n.type === 'function_definition' &&
236
+ ((_c = n.firstNamedChild) === null || _c === void 0 ? void 0 : _c.text) === word) {
237
+ declaration = n.firstNamedChild;
238
+ continueSearching = false;
239
+ return false;
240
+ }
241
+ return true;
242
+ });
243
+ return { declaration, continueSearching };
244
+ }
245
+ /**
246
+ * Searches for the original declaration of `symbol`. Local semantics here
247
+ * means that the symbol is local to a function, hence, `baseNode` should
248
+ * be the `compound_statement` of a `function_definition` and `symbolInfo`
249
+ * should contain data about a variable.
250
+ */
251
+ function findDeclarationUsingLocalSemantics({ baseNode, symbolInfo: { position, word }, otherInfo: { boundary }, }) {
252
+ let declaration;
253
+ let continueSearching = false;
254
+ TreeSitterUtil.forEach(baseNode, (n) => {
255
+ var _a;
256
+ if ((declaration && !continueSearching) ||
257
+ n.startPosition.row > boundary ||
258
+ ['function_definition', 'subshell'].includes(n.type)) {
259
+ return false;
260
+ }
261
+ if (n.type !== 'declaration_command') {
262
+ return true;
263
+ }
264
+ if (!['local', 'declare', 'typeset'].includes((_a = n.firstChild) === null || _a === void 0 ? void 0 : _a.text)) {
265
+ return false;
266
+ }
267
+ for (const v of n.descendantsOfType('variable_name')) {
268
+ if (v.text !== word ||
269
+ TreeSitterUtil.findParentOfType(v, ['simple_expansion', 'expansion'])) {
270
+ continue;
271
+ }
272
+ if (!isDefinedVariableInExpression(n, v, position)) {
273
+ declaration = v;
274
+ continueSearching = false;
275
+ break;
276
+ }
277
+ }
278
+ return false;
279
+ });
280
+ return { declaration, continueSearching };
281
+ }
282
+ /**
283
+ * This is used in checking self-assignment `var=$var` edge cases where
284
+ * `position` is within `$var`. Based on the `definition` node (should be
285
+ * `declaration_command` or `variable_assignment`) and `variable` node (should
286
+ * be `variable_name`) given, estimates if `position` is within the expressiion
287
+ * (after the equals sign) of an assignment. If it is, then `var` should be
288
+ * skipped and a higher scope should be checked for the original declaration.
289
+ */
290
+ function isDefinedVariableInExpression(definition, variable, position) {
291
+ return (definition.endPosition.row >= position.line &&
292
+ (variable.endPosition.column < position.character ||
293
+ variable.endPosition.row < position.line));
294
+ }
295
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../src/util/declarations.ts"],"names":[],"mappings":";;AAiCA,sDAsBC;AAMD,4DAiBC;AASD,oDAuEC;AA2HD,kFA0GC;AAQD,gFA4CC;AAvbD,kDAAiD;AAGjD,gDAA+C;AAE/C,MAAM,4BAA4B,GAAmD;IACnF,mFAAmF;IACnF,+BAA+B,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ;IACxD,mBAAmB,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ;IAC5C,mBAAmB,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ;CAC7C,CAAA;AAKD,MAAM,kCAAkC,GAAG,IAAI,GAAG,CAAC;IACjD,cAAc;IACd,qBAAqB;CACtB,CAAC,CAAA;AAEF;;;;;;;;;;;;GAYG;AACH,SAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,GAAG,GAIJ;IACC,MAAM,kBAAkB,GAAuB,EAAE,CAAA;IAEjD,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,cAAc,GAAG,CAAC,kCAAkC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEzE,MAAM,MAAM,GAAG,4BAA4B,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QAC1D,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;YACxB,kBAAkB,CAAC,IAAI,CAAC,GAAG,MAAM,C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A;QACd,CAAC;QAED,IAAI,CAAC,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;YACrC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAA,CAAC,CAAC,UAAU,0CAAE,IAAW,CAAC,EAAE,CAAC;YACzE,OAAO,KAAK,CAAA;QACd,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,IACE,CAAC,CAAC,IAAI,KAAK,IAAI;gBACf,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC,EACrE,CAAC;gBACD,SAAQ;YACV,CAAC;YAED,IAAI,CAAC,6BAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC;gBACnD,WAAW,GAAG,CAAC,CAAA;gBACf,iBAAiB,GAAG,KAAK,CAAA;gBACzB,MAAK;YACP,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAA;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,6BAA6B,CACpC,UAA6B,EAC7B,QAA2B,EAC3B,QAAsB;IAEtB,OAAO,CACL,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI;QAC3C,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,QAAQ,CAAC,SAAS;YAC/C,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,CAC5C,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function discriminate<K extends PropertyKey, V extends string | number | boolean>(discriminantKey: K, discriminantValue: V): <T extends Record<K, any>>(obj: T & Record<K, V extends T[K] ? T[K] : V>) => obj is Extract<T, Record<K, V>>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discriminate = discriminate;
4
+ function discriminate(discriminantKey, discriminantValue) {
5
+ return (obj) => obj[discriminantKey] === discriminantValue;
6
+ }
7
+ //# sourceMappingURL=discriminate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discriminate.js","sourceRoot":"","sources":["../../src/util/discriminate.ts"],"names":[],"mappings":";;AAAA,oCAOC;AAPD,SAAgB,YAAY,CAC1B,eAAkB,EAClB,iBAAoB;IAEpB,OAAO,CACL,GAA6C,EACZ,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,iBAAiB,CAAA;AAClF,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function untildify(pathWithTilde: string): string;
2
+ export declare function getFilePaths({ globPattern, rootPath, maxItems, }: {
3
+ globPattern: string;
4
+ rootPath: string;
5
+ maxItems: number;
6
+ }): Promise<string[]>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.untildify = untildify;
20
+ exports.getFilePaths = getFilePaths;
21
+ const os = require("node:os");
22
+ const node_url_1 = require("node:url");
23
+ const fastGlob = require("fast-glob");
24
+ // from https://github.com/sindresorhus/untildify/blob/f85a087418aeaa2beb56fe2684fe3b64fc8c588d/index.js#L11
25
+ function untildify(pathWithTilde) {
26
+ const homeDirectory = os.homedir();
27
+ return homeDirectory
28
+ ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
29
+ : pathWithTilde;
30
+ }
31
+ function getFilePaths(_a) {
32
+ return __awaiter(this, arguments, void 0, function* ({ globPattern, rootPath, maxItems, }) {
33
+ var _b, e_1, _c, _d;
34
+ if (rootPath.startsWith('file://')) {
35
+ rootPath = (0, node_url_1.fileURLToPath)(rootPath);
36
+ }
37
+ const stream = fastGlob.stream([globPattern], {
38
+ absolute: true,
39
+ onlyFiles: true,
40
+ cwd: rootPath,
41
+ followSymbolicLinks: true,
42
+ suppressErrors: true,
43
+ });
44
+ // NOTE: we use a stream here to not block the event loop
45
+ // and ensure that we stop reading files if the glob returns
46
+ // too many files.
47
+ const files = [];
48
+ let i = 0;
49
+ try {
50
+ for (var _e = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _e = true) {
51
+ _d = stream_1_1.value;
52
+ _e = false;
53
+ const fileEntry = _d;
54
+ if (i >= maxItems) {
55
+ // NOTE: Close the stream to stop reading files paths.
56
+ stream.emit('close');
57
+ break;
58
+ }
59
+ files.push(fileEntry.toString());
60
+ i++;
61
+ }
62
+ }
63
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
64
+ finally {
65
+ try {
66
+ if (!_e && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
67
+ }
68
+ finally { if (e_1) throw e_1.error; }
69
+ }
70
+ return files;
71
+ });
72
+ }
73
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/util/fs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,8BAKC;AAED,oCAsCC;AAnDD,8BAA6B;AAC7B,uCAAwC;AAExC,sCAAqC;AAErC,4GAA4G;AAC5G,SAAgB,SAAS,CAAC,aAAqB;IAC7C,MAAM,aAAa,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAClC,OAAO,aAAa;QAClB,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC;QACvD,CAAC,CAAC,aAAa,CAAA;AACnB,CAAC;AAED,SAAsB,YAAY;yDAAC,EACjC,WAAW,EACX,QAAQ,EACR,QAAQ,GAKT;;QACC,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,QAAQ,GAAG,IAAA,wBAAa,EAAC,QAAQ,CAAC,CAAA;QACpC,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,EAAE;YAC5C,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,QAAQ;YACb,mBAAmB,EAAE,IAAI;YACzB,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;QAEF,yDAAyD;QACzD,4DAA4D;QAC5D,kBAAkB;QAClB,MAAM,KAAK,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,GAAG,CAAC,CAAA;;YACT,KAA8B,eAAA,WAAA,cAAA,MAAM,CAAA,YAAA,4EAAE,CAAC;gBAAT,sBAAM;gBAAN,WAAM;gBAAzB,MAAM,SAAS,KAAA,CAAA;gBACxB,IAAI,CAA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