@unocss/preset-icons 0.65.1 → 0.65.2

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/browser.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { c as createCDNLoader } from './shared/preset-icons.Bd-ia2YP.mjs';
2
- import { c as createPresetIcons, b as createCDNFetchLoader, l as loadIcon } from './shared/preset-icons.BORBFY-D.mjs';
3
- export { a as combineLoaders, g as getEnvFlags, i as icons, p as parseIconWithLoader } from './shared/preset-icons.BORBFY-D.mjs';
1
+ import { c as createCDNLoader } from './shared/preset-icons.CqrgFOyb.mjs';
2
+ import { c as createPresetIcons, b as createCDNFetchLoader, l as loadIcon } from './shared/preset-icons.DvZCj0no.mjs';
3
+ export { a as combineLoaders, g as getEnvFlags, i as icons, p as parseIconWithLoader } from './shared/preset-icons.DvZCj0no.mjs';
4
4
  import 'ofetch';
5
5
  import '@unocss/core';
6
6
 
package/dist/core.d.mts CHANGED
@@ -50,6 +50,19 @@ interface IconsOptions {
50
50
  * @default false
51
51
  */
52
52
  warn?: boolean;
53
+ /**
54
+ * `@iconify-json` collections to use (will be also auto installed when missing and `autoInstall` enabled).
55
+ *
56
+ * This option should be used only when there are new `@iconify-json` collections not listed in the default icons preset collection names.
57
+ *
58
+ * Adding external collections will not work, you should use `FileSystemIconLoader` from
59
+ * `@iconify/utils/lib/loader/fs` or `createExternalPackageIconLoader` from
60
+ * `@iconify/utils/lib/loader/external-pkg` instead.
61
+ *
62
+ * @see https://unocss.dev/presets/icons#filesystemiconloader
63
+ * @see https://unocss.dev/presets/icons#externalpackageiconloader
64
+ */
65
+ iconifyCollectionsNames?: string[];
53
66
  /**
54
67
  * In Node.js environment, the preset will search for the installed iconify dataset automatically.
55
68
  * When using in the browser, this options is provided to provide dataset with custom loading mechanism.
@@ -323,7 +336,7 @@ declare function getEnvFlags(): {
323
336
  isVSCode: boolean;
324
337
  isESLint: boolean;
325
338
  };
326
- declare function parseIconWithLoader(body: string, loader: UniversalIconLoader, options?: IconifyLoaderOptions): Promise<{
339
+ declare function parseIconWithLoader(body: string, loader: UniversalIconLoader, options?: IconifyLoaderOptions, safeCollectionsNames?: string[]): Promise<{
327
340
  collection: string;
328
341
  name: string;
329
342
  svg: string;
package/dist/core.d.ts CHANGED
@@ -50,6 +50,19 @@ interface IconsOptions {
50
50
  * @default false
51
51
  */
52
52
  warn?: boolean;
53
+ /**
54
+ * `@iconify-json` collections to use (will be also auto installed when missing and `autoInstall` enabled).
55
+ *
56
+ * This option should be used only when there are new `@iconify-json` collections not listed in the default icons preset collection names.
57
+ *
58
+ * Adding external collections will not work, you should use `FileSystemIconLoader` from
59
+ * `@iconify/utils/lib/loader/fs` or `createExternalPackageIconLoader` from
60
+ * `@iconify/utils/lib/loader/external-pkg` instead.
61
+ *
62
+ * @see https://unocss.dev/presets/icons#filesystemiconloader
63
+ * @see https://unocss.dev/presets/icons#externalpackageiconloader
64
+ */
65
+ iconifyCollectionsNames?: string[];
53
66
  /**
54
67
  * In Node.js environment, the preset will search for the installed iconify dataset automatically.
55
68
  * When using in the browser, this options is provided to provide dataset with custom loading mechanism.
@@ -323,7 +336,7 @@ declare function getEnvFlags(): {
323
336
  isVSCode: boolean;
324
337
  isESLint: boolean;
325
338
  };
326
- declare function parseIconWithLoader(body: string, loader: UniversalIconLoader, options?: IconifyLoaderOptions): Promise<{
339
+ declare function parseIconWithLoader(body: string, loader: UniversalIconLoader, options?: IconifyLoaderOptions, safeCollectionsNames?: string[]): Promise<{
327
340
  collection: string;
328
341
  name: string;
329
342
  svg: string;
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { a as combineLoaders, b as createCDNFetchLoader, c as createPresetIcons, g as getEnvFlags, i as icons, p as parseIconWithLoader } from './shared/preset-icons.BORBFY-D.mjs';
1
+ export { a as combineLoaders, b as createCDNFetchLoader, c as createPresetIcons, g as getEnvFlags, i as icons, p as parseIconWithLoader } from './shared/preset-icons.DvZCj0no.mjs';
2
2
  import '@unocss/core';
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { definePreset } from '@unocss/core';
2
- import { c as createCDNLoader } from './shared/preset-icons.Bd-ia2YP.mjs';
3
- import { c as createPresetIcons, g as getEnvFlags, a as combineLoaders, l as loadIcon } from './shared/preset-icons.BORBFY-D.mjs';
4
- export { b as createCDNFetchLoader, i as icons, p as parseIconWithLoader } from './shared/preset-icons.BORBFY-D.mjs';
2
+ import { c as createCDNLoader } from './shared/preset-icons.CqrgFOyb.mjs';
3
+ import { c as createPresetIcons, g as getEnvFlags, a as combineLoaders, l as loadIcon } from './shared/preset-icons.DvZCj0no.mjs';
4
+ export { b as createCDNFetchLoader, i as icons, p as parseIconWithLoader } from './shared/preset-icons.DvZCj0no.mjs';
5
5
  import 'ofetch';
6
6
 
7
7
  const _factory = /* @__PURE__ */ createPresetIcons(async (options) => {
@@ -1,5 +1,5 @@
1
1
  import { $fetch } from 'ofetch';
2
- import { b as createCDNFetchLoader } from './preset-icons.BORBFY-D.mjs';
2
+ import { b as createCDNFetchLoader } from './preset-icons.DvZCj0no.mjs';
3
3
 
4
4
  function createCDNLoader(cdnBase) {
5
5
  return createCDNFetchLoader($fetch, cdnBase);
@@ -748,6 +748,7 @@ function createPresetIcons(lookupIconLoader) {
748
748
  mode = "auto",
749
749
  prefix = "i-",
750
750
  warn = false,
751
+ iconifyCollectionsNames,
751
752
  collections: customCollections,
752
753
  extraProperties = {},
753
754
  customizations = {},
@@ -797,7 +798,12 @@ function createPresetIcons(lookupIconLoader) {
797
798
  let [full, body, _mode = mode] = matcher;
798
799
  iconLoader = iconLoader || await lookupIconLoader(options);
799
800
  const usedProps = {};
800
- const parsed = await parseIconWithLoader(body, iconLoader, { ...loaderOptions, usedProps });
801
+ const parsed = await parseIconWithLoader(
802
+ body,
803
+ iconLoader,
804
+ { ...loaderOptions, usedProps },
805
+ iconifyCollectionsNames
806
+ );
801
807
  if (!parsed) {
802
808
  if (warn && !flags.isESLint)
803
809
  warnOnce(`failed to load icon "${full}"`);
@@ -885,24 +891,25 @@ function getEnvFlags() {
885
891
  isESLint
886
892
  };
887
893
  }
888
- async function parseIconWithLoader(body, loader, options = {}) {
894
+ async function parseIconWithLoader(body, loader, options = {}, safeCollectionsNames = []) {
889
895
  let collection = "";
890
896
  let name = "";
891
897
  let svg;
892
- const allCollections = [
898
+ const allCollections = /* @__PURE__ */ new Set([
893
899
  ...icons,
900
+ ...safeCollectionsNames,
894
901
  ...Object.keys(options.customCollections || {})
895
- ];
902
+ ]);
896
903
  if (body.includes(":")) {
897
904
  [collection, name] = body.split(":");
898
- if (!allCollections.includes(collection))
905
+ if (!allCollections.has(collection))
899
906
  return;
900
907
  svg = await loader(collection, name, options);
901
908
  } else {
902
909
  const parts = body.split(/-/g);
903
910
  for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
904
911
  collection = parts.slice(0, i).join("-");
905
- if (!allCollections.includes(collection))
912
+ if (!allCollections.has(collection))
906
913
  continue;
907
914
  name = parts.slice(i).join("-");
908
915
  svg = await loader(collection, name, options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
3
  "type": "module",
4
- "version": "0.65.1",
4
+ "version": "0.65.2",
5
5
  "description": "Pure CSS Icons for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -53,15 +53,16 @@
53
53
  "dist"
54
54
  ],
55
55
  "dependencies": {
56
- "@iconify/utils": "^2.1.33",
56
+ "@iconify/utils": "^2.2.1",
57
57
  "ofetch": "^1.4.1",
58
- "@unocss/core": "0.65.1"
58
+ "@unocss/core": "0.65.2"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@iconify/types": "^2.0.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "unbuild",
65
- "stub": "unbuild --stub"
65
+ "stub": "unbuild --stub",
66
+ "test:attw": "attw --pack --config-path ../../.attw-esm-only.json"
66
67
  }
67
68
  }