diff --git a/e2e/browserslist/package-json/package.json b/e2e/browserslist/package-json/package.json index e32ff630e..7c5ff7d87 100644 --- a/e2e/browserslist/package-json/package.json +++ b/e2e/browserslist/package-json/package.json @@ -7,7 +7,7 @@ "test": "BROWSERSLIST_ENV=development node ./index.mjs && BROWSERSLIST_ENV=production node ./index.mjs && BROWSERSLIST_ENV=legacy-edge node ./index.mjs && node ./use-plugin-option.mjs" }, "devDependencies": { - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env" }, "browserslist": { diff --git a/e2e/package-lock.json b/e2e/package-lock.json index 7b729237d..b1cc9d29f 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -16,7 +16,7 @@ ] }, "../plugin-packs/postcss-preset-env": { - "version": "9.1.0", + "version": "9.1.1", "funding": [ { "type": "github", @@ -41,8 +41,8 @@ "@csstools/postcss-logical-float-and-clear": "^2.0.0", "@csstools/postcss-logical-resize": "^2.0.0", "@csstools/postcss-logical-viewport-units": "^2.0.1", - "@csstools/postcss-media-minmax": "^1.0.6", - "@csstools/postcss-media-queries-aspect-ratio-number-values": "^2.0.1", + "@csstools/postcss-media-minmax": "^1.0.7", + "@csstools/postcss-media-queries-aspect-ratio-number-values": "^2.0.2", "@csstools/postcss-nested-calc": "^3.0.0", "@csstools/postcss-normalize-display-values": "^3.0.0", "@csstools/postcss-oklab-function": "^3.0.1", @@ -53,12 +53,12 @@ "@csstools/postcss-text-decoration-shorthand": "^3.0.0", "@csstools/postcss-trigonometric-functions": "^3.0.1", "@csstools/postcss-unset-value": "^3.0.0", - "autoprefixer": "^10.4.14", - "browserslist": "^4.21.9", + "autoprefixer": "^10.4.15", + "browserslist": "^4.21.10", "css-blank-pseudo": "^6.0.0", "css-has-pseudo": "^6.0.0", "css-prefers-color-scheme": "^9.0.0", - "cssdb": "^7.7.0", + "cssdb": "^7.7.1", "postcss-attribute-case-insensitive": "^6.0.2", "postcss-clamp": "^4.1.0", "postcss-color-functional-notation": "^6.0.0", @@ -77,7 +77,7 @@ "postcss-initial": "^4.0.1", "postcss-lab-function": "^6.0.1", "postcss-logical": "^7.0.0", - "postcss-nesting": "^12.0.0", + "postcss-nesting": "^12.0.1", "postcss-opacity-percentage": "^2.0.0", "postcss-overflow-shorthand": "^5.0.0", "postcss-page-break": "^3.0.4", @@ -118,7 +118,7 @@ "@csstools/cascade-layer-name-parser": "^1.0.4", "@csstools/css-parser-algorithms": "^2.3.1", "@csstools/css-tokenizer": "^2.2.0", - "@csstools/media-query-list-parser": "^2.1.3" + "@csstools/media-query-list-parser": "^2.1.4" }, "devDependencies": { "@csstools/postcss-tape": "*" @@ -179,7 +179,7 @@ "license": "MIT-0", "devDependencies": { "@csstools/postcss-tape": "*", - "open-props": "^1.5.10", + "open-props": "^1.5.13", "postcss-custom-media": "^10.0.0", "postcss-custom-properties": "^13.3.0" }, @@ -223,7 +223,7 @@ "name": "@csstools/e2e--browserslist--package-json", "version": "0.0.0", "devDependencies": { - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env" } }, @@ -1774,9 +1774,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.28.tgz", + "integrity": "sha512-Z7V5j0cq8oEKyejIKfpD8b4eBy9cwW2JWPk0+fB1HOAMsfHbnAXLLS+PfVWlzMSLQaWttKDt607I0XHmpE67Vw==", "funding": [ { "type": "opencollective", @@ -2762,7 +2762,7 @@ "name": "@csstools/e2e--webpack--bundle-through", "version": "0.0.0", "dependencies": { - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env", "webpack": "^5.88.2", "webpack-cli": "^5.1.3" @@ -2773,7 +2773,7 @@ "version": "0.0.0", "dependencies": { "css-loader": "^6.7.1", - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-loader": "^7.2.4", "postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env", "style-loader": "^3.3.1", diff --git a/e2e/webpack/bundle-through/package.json b/e2e/webpack/bundle-through/package.json index 725f0d146..96aa5df54 100644 --- a/e2e/webpack/bundle-through/package.json +++ b/e2e/webpack/bundle-through/package.json @@ -9,7 +9,7 @@ "test": "node ./dist/bundle-from-mjs.cjs && node ./dist/bundle-from-cjs.cjs " }, "dependencies": { - "postcss": "^8.4.27", + "postcss": "^8.4.28", "webpack": "^5.88.2", "webpack-cli": "^5.1.3", "postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env" diff --git a/e2e/webpack/postcss-loader/package.json b/e2e/webpack/postcss-loader/package.json index 31105b2c2..6063c12f6 100644 --- a/e2e/webpack/postcss-loader/package.json +++ b/e2e/webpack/postcss-loader/package.json @@ -8,7 +8,7 @@ "build": "webpack --config webpack.config.js" }, "dependencies": { - "postcss": "^8.4.27", + "postcss": "^8.4.28", "webpack": "^5.88.2", "webpack-cli": "^5.1.3", "postcss-loader": "^7.2.4", diff --git a/plugins/postcss-design-tokens/.tape.mjs b/plugins/postcss-design-tokens/.tape.mjs index 1399bd258..5413295c2 100644 --- a/plugins/postcss-design-tokens/.tape.mjs +++ b/plugins/postcss-design-tokens/.tape.mjs @@ -94,6 +94,9 @@ postcssTape(plugin)({ message: "supports value parsing (G)", warnings: 2 }, + 'imported-double-slash': { + message: "supports 'node_modules://'", + }, 'examples/example': { message: 'minimal example', options: {}, diff --git a/plugins/postcss-design-tokens/CHANGELOG.md b/plugins/postcss-design-tokens/CHANGELOG.md index afeef0ad0..09248eaf6 100644 --- a/plugins/postcss-design-tokens/CHANGELOG.md +++ b/plugins/postcss-design-tokens/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Design Tokens +### Unreleased (minor) + +- Add support for the shorter `node_modules:package` syntax +- Fix node module resolution + ### 3.0.1 _July 24, 2023_ diff --git a/plugins/postcss-design-tokens/README.md b/plugins/postcss-design-tokens/README.md index 26da139ef..7aa23080e 100644 --- a/plugins/postcss-design-tokens/README.md +++ b/plugins/postcss-design-tokens/README.md @@ -321,8 +321,8 @@ The `@design-tokens` rule is used to import design tokens from a JSON file into You can also import tokens from an `npm` package: ```pcss -@design-tokens url('node_modules://my-npm-package/tokens.json') format('style-dictionary3'); -@design-tokens url('node_modules://my-npm-package/tokens-dark-mode.json') format('style-dictionary3') when('dark'); +@design-tokens url('node_modules:my-npm-package/tokens.json') format('style-dictionary3'); +@design-tokens url('node_modules:my-npm-package/tokens-dark-mode.json') format('style-dictionary3') when('dark'); ``` ``` diff --git a/plugins/postcss-design-tokens/dist/index.cjs b/plugins/postcss-design-tokens/dist/index.cjs index ea0f1bfdb..3f24fc93d 100644 --- a/plugins/postcss-design-tokens/dist/index.cjs +++ b/plugins/postcss-design-tokens/dist/index.cjs @@ -1 +1 @@ -"use strict";var e=require("postcss-value-parser"),t=require("path"),n=require("fs"),r=require("module"),o=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer");function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach((function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")}));s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch(e){t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;let u=a.get(e)||new Set;if(u=Array.from(u),t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const a=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(a.has(n.toUnit)){if(a.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return a.set(n.toUnit,!0),`${t}${n.toUnit}`;a.set(n.toUnit,!1)}catch(e){a.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}var o,s;return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),(null==(o=n.pluginOptions)?void 0:o.rootFontSize)??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),(null==(s=n.pluginOptions)?void 0:s.rootFontSize)??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type)))continue;const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type)))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=Object(e[o]);if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(void 0!==s.value){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){if("3"===e)return extractStyleDictionaryV3Tokens(t,n);throw new Error("Unsupported version: "+e)}const i="6b4e71e7-4787-42f7-a092-8684961895db",u=r.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs",document.baseURI).href);function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[i]};return n.walk((e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter((e=>"string"===e.type)).map((e=>e.value)))})),r.conditions.length||(r.conditions=[i]),r}async function tokensFromImport(e,r,o,s,a,i){var l;const{filePath:c,format:f,conditions:p}=parseImport(a);if(!p.every((e=>o.includes(e))))return!1;let d="";if(c.startsWith("node_modules://"))try{d=u.resolve(c.slice(15),{paths:[t.dirname(s)]})}catch(e){throw new Error(`Failed to read ${c} with error ${e.message}`)}else d=t.resolve(t.dirname(s),c);if(i.has(d))return!1;r.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:d,parent:null==(l=e.source)||null==(l=l.input)?void 0:l.file}),i.add(d);const m=await n.promises.readFile(d,"utf8"),w=JSON.parse(m);if("style-dictionary3"===f)return{filePath:t.resolve(c),tokens:extractStyleDictionaryTokens("3",w,d)};throw new Error("Unsupported format: "+f)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[i],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter((e=>"string"==typeof e))),0===t.is.length&&(t.is=[i]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValuesFromTokens(e){return o.parseListOfComponentValues(e,{onParseError:e=>{throw e}})}function parseComponentValues(e){const t=s.tokenizer({css:e},{onParseError:e=>{throw e}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n.push(t.nextToken()),parseComponentValuesFromTokens(n)}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach(((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk(((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0}))}})),a?s.map((e=>e.toString())).join(""):r}function transformComponentValue(e,t,n,r,a){if(!o.isFunctionNode(e))return;if(e.getName().toLowerCase()!==a.valueFunctionName)return;let i="",u="",l="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{OnceExit(){e=new Map,n=new Set},Once:async(r,o)=>{const s=[];r.walkAtRules((e=>{var n;if(e.name.toLowerCase()!==t.importAtRuleName)return;if(null==e||null==(n=e.source)||null==(n=n.input)||!n.file)return;const r=e.source.input.file,o=e.params;e.remove(),s.push({filePath:r,params:o,node:e})}));for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+e.message);continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch(e){n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch(e){n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0,module.exports=creator; +"use strict";var e=require("postcss-value-parser"),t=require("path"),n=require("fs"),r=require("module"),o=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer");function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach((function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")}));s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch(e){t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;let u=a.get(e)||new Set;if(u=Array.from(u),t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const a=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(a.has(n.toUnit)){if(a.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return a.set(n.toUnit,!0),`${t}${n.toUnit}`;a.set(n.toUnit,!1)}catch(e){a.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}var o,s;return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),(null==(o=n.pluginOptions)?void 0:o.rootFontSize)??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),(null==(s=n.pluginOptions)?void 0:s.rootFontSize)??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type)))continue;const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type)))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=Object(e[o]);if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(void 0!==s.value){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){if("3"===e)return extractStyleDictionaryV3Tokens(t,n);throw new Error("Unsupported version: "+e)}const i="6b4e71e7-4787-42f7-a092-8684961895db";function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[i]};return n.walk((e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter((e=>"string"===e.type)).map((e=>e.value)))})),r.conditions.length||(r.conditions=[i]),r}async function tokensFromImport(e,o,s,a,i,u){var l;const{filePath:c,format:f,conditions:p}=parseImport(i);if(!p.every((e=>s.includes(e))))return!1;let d="";try{if(c.startsWith("node_modules://")){d=r.createRequire(t.dirname(a)).resolve(c.slice(15))}else if(c.startsWith("node_modules:")){d=r.createRequire(t.dirname(a)).resolve(c.slice(13))}else d=t.resolve(t.dirname(a),c)}catch(e){throw new Error(`Failed to read ${c} with error ${e.message}`)}if(u.has(d))return!1;o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:d,parent:null==(l=e.source)||null==(l=l.input)?void 0:l.file}),u.add(d);const m=await n.promises.readFile(d,"utf8"),w=JSON.parse(m);if("style-dictionary3"===f)return{filePath:t.resolve(c),tokens:extractStyleDictionaryTokens("3",w,d)};throw new Error("Unsupported format: "+f)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[i],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter((e=>"string"==typeof e))),0===t.is.length&&(t.is=[i]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValuesFromTokens(e){return o.parseListOfComponentValues(e,{onParseError:e=>{throw e}})}function parseComponentValues(e){const t=s.tokenizer({css:e},{onParseError:e=>{throw e}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n.push(t.nextToken()),parseComponentValuesFromTokens(n)}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach(((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk(((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0}))}})),a?s.map((e=>e.toString())).join(""):r}function transformComponentValue(e,t,n,r,a){if(!o.isFunctionNode(e))return;if(e.getName().toLowerCase()!==a.valueFunctionName)return;let i="",u="",l="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{OnceExit(){e=new Map,n=new Set},Once:async(r,o)=>{const s=[];r.walkAtRules((e=>{var n;if(e.name.toLowerCase()!==t.importAtRuleName)return;if(null==e||null==(n=e.source)||null==(n=n.input)||!n.file)return;const r=e.source.input.file,o=e.params;e.remove(),s.push({filePath:r,params:o,node:e})}));for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+e.message);continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch(e){n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch(e){n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-design-tokens/dist/index.mjs b/plugins/postcss-design-tokens/dist/index.mjs index 1bceb294e..80d86415d 100644 --- a/plugins/postcss-design-tokens/dist/index.mjs +++ b/plugins/postcss-design-tokens/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import t from"path";import{promises as n}from"fs";import r from"module";import{parseListOfComponentValues as o,isFunctionNode as a,isWhitespaceNode as s,isCommentNode as i,isTokenNode as u}from"@csstools/css-parser-algorithms";import{tokenizer as l,TokenType as c}from"@csstools/css-tokenizer";function toposort(e,t){let n=e.length;const r=new Array(n),o={};let a=n;const s=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach((function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")}));a--;)o[a]||visit(e[a],a,new Set);return r;function visit(e,t,a){if(a.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch(e){t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;let u=s.get(e)||new Set;if(u=Array.from(u),t=u.length){a.add(e);do{const e=u[--t];visit(e,i.get(e),a)}while(t);a.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const f=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(f.has(n.toUnit)){if(f.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return f.set(n.toUnit,!0),`${t}${n.toUnit}`;f.set(n.toUnit,!1)}catch(e){f.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}var o,a;return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),(null==(o=n.pluginOptions)?void 0:o.rootFontSize)??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),(null==(a=n.pluginOptions)?void 0:a.rootFontSize)??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type)))continue;const a=o.map((e=>e.value)).join(""),s=e.get(r);s.value=a,s.cssValue=e=>applyTransformsToValue(a,e),e.set(r,s),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type)))throw new Error('Token "'+r+'" can not be fully resolved');const a=o.map((e=>e.value)).join(""),s=e.get(r);s.value=a,s.cssValue=e=>applyTransformsToValue(a,e),e.set(r,s),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let a=0;a0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+a);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+a);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=s}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const a=Object(e[o]);if(!a)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(void 0!==a.value){const e=extractStyleDictionaryV3Token(a,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,s]of extractTokens(a,[...t,o],n).entries())r.set(e,s)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){if("3"===e)return extractStyleDictionaryV3Tokens(t,n);throw new Error("Unsupported version: "+e)}const p="6b4e71e7-4787-42f7-a092-8684961895db",m=r.createRequire(import.meta.url);function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[p]};return n.walk((e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter((e=>"string"===e.type)).map((e=>e.value)))})),r.conditions.length||(r.conditions=[p]),r}async function tokensFromImport(e,r,o,a,s,i){var u;const{filePath:l,format:c,conditions:f}=parseImport(s);if(!f.every((e=>o.includes(e))))return!1;let p="";if(l.startsWith("node_modules://"))try{p=m.resolve(l.slice(15),{paths:[t.dirname(a)]})}catch(e){throw new Error(`Failed to read ${l} with error ${e.message}`)}else p=t.resolve(t.dirname(a),l);if(i.has(p))return!1;r.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:p,parent:null==(u=e.source)||null==(u=u.input)?void 0:u.file}),i.add(p);const d=await n.readFile(p,"utf8"),w=JSON.parse(d);if("style-dictionary3"===c)return{filePath:t.resolve(l),tokens:extractStyleDictionaryTokens("3",w,p)};throw new Error("Unsupported format: "+c)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[p],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter((e=>"string"==typeof e))),0===t.is.length&&(t.is=[p]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValuesFromTokens(e){return o(e,{onParseError:e=>{throw e}})}function parseComponentValues(e){const t=l({css:e},{onParseError:e=>{throw e}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n.push(t.nextToken()),parseComponentValuesFromTokens(n)}function transform(e,t,n,r,o){const a=parseComponentValues(r);let s=!1;return a.forEach(((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return a.splice(i,1,...u),s=!0,!1}r.walk(((r,a)=>{if("string"==typeof a)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(a,1,...i),s=!0,!1):void 0}))}})),s?a.map((e=>e.toString())).join(""):r}function transformComponentValue(e,t,n,r,o){if(!a(e))return;if(e.getName().toLowerCase()!==o.valueFunctionName)return;let l="",f="",p="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{OnceExit(){e=new Map,n=new Set},Once:async(r,o)=>{const a=[];r.walkAtRules((e=>{var n;if(e.name.toLowerCase()!==t.importAtRuleName)return;if(null==e||null==(n=e.source)||null==(n=n.input)||!n.file)return;const r=e.source.input.file,o=e.params;e.remove(),a.push({filePath:r,params:o,node:e})}));for(const s of a.values()){let a;try{if(a=await tokensFromImport(r,o,t.is,s.filePath,s.params,n),!a)continue}catch(e){s.node.warn(o.result,`Failed to import design tokens from "${s.params}" with error:\n\t`+e.message);continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:a.filePath,parent:s.filePath}),e=mergeTokens(e,a.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch(e){n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch(e){n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import t from"path";import{promises as n}from"fs";import r from"module";import{parseListOfComponentValues as o,isFunctionNode as s,isWhitespaceNode as a,isCommentNode as i,isTokenNode as u}from"@csstools/css-parser-algorithms";import{tokenizer as l,TokenType as c}from"@csstools/css-tokenizer";function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach((function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")}));s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch(e){t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;let u=a.get(e)||new Set;if(u=Array.from(u),t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const f=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(f.has(n.toUnit)){if(f.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return f.set(n.toUnit,!0),`${t}${n.toUnit}`;f.set(n.toUnit,!1)}catch(e){f.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}var o,s;return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),(null==(o=n.pluginOptions)?void 0:o.rootFontSize)??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),(null==(s=n.pluginOptions)?void 0:s.rootFontSize)??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type)))continue;const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type)))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map((e=>e.value)).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=Object(e[o]);if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(void 0!==s.value){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){if("3"===e)return extractStyleDictionaryV3Tokens(t,n);throw new Error("Unsupported version: "+e)}const p="6b4e71e7-4787-42f7-a092-8684961895db";function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[p]};return n.walk((e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter((e=>"string"===e.type)).map((e=>e.value)))})),r.conditions.length||(r.conditions=[p]),r}async function tokensFromImport(e,o,s,a,i,u){var l;const{filePath:c,format:f,conditions:p}=parseImport(i);if(!p.every((e=>s.includes(e))))return!1;let m="";try{if(c.startsWith("node_modules://")){m=r.createRequire(t.dirname(a)).resolve(c.slice(15))}else if(c.startsWith("node_modules:")){m=r.createRequire(t.dirname(a)).resolve(c.slice(13))}else m=t.resolve(t.dirname(a),c)}catch(e){throw new Error(`Failed to read ${c} with error ${e.message}`)}if(u.has(m))return!1;o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:m,parent:null==(l=e.source)||null==(l=l.input)?void 0:l.file}),u.add(m);const d=await n.readFile(m,"utf8"),w=JSON.parse(d);if("style-dictionary3"===f)return{filePath:t.resolve(c),tokens:extractStyleDictionaryTokens("3",w,m)};throw new Error("Unsupported format: "+f)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[p],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter((e=>"string"==typeof e))),0===t.is.length&&(t.is=[p]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValuesFromTokens(e){return o(e,{onParseError:e=>{throw e}})}function parseComponentValues(e){const t=l({css:e},{onParseError:e=>{throw e}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n.push(t.nextToken()),parseComponentValuesFromTokens(n)}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach(((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk(((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0}))}})),a?s.map((e=>e.toString())).join(""):r}function transformComponentValue(e,t,n,r,o){if(!s(e))return;if(e.getName().toLowerCase()!==o.valueFunctionName)return;let l="",f="",p="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{OnceExit(){e=new Map,n=new Set},Once:async(r,o)=>{const s=[];r.walkAtRules((e=>{var n;if(e.name.toLowerCase()!==t.importAtRuleName)return;if(null==e||null==(n=e.source)||null==(n=n.input)||!n.file)return;const r=e.source.input.file,o=e.params;e.remove(),s.push({filePath:r,params:o,node:e})}));for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+e.message);continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch(e){n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch(e){n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0;export{creator as default}; diff --git a/plugins/postcss-design-tokens/docs/README.md b/plugins/postcss-design-tokens/docs/README.md index 0b57f010b..192713f84 100644 --- a/plugins/postcss-design-tokens/docs/README.md +++ b/plugins/postcss-design-tokens/docs/README.md @@ -190,8 +190,8 @@ The `@design-tokens` rule is used to import design tokens from a JSON file into You can also import tokens from an `npm` package: ```pcss -@design-tokens url('node_modules://my-npm-package/tokens.json') format('style-dictionary3'); -@design-tokens url('node_modules://my-npm-package/tokens-dark-mode.json') format('style-dictionary3') when('dark'); +@design-tokens url('node_modules:my-npm-package/tokens.json') format('style-dictionary3'); +@design-tokens url('node_modules:my-npm-package/tokens-dark-mode.json') format('style-dictionary3') when('dark'); ``` ``` diff --git a/plugins/postcss-design-tokens/src/data-formats/parse-import.ts b/plugins/postcss-design-tokens/src/data-formats/parse-import.ts index 2476d0cd5..895c33699 100644 --- a/plugins/postcss-design-tokens/src/data-formats/parse-import.ts +++ b/plugins/postcss-design-tokens/src/data-formats/parse-import.ts @@ -7,8 +7,6 @@ import { DEFAULT_CONDITION } from '../constants'; import module from 'module'; import type { Helpers, Root } from 'postcss'; -const require = module.createRequire(import.meta.url); - function parseImport(statement: string): { filePath: string, format: string, conditions: Array } { const importAST = valueParser(statement); @@ -48,18 +46,21 @@ export async function tokensFromImport(root: Root, postcssHelpers: Helpers, buil } let resolvedPath = ''; - if (filePath.startsWith('node_modules://')) { - try { - resolvedPath = require.resolve(filePath.slice(15), { - paths: [ - path.dirname(sourceFilePath), - ], - }); - } catch (e) { - throw new Error(`Failed to read ${filePath} with error ${(e as Error).message}`); + + try { + if (filePath.startsWith('node_modules://')) { + const require = module.createRequire(path.dirname(sourceFilePath)); + + resolvedPath = require.resolve(filePath.slice(15)); + } else if (filePath.startsWith('node_modules:')) { + const require = module.createRequire(path.dirname(sourceFilePath)); + + resolvedPath = require.resolve(filePath.slice(13)); + } else { + resolvedPath = path.resolve(path.dirname(sourceFilePath), filePath); } - } else { - resolvedPath = path.resolve(path.dirname(sourceFilePath), filePath); + } catch (e) { + throw new Error(`Failed to read ${filePath} with error ${(e as Error).message}`); } if (alreadyImported.has(resolvedPath)) { diff --git a/plugins/postcss-design-tokens/test/imported-double-slash.css b/plugins/postcss-design-tokens/test/imported-double-slash.css new file mode 100644 index 000000000..053a4b3ab --- /dev/null +++ b/plugins/postcss-design-tokens/test/imported-double-slash.css @@ -0,0 +1,5 @@ +@design-tokens url(node_modules://style-dictionary-design-tokens-example/style-dictionary.tokens.json) format('style-dictionary3'); + +.foo { + color: design-token('color.font.base'); +} diff --git a/plugins/postcss-design-tokens/test/imported-double-slash.expect.css b/plugins/postcss-design-tokens/test/imported-double-slash.expect.css new file mode 100644 index 000000000..17ecc944d --- /dev/null +++ b/plugins/postcss-design-tokens/test/imported-double-slash.expect.css @@ -0,0 +1,3 @@ +.foo { + color: #111111; +} diff --git a/plugins/postcss-design-tokens/test/imported.css b/plugins/postcss-design-tokens/test/imported.css index db848c441..1171569cf 100644 --- a/plugins/postcss-design-tokens/test/imported.css +++ b/plugins/postcss-design-tokens/test/imported.css @@ -1 +1 @@ -@design-tokens url(node_modules://style-dictionary-design-tokens-example/style-dictionary.tokens.json) format('style-dictionary3'); +@design-tokens url(node_modules:style-dictionary-design-tokens-example/style-dictionary.tokens.json) format('style-dictionary3'); diff --git a/plugins/postcss-global-data/.tape.mjs b/plugins/postcss-global-data/.tape.mjs index 3f85063ff..87b0ac622 100644 --- a/plugins/postcss-global-data/.tape.mjs +++ b/plugins/postcss-global-data/.tape.mjs @@ -20,7 +20,7 @@ postcssTape(plugin)({ plugins: [ plugin({ files: [ - 'node_modules://open-props/media.min.css', + 'node_modules:open-props/media.min.css', 'node_modules://open-props/open-props.min.css', ] }), diff --git a/plugins/postcss-global-data/CHANGELOG.md b/plugins/postcss-global-data/CHANGELOG.md index 17138b517..0e6d1468f 100644 --- a/plugins/postcss-global-data/CHANGELOG.md +++ b/plugins/postcss-global-data/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS global-data +### Unreleased (minor) + +- Add support for the shorter `node_modules:package` syntax +- Fix node module resolution + ### 2.0.1 _July 24, 2023_ diff --git a/plugins/postcss-global-data/dist/index.cjs b/plugins/postcss-global-data/dist/index.cjs index 4d1b11fc2..7c4857262 100644 --- a/plugins/postcss-global-data/dist/index.cjs +++ b/plugins/postcss-global-data/dist/index.cjs @@ -1 +1 @@ -"use strict";var e=require("path"),r=require("fs");const t=require("module").createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs",document.baseURI).href);function parseImport(s,n,o,a){var c;let i="";if(o.startsWith("node_modules://"))try{i=t.resolve(o.slice(15),{paths:[e.dirname(o)]})}catch(e){throw new Error(`Failed to read ${o} with error ${e.message}`)}else i=e.resolve(o);if(a.has(i))return!1;a.add(i),n.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:i,parent:null==(c=s.source)||null==(c=c.input)?void 0:c.file});const u=r.readFileSync(i,"utf8");return n.postcss.parse(u,{from:i})}const creator=e=>{const r=Object.assign({files:[]},e);return{postcssPlugin:"postcss-global-data",prepare(){let e=new Set,t=new Set;return{Once:(s,n)=>{r.files.forEach((r=>{if(e.has(r))return;const o=parseImport(s,n,r,e);o&&o.each((e=>{s.append(e),t.add(e)}))}))},OnceExit:()=>{t.forEach((e=>{e.remove()})),t=new Set,e=new Set}}}}};creator.postcss=!0,module.exports=creator; +"use strict";var e=require("path"),s=require("fs"),r=require("module");function parseImport(t,o,a,n){var c;let l="";try{if(a.startsWith("node_modules://")){l=r.createRequire(process.cwd()).resolve(a.slice(15))}else if(a.startsWith("node_modules:")){l=r.createRequire(process.cwd()).resolve(a.slice(13))}else l=e.resolve(a)}catch(e){throw new Error(`Failed to read ${a} with error ${e.message}`)}if(n.has(l))return!1;n.add(l),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:l,parent:null==(c=t.source)||null==(c=c.input)?void 0:c.file});const i=s.readFileSync(l,"utf8");return o.postcss.parse(i,{from:l})}const creator=e=>{const s=Object.assign({files:[]},e);return{postcssPlugin:"postcss-global-data",prepare(){let e=new Set,r=new Set;return{Once:(t,o)=>{s.files.forEach((s=>{if(e.has(s))return;const a=parseImport(t,o,s,e);a&&a.each((e=>{t.append(e),r.add(e)}))}))},OnceExit:()=>{r.forEach((e=>{e.remove()})),r=new Set,e=new Set}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-global-data/dist/index.mjs b/plugins/postcss-global-data/dist/index.mjs index 8713486cb..b8c6c1af3 100644 --- a/plugins/postcss-global-data/dist/index.mjs +++ b/plugins/postcss-global-data/dist/index.mjs @@ -1 +1 @@ -import e from"path";import t from"fs";import r from"module";const s=r.createRequire(import.meta.url);function parseImport(r,o,a,n){var l;let p="";if(a.startsWith("node_modules://"))try{p=s.resolve(a.slice(15),{paths:[e.dirname(a)]})}catch(e){throw new Error(`Failed to read ${a} with error ${e.message}`)}else p=e.resolve(a);if(n.has(p))return!1;n.add(p),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:p,parent:null==(l=r.source)||null==(l=l.input)?void 0:l.file});const i=t.readFileSync(p,"utf8");return o.postcss.parse(i,{from:p})}const creator=e=>{const t=Object.assign({files:[]},e);return{postcssPlugin:"postcss-global-data",prepare(){let e=new Set,r=new Set;return{Once:(s,o)=>{t.files.forEach((t=>{if(e.has(t))return;const a=parseImport(s,o,t,e);a&&a.each((e=>{s.append(e),r.add(e)}))}))},OnceExit:()=>{r.forEach((e=>{e.remove()})),r=new Set,e=new Set}}}}};creator.postcss=!0;export{creator as default}; +import e from"path";import s from"fs";import r from"module";function parseImport(t,o,a,n){var l;let c="";try{if(a.startsWith("node_modules://")){c=r.createRequire(process.cwd()).resolve(a.slice(15))}else if(a.startsWith("node_modules:")){c=r.createRequire(process.cwd()).resolve(a.slice(13))}else c=e.resolve(a)}catch(e){throw new Error(`Failed to read ${a} with error ${e.message}`)}if(n.has(c))return!1;n.add(c),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:c,parent:null==(l=t.source)||null==(l=l.input)?void 0:l.file});const i=s.readFileSync(c,"utf8");return o.postcss.parse(i,{from:c})}const creator=e=>{const s=Object.assign({files:[]},e);return{postcssPlugin:"postcss-global-data",prepare(){let e=new Set,r=new Set;return{Once:(t,o)=>{s.files.forEach((s=>{if(e.has(s))return;const a=parseImport(t,o,s,e);a&&a.each((e=>{t.append(e),r.add(e)}))}))},OnceExit:()=>{r.forEach((e=>{e.remove()})),r=new Set,e=new Set}}}}};creator.postcss=!0;export{creator as default}; diff --git a/plugins/postcss-global-data/src/parse-import.ts b/plugins/postcss-global-data/src/parse-import.ts index f90dee5e3..7439e1f5f 100644 --- a/plugins/postcss-global-data/src/parse-import.ts +++ b/plugins/postcss-global-data/src/parse-import.ts @@ -3,23 +3,23 @@ import fs from 'fs'; import type { Helpers, Root } from 'postcss'; import module from 'module'; -const require = module.createRequire(import.meta.url); - export function parseImport(root: Root, postcssHelpers: Helpers, filePath: string, alreadyImported: Set) { let resolvedPath = ''; - if (filePath.startsWith('node_modules://')) { - try { - resolvedPath = require.resolve(filePath.slice(15), { - paths: [ - path.dirname(filePath), - ], - }); - } catch (e) { - throw new Error(`Failed to read ${filePath} with error ${(e as Error).message}`); + try { + if (filePath.startsWith('node_modules://')) { + const require = module.createRequire(process.cwd()); + + resolvedPath = require.resolve(filePath.slice(15)); + } else if (filePath.startsWith('node_modules:')) { + const require = module.createRequire(process.cwd()); + + resolvedPath = require.resolve(filePath.slice(13)); + } else { + resolvedPath = path.resolve(filePath); } - } else { - resolvedPath = path.resolve(filePath); + } catch (e) { + throw new Error(`Failed to read ${filePath} with error ${(e as Error).message}`); } if (alreadyImported.has(resolvedPath)) { diff --git a/plugins/postcss-minify/README.md b/plugins/postcss-minify/README.md index f226b24b2..b88300db8 100644 --- a/plugins/postcss-minify/README.md +++ b/plugins/postcss-minify/README.md @@ -8,7 +8,10 @@ It guarantees two things : - browsers can not tell the difference between the original and the minified CSS - lawyers can not tell the difference between the original and the minified CSS -It is not a CSS optimizer, it does not try to reduce the size of the CSS by altering the CSS itself. +Compared to other minifiers, [PostCSS Minify] is purely focused on correctness and fidelity. +[PostCSS Minify] only collapses whitespace and comments while preserving those comments that are important for legal compliance. + +[PostCSS Minify] is not a CSS optimizer, it does not try to reduce the size of the CSS file by altering the CSS itself. ```pcss /* diff --git a/plugins/postcss-minify/docs/README.md b/plugins/postcss-minify/docs/README.md index 8d8a384a9..63b383b11 100644 --- a/plugins/postcss-minify/docs/README.md +++ b/plugins/postcss-minify/docs/README.md @@ -22,7 +22,10 @@ It guarantees two things : - browsers can not tell the difference between the original and the minified CSS - lawyers can not tell the difference between the original and the minified CSS -It is not a CSS optimizer, it does not try to reduce the size of the CSS by altering the CSS itself. +Compared to other minifiers, [] is purely focused on correctness and fidelity. +[] only collapses whitespace and comments while preserving those comments that are important for legal compliance. + +[] is not a CSS optimizer, it does not try to reduce the size of the CSS file by altering the CSS itself. ```pcss diff --git a/plugins/postcss-minify/package.json b/plugins/postcss-minify/package.json index 47603bc7f..ecc9a2a67 100644 --- a/plugins/postcss-minify/package.json +++ b/plugins/postcss-minify/package.json @@ -1,6 +1,6 @@ { "name": "@csstools/postcss-minify", - "description": "TODO: Add description for Minify", + "description": "A very basic CSS minifier", "version": "0.0.0", "contributors": [ { diff --git a/sites/package-lock.json b/sites/package-lock.json index 8c5e43aad..10089f000 100644 --- a/sites/package-lock.json +++ b/sites/package-lock.json @@ -12,7 +12,7 @@ "postcss-preset-env" ], "devDependencies": { - "stylelint": "^15.10.2", + "stylelint": "^15.10.3", "stylelint-config-standard": "^34.0.0" }, "engines": { @@ -3501,9 +3501,9 @@ } }, "node_modules/@rollup/plugin-node-resolve": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", - "integrity": "sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.0.tgz", + "integrity": "sha512-mKur03xNGT8O9ODO6FtT43ITGqHWZbKPdVJHZb+iV9QYcdlhUUB0wgknvA4KCUmC5oHJF6O2W1EgmyOQyVUI4Q==", "dev": true, "dependencies": { "@rollup/pluginutils": "^5.0.1", @@ -5578,9 +5578,9 @@ } }, "node_modules/cssdb": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/cssdb/-/cssdb-7.7.0.tgz", - "integrity": "sha512-1hN+I3r4VqSNQ+OmMXxYexnumbOONkSil0TWMebVXHtzYW4tRRPovUNHPHj2d4nrgOuYJ8Vs3XwvywsuwwXNNA==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/cssdb/-/cssdb-7.7.1.tgz", + "integrity": "sha512-kM+Fs0BFyhJNeE6wbOrlnRsugRdL6vn7QcON0aBDZ7XRd7RI2pMlk+nxoHuTb4Et+aBobXgK0I+6NGLA0LLgTw==", "dev": true, "funding": [ { @@ -6531,9 +6531,9 @@ } }, "node_modules/eslint-plugin-import": { - "version": "2.28.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.0.tgz", - "integrity": "sha512-B8s/n+ZluN7sxj9eUf7/pRFERX0r5bnFA2dCaLHy2ZeaQEAz0k+ZZkFWRFHJAqxfxQDx6KLv9LeIki7cFdwW+Q==", + "version": "2.28.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.1.tgz", + "integrity": "sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==", "dev": true, "dependencies": { "array-includes": "^3.1.6", @@ -6545,13 +6545,12 @@ "eslint-import-resolver-node": "^0.3.7", "eslint-module-utils": "^2.8.0", "has": "^1.0.3", - "is-core-module": "^2.12.1", + "is-core-module": "^2.13.0", "is-glob": "^4.0.3", "minimatch": "^3.1.2", "object.fromentries": "^2.0.6", "object.groupby": "^1.0.0", "object.values": "^1.1.6", - "resolve": "^1.22.3", "semver": "^6.3.1", "tsconfig-paths": "^3.14.2" }, @@ -8188,9 +8187,9 @@ } }, "node_modules/is-core-module": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", - "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -8767,9 +8766,9 @@ } }, "node_modules/known-css-properties": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.27.0.tgz", - "integrity": "sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg==", + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.28.0.tgz", + "integrity": "sha512-9pSL5XB4J+ifHP0e0jmmC98OGC1nL8/JjS+fi6mnTlIf//yt/MfVLtKg7S6nCtj/8KTcWX7nRlY0XywoYY1ISQ==", "dev": true }, "node_modules/language-subtag-registry": { @@ -10529,9 +10528,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.28.tgz", + "integrity": "sha512-Z7V5j0cq8oEKyejIKfpD8b4eBy9cwW2JWPk0+fB1HOAMsfHbnAXLLS+PfVWlzMSLQaWttKDt607I0XHmpE67Vw==", "dev": true, "funding": [ { @@ -13638,14 +13637,14 @@ } }, "node_modules/stylelint": { - "version": "15.10.2", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-15.10.2.tgz", - "integrity": "sha512-UxqSb3hB74g4DTO45QhUHkJMjKKU//lNUAOWyvPBVPZbCknJ5HjOWWZo+UDuhHa9FLeVdHBZXxu43eXkjyIPWg==", + "version": "15.10.3", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-15.10.3.tgz", + "integrity": "sha512-aBQMMxYvFzJJwkmg+BUUg3YfPyeuCuKo2f+LOw7yYbU8AZMblibwzp9OV4srHVeQldxvSFdz0/Xu8blq2AesiA==", "dev": true, "dependencies": { - "@csstools/css-parser-algorithms": "^2.3.0", - "@csstools/css-tokenizer": "^2.1.1", - "@csstools/media-query-list-parser": "^2.1.2", + "@csstools/css-parser-algorithms": "^2.3.1", + "@csstools/css-tokenizer": "^2.2.0", + "@csstools/media-query-list-parser": "^2.1.4", "@csstools/selector-specificity": "^3.0.0", "balanced-match": "^2.0.0", "colord": "^2.9.3", @@ -13653,7 +13652,7 @@ "css-functions-list": "^3.2.0", "css-tree": "^2.3.1", "debug": "^4.3.4", - "fast-glob": "^3.3.0", + "fast-glob": "^3.3.1", "fastest-levenshtein": "^1.0.16", "file-entry-cache": "^6.0.1", "global-modules": "^2.0.0", @@ -13664,13 +13663,13 @@ "import-lazy": "^4.0.0", "imurmurhash": "^0.1.4", "is-plain-object": "^5.0.0", - "known-css-properties": "^0.27.0", + "known-css-properties": "^0.28.0", "mathml-tag-names": "^2.1.3", "meow": "^10.1.5", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", "picocolors": "^1.0.0", - "postcss": "^8.4.25", + "postcss": "^8.4.27", "postcss-resolve-nested-selector": "^0.1.1", "postcss-safe-parser": "^6.0.0", "postcss-selector-parser": "^6.0.13", @@ -13997,9 +13996,9 @@ } }, "node_modules/tslib": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", - "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", "dev": true }, "node_modules/tuf-js": { @@ -14686,21 +14685,21 @@ "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-node-resolve": "^15.2.0", "@rollup/plugin-terser": "^0.4.0", "babel-eslint": "^10.1.0", "browser-sync": "^2.29.1", "codemirror": "^6.0.1", - "cssdb": "^7.5.1", + "cssdb": "^7.7.1", "cssnano": "^6.0.0", "eslint": "^8.47.0", "eslint-config-airbnb": "^19.0.4", - "eslint-plugin-import": "^2.28.0", + "eslint-plugin-import": "^2.28.1", "hasha": "^5.2.2", "luxon": "^3.4.0", "markdown-it": "^13.0.1", "npm-run-all": "^4.1.5", - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-cli": "^10.1.0", "postcss-import": "^15.1.0", "postcss-preset-env": "^9.1.1", @@ -14708,7 +14707,7 @@ "rollup-plugin-filesize": "^10.0.0", "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-polyfill-node": "^0.12.0", - "tslib": "^2.6.1", + "tslib": "^2.6.2", "typescript": "^5.1.6" }, "engines": { diff --git a/sites/package.json b/sites/package.json index a49ffda7e..6280931e1 100644 --- a/sites/package.json +++ b/sites/package.json @@ -22,7 +22,7 @@ "postcss-preset-env" ], "devDependencies": { - "stylelint": "^15.10.2", + "stylelint": "^15.10.3", "stylelint-config-standard": "^34.0.0" }, "scripts": { diff --git a/sites/postcss-preset-env/package.json b/sites/postcss-preset-env/package.json index 5906aff1f..c335a0f2a 100644 --- a/sites/postcss-preset-env/package.json +++ b/sites/postcss-preset-env/package.json @@ -87,21 +87,21 @@ "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-node-resolve": "^15.2.0", "@rollup/plugin-terser": "^0.4.0", "babel-eslint": "^10.1.0", "browser-sync": "^2.29.1", "codemirror": "^6.0.1", - "cssdb": "^7.5.1", + "cssdb": "^7.7.1", "cssnano": "^6.0.0", "eslint": "^8.47.0", "eslint-config-airbnb": "^19.0.4", - "eslint-plugin-import": "^2.28.0", + "eslint-plugin-import": "^2.28.1", "hasha": "^5.2.2", "luxon": "^3.4.0", "markdown-it": "^13.0.1", "npm-run-all": "^4.1.5", - "postcss": "^8.4.27", + "postcss": "^8.4.28", "postcss-cli": "^10.1.0", "postcss-import": "^15.1.0", "postcss-preset-env": "^9.1.1", @@ -109,7 +109,7 @@ "rollup-plugin-filesize": "^10.0.0", "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-polyfill-node": "^0.12.0", - "tslib": "^2.6.1", + "tslib": "^2.6.2", "typescript": "^5.1.6" }, "volta": {