reflex-search 1.5.2 → 1.6.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 (58) hide show
  1. package/node_modules/.package-lock.json +15 -15
  2. package/node_modules/axios/CHANGELOG.md +126 -1
  3. package/node_modules/axios/README.md +390 -257
  4. package/node_modules/axios/dist/axios.js +511 -154
  5. package/node_modules/axios/dist/axios.min.js +3 -3
  6. package/node_modules/axios/dist/axios.min.js.map +1 -1
  7. package/node_modules/axios/dist/browser/axios.cjs +537 -124
  8. package/node_modules/axios/dist/esm/axios.js +537 -124
  9. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  10. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  11. package/node_modules/axios/dist/node/axios.cjs +753 -226
  12. package/node_modules/axios/index.d.cts +27 -4
  13. package/node_modules/axios/index.d.ts +23 -2
  14. package/node_modules/axios/lib/adapters/adapters.js +1 -1
  15. package/node_modules/axios/lib/adapters/fetch.js +217 -47
  16. package/node_modules/axios/lib/adapters/http.js +274 -169
  17. package/node_modules/axios/lib/adapters/xhr.js +1 -0
  18. package/node_modules/axios/lib/core/Axios.js +4 -2
  19. package/node_modules/axios/lib/core/AxiosError.js +13 -1
  20. package/node_modules/axios/lib/core/AxiosHeaders.js +12 -9
  21. package/node_modules/axios/lib/core/buildFullPath.js +29 -1
  22. package/node_modules/axios/lib/core/mergeConfig.js +35 -0
  23. package/node_modules/axios/lib/defaults/transitional.js +2 -0
  24. package/node_modules/axios/lib/env/data.js +1 -1
  25. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +1 -3
  26. package/node_modules/axios/lib/helpers/Http2Sessions.js +119 -0
  27. package/node_modules/axios/lib/helpers/buildURL.js +7 -4
  28. package/node_modules/axios/lib/helpers/composeSignals.js +1 -1
  29. package/node_modules/axios/lib/helpers/cookies.js +5 -1
  30. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +16 -11
  31. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -3
  32. package/node_modules/axios/lib/helpers/formDataToStream.js +2 -2
  33. package/node_modules/axios/lib/helpers/fromDataURI.js +4 -2
  34. package/node_modules/axios/lib/helpers/resolveConfig.js +26 -13
  35. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +33 -1
  36. package/node_modules/axios/lib/helpers/toFormData.js +48 -12
  37. package/node_modules/axios/lib/helpers/validator.js +1 -1
  38. package/node_modules/axios/lib/utils.js +97 -12
  39. package/node_modules/axios/package.json +29 -13
  40. package/node_modules/brace-expansion/dist/commonjs/index.js +24 -14
  41. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
  42. package/node_modules/brace-expansion/dist/esm/index.js +24 -14
  43. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
  44. package/node_modules/brace-expansion/package.json +2 -2
  45. package/node_modules/form-data/CHANGELOG.md +29 -2
  46. package/node_modules/form-data/README.md +4 -4
  47. package/node_modules/form-data/lib/form_data.js +14 -2
  48. package/node_modules/form-data/package.json +7 -7
  49. package/node_modules/hasown/CHANGELOG.md +18 -0
  50. package/node_modules/hasown/eslint.config.mjs +6 -0
  51. package/node_modules/hasown/package.json +13 -14
  52. package/npm-shrinkwrap.json +16 -16
  53. package/package.json +2 -2
  54. package/node_modules/axios/dist/axios.js.map +0 -1
  55. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  56. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  57. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
  58. package/node_modules/hasown/.eslintrc +0 -5
@@ -5,6 +5,10 @@ import AxiosError from '../core/AxiosError.js';
5
5
  // temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored
6
6
  import PlatformFormData from '../platform/node/classes/FormData.js';
7
7
 
