weapp-tailwindcss 4.10.3 → 4.11.0-alpha.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/{chunk-3XVUGMTY.mjs → chunk-2LH6PZH3.mjs} +8 -4
- package/dist/{chunk-3WUHHFLF.mjs → chunk-35EI5JMK.mjs} +4 -2
- package/dist/{chunk-RYC23C3K.js → chunk-4LPOQMFS.js} +203 -198
- package/dist/{chunk-5U24PLVV.js → chunk-ACTJYB33.js} +4 -2
- package/dist/chunk-CZLXTEHN.js +1936 -0
- package/dist/{chunk-TNYEOBAC.mjs → chunk-DOH7FULQ.mjs} +1 -1
- package/dist/{chunk-E7775SFS.mjs → chunk-FZNYV7VH.mjs} +914 -334
- package/dist/{chunk-6Z4GEN2Y.js → chunk-G3G437UE.js} +2 -2
- package/dist/{chunk-DEIJXHGJ.js → chunk-G5NLM3AL.js} +978 -398
- package/dist/{chunk-W2N6G2QQ.js → chunk-GWDHNCL2.js} +60 -46
- package/dist/{chunk-QOTLDKI4.mjs → chunk-IEZ5RBMG.mjs} +197 -192
- package/dist/{chunk-RM3SY4S4.mjs → chunk-JBM3HGHP.mjs} +52 -12
- package/dist/{chunk-WXT2GI5R.mjs → chunk-KKT2DKMW.mjs} +30 -16
- package/dist/chunk-LD7LZ4IK.mjs +1933 -0
- package/dist/{chunk-GCRL3ZYP.js → chunk-NOKJXG3W.js} +5 -5
- package/dist/{chunk-YUTKX7JZ.js → chunk-OV7FX6XR.js} +1 -1
- package/dist/{chunk-SR4GC2F4.js → chunk-OYSABARD.js} +8 -4
- package/dist/{chunk-LICQ6EGN.mjs → chunk-QYZCRG7F.mjs} +2 -2
- package/dist/{chunk-UYTCZXNE.mjs → chunk-R6KEYO3F.mjs} +6 -5
- package/dist/{chunk-WF636Q5E.js → chunk-SQG2MOFQ.js} +10 -9
- package/dist/{chunk-L7OBNTRI.js → chunk-W2EMGF7H.js} +57 -17
- package/dist/cli.js +45 -42
- package/dist/cli.mjs +9 -6
- package/dist/core.d.mts +4 -3
- package/dist/core.d.ts +4 -3
- package/dist/core.js +124 -30
- package/dist/core.mjs +119 -25
- package/dist/css-macro/postcss.js +6 -5
- package/dist/css-macro/postcss.mjs +4 -3
- package/dist/css-macro.js +5 -5
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/escape.js +2 -1
- package/dist/escape.mjs +2 -1
- package/dist/gulp.d.mts +1 -1
- package/dist/gulp.d.ts +1 -1
- package/dist/gulp.js +8 -7
- package/dist/gulp.mjs +8 -7
- package/dist/index.js +11 -11
- package/dist/index.mjs +9 -9
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +9 -8
- package/dist/vite.mjs +8 -7
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +10 -9
- package/dist/webpack.mjs +8 -7
- package/dist/webpack4.d.mts +1 -1
- package/dist/webpack4.d.ts +1 -1
- package/dist/webpack4.js +64 -49
- package/dist/webpack4.mjs +33 -18
- package/package.json +7 -7
- package/dist/chunk-PALDKVKG.mjs +0 -1291
- package/dist/chunk-YJSFFRNZ.js +0 -1291
package/dist/core.d.mts
CHANGED
|
@@ -9,6 +9,9 @@ import 'node:buffer';
|
|
|
9
9
|
import 'webpack';
|
|
10
10
|
import 'lru-cache';
|
|
11
11
|
|
|
12
|
+
type RuntimeJsTransformOptions = {
|
|
13
|
+
runtimeSet?: Set<string>;
|
|
14
|
+
} & CreateJsHandlerOptions;
|
|
12
15
|
/**
|
|
13
16
|
* 创建一个上下文对象,用于处理小程序的模板、样式和脚本转换。
|
|
14
17
|
* @param options - 用户定义的选项对象
|
|
@@ -17,9 +20,7 @@ import 'lru-cache';
|
|
|
17
20
|
declare function createContext(options?: UserDefinedOptions): {
|
|
18
21
|
transformWxss: (rawCss: string, options?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
19
22
|
transformWxml: (rawWxml: string, options?: ITemplateHandlerOptions) => Promise<string>;
|
|
20
|
-
transformJs: (rawJs: string, options?:
|
|
21
|
-
runtimeSet?: Set<string>;
|
|
22
|
-
} & CreateJsHandlerOptions) => Promise<JsHandlerResult>;
|
|
23
|
+
transformJs: (rawJs: string, options?: RuntimeJsTransformOptions) => Promise<JsHandlerResult>;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
export { createContext };
|
package/dist/core.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ import 'node:buffer';
|
|
|
9
9
|
import 'webpack';
|
|
10
10
|
import 'lru-cache';
|
|
11
11
|
|
|
12
|
+
type RuntimeJsTransformOptions = {
|
|
13
|
+
runtimeSet?: Set<string>;
|
|
14
|
+
} & CreateJsHandlerOptions;
|
|
12
15
|
/**
|
|
13
16
|
* 创建一个上下文对象,用于处理小程序的模板、样式和脚本转换。
|
|
14
17
|
* @param options - 用户定义的选项对象
|
|
@@ -17,9 +20,7 @@ import 'lru-cache';
|
|
|
17
20
|
declare function createContext(options?: UserDefinedOptions): {
|
|
18
21
|
transformWxss: (rawCss: string, options?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
19
22
|
transformWxml: (rawWxml: string, options?: ITemplateHandlerOptions) => Promise<string>;
|
|
20
|
-
transformJs: (rawJs: string, options?:
|
|
21
|
-
runtimeSet?: Set<string>;
|
|
22
|
-
} & CreateJsHandlerOptions) => Promise<JsHandlerResult>;
|
|
23
|
+
transformJs: (rawJs: string, options?: RuntimeJsTransformOptions) => Promise<JsHandlerResult>;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
export { createContext };
|
package/dist/core.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNOKJXG3Wjs = require('./chunk-NOKJXG3W.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
7
|
+
var _chunkG5NLM3ALjs = require('./chunk-G5NLM3AL.js');
|
|
8
|
+
require('./chunk-4LPOQMFS.js');
|
|
9
|
+
require('./chunk-ACTJYB33.js');
|
|
10
10
|
require('./chunk-DYLQ6UOI.js');
|
|
11
|
-
require('./chunk-
|
|
11
|
+
require('./chunk-OV7FX6XR.js');
|
|
12
12
|
|
|
13
13
|
// src/core.ts
|
|
14
14
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
15
15
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
16
|
+
var DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({
|
|
17
|
+
isMainChunk: true
|
|
18
|
+
});
|
|
19
|
+
function resolveTransformWxssOptions(options) {
|
|
20
|
+
if (!options) {
|
|
21
|
+
return DEFAULT_MAIN_CHUNK_STYLE_OPTIONS;
|
|
22
|
+
}
|
|
23
|
+
if (options.isMainChunk === true) {
|
|
24
|
+
return options;
|
|
25
|
+
}
|
|
26
|
+
return _shared.defuOverrideArray.call(void 0, options, DEFAULT_MAIN_CHUNK_STYLE_OPTIONS);
|
|
27
|
+
}
|
|
16
28
|
function createContext(options = {}) {
|
|
17
|
-
const opts =
|
|
29
|
+
const opts = _chunkG5NLM3ALjs.getCompilerContext.call(void 0, options);
|
|
18
30
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
19
|
-
const patchRecorderState =
|
|
31
|
+
const patchRecorderState = _chunkNOKJXG3Wjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
20
32
|
source: "runtime",
|
|
21
33
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
22
34
|
});
|
|
@@ -27,55 +39,137 @@ function createContext(options = {}) {
|
|
|
27
39
|
refreshTailwindcssPatcher,
|
|
28
40
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
29
41
|
};
|
|
42
|
+
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
43
|
+
function getDefaultJsHandlerOptions(majorVersion = runtimeState.twPatcher.majorVersion) {
|
|
44
|
+
if (typeof majorVersion !== "number") {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
48
|
+
if (!cached) {
|
|
49
|
+
cached = {
|
|
50
|
+
tailwindcssMajorVersion: majorVersion
|
|
51
|
+
};
|
|
52
|
+
defaultJsHandlerOptionsCache.set(majorVersion, cached);
|
|
53
|
+
}
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
30
56
|
function withRuntimeTailwindMajorVersion(options2) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (typeof
|
|
35
|
-
return
|
|
57
|
+
if (!options2) {
|
|
58
|
+
return getDefaultJsHandlerOptions();
|
|
59
|
+
}
|
|
60
|
+
if (typeof options2.tailwindcssMajorVersion === "number") {
|
|
61
|
+
return options2;
|
|
36
62
|
}
|
|
37
63
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
38
|
-
if (typeof majorVersion
|
|
39
|
-
|
|
64
|
+
if (typeof majorVersion !== "number") {
|
|
65
|
+
return options2;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...options2,
|
|
69
|
+
tailwindcssMajorVersion: majorVersion
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function resolveTransformJsOptions(options2) {
|
|
73
|
+
if (!options2) {
|
|
74
|
+
return getDefaultJsHandlerOptions();
|
|
75
|
+
}
|
|
76
|
+
let hasHandlerOption = false;
|
|
77
|
+
let runtimeSetProvided = false;
|
|
78
|
+
for (const key in options2) {
|
|
79
|
+
if (key === "runtimeSet") {
|
|
80
|
+
runtimeSetProvided = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
hasHandlerOption = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (!hasHandlerOption) {
|
|
87
|
+
return getDefaultJsHandlerOptions();
|
|
88
|
+
}
|
|
89
|
+
if (!runtimeSetProvided && typeof options2.tailwindcssMajorVersion === "number") {
|
|
90
|
+
return options2;
|
|
40
91
|
}
|
|
41
|
-
|
|
92
|
+
if (runtimeSetProvided) {
|
|
93
|
+
const { runtimeSet: _runtimeSet, ...handlerOptions } = options2;
|
|
94
|
+
return withRuntimeTailwindMajorVersion(handlerOptions);
|
|
95
|
+
}
|
|
96
|
+
return withRuntimeTailwindMajorVersion(options2);
|
|
97
|
+
}
|
|
98
|
+
const runtimeAwareTemplateJsHandler = (source, runtime, handlerOptions) => {
|
|
99
|
+
return jsHandler(source, runtime, withRuntimeTailwindMajorVersion(handlerOptions));
|
|
100
|
+
};
|
|
101
|
+
let cachedDefaultTemplateHandlerOptions;
|
|
102
|
+
let cachedDefaultTemplateRuntimeSet;
|
|
103
|
+
let cachedRuntimeOnlyTemplateHandlerOptions;
|
|
104
|
+
let cachedRuntimeOnlyTemplateRuntimeSet;
|
|
105
|
+
function getDefaultTemplateHandlerOptions() {
|
|
106
|
+
if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
|
|
107
|
+
cachedDefaultTemplateRuntimeSet = runtimeSet;
|
|
108
|
+
cachedDefaultTemplateHandlerOptions = {
|
|
109
|
+
runtimeSet,
|
|
110
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return cachedDefaultTemplateHandlerOptions;
|
|
114
|
+
}
|
|
115
|
+
function resolveTransformWxmlOptions(options2) {
|
|
116
|
+
if (!options2) {
|
|
117
|
+
return getDefaultTemplateHandlerOptions();
|
|
118
|
+
}
|
|
119
|
+
let hasOverride = false;
|
|
120
|
+
for (const key in options2) {
|
|
121
|
+
if (key !== "runtimeSet") {
|
|
122
|
+
hasOverride = true;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!hasOverride) {
|
|
127
|
+
const runtimeOverride = options2.runtimeSet;
|
|
128
|
+
if (runtimeOverride === void 0 || runtimeOverride === runtimeSet) {
|
|
129
|
+
return getDefaultTemplateHandlerOptions();
|
|
130
|
+
}
|
|
131
|
+
if (cachedRuntimeOnlyTemplateRuntimeSet !== runtimeOverride || !cachedRuntimeOnlyTemplateHandlerOptions) {
|
|
132
|
+
cachedRuntimeOnlyTemplateRuntimeSet = runtimeOverride;
|
|
133
|
+
cachedRuntimeOnlyTemplateHandlerOptions = {
|
|
134
|
+
runtimeSet: runtimeOverride,
|
|
135
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return cachedRuntimeOnlyTemplateHandlerOptions;
|
|
139
|
+
}
|
|
140
|
+
return _shared.defuOverrideArray.call(void 0, options2, {
|
|
141
|
+
runtimeSet,
|
|
142
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
143
|
+
});
|
|
42
144
|
}
|
|
43
145
|
async function transformWxss(rawCss, options2) {
|
|
44
146
|
await runtimeState.patchPromise;
|
|
45
|
-
const result = await styleHandler(rawCss,
|
|
46
|
-
|
|
47
|
-
}));
|
|
48
|
-
runtimeSet = await _chunkDEIJXHGJjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
147
|
+
const result = await styleHandler(rawCss, resolveTransformWxssOptions(options2));
|
|
148
|
+
runtimeSet = await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
49
149
|
forceRefresh: true,
|
|
50
150
|
forceCollect: true
|
|
51
151
|
});
|
|
52
152
|
return result;
|
|
53
153
|
}
|
|
54
|
-
async function transformJs(rawJs, options2
|
|
154
|
+
async function transformJs(rawJs, options2) {
|
|
55
155
|
await runtimeState.patchPromise;
|
|
56
156
|
if (_optionalChain([options2, 'optionalAccess', _ => _.runtimeSet])) {
|
|
57
157
|
runtimeSet = options2.runtimeSet;
|
|
58
158
|
} else if (runtimeSet.size === 0) {
|
|
59
|
-
runtimeSet = await
|
|
159
|
+
runtimeSet = await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
60
160
|
forceCollect: true
|
|
61
161
|
});
|
|
62
162
|
}
|
|
63
|
-
return await jsHandler(rawJs, runtimeSet,
|
|
163
|
+
return await jsHandler(rawJs, runtimeSet, resolveTransformJsOptions(options2));
|
|
64
164
|
}
|
|
65
165
|
async function transformWxml(rawWxml, options2) {
|
|
66
166
|
await runtimeState.patchPromise;
|
|
67
167
|
if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
|
|
68
|
-
runtimeSet = await
|
|
168
|
+
runtimeSet = await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
69
169
|
forceCollect: true
|
|
70
170
|
});
|
|
71
171
|
}
|
|
72
|
-
|
|
73
|
-
return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
|
|
74
|
-
runtimeSet,
|
|
75
|
-
jsHandler: (source, runtime, handlerOptions) => {
|
|
76
|
-
return runtimeJsHandler(source, runtime, withRuntimeTailwindMajorVersion(handlerOptions));
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
172
|
+
return templateHandler(rawWxml, resolveTransformWxmlOptions(options2));
|
|
79
173
|
}
|
|
80
174
|
return {
|
|
81
175
|
transformWxss,
|
package/dist/core.mjs
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setupPatchRecorder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QYZCRG7F.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ensureRuntimeClassSet,
|
|
6
6
|
getCompilerContext
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-FZNYV7VH.mjs";
|
|
8
|
+
import "./chunk-IEZ5RBMG.mjs";
|
|
9
|
+
import "./chunk-35EI5JMK.mjs";
|
|
10
10
|
import "./chunk-OOHJLO5M.mjs";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-DOH7FULQ.mjs";
|
|
12
12
|
|
|
13
13
|
// src/core.ts
|
|
14
14
|
import process from "process";
|
|
15
15
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
16
|
+
var DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({
|
|
17
|
+
isMainChunk: true
|
|
18
|
+
});
|
|
19
|
+
function resolveTransformWxssOptions(options) {
|
|
20
|
+
if (!options) {
|
|
21
|
+
return DEFAULT_MAIN_CHUNK_STYLE_OPTIONS;
|
|
22
|
+
}
|
|
23
|
+
if (options.isMainChunk === true) {
|
|
24
|
+
return options;
|
|
25
|
+
}
|
|
26
|
+
return defuOverrideArray(options, DEFAULT_MAIN_CHUNK_STYLE_OPTIONS);
|
|
27
|
+
}
|
|
16
28
|
function createContext(options = {}) {
|
|
17
29
|
const opts = getCompilerContext(options);
|
|
18
30
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
@@ -27,31 +39,119 @@ function createContext(options = {}) {
|
|
|
27
39
|
refreshTailwindcssPatcher,
|
|
28
40
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
29
41
|
};
|
|
42
|
+
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
43
|
+
function getDefaultJsHandlerOptions(majorVersion = runtimeState.twPatcher.majorVersion) {
|
|
44
|
+
if (typeof majorVersion !== "number") {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
48
|
+
if (!cached) {
|
|
49
|
+
cached = {
|
|
50
|
+
tailwindcssMajorVersion: majorVersion
|
|
51
|
+
};
|
|
52
|
+
defaultJsHandlerOptionsCache.set(majorVersion, cached);
|
|
53
|
+
}
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
30
56
|
function withRuntimeTailwindMajorVersion(options2) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (typeof
|
|
35
|
-
return
|
|
57
|
+
if (!options2) {
|
|
58
|
+
return getDefaultJsHandlerOptions();
|
|
59
|
+
}
|
|
60
|
+
if (typeof options2.tailwindcssMajorVersion === "number") {
|
|
61
|
+
return options2;
|
|
36
62
|
}
|
|
37
63
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
38
|
-
if (typeof majorVersion
|
|
39
|
-
|
|
64
|
+
if (typeof majorVersion !== "number") {
|
|
65
|
+
return options2;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...options2,
|
|
69
|
+
tailwindcssMajorVersion: majorVersion
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function resolveTransformJsOptions(options2) {
|
|
73
|
+
if (!options2) {
|
|
74
|
+
return getDefaultJsHandlerOptions();
|
|
75
|
+
}
|
|
76
|
+
let hasHandlerOption = false;
|
|
77
|
+
let runtimeSetProvided = false;
|
|
78
|
+
for (const key in options2) {
|
|
79
|
+
if (key === "runtimeSet") {
|
|
80
|
+
runtimeSetProvided = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
hasHandlerOption = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (!hasHandlerOption) {
|
|
87
|
+
return getDefaultJsHandlerOptions();
|
|
88
|
+
}
|
|
89
|
+
if (!runtimeSetProvided && typeof options2.tailwindcssMajorVersion === "number") {
|
|
90
|
+
return options2;
|
|
40
91
|
}
|
|
41
|
-
|
|
92
|
+
if (runtimeSetProvided) {
|
|
93
|
+
const { runtimeSet: _runtimeSet, ...handlerOptions } = options2;
|
|
94
|
+
return withRuntimeTailwindMajorVersion(handlerOptions);
|
|
95
|
+
}
|
|
96
|
+
return withRuntimeTailwindMajorVersion(options2);
|
|
97
|
+
}
|
|
98
|
+
const runtimeAwareTemplateJsHandler = (source, runtime, handlerOptions) => {
|
|
99
|
+
return jsHandler(source, runtime, withRuntimeTailwindMajorVersion(handlerOptions));
|
|
100
|
+
};
|
|
101
|
+
let cachedDefaultTemplateHandlerOptions;
|
|
102
|
+
let cachedDefaultTemplateRuntimeSet;
|
|
103
|
+
let cachedRuntimeOnlyTemplateHandlerOptions;
|
|
104
|
+
let cachedRuntimeOnlyTemplateRuntimeSet;
|
|
105
|
+
function getDefaultTemplateHandlerOptions() {
|
|
106
|
+
if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
|
|
107
|
+
cachedDefaultTemplateRuntimeSet = runtimeSet;
|
|
108
|
+
cachedDefaultTemplateHandlerOptions = {
|
|
109
|
+
runtimeSet,
|
|
110
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return cachedDefaultTemplateHandlerOptions;
|
|
114
|
+
}
|
|
115
|
+
function resolveTransformWxmlOptions(options2) {
|
|
116
|
+
if (!options2) {
|
|
117
|
+
return getDefaultTemplateHandlerOptions();
|
|
118
|
+
}
|
|
119
|
+
let hasOverride = false;
|
|
120
|
+
for (const key in options2) {
|
|
121
|
+
if (key !== "runtimeSet") {
|
|
122
|
+
hasOverride = true;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!hasOverride) {
|
|
127
|
+
const runtimeOverride = options2.runtimeSet;
|
|
128
|
+
if (runtimeOverride === void 0 || runtimeOverride === runtimeSet) {
|
|
129
|
+
return getDefaultTemplateHandlerOptions();
|
|
130
|
+
}
|
|
131
|
+
if (cachedRuntimeOnlyTemplateRuntimeSet !== runtimeOverride || !cachedRuntimeOnlyTemplateHandlerOptions) {
|
|
132
|
+
cachedRuntimeOnlyTemplateRuntimeSet = runtimeOverride;
|
|
133
|
+
cachedRuntimeOnlyTemplateHandlerOptions = {
|
|
134
|
+
runtimeSet: runtimeOverride,
|
|
135
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return cachedRuntimeOnlyTemplateHandlerOptions;
|
|
139
|
+
}
|
|
140
|
+
return defuOverrideArray(options2, {
|
|
141
|
+
runtimeSet,
|
|
142
|
+
jsHandler: runtimeAwareTemplateJsHandler
|
|
143
|
+
});
|
|
42
144
|
}
|
|
43
145
|
async function transformWxss(rawCss, options2) {
|
|
44
146
|
await runtimeState.patchPromise;
|
|
45
|
-
const result = await styleHandler(rawCss,
|
|
46
|
-
isMainChunk: true
|
|
47
|
-
}));
|
|
147
|
+
const result = await styleHandler(rawCss, resolveTransformWxssOptions(options2));
|
|
48
148
|
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
49
149
|
forceRefresh: true,
|
|
50
150
|
forceCollect: true
|
|
51
151
|
});
|
|
52
152
|
return result;
|
|
53
153
|
}
|
|
54
|
-
async function transformJs(rawJs, options2
|
|
154
|
+
async function transformJs(rawJs, options2) {
|
|
55
155
|
await runtimeState.patchPromise;
|
|
56
156
|
if (options2?.runtimeSet) {
|
|
57
157
|
runtimeSet = options2.runtimeSet;
|
|
@@ -60,7 +160,7 @@ function createContext(options = {}) {
|
|
|
60
160
|
forceCollect: true
|
|
61
161
|
});
|
|
62
162
|
}
|
|
63
|
-
return await jsHandler(rawJs, runtimeSet,
|
|
163
|
+
return await jsHandler(rawJs, runtimeSet, resolveTransformJsOptions(options2));
|
|
64
164
|
}
|
|
65
165
|
async function transformWxml(rawWxml, options2) {
|
|
66
166
|
await runtimeState.patchPromise;
|
|
@@ -69,13 +169,7 @@ function createContext(options = {}) {
|
|
|
69
169
|
forceCollect: true
|
|
70
170
|
});
|
|
71
171
|
}
|
|
72
|
-
|
|
73
|
-
return templateHandler(rawWxml, defuOverrideArray(options2, {
|
|
74
|
-
runtimeSet,
|
|
75
|
-
jsHandler: (source, runtime, handlerOptions) => {
|
|
76
|
-
return runtimeJsHandler(source, runtime, withRuntimeTailwindMajorVersion(handlerOptions));
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
172
|
+
return templateHandler(rawWxml, resolveTransformWxmlOptions(options2));
|
|
79
173
|
}
|
|
80
174
|
return {
|
|
81
175
|
transformWxss,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
5
|
+
var _chunkOYSABARDjs = require('../chunk-OYSABARD.js');
|
|
6
|
+
require('../chunk-OV7FX6XR.js');
|
|
7
7
|
|
|
8
8
|
// src/css-macro/postcss.ts
|
|
9
|
+
var IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
9
10
|
var creator = () => {
|
|
10
11
|
return {
|
|
11
12
|
postcssPlugin: "postcss-weapp-tw-css-macro-plugin",
|
|
@@ -14,13 +15,13 @@ var creator = () => {
|
|
|
14
15
|
AtRule(atRule, helper) {
|
|
15
16
|
if (atRule.name === "media") {
|
|
16
17
|
const values = [];
|
|
17
|
-
|
|
18
|
+
_chunkOYSABARDjs.matchCustomPropertyFromValue.call(void 0, atRule.params, (arr) => {
|
|
18
19
|
values.push(arr[1]);
|
|
19
20
|
});
|
|
20
21
|
if (values.length > 0) {
|
|
21
22
|
const isNegative = atRule.params.includes("not");
|
|
22
23
|
const text = values.join(" ");
|
|
23
|
-
const comment = isNegative ?
|
|
24
|
+
const comment = isNegative ? _chunkOYSABARDjs.ifndef.call(void 0, text) : _chunkOYSABARDjs.ifdef.call(void 0, text);
|
|
24
25
|
const nextNodes = [
|
|
25
26
|
helper.comment({
|
|
26
27
|
raws: {
|
|
@@ -41,7 +42,7 @@ var creator = () => {
|
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
CommentExit(comment) {
|
|
44
|
-
if (
|
|
45
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
45
46
|
comment.raws.left = " ";
|
|
46
47
|
comment.raws.right = " ";
|
|
47
48
|
}
|
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
ifdef,
|
|
3
3
|
ifndef,
|
|
4
4
|
matchCustomPropertyFromValue
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-2LH6PZH3.mjs";
|
|
6
|
+
import "../chunk-DOH7FULQ.mjs";
|
|
7
7
|
|
|
8
8
|
// src/css-macro/postcss.ts
|
|
9
|
+
var IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
9
10
|
var creator = () => {
|
|
10
11
|
return {
|
|
11
12
|
postcssPlugin: "postcss-weapp-tw-css-macro-plugin",
|
|
@@ -41,7 +42,7 @@ var creator = () => {
|
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
CommentExit(comment) {
|
|
44
|
-
if (
|
|
45
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
45
46
|
comment.raws.left = " ";
|
|
46
47
|
comment.raws.right = " ";
|
|
47
48
|
}
|
package/dist/css-macro.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkOYSABARDjs = require('./chunk-OYSABARD.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
8
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-OV7FX6XR.js');
|
|
9
9
|
|
|
10
10
|
// src/css-macro/index.ts
|
|
11
11
|
var _plugin = require('tailwindcss/plugin'); var _plugin2 = _interopRequireDefault(_plugin);
|
|
@@ -33,12 +33,12 @@ var cssMacro = _plugin2.default.withOptions((options) => {
|
|
|
33
33
|
const { matchVariant, addVariant } = api;
|
|
34
34
|
const supportsDynamic = typeof matchVariant === "function";
|
|
35
35
|
if (dynamic && supportsDynamic) {
|
|
36
|
-
matchVariant("ifdef", (value) =>
|
|
37
|
-
matchVariant("ifndef", (value) =>
|
|
36
|
+
matchVariant("ifdef", (value) => _chunkOYSABARDjs.createMediaQuery.call(void 0, value));
|
|
37
|
+
matchVariant("ifndef", (value) => _chunkOYSABARDjs.createNegativeMediaQuery.call(void 0, value));
|
|
38
38
|
}
|
|
39
39
|
if (typeof addVariant === "function") {
|
|
40
40
|
for (const variant of staticVariants) {
|
|
41
|
-
const query = variant.negative ?
|
|
41
|
+
const query = variant.negative ? _chunkOYSABARDjs.createNegativeMediaQuery.call(void 0, variant.value) : _chunkOYSABARDjs.createMediaQuery.call(void 0, variant.value);
|
|
42
42
|
addVariant(variant.name, query);
|
|
43
43
|
}
|
|
44
44
|
}
|
package/dist/css-macro.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMediaQuery,
|
|
3
3
|
createNegativeMediaQuery
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2LH6PZH3.mjs";
|
|
5
5
|
import {
|
|
6
6
|
defu
|
|
7
7
|
} from "./chunk-OOHJLO5M.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-DOH7FULQ.mjs";
|
|
9
9
|
|
|
10
10
|
// src/css-macro/index.ts
|
|
11
11
|
import plugin from "tailwindcss/plugin";
|
package/dist/defaults.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkACTJYB33js = require('./chunk-ACTJYB33.js');
|
|
4
4
|
require('./chunk-DYLQ6UOI.js');
|
|
5
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-OV7FX6XR.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.getDefaultOptions =
|
|
8
|
+
exports.getDefaultOptions = _chunkACTJYB33js.getDefaultOptions;
|
package/dist/defaults.mjs
CHANGED
package/dist/escape.js
CHANGED
|
@@ -29,6 +29,7 @@ module.exports = __toCommonJS(escape_exports);
|
|
|
29
29
|
|
|
30
30
|
// src/wxml/shared.ts
|
|
31
31
|
var import_escape = require("@weapp-core/escape");
|
|
32
|
+
var NEWLINE_RE = /[\n\r]+/g;
|
|
32
33
|
function replaceWxml(original, options = {
|
|
33
34
|
keepEOL: false,
|
|
34
35
|
escapeMap: import_escape.MappingChars2String
|
|
@@ -36,7 +37,7 @@ function replaceWxml(original, options = {
|
|
|
36
37
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
37
38
|
let res = original;
|
|
38
39
|
if (!keepEOL) {
|
|
39
|
-
res = res.replaceAll(
|
|
40
|
+
res = res.replaceAll(NEWLINE_RE, "");
|
|
40
41
|
}
|
|
41
42
|
res = (0, import_escape.escape)(res, {
|
|
42
43
|
map: escapeMap,
|
package/dist/escape.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/wxml/shared.ts
|
|
2
2
|
import { escape, MappingChars2String } from "@weapp-core/escape";
|
|
3
|
+
var NEWLINE_RE = /[\n\r]+/g;
|
|
3
4
|
function replaceWxml(original, options = {
|
|
4
5
|
keepEOL: false,
|
|
5
6
|
escapeMap: MappingChars2String
|
|
@@ -7,7 +8,7 @@ function replaceWxml(original, options = {
|
|
|
7
8
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
8
9
|
let res = original;
|
|
9
10
|
if (!keepEOL) {
|
|
10
|
-
res = res.replaceAll(
|
|
11
|
+
res = res.replaceAll(NEWLINE_RE, "");
|
|
11
12
|
}
|
|
12
13
|
res = escape(res, {
|
|
13
14
|
map: escapeMap,
|
package/dist/gulp.d.mts
CHANGED
|
@@ -21,4 +21,4 @@ declare function createPlugins(options?: UserDefinedOptions): {
|
|
|
21
21
|
transformJs: (options?: Partial<CreateJsHandlerOptions>) => stream.Transform;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export { UserDefinedOptions, createPlugins };
|
|
24
|
+
export { UserDefinedOptions, createPlugins, createPlugins as weappTailwindcss };
|
package/dist/gulp.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ declare function createPlugins(options?: UserDefinedOptions): {
|
|
|
21
21
|
transformJs: (options?: Partial<CreateJsHandlerOptions>) => stream.Transform;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export { UserDefinedOptions, createPlugins };
|
|
24
|
+
export { UserDefinedOptions, createPlugins, createPlugins as weappTailwindcss };
|
package/dist/gulp.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkW2EMGF7Hjs = require('./chunk-W2EMGF7H.js');
|
|
4
4
|
require('./chunk-LTJQUORK.js');
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-NOKJXG3W.js');
|
|
6
|
+
require('./chunk-G5NLM3AL.js');
|
|
7
|
+
require('./chunk-4LPOQMFS.js');
|
|
8
|
+
require('./chunk-ACTJYB33.js');
|
|
9
9
|
require('./chunk-DYLQ6UOI.js');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-OV7FX6XR.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
exports.createPlugins = _chunkW2EMGF7Hjs.createPlugins; exports.weappTailwindcss = _chunkW2EMGF7Hjs.createPlugins;
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugins
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JBM3HGHP.mjs";
|
|
4
4
|
import "./chunk-RRHPTTCP.mjs";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-QYZCRG7F.mjs";
|
|
6
|
+
import "./chunk-FZNYV7VH.mjs";
|
|
7
|
+
import "./chunk-IEZ5RBMG.mjs";
|
|
8
|
+
import "./chunk-35EI5JMK.mjs";
|
|
9
9
|
import "./chunk-OOHJLO5M.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-DOH7FULQ.mjs";
|
|
11
11
|
export {
|
|
12
|
-
createPlugins
|
|
12
|
+
createPlugins,
|
|
13
|
+
createPlugins as weappTailwindcss
|
|
13
14
|
};
|