@csszyx/runtime 0.9.4 → 0.9.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
@@ -257,6 +257,25 @@ function endHydration() {
257
257
  }
258
258
  }
259
259
 
260
+ function transform(szProp) {
261
+ const res = browser.transform(szProp);
262
+ const className = res.className;
263
+ if (!className) {
264
+ return res;
265
+ }
266
+ const globals = globalThis;
267
+ const ssrMangleMap = globals.__csszyx_ssr_mangle_map || globals.__csszyx?.mangleMap;
268
+ const browserMangleMap = typeof window !== "undefined" ? window.__csszyx?.mangleMap : void 0;
269
+ const activeMangleMap = ssrMangleMap || browserMangleMap;
270
+ if (activeMangleMap) {
271
+ const mangled = className.split(/\s+/).filter(Boolean).map((c) => activeMangleMap[c] || c).join(" ");
272
+ return {
273
+ className: mangled,
274
+ attributes: res.attributes
275
+ };
276
+ }
277
+ return res;
278
+ }
260
279
  function _sz(...classes) {
261
280
  if (classes.length === 1) {
262
281
  const cls = classes[0];
@@ -266,7 +285,10 @@ function _sz(...classes) {
266
285
  if (!cls) {
267
286
  return "";
268
287
  }
269
- const res = browser.transform(cls);
288
+ if (Array.isArray(cls)) {
289
+ return _sz(...cls);
290
+ }
291
+ const res = transform(cls);
270
292
  return typeof res === "string" ? res : res.className;
271
293
  }
272
294
  let result = "";
@@ -276,7 +298,19 @@ function _sz(...classes) {
276
298
  if (!cls) {
277
299
  continue;
278
300
  }
279
- const res = typeof cls === "string" ? cls : browser.transform(cls);
301
+ if (Array.isArray(cls)) {
302
+ const str2 = _sz(...cls);
303
+ if (!str2) {
304
+ continue;
305
+ }
306
+ if (needsSpace) {
307
+ result += " ";
308
+ }
309
+ result += str2;
310
+ needsSpace = true;
311
+ continue;
312
+ }
313
+ const res = typeof cls === "string" ? cls : transform(cls);
280
314
  const str = typeof res === "string" ? res : res.className;
281
315
  if (!str) {
282
316
  continue;
@@ -297,7 +331,10 @@ function _szIf(condition, truthyValue, falsyValue) {
297
331
  if (typeof value === "string") {
298
332
  return value;
299
333
  }
300
- const res = browser.transform(value);
334
+ if (Array.isArray(value)) {
335
+ return _sz(...value);
336
+ }
337
+ const res = transform(value);
301
338
  return typeof res === "string" ? res : res.className;
302
339
  }
303
340
  function _szSwitch(conditions, defaultValue = "") {
@@ -310,7 +347,10 @@ function _szSwitch(conditions, defaultValue = "") {
310
347
  if (typeof value === "string") {
311
348
  return value;
312
349
  }
313
- const res2 = browser.transform(value);
350
+ if (Array.isArray(value)) {
351
+ return _sz(...value);
352
+ }
353
+ const res2 = transform(value);
314
354
  return typeof res2 === "string" ? res2 : res2.className;
315
355
  }
316
356
  }
@@ -320,7 +360,10 @@ function _szSwitch(conditions, defaultValue = "") {
320
360
  if (typeof defaultValue === "string") {
321
361
  return defaultValue;
322
362
  }
323
- const res = browser.transform(defaultValue);
363
+ if (Array.isArray(defaultValue)) {
364
+ return _sz(...defaultValue);
365
+ }
366
+ const res = transform(defaultValue);
324
367
  return typeof res === "string" ? res : res.className;
325
368
  }
326
369
  function _szMerge(...classes) {
@@ -331,7 +374,22 @@ function _szMerge(...classes) {
331
374
  if (!cls) {
332
375
  continue;
333
376
  }
334
- const res = typeof cls === "string" ? cls : browser.transform(cls);
377
+ if (Array.isArray(cls)) {
378
+ const str2 = _szMerge(...cls);
379
+ if (!str2) {
380
+ continue;
381
+ }
382
+ const parts2 = str2.split(/\s+/);
383
+ for (let j = 0; j < parts2.length; j++) {
384
+ const part = parts2[j];
385
+ if (part && !seen.has(part)) {
386
+ seen.add(part);
387
+ result.push(part);
388
+ }
389
+ }
390
+ continue;
391
+ }
392
+ const res = typeof cls === "string" ? cls : transform(cls);
335
393
  const str = typeof res === "string" ? res : res.className;
336
394
  if (!str) {
337
395
  continue;
package/dist/index.d.cts CHANGED
@@ -13,9 +13,9 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
13
13
  */
14
14
 
15
15
  /**
16
- * Type for sz input - can be a pre-compiled string or SzObject.
16
+ * Type for sz input - can be a pre-compiled string, SzObject, or recursive array.
17
17
  */
18
- type SzInput = string | SzObject | null | undefined | false;
18
+ type SzInput = string | SzObject | SzInput[] | null | undefined | false;
19
19
  /**
20
20
  * Zero-overhead className passthrough/concatenation helper.
21
21
  *
package/dist/index.d.mts CHANGED
@@ -13,9 +13,9 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
13
13
  */
14
14
 
15
15
  /**
16
- * Type for sz input - can be a pre-compiled string or SzObject.
16
+ * Type for sz input - can be a pre-compiled string, SzObject, or recursive array.
17
17
  */
18
- type SzInput = string | SzObject | null | undefined | false;
18
+ type SzInput = string | SzObject | SzInput[] | null | undefined | false;
19
19
  /**
20
20
  * Zero-overhead className passthrough/concatenation helper.
21
21
  *
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { transform } from '@csszyx/compiler/browser';
1
+ import { transform as transform$1 } from '@csszyx/compiler/browser';
2
2
  export { __szColorVar } from '@csszyx/compiler/color-var';
3
3
 
4
4
  function verifyRecoveryToken(element, manifest) {
@@ -255,6 +255,25 @@ function endHydration() {
255
255
  }
256
256
  }
257
257
 
258
+ function transform(szProp) {
259
+ const res = transform$1(szProp);
260
+ const className = res.className;
261
+ if (!className) {
262
+ return res;
263
+ }
264
+ const globals = globalThis;
265
+ const ssrMangleMap = globals.__csszyx_ssr_mangle_map || globals.__csszyx?.mangleMap;
266
+ const browserMangleMap = typeof window !== "undefined" ? window.__csszyx?.mangleMap : void 0;
267
+ const activeMangleMap = ssrMangleMap || browserMangleMap;
268
+ if (activeMangleMap) {
269
+ const mangled = className.split(/\s+/).filter(Boolean).map((c) => activeMangleMap[c] || c).join(" ");
270
+ return {
271
+ className: mangled,
272
+ attributes: res.attributes
273
+ };
274
+ }
275
+ return res;
276
+ }
258
277
  function _sz(...classes) {
259
278
  if (classes.length === 1) {
260
279
  const cls = classes[0];
@@ -264,6 +283,9 @@ function _sz(...classes) {
264
283
  if (!cls) {
265
284
  return "";
266
285
  }
286
+ if (Array.isArray(cls)) {
287
+ return _sz(...cls);
288
+ }
267
289
  const res = transform(cls);
268
290
  return typeof res === "string" ? res : res.className;
269
291
  }
@@ -274,6 +296,18 @@ function _sz(...classes) {
274
296
  if (!cls) {
275
297
  continue;
276
298
  }
299
+ if (Array.isArray(cls)) {
300
+ const str2 = _sz(...cls);
301
+ if (!str2) {
302
+ continue;
303
+ }
304
+ if (needsSpace) {
305
+ result += " ";
306
+ }
307
+ result += str2;
308
+ needsSpace = true;
309
+ continue;
310
+ }
277
311
  const res = typeof cls === "string" ? cls : transform(cls);
278
312
  const str = typeof res === "string" ? res : res.className;
279
313
  if (!str) {
@@ -295,6 +329,9 @@ function _szIf(condition, truthyValue, falsyValue) {
295
329
  if (typeof value === "string") {
296
330
  return value;
297
331
  }
332
+ if (Array.isArray(value)) {
333
+ return _sz(...value);
334
+ }
298
335
  const res = transform(value);
299
336
  return typeof res === "string" ? res : res.className;
300
337
  }
@@ -308,6 +345,9 @@ function _szSwitch(conditions, defaultValue = "") {
308
345
  if (typeof value === "string") {
309
346
  return value;
310
347
  }
348
+ if (Array.isArray(value)) {
349
+ return _sz(...value);
350
+ }
311
351
  const res2 = transform(value);
312
352
  return typeof res2 === "string" ? res2 : res2.className;
313
353
  }
@@ -318,6 +358,9 @@ function _szSwitch(conditions, defaultValue = "") {
318
358
  if (typeof defaultValue === "string") {
319
359
  return defaultValue;
320
360
  }
361
+ if (Array.isArray(defaultValue)) {
362
+ return _sz(...defaultValue);
363
+ }
321
364
  const res = transform(defaultValue);
322
365
  return typeof res === "string" ? res : res.className;
323
366
  }
@@ -329,6 +372,21 @@ function _szMerge(...classes) {
329
372
  if (!cls) {
330
373
  continue;
331
374
  }
375
+ if (Array.isArray(cls)) {
376
+ const str2 = _szMerge(...cls);
377
+ if (!str2) {
378
+ continue;
379
+ }
380
+ const parts2 = str2.split(/\s+/);
381
+ for (let j = 0; j < parts2.length; j++) {
382
+ const part = parts2[j];
383
+ if (part && !seen.has(part)) {
384
+ seen.add(part);
385
+ result.push(part);
386
+ }
387
+ }
388
+ continue;
389
+ }
332
390
  const res = typeof cls === "string" ? cls : transform(cls);
333
391
  const str = typeof res === "string" ? res : res.className;
334
392
  if (!str) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/runtime",
3
- "version": "0.9.4",
3
+ "version": "0.9.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.9.4",
53
- "@csszyx/core": "0.9.4"
52
+ "@csszyx/compiler": "0.9.6",
53
+ "@csszyx/core": "0.9.6"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^20.11.0",