@pandacss/core
Advanced tools
Comparing version 0.0.0-dev-20221218075945 to 0.0.0-dev-20221218093122
@@ -235,3 +235,2 @@ import { RawCondition, Dict, UtilityConfig, PropertyConfig, PatternHelpers, CssKeyframes, RecipeConfig } from '@pandacss/types'; | ||
} | undefined); | ||
addGlobalCss: (styleObject: Dict) => void; | ||
processGlobalCss: (styleObject: Dict) => void; | ||
@@ -238,0 +237,0 @@ processSelectorObject(selector: string, styleObject: Dict): void; |
@@ -589,3 +589,3 @@ "use strict"; | ||
// src/optimize.ts | ||
var import_postcss7 = __toESM(require("postcss")); | ||
var import_postcss6 = __toESM(require("postcss")); | ||
var import_postcss_discard_duplicates = __toESM(require("postcss-discard-duplicates")); | ||
@@ -613,50 +613,21 @@ var import_postcss_nested2 = __toESM(require("postcss-nested")); | ||
// src/plugins/sort-mq.ts | ||
var import_postcss6 = require("postcss"); | ||
var import_sort_css_media_queries = __toESM(require("sort-css-media-queries")); | ||
function sortMediaQueries() { | ||
const inner = (root) => { | ||
const rules = { | ||
unlayered: [], | ||
layered: [] | ||
}; | ||
for (const node of root.nodes) { | ||
const key = node.type === "atrule" && node.name === "layer" ? "layered" : "unlayered"; | ||
rules[key].push(node); | ||
} | ||
const unlayeredRoot = root.clone().removeAll(); | ||
unlayeredRoot.append(...rules.unlayered); | ||
sortMediaQuery(unlayeredRoot); | ||
const layeredRoot = root.clone().removeAll(); | ||
for (const rule of rules.layered) { | ||
layeredRoot.append(...inner(rule)); | ||
} | ||
if (layeredRoot.nodes.length) { | ||
unlayeredRoot.append(...layeredRoot.nodes); | ||
} | ||
return [unlayeredRoot]; | ||
const parentMap = /* @__PURE__ */ new Map(); | ||
root.walkAtRules("media", (atRule3) => { | ||
const clone = atRule3.clone(); | ||
const parent = atRule3.parent || root; | ||
parentMap.get(parent) || parentMap.set(parent, []); | ||
parentMap.get(parent).push(clone); | ||
atRule3.remove(); | ||
}); | ||
parentMap.forEach((atRules, parent) => { | ||
atRules.sort((a, b) => (0, import_sort_css_media_queries.default)(a.params, b.params)).forEach((atRule3) => { | ||
parent.append(atRule3); | ||
}); | ||
}); | ||
}; | ||
return (root) => { | ||
root.nodes = inner(root); | ||
}; | ||
return inner; | ||
} | ||
var sortMediaQuery = (container) => { | ||
const atRules = []; | ||
container.walkAtRules("media", (atRule3) => { | ||
const query = atRule3.params; | ||
if (!atRules[query]) { | ||
atRules[query] = new import_postcss6.AtRule({ | ||
name: atRule3.name, | ||
params: atRule3.params, | ||
source: atRule3.source | ||
}); | ||
} | ||
atRule3.nodes.forEach((node) => { | ||
atRules[query].append(node.clone()); | ||
}); | ||
atRule3.remove(); | ||
}); | ||
Object.keys(atRules).sort(import_sort_css_media_queries.default).forEach((query) => { | ||
container.append(atRules[query]); | ||
}); | ||
}; | ||
sortMediaQueries.postcssPlugin = "panda-sort-mq"; | ||
@@ -688,7 +659,7 @@ | ||
function optimizeCss(code, { minify = false } = {}) { | ||
const { css } = (0, import_postcss7.default)([ | ||
const { css } = (0, import_postcss6.default)([ | ||
(0, import_postcss_nested2.default)(), | ||
mergeLayers(), | ||
sortMediaQueries(), | ||
(0, import_postcss_discard_duplicates.default)(), | ||
(0, import_postcss_nested2.default)(), | ||
minify ? (0, import_postcss_normalize_whitespace.default)() : prettify() | ||
@@ -699,7 +670,7 @@ ]).process(code); | ||
function discardDuplicate(code) { | ||
const { css } = (0, import_postcss7.default)([mergeLayers(), (0, import_postcss_discard_duplicates.default)()]).process(code); | ||
const { css } = (0, import_postcss6.default)([mergeLayers(), (0, import_postcss_discard_duplicates.default)()]).process(code); | ||
return css; | ||
} | ||
function prettifyCss(code) { | ||
const { css } = (0, import_postcss7.default)([prettify()]).process(code); | ||
const { css } = (0, import_postcss6.default)([prettify()]).process(code); | ||
return css; | ||
@@ -714,3 +685,3 @@ } | ||
var import_shared5 = require("@pandacss/shared"); | ||
var import_postcss8 = __toESM(require("postcss")); | ||
var import_postcss7 = __toESM(require("postcss")); | ||
var import_shared6 = require("@pandacss/shared"); | ||
@@ -720,3 +691,3 @@ var AtomicRule = class { | ||
this.context = context; | ||
this.root = import_postcss8.default.root(); | ||
this.root = import_postcss7.default.root(); | ||
} | ||
@@ -760,3 +731,3 @@ root; | ||
if (transformed.layer) { | ||
const atRule4 = import_postcss8.default.atRule({ | ||
const atRule4 = import_postcss7.default.atRule({ | ||
name: "layer", | ||
@@ -771,3 +742,3 @@ params: transformed.layer, | ||
}); | ||
const atRule3 = import_postcss8.default.atRule({ | ||
const atRule3 = import_postcss7.default.atRule({ | ||
name: "layer", | ||
@@ -876,3 +847,3 @@ params: this.layer, | ||
var import_shared8 = require("@pandacss/shared"); | ||
var import_postcss9 = __toESM(require("postcss")); | ||
var import_postcss8 = __toESM(require("postcss")); | ||
var Stylesheet = class { | ||
@@ -883,6 +854,6 @@ constructor(context, options) { | ||
} | ||
addGlobalCss = (styleObject) => { | ||
processGlobalCss = (styleObject) => { | ||
const { conditions, utility } = this.context; | ||
const css = serializeStyles(styleObject, { conditions, utility }); | ||
const layer = import_postcss9.default.atRule({ | ||
const layer = import_postcss8.default.atRule({ | ||
name: "layer", | ||
@@ -894,11 +865,8 @@ params: "base", | ||
}; | ||
processGlobalCss = (styleObject) => { | ||
this.addGlobalCss(styleObject); | ||
}; | ||
processSelectorObject(selector, styleObject) { | ||
const cssString = toCss(styleObject); | ||
const { nodes } = import_postcss9.default.parse(cssString); | ||
const { nodes } = import_postcss8.default.parse(cssString); | ||
if (nodes.length === 0) | ||
return; | ||
const output = import_postcss9.default.rule({ | ||
const output = import_postcss8.default.rule({ | ||
selector, | ||
@@ -905,0 +873,0 @@ nodes: cssString.root.nodes |
{ | ||
"name": "@pandacss/core", | ||
"version": "0.0.0-dev-20221218075945", | ||
"version": "0.0.0-dev-20221218093122", | ||
"description": "core functions for extract-it", | ||
@@ -26,11 +26,11 @@ "main": "dist/index.js", | ||
"lodash.merge": "4.6.2", | ||
"@pandacss/error": "0.0.0-dev-20221218075945", | ||
"@pandacss/types": "0.0.0-dev-20221218075945", | ||
"@pandacss/shared": "0.0.0-dev-20221218075945", | ||
"@pandacss/logger": "0.0.0-dev-20221218075945", | ||
"@pandacss/token-dictionary": "0.0.0-dev-20221218075945" | ||
"@pandacss/error": "0.0.0-dev-20221218093122", | ||
"@pandacss/types": "0.0.0-dev-20221218093122", | ||
"@pandacss/shared": "0.0.0-dev-20221218093122", | ||
"@pandacss/logger": "0.0.0-dev-20221218093122", | ||
"@pandacss/token-dictionary": "0.0.0-dev-20221218093122" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash.merge": "4.6.7", | ||
"@pandacss/fixture": "0.0.0-dev-20221218075945" | ||
"@pandacss/fixture": "0.0.0-dev-20221218093122" | ||
}, | ||
@@ -37,0 +37,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
74082
2433
+ Added@pandacss/error@0.0.0-dev-20221218093122(transitive)
+ Added@pandacss/logger@0.0.0-dev-20221218093122(transitive)
+ Added@pandacss/shared@0.0.0-dev-20221218093122(transitive)
+ Added@pandacss/token-dictionary@0.0.0-dev-20221218093122(transitive)
+ Added@pandacss/types@0.0.0-dev-20221218093122(transitive)
- Removed@pandacss/error@0.0.0-dev-20221218075945(transitive)
- Removed@pandacss/logger@0.0.0-dev-20221218075945(transitive)
- Removed@pandacss/shared@0.0.0-dev-20221218075945(transitive)
- Removed@pandacss/token-dictionary@0.0.0-dev-20221218075945(transitive)
- Removed@pandacss/types@0.0.0-dev-20221218075945(transitive)