@plumeria/utils 19.6.2 → 19.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parser.js CHANGED
@@ -298,9 +298,20 @@ function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTra
298
298
  }
299
299
  if (!exports.t.isObjectProperty(prop))
300
300
  return;
301
- const key = getPropertyKey(prop.key, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
302
- if (!key)
301
+ const rawKey = getPropertyKey(prop.key, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
302
+ if (!rawKey)
303
303
  return;
304
+ const key = typeof rawKey === 'string' ? (0, zss_engine_1.stripSelectorComments)(rawKey) : rawKey;
305
+ if (typeof key === 'string' &&
306
+ (key.startsWith(':') || key.startsWith('['))) {
307
+ const nesting = (0, zss_engine_1.findInvalidSelector)(key);
308
+ if (nesting?.kind === 'same-name')
309
+ throw new Error(`[plumeria] "${nesting.name}()" cannot be nested inside another "${nesting.name}()": "${key}". Rewrite the selector without nesting.`);
310
+ if (nesting?.kind === 'stray-quote')
311
+ throw new Error(`[plumeria] Unexpected quote in selector: "${key}". Close the string inside brackets or parentheses, or remove the quote.`);
312
+ if (nesting?.kind === 'too-deep')
313
+ throw new Error(`[plumeria] Selector nests deeper than ${zss_engine_1.MAX_SELECTOR_NESTING} levels: "${key}". Rewrite the selector with fewer levels.`);
314
+ }
304
315
  const val = unwrapExpression(prop.value);
305
316
  if (exports.t.isIdentifier(val) || exports.t.isMemberExpression(val)) {
306
317
  if (resolveVariable && exports.t.isMemberExpression(val)) {
@@ -5,7 +5,7 @@ const CORE = '@plumeria/core';
5
5
  const isIdentifierStart = (c) => (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95 || c === 36;
6
6
  const isNameChar = (c) => isIdentifierStart(c) || (c >= 48 && c <= 57) || c === 46 || c === 45;
7
7
  const isSpace = (c) => c === 32 || (c >= 9 && c <= 13);
8
- const EXPRESSION_BEFORE = new Set(Array.from('(,=:[!&|?{};+-*%<>~^', (c) => c.charCodeAt(0)));
8
+ const EXPRESSION_BEFORE = new Set(Array.from('(,=:[!&|?{};+-*%<>~^/', (c) => c.charCodeAt(0)));
9
9
  const EXPRESSION_WORDS = new Set([
10
10
  'return',
11
11
  'yield',
@@ -202,7 +202,7 @@ const writesAttribute = (source, name) => {
202
202
  if (end === -1)
203
203
  return true;
204
204
  i = end;
205
- previous = 96;
205
+ previous = source.charCodeAt(i) === 123 ? 123 : 96;
206
206
  continue;
207
207
  }
208
208
  if (c === 123) {
@@ -217,7 +217,7 @@ const writesAttribute = (source, name) => {
217
217
  if (end === -1)
218
218
  return true;
219
219
  i = end;
220
- previous = 96;
220
+ previous = source.charCodeAt(i) === 123 ? 123 : 96;
221
221
  continue;
222
222
  }
223
223
  if (kind === 'attribute') {
@@ -237,6 +237,7 @@ const writesAttribute = (source, name) => {
237
237
  source.charCodeAt(previousEnd - 2) === previous;
238
238
  const expressionStart = previous === 0 ||
239
239
  (EXPRESSION_BEFORE.has(previous) && !afterUpdate) ||
240
+ (previous === 46 && source.startsWith('...', previousEnd - 3)) ||
240
241
  (isNameChar(previous) &&
241
242
  EXPRESSION_WORDS.has(wordBefore(source, previousEnd)));
242
243
  if (c === 47 && expressionStart) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "19.6.2",
3
+ "version": "19.8.0",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "@swc/core": "1.15.47",
26
26
  "lightningcss": "^1.32.0",
27
27
  "postcss": "8.5.26",
28
- "zss-engine": "2.8.0"
28
+ "zss-engine": "2.9.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",