@salty-css/core 0.1.0-alpha.18 → 0.1.0-alpha.19

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/bin/main.cjs CHANGED
@@ -230,7 +230,7 @@ const getFramework = (name) => {
230
230
  return frameworksByName[name];
231
231
  };
232
232
  const templateLoaders = {
233
- "salty.config.ts": () => Promise.resolve().then(() => require("../salty.config-cqavVm2t.cjs")),
233
+ "salty.config.ts": () => Promise.resolve().then(() => require("../salty.config-DogY_sSQ.cjs")),
234
234
  "saltygen/index.css": () => Promise.resolve().then(() => require("../index-ByR0nfaf.cjs")),
235
235
  "react/styled-file.ts": () => Promise.resolve().then(() => require("../styled-file-CPd_rTW2.cjs")),
236
236
  "react/vanilla-file.ts": () => Promise.resolve().then(() => require("../vanilla-file-r0fp2q_m.cjs")),
package/bin/main.js CHANGED
@@ -227,7 +227,7 @@ const getFramework = (name) => {
227
227
  return frameworksByName[name];
228
228
  };
229
229
  const templateLoaders = {
230
- "salty.config.ts": () => import("../salty.config-DjosWdPw.js"),
230
+ "salty.config.ts": () => import("../salty.config-GV37Q-D2.js"),
231
231
  "saltygen/index.css": () => import("../index-DKz1QXqs.js"),
232
232
  "react/styled-file.ts": () => import("../styled-file-Cda3EeR6.js"),
233
233
  "react/vanilla-file.ts": () => import("../vanilla-file-1kOqbCIM.js"),
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { p as parseAndJoinStyles } from "./parse-styles-D4No4G35.js";
4
+ import { p as parseAndJoinStyles } from "./parse-styles-g4NPgqhh.js";
5
5
  import { d as dashCase } from "./dash-case-DblXvymC.js";
6
6
  import { t as toHash } from "./to-hash-DAN2LcHK.js";
7
7
  class StylesGenerator {
@@ -2,7 +2,7 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const parseStyles = require("./parse-styles-BD9M4FTQ.cjs");
5
+ const parseStyles = require("./parse-styles-DWQ4UQCp.cjs");
6
6
  const dashCase = require("./dash-case-DIwKaYgE.cjs");
7
7
  const toHash = require("./to-hash-C05Y906F.cjs");
8
8
  class StylesGenerator {
@@ -13,7 +13,7 @@ const compiler_helpers = require("./helpers.cjs");
13
13
  const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
14
14
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
15
15
  const toHash = require("../to-hash-C05Y906F.cjs");
16
- const parseStyles = require("../parse-styles-BD9M4FTQ.cjs");
16
+ const parseStyles = require("../parse-styles-DWQ4UQCp.cjs");
17
17
  const css_merge = require("../css/merge.cjs");
18
18
  const parsers_index = require("../parsers/index.cjs");
19
19
  const compiler_getFiles = require("./get-files.cjs");
@@ -11,7 +11,7 @@ import { isSaltyFile, resolveExportValue, getCorePackageRoot, saltyFileExtension
11
11
  import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
12
12
  import { d as dashCase } from "../dash-case-DblXvymC.js";
13
13
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
14
- import { p as parseAndJoinStyles, b as parseVariableTokens } from "../parse-styles-D4No4G35.js";
14
+ import { p as parseAndJoinStyles, b as parseVariableTokens } from "../parse-styles-g4NPgqhh.js";
15
15
  import { mergeObjects, mergeFactories } from "../css/merge.js";
16
16
  import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
17
17
  import { getPackageJson } from "./get-files.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BD9M4FTQ.cjs");
3
+ const parseStyles = require("../parse-styles-DWQ4UQCp.cjs");
4
4
  const toHash = require("../to-hash-C05Y906F.cjs");
5
5
  const cache_resolveDynamicConfigCache = require("../cache/resolve-dynamic-config-cache.cjs");
6
6
  const getDynamicStylesClassName = (styles) => {
@@ -1,4 +1,4 @@
1
- import { a as parseStyles } from "../parse-styles-D4No4G35.js";
1
+ import { a as parseStyles } from "../parse-styles-g4NPgqhh.js";
2
2
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
3
3
  import { resolveDynamicConfigCache } from "../cache/resolve-dynamic-config-cache.js";
4
4
  const getDynamicStylesClassName = (styles) => {
package/css/keyframes.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BD9M4FTQ.cjs");
3
+ const parseStyles = require("../parse-styles-DWQ4UQCp.cjs");
4
4
  const toHash = require("../to-hash-C05Y906F.cjs");
5
5
  const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
6
6
  const modifyKeyframes = async (params = {}) => {
package/css/keyframes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as parseAndJoinStyles } from "../parse-styles-D4No4G35.js";
1
+ import { p as parseAndJoinStyles } from "../parse-styles-g4NPgqhh.js";
2
2
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
3
3
  const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
4
4
  const modifyKeyframes = async (params = {}) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-0oGsYErm.cjs");
3
+ const classNameGenerator = require("../class-name-generator-CYgwnxnZ.cjs");
4
4
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
5
5
  class StyledGenerator extends classNameGenerator.StylesGenerator {
6
6
  constructor(tagName, _params) {
@@ -1,5 +1,5 @@
1
- import { S as StylesGenerator } from "../class-name-generator-D6ytQ7rP.js";
2
- import { C } from "../class-name-generator-D6ytQ7rP.js";
1
+ import { S as StylesGenerator } from "../class-name-generator-BKMSRP7N.js";
2
+ import { C } from "../class-name-generator-BKMSRP7N.js";
3
3
  import { d as dashCase } from "../dash-case-DblXvymC.js";
4
4
  class StyledGenerator extends StylesGenerator {
5
5
  constructor(tagName, _params) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-0oGsYErm.cjs");
3
+ const classNameGenerator = require("../class-name-generator-CYgwnxnZ.cjs");
4
4
  const classNameInstance = (params) => {
5
5
  const generator = new classNameGenerator.ClassNameGenerator(params);
6
6
  const createClass = (classNameStr) => {
@@ -1,4 +1,4 @@
1
- import { C as ClassNameGenerator } from "../class-name-generator-D6ytQ7rP.js";
1
+ import { C as ClassNameGenerator } from "../class-name-generator-BKMSRP7N.js";
2
2
  const classNameInstance = (params) => {
3
3
  const generator = new ClassNameGenerator(params);
4
4
  const createClass = (classNameStr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.1.0-alpha.18",
3
+ "version": "0.1.0-alpha.19",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -21,7 +21,7 @@ const parseValueTokens = (tokenNames) => (value) => {
21
21
  const hasToken = /\{[^{}]+\}/g.test(value);
22
22
  if (!hasToken) return void 0;
23
23
  const transformed = value.replace(/\{([^{}]+)\}/g, (...args) => {
24
- const variable = dashCase.dashCase(args[1].replaceAll(".", "-"));
24
+ const variable = dashCase.dashCase(args[1].trim().replaceAll(".", "-"));
25
25
  if (tokenNames && !tokenNames.includes(variable)) console.warn(`Token ${variable} might not exist`);
26
26
  if (variable.startsWith("-")) return `-${variable}`;
27
27
  return `var(--${variable})`;
@@ -75,22 +75,44 @@ const addUnit = (key, value, config) => {
75
75
  return `${value}`;
76
76
  };
77
77
  const vendorPrefixes = ["Webkit", "Moz", "ms", "O"];
78
+ const isVendorPrefixed = (key) => {
79
+ return vendorPrefixes.some((prefix) => {
80
+ if (!key.startsWith(prefix)) return false;
81
+ const next = key.charAt(prefix.length);
82
+ return next >= "A" && next <= "Z";
83
+ });
84
+ };
78
85
  const propertyNameCheck = (key) => {
79
86
  if (key.startsWith("-")) return key;
80
- if (vendorPrefixes.some((prefix) => key.startsWith(prefix))) return `-${dashCase.dashCase(key)}`;
87
+ if (isVendorPrefixed(key)) return `-${dashCase.dashCase(key)}`;
81
88
  return dashCase.dashCase(key);
82
89
  };
90
+ const reportParserIssue = (strict, message) => {
91
+ if (strict === true) throw new Error(`[salty-css] ${message}`);
92
+ if (strict === "warn") console.warn(`[salty-css] ${message}`);
93
+ };
94
+ const pseudoTypoRegex = /^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/;
95
+ const templateLiteralLeftoverRegex = /\$\{[^}]+\}/;
96
+ const bareAtRuleRegex = /^@(media|supports|container|layer)\s*$/;
83
97
  const parseStyles = async (styles, currentScope = "", config, omitTemplates = false) => {
84
98
  if (!styles) throw new Error("No styles provided to parseStyles function!");
85
99
  const cssStyles = /* @__PURE__ */ new Set();
86
100
  const entries = Object.entries(styles);
101
+ const strict = config == null ? void 0 : config.strict;
87
102
  const processStyleEntry = async ([key, value]) => {
88
103
  var _a, _b;
89
104
  const _key = key.trim().replace(/^\?+/g, "");
90
105
  const propertyName = propertyNameCheck(_key);
91
106
  const toString = (val, eol = ";") => `${propertyName}:${val}${eol}`;
92
107
  const context = { scope: currentScope, config };
93
- if (typeof value === "function") return processStyleEntry([key, value(context)]);
108
+ if (typeof value === "function") {
109
+ try {
110
+ return await processStyleEntry([key, value(context)]);
111
+ } catch (error) {
112
+ reportParserIssue(strict, `Function value for "${_key}" threw: ${(error == null ? void 0 : error.message) ?? error}`);
113
+ return void 0;
114
+ }
115
+ }
94
116
  if (value instanceof Promise) return processStyleEntry([key, await value]);
95
117
  if ((config == null ? void 0 : config.templates) && ((_a = config.templatePaths) == null ? void 0 : _a[_key])) {
96
118
  try {
@@ -124,6 +146,10 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
124
146
  console.warn(`Template "${_key}" with path of "${value}" was not found in config!`);
125
147
  return void 0;
126
148
  }
149
+ if (Array.isArray(value)) {
150
+ if (value.length === 0) return void 0;
151
+ return processStyleEntry([key, value.join(", ")]);
152
+ }
127
153
  if (typeof value === "object") {
128
154
  if (!value) return void 0;
129
155
  if (value.isColor) return toString(value.toString());
@@ -160,31 +186,62 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
160
186
  return `.${prop}-${val}`;
161
187
  });
162
188
  const scope2 = `${currentScope}:where(${scopes.join(", ")})`;
163
- console.log(`Union variant scope: ${scope2}`);
164
189
  const results2 = await parseStyles(css2, scope2, config);
165
190
  results2.forEach((res) => cssStyles.add(res));
166
191
  }
167
192
  return void 0;
168
193
  }
169
194
  if (_key.startsWith("@")) {
195
+ if (bareAtRuleRegex.test(_key)) reportParserIssue(strict, `At-rule "${_key}" is missing its condition (e.g. "@media (min-width: 600px)").`);
170
196
  const mediaQuery = ((_b = config == null ? void 0 : config.mediaQueries) == null ? void 0 : _b[_key]) || _key;
171
197
  const results2 = await parseAndJoinStyles(value, currentScope, config);
172
198
  const query = `${mediaQuery} { ${results2} }`;
173
199
  cssStyles.add(query);
174
200
  return void 0;
175
201
  }
202
+ if (Object.keys(value).length === 0) return void 0;
203
+ if (pseudoTypoRegex.test(_key)) {
204
+ reportParserIssue(strict, `Selector "${_key}" looks like a missing-colon typo (did you mean "&:${_key.slice(1)}"?).`);
205
+ }
176
206
  const scope = combineSelectors(currentScope, _key);
177
207
  const results = await parseStyles(value, scope, config);
178
208
  results.forEach((result) => cssStyles.add(result));
179
209
  return void 0;
180
210
  }
211
+ if (_key.startsWith("$")) {
212
+ reportParserIssue(strict, `Property key "${_key}" looks like a SCSS variable — Salty does not support those.`);
213
+ return void 0;
214
+ }
215
+ if (_key.includes(":")) {
216
+ reportParserIssue(strict, `Property key "${_key}" contains a colon — did you accidentally paste a whole declaration as a key?`);
217
+ return void 0;
218
+ }
219
+ if (value === void 0 || value === null) {
220
+ reportParserIssue(strict, `Property "${_key}" has a ${value === void 0 ? "undefined" : "null"} value — skipping.`);
221
+ return void 0;
222
+ }
223
+ if (typeof value === "boolean") {
224
+ reportParserIssue(strict, `Property "${_key}" has a boolean value (${value}) — skipping.`);
225
+ return void 0;
226
+ }
227
+ if (value === "") return void 0;
181
228
  if (typeof value === "number") {
229
+ if (!Number.isFinite(value)) {
230
+ reportParserIssue(strict, `Property "${_key}" has a non-finite numeric value (${value}) — skipping.`);
231
+ return void 0;
232
+ }
182
233
  const withUnit = addUnit(propertyName, value, config);
183
234
  return toString(withUnit);
184
235
  }
185
236
  if (typeof value !== "string") {
186
- if ("toString" in value) value = value.toString();
187
- else throw new Error(`Invalid value type for property ${propertyName}`);
237
+ if (value && typeof value === "object" && "toString" in value) value = value.toString();
238
+ else {
239
+ reportParserIssue(strict, `Property "${_key}" has an unsupported value type (${typeof value}) — skipping.`);
240
+ return void 0;
241
+ }
242
+ }
243
+ if (typeof value === "string" && templateLiteralLeftoverRegex.test(value)) {
244
+ reportParserIssue(strict, `Property "${_key}" value "${value}" contains an unresolved \`\${...}\` — did you forget to interpolate?`);
188
245
  }
189
246
  return toString(value);
190
247
  };
@@ -252,8 +309,9 @@ const combineSelectors = (currentScope, key) => {
252
309
  if (!currentScope) return key;
253
310
  const parents = splitTopLevelCommas(currentScope);
254
311
  const children = splitTopLevelCommas(key);
312
+ if (!children.length) return currentScope;
255
313
  if (parents.length <= 1 && children.length <= 1) {
256
- return joinSelector(currentScope, key);
314
+ return joinSelector(parents[0] ?? currentScope, children[0]);
257
315
  }
258
316
  const combos = [];
259
317
  for (const p of parents) {
@@ -268,3 +326,4 @@ exports.parseStyles = parseStyles;
268
326
  exports.parseValueModifiers = parseValueModifiers;
269
327
  exports.parseValueTokens = parseValueTokens;
270
328
  exports.parseVariableTokens = parseVariableTokens;
329
+ exports.reportParserIssue = reportParserIssue;
@@ -20,7 +20,7 @@ const parseValueTokens = (tokenNames) => (value) => {
20
20
  const hasToken = /\{[^{}]+\}/g.test(value);
21
21
  if (!hasToken) return void 0;
22
22
  const transformed = value.replace(/\{([^{}]+)\}/g, (...args) => {
23
- const variable = dashCase(args[1].replaceAll(".", "-"));
23
+ const variable = dashCase(args[1].trim().replaceAll(".", "-"));
24
24
  if (tokenNames && !tokenNames.includes(variable)) console.warn(`Token ${variable} might not exist`);
25
25
  if (variable.startsWith("-")) return `-${variable}`;
26
26
  return `var(--${variable})`;
@@ -74,22 +74,44 @@ const addUnit = (key, value, config) => {
74
74
  return `${value}`;
75
75
  };
76
76
  const vendorPrefixes = ["Webkit", "Moz", "ms", "O"];
77
+ const isVendorPrefixed = (key) => {
78
+ return vendorPrefixes.some((prefix) => {
79
+ if (!key.startsWith(prefix)) return false;
80
+ const next = key.charAt(prefix.length);
81
+ return next >= "A" && next <= "Z";
82
+ });
83
+ };
77
84
  const propertyNameCheck = (key) => {
78
85
  if (key.startsWith("-")) return key;
79
- if (vendorPrefixes.some((prefix) => key.startsWith(prefix))) return `-${dashCase(key)}`;
86
+ if (isVendorPrefixed(key)) return `-${dashCase(key)}`;
80
87
  return dashCase(key);
81
88
  };
89
+ const reportParserIssue = (strict, message) => {
90
+ if (strict === true) throw new Error(`[salty-css] ${message}`);
91
+ if (strict === "warn") console.warn(`[salty-css] ${message}`);
92
+ };
93
+ const pseudoTypoRegex = /^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/;
94
+ const templateLiteralLeftoverRegex = /\$\{[^}]+\}/;
95
+ const bareAtRuleRegex = /^@(media|supports|container|layer)\s*$/;
82
96
  const parseStyles = async (styles, currentScope = "", config, omitTemplates = false) => {
83
97
  if (!styles) throw new Error("No styles provided to parseStyles function!");
84
98
  const cssStyles = /* @__PURE__ */ new Set();
85
99
  const entries = Object.entries(styles);
100
+ const strict = config == null ? void 0 : config.strict;
86
101
  const processStyleEntry = async ([key, value]) => {
87
102
  var _a, _b;
88
103
  const _key = key.trim().replace(/^\?+/g, "");
89
104
  const propertyName = propertyNameCheck(_key);
90
105
  const toString = (val, eol = ";") => `${propertyName}:${val}${eol}`;
91
106
  const context = { scope: currentScope, config };
92
- if (typeof value === "function") return processStyleEntry([key, value(context)]);
107
+ if (typeof value === "function") {
108
+ try {
109
+ return await processStyleEntry([key, value(context)]);
110
+ } catch (error) {
111
+ reportParserIssue(strict, `Function value for "${_key}" threw: ${(error == null ? void 0 : error.message) ?? error}`);
112
+ return void 0;
113
+ }
114
+ }
93
115
  if (value instanceof Promise) return processStyleEntry([key, await value]);
94
116
  if ((config == null ? void 0 : config.templates) && ((_a = config.templatePaths) == null ? void 0 : _a[_key])) {
95
117
  try {
@@ -123,6 +145,10 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
123
145
  console.warn(`Template "${_key}" with path of "${value}" was not found in config!`);
124
146
  return void 0;
125
147
  }
148
+ if (Array.isArray(value)) {
149
+ if (value.length === 0) return void 0;
150
+ return processStyleEntry([key, value.join(", ")]);
151
+ }
126
152
  if (typeof value === "object") {
127
153
  if (!value) return void 0;
128
154
  if (value.isColor) return toString(value.toString());
@@ -159,31 +185,62 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
159
185
  return `.${prop}-${val}`;
160
186
  });
161
187
  const scope2 = `${currentScope}:where(${scopes.join(", ")})`;
162
- console.log(`Union variant scope: ${scope2}`);
163
188
  const results2 = await parseStyles(css2, scope2, config);
164
189
  results2.forEach((res) => cssStyles.add(res));
165
190
  }
166
191
  return void 0;
167
192
  }
168
193
  if (_key.startsWith("@")) {
194
+ if (bareAtRuleRegex.test(_key)) reportParserIssue(strict, `At-rule "${_key}" is missing its condition (e.g. "@media (min-width: 600px)").`);
169
195
  const mediaQuery = ((_b = config == null ? void 0 : config.mediaQueries) == null ? void 0 : _b[_key]) || _key;
170
196
  const results2 = await parseAndJoinStyles(value, currentScope, config);
171
197
  const query = `${mediaQuery} { ${results2} }`;
172
198
  cssStyles.add(query);
173
199
  return void 0;
174
200
  }
201
+ if (Object.keys(value).length === 0) return void 0;
202
+ if (pseudoTypoRegex.test(_key)) {
203
+ reportParserIssue(strict, `Selector "${_key}" looks like a missing-colon typo (did you mean "&:${_key.slice(1)}"?).`);
204
+ }
175
205
  const scope = combineSelectors(currentScope, _key);
176
206
  const results = await parseStyles(value, scope, config);
177
207
  results.forEach((result) => cssStyles.add(result));
178
208
  return void 0;
179
209
  }
210
+ if (_key.startsWith("$")) {
211
+ reportParserIssue(strict, `Property key "${_key}" looks like a SCSS variable — Salty does not support those.`);
212
+ return void 0;
213
+ }
214
+ if (_key.includes(":")) {
215
+ reportParserIssue(strict, `Property key "${_key}" contains a colon — did you accidentally paste a whole declaration as a key?`);
216
+ return void 0;
217
+ }
218
+ if (value === void 0 || value === null) {
219
+ reportParserIssue(strict, `Property "${_key}" has a ${value === void 0 ? "undefined" : "null"} value — skipping.`);
220
+ return void 0;
221
+ }
222
+ if (typeof value === "boolean") {
223
+ reportParserIssue(strict, `Property "${_key}" has a boolean value (${value}) — skipping.`);
224
+ return void 0;
225
+ }
226
+ if (value === "") return void 0;
180
227
  if (typeof value === "number") {
228
+ if (!Number.isFinite(value)) {
229
+ reportParserIssue(strict, `Property "${_key}" has a non-finite numeric value (${value}) — skipping.`);
230
+ return void 0;
231
+ }
181
232
  const withUnit = addUnit(propertyName, value, config);
182
233
  return toString(withUnit);
183
234
  }
184
235
  if (typeof value !== "string") {
185
- if ("toString" in value) value = value.toString();
186
- else throw new Error(`Invalid value type for property ${propertyName}`);
236
+ if (value && typeof value === "object" && "toString" in value) value = value.toString();
237
+ else {
238
+ reportParserIssue(strict, `Property "${_key}" has an unsupported value type (${typeof value}) — skipping.`);
239
+ return void 0;
240
+ }
241
+ }
242
+ if (typeof value === "string" && templateLiteralLeftoverRegex.test(value)) {
243
+ reportParserIssue(strict, `Property "${_key}" value "${value}" contains an unresolved \`\${...}\` — did you forget to interpolate?`);
187
244
  }
188
245
  return toString(value);
189
246
  };
@@ -251,8 +308,9 @@ const combineSelectors = (currentScope, key) => {
251
308
  if (!currentScope) return key;
252
309
  const parents = splitTopLevelCommas(currentScope);
253
310
  const children = splitTopLevelCommas(key);
311
+ if (!children.length) return currentScope;
254
312
  if (parents.length <= 1 && children.length <= 1) {
255
- return joinSelector(currentScope, key);
313
+ return joinSelector(parents[0] ?? currentScope, children[0]);
256
314
  }
257
315
  const combos = [];
258
316
  for (const p of parents) {
@@ -267,5 +325,6 @@ export {
267
325
  parseVariableTokens as b,
268
326
  parseValueModifiers as c,
269
327
  parseValueTokens as d,
270
- parseAndJoinStyles as p
328
+ parseAndJoinStyles as p,
329
+ reportParserIssue as r
271
330
  };
package/parsers/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BD9M4FTQ.cjs");
3
+ const parseStyles = require("../parse-styles-DWQ4UQCp.cjs");
4
4
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
5
5
  const toHash = require("../to-hash-C05Y906F.cjs");
6
6
  const parseTemplates = async (obj, path = []) => {
@@ -52,6 +52,7 @@ exports.parseStyles = parseStyles.parseStyles;
52
52
  exports.parseValueModifiers = parseStyles.parseValueModifiers;
53
53
  exports.parseValueTokens = parseStyles.parseValueTokens;
54
54
  exports.parseVariableTokens = parseStyles.parseVariableTokens;
55
+ exports.reportParserIssue = parseStyles.reportParserIssue;
55
56
  exports.getTemplateKeys = getTemplateKeys;
56
57
  exports.getTemplateTokens = getTemplateTokens;
57
58
  exports.getTemplateTypes = getTemplateTypes;
@@ -3,3 +3,4 @@ export * from './parse-styles';
3
3
  export * from './parse-templates';
4
4
  export * from './parse-tokens';
5
5
  export * from './parser-types';
6
+ export * from './strict';
package/parsers/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { p as parseAndJoinStyles } from "../parse-styles-D4No4G35.js";
2
- import { a, c, d, b } from "../parse-styles-D4No4G35.js";
1
+ import { p as parseAndJoinStyles } from "../parse-styles-g4NPgqhh.js";
2
+ import { a, c, d, b, r } from "../parse-styles-g4NPgqhh.js";
3
3
  import { d as dashCase } from "../dash-case-DblXvymC.js";
4
4
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
5
5
  const parseTemplates = async (obj, path = []) => {
@@ -55,5 +55,6 @@ export {
55
55
  parseTemplates,
56
56
  c as parseValueModifiers,
57
57
  d as parseValueTokens,
58
- b as parseVariableTokens
58
+ b as parseVariableTokens,
59
+ r as reportParserIssue
59
60
  };
@@ -0,0 +1,3 @@
1
+ export declare const pseudoTypoRegex: RegExp;
2
+ export declare const templateLiteralLeftoverRegex: RegExp;
3
+ export declare const bareAtRuleRegex: RegExp;
@@ -0,0 +1,2 @@
1
+ export type StrictMode = boolean | 'warn' | undefined;
2
+ export declare const reportParserIssue: (strict: StrictMode, message: string) => void;
package/runtime/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BD9M4FTQ.cjs");
3
+ const parseStyles = require("../parse-styles-DWQ4UQCp.cjs");
4
4
  const defineRuntime = (config) => {
5
5
  const getDynamicStylesCss = async (styles, scope) => {
6
6
  const parsed = await parseStyles.parseStyles(styles, scope, config);
package/runtime/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as parseStyles } from "../parse-styles-D4No4G35.js";
1
+ import { a as parseStyles } from "../parse-styles-g4NPgqhh.js";
2
2
  const defineRuntime = (config) => {
3
3
  const getDynamicStylesCss = async (styles, scope) => {
4
4
  const parsed = await parseStyles(styles, scope, config);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const salty_config = "import { defineConfig } from '@salty-css/core/config';\n\nexport const config = defineConfig({\n // Add your custom config here\n externalModules: ['react', 'react-dom']\n});\n";
3
+ const salty_config = "import { defineConfig } from '@salty-css/core/config';\n\nexport const config = defineConfig({\n strict: true,\n externalModules: ['react', 'react-dom']\n});\n";
4
4
  exports.default = salty_config;
@@ -0,0 +1,4 @@
1
+ const salty_config = "import { defineConfig } from '@salty-css/core/config';\n\nexport const config = defineConfig({\n strict: true,\n externalModules: ['react', 'react-dom']\n});\n";
2
+ export {
3
+ salty_config as default
4
+ };
@@ -68,6 +68,14 @@ export interface SaltyConfig {
68
68
  * Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
69
69
  */
70
70
  externalModules?: ('react' | 'react-dom' | OrString)[];
71
+ /**
72
+ * Controls how the parser reacts to suspicious or malformed input
73
+ * (typos, invalid value types, malformed selectors, etc.).
74
+ * - `true` — throw on issues (recommended for new projects)
75
+ * - `'warn'` — log a warning and continue
76
+ * - `false` / undefined — silent, behave like prior versions
77
+ */
78
+ strict?: boolean | 'warn';
71
79
  /**
72
80
  * default unit for px based properties when providing a number value. Default is 'px'.
73
81
  */
@@ -78,6 +86,7 @@ export interface CachedConfig {
78
86
  staticVariables: Record<string, any>;
79
87
  mediaQueries: Record<string, string>;
80
88
  modifiers?: CssModifiers;
89
+ strict?: boolean | 'warn';
81
90
  templatePaths: {
82
91
  [key: string]: string;
83
92
  };
@@ -1,4 +0,0 @@
1
- const salty_config = "import { defineConfig } from '@salty-css/core/config';\n\nexport const config = defineConfig({\n // Add your custom config here\n externalModules: ['react', 'react-dom']\n});\n";
2
- export {
3
- salty_config as default
4
- };