catom 2.1.0 → 2.2.0
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/dist/runtime/index.d.ts +90 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/vite/index.d.ts +81 -0
- package/dist/vite/index.js +416 -0
- package/dist/vite/index.js.map +1 -0
- package/package.json +51 -26
- package/src/virtual.d.ts +9 -0
- package/LICENSE +0 -21
- package/README.md +0 -150
- package/babelPlugin.d.ts +0 -1
- package/babelPlugin.js +0 -1
- package/css.d.ts +0 -1
- package/css.js +0 -1
- package/dist/babelPlugin.d.ts +0 -4
- package/dist/babelPlugin.js +0 -63
- package/dist/css.d.ts +0 -5
- package/dist/css.js +0 -35
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -11
- package/dist/plugin/astObject.d.ts +0 -3
- package/dist/plugin/astObject.js +0 -62
- package/dist/plugin/constants.d.ts +0 -17
- package/dist/plugin/constants.js +0 -9
- package/dist/plugin/cssTransform.d.ts +0 -3
- package/dist/plugin/cssTransform.js +0 -92
- package/dist/plugin/hash.d.ts +0 -1
- package/dist/plugin/hash.js +0 -50
- package/tsconfig.json +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/hash.ts","../../src/core/css-generator.ts","../../src/vite/transform.ts","../../src/vite/index.ts"],"names":["rules"],"mappings":";;;;;;AAKO,SAAS,QAAQ,GAAA,EAAqB;AAO3C,EAAA,IAAI,CAAA,GAAI,CAAA;AAGR,EAAA,IAAI,CAAA;AACJ,EAAA,IAAI,CAAA,GAAI,CAAA;AACR,EAAA,IAAI,MAAM,GAAA,CAAI,MAAA;AAEd,EAAA,OAAO,GAAA,IAAO,CAAA,EAAG,EAAE,CAAA,EAAG,OAAO,CAAA,EAAG;AAC9B,IAAA,CAAA,GACG,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAI,GAAA,GAAA,CACnB,IAAI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AAED,QAAA,OAAO;AAAA,UACL,MAAM,MAAA,CAAO,IAAA;AAAA,UACb,GAAA,EAAK;AAAA;AAAA,SACP;AAAA,MACF,SAAS,KAAA,EAAO;AAEd,QAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,QAAA,IAAA,CAAK,KAAA,CAAM,CAAA,2BAAA,EAA8B,EAAE,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA;AAAA,MAC3D;AAAA,IACF,CAAA;AAAA;AAAA,IAGA,YAAY,EAAA,EAAI;AACd,MAAA,IAAI,SAAA,CAAU,GAAA,CAAI,EAAE,CAAA,EAAG;AACrB,QAAA,SAAA,CAAU,OAAO,EAAE,CAAA;AAAA,MACrB;AAAA,IACF;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Murmur2 hash implementation (from emotion-js)\n * Fast, non-cryptographic hash function for generating unique class names\n * https://github.com/emotion-js/emotion/blob/master/packages/hash/src/index.js\n */\nexport function murmur2(str: string): string {\n // 'm' and 'r' are mixing constants generated offline.\n // They're not really 'magic', they just happen to work well.\n // const m = 0x5bd1e995;\n // const r = 24;\n\n // Initialize the hash\n let h = 0\n\n // Mix 4 bytes at a time into the hash\n let k: number\n let i = 0\n let len = str.length\n\n for (; len >= 4; ++i, len -= 4) {\n k =\n (str.charCodeAt(i) & 0xff) |\n ((str.charCodeAt(++i) & 0xff) << 8) |\n ((str.charCodeAt(++i) & 0xff) << 16) |\n ((str.charCodeAt(++i) & 0xff) << 24)\n\n k =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0xe995) << 16)\n k ^= /* k >>> r: */ k >>> 24\n\n h =\n /* Math.imul(k, m): */\n ((k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0xe995) << 16)) ^\n /* Math.imul(h, m): */\n ((h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0xe995) << 16))\n }\n\n // Handle the last few bytes of the input array\n switch (len) {\n case 3:\n h ^= (str.charCodeAt(i + 2) & 0xff) << 16\n // falls through\n case 2:\n h ^= (str.charCodeAt(i + 1) & 0xff) << 8\n // falls through\n case 1:\n h ^= str.charCodeAt(i) & 0xff\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0xe995) << 16)\n }\n\n // Do a few final mixes of the hash to ensure the last few\n // bytes are well-incorporated.\n h ^= h >>> 13\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0xe995) << 16)\n\n return ((h ^ (h >>> 15)) >>> 0).toString(36)\n}\n\n/**\n * Characters that require underscore prefix for valid CSS class names\n */\nconst PREFIX_CHARS = new Set('0123456789-'.split(''))\n\n/**\n * Make a hash safe for use as a CSS class name\n * Prefixes with underscore if starts with digit or dash\n */\nexport function makeCSSCompatible(hash: string): string {\n if (PREFIX_CHARS.has(hash[0])) {\n return `_${hash}`\n }\n return hash\n}\n\n/**\n * Generate a CSS-safe hash from an identity string\n */\nexport function generateHash(identity: string): string {\n return makeCSSCompatible(murmur2(identity))\n}\n","import { generateHash } from './hash.js'\nimport type { CSSRule } from './types.js'\n\n/**\n * Regex to convert camelCase to kebab-case\n */\nconst KEBAB_CASE_REGEX = /([a-z0-9]|(?=[A-Z]))([A-Z])/g\n\n/**\n * Convert camelCase CSS property to kebab-case\n * e.g., \"backgroundColor\" -> \"background-color\"\n */\nexport function toKebabCase(property: string): string {\n return property.replace(KEBAB_CASE_REGEX, '$1-$2').toLowerCase()\n}\n\n/**\n * Create a unique identity string for a CSS rule\n * Used for hashing and deduplication\n * Includes both media and pseudo in identity for proper deduplication\n */\nexport function createRuleIdentity(\n property: string,\n value: string,\n media?: string,\n pseudo?: string\n): string {\n const mediaPrefix = media ? `@${media.trim()}` : ''\n const pseudoPrefix = pseudo ? pseudo.trim() : ''\n const kebabProp = toKebabCase(property)\n return `${mediaPrefix}${pseudoPrefix}${kebabProp}:${value};`\n}\n\n/**\n * Create a CSS rule from property and value\n */\nexport function createCSSRule(\n property: string,\n value: string | number,\n media?: string,\n pseudo?: string\n): CSSRule {\n const stringValue = String(value).trim()\n const kebabProperty = toKebabCase(property.trim())\n const identity = createRuleIdentity(property, stringValue, media, pseudo)\n const hash = generateHash(identity)\n\n return {\n hash,\n property: kebabProperty,\n value: stringValue,\n media: media?.trim(),\n pseudo: pseudo?.trim(),\n }\n}\n\n/**\n * Deduplicate CSS rules by their identity\n * Rules with identical property:value (and media/pseudo) share the same hash\n */\nexport function deduplicateRules(rules: CSSRule[]): CSSRule[] {\n const seen = new Map<string, CSSRule>()\n\n for (const rule of rules) {\n const identity = createRuleIdentity(rule.property, rule.value, rule.media, rule.pseudo)\n if (!seen.has(identity)) {\n seen.set(identity, rule)\n }\n }\n\n return Array.from(seen.values())\n}\n\n/**\n * Group rules by their CSS declaration for merging selectors\n * e.g., multiple classes with same \"color: red\" get merged\n */\ninterface GroupedRule {\n declaration: string // e.g., \"color: red;\"\n hashes: Set<string>\n media?: string\n pseudo?: string\n}\n\nfunction groupRulesByDeclaration(rules: CSSRule[]): GroupedRule[] {\n const groups = new Map<string, GroupedRule>()\n\n for (const rule of rules) {\n const declaration = `${rule.property}:${rule.value};`\n const groupKey = `${rule.media || ''}|${rule.pseudo || ''}|${declaration}`\n\n if (!groups.has(groupKey)) {\n groups.set(groupKey, {\n declaration,\n hashes: new Set(),\n media: rule.media,\n pseudo: rule.pseudo,\n })\n }\n groups.get(groupKey)!.hashes.add(rule.hash)\n }\n\n return Array.from(groups.values())\n}\n\n/**\n * Generate final CSS string from rules\n * Handles deduplication and groups media queries\n */\nexport function generateCSS(rules: CSSRule[]): string {\n const dedupedRules = deduplicateRules(rules)\n\n // Separate rules by type\n const regularRules: CSSRule[] = []\n const pseudoRules: CSSRule[] = []\n const mediaRules = new Map<string, CSSRule[]>()\n\n for (const rule of dedupedRules) {\n if (rule.media) {\n const existing = mediaRules.get(rule.media) || []\n existing.push(rule)\n mediaRules.set(rule.media, existing)\n } else if (rule.pseudo) {\n pseudoRules.push(rule)\n } else {\n regularRules.push(rule)\n }\n }\n\n const cssLines: string[] = []\n\n // Generate regular rules (grouped by declaration)\n const regularGroups = groupRulesByDeclaration(regularRules)\n for (const group of regularGroups.sort((a, b) => a.declaration.localeCompare(b.declaration))) {\n const selectors = Array.from(group.hashes)\n .sort()\n .map((h) => `.${h}`)\n .join(',\\n')\n cssLines.push(`${selectors} { ${group.declaration} }`)\n }\n\n // Generate pseudo rules\n const pseudoGroups = groupRulesByDeclaration(pseudoRules)\n for (const group of pseudoGroups.sort((a, b) => a.declaration.localeCompare(b.declaration))) {\n const selectors = Array.from(group.hashes)\n .sort()\n .map((h) => `.${h}${group.pseudo}`)\n .join(',\\n')\n cssLines.push(`${selectors} { ${group.declaration} }`)\n }\n\n // Generate media queries\n const sortedMediaQueries = Array.from(mediaRules.entries()).sort(([a], [b]) =>\n a.localeCompare(b)\n )\n\n for (const [query, rules] of sortedMediaQueries) {\n const mediaGroups = groupRulesByDeclaration(rules)\n const mediaLines: string[] = []\n\n for (const group of mediaGroups.sort((a, b) => a.declaration.localeCompare(b.declaration))) {\n const suffix = group.pseudo || ''\n const selectors = Array.from(group.hashes)\n .sort()\n .map((h) => `.${h}${suffix}`)\n .join(',\\n')\n mediaLines.push(` ${selectors} { ${group.declaration} }`)\n }\n\n cssLines.push(`@media ${query} {\\n${mediaLines.join('\\n')}\\n}`)\n }\n\n return cssLines.join('\\n')\n}\n","import { parseSync } from '@swc/core'\nimport type {\n CallExpression,\n Expression,\n KeyValueProperty,\n ObjectExpression,\n Program,\n StringLiteral,\n NumericLiteral,\n SpreadElement,\n Property,\n} from '@swc/core'\nimport { createCSSRule } from '../core/css-generator.js'\nimport type { CSSRule, TransformResult } from '../core/types.js'\n\n/**\n * Check if an expression is a string or numeric literal\n */\nfunction isLiteral(expr: Expression): expr is StringLiteral | NumericLiteral {\n return expr.type === 'StringLiteral' || expr.type === 'NumericLiteral'\n}\n\n/**\n * Get the value from a literal expression\n */\nfunction getLiteralValue(expr: StringLiteral | NumericLiteral): string | number {\n if (expr.type === 'StringLiteral') {\n return expr.value\n }\n return expr.value\n}\n\n/**\n * Extract the key name from a property\n */\nfunction getPropertyKey(prop: KeyValueProperty): string | null {\n if (prop.key.type === 'Identifier') {\n return prop.key.value\n }\n if (prop.key.type === 'StringLiteral') {\n return prop.key.value\n }\n return null\n}\n\n/**\n * Process a CSS properties object and extract rules\n */\nfunction processPropertiesObject(\n obj: ObjectExpression,\n rules: CSSRule[],\n media?: string,\n pseudo?: string\n): void {\n for (const prop of obj.properties) {\n if (prop.type === 'SpreadElement') {\n // Handle spread - try to process if it's an object literal\n if (prop.argument.type === 'ObjectExpression') {\n processPropertiesObject(prop.argument, rules, media, pseudo)\n } else {\n throw new Error(\n `[catom] Spread elements must be object literals. ` +\n `Dynamic spreads are not supported at compile time.`\n )\n }\n continue\n }\n\n if (prop.type !== 'KeyValueProperty') {\n continue\n }\n\n const keyName = getPropertyKey(prop)\n if (!keyName) {\n throw new Error(`[catom] Could not determine property key. Only identifiers and string literals are supported.`)\n }\n\n const value = prop.value\n\n // Handle media queries\n if (keyName === 'media') {\n if (value.type !== 'ObjectExpression') {\n throw new Error(`[catom] 'media' property must be an object literal.`)\n }\n for (const mediaProp of value.properties) {\n if (mediaProp.type !== 'KeyValueProperty') continue\n const mediaQuery = getPropertyKey(mediaProp)\n if (!mediaQuery) continue\n if (mediaProp.value.type !== 'ObjectExpression') {\n throw new Error(`[catom] Media query '${mediaQuery}' must contain an object literal.`)\n }\n processPropertiesObject(mediaProp.value, rules, mediaQuery, pseudo)\n }\n continue\n }\n\n // Handle pseudo selectors\n if (keyName === 'pseudo') {\n if (value.type !== 'ObjectExpression') {\n throw new Error(`[catom] 'pseudo' property must be an object literal.`)\n }\n for (const pseudoProp of value.properties) {\n if (pseudoProp.type !== 'KeyValueProperty') continue\n const pseudoSelector = getPropertyKey(pseudoProp)\n if (!pseudoSelector) continue\n if (pseudoProp.value.type !== 'ObjectExpression') {\n throw new Error(`[catom] Pseudo selector '${pseudoSelector}' must contain an object literal.`)\n }\n processPropertiesObject(pseudoProp.value, rules, media, pseudoSelector)\n }\n continue\n }\n\n // Handle regular CSS properties\n // Unwrap TSAsExpression if present (e.g., `value as const`)\n let actualValue = value\n if (actualValue.type === 'TsAsExpression') {\n actualValue = actualValue.expression\n }\n\n if (!isLiteral(actualValue)) {\n throw new Error(\n `[catom] Property '${keyName}' has a non-literal value. ` +\n `Only string and number literals are supported at compile time. ` +\n `Got: ${actualValue.type}`\n )\n }\n\n const rule = createCSSRule(keyName, getLiteralValue(actualValue), media, pseudo)\n rules.push(rule)\n }\n}\n\n/**\n * Process a css() call expression and return the extracted rules and replacement hashes\n */\nfunction processCSSCall(callExpr: CallExpression): { rules: CSSRule[]; classNames: string } {\n const rules: CSSRule[] = []\n\n if (callExpr.arguments.length === 0) {\n return { rules: [], classNames: '' }\n }\n\n const arg = callExpr.arguments[0]\n if (arg.expression.type !== 'ObjectExpression') {\n throw new Error(\n `[catom] css() must be called with an object literal. ` +\n `Got: ${arg.expression.type}`\n )\n }\n\n processPropertiesObject(arg.expression, rules)\n\n const classNames = rules.map((r) => r.hash).join(' ')\n return { rules, classNames }\n}\n\n// Keys to skip during AST traversal (not AST nodes)\nconst SKIP_KEYS = new Set(['span', 'ctxt', 'type', 'value', 'raw', 'cooked'])\n\n/**\n * Check if a value is an AST node (has a type property)\n */\nfunction isASTNode(value: unknown): value is { type: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<string, unknown>).type === 'string'\n )\n}\n\n/**\n * Recursively walk the AST and find/transform css() calls\n */\nfunction walkAndTransform(\n node: unknown,\n functionName: string,\n allRules: CSSRule[],\n replacements: Map<number, string>,\n visited = new WeakSet<object>()\n): void {\n if (!node || typeof node !== 'object') return\n \n // Prevent cycles\n if (visited.has(node as object)) return\n visited.add(node as object)\n\n // Check if this is a css() call\n if (isCallExpression(node)) {\n const callee = node.callee\n if (\n callee.type === 'Identifier' &&\n callee.value === functionName\n ) {\n try {\n const { rules, classNames } = processCSSCall(node)\n allRules.push(...rules)\n // Store replacement: we'll replace by position\n replacements.set(node.span.start, classNames)\n } catch (error) {\n // Re-throw with location info if available\n const loc = node.span\n const prefix = loc ? `[${loc.start}:${loc.end}]` : ''\n throw new Error(`${prefix} ${(error as Error).message}`)\n }\n }\n }\n\n // Recurse into AST node properties\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (SKIP_KEYS.has(key)) continue\n \n const value = (node as Record<string, unknown>)[key]\n if (Array.isArray(value)) {\n for (const item of value) {\n if (isASTNode(item)) {\n walkAndTransform(item, functionName, allRules, replacements, visited)\n }\n }\n } else if (isASTNode(value)) {\n walkAndTransform(value, functionName, allRules, replacements, visited)\n }\n }\n}\n\nfunction isCallExpression(node: unknown): node is CallExpression {\n return (\n typeof node === 'object' &&\n node !== null &&\n (node as { type?: string }).type === 'CallExpression'\n )\n}\n\n/**\n * Transform source code by replacing css() calls with class name strings\n */\nexport function transformCode(\n code: string,\n id: string,\n functionName: string = 'css'\n): TransformResult {\n // Determine syntax from file extension\n const isTypeScript = /\\.tsx?$/.test(id)\n const isJSX = /\\.[jt]sx$/.test(id)\n\n let ast: Program\n try {\n ast = parseSync(code, {\n syntax: isTypeScript ? 'typescript' : 'ecmascript',\n tsx: isJSX && isTypeScript,\n jsx: isJSX && !isTypeScript,\n comments: true,\n })\n } catch {\n // If parsing fails, return unchanged\n return { code, cssRules: [], transformed: false }\n }\n\n const allRules: CSSRule[] = []\n const replacements = new Map<number, string>()\n\n // Walk the AST\n walkAndTransform(ast, functionName, allRules, replacements)\n\n if (replacements.size === 0) {\n return { code, cssRules: [], transformed: false }\n }\n\n // Apply replacements to the source code\n // We need to do this carefully to handle position shifts\n let result = code\n const sortedReplacements = Array.from(replacements.entries()).sort(\n ([a], [b]) => b - a // Sort descending so we replace from end to start\n )\n\n for (const [start, classNames] of sortedReplacements) {\n // Find the css(...) call in the original code starting at this position\n // We need to find the matching closing paren\n const searchStart = start - 1 // SWC positions seem to be 1-indexed\n const cssCallMatch = findCSSCallBounds(result, searchStart, functionName)\n if (cssCallMatch) {\n const replacement = JSON.stringify(classNames)\n result =\n result.slice(0, cssCallMatch.start) +\n replacement +\n result.slice(cssCallMatch.end)\n }\n }\n\n return {\n code: result,\n cssRules: allRules,\n transformed: true,\n }\n}\n\n/**\n * Find the bounds of a css() call in source code\n */\nfunction findCSSCallBounds(\n code: string,\n startPos: number,\n functionName: string\n): { start: number; end: number } | null {\n // Look for the function name near this position\n const searchWindow = 50\n const searchStart = Math.max(0, startPos - searchWindow)\n const searchEnd = Math.min(code.length, startPos + searchWindow)\n const searchRegion = code.slice(searchStart, searchEnd)\n\n // Find the function call\n const funcPattern = new RegExp(`\\\\b${functionName}\\\\s*\\\\(`)\n const match = funcPattern.exec(searchRegion)\n if (!match) return null\n\n const callStart = searchStart + match.index\n const parenStart = callStart + match[0].length - 1\n\n // Find matching closing paren\n let depth = 1\n let i = parenStart + 1\n while (i < code.length && depth > 0) {\n const char = code[i]\n if (char === '(') depth++\n else if (char === ')') depth--\n i++\n }\n\n if (depth !== 0) return null\n\n return { start: callStart, end: i }\n}\n","import type { Plugin } from 'vite'\nimport { createFilter } from 'vite'\n\nimport { generateCSS } from '../core/css-generator.js'\nimport { transformCode } from './transform.js'\nimport type { CSSRule, CatomPluginOptions, ModuleCSSState } from '../core/types.js'\n\nexport type { CatomPluginOptions, CSSRule, CSSInput } from '../core/types.js'\n\nconst VIRTUAL_MODULE_ID = 'virtual:catom.css'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\n/**\n * Vite plugin for zero-runtime CSS-in-JS with atomic CSS generation\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import catom from 'catom/vite'\n *\n * export default defineConfig({\n * plugins: [catom()]\n * })\n * ```\n *\n * @example\n * ```ts\n * // In your app code\n * import { css } from 'catom'\n * import 'virtual:catom.css'\n *\n * const button = css({\n * color: 'red',\n * padding: '8px',\n * pseudo: { ':hover': { color: 'blue' } }\n * })\n * // After transform: const button = \"_a1b2c3 _d4e5f6 _g7h8i9\"\n * ```\n */\nexport default function catomPlugin(options: CatomPluginOptions = {}): Plugin {\n const {\n include = /\\.[jt]sx?$/,\n exclude = /node_modules/,\n functionName = 'css',\n } = options\n\n // Per-build state: Map<moduleId, ModuleCSSState>\n // This gets reset on each build but persists during dev for the same module\n const moduleCSS = new Map<string, ModuleCSSState>()\n\n // Create filter for file matching\n let filter: (id: string) => boolean\n\n return {\n name: 'vite-plugin-catom',\n\n // Ensure we run before other transforms\n enforce: 'pre',\n\n configResolved() {\n filter = createFilter(include, exclude)\n },\n\n buildStart() {\n // Clear CSS state at the start of each build\n // This ensures clean builds and prevents stale CSS\n moduleCSS.clear()\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n return null\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n // Aggregate all CSS rules from all modules\n const allRules: CSSRule[] = []\n for (const state of moduleCSS.values()) {\n allRules.push(...state.rules)\n }\n\n // Generate deduplicated CSS\n const css = generateCSS(allRules)\n return css\n }\n return null\n },\n\n transform(code, id) {\n // Skip non-matching files\n if (!filter(id)) {\n return null\n }\n\n // Skip if no css() calls (quick check before parsing)\n if (!code.includes(functionName + '(')) {\n return null\n }\n\n try {\n const result = transformCode(code, id, functionName)\n\n if (!result.transformed) {\n return null\n }\n\n // Store CSS rules for this module\n moduleCSS.set(id, {\n rules: result.cssRules,\n timestamp: Date.now(),\n })\n\n return {\n code: result.code,\n map: null, // TODO: Add source map support\n }\n } catch (error) {\n // Include file path in error message\n const message = error instanceof Error ? error.message : String(error)\n this.error(`[catom] Error transforming ${id}: ${message}`)\n }\n },\n\n // Handle module removal (for dev server)\n watchChange(id) {\n if (moduleCSS.has(id)) {\n moduleCSS.delete(id)\n }\n },\n }\n}\n\n// Also export as named export for flexibility\nexport { catomPlugin }\n"]}
|
package/package.json
CHANGED
|
@@ -1,39 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catom",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Zero-runtime CSS-in-JS with atomic CSS generation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/runtime/index.js",
|
|
7
|
+
"module": "dist/runtime/index.js",
|
|
8
|
+
"types": "dist/runtime/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/runtime/index.d.ts",
|
|
12
|
+
"import": "./dist/runtime/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./vite": {
|
|
15
|
+
"types": "./dist/vite/index.d.ts",
|
|
16
|
+
"import": "./dist/vite/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./virtual": {
|
|
19
|
+
"types": "./src/virtual.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src/virtual.d.ts"
|
|
25
|
+
],
|
|
6
26
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
10
31
|
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"vite",
|
|
34
|
+
"vite-plugin",
|
|
35
|
+
"css-in-js",
|
|
36
|
+
"atomic-css",
|
|
37
|
+
"zero-runtime",
|
|
38
|
+
"catom"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
11
41
|
"repository": {
|
|
12
42
|
"type": "git",
|
|
13
43
|
"url": "git+https://github.com/Hydrophobefireman/catom.git"
|
|
14
44
|
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"bugs": {
|
|
17
|
-
"url": "https://github.com/Hydrophobefireman/catom/issues"
|
|
18
|
-
},
|
|
19
|
-
"module": "dist/index.js",
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
21
|
-
"sideEffects": false,
|
|
22
|
-
"homepage": "https://github.com/Hydrophobefireman/catom#readme",
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@babel/types": "^7.20.2",
|
|
25
|
-
"@types/babel__template": "^7.4.1",
|
|
26
|
-
"@types/babel__traverse": "^7.18.2",
|
|
27
|
-
"@types/estree": "^1.0.0",
|
|
28
|
-
"@types/node": "^18.11.9",
|
|
29
|
-
"typescript": "^4.8.4"
|
|
30
|
-
},
|
|
31
45
|
"peerDependencies": {
|
|
32
|
-
"
|
|
46
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"vite": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
33
52
|
},
|
|
34
53
|
"dependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"
|
|
37
|
-
|
|
54
|
+
"@swc/core": "^1.15.11",
|
|
55
|
+
"csstype": "^3.2.3"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^20.11.0",
|
|
59
|
+
"tsup": "^8.0.0",
|
|
60
|
+
"tsx": "^4.21.0",
|
|
61
|
+
"typescript": "^5.3.0",
|
|
62
|
+
"vite": "^7.0.0"
|
|
38
63
|
}
|
|
39
64
|
}
|
package/src/virtual.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual module type declaration for catom CSS
|
|
3
|
+
* Add this to your tsconfig.json "include" or reference it in a .d.ts file
|
|
4
|
+
*/
|
|
5
|
+
declare module 'virtual:catom.css' {
|
|
6
|
+
// This is a CSS module with no exports
|
|
7
|
+
const content: string
|
|
8
|
+
export default content
|
|
9
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Hydrophobefireman
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# Catom
|
|
2
|
-
|
|
3
|
-
## A 0 runtime css in ~~js~~ css tool
|
|
4
|
-
|
|
5
|
-
### Stage: Pre Alpha ([Caveats](#caveats))
|
|
6
|
-
|
|
7
|
-
Catom allows you to write CSS in your javascript/typescript file and creates highly optimized CSS out of it.
|
|
8
|
-
|
|
9
|
-
Each rule creates a unique class definition out of it and it gives you 100% freedom about where to put your generated css bundle.
|
|
10
|
-
|
|
11
|
-
Your javascript code has 0 references to any styles and all that's left is are the compiled hashed clasnames as a string.
|
|
12
|
-
|
|
13
|
-
It's framework agnostic as it emits pure CSS and leaves out just the classnames
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
somewhere in our App.js
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
import { css } from "catom";
|
|
21
|
-
|
|
22
|
-
const styledButton = css({
|
|
23
|
-
color: "#ff0000",
|
|
24
|
-
borderRadius: "5px",
|
|
25
|
-
padding: "4px",
|
|
26
|
-
});
|
|
27
|
-
const styledDiv = css({ color: "blue", borderRadius: "5px", padding: "4px" });
|
|
28
|
-
|
|
29
|
-
function App() {
|
|
30
|
-
return (
|
|
31
|
-
<div className={styledDiv}>
|
|
32
|
-
<button className={styledButton}>Hi</button>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**Css generated:**
|
|
39
|
-
|
|
40
|
-
```css
|
|
41
|
-
._6da32 {
|
|
42
|
-
color: #ff0000;
|
|
43
|
-
}
|
|
44
|
-
.quva1q {
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
}
|
|
47
|
-
._2rlxtj {
|
|
48
|
-
padding: 4px;
|
|
49
|
-
}
|
|
50
|
-
._14ksm7b {
|
|
51
|
-
color: blue;
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**App.js:**
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
const styledButton = "_6da32 quva1q _2rlxtj";
|
|
59
|
-
const styledDiv = "_14ksm7b quva1q _2rlxtj";
|
|
60
|
-
....
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
As we had only 4 unique rules, catom generated only 4 classes.
|
|
64
|
-
|
|
65
|
-
Catom also supports media queries and pseudo properties passing them in an object
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
const mediaQuery = css({
|
|
69
|
-
media: { "only screen and (max-width:500px)": { color: "red" } },
|
|
70
|
-
});
|
|
71
|
-
const pseudoQuery = css({ pseudo: { ":hover": { color: "green" } } });
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
# Installation and Usage
|
|
75
|
-
|
|
76
|
-
Install using npm or yarn
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
npm i catom -D
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
In your babel config:
|
|
83
|
-
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"plugins": [
|
|
87
|
-
"catom/babelPlugin"
|
|
88
|
-
`....
|
|
89
|
-
]
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
As catom doesn't really interact with your build tool at all, it's your job to inject the generated style.
|
|
95
|
-
|
|
96
|
-
Here's an example of how you can use it with HTMLWebpackPlugin.
|
|
97
|
-
|
|
98
|
-
`webpack.confg.js`
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
const { emitCSS } = require("catom/css");
|
|
102
|
-
// ...
|
|
103
|
-
module.exports = {
|
|
104
|
-
plugins: [
|
|
105
|
-
new HtmlWebpackPlugin({
|
|
106
|
-
templateParameters: async function templateParametersGenerator(
|
|
107
|
-
compilation,
|
|
108
|
-
files,
|
|
109
|
-
tags,
|
|
110
|
-
options
|
|
111
|
-
) {
|
|
112
|
-
return {
|
|
113
|
-
compilation,
|
|
114
|
-
webpackConfig: compilation.options,
|
|
115
|
-
htmlWebpackPlugin: {
|
|
116
|
-
tags,
|
|
117
|
-
files,
|
|
118
|
-
options: Object.assign(options, {
|
|
119
|
-
emitCSS,
|
|
120
|
-
}),
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
}),
|
|
125
|
-
],
|
|
126
|
-
};
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
and then inject it using a template parameter.
|
|
130
|
-
|
|
131
|
-
```html
|
|
132
|
-
<head>
|
|
133
|
-
<style>
|
|
134
|
-
<%= htmlWebpackPlugin.options.emitCSS() %>
|
|
135
|
-
</style>
|
|
136
|
-
</head>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
it also allows you to use postCSS plugins by importing the `transformCSS` and/or `autoPrefixCSS` functions
|
|
140
|
-
|
|
141
|
-
# 0 Runtime
|
|
142
|
-
|
|
143
|
-
Catom ships with 0 js code in your bundle. In fact the first thing the babel transform does, is to [remove](https://github.com/Hydrophobefireman/catom/blob/378fefef245c399a550edb60916c051f87f671ea/babelPlugin.ts#L17) all imports of the `css` function from your code.
|
|
144
|
-
|
|
145
|
-
# Caveats
|
|
146
|
-
|
|
147
|
-
- It's just something I threw together because I wanted it for a project
|
|
148
|
-
- Not even close to production ready
|
|
149
|
-
- Since it works with AST, it does not allow you to use variable in the values (In work)
|
|
150
|
-
- No support for keyframes as of now
|
package/babelPlugin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./dist/babelPlugin";
|
package/babelPlugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./dist/babelPlugin");
|
package/css.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./dist/css";
|
package/css.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./dist/css");
|
package/dist/babelPlugin.d.ts
DELETED
package/dist/babelPlugin.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const template = __importStar(require("@babel/template"));
|
|
27
|
-
const astObject_1 = require("./plugin/astObject");
|
|
28
|
-
function handleExpression(path, expression, removeName) {
|
|
29
|
-
if (!expression)
|
|
30
|
-
return;
|
|
31
|
-
if (expression.type === "CallExpression") {
|
|
32
|
-
return commonInject(path, expression, {
|
|
33
|
-
name: removeName,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function catomBabelPlugin() {
|
|
38
|
-
let removeName = "css";
|
|
39
|
-
return {
|
|
40
|
-
visitor: {
|
|
41
|
-
CallExpression(path) {
|
|
42
|
-
return handleExpression(path, path.node, removeName);
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
exports.default = catomBabelPlugin;
|
|
48
|
-
function commonInject(path, right, options) {
|
|
49
|
-
const callee = right.callee;
|
|
50
|
-
if (callee && callee.type === "Identifier") {
|
|
51
|
-
if (callee.name === options.name) {
|
|
52
|
-
const arg0 = right.arguments[0];
|
|
53
|
-
return injectDependency(path, arg0);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function injectDependency(path, arg0) {
|
|
58
|
-
if (arg0.type === "ObjectExpression") {
|
|
59
|
-
let retArray = [];
|
|
60
|
-
(0, astObject_1.parseObjectExpression)(arg0, retArray);
|
|
61
|
-
path.replaceWith(template.statement.ast(JSON.stringify(retArray.join(" "))));
|
|
62
|
-
}
|
|
63
|
-
}
|
package/dist/css.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { emitCSS } from "./plugin/cssTransform";
|
|
3
|
-
export default function transformCSS(css?: string, ...plugins: any): Promise<Buffer>;
|
|
4
|
-
export declare function autoPrefixCSS(css?: string, ...plugins: any): Promise<Buffer>;
|
|
5
|
-
export { emitCSS };
|
package/dist/css.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitCSS = exports.autoPrefixCSS = void 0;
|
|
4
|
-
const lightningcss_1 = require("lightningcss");
|
|
5
|
-
const cssTransform_1 = require("./plugin/cssTransform");
|
|
6
|
-
Object.defineProperty(exports, "emitCSS", { enumerable: true, get: function () { return cssTransform_1.emitCSS; } });
|
|
7
|
-
async function transformCSS(css, ...plugins) {
|
|
8
|
-
css = css || (0, cssTransform_1.emitCSS)();
|
|
9
|
-
const { code } = (0, lightningcss_1.transform)({
|
|
10
|
-
code: Buffer.from(css),
|
|
11
|
-
drafts: { customMedia: true, nesting: true },
|
|
12
|
-
minify: true,
|
|
13
|
-
filename: "style.css",
|
|
14
|
-
sourceMap: false,
|
|
15
|
-
// browserslist hardcoded
|
|
16
|
-
// probably change or manually audit
|
|
17
|
-
targets: {
|
|
18
|
-
android: 6422528,
|
|
19
|
-
chrome: 6488064,
|
|
20
|
-
edge: 6488064,
|
|
21
|
-
firefox: 6356992,
|
|
22
|
-
ie: 720896,
|
|
23
|
-
ios_saf: 983552,
|
|
24
|
-
opera: 5439488,
|
|
25
|
-
safari: 983552,
|
|
26
|
-
samsung: 1048576,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return code;
|
|
30
|
-
}
|
|
31
|
-
exports.default = transformCSS;
|
|
32
|
-
function autoPrefixCSS(css, ...plugins) {
|
|
33
|
-
return transformCSS(css);
|
|
34
|
-
}
|
|
35
|
-
exports.autoPrefixCSS = autoPrefixCSS;
|
package/dist/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Properties } from "csstype";
|
|
2
|
-
declare const config: {
|
|
3
|
-
allowRuntime: boolean;
|
|
4
|
-
};
|
|
5
|
-
declare function css(_styleRule: Properties & {
|
|
6
|
-
media?: {
|
|
7
|
-
[query: string]: Properties;
|
|
8
|
-
};
|
|
9
|
-
pseudo?: {
|
|
10
|
-
[psuedoProp: string]: Properties;
|
|
11
|
-
};
|
|
12
|
-
}): string;
|
|
13
|
-
export { css, config };
|
package/dist/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.config = exports.css = void 0;
|
|
4
|
-
const config = { allowRuntime: false };
|
|
5
|
-
exports.config = config;
|
|
6
|
-
function css(_styleRule) {
|
|
7
|
-
if (!config.allowRuntime)
|
|
8
|
-
throw new Error("Catom is in compile mode! Are you sure you ran your webpack transform correctly?");
|
|
9
|
-
return "";
|
|
10
|
-
}
|
|
11
|
-
exports.css = css;
|
package/dist/plugin/astObject.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseObjectExpression = void 0;
|
|
4
|
-
const cssTransform_1 = require("./cssTransform");
|
|
5
|
-
function parseObjectExpression(object, retArray, hashable) {
|
|
6
|
-
return object.properties.forEach((p) => handleProperties(p, retArray, hashable));
|
|
7
|
-
}
|
|
8
|
-
exports.parseObjectExpression = parseObjectExpression;
|
|
9
|
-
function handleSpread(spread, retArray, hashable) {
|
|
10
|
-
const argument = spread.argument;
|
|
11
|
-
if (argument.type === "ObjectExpression") {
|
|
12
|
-
return parseObjectExpression(argument, retArray, hashable);
|
|
13
|
-
}
|
|
14
|
-
throw Error(`Cannot parse ${spread.type}. Catom compiler only accepts compile time constant values`);
|
|
15
|
-
}
|
|
16
|
-
function handleProperties(propertyOrSpread, retArray, hashable) {
|
|
17
|
-
if (propertyOrSpread.type === "SpreadElement") {
|
|
18
|
-
return handleSpread(propertyOrSpread, retArray, hashable);
|
|
19
|
-
}
|
|
20
|
-
let { key, value } = propertyOrSpread;
|
|
21
|
-
if (value.type === "TSAsExpression")
|
|
22
|
-
value = value.expression;
|
|
23
|
-
let keyName;
|
|
24
|
-
if (key.type === "StringLiteral") {
|
|
25
|
-
keyName = key.value;
|
|
26
|
-
}
|
|
27
|
-
else if (key.type === "Identifier") {
|
|
28
|
-
keyName = key.name;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return throwErr();
|
|
32
|
-
}
|
|
33
|
-
const isMedia = keyName === "media";
|
|
34
|
-
const isPseudo = keyName === "pseudo";
|
|
35
|
-
const canAcceptObjectLiteralInValue = isMedia || isPseudo;
|
|
36
|
-
if (value.type === "StringLiteral" || value.type === "NumericLiteral") {
|
|
37
|
-
if (canAcceptObjectLiteralInValue)
|
|
38
|
-
throwErr("Need an object literal for media query or pseudo selector");
|
|
39
|
-
return retArray.push((0, cssTransform_1.createValueHash)(keyName, value.value, hashable));
|
|
40
|
-
}
|
|
41
|
-
if (canAcceptObjectLiteralInValue && value.type === "ObjectExpression") {
|
|
42
|
-
return value.properties.forEach((prop) => handleMediaOrPseudoProperties(prop, retArray, isMedia, isPseudo));
|
|
43
|
-
}
|
|
44
|
-
throwErr();
|
|
45
|
-
}
|
|
46
|
-
function handleMediaOrPseudoProperties(property, retArray, isMedia, isPseudo) {
|
|
47
|
-
if (property.type === "ObjectProperty") {
|
|
48
|
-
const { key, value } = property;
|
|
49
|
-
let keyName;
|
|
50
|
-
if (key.type === "StringLiteral")
|
|
51
|
-
keyName = key.value;
|
|
52
|
-
else if (key.type === "Identifier")
|
|
53
|
-
keyName = key.name;
|
|
54
|
-
if (value.type === "ObjectExpression") {
|
|
55
|
-
return parseObjectExpression(value, retArray, (isMedia && { media: keyName }) || (isPseudo && { pseudo: keyName }));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
throwErr();
|
|
59
|
-
}
|
|
60
|
-
function throwErr(err) {
|
|
61
|
-
throw TypeError(err || "Catom only accepts literals and compile time constant values");
|
|
62
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { Program } from "estree";
|
|
2
|
-
export declare type PropMap = Map<string, CSSProps>;
|
|
3
|
-
export interface AtomicCSSOptions {
|
|
4
|
-
transpileFunctionName: "css";
|
|
5
|
-
}
|
|
6
|
-
export interface CSSProps {
|
|
7
|
-
class: string;
|
|
8
|
-
cssRule: string;
|
|
9
|
-
}
|
|
10
|
-
export interface Hashable {
|
|
11
|
-
media?: string;
|
|
12
|
-
pseudo?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const NAME = "AtomicCssWebpackPlugin";
|
|
15
|
-
export declare const defaultOptions: AtomicCSSOptions;
|
|
16
|
-
export declare const KEBAB_CASE_REGEXP: RegExp;
|
|
17
|
-
export declare const PREFIX_WITH_UNDERSCORE: string[];
|
package/dist/plugin/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PREFIX_WITH_UNDERSCORE = exports.KEBAB_CASE_REGEXP = exports.defaultOptions = exports.NAME = void 0;
|
|
4
|
-
exports.NAME = "AtomicCssWebpackPlugin";
|
|
5
|
-
exports.defaultOptions = {
|
|
6
|
-
transpileFunctionName: "css",
|
|
7
|
-
};
|
|
8
|
-
exports.KEBAB_CASE_REGEXP = /([a-z0-9]|(?=[A-Z]))([A-Z])/g;
|
|
9
|
-
exports.PREFIX_WITH_UNDERSCORE = "1234567890-".split("");
|