@csszyx/unplugin 0.16.0 → 0.17.1

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +15 -4
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.mts +2 -2
  5. package/dist/index.mjs +14 -4
  6. package/dist/jest-transform.cjs +186 -0
  7. package/dist/jest-transform.d.cts +112 -0
  8. package/dist/jest-transform.d.mts +110 -0
  9. package/dist/jest-transform.mjs +175 -0
  10. package/dist/next-prebuild.cjs +7 -6
  11. package/dist/next-prebuild.d.cts +12 -2
  12. package/dist/next-prebuild.d.mts +12 -2
  13. package/dist/next-prebuild.mjs +6 -5
  14. package/dist/next-turbo-loader.cjs +11 -9
  15. package/dist/next-turbo-loader.d.cts +1 -1
  16. package/dist/next-turbo-loader.d.mts +1 -1
  17. package/dist/next-turbo-loader.mjs +8 -6
  18. package/dist/next-watcher.cjs +124 -15
  19. package/dist/next-watcher.d.cts +16 -3
  20. package/dist/next-watcher.d.mts +16 -3
  21. package/dist/next-watcher.mjs +124 -15
  22. package/dist/shared/{unplugin.C-oQU1jl.mjs → unplugin.2uf-U76p.mjs} +1 -1
  23. package/dist/shared/{unplugin.BWnmKv07.cjs → unplugin.BKID6KXV.cjs} +5 -1
  24. package/dist/shared/{unplugin.PKo7wFzu.d.cts → unplugin.BO2_hyS3.d.cts} +38 -5
  25. package/dist/shared/{unplugin.DH_ij6cf.mjs → unplugin.Ba3O1r8M.mjs} +2 -6
  26. package/dist/shared/unplugin.BqKLlo1h.cjs +8 -0
  27. package/dist/shared/{unplugin.Vn9x8SBP.mjs → unplugin.C3bgc29e.mjs} +3 -2
  28. package/dist/shared/{unplugin.Ceq-N4jI.mjs → unplugin.CK-DfKTP.mjs} +21 -111
  29. package/dist/shared/{unplugin.COlI0dJs.d.mts → unplugin.C_2R8vIk.d.cts} +1 -1
  30. package/dist/shared/unplugin.CcSfaIVx.mjs +13547 -0
  31. package/dist/shared/{unplugin.rWOMecQs.d.cts → unplugin.CfXjAV63.d.mts} +1 -1
  32. package/dist/shared/{unplugin.J6ue_lRJ.cjs → unplugin.D0tMgokL.cjs} +24 -115
  33. package/dist/shared/{unplugin.DDSWQJYX.cjs → unplugin.DS6CFjim.cjs} +3 -8
  34. package/dist/shared/{unplugin.gksolKh2.cjs → unplugin.DXzIP7lP.cjs} +5 -4
  35. package/dist/shared/unplugin.DZdsqdQa.cjs +13635 -0
  36. package/dist/shared/unplugin.DcXM9sq5.mjs +109 -0
  37. package/dist/shared/unplugin.Defu9wGh.cjs +115 -0
  38. package/dist/shared/{unplugin.Bu2rzRtv.d.mts → unplugin.DptK3pl4.d.mts} +38 -5
  39. package/dist/shared/{unplugin.BGog1Bib.d.cts → unplugin.XdPo6azz.d.cts} +3 -0
  40. package/dist/shared/{unplugin.BGog1Bib.d.mts → unplugin.XdPo6azz.d.mts} +3 -0
  41. package/dist/shared/{unplugin.BzF0V2kw.cjs → unplugin.YcnV3Izb.cjs} +6 -6
  42. package/dist/shared/{unplugin.BLptVbUe.mjs → unplugin.eCo7_znv.mjs} +4 -2
  43. package/dist/shared/unplugin.wMeicb6E.mjs +6 -0
  44. package/dist/vite.cjs +14 -4
  45. package/dist/vite.d.cts +2 -2
  46. package/dist/vite.d.mts +1 -1
  47. package/dist/vite.mjs +14 -4
  48. package/dist/webpack.cjs +14 -4
  49. package/dist/webpack.d.cts +1 -2
  50. package/dist/webpack.d.mts +1 -1
  51. package/dist/webpack.mjs +14 -4
  52. package/package.json +22 -11
  53. package/dist/shared/unplugin.D3yBoTHP.cjs +0 -5462
  54. package/dist/shared/unplugin.Dx0ngYWw.mjs +0 -5381
@@ -1,4 +1,4 @@
1
- import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.BGog1Bib.cjs';
1
+ import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.XdPo6azz.mjs';
2
2
 
3
3
  /** Options for one synchronous watcher materialization cycle. */
