weapp-tailwindcss 4.12.0 → 5.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/index.d.ts +3 -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.d.ts +4 -0
- package/dist/bundlers/shared/css-imports.d.ts +8 -0
- package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +41 -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 +19 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +20 -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/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 +11 -0
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
- package/dist/bundlers/vite/utils.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
- package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -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/chunk-8l464Juk.js +28 -0
- package/dist/cli/config.d.ts +5 -0
- package/dist/cli/context.d.ts +16 -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/patch-cwd.d.ts +1 -0
- package/dist/cli/helpers.d.ts +5 -0
- package/dist/cli/mount-options/patch-status.d.ts +2 -0
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/patch-options.d.ts +6 -0
- package/dist/cli/tokens.d.ts +4 -0
- package/dist/cli/types.d.ts +17 -0
- package/dist/cli/vscode-entry.d.ts +14 -0
- package/dist/cli/workspace/package-dirs.d.ts +3 -0
- package/dist/cli/workspace/patch-package.d.ts +3 -0
- package/dist/cli/workspace/patch-utils.d.ts +3 -0
- package/dist/cli/workspace/types.d.ts +11 -0
- package/dist/cli/workspace/workspace-globs.d.ts +2 -0
- package/dist/cli/workspace/workspace-io.d.ts +1 -0
- package/dist/cli/workspace/workspace-lock.d.ts +1 -0
- package/dist/cli/workspace.d.ts +2 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2425 -3524
- package/dist/cli.mjs +2402 -3505
- package/dist/constants-B-_T5UnW.mjs +44 -0
- package/dist/constants-p1dyh1x1.js +73 -0
- package/dist/constants.d.ts +13 -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 +138 -180
- package/dist/core.mjs +135 -180
- package/dist/css-imports-BbrbluP9.js +177 -0
- package/dist/css-imports-CSdPq_Sc.mjs +128 -0
- 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 +1 -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 +2 -11
- package/dist/defaults.js +132 -8
- package/dist/defaults.mjs +128 -7
- package/dist/escape.js +31 -54
- package/dist/escape.mjs +18 -25
- package/dist/experimental/index.d.ts +2 -0
- package/dist/experimental/oxc/ast-utils.d.ts +30 -0
- package/dist/experimental/oxc/index.d.ts +2 -0
- package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
- package/dist/experimental/shared/cache.d.ts +3 -0
- package/dist/experimental/shared/transform.d.ts +3 -0
- package/dist/experimental/shared.d.ts +8 -0
- package/dist/experimental/swc/ast-utils.d.ts +30 -0
- package/dist/experimental/swc/index.d.ts +2 -0
- package/dist/experimental/swc/module-specifiers.d.ts +2 -0
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/options.d.ts +15 -0
- package/dist/generator/types.d.ts +19 -0
- package/dist/generator-CZ-JXw6T.js +492 -0
- package/dist/generator-Dwxgra97.mjs +399 -0
- package/dist/generator-css-CnYjiMrD.js +1084 -0
- package/dist/generator-css-DhPFjSzK.mjs +1057 -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 +271 -13
- package/dist/gulp.mjs +263 -13
- 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 +4 -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/syntax.d.ts +10 -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/loader-anchors-DvwgIYdA.mjs +205 -0
- package/dist/loader-anchors-cprm4Klq.js +273 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger-BZ45DZJT.js +1003 -0
- package/dist/logger-BoVx1Dbt.mjs +935 -0
- package/dist/patcher-options-6gJN2EXy.js +115 -0
- package/dist/patcher-options-DQfR5xxT.mjs +92 -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 +278 -0
- package/dist/postcss.mjs +268 -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 +115 -163
- package/dist/presets.mjs +107 -163
- package/dist/recorder-B_XyZ576.mjs +2763 -0
- package/dist/recorder-rn_2v_nd.js +2878 -0
- package/dist/reset/index.d.ts +2 -0
- package/dist/reset.d.ts +1 -4
- package/dist/reset.js +19 -8
- package/dist/reset.mjs +2 -8
- 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/tailwindcss/index.d.ts +11 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/patcher-options.d.ts +56 -0
- package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
- package/dist/tailwindcss/patcher.d.ts +13 -0
- package/dist/tailwindcss/recorder.d.ts +13 -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.d.ts +29 -0
- package/dist/tailwindcss/targets/paths.d.ts +13 -0
- package/dist/tailwindcss/targets/record-io.d.ts +5 -0
- package/dist/tailwindcss/targets/recorder.d.ts +3 -0
- package/dist/tailwindcss/targets/types.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +6 -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/index.d.ts +2 -0
- package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
- package/dist/tailwindcss/v4/patcher.d.ts +14 -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 +4 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
- package/dist/typedoc.export.d.ts +5 -0
- package/dist/types/base.d.ts +1 -0
- package/dist/types/disabled-options.d.ts +4 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/shared.d.ts +7 -0
- package/dist/types/user-defined-options/general.d.ts +31 -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 +6 -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-7DUGTFED.mjs +48 -0
- package/dist/utils-DmC9_In3.js +61 -0
- package/dist/vite-BHpAqldo.js +1952 -0
- package/dist/vite-C8JlHiyR.mjs +1940 -0
- package/dist/vite.d.ts +4 -17
- package/dist/vite.js +5 -14
- package/dist/vite.mjs +2 -14
- package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
- package/dist/weapp-tw-runtime-classset-loader.js +31 -50
- package/dist/webpack-CABjKGGQ.mjs +441 -0
- package/dist/webpack-DNIJ0ysE.js +456 -0
- package/dist/webpack.d.ts +4 -25
- package/dist/webpack.js +6 -17
- package/dist/webpack.mjs +2 -17
- package/dist/webpack4.d.ts +4 -26
- package/dist/webpack4.js +375 -481
- package/dist/webpack4.mjs +366 -482
- 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 +19 -5
- 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/core.mjs
CHANGED
|
@@ -1,185 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
getCompilerContext,
|
|
4
|
-
setupPatchRecorder,
|
|
5
|
-
shouldSkipJsTransform
|
|
6
|
-
} from "./chunk-KGTVD4EP.mjs";
|
|
7
|
-
import "./chunk-PCDYXXSK.mjs";
|
|
8
|
-
import "./chunk-XAKAD2CR.mjs";
|
|
9
|
-
import "./chunk-OOHJLO5M.mjs";
|
|
10
|
-
import "./chunk-NNOQDMUP.mjs";
|
|
11
|
-
|
|
12
|
-
// src/core.ts
|
|
13
|
-
import process from "process";
|
|
1
|
+
import { g as ensureRuntimeClassSet, n as shouldSkipJsTransform, r as getCompilerContext, t as setupPatchRecorder } from "./recorder-B_XyZ576.mjs";
|
|
2
|
+
import process from "node:process";
|
|
14
3
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
4
|
+
//#region src/core.ts
|
|
5
|
+
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
|
18
6
|
function resolveTransformWxssOptions(options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (options.isMainChunk === true) {
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
25
|
-
return defuOverrideArray(options, DEFAULT_MAIN_CHUNK_STYLE_OPTIONS);
|
|
7
|
+
if (!options) return DEFAULT_MAIN_CHUNK_STYLE_OPTIONS;
|
|
8
|
+
if (options.isMainChunk === true) return options;
|
|
9
|
+
return defuOverrideArray(options, DEFAULT_MAIN_CHUNK_STYLE_OPTIONS);
|
|
26
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 创建一个上下文对象,用于处理小程序的模板、样式和脚本转换。
|
|
13
|
+
* @param options - 用户定义的选项对象
|
|
14
|
+
* @returns 返回一个包含 transformWxss、transformWxml 和 transformJs 方法的对象
|
|
15
|
+
*/
|
|
27
16
|
function createContext(options = {}) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
forceCollect: true
|
|
150
|
-
});
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
async function transformJs(rawJs, options2) {
|
|
154
|
-
await runtimeState.patchPromise;
|
|
155
|
-
if (options2?.runtimeSet) {
|
|
156
|
-
runtimeSet = options2.runtimeSet;
|
|
157
|
-
} else if (runtimeSet.size === 0) {
|
|
158
|
-
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
159
|
-
forceCollect: true
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const resolvedOptions = resolveTransformJsOptions(options2);
|
|
163
|
-
if (shouldSkipJsTransform(rawJs, resolvedOptions)) {
|
|
164
|
-
return { code: rawJs };
|
|
165
|
-
}
|
|
166
|
-
return await jsHandler(rawJs, runtimeSet, resolvedOptions);
|
|
167
|
-
}
|
|
168
|
-
async function transformWxml(rawWxml, options2) {
|
|
169
|
-
await runtimeState.patchPromise;
|
|
170
|
-
if (!options2?.runtimeSet && runtimeSet.size === 0) {
|
|
171
|
-
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
172
|
-
forceCollect: true
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return templateHandler(rawWxml, resolveTransformWxmlOptions(options2));
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
transformWxss,
|
|
179
|
-
transformWxml,
|
|
180
|
-
transformJs
|
|
181
|
-
};
|
|
17
|
+
const opts = getCompilerContext(options);
|
|
18
|
+
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
19
|
+
const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
|
|
20
|
+
source: "runtime",
|
|
21
|
+
cwd: opts.tailwindcssBasedir ?? process.cwd()
|
|
22
|
+
});
|
|
23
|
+
let runtimeSet = /* @__PURE__ */ new Set();
|
|
24
|
+
const runtimeState = {
|
|
25
|
+
twPatcher: initialTwPatcher,
|
|
26
|
+
patchPromise: patchRecorderState.patchPromise,
|
|
27
|
+
refreshTailwindcssPatcher,
|
|
28
|
+
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
29
|
+
};
|
|
30
|
+
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
31
|
+
function getDefaultJsHandlerOptions(majorVersion = runtimeState.twPatcher.majorVersion) {
|
|
32
|
+
if (typeof majorVersion !== "number") return;
|
|
33
|
+
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
34
|
+
if (!cached) {
|
|
35
|
+
cached = { tailwindcssMajorVersion: majorVersion };
|
|
36
|
+
defaultJsHandlerOptionsCache.set(majorVersion, cached);
|
|
37
|
+
}
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
function withRuntimeTailwindMajorVersion(options) {
|
|
41
|
+
if (!options) return getDefaultJsHandlerOptions();
|
|
42
|
+
if (typeof options.tailwindcssMajorVersion === "number") return options;
|
|
43
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
44
|
+
if (typeof majorVersion !== "number") return options;
|
|
45
|
+
return {
|
|
46
|
+
...options,
|
|
47
|
+
tailwindcssMajorVersion: majorVersion
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function resolveTransformJsOptions(options) {
|
|
51
|
+
if (!options) return getDefaultJsHandlerOptions();
|
|
52
|
+
let hasHandlerOption = false;
|
|
53
|
+
let runtimeSetProvided = false;
|
|
54
|
+
for (const key in options) {
|
|
55
|
+
if (key === "runtimeSet") {
|
|
56
|
+
runtimeSetProvided = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
hasHandlerOption = true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
if (!hasHandlerOption) return getDefaultJsHandlerOptions();
|
|
63
|
+
if (!runtimeSetProvided && typeof options.tailwindcssMajorVersion === "number") return options;
|
|
64
|
+
if (runtimeSetProvided) {
|
|
65
|
+
const { runtimeSet: _runtimeSet, ...handlerOptions } = options;
|
|
66
|
+
return withRuntimeTailwindMajorVersion(handlerOptions);
|
|
67
|
+
}
|
|
68
|
+
return withRuntimeTailwindMajorVersion(options);
|
|
69
|
+
}
|
|
70
|
+
const runtimeAwareTemplateJsHandler = (source, runtime, handlerOptions) => {
|
|
71
|
+
return jsHandler(source, runtime, withRuntimeTailwindMajorVersion(handlerOptions));
|
|
72
|
+
};
|
|
73
|
+
let cachedDefaultTemplateHandlerOptions;
|
|
74
|
+
let cachedDefaultTemplateRuntimeSet;
|
|
75
|
+
let cachedRuntimeOnlyTemplateHandlerOptions;
|
|
76
|
+
let cachedRuntimeOnlyTemplateRuntimeSet;
|
|
77
|
+
function getDefaultTemplateHandlerOptions() {
|
|
78
|
+
if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
|
|
79
|
+
cachedDefaultTemplateRuntimeSet = runtimeSet;
|
|
80
|
+
cachedDefaultTemplateHandlerOptions = {
|
|
81
|
+
runtimeSet,
|
|
82
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return cachedDefaultTemplateHandlerOptions;
|
|
86
|
+
}
|
|
87
|
+
function resolveTransformWxmlOptions(options) {
|
|
88
|
+
if (!options) return getDefaultTemplateHandlerOptions();
|
|
89
|
+
let hasOverride = false;
|
|
90
|
+
for (const key in options) if (key !== "runtimeSet") {
|
|
91
|
+
hasOverride = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (!hasOverride) {
|
|
95
|
+
const runtimeOverride = options.runtimeSet;
|
|
96
|
+
if (runtimeOverride === void 0 || runtimeOverride === runtimeSet) return getDefaultTemplateHandlerOptions();
|
|
97
|
+
if (cachedRuntimeOnlyTemplateRuntimeSet !== runtimeOverride || !cachedRuntimeOnlyTemplateHandlerOptions) {
|
|
98
|
+
cachedRuntimeOnlyTemplateRuntimeSet = runtimeOverride;
|
|
99
|
+
cachedRuntimeOnlyTemplateHandlerOptions = {
|
|
100
|
+
runtimeSet: runtimeOverride,
|
|
101
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return cachedRuntimeOnlyTemplateHandlerOptions;
|
|
105
|
+
}
|
|
106
|
+
return defuOverrideArray(options, {
|
|
107
|
+
runtimeSet,
|
|
108
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function transformWxss(rawCss, options) {
|
|
112
|
+
await runtimeState.patchPromise;
|
|
113
|
+
const result = await styleHandler(rawCss, resolveTransformWxssOptions(options));
|
|
114
|
+
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
115
|
+
forceRefresh: true,
|
|
116
|
+
forceCollect: true
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
async function transformJs(rawJs, options) {
|
|
121
|
+
await runtimeState.patchPromise;
|
|
122
|
+
if (options?.runtimeSet) runtimeSet = options.runtimeSet;
|
|
123
|
+
else if (runtimeSet.size === 0) runtimeSet = await ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
124
|
+
const resolvedOptions = resolveTransformJsOptions(options);
|
|
125
|
+
if (shouldSkipJsTransform(rawJs, resolvedOptions)) return { code: rawJs };
|
|
126
|
+
return await jsHandler(rawJs, runtimeSet, resolvedOptions);
|
|
127
|
+
}
|
|
128
|
+
async function transformWxml(rawWxml, options) {
|
|
129
|
+
await runtimeState.patchPromise;
|
|
130
|
+
if (!options?.runtimeSet && runtimeSet.size === 0) runtimeSet = await ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
131
|
+
return templateHandler(rawWxml, resolveTransformWxmlOptions(options));
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
transformWxss,
|
|
135
|
+
transformWxml,
|
|
136
|
+
transformJs
|
|
137
|
+
};
|
|
182
138
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
139
|
+
//#endregion
|
|
140
|
+
export { createContext };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
+
let node_module = require("node:module");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
node_path = require_chunk.__toESM(node_path);
|
|
5
|
+
//#region src/bundlers/shared/module-graph.ts
|
|
6
|
+
const QUERY_HASH_RE = /[?#].*$/u;
|
|
7
|
+
const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
8
|
+
const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
|
|
9
|
+
const VIRTUAL_PREFIX = "\0";
|
|
10
|
+
const JS_EXTENSIONS = [
|
|
11
|
+
".js",
|
|
12
|
+
".mjs",
|
|
13
|
+
".cjs"
|
|
14
|
+
];
|
|
15
|
+
function normalizeOutputPathKey(value) {
|
|
16
|
+
return node_path.default.normalize(value).replace(/\\/g, "/");
|
|
17
|
+
}
|
|
18
|
+
function stripQueryAndHash(specifier) {
|
|
19
|
+
return specifier.replace(QUERY_HASH_RE, "");
|
|
20
|
+
}
|
|
21
|
+
function isResolvableSpecifier(specifier) {
|
|
22
|
+
if (!specifier) return false;
|
|
23
|
+
const normalized = stripQueryAndHash(specifier);
|
|
24
|
+
if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
|
|
25
|
+
if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
|
|
26
|
+
return !PROTOCOL_RE.test(normalized);
|
|
27
|
+
}
|
|
28
|
+
function toAbsoluteOutputPath(fileName, outDir) {
|
|
29
|
+
if (node_path.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return node_path.default.normalize(fileName);
|
|
30
|
+
return node_path.default.resolve(outDir, fileName);
|
|
31
|
+
}
|
|
32
|
+
function matchWithExtensions(candidate, hasOutput) {
|
|
33
|
+
if (hasOutput(candidate)) return candidate;
|
|
34
|
+
if (!node_path.default.extname(candidate)) for (const ext of JS_EXTENSIONS) {
|
|
35
|
+
const extended = `${candidate}${ext}`;
|
|
36
|
+
if (hasOutput(extended)) return extended;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
40
|
+
if (!isResolvableSpecifier(specifier)) return;
|
|
41
|
+
const normalized = stripQueryAndHash(specifier);
|
|
42
|
+
let candidate;
|
|
43
|
+
if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = node_path.default.normalize(normalized);
|
|
44
|
+
else if (normalized.startsWith("/")) candidate = node_path.default.resolve(outDir, normalized.slice(1));
|
|
45
|
+
else candidate = node_path.default.resolve(node_path.default.dirname(importer), normalized);
|
|
46
|
+
return matchWithExtensions(candidate, hasOutput);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/utils/disabled.ts
|
|
50
|
+
function resolveDisabledOptions(disabled) {
|
|
51
|
+
if (disabled === true) return {
|
|
52
|
+
plugin: true,
|
|
53
|
+
rewriteCssImports: false
|
|
54
|
+
};
|
|
55
|
+
if (disabled === false || disabled == null) return {
|
|
56
|
+
plugin: false,
|
|
57
|
+
rewriteCssImports: false
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
plugin: disabled.plugin ?? false,
|
|
61
|
+
rewriteCssImports: disabled.rewriteCssImports ?? false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/utils/resolve-package.ts
|
|
66
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
67
|
+
function resolvePackageDir(name) {
|
|
68
|
+
const pkgPath = require$1.resolve(`${name}/package.json`);
|
|
69
|
+
return node_path.default.dirname(pkgPath);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/bundlers/shared/run-tasks.ts
|
|
73
|
+
async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
|
|
74
|
+
if (factories.length === 0) return [];
|
|
75
|
+
const results = Array.from({ length: factories.length });
|
|
76
|
+
const executing = /* @__PURE__ */ new Set();
|
|
77
|
+
let cursor = 0;
|
|
78
|
+
const effectiveLimit = Math.max(1, limit);
|
|
79
|
+
const scheduleNext = () => {
|
|
80
|
+
if (cursor >= factories.length) return;
|
|
81
|
+
const currentIndex = cursor++;
|
|
82
|
+
const wrapped = Promise.resolve(factories[currentIndex]()).then((value) => {
|
|
83
|
+
results[currentIndex] = value;
|
|
84
|
+
}).finally(() => {
|
|
85
|
+
executing.delete(wrapped);
|
|
86
|
+
});
|
|
87
|
+
executing.add(wrapped);
|
|
88
|
+
};
|
|
89
|
+
while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
|
|
90
|
+
while (cursor < factories.length) {
|
|
91
|
+
await Promise.race(executing);
|
|
92
|
+
scheduleNext();
|
|
93
|
+
}
|
|
94
|
+
await Promise.all(executing);
|
|
95
|
+
return results;
|
|
96
|
+
}
|
|
97
|
+
function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
98
|
+
if (factories.length === 0) return;
|
|
99
|
+
queue.push(runWithConcurrency(factories, limit).then(() => void 0));
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/bundlers/shared/css-imports.ts
|
|
103
|
+
const tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
104
|
+
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
105
|
+
function normalizeTailwindcssSpecifier(specifier) {
|
|
106
|
+
if (specifier === "tailwindcss$") return "tailwindcss";
|
|
107
|
+
return specifier;
|
|
108
|
+
}
|
|
109
|
+
function getTailwindcssSubpath(specifier) {
|
|
110
|
+
if (specifier === "tailwindcss") return "index.css";
|
|
111
|
+
return specifier.slice(12);
|
|
112
|
+
}
|
|
113
|
+
function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
114
|
+
const normalized = normalizeTailwindcssSpecifier(specifier);
|
|
115
|
+
if (!tailwindcssImportRE.test(normalized)) return null;
|
|
116
|
+
if (normalized === "tailwindcss") return options?.rootImport ?? "weapp-tailwindcss/index.css";
|
|
117
|
+
return (options?.join ?? node_path.default.join)(pkgDir, getTailwindcssSubpath(normalized));
|
|
118
|
+
}
|
|
119
|
+
function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
120
|
+
let hasReplacements = false;
|
|
121
|
+
const rewritten = code.replace(tailwindcssCssImportStatementRE, (full, prefix, quote, specifier, suffix) => {
|
|
122
|
+
const replacement = resolveTailwindcssImport(specifier, pkgDir, options);
|
|
123
|
+
if (!replacement) return full;
|
|
124
|
+
hasReplacements = true;
|
|
125
|
+
return `${prefix}${quote}${replacement}${suffix}`;
|
|
126
|
+
});
|
|
127
|
+
return hasReplacements ? rewritten : void 0;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
Object.defineProperty(exports, "normalizeOutputPathKey", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function() {
|
|
133
|
+
return normalizeOutputPathKey;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, "pushConcurrentTaskFactories", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function() {
|
|
139
|
+
return pushConcurrentTaskFactories;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(exports, "resolveDisabledOptions", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function() {
|
|
145
|
+
return resolveDisabledOptions;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "resolveOutputSpecifier", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function() {
|
|
151
|
+
return resolveOutputSpecifier;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(exports, "resolvePackageDir", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function() {
|
|
157
|
+
return resolvePackageDir;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "resolveTailwindcssImport", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function() {
|
|
163
|
+
return resolveTailwindcssImport;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "rewriteTailwindcssImportsInCode", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function() {
|
|
169
|
+
return rewriteTailwindcssImportsInCode;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "toAbsoluteOutputPath", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function() {
|
|
175
|
+
return toAbsoluteOutputPath;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/bundlers/shared/module-graph.ts
|
|
4
|
+
const QUERY_HASH_RE = /[?#].*$/u;
|
|
5
|
+
const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
6
|
+
const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
|
|
7
|
+
const VIRTUAL_PREFIX = "\0";
|
|
8
|
+
const JS_EXTENSIONS = [
|
|
9
|
+
".js",
|
|
10
|
+
".mjs",
|
|
11
|
+
".cjs"
|
|
12
|
+
];
|
|
13
|
+
function normalizeOutputPathKey(value) {
|
|
14
|
+
return path.normalize(value).replace(/\\/g, "/");
|
|
15
|
+
}
|
|
16
|
+
function stripQueryAndHash(specifier) {
|
|
17
|
+
return specifier.replace(QUERY_HASH_RE, "");
|
|
18
|
+
}
|
|
19
|
+
function isResolvableSpecifier(specifier) {
|
|
20
|
+
if (!specifier) return false;
|
|
21
|
+
const normalized = stripQueryAndHash(specifier);
|
|
22
|
+
if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
|
|
23
|
+
if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
|
|
24
|
+
return !PROTOCOL_RE.test(normalized);
|
|
25
|
+
}
|
|
26
|
+
function toAbsoluteOutputPath(fileName, outDir) {
|
|
27
|
+
if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
|
|
28
|
+
return path.resolve(outDir, fileName);
|
|
29
|
+
}
|
|
30
|
+
function matchWithExtensions(candidate, hasOutput) {
|
|
31
|
+
if (hasOutput(candidate)) return candidate;
|
|
32
|
+
if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
|
|
33
|
+
const extended = `${candidate}${ext}`;
|
|
34
|
+
if (hasOutput(extended)) return extended;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
38
|
+
if (!isResolvableSpecifier(specifier)) return;
|
|
39
|
+
const normalized = stripQueryAndHash(specifier);
|
|
40
|
+
let candidate;
|
|
41
|
+
if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
|
|
42
|
+
else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
|
|
43
|
+
else candidate = path.resolve(path.dirname(importer), normalized);
|
|
44
|
+
return matchWithExtensions(candidate, hasOutput);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/utils/disabled.ts
|
|
48
|
+
function resolveDisabledOptions(disabled) {
|
|
49
|
+
if (disabled === true) return {
|
|
50
|
+
plugin: true,
|
|
51
|
+
rewriteCssImports: false
|
|
52
|
+
};
|
|
53
|
+
if (disabled === false || disabled == null) return {
|
|
54
|
+
plugin: false,
|
|
55
|
+
rewriteCssImports: false
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
plugin: disabled.plugin ?? false,
|
|
59
|
+
rewriteCssImports: disabled.rewriteCssImports ?? false
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils/resolve-package.ts
|
|
64
|
+
const require = createRequire(import.meta.url);
|
|
65
|
+
function resolvePackageDir(name) {
|
|
66
|
+
const pkgPath = require.resolve(`${name}/package.json`);
|
|
67
|
+
return path.dirname(pkgPath);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/bundlers/shared/run-tasks.ts
|
|
71
|
+
async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
|
|
72
|
+
if (factories.length === 0) return [];
|
|
73
|
+
const results = Array.from({ length: factories.length });
|
|
74
|
+
const executing = /* @__PURE__ */ new Set();
|
|
75
|
+
let cursor = 0;
|
|
76
|
+
const effectiveLimit = Math.max(1, limit);
|
|
77
|
+
const scheduleNext = () => {
|
|
78
|
+
if (cursor >= factories.length) return;
|
|
79
|
+
const currentIndex = cursor++;
|
|
80
|
+
const wrapped = Promise.resolve(factories[currentIndex]()).then((value) => {
|
|
81
|
+
results[currentIndex] = value;
|
|
82
|
+
}).finally(() => {
|
|
83
|
+
executing.delete(wrapped);
|
|
84
|
+
});
|
|
85
|
+
executing.add(wrapped);
|
|
86
|
+
};
|
|
87
|
+
while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
|
|
88
|
+
while (cursor < factories.length) {
|
|
89
|
+
await Promise.race(executing);
|
|
90
|
+
scheduleNext();
|
|
91
|
+
}
|
|
92
|
+
await Promise.all(executing);
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
96
|
+
if (factories.length === 0) return;
|
|
97
|
+
queue.push(runWithConcurrency(factories, limit).then(() => void 0));
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/bundlers/shared/css-imports.ts
|
|
101
|
+
const tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
102
|
+
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
103
|
+
function normalizeTailwindcssSpecifier(specifier) {
|
|
104
|
+
if (specifier === "tailwindcss$") return "tailwindcss";
|
|
105
|
+
return specifier;
|
|
106
|
+
}
|
|
107
|
+
function getTailwindcssSubpath(specifier) {
|
|
108
|
+
if (specifier === "tailwindcss") return "index.css";
|
|
109
|
+
return specifier.slice(12);
|
|
110
|
+
}
|
|
111
|
+
function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
112
|
+
const normalized = normalizeTailwindcssSpecifier(specifier);
|
|
113
|
+
if (!tailwindcssImportRE.test(normalized)) return null;
|
|
114
|
+
if (normalized === "tailwindcss") return options?.rootImport ?? "weapp-tailwindcss/index.css";
|
|
115
|
+
return (options?.join ?? path.join)(pkgDir, getTailwindcssSubpath(normalized));
|
|
116
|
+
}
|
|
117
|
+
function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
118
|
+
let hasReplacements = false;
|
|
119
|
+
const rewritten = code.replace(tailwindcssCssImportStatementRE, (full, prefix, quote, specifier, suffix) => {
|
|
120
|
+
const replacement = resolveTailwindcssImport(specifier, pkgDir, options);
|
|
121
|
+
if (!replacement) return full;
|
|
122
|
+
hasReplacements = true;
|
|
123
|
+
return `${prefix}${quote}${replacement}${suffix}`;
|
|
124
|
+
});
|
|
125
|
+
return hasReplacements ? rewritten : void 0;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { resolveDisabledOptions as a, toAbsoluteOutputPath as c, resolvePackageDir as i, rewriteTailwindcssImportsInCode as n, normalizeOutputPathKey as o, pushConcurrentTaskFactories as r, resolveOutputSpecifier as s, resolveTailwindcssImport as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const uniAppPlatform: string[];
|
|
2
|
+
export declare const queryKey = "weapp-tw-platform";
|
|
3
|
+
export declare function createMediaQuery(value: string): string;
|
|
4
|
+
export declare function createNegativeMediaQuery(value: string): string;
|
|
5
|
+
export declare function normalComment(text: string): string;
|
|
6
|
+
export declare function ifdef(text: string): {
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function ifndef(text: string): {
|
|
11
|
+
start: string;
|
|
12
|
+
end: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function matchCustomPropertyFromValue(str: string, cb: (arr: RegExpExecArray, index: number) => void): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
variantsMap?: Record<string, string | {
|
|
3
|
+
value: string;
|
|
4
|
+
negative?: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
dynamic?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const cssMacro: {
|
|
9
|
+
(options: Options | undefined): {
|
|
10
|
+
handler: import("tailwindcss/types/config").PluginCreator;
|
|
11
|
+
config?: Partial<import("tailwindcss/types/config").Config>;
|
|
12
|
+
};
|
|
13
|
+
__isOptionsFunction: true;
|
|
14
|
+
};
|
|
15
|
+
export default cssMacro;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { PluginCreator } from 'postcss';
|
|
2
|
-
|
|
3
|
-
interface Options {
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
export interface Options {
|
|
4
3
|
}
|
|
5
4
|
declare const creator: PluginCreator<Options>;
|
|
6
|
-
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
export = creator;
|
|
9
|
-
export type { Options };
|
|
5
|
+
export default creator;
|