astro-ghostcms/.pnpm-store/v3/files/b4/b9de8fabf8df618b9f857b8cc63...

8 lines
142 KiB
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
{
"version": 3,
"sources": ["../../src/transformers/inline.ts", "../../node_modules/.pnpm/stylis@4.1.2/node_modules/stylis/src/Enum.js", "../../node_modules/.pnpm/stylis@4.1.2/node_modules/stylis/src/Utility.js", "../../node_modules/.pnpm/stylis@4.1.2/node_modules/stylis/src/Tokenizer.js", "../../node_modules/.pnpm/stylis@4.1.2/node_modules/stylis/src/Parser.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/ast/ast.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/flatten/flatten.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/internals.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/codepoints.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/process.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/tokens.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/lexer.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/utils.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/index.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/helpers.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/units.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/compile.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/matches.js"],
"sourcesContent": ["import { walkSync, ELEMENT_NODE, TEXT_NODE, Node } from \"../index.js\";\nimport { querySelectorAll, specificity } from \"../selector.js\";\nimport { type Element as CSSEntry, compile } from \"stylis\";\nimport { compileQuery, matches, type Environment } from 'media-query-fns';\n\nexport interface InlineOptions {\n /** Emit `style` attributes as objects rather than strings. */\n useObjectSyntax: boolean;\n env: Partial<Environment> & { width: number, height: number };\n}\nexport default function inline(opts?: Partial<InlineOptions>) {\n const { useObjectSyntax = false } = opts ?? {};\n return (doc: Node): Node => {\n const style: string[] = useObjectSyntax ? [':where([style]) {}'] : [];\n const actions: (() => void)[] = [];\n walkSync(doc, (node: Node, parent?: Node) => {\n if (node.type === ELEMENT_NODE) {\n if (node.name === \"style\") {\n style.push(\n node.children\n .map((c: Node) => (c.type === TEXT_NODE ? c.value : \"\"))\n .join(\"\")\n );\n actions.push(() => {\n parent!.children = parent!.children.filter((c: Node) => c !== node);\n });\n }\n }\n });\n for (const action of actions) {\n action();\n }\n const styles = style.join(\"\\n\");\n const css = compile(styles);\n const selectors = new Map<string, Record<string, string>>();\n\n function applyRule(rule: CSSEntry) {\n if (rule.type === 'rule') {\n const rules = Object.fromEntries(\n (rule.children as unknown as Element[])\n .map((child: any) => [child.props, child.children])\n );\n for (const selector of rule.props) {\n const value = Object.assign(selectors.get(selector) ?? {}, rules);\n selectors.set(selector, value);\n }\n } else if (rule.type === '@media' && opts?.env) {\n const env = getEnvironment(opts.env);\n const args = Array.isArray(rule.props) ? rule.props : [rule.props];\n const queries = args.map(arg => compileQuery(arg))\n for (const query of queries) {\n if (matches(query, env)) {\n for (const child of rule.children) {\n applyRule(child as CSSEntry)\n }\n return;\n }\n }\n }\n }\n for (const rule of css) {\n applyRule(rule);\n }\n const rules = new Map<Node, Record<string, string>>();\n for (const [selector, styles] of Array.from(selectors).sort(([a], [b]) => {\n const $a = specificity(a);\n const $b = specificity(b);\n if ($a > $b) return 1;\n if ($b > $a) return -1;\n return 0;\n })) {\n const nodes = querySelectorAll(doc, selector);\n for (const node of nodes) {\n const curr = rules.get(node) ?? {};\n rules.set(node, Object.assign(curr, styles));\n }\n }\n\n for (const [node, rule] of rules) {\n let style = node.attributes.style ?? \"\";\n let styleObj: Record<string, string> = {};\n for (const decl of compile(style)) {\n if (decl.type === \"decl\") {\n if (\n typeof decl.props === \"string\" &&\n typeof decl.children === \"string\"\n ) {\n styleObj[decl.props] = decl.children;\n }\n }\n }\n styleObj = Object.assign({}, rule, styleObj);\n if (useObjectSyntax) {\n node.attributes.style = styleObj;\n } else {\n node.attributes.style = `${Object.entries(styleObj)\n .map(([decl, value]) => `${decl}:${value.replace(\"!important\", \"\")};`)\n .join(\"\")}`;\n }\n }\n return doc;\n };\n}\n\ntype AlwaysDefinedValues = \"widthPx\" | \"heightPx\" | \"deviceWidthPx\" | \"deviceHeightPx\" | \"dppx\";\ntype ResolvedEnvironment = Omit<Partial<Environment>, AlwaysDefinedValues> & Record<AlwaysDefinedValues, number>;\nfunction getEnvironment(baseEnv: InlineOptions['env']): ResolvedEnvironment {\n const { width, height, dppx = 1, widthPx = width, heightPx = height, deviceWidthPx =
"mappings": "AAAA,OAAS,YAAAA,GAAU,gBAAAC,GAAc,aAAAC,OAAuB,cACxD,OAAS,oBAAAC,GAAkB,eAAAC,OAAmB,iBCGvC,IAAIC,GAAU,OACVC,GAAU,OACVC,GAAc,OCFlB,IAAIC,GAAM,KAAK,IAMXC,EAAO,OAAO,aAqBlB,SAASC,EAAMC,EAAO,CAC5B,OAAOA,EAAM,KAAK,CACnB,CAiBO,SAASC,EAASC,EAAOC,EAASC,EAAa,CACrD,OAAOF,EAAM,QAAQC,EAASC,CAAW,CAC1C,CAOO,SAASC,GAASH,EAAOI,EAAQ,CACvC,OAAOJ,EAAM,QAAQI,CAAM,CAC5B,CAOO,SAASC,EAAQL,EAAOM,EAAO,CACrC,OAAON,EAAM,WAAWM,CAAK,EAAI,CAClC,CAQO,SAASC,EAAQP,EAAOQ,EAAOC,EAAK,CAC1C,OAAOT,EAAM,MAAMQ,EAAOC,CAAG,CAC9B,CAMO,SAASC,EAAQV,EAAO,CA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EAAOb,CAAU,EAAIZ,GACzCsB,EAAOpB,EAAW,GAAKwB,GAAYd,EAAa,IAAKpB,EAAMD,EAAQS,EAAS,CAAC,EAAI0B,GAAYV,EAAQJ,EAAY,IAAK,EAAE,EAAI,IAAKpB,EAAMD,EAAQS,EAAS,CAAC,EAAGH,CAAY,EACzK,UAEI,IAAIe,GAAc,YAKtB,GAFAU,EAAOX,EAAYgB,GAAQf,EAAYtB,EAAMC,EAAQO,EAAOC,EAAQN,EAAOG,EAAQY,EAAMC,EAAQ,CAAC,EAAGC,EAAW,CAAC,EAAGV,CAAM,EAAGN,CAAQ,EAEjIa,IAAc,IACjB,GAAIR,IAAW,EACdX,GAAMwB,EAAYtB,EAAMqB,EAAWA,EAAWF,EAAOf,EAAUM,EAAQJ,EAAQc,CAAQ,MAEvF,
"names": ["walkSync", "ELEMENT_NODE", "TEXT_NODE", "querySelectorAll", "specificity", "COMMENT", "RULESET", "DECLARATION", "abs", "from", "trim", "value", "replace", "value", "pattern", "replacement", "indexof", "search", "charat", "index", "substr", "begin", "end", "strlen", "sizeof", "append", "array", "line", "column", "length", "position", "character", "characters", "node", "value", "root", "parent", "type", "props", "children", "char", "character", "prev", "position", "charat", "characters", "column", "line", "next", "length", "peek", "caret", "slice", "begin", "end", "substr", "token", "type", "alloc", "value", "strlen", "dealloc", "delimit", "trim", "delimiter", "whitespace", "type", "character", "peek", "next", "token", "escaping", "index", "count", "next", "character", "slice", "caret", "peek", "delimiter", "type", "position", "commenter", "from", "identifier", "token", "compile", "value", "dealloc", "parse", "alloc", "root", "parent", "rule", "rules", "rulesets", "pseudo", "points", "declarations", "index", "offset", "length", "atrule", "property", "previous", "variable", "scanning", "ampersand", "character", "type", "props", "children", "reference", "characters", "next", "charat", "indexof", "replace", "delimit", "whitespace", "escaping", "caret", "peek", "append", "comment", "commenter", "strlen", "declaration", "ruleset", "prev", "from", "identifier", "post", "size", "sizeof", "i", "j", "k", "substr", "abs", "z", "trim", "node", "RULESET", "COMMENT", "char", "DECLARATION", "isParserError", "splitMediaQueryList", "t", "r", "n", "readMediaQueryList", "e", "readMediaQuery", "i", "readMediaCondition", "a", "d", "s", "o", "l", "u", "readMediaFeature", "readRange", "p", "f", "c", "h", "E", "v", "flattenMediaQueryList", "e", "flattenMediaQuery", "flattenMediaCondition", "o", "i", "invertParserError", "t", "d", "e", "deleteUndefinedValues", "e", "readCodepoints", "s", "t", "r", "a", "convertToParserTokens", "t", "r", "s", "codepointsToTokens", "f", "c", "p", "d", "h", "e", "n", "s", "consumeString", "t", "wouldStartIdentifier", "consumeIdentUnsafe", "consumeNumeric", "consumeIdentLike", "consumeIdent", "u", "r", "consumeEscape", "i", "a", "consumeNumber", "o", "l", "consumeUrl", "lexer", "m", "e", "codepointsToTokens", "readCodepoints", "isParserError", "convertToParserTokens", "isParserError", "r", "parseMediaQueryList", "t", "e", "lexer", "isParserError", "invertParserError", "deleteUndefinedValues", "flattenMediaQueryList", "readMediaQueryList", "DISCRETE_FEATURES", "RANGE_NUMBER_FEATURES", "RANGE_RATIO_FEATURES", "permToConditionPairs", "e", "hasDiscreteKey", "t", "isDiscreteKey", "hasRangeRatioKey", "isRangeRatioKey", "o", "hasRangeNumberKey", "isRangeNumberKey", "hasRangeKey", "isRangeKey", "isFeatureKey", "isRangeNumberKey", "isRangeRatioKey", "isDiscreteKey", "attachPair", "t", "andRanges", "e", "o", "n", "r", "s", "a", "i", "p", "u", "d", "l", "g", "f", "h", "y", "R", "m", "boundRange", "hasRangeRatioKey", "RANGE_RATIO_FEATURES", "RANGE_NUMBER_FEATURES", "notRatioRange", "t", "RANGE_RATIO_FEATURES", "o", "n", "r", "s", "i", "c", "d", "l", "notNumberRange", "RANGE_NUMBER_FEATURES", "i", "convertToUnit", "t", "n", "compileStaticUnitConversions", "r", "o", "a", "u", "p", "m", "s", "f", "v", "c", "simplifyMediaFeature", "isRangeKey", "e", "isFeatureKey", "getRatio", "getValue", "RANGE_NUMBER_FEATURES", "andPerms", "e", "r", "mergePerms", "a", "permToConditionPairs", "attachPair", "hasRangeNumberKey", "hasRangeRatioKey", "andRanges", "notPerms", "invertPerm", "o", "t", "hasDiscreteKey", "DISCRETE_FEATURES", "notRatioRange", "notNumberRange", "s", "mediaFeatureToPerms", "simplifyMediaFeature", "isDiscreteKey", "isRangeRatioKey", "getRatio", "boundRange", "getValue", "mediaConditionToPerms", "simplifyPerms", "n", "i", "hasRangeKey", "compileAST", "compileStaticUnitConversions", "compileQuery", "parseMediaQueryList", "isParserError", "DESKTOP_ENVIRONMENT", "e", "validateEnv", "o", "matches", "r", "t", "n", "i", "s", "a", "l", "f", "inline", "opts", "useObjectSyntax", "doc", "style", "actions", "walkSync", "node"
}