@csszyx/runtime 0.10.3 → 0.10.5

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/index.cjs CHANGED
@@ -1332,11 +1332,44 @@ const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
1332
1332
  function decodeToken(token) {
1333
1333
  const decode = globalThis.__csszyx?.decode;
1334
1334
  if (typeof decode === "function") {
1335
- return decode(token) ?? token;
1335
+ try {
1336
+ const decoded = decode(token);
1337
+ return typeof decoded === "string" ? decoded : token;
1338
+ } catch {
1339
+ return token;
1340
+ }
1336
1341
  }
1337
1342
  return token;
1338
1343
  }
1339
- function conflictKey(token) {
1344
+ const SHORTHAND_COVERAGE = {
1345
+ p: ["p", "px", "py", "pt", "pr", "pb", "pl", "ps", "pe"],
1346
+ px: ["px", "pl", "pr", "ps", "pe"],
1347
+ py: ["py", "pt", "pb"],
1348
+ m: ["m", "mx", "my", "mt", "mr", "mb", "ml", "ms", "me"],
1349
+ mx: ["mx", "ml", "mr", "ms", "me"],
1350
+ my: ["my", "mt", "mb"],
1351
+ // inset (position) — physical sides only.
1352
+ inset: ["inset", "inset-x", "inset-y", "top", "right", "bottom", "left"],
1353
+ "inset-x": ["inset-x", "left", "right"],
1354
+ "inset-y": ["inset-y", "top", "bottom"],
1355
+ // border-radius — physical corners only (logical rounded-s*/e* stay keep-both).
1356
+ rounded: [
1357
+ "rounded",
1358
+ "rounded-t",
1359
+ "rounded-r",
1360
+ "rounded-b",
1361
+ "rounded-l",
1362
+ "rounded-tl",
1363
+ "rounded-tr",
1364
+ "rounded-br",
1365
+ "rounded-bl"
1366
+ ],
1367
+ "rounded-t": ["rounded-t", "rounded-tl", "rounded-tr"],
1368
+ "rounded-r": ["rounded-r", "rounded-tr", "rounded-br"],
1369
+ "rounded-b": ["rounded-b", "rounded-bl", "rounded-br"],
1370
+ "rounded-l": ["rounded-l", "rounded-tl", "rounded-bl"]
1371
+ };
1372
+ function mergeClassify(token) {
1340
1373
  const base = stripVariant(token);
1341
1374
  const variant = token.slice(0, token.length - base.length);
1342
1375
  const norm = normalizeBase(base);
@@ -1351,7 +1384,11 @@ function conflictKey(token) {
1351
1384
  if (AMBIGUOUS_PREFIXES.has(prefix)) {
1352
1385
  return null;
1353
1386
  }
1354
- return `${variant}\0${prefix}`;
1387
+ const coveredPrefixes = SHORTHAND_COVERAGE[prefix] ?? [prefix];
1388
+ return {
1389
+ key: `${variant} ${prefix}`,
1390
+ covers: coveredPrefixes.map((p) => `${variant} ${p}`)
1391
+ };
1355
1392
  }
1356
1393
  }
1357
1394
  return null;
@@ -1368,11 +1405,14 @@ function szcn(...inputs) {
1368
1405
  continue;
1369
1406
  }
1370
1407
  const original = decodeToken(token);
1371
- const key = conflictKey(original) ?? `${original}`;
1372
- if (byKey.has(key)) {
1373
- const at = order.indexOf(key);
1374
- if (at !== -1) {
1375
- order.splice(at, 1);
1408
+ const info = mergeClassify(original);
1409
+ const key = info ? info.key : original;
1410
+ for (const covered of info ? info.covers : [key]) {
1411
+ if (byKey.delete(covered)) {
1412
+ const at = order.indexOf(covered);
1413
+ if (at !== -1) {
1414
+ order.splice(at, 1);
1415
+ }
1376
1416
  }
1377
1417
  }
1378
1418
  byKey.set(key, token);
@@ -1383,7 +1423,7 @@ function szcn(...inputs) {
1383
1423
  }
1384
1424
 
1385
1425
  const warned$1 = /* @__PURE__ */ new Set();
1386
- const RAW_SZ_WARNING = '[csszyx] A raw `sz` object reached the runtime and was dropped before it could leak to the DOM as sz="[object Object]".\nThis means the file was not compiled \u2014 its `sz` produces no CSS. If it lives in a workspace package, add that package to `compilePackages`; otherwise check that the bundler is not skipping the file.';
1426
+ const RAW_SZ_WARNING = '[csszyx] A raw `sz` object reached the runtime and was dropped before it could leak to the DOM as sz="[object Object]".\nThis means the file was not compiled \u2014 its `sz` produces no CSS. If it lives in a workspace package, add that package directory to `compileSources`; otherwise check that the bundler is not skipping the file.';
1387
1427
  function warnRawSz() {
1388
1428
  if (warned$1.has(RAW_SZ_WARNING)) return;
1389
1429
  warned$1.add(RAW_SZ_WARNING);
package/dist/index.d.cts CHANGED
@@ -782,7 +782,7 @@ declare function omitSz(sz: SzInput, selector: BoxSelector): SzObject;
782
782
  *
783
783
  * The compiler rewrites `sz` to `className` at build time, so a compiled
784
784
  * component never carries a leftover `sz` prop. But when a file is NOT compiled
785
- * — e.g. a workspace package missing from `compilePackages`, or any source the
785
+ * — e.g. a workspace package missing from `compileSources`, or any source the
786
786
  * bundler skipped — a hand-forwarded `sz` survives and React spreads it to the
787
787
  * DOM as `sz="[object Object]"`. `stripSzProps` removes `sz` from the forwarded
788
788
  * props so it never reaches the DOM, and in development warns once when the
package/dist/index.d.mts CHANGED
@@ -782,7 +782,7 @@ declare function omitSz(sz: SzInput, selector: BoxSelector): SzObject;
782
782
  *
783
783
  * The compiler rewrites `sz` to `className` at build time, so a compiled
784
784
  * component never carries a leftover `sz` prop. But when a file is NOT compiled
785
- * — e.g. a workspace package missing from `compilePackages`, or any source the
785
+ * — e.g. a workspace package missing from `compileSources`, or any source the
786
786
  * bundler skipped — a hand-forwarded `sz` survives and React spreads it to the
787
787
  * DOM as `sz="[object Object]"`. `stripSzProps` removes `sz` from the forwarded
788
788
  * props so it never reaches the DOM, and in development warns once when the
package/dist/index.mjs CHANGED
@@ -1330,11 +1330,44 @@ const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
1330
1330
  function decodeToken(token) {
1331
1331
  const decode = globalThis.__csszyx?.decode;
1332
1332
  if (typeof decode === "function") {
1333
- return decode(token) ?? token;
1333
+ try {
1334
+ const decoded = decode(token);
1335
+ return typeof decoded === "string" ? decoded : token;
1336
+ } catch {
1337
+ return token;
1338
+ }
1334
1339
  }
1335
1340
  return token;
1336
1341
  }
1337
- function conflictKey(token) {
1342
+ const SHORTHAND_COVERAGE = {
1343
+ p: ["p", "px", "py", "pt", "pr", "pb", "pl", "ps", "pe"],
1344
+ px: ["px", "pl", "pr", "ps", "pe"],
1345
+ py: ["py", "pt", "pb"],
1346
+ m: ["m", "mx", "my", "mt", "mr", "mb", "ml", "ms", "me"],
1347
+ mx: ["mx", "ml", "mr", "ms", "me"],
1348
+ my: ["my", "mt", "mb"],
1349
+ // inset (position) — physical sides only.
1350
+ inset: ["inset", "inset-x", "inset-y", "top", "right", "bottom", "left"],
1351
+ "inset-x": ["inset-x", "left", "right"],
1352
+ "inset-y": ["inset-y", "top", "bottom"],
1353
+ // border-radius — physical corners only (logical rounded-s*/e* stay keep-both).
1354
+ rounded: [
1355
+ "rounded",
1356
+ "rounded-t",
1357
+ "rounded-r",
1358
+ "rounded-b",
1359
+ "rounded-l",
1360
+ "rounded-tl",
1361
+ "rounded-tr",
1362
+ "rounded-br",
1363
+ "rounded-bl"
1364
+ ],
1365
+ "rounded-t": ["rounded-t", "rounded-tl", "rounded-tr"],
1366
+ "rounded-r": ["rounded-r", "rounded-tr", "rounded-br"],
1367
+ "rounded-b": ["rounded-b", "rounded-bl", "rounded-br"],
1368
+ "rounded-l": ["rounded-l", "rounded-tl", "rounded-bl"]
1369
+ };
1370
+ function mergeClassify(token) {
1338
1371
  const base = stripVariant(token);
1339
1372
  const variant = token.slice(0, token.length - base.length);
1340
1373
  const norm = normalizeBase(base);
@@ -1349,7 +1382,11 @@ function conflictKey(token) {
1349
1382
  if (AMBIGUOUS_PREFIXES.has(prefix)) {
1350
1383
  return null;
1351
1384
  }
1352
- return `${variant}\0${prefix}`;
1385
+ const coveredPrefixes = SHORTHAND_COVERAGE[prefix] ?? [prefix];
1386
+ return {
1387
+ key: `${variant} ${prefix}`,
1388
+ covers: coveredPrefixes.map((p) => `${variant} ${p}`)
1389
+ };
1353
1390
  }
1354
1391
  }
1355
1392
  return null;
@@ -1366,11 +1403,14 @@ function szcn(...inputs) {
1366
1403
  continue;
1367
1404
  }
1368
1405
  const original = decodeToken(token);
1369
- const key = conflictKey(original) ?? `${original}`;
1370
- if (byKey.has(key)) {
1371
- const at = order.indexOf(key);
1372
- if (at !== -1) {
1373
- order.splice(at, 1);
1406
+ const info = mergeClassify(original);
1407
+ const key = info ? info.key : original;
1408
+ for (const covered of info ? info.covers : [key]) {
1409
+ if (byKey.delete(covered)) {
1410
+ const at = order.indexOf(covered);
1411
+ if (at !== -1) {
1412
+ order.splice(at, 1);
1413
+ }
1374
1414
  }
1375
1415
  }
1376
1416
  byKey.set(key, token);
@@ -1381,7 +1421,7 @@ function szcn(...inputs) {
1381
1421
  }
1382
1422
 
1383
1423
  const warned$1 = /* @__PURE__ */ new Set();
1384
- const RAW_SZ_WARNING = '[csszyx] A raw `sz` object reached the runtime and was dropped before it could leak to the DOM as sz="[object Object]".\nThis means the file was not compiled \u2014 its `sz` produces no CSS. If it lives in a workspace package, add that package to `compilePackages`; otherwise check that the bundler is not skipping the file.';
1424
+ const RAW_SZ_WARNING = '[csszyx] A raw `sz` object reached the runtime and was dropped before it could leak to the DOM as sz="[object Object]".\nThis means the file was not compiled \u2014 its `sz` produces no CSS. If it lives in a workspace package, add that package directory to `compileSources`; otherwise check that the bundler is not skipping the file.';
1385
1425
  function warnRawSz() {
1386
1426
  if (warned$1.has(RAW_SZ_WARNING)) return;
1387
1427
  warned$1.add(RAW_SZ_WARNING);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/runtime",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "Runtime helpers and hydration guards for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -49,8 +49,8 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "@csszyx/compiler": "0.10.3",
53
- "@csszyx/core": "0.10.3"
52
+ "@csszyx/compiler": "0.10.5",
53
+ "@csszyx/core": "0.10.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^20.11.0",