weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.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/bundlers/shared/generator-css.d.ts +3 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -1
- package/dist/bundlers/vite/source-candidates.d.ts +15 -0
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/generator/options.d.ts +2 -0
- package/dist/generator/types.d.ts +1 -0
- package/dist/generator-Y-Ikv4Fu.mjs +1177 -0
- package/dist/{generator-css-DhPFjSzK.mjs → generator-css-Bwy_Uz89.mjs} +72 -32
- package/dist/{generator-css-CnYjiMrD.js → generator-css-CRLrHW4F.js} +72 -32
- package/dist/{generator-CZ-JXw6T.js → generator-mmhXzZnv.js} +797 -13
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +4 -5
- package/dist/gulp.mjs +4 -5
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{loader-anchors-DvwgIYdA.mjs → loader-anchors-1MumTAtA.mjs} +2 -2
- package/dist/{loader-anchors-cprm4Klq.js → loader-anchors-TrFvT6g1.js} +1 -1
- package/dist/postcss.js +3 -1
- package/dist/postcss.mjs +3 -1
- package/dist/{recorder-rn_2v_nd.js → recorder-GdTJ3QqX.js} +1 -1
- package/dist/{recorder-B_XyZ576.mjs → recorder-XdFvVASS.mjs} +1 -1
- package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
- package/dist/{vite-C8JlHiyR.mjs → vite-BDywuCjn.mjs} +409 -163
- package/dist/{vite-BHpAqldo.js → vite-DgRh_GXn.js} +405 -158
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/{webpack-DNIJ0ysE.js → webpack-CAJR4hhP.js} +3 -3
- package/dist/{webpack-CABjKGGQ.mjs → webpack-CiHqVZTg.mjs} +3 -3
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/dist/webpack4.js +3 -3
- package/dist/webpack4.mjs +3 -3
- package/package.json +5 -8
- package/dist/generator-Dwxgra97.mjs +0 -399
|
@@ -154,7 +154,7 @@ function loadTailwindcssPlugin(source) {
|
|
|
154
154
|
}
|
|
155
155
|
function collectClassSet(plugin) {
|
|
156
156
|
const classSet = /* @__PURE__ */ new Set();
|
|
157
|
-
for (const context of plugin.contextRef?.value ?? []) for (const candidate of context.classCache?.keys() ?? []) if (candidate !== "*") classSet.add(candidate);
|
|
157
|
+
for (const context of plugin.contextRef?.value ?? []) for (const candidate of context.classCache?.keys() ?? []) if (String(candidate) !== "*") classSet.add(candidate);
|
|
158
158
|
return classSet;
|
|
159
159
|
}
|
|
160
160
|
function collectDependencyMessages(result) {
|
|
@@ -277,6 +277,16 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
|
277
277
|
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
278
278
|
}
|
|
279
279
|
//#endregion
|
|
280
|
+
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
281
|
+
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
|
|
282
|
+
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
283
|
+
return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
|
|
284
|
+
}
|
|
285
|
+
function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
286
|
+
if (!candidates) return;
|
|
287
|
+
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
280
290
|
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
281
291
|
const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
282
292
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
@@ -284,8 +294,18 @@ const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
|
284
294
|
isMainChunk: true,
|
|
285
295
|
majorVersion: 4
|
|
286
296
|
});
|
|
297
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
298
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
299
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
300
|
+
try {
|
|
301
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
302
|
+
} catch {
|
|
303
|
+
return match;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
287
307
|
async function transformTailwindV4CssToWeapp(css, options) {
|
|
288
|
-
return pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
|
|
308
|
+
return pruneMiniProgramGeneratedCss((await defaultStyleHandler(normalizeTailwindV4GeneratedUrlValues(css), {
|
|
289
309
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
290
310
|
cssRemoveHoverPseudoClass: true,
|
|
291
311
|
isMainChunk: true,
|
|
@@ -294,17 +314,772 @@ async function transformTailwindV4CssToWeapp(css, options) {
|
|
|
294
314
|
})).css);
|
|
295
315
|
}
|
|
296
316
|
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
297
|
-
|
|
317
|
+
const compatibleCss = normalizeTailwindV4GeneratedUrlValues(css);
|
|
318
|
+
return target === "weapp" ? transformTailwindV4CssToWeapp(compatibleCss, options) : compatibleCss;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
322
|
+
const TAILWIND_V3_COLOR_STEPS = [
|
|
323
|
+
"50",
|
|
324
|
+
"100",
|
|
325
|
+
"200",
|
|
326
|
+
"300",
|
|
327
|
+
"400",
|
|
328
|
+
"500",
|
|
329
|
+
"600",
|
|
330
|
+
"700",
|
|
331
|
+
"800",
|
|
332
|
+
"900",
|
|
333
|
+
"950"
|
|
334
|
+
];
|
|
335
|
+
const TAILWIND_V3_COLOR_PALETTE = {
|
|
336
|
+
slate: [
|
|
337
|
+
"#f8fafc",
|
|
338
|
+
"#f1f5f9",
|
|
339
|
+
"#e2e8f0",
|
|
340
|
+
"#cbd5e1",
|
|
341
|
+
"#94a3b8",
|
|
342
|
+
"#64748b",
|
|
343
|
+
"#475569",
|
|
344
|
+
"#334155",
|
|
345
|
+
"#1e293b",
|
|
346
|
+
"#0f172a",
|
|
347
|
+
"#020617"
|
|
348
|
+
],
|
|
349
|
+
gray: [
|
|
350
|
+
"#f9fafb",
|
|
351
|
+
"#f3f4f6",
|
|
352
|
+
"#e5e7eb",
|
|
353
|
+
"#d1d5db",
|
|
354
|
+
"#9ca3af",
|
|
355
|
+
"#6b7280",
|
|
356
|
+
"#4b5563",
|
|
357
|
+
"#374151",
|
|
358
|
+
"#1f2937",
|
|
359
|
+
"#111827",
|
|
360
|
+
"#030712"
|
|
361
|
+
],
|
|
362
|
+
zinc: [
|
|
363
|
+
"#fafafa",
|
|
364
|
+
"#f4f4f5",
|
|
365
|
+
"#e4e4e7",
|
|
366
|
+
"#d4d4d8",
|
|
367
|
+
"#a1a1aa",
|
|
368
|
+
"#71717a",
|
|
369
|
+
"#52525b",
|
|
370
|
+
"#3f3f46",
|
|
371
|
+
"#27272a",
|
|
372
|
+
"#18181b",
|
|
373
|
+
"#09090b"
|
|
374
|
+
],
|
|
375
|
+
neutral: [
|
|
376
|
+
"#fafafa",
|
|
377
|
+
"#f5f5f5",
|
|
378
|
+
"#e5e5e5",
|
|
379
|
+
"#d4d4d4",
|
|
380
|
+
"#a3a3a3",
|
|
381
|
+
"#737373",
|
|
382
|
+
"#525252",
|
|
383
|
+
"#404040",
|
|
384
|
+
"#262626",
|
|
385
|
+
"#171717",
|
|
386
|
+
"#0a0a0a"
|
|
387
|
+
],
|
|
388
|
+
stone: [
|
|
389
|
+
"#fafaf9",
|
|
390
|
+
"#f5f5f4",
|
|
391
|
+
"#e7e5e4",
|
|
392
|
+
"#d6d3d1",
|
|
393
|
+
"#a8a29e",
|
|
394
|
+
"#78716c",
|
|
395
|
+
"#57534e",
|
|
396
|
+
"#44403c",
|
|
397
|
+
"#292524",
|
|
398
|
+
"#1c1917",
|
|
399
|
+
"#0c0a09"
|
|
400
|
+
],
|
|
401
|
+
red: [
|
|
402
|
+
"#fef2f2",
|
|
403
|
+
"#fee2e2",
|
|
404
|
+
"#fecaca",
|
|
405
|
+
"#fca5a5",
|
|
406
|
+
"#f87171",
|
|
407
|
+
"#ef4444",
|
|
408
|
+
"#dc2626",
|
|
409
|
+
"#b91c1c",
|
|
410
|
+
"#991b1b",
|
|
411
|
+
"#7f1d1d",
|
|
412
|
+
"#450a0a"
|
|
413
|
+
],
|
|
414
|
+
orange: [
|
|
415
|
+
"#fff7ed",
|
|
416
|
+
"#ffedd5",
|
|
417
|
+
"#fed7aa",
|
|
418
|
+
"#fdba74",
|
|
419
|
+
"#fb923c",
|
|
420
|
+
"#f97316",
|
|
421
|
+
"#ea580c",
|
|
422
|
+
"#c2410c",
|
|
423
|
+
"#9a3412",
|
|
424
|
+
"#7c2d12",
|
|
425
|
+
"#431407"
|
|
426
|
+
],
|
|
427
|
+
amber: [
|
|
428
|
+
"#fffbeb",
|
|
429
|
+
"#fef3c7",
|
|
430
|
+
"#fde68a",
|
|
431
|
+
"#fcd34d",
|
|
432
|
+
"#fbbf24",
|
|
433
|
+
"#f59e0b",
|
|
434
|
+
"#d97706",
|
|
435
|
+
"#b45309",
|
|
436
|
+
"#92400e",
|
|
437
|
+
"#78350f",
|
|
438
|
+
"#451a03"
|
|
439
|
+
],
|
|
440
|
+
yellow: [
|
|
441
|
+
"#fefce8",
|
|
442
|
+
"#fef9c3",
|
|
443
|
+
"#fef08a",
|
|
444
|
+
"#fde047",
|
|
445
|
+
"#facc15",
|
|
446
|
+
"#eab308",
|
|
447
|
+
"#ca8a04",
|
|
448
|
+
"#a16207",
|
|
449
|
+
"#854d0e",
|
|
450
|
+
"#713f12",
|
|
451
|
+
"#422006"
|
|
452
|
+
],
|
|
453
|
+
lime: [
|
|
454
|
+
"#f7fee7",
|
|
455
|
+
"#ecfccb",
|
|
456
|
+
"#d9f99d",
|
|
457
|
+
"#bef264",
|
|
458
|
+
"#a3e635",
|
|
459
|
+
"#84cc16",
|
|
460
|
+
"#65a30d",
|
|
461
|
+
"#4d7c0f",
|
|
462
|
+
"#3f6212",
|
|
463
|
+
"#365314",
|
|
464
|
+
"#1a2e05"
|
|
465
|
+
],
|
|
466
|
+
green: [
|
|
467
|
+
"#f0fdf4",
|
|
468
|
+
"#dcfce7",
|
|
469
|
+
"#bbf7d0",
|
|
470
|
+
"#86efac",
|
|
471
|
+
"#4ade80",
|
|
472
|
+
"#22c55e",
|
|
473
|
+
"#16a34a",
|
|
474
|
+
"#15803d",
|
|
475
|
+
"#166534",
|
|
476
|
+
"#14532d",
|
|
477
|
+
"#052e16"
|
|
478
|
+
],
|
|
479
|
+
emerald: [
|
|
480
|
+
"#ecfdf5",
|
|
481
|
+
"#d1fae5",
|
|
482
|
+
"#a7f3d0",
|
|
483
|
+
"#6ee7b7",
|
|
484
|
+
"#34d399",
|
|
485
|
+
"#10b981",
|
|
486
|
+
"#059669",
|
|
487
|
+
"#047857",
|
|
488
|
+
"#065f46",
|
|
489
|
+
"#064e3b",
|
|
490
|
+
"#022c22"
|
|
491
|
+
],
|
|
492
|
+
teal: [
|
|
493
|
+
"#f0fdfa",
|
|
494
|
+
"#ccfbf1",
|
|
495
|
+
"#99f6e4",
|
|
496
|
+
"#5eead4",
|
|
497
|
+
"#2dd4bf",
|
|
498
|
+
"#14b8a6",
|
|
499
|
+
"#0d9488",
|
|
500
|
+
"#0f766e",
|
|
501
|
+
"#115e59",
|
|
502
|
+
"#134e4a",
|
|
503
|
+
"#042f2e"
|
|
504
|
+
],
|
|
505
|
+
cyan: [
|
|
506
|
+
"#ecfeff",
|
|
507
|
+
"#cffafe",
|
|
508
|
+
"#a5f3fc",
|
|
509
|
+
"#67e8f9",
|
|
510
|
+
"#22d3ee",
|
|
511
|
+
"#06b6d4",
|
|
512
|
+
"#0891b2",
|
|
513
|
+
"#0e7490",
|
|
514
|
+
"#155e75",
|
|
515
|
+
"#164e63",
|
|
516
|
+
"#083344"
|
|
517
|
+
],
|
|
518
|
+
sky: [
|
|
519
|
+
"#f0f9ff",
|
|
520
|
+
"#e0f2fe",
|
|
521
|
+
"#bae6fd",
|
|
522
|
+
"#7dd3fc",
|
|
523
|
+
"#38bdf8",
|
|
524
|
+
"#0ea5e9",
|
|
525
|
+
"#0284c7",
|
|
526
|
+
"#0369a1",
|
|
527
|
+
"#075985",
|
|
528
|
+
"#0c4a6e",
|
|
529
|
+
"#082f49"
|
|
530
|
+
],
|
|
531
|
+
blue: [
|
|
532
|
+
"#eff6ff",
|
|
533
|
+
"#dbeafe",
|
|
534
|
+
"#bfdbfe",
|
|
535
|
+
"#93c5fd",
|
|
536
|
+
"#60a5fa",
|
|
537
|
+
"#3b82f6",
|
|
538
|
+
"#2563eb",
|
|
539
|
+
"#1d4ed8",
|
|
540
|
+
"#1e40af",
|
|
541
|
+
"#1e3a8a",
|
|
542
|
+
"#172554"
|
|
543
|
+
],
|
|
544
|
+
indigo: [
|
|
545
|
+
"#eef2ff",
|
|
546
|
+
"#e0e7ff",
|
|
547
|
+
"#c7d2fe",
|
|
548
|
+
"#a5b4fc",
|
|
549
|
+
"#818cf8",
|
|
550
|
+
"#6366f1",
|
|
551
|
+
"#4f46e5",
|
|
552
|
+
"#4338ca",
|
|
553
|
+
"#3730a3",
|
|
554
|
+
"#312e81",
|
|
555
|
+
"#1e1b4b"
|
|
556
|
+
],
|
|
557
|
+
violet: [
|
|
558
|
+
"#f5f3ff",
|
|
559
|
+
"#ede9fe",
|
|
560
|
+
"#ddd6fe",
|
|
561
|
+
"#c4b5fd",
|
|
562
|
+
"#a78bfa",
|
|
563
|
+
"#8b5cf6",
|
|
564
|
+
"#7c3aed",
|
|
565
|
+
"#6d28d9",
|
|
566
|
+
"#5b21b6",
|
|
567
|
+
"#4c1d95",
|
|
568
|
+
"#2e1065"
|
|
569
|
+
],
|
|
570
|
+
purple: [
|
|
571
|
+
"#faf5ff",
|
|
572
|
+
"#f3e8ff",
|
|
573
|
+
"#e9d5ff",
|
|
574
|
+
"#d8b4fe",
|
|
575
|
+
"#c084fc",
|
|
576
|
+
"#a855f7",
|
|
577
|
+
"#9333ea",
|
|
578
|
+
"#7e22ce",
|
|
579
|
+
"#6b21a8",
|
|
580
|
+
"#581c87",
|
|
581
|
+
"#3b0764"
|
|
582
|
+
],
|
|
583
|
+
fuchsia: [
|
|
584
|
+
"#fdf4ff",
|
|
585
|
+
"#fae8ff",
|
|
586
|
+
"#f5d0fe",
|
|
587
|
+
"#f0abfc",
|
|
588
|
+
"#e879f9",
|
|
589
|
+
"#d946ef",
|
|
590
|
+
"#c026d3",
|
|
591
|
+
"#a21caf",
|
|
592
|
+
"#86198f",
|
|
593
|
+
"#701a75",
|
|
594
|
+
"#4a044e"
|
|
595
|
+
],
|
|
596
|
+
pink: [
|
|
597
|
+
"#fdf2f8",
|
|
598
|
+
"#fce7f3",
|
|
599
|
+
"#fbcfe8",
|
|
600
|
+
"#f9a8d4",
|
|
601
|
+
"#f472b6",
|
|
602
|
+
"#ec4899",
|
|
603
|
+
"#db2777",
|
|
604
|
+
"#be185d",
|
|
605
|
+
"#9d174d",
|
|
606
|
+
"#831843",
|
|
607
|
+
"#500724"
|
|
608
|
+
],
|
|
609
|
+
rose: [
|
|
610
|
+
"#fff1f2",
|
|
611
|
+
"#ffe4e6",
|
|
612
|
+
"#fecdd3",
|
|
613
|
+
"#fda4af",
|
|
614
|
+
"#fb7185",
|
|
615
|
+
"#f43f5e",
|
|
616
|
+
"#e11d48",
|
|
617
|
+
"#be123c",
|
|
618
|
+
"#9f1239",
|
|
619
|
+
"#881337",
|
|
620
|
+
"#4c0519"
|
|
621
|
+
]
|
|
622
|
+
};
|
|
623
|
+
function createTailwindV3DefaultColorThemeCss() {
|
|
624
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
625
|
+
for (const [color, values] of Object.entries(TAILWIND_V3_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V3_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V3_COLOR_STEPS[index]}: ${values[index]};`);
|
|
626
|
+
return [
|
|
627
|
+
"@theme {",
|
|
628
|
+
...declarations,
|
|
629
|
+
"}"
|
|
630
|
+
].join("\n");
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-compatibility.ts
|
|
634
|
+
const TAILWIND_V3_COMPATIBILITY_THEME_CSS = [
|
|
635
|
+
"@theme {",
|
|
636
|
+
" --default-ring-width: 3px;",
|
|
637
|
+
" --default-ring-color: var(--color-blue-500, #3b82f6);",
|
|
638
|
+
" --default-outline-width: 3px;",
|
|
639
|
+
"",
|
|
640
|
+
" --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
|
|
641
|
+
" --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
|
|
642
|
+
" --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
|
|
643
|
+
" --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
|
|
644
|
+
" --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
|
|
645
|
+
" --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
|
|
646
|
+
"",
|
|
647
|
+
" --blur-xs: 4px;",
|
|
648
|
+
" --blur-sm: 4px;",
|
|
649
|
+
" --blur: 8px;",
|
|
650
|
+
" --backdrop-blur-xs: 4px;",
|
|
651
|
+
" --backdrop-blur-sm: 4px;",
|
|
652
|
+
" --backdrop-blur: 8px;",
|
|
653
|
+
"",
|
|
654
|
+
" --radius-xs: 0.125rem;",
|
|
655
|
+
" --radius-sm: 0.125rem;",
|
|
656
|
+
" --radius: 0.25rem;",
|
|
657
|
+
"}",
|
|
658
|
+
createTailwindV3DefaultColorThemeCss()
|
|
659
|
+
].join("\n");
|
|
660
|
+
const TAILWIND_V3_COMPATIBILITY_BASE_CSS = [
|
|
661
|
+
"@layer base {",
|
|
662
|
+
" *,",
|
|
663
|
+
" ::after,",
|
|
664
|
+
" ::before,",
|
|
665
|
+
" ::backdrop,",
|
|
666
|
+
" ::file-selector-button {",
|
|
667
|
+
" border-color: var(--color-gray-200, currentcolor);",
|
|
668
|
+
" }",
|
|
669
|
+
"",
|
|
670
|
+
" input::placeholder,",
|
|
671
|
+
" textarea::placeholder {",
|
|
672
|
+
" opacity: 1;",
|
|
673
|
+
" color: var(--color-gray-400, currentcolor);",
|
|
674
|
+
" }",
|
|
675
|
+
"",
|
|
676
|
+
" button:not(:disabled),",
|
|
677
|
+
" [role=\"button\"]:not(:disabled) {",
|
|
678
|
+
" cursor: pointer;",
|
|
679
|
+
" }",
|
|
680
|
+
"",
|
|
681
|
+
" dialog {",
|
|
682
|
+
" margin: auto;",
|
|
683
|
+
" }",
|
|
684
|
+
"}"
|
|
685
|
+
].join("\n");
|
|
686
|
+
function applyTailwindV3CompatibilityCss(css) {
|
|
687
|
+
return `${TAILWIND_V3_COMPATIBILITY_THEME_CSS}\n${css}\n${TAILWIND_V3_COMPATIBILITY_BASE_CSS}`;
|
|
688
|
+
}
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
691
|
+
const TAILWIND_V4_COLOR_STEPS = [
|
|
692
|
+
"50",
|
|
693
|
+
"100",
|
|
694
|
+
"200",
|
|
695
|
+
"300",
|
|
696
|
+
"400",
|
|
697
|
+
"500",
|
|
698
|
+
"600",
|
|
699
|
+
"700",
|
|
700
|
+
"800",
|
|
701
|
+
"900",
|
|
702
|
+
"950"
|
|
703
|
+
];
|
|
704
|
+
const TAILWIND_V4_COLOR_PALETTE = {
|
|
705
|
+
slate: [
|
|
706
|
+
"#f8fafc",
|
|
707
|
+
"#f1f5f9",
|
|
708
|
+
"#e2e8f0",
|
|
709
|
+
"#cad5e2",
|
|
710
|
+
"#90a1b9",
|
|
711
|
+
"#62748e",
|
|
712
|
+
"#45556c",
|
|
713
|
+
"#314158",
|
|
714
|
+
"#1d293d",
|
|
715
|
+
"#0f172b",
|
|
716
|
+
"#020618"
|
|
717
|
+
],
|
|
718
|
+
gray: [
|
|
719
|
+
"#f9fafb",
|
|
720
|
+
"#f3f4f6",
|
|
721
|
+
"#e5e7eb",
|
|
722
|
+
"#d1d5dc",
|
|
723
|
+
"#99a1af",
|
|
724
|
+
"#6a7282",
|
|
725
|
+
"#4a5565",
|
|
726
|
+
"#364153",
|
|
727
|
+
"#1e2939",
|
|
728
|
+
"#101828",
|
|
729
|
+
"#030712"
|
|
730
|
+
],
|
|
731
|
+
zinc: [
|
|
732
|
+
"#fafafa",
|
|
733
|
+
"#f4f4f5",
|
|
734
|
+
"#e4e4e7",
|
|
735
|
+
"#d4d4d8",
|
|
736
|
+
"#9f9fa9",
|
|
737
|
+
"#71717b",
|
|
738
|
+
"#52525c",
|
|
739
|
+
"#3f3f46",
|
|
740
|
+
"#27272a",
|
|
741
|
+
"#18181b",
|
|
742
|
+
"#09090b"
|
|
743
|
+
],
|
|
744
|
+
neutral: [
|
|
745
|
+
"#fafafa",
|
|
746
|
+
"#f5f5f5",
|
|
747
|
+
"#e5e5e5",
|
|
748
|
+
"#d4d4d4",
|
|
749
|
+
"#a1a1a1",
|
|
750
|
+
"#737373",
|
|
751
|
+
"#525252",
|
|
752
|
+
"#404040",
|
|
753
|
+
"#262626",
|
|
754
|
+
"#171717",
|
|
755
|
+
"#0a0a0a"
|
|
756
|
+
],
|
|
757
|
+
stone: [
|
|
758
|
+
"#fafaf9",
|
|
759
|
+
"#f5f5f4",
|
|
760
|
+
"#e7e5e4",
|
|
761
|
+
"#d6d3d1",
|
|
762
|
+
"#a6a09b",
|
|
763
|
+
"#79716b",
|
|
764
|
+
"#57534d",
|
|
765
|
+
"#44403b",
|
|
766
|
+
"#292524",
|
|
767
|
+
"#1c1917",
|
|
768
|
+
"#0c0a09"
|
|
769
|
+
],
|
|
770
|
+
mauve: [
|
|
771
|
+
"#fafafa",
|
|
772
|
+
"#f3f1f3",
|
|
773
|
+
"#e7e4e7",
|
|
774
|
+
"#d7d0d7",
|
|
775
|
+
"#a89ea9",
|
|
776
|
+
"#79697b",
|
|
777
|
+
"#594c5b",
|
|
778
|
+
"#463947",
|
|
779
|
+
"#2a212c",
|
|
780
|
+
"#1d161e",
|
|
781
|
+
"#0c090c"
|
|
782
|
+
],
|
|
783
|
+
olive: [
|
|
784
|
+
"#fbfbf9",
|
|
785
|
+
"#f4f4f0",
|
|
786
|
+
"#e8e8e3",
|
|
787
|
+
"#d8d8d0",
|
|
788
|
+
"#abab9c",
|
|
789
|
+
"#7c7c67",
|
|
790
|
+
"#5b5b4b",
|
|
791
|
+
"#474739",
|
|
792
|
+
"#2b2b22",
|
|
793
|
+
"#1d1d16",
|
|
794
|
+
"#0c0c09"
|
|
795
|
+
],
|
|
796
|
+
mist: [
|
|
797
|
+
"#f9fbfb",
|
|
798
|
+
"#f1f3f3",
|
|
799
|
+
"#e3e7e8",
|
|
800
|
+
"#d0d6d8",
|
|
801
|
+
"#9ca8ab",
|
|
802
|
+
"#67787c",
|
|
803
|
+
"#4b585b",
|
|
804
|
+
"#394447",
|
|
805
|
+
"#22292b",
|
|
806
|
+
"#161b1d",
|
|
807
|
+
"#090b0c"
|
|
808
|
+
],
|
|
809
|
+
taupe: [
|
|
810
|
+
"#fbfaf9",
|
|
811
|
+
"#f3f1f1",
|
|
812
|
+
"#e8e4e3",
|
|
813
|
+
"#d8d2d0",
|
|
814
|
+
"#aba09c",
|
|
815
|
+
"#7c6d67",
|
|
816
|
+
"#5b4f4b",
|
|
817
|
+
"#473c39",
|
|
818
|
+
"#2b2422",
|
|
819
|
+
"#1d1816",
|
|
820
|
+
"#0c0a09"
|
|
821
|
+
],
|
|
822
|
+
red: [
|
|
823
|
+
"#fef2f2",
|
|
824
|
+
"#ffe2e2",
|
|
825
|
+
"#ffc9c9",
|
|
826
|
+
"#ffa2a2",
|
|
827
|
+
"#ff6467",
|
|
828
|
+
"#fb2c36",
|
|
829
|
+
"#e7000b",
|
|
830
|
+
"#c10007",
|
|
831
|
+
"#9f0712",
|
|
832
|
+
"#82181a",
|
|
833
|
+
"#460809"
|
|
834
|
+
],
|
|
835
|
+
orange: [
|
|
836
|
+
"#fff7ed",
|
|
837
|
+
"#ffedd4",
|
|
838
|
+
"#ffd6a7",
|
|
839
|
+
"#ffb86a",
|
|
840
|
+
"#ff8904",
|
|
841
|
+
"#ff6900",
|
|
842
|
+
"#f54900",
|
|
843
|
+
"#ca3500",
|
|
844
|
+
"#9f2d00",
|
|
845
|
+
"#7e2a0c",
|
|
846
|
+
"#441306"
|
|
847
|
+
],
|
|
848
|
+
amber: [
|
|
849
|
+
"#fffbeb",
|
|
850
|
+
"#fef3c6",
|
|
851
|
+
"#fee685",
|
|
852
|
+
"#ffd230",
|
|
853
|
+
"#ffb900",
|
|
854
|
+
"#fe9a00",
|
|
855
|
+
"#e17100",
|
|
856
|
+
"#bb4d00",
|
|
857
|
+
"#973c00",
|
|
858
|
+
"#7b3306",
|
|
859
|
+
"#461901"
|
|
860
|
+
],
|
|
861
|
+
yellow: [
|
|
862
|
+
"#fefce8",
|
|
863
|
+
"#fef9c2",
|
|
864
|
+
"#fff085",
|
|
865
|
+
"#ffdf20",
|
|
866
|
+
"#fdc700",
|
|
867
|
+
"#f0b100",
|
|
868
|
+
"#d08700",
|
|
869
|
+
"#a65f00",
|
|
870
|
+
"#894b00",
|
|
871
|
+
"#733e0a",
|
|
872
|
+
"#432004"
|
|
873
|
+
],
|
|
874
|
+
lime: [
|
|
875
|
+
"#f7fee7",
|
|
876
|
+
"#ecfcca",
|
|
877
|
+
"#d8f999",
|
|
878
|
+
"#bbf451",
|
|
879
|
+
"#9ae600",
|
|
880
|
+
"#7ccf00",
|
|
881
|
+
"#5ea500",
|
|
882
|
+
"#497d00",
|
|
883
|
+
"#3c6300",
|
|
884
|
+
"#35530e",
|
|
885
|
+
"#192e03"
|
|
886
|
+
],
|
|
887
|
+
green: [
|
|
888
|
+
"#f0fdf4",
|
|
889
|
+
"#dcfce7",
|
|
890
|
+
"#b9f8cf",
|
|
891
|
+
"#7bf1a8",
|
|
892
|
+
"#05df72",
|
|
893
|
+
"#00c950",
|
|
894
|
+
"#00a63e",
|
|
895
|
+
"#008236",
|
|
896
|
+
"#016630",
|
|
897
|
+
"#0d542b",
|
|
898
|
+
"#032e15"
|
|
899
|
+
],
|
|
900
|
+
emerald: [
|
|
901
|
+
"#ecfdf5",
|
|
902
|
+
"#d0fae5",
|
|
903
|
+
"#a4f4cf",
|
|
904
|
+
"#5ee9b5",
|
|
905
|
+
"#00d492",
|
|
906
|
+
"#00bc7d",
|
|
907
|
+
"#009966",
|
|
908
|
+
"#007a55",
|
|
909
|
+
"#006045",
|
|
910
|
+
"#004f3b",
|
|
911
|
+
"#002c22"
|
|
912
|
+
],
|
|
913
|
+
teal: [
|
|
914
|
+
"#f0fdfa",
|
|
915
|
+
"#cbfbf1",
|
|
916
|
+
"#96f7e4",
|
|
917
|
+
"#46ecd5",
|
|
918
|
+
"#00d5be",
|
|
919
|
+
"#00bba7",
|
|
920
|
+
"#009689",
|
|
921
|
+
"#00786f",
|
|
922
|
+
"#005f5a",
|
|
923
|
+
"#0b4f4a",
|
|
924
|
+
"#022f2e"
|
|
925
|
+
],
|
|
926
|
+
cyan: [
|
|
927
|
+
"#ecfeff",
|
|
928
|
+
"#cefafe",
|
|
929
|
+
"#a2f4fd",
|
|
930
|
+
"#53eafd",
|
|
931
|
+
"#00d3f2",
|
|
932
|
+
"#00b8db",
|
|
933
|
+
"#0092b8",
|
|
934
|
+
"#007595",
|
|
935
|
+
"#005f78",
|
|
936
|
+
"#104e64",
|
|
937
|
+
"#053345"
|
|
938
|
+
],
|
|
939
|
+
sky: [
|
|
940
|
+
"#f0f9ff",
|
|
941
|
+
"#dff2fe",
|
|
942
|
+
"#b8e6fe",
|
|
943
|
+
"#74d4ff",
|
|
944
|
+
"#00bcff",
|
|
945
|
+
"#00a6f4",
|
|
946
|
+
"#0084d1",
|
|
947
|
+
"#0069a8",
|
|
948
|
+
"#00598a",
|
|
949
|
+
"#024a70",
|
|
950
|
+
"#052f4a"
|
|
951
|
+
],
|
|
952
|
+
blue: [
|
|
953
|
+
"#eff6ff",
|
|
954
|
+
"#dbeafe",
|
|
955
|
+
"#bedbff",
|
|
956
|
+
"#8ec5ff",
|
|
957
|
+
"#51a2ff",
|
|
958
|
+
"#2b7fff",
|
|
959
|
+
"#155dfc",
|
|
960
|
+
"#1447e6",
|
|
961
|
+
"#193cb8",
|
|
962
|
+
"#1c398e",
|
|
963
|
+
"#162456"
|
|
964
|
+
],
|
|
965
|
+
indigo: [
|
|
966
|
+
"#eef2ff",
|
|
967
|
+
"#e0e7ff",
|
|
968
|
+
"#c6d2ff",
|
|
969
|
+
"#a3b3ff",
|
|
970
|
+
"#7c86ff",
|
|
971
|
+
"#615fff",
|
|
972
|
+
"#4f39f6",
|
|
973
|
+
"#432dd7",
|
|
974
|
+
"#372aac",
|
|
975
|
+
"#312c85",
|
|
976
|
+
"#1e1a4d"
|
|
977
|
+
],
|
|
978
|
+
violet: [
|
|
979
|
+
"#f5f3ff",
|
|
980
|
+
"#ede9fe",
|
|
981
|
+
"#ddd6ff",
|
|
982
|
+
"#c4b4ff",
|
|
983
|
+
"#a684ff",
|
|
984
|
+
"#8e51ff",
|
|
985
|
+
"#7f22fe",
|
|
986
|
+
"#7008e7",
|
|
987
|
+
"#5d0ec0",
|
|
988
|
+
"#4d179a",
|
|
989
|
+
"#2f0d68"
|
|
990
|
+
],
|
|
991
|
+
purple: [
|
|
992
|
+
"#faf5ff",
|
|
993
|
+
"#f3e8ff",
|
|
994
|
+
"#e9d4ff",
|
|
995
|
+
"#dab2ff",
|
|
996
|
+
"#c27aff",
|
|
997
|
+
"#ad46ff",
|
|
998
|
+
"#9810fa",
|
|
999
|
+
"#8200db",
|
|
1000
|
+
"#6e11b0",
|
|
1001
|
+
"#59168b",
|
|
1002
|
+
"#3c0366"
|
|
1003
|
+
],
|
|
1004
|
+
fuchsia: [
|
|
1005
|
+
"#fdf4ff",
|
|
1006
|
+
"#fae8ff",
|
|
1007
|
+
"#f6cfff",
|
|
1008
|
+
"#f4a8ff",
|
|
1009
|
+
"#ed6aff",
|
|
1010
|
+
"#e12afb",
|
|
1011
|
+
"#c800de",
|
|
1012
|
+
"#a800b7",
|
|
1013
|
+
"#8a0194",
|
|
1014
|
+
"#721378",
|
|
1015
|
+
"#4b004f"
|
|
1016
|
+
],
|
|
1017
|
+
pink: [
|
|
1018
|
+
"#fdf2f8",
|
|
1019
|
+
"#fce7f3",
|
|
1020
|
+
"#fccee8",
|
|
1021
|
+
"#fda5d5",
|
|
1022
|
+
"#fb64b6",
|
|
1023
|
+
"#f6339a",
|
|
1024
|
+
"#e60076",
|
|
1025
|
+
"#c6005c",
|
|
1026
|
+
"#a3004c",
|
|
1027
|
+
"#861043",
|
|
1028
|
+
"#510424"
|
|
1029
|
+
],
|
|
1030
|
+
rose: [
|
|
1031
|
+
"#fff1f2",
|
|
1032
|
+
"#ffe4e6",
|
|
1033
|
+
"#ffccd3",
|
|
1034
|
+
"#ffa1ad",
|
|
1035
|
+
"#ff637e",
|
|
1036
|
+
"#ff2056",
|
|
1037
|
+
"#ec003f",
|
|
1038
|
+
"#c70036",
|
|
1039
|
+
"#a50036",
|
|
1040
|
+
"#8b0836",
|
|
1041
|
+
"#4d0218"
|
|
1042
|
+
]
|
|
1043
|
+
};
|
|
1044
|
+
function createTailwindV4DefaultColorThemeCss() {
|
|
1045
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
1046
|
+
for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
|
|
1047
|
+
return [
|
|
1048
|
+
"@theme {",
|
|
1049
|
+
...declarations,
|
|
1050
|
+
"}"
|
|
1051
|
+
].join("\n");
|
|
298
1052
|
}
|
|
299
1053
|
//#endregion
|
|
300
1054
|
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1055
|
+
function findLeadingImportInsertionIndex(css) {
|
|
1056
|
+
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1057
|
+
let insertionIndex = 0;
|
|
1058
|
+
let match = importPattern.exec(css);
|
|
1059
|
+
while (match !== null) {
|
|
1060
|
+
insertionIndex = match.index + match[0].length;
|
|
1061
|
+
match = importPattern.exec(css);
|
|
1062
|
+
}
|
|
1063
|
+
return insertionIndex;
|
|
1064
|
+
}
|
|
1065
|
+
function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
1066
|
+
const themeCss = createTailwindV4DefaultColorThemeCss();
|
|
1067
|
+
const insertionIndex = findLeadingImportInsertionIndex(css);
|
|
1068
|
+
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
1069
|
+
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
1070
|
+
}
|
|
301
1071
|
function createTailwindV4Engine(source) {
|
|
302
|
-
const engine = (0, tailwindcss_patch.createTailwindV4Engine)(source);
|
|
303
1072
|
async function generate(options = {}) {
|
|
304
|
-
const { styleOptions, target = "weapp", ...patchOptions } = options;
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
1073
|
+
const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
|
|
1074
|
+
const sourceCss = tailwindcssV3Compatibility ?? target === "weapp" ? applyTailwindV3CompatibilityCss(source.css) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(source.css) : source.css;
|
|
1075
|
+
const candidates = target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(patchOptions.candidates) : patchOptions.candidates;
|
|
1076
|
+
const result = await (0, tailwindcss_patch.createTailwindV4Engine)(sourceCss === source.css ? source : {
|
|
1077
|
+
...source,
|
|
1078
|
+
css: sourceCss
|
|
1079
|
+
}).generate({
|
|
1080
|
+
scanSources,
|
|
1081
|
+
...patchOptions,
|
|
1082
|
+
candidates
|
|
308
1083
|
});
|
|
309
1084
|
const rawCss = result.css;
|
|
310
1085
|
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
@@ -317,8 +1092,8 @@ function createTailwindV4Engine(source) {
|
|
|
317
1092
|
}
|
|
318
1093
|
return {
|
|
319
1094
|
source,
|
|
320
|
-
loadDesignSystem:
|
|
321
|
-
validateCandidates:
|
|
1095
|
+
loadDesignSystem: (0, tailwindcss_patch.createTailwindV4Engine)(source).loadDesignSystem,
|
|
1096
|
+
validateCandidates: (0, tailwindcss_patch.createTailwindV4Engine)(source).validateCandidates,
|
|
322
1097
|
generate
|
|
323
1098
|
};
|
|
324
1099
|
}
|
|
@@ -373,16 +1148,19 @@ async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
|
373
1148
|
function normalizeWeappTailwindcssGeneratorOptions(options) {
|
|
374
1149
|
if (options === false) return {
|
|
375
1150
|
mode: "off",
|
|
376
|
-
target: "weapp"
|
|
1151
|
+
target: "weapp",
|
|
1152
|
+
tailwindcssV3Compatibility: true
|
|
377
1153
|
};
|
|
378
1154
|
if (options === true || options == null) return {
|
|
379
1155
|
mode: "auto",
|
|
380
|
-
target: "weapp"
|
|
1156
|
+
target: "weapp",
|
|
1157
|
+
tailwindcssV3Compatibility: true
|
|
381
1158
|
};
|
|
382
1159
|
return {
|
|
383
1160
|
mode: options.mode ?? "auto",
|
|
384
1161
|
target: options.target ?? "weapp",
|
|
385
|
-
styleOptions: options.styleOptions
|
|
1162
|
+
styleOptions: options.styleOptions,
|
|
1163
|
+
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility ?? (options.target ?? "weapp") === "weapp"
|
|
386
1164
|
};
|
|
387
1165
|
}
|
|
388
1166
|
//#endregion
|
|
@@ -412,6 +1190,12 @@ Object.defineProperty(exports, "createWeappTailwindcssGeneratorFromPatcher", {
|
|
|
412
1190
|
return createWeappTailwindcssGeneratorFromPatcher;
|
|
413
1191
|
}
|
|
414
1192
|
});
|
|
1193
|
+
Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
|
|
1194
|
+
enumerable: true,
|
|
1195
|
+
get: function() {
|
|
1196
|
+
return filterUnsupportedMiniProgramTailwindV4Candidates;
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
415
1199
|
Object.defineProperty(exports, "normalizeWeappTailwindcssGeneratorOptions", {
|
|
416
1200
|
enumerable: true,
|
|
417
1201
|
get: function() {
|