8
+ // Default nesting limit shared with the inverse transform (formDataToJSON) so
9
+ // the FormData <-> JSON round-trip stays symmetric.
10
+ export const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
11
+
8
12
  /**
9
13
  * Determines if the given thing is a array or js object.
10
14
  *
@@ -115,8 +119,9 @@ function toFormData(obj, formData, options) {
115
119
  const dots = options.dots;
116
120
  const indexes = options.indexes;
117
121
  const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
118
- const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
122
+ const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
119
123
  const useBlob = _Blob && utils.isSpecCompliantForm(formData);
124
+ const stack = [];
120
125
 
121
126
  if (!utils.isFunction(visitor)) {
122
127
  throw new TypeError('visitor must be a function');
@@ -138,12 +143,50 @@ function toFormData(obj, formData, options) {
138
143
  }
139
144
 
140
145
  if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
141
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
146
+ if (useBlob && typeof _Blob === 'function') {
147
+ return new _Blob([value]);
148
+ }
149
+ if (typeof Buffer !== 'undefined') {
150
+ return Buffer.from(value);
151
+ }
152
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
142
153
  }
143
154
 
144
155
  return value;
145
156
  }
146
157
 
158
+ function throwIfMaxDepthExceeded(depth) {
159
+ if (depth > maxDepth) {
160
+ throw new AxiosError(
161
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
162
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
163
+ );
164
+ }
165
+ }
166
+
167
+ function stringifyWithDepthLimit(value, depth) {
168
+ if (maxDepth === Infinity) {
169
+ return JSON.stringify(value);
170
+ }
171
+
172
+ const ancestors = [];
173
+
174
+ return JSON.stringify(value, function limitDepth(_key, currentValue) {
175
+ if (!utils.isObject(currentValue)) {
176
+ return currentValue;
177
+ }
178
+
179
+ while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
180
+ ancestors.pop();
181
+ }
182
+
183
+ ancestors.push(currentValue);
184
+ throwIfMaxDepthExceeded(depth + ancestors.length - 1);
185
+
186
+ return currentValue;
187
+ });
188
+ }
189
+
147
190
  /**
148
191
  * Default visitor.
149
192
  *
@@ -167,7 +210,7 @@ function toFormData(obj, formData, options) {
167
210
  // eslint-disable-next-line no-param-reassign
168
211
  key = metaTokens ? key : key.slice(0, -2);
169
212
  // eslint-disable-next-line no-param-reassign
170
- value = JSON.stringify(value);
213
+ value = stringifyWithDepthLimit(value, 1);
171
214
  } else if (
172
215
  (utils.isArray(value) && isFlatArray(value)) ||
173
216
  ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
@@ -200,8 +243,6 @@ function toFormData(obj, formData, options) {
200
243
  return false;
201
244
  }
202
245
 
203
- const stack = [];
204
-
205
246
  const exposedHelpers = Object.assign(predicates, {
206
247
  defaultVisitor,
207
248
  convertValue,
@@ -211,15 +252,10 @@ function toFormData(obj, formData, options) {
211
252
  function build(value, path, depth = 0) {
212
253
  if (utils.isUndefined(value)) return;
213
254
 
214
- if (depth > maxDepth) {
215
- throw new AxiosError(
216
- 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
217
- AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
218
- );
219
- }
255
+ throwIfMaxDepthExceeded(depth);
220
256
 
221
257
  if (stack.indexOf(value) !== -1) {
222
- throw Error('Circular reference detected in ' + path.join('.'));
258
+ throw new Error('Circular reference detected in ' + path.join('.'));
223
259
  }
224
260
 
225
261
  stack.push(value);
@@ -79,7 +79,7 @@ validators.spelling = function spelling(correctSpelling) {
79
79
  */
80
80
 
