weapp-tailwindcss 4.12.0 → 5.0.0-next.10
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/README.md +4 -5
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/babel/index.d.ts +3 -0
- package/dist/bundle-state-BWqi5ZyX.mjs +343 -0
- package/dist/bundle-state-EUbcdKqo.js +410 -0
- package/dist/bundlers/gulp/index.d.ts +7 -0
- package/dist/bundlers/shared/cache.d.ts +16 -0
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +3 -0
- package/dist/bundlers/shared/css-imports.d.ts +8 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +13 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +33 -0
- package/dist/bundlers/shared/module-graph.d.ts +5 -0
- package/dist/bundlers/shared/run-tasks.d.ts +2 -0
- package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
- package/dist/bundlers/vite/bundle-state.d.ts +43 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +22 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +34 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
- package/dist/bundlers/vite/index.d.ts +3 -0
- package/dist/bundlers/vite/js-precheck.d.ts +1 -0
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/query.d.ts +15 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +13 -0
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
- package/dist/bundlers/vite/source-candidates.d.ts +18 -0
- package/dist/bundlers/vite/source-scan.d.ts +8 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/vite/utils.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +10 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +14 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
- package/dist/cache/index.d.ts +38 -0
- package/dist/cache/md5.d.ts +1 -0
- package/dist/cache-BVAiJV3J.js +502 -0
- package/dist/cache-CHs4DXui.mjs +434 -0
- package/dist/chunk-8l464Juk.js +28 -0
- package/dist/cli/context.d.ts +13 -0
- package/dist/cli/doctor/constants.d.ts +7 -0
- package/dist/cli/doctor/types.d.ts +31 -0
- package/dist/cli/doctor.d.ts +4 -0
- package/dist/cli/helpers/options/format.d.ts +2 -0
- package/dist/cli/helpers/options/parse.d.ts +3 -0
- package/dist/cli/helpers/options/resolve.d.ts +1 -0
- package/dist/cli/helpers/options.d.ts +3 -0
- package/dist/cli/helpers.d.ts +4 -0
- package/dist/cli/mount-options.d.ts +4 -0
- package/dist/cli/types.d.ts +15 -0
- package/dist/cli/vscode-entry.d.ts +14 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +1985 -3574
- package/dist/cli.mjs +1962 -3554
- package/dist/constants-BG12WAKw.mjs +44 -0
- package/dist/constants-BeeyfJ9k.js +73 -0
- package/dist/constants.d.ts +12 -0
- package/dist/context/compiler-context-cache.d.ts +3 -0
- package/dist/context/custom-attributes.d.ts +2 -0
- package/dist/context/handlers.d.ts +6 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/logger.d.ts +4 -0
- package/dist/context/tailwindcss/basedir.d.ts +1 -0
- package/dist/context/tailwindcss/rax.d.ts +2 -0
- package/dist/context/tailwindcss.d.ts +4 -0
- package/dist/context/workspace.d.ts +3 -0
- package/dist/core.d.ts +5 -21
- package/dist/core.js +131 -180
- package/dist/core.mjs +129 -180
- package/dist/css-macro/constants.d.ts +14 -0
- package/dist/css-macro/index.d.ts +15 -0
- package/dist/css-macro/postcss.d.ts +3 -7
- package/dist/css-macro/postcss.js +44 -58
- package/dist/css-macro/postcss.mjs +44 -56
- package/dist/css-macro.d.ts +2 -20
- package/dist/css-macro.js +37 -50
- package/dist/css-macro.mjs +33 -47
- package/dist/debug/index.d.ts +5 -0
- package/dist/defaults.d.ts +16 -11
- package/dist/defaults.js +151 -8
- package/dist/defaults.mjs +143 -7
- package/dist/escape.js +31 -54
- package/dist/escape.mjs +18 -25
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/options.d.ts +16 -0
- package/dist/generator/types.d.ts +20 -0
- package/dist/generator-DKkhJbOg.js +1531 -0
- package/dist/generator-UBmfduYg.mjs +1432 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +19 -0
- package/dist/generator.mjs +2 -0
- package/dist/gulp.d.ts +4 -24
- package/dist/gulp.js +370 -13
- package/dist/gulp.mjs +362 -13
- package/dist/incremental-runtime-class-set-BYmzQ-_f.js +1555 -0
- package/dist/incremental-runtime-class-set-BgMW6wf2.mjs +1510 -0
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/index.mjs +6 -24
- package/dist/js/JsTokenUpdater.d.ts +14 -0
- package/dist/js/ModuleGraph.d.ts +18 -0
- package/dist/js/NodePathWalker.d.ts +33 -0
- package/dist/js/babel/parse.d.ts +9 -0
- package/dist/js/babel/process.d.ts +4 -0
- package/dist/js/babel.d.ts +13 -0
- package/dist/js/class-context.d.ts +3 -0
- package/dist/js/evalTransforms.d.ts +7 -0
- package/dist/js/handlers.d.ts +5 -0
- package/dist/js/index.d.ts +5 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/module-graph/ignored-exports.d.ts +18 -0
- package/dist/js/module-graph/types.d.ts +17 -0
- package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
- package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
- package/dist/js/precheck.d.ts +2 -0
- package/dist/js/sourceAnalysis.d.ts +17 -0
- package/dist/js/taggedTemplateIgnore.d.ts +13 -0
- package/dist/js/types.d.ts +11 -0
- package/dist/lightningcss/index.d.ts +8 -0
- package/dist/lightningcss/style-handler/options.d.ts +3 -0
- package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
- package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
- package/dist/lightningcss/style-handler.d.ts +17 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger-CZUxvJJD.mjs +2 -0
- package/dist/logger-EVNB9z7i.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-C7efq3hr.mjs +231 -0
- package/dist/postcss-Dg-_lyHS.js +240 -0
- package/dist/postcss-html-transform.d.ts +3 -3
- package/dist/postcss-html-transform.js +7 -10
- package/dist/postcss-html-transform.mjs +3 -6
- package/dist/postcss.d.ts +15 -0
- package/dist/postcss.js +7 -0
- package/dist/postcss.mjs +2 -0
- package/dist/precheck-B32p-gLI.js +2736 -0
- package/dist/precheck-B4RH6ZNN.mjs +2622 -0
- package/dist/presets/hbuilderx.d.ts +4 -0
- package/dist/presets/index.d.ts +3 -0
- package/dist/presets/shared.d.ts +10 -0
- package/dist/presets/taro.d.ts +4 -0
- package/dist/presets/uni-app-x.d.ts +16 -0
- package/dist/presets/uni-app.d.ts +4 -0
- package/dist/presets.d.ts +1 -76
- package/dist/presets.js +117 -163
- package/dist/presets.mjs +109 -163
- package/dist/reset/index.d.ts +2 -0
- package/dist/reset.d.ts +2 -4
- package/dist/reset.js +19 -8
- package/dist/reset.mjs +2 -8
- package/dist/runtime-patch-CwN5ya72.mjs +71 -0
- package/dist/runtime-patch-D6mBo_KB.js +85 -0
- package/dist/shared/classname-transform.d.ts +14 -0
- package/dist/shared/mpx.d.ts +7 -0
- package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
- package/dist/source-scan-BaYvNx-k.js +293 -0
- package/dist/source-scan-cGZxoJqP.mjs +254 -0
- package/dist/tailwindcss/index.d.ts +11 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -0
- package/dist/tailwindcss/patcher-options.d.ts +8 -0
- package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
- package/dist/tailwindcss/patcher.d.ts +12 -0
- package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
- package/dist/tailwindcss/runtime/cache.d.ts +11 -0
- package/dist/tailwindcss/runtime-logs.d.ts +3 -0
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +28 -0
- package/dist/tailwindcss/source-scan.d.ts +25 -0
- package/dist/tailwindcss/targets.d.ts +2 -0
- package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
- package/dist/tailwindcss/v4/config.d.ts +5 -0
- package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/index.d.ts +2 -0
- package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher.d.ts +15 -0
- package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +7 -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 +19 -0
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-Bu-RWIHx.js +630 -0
- package/dist/tailwindcss-C5IgPlQ0.mjs +579 -0
- package/dist/typedoc.export.d.ts +3 -0
- package/dist/types/base.d.ts +1 -0
- package/dist/types/index.d.ts +97 -0
- package/dist/types/shared.d.ts +10 -0
- package/dist/types/user-defined-options/general.d.ts +29 -0
- package/dist/types/user-defined-options/important.d.ts +37 -0
- package/dist/types/user-defined-options/index.d.ts +11 -0
- package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
- package/dist/types/user-defined-options/matcher.d.ts +9 -0
- package/dist/types.d.ts +1 -150
- package/dist/types.js +0 -1
- package/dist/types.mjs +1 -1
- package/dist/uni-app-x/component-local-style.d.ts +19 -0
- package/dist/uni-app-x/index.d.ts +2 -0
- package/dist/uni-app-x/options.d.ts +12 -0
- package/dist/uni-app-x/style-isolation.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +9 -0
- package/dist/uni-app-x/vite.d.ts +36 -0
- package/dist/utils/decode.d.ts +2 -0
- package/dist/utils/disabled.d.ts +5 -0
- package/dist/utils/hbuilderx.d.ts +5 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/nameMatcher.d.ts +4 -0
- package/dist/utils/resolve-package.d.ts +1 -0
- package/dist/utils/uni-platform.d.ts +11 -0
- package/dist/utils-BiShvil9.js +61 -0
- package/dist/utils-Btw1iOVV.mjs +48 -0
- package/dist/vite-BU74SkOi.mjs +2246 -0
- package/dist/vite-CKjx_5c3.js +2261 -0
- package/dist/vite.d.ts +3 -17
- package/dist/vite.js +4 -14
- package/dist/vite.mjs +2 -14
- package/dist/weapp-tw-css-import-rewrite-loader.js +68 -92
- package/dist/weapp-tw-runtime-classset-loader.js +31 -50
- package/dist/webpack-CAk_ITq7.mjs +713 -0
- package/dist/webpack-damWiYqY.js +723 -0
- package/dist/webpack.d.ts +4 -25
- package/dist/webpack.js +6 -17
- package/dist/webpack.mjs +2 -17
- package/dist/wxml/Tokenizer.d.ts +15 -0
- package/dist/wxml/custom-attributes.d.ts +4 -0
- package/dist/wxml/index.d.ts +2 -0
- package/dist/wxml/shared.d.ts +2 -0
- package/dist/wxml/tokenizer/types.d.ts +18 -0
- package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
- package/dist/wxml/utils/codegen.d.ts +2 -0
- package/dist/wxml/utils/custom-template.d.ts +3 -0
- package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
- package/dist/wxml/utils/fragment-updater.d.ts +4 -0
- package/dist/wxml/utils/template-fragments.d.ts +3 -0
- package/dist/wxml/utils.d.ts +8 -0
- package/dist/wxml/whitespace.d.ts +2 -0
- package/generator-placeholder.css +1 -0
- package/package.json +39 -38
- package/dist/chunk-24AGZQVR.js +0 -183
- package/dist/chunk-3VQKDHGP.mjs +0 -179
- package/dist/chunk-4AFQP74Z.js +0 -24
- package/dist/chunk-57SOQCAU.mjs +0 -582
- package/dist/chunk-5ZYHNDEK.mjs +0 -2439
- package/dist/chunk-76S2EME4.mjs +0 -34
- package/dist/chunk-A5PB4KZT.js +0 -138
- package/dist/chunk-DUHYLR2R.js +0 -276
- package/dist/chunk-DYLQ6UOI.js +0 -71
- package/dist/chunk-E7I5TW5K.js +0 -52
- package/dist/chunk-FS2NOOEB.js +0 -292
- package/dist/chunk-HVNGIKLS.js +0 -3930
- package/dist/chunk-JZQBZHN5.js +0 -579
- package/dist/chunk-KGTVD4EP.mjs +0 -3930
- package/dist/chunk-NNOQDMUP.mjs +0 -10
- package/dist/chunk-OF6MFURR.js +0 -34
- package/dist/chunk-OFB2KBRP.js +0 -2442
- package/dist/chunk-OOHJLO5M.mjs +0 -71
- package/dist/chunk-PCDYXXSK.mjs +0 -1515
- package/dist/chunk-RKISS72P.js +0 -7
- package/dist/chunk-RRQZL7FQ.mjs +0 -292
- package/dist/chunk-XAKAD2CR.mjs +0 -138
- package/dist/chunk-XZP3MREK.mjs +0 -276
- package/dist/chunk-ZAA5ZG3D.js +0 -1518
- package/dist/chunk-ZCH4YINE.mjs +0 -52
- package/dist/cli.d.mts +0 -2
- package/dist/core.d.mts +0 -26
- package/dist/css-macro/postcss.d.mts +0 -7
- package/dist/css-macro.d.mts +0 -18
- package/dist/defaults.d.mts +0 -11
- package/dist/gulp.d.mts +0 -24
- package/dist/index-BXrmQelt.d.mts +0 -672
- package/dist/index-BXrmQelt.d.ts +0 -672
- package/dist/index.d.mts +0 -15
- package/dist/postcss-html-transform.d.mts +0 -2
- package/dist/presets.d.mts +0 -76
- package/dist/reset.d.mts +0 -1
- package/dist/types.d.mts +0 -150
- package/dist/vite.d.mts +0 -17
- package/dist/webpack.d.mts +0 -25
- package/dist/webpack4.d.mts +0 -26
- package/dist/webpack4.d.ts +0 -26
- package/dist/webpack4.js +0 -493
- package/dist/webpack4.mjs +0 -495
- package/scripts/postinstall.mjs +0 -59
package/dist/gulp.mjs
CHANGED
|
@@ -1,13 +1,362 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { n as getRuntimeClassSetSignature } from "./cache-CHs4DXui.mjs";
|
|
2
|
+
import { n as createDebug } from "./runtime-patch-CwN5ya72.mjs";
|
|
3
|
+
import { a as hasTailwindRootDirectives, i as processCachedTask, n as generateCssByGenerator, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-BgMW6wf2.mjs";
|
|
4
|
+
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-B4RH6ZNN.mjs";
|
|
5
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-C5IgPlQ0.mjs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import fs from "node:fs";
|
|
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
|
+
const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
|
|
50
|
+
async function refreshRuntimeSet(options = false) {
|
|
51
|
+
const normalizedOptions = typeof options === "boolean" ? {
|
|
52
|
+
forceRefresh: options,
|
|
53
|
+
forceCollect: options,
|
|
54
|
+
clearCache: options
|
|
55
|
+
} : options;
|
|
56
|
+
const forceRefresh = normalizedOptions.forceRefresh === true;
|
|
57
|
+
const shouldForceCollect = normalizedOptions.forceCollect === true || runtimeSetDirty;
|
|
58
|
+
const clearCache = normalizedOptions.clearCache === true || runtimeSetDirty;
|
|
59
|
+
if (!forceRefresh && !shouldForceCollect && runtimeSetInitialized) return runtimeSet;
|
|
60
|
+
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
61
|
+
forceRefresh,
|
|
62
|
+
forceCollect: shouldForceCollect,
|
|
63
|
+
clearCache,
|
|
64
|
+
allowEmpty: false
|
|
65
|
+
});
|
|
66
|
+
runtimeSetInitialized = true;
|
|
67
|
+
runtimeSetDirty = false;
|
|
68
|
+
return runtimeSet;
|
|
69
|
+
}
|
|
70
|
+
function createRuntimeSnapshot(changedFiles) {
|
|
71
|
+
const runtimeAffectingChangedByType = {
|
|
72
|
+
html: /* @__PURE__ */ new Set(),
|
|
73
|
+
js: /* @__PURE__ */ new Set(),
|
|
74
|
+
css: /* @__PURE__ */ new Set(),
|
|
75
|
+
other: /* @__PURE__ */ new Set()
|
|
76
|
+
};
|
|
77
|
+
for (const file of changedFiles) {
|
|
78
|
+
const entry = runtimeSourcesByFile.get(file);
|
|
79
|
+
if (entry) runtimeAffectingChangedByType[entry.type].add(file);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
entries: [...runtimeSourcesByFile.entries()].map(([file, entry]) => ({
|
|
83
|
+
file,
|
|
84
|
+
output: {
|
|
85
|
+
fileName: file,
|
|
86
|
+
source: entry.source,
|
|
87
|
+
type: "asset"
|
|
88
|
+
},
|
|
89
|
+
source: entry.source,
|
|
90
|
+
type: entry.type
|
|
91
|
+
})),
|
|
92
|
+
jsEntries: /* @__PURE__ */ new Map(),
|
|
93
|
+
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
94
|
+
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
95
|
+
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
96
|
+
changedByType: {
|
|
97
|
+
html: /* @__PURE__ */ new Set(),
|
|
98
|
+
js: /* @__PURE__ */ new Set(),
|
|
99
|
+
css: /* @__PURE__ */ new Set(),
|
|
100
|
+
other: /* @__PURE__ */ new Set()
|
|
101
|
+
},
|
|
102
|
+
runtimeAffectingChangedByType,
|
|
103
|
+
processFiles: {
|
|
104
|
+
html: /* @__PURE__ */ new Set(),
|
|
105
|
+
js: /* @__PURE__ */ new Set(),
|
|
106
|
+
css: /* @__PURE__ */ new Set()
|
|
107
|
+
},
|
|
108
|
+
linkedImpactsByEntry: /* @__PURE__ */ new Map()
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function refreshRuntimeSetForSource(file, rawSource, type) {
|
|
112
|
+
const filename = path.resolve(file.path);
|
|
113
|
+
const hash = cache.computeHash(rawSource);
|
|
114
|
+
const changed = runtimeSourceHashByFile.get(filename) !== hash;
|
|
115
|
+
runtimeSourceHashByFile.set(filename, hash);
|
|
116
|
+
runtimeSourcesByFile.set(filename, {
|
|
117
|
+
source: rawSource,
|
|
118
|
+
type
|
|
119
|
+
});
|
|
120
|
+
if (!changed && runtimeSetInitialized) return runtimeSet;
|
|
121
|
+
if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
|
|
122
|
+
runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, createRuntimeSnapshot([filename]));
|
|
123
|
+
runtimeSetInitialized = true;
|
|
124
|
+
return runtimeSet;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
debug("gulp incremental runtime set sync failed, fallback to collect: %O", error);
|
|
127
|
+
await bundleRuntimeClassSetManager.reset();
|
|
128
|
+
}
|
|
129
|
+
return refreshRuntimeSet({ forceCollect: true });
|
|
130
|
+
}
|
|
131
|
+
function createRuntimeSetHash(rawSource, nextRuntimeSet) {
|
|
132
|
+
return cache.computeHash([
|
|
133
|
+
rawSource,
|
|
134
|
+
getRuntimeClassSetSignature(runtimeState.twPatcher),
|
|
135
|
+
[...nextRuntimeSet].sort().join("\n")
|
|
136
|
+
].join("\n\n"));
|
|
137
|
+
}
|
|
138
|
+
async function registerAutoCssSource(file, rawSource) {
|
|
139
|
+
if (hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !file.path || !hasTailwindRootDirectives(rawSource)) return false;
|
|
140
|
+
if (!upsertTailwindV4CssSource(opts, {
|
|
141
|
+
file: path.resolve(file.path),
|
|
142
|
+
css: rawSource
|
|
143
|
+
})) return false;
|
|
144
|
+
runtimeSetInitialized = false;
|
|
145
|
+
runtimeSetDirty = true;
|
|
146
|
+
await bundleRuntimeClassSetManager.reset();
|
|
147
|
+
debug("detected tailwindcss v4 css source from gulp css file: %s", file.path);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
function resolveWithExtensions(base) {
|
|
151
|
+
for (const ext of MODULE_EXTENSIONS) {
|
|
152
|
+
const candidate = `${base}${ext}`;
|
|
153
|
+
try {
|
|
154
|
+
if (fs.statSync(candidate).isFile()) return candidate;
|
|
155
|
+
} catch {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function resolveLocalModuleCandidate(base) {
|
|
161
|
+
try {
|
|
162
|
+
const stat = fs.statSync(base);
|
|
163
|
+
if (stat.isFile()) return base;
|
|
164
|
+
if (stat.isDirectory()) {
|
|
165
|
+
const resolvedIndex = resolveWithExtensions(path.join(base, "index"));
|
|
166
|
+
if (resolvedIndex) return resolvedIndex;
|
|
167
|
+
}
|
|
168
|
+
} catch {}
|
|
169
|
+
if (!path.extname(base)) return resolveWithExtensions(base);
|
|
170
|
+
}
|
|
171
|
+
function createModuleGraphOptionsFor() {
|
|
172
|
+
return {
|
|
173
|
+
resolve(specifier, importer) {
|
|
174
|
+
if (!specifier) return;
|
|
175
|
+
if (!specifier.startsWith(".") && !path.isAbsolute(specifier)) return;
|
|
176
|
+
return resolveLocalModuleCandidate(path.resolve(path.dirname(importer), specifier));
|
|
177
|
+
},
|
|
178
|
+
load(id) {
|
|
179
|
+
try {
|
|
180
|
+
return fs.readFileSync(id, "utf8");
|
|
181
|
+
} catch {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
filter(id) {
|
|
186
|
+
const relative = path.relative(process.cwd(), id);
|
|
187
|
+
return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function resolveModuleGraphOptions(moduleGraph) {
|
|
192
|
+
if (moduleGraph) return moduleGraph;
|
|
193
|
+
if (!cachedDefaultModuleGraphOptions) cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
|
|
194
|
+
return cachedDefaultModuleGraphOptions;
|
|
195
|
+
}
|
|
196
|
+
function createVinylTransform(handler) {
|
|
197
|
+
return new Transform({
|
|
198
|
+
objectMode: true,
|
|
199
|
+
async transform(file, _encoding, callback) {
|
|
200
|
+
try {
|
|
201
|
+
await handler(file);
|
|
202
|
+
callback(null, file);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
callback(error, file);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function resolveWxssHandlerOptions(options) {
|
|
210
|
+
const majorVersion = runtimeState.twPatcher.majorVersion ?? "unknown";
|
|
211
|
+
if (!options || Object.keys(options).length === 0) {
|
|
212
|
+
let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
|
|
213
|
+
if (!cached) {
|
|
214
|
+
cached = runtimeState.twPatcher.majorVersion === void 0 ? {} : { majorVersion: runtimeState.twPatcher.majorVersion };
|
|
215
|
+
defaultStyleHandlerOptionsCache.set(majorVersion, cached);
|
|
216
|
+
}
|
|
217
|
+
return cached;
|
|
218
|
+
}
|
|
219
|
+
return runtimeState.twPatcher.majorVersion === void 0 ? { ...options } : {
|
|
220
|
+
majorVersion: runtimeState.twPatcher.majorVersion,
|
|
221
|
+
...options
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function resolveGulpMatcherName(file) {
|
|
225
|
+
return (file.relative || path.basename(file.path)).replaceAll(path.sep, "/");
|
|
226
|
+
}
|
|
227
|
+
function resolveWxssFileHandlerOptions(file, options) {
|
|
228
|
+
const resolved = resolveWxssHandlerOptions(options);
|
|
229
|
+
if (resolved.isMainChunk !== void 0) return resolved;
|
|
230
|
+
return {
|
|
231
|
+
...resolved,
|
|
232
|
+
isMainChunk: opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function resolveWxssUserHandlerOptions(options) {
|
|
236
|
+
return {
|
|
237
|
+
...resolveWxssHandlerOptions(options),
|
|
238
|
+
isMainChunk: false
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function resolveWxmlHandlerOptions(options) {
|
|
242
|
+
if (!options || Object.keys(options).length === 0) {
|
|
243
|
+
if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
|
|
244
|
+
cachedDefaultTemplateRuntimeSet = runtimeSet;
|
|
245
|
+
cachedDefaultTemplateHandlerOptions = { runtimeSet };
|
|
246
|
+
}
|
|
247
|
+
return cachedDefaultTemplateHandlerOptions;
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
runtimeSet,
|
|
251
|
+
...options
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const transformWxss = (options = {}) => createVinylTransform(async (file) => {
|
|
255
|
+
if (!file.contents) return;
|
|
256
|
+
const rawSource = file.contents.toString();
|
|
257
|
+
const cssSourceChanged = await registerAutoCssSource(file, rawSource);
|
|
258
|
+
const nextRuntimeSet = await refreshRuntimeSet({
|
|
259
|
+
forceRefresh: cssSourceChanged,
|
|
260
|
+
forceCollect: cssSourceChanged || opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType),
|
|
261
|
+
clearCache: cssSourceChanged
|
|
262
|
+
});
|
|
263
|
+
await processCachedTask({
|
|
264
|
+
cache,
|
|
265
|
+
cacheKey: file.path,
|
|
266
|
+
hash: createRuntimeSetHash(rawSource, nextRuntimeSet),
|
|
267
|
+
applyResult(source) {
|
|
268
|
+
file.contents = Buffer.from(source);
|
|
269
|
+
},
|
|
270
|
+
onCacheHit() {
|
|
271
|
+
debug("css cache hit: %s", file.path);
|
|
272
|
+
},
|
|
273
|
+
async transform() {
|
|
274
|
+
await runtimeState.readyPromise;
|
|
275
|
+
const cssHandlerOptions = resolveWxssFileHandlerOptions(file, options);
|
|
276
|
+
const css = (await generateCssByGenerator({
|
|
277
|
+
opts,
|
|
278
|
+
runtimeState,
|
|
279
|
+
runtime: nextRuntimeSet,
|
|
280
|
+
rawSource,
|
|
281
|
+
file: file.path,
|
|
282
|
+
cssHandlerOptions,
|
|
283
|
+
cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
|
|
284
|
+
styleHandler,
|
|
285
|
+
debug
|
|
286
|
+
}))?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
|
|
287
|
+
debug("css handle: %s", file.path);
|
|
288
|
+
return { result: css };
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
const transformJs = (options = {}) => createVinylTransform(async (file) => {
|
|
293
|
+
if (!file.contents) return;
|
|
294
|
+
const filename = path.resolve(file.path);
|
|
295
|
+
const rawSource = file.contents.toString();
|
|
296
|
+
await refreshRuntimeSetForSource(file, rawSource, "js");
|
|
297
|
+
await runtimeState.readyPromise;
|
|
298
|
+
const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
|
|
299
|
+
const handlerOptions = {
|
|
300
|
+
...options,
|
|
301
|
+
filename,
|
|
302
|
+
moduleGraph,
|
|
303
|
+
babelParserOptions: {
|
|
304
|
+
...options?.babelParserOptions ?? {},
|
|
305
|
+
sourceFilename: filename
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
if (runtimeState.twPatcher.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.twPatcher.majorVersion;
|
|
309
|
+
await processCachedTask({
|
|
310
|
+
cache,
|
|
311
|
+
cacheKey: file.path,
|
|
312
|
+
rawSource,
|
|
313
|
+
applyResult(source) {
|
|
314
|
+
file.contents = Buffer.from(source);
|
|
315
|
+
},
|
|
316
|
+
onCacheHit() {
|
|
317
|
+
debug("js cache hit: %s", file.path);
|
|
318
|
+
},
|
|
319
|
+
async transform() {
|
|
320
|
+
await runtimeState.readyPromise;
|
|
321
|
+
const currentSource = file.contents?.toString() ?? rawSource;
|
|
322
|
+
if (shouldSkipJsTransform(currentSource, {
|
|
323
|
+
...handlerOptions,
|
|
324
|
+
classNameSet: runtimeSet
|
|
325
|
+
})) return { result: currentSource };
|
|
326
|
+
const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
327
|
+
debug("js handle: %s", file.path);
|
|
328
|
+
return { result: code };
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
const transformWxml = (options = {}) => createVinylTransform(async (file) => {
|
|
333
|
+
if (!file.contents) return;
|
|
334
|
+
const rawSource = file.contents.toString();
|
|
335
|
+
await refreshRuntimeSetForSource(file, rawSource, "html");
|
|
336
|
+
await runtimeState.readyPromise;
|
|
337
|
+
await processCachedTask({
|
|
338
|
+
cache,
|
|
339
|
+
cacheKey: file.path,
|
|
340
|
+
rawSource,
|
|
341
|
+
applyResult(source) {
|
|
342
|
+
file.contents = Buffer.from(source);
|
|
343
|
+
},
|
|
344
|
+
onCacheHit() {
|
|
345
|
+
debug("html cache hit: %s", file.path);
|
|
346
|
+
},
|
|
347
|
+
async transform() {
|
|
348
|
+
await runtimeState.readyPromise;
|
|
349
|
+
const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
|
|
350
|
+
debug("html handle: %s", file.path);
|
|
351
|
+
return { result: code };
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
return {
|
|
356
|
+
transformWxss,
|
|
357
|
+
transformWxml,
|
|
358
|
+
transformJs
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
//#endregion
|
|
362
|
+
export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
|