@unocss/autocomplete 0.53.6 → 0.54.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
@@ -60,12 +60,16 @@ function handleRegexMatch(str, regex, onMatched, onNotMatched) {
60
60
  if (lastIndex !== str.length)
61
61
  onNotMatched(str.slice(lastIndex), lastIndex, str.length);
62
62
  }
63
- function parseAutocomplete(template, theme = {}) {
63
+ function parseAutocomplete(template, theme = {}, extraShorthands = {}) {
64
64
  const parts = [];
65
+ const newShorthands = {
66
+ ...shorthands,
67
+ ...extraShorthands
68
+ };
65
69
  template = template.replace(/<(\w+)>/g, (_, key) => {
66
- if (!shorthands[key])
70
+ if (!newShorthands[key])
67
71
  throw new Error(`Unknown template shorthand: ${key}`);
68
- return shorthands[key];
72
+ return newShorthands[key];
69
73
  });
70
74
  handleGroups(template);
71
75
  const fzf$1 = new fzf.Fzf(getAllCombination(parts));
@@ -234,7 +238,7 @@ function createAutocomplete(uno, options = {}) {
234
238
  }
235
239
  function getParsed(template) {
236
240
  if (!templateCache.has(template))
237
- templateCache.set(template, parseAutocomplete(template, uno.config.theme));
241
+ templateCache.set(template, parseAutocomplete(template, uno.config.theme, uno.config.autocomplete.shorthands));
238
242
  return templateCache.get(template).suggest;
239
243
  }
240
244
  async function suggest(input, allowsEmptyInput = false) {
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ declare function createAutocomplete(uno: UnoGenerator, options?: AutocompleteOpt
35
35
 
36
36
  declare const shorthands: Record<string, string>;
37
37
  declare const ignoredThemeKeys: string[];
38
- declare function parseAutocomplete(template: string, theme?: any): ParsedAutocompleteTemplate;
38
+ declare function parseAutocomplete(template: string, theme?: any, extraShorthands?: Record<string, string>): ParsedAutocompleteTemplate;
39
39
 
40
40
  declare function searchUsageBoundary(line: string, index: number): {
41
41
  content: string;
package/dist/index.mjs CHANGED
@@ -56,12 +56,16 @@ function handleRegexMatch(str, regex, onMatched, onNotMatched) {
56
56
  if (lastIndex !== str.length)
57
57
  onNotMatched(str.slice(lastIndex), lastIndex, str.length);
58
58
  }
59
- function parseAutocomplete(template, theme = {}) {
59
+ function parseAutocomplete(template, theme = {}, extraShorthands = {}) {
60
60
  const parts = [];
61
+ const newShorthands = {
62
+ ...shorthands,
63
+ ...extraShorthands
64
+ };
61
65
  template = template.replace(/<(\w+)>/g, (_, key) => {
62
- if (!shorthands[key])
66
+ if (!newShorthands[key])
63
67
  throw new Error(`Unknown template shorthand: ${key}`);
64
- return shorthands[key];
68
+ return newShorthands[key];
65
69
  });
66
70
  handleGroups(template);
67
71
  const fzf = new Fzf(getAllCombination(parts));
@@ -230,7 +234,7 @@ function createAutocomplete(uno, options = {}) {
230
234
  }
231
235
  function getParsed(template) {
232
236
  if (!templateCache.has(template))
233
- templateCache.set(template, parseAutocomplete(template, uno.config.theme));
237
+ templateCache.set(template, parseAutocomplete(template, uno.config.theme, uno.config.autocomplete.shorthands));
234
238
  return templateCache.get(template).suggest;
235
239
  }
236
240
  async function suggest(input, allowsEmptyInput = false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/autocomplete",
3
- "version": "0.53.6",
3
+ "version": "0.54.1",
4
4
  "description": "Autocomplete utils for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "lru-cache": "^10.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@unocss/core": "0.53.6"
40
+ "@unocss/core": "0.54.1"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild",