@unocss/autocomplete 0.31.16 → 0.32.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.
package/dist/index.cjs CHANGED
@@ -156,14 +156,13 @@ function createAutocomplete(uno) {
156
156
  };
157
157
  async function enumerate() {
158
158
  const matched = /* @__PURE__ */ new Set();
159
- const a2z = "abcdefghijklmnopqrstuvwxyz";
160
- const p = [];
161
- for (const a of a2z) {
162
- for (const b of a2z) {
163
- p.push(suggest(`${a}${b}`).then((i) => i.forEach((j) => matched.add(j))));
164
- }
165
- }
166
- await Promise.all(p);
159
+ const a2z = Array.from("abcdefghijklmnopqrstuvwxyz");
160
+ const a2zd = [...a2z, "-"];
161
+ const keys = a2z.flatMap((i) => [
162
+ i,
163
+ ...a2zd.map((j) => `${i}${j}`)
164
+ ]);
165
+ await Promise.all(keys.map((key) => suggest(key).then((i) => i.forEach((j) => matched.add(j)))));
167
166
  return matched;
168
167
  }
169
168
  function getParsed(template) {
@@ -177,7 +176,7 @@ function createAutocomplete(uno) {
177
176
  if (cache.has(input))
178
177
  return cache.get(input);
179
178
  const [, processed, , variants] = uno.matchVariants(input);
180
- const idx = processed ? input.search(processed) : input.length;
179
+ const idx = processed ? input.search(core.escapeRegExp(processed)) : input.length;
181
180
  if (idx === -1)
182
181
  return [];
183
182
  const variantPrefix = input.slice(0, idx);
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { toArray, uniq } from '@unocss/core';
1
+ import { escapeRegExp, toArray, uniq } from '@unocss/core';
2
2
  import LRU from 'lru-cache';
3
3
 
4
4
  const shorthands = {
@@ -148,14 +148,13 @@ function createAutocomplete(uno) {
148
148
  };
149
149
  async function enumerate() {
150
150
  const matched = /* @__PURE__ */ new Set();
151
- const a2z = "abcdefghijklmnopqrstuvwxyz";
152
- const p = [];
153
- for (const a of a2z) {
154
- for (const b of a2z) {
155
- p.push(suggest(`${a}${b}`).then((i) => i.forEach((j) => matched.add(j))));
156
- }
157
- }
158
- await Promise.all(p);
151
+ const a2z = Array.from("abcdefghijklmnopqrstuvwxyz");
152
+ const a2zd = [...a2z, "-"];
153
+ const keys = a2z.flatMap((i) => [
154
+ i,
155
+ ...a2zd.map((j) => `${i}${j}`)
156
+ ]);
157
+ await Promise.all(keys.map((key) => suggest(key).then((i) => i.forEach((j) => matched.add(j)))));
159
158
  return matched;
160
159
  }
161
160
  function getParsed(template) {
@@ -169,7 +168,7 @@ function createAutocomplete(uno) {
169
168
  if (cache.has(input))
170
169
  return cache.get(input);
171
170
  const [, processed, , variants] = uno.matchVariants(input);
172
- const idx = processed ? input.search(processed) : input.length;
171
+ const idx = processed ? input.search(escapeRegExp(processed)) : input.length;
173
172
  if (idx === -1)
174
173
  return [];
175
174
  const variantPrefix = input.slice(0, idx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/autocomplete",
3
- "version": "0.31.16",
3
+ "version": "0.32.1",
4
4
  "description": "Autocomplete utils for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/lru-cache": "^7.6.1",
39
- "@unocss/core": "0.31.16"
39
+ "@unocss/core": "0.32.1"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild",