@linaria/atomic 4.5.1 → 4.5.3
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.
|
@@ -49,7 +49,7 @@ __export(styled_exports, {
|
|
|
49
49
|
module.exports = __toCommonJS(styled_exports);
|
|
50
50
|
var import_logger = require("@linaria/logger");
|
|
51
51
|
var import_styled = __toESM(require("@linaria/react/processors/styled"));
|
|
52
|
-
var
|
|
52
|
+
var import_utils2 = require("@linaria/utils");
|
|
53
53
|
|
|
54
54
|
// src/processors/helpers/atomize.ts
|
|
55
55
|
var import_known_css_properties = require("known-css-properties");
|
|
@@ -348,7 +348,7 @@ var AtomicStyledProcessor = class extends import_styled.default {
|
|
|
348
348
|
extractRules(valueCache, cssText, loc) {
|
|
349
349
|
const rules = {};
|
|
350
350
|
const wrappedValue = typeof this.component === "string" ? null : valueCache.get(this.component.node.name);
|
|
351
|
-
const atomicRules = atomize(cssText, (0,
|
|
351
|
+
const atomicRules = atomize(cssText, (0, import_utils2.hasMeta)(wrappedValue));
|
|
352
352
|
atomicRules.forEach((rule) => {
|
|
353
353
|
rules[rule.cssText] = {
|
|
354
354
|
cssText: rule.cssText,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/processors/styled.ts","../../src/processors/helpers/atomize.ts","../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport { hasMeta } from '@linaria/tags';\nimport type { Rules, ValueCache } from '@linaria/tags';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n","import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n","const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAsB;AAEtB,oBAA4B;AAC5B,kBAAwB;;;ACLxB,kCAAuC;AAEvC,qBAAoB;AACpB,oBAAmB;AAEnB,mBAAwB;;;ACLxB,IAAM,sBAAsB;AAAA,EAI1B,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,gBAAgB,gBAAgB,cAAc;AAAA,EACvD,oBAAoB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,sBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;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;AAEA;AAAA,QACE;AAAA,QACA;AAAA,EAAK,KAAK;AAAA,MACZ;AAAA,IACF,CAAC;AAED,uBAAK,UAAW,YAEb,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,EACjC,IAAI,CAAC,SAAS,KAAK,SAAU,EAC7B,KAAK,GAAG;AAEX,WAAO;AAAA,EACT;AAAA,EAEmB,WAAmB;AACpC,UAAM,QAAQ,MAAM,SAAS;AAC7B,UAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACrE,UAAM,SAAS;AACf,WAAO;AAAA,EACT;AAAA,EAEmB,cACjB,QACA,MACA,cACQ;AACR,UAAM,KAAK,KAAK,oBAAoB,QAAQ,MAAM,YAAY;AAC9D,QAAI,IAAI;AACN,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,KAAK,mBAAmB,QAAQ,MAAM,YAAY;AAElE,WAAO,QAAQ;AAAA,EACjB;AACF;AAvEE;","names":["knownProperties","postcss","stylis","StyledProcessor"]}
|
|
1
|
+
{"version":3,"sources":["../../src/processors/styled.ts","../../src/processors/helpers/atomize.ts","../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport type { Rules, ValueCache } from '@linaria/tags';\nimport { hasMeta } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n","import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n","const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAsB;AAEtB,oBAA4B;AAE5B,IAAAA,gBAAwB;;;ACNxB,kCAAuC;AAEvC,qBAAoB;AACpB,oBAAmB;AAEnB,mBAAwB;;;ACLxB,IAAM,sBAAsB;AAAA,EAI1B,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,gBAAgB,gBAAgB,cAAc;AAAA,EACvD,oBAAoB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,sBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACnB;AAAA,IACA;AAA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OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,EACjC,IAAI,CAAC,SAAS,KAAK,SAAU,EAC7B,KAAK,GAAG;AAEX,WAAO;AAAA,EACT;AAAA,EAEmB,WAAmB;AACpC,UAAM,QAAQ,MAAM,SAAS;AAC7B,UAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACrE,UAAM,SAAS;AACf,WAAO;AAAA,EACT;AAAA,EAEmB,cACjB,QACA,MACA,cACQ;AACR,UAAM,KAAK,KAAK,oBAAoB,QAAQ,MAAM,YAAY;AAC9D,QAAI,IAAI;AACN,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,KAAK,mBAAmB,QAAQ,MAAM,YAAY;AAElE,WAAO,QAAQ;AAAA,EACjB;AACF;AAvEE;","names":["import_utils","knownProperties","postcss","stylis","StyledProcessor"]}
|
|
@@ -20,7 +20,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
20
20
|
// src/processors/styled.ts
|
|
21
21
|
import { debug } from "@linaria/logger";
|
|
22
22
|
import StyledProcessor from "@linaria/react/processors/styled";
|
|
23
|
-
import { hasMeta } from "@linaria/
|
|
23
|
+
import { hasMeta } from "@linaria/utils";
|
|
24
24
|
|
|
25
25
|
// src/processors/helpers/atomize.ts
|
|
26
26
|
import { all as knownProperties } from "known-css-properties";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/processors/styled.ts","../../src/processors/helpers/atomize.ts","../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport { hasMeta } from '@linaria/tags';\nimport type { Rules, ValueCache } from '@linaria/tags';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n","import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n","const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AAEtB,OAAO,qBAAqB;AAC5B,SAAS,eAAe;;;ACLxB,SAAS,OAAO,uBAAuB;AAEvC,OAAO,aAAa;AACpB,OAAO,YAAY;AAEnB,SAAS,eAAe;;;ACLxB,IAAM,sBAAsB;AAAA,EAI1B,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,gBAAgB,gBAAgB,cAAc;AAAA,EACvD,oBAAoB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,sBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAC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QAChB,aAAa,KAAK;AAAA,QAClB,MAAM;AAAA,MACR;AAEA;AAAA,QACE;AAAA,QACA;AAAA,EAAK,KAAK;AAAA,MACZ;AAAA,IACF,CAAC;AAED,uBAAK,UAAW,YAEb,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,EACjC,IAAI,CAAC,SAAS,KAAK,SAAU,EAC7B,KAAK,GAAG;AAEX,WAAO;AAAA,EACT;AAAA,EAEmB,WAAmB;AACpC,UAAM,QAAQ,MAAM,SAAS;AAC7B,UAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACrE,UAAM,SAAS;AACf,WAAO;AAAA,EACT;AAAA,EAEmB,cACjB,QACA,MACA,cACQ;AACR,UAAM,KAAK,KAAK,oBAAoB,QAAQ,MAAM,YAAY;AAC9D,QAAI,IAAI;AACN,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,KAAK,mBAAmB,QAAQ,MAAM,YAAY;AAElE,WAAO,QAAQ;AAAA,EACjB;AACF;AAvEE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/processors/styled.ts","../../src/processors/helpers/atomize.ts","../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport type { Rules, ValueCache } from '@linaria/tags';\nimport { hasMeta } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n","import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n","const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AAEtB,OAAO,qBAAqB;AAE5B,SAAS,eAAe;;;ACNxB,SAAS,OAAO,uBAAuB;AAEvC,OAAO,aAAa;AACpB,OAAO,YAAY;AAEnB,SAAS,eAAe;;;ACLxB,IAAM,sBAAsB;AAAA,EAI1B,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,gBAAgB,gBAAgB,cAAc;AAAA,EACvD,oBAAoB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,sBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,qBAAqB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAA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SAAS,KAAK,SAAU,EAC7B,KAAK,GAAG;AAEX,WAAO;AAAA,EACT;AAAA,EAEmB,WAAmB;AACpC,UAAM,QAAQ,MAAM,SAAS;AAC7B,UAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACrE,UAAM,SAAS;AACf,WAAO;AAAA,EACT;AAAA,EAEmB,cACjB,QACA,MACA,cACQ;AACR,UAAM,KAAK,KAAK,oBAAoB,QAAQ,MAAM,YAAY;AAC9D,QAAI,IAAI;AACN,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,KAAK,mBAAmB,QAAQ,MAAM,YAAY;AAElE,WAAO,QAAQ;AAAA,EACjB;AACF;AAvEE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linaria/atomic",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "Blazing fast zero-runtime CSS in JS library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"postcss": "^8.3.11",
|
|
47
47
|
"stylis": "^3.5.4",
|
|
48
48
|
"ts-invariant": "^0.10.3",
|
|
49
|
-
"@linaria/core": "^4.5.
|
|
49
|
+
"@linaria/core": "^4.5.3",
|
|
50
50
|
"@linaria/logger": "^4.5.0",
|
|
51
|
-
"@linaria/react": "^4.5.
|
|
52
|
-
"@linaria/tags": "^4.5.
|
|
53
|
-
"@linaria/utils": "^4.5.
|
|
51
|
+
"@linaria/react": "^4.5.3",
|
|
52
|
+
"@linaria/tags": "^4.5.3",
|
|
53
|
+
"@linaria/utils": "^4.5.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/types": "^7.
|
|
56
|
+
"@babel/types": "^7.22.5",
|
|
57
57
|
"@types/node": "^17.0.39"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|