decidim 0.27.2 → 0.27.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +17 -10
  3. data/babel.config.json +1 -4
  4. data/docs/modules/customize/pages/data_consent.adoc +1 -1
  5. data/lib/decidim/release_manager.rb.new +43 -0
  6. data/lib/decidim/version.rb +1 -1
  7. data/package-lock.json +343 -255
  8. data/packages/browserslist-config/package.json +1 -1
  9. data/packages/core/node_modules/diff/CONTRIBUTING.md +39 -0
  10. data/packages/core/node_modules/diff/LICENSE +31 -0
  11. data/packages/core/node_modules/diff/README.md +211 -0
  12. data/packages/core/node_modules/diff/dist/diff.js +1627 -0
  13. data/packages/core/node_modules/diff/dist/diff.min.js +38 -0
  14. data/packages/core/node_modules/diff/lib/convert/dmp.js +32 -0
  15. data/packages/core/node_modules/diff/lib/convert/xml.js +42 -0
  16. data/packages/core/node_modules/diff/lib/diff/array.js +45 -0
  17. data/packages/core/node_modules/diff/lib/diff/base.js +307 -0
  18. data/packages/core/node_modules/diff/lib/diff/character.js +37 -0
  19. data/packages/core/node_modules/diff/lib/diff/css.js +41 -0
  20. data/packages/core/node_modules/diff/lib/diff/json.js +163 -0
  21. data/packages/core/node_modules/diff/lib/diff/line.js +89 -0
  22. data/packages/core/node_modules/diff/lib/diff/sentence.js +41 -0
  23. data/packages/core/node_modules/diff/lib/diff/word.js +108 -0
  24. data/packages/core/node_modules/diff/lib/index.es6.js +1561 -0
  25. data/packages/core/node_modules/diff/lib/index.js +216 -0
  26. data/packages/core/node_modules/diff/lib/index.mjs +1561 -0
  27. data/packages/core/node_modules/diff/lib/patch/apply.js +238 -0
  28. data/packages/core/node_modules/diff/lib/patch/create.js +272 -0
  29. data/packages/core/node_modules/diff/lib/patch/merge.js +613 -0
  30. data/packages/core/node_modules/diff/lib/patch/parse.js +167 -0
  31. data/packages/core/node_modules/diff/lib/util/array.js +32 -0
  32. data/packages/core/node_modules/diff/lib/util/distance-iterator.js +57 -0
  33. data/packages/core/node_modules/diff/lib/util/params.js +24 -0
  34. data/packages/core/node_modules/diff/package.json +87 -0
  35. data/packages/core/node_modules/diff/release-notes.md +309 -0
  36. data/packages/core/node_modules/diff/runtime.js +3 -0
  37. data/packages/core/package-lock.json +4889 -0
  38. data/packages/core/package.json +1 -1
  39. data/packages/dev/package.json +1 -1
  40. data/packages/elections/package.json +1 -1
  41. data/packages/eslint-config/package.json +1 -1
  42. data/packages/stylelint-config/package.json +1 -1
  43. data/packages/webpacker/node_modules/argparse/CHANGELOG.md +216 -0
  44. data/packages/webpacker/node_modules/argparse/LICENSE +254 -0
  45. data/packages/webpacker/node_modules/argparse/README.md +84 -0
  46. data/packages/webpacker/node_modules/argparse/argparse.js +3707 -0
  47. data/packages/webpacker/node_modules/argparse/lib/sub.js +67 -0
  48. data/packages/webpacker/node_modules/argparse/lib/textwrap.js +440 -0
  49. data/packages/webpacker/node_modules/argparse/package.json +31 -0
  50. data/packages/{core/node_modules/uuid/LICENSE.md → webpacker/node_modules/brace-expansion/LICENSE} +2 -2
  51. data/packages/webpacker/node_modules/brace-expansion/README.md +135 -0
  52. data/packages/webpacker/node_modules/brace-expansion/index.js +203 -0
  53. data/packages/webpacker/node_modules/brace-expansion/package.json +46 -0
  54. data/packages/webpacker/node_modules/glob/LICENSE +15 -0
  55. data/packages/webpacker/node_modules/glob/README.md +1214 -0
  56. data/packages/webpacker/node_modules/glob/dist/cjs/package.json +4 -0
  57. data/packages/webpacker/node_modules/glob/dist/cjs/src/bin.d.ts +3 -0
  58. data/packages/webpacker/node_modules/glob/dist/cjs/src/bin.d.ts.map +1 -0
  59. data/packages/webpacker/node_modules/glob/dist/cjs/src/bin.js +270 -0
  60. data/packages/webpacker/node_modules/glob/dist/cjs/src/bin.js.map +1 -0
  61. data/packages/webpacker/node_modules/glob/dist/cjs/src/glob.d.ts +344 -0
  62. data/packages/webpacker/node_modules/glob/dist/cjs/src/glob.d.ts.map +1 -0
  63. data/packages/webpacker/node_modules/glob/dist/cjs/src/glob.js +238 -0
  64. data/packages/webpacker/node_modules/glob/dist/cjs/src/glob.js.map +1 -0
  65. data/packages/webpacker/node_modules/glob/dist/cjs/src/has-magic.d.ts +14 -0
  66. data/packages/webpacker/node_modules/glob/dist/cjs/src/has-magic.d.ts.map +1 -0
  67. data/packages/webpacker/node_modules/glob/dist/cjs/src/has-magic.js +27 -0
  68. data/packages/webpacker/node_modules/glob/dist/cjs/src/has-magic.js.map +1 -0
  69. data/packages/webpacker/node_modules/glob/dist/cjs/src/ignore.d.ts +20 -0
  70. data/packages/webpacker/node_modules/glob/dist/cjs/src/ignore.d.ts.map +1 -0
  71. data/packages/webpacker/node_modules/glob/dist/cjs/src/ignore.js +103 -0
  72. data/packages/webpacker/node_modules/glob/dist/cjs/src/ignore.js.map +1 -0
  73. data/packages/webpacker/node_modules/glob/dist/cjs/src/index.d.ts +95 -0
  74. data/packages/webpacker/node_modules/glob/dist/cjs/src/index.d.ts.map +1 -0
  75. data/packages/webpacker/node_modules/glob/dist/cjs/src/index.js +68 -0
  76. data/packages/webpacker/node_modules/glob/dist/cjs/src/index.js.map +1 -0
  77. data/packages/webpacker/node_modules/glob/dist/cjs/src/pattern.d.ts +77 -0
  78. data/packages/webpacker/node_modules/glob/dist/cjs/src/pattern.d.ts.map +1 -0
  79. data/packages/webpacker/node_modules/glob/dist/cjs/src/pattern.js +219 -0
  80. data/packages/webpacker/node_modules/glob/dist/cjs/src/pattern.js.map +1 -0
  81. data/packages/webpacker/node_modules/glob/dist/cjs/src/processor.d.ts +59 -0
  82. data/packages/webpacker/node_modules/glob/dist/cjs/src/processor.d.ts.map +1 -0
  83. data/packages/webpacker/node_modules/glob/dist/cjs/src/processor.js +309 -0
  84. data/packages/webpacker/node_modules/glob/dist/cjs/src/processor.js.map +1 -0
  85. data/packages/webpacker/node_modules/glob/dist/cjs/src/walker.d.ts +96 -0
  86. data/packages/webpacker/node_modules/glob/dist/cjs/src/walker.d.ts.map +1 -0
  87. data/packages/webpacker/node_modules/glob/dist/cjs/src/walker.js +358 -0
  88. data/packages/webpacker/node_modules/glob/dist/cjs/src/walker.js.map +1 -0
  89. data/packages/webpacker/node_modules/glob/dist/mjs/glob.d.ts +344 -0
  90. data/packages/webpacker/node_modules/glob/dist/mjs/glob.d.ts.map +1 -0
  91. data/packages/webpacker/node_modules/glob/dist/mjs/glob.js +234 -0
  92. data/packages/webpacker/node_modules/glob/dist/mjs/glob.js.map +1 -0
  93. data/packages/webpacker/node_modules/glob/dist/mjs/has-magic.d.ts +14 -0
  94. data/packages/webpacker/node_modules/glob/dist/mjs/has-magic.d.ts.map +1 -0
  95. data/packages/webpacker/node_modules/glob/dist/mjs/has-magic.js +23 -0
  96. data/packages/webpacker/node_modules/glob/dist/mjs/has-magic.js.map +1 -0
  97. data/packages/webpacker/node_modules/glob/dist/mjs/ignore.d.ts +20 -0
  98. data/packages/webpacker/node_modules/glob/dist/mjs/ignore.d.ts.map +1 -0
  99. data/packages/webpacker/node_modules/glob/dist/mjs/ignore.js +99 -0
  100. data/packages/webpacker/node_modules/glob/dist/mjs/ignore.js.map +1 -0
  101. data/packages/webpacker/node_modules/glob/dist/mjs/index.d.ts +95 -0
  102. data/packages/webpacker/node_modules/glob/dist/mjs/index.d.ts.map +1 -0
  103. data/packages/webpacker/node_modules/glob/dist/mjs/index.js +56 -0
  104. data/packages/webpacker/node_modules/glob/dist/mjs/index.js.map +1 -0
  105. data/packages/webpacker/node_modules/glob/dist/mjs/package.json +4 -0
  106. data/packages/webpacker/node_modules/glob/dist/mjs/pattern.d.ts +77 -0
  107. data/packages/webpacker/node_modules/glob/dist/mjs/pattern.d.ts.map +1 -0
  108. data/packages/webpacker/node_modules/glob/dist/mjs/pattern.js +215 -0
  109. data/packages/webpacker/node_modules/glob/dist/mjs/pattern.js.map +1 -0
  110. data/packages/webpacker/node_modules/glob/dist/mjs/processor.d.ts +59 -0
  111. data/packages/webpacker/node_modules/glob/dist/mjs/processor.d.ts.map +1 -0
  112. data/packages/webpacker/node_modules/glob/dist/mjs/processor.js +302 -0
  113. data/packages/webpacker/node_modules/glob/dist/mjs/processor.js.map +1 -0
  114. data/packages/webpacker/node_modules/glob/dist/mjs/walker.d.ts +96 -0
  115. data/packages/webpacker/node_modules/glob/dist/mjs/walker.d.ts.map +1 -0
  116. data/packages/webpacker/node_modules/glob/dist/mjs/walker.js +352 -0
  117. data/packages/webpacker/node_modules/glob/dist/mjs/walker.js.map +1 -0
  118. data/packages/webpacker/node_modules/glob/package.json +98 -0
  119. data/packages/webpacker/node_modules/js-yaml/CHANGELOG.md +616 -0
  120. data/packages/webpacker/node_modules/js-yaml/LICENSE +21 -0
  121. data/packages/webpacker/node_modules/js-yaml/README.md +246 -0
  122. data/packages/webpacker/node_modules/js-yaml/bin/js-yaml.js +126 -0
  123. data/packages/webpacker/node_modules/js-yaml/dist/js-yaml.js +3874 -0
  124. data/packages/webpacker/node_modules/js-yaml/dist/js-yaml.min.js +2 -0
  125. data/packages/webpacker/node_modules/js-yaml/dist/js-yaml.mjs +3851 -0
  126. data/packages/webpacker/node_modules/js-yaml/index.js +47 -0
  127. data/packages/webpacker/node_modules/js-yaml/lib/common.js +59 -0
  128. data/packages/webpacker/node_modules/js-yaml/lib/dumper.js +965 -0
  129. data/packages/webpacker/node_modules/js-yaml/lib/exception.js +55 -0
  130. data/packages/webpacker/node_modules/js-yaml/lib/loader.js +1727 -0
  131. data/packages/webpacker/node_modules/js-yaml/lib/schema/core.js +11 -0
  132. data/packages/webpacker/node_modules/js-yaml/lib/schema/default.js +22 -0
  133. data/packages/webpacker/node_modules/js-yaml/lib/schema/failsafe.js +17 -0
  134. data/packages/webpacker/node_modules/js-yaml/lib/schema/json.js +19 -0
  135. data/packages/webpacker/node_modules/js-yaml/lib/schema.js +121 -0
  136. data/packages/webpacker/node_modules/js-yaml/lib/snippet.js +101 -0
  137. data/packages/webpacker/node_modules/js-yaml/lib/type/binary.js +125 -0
  138. data/packages/webpacker/node_modules/js-yaml/lib/type/bool.js +35 -0
  139. data/packages/webpacker/node_modules/js-yaml/lib/type/float.js +97 -0
  140. data/packages/webpacker/node_modules/js-yaml/lib/type/int.js +156 -0
  141. data/packages/webpacker/node_modules/js-yaml/lib/type/map.js +8 -0
  142. data/packages/webpacker/node_modules/js-yaml/lib/type/merge.js +12 -0
  143. data/packages/webpacker/node_modules/js-yaml/lib/type/null.js +35 -0
  144. data/packages/webpacker/node_modules/js-yaml/lib/type/omap.js +44 -0
  145. data/packages/webpacker/node_modules/js-yaml/lib/type/pairs.js +53 -0
  146. data/packages/webpacker/node_modules/js-yaml/lib/type/seq.js +8 -0
  147. data/packages/webpacker/node_modules/js-yaml/lib/type/set.js +29 -0
  148. data/packages/webpacker/node_modules/js-yaml/lib/type/str.js +8 -0
  149. data/packages/webpacker/node_modules/js-yaml/lib/type/timestamp.js +88 -0
  150. data/packages/webpacker/node_modules/js-yaml/lib/type.js +66 -0
  151. data/packages/webpacker/node_modules/js-yaml/package.json +66 -0
  152. data/packages/webpacker/node_modules/minimatch/LICENSE +15 -0
  153. data/packages/webpacker/node_modules/minimatch/README.md +454 -0
  154. data/packages/webpacker/node_modules/minimatch/dist/cjs/assert-valid-pattern.d.ts +2 -0
  155. data/packages/webpacker/node_modules/minimatch/dist/cjs/assert-valid-pattern.d.ts.map +1 -0
  156. data/packages/webpacker/node_modules/minimatch/dist/cjs/assert-valid-pattern.js +14 -0
  157. data/packages/webpacker/node_modules/minimatch/dist/cjs/assert-valid-pattern.js.map +1 -0
  158. data/packages/webpacker/node_modules/minimatch/dist/cjs/ast.d.ts +19 -0
  159. data/packages/webpacker/node_modules/minimatch/dist/cjs/ast.d.ts.map +1 -0
  160. data/packages/webpacker/node_modules/minimatch/dist/cjs/ast.js +589 -0
  161. data/packages/webpacker/node_modules/minimatch/dist/cjs/ast.js.map +1 -0
  162. data/packages/webpacker/node_modules/minimatch/dist/cjs/brace-expressions.d.ts +8 -0
  163. data/packages/webpacker/node_modules/minimatch/dist/cjs/brace-expressions.d.ts.map +1 -0
  164. data/packages/webpacker/node_modules/minimatch/dist/cjs/brace-expressions.js +152 -0
  165. data/packages/webpacker/node_modules/minimatch/dist/cjs/brace-expressions.js.map +1 -0
  166. data/packages/webpacker/node_modules/minimatch/dist/cjs/escape.d.ts +12 -0
  167. data/packages/webpacker/node_modules/minimatch/dist/cjs/escape.d.ts.map +1 -0
  168. data/packages/webpacker/node_modules/minimatch/dist/cjs/escape.js +22 -0
  169. data/packages/webpacker/node_modules/minimatch/dist/cjs/escape.js.map +1 -0
  170. data/packages/webpacker/node_modules/minimatch/dist/cjs/index.d.ts +94 -0
  171. data/packages/webpacker/node_modules/minimatch/dist/cjs/index.d.ts.map +1 -0
  172. data/packages/webpacker/node_modules/minimatch/dist/cjs/index.js +1011 -0
  173. data/packages/webpacker/node_modules/minimatch/dist/cjs/index.js.map +1 -0
  174. data/packages/webpacker/node_modules/minimatch/dist/cjs/package.json +3 -0
  175. data/packages/webpacker/node_modules/minimatch/dist/cjs/unescape.d.ts +17 -0
  176. data/packages/webpacker/node_modules/minimatch/dist/cjs/unescape.d.ts.map +1 -0
  177. data/packages/webpacker/node_modules/minimatch/dist/cjs/unescape.js +24 -0
  178. data/packages/webpacker/node_modules/minimatch/dist/cjs/unescape.js.map +1 -0
  179. data/packages/webpacker/node_modules/minimatch/dist/mjs/assert-valid-pattern.d.ts +2 -0
  180. data/packages/webpacker/node_modules/minimatch/dist/mjs/assert-valid-pattern.d.ts.map +1 -0
  181. data/packages/webpacker/node_modules/minimatch/dist/mjs/assert-valid-pattern.js +10 -0
  182. data/packages/webpacker/node_modules/minimatch/dist/mjs/assert-valid-pattern.js.map +1 -0
  183. data/packages/webpacker/node_modules/minimatch/dist/mjs/ast.d.ts +19 -0
  184. data/packages/webpacker/node_modules/minimatch/dist/mjs/ast.d.ts.map +1 -0
  185. data/packages/webpacker/node_modules/minimatch/dist/mjs/ast.js +585 -0
  186. data/packages/webpacker/node_modules/minimatch/dist/mjs/ast.js.map +1 -0
  187. data/packages/webpacker/node_modules/minimatch/dist/mjs/brace-expressions.d.ts +8 -0
  188. data/packages/webpacker/node_modules/minimatch/dist/mjs/brace-expressions.d.ts.map +1 -0
  189. data/packages/webpacker/node_modules/minimatch/dist/mjs/brace-expressions.js +148 -0
  190. data/packages/webpacker/node_modules/minimatch/dist/mjs/brace-expressions.js.map +1 -0
  191. data/packages/webpacker/node_modules/minimatch/dist/mjs/escape.d.ts +12 -0
  192. data/packages/webpacker/node_modules/minimatch/dist/mjs/escape.d.ts.map +1 -0
  193. data/packages/webpacker/node_modules/minimatch/dist/mjs/escape.js +18 -0
  194. data/packages/webpacker/node_modules/minimatch/dist/mjs/escape.js.map +1 -0
  195. data/packages/webpacker/node_modules/minimatch/dist/mjs/index.d.ts +94 -0
  196. data/packages/webpacker/node_modules/minimatch/dist/mjs/index.d.ts.map +1 -0
  197. data/packages/webpacker/node_modules/minimatch/dist/mjs/index.js +995 -0
  198. data/packages/webpacker/node_modules/minimatch/dist/mjs/index.js.map +1 -0
  199. data/packages/webpacker/node_modules/minimatch/dist/mjs/package.json +3 -0
  200. data/packages/webpacker/node_modules/minimatch/dist/mjs/unescape.d.ts +17 -0
  201. data/packages/webpacker/node_modules/minimatch/dist/mjs/unescape.d.ts.map +1 -0
  202. data/packages/webpacker/node_modules/minimatch/dist/mjs/unescape.js +20 -0
  203. data/packages/webpacker/node_modules/minimatch/dist/mjs/unescape.js.map +1 -0
  204. data/packages/webpacker/node_modules/minimatch/package.json +86 -0
  205. data/packages/webpacker/package.json +2 -2
  206. metadata +238 -65
  207. data/packages/core/node_modules/uuid/AUTHORS +0 -5
  208. data/packages/core/node_modules/uuid/CHANGELOG.md +0 -119
  209. data/packages/core/node_modules/uuid/README.md +0 -276
  210. data/packages/core/node_modules/uuid/bin/uuid +0 -65
  211. data/packages/core/node_modules/uuid/index.js +0 -8
  212. data/packages/core/node_modules/uuid/lib/bytesToUuid.js +0 -26
  213. data/packages/core/node_modules/uuid/lib/md5-browser.js +0 -216
  214. data/packages/core/node_modules/uuid/lib/md5.js +0 -25
  215. data/packages/core/node_modules/uuid/lib/rng-browser.js +0 -34
  216. data/packages/core/node_modules/uuid/lib/rng.js +0 -8
  217. data/packages/core/node_modules/uuid/lib/sha1-browser.js +0 -89
  218. data/packages/core/node_modules/uuid/lib/sha1.js +0 -25
  219. data/packages/core/node_modules/uuid/lib/v35.js +0 -57
  220. data/packages/core/node_modules/uuid/package.json +0 -49
  221. data/packages/core/node_modules/uuid/v1.js +0 -109
  222. data/packages/core/node_modules/uuid/v3.js +0 -4
  223. data/packages/core/node_modules/uuid/v4.js +0 -29
  224. data/packages/core/node_modules/uuid/v5.js +0 -3
