@unocss/autocomplete 0.31.17 → 0.32.7

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,14 @@ 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)))));
166
+ await Promise.all([...matched].filter((i) => i.match(/^\w+$/) && i.length > 3).map((i) => suggest(`${i}-`).then((i2) => i2.forEach((j) => matched.add(j)))));
167
167
  return matched;
168
168
  }
169
169
  function getParsed(template) {
@@ -177,7 +177,7 @@ function createAutocomplete(uno) {
177
177
  if (cache.has(input))
178
178
  return cache.get(input);
179
179
  const [, processed, , variants] = uno.matchVariants(input);
180
- const idx = processed ? input.search(processed) : input.length;
180
+ const idx = processed ? input.search(core.escapeRegExp(processed)) : input.length;
181
181
  if (idx === -1)
182
182
  return [];
183
183
  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,14 @@ 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)))));
158
+ await Promise.all([...matched].filter((i) => i.match(/^\w+$/) && i.length > 3).map((i) => suggest(`${i}-`).then((i2) => i2.forEach((j) => matched.add(j)))));
159
159
  return matched;
160
160
  }
161
161
  function getParsed(template) {
@@ -169,7 +169,7 @@ function createAutocomplete(uno) {
169
169
  if (cache.has(input))
170
170
  return cache.get(input);
171
171
  const [, processed, , variants] = uno.matchVariants(input);
172
- const idx = processed ? input.search(processed) : input.length;
172
+ const idx = processed ? input.search(escapeRegExp(processed)) : input.length;
173
173
  if (idx === -1)
174
174
  return [];
175
175
  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.17",
3
+ "version": "0.32.7",
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.17"
39
+ "@unocss/core": "0.32.7"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild",