@csszyx/runtime 0.10.4 → 0.10.6

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
@@ -334,6 +334,7 @@ function transform(szProp) {
334
334
  function _sz(...classes) {
335
335
  return szJoin(classes, 0);
336
336
  }
337
+ const szr = _sz;
337
338
  function szJoin(classes, depth) {
338
339
  if (depth >= browser.MAX_SZ_DEPTH) {
339
340
  throw new browser.SzDepthError();
@@ -1332,7 +1333,12 @@ const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
1332
1333
  function decodeToken(token) {
1333
1334
  const decode = globalThis.__csszyx?.decode;
1334
1335
  if (typeof decode === "function") {
1335
- return decode(token) ?? token;
1336
+ try {
1337
+ const decoded = decode(token);
1338
+ return typeof decoded === "string" ? decoded : token;
1339
+ } catch {
1340
+ return token;
1341
+ }
1336
1342
  }
1337
1343
  return token;
1338
1344
  }
@@ -1672,6 +1678,7 @@ exports.splitBoxSz = splitBoxSz;
1672
1678
  exports.startHydration = startHydration;
1673
1679
  exports.stripSzProps = stripSzProps;
1674
1680
  exports.szcn = szcn;
1681
+ exports.szr = szr;
1675
1682
  exports.szv = szv;
1676
1683
  exports.validateHydrationClass = validateHydrationClass;
1677
1684
  exports.verifyAllTokens = verifyAllTokens;
package/dist/index.d.cts CHANGED
@@ -43,6 +43,30 @@ type SzInput = string | SzObject | SzInput[] | null | undefined | false;
43
43
  * ```
44
44
  */
45
45
  declare function _sz(...classes: SzInput[]): string;
46
+ /**
47
+ * Resolve sz object(s) and/or class strings into a single className string,
48
+ * mangle-aware. This is the PUBLIC, hand-written name for the otherwise
49
+ * compiler-injected `_sz` helper (the `_` prefix marks compiler-generated code
50
+ * you should not hand-author; `szr` is the one you call by hand).
51
+ *
52
+ * Reach for `szr` when you build a className from `szv` factory output or sz
53
+ * objects — e.g. a split/layered design system that declares variants in a
54
+ * module and resolves them at the leaf:
55
+ *
56
+ * ```ts
57
+ * import { szr, szv } from '@csszyx/runtime';
58
+ * const cardSz = szv({ variants: { pad: { lg: { p: 8 } } } });
59
+ * const cls = szr(cardSz({ pad: 'lg' }), isWide && stackSz({ gap: 'xl' }));
60
+ * ```
61
+ *
62
+ * Falsy inputs are skipped (clsx-style). `szr` CONCATENATES (keeps every class);
63
+ * to combine with last-wins OVERRIDE on a same-utility conflict, use `szcn`.
64
+ * `szr` accepts sz OBJECTS; `szcn` accepts className STRINGS.
65
+ *
66
+ * @param classes - sz objects, class strings, or falsy values (skipped).
67
+ * @returns The resolved className string (mangled in a production build).
68
+ */
69
+ declare const szr: (...classes: SzInput[]) => string;
46
70
  /**
47
71
  * Merges className strings, removing duplicates.
48
72
  *
@@ -961,5 +985,5 @@ declare function isRuntimeInitialized(): boolean;
961
985
  */
962
986
  declare function resetRuntime(): void;
963
987
 
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 };
988
+ 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, szr, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
965
989
  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
@@ -43,6 +43,30 @@ type SzInput = string | SzObject | SzInput[] | null | undefined | false;
43
43
  * ```
44
44
  */
45
45
  declare function _sz(...classes: SzInput[]): string;
46
+ /**
47
+ * Resolve sz object(s) and/or class strings into a single className string,
48
+ * mangle-aware. This is the PUBLIC, hand-written name for the otherwise
49
+ * compiler-injected `_sz` helper (the `_` prefix marks compiler-generated code
50
+ * you should not hand-author; `szr` is the one you call by hand).
51
+ *
52
+ * Reach for `szr` when you build a className from `szv` factory output or sz
53
+ * objects — e.g. a split/layered design system that declares variants in a
54
+ * module and resolves them at the leaf:
55
+ *
56
+ * ```ts
57
+ * import { szr, szv } from '@csszyx/runtime';
58
+ * const cardSz = szv({ variants: { pad: { lg: { p: 8 } } } });
59
+ * const cls = szr(cardSz({ pad: 'lg' }), isWide && stackSz({ gap: 'xl' }));
60
+ * ```
61
+ *
62
+ * Falsy inputs are skipped (clsx-style). `szr` CONCATENATES (keeps every class);
63
+ * to combine with last-wins OVERRIDE on a same-utility conflict, use `szcn`.
64
+ * `szr` accepts sz OBJECTS; `szcn` accepts className STRINGS.
65
+ *
66
+ * @param classes - sz objects, class strings, or falsy values (skipped).
67
+ * @returns The resolved className string (mangled in a production build).
68
+ */
69
+ declare const szr: (...classes: SzInput[]) => string;
46
70
  /**
47
71
  * Merges className strings, removing duplicates.
48
72
  *
@@ -961,5 +985,5 @@ declare function isRuntimeInitialized(): boolean;
961
985
  */
962
986
  declare function resetRuntime(): void;
963
987
 
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 };
988
+ 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, szr, szv, validateHydrationClass, verifyAllTokens, verifyMangleChecksum, verifyMangleChecksumAsync, verifyMangleMapIntegrity, verifyRecoveryToken };
965
989
  export type { BoxRole, BoxSelector, Classification, HydrationError, HydrationErrorType, MangleMap, RecoveryManifest, RecoveryMode, RuntimeConfig, SSRContext, SplitBoxOptions, SplitBoxResult, SplitBoxSzOptions, SplitBoxSzResult, SzInput, TokenData, VerificationResult };
package/dist/index.mjs CHANGED
@@ -332,6 +332,7 @@ function transform(szProp) {
332
332
  function _sz(...classes) {
333
333
  return szJoin(classes, 0);
334
334
  }
335
+ const szr = _sz;
335
336
  function szJoin(classes, depth) {
336
337
  if (depth >= MAX_SZ_DEPTH) {
337
338
  throw new SzDepthError();
@@ -1330,7 +1331,12 @@ const AMBIGUOUS_PREFIXES = /* @__PURE__ */ new Set([
1330
1331
  function decodeToken(token) {
1331
1332
  const decode = globalThis.__csszyx?.decode;
1332
1333
  if (typeof decode === "function") {
1333
- return decode(token) ?? token;
1334
+ try {
1335
+ const decoded = decode(token);
1336
+ return typeof decoded === "string" ? decoded : token;
1337
+ } catch {
1338
+ return token;
1339
+ }
1334
1340
  }
1335
1341
  return token;
1336
1342
  }
@@ -1625,4 +1631,4 @@ function resetRuntime() {
1625
1631
  runtimeState.initialized = false;
1626
1632
  }
1627
1633
 
1628
- 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 };
1634
+ 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, szr, 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.4",
3
+ "version": "0.10.6",
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.4",
53
- "@csszyx/core": "0.10.4"
52
+ "@csszyx/core": "0.10.6",
53
+ "@csszyx/compiler": "0.10.6"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^20.11.0",