@telegraph/style-engine 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @telegraph/style-engine
|
|
2
2
|
|
|
3
|
+
## 0.1.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dfafb5d`](https://github.com/knocklabs/telegraph/commit/dfafb5de1da5664bbe832fa0a36518ee53fed162) Thanks [@kylemcd](https://github.com/kylemcd)! - don't throw error when not in monorepo
|
|
8
|
+
|
|
3
9
|
## 0.1.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/postcss.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const a=require("path"),l=require("fs"),m=require("postcss");function y(
|
|
1
|
+
"use strict";const a=require("path"),l=require("fs"),m=require("postcss");function y(t=process.cwd()){let e=t,s=!0;for(;s;){const n=a.join(e,"package.json");if(l.existsSync(n))try{if(JSON.parse(l.readFileSync(n,"utf8")).workspaces)return e}catch{}const r=a.dirname(e);r===e&&(s=!1),e=r}}const d=(t,e)=>{var s;if(!(!t.dependencies||((s=Object.keys(t.dependencies))==null?void 0:s.length)===0))return Object.entries(t.dependencies).reduce((n,[r,c])=>(r.startsWith("@telegraph/")&&(n[r]={name:r,version:c,path:a.resolve(e,"node_modules",r)}),n),{})};function v(){const t=a.resolve(process.cwd(),"package.json"),e=JSON.parse(l.readFileSync(t,"utf8")),s=d(e,process.cwd()),n=y(),r=c=>{if(!c||Object.keys(c).length===0)return c;const i={...c};for(const u of Object.values(c)){let o,p;u.version.includes("workspace:")&&n?(o=a.resolve(n,"node_modules",u.name,"package.json"),p=n):(o=a.resolve(process.cwd(),"node_modules",u.name,"package.json"),p=process.cwd());try{const g=JSON.parse(l.readFileSync(o,"utf8")),h=d(g,p);if(Object.assign(i,h),h){const k=r(h);Object.assign(i,k)}}catch{continue}}return i};return s?r(s):{}}function f({fileName:t="default.css",path:e}){try{const s=`${e}/dist/css/${t}`,n=a.resolve(s);return l.existsSync(n)?l.readFileSync(n,"utf8"):null}catch{return null}}const j=async({root:t,config:e})=>{const s=v(),n=e.components===!0?Object.values(s).filter(o=>!o.name.includes("@telegraph/tokens")):[],r=e.tokens.length>0?Object.values(s).filter(o=>o.name.includes("@telegraph/tokens")):[],c=n.map(o=>f({path:o.path})).filter(Boolean),i=e.tokens.map(o=>r.map(g=>f({path:g.path,fileName:`${o}.css`})).filter(Boolean)).filter(Boolean),u=[...c,...i];for(const o of u){const p=m.parse(o);t.append(p)}},O=()=>({postcssPlugin:"@telegraph/style-engine",plugins:[{postcssPlugin:"telegraph",AtRule:{telegraph(){}},async Once(t){const e={tokens:[],components:!1};t.walkAtRules("telegraph",s=>{s.params==="components"&&(e.components=!0,s.remove()),s.params==="tokens-light"&&(e.tokens.push("light"),s.remove()),s.params==="tokens-dark"&&(e.tokens.push("dark"),s.remove()),s.params==="tokens"&&(e.tokens.push("default"),s.remove())}),await j({root:t,config:{tokens:e.tokens,components:e.components}})}}]}),P=Object.assign(O,{postcss:!0});module.exports=P;
|
|
2
2
|
//# sourceMappingURL=postcss.js.map
|
package/dist/cjs/postcss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.js","sources":["../../src/plugins/postcss.ts"],"sourcesContent":["import { type AcceptedPlugin, type PluginCreator, type Root } from \"postcss\";\n\n// Using require() instead of import to prevent ESM-related bugs in PostCSS.\n// ESM = ECMAScript Modules (the import/export syntax)\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodePath = require(\"path\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodeFs = require(\"fs\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst postcss = require(\"postcss\");\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\ntype DepObject = Record<\n string,\n {\n name: string;\n version: string;\n path: string;\n }\n>;\n\n/**\n * Traverses up the directory tree to find the root of the monorepo by looking for a package.json with workspaces.\n * This is needed to properly resolve workspace dependencies in a monorepo setup.\n */\nfunction findMonorepoRoot(start = process.cwd()): string {\n let current = start;\n let run = true;\n\n while (run) {\n const pkgJsonPath = nodePath.join(current, \"package.json\");\n if (nodeFs.existsSync(pkgJsonPath)) {\n try {\n const pkg = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n if (pkg.workspaces) {\n return current;\n }\n } catch {\n // malformed package.json, skip\n }\n }\n\n const parent = nodePath.dirname(current);\n if (parent === current) run = false;\n current = parent;\n }\n\n throw new Error(\n 'Could not find monorepo root (no package.json with \"workspaces\" found)',\n );\n}\n\n/**\n * Extracts all @telegraph/* dependencies from a package.json file and returns them with their paths.\n * This is used to find all Telegraph packages that might contain CSS we need to include.\n */\nconst getTelegraphDepsFromPackageJson = (\n pkg: PkgJson,\n pkgPath: string,\n): DepObject | undefined => {\n if (!pkg.dependencies || Object.keys(pkg.dependencies)?.length === 0) return;\n\n return Object.entries(pkg.dependencies).reduce((acc, [dep, version]) => {\n if (dep.startsWith(\"@telegraph/\")) {\n acc[dep] = {\n name: dep,\n version,\n path: nodePath.resolve(pkgPath, \"node_modules\", dep),\n };\n }\n return acc;\n }, {} as DepObject);\n};\n\n/**\n * Gets all Telegraph dependencies recursively, including dependencies of dependencies.\n * Handles both normal npm dependencies and workspace dependencies in a monorepo.\n */\nfunction getTelegraphDeps(): DepObject {\n const pkgPath = nodePath.resolve(process.cwd(), \"package.json\");\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf8\"));\n const topLevelDeps = getTelegraphDepsFromPackageJson(pkg, process.cwd());\n const monorepoRoot = findMonorepoRoot();\n\n const recursivelyGetTelegraphDeps = (deps: DepObject): DepObject => {\n if (!deps || Object.keys(deps).length === 0) {\n return deps;\n }\n\n const allDeps = { ...deps };\n\n for (const dep of Object.values(deps)) {\n let pkgJsonPath: string;\n let searchPath: string;\n\n if (dep.version.includes(\"workspace:\") && monorepoRoot) {\n pkgJsonPath = nodePath.resolve(\n monorepoRoot,\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = monorepoRoot;\n } else {\n pkgJsonPath = nodePath.resolve(\n process.cwd(),\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = process.cwd();\n }\n\n try {\n const pkgJson = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = getTelegraphDepsFromPackageJson(pkgJson, searchPath);\n\n // Merge new dependencies into allDeps\n Object.assign(allDeps, deps);\n\n if (deps) {\n // Recursively get dependencies of dependencies\n const nestedDeps = recursivelyGetTelegraphDeps(deps);\n Object.assign(allDeps, nestedDeps);\n }\n } catch (err) {\n // Skip if package.json cannot be read\n continue;\n }\n }\n\n return allDeps;\n };\n\n if (topLevelDeps) {\n return recursivelyGetTelegraphDeps(topLevelDeps);\n }\n\n return {};\n}\n\ntype GetCssStylesParams = {\n fileName?: string;\n path: string;\n};\n\n/**\n * Reads CSS file content from a Telegraph package's dist/css directory.\n * Returns null if the file doesn't exist or can't be read.\n */\nfunction getCssStyles({\n fileName = \"default.css\",\n path,\n}: GetCssStylesParams): string | null {\n try {\n const cssPath = `${path}/dist/css/${fileName}`;\n const pkgPath = nodePath.resolve(cssPath);\n\n if (nodeFs.existsSync(pkgPath)) {\n return nodeFs.readFileSync(pkgPath, \"utf8\");\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\ntype BuildTelegraphCssParams = {\n root: Root;\n config: {\n tokens: Array<\"light\" | \"dark\" | \"default\">;\n components: boolean;\n };\n};\n\n/**\n * Main function that builds the final CSS by:\n * 1. Getting all Telegraph dependencies\n * 2. Filtering for either token packages or component packages based on config\n * 3. Reading their CSS files\n * 4. Appending all CSS to the PostCSS Root node\n */\nconst buildTelegraphCss = async ({ root, config }: BuildTelegraphCssParams) => {\n const deps = getTelegraphDeps();\n\n const depsWithoutTokens =\n config.components === true\n ? Object.values(deps).filter(\n (dep) => !dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const tokensDeps =\n config.tokens.length > 0\n ? Object.values(deps).filter((dep) =>\n dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const cssFiles = depsWithoutTokens\n .map((dep) => getCssStyles({ path: dep.path }))\n .filter(Boolean) as Array<string>;\n\n const tokensCssFiles = config.tokens\n .map((token) => {\n const cssFile = tokensDeps.map((dep) =>\n getCssStyles({ path: dep.path, fileName: `${token}.css` }),\n );\n\n return cssFile.filter(Boolean) as Array<string>;\n })\n .filter(Boolean);\n\n const allCssFiles = [...cssFiles, ...tokensCssFiles];\n\n for (const content of allCssFiles) {\n const parsed = postcss.parse(content);\n root.append(parsed);\n }\n};\n\n/**\n * PostCSS plugin that processes @telegraph rules in CSS files.\n * It looks for @telegraph tokens, @telegraph tokens-light, @telegraph tokens-dark,\n * and @telegraph components rules and includes the appropriate CSS from Telegraph packages.\n */\nconst styleEnginePostCssPlugin = (): AcceptedPlugin => {\n return {\n postcssPlugin: \"@telegraph/style-engine\",\n plugins: [\n {\n postcssPlugin: \"style-engine\",\n async Once(root) {\n const run = {\n tokens: [] as BuildTelegraphCssParams[\"config\"][\"tokens\"],\n components: false,\n };\n root.walkAtRules(\"telegraph\", (atRule) => {\n if (atRule.params === \"components\") {\n run.components = true;\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-light\") {\n run.tokens.push(\"light\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-dark\") {\n run.tokens.push(\"dark\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens\") {\n run.tokens.push(\"default\");\n atRule.remove();\n }\n });\n\n await buildTelegraphCss({\n root,\n config: {\n tokens: run.tokens,\n components: run.components,\n },\n });\n },\n },\n ],\n };\n};\n\nexport default Object.assign(styleEnginePostCssPlugin, {\n postcss: true,\n}) as PluginCreator<Record<string, never>>;\n"],"names":["nodePath","nodeFs","postcss","findMonorepoRoot","start","current","run","pkgJsonPath","parent","getTelegraphDepsFromPackageJson","pkg","pkgPath","_a","acc","dep","version","getTelegraphDeps","topLevelDeps","monorepoRoot","recursivelyGetTelegraphDeps","deps","allDeps","searchPath","pkgJson","nestedDeps","getCssStyles","fileName","path","cssPath","buildTelegraphCss","root","config","depsWithoutTokens","tokensDeps","cssFiles","tokensCssFiles","token","allCssFiles","content","parsed","styleEnginePostCssPlugin","atRule","postcss$1"],"mappings":"aAKA,MAAMA,EAAW,QAAQ,MAAM,EAEzBC,EAAS,QAAQ,IAAI,EAErBC,EAAU,QAAQ,SAAS,EAoBjC,SAASC,EAAiBC,EAAQ,QAAQ,MAAe,CACvD,IAAIC,EAAUD,EACVE,EAAM,GAEV,KAAOA,GAAK,CACV,MAAMC,EAAcP,EAAS,KAAKK,EAAS,cAAc,EACrD,GAAAJ,EAAO,WAAWM,CAAW,EAC3B,GAAA,CAEF,GADY,KAAK,MAAMN,EAAO,aAAaM,EAAa,MAAM,CAAC,EACvD,WACC,OAAAF,CACT,MACM,CAAA,CAKJ,MAAAG,EAASR,EAAS,QAAQK,CAAO,EACnCG,IAAWH,IAAeC,EAAA,IACpBD,EAAAG,CAAA,CAGZ,MAAM,IAAI,MACR,wEACF,CACF,CAMA,MAAMC,EAAkC,CACtCC,EACAC,IAC0B,OACtB,GAAA,GAACD,EAAI,gBAAgBE,EAAA,OAAO,KAAKF,EAAI,YAAY,IAA5B,YAAAE,EAA+B,UAAW,GAE5D,OAAA,OAAO,QAAQF,EAAI,YAAY,EAAE,OAAO,CAACG,EAAK,CAACC,EAAKC,CAAO,KAC5DD,EAAI,WAAW,aAAa,IAC9BD,EAAIC,CAAG,EAAI,CACT,KAAMA,EACN,QAAAC,EACA,KAAMf,EAAS,QAAQW,EAAS,eAAgBG,CAAG,CACrD,GAEKD,GACN,EAAe,CACpB,EAMA,SAASG,GAA8B,CACrC,MAAML,EAAUX,EAAS,QAAQ,QAAQ,MAAO,cAAc,EACxDU,EAAM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,CACF,CAEJ,GAGFoC,EAAe,OAAO,OAAOF,EAA0B,CACrD,QAAS,EACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"postcss.js","sources":["../../src/plugins/postcss.ts"],"sourcesContent":["import { type AcceptedPlugin, type PluginCreator, type Root } from \"postcss\";\n\n// Using require() instead of import to prevent ESM-related bugs in PostCSS.\n// ESM = ECMAScript Modules (the import/export syntax)\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodePath = require(\"path\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodeFs = require(\"fs\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst postcss = require(\"postcss\");\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\ntype DepObject = Record<\n string,\n {\n name: string;\n version: string;\n path: string;\n }\n>;\n\n/**\n * Traverses up the directory tree to find the root of the monorepo by looking for a package.json with workspaces.\n * This is needed to properly resolve workspace dependencies in a monorepo setup.\n */\nfunction findMonorepoRoot(start = process.cwd()): string | undefined {\n let current = start;\n let run = true;\n\n while (run) {\n const pkgJsonPath = nodePath.join(current, \"package.json\");\n if (nodeFs.existsSync(pkgJsonPath)) {\n try {\n const pkg = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n if (pkg.workspaces) {\n return current;\n }\n } catch {\n // malformed package.json, skip\n }\n }\n\n const parent = nodePath.dirname(current);\n if (parent === current) run = false;\n current = parent;\n }\n\n return undefined;\n}\n\n/**\n * Extracts all @telegraph/* dependencies from a package.json file and returns them with their paths.\n * This is used to find all Telegraph packages that might contain CSS we need to include.\n */\nconst getTelegraphDepsFromPackageJson = (\n pkg: PkgJson,\n pkgPath: string,\n): DepObject | undefined => {\n if (!pkg.dependencies || Object.keys(pkg.dependencies)?.length === 0) return;\n\n return Object.entries(pkg.dependencies).reduce((acc, [dep, version]) => {\n if (dep.startsWith(\"@telegraph/\")) {\n acc[dep] = {\n name: dep,\n version,\n path: nodePath.resolve(pkgPath, \"node_modules\", dep),\n };\n }\n return acc;\n }, {} as DepObject);\n};\n\n/**\n * Gets all Telegraph dependencies recursively, including dependencies of dependencies.\n * Handles both normal npm dependencies and workspace dependencies in a monorepo.\n */\nfunction getTelegraphDeps(): DepObject {\n const pkgPath = nodePath.resolve(process.cwd(), \"package.json\");\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf8\"));\n const topLevelDeps = getTelegraphDepsFromPackageJson(pkg, process.cwd());\n const monorepoRoot = findMonorepoRoot();\n\n const recursivelyGetTelegraphDeps = (deps: DepObject): DepObject => {\n if (!deps || Object.keys(deps).length === 0) {\n return deps;\n }\n\n const allDeps = { ...deps };\n\n for (const dep of Object.values(deps)) {\n let pkgJsonPath: string;\n let searchPath: string;\n\n if (dep.version.includes(\"workspace:\") && monorepoRoot) {\n pkgJsonPath = nodePath.resolve(\n monorepoRoot,\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = monorepoRoot;\n } else {\n pkgJsonPath = nodePath.resolve(\n process.cwd(),\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = process.cwd();\n }\n\n try {\n const pkgJson = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = getTelegraphDepsFromPackageJson(pkgJson, searchPath);\n\n // Merge new dependencies into allDeps\n Object.assign(allDeps, deps);\n\n if (deps) {\n // Recursively get dependencies of dependencies\n const nestedDeps = recursivelyGetTelegraphDeps(deps);\n Object.assign(allDeps, nestedDeps);\n }\n } catch (err) {\n // Skip if package.json cannot be read\n continue;\n }\n }\n\n return allDeps;\n };\n\n if (topLevelDeps) {\n return recursivelyGetTelegraphDeps(topLevelDeps);\n }\n\n return {};\n}\n\ntype GetCssStylesParams = {\n fileName?: string;\n path: string;\n};\n\n/**\n * Reads CSS file content from a Telegraph package's dist/css directory.\n * Returns null if the file doesn't exist or can't be read.\n */\nfunction getCssStyles({\n fileName = \"default.css\",\n path,\n}: GetCssStylesParams): string | null {\n try {\n const cssPath = `${path}/dist/css/${fileName}`;\n const pkgPath = nodePath.resolve(cssPath);\n\n if (nodeFs.existsSync(pkgPath)) {\n return nodeFs.readFileSync(pkgPath, \"utf8\");\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\ntype BuildTelegraphCssParams = {\n root: Root;\n config: {\n tokens: Array<\"light\" | \"dark\" | \"default\">;\n components: boolean;\n };\n};\n\n/**\n * Main function that builds the final CSS by:\n * 1. Getting all Telegraph dependencies\n * 2. Filtering for either token packages or component packages based on config\n * 3. Reading their CSS files\n * 4. Appending all CSS to the PostCSS Root node\n */\nconst buildTelegraphCss = async ({ root, config }: BuildTelegraphCssParams) => {\n const deps = getTelegraphDeps();\n\n const depsWithoutTokens =\n config.components === true\n ? Object.values(deps).filter(\n (dep) => !dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const tokensDeps =\n config.tokens.length > 0\n ? Object.values(deps).filter((dep) =>\n dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const cssFiles = depsWithoutTokens\n .map((dep) => getCssStyles({ path: dep.path }))\n .filter(Boolean) as Array<string>;\n\n const tokensCssFiles = config.tokens\n .map((token) => {\n const cssFile = tokensDeps.map((dep) =>\n getCssStyles({ path: dep.path, fileName: `${token}.css` }),\n );\n\n return cssFile.filter(Boolean) as Array<string>;\n })\n .filter(Boolean);\n\n const allCssFiles = [...cssFiles, ...tokensCssFiles];\n\n for (const content of allCssFiles) {\n const parsed = postcss.parse(content);\n root.append(parsed);\n }\n};\n\n/**\n * PostCSS plugin that processes @telegraph rules in CSS files.\n * It looks for @telegraph tokens, @telegraph tokens-light, @telegraph tokens-dark,\n * and @telegraph components rules and includes the appropriate CSS from Telegraph packages.\n */\nconst styleEnginePostCssPlugin = (): AcceptedPlugin => {\n return {\n postcssPlugin: \"@telegraph/style-engine\",\n plugins: [\n {\n postcssPlugin: \"telegraph\",\n AtRule: {\n telegraph() {},\n },\n async Once(root) {\n const run = {\n tokens: [] as BuildTelegraphCssParams[\"config\"][\"tokens\"],\n components: false,\n };\n root.walkAtRules(\"telegraph\", (atRule) => {\n if (atRule.params === \"components\") {\n run.components = true;\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-light\") {\n run.tokens.push(\"light\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-dark\") {\n run.tokens.push(\"dark\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens\") {\n run.tokens.push(\"default\");\n atRule.remove();\n }\n });\n\n await buildTelegraphCss({\n root,\n config: {\n tokens: run.tokens,\n components: run.components,\n },\n });\n },\n },\n ],\n };\n};\n\nexport default Object.assign(styleEnginePostCssPlugin, {\n postcss: true,\n}) as PluginCreator<Record<string, never>>;\n"],"names":["nodePath","nodeFs","postcss","findMonorepoRoot","start","current","run","pkgJsonPath","parent","getTelegraphDepsFromPackageJson","pkg","pkgPath","_a","acc","dep","version","getTelegraphDeps","topLevelDeps","monorepoRoot","recursivelyGetTelegraphDeps","deps","allDeps","searchPath","pkgJson","nestedDeps","getCssStyles","fileName","path","cssPath","buildTelegraphCss","root","config","depsWithoutTokens","tokensDeps","cssFiles","tokensCssFiles","token","allCssFiles","content","parsed","styleEnginePostCssPlugin","atRule","postcss$1"],"mappings":"aAKA,MAAMA,EAAW,QAAQ,MAAM,EAEzBC,EAAS,QAAQ,IAAI,EAErBC,EAAU,QAAQ,SAAS,EAoBjC,SAASC,EAAiBC,EAAQ,QAAQ,MAA2B,CACnE,IAAIC,EAAUD,EACVE,EAAM,GAEV,KAAOA,GAAK,CACV,MAAMC,EAAcP,EAAS,KAAKK,EAAS,cAAc,EACrD,GAAAJ,EAAO,WAAWM,CAAW,EAC3B,GAAA,CAEF,GADY,KAAK,MAAMN,EAAO,aAAaM,EAAa,MAAM,CAAC,EACvD,WACC,OAAAF,CACT,MACM,CAAA,CAKJ,MAAAG,EAASR,EAAS,QAAQK,CAAO,EACnCG,IAAWH,IAAeC,EAAA,IACpBD,EAAAG,CAAA,CAId,CAMA,MAAMC,EAAkC,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ACV,OAAQ,CAAC,EACT,WAAY,EACd,EACKwB,EAAA,YAAY,YAAcW,GAAW,CACpCA,EAAO,SAAW,eACpBnC,EAAI,WAAa,GACjBmC,EAAO,OAAO,GAGZA,EAAO,SAAW,iBAChBnC,EAAA,OAAO,KAAK,OAAO,EACvBmC,EAAO,OAAO,GAGZA,EAAO,SAAW,gBAChBnC,EAAA,OAAO,KAAK,MAAM,EACtBmC,EAAO,OAAO,GAGZA,EAAO,SAAW,WAChBnC,EAAA,OAAO,KAAK,SAAS,EACzBmC,EAAO,OAAO,EAChB,CACD,EAED,MAAMZ,EAAkB,CACtB,KAAAC,EACA,OAAQ,CACN,OAAQxB,EAAI,OACZ,WAAYA,EAAI,UAAA,CAClB,CACD,CAAA,CACH,CACF,CAEJ,GAGFoC,EAAe,OAAO,OAAOF,EAA0B,CACrD,QAAS,EACX,CAAC"}
|
package/dist/esm/postcss.mjs
CHANGED
|
@@ -1,52 +1,49 @@
|
|
|
1
1
|
const a = require("path"), l = require("fs"), m = require("postcss");
|
|
2
|
-
function y(
|
|
3
|
-
let e =
|
|
2
|
+
function y(t = process.cwd()) {
|
|
3
|
+
let e = t, s = !0;
|
|
4
4
|
for (; s; ) {
|
|
5
|
-
const
|
|
6
|
-
if (l.existsSync(
|
|
5
|
+
const n = a.join(e, "package.json");
|
|
6
|
+
if (l.existsSync(n))
|
|
7
7
|
try {
|
|
8
|
-
if (JSON.parse(l.readFileSync(
|
|
8
|
+
if (JSON.parse(l.readFileSync(n, "utf8")).workspaces)
|
|
9
9
|
return e;
|
|
10
10
|
} catch {
|
|
11
11
|
}
|
|
12
12
|
const r = a.dirname(e);
|
|
13
13
|
r === e && (s = !1), e = r;
|
|
14
14
|
}
|
|
15
|
-
throw new Error(
|
|
16
|
-
'Could not find monorepo root (no package.json with "workspaces" found)'
|
|
17
|
-
);
|
|
18
15
|
}
|
|
19
|
-
const
|
|
16
|
+
const h = (t, e) => {
|
|
20
17
|
var s;
|
|
21
|
-
if (!(!
|
|
22
|
-
return Object.entries(
|
|
18
|
+
if (!(!t.dependencies || ((s = Object.keys(t.dependencies)) == null ? void 0 : s.length) === 0))
|
|
19
|
+
return Object.entries(t.dependencies).reduce((n, [r, c]) => (r.startsWith("@telegraph/") && (n[r] = {
|
|
23
20
|
name: r,
|
|
24
21
|
version: c,
|
|
25
22
|
path: a.resolve(e, "node_modules", r)
|
|
26
|
-
}),
|
|
23
|
+
}), n), {});
|
|
27
24
|
};
|
|
28
|
-
function
|
|
29
|
-
const
|
|
25
|
+
function v() {
|
|
26
|
+
const t = a.resolve(process.cwd(), "package.json"), e = JSON.parse(l.readFileSync(t, "utf8")), s = h(e, process.cwd()), n = y(), r = (c) => {
|
|
30
27
|
if (!c || Object.keys(c).length === 0)
|
|
31
28
|
return c;
|
|
32
29
|
const i = { ...c };
|
|
33
30
|
for (const u of Object.values(c)) {
|
|
34
31
|
let o, p;
|
|
35
|
-
u.version.includes("workspace:") &&
|
|
36
|
-
|
|
32
|
+
u.version.includes("workspace:") && n ? (o = a.resolve(
|
|
33
|
+
n,
|
|
37
34
|
"node_modules",
|
|
38
35
|
u.name,
|
|
39
36
|
"package.json"
|
|
40
|
-
), p =
|
|
37
|
+
), p = n) : (o = a.resolve(
|
|
41
38
|
process.cwd(),
|
|
42
39
|
"node_modules",
|
|
43
40
|
u.name,
|
|
44
41
|
"package.json"
|
|
45
42
|
), p = process.cwd());
|
|
46
43
|
try {
|
|
47
|
-
const d = JSON.parse(l.readFileSync(o, "utf8")),
|
|
48
|
-
if (Object.assign(i,
|
|
49
|
-
const k = r(
|
|
44
|
+
const d = JSON.parse(l.readFileSync(o, "utf8")), g = h(d, p);
|
|
45
|
+
if (Object.assign(i, g), g) {
|
|
46
|
+
const k = r(g);
|
|
50
47
|
Object.assign(i, k);
|
|
51
48
|
}
|
|
52
49
|
} catch {
|
|
@@ -57,43 +54,47 @@ function j() {
|
|
|
57
54
|
};
|
|
58
55
|
return s ? r(s) : {};
|
|
59
56
|
}
|
|
60
|
-
function
|
|
61
|
-
fileName:
|
|
57
|
+
function f({
|
|
58
|
+
fileName: t = "default.css",
|
|
62
59
|
path: e
|
|
63
60
|
}) {
|
|
64
61
|
try {
|
|
65
|
-
const s = `${e}/dist/css/${
|
|
66
|
-
return l.existsSync(
|
|
62
|
+
const s = `${e}/dist/css/${t}`, n = a.resolve(s);
|
|
63
|
+
return l.existsSync(n) ? l.readFileSync(n, "utf8") : null;
|
|
67
64
|
} catch {
|
|
68
65
|
return null;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
|
-
const
|
|
72
|
-
const s =
|
|
68
|
+
const j = async ({ root: t, config: e }) => {
|
|
69
|
+
const s = v(), n = e.components === !0 ? Object.values(s).filter(
|
|
73
70
|
(o) => !o.name.includes("@telegraph/tokens")
|
|
74
71
|
) : [], r = e.tokens.length > 0 ? Object.values(s).filter(
|
|
75
72
|
(o) => o.name.includes("@telegraph/tokens")
|
|
76
|
-
) : [], c =
|
|
77
|
-
(d) =>
|
|
73
|
+
) : [], c = n.map((o) => f({ path: o.path })).filter(Boolean), i = e.tokens.map((o) => r.map(
|
|
74
|
+
(d) => f({ path: d.path, fileName: `${o}.css` })
|
|
78
75
|
).filter(Boolean)).filter(Boolean), u = [...c, ...i];
|
|
79
76
|
for (const o of u) {
|
|
80
77
|
const p = m.parse(o);
|
|
81
|
-
|
|
78
|
+
t.append(p);
|
|
82
79
|
}
|
|
83
|
-
},
|
|
80
|
+
}, O = () => ({
|
|
84
81
|
postcssPlugin: "@telegraph/style-engine",
|
|
85
82
|
plugins: [
|
|
86
83
|
{
|
|
87
|
-
postcssPlugin: "
|
|
88
|
-
|
|
84
|
+
postcssPlugin: "telegraph",
|
|
85
|
+
AtRule: {
|
|
86
|
+
telegraph() {
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
async Once(t) {
|
|
89
90
|
const e = {
|
|
90
91
|
tokens: [],
|
|
91
92
|
components: !1
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
+
t.walkAtRules("telegraph", (s) => {
|
|
94
95
|
s.params === "components" && (e.components = !0, s.remove()), s.params === "tokens-light" && (e.tokens.push("light"), s.remove()), s.params === "tokens-dark" && (e.tokens.push("dark"), s.remove()), s.params === "tokens" && (e.tokens.push("default"), s.remove());
|
|
95
|
-
}), await
|
|
96
|
-
root:
|
|
96
|
+
}), await j({
|
|
97
|
+
root: t,
|
|
97
98
|
config: {
|
|
98
99
|
tokens: e.tokens,
|
|
99
100
|
components: e.components
|
|
@@ -102,10 +103,10 @@ const v = async ({ root: n, config: e }) => {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
]
|
|
105
|
-
}),
|
|
106
|
+
}), P = Object.assign(O, {
|
|
106
107
|
postcss: !0
|
|
107
108
|
});
|
|
108
109
|
export {
|
|
109
|
-
|
|
110
|
+
P as default
|
|
110
111
|
};
|
|
111
112
|
//# sourceMappingURL=postcss.mjs.map
|
package/dist/esm/postcss.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.mjs","sources":["../../src/plugins/postcss.ts"],"sourcesContent":["import { type AcceptedPlugin, type PluginCreator, type Root } from \"postcss\";\n\n// Using require() instead of import to prevent ESM-related bugs in PostCSS.\n// ESM = ECMAScript Modules (the import/export syntax)\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodePath = require(\"path\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodeFs = require(\"fs\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst postcss = require(\"postcss\");\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\ntype DepObject = Record<\n string,\n {\n name: string;\n version: string;\n path: string;\n }\n>;\n\n/**\n * Traverses up the directory tree to find the root of the monorepo by looking for a package.json with workspaces.\n * This is needed to properly resolve workspace dependencies in a monorepo setup.\n */\nfunction findMonorepoRoot(start = process.cwd()): string {\n let current = start;\n let run = true;\n\n while (run) {\n const pkgJsonPath = nodePath.join(current, \"package.json\");\n if (nodeFs.existsSync(pkgJsonPath)) {\n try {\n const pkg = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n if (pkg.workspaces) {\n return current;\n }\n } catch {\n // malformed package.json, skip\n }\n }\n\n const parent = nodePath.dirname(current);\n if (parent === current) run = false;\n current = parent;\n }\n\n throw new Error(\n 'Could not find monorepo root (no package.json with \"workspaces\" found)',\n );\n}\n\n/**\n * Extracts all @telegraph/* dependencies from a package.json file and returns them with their paths.\n * This is used to find all Telegraph packages that might contain CSS we need to include.\n */\nconst getTelegraphDepsFromPackageJson = (\n pkg: PkgJson,\n pkgPath: string,\n): DepObject | undefined => {\n if (!pkg.dependencies || Object.keys(pkg.dependencies)?.length === 0) return;\n\n return Object.entries(pkg.dependencies).reduce((acc, [dep, version]) => {\n if (dep.startsWith(\"@telegraph/\")) {\n acc[dep] = {\n name: dep,\n version,\n path: nodePath.resolve(pkgPath, \"node_modules\", dep),\n };\n }\n return acc;\n }, {} as DepObject);\n};\n\n/**\n * Gets all Telegraph dependencies recursively, including dependencies of dependencies.\n * Handles both normal npm dependencies and workspace dependencies in a monorepo.\n */\nfunction getTelegraphDeps(): DepObject {\n const pkgPath = nodePath.resolve(process.cwd(), \"package.json\");\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf8\"));\n const topLevelDeps = getTelegraphDepsFromPackageJson(pkg, process.cwd());\n const monorepoRoot = findMonorepoRoot();\n\n const recursivelyGetTelegraphDeps = (deps: DepObject): DepObject => {\n if (!deps || Object.keys(deps).length === 0) {\n return deps;\n }\n\n const allDeps = { ...deps };\n\n for (const dep of Object.values(deps)) {\n let pkgJsonPath: string;\n let searchPath: string;\n\n if (dep.version.includes(\"workspace:\") && monorepoRoot) {\n pkgJsonPath = nodePath.resolve(\n monorepoRoot,\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = monorepoRoot;\n } else {\n pkgJsonPath = nodePath.resolve(\n process.cwd(),\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = process.cwd();\n }\n\n try {\n const pkgJson = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = getTelegraphDepsFromPackageJson(pkgJson, searchPath);\n\n // Merge new dependencies into allDeps\n Object.assign(allDeps, deps);\n\n if (deps) {\n // Recursively get dependencies of dependencies\n const nestedDeps = recursivelyGetTelegraphDeps(deps);\n Object.assign(allDeps, nestedDeps);\n }\n } catch (err) {\n // Skip if package.json cannot be read\n continue;\n }\n }\n\n return allDeps;\n };\n\n if (topLevelDeps) {\n return recursivelyGetTelegraphDeps(topLevelDeps);\n }\n\n return {};\n}\n\ntype GetCssStylesParams = {\n fileName?: string;\n path: string;\n};\n\n/**\n * Reads CSS file content from a Telegraph package's dist/css directory.\n * Returns null if the file doesn't exist or can't be read.\n */\nfunction getCssStyles({\n fileName = \"default.css\",\n path,\n}: GetCssStylesParams): string | null {\n try {\n const cssPath = `${path}/dist/css/${fileName}`;\n const pkgPath = nodePath.resolve(cssPath);\n\n if (nodeFs.existsSync(pkgPath)) {\n return nodeFs.readFileSync(pkgPath, \"utf8\");\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\ntype BuildTelegraphCssParams = {\n root: Root;\n config: {\n tokens: Array<\"light\" | \"dark\" | \"default\">;\n components: boolean;\n };\n};\n\n/**\n * Main function that builds the final CSS by:\n * 1. Getting all Telegraph dependencies\n * 2. Filtering for either token packages or component packages based on config\n * 3. Reading their CSS files\n * 4. Appending all CSS to the PostCSS Root node\n */\nconst buildTelegraphCss = async ({ root, config }: BuildTelegraphCssParams) => {\n const deps = getTelegraphDeps();\n\n const depsWithoutTokens =\n config.components === true\n ? Object.values(deps).filter(\n (dep) => !dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const tokensDeps =\n config.tokens.length > 0\n ? Object.values(deps).filter((dep) =>\n dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const cssFiles = depsWithoutTokens\n .map((dep) => getCssStyles({ path: dep.path }))\n .filter(Boolean) as Array<string>;\n\n const tokensCssFiles = config.tokens\n .map((token) => {\n const cssFile = tokensDeps.map((dep) =>\n getCssStyles({ path: dep.path, fileName: `${token}.css` }),\n );\n\n return cssFile.filter(Boolean) as Array<string>;\n })\n .filter(Boolean);\n\n const allCssFiles = [...cssFiles, ...tokensCssFiles];\n\n for (const content of allCssFiles) {\n const parsed = postcss.parse(content);\n root.append(parsed);\n }\n};\n\n/**\n * PostCSS plugin that processes @telegraph rules in CSS files.\n * It looks for @telegraph tokens, @telegraph tokens-light, @telegraph tokens-dark,\n * and @telegraph components rules and includes the appropriate CSS from Telegraph packages.\n */\nconst styleEnginePostCssPlugin = (): AcceptedPlugin => {\n return {\n postcssPlugin: \"@telegraph/style-engine\",\n plugins: [\n {\n postcssPlugin: \"style-engine\",\n async Once(root) {\n const run = {\n tokens: [] as BuildTelegraphCssParams[\"config\"][\"tokens\"],\n components: false,\n };\n root.walkAtRules(\"telegraph\", (atRule) => {\n if (atRule.params === \"components\") {\n run.components = true;\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-light\") {\n run.tokens.push(\"light\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-dark\") {\n run.tokens.push(\"dark\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens\") {\n run.tokens.push(\"default\");\n atRule.remove();\n }\n });\n\n await buildTelegraphCss({\n root,\n config: {\n tokens: run.tokens,\n components: run.components,\n },\n });\n },\n },\n ],\n };\n};\n\nexport default Object.assign(styleEnginePostCssPlugin, {\n postcss: true,\n}) as PluginCreator<Record<string, never>>;\n"],"names":["nodePath","nodeFs","postcss","findMonorepoRoot","start","current","run","pkgJsonPath","parent","getTelegraphDepsFromPackageJson","pkg","pkgPath","_a","acc","dep","version","getTelegraphDeps","topLevelDeps","monorepoRoot","recursivelyGetTelegraphDeps","deps","allDeps","searchPath","pkgJson","nestedDeps","getCssStyles","fileName","path","cssPath","buildTelegraphCss","root","config","depsWithoutTokens","tokensDeps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AO;AAAA,QAChB,CACD,GAED,MAAMZ,EAAkB;AAAA,UACtB,MAAAC;AAAA,UACA,QAAQ;AAAA,YACN,QAAQxB,EAAI;AAAA,YACZ,YAAYA,EAAI;AAAA,UAAA;AAAA,QAClB,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ,IAGFoC,IAAe,OAAO,OAAOF,GAA0B;AAAA,EACrD,SAAS;AACX,CAAC;"}
|
|
1
|
+
{"version":3,"file":"postcss.mjs","sources":["../../src/plugins/postcss.ts"],"sourcesContent":["import { type AcceptedPlugin, type PluginCreator, type Root } from \"postcss\";\n\n// Using require() instead of import to prevent ESM-related bugs in PostCSS.\n// ESM = ECMAScript Modules (the import/export syntax)\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodePath = require(\"path\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nodeFs = require(\"fs\");\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst postcss = require(\"postcss\");\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n};\n\ntype DepObject = Record<\n string,\n {\n name: string;\n version: string;\n path: string;\n }\n>;\n\n/**\n * Traverses up the directory tree to find the root of the monorepo by looking for a package.json with workspaces.\n * This is needed to properly resolve workspace dependencies in a monorepo setup.\n */\nfunction findMonorepoRoot(start = process.cwd()): string | undefined {\n let current = start;\n let run = true;\n\n while (run) {\n const pkgJsonPath = nodePath.join(current, \"package.json\");\n if (nodeFs.existsSync(pkgJsonPath)) {\n try {\n const pkg = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n if (pkg.workspaces) {\n return current;\n }\n } catch {\n // malformed package.json, skip\n }\n }\n\n const parent = nodePath.dirname(current);\n if (parent === current) run = false;\n current = parent;\n }\n\n return undefined;\n}\n\n/**\n * Extracts all @telegraph/* dependencies from a package.json file and returns them with their paths.\n * This is used to find all Telegraph packages that might contain CSS we need to include.\n */\nconst getTelegraphDepsFromPackageJson = (\n pkg: PkgJson,\n pkgPath: string,\n): DepObject | undefined => {\n if (!pkg.dependencies || Object.keys(pkg.dependencies)?.length === 0) return;\n\n return Object.entries(pkg.dependencies).reduce((acc, [dep, version]) => {\n if (dep.startsWith(\"@telegraph/\")) {\n acc[dep] = {\n name: dep,\n version,\n path: nodePath.resolve(pkgPath, \"node_modules\", dep),\n };\n }\n return acc;\n }, {} as DepObject);\n};\n\n/**\n * Gets all Telegraph dependencies recursively, including dependencies of dependencies.\n * Handles both normal npm dependencies and workspace dependencies in a monorepo.\n */\nfunction getTelegraphDeps(): DepObject {\n const pkgPath = nodePath.resolve(process.cwd(), \"package.json\");\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf8\"));\n const topLevelDeps = getTelegraphDepsFromPackageJson(pkg, process.cwd());\n const monorepoRoot = findMonorepoRoot();\n\n const recursivelyGetTelegraphDeps = (deps: DepObject): DepObject => {\n if (!deps || Object.keys(deps).length === 0) {\n return deps;\n }\n\n const allDeps = { ...deps };\n\n for (const dep of Object.values(deps)) {\n let pkgJsonPath: string;\n let searchPath: string;\n\n if (dep.version.includes(\"workspace:\") && monorepoRoot) {\n pkgJsonPath = nodePath.resolve(\n monorepoRoot,\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = monorepoRoot;\n } else {\n pkgJsonPath = nodePath.resolve(\n process.cwd(),\n \"node_modules\",\n dep.name,\n \"package.json\",\n );\n searchPath = process.cwd();\n }\n\n try {\n const pkgJson = JSON.parse(nodeFs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = getTelegraphDepsFromPackageJson(pkgJson, searchPath);\n\n // Merge new dependencies into allDeps\n Object.assign(allDeps, deps);\n\n if (deps) {\n // Recursively get dependencies of dependencies\n const nestedDeps = recursivelyGetTelegraphDeps(deps);\n Object.assign(allDeps, nestedDeps);\n }\n } catch (err) {\n // Skip if package.json cannot be read\n continue;\n }\n }\n\n return allDeps;\n };\n\n if (topLevelDeps) {\n return recursivelyGetTelegraphDeps(topLevelDeps);\n }\n\n return {};\n}\n\ntype GetCssStylesParams = {\n fileName?: string;\n path: string;\n};\n\n/**\n * Reads CSS file content from a Telegraph package's dist/css directory.\n * Returns null if the file doesn't exist or can't be read.\n */\nfunction getCssStyles({\n fileName = \"default.css\",\n path,\n}: GetCssStylesParams): string | null {\n try {\n const cssPath = `${path}/dist/css/${fileName}`;\n const pkgPath = nodePath.resolve(cssPath);\n\n if (nodeFs.existsSync(pkgPath)) {\n return nodeFs.readFileSync(pkgPath, \"utf8\");\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\ntype BuildTelegraphCssParams = {\n root: Root;\n config: {\n tokens: Array<\"light\" | \"dark\" | \"default\">;\n components: boolean;\n };\n};\n\n/**\n * Main function that builds the final CSS by:\n * 1. Getting all Telegraph dependencies\n * 2. Filtering for either token packages or component packages based on config\n * 3. Reading their CSS files\n * 4. Appending all CSS to the PostCSS Root node\n */\nconst buildTelegraphCss = async ({ root, config }: BuildTelegraphCssParams) => {\n const deps = getTelegraphDeps();\n\n const depsWithoutTokens =\n config.components === true\n ? Object.values(deps).filter(\n (dep) => !dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const tokensDeps =\n config.tokens.length > 0\n ? Object.values(deps).filter((dep) =>\n dep.name.includes(\"@telegraph/tokens\"),\n )\n : [];\n\n const cssFiles = depsWithoutTokens\n .map((dep) => getCssStyles({ path: dep.path }))\n .filter(Boolean) as Array<string>;\n\n const tokensCssFiles = config.tokens\n .map((token) => {\n const cssFile = tokensDeps.map((dep) =>\n getCssStyles({ path: dep.path, fileName: `${token}.css` }),\n );\n\n return cssFile.filter(Boolean) as Array<string>;\n })\n .filter(Boolean);\n\n const allCssFiles = [...cssFiles, ...tokensCssFiles];\n\n for (const content of allCssFiles) {\n const parsed = postcss.parse(content);\n root.append(parsed);\n }\n};\n\n/**\n * PostCSS plugin that processes @telegraph rules in CSS files.\n * It looks for @telegraph tokens, @telegraph tokens-light, @telegraph tokens-dark,\n * and @telegraph components rules and includes the appropriate CSS from Telegraph packages.\n */\nconst styleEnginePostCssPlugin = (): AcceptedPlugin => {\n return {\n postcssPlugin: \"@telegraph/style-engine\",\n plugins: [\n {\n postcssPlugin: \"telegraph\",\n AtRule: {\n telegraph() {},\n },\n async Once(root) {\n const run = {\n tokens: [] as BuildTelegraphCssParams[\"config\"][\"tokens\"],\n components: false,\n };\n root.walkAtRules(\"telegraph\", (atRule) => {\n if (atRule.params === \"components\") {\n run.components = true;\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-light\") {\n run.tokens.push(\"light\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens-dark\") {\n run.tokens.push(\"dark\");\n atRule.remove();\n }\n\n if (atRule.params === \"tokens\") {\n run.tokens.push(\"default\");\n atRule.remove();\n }\n });\n\n await buildTelegraphCss({\n root,\n config: {\n tokens: run.tokens,\n components: run.components,\n },\n });\n },\n },\n ],\n };\n};\n\nexport default Object.assign(styleEnginePostCssPlugin, {\n postcss: true,\n}) as PluginCreator<Record<string, never>>;\n"],"names":["nodePath","nodeFs","postcss","findMonorepoRoot","start","current","run","pkgJsonPath","parent","getTelegraphDepsFromPackageJson","pkg","pkgPath","_a","acc","dep","version","getTelegraphDeps","topLevelDeps","monorepoRoot","recursivelyGetTelegraphDeps","deps","allDeps","searchPath","pkgJson","nestedDeps","getCssStyles","fileName","path","cssPath","buildTelegraphCss","root","config","depsWithoutTokens","tokensDeps","cssFiles","tokensCssFiles","token","allCssFiles","content","parsed","styleEnginePostCssPlugin","atRule","postcss$1"],"mappings":"AAKA,MAAMA,IAAW,QAAQ,MAAM,GAEzBC,IAAS,QAAQ,IAAI,GAErBC,IAAU,QAAQ,SAAS;AAoBjC,SAASC,EAAiBC,IAAQ,QAAQ,OAA2B;AACnE,MAAIC,IAAUD,GACVE,IAAM;AAEV,SAAOA,KAAK;AACV,UAAMC,IAAcP,EAAS,KAAKK,GAAS,cAAc;AACrD,QAAAJ,EAAO,WAAWM,CAAW;AAC3B,UAAA;AAEF,Y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../../../src/plugins/postcss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAa,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"postcss.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAa,MAAM,SAAS,CAAC;wBAwRvE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAF1C,wBAE2C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telegraph/style-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "A wrappar around vanilla extract to style telegraph",
|
|
5
5
|
"repository": "https://github.com/knocklabs/telegraph/tree/main/packages/style-engine",
|
|
6
6
|
"author": "@knocklabs",
|