@csszyx/runtime 0.10.2 → 0.10.3
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 +70 -0
- package/dist/index.d.cts +15 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.mjs +70 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1313,6 +1313,75 @@ function omitSz(sz, selector) {
|
|
|
1313
1313
|
return filterSz(flattenSz(sz, 0), selector, false, 0);
|
|
1314
1314
|
}
|
|
1315
1315
|
|
|
1316
|
+
const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
|
|
1317
|
+
"flex",
|
|
1318
|
+
// flex-1 (flex shorthand) vs flex-row (flex-direction)
|
|
1319
|
+
"text",
|
|
1320
|
+
// text-sm (font-size) vs text-red-500 (color)
|
|
1321
|
+
"bg",
|
|
1322
|
+
// bg-red-500 (color) vs bg-cover (size) vs bg-center (position)
|
|
1323
|
+
"border",
|
|
1324
|
+
// border-2 (width) vs border-red-500 (color) vs border-solid (style)
|
|
1325
|
+
"divide",
|
|
1326
|
+
// divide-x (width) vs divide-red-500 (color)
|
|
1327
|
+
"ring",
|
|
1328
|
+
// ring-2 (width) vs ring-red-500 (color)
|
|
1329
|
+
"outline"
|
|
1330
|
+
// outline-2 (width) vs outline-red-500 (color)
|
|
1331
|
+
]);
|
|
1332
|
+
function decodeToken(token) {
|
|
1333
|
+
const decode = globalThis.__csszyx?.decode;
|
|
1334
|
+
if (typeof decode === "function") {
|
|
1335
|
+
return decode(token) ?? token;
|
|
1336
|
+
}
|
|
1337
|
+
return token;
|
|
1338
|
+
}
|
|
1339
|
+
function conflictKey(token) {
|
|
1340
|
+
const base = stripVariant(token);
|
|
1341
|
+
const variant = token.slice(0, token.length - base.length);
|
|
1342
|
+
const norm = normalizeBase(base);
|
|
1343
|
+
if (!norm) {
|
|
1344
|
+
return null;
|
|
1345
|
+
}
|
|
1346
|
+
if (BOX_ROLE_TOKENS.has(norm)) {
|
|
1347
|
+
return null;
|
|
1348
|
+
}
|
|
1349
|
+
for (const [prefix] of BOX_ROLE_PREFIXES) {
|
|
1350
|
+
if (norm === prefix || norm.startsWith(`${prefix}-`)) {
|
|
1351
|
+
if (AMBIGUOUS_PREFIXES.has(prefix)) {
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
return `${variant}\0${prefix}`;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return null;
|
|
1358
|
+
}
|
|
1359
|
+
function szcn(...inputs) {
|
|
1360
|
+
const order = [];
|
|
1361
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1362
|
+
for (const input of inputs) {
|
|
1363
|
+
if (!input || typeof input !== "string") {
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
for (const token of input.split(/\s+/)) {
|
|
1367
|
+
if (!token) {
|
|
1368
|
+
continue;
|
|
1369
|
+
}
|
|
1370
|
+
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);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
byKey.set(key, token);
|
|
1379
|
+
order.push(key);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return order.map((key) => byKey.get(key)).join(" ");
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1316
1385
|
const warned$1 = /* @__PURE__ */ new Set();
|
|
1317
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.';
|
|
1318
1387
|
function warnRawSz() {
|
|
@@ -1567,6 +1636,7 @@ exports.splitBox = splitBox;
|
|
|
1567
1636
|
exports.splitBoxSz = splitBoxSz;
|
|
1568
1637
|
exports.startHydration = startHydration;
|
|
1569
1638
|
exports.stripSzProps = stripSzProps;
|
|
1639
|
+
exports.szcn = szcn;
|
|
1570
1640
|
exports.szv = szv;
|
|
1571
1641
|
exports.validateHydrationClass = validateHydrationClass;
|
|
1572
1642
|
exports.verifyAllTokens = verifyAllTokens;
|
package/dist/index.d.cts
CHANGED
|
@@ -598,6 +598,20 @@ declare function startHydration(): void;
|
|
|
598
598
|
*/
|
|
599
599
|
declare function endHydration(): void;
|
|
600
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Merge className strings with last-wins override per utility, mangle-aware.
|
|
603
|
+
*
|
|
604
|
+
* Intended for the single resolution point in a layered design-system component
|
|
605
|
+
* (typically at the leaf Box): combine the component's default classes with the
|
|
606
|
+
* forwarded override so the override wins on a same-utility collision, while
|
|
607
|
+
* keeping production mangling intact (unlike npm tailwind-merge).
|
|
608
|
+
*
|
|
609
|
+
* @param inputs - Class strings; falsy inputs (`false`/`null`/`undefined`/`''`) are skipped.
|
|
610
|
+
* @returns The merged className string.
|
|
611
|
+
* @example szcn('gap-2 p-4', 'gap-8') // → 'p-4 gap-8' (gap-8 overrides gap-2)
|
|
612
|
+
*/
|
|
613
|
+
declare function szcn(...inputs: (string | false | null | undefined)[]): string;
|
|
614
|
+
|
|
601
615
|
/** Which side of the CSS box-model border a property acts on. */
|
|
602
616
|
type BoxRole = 'outer' | 'inner';
|
|
603
617
|
|
|
@@ -947,5 +961,5 @@ declare function isRuntimeInitialized(): boolean;
|
|
|
947
961
|
*/
|
|
948
962
|
declare function resetRuntime(): void;
|
|
949
963
|
|
|
950
|
-
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
|
964
|
+
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szcn, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
|
951
965
|
export type { BoxRole, BoxSelector, Classification, HydrationError, HydrationErrorType, MangleMap, RecoveryManifest, RecoveryMode, RuntimeConfig, SSRContext, SplitBoxOptions, SplitBoxResult, SplitBoxSzOptions, SplitBoxSzResult, SzInput, TokenData, VerificationResult };
|
package/dist/index.d.mts
CHANGED
|
@@ -598,6 +598,20 @@ declare function startHydration(): void;
|
|
|
598
598
|
*/
|
|
599
599
|
declare function endHydration(): void;
|
|
600
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Merge className strings with last-wins override per utility, mangle-aware.
|
|
603
|
+
*
|
|
604
|
+
* Intended for the single resolution point in a layered design-system component
|
|
605
|
+
* (typically at the leaf Box): combine the component's default classes with the
|
|
606
|
+
* forwarded override so the override wins on a same-utility collision, while
|
|
607
|
+
* keeping production mangling intact (unlike npm tailwind-merge).
|
|
608
|
+
*
|
|
609
|
+
* @param inputs - Class strings; falsy inputs (`false`/`null`/`undefined`/`''`) are skipped.
|
|
610
|
+
* @returns The merged className string.
|
|
611
|
+
* @example szcn('gap-2 p-4', 'gap-8') // → 'p-4 gap-8' (gap-8 overrides gap-2)
|
|
612
|
+
*/
|
|
613
|
+
declare function szcn(...inputs: (string | false | null | undefined)[]): string;
|
|
614
|
+
|
|
601
615
|
/** Which side of the CSS box-model border a property acts on. */
|
|
602
616
|
type BoxRole = 'outer' | 'inner';
|
|
603
617
|
|
|
@@ -947,5 +961,5 @@ declare function isRuntimeInitialized(): boolean;
|
|
|
947
961
|
*/
|
|
948
962
|
declare function resetRuntime(): void;
|
|
949
963
|
|
|
950
|
-
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
|
964
|
+
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szcn, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
|
951
965
|
export type { BoxRole, BoxSelector, Classification, HydrationError, HydrationErrorType, MangleMap, RecoveryManifest, RecoveryMode, RuntimeConfig, SSRContext, SplitBoxOptions, SplitBoxResult, SplitBoxSzOptions, SplitBoxSzResult, SzInput, TokenData, VerificationResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1311,6 +1311,75 @@ function omitSz(sz, selector) {
|
|
|
1311
1311
|
return filterSz(flattenSz(sz, 0), selector, false, 0);
|
|
1312
1312
|
}
|
|
1313
1313
|
|
|
1314
|
+
const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
|
|
1315
|
+
"flex",
|
|
1316
|
+
// flex-1 (flex shorthand) vs flex-row (flex-direction)
|
|
1317
|
+
"text",
|
|
1318
|
+
// text-sm (font-size) vs text-red-500 (color)
|
|
1319
|
+
"bg",
|
|
1320
|
+
// bg-red-500 (color) vs bg-cover (size) vs bg-center (position)
|
|
1321
|
+
"border",
|
|
1322
|
+
// border-2 (width) vs border-red-500 (color) vs border-solid (style)
|
|
1323
|
+
"divide",
|
|
1324
|
+
// divide-x (width) vs divide-red-500 (color)
|
|
1325
|
+
"ring",
|
|
1326
|
+
// ring-2 (width) vs ring-red-500 (color)
|
|
1327
|
+
"outline"
|
|
1328
|
+
// outline-2 (width) vs outline-red-500 (color)
|
|
1329
|
+
]);
|
|
1330
|
+
function decodeToken(token) {
|
|
1331
|
+
const decode = globalThis.__csszyx?.decode;
|
|
1332
|
+
if (typeof decode === "function") {
|
|
1333
|
+
return decode(token) ?? token;
|
|
1334
|
+
}
|
|
1335
|
+
return token;
|
|
1336
|
+
}
|
|
1337
|
+
function conflictKey(token) {
|
|
1338
|
+
const base = stripVariant(token);
|
|
1339
|
+
const variant = token.slice(0, token.length - base.length);
|
|
1340
|
+
const norm = normalizeBase(base);
|
|
1341
|
+
if (!norm) {
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1344
|
+
if (BOX_ROLE_TOKENS.has(norm)) {
|
|
1345
|
+
return null;
|
|
1346
|
+
}
|
|
1347
|
+
for (const [prefix] of BOX_ROLE_PREFIXES) {
|
|
1348
|
+
if (norm === prefix || norm.startsWith(`${prefix}-`)) {
|
|
1349
|
+
if (AMBIGUOUS_PREFIXES.has(prefix)) {
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
return `${variant}\0${prefix}`;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
function szcn(...inputs) {
|
|
1358
|
+
const order = [];
|
|
1359
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1360
|
+
for (const input of inputs) {
|
|
1361
|
+
if (!input || typeof input !== "string") {
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
for (const token of input.split(/\s+/)) {
|
|
1365
|
+
if (!token) {
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
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);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
byKey.set(key, token);
|
|
1377
|
+
order.push(key);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return order.map((key) => byKey.get(key)).join(" ");
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1314
1383
|
const warned$1 = /* @__PURE__ */ new Set();
|
|
1315
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.';
|
|
1316
1385
|
function warnRawSz() {
|
|
@@ -1521,4 +1590,4 @@ function resetRuntime() {
|
|
|
1521
1590
|
runtimeState.initialized = false;
|
|
1522
1591
|
}
|
|
1523
1592
|
|
|
1524
|
-
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
|
1593
|
+
export { DEFAULT_RUNTIME_CONFIG, VERSION, _sz, _sz2, _sz3, _szMerge, abortHydration, attemptCSRRecovery, classify, classifySzKey, clearHydrationErrors, computeMangleChecksumAsync, disableCSRRecovery, enableCSRRecovery, endHydration, getAbortedSubtreeCount, getHydrationErrors, getRecoveryMode, getRuntimeConfig, getSSRContext, guardHydration, has, hasRecoveryToken, hasSz, initRuntime, isCSRRecoveryAllowed, isHydrating, isHydrationAborted, isRuntimeInitialized, isSSREnvironment, isValidMangleMap, isValidManifest, loadMangleMapFromDOM, loadManifestFromDOM, omit, omitSz, pick, pickSz, resetRuntime, splitBox, splitBoxSz, startHydration, stripSzProps, szcn, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/runtime",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
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.
|
|
53
|
-
"@csszyx/core": "0.10.
|
|
52
|
+
"@csszyx/compiler": "0.10.3",
|
|
53
|
+
"@csszyx/core": "0.10.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^20.11.0",
|