weapp-tailwindcss 5.2.6 → 5.2.8
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/final-css-cleanup.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +8 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -3
- package/dist/bundlers/vite/module-identity.d.ts +9 -0
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +0 -1
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +4 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -1
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -0
- package/dist/cli.js +1 -0
- package/dist/{context-YAvTyPV2.js → context-BMkbwnH8.js} +10 -23
- package/dist/{context-OqD_eBxQ.cjs → context-CByXWyhQ.cjs} +179 -25
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-BE34PYSC.cjs → generator-B0dCFlP1.cjs} +10 -0
- package/dist/{generator-DYeAa2-5.js → generator-BLpOsd5O.js} +10 -0
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DCItlfoq.js → gulp-BWhCahA2.js} +7 -7
- package/dist/{gulp-CPIE1yPk.cjs → gulp-BdoorWb5.cjs} +10 -10
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-BevXxu6p.js → hmr-timing-CJocHeZr.js} +122 -16
- package/dist/{hmr-timing-Chyd_Yfw.cjs → hmr-timing-DiYnyg_W.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-hVsoTfwL.cjs → options-zpZez7qe.cjs} +1 -1
- package/dist/{pipeline-helpers-Cwv-X4Rj.cjs → pipeline-helpers-CsNLoEX1.cjs} +4 -4
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{source-candidate-scan-signature-DG5mQZ8o.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-DLFqYads.js → source-candidate-scan-signature-of-TmeOs.js} +3 -3
- package/dist/{style-options-B_ppaVIg.cjs → style-options-COpQc8fr.cjs} +2 -2
- package/dist/{tailwindcss-CTpCc_nd.js → tailwindcss-2zdmASlM.js} +1 -1
- package/dist/{tailwindcss-DcpiKvmJ.cjs → tailwindcss-LtnGCxF0.cjs} +2 -2
- package/dist/{transform-BbaPIji9.js → transform-DVGsr8cV.js} +24 -7
- package/dist/{transform-BUEyOCT7.cjs → transform-DzVJW6Dp.cjs} +24 -7
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/vite/author-apply.d.ts +1 -0
- package/dist/uni-app-x/vite/harmony-apply.d.ts +4 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +27 -0
- package/dist/uni-app-x/vite/style-request.d.ts +3 -0
- package/dist/uni-app-x/vite.d.ts +3 -24
- package/dist/{v4-generation-core-Dtmu8Yax.cjs → v4-generation-core-BjHT6qGC.cjs} +132 -14
- package/dist/{vite-Bk1YU9L0.js → vite-BJJqWc_F.js} +567 -292
- package/dist/{vite-DmN_Y8Uk.cjs → vite-V86H6PZa.cjs} +570 -295
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{webpack-DtkSnYyR.js → webpack-CkeFhPY2.js} +7 -7
- package/dist/{webpack-DvmrFist.cjs → webpack-CzQrloDg.cjs} +9 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
- package/dist/bundlers/vite/processed-css-assets/empty-at-rule.d.ts +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HmrContext, ResolvedConfig } from 'vite';
|
|
2
|
+
import type { AppType, ICustomAttributesEntities, InternalUserDefinedOptions, JsHandler } from '../../types/index.js';
|
|
3
|
+
export interface CreateUniAppXPluginsOptions {
|
|
4
|
+
appType: AppType;
|
|
5
|
+
customAttributesEntities: ICustomAttributesEntities;
|
|
6
|
+
disabledDefaultTemplateHandler: boolean | undefined;
|
|
7
|
+
mainCssChunkMatcher: NonNullable<InternalUserDefinedOptions['mainCssChunkMatcher']>;
|
|
8
|
+
runtimeState: {
|
|
9
|
+
readyPromise: Promise<unknown>;
|
|
10
|
+
};
|
|
11
|
+
styleHandler: InternalUserDefinedOptions['styleHandler'];
|
|
12
|
+
syncSourceCandidatesForHotUpdate?: ((ctx: HmrContext) => Promise<void>) | undefined;
|
|
13
|
+
tailwindRootCssModuleIds?: Iterable<string> | undefined;
|
|
14
|
+
generateCss?: ((id: string, code: string, hookContext?: {
|
|
15
|
+
addWatchFile?: (id: string) => void;
|
|
16
|
+
disableSourceScan?: boolean;
|
|
17
|
+
sourceCandidates?: Iterable<string>;
|
|
18
|
+
transient?: boolean;
|
|
19
|
+
}) => Promise<string | undefined> | string | undefined) | undefined;
|
|
20
|
+
jsHandler: JsHandler;
|
|
21
|
+
ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
|
|
22
|
+
getResolvedConfig: () => ResolvedConfig | undefined;
|
|
23
|
+
isIosPlatform?: boolean;
|
|
24
|
+
isEnabled?: (() => boolean) | undefined;
|
|
25
|
+
uniAppX?: InternalUserDefinedOptions['uniAppX'];
|
|
26
|
+
viteProcessedCssSourceFiles?: Iterable<string> | undefined;
|
|
27
|
+
}
|
package/dist/uni-app-x/vite.d.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import type { OutputAsset } from 'rollup';
|
|
2
|
-
import type { Plugin
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import type { CreateUniAppXPluginsOptions } from './vite/plugin-options.js';
|
|
3
4
|
import type { ICreateCacheReturnType } from '../cache/index.js';
|
|
4
|
-
import type {
|
|
5
|
-
interface CreateUniAppXPluginsOptions {
|
|
6
|
-
appType: AppType;
|
|
7
|
-
customAttributesEntities: ICustomAttributesEntities;
|
|
8
|
-
disabledDefaultTemplateHandler: boolean | undefined;
|
|
9
|
-
mainCssChunkMatcher: NonNullable<InternalUserDefinedOptions['mainCssChunkMatcher']>;
|
|
10
|
-
runtimeState: {
|
|
11
|
-
readyPromise: Promise<unknown>;
|
|
12
|
-
};
|
|
13
|
-
styleHandler: InternalUserDefinedOptions['styleHandler'];
|
|
14
|
-
tailwindRootCssModuleIds?: Iterable<string> | undefined;
|
|
15
|
-
generateCss?: ((id: string, code: string, hookContext?: {
|
|
16
|
-
addWatchFile?: (id: string) => void;
|
|
17
|
-
transient?: boolean;
|
|
18
|
-
}) => Promise<string | undefined> | string | undefined) | undefined;
|
|
19
|
-
jsHandler: JsHandler;
|
|
20
|
-
ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
|
|
21
|
-
getResolvedConfig: () => ResolvedConfig | undefined;
|
|
22
|
-
isIosPlatform?: boolean;
|
|
23
|
-
isEnabled?: (() => boolean) | undefined;
|
|
24
|
-
uniAppX?: InternalUserDefinedOptions['uniAppX'];
|
|
25
|
-
viteProcessedCssSourceFiles?: Iterable<string> | undefined;
|
|
26
|
-
}
|
|
5
|
+
import type { CreateJsHandlerOptions, InternalUserDefinedOptions, JsHandler, LinkedJsModuleResult } from '../types/index.js';
|
|
27
6
|
export declare function createUniAppXPlugins(options: CreateUniAppXPluginsOptions): Plugin[];
|
|
28
7
|
type ApplyLinkedResults = (linked: Record<string, LinkedJsModuleResult> | undefined) => void;
|
|
29
8
|
interface CreateUniAppXAssetTaskOptions {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
3
|
require("./auto-DtU6f3X6.cjs");
|
|
4
4
|
const require_object = require("./object-C_Vr6_S5.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
6
6
|
const require_wxml = require("./wxml-DSMNuUaP.cjs");
|
|
7
|
-
const require_style_options = require("./style-options-
|
|
7
|
+
const require_style_options = require("./style-options-COpQc8fr.cjs");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
let node_path = require("node:path");
|
|
10
10
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
@@ -341,15 +341,17 @@ function createSourceCandidateStore(options = {}) {
|
|
|
341
341
|
}
|
|
342
342
|
async function syncCurrentSource(id, source) {
|
|
343
343
|
const normalizedId = cleanUrl(id);
|
|
344
|
-
transformCandidatesById.delete(normalizedId);
|
|
345
|
-
cssCandidatesById.delete(normalizedId);
|
|
346
|
-
transformSourceById.delete(normalizedId);
|
|
347
|
-
cssSourceById.delete(normalizedId);
|
|
348
|
-
recompute(normalizedId);
|
|
349
344
|
const previousFileCandidates = new Set(candidatesById.get(normalizedId) ?? []);
|
|
350
|
-
const
|
|
345
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
346
|
+
const nextCandidates = await resolveCandidates(source, extension);
|
|
351
347
|
const affectedCandidates = /* @__PURE__ */ new Set([...previousFileCandidates, ...nextCandidates]);
|
|
352
348
|
const previousVisibleCandidates = collectVisibleCandidates(affectedCandidates);
|
|
349
|
+
if (extension !== "css") {
|
|
350
|
+
transformCandidatesById.delete(normalizedId);
|
|
351
|
+
cssCandidatesById.delete(normalizedId);
|
|
352
|
+
transformSourceById.delete(normalizedId);
|
|
353
|
+
cssSourceById.delete(normalizedId);
|
|
354
|
+
}
|
|
353
355
|
scanSourceById.set(normalizedId, source);
|
|
354
356
|
replaceScanLayer(normalizedId, nextCandidates);
|
|
355
357
|
return diffCandidateSets(previousVisibleCandidates, collectVisibleCandidates(affectedCandidates));
|
|
@@ -2041,6 +2043,104 @@ function annotateCssSourceTrace(css, options) {
|
|
|
2041
2043
|
}
|
|
2042
2044
|
}
|
|
2043
2045
|
//#endregion
|
|
2046
|
+
//#region src/bundlers/shared/final-css-cleanup.ts
|
|
2047
|
+
function isAtRuleNameCharacter(code) {
|
|
2048
|
+
return code === 45 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
2049
|
+
}
|
|
2050
|
+
function isCssWhitespace(code) {
|
|
2051
|
+
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
|
|
2052
|
+
}
|
|
2053
|
+
function findAtRuleBlockStart(css, start) {
|
|
2054
|
+
let parenthesisDepth = 0;
|
|
2055
|
+
let quote = 0;
|
|
2056
|
+
let squareBracketDepth = 0;
|
|
2057
|
+
for (let index = start; index < css.length; index++) {
|
|
2058
|
+
const code = css.charCodeAt(index);
|
|
2059
|
+
if (quote !== 0) {
|
|
2060
|
+
if (code === 92) index++;
|
|
2061
|
+
else if (code === quote) quote = 0;
|
|
2062
|
+
continue;
|
|
2063
|
+
}
|
|
2064
|
+
if (code === 34 || code === 39) {
|
|
2065
|
+
quote = code;
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
if (code === 92) {
|
|
2069
|
+
index++;
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
if (code === 47 && css.charCodeAt(index + 1) === 42) {
|
|
2073
|
+
const commentEnd = css.indexOf("*/", index + 2);
|
|
2074
|
+
if (commentEnd < 0) return -1;
|
|
2075
|
+
index = commentEnd + 1;
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
if (code === 40) {
|
|
2079
|
+
parenthesisDepth++;
|
|
2080
|
+
continue;
|
|
2081
|
+
}
|
|
2082
|
+
if (code === 41 && parenthesisDepth > 0) {
|
|
2083
|
+
parenthesisDepth--;
|
|
2084
|
+
continue;
|
|
2085
|
+
}
|
|
2086
|
+
if (code === 91) {
|
|
2087
|
+
squareBracketDepth++;
|
|
2088
|
+
continue;
|
|
2089
|
+
}
|
|
2090
|
+
if (code === 93 && squareBracketDepth > 0) {
|
|
2091
|
+
squareBracketDepth--;
|
|
2092
|
+
continue;
|
|
2093
|
+
}
|
|
2094
|
+
if (code === 123 && parenthesisDepth === 0 && squareBracketDepth === 0) return index;
|
|
2095
|
+
if ((code === 59 || code === 125) && parenthesisDepth === 0 && squareBracketDepth === 0) return -1;
|
|
2096
|
+
}
|
|
2097
|
+
return -1;
|
|
2098
|
+
}
|
|
2099
|
+
function isEmptyAtRuleBody(css, blockStart) {
|
|
2100
|
+
for (let index = blockStart + 1; index < css.length; index++) {
|
|
2101
|
+
const code = css.charCodeAt(index);
|
|
2102
|
+
if (isCssWhitespace(code)) continue;
|
|
2103
|
+
if (code === 47 && css.charCodeAt(index + 1) === 42) {
|
|
2104
|
+
const commentEnd = css.indexOf("*/", index + 2);
|
|
2105
|
+
if (commentEnd < 0) return false;
|
|
2106
|
+
index = commentEnd + 1;
|
|
2107
|
+
continue;
|
|
2108
|
+
}
|
|
2109
|
+
return code === 125;
|
|
2110
|
+
}
|
|
2111
|
+
return false;
|
|
2112
|
+
}
|
|
2113
|
+
function hasEmptyAtRuleBlockCandidate(css) {
|
|
2114
|
+
let searchFrom = 0;
|
|
2115
|
+
while (searchFrom < css.length) {
|
|
2116
|
+
const atRuleStart = css.indexOf("@", searchFrom);
|
|
2117
|
+
if (atRuleStart < 0) return false;
|
|
2118
|
+
searchFrom = atRuleStart + 1;
|
|
2119
|
+
if (!isAtRuleNameCharacter(css.charCodeAt(searchFrom))) continue;
|
|
2120
|
+
const blockStart = findAtRuleBlockStart(css, searchFrom + 1);
|
|
2121
|
+
if (blockStart >= 0 && isEmptyAtRuleBody(css, blockStart)) return true;
|
|
2122
|
+
}
|
|
2123
|
+
return false;
|
|
2124
|
+
}
|
|
2125
|
+
/**
|
|
2126
|
+
* 在小程序样式进入最终产物图时递归清理空的块级 at-rule。
|
|
2127
|
+
*/
|
|
2128
|
+
function finalizeMiniProgramCssStructure(css) {
|
|
2129
|
+
if (!hasEmptyAtRuleBlockCandidate(css)) return css;
|
|
2130
|
+
try {
|
|
2131
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2132
|
+
let removed = 0;
|
|
2133
|
+
let passRemoved = 0;
|
|
2134
|
+
do {
|
|
2135
|
+
passRemoved = (0, _weapp_tailwindcss_postcss.removeEmptyAtRules)(root);
|
|
2136
|
+
removed += passRemoved;
|
|
2137
|
+
} while (passRemoved > 0);
|
|
2138
|
+
return removed > 0 ? root.toString() : css;
|
|
2139
|
+
} catch {
|
|
2140
|
+
return css;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
//#endregion
|
|
2044
2144
|
//#region src/bundlers/shared/generated-css-marker.ts
|
|
2045
2145
|
const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
|
|
2046
2146
|
const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
|
|
@@ -3101,14 +3201,17 @@ function collectGeneratorCssCandidates(css) {
|
|
|
3101
3201
|
//#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
|
|
3102
3202
|
function resolveTailwindV4ApplyReference(options) {
|
|
3103
3203
|
const references = /* @__PURE__ */ new Set();
|
|
3104
|
-
for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && require_generator.hasTailwindRootDirectives(source.css, { importFallback: true }) &&
|
|
3204
|
+
for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && require_generator.hasTailwindRootDirectives(source.css, { importFallback: true }) && hasTailwindApplyContextDirective(source.css)) references.add(source.file);
|
|
3105
3205
|
return references.size === 1 ? references.values().next().value : void 0;
|
|
3106
3206
|
}
|
|
3107
|
-
function
|
|
3207
|
+
function hasTailwindApplyContextDirective(css) {
|
|
3108
3208
|
try {
|
|
3109
3209
|
let found = false;
|
|
3110
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules(
|
|
3111
|
-
|
|
3210
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules((rule) => {
|
|
3211
|
+
if (rule.name === "theme" || rule.name === "config") {
|
|
3212
|
+
found = true;
|
|
3213
|
+
return false;
|
|
3214
|
+
}
|
|
3112
3215
|
});
|
|
3113
3216
|
return found;
|
|
3114
3217
|
} catch {
|
|
@@ -4734,7 +4837,10 @@ async function executeGeneratorPipelineWithOwner(context) {
|
|
|
4734
4837
|
const sourceCss = options.deferCssAdaptation ? (0, _weapp_tailwindcss_postcss.removeMatchingLocalCssImports)(source.css, localImports) : source.css;
|
|
4735
4838
|
const generatorSource = options.disableSourceScan === true ? {
|
|
4736
4839
|
...source,
|
|
4737
|
-
css: require_generator.removeTailwindSourceDirectives(sourceCss, {
|
|
4840
|
+
css: require_generator.removeTailwindSourceDirectives(sourceCss, {
|
|
4841
|
+
importFallback: generatorOptions.importFallback,
|
|
4842
|
+
preserveApplyContext: true
|
|
4843
|
+
})
|
|
4738
4844
|
} : sourceCss === source.css ? source : {
|
|
4739
4845
|
...source,
|
|
4740
4846
|
css: sourceCss
|
|
@@ -5326,6 +5432,12 @@ Object.defineProperty(exports, "extractMarkedUserLayerComponentsCss", {
|
|
|
5326
5432
|
return extractMarkedUserLayerComponentsCss;
|
|
5327
5433
|
}
|
|
5328
5434
|
});
|
|
5435
|
+
Object.defineProperty(exports, "finalizeMiniProgramCssStructure", {
|
|
5436
|
+
enumerable: true,
|
|
5437
|
+
get: function() {
|
|
5438
|
+
return finalizeMiniProgramCssStructure;
|
|
5439
|
+
}
|
|
5440
|
+
});
|
|
5329
5441
|
Object.defineProperty(exports, "finalizeMiniProgramGeneratorCss", {
|
|
5330
5442
|
enumerable: true,
|
|
5331
5443
|
get: function() {
|
|
@@ -5356,6 +5468,12 @@ Object.defineProperty(exports, "hasBundlerGeneratedCssMarker", {
|
|
|
5356
5468
|
return hasBundlerGeneratedCssMarker;
|
|
5357
5469
|
}
|
|
5358
5470
|
});
|
|
5471
|
+
Object.defineProperty(exports, "hasEmptyAtRuleBlockCandidate", {
|
|
5472
|
+
enumerable: true,
|
|
5473
|
+
get: function() {
|
|
5474
|
+
return hasEmptyAtRuleBlockCandidate;
|
|
5475
|
+
}
|
|
5476
|
+
});
|
|
5359
5477
|
Object.defineProperty(exports, "hasMiniProgramTailwindV4PreflightReset", {
|
|
5360
5478
|
enumerable: true,
|
|
5361
5479
|
get: function() {
|