stylpp 1.0.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/README.md +475 -0
- package/bin/stylpp.js +2 -0
- package/dist/stylpp.esm.js +726 -0
- package/dist/stylpp.esm.js.map +1 -0
- package/dist/stylpp.js +734 -0
- package/dist/stylpp.js.map +1 -0
- package/dist/stylpp.min.js +2 -0
- package/dist/stylpp.min.js.map +1 -0
- package/package.json +59 -0
- package/src/cli/index.js +400 -0
- package/src/compiler/animation.js +346 -0
- package/src/compiler/effects.js +344 -0
- package/src/compiler/generator.js +157 -0
- package/src/compiler/index.js +119 -0
- package/src/compiler/parser.js +210 -0
- package/src/compiler/physics.js +286 -0
- package/src/compiler/transformer.js +228 -0
- package/src/runtime/advanced.js +293 -0
- package/src/runtime/browser.js +239 -0
- package/stylpp-1.0.0.tgz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylpp.js","sources":["../src/compiler/parser.js","../src/compiler/transformer.js","../src/compiler/generator.js","../src/compiler/index.js"],"sourcesContent":["/**\r\n * STYL++ Parser\r\n * Converts STYL++ source code into an Abstract Syntax Tree (AST)\r\n * Handles semicolon-based indentation and property-value parsing\r\n */\r\n\r\nclass StylppParser {\r\n constructor(options = {}) {\r\n this.options = options;\r\n this.errors = [];\r\n }\r\n\r\n /**\r\n * Parse STYL++ code and return AST\r\n * @param {string} code - STYL++ source code\r\n * @returns {Object} AST\r\n */\r\n parse(code) {\r\n const lines = code.split('\\n');\r\n const ast = {\r\n type: 'stylesheet',\r\n rules: [],\r\n variables: {}\r\n };\r\n\r\n let currentIndent = 0;\r\n const stack = [];\r\n\r\n for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {\r\n const line = lines[lineNumber];\r\n const trimmed = line.trim();\r\n\r\n // Skip empty lines\r\n if (!trimmed) continue;\r\n\r\n // Skip comment lines (start with ; at beginning)\r\n if (trimmed.startsWith(';') && !trimmed.match(/^\\s*;\\s*\\w+/)) continue;\r\n\r\n // Count leading semicolons for indentation\r\n const indentMatch = line.match(/^(;*)/);\r\n const indentLevel = indentMatch ? indentMatch[0].length : 0;\r\n const content = line.substring(indentLevel).trim();\r\n\r\n // Skip empty content\r\n if (!content) continue;\r\n\r\n // Handle variables section\r\n if (content === 'variables;' || content === 'variables') {\r\n const variablesSection = this.parseVariablesSection(lines, lineNumber + 1);\r\n ast.variables = variablesSection.variables;\r\n lineNumber = variablesSection.endLine;\r\n continue;\r\n }\r\n\r\n // Handle property-value pairs\r\n if (content.endsWith(';') && indentLevel > 0) {\r\n const propValue = this.parseProperty(content);\r\n if (propValue && stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n if (!parent.declarations) parent.declarations = [];\r\n parent.declarations.push(propValue);\r\n }\r\n continue;\r\n }\r\n\r\n // Handle rules/selectors\r\n const selector = content.replace(/;$/, '');\r\n const newRule = {\r\n type: 'rule',\r\n selector: selector,\r\n declarations: [],\r\n rules: []\r\n };\r\n\r\n // Manage indentation stack\r\n if (indentLevel > currentIndent) {\r\n // Nested rule\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n } else if (indentLevel < currentIndent) {\r\n // Pop stack until we reach the right level\r\n const popCount = (currentIndent - indentLevel);\r\n for (let i = 0; i < popCount; i++) {\r\n stack.pop();\r\n }\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n } else {\r\n // Same level\r\n if (stack.length > 0) {\r\n stack.pop();\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n }\r\n\r\n currentIndent = indentLevel;\r\n }\r\n\r\n return ast;\r\n }\r\n\r\n /**\r\n * Parse variables section\r\n * @param {Array} lines - All code lines\r\n * @param {number} startLine - Starting line number\r\n * @returns {Object} Variables and end line\r\n */\r\n parseVariablesSection(lines, startLine) {\r\n const variables = {};\r\n let endLine = startLine;\r\n\r\n for (let i = startLine; i < lines.length; i++) {\r\n const line = lines[i];\r\n const trimmed = line.trim();\r\n\r\n if (!trimmed || trimmed.startsWith(';')) continue;\r\n\r\n // Check if we've exited the variables section\r\n const leadingSemicolons = line.match(/^(;*)/)[0].length;\r\n if (leadingSemicolons === 0 && trimmed && !trimmed.match(/^\\w+\\s+/)) {\r\n break;\r\n }\r\n\r\n const parts = trimmed.split(/\\s+/);\r\n if (parts.length >= 2) {\r\n const name = parts[0];\r\n const value = parts.slice(1).join(' ').replace(/;$/, '');\r\n variables[name] = value;\r\n endLine = i;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n return { variables, endLine };\r\n }\r\n\r\n /**\r\n * Parse a property-value pair\r\n * @param {string} content - Property-value string (e.g., \"background white;\")\r\n * @returns {Object} Declaration object\r\n */\r\n parseProperty(content) {\r\n // Remove trailing semicolon\r\n const cleaned = content.replace(/;$/, '').trim();\r\n \r\n // Split by first space to separate property from value\r\n const spaceIndex = cleaned.indexOf(' ');\r\n if (spaceIndex === -1) return null;\r\n\r\n const property = cleaned.substring(0, spaceIndex);\r\n const value = cleaned.substring(spaceIndex + 1);\r\n\r\n return {\r\n type: 'declaration',\r\n property: property,\r\n value: value\r\n };\r\n }\r\n\r\n /**\r\n * Parse for loop syntax: for i in 1 to 5;\r\n * @param {string} content - For loop declaration\r\n * @returns {Object} Loop object or null\r\n */\r\n parseForLoop(content) {\r\n const match = content.match(/for\\s+(\\w+)\\s+in\\s+([\\d\\w]+)\\s+to\\s+([\\d\\w]+)/);\r\n if (!match) return null;\r\n\r\n return {\r\n type: 'for-loop',\r\n variable: match[1],\r\n from: parseInt(match[2]),\r\n to: parseInt(match[3])\r\n };\r\n }\r\n\r\n /**\r\n * Parse if/conditional syntax: if condition;\r\n * @param {string} content - If statement\r\n * @returns {Object} Conditional object or null\r\n */\r\n parseConditional(content) {\r\n const match = content.match(/@(\\w+)/);\r\n if (!match) return null;\r\n\r\n return {\r\n type: 'conditional',\r\n condition: match[1]\r\n };\r\n }\r\n}\r\n\r\nmodule.exports = StylppParser;\r\n","/**\r\n * STYL++ Transformer\r\n * Transforms the AST to handle:\r\n * - Variable resolution\r\n * - Math operations\r\n * - Loop expansion\r\n * - Conditional processing\r\n * - Function expansion\r\n */\r\n\r\nclass StylppTransformer {\r\n constructor(options = {}) {\r\n this.options = options;\r\n this.variables = {};\r\n this.errors = [];\r\n }\r\n\r\n /**\r\n * Transform AST\r\n * @param {Object} ast - Original AST\r\n * @returns {Object} Transformed AST\r\n */\r\n transform(ast) {\r\n // First pass: collect all variables\r\n this.variables = { ...ast.variables };\r\n\r\n // Second pass: transform rules\r\n const transformedRules = ast.rules.map(rule => this.transformRule(rule));\r\n\r\n return {\r\n type: 'stylesheet',\r\n rules: transformedRules,\r\n variables: this.variables\r\n };\r\n }\r\n\r\n /**\r\n * Transform a single rule\r\n * @param {Object} rule - Rule object\r\n * @returns {Object} Transformed rule\r\n */\r\n transformRule(rule) {\r\n const transformed = {\r\n type: rule.type,\r\n selector: rule.selector,\r\n declarations: [],\r\n rules: []\r\n };\r\n\r\n // Transform declarations\r\n if (rule.declarations) {\r\n rule.declarations.forEach(decl => {\r\n const transformedDecl = this.transformDeclaration(decl);\r\n if (Array.isArray(transformedDecl)) {\r\n transformed.declarations.push(...transformedDecl);\r\n } else {\r\n transformed.declarations.push(transformedDecl);\r\n }\r\n });\r\n }\r\n\r\n // Transform nested rules\r\n if (rule.rules) {\r\n rule.rules.forEach(nestedRule => {\r\n const transformed = this.transformRule(nestedRule);\r\n if (Array.isArray(transformed)) {\r\n transformed.forEach(r => rule.rules.push(r));\r\n } else {\r\n rule.rules.push(transformed);\r\n }\r\n });\r\n transformed.rules = rule.rules;\r\n }\r\n\r\n return transformed;\r\n }\r\n\r\n /**\r\n * Transform a declaration (property-value pair)\r\n * @param {Object} decl - Declaration object\r\n * @returns {Object|Array} Transformed declaration(s)\r\n */\r\n transformDeclaration(decl) {\r\n let value = decl.value;\r\n\r\n // Resolve variables\r\n value = this.resolveVariables(value);\r\n\r\n // Handle math operations\r\n if (this.hasMathOperation(value)) {\r\n value = this.processMathOperation(value);\r\n }\r\n\r\n // Handle responsive values\r\n if (this.isResponsiveValue(value)) {\r\n value = this.processResponsiveValue(value);\r\n }\r\n\r\n // Handle color operations\r\n if (this.isColorOperation(value)) {\r\n value = this.processColorOperation(value);\r\n }\r\n\r\n return {\r\n type: 'declaration',\r\n property: decl.property,\r\n value: value\r\n };\r\n }\r\n\r\n /**\r\n * Resolve variables in value (e.g., var(primary) -> #007bff)\r\n * @param {string} value - Value string\r\n * @returns {string} Resolved value\r\n */\r\n resolveVariables(value) {\r\n return value.replace(/var\\((\\w+)\\)/g, (match, varName) => {\r\n return this.variables[varName] || match;\r\n });\r\n }\r\n\r\n /**\r\n * Check if value contains math operations\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n hasMathOperation(value) {\r\n return /[\\+\\-\\*\\/\\^]/.test(value) && /\\d/.test(value);\r\n }\r\n\r\n /**\r\n * Process math operations: 100% - 40px -> calc(100% - 40px)\r\n * @param {string} value - Value with math\r\n * @returns {string} CSS calc expression\r\n */\r\n processMathOperation(value) {\r\n // Already has calc? Return as-is\r\n if (value.includes('calc(')) return value;\r\n\r\n // Check for mathematical expressions\r\n const mathPattern = /^[\\d\\w\\s\\+\\-\\*\\/\\%\\(\\)\\.]+$/;\r\n if (mathPattern.test(value.replace(/px|em|rem|%|vh|vw|ex|ch|deg|s|ms/g, ''))) {\r\n return `calc(${value})`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Check if value is a responsive function\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n isResponsiveValue(value) {\r\n return /responsive\\(|fluid\\(/.test(value);\r\n }\r\n\r\n /**\r\n * Process responsive value: responsive(300px, 800px) -> clamp(...)\r\n * @param {string} value - Value string\r\n * @returns {string} Clamp expression\r\n */\r\n processResponsiveValue(value) {\r\n // responsive(300px, 800px) -> clamp(300px, 50vw + 100px, 800px)\r\n const match = value.match(/responsive\\(([^,]+),\\s*([^)]+)\\)/);\r\n if (match) {\r\n const min = match[1].trim();\r\n const max = match[2].trim();\r\n const mid = `${(parseInt(min) + parseInt(max)) / 4}px`;\r\n return `clamp(${min}, 50vw + ${mid}, ${max})`;\r\n }\r\n\r\n // fluid(300px, 800px)\r\n const fluidMatch = value.match(/fluid\\(([^,]+),\\s*([^)]+)\\)/);\r\n if (fluidMatch) {\r\n const min = fluidMatch[1].trim();\r\n const max = fluidMatch[2].trim();\r\n return `clamp(${min}, 5vw, ${max})`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Check if value uses color operations\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n isColorOperation(value) {\r\n return /darken\\(|lighten\\(|mix\\(/.test(value);\r\n }\r\n\r\n /**\r\n * Process color operations\r\n * @param {string} value - Value string\r\n * @returns {string} Processed color\r\n */\r\n processColorOperation(value) {\r\n // darken(#007bff, 20%) - simplified implementation\r\n const darkenMatch = value.match(/darken\\(([^,]+),\\s*(\\d+)%\\)/);\r\n if (darkenMatch) {\r\n const color = darkenMatch[1].trim();\r\n const amount = parseInt(darkenMatch[2]);\r\n // Simple approximation - in real implementation would use color library\r\n return `${color}`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Expand for loops\r\n * @param {Object} rule - Rule with for loop\r\n * @param {number} iterations - Number of iterations\r\n * @returns {Array} Expanded rules\r\n */\r\n expandForLoop(rule, iterations) {\r\n const expanded = [];\r\n for (let i = 0; i < iterations; i++) {\r\n const expandedRule = { ...rule };\r\n expandedRule.selector = rule.selector.replace(/{i}/g, i);\r\n expanded.push(expandedRule);\r\n }\r\n return expanded;\r\n }\r\n}\r\n\r\nmodule.exports = StylppTransformer;\r\n","/**\r\n * STYL++ CSS Generator\r\n * Converts the transformed AST into valid CSS output\r\n * Supports minification, source maps, and vendor prefixes\r\n */\r\n\r\nclass StylppGenerator {\r\n constructor(options = {}) {\r\n this.options = {\r\n minify: false,\r\n sourceMap: false,\r\n vendorPrefix: true,\r\n ...options\r\n };\r\n this.css = '';\r\n this.sourceMap = { version: 3, sources: [], mappings: '' };\r\n }\r\n\r\n /**\r\n * Generate CSS from AST\r\n * @param {Object} ast - Transformed AST\r\n * @returns {string} CSS code\r\n */\r\n generate(ast) {\r\n this.css = '';\r\n this.generateRules(ast.rules, 0);\r\n\r\n if (this.options.minify) {\r\n this.css = this.minifyCSS(this.css);\r\n }\r\n\r\n return this.css;\r\n }\r\n\r\n /**\r\n * Generate rules recursively\r\n * @param {Array} rules - Rules array\r\n * @param {number} indent - Indentation level\r\n */\r\n generateRules(rules, indent = 0) {\r\n const indentStr = this.options.minify ? '' : ' '.repeat(indent);\r\n const newline = this.options.minify ? '' : '\\n';\r\n\r\n rules.forEach(rule => {\r\n if (rule.type === 'rule') {\r\n this.css += `${indentStr}${rule.selector} {${newline}`;\r\n\r\n // Add declarations\r\n if (rule.declarations && rule.declarations.length > 0) {\r\n rule.declarations.forEach(decl => {\r\n const property = this.normalizeProperty(decl.property);\r\n const value = this.normalizeValue(decl.value);\r\n this.css += `${indentStr} ${property}: ${value};${newline}`;\r\n\r\n // Add vendor prefixes if needed\r\n if (this.options.vendorPrefix) {\r\n const prefixed = this.getVendorPrefixes(property, value);\r\n prefixed.forEach(p => {\r\n this.css += `${indentStr} ${p.property}: ${p.value};${newline}`;\r\n });\r\n }\r\n });\r\n }\r\n\r\n // Add nested rules\r\n if (rule.rules && rule.rules.length > 0) {\r\n this.generateRules(rule.rules, indent + 1);\r\n }\r\n\r\n this.css += `${indentStr}}${newline}`;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Normalize CSS property names (handle hyphenation)\r\n * @param {string} property - Property name\r\n * @returns {string} Normalized property\r\n */\r\n normalizeProperty(property) {\r\n // Convert camelCase to kebab-case\r\n return property.replace(/([A-Z])/g, '-$1').toLowerCase();\r\n }\r\n\r\n /**\r\n * Normalize CSS values\r\n * @param {string} value - Property value\r\n * @returns {string} Normalized value\r\n */\r\n normalizeValue(value) {\r\n // Remove extra whitespace\r\n value = value.replace(/\\s+/g, ' ').trim();\r\n\r\n // Ensure calc() is properly formatted\r\n if (value.includes('calc(')) {\r\n value = value.replace(/calc\\(\\s+/g, 'calc(').replace(/\\s+\\)/g, ')');\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Get vendor prefixes for a property\r\n * @param {string} property - CSS property\r\n * @param {string} value - CSS value\r\n * @returns {Array} Vendor-prefixed versions\r\n */\r\n getVendorPrefixes(property, value) {\r\n const prefixes = [];\r\n const prefixMap = {\r\n 'transform': ['-webkit-transform', '-moz-transform', '-o-transform'],\r\n 'transition': ['-webkit-transition', '-moz-transition', '-o-transition'],\r\n 'box-shadow': ['-webkit-box-shadow'],\r\n 'border-radius': ['-webkit-border-radius'],\r\n 'gradient': ['-webkit-linear-gradient', '-moz-linear-gradient'],\r\n 'appearance': ['-webkit-appearance', '-moz-appearance'],\r\n 'user-select': ['-webkit-user-select', '-moz-user-select', '-ms-user-select']\r\n };\r\n\r\n Object.keys(prefixMap).forEach(key => {\r\n if (property.includes(key)) {\r\n prefixMap[key].forEach(prefixed => {\r\n prefixes.push({ property: prefixed, value: value });\r\n });\r\n }\r\n });\r\n\r\n return prefixes;\r\n }\r\n\r\n /**\r\n * Minify CSS\r\n * @param {string} css - CSS code\r\n * @returns {string} Minified CSS\r\n */\r\n minifyCSS(css) {\r\n return css\r\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\r\n .replace(/\\s+{/g, '{') // Remove spaces before {\r\n .replace(/\\s+}/g, '}') // Remove spaces before }\r\n .replace(/;\\s+/g, ';') // Remove spaces after ;\r\n .replace(/:\\s+/g, ':') // Remove spaces after :\r\n .replace(/,\\s+/g, ',') // Remove spaces after ,\r\n .replace(/\\n/g, '') // Remove newlines\r\n .trim();\r\n }\r\n\r\n /**\r\n * Generate source map\r\n * @returns {Object} Source map object\r\n */\r\n generateSourceMap() {\r\n return this.sourceMap;\r\n }\r\n}\r\n\r\nmodule.exports = StylppGenerator;\r\n","/**\r\n * STYL++ Main Compiler\r\n * Orchestrates parsing, transformation, and code generation\r\n */\r\n\r\nconst StylppParser = require('./parser');\r\nconst StylppTransformer = require('./transformer');\r\nconst StylppGenerator = require('./generator');\r\n\r\nclass StylppCompiler {\r\n constructor(options = {}) {\r\n this.options = {\r\n minify: false,\r\n sourceMap: false,\r\n vendorPrefix: true,\r\n ...options\r\n };\r\n \r\n this.parser = new StylppParser();\r\n this.transformer = new StylppTransformer();\r\n this.generator = new StylppGenerator(this.options);\r\n }\r\n\r\n /**\r\n * Compile STYL++ code to CSS\r\n * @param {string} code - STYL++ source code\r\n * @param {string} filename - Source filename (for error reporting)\r\n * @returns {Object} Compilation result\r\n */\r\n compile(code, filename = 'input.stylpp') {\r\n try {\r\n // Phase 1: Parse\r\n const ast = this.parser.parse(code);\r\n\r\n if (this.parser.errors.length > 0) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: null,\r\n errors: this.parser.errors,\r\n filename\r\n };\r\n }\r\n\r\n // Phase 2: Transform\r\n const transformedAst = this.transformer.transform(ast);\r\n\r\n if (this.transformer.errors.length > 0) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: ast,\r\n transformedAst: null,\r\n errors: this.transformer.errors,\r\n filename\r\n };\r\n }\r\n\r\n // Phase 3: Generate\r\n const css = this.generator.generate(transformedAst);\r\n\r\n // Optional: Generate source map\r\n let sourceMap = null;\r\n if (this.options.sourceMap) {\r\n sourceMap = this.generator.generateSourceMap();\r\n }\r\n\r\n return {\r\n success: true,\r\n css: css,\r\n ast: ast,\r\n transformedAst: transformedAst,\r\n sourceMap: sourceMap,\r\n errors: [],\r\n filename\r\n };\r\n\r\n } catch (error) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: null,\r\n transformedAst: null,\r\n errors: [{\r\n type: 'CompileError',\r\n message: error.message,\r\n stack: error.stack,\r\n filename\r\n }],\r\n filename\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Check if code is valid without compiling\r\n * @param {string} code - STYL++ source code\r\n * @returns {Object} Validation result\r\n */\r\n validate(code) {\r\n try {\r\n const ast = this.parser.parse(code);\r\n return {\r\n valid: true,\r\n errors: []\r\n };\r\n } catch (error) {\r\n return {\r\n valid: false,\r\n errors: [{\r\n message: error.message,\r\n line: error.line\r\n }]\r\n };\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = StylppCompiler;\r\n"],"names":["StylppParser","StylppTransformer","StylppGenerator","require$$0","require$$1","require$$2"],"mappings":";;;;;;;;;;;;;;;;sBAMA,MAAM,YAAY,CAAC;CACnB,EAAE,WAAW,CAAC,OAAO,GAAG,EAAE,EAAE;CAC5B,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;CAC3B,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;CACrB,EAAA,CAAG;AACH;CACA;CACA;CACA;CACA;CACA;CACA,EAAE,KAAK,CAAC,IAAI,EAAE;CACd,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;CACnC,IAAI,MAAM,GAAG,GAAG;CAChB,MAAM,IAAI,EAAE,YAAY;CACxB,MAAM,KAAK,EAAE,EAAE;CACf,MAAM,SAAS,EAAE,EAAE;CACnB,KAAK,CAAC;AACN;CACA,IAAI,IAAI,aAAa,GAAG,CAAC,CAAC;CAC1B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;AACrB;CACA,IAAI,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;CACtE,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;CACrC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,EAAE,KAAK,CAAC,OAAO;CAChC,UAAU,KAAK,EAAE,KAAK,CAAC,KAAK;CAC5B,UAAU,QAAQ;CAClB,SAAS,CAAC;CACV,QAAQ,QAAQ;CAChB,OAAO,CAAC;CACR,IAAA,CAAK;CACL,EAAA,CAAG;AACH;CACA;CACA;CACA;CACA;CACA;CACA,EAAE,QAAQ,CAAC,IAAI,EAAE;CACjB,IAAI,IAAI;CACR,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;CAC1C,MAAM,OAAO;CACb,QAAQ,KAAK,EAAE,IAAI;CACnB,QAAQ,MAAM,EAAE,EAAE;CAClB,OAAO,CAAC;CACR,IAAA,CAAK,CAAC,OAAO,KAAK,EAAE;CACpB,MAAM,OAAO;CACb,QAAQ,KAAK,EAAE,KAAK;CACpB,QAAQ,MAAM,EAAE,CAAC;CACjB,UAAU,OAAO,EAAE,KAAK,CAAC,OAAO;CAChC,UAAU,IAAI,EAAE,KAAK,CAAC,IAAI;CAC1B,SAAS,CAAC;CACV,OAAO,CAAC;CACR,IAAA,CAAK;CACL,EAAA,CAAG;CACH,CAAC;AACD;CACA,IAAA,QAAc,GAAG,cAAc;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).StylppCompiler=r()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r=class{constructor(e={}){this.options=e,this.errors=[]}parse(e){const r=e.split("\n"),s={type:"stylesheet",rules:[],variables:{}};let t=0;const n=[];for(let e=0;e<r.length;e++){const a=r[e],i=a.trim();if(!i)continue;if(i.startsWith(";")&&!i.match(/^\s*;\s*\w+/))continue;const o=a.match(/^(;*)/),l=o?o[0].length:0,c=a.substring(l).trim();if(!c)continue;if("variables;"===c||"variables"===c){const t=this.parseVariablesSection(r,e+1);s.variables=t.variables,e=t.endLine;continue}if(c.endsWith(";")&&l>0){const e=this.parseProperty(c);if(e&&n.length>0){const r=n[n.length-1];r.declarations||(r.declarations=[]),r.declarations.push(e)}continue}const p={type:"rule",selector:c.replace(/;$/,""),declarations:[],rules:[]};if(l>t){if(n.length>0){n[n.length-1].rules.push(p)}n.push(p)}else if(l<t){const e=t-l;for(let r=0;r<e;r++)n.pop();if(n.length>0){n[n.length-1].rules.push(p)}else s.rules.push(p);n.push(p)}else{if(n.length>0)if(n.pop(),n.length>0){n[n.length-1].rules.push(p)}else s.rules.push(p);else s.rules.push(p);n.push(p)}t=l}return s}parseVariablesSection(e,r){const s={};let t=r;for(let n=r;n<e.length;n++){const r=e[n],a=r.trim();if(!a||a.startsWith(";"))continue;if(0===r.match(/^(;*)/)[0].length&&a&&!a.match(/^\w+\s+/))break;const i=a.split(/\s+/);if(!(i.length>=2))break;{const e=i[0],r=i.slice(1).join(" ").replace(/;$/,"");s[e]=r,t=n}}return{variables:s,endLine:t}}parseProperty(e){const r=e.replace(/;$/,"").trim(),s=r.indexOf(" ");if(-1===s)return null;return{type:"declaration",property:r.substring(0,s),value:r.substring(s+1)}}parseForLoop(e){const r=e.match(/for\s+(\w+)\s+in\s+([\d\w]+)\s+to\s+([\d\w]+)/);return r?{type:"for-loop",variable:r[1],from:parseInt(r[2]),to:parseInt(r[3])}:null}parseConditional(e){const r=e.match(/@(\w+)/);return r?{type:"conditional",condition:r[1]}:null}};var s=class{constructor(e={}){this.options=e,this.variables={},this.errors=[]}transform(e){this.variables={...e.variables};return{type:"stylesheet",rules:e.rules.map(e=>this.transformRule(e)),variables:this.variables}}transformRule(e){const r={type:e.type,selector:e.selector,declarations:[],rules:[]};return e.declarations&&e.declarations.forEach(e=>{const s=this.transformDeclaration(e);Array.isArray(s)?r.declarations.push(...s):r.declarations.push(s)}),e.rules&&(e.rules.forEach(r=>{const s=this.transformRule(r);Array.isArray(s)?s.forEach(r=>e.rules.push(r)):e.rules.push(s)}),r.rules=e.rules),r}transformDeclaration(e){let r=e.value;return r=this.resolveVariables(r),this.hasMathOperation(r)&&(r=this.processMathOperation(r)),this.isResponsiveValue(r)&&(r=this.processResponsiveValue(r)),this.isColorOperation(r)&&(r=this.processColorOperation(r)),{type:"declaration",property:e.property,value:r}}resolveVariables(e){return e.replace(/var\((\w+)\)/g,(e,r)=>this.variables[r]||e)}hasMathOperation(e){return/[\+\-\*\/\^]/.test(e)&&/\d/.test(e)}processMathOperation(e){if(e.includes("calc("))return e;return/^[\d\w\s\+\-\*\/\%\(\)\.]+$/.test(e.replace(/px|em|rem|%|vh|vw|ex|ch|deg|s|ms/g,""))?`calc(${e})`:e}isResponsiveValue(e){return/responsive\(|fluid\(/.test(e)}processResponsiveValue(e){const r=e.match(/responsive\(([^,]+),\s*([^)]+)\)/);if(r){const e=r[1].trim(),s=r[2].trim();return`clamp(${e}, 50vw + ${(parseInt(e)+parseInt(s))/4+"px"}, ${s})`}const s=e.match(/fluid\(([^,]+),\s*([^)]+)\)/);if(s){return`clamp(${s[1].trim()}, 5vw, ${s[2].trim()})`}return e}isColorOperation(e){return/darken\(|lighten\(|mix\(/.test(e)}processColorOperation(e){const r=e.match(/darken\(([^,]+),\s*(\d+)%\)/);if(r){const e=r[1].trim();return parseInt(r[2]),`${e}`}return e}expandForLoop(e,r){const s=[];for(let t=0;t<r;t++){const r={...e};r.selector=e.selector.replace(/{i}/g,t),s.push(r)}return s}};const t=r,n=s,a=class{constructor(e={}){this.options={minify:!1,sourceMap:!1,vendorPrefix:!0,...e},this.css="",this.sourceMap={version:3,sources:[],mappings:""}}generate(e){return this.css="",this.generateRules(e.rules,0),this.options.minify&&(this.css=this.minifyCSS(this.css)),this.css}generateRules(e,r=0){const s=this.options.minify?"":" ".repeat(r),t=this.options.minify?"":"\n";e.forEach(e=>{"rule"===e.type&&(this.css+=`${s}${e.selector} {${t}`,e.declarations&&e.declarations.length>0&&e.declarations.forEach(e=>{const r=this.normalizeProperty(e.property),n=this.normalizeValue(e.value);if(this.css+=`${s} ${r}: ${n};${t}`,this.options.vendorPrefix){this.getVendorPrefixes(r,n).forEach(e=>{this.css+=`${s} ${e.property}: ${e.value};${t}`})}}),e.rules&&e.rules.length>0&&this.generateRules(e.rules,r+1),this.css+=`${s}}${t}`)})}normalizeProperty(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}normalizeValue(e){return(e=e.replace(/\s+/g," ").trim()).includes("calc(")&&(e=e.replace(/calc\(\s+/g,"calc(").replace(/\s+\)/g,")")),e}getVendorPrefixes(e,r){const s=[],t={transform:["-webkit-transform","-moz-transform","-o-transform"],transition:["-webkit-transition","-moz-transition","-o-transition"],"box-shadow":["-webkit-box-shadow"],"border-radius":["-webkit-border-radius"],gradient:["-webkit-linear-gradient","-moz-linear-gradient"],appearance:["-webkit-appearance","-moz-appearance"],"user-select":["-webkit-user-select","-moz-user-select","-ms-user-select"]};return Object.keys(t).forEach(n=>{e.includes(n)&&t[n].forEach(e=>{s.push({property:e,value:r})})}),s}minifyCSS(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+{/g,"{").replace(/\s+}/g,"}").replace(/;\s+/g,";").replace(/:\s+/g,":").replace(/,\s+/g,",").replace(/\n/g,"").trim()}generateSourceMap(){return this.sourceMap}};return e(class{constructor(e={}){this.options={minify:!1,sourceMap:!1,vendorPrefix:!0,...e},this.parser=new t,this.transformer=new n,this.generator=new a(this.options)}compile(e,r="input.stylpp"){try{const s=this.parser.parse(e);if(this.parser.errors.length>0)return{success:!1,css:"",ast:null,errors:this.parser.errors,filename:r};const t=this.transformer.transform(s);if(this.transformer.errors.length>0)return{success:!1,css:"",ast:s,transformedAst:null,errors:this.transformer.errors,filename:r};const n=this.generator.generate(t);let a=null;return this.options.sourceMap&&(a=this.generator.generateSourceMap()),{success:!0,css:n,ast:s,transformedAst:t,sourceMap:a,errors:[],filename:r}}catch(e){return{success:!1,css:"",ast:null,transformedAst:null,errors:[{type:"CompileError",message:e.message,stack:e.stack,filename:r}],filename:r}}}validate(e){try{this.parser.parse(e);return{valid:!0,errors:[]}}catch(e){return{valid:!1,errors:[{message:e.message,line:e.line}]}}}})});
|
|
2
|
+
//# sourceMappingURL=stylpp.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylpp.min.js","sources":["../src/compiler/parser.js","../src/compiler/transformer.js","../src/compiler/index.js","../src/compiler/generator.js"],"sourcesContent":["/**\r\n * STYL++ Parser\r\n * Converts STYL++ source code into an Abstract Syntax Tree (AST)\r\n * Handles semicolon-based indentation and property-value parsing\r\n */\r\n\r\nclass StylppParser {\r\n constructor(options = {}) {\r\n this.options = options;\r\n this.errors = [];\r\n }\r\n\r\n /**\r\n * Parse STYL++ code and return AST\r\n * @param {string} code - STYL++ source code\r\n * @returns {Object} AST\r\n */\r\n parse(code) {\r\n const lines = code.split('\\n');\r\n const ast = {\r\n type: 'stylesheet',\r\n rules: [],\r\n variables: {}\r\n };\r\n\r\n let currentIndent = 0;\r\n const stack = [];\r\n\r\n for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {\r\n const line = lines[lineNumber];\r\n const trimmed = line.trim();\r\n\r\n // Skip empty lines\r\n if (!trimmed) continue;\r\n\r\n // Skip comment lines (start with ; at beginning)\r\n if (trimmed.startsWith(';') && !trimmed.match(/^\\s*;\\s*\\w+/)) continue;\r\n\r\n // Count leading semicolons for indentation\r\n const indentMatch = line.match(/^(;*)/);\r\n const indentLevel = indentMatch ? indentMatch[0].length : 0;\r\n const content = line.substring(indentLevel).trim();\r\n\r\n // Skip empty content\r\n if (!content) continue;\r\n\r\n // Handle variables section\r\n if (content === 'variables;' || content === 'variables') {\r\n const variablesSection = this.parseVariablesSection(lines, lineNumber + 1);\r\n ast.variables = variablesSection.variables;\r\n lineNumber = variablesSection.endLine;\r\n continue;\r\n }\r\n\r\n // Handle property-value pairs\r\n if (content.endsWith(';') && indentLevel > 0) {\r\n const propValue = this.parseProperty(content);\r\n if (propValue && stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n if (!parent.declarations) parent.declarations = [];\r\n parent.declarations.push(propValue);\r\n }\r\n continue;\r\n }\r\n\r\n // Handle rules/selectors\r\n const selector = content.replace(/;$/, '');\r\n const newRule = {\r\n type: 'rule',\r\n selector: selector,\r\n declarations: [],\r\n rules: []\r\n };\r\n\r\n // Manage indentation stack\r\n if (indentLevel > currentIndent) {\r\n // Nested rule\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n } else if (indentLevel < currentIndent) {\r\n // Pop stack until we reach the right level\r\n const popCount = (currentIndent - indentLevel);\r\n for (let i = 0; i < popCount; i++) {\r\n stack.pop();\r\n }\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n } else {\r\n // Same level\r\n if (stack.length > 0) {\r\n stack.pop();\r\n if (stack.length > 0) {\r\n const parent = stack[stack.length - 1];\r\n parent.rules.push(newRule);\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n } else {\r\n ast.rules.push(newRule);\r\n }\r\n stack.push(newRule);\r\n }\r\n\r\n currentIndent = indentLevel;\r\n }\r\n\r\n return ast;\r\n }\r\n\r\n /**\r\n * Parse variables section\r\n * @param {Array} lines - All code lines\r\n * @param {number} startLine - Starting line number\r\n * @returns {Object} Variables and end line\r\n */\r\n parseVariablesSection(lines, startLine) {\r\n const variables = {};\r\n let endLine = startLine;\r\n\r\n for (let i = startLine; i < lines.length; i++) {\r\n const line = lines[i];\r\n const trimmed = line.trim();\r\n\r\n if (!trimmed || trimmed.startsWith(';')) continue;\r\n\r\n // Check if we've exited the variables section\r\n const leadingSemicolons = line.match(/^(;*)/)[0].length;\r\n if (leadingSemicolons === 0 && trimmed && !trimmed.match(/^\\w+\\s+/)) {\r\n break;\r\n }\r\n\r\n const parts = trimmed.split(/\\s+/);\r\n if (parts.length >= 2) {\r\n const name = parts[0];\r\n const value = parts.slice(1).join(' ').replace(/;$/, '');\r\n variables[name] = value;\r\n endLine = i;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n return { variables, endLine };\r\n }\r\n\r\n /**\r\n * Parse a property-value pair\r\n * @param {string} content - Property-value string (e.g., \"background white;\")\r\n * @returns {Object} Declaration object\r\n */\r\n parseProperty(content) {\r\n // Remove trailing semicolon\r\n const cleaned = content.replace(/;$/, '').trim();\r\n \r\n // Split by first space to separate property from value\r\n const spaceIndex = cleaned.indexOf(' ');\r\n if (spaceIndex === -1) return null;\r\n\r\n const property = cleaned.substring(0, spaceIndex);\r\n const value = cleaned.substring(spaceIndex + 1);\r\n\r\n return {\r\n type: 'declaration',\r\n property: property,\r\n value: value\r\n };\r\n }\r\n\r\n /**\r\n * Parse for loop syntax: for i in 1 to 5;\r\n * @param {string} content - For loop declaration\r\n * @returns {Object} Loop object or null\r\n */\r\n parseForLoop(content) {\r\n const match = content.match(/for\\s+(\\w+)\\s+in\\s+([\\d\\w]+)\\s+to\\s+([\\d\\w]+)/);\r\n if (!match) return null;\r\n\r\n return {\r\n type: 'for-loop',\r\n variable: match[1],\r\n from: parseInt(match[2]),\r\n to: parseInt(match[3])\r\n };\r\n }\r\n\r\n /**\r\n * Parse if/conditional syntax: if condition;\r\n * @param {string} content - If statement\r\n * @returns {Object} Conditional object or null\r\n */\r\n parseConditional(content) {\r\n const match = content.match(/@(\\w+)/);\r\n if (!match) return null;\r\n\r\n return {\r\n type: 'conditional',\r\n condition: match[1]\r\n };\r\n }\r\n}\r\n\r\nmodule.exports = StylppParser;\r\n","/**\r\n * STYL++ Transformer\r\n * Transforms the AST to handle:\r\n * - Variable resolution\r\n * - Math operations\r\n * - Loop expansion\r\n * - Conditional processing\r\n * - Function expansion\r\n */\r\n\r\nclass StylppTransformer {\r\n constructor(options = {}) {\r\n this.options = options;\r\n this.variables = {};\r\n this.errors = [];\r\n }\r\n\r\n /**\r\n * Transform AST\r\n * @param {Object} ast - Original AST\r\n * @returns {Object} Transformed AST\r\n */\r\n transform(ast) {\r\n // First pass: collect all variables\r\n this.variables = { ...ast.variables };\r\n\r\n // Second pass: transform rules\r\n const transformedRules = ast.rules.map(rule => this.transformRule(rule));\r\n\r\n return {\r\n type: 'stylesheet',\r\n rules: transformedRules,\r\n variables: this.variables\r\n };\r\n }\r\n\r\n /**\r\n * Transform a single rule\r\n * @param {Object} rule - Rule object\r\n * @returns {Object} Transformed rule\r\n */\r\n transformRule(rule) {\r\n const transformed = {\r\n type: rule.type,\r\n selector: rule.selector,\r\n declarations: [],\r\n rules: []\r\n };\r\n\r\n // Transform declarations\r\n if (rule.declarations) {\r\n rule.declarations.forEach(decl => {\r\n const transformedDecl = this.transformDeclaration(decl);\r\n if (Array.isArray(transformedDecl)) {\r\n transformed.declarations.push(...transformedDecl);\r\n } else {\r\n transformed.declarations.push(transformedDecl);\r\n }\r\n });\r\n }\r\n\r\n // Transform nested rules\r\n if (rule.rules) {\r\n rule.rules.forEach(nestedRule => {\r\n const transformed = this.transformRule(nestedRule);\r\n if (Array.isArray(transformed)) {\r\n transformed.forEach(r => rule.rules.push(r));\r\n } else {\r\n rule.rules.push(transformed);\r\n }\r\n });\r\n transformed.rules = rule.rules;\r\n }\r\n\r\n return transformed;\r\n }\r\n\r\n /**\r\n * Transform a declaration (property-value pair)\r\n * @param {Object} decl - Declaration object\r\n * @returns {Object|Array} Transformed declaration(s)\r\n */\r\n transformDeclaration(decl) {\r\n let value = decl.value;\r\n\r\n // Resolve variables\r\n value = this.resolveVariables(value);\r\n\r\n // Handle math operations\r\n if (this.hasMathOperation(value)) {\r\n value = this.processMathOperation(value);\r\n }\r\n\r\n // Handle responsive values\r\n if (this.isResponsiveValue(value)) {\r\n value = this.processResponsiveValue(value);\r\n }\r\n\r\n // Handle color operations\r\n if (this.isColorOperation(value)) {\r\n value = this.processColorOperation(value);\r\n }\r\n\r\n return {\r\n type: 'declaration',\r\n property: decl.property,\r\n value: value\r\n };\r\n }\r\n\r\n /**\r\n * Resolve variables in value (e.g., var(primary) -> #007bff)\r\n * @param {string} value - Value string\r\n * @returns {string} Resolved value\r\n */\r\n resolveVariables(value) {\r\n return value.replace(/var\\((\\w+)\\)/g, (match, varName) => {\r\n return this.variables[varName] || match;\r\n });\r\n }\r\n\r\n /**\r\n * Check if value contains math operations\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n hasMathOperation(value) {\r\n return /[\\+\\-\\*\\/\\^]/.test(value) && /\\d/.test(value);\r\n }\r\n\r\n /**\r\n * Process math operations: 100% - 40px -> calc(100% - 40px)\r\n * @param {string} value - Value with math\r\n * @returns {string} CSS calc expression\r\n */\r\n processMathOperation(value) {\r\n // Already has calc? Return as-is\r\n if (value.includes('calc(')) return value;\r\n\r\n // Check for mathematical expressions\r\n const mathPattern = /^[\\d\\w\\s\\+\\-\\*\\/\\%\\(\\)\\.]+$/;\r\n if (mathPattern.test(value.replace(/px|em|rem|%|vh|vw|ex|ch|deg|s|ms/g, ''))) {\r\n return `calc(${value})`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Check if value is a responsive function\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n isResponsiveValue(value) {\r\n return /responsive\\(|fluid\\(/.test(value);\r\n }\r\n\r\n /**\r\n * Process responsive value: responsive(300px, 800px) -> clamp(...)\r\n * @param {string} value - Value string\r\n * @returns {string} Clamp expression\r\n */\r\n processResponsiveValue(value) {\r\n // responsive(300px, 800px) -> clamp(300px, 50vw + 100px, 800px)\r\n const match = value.match(/responsive\\(([^,]+),\\s*([^)]+)\\)/);\r\n if (match) {\r\n const min = match[1].trim();\r\n const max = match[2].trim();\r\n const mid = `${(parseInt(min) + parseInt(max)) / 4}px`;\r\n return `clamp(${min}, 50vw + ${mid}, ${max})`;\r\n }\r\n\r\n // fluid(300px, 800px)\r\n const fluidMatch = value.match(/fluid\\(([^,]+),\\s*([^)]+)\\)/);\r\n if (fluidMatch) {\r\n const min = fluidMatch[1].trim();\r\n const max = fluidMatch[2].trim();\r\n return `clamp(${min}, 5vw, ${max})`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Check if value uses color operations\r\n * @param {string} value - Value string\r\n * @returns {boolean}\r\n */\r\n isColorOperation(value) {\r\n return /darken\\(|lighten\\(|mix\\(/.test(value);\r\n }\r\n\r\n /**\r\n * Process color operations\r\n * @param {string} value - Value string\r\n * @returns {string} Processed color\r\n */\r\n processColorOperation(value) {\r\n // darken(#007bff, 20%) - simplified implementation\r\n const darkenMatch = value.match(/darken\\(([^,]+),\\s*(\\d+)%\\)/);\r\n if (darkenMatch) {\r\n const color = darkenMatch[1].trim();\r\n const amount = parseInt(darkenMatch[2]);\r\n // Simple approximation - in real implementation would use color library\r\n return `${color}`;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Expand for loops\r\n * @param {Object} rule - Rule with for loop\r\n * @param {number} iterations - Number of iterations\r\n * @returns {Array} Expanded rules\r\n */\r\n expandForLoop(rule, iterations) {\r\n const expanded = [];\r\n for (let i = 0; i < iterations; i++) {\r\n const expandedRule = { ...rule };\r\n expandedRule.selector = rule.selector.replace(/{i}/g, i);\r\n expanded.push(expandedRule);\r\n }\r\n return expanded;\r\n }\r\n}\r\n\r\nmodule.exports = StylppTransformer;\r\n","/**\r\n * STYL++ Main Compiler\r\n * Orchestrates parsing, transformation, and code generation\r\n */\r\n\r\nconst StylppParser = require('./parser');\r\nconst StylppTransformer = require('./transformer');\r\nconst StylppGenerator = require('./generator');\r\n\r\nclass StylppCompiler {\r\n constructor(options = {}) {\r\n this.options = {\r\n minify: false,\r\n sourceMap: false,\r\n vendorPrefix: true,\r\n ...options\r\n };\r\n \r\n this.parser = new StylppParser();\r\n this.transformer = new StylppTransformer();\r\n this.generator = new StylppGenerator(this.options);\r\n }\r\n\r\n /**\r\n * Compile STYL++ code to CSS\r\n * @param {string} code - STYL++ source code\r\n * @param {string} filename - Source filename (for error reporting)\r\n * @returns {Object} Compilation result\r\n */\r\n compile(code, filename = 'input.stylpp') {\r\n try {\r\n // Phase 1: Parse\r\n const ast = this.parser.parse(code);\r\n\r\n if (this.parser.errors.length > 0) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: null,\r\n errors: this.parser.errors,\r\n filename\r\n };\r\n }\r\n\r\n // Phase 2: Transform\r\n const transformedAst = this.transformer.transform(ast);\r\n\r\n if (this.transformer.errors.length > 0) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: ast,\r\n transformedAst: null,\r\n errors: this.transformer.errors,\r\n filename\r\n };\r\n }\r\n\r\n // Phase 3: Generate\r\n const css = this.generator.generate(transformedAst);\r\n\r\n // Optional: Generate source map\r\n let sourceMap = null;\r\n if (this.options.sourceMap) {\r\n sourceMap = this.generator.generateSourceMap();\r\n }\r\n\r\n return {\r\n success: true,\r\n css: css,\r\n ast: ast,\r\n transformedAst: transformedAst,\r\n sourceMap: sourceMap,\r\n errors: [],\r\n filename\r\n };\r\n\r\n } catch (error) {\r\n return {\r\n success: false,\r\n css: '',\r\n ast: null,\r\n transformedAst: null,\r\n errors: [{\r\n type: 'CompileError',\r\n message: error.message,\r\n stack: error.stack,\r\n filename\r\n }],\r\n filename\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Check if code is valid without compiling\r\n * @param {string} code - STYL++ source code\r\n * @returns {Object} Validation result\r\n */\r\n validate(code) {\r\n try {\r\n const ast = this.parser.parse(code);\r\n return {\r\n valid: true,\r\n errors: []\r\n };\r\n } catch (error) {\r\n return {\r\n valid: false,\r\n errors: [{\r\n message: error.message,\r\n line: error.line\r\n }]\r\n };\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = StylppCompiler;\r\n","/**\r\n * STYL++ CSS Generator\r\n * Converts the transformed AST into valid CSS output\r\n * Supports minification, source maps, and vendor prefixes\r\n */\r\n\r\nclass StylppGenerator {\r\n constructor(options = {}) {\r\n this.options = {\r\n minify: false,\r\n sourceMap: false,\r\n vendorPrefix: true,\r\n ...options\r\n };\r\n this.css = '';\r\n this.sourceMap = { version: 3, sources: [], mappings: '' };\r\n }\r\n\r\n /**\r\n * Generate CSS from AST\r\n * @param {Object} ast - Transformed AST\r\n * @returns {string} CSS code\r\n */\r\n generate(ast) {\r\n this.css = '';\r\n this.generateRules(ast.rules, 0);\r\n\r\n if (this.options.minify) {\r\n this.css = this.minifyCSS(this.css);\r\n }\r\n\r\n return this.css;\r\n }\r\n\r\n /**\r\n * Generate rules recursively\r\n * @param {Array} rules - Rules array\r\n * @param {number} indent - Indentation level\r\n */\r\n generateRules(rules, indent = 0) {\r\n const indentStr = this.options.minify ? '' : ' '.repeat(indent);\r\n const newline = this.options.minify ? '' : '\\n';\r\n\r\n rules.forEach(rule => {\r\n if (rule.type === 'rule') {\r\n this.css += `${indentStr}${rule.selector} {${newline}`;\r\n\r\n // Add declarations\r\n if (rule.declarations && rule.declarations.length > 0) {\r\n rule.declarations.forEach(decl => {\r\n const property = this.normalizeProperty(decl.property);\r\n const value = this.normalizeValue(decl.value);\r\n this.css += `${indentStr} ${property}: ${value};${newline}`;\r\n\r\n // Add vendor prefixes if needed\r\n if (this.options.vendorPrefix) {\r\n const prefixed = this.getVendorPrefixes(property, value);\r\n prefixed.forEach(p => {\r\n this.css += `${indentStr} ${p.property}: ${p.value};${newline}`;\r\n });\r\n }\r\n });\r\n }\r\n\r\n // Add nested rules\r\n if (rule.rules && rule.rules.length > 0) {\r\n this.generateRules(rule.rules, indent + 1);\r\n }\r\n\r\n this.css += `${indentStr}}${newline}`;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Normalize CSS property names (handle hyphenation)\r\n * @param {string} property - Property name\r\n * @returns {string} Normalized property\r\n */\r\n normalizeProperty(property) {\r\n // Convert camelCase to kebab-case\r\n return property.replace(/([A-Z])/g, '-$1').toLowerCase();\r\n }\r\n\r\n /**\r\n * Normalize CSS values\r\n * @param {string} value - Property value\r\n * @returns {string} Normalized value\r\n */\r\n normalizeValue(value) {\r\n // Remove extra whitespace\r\n value = value.replace(/\\s+/g, ' ').trim();\r\n\r\n // Ensure calc() is properly formatted\r\n if (value.includes('calc(')) {\r\n value = value.replace(/calc\\(\\s+/g, 'calc(').replace(/\\s+\\)/g, ')');\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /**\r\n * Get vendor prefixes for a property\r\n * @param {string} property - CSS property\r\n * @param {string} value - CSS value\r\n * @returns {Array} Vendor-prefixed versions\r\n */\r\n getVendorPrefixes(property, value) {\r\n const prefixes = [];\r\n const prefixMap = {\r\n 'transform': ['-webkit-transform', '-moz-transform', '-o-transform'],\r\n 'transition': ['-webkit-transition', '-moz-transition', '-o-transition'],\r\n 'box-shadow': ['-webkit-box-shadow'],\r\n 'border-radius': ['-webkit-border-radius'],\r\n 'gradient': ['-webkit-linear-gradient', '-moz-linear-gradient'],\r\n 'appearance': ['-webkit-appearance', '-moz-appearance'],\r\n 'user-select': ['-webkit-user-select', '-moz-user-select', '-ms-user-select']\r\n };\r\n\r\n Object.keys(prefixMap).forEach(key => {\r\n if (property.includes(key)) {\r\n prefixMap[key].forEach(prefixed => {\r\n prefixes.push({ property: prefixed, value: value });\r\n });\r\n }\r\n });\r\n\r\n return prefixes;\r\n }\r\n\r\n /**\r\n * Minify CSS\r\n * @param {string} css - CSS code\r\n * @returns {string} Minified CSS\r\n */\r\n minifyCSS(css) {\r\n return css\r\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Remove comments\r\n .replace(/\\s+{/g, '{') // Remove spaces before {\r\n .replace(/\\s+}/g, '}') // Remove spaces before }\r\n .replace(/;\\s+/g, ';') // Remove spaces after ;\r\n .replace(/:\\s+/g, ':') // Remove spaces after :\r\n .replace(/,\\s+/g, ',') // Remove spaces after ,\r\n .replace(/\\n/g, '') // Remove newlines\r\n .trim();\r\n }\r\n\r\n /**\r\n * Generate source map\r\n * @returns {Object} Source map object\r\n */\r\n generateSourceMap() {\r\n return this.sourceMap;\r\n }\r\n}\r\n\r\nmodule.exports = StylppGenerator;\r\n"],"names":["parser","constructor","options","this","errors","parse","code","lines","split","ast","type","rules","variables","currentIndent","stack","lineNumber","length","line","trimmed","trim","startsWith","match","indentMatch","indentLevel","content","substring","variablesSection","parseVariablesSection","endLine","endsWith","propValue","parseProperty","parent","declarations","push","newRule","selector","replace","popCount","i","pop","startLine","parts","name","value","slice","join","cleaned","spaceIndex","indexOf","property","parseForLoop","variable","from","parseInt","to","parseConditional","condition","transformer","transform","map","rule","transformRule","transformed","forEach","decl","transformedDecl","transformDeclaration","Array","isArray","nestedRule","r","resolveVariables","hasMathOperation","processMathOperation","isResponsiveValue","processResponsiveValue","isColorOperation","processColorOperation","varName","test","includes","min","max","fluidMatch","darkenMatch","color","expandForLoop","iterations","expanded","expandedRule","StylppParser","require$$0","StylppTransformer","require$$1","StylppGenerator","minify","sourceMap","vendorPrefix","css","version","sources","mappings","generate","generateRules","minifyCSS","indent","indentStr","repeat","newline","normalizeProperty","normalizeValue","getVendorPrefixes","p","toLowerCase","prefixes","prefixMap","transition","gradient","appearance","Object","keys","key","prefixed","generateSourceMap","generator","compile","filename","success","transformedAst","error","message","validate","valid"],"mappings":"kVAiNA,IAAAA,EA3MA,MACE,WAAAC,CAAYC,EAAU,IACpBC,KAAKD,QAAUA,EACfC,KAAKC,OAAS,EAClB,CAOE,KAAAC,CAAMC,GACJ,MAAMC,EAAQD,EAAKE,MAAM,MACnBC,EAAM,CACVC,KAAM,aACNC,MAAO,GACPC,UAAW,CAAA,GAGb,IAAIC,EAAgB,EACpB,MAAMC,EAAQ,GAEd,IAAK,IAAIC,EAAa,EAAGA,EAAaR,EAAMS,OAAQD,IAAc,CAChE,MAAME,EAAOV,EAAMQ,GACbG,EAAUD,EAAKE,OAGrB,IAAKD,EAAS,SAGd,GAAIA,EAAQE,WAAW,OAASF,EAAQG,MAAM,eAAgB,SAG9D,MAAMC,EAAcL,EAAKI,MAAM,SACzBE,EAAcD,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EAAiB9H,KAAKuD,YAAYC,UAAUlD,GAElD,GAAIN,KAAKuD,YAAYtD,OAAOY,OAAS,EACnC,MAAO,CACLgH,SAAS,EACT7B,IAAK,GACL1F,IAAKA,EACLwH,eAAgB,KAChB7H,OAAQD,KAAKuD,YAAYtD,OACzB2H,YAKJ,MAAM5B,EAAMhG,KAAK0H,UAAUtB,SAAS0B,GAGpC,IAAIhC,EAAY,KAKhB,OAJI9F,KAAKD,QAAQ+F,YACfA,EAAY9F,KAAK0H,UAAUD,qBAGtB,CACLI,SAAS,EACT7B,IAAKA,EACL1F,IAAKA,EACLwH,eAAgBA,EAChBhC,UAAWA,EACX7F,OAAQ,GACR2H,WAGR,CAAM,MAAOG,GACP,MAAO,CACLF,SAAS,EACT7B,IAAK,GACL1F,IAAK,KACLwH,eAAgB,KAChB7H,OAAQ,CAAC,CACPM,KAAM,eACNyH,QAASD,EAAMC,QACfrH,MAAOoH,EAAMpH,MACbiH,aAEFA,WAER,CACA,CAOE,QAAAK,CAAS9H,GACP,IACcH,KAAKH,OAAOK,MAAMC,GAC9B,MAAO,CACL+H,OAAO,EACPjI,OAAQ,GAEhB,CAAM,MAAO8H,GACP,MAAO,CACLG,OAAO,EACPjI,OAAQ,CAAC,CACP+H,QAASD,EAAMC,QACflH,KAAMiH,EAAMjH,OAGtB,CACA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "stylpp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "STYL++ - A revolutionary styling language with semicolon-based syntax",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"browser": "dist/stylpp.min.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"stylpp": "./bin/stylpp.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rollup -c rollup.config.js",
|
|
14
|
+
"build:watch": "rollup -c rollup.config.js --watch",
|
|
15
|
+
"build:prod": "npm run build -- --environment NODE_ENV:production",
|
|
16
|
+
"test": "node tests/advanced.test.js",
|
|
17
|
+
"test:all": "node tests/run.js && node tests/advanced.test.js",
|
|
18
|
+
"test:compiler": "node tests/run.js",
|
|
19
|
+
"test:advanced": "node tests/advanced.test.js",
|
|
20
|
+
"lint": "eslint src/ --fix",
|
|
21
|
+
"format": "prettier --write src/ --tab-width 2",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"dev": "npm run build:watch",
|
|
24
|
+
"serve": "node ./src/cli/index.js serve",
|
|
25
|
+
"cli": "node ./bin/stylpp.js",
|
|
26
|
+
"start": "npm run build && npm run serve"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"css",
|
|
30
|
+
"styling",
|
|
31
|
+
"preprocessor",
|
|
32
|
+
"stylesheet",
|
|
33
|
+
"stylpp",
|
|
34
|
+
"semicolon"
|
|
35
|
+
],
|
|
36
|
+
"author": "Francis Jusu",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/stylpp/stylpp"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/stylpp/stylpp/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/stylpp/stylpp",
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
48
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
49
|
+
"rollup": "^4.0.0",
|
|
50
|
+
"rollup-plugin-terser": "^7.0.0",
|
|
51
|
+
"eslint": "^8.0.0",
|
|
52
|
+
"prettier": "^3.0.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"chokidar": "^3.5.0",
|
|
56
|
+
"express": "^4.18.0",
|
|
57
|
+
"ws": "^8.13.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/cli/index.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* STYL++ Command Line Interface
|
|
5
|
+
* Provides commands for compiling, watching, and serving STYL++ files
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const StylppCompiler = require('../compiler/index.js');
|
|
11
|
+
const chokidar = require('chokidar');
|
|
12
|
+
const express = require('express');
|
|
13
|
+
const WebSocket = require('ws');
|
|
14
|
+
|
|
15
|
+
class StylppCLI {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.compiler = new StylppCompiler({
|
|
18
|
+
sourceMap: true,
|
|
19
|
+
vendorPrefix: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Main CLI entry point
|
|
25
|
+
* @param {Array} args - Command line arguments
|
|
26
|
+
*/
|
|
27
|
+
async run(args) {
|
|
28
|
+
if (args.length === 0) {
|
|
29
|
+
this.showHelp();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const command = args[0];
|
|
34
|
+
const params = args.slice(1);
|
|
35
|
+
|
|
36
|
+
switch (command) {
|
|
37
|
+
case 'compile':
|
|
38
|
+
await this.compileCommand(params);
|
|
39
|
+
break;
|
|
40
|
+
case 'watch':
|
|
41
|
+
await this.watchCommand(params);
|
|
42
|
+
break;
|
|
43
|
+
case 'serve':
|
|
44
|
+
await this.serveCommand(params);
|
|
45
|
+
break;
|
|
46
|
+
case 'lint':
|
|
47
|
+
await this.lintCommand(params);
|
|
48
|
+
break;
|
|
49
|
+
case 'format':
|
|
50
|
+
await this.formatCommand(params);
|
|
51
|
+
break;
|
|
52
|
+
case '--version':
|
|
53
|
+
case '-v':
|
|
54
|
+
this.showVersion();
|
|
55
|
+
break;
|
|
56
|
+
case '--help':
|
|
57
|
+
case '-h':
|
|
58
|
+
this.showHelp();
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
console.error(`Unknown command: ${command}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Compile command: stylpp compile input.stylpp output.css
|
|
68
|
+
*/
|
|
69
|
+
async compileCommand(params) {
|
|
70
|
+
if (params.length < 1) {
|
|
71
|
+
console.error('Usage: stylpp compile <input> [output]');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const inputFile = params[0];
|
|
76
|
+
let outputFile = params[1] || inputFile.replace('.stylpp', '.css');
|
|
77
|
+
|
|
78
|
+
if (!fs.existsSync(inputFile)) {
|
|
79
|
+
console.error(`Error: File not found: ${inputFile}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const code = fs.readFileSync(inputFile, 'utf-8');
|
|
85
|
+
const result = this.compiler.compile(code, inputFile);
|
|
86
|
+
|
|
87
|
+
if (result.success) {
|
|
88
|
+
fs.writeFileSync(outputFile, result.css);
|
|
89
|
+
console.log(`✓ Compiled ${inputFile} → ${outputFile}`);
|
|
90
|
+
|
|
91
|
+
if (result.sourceMap) {
|
|
92
|
+
const mapFile = outputFile + '.map';
|
|
93
|
+
fs.writeFileSync(mapFile, JSON.stringify(result.sourceMap));
|
|
94
|
+
console.log(`✓ Generated source map: ${mapFile}`);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
console.error('Compilation failed:');
|
|
98
|
+
result.errors.forEach(error => {
|
|
99
|
+
console.error(` ${error.message}`);
|
|
100
|
+
});
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(`Error: ${error.message}`);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Watch command: stylpp watch src/ --output dist/
|
|
111
|
+
*/
|
|
112
|
+
async watchCommand(params) {
|
|
113
|
+
if (params.length < 1) {
|
|
114
|
+
console.error('Usage: stylpp watch <input-dir> [output-dir]');
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const inputDir = params[0];
|
|
119
|
+
const outputDir = params[1] || 'dist';
|
|
120
|
+
|
|
121
|
+
if (!fs.existsSync(inputDir)) {
|
|
122
|
+
console.error(`Error: Directory not found: ${inputDir}`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!fs.existsSync(outputDir)) {
|
|
127
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log(`Watching ${inputDir}...`);
|
|
131
|
+
|
|
132
|
+
const watcher = chokidar.watch(`${inputDir}/**/*.stylpp`);
|
|
133
|
+
|
|
134
|
+
watcher.on('add', async (filePath) => {
|
|
135
|
+
await this.processFile(filePath, inputDir, outputDir);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
watcher.on('change', async (filePath) => {
|
|
139
|
+
await this.processFile(filePath, inputDir, outputDir);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
watcher.on('unlink', (filePath) => {
|
|
143
|
+
const relative = path.relative(inputDir, filePath);
|
|
144
|
+
const outputFile = path.join(outputDir, relative.replace('.stylpp', '.css'));
|
|
145
|
+
if (fs.existsSync(outputFile)) {
|
|
146
|
+
fs.unlinkSync(outputFile);
|
|
147
|
+
console.log(`✓ Removed ${outputFile}`);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Process a single file
|
|
154
|
+
*/
|
|
155
|
+
async processFile(filePath, inputDir, outputDir) {
|
|
156
|
+
try {
|
|
157
|
+
const code = fs.readFileSync(filePath, 'utf-8');
|
|
158
|
+
const result = this.compiler.compile(code, filePath);
|
|
159
|
+
|
|
160
|
+
if (result.success) {
|
|
161
|
+
const relative = path.relative(inputDir, filePath);
|
|
162
|
+
const outputFile = path.join(outputDir, relative.replace('.stylpp', '.css'));
|
|
163
|
+
const dir = path.dirname(outputFile);
|
|
164
|
+
|
|
165
|
+
if (!fs.existsSync(dir)) {
|
|
166
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fs.writeFileSync(outputFile, result.css);
|
|
170
|
+
console.log(`✓ ${relative}`);
|
|
171
|
+
} else {
|
|
172
|
+
console.error(`✗ ${path.relative(inputDir, filePath)}`);
|
|
173
|
+
result.errors.forEach(error => {
|
|
174
|
+
console.error(` ${error.message}`);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(`Error processing ${filePath}: ${error.message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Serve command: stylpp serve --port 3000
|
|
184
|
+
*/
|
|
185
|
+
async serveCommand(params) {
|
|
186
|
+
let port = 3000;
|
|
187
|
+
let dir = '.';
|
|
188
|
+
|
|
189
|
+
for (let i = 0; i < params.length; i++) {
|
|
190
|
+
if (params[i] === '--port' && i + 1 < params.length) {
|
|
191
|
+
port = parseInt(params[i + 1]);
|
|
192
|
+
i++;
|
|
193
|
+
} else if (params[i] === '--dir' && i + 1 < params.length) {
|
|
194
|
+
dir = params[i + 1];
|
|
195
|
+
i++;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const app = express();
|
|
200
|
+
const wss = new WebSocket.Server({ noServer: true });
|
|
201
|
+
|
|
202
|
+
app.use(express.static(dir));
|
|
203
|
+
|
|
204
|
+
// Middleware to serve .stylpp as CSS
|
|
205
|
+
app.use((req, res, next) => {
|
|
206
|
+
if (req.url.endsWith('.stylpp')) {
|
|
207
|
+
const filePath = path.join(dir, req.url);
|
|
208
|
+
if (fs.existsSync(filePath)) {
|
|
209
|
+
try {
|
|
210
|
+
const code = fs.readFileSync(filePath, 'utf-8');
|
|
211
|
+
const result = this.compiler.compile(code, req.url);
|
|
212
|
+
if (result.success) {
|
|
213
|
+
res.type('text/css').send(result.css);
|
|
214
|
+
} else {
|
|
215
|
+
res.status(400).send(result.errors[0].message);
|
|
216
|
+
}
|
|
217
|
+
} catch (error) {
|
|
218
|
+
res.status(500).send(error.message);
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
res.status(404).send('Not found');
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
next();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const server = app.listen(port, () => {
|
|
229
|
+
console.log(`STYL++ dev server running at http://localhost:${port}`);
|
|
230
|
+
console.log(`Watching for changes...`);
|
|
231
|
+
|
|
232
|
+
// Watch for file changes
|
|
233
|
+
if (fs.existsSync('src')) {
|
|
234
|
+
const watcher = chokidar.watch('src/**/*.stylpp');
|
|
235
|
+
watcher.on('change', (filePath) => {
|
|
236
|
+
wss.clients.forEach(client => {
|
|
237
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
238
|
+
try {
|
|
239
|
+
const code = fs.readFileSync(filePath, 'utf-8');
|
|
240
|
+
client.send(JSON.stringify({
|
|
241
|
+
type: 'stylpp-change',
|
|
242
|
+
id: filePath,
|
|
243
|
+
code: code
|
|
244
|
+
}));
|
|
245
|
+
} catch (error) {
|
|
246
|
+
console.error(`Error reading ${filePath}: ${error.message}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
server.on('upgrade', (request, socket, head) => {
|
|
255
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
256
|
+
wss.emit('connection', ws, request);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Lint command: stylpp lint *.stylpp
|
|
263
|
+
*/
|
|
264
|
+
async lintCommand(params) {
|
|
265
|
+
if (params.length === 0) {
|
|
266
|
+
console.error('Usage: stylpp lint <file-pattern>');
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const pattern = params[0];
|
|
271
|
+
const glob = require('glob');
|
|
272
|
+
|
|
273
|
+
glob(pattern, async (err, files) => {
|
|
274
|
+
if (err) {
|
|
275
|
+
console.error(err);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let errorCount = 0;
|
|
280
|
+
|
|
281
|
+
for (const file of files) {
|
|
282
|
+
const code = fs.readFileSync(file, 'utf-8');
|
|
283
|
+
const result = this.compiler.validate(code);
|
|
284
|
+
|
|
285
|
+
if (!result.valid) {
|
|
286
|
+
console.error(`✗ ${file}`);
|
|
287
|
+
result.errors.forEach(error => {
|
|
288
|
+
console.error(` ${error.message}`);
|
|
289
|
+
errorCount++;
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
console.log(`✓ ${file}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (errorCount > 0) {
|
|
297
|
+
console.error(`\n${errorCount} error(s) found`);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Format command: stylpp format *.stylpp
|
|
305
|
+
*/
|
|
306
|
+
async formatCommand(params) {
|
|
307
|
+
if (params.length === 0) {
|
|
308
|
+
console.error('Usage: stylpp format <file-pattern>');
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const pattern = params[0];
|
|
313
|
+
const glob = require('glob');
|
|
314
|
+
|
|
315
|
+
glob(pattern, (err, files) => {
|
|
316
|
+
if (err) {
|
|
317
|
+
console.error(err);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
files.forEach(file => {
|
|
322
|
+
const code = fs.readFileSync(file, 'utf-8');
|
|
323
|
+
const formatted = this.formatCode(code);
|
|
324
|
+
fs.writeFileSync(file, formatted);
|
|
325
|
+
console.log(`✓ Formatted ${file}`);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Format STYL++ code
|
|
332
|
+
*/
|
|
333
|
+
formatCode(code) {
|
|
334
|
+
const lines = code.split('\n');
|
|
335
|
+
const formatted = [];
|
|
336
|
+
let indentLevel = 0;
|
|
337
|
+
|
|
338
|
+
lines.forEach((line) => {
|
|
339
|
+
const trimmed = line.trim();
|
|
340
|
+
|
|
341
|
+
if (!trimmed) {
|
|
342
|
+
formatted.push('');
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const leadingSemicolons = line.match(/^(;*)/)[0].length;
|
|
347
|
+
const indent = ';'.repeat(leadingSemicolons);
|
|
348
|
+
|
|
349
|
+
formatted.push(indent + trimmed);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
return formatted.join('\n');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Show help message
|
|
357
|
+
*/
|
|
358
|
+
showHelp() {
|
|
359
|
+
console.log(`
|
|
360
|
+
STYL++ - A revolutionary styling language
|
|
361
|
+
|
|
362
|
+
Usage:
|
|
363
|
+
stylpp <command> [options]
|
|
364
|
+
|
|
365
|
+
Commands:
|
|
366
|
+
compile <input> [output] Compile STYL++ to CSS
|
|
367
|
+
watch <input> [output] Watch and compile files
|
|
368
|
+
serve [--port 3000] Start development server
|
|
369
|
+
lint <pattern> Check files for errors
|
|
370
|
+
format <pattern> Format STYL++ files
|
|
371
|
+
|
|
372
|
+
Options:
|
|
373
|
+
--help, -h Show this help message
|
|
374
|
+
--version, -v Show version
|
|
375
|
+
|
|
376
|
+
Examples:
|
|
377
|
+
stylpp compile style.stylpp style.css
|
|
378
|
+
stylpp watch src/ --output dist/
|
|
379
|
+
stylpp serve --port 8000
|
|
380
|
+
stylpp lint *.stylpp
|
|
381
|
+
stylpp format *.stylpp
|
|
382
|
+
`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Show version
|
|
387
|
+
*/
|
|
388
|
+
showVersion() {
|
|
389
|
+
const pkg = require('../../package.json');
|
|
390
|
+
console.log(`STYL++ v${pkg.version}`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Run CLI
|
|
395
|
+
if (require.main === module) {
|
|
396
|
+
const cli = new StylppCLI();
|
|
397
|
+
cli.run(process.argv.slice(2));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
module.exports = StylppCLI;
|