@@ -0,0 +1,585 @@
1
+ // parse a single path portion
2
+ import { parseClass } from './brace-expressions.js';
3
+ import { unescape } from './unescape.js';
4
+ const types = new Set(['!', '?', '+', '*', '@']);
5
+ const isExtglobType = (c) => types.has(c);
6
+ // Patterns that get prepended to bind to the start of either the
7
+ // entire string, or just a single path portion, to prevent dots
8
+ // and/or traversal patterns, when needed.
9
+ // Exts don't need the ^ or / bit, because the root binds that already.
10
+ const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
11
+ const startNoDot = '(?!\\.)';
12
+ // characters that indicate a start of pattern needs the "no dots" bit,
13
+ // because a dot *might* be matched. ( is not in the list, because in
14
+ // the case of a child extglob, it will handle the prevention itself.
15
+ const addPatternStart = new Set(['[', '.']);
16
+ // cases where traversal is A-OK, no dot prevention needed
17
+ const justDots = new Set(['..', '.']);
18
+ const reSpecials = new Set('().*{}+?[]^$\\!');
19
+ const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
20
+ // any single thing other than /
21
+ const qmark = '[^/]';
22
+ // * => any number of characters
23
+ const star = qmark + '*?';
24
+ // use + when we need to ensure that *something* matches, because the * is
25
+ // the only thing in the path portion.
26
+ const starNoEmpty = qmark + '+?';
27
+ // remove the \ chars that we added if we end up doing a nonmagic compare
28
+ // const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
29
+ export class AST {
30
+ type;
31
+ #root;
32
+ #hasMagic;
33
+ #uflag = false;
34
+ #parts = [];
35
+ #parent;
36
+ #parentIndex;
37
+ #negs;
38
+ #filledNegs = false;
39
+ #options;
40
+ #toString;
41
+ // set to true if it's an extglob with no children
42
+ // (which really means one child of '')
43
+ #emptyExt = false;
44
+ constructor(type, parent, options = {}) {
45
+ this.type = type;
46
+ // extglobs are inherently magical
47
+ if (type)
48
+ this.#hasMagic = true;
49
+ this.#parent = parent;
50
+ this.#root = this.#parent ? this.#parent.#root : this;
51
+ this.#options = this.#root === this ? options : this.#root.#options;
52
+ this.#negs = this.#root === this ? [] : this.#root.#negs;
53
+ if (type === '!' && !this.#root.#filledNegs)
54
+ this.#negs.push(this);
55
+ this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
56
+ }
57
+ get hasMagic() {
58
+ /* c8 ignore start */
59
+ if (this.#hasMagic !== undefined)
60
+ return this.#hasMagic;
61
+ /* c8 ignore stop */
62
+ for (const p of this.#parts) {
63
+ if (typeof p === 'string')
64
+ continue;
65
+ if (p.type || p.hasMagic)
66
+ return (this.#hasMagic = true);
67
+ }
68
+ // note: will be undefined until we generate the regexp src and find out
69
+ return this.#hasMagic;
70
+ }
71
+ // reconstructs the pattern
72
+ toString() {
73
+ if (this.#toString !== undefined)
74
+ return this.#toString;
75
+ if (!this.type) {
76
+ return (this.#toString = this.#parts.map(p => String(p)).join(''));
77
+ }
78
+ else {
79
+ return (this.#toString =
80
+ this.type + '(' + this.#parts.map(p => String(p)).join('|') + ')');
81
+ }
82
+ }
83
+ #fillNegs() {
84
+ /* c8 ignore start */
85
+ if (this !== this.#root)
86
+ throw new Error('should only call on root');
87
+ if (this.#filledNegs)
88
+ return this;
89
+ /* c8 ignore stop */
90
+ // call toString() once to fill this out
91
+ this.toString();
92
+ this.#filledNegs = true;
93
+ let n;
94
+ while ((n = this.#negs.pop())) {
95
+ if (n.type !== '!')
96
+ continue;
97
+ // walk up the tree, appending everthing that comes AFTER parentIndex
98
+ let p = n;
99
+ let pp = p.#parent;
100
+ while (pp) {
101
+ for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
102
+ for (const part of n.#parts) {
103
+ /* c8 ignore start */
104
+ if (typeof part === 'string') {
105
+ throw new Error('string part in extglob AST??');
106
+ }
107
+ /* c8 ignore stop */
108
+ part.copyIn(pp.#parts[i]);
109
+ }
110
+ }
111
+ p = pp;
112
+ pp = p.#parent;
113
+ }
114
+ }
115
+ return this;
116
+ }
117
+ push(...parts) {
118
+ for (const p of parts) {
119
+ if (p === '')
120
+ continue;
121
+ /* c8 ignore start */
122
+ if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
123
+ throw new Error('invalid part: ' + p);
124
+ }
125
+ /* c8 ignore stop */
126
+ this.#parts.push(p);
127
+ }
128
+ }
129
+ toJSON() {
130
+ const ret = this.type === null
131
+ ? this.#parts.slice().map(p => (typeof p === 'string' ? p : p.toJSON()))
132
+ : [this.type, ...this.#parts.map(p => p.toJSON())];
133
+ if (this.isStart() && !this.type)
134
+ ret.unshift([]);
135
+ if (this.isEnd() &&
136
+ (this === this.#root ||
137
+ (this.#root.#filledNegs && this.#parent?.type === '!'))) {
138
+ ret.push({});
139
+ }
140
+ return ret;
141
+ }
142
+ isStart() {
143
+ if (this.#root === this)
144
+ return true;
145
+ // if (this.type) return !!this.#parent?.isStart()
146
+ if (!this.#parent?.isStart())
147
+ return false;
148
+ if (this.#parentIndex === 0)
149
+ return true;
150
+ // if everything AHEAD of this is a negation, then it's still the "start"
151
+ const p = this.#parent;
152
+ for (let i = 0; i < this.#parentIndex; i++) {
153
+ const pp = p.#parts[i];
154
+ if (!(pp instanceof AST && pp.type === '!')) {
155
+ return false;
156
+ }
157
+ }
158
+ return true;
159
+ }
160
+ isEnd() {
161
+ if (this.#root === this)
162
+ return true;
163
+ if (this.#parent?.type === '!')
164
+ return true;
165
+ if (!this.#parent?.isEnd())
166
+ return false;
167
+ if (!this.type)
168
+ return this.#parent?.isEnd();
169
+ // if not root, it'll always have a parent
170
+ /* c8 ignore start */
171
+ const pl = this.#parent ? this.#parent.#parts.length : 0;
172
+ /* c8 ignore stop */
173
+ return this.#parentIndex === pl - 1;
174
+ }
175
+ copyIn(part) {
176
+ if (typeof part === 'string')
177
+ this.push(part);
178
+ else
179
+ this.push(part.clone(this));
180
+ }
181
+ clone(parent) {
182
+ const c = new AST(this.type, parent);
183
+ for (const p of this.#parts) {
184
+ c.copyIn(p);
185
+ }
186
+ return c;
187
+ }
188
+ static #parseAST(str, ast, pos, opt) {
189
+ let escaping = false;
190
+ let inBrace = false;
191
+ let braceStart = -1;
192
+ let braceNeg = false;
193
+ if (ast.type === null) {
194
+ // outside of a extglob, append until we find a start
195
+ let i = pos;
196
+ let acc = '';
197
+ while (i < str.length) {
198
+ const c = str.charAt(i++);
199
+ // still accumulate escapes at this point, but we do ignore
200
+ // starts that are escaped
201
+ if (escaping || c === '\\') {
202
+ escaping = !escaping;
203
+ acc += c;
204
+ continue;
205
+ }
206
+ if (inBrace) {
207
+ if (i === braceStart + 1) {
208
+ if (c === '^' || c === '!') {
209
+ braceNeg = true;
210
+ }
211
+ }
212
+ else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
213
+ inBrace = false;
214
+ }
215
+ acc += c;
216
+ continue;
217
+ }
218
+ else if (c === '[') {
219
+ inBrace = true;
220
+ braceStart = i;
221
+ braceNeg = false;
222
+ acc += c;
223
+ continue;
224
+ }
225
+ if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
226
+ ast.push(acc);
227
+ acc = '';
228
+ const ext = new AST(c, ast);
229
+ i = AST.#parseAST(str, ext, i, opt);
230
+ ast.push(ext);
231
+ continue;
232
+ }
233
+ acc += c;
234
+ }
235
+ ast.push(acc);
236
+ return i;
237
+ }
238
+ // some kind of extglob, pos is at the (
239
+ // find the next | or )
240
+ let i = pos + 1;
241
+ let part = new AST(null, ast);
242
+ const parts = [];
243
+ let acc = '';
244
+ while (i < str.length) {
245
+ const c = str.charAt(i++);
246
+ // still accumulate escapes at this point, but we do ignore
247
+ // starts that are escaped
248
+ if (escaping || c === '\\') {
249
+ escaping = !escaping;
250
+ acc += c;
251
+ continue;
252
+ }
253
+ if (inBrace) {
254
+ if (i === braceStart + 1) {
255
+ if (c === '^' || c === '!') {
256
+ braceNeg = true;
257
+ }
258
+ }
259
+ else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
260
+ inBrace = false;
261
+ }
262
+ acc += c;
263
+ continue;
264
+ }
265
+ else if (c === '[') {
266
+ inBrace = true;
267
+ braceStart = i;
268
+ braceNeg = false;
269
+ acc += c;
270
+ continue;
271
+ }
272
+ if (isExtglobType(c) && str.charAt(i) === '(') {
273
+ part.push(acc);
274
+ acc = '';
275
+ const ext = new AST(c, part);
276
+ part.push(ext);
277
+ i = AST.#parseAST(str, ext, i, opt);
278
+ continue;
279
+ }
280
+ if (c === '|') {
281
+ part.push(acc);
282
+ acc = '';
283
+ parts.push(part);
284
+ part = new AST(null, ast);
285
+ continue;
286
+ }
287
+ if (c === ')') {
288
+ if (acc === '' && ast.#parts.length === 0) {
289
+ ast.#emptyExt = true;
290
+ }
291
+ part.push(acc);
292
+ acc = '';
293
+ ast.push(...parts, part);
294
+ return i;
295
+ }
296
+ acc += c;
297
+ }
298
+ // unfinished extglob
299
+ // if we got here, it was a malformed extglob! not an extglob, but
300
+ // maybe something else in there.
301
+ ast.type = null;
302
+ ast.#hasMagic = undefined;
303
+ ast.#parts = [str.substring(pos - 1)];
304
+ return i;
305
+ }
306
+ static fromGlob(pattern, options = {}) {
307
+ const ast = new AST(null, undefined, options);
308
+ AST.#parseAST(pattern, ast, 0, options);
309
+ return ast;
310
+ }
311
+ // returns the regular expression if there's magic, or the unescaped
312
+ // string if not.
313
+ toMMPattern() {
314
+ // should only be called on root
315
+ /* c8 ignore start */
316
+ if (this !== this.#root)
317
+ return this.#root.toMMPattern();
318
+ /* c8 ignore stop */
319
+ const glob = this.toString();
320
+ const [re, body, hasMagic, uflag] = this.toRegExpSource();
321
+ // if we're in nocase mode, and not nocaseMagicOnly, then we do
322
+ // still need a regular expression if we have to case-insensitively
323
+ // match capital/lowercase characters.
324
+ const anyMagic = hasMagic ||
325
+ this.#hasMagic ||
326
+ (this.#options.nocase &&
327
+ !this.#options.nocaseMagicOnly &&
328
+ glob.toUpperCase() !== glob.toLowerCase());
329
+ if (!anyMagic) {
330
+ return body;
331
+ }
332
+ const flags = (this.#options.nocase ? 'i' : '') + (uflag ? 'u' : '');
333
+ return Object.assign(new RegExp(`^${re}$`, flags), {
334
+ _src: re,
335
+ _glob: glob,
336
+ });
337
+ }
338
+ // returns the string match, the regexp source, whether there's magic
339
+ // in the regexp (so a regular expression is required) and whether or
340
+ // not the uflag is needed for the regular expression (for posix classes)
341
+ // TODO: instead of injecting the start/end at this point, just return
342
+ // the BODY of the regexp, along with the start/end portions suitable
343
+ // for binding the start/end in either a joined full-path makeRe context
344
+ // (where we bind to (^|/), or a standalone matchPart context (where
345
+ // we bind to ^, and not /). Otherwise slashes get duped!
346
+ //
347
+ // In part-matching mode, the start is:
348
+ // - if not isStart: nothing
349
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
350
+ // - if dots allowed or not possible: ^
351
+ // - if dots possible and not allowed: ^(?!\.)
352
+ // end is:
353
+ // - if not isEnd(): nothing
354
+ // - else: $
355
+ //
356
+ // In full-path matching mode, we put the slash at the START of the
357
+ // pattern, so start is:
358
+ // - if first pattern: same as part-matching mode
359
+ // - if not isStart(): nothing
360
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
361
+ // - if dots allowed or not possible: /
362
+ // - if dots possible and not allowed: /(?!\.)
363
+ // end is:
364
+ // - if last pattern, same as part-matching mode
365
+ // - else nothing
366
+ //
367
+ // Always put the (?:$|/) on negated tails, though, because that has to be
368
+ // there to bind the end of the negated pattern portion, and it's easier to
369
+ // just stick it in now rather than try to inject it later in the middle of
370
+ // the pattern.
371
+ //
372
+ // We can just always return the same end, and leave it up to the caller
373
+ // to know whether it's going to be used joined or in parts.
374
+ // And, if the start is adjusted slightly, can do the same there:
375
+ // - if not isStart: nothing
376
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
377
+ // - if dots allowed or not possible: (?:/|^)
378
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
379
+ //
380
+ // But it's better to have a simpler binding without a conditional, for
381
+ // performance, so probably better to return both start options.
382
+ //
383
+ // Then the caller just ignores the end if it's not the first pattern,
384
+ // and the start always gets applied.
385
+ //
386
+ // But that's always going to be $ if it's the ending pattern, or nothing,
387
+ // so the caller can just attach $ at the end of the pattern when building.
388
+ //
389
+ // So the todo is:
390
+ // - better detect what kind of start is needed
391
+ // - return both flavors of starting pattern
392
+ // - attach $ at the end of the pattern when creating the actual RegExp
393
+ //
394
+ // Ah, but wait, no, that all only applies to the root when the first pattern
395
+ // is not an extglob. If the first pattern IS an extglob, then we need all
396
+ // that dot prevention biz to live in the extglob portions, because eg
397
+ // +(*|.x*) can match .xy but not .yx.
398
+ //
399
+ // So, return the two flavors if it's #root and the first child is not an
400
+ // AST, otherwise leave it to the child AST to handle it, and there,
401
+ // use the (?:^|/) style of start binding.
402
+ //
403
+ // Even simplified further:
404
+ // - Since the start for a join is eg /(?!\.) and the start for a part
405
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
406
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
407
+ toRegExpSource(allowDot) {
408
+ const dot = allowDot ?? !!this.#options.dot;
409
+ if (this.#root === this)
410
+ this.#fillNegs();
411
+ if (!this.type) {
412
+ const noEmpty = this.isStart() && this.isEnd();
413
+ const src = this.#parts
414
+ .map(p => {
415
+ const [re, _, hasMagic, uflag] = typeof p === 'string'
416
+ ? AST.#parseGlob(p, this.#hasMagic, noEmpty)
417
+ : p.toRegExpSource(allowDot);
418
+ this.#hasMagic = this.#hasMagic || hasMagic;
419
+ this.#uflag = this.#uflag || uflag;
420
+ return re;
421
+ })
422
+ .join('');
423
+ let start = '';
424
+ if (this.isStart()) {
425
+ if (typeof this.#parts[0] === 'string') {
426
+ // this is the string that will match the start of the pattern,
427
+ // so we need to protect against dots and such.
428
+ // '.' and '..' cannot match unless the pattern is that exactly,
429
+ // even if it starts with . or dot:true is set.
430
+ const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
431
+ if (!dotTravAllowed) {
432
+ const aps = addPatternStart;
433
+ // check if we have a possibility of matching . or ..,
434
+ // and prevent that.
435
+ const needNoTrav =
436
+ // dots are allowed, and the pattern starts with [ or .
437
+ (dot && aps.has(src.charAt(0))) ||
438
+ // the pattern starts with \., and then [ or .
439
+ (src.startsWith('\\.') && aps.has(src.charAt(2))) ||
440
+ // the pattern starts with \.\., and then [ or .
441
+ (src.startsWith('\\.\\.') && aps.has(src.charAt(4)));
442
+ // no need to prevent dots if it can't match a dot, or if a
443
+ // sub-pattern will be preventing it anyway.
444
+ const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
445
+ start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';
446
+ }
447
+ }
448
+ }
449
+ // append the "end of path portion" pattern to negation tails
450
+ let end = '';
451
+ if (this.isEnd() &&
452
+ this.#root.#filledNegs &&
453
+ this.#parent?.type === '!') {
454
+ end = '(?:$|\\/)';
455
+ }
456
+ const final = start + src + end;
457
+ return [
458
+ final,
459
+ unescape(src),
460
+ (this.#hasMagic = !!this.#hasMagic),
461
+ this.#uflag,
462
+ ];
463
+ }
464
+ // We need to calculate the body *twice* if it's a repeat pattern
465
+ // at the start, once in nodot mode, then again in dot mode, so a
466
+ // pattern like *(?) can match 'x.y'
467
+ const repeated = this.type === '*' || this.type === '+';
468
+ // some kind of extglob
469
+ const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
470
+ let body = this.#partsToRegExp(dot);
471
+ if (this.isStart() && this.isEnd() && !body && this.type !== '!') {
472
+ // invalid extglob, has to at least be *something* present, if it's
473
+ // the entire path portion.
474
+ const s = this.toString();
475
+ this.#parts = [s];
476
+ this.type = null;
477
+ this.#hasMagic = undefined;
478
+ return [s, unescape(this.toString()), false, false];
479
+ }
480
+ // XXX abstract out this map method
481
+ let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot
482
+ ? ''
483
+ : this.#partsToRegExp(true);
484
+ if (bodyDotAllowed === body) {
485
+ bodyDotAllowed = '';
486
+ }
487
+ if (bodyDotAllowed) {
488
+ body = `(?:${body})(?:${bodyDotAllowed})*?`;
489
+ }
490
+ // an empty !() is exactly equivalent to a starNoEmpty
491
+ let final = '';
492
+ if (this.type === '!' && this.#emptyExt) {
493
+ final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
494
+ }
495
+ else {
496
+ const close = this.type === '!'
497
+ ? // !() must match something,but !(x) can match ''
498
+ '))' +
499
+ (this.isStart() && !dot && !allowDot ? startNoDot : '') +
500
+ star +
501
+ ')'
502
+ : this.type === '@'
503
+ ? ')'
504
+ : this.type === '?'
505
+ ? ')?'
506
+ : this.type === '+' && bodyDotAllowed
507
+ ? ')'
508
+ : this.type === '*' && bodyDotAllowed
509
+ ? `)?`
510
+ : `)${this.type}`;
511
+ final = start + body + close;
512
+ }
513
+ return [
514
+ final,
515
+ unescape(body),
516
+ (this.#hasMagic = !!this.#hasMagic),
517
+ this.#uflag,
518
+ ];
519
+ }
520
+ #partsToRegExp(dot) {
521
+ return this.#parts
522
+ .map(p => {
523
+ // extglob ASTs should only contain parent ASTs
524
+ /* c8 ignore start */
525
+ if (typeof p === 'string') {
526
+ throw new Error('string type in extglob ast??');
527
+ }
528
+ /* c8 ignore stop */
529
+ // can ignore hasMagic, because extglobs are already always magic
530
+ const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
531
+ this.#uflag = this.#uflag || uflag;
532
+ return re;
533
+ })
534
+ .filter(p => !(this.isStart() && this.isEnd()) || !!p)
535
+ .join('|');
536
+ }
537
+ static #parseGlob(glob, hasMagic, noEmpty = false) {
538
+ let escaping = false;
539
+ let re = '';
540
+ let uflag = false;
541
+ for (let i = 0; i < glob.length; i++) {
542
+ const c = glob.charAt(i);
543
+ if (escaping) {
544
+ escaping = false;
545
+ re += (reSpecials.has(c) ? '\\' : '') + c;
546
+ continue;
547
+ }
548
+ if (c === '\\') {
549
+ if (i === glob.length - 1) {
550
+ re += '\\\\';
551
+ }
552
+ else {
553
+ escaping = true;
554
+ }
555
+ continue;
556
+ }
557
+ if (c === '[') {
558
+ const [src, needUflag, consumed, magic] = parseClass(glob, i);
559
+ if (consumed) {
560
+ re += src;
561
+ uflag = uflag || needUflag;
562
+ i += consumed - 1;
563
+ hasMagic = hasMagic || magic;
564
+ continue;
565
+ }
566
+ }
567
+ if (c === '*') {
568
+ if (noEmpty && glob === '*')
569
+ re += starNoEmpty;
570
+ else
571
+ re += star;
572
+ hasMagic = true;
573
+ continue;
574
+ }
575
+ if (c === '?') {
576
+ re += qmark;
577
+ hasMagic = true;
578
+ continue;
579
+ }
580
+ re += regExpEscape(c);
581
+ }
582
+ return [re, unescape(glob), !!hasMagic, uflag];
583
+ }
584
+ }
585
+ //# sourceMappingURL=ast.js.map