weapp-tailwindcss 3.3.7 → 3.4.0-alpha.0
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-257YPDSI.mjs +173 -0
- package/dist/chunk-75EWCRQW.mjs +13 -0
- package/dist/chunk-AB467PG7.mjs +43 -0
- package/dist/chunk-E7XGHGC7.mjs +62 -0
- package/dist/chunk-GUE4UCRJ.mjs +126 -0
- package/dist/chunk-IOYI6MSW.mjs +533 -0
- package/dist/chunk-LDWI65M5.mjs +152 -0
- package/dist/chunk-NVFWRLOI.mjs +27 -0
- package/dist/chunk-ORMKM6ZA.mjs +30 -0
- package/dist/chunk-PC4B5JJB.mjs +953 -0
- package/dist/chunk-SRLZU2YE.mjs +95 -0
- package/dist/chunk-VECXHWWG.mjs +31 -0
- package/dist/chunk-VN37QGSM.mjs +216 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +1760 -52
- package/dist/cli.mjs +34 -46
- package/dist/core.d.mts +22 -0
- package/dist/core.d.ts +16 -2
- package/dist/core.js +1775 -62
- package/dist/core.mjs +46 -62
- package/dist/css-macro/index.d.mts +18 -0
- package/dist/css-macro/index.d.ts +7 -4
- package/dist/css-macro/index.js +140 -30
- package/dist/css-macro/index.mjs +35 -28
- package/dist/css-macro/postcss.d.mts +7 -0
- package/dist/css-macro/postcss.d.ts +5 -3
- package/dist/css-macro/postcss.js +99 -46
- package/dist/css-macro/postcss.mjs +54 -45
- package/dist/defaults.d.mts +16 -0
- package/dist/defaults.d.ts +16 -2
- package/dist/defaults.js +208 -7
- package/dist/defaults.mjs +9 -4
- package/dist/gulp.d.mts +26 -0
- package/dist/gulp.d.ts +26 -1
- package/dist/gulp.js +1898 -40
- package/dist/gulp.mjs +15 -32
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +2291 -44
- package/dist/index.mjs +23 -34
- package/dist/postcss.d.mts +23 -0
- package/dist/postcss.d.ts +23 -1
- package/dist/postcss.js +598 -22
- package/dist/postcss.mjs +17 -8
- package/dist/replace.d.mts +19 -0
- package/dist/replace.d.ts +19 -3
- package/dist/replace.js +93 -42
- package/dist/replace.mjs +30 -26
- package/dist/types-DSNuiOhH.d.mts +519 -0
- package/dist/types-DSNuiOhH.d.ts +519 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -1
- package/dist/vite.js +1947 -38
- package/dist/vite.mjs +15 -30
- package/dist/weapp-tw-runtime-loader.d.mts +7 -0
- package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
- package/dist/weapp-tw-runtime-loader.js +41 -14
- package/dist/weapp-tw-runtime-loader.mjs +12 -8
- package/dist/webpack.d.mts +26 -0
- package/dist/webpack.d.ts +26 -1
- package/dist/webpack.js +1994 -38
- package/dist/webpack.mjs +15 -30
- package/dist/webpack4.d.mts +27 -0
- package/dist/webpack4.d.ts +27 -1
- package/dist/webpack4.js +1979 -191
- package/dist/webpack4.mjs +211 -189
- package/package.json +18 -19
- package/dist/babel/index.d.ts +0 -16
- package/dist/bundlers/gulp/index.d.ts +0 -8
- package/dist/bundlers/vite/index.d.ts +0 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
- package/dist/bundlers/webpack/index.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -32
- package/dist/constants-CFM1J-h1.js +0 -42
- package/dist/constants-Dy2Dd3Fz.mjs +0 -36
- package/dist/constants.d.ts +0 -7
- package/dist/css-macro/constants.d.ts +0 -14
- package/dist/debug/index.d.ts +0 -2
- package/dist/defaults-DUZZvtdg.mjs +0 -149
- package/dist/defaults-syv_N3uk.js +0 -156
- package/dist/defu-Cdz2PomB.js +0 -60
- package/dist/defu-n46TJT6t.mjs +0 -57
- package/dist/env.d.ts +0 -2
- package/dist/escape.d.ts +0 -4
- package/dist/extractors/split.d.ts +0 -3
- package/dist/index-B8TOcVAt.js +0 -130
- package/dist/index-BEIjgKpF.mjs +0 -11
- package/dist/index-BKZH-Gxq.mjs +0 -134
- package/dist/index-BPzIdybK.mjs +0 -513
- package/dist/index-Bc61v7B0.mjs +0 -124
- package/dist/index-DXeB6ex8.js +0 -136
- package/dist/index-DwZHOkK3.js +0 -526
- package/dist/index-HC-Qkn0i.js +0 -17
- package/dist/js/handlers.d.ts +0 -13
- package/dist/js/index.d.ts +0 -7
- package/dist/mangle/index.d.ts +0 -8
- package/dist/options-BHJnjA_a.mjs +0 -981
- package/dist/options-DAp5AdGz.js +0 -1014
- package/dist/options.d.ts +0 -2
- package/dist/postcss/cssVars.d.ts +0 -5
- package/dist/postcss/index.d.ts +0 -3
- package/dist/postcss/mp.d.ts +0 -8
- package/dist/postcss/plugins/ctx.d.ts +0 -6
- package/dist/postcss/plugins/index.d.ts +0 -7
- package/dist/postcss/plugins/post.d.ts +0 -5
- package/dist/postcss/plugins/pre.d.ts +0 -5
- package/dist/postcss/preflight.d.ts +0 -3
- package/dist/postcss/selectorParser.d.ts +0 -6
- package/dist/postcss/shared.d.ts +0 -3
- package/dist/postcss/symbols.d.ts +0 -1
- package/dist/reg.d.ts +0 -1
- package/dist/shared-DbJl6i6a.mjs +0 -25
- package/dist/shared-hzYeE1wX.js +0 -28
- package/dist/tailwindcss/patcher.d.ts +0 -8
- package/dist/tailwindcss/supportCustomUnit.d.ts +0 -6
- package/dist/types.d.ts +0 -179
- package/dist/utils.d.ts +0 -18
- package/dist/v5-B9S3lBOs.mjs +0 -174
- package/dist/v5-QURRYPNk.js +0 -181
- package/dist/wxml/Tokenizer.d.ts +0 -31
- package/dist/wxml/index.d.ts +0 -2
- package/dist/wxml/shared.d.ts +0 -2
- package/dist/wxml/utils.d.ts +0 -9
package/dist/core.mjs
CHANGED
|
@@ -1,65 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import '@babel/types';
|
|
14
|
-
import 'htmlparser2';
|
|
15
|
-
import 'postcss';
|
|
16
|
-
import './index-BPzIdybK.mjs';
|
|
17
|
-
import '@csstools/postcss-is-pseudo-class';
|
|
18
|
-
import 'postcss-rem-to-responsive-pixel';
|
|
19
|
-
import 'postcss-selector-parser';
|
|
20
|
-
import 'node:path';
|
|
21
|
-
import 'node:fs';
|
|
22
|
-
import 'node:process';
|
|
23
|
-
import 'semver';
|
|
24
|
-
import 'tailwindcss-patch';
|
|
25
|
-
import '@tailwindcss-mangle/shared';
|
|
26
|
-
import 'lru-cache';
|
|
27
|
-
import 'md5';
|
|
1
|
+
import {
|
|
2
|
+
getOptions
|
|
3
|
+
} from "./chunk-PC4B5JJB.mjs";
|
|
4
|
+
import "./chunk-SRLZU2YE.mjs";
|
|
5
|
+
import "./chunk-GUE4UCRJ.mjs";
|
|
6
|
+
import "./chunk-IOYI6MSW.mjs";
|
|
7
|
+
import "./chunk-NVFWRLOI.mjs";
|
|
8
|
+
import "./chunk-ORMKM6ZA.mjs";
|
|
9
|
+
import "./chunk-VECXHWWG.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__async
|
|
12
|
+
} from "./chunk-E7XGHGC7.mjs";
|
|
28
13
|
|
|
14
|
+
// src/core.ts
|
|
29
15
|
function createContext(options = {}) {
|
|
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
|
-
transformWxml,
|
|
61
|
-
transformJs,
|
|
62
|
-
};
|
|
16
|
+
const opts = getOptions(options);
|
|
17
|
+
const { templateHandler, styleHandler, patch, jsHandler, twPatcher } = opts;
|
|
18
|
+
let runtimeSet = /* @__PURE__ */ new Set();
|
|
19
|
+
patch == null ? void 0 : patch();
|
|
20
|
+
function transformWxss(rawCss, options2) {
|
|
21
|
+
return __async(this, null, function* () {
|
|
22
|
+
const code = yield styleHandler(rawCss, Object.assign({
|
|
23
|
+
isMainChunk: true
|
|
24
|
+
}, options2));
|
|
25
|
+
return code;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function transformJs(_0) {
|
|
29
|
+
return __async(this, arguments, function* (rawJs, options2 = {}) {
|
|
30
|
+
runtimeSet = options2 && options2.runtimeSet ? options2.runtimeSet : twPatcher.getClassSet();
|
|
31
|
+
const { code } = yield jsHandler(rawJs, runtimeSet, options2);
|
|
32
|
+
return code;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function transformWxml(rawWxml, options2) {
|
|
36
|
+
const code = templateHandler(rawWxml, Object.assign({
|
|
37
|
+
runtimeSet
|
|
38
|
+
}, options2));
|
|
39
|
+
return code;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
transformWxss,
|
|
43
|
+
transformWxml,
|
|
44
|
+
transformJs
|
|
45
|
+
};
|
|
63
46
|
}
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
export {
|
|
48
|
+
createContext
|
|
49
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as tailwindcss_types_config from 'tailwindcss/types/config';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
4
|
+
variantsMap?: Record<string, string | {
|
|
5
|
+
value: string;
|
|
6
|
+
negative?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
dynamic?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: {
|
|
11
|
+
(options: Options): {
|
|
12
|
+
handler: tailwindcss_types_config.PluginCreator;
|
|
13
|
+
config?: Partial<tailwindcss_types_config.Config>;
|
|
14
|
+
};
|
|
15
|
+
__isOptionsFunction: true;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { type Options, _default as default };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as tailwindcss_types_config from 'tailwindcss/types/config';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
2
4
|
variantsMap?: Record<string, string | {
|
|
3
5
|
value: string;
|
|
4
6
|
negative?: boolean;
|
|
@@ -7,9 +9,10 @@ export interface Options {
|
|
|
7
9
|
}
|
|
8
10
|
declare const _default: {
|
|
9
11
|
(options: Options): {
|
|
10
|
-
handler:
|
|
11
|
-
config?: Partial<
|
|
12
|
+
handler: tailwindcss_types_config.PluginCreator;
|
|
13
|
+
config?: Partial<tailwindcss_types_config.Config>;
|
|
12
14
|
};
|
|
13
15
|
__isOptionsFunction: true;
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
export { type Options, _default as default };
|
package/dist/css-macro/index.js
CHANGED
|
@@ -1,36 +1,146 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
29
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
30
|
+
// src/css-macro/index.ts
|
|
31
|
+
var css_macro_exports = {};
|
|
32
|
+
__export(css_macro_exports, {
|
|
33
|
+
default: () => css_macro_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(css_macro_exports);
|
|
36
|
+
var import_plugin = __toESM(require("tailwindcss/plugin"));
|
|
6
37
|
|
|
7
|
-
|
|
38
|
+
// src/css-macro/constants.ts
|
|
39
|
+
var queryKey = "weapp-tw-platform";
|
|
40
|
+
function createMediaQuery(value) {
|
|
41
|
+
return `@media (${queryKey}:"${value}"){&}`;
|
|
42
|
+
}
|
|
43
|
+
function createNegativeMediaQuery(value) {
|
|
44
|
+
return `@media not screen and (${queryKey}:"${value}"){&}`;
|
|
45
|
+
}
|
|
8
46
|
|
|
9
|
-
|
|
47
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
48
|
+
function isPlainObject(value) {
|
|
49
|
+
if (value === null || typeof value !== "object") {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const prototype = Object.getPrototypeOf(value);
|
|
53
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (Symbol.iterator in value) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (Symbol.toStringTag in value) {
|
|
60
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
65
|
+
if (!isPlainObject(defaults)) {
|
|
66
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
67
|
+
}
|
|
68
|
+
const object = Object.assign({}, defaults);
|
|
69
|
+
for (const key in baseObject) {
|
|
70
|
+
if (key === "__proto__" || key === "constructor") {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const value = baseObject[key];
|
|
74
|
+
if (value === null || value === void 0) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
81
|
+
object[key] = [...value, ...object[key]];
|
|
82
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
83
|
+
object[key] = _defu(
|
|
84
|
+
value,
|
|
85
|
+
object[key],
|
|
86
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
87
|
+
merger
|
|
88
|
+
);
|
|
89
|
+
} else {
|
|
90
|
+
object[key] = value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return object;
|
|
94
|
+
}
|
|
95
|
+
function createDefu(merger) {
|
|
96
|
+
return (...arguments_) => (
|
|
97
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
98
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
var defu = createDefu();
|
|
102
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
103
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
104
|
+
object[key] = currentValue(object[key]);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
109
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
110
|
+
object[key] = currentValue(object[key]);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
10
114
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (dynamicMode) {
|
|
18
|
-
matchVariant('ifdef', (value) => {
|
|
19
|
-
return constants.createMediaQuery(value);
|
|
20
|
-
});
|
|
21
|
-
matchVariant('ifndef', (value) => {
|
|
22
|
-
return constants.createNegativeMediaQuery(value);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
for (const [name, obj] of Object.entries(variantsMap)) {
|
|
26
|
-
if (typeof obj === 'string') {
|
|
27
|
-
addVariant(name, constants.createMediaQuery(obj));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
addVariant(name, obj.negative ? constants.createNegativeMediaQuery(obj.value) : constants.createMediaQuery(obj.value));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
115
|
+
// src/utils.ts
|
|
116
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
117
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
118
|
+
obj[key] = value;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
34
121
|
});
|
|
35
122
|
|
|
36
|
-
|
|
123
|
+
// src/css-macro/index.ts
|
|
124
|
+
var css_macro_default = import_plugin.default.withOptions((options) => {
|
|
125
|
+
const { dynamic: dynamicMode, variantsMap } = defu(options, {
|
|
126
|
+
dynamic: true,
|
|
127
|
+
variantsMap: {}
|
|
128
|
+
});
|
|
129
|
+
return ({ matchVariant, addVariant }) => {
|
|
130
|
+
if (dynamicMode) {
|
|
131
|
+
matchVariant("ifdef", (value) => {
|
|
132
|
+
return createMediaQuery(value);
|
|
133
|
+
});
|
|
134
|
+
matchVariant("ifndef", (value) => {
|
|
135
|
+
return createNegativeMediaQuery(value);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
for (const [name, obj] of Object.entries(variantsMap)) {
|
|
139
|
+
if (typeof obj === "string") {
|
|
140
|
+
addVariant(name, createMediaQuery(obj));
|
|
141
|
+
} else {
|
|
142
|
+
addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
});
|
package/dist/css-macro/index.mjs
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
createMediaQuery,
|
|
3
|
+
createNegativeMediaQuery
|
|
4
|
+
} from "../chunk-AB467PG7.mjs";
|
|
5
|
+
import {
|
|
6
|
+
defu
|
|
7
|
+
} from "../chunk-GUE4UCRJ.mjs";
|
|
8
|
+
import "../chunk-E7XGHGC7.mjs";
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
10
|
+
// src/css-macro/index.ts
|
|
11
|
+
import plugin from "tailwindcss/plugin";
|
|
12
|
+
var css_macro_default = plugin.withOptions((options) => {
|
|
13
|
+
const { dynamic: dynamicMode, variantsMap } = defu(options, {
|
|
14
|
+
dynamic: true,
|
|
15
|
+
variantsMap: {}
|
|
16
|
+
});
|
|
17
|
+
return ({ matchVariant, addVariant }) => {
|
|
18
|
+
if (dynamicMode) {
|
|
19
|
+
matchVariant("ifdef", (value) => {
|
|
20
|
+
return createMediaQuery(value);
|
|
21
|
+
});
|
|
22
|
+
matchVariant("ifndef", (value) => {
|
|
23
|
+
return createNegativeMediaQuery(value);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const [name, obj] of Object.entries(variantsMap)) {
|
|
27
|
+
if (typeof obj === "string") {
|
|
28
|
+
addVariant(name, createMediaQuery(obj));
|
|
29
|
+
} else {
|
|
30
|
+
addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
28
34
|
});
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
export {
|
|
36
|
+
css_macro_default as default
|
|
37
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
3
4
|
}
|
|
4
5
|
declare const creator: PluginCreator<Options>;
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export { type Options, creator as default };
|
|
@@ -1,51 +1,104 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
19
|
|
|
3
|
-
|
|
20
|
+
// src/css-macro/postcss.ts
|
|
21
|
+
var postcss_exports = {};
|
|
22
|
+
__export(postcss_exports, {
|
|
23
|
+
default: () => postcss_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(postcss_exports);
|
|
4
26
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
// src/css-macro/constants.ts
|
|
28
|
+
var queryKey = "weapp-tw-platform";
|
|
29
|
+
function normalComment(text) {
|
|
30
|
+
if (typeof text === "string") {
|
|
31
|
+
return text.replaceAll(new RegExp("(?<!\\\\)_", "g"), " ");
|
|
32
|
+
}
|
|
33
|
+
return text;
|
|
34
|
+
}
|
|
35
|
+
function ifdef(text) {
|
|
36
|
+
return {
|
|
37
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
38
|
+
end: `#endif`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function ifndef(text) {
|
|
42
|
+
return {
|
|
43
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
44
|
+
end: `#endif`
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
48
|
+
let arr;
|
|
49
|
+
let index = 0;
|
|
50
|
+
const regex = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
51
|
+
while ((arr = regex.exec(str)) !== null) {
|
|
52
|
+
cb(arr, index);
|
|
53
|
+
index++;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/css-macro/postcss.ts
|
|
58
|
+
var creator = () => {
|
|
59
|
+
return {
|
|
60
|
+
postcssPlugin: "postcss-weapp-tw-css-macro-plugin",
|
|
61
|
+
prepare() {
|
|
62
|
+
return {
|
|
63
|
+
AtRule(atRule, helper) {
|
|
64
|
+
var _a;
|
|
65
|
+
if (atRule.name === "media") {
|
|
66
|
+
const values = [];
|
|
67
|
+
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
68
|
+
values.push(arr[1]);
|
|
69
|
+
});
|
|
70
|
+
if (values.length > 0) {
|
|
71
|
+
const isNegative = atRule.params.includes("not");
|
|
72
|
+
const text = values.join(" ");
|
|
73
|
+
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
74
|
+
atRule.replaceWith([
|
|
75
|
+
helper.comment({
|
|
76
|
+
raws: {
|
|
77
|
+
before: "\n"
|
|
78
|
+
},
|
|
79
|
+
text: comment.start
|
|
80
|
+
}),
|
|
81
|
+
...(_a = atRule.nodes) != null ? _a : [],
|
|
82
|
+
// .map((x) => x.clone()),
|
|
83
|
+
helper.comment({
|
|
84
|
+
raws: {
|
|
85
|
+
before: "\n"
|
|
86
|
+
},
|
|
87
|
+
text: comment.end
|
|
88
|
+
})
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
46
92
|
},
|
|
47
|
-
|
|
93
|
+
CommentExit(comment) {
|
|
94
|
+
if (/#(?:ifn?def|endif)/.test(comment.text)) {
|
|
95
|
+
comment.raws.left = " ";
|
|
96
|
+
comment.raws.right = " ";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
48
102
|
};
|
|
49
103
|
creator.postcss = true;
|
|
50
|
-
|
|
51
|
-
module.exports = creator;
|
|
104
|
+
var postcss_default = creator;
|