weapp-tailwindcss 5.0.5 → 5.0.7
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/{bundle-state-Cso_ceUo.js → bundle-state-BzwPS-UI.js} +2 -1
- package/dist/{bundle-state-DEyxCR4f.mjs → bundle-state-ChcOKb9w.mjs} +2 -1
- package/dist/bundlers/gulp/index.d.ts +3 -4
- package/dist/bundlers/gulp/module-graph.d.ts +2 -0
- package/dist/bundlers/gulp/runtime-snapshot.d.ts +5 -0
- package/dist/bundlers/gulp/vinyl-transform.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/css-source-trace.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +56 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +27 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +26 -0
- package/dist/bundlers/shared/generator-css/validate.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +4 -32
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +14 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +11 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/style-matching.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +68 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -62
- package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +4 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +2 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +13 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +17 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/scan-root.d.ts +10 -0
- package/dist/bundlers/vite/source-candidates/script.d.ts +7 -0
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +1 -0
- package/dist/bundlers/vite/source-candidates.d.ts +8 -3
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +20 -0
- package/dist/bundlers/vite/source-scan/dependencies.d.ts +2 -0
- package/dist/bundlers/vite/source-scan.d.ts +2 -12
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -20
- package/dist/cli.js +69 -69
- package/dist/cli.mjs +69 -69
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{defaults-BPUuNYcD.js → defaults-Boc26eel.js} +1 -0
- package/dist/{defaults-8xrgzxFY.mjs → defaults-DH0ZQRhy.mjs} +1 -0
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-AD-eX8Tr.js → generator-6yF8wjxR.js} +1 -1
- package/dist/{generator-DVWLNO0n.mjs → generator-BON6M1bL.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp-_7p1Z2vc.js +473 -0
- package/dist/gulp-oE-Byqk6.mjs +463 -0
- package/dist/gulp.js +4 -414
- package/dist/gulp.mjs +1 -406
- package/dist/{incremental-runtime-class-set-vOetpdWs.js → hmr-timing-BKQNRxHr.js} +1257 -459
- package/dist/{incremental-runtime-class-set-xf49kky6.mjs → hmr-timing-BVTGf5ch.mjs} +1221 -477
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{postcss-Cbi6RFpf.js → postcss-BTIunhWl.js} +7 -7
- package/dist/{postcss-hSUxK7oR.mjs → postcss-BtmrrZ31.mjs} +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-Bsn_LMmo.mjs → precheck-CZjr87m_.mjs} +19 -5
- package/dist/{precheck-b8Y8qZg0.js → precheck-fhIkzCSU.js} +19 -5
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/tailwindcss/source-scan/inline-source.d.ts +7 -0
- package/dist/tailwindcss/source-scan.d.ts +2 -7
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +3 -0
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +10 -0
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +6 -0
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/{tailwindcss-AWaPVF2B.mjs → tailwindcss-bbQUg25J.mjs} +2 -2
- package/dist/{tailwindcss-CpQ6X4l6.js → tailwindcss-vswd1gc3.js} +2 -2
- package/dist/{transform-BkGtbxb1.js → transform-CReJxxh_.js} +11 -2
- package/dist/{transform-DumSZmTh.mjs → transform-DEsFlG9k.mjs} +11 -2
- package/dist/types/typedoc-tailwindcss-patch.d.ts +4 -2
- package/dist/types/user-defined-options/general.d.ts +5 -0
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/harmony.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +16 -0
- package/dist/uni-app-x/style-asset.d.ts +20 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite.d.ts +1 -0
- package/dist/{v3-engine-CM0TRa8V.js → v3-engine-CEMXFegG.js} +714 -663
- package/dist/{v3-engine-Cczrkzqt.mjs → v3-engine-CdIwmHuc.mjs} +758 -707
- package/dist/{vite-CTuHPC91.js → vite-0jFbh9hx.js} +1797 -386
- package/dist/{vite-DLXDMHON.mjs → vite-C7BGAlCE.mjs} +1779 -369
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +1169 -1002
- package/dist/{webpack-DJFw08SK.mjs → webpack-Dx6_eg5k.mjs} +96 -36
- package/dist/{webpack-BBHJYKqB.js → webpack-aEuDoYfQ.js} +105 -44
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -5
- package/dist/source-candidates-BsWYoIPN.mjs +0 -355
- package/dist/source-candidates-o2ZrKWzu.js +0 -374
package/dist/gulp.mjs
CHANGED
|
@@ -1,407 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-Bsn_LMmo.mjs";
|
|
3
|
-
import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-AWaPVF2B.mjs";
|
|
4
|
-
import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-xf49kky6.mjs";
|
|
5
|
-
import { n as createTailwindV3DefaultExtractor, t as createSourceCandidateCollector } from "./source-candidates-BsWYoIPN.mjs";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import process from "node:process";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
import { Buffer } from "node:buffer";
|
|
10
|
-
import stream from "node:stream";
|
|
11
|
-
//#region src/bundlers/gulp/index.ts
|
|
12
|
-
const debug = createDebug();
|
|
13
|
-
const Transform = stream.Transform;
|
|
14
|
-
/**
|
|
15
|
-
* @name weapp-tw-gulp
|
|
16
|
-
* @description gulp版本weapp-tw插件
|
|
17
|
-
* @link https://tw.icebreaker.top/docs/quick-start/frameworks/native
|
|
18
|
-
*/
|
|
19
|
-
function createPlugins(options = {}) {
|
|
20
|
-
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots(options);
|
|
21
|
-
const opts = getCompilerContext({
|
|
22
|
-
...options,
|
|
23
|
-
__internalDeferMissingCssEntriesWarning: true
|
|
24
|
-
});
|
|
25
|
-
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
26
|
-
const readyPromise = createTailwindRuntimeReadyPromise(initialTwPatcher);
|
|
27
|
-
let runtimeSet = /* @__PURE__ */ new Set();
|
|
28
|
-
const runtimeState = {
|
|
29
|
-
twPatcher: initialTwPatcher,
|
|
30
|
-
readyPromise,
|
|
31
|
-
refreshTailwindcssPatcher
|
|
32
|
-
};
|
|
33
|
-
const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
34
|
-
let cachedDefaultTemplateHandlerOptions;
|
|
35
|
-
let cachedDefaultTemplateRuntimeSet;
|
|
36
|
-
let cachedDefaultModuleGraphOptions;
|
|
37
|
-
const MODULE_EXTENSIONS = [
|
|
38
|
-
".js",
|
|
39
|
-
".mjs",
|
|
40
|
-
".cjs",
|
|
41
|
-
".ts",
|
|
42
|
-
".tsx",
|
|
43
|
-
".jsx"
|
|
44
|
-
];
|
|
45
|
-
let runtimeSetInitialized = false;
|
|
46
|
-
let runtimeSetDirty = false;
|
|
47
|
-
const runtimeSourceHashByFile = /* @__PURE__ */ new Map();
|
|
48
|
-
const runtimeSourcesByFile = /* @__PURE__ */ new Map();
|
|
49
|
-
let cachedGulpSourceCandidates;
|
|
50
|
-
let cachedGulpSourceCandidateSignature;
|
|
51
|
-
const sourceCandidateExtractor = initialTwPatcher.majorVersion === 3 ? createTailwindV3DefaultExtractor() : void 0;
|
|
52
|
-
const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
|
|
53
|
-
async function refreshRuntimeSet(options = false) {
|
|
54
|
-
const normalizedOptions = typeof options === "boolean" ? {
|
|
55
|
-
forceRefresh: options,
|
|
56
|
-
forceCollect: options,
|
|
57
|
-
clearCache: options
|
|
58
|
-
} : options;
|
|
59
|
-
const forceRefresh = normalizedOptions.forceRefresh === true;
|
|
60
|
-
const shouldForceCollect = normalizedOptions.forceCollect === true || runtimeSetDirty;
|
|
61
|
-
const clearCache = normalizedOptions.clearCache === true || runtimeSetDirty;
|
|
62
|
-
if (!forceRefresh && !shouldForceCollect && runtimeSetInitialized) return runtimeSet;
|
|
63
|
-
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
64
|
-
forceRefresh,
|
|
65
|
-
forceCollect: shouldForceCollect,
|
|
66
|
-
clearCache,
|
|
67
|
-
allowEmpty: false
|
|
68
|
-
});
|
|
69
|
-
runtimeSetInitialized = true;
|
|
70
|
-
runtimeSetDirty = false;
|
|
71
|
-
return runtimeSet;
|
|
72
|
-
}
|
|
73
|
-
function createRuntimeSnapshot(changedFiles) {
|
|
74
|
-
const runtimeAffectingChangedByType = {
|
|
75
|
-
html: /* @__PURE__ */ new Set(),
|
|
76
|
-
js: /* @__PURE__ */ new Set(),
|
|
77
|
-
css: /* @__PURE__ */ new Set(),
|
|
78
|
-
other: /* @__PURE__ */ new Set()
|
|
79
|
-
};
|
|
80
|
-
for (const file of changedFiles) {
|
|
81
|
-
const entry = runtimeSourcesByFile.get(file);
|
|
82
|
-
if (entry) runtimeAffectingChangedByType[entry.type].add(file);
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
entries: [...runtimeSourcesByFile.entries()].map(([file, entry]) => ({
|
|
86
|
-
file,
|
|
87
|
-
output: {
|
|
88
|
-
fileName: file,
|
|
89
|
-
source: entry.source,
|
|
90
|
-
type: "asset"
|
|
91
|
-
},
|
|
92
|
-
source: entry.source,
|
|
93
|
-
type: entry.type
|
|
94
|
-
})),
|
|
95
|
-
jsEntries: /* @__PURE__ */ new Map(),
|
|
96
|
-
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
97
|
-
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
98
|
-
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
99
|
-
changedByType: {
|
|
100
|
-
html: /* @__PURE__ */ new Set(),
|
|
101
|
-
js: /* @__PURE__ */ new Set(),
|
|
102
|
-
css: /* @__PURE__ */ new Set(),
|
|
103
|
-
other: /* @__PURE__ */ new Set()
|
|
104
|
-
},
|
|
105
|
-
runtimeAffectingChangedByType,
|
|
106
|
-
processFiles: {
|
|
107
|
-
html: /* @__PURE__ */ new Set(),
|
|
108
|
-
js: /* @__PURE__ */ new Set(),
|
|
109
|
-
css: /* @__PURE__ */ new Set()
|
|
110
|
-
},
|
|
111
|
-
linkedImpactsByEntry: /* @__PURE__ */ new Map()
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
async function refreshRuntimeSetForSource(file, rawSource, type) {
|
|
115
|
-
const filename = path.resolve(file.path);
|
|
116
|
-
const hash = cache.computeHash(rawSource);
|
|
117
|
-
const changed = runtimeSourceHashByFile.get(filename) !== hash;
|
|
118
|
-
runtimeSourceHashByFile.set(filename, hash);
|
|
119
|
-
runtimeSourcesByFile.set(filename, {
|
|
120
|
-
source: rawSource,
|
|
121
|
-
type
|
|
122
|
-
});
|
|
123
|
-
if (!changed && runtimeSetInitialized) return runtimeSet;
|
|
124
|
-
if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
|
|
125
|
-
runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, createRuntimeSnapshot([filename]));
|
|
126
|
-
runtimeSetInitialized = true;
|
|
127
|
-
return runtimeSet;
|
|
128
|
-
} catch (error) {
|
|
129
|
-
debug("gulp incremental runtime set sync failed, fallback to collect: %O", error);
|
|
130
|
-
await bundleRuntimeClassSetManager.reset();
|
|
131
|
-
}
|
|
132
|
-
return refreshRuntimeSet({ forceCollect: true });
|
|
133
|
-
}
|
|
134
|
-
async function refreshGulpSourceCandidates(forceRefresh = false) {
|
|
135
|
-
if (runtimeState.twPatcher.majorVersion !== 3) return /* @__PURE__ */ new Set();
|
|
136
|
-
const root = opts.tailwindcssBasedir ?? process.cwd();
|
|
137
|
-
const sourceScan = await resolveViteSourceScanEntries(opts, runtimeState.twPatcher, { root });
|
|
138
|
-
const nextSignature = cache.computeHash(JSON.stringify({
|
|
139
|
-
root,
|
|
140
|
-
entries: sourceScan?.entries,
|
|
141
|
-
inlineCandidates: sourceScan?.inlineCandidates ? {
|
|
142
|
-
included: [...sourceScan.inlineCandidates.included].sort(),
|
|
143
|
-
excluded: [...sourceScan.inlineCandidates.excluded].sort()
|
|
144
|
-
} : void 0,
|
|
145
|
-
explicit: sourceScan?.explicit ?? false,
|
|
146
|
-
dependencies: [...sourceScan?.dependencies ?? []].sort()
|
|
147
|
-
}));
|
|
148
|
-
if (!forceRefresh && cachedGulpSourceCandidateSignature === nextSignature && cachedGulpSourceCandidates) return cachedGulpSourceCandidates;
|
|
149
|
-
const collector = createSourceCandidateCollector({
|
|
150
|
-
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
151
|
-
extractor: sourceCandidateExtractor
|
|
152
|
-
});
|
|
153
|
-
await collector.scanRoot({
|
|
154
|
-
entries: sourceScan?.entries,
|
|
155
|
-
root
|
|
156
|
-
});
|
|
157
|
-
collector.syncInline(sourceScan?.inlineCandidates);
|
|
158
|
-
cachedGulpSourceCandidateSignature = nextSignature;
|
|
159
|
-
cachedGulpSourceCandidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
|
|
160
|
-
return cachedGulpSourceCandidates;
|
|
161
|
-
}
|
|
162
|
-
function createRuntimeSetHash(rawSource, nextRuntimeSet) {
|
|
163
|
-
return cache.computeHash([
|
|
164
|
-
rawSource,
|
|
165
|
-
getRuntimeClassSetSignature(runtimeState.twPatcher),
|
|
166
|
-
[...nextRuntimeSet].sort().join("\n")
|
|
167
|
-
].join("\n\n"));
|
|
168
|
-
}
|
|
169
|
-
async function registerAutoCssSource(file, rawSource) {
|
|
170
|
-
if (hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !file.path || !hasTailwindRootDirectives(rawSource)) return false;
|
|
171
|
-
const sourceFile = path.resolve(file.path);
|
|
172
|
-
const sourceCss = normalizeTailwindSourceForGenerator(normalizeTailwindConfigDirectives(rawSource, path.dirname(sourceFile)), { importFallback: true });
|
|
173
|
-
if (!upsertTailwindV4CssSource(opts, {
|
|
174
|
-
file: sourceFile,
|
|
175
|
-
base: path.dirname(sourceFile),
|
|
176
|
-
css: sourceCss
|
|
177
|
-
})) return false;
|
|
178
|
-
runtimeSetInitialized = false;
|
|
179
|
-
runtimeSetDirty = true;
|
|
180
|
-
await bundleRuntimeClassSetManager.reset();
|
|
181
|
-
debug("detected tailwindcss v4 css source from gulp css file: %s", file.path);
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
function resolveWithExtensions(base) {
|
|
185
|
-
for (const ext of MODULE_EXTENSIONS) {
|
|
186
|
-
const candidate = `${base}${ext}`;
|
|
187
|
-
try {
|
|
188
|
-
if (fs.statSync(candidate).isFile()) return candidate;
|
|
189
|
-
} catch {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function resolveLocalModuleCandidate(base) {
|
|
195
|
-
try {
|
|
196
|
-
const stat = fs.statSync(base);
|
|
197
|
-
if (stat.isFile()) return base;
|
|
198
|
-
if (stat.isDirectory()) {
|
|
199
|
-
const resolvedIndex = resolveWithExtensions(path.join(base, "index"));
|
|
200
|
-
if (resolvedIndex) return resolvedIndex;
|
|
201
|
-
}
|
|
202
|
-
} catch {}
|
|
203
|
-
if (!path.extname(base)) return resolveWithExtensions(base);
|
|
204
|
-
}
|
|
205
|
-
function createModuleGraphOptionsFor() {
|
|
206
|
-
return {
|
|
207
|
-
resolve(specifier, importer) {
|
|
208
|
-
if (!specifier) return;
|
|
209
|
-
if (!specifier.startsWith(".") && !path.isAbsolute(specifier)) return;
|
|
210
|
-
return resolveLocalModuleCandidate(path.resolve(path.dirname(importer), specifier));
|
|
211
|
-
},
|
|
212
|
-
load(id) {
|
|
213
|
-
try {
|
|
214
|
-
return fs.readFileSync(id, "utf8");
|
|
215
|
-
} catch {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
filter(id) {
|
|
220
|
-
const relative = path.relative(process.cwd(), id);
|
|
221
|
-
return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function resolveModuleGraphOptions(moduleGraph) {
|
|
226
|
-
if (moduleGraph) return moduleGraph;
|
|
227
|
-
if (!cachedDefaultModuleGraphOptions) cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
|
|
228
|
-
return cachedDefaultModuleGraphOptions;
|
|
229
|
-
}
|
|
230
|
-
function createVinylTransform(phase, handler) {
|
|
231
|
-
return new Transform({
|
|
232
|
-
objectMode: true,
|
|
233
|
-
async transform(file, _encoding, callback) {
|
|
234
|
-
const hmrTimingStartedAt = performance.now();
|
|
235
|
-
try {
|
|
236
|
-
await handler(file);
|
|
237
|
-
emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, { file: file.relative || path.basename(file.path) });
|
|
238
|
-
callback(null, file);
|
|
239
|
-
} catch (error) {
|
|
240
|
-
callback(error, file);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
function resolveWxssHandlerOptions(options) {
|
|
246
|
-
const majorVersion = runtimeState.twPatcher.majorVersion ?? "unknown";
|
|
247
|
-
if (!options || Object.keys(options).length === 0) {
|
|
248
|
-
let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
|
|
249
|
-
if (!cached) {
|
|
250
|
-
cached = runtimeState.twPatcher.majorVersion === void 0 ? {} : { majorVersion: runtimeState.twPatcher.majorVersion };
|
|
251
|
-
defaultStyleHandlerOptionsCache.set(majorVersion, cached);
|
|
252
|
-
}
|
|
253
|
-
return cached;
|
|
254
|
-
}
|
|
255
|
-
return runtimeState.twPatcher.majorVersion === void 0 ? { ...options } : {
|
|
256
|
-
majorVersion: runtimeState.twPatcher.majorVersion,
|
|
257
|
-
...options
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function resolveGulpMatcherName(file) {
|
|
261
|
-
return (file.relative || path.basename(file.path)).replaceAll(path.sep, "/");
|
|
262
|
-
}
|
|
263
|
-
function resolveWxssFileHandlerOptions(file, options) {
|
|
264
|
-
const resolved = resolveWxssHandlerOptions(options);
|
|
265
|
-
if (resolved.isMainChunk !== void 0) return resolved;
|
|
266
|
-
return {
|
|
267
|
-
...resolved,
|
|
268
|
-
isMainChunk: opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function resolveWxssUserHandlerOptions(options) {
|
|
272
|
-
return {
|
|
273
|
-
...resolveWxssHandlerOptions(options),
|
|
274
|
-
isMainChunk: false
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function resolveWxmlHandlerOptions(options) {
|
|
278
|
-
if (!options || Object.keys(options).length === 0) {
|
|
279
|
-
if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
|
|
280
|
-
cachedDefaultTemplateRuntimeSet = runtimeSet;
|
|
281
|
-
cachedDefaultTemplateHandlerOptions = { runtimeSet };
|
|
282
|
-
}
|
|
283
|
-
return cachedDefaultTemplateHandlerOptions;
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
runtimeSet,
|
|
287
|
-
...options
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
|
|
291
|
-
if (!file.contents) return;
|
|
292
|
-
const rawSource = file.contents.toString();
|
|
293
|
-
const cssSourceChanged = await registerAutoCssSource(file, rawSource);
|
|
294
|
-
const isMainChunk = opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType);
|
|
295
|
-
const shouldUseGenerator = runtimeState.twPatcher.majorVersion !== 3 || hasTailwindRootDirectives(rawSource);
|
|
296
|
-
let nextRuntimeSet = await refreshRuntimeSet({
|
|
297
|
-
forceRefresh: cssSourceChanged,
|
|
298
|
-
forceCollect: cssSourceChanged || runtimeState.twPatcher.majorVersion !== 4 && isMainChunk,
|
|
299
|
-
clearCache: cssSourceChanged
|
|
300
|
-
});
|
|
301
|
-
if (runtimeState.twPatcher.majorVersion === 3 && isMainChunk && shouldUseGenerator) {
|
|
302
|
-
const sourceCandidates = await refreshGulpSourceCandidates(cssSourceChanged);
|
|
303
|
-
if (sourceCandidates.size > 0) {
|
|
304
|
-
nextRuntimeSet = new Set([...nextRuntimeSet, ...sourceCandidates]);
|
|
305
|
-
runtimeSet = nextRuntimeSet;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
await processCachedTask({
|
|
309
|
-
cache,
|
|
310
|
-
cacheKey: file.path,
|
|
311
|
-
hash: createRuntimeSetHash(rawSource, nextRuntimeSet),
|
|
312
|
-
applyResult(source) {
|
|
313
|
-
file.contents = Buffer.from(source);
|
|
314
|
-
},
|
|
315
|
-
onCacheHit() {
|
|
316
|
-
debug("css cache hit: %s", file.path);
|
|
317
|
-
},
|
|
318
|
-
async transform() {
|
|
319
|
-
await runtimeState.readyPromise;
|
|
320
|
-
const cssHandlerOptions = resolveWxssFileHandlerOptions(file, options);
|
|
321
|
-
const css = (shouldUseGenerator ? await generateCssByGenerator({
|
|
322
|
-
opts,
|
|
323
|
-
runtimeState,
|
|
324
|
-
runtime: nextRuntimeSet,
|
|
325
|
-
rawSource,
|
|
326
|
-
file: file.path,
|
|
327
|
-
cssHandlerOptions,
|
|
328
|
-
cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
|
|
329
|
-
styleHandler,
|
|
330
|
-
debug
|
|
331
|
-
}) : void 0)?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
|
|
332
|
-
debug("css handle: %s", file.path);
|
|
333
|
-
return { result: css };
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
|
|
338
|
-
if (!file.contents) return;
|
|
339
|
-
const filename = path.resolve(file.path);
|
|
340
|
-
const rawSource = file.contents.toString();
|
|
341
|
-
await refreshRuntimeSetForSource(file, rawSource, "js");
|
|
342
|
-
await runtimeState.readyPromise;
|
|
343
|
-
const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
|
|
344
|
-
const handlerOptions = {
|
|
345
|
-
...options,
|
|
346
|
-
filename,
|
|
347
|
-
moduleGraph,
|
|
348
|
-
babelParserOptions: {
|
|
349
|
-
...options?.babelParserOptions ?? {},
|
|
350
|
-
sourceFilename: filename
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
if (runtimeState.twPatcher.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.twPatcher.majorVersion;
|
|
354
|
-
await processCachedTask({
|
|
355
|
-
cache,
|
|
356
|
-
cacheKey: file.path,
|
|
357
|
-
rawSource,
|
|
358
|
-
applyResult(source) {
|
|
359
|
-
file.contents = Buffer.from(source);
|
|
360
|
-
},
|
|
361
|
-
onCacheHit() {
|
|
362
|
-
debug("js cache hit: %s", file.path);
|
|
363
|
-
},
|
|
364
|
-
async transform() {
|
|
365
|
-
await runtimeState.readyPromise;
|
|
366
|
-
const currentSource = file.contents?.toString() ?? rawSource;
|
|
367
|
-
if (shouldSkipJsTransform(currentSource, {
|
|
368
|
-
...handlerOptions,
|
|
369
|
-
classNameSet: runtimeSet
|
|
370
|
-
})) return { result: currentSource };
|
|
371
|
-
const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
372
|
-
debug("js handle: %s", file.path);
|
|
373
|
-
return { result: code };
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
|
|
378
|
-
if (!file.contents) return;
|
|
379
|
-
const rawSource = file.contents.toString();
|
|
380
|
-
await refreshRuntimeSetForSource(file, rawSource, "html");
|
|
381
|
-
await runtimeState.readyPromise;
|
|
382
|
-
await processCachedTask({
|
|
383
|
-
cache,
|
|
384
|
-
cacheKey: file.path,
|
|
385
|
-
rawSource,
|
|
386
|
-
applyResult(source) {
|
|
387
|
-
file.contents = Buffer.from(source);
|
|
388
|
-
},
|
|
389
|
-
onCacheHit() {
|
|
390
|
-
debug("html cache hit: %s", file.path);
|
|
391
|
-
},
|
|
392
|
-
async transform() {
|
|
393
|
-
await runtimeState.readyPromise;
|
|
394
|
-
const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
|
|
395
|
-
debug("html handle: %s", file.path);
|
|
396
|
-
return { result: code };
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
return {
|
|
401
|
-
transformWxss,
|
|
402
|
-
transformWxml,
|
|
403
|
-
transformJs
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
//#endregion
|
|
1
|
+
import { t as createPlugins } from "./gulp-oE-Byqk6.mjs";
|
|
407
2
|
export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
|