vite-plugin-material-symbols 0.3.0 → 0.4.0-beta.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Version 0
4
4
 
5
+ ### v0.4.0
6
+
7
+ - New option: `preload`, boolean:
8
+ - Enables higher priority to loading symbols;
9
+ - Disabled by default;
10
+ - More information: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload
11
+
5
12
  ### v0.3.0
6
13
 
7
14
  - Fixed the leading slash problem in `dev` mode (serve mode);
package/README.md CHANGED
@@ -107,4 +107,8 @@ getUrl:
107
107
  exampleArguments: ["icon_names=chevron_right,comment,home"] # can be empty string
108
108
  returns: string # the URL
109
109
  default: (iconNamesParam) => `https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${iconNamesParam}`
110
+ preload:
111
+ type: boolean
112
+ description: Enables higher priority to loading symbols
113
+ default: false
110
114
  ```
package/dist/index.d.ts CHANGED
@@ -12,7 +12,13 @@ type PluginOptions = {
12
12
  * @default Icon
13
13
  * */
14
14
  component: string;
15
+ /**
16
+ * Enables higher priority to loading symbols
17
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload
18
+ * @default false
19
+ */
20
+ preload: boolean;
15
21
  };
16
- declare const plugin: ({ component, getUrl, }?: Partial<PluginOptions>) => Plugin;
22
+ declare const plugin: ({ component, getUrl, preload, }?: Partial<PluginOptions>) => Plugin;
17
23
 
18
24
  export { plugin as default };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import esquery from "esquery";const isStringLiteral=(h)=>h.type==="Literal"&&"value"in h&&typeof h.value==="string",defaultUrlProvider=(h)=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${h}`,makeSelector=(h)=>[`CallExpression[callee.name='jsx'][arguments.0.name='${h}']`,".arguments","Property[key.name='children'] Literal"].join(" > "),makeIconNamesParam=(h)=>{if(!h.size)return "";const i=[];for(const j of h.values())i.push(j);return `icon_names=${i.toSorted().join(",")}`},plugin=({component:h="Icon",getUrl:i=defaultUrlProvider}={})=>{const j=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:k,ast:l}){if(!l)return;const m=esquery.query(l,makeSelector(h)).filter(isStringLiteral);for(const {value:n}of m)this.debug({id:k,message:n}),j.add(n)},transformIndexHtml:(k)=>({html:k,tags:[{injectTo:"head",tag:"link",attrs:{rel:"stylesheet",href:i(makeIconNamesParam(j))}}]})}};var src_default=plugin;export {src_default as default};
1
+ import esquery from "esquery";const isStringLiteral=(h)=>h.type==="Literal"&&"value"in h&&typeof h.value==="string",defaultUrlProvider=(h)=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${h}`,makeSelector=(h)=>[`CallExpression[callee.name='jsx'][arguments.0.name='${h}']`,".arguments","Property[key.name='children'] Literal"].join(" > "),makeIconNamesParam=(h)=>{if(!h.size)return "";const i=[];for(const j of h.values())i.push(j);return `icon_names=${i.toSorted().join(",")}`},plugin=({component:h="Icon",getUrl:i=defaultUrlProvider,preload:j=!1}={})=>{const k=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:l,ast:m}){if(!m)return;const n=esquery.query(m,makeSelector(h)).filter(isStringLiteral);for(const {value:o}of n)this.debug({id:l,message:o}),k.add(o)},transformIndexHtml:(l)=>{const m=i(makeIconNamesParam(k)),n=[{injectTo:"head",tag:"link",attrs:{rel:"stylesheet",href:m}}];if(j)n.push({injectTo:"head-prepend",tag:"link",attrs:{rel:"preload",as:"style",href:m}});return {html:l,tags:n}}}};var src_default=plugin;export {src_default as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-material-symbols",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-beta.2",
4
4
  "description": "Selective loading of Material Symbols for production",
5
5
  "main": "dist/index.js",
6
6
  "repository": {