81
81
  function assertOptions(options, schema, allowUnknown) {
82
- if (typeof options !== 'object') {
82
+ if (typeof options !== 'object' || options === null) {
83
83
  throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
84
84
  }
85
85
  const keys = Object.keys(options);
@@ -8,6 +8,57 @@ const { toString } = Object.prototype;
8
8
  const { getPrototypeOf } = Object;
9
9
  const { iterator, toStringTag } = Symbol;
10
10
 
11
+ /* Creating a function that will check if an object has a property. */
12
+ const hasOwnProperty = (
13
+ ({ hasOwnProperty }) =>
14
+ (obj, prop) =>
15
+ hasOwnProperty.call(obj, prop)
16
+ )(Object.prototype);
17
+
18
+ /**
19
+ * Walk the prototype chain (excluding the shared Object.prototype) looking for
20
+ * an own `prop`. This distinguishes genuine own/inherited members — including
21
+ * class accessors and template prototypes — from members injected via
22
+ * Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
23
+ * live on Object.prototype itself and are therefore never matched.
24
+ *
25
+ * @param {*} thing The value whose chain to inspect
26
+ * @param {string|symbol} prop The property key to look for
27
+ *
28
+ * @returns {boolean} True when `prop` is owned below Object.prototype
29
+ */
30
+ const hasOwnInPrototypeChain = (thing, prop) => {
31
+ let obj = thing;
32
+ const seen = [];
33
+
34
+ while (obj != null && obj !== Object.prototype) {
35
+ if (seen.indexOf(obj) !== -1) {
36
+ return false;
37
+ }
38
+ seen.push(obj);
39
+
40
+ if (hasOwnProperty(obj, prop)) {
41
+ return true;
42
+ }
43
+ obj = getPrototypeOf(obj);
44
+ }
45
+ return false;
46
+ };
47
+
48
+ /**
49
+ * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
50
+ * properties and members inherited from a non-Object.prototype source (a class
51
+ * instance or template object) are honored; a value reachable only through a
52
+ * polluted Object.prototype is ignored and `undefined` is returned.
53
+ *
54
+ * @param {*} obj The source object
55
+ * @param {string|symbol} prop The property key to read
56
+ *
57
+ * @returns {*} The resolved value, or undefined when unsafe/absent
58
+ */
59
+ const getSafeProp = (obj, prop) =>
60
+ obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
61
+
11
62
  const kindOf = ((cache) => (thing) => {
12
63
  const str = toString.call(thing);
13
64
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -133,7 +184,7 @@ const isBoolean = (thing) => thing === true || thing === false;
133
184
  * @returns {boolean} True if value is a plain Object, otherwise false
134
185
  */
135
186
  const isPlainObject = (val) => {
136
- if (kindOf(val) !== 'object') {
187
+ if (!isObject(val)) {
137
188
  return false;
138
189
  }
139
190
 
@@ -141,9 +192,12 @@ const isPlainObject = (val) => {
141
192
  return (
142
193
  (prototype === null ||
143
194
  prototype === Object.prototype ||
144
- Object.getPrototypeOf(prototype) === null) &&
145
- !(toStringTag in val) &&
146
- !(iterator in val)
195
+ getPrototypeOf(prototype) === null) &&
196
+ // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
197
+ // Symbol.iterator as evidence the value is a tagged/iterable type rather
198
+ // than a plain object, while ignoring keys injected onto Object.prototype.
199
+ !hasOwnInPrototypeChain(val, toStringTag) &&
200
+ !hasOwnInPrototypeChain(val, iterator)
147
201
  );
148
202
  };
149
203
 
@@ -412,7 +466,9 @@ function merge(...objs) {
412
466
  return;
413
467
  }
414
468
 
415
- const targetKey = (caseless && findKey(result, key)) || key;
469
+ // findKey lowercases the key, so caseless lookup only applies to strings —
470
+ // symbol keys are identity-matched.
471
+ const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
416
472
  // Read via own-prop only — a bare `result[targetKey]` walks the prototype
417
473
  // chain, so a polluted Object.prototype value could surface here and get
418
474
  // copied into the merged result.
@@ -429,7 +485,24 @@ function merge(...objs) {
429
485
  };
430
486
 
431
487
  for (let i = 0, l = objs.length; i < l; i++) {
432
- objs[i] && forEach(objs[i], assignValue);
488
+ const source = objs[i];
489
+ if (!source || isBuffer(source)) {
490
+ continue;
491
+ }
492
+
493
+ forEach(source, assignValue);
494
+
495
+ if (typeof source !== 'object' || isArray(source)) {
496
+ continue;
497
+ }
498
+
499
+ const symbols = Object.getOwnPropertySymbols(source);
500
+ for (let j = 0; j < symbols.length; j++) {
501
+ const symbol = symbols[j];
502
+ if (propertyIsEnumerable.call(source, symbol)) {
503
+ assignValue(source[symbol], symbol);
504
+ }
505
+ }
433
506
  }
434
507
  return result;
435
508
  }
@@ -651,12 +724,7 @@ const toCamelCase = (str) => {
651
724
  });
652
725
  };
653
726
 
654
- /* Creating a function that will check if an object has a property. */
655
- const hasOwnProperty = (
656
- ({ hasOwnProperty }) =>
657
- (obj, prop) =>
658
- hasOwnProperty.call(obj, prop)
659
- )(Object.prototype);
727
+ const { propertyIsEnumerable } = Object.prototype;
660
728
 
661
729
  /**
662
730
  * Determine if a value is a RegExp object
@@ -869,6 +937,20 @@ const asap =
869
937
 
870
938
  const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
871
939
 
940
+ /**
941
+ * Determine if a value is iterable via an iterator that is NOT sourced solely
942
+ * from a polluted Object.prototype. Use this instead of `isIterable` whenever
943
+ * the iterable comes from untrusted input (e.g. user-supplied header sources),
944
+ * so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
945
+ * into an attacker-controlled entries iterator.
946
+ *
947
+ * @param {*} thing The value to test
948
+ *
949
+ * @returns {boolean} True if value has a non-polluted iterator
950
+ */
951
+ const isSafeIterable = (thing) =>
952
+ thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
953
+
872
954
  export default {
873
955
  isArray,
874
956
  isArrayBuffer,
@@ -913,6 +995,8 @@ export default {
913
995
  isHTMLForm,
914
996
  hasOwnProperty,
915
997
  hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
998
+ hasOwnInPrototypeChain,
999
+ getSafeProp,
916
1000
  reduceDescriptors,
917
1001
  freezeMethods,
918
1002
  toObjectSet,
@@ -929,4 +1013,5 @@ export default {
929
1013
  setImmediate: _setImmediate,
930
1014
  asap,
931
1015
  isIterable,
1016
+ isSafeIterable,
932
1017
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.16.1",
3
+ "version": "1.18.1",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "./dist/node/axios.cjs",
6
6
  "module": "./index.js",
@@ -86,9 +86,9 @@
86
86
  "Justin Beckwith (https://github.com/JustinBeckwith)",
87
87
  "Martti Laine (https://github.com/codeclown)",
88
88
  "Xianming Zhong (https://github.com/chinesedfan)",
89
- "Willian Agostini (https://github.com/WillianAgostini)",
90
89
  "Shaan Majid (https://github.com/shaanmajid)",
91
90
  "Remco Haszing (https://github.com/remcohaszing)",
91
+ "Willian Agostini (https://github.com/WillianAgostini)",
92
92
  "Rikki Gibson (https://github.com/RikkiGibson)"
93
93
  ],
94
94
  "sideEffects": false,
@@ -97,6 +97,22 @@
97
97
  "url": "https://github.com/axios/axios/issues"
98
98
  },
99
99
  "homepage": "https://axios-http.com",
100
+ "files": [
101
+ "index.js",
102
+ "index.d.ts",
103
+ "index.d.cts",
104
+ "CHANGELOG.md",
105
+ "MIGRATION_GUIDE.md",
106
+ "lib/",
107
+ "dist/axios.js",
108
+ "dist/axios.min.js",
109
+ "dist/axios.min.js.map",
110
+ "dist/esm/axios.js",
111
+ "dist/esm/axios.min.js",
112
+ "dist/esm/axios.min.js.map",
113
+ "dist/browser/axios.cjs",
114
+ "dist/node/axios.cjs"
115
+ ],
100
116
  "scripts": {
101
117
  "build": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
102
118
  "version": "npm run build && git add package.json",
@@ -128,9 +144,9 @@
128
144
  },
129
145
  "devDependencies": {
130
146
  "@babel/core": "^7.29.0",
131
- "@babel/preset-env": "^7.29.2",
132
- "@commitlint/cli": "^20.5.0",
133
- "@commitlint/config-conventional": "^20.5.0",
147
+ "@babel/preset-env": "^7.29.5",
148
+ "@commitlint/cli": "^21.0.1",
149
+ "@commitlint/config-conventional": "^21.0.1",
134
150
  "@eslint/js": "^10.0.1",
135
151
  "@rollup/plugin-alias": "^6.0.0",
136
152
  "@rollup/plugin-babel": "^7.0.0",
@@ -138,34 +154,34 @@
138
154
  "@rollup/plugin-json": "^6.1.0",
139
155
  "@rollup/plugin-node-resolve": "^16.0.3",
140
156
  "@rollup/plugin-terser": "^1.0.0",
141
- "@vitest/browser": "^4.1.5",
142
- "@vitest/browser-playwright": "^4.1.5",
157
+ "@vitest/browser": "^4.1.7",
158
+ "@vitest/browser-playwright": "^4.1.7",
143
159
  "abortcontroller-polyfill": "^1.7.8",
144
160
  "acorn": "^8.16.0",
145
161
  "body-parser": "^2.2.2",
146
162
  "chalk": "^5.6.2",
147
163
  "cross-env": "^10.1.0",
148
164
  "dev-null": "^0.1.1",
149
- "eslint": "^10.2.1",
165
+ "eslint": "^10.4.0",
150
166
  "express": "^5.2.1",
151
167
  "formdata-node": "^6.0.3",
152
168
  "formidable": "^3.5.4",
153
169
  "fs-extra": "^11.3.4",
154
170
  "get-stream": "^9.0.1",
155
- "globals": "^17.5.0",
171
+ "globals": "^17.6.0",
156
172
  "gulp": "^5.0.1",
157
173
  "husky": "^9.1.7",
158
- "lint-staged": "^16.4.0",
174
+ "lint-staged": "^17.0.5",
159
175
  "minimist": "^1.2.8",
160
176
  "multer": "^2.1.1",
161
- "playwright": "^1.59.1",
177
+ "playwright": "^1.60.0",
162
178
  "prettier": "^3.8.3",
163
- "rollup": "^4.60.2",
179
+ "rollup": "^4.60.4",
164
180
  "rollup-plugin-bundle-size": "^1.0.3",
165
181
  "selfsigned": "^5.5.0",
166
182
  "stream-throttle": "^0.1.3",
167
183
  "typescript": "^5.9.3",
168
- "vitest": "^4.1.5"
184
+ "vitest": "^4.1.7"
169
185
  },
170
186
  "commitlint": {
171
187
  "rules": {
@@ -95,19 +95,23 @@ function gte(i, y) {
95
95
  function expand_(str, max, isTop) {
96
96
  /** @type {string[]} */
97
97
  const expansions = [];
98
- const m = (0, balanced_match_1.balanced)('{', '}', str);
99
- if (!m)
100
- return [str];
101
- // no need to expand pre, since it is guaranteed to be free of brace-sets
102
- const pre = m.pre;
103
- const post = m.post.length ? expand_(m.post, max, false) : [''];
104
- if (/\$$/.test(m.pre)) {
105
- for (let k = 0; k < post.length && k < max; k++) {
106
- const expansion = pre + '{' + m.body + '}' + post[k];
107
- expansions.push(expansion);
98
+ // The `{a},b}` rewrite below restarts expansion on a rewritten string with
99
+ // the same `max` and `isTop = true`. Loop instead of recursing so a long run
100
+ // of non-expanding `{}` groups can't exhaust the call stack.
101
+ for (;;) {
102
+ const m = (0, balanced_match_1.balanced)('{', '}', str);
103
+ if (!m)
104
+ return [str];
105
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
106
+ const pre = m.pre;
107
+ if (/\$$/.test(m.pre)) {
108
+ const post = m.post.length ? expand_(m.post, max, false) : [''];
109
+ for (let k = 0; k < post.length && k < max; k++) {
110
+ const expansion = pre + '{' + m.body + '}' + post[k];
111
+ expansions.push(expansion);
112
+ }
113
+ return expansions;
108
114
  }
109
- }
110
- else {
111
115
  const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
112
116
  const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
113
117
  const isSequence = isNumericSequence || isAlphaSequence;
@@ -116,10 +120,16 @@ function expand_(str, max, isTop) {
116
120
  // {a},b}
117
121
  if (m.post.match(/,(?!,).*\}/)) {
118
122
  str = m.pre + '{' + m.body + escClose + m.post;
119
- return expand_(str, max, true);
123
+ isTop = true;
124
+ continue;
120
125
  }
121
126
  return [str];
122
127
  }
128
+ // Only expand post once we know this brace set actually expands. Computing
129
+ // it before the early returns above expanded post a second time on every
130
+ // non-expanding `{}`, which is what made inputs like `a{},{},{}...` blow up
131
+ // exponentially.
132
+ const post = m.post.length ? expand_(m.post, max, false) : [''];
123
133
  let n;
124
134
  if (isSequence) {
125
135
  n = m.body.split(/\.\./);
@@ -195,7 +205,7 @@ function expand_(str, max, isTop) {
195
205
  }
196
206
  }
197
207
  }
208
+ return expansions;
198
209
  }
199
- return expansions;
200
210
  }
201
211
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA8EA,wBAkBC;AAhGD,mDAAyC;AAEzC,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,C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CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n if (!str) {\n return ['']\n }\n\n const parts: string[] = []\n const m = balanced('{', '}', str)\n\n if (!m) {\n return str.split(',')\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n\n p[p.length - 1] += '{' + body + '}'\n const postParts = parseCommaParts(post)\n if (post.length) {\n ;(p[p.length - 1] as string) += postParts.shift()\n p.push.apply(p, postParts)\n }\n\n parts.push.apply(parts, p)\n\n return parts\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const { max = EXPANSION_MAX } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(escapeBraces(str), max, true).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\nfunction expand_(str: string, max: number, isTop: boolean): string[] {\n /** @type {string[]} */\n const expansions: string[] = []\n\n const m = balanced('{', '}', str)\n if (!m) return [str]\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = m.pre\n const post: string[] = m.post.length ? expand_(m.post, max, false) : ['']\n\n if (/\\$$/.test(m.pre)) {\n for (let k = 0; k < post.length && k < max; k++) {\n const expansion = pre + '{' + m.body + '}' + post[k]\n expansions.push(expansion)\n }\n } else {\n const isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body)\n const isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(\n m.body,\n )\n const isSequence = isNumericSequence || isAlphaSequence\n const isOptions = m.body.indexOf(',') >= 0\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,(?!,).*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post\n return expand_(str, max, true)\n }\n return [str]\n }\n\n let n: string[]\n if (isSequence) {\n n = m.body.split(/\\.\\./)\n } else {\n n = parseCommaParts(m.body)\n if (n.length === 1 && n[0] !== undefined) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand_(n[0], max, false).map(embrace)\n //XXX is this necessary? Can't seem to hit it in tests.\n /* c8 ignore start */\n if (n.length === 1) {\n return post.map(p => m.pre + n[0] + p)\n }\n /* c8 ignore stop */\n }\n }\n\n // at this point, n is the parts, and we know it's not a comma set\n // with a single entry.\n let N: string[]\n\n if (isSequence && n[0] !== undefined && n[1] !== undefined) {\n const x = numeric(n[0])\n const y = numeric(n[1])\n const width = Math.max(n[0].length, n[1].length)\n let incr =\n n.length === 3 && n[2] !== undefined ?\n Math.max(Math.abs(numeric(n[2])), 1)\n : 1\n let test = lte\n const reverse = y < x\n if (reverse) {\n incr *= -1\n test = gte\n }\n const pad = n.some(isPadded)\n\n N = []\n\n for (let i = x; test(i, y) && N.length < max; i += incr) {\n let c\n if (isAlphaSequence) {\n c = String.fromCharCode(i)\n if (c === '\\\\') {\n c = ''\n }\n } else {\n c = String(i)\n if (pad) {\n const need = width - c.length\n if (need > 0) {\n const z = new Array(need + 1).join('0')\n if (i < 0) {\n c = '-' + z + c.slice(1)\n } else {\n c = z + c\n }\n }\n }\n }\n N.push(c)\n }\n } else {\n N = []\n\n for (let j = 0; j < n.length; j++) {\n N.push.apply(N, expand_(n[j] as string, max, false))\n }\n }\n\n for (let j = 0; j < N.length; j++) {\n for (let k = 0; k < post.length && expansions.length < max; k++) {\n const expansion = pre + N[j] + post[k]\n if (!isTop || isSequence || expansion) {\n expansions.push(expansion)\n }\n }\n }\n }\n\n return expansions\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA8EA,wBAkBC;AAhGD,mDAAyC;AAEzC,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AACjD,MAAM,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC,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,CAAC;gBAChE,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;gBACtC,IAAI,CAAC,KAAK,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;oBACtC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAA;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n if (!str) {\n return ['']\n }\n\n const parts: string[] = []\n const m = balanced('{', '}', str)\n\n if (!m) {\n return str.split(',')\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n\n p[p.length - 1] += '{' + body + '}'\n const postParts = parseCommaParts(post)\n if (post.length) {\n ;(p[p.length - 1] as string) += postParts.shift()\n p.push.apply(p, postParts)\n }\n\n parts.push.apply(parts, p)\n\n return parts\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const { max = EXPANSION_MAX } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(escapeBraces(str), max, true).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\nfunction expand_(str: string, max: number, isTop: boolean): string[] {\n /** @type {string[]} */\n const expansions: string[] = []\n\n // The `{a},b}` rewrite below restarts expansion on a rewritten string with\n // the same `max` and `isTop = true`. Loop instead of recursing so a long run\n // of non-expanding `{}` groups can't exhaust the call stack.\n for (;;) {\n const m = balanced('{', '}', str)\n if (!m) return [str]\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = m.pre\n\n if (/\\$$/.test(m.pre)) {\n const post: string[] =\n m.post.length ? expand_(m.post, max, false) : ['']\n for (let k = 0; k < post.length && k < max; k++) {\n const expansion = pre + '{' + m.body + '}' + post[k]\n expansions.push(expansion)\n }\n return expansions\n }\n\n const isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body)\n const isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(\n m.body,\n )\n const isSequence = isNumericSequence || isAlphaSequence\n const isOptions = m.body.indexOf(',') >= 0\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,(?!,).*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post\n isTop = true\n continue\n }\n return [str]\n }\n\n // Only expand post once we know this brace set actually expands. Computing\n // it before the early returns above expanded post a second time on every\n // non-expanding `{}`, which is what made inputs like `a{},{},{}...` blow up\n // exponentially.\n const post: string[] =\n m.post.length ? expand_(m.post, max, false) : ['']\n\n let n: string[]\n if (isSequence) {\n n = m.body.split(/\\.\\./)\n } else {\n n = parseCommaParts(m.body)\n if (n.length === 1 && n[0] !== undefined) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand_(n[0], max, false).map(embrace)\n //XXX is this necessary? Can't seem to hit it in tests.\n /* c8 ignore start */\n if (n.length === 1) {\n return post.map(p => m.pre + n[0] + p)\n }\n /* c8 ignore stop */\n }\n }\n\n // at this point, n is the parts, and we know it's not a comma set\n // with a single entry.\n let N: string[]\n\n if (isSequence && n[0] !== undefined && n[1] !== undefined) {\n const x = numeric(n[0])\n const y = numeric(n[1])\n const width = Math.max(n[0].length, n[1].length)\n let incr =\n n.length === 3 && n[2] !== undefined ?\n Math.max(Math.abs(numeric(n[2])), 1)\n : 1\n let test = lte\n const reverse = y < x\n if (reverse) {\n incr *= -1\n test = gte\n }\n const pad = n.some(isPadded)\n\n N = []\n\n for (let i = x; test(i, y) && N.length < max; i += incr) {\n let c\n if (isAlphaSequence) {\n c = String.fromCharCode(i)\n if (c === '\\\\') {\n c = ''\n }\n } else {\n c = String(i)\n if (pad) {\n const need = width - c.length\n if (need > 0) {\n const z = new Array(need + 1).join('0')\n if (i < 0) {\n c = '-' + z + c.slice(1)\n } else {\n c = z + c\n }\n }\n }\n }\n N.push(c)\n }\n } else {\n N = []\n\n for (let j = 0; j < n.length; j++) {\n N.push.apply(N, expand_(n[j] as string, max, false))\n }\n }\n\n for (let j = 0; j < N.length; j++) {\n for (let k = 0; k < post.length && expansions.length < max; k++) {\n const expansion = pre + N[j] + post[k]\n if (!isTop || isSequence || expansion) {\n expansions.push(expansion)\n }\n }\n }\n\n return expansions\n }\n}\n"]}
@@ -91,19 +91,23 @@ function gte(i, y) {
91
91
  function expand_(str, max, isTop) {
92
92
  /** @type {string[]} */
93
93
  const expansions = [];
94
- const m = balanced('{', '}', str);
95
- if (!m)
96
- return [str];
97
- // no need to expand pre, since it is guaranteed to be free of brace-sets
98
- const pre = m.pre;
99
- const post = m.post.length ? expand_(m.post, max, false) : [''];
100
- if (/\$$/.test(m.pre)) {
101
- for (let k = 0; k < post.length && k < max; k++) {
102
- const expansion = pre + '{' + m.body + '}' + post[k];
103
- expansions.push(expansion);
94
+ // The `{a},b}` rewrite below restarts expansion on a rewritten string with
95
+ // the same `max` and `isTop = true`. Loop instead of recursing so a long run
96
+ // of non-expanding `{}` groups can't exhaust the call stack.
97
+ for (;;) {
98
+ const m = balanced('{', '}', str);
99
+ if (!m)
100
+ return [str];
101
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
102
+ const pre = m.pre;
103
+ if (/\$$/.test(m.pre)) {
104
+ const post = m.post.length ? expand_(m.post, max, false) : [''];
105
+ for (let k = 0; k < post.length && k < max; k++) {
106
+ const expansion = pre + '{' + m.body + '}' + post[k];
107
+ expansions.push(expansion);
108
+ }
109
+ return expansions;
104
110
  }
105
- }
106
- else {
107
111
  const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
108
112
  const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
109
113
  const isSequence = isNumericSequence || isAlphaSequence;
@@ -112,10 +116,16 @@ function expand_(str, max, isTop) {
112
116
  // {a},b}
113
117
  if (m.post.match(/,(?!,).*\}/)) {
114
118
  str = m.pre + '{' + m.body + escClose + m.post;
115
- return expand_(str, max, true);
119
+ isTop = true;
120
+ continue;
116
121
  }
117
122
  return [str];
118
123
  }
124
+ // Only expand post once we know this brace set actually expands. Computing
125
+ // it before the early returns above expanded post a second time on every
126
+ // non-expanding `{}`, which is what made inputs like `a{},{},{}...` blow up
127
+ // exponentially.
128
+ const post = m.post.length ? expand_(m.post, max, false) : [''];
119
129
  let n;
120
130
  if (isSequence) {
121
131
  n = m.body.split(/\.\./);
@@ -191,7 +201,7 @@ function expand_(str, max, isTop) {
191
201
  }
192
202
  }
193
203
  }
204
+ return expansions;
194
205
  }
195
- return expansions;
196
206
  }
197
207
  //# sourceMappingURL=index.js.map