@yannosay/sinth 1.12.5 → 3.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.
@@ -82,7 +82,6 @@ function preprocessSinthStyle(raw) {
82
82
  if (trimmed.startsWith("--") && !trimmed.startsWith("--[")) {
83
83
  continue;
84
84
  }
85
- // Standard comments pass through
86
85
  if (trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*")) {
87
86
  result.push(line);
88
87
  continue;
@@ -163,38 +162,38 @@ function convertCSSProps(css) {
163
162
  }
164
163
  function processStyleBlock(block, hash, params = new Map()) {
165
164
  let raw = block.raw;
166
- // 1. interpolate {param} placeholders
167
165
  if (params.size > 0)
168
- raw = (0, utils_1.interpolateAttr)(raw, params);
169
- // 2. sinth style preprocessing
170
- raw = preprocessSinthStyle(raw);
171
- // 3. warn if & in plain CSS
172
- if (block.lang === "css" && raw.includes("&")) {
166
+ raw = (0, utils_1.interpolateAttr)(raw, params); // interpolate {param} placeholders
167
+ // this allows dynamic values in styles
168
+ raw = preprocessSinthStyle(raw); // sinth style preprocessing
169
+ if (block.lang === "css" && raw.includes("&")) { // warn if & in plain CSS
173
170
  types_1.SinthWarning.emit(`'&' (CSS nesting) found in style block. Nested selectors require a modern browser or lang="scss".`, block.loc);
174
171
  }
175
- // 4. camelCase → kebab-case
176
172
  let css = convertCSSProps(raw);
177
- // 5. SCSS compilation
173
+ // SCSS compilation
178
174
  if (block.lang === "scss") {
175
+ let sass;
179
176
  try {
180
177
  // eslint-disable-next-line @typescript-eslint/no-require-imports
181
- const sass = require("sass");
178
+ sass = require("sass");
179
+ }
180
+ catch {
181
+ throw new types_1.SinthError(`style lang="scss" requires the 'sass' package to be installed.\n` +
182
+ `Run: npm install sass`, block.loc);
183
+ }
184
+ try {
182
185
  css = sass.compileString(css).css;
183
186
  }
184
187
  catch (e) {
185
188
  const err = e;
186
- if (err.code === "MODULE_NOT_FOUND" || err.message?.includes("Cannot find module")) {
187
- throw new types_1.SinthError("SCSS requires the 'sass' package. Install with: npm install sass");
188
- }
189
189
  throw new types_1.SinthError(`SCSS compilation failed: ${err.message ?? String(e)}`);
190
190
  }
191
191
  }
192
- // 6. if target component given, wrap content in its CSS selector
193
192
  if (block.target) {
194
193
  const selector = sinthCompToSelector(block.target);
195
194
  css = `${selector} {\n${css}\n}`;
196
195
  }
197
- // 7. scope (except it's global)
196
+ // scope (except it is global)
198
197
  if (!block.global)
199
198
  css = scopeCSS(css, hash);
200
199
  return css;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "1.12.5",
3
+ "version": "3.0.0",
4
4
  "description": "A declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
@@ -38,15 +38,15 @@
38
38
  "build": "tsc",
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
- "dependencies": {
42
- "sass": "^1.70.0"
43
- },
44
41
  "devDependencies": {
45
- "@types/node": "^20.19.41",
46
- "typescript": "^5.3.0",
47
- "ts-node": "^10.9.0"
42
+ "@types/node": "^25.9.3",
43
+ "ts-node": "^10.9.0",
44
+ "typescript": "^5.3.0"
48
45
  },
49
46
  "engines": {
50
47
  "node": ">=18.0.0"
48
+ },
49
+ "dependencies": {
50
+ "sass": "^1.101.0"
51
51
  }
52
- }
52
+ }