4
4
  interface NextWatcherCycleOptions {
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fs = require('node:fs');
4
4
  const path = require('node:path');
5
- const safelistSource = require('./unplugin.DDSWQJYX.cjs');
5
+ const safelistSource = require('./unplugin.DS6CFjim.cjs');
6
6
 
7
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
8
 
@@ -273,26 +273,6 @@ function scanCustomPropertyNames(block) {
273
273
  return names;
274
274
  }
275
275
 
276
- const LEADING_WHITESPACE_RE = /^\s+/;
277
- const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
278
- const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
279
- const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
280
- function insertAfterUseDirective(code, insertion) {
281
- let offset = 0;
282
- while (offset < code.length) {
283
- const triviaLength = leadingTriviaLength(code.slice(offset));
284
- if (triviaLength === 0) break;
285
- offset += triviaLength;
286
- }
287
- const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
288
- if (!directive) return `${insertion}${code}`;
289
- const insertionOffset = offset + directive[0].length;
290
- return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
291
- }
292
- function leadingTriviaLength(source) {
293
- return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
294
- }
295
-
296
276
  const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
297
277
  const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
298
278
  const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
@@ -337,7 +317,7 @@ export default checksum;
337
317
  `;
338
318
  }
339
319
  function isVirtualModule(id) {
340
- return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
320
+ return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID || id === UNSERVED_VIRTUAL_ID;
341
321
  }
342
322
  function resolveVirtualModule(id) {
343
323
  if (id === VIRTUAL_MODULE_ID) {
@@ -352,14 +332,32 @@ function resolveVirtualModule(id) {
352
332
  if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
353
333
  return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
354
334
  }
335
+ if (id === UNSERVED_VIRTUAL_ID) {
336
+ return RESOLVED_UNSERVED_VIRTUAL_ID;
337
+ }
355
338
  return void 0;
356
339
  }
357
340
  const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
358
341
  const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
342
+ const UNSERVED_VIRTUAL_ID = "virtual:csszyx/unserved";
343
+ const RESOLVED_UNSERVED_VIRTUAL_ID = `\0${UNSERVED_VIRTUAL_ID}`;
359
344
  const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
360
345
  const CENSUS_PLACEHOLDER = "___CSSZYX_CENSUS___";
361
346
  const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
362
347
  const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
348
+ const UNSERVED_PLACEHOLDER = "___CSSZYX_UNSERVED___";
349
+ function createUnservedRuntimeModule(classes) {
350
+ return `/**
351
+ * Auto-generated by csszyx: registers the class names this project's Tailwind
352
+ * produces no CSS for.
353
+ *
354
+ * @generated
355
+ */
356
+ import { registerUnservedClasses } from '@csszyx/runtime';
357
+
358
+ registerUnservedClasses(${classes === void 0 ? UNSERVED_PLACEHOLDER : JSON.stringify(classes)});
359
+ `;
360
+ }
363
361
  function createMangleRuntimeModule(globalVarAliasPrefix, exposeDebugGlobal = false) {
364
362
  return `/**
365
363
  * Auto-generated by csszyx: registers the runtime mangle map from the bundle.
@@ -396,94 +394,6 @@ function createThemeGroupsModule(tokens) {
396
394
  ].join("\n");
397
395
  }
398
396
 
399
- const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
400
- function clauseNames(clauseBody) {
401
- const names = [];
402
- for (const part of clauseBody.split(",")) {
403
- const trimmed = part.trim();
404
- if (!trimmed) {
405
- continue;
406
- }
407
- const spaceAt = trimmed.search(/\s/);
408
- names.push(spaceAt === -1 ? trimmed : trimmed.slice(0, spaceAt));
409
- }
410
- return names;
411
- }
412
- function importsRuntimeHelper(code, helper) {
413
- RUNTIME_IMPORT_CLAUSE_RE.lastIndex = 0;
414
- for (let match = RUNTIME_IMPORT_CLAUSE_RE.exec(code); match; match = RUNTIME_IMPORT_CLAUSE_RE.exec(code)) {
415
- if (clauseNames(match[1]).includes(helper)) {
416
- return true;
417
- }
418
- }
419
- return false;
420
- }
421
- const RUNTIME_IMPORT_APPEND_RE = /(import\s+\{[^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/;
422
- function findRuntimeImportClause(code) {
423
- const match = RUNTIME_IMPORT_APPEND_RE.exec(code);
424
- return match ? { statement: match[0], prefixWithBody: match[1] } : null;
425
- }
426
-
427
- function runtimeHelperGroupsFromUsage(usage) {
428
- const slim = usage.usesSzPart === true && usage.szPartArgsProvable === true && usage.usesRuntime !== true && usage.usesMerge !== true;
429
- const groups = { all: [], barrel: [], merge: [] };
430
- const append = (helper, toMerge = false) => {
431
- groups.all.push(helper);
432
- (toMerge ? groups.merge : groups.barrel).push(helper);
433
- };
434
- if (usage.usesRuntime) append("_sz");
435
- if (usage.usesMerge) append("_szMerge");
436
- if (usage.usesSzcn) append("_szcn", slim);
437
- if (usage.usesSzPart) append("_szPart", slim);
438
- if (usage.usesSzvPick) append("__szvPick");
439
- if (usage.usesSzvPick1) append("__szvPick1");
440
- if (usage.usesColorVar) append("__szColorVar");
441
- if (usage.usesSpacingVar) append("__szSpacingVar");
442
- if (usage.usesUnitVar) append("__szUnitVar");
443
- if (usage.usesBoolClass) append("__szBoolClass");
444
- return groups;
445
- }
446
- function injectNextRuntimeImports(code, usage) {
447
- const groups = runtimeHelperGroupsFromUsage(usage);
448
- const helpers = groups.all;
449
- if (helpers.length === 0) {
450
- return { code, injected: [] };
451
- }
452
- const hasRuntimeImport = code.includes("@csszyx/runtime");
453
- const missing = hasRuntimeImport ? helpers.filter((helper) => !importsRuntimeHelper(code, helper)) : helpers;
454
- if (missing.length === 0) {
455
- return { code, injected: [] };
456
- }
457
- if (groups.merge.length > 0) {
458
- const mergeHelpers = missing.filter((helper) => groups.merge.includes(helper));
459
- const barrelHelpers = missing.filter((helper) => groups.barrel.includes(helper));
460
- let next = insertRuntimeImport(
461
- code,
462
- `import { ${mergeHelpers.join(", ")} } from '@csszyx/runtime/merge';
463
- `
464
- );
465
- if (barrelHelpers.length > 0) {
466
- next = insertRuntimeImport(
467
- next,
468
- `import { ${barrelHelpers.join(", ")} } from '@csszyx/runtime';
469
- `
470
- );
471
- }
472
- return { code: next, injected: missing };
473
- }
474
- return {
475
- code: insertRuntimeImport(
476
- code,
477
- `import { ${missing.join(", ")} } from '@csszyx/runtime';
478
- `
479
- ),
480
- injected: missing
481
- };
482
- }
483
- function insertRuntimeImport(code, importStmt) {
484
- return insertAfterUseDirective(code, importStmt);
485
- }
486
-
487
397
  const THEME_SCAN_IGNORE_DIRS = /* @__PURE__ */ new Set([
488
398
  "node_modules",
489
399
  ".next",
@@ -600,27 +510,26 @@ exports.MANGLE_MAP_PLACEHOLDER = MANGLE_MAP_PLACEHOLDER;
600
510
  exports.MANGLE_RUNTIME_VIRTUAL_ID = MANGLE_RUNTIME_VIRTUAL_ID;
601
511
  exports.RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
602
512
  exports.RESOLVED_THEME_GROUPS_VIRTUAL_ID = RESOLVED_THEME_GROUPS_VIRTUAL_ID;
513
+ exports.RESOLVED_UNSERVED_VIRTUAL_ID = RESOLVED_UNSERVED_VIRTUAL_ID;
603
514
  exports.RESOLVED_VIRTUAL_CHECKSUM_ID = RESOLVED_VIRTUAL_CHECKSUM_ID;
604
515
  exports.RESOLVED_VIRTUAL_MODULE_ID = RESOLVED_VIRTUAL_MODULE_ID;
605
516
  exports.THEME_GROUPS_FILE_MARKER = THEME_GROUPS_FILE_MARKER;
606
517
  exports.THEME_GROUPS_VIRTUAL_ID = THEME_GROUPS_VIRTUAL_ID;
518
+ exports.UNSERVED_PLACEHOLDER = UNSERVED_PLACEHOLDER;
519
+ exports.UNSERVED_VIRTUAL_ID = UNSERVED_VIRTUAL_ID;
607
520
  exports.VAR_MANGLE_MAP_PLACEHOLDER = VAR_MANGLE_MAP_PLACEHOLDER;
608
521
  exports.createChecksumModule = createChecksumModule;
609
522
  exports.createMangleMapModule = createMangleMapModule;
610
523
  exports.createMangleRuntimeModule = createMangleRuntimeModule;
611
524
  exports.createThemeGroupsModule = createThemeGroupsModule;
525
+ exports.createUnservedRuntimeModule = createUnservedRuntimeModule;
612
526
  exports.discoverProjectTheme = discoverProjectTheme;
613
527
  exports.ensureThemeGroupsFile = ensureThemeGroupsFile;
614
- exports.findRuntimeImportClause = findRuntimeImportClause;
615
528
  exports.hasTokens = hasTokens;
616
- exports.importsRuntimeHelper = importsRuntimeHelper;
617
- exports.injectNextRuntimeImports = injectNextRuntimeImports;
618
- exports.insertAfterUseDirective = insertAfterUseDirective;
619
529
  exports.isVirtualModule = isVirtualModule;
620
530
  exports.mergeThemes = mergeThemes;
621
531
  exports.parseThemeBlocks = parseThemeBlocks;
622
532
  exports.parseUtilityBlocks = parseUtilityBlocks;
623
533
  exports.resolveVirtualModule = resolveVirtualModule;
624
- exports.runtimeHelperGroupsFromUsage = runtimeHelperGroupsFromUsage;
625
534
  exports.scanCustomPropertyNames = scanCustomPropertyNames;
626
535
  exports.themeGroupsSpecifier = themeGroupsSpecifier;
@@ -3,6 +3,7 @@
3
3
  const node_crypto = require('node:crypto');
4
4
  const fs = require('node:fs');
5
5
  const path = require('node:path');
6
+ const pathNormalization = require('./unplugin.BqKLlo1h.cjs');
6
7
 
7
8
  function _interopNamespaceCompat(e) {
8
9
  if (e && typeof e === 'object' && 'default' in e) return e;
@@ -27,11 +28,6 @@ function sortStrings(values) {
27
28
  });
28
29
  }
29
30
 
30
- const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
31
- function normalizePathSeparators(value) {
32
- return value.split(WINDOWS_PATH_SEPARATOR).join("/");
33
- }
34
-
35
31
  const DEFAULT_RENAME_RETRIES = 5;
36
32
  const DEFAULT_RENAME_RETRY_DELAY_MS = 10;
37
33
  function isRetryableRenameError(error) {
@@ -229,8 +225,8 @@ function legacySourceMessage(cssFile, target) {
229
225
  const TAILWIND_SPECIFIER = String.raw`["']tailwindcss(?:\/[^"']*)?["']`;
230
226
  const TAILWIND_IMPORT = new RegExp(String.raw`@import\s+${TAILWIND_SPECIFIER}`);
231
227
  function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
232
- const safelistPath = normalizePathSeparators(path__namespace.join(rootDir, safelistFilename));
233
- const cssDir = normalizePathSeparators(path__namespace.dirname(cssId));
228
+ const safelistPath = pathNormalization.normalizePathSeparators(path__namespace.join(rootDir, safelistFilename));
229
+ const cssDir = pathNormalization.normalizePathSeparators(path__namespace.dirname(cssId));
234
230
  let relPath = path__namespace.posix.relative(cssDir, safelistPath);
235
231
  if (!relPath.startsWith("./") && !relPath.startsWith("../")) {
236
232
  relPath = `./${relPath}`;
@@ -282,7 +278,6 @@ exports.findLegacySourceDirective = findLegacySourceDirective;
282
278
  exports.findPostcssConfigWithoutCsszyx = findPostcssConfigWithoutCsszyx;
283
279
  exports.legacySourceMessage = legacySourceMessage;
284
280
  exports.missingPostcssPluginMessage = missingPostcssPluginMessage;
285
- exports.normalizePathSeparators = normalizePathSeparators;
286
281
  exports.removeLegacySafelists = removeLegacySafelists;
287
282
  exports.renderSafelistFile = renderSafelistFile;
288
283
  exports.sortStrings = sortStrings;
@@ -4,9 +4,10 @@ const fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
  const compiler = require('@csszyx/compiler');
6
6
  const types = require('@csszyx/types');
7
- const transformCache = require('./unplugin.BzF0V2kw.cjs');
8
- const safelistSource = require('./unplugin.DDSWQJYX.cjs');
7
+ const transformCache = require('./unplugin.YcnV3Izb.cjs');
8
+ const pathNormalization = require('./unplugin.BqKLlo1h.cjs');
9
9
  const node_crypto = require('node:crypto');
10
+ const safelistSource = require('./unplugin.DS6CFjim.cjs');
10
11
 
11
12
  function _interopNamespaceCompat(e) {
12
13
  if (e && typeof e === 'object' && 'default' in e) return e;
@@ -124,7 +125,7 @@ function configWithImportedStaticSz(config, importedStaticSz) {
124
125
  };
125
126
  }
126
127
  function normalizeProviderPaths(providers) {
127
- return [...new Set(providers.map(safelistSource.normalizePathSeparators))];
128
+ return [...new Set(providers.map(pathNormalization.normalizePathSeparators))];
128
129
  }
129
130
 
130
131
  function readPackageVersion(relativePackageJson, fromUrl) {
@@ -283,7 +284,7 @@ function createNextSourceTransformCacheInput(input, filename, producer) {
283
284
  };
284
285
  }
285
286
  function normalizeSourceFilename(filename) {
286
- return safelistSource.normalizePathSeparators(filename);
287
+ return pathNormalization.normalizePathSeparators(filename);
287
288
  }
288
289
  function normalizeGlobalVarAliasesForCache(aliases) {
289
290
  if (!aliases) {