weapp-tailwindcss 4.8.3 → 4.8.5-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-7KTLLGAG.mjs → chunk-3XGTIDA6.mjs} +72 -49
- package/dist/{chunk-26ZRX6OH.js → chunk-5KVCFUCR.js} +27 -20
- package/dist/{chunk-QGH4JZRW.mjs → chunk-67CD2S5L.mjs} +0 -8
- package/dist/{chunk-H34KPZQW.js → chunk-AB45L5FP.js} +2 -2
- package/dist/{chunk-E3GZQTOH.mjs → chunk-E4WMGIBB.mjs} +13 -6
- package/dist/{chunk-KSHK56CW.mjs → chunk-EQP3XJUM.mjs} +1 -1
- package/dist/chunk-GBKTM7HE.mjs +29 -0
- package/dist/{chunk-NLLCK6RM.mjs → chunk-NE4IF47K.mjs} +11 -4
- package/dist/{chunk-UUVGNRUM.mjs → chunk-NMUFIIAM.mjs} +36 -23
- package/dist/{chunk-N2ZUYGKA.js → chunk-OQGFV6TW.js} +14 -7
- package/dist/{chunk-UCA2DMVN.js → chunk-OR5KGJ46.js} +5 -5
- package/dist/{chunk-W5Z3I3S2.js → chunk-QZ5JL3U3.js} +52 -39
- package/dist/chunk-R6ERGDBQ.js +29 -0
- package/dist/{chunk-2ZEOKKVA.js → chunk-RJRLVYVJ.js} +77 -54
- package/dist/{chunk-WTOLVORM.mjs → chunk-T25LQFYZ.mjs} +389 -52
- package/dist/chunk-UTZLVU3M.js +7 -0
- package/dist/{chunk-PLV4QGF4.js → chunk-YKMZHWQ4.js} +427 -90
- package/dist/cli.js +270 -311
- package/dist/cli.mjs +273 -313
- package/dist/core.js +19 -11
- package/dist/core.mjs +14 -6
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -5
- package/dist/gulp.mjs +5 -4
- package/dist/index.js +10 -9
- package/dist/index.mjs +8 -7
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +4 -6
- package/dist/presets.mjs +3 -5
- package/dist/reset.d.mts +30 -0
- package/dist/reset.d.ts +32 -0
- package/dist/reset.js +161 -0
- package/dist/reset.mjs +161 -0
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -6
- package/dist/vite.mjs +5 -4
- package/dist/webpack.js +8 -7
- package/dist/webpack.mjs +6 -5
- package/dist/webpack4.js +29 -22
- package/dist/webpack4.mjs +14 -7
- package/package.json +12 -5
- package/dist/chunk-OXASK55Q.js +0 -6
- package/dist/chunk-PMF2CCKK.mjs +0 -6
- package/dist/chunk-UJIUFWXE.js +0 -15
package/dist/core.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
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 _chunkR6ERGDBQjs = require('./chunk-R6ERGDBQ.js');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
require('./chunk-
|
|
7
|
+
|
|
8
|
+
var _chunkYKMZHWQ4js = require('./chunk-YKMZHWQ4.js');
|
|
9
|
+
require('./chunk-RJRLVYVJ.js');
|
|
8
10
|
require('./chunk-ZSTF2AEN.js');
|
|
9
11
|
require('./chunk-UW3WHSZ5.js');
|
|
10
|
-
require('./chunk-
|
|
12
|
+
require('./chunk-UTZLVU3M.js');
|
|
11
13
|
|
|
12
14
|
// src/core.ts
|
|
15
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
13
16
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
14
17
|
function createContext(options = {}) {
|
|
15
|
-
const opts =
|
|
18
|
+
const opts = _chunkYKMZHWQ4js.getCompilerContext.call(void 0, options);
|
|
16
19
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
20
|
+
const patchRecorderState = _chunkR6ERGDBQjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
21
|
+
source: "runtime",
|
|
22
|
+
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
23
|
+
});
|
|
17
24
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
18
25
|
const runtimeState = {
|
|
19
26
|
twPatcher: initialTwPatcher,
|
|
20
|
-
patchPromise:
|
|
21
|
-
refreshTailwindcssPatcher
|
|
27
|
+
patchPromise: patchRecorderState.patchPromise,
|
|
28
|
+
refreshTailwindcssPatcher,
|
|
29
|
+
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
22
30
|
};
|
|
23
31
|
async function refreshRuntimeState(force) {
|
|
24
|
-
await
|
|
32
|
+
await _chunkYKMZHWQ4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
25
33
|
}
|
|
26
34
|
async function transformWxss(rawCss, options2) {
|
|
27
35
|
await runtimeState.patchPromise;
|
|
@@ -30,7 +38,7 @@ function createContext(options = {}) {
|
|
|
30
38
|
}));
|
|
31
39
|
await refreshRuntimeState(true);
|
|
32
40
|
await runtimeState.patchPromise;
|
|
33
|
-
runtimeSet = await
|
|
41
|
+
runtimeSet = await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
34
42
|
return result;
|
|
35
43
|
}
|
|
36
44
|
async function transformJs(rawJs, options2 = {}) {
|
|
@@ -40,7 +48,7 @@ function createContext(options = {}) {
|
|
|
40
48
|
} else {
|
|
41
49
|
await refreshRuntimeState(true);
|
|
42
50
|
await runtimeState.patchPromise;
|
|
43
|
-
runtimeSet = await
|
|
51
|
+
runtimeSet = await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
44
52
|
}
|
|
45
53
|
return await jsHandler(rawJs, runtimeSet, options2);
|
|
46
54
|
}
|
|
@@ -49,7 +57,7 @@ function createContext(options = {}) {
|
|
|
49
57
|
if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
|
|
50
58
|
await refreshRuntimeState(true);
|
|
51
59
|
await runtimeState.patchPromise;
|
|
52
|
-
runtimeSet = await
|
|
60
|
+
runtimeSet = await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
53
61
|
}
|
|
54
62
|
return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
|
|
55
63
|
runtimeSet
|
package/dist/core.mjs
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setupPatchRecorder
|
|
3
|
+
} from "./chunk-GBKTM7HE.mjs";
|
|
1
4
|
import {
|
|
2
5
|
collectRuntimeClassSet,
|
|
3
|
-
createTailwindPatchPromise,
|
|
4
6
|
getCompilerContext,
|
|
5
7
|
refreshTailwindRuntimeState
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-T25LQFYZ.mjs";
|
|
9
|
+
import "./chunk-3XGTIDA6.mjs";
|
|
8
10
|
import "./chunk-DKPIYG24.mjs";
|
|
9
11
|
import "./chunk-ZNKIYZRQ.mjs";
|
|
10
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-67CD2S5L.mjs";
|
|
11
13
|
|
|
12
14
|
// src/core.ts
|
|
15
|
+
import process from "process";
|
|
13
16
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
14
17
|
function createContext(options = {}) {
|
|
15
18
|
const opts = getCompilerContext(options);
|
|
16
19
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
20
|
+
const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
|
|
21
|
+
source: "runtime",
|
|
22
|
+
cwd: opts.tailwindcssBasedir ?? process.cwd()
|
|
23
|
+
});
|
|
17
24
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
18
25
|
const runtimeState = {
|
|
19
26
|
twPatcher: initialTwPatcher,
|
|
20
|
-
patchPromise:
|
|
21
|
-
refreshTailwindcssPatcher
|
|
27
|
+
patchPromise: patchRecorderState.patchPromise,
|
|
28
|
+
refreshTailwindcssPatcher,
|
|
29
|
+
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
22
30
|
};
|
|
23
31
|
async function refreshRuntimeState(force) {
|
|
24
32
|
await refreshTailwindRuntimeState(runtimeState, force);
|
package/dist/css-macro.js
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkNS3NEDWDjs = require('./chunk-NS3NEDWD.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
8
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-UTZLVU3M.js');
|
|
9
9
|
|
|
10
10
|
// src/css-macro/index.ts
|
|
11
11
|
var _plugin = require('tailwindcss/plugin'); var _plugin2 = _interopRequireDefault(_plugin);
|
package/dist/css-macro.mjs
CHANGED
package/dist/defaults.js
CHANGED
package/dist/defaults.mjs
CHANGED
package/dist/gulp.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOQGFV6TWjs = require('./chunk-OQGFV6TW.js');
|
|
4
4
|
require('./chunk-LTJQUORK.js');
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-R6ERGDBQ.js');
|
|
6
|
+
require('./chunk-YKMZHWQ4.js');
|
|
7
|
+
require('./chunk-RJRLVYVJ.js');
|
|
7
8
|
require('./chunk-ZSTF2AEN.js');
|
|
8
9
|
require('./chunk-UW3WHSZ5.js');
|
|
9
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-UTZLVU3M.js');
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
exports.createPlugins =
|
|
13
|
+
exports.createPlugins = _chunkOQGFV6TWjs.createPlugins;
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugins
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NE4IF47K.mjs";
|
|
4
4
|
import "./chunk-RRHPTTCP.mjs";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-GBKTM7HE.mjs";
|
|
6
|
+
import "./chunk-T25LQFYZ.mjs";
|
|
7
|
+
import "./chunk-3XGTIDA6.mjs";
|
|
7
8
|
import "./chunk-DKPIYG24.mjs";
|
|
8
9
|
import "./chunk-ZNKIYZRQ.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-67CD2S5L.mjs";
|
|
10
11
|
export {
|
|
11
12
|
createPlugins
|
|
12
13
|
};
|
package/dist/index.js
CHANGED
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunk5KVCFUCRjs = require('./chunk-5KVCFUCR.js');
|
|
6
|
+
require('./chunk-OR5KGJ46.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkOQGFV6TWjs = require('./chunk-OQGFV6TW.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
require('./chunk-
|
|
12
|
+
var _chunkQZ5JL3U3js = require('./chunk-QZ5JL3U3.js');
|
|
13
|
+
require('./chunk-AB45L5FP.js');
|
|
14
14
|
require('./chunk-LTJQUORK.js');
|
|
15
|
-
require('./chunk-
|
|
16
|
-
require('./chunk-
|
|
15
|
+
require('./chunk-R6ERGDBQ.js');
|
|
16
|
+
require('./chunk-YKMZHWQ4.js');
|
|
17
|
+
require('./chunk-RJRLVYVJ.js');
|
|
17
18
|
require('./chunk-ZSTF2AEN.js');
|
|
18
19
|
require('./chunk-UW3WHSZ5.js');
|
|
19
|
-
require('./chunk-
|
|
20
|
+
require('./chunk-UTZLVU3M.js');
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
exports.UnifiedViteWeappTailwindcssPlugin =
|
|
26
|
+
exports.UnifiedViteWeappTailwindcssPlugin = _chunkQZ5JL3U3js.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunk5KVCFUCRjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkOQGFV6TWjs.createPlugins; exports.weappTailwindcssPackageDir = _chunk5KVCFUCRjs.weappTailwindcssPackageDir;
|
package/dist/index.mjs
CHANGED
|
@@ -2,21 +2,22 @@ import "./chunk-YAN7TO2B.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
UnifiedWebpackPluginV5,
|
|
4
4
|
weappTailwindcssPackageDir
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-E4WMGIBB.mjs";
|
|
6
|
+
import "./chunk-EQP3XJUM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createPlugins
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NE4IF47K.mjs";
|
|
10
10
|
import {
|
|
11
11
|
UnifiedViteWeappTailwindcssPlugin
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NMUFIIAM.mjs";
|
|
13
13
|
import "./chunk-JW7P34IH.mjs";
|
|
14
14
|
import "./chunk-RRHPTTCP.mjs";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-GBKTM7HE.mjs";
|
|
16
|
+
import "./chunk-T25LQFYZ.mjs";
|
|
17
|
+
import "./chunk-3XGTIDA6.mjs";
|
|
17
18
|
import "./chunk-DKPIYG24.mjs";
|
|
18
19
|
import "./chunk-ZNKIYZRQ.mjs";
|
|
19
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-67CD2S5L.mjs";
|
|
20
21
|
export {
|
|
21
22
|
UnifiedViteWeappTailwindcssPlugin,
|
|
22
23
|
UnifiedWebpackPluginV5,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-UTZLVU3M.js');
|
|
2
2
|
|
|
3
3
|
// src/postcss-html-transform.ts
|
|
4
4
|
var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _htmltransform2 = _interopRequireDefault(_htmltransform);
|
package/dist/presets.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
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
|
-
var _chunkOXASK55Qjs = require('./chunk-OXASK55Q.js');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
var _chunk2ZEOKKVAjs = require('./chunk-2ZEOKKVA.js');
|
|
4
|
+
var _chunkRJRLVYVJjs = require('./chunk-RJRLVYVJ.js');
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
10
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-UTZLVU3M.js');
|
|
11
9
|
|
|
12
10
|
// src/presets.ts
|
|
13
11
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
14
12
|
function uniAppX(options) {
|
|
15
|
-
|
|
13
|
+
_chunkRJRLVYVJjs.logger.info(`UNI_PLATFORM: ${_process2.default.env.UNI_PLATFORM}`);
|
|
16
14
|
const isApp = _process2.default.env.UNI_PLATFORM === "app" || _process2.default.env.UNI_PLATFORM === "app-plus" || _process2.default.env.UNI_PLATFORM === "app-harmony";
|
|
17
15
|
return _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
18
16
|
_nullishCoalesce(options.rawOptions, () => ( {})),
|
|
@@ -57,7 +55,7 @@ function toCssEntries(entries) {
|
|
|
57
55
|
return Array.isArray(entries) ? entries : [entries];
|
|
58
56
|
}
|
|
59
57
|
function hbuilderx(options = {}) {
|
|
60
|
-
const baseDir =
|
|
58
|
+
const baseDir = _chunkRJRLVYVJjs.resolveTailwindcssBasedir.call(void 0, options.base);
|
|
61
59
|
const cssEntries = toCssEntries(options.cssEntries);
|
|
62
60
|
const tailwindConfig = {
|
|
63
61
|
v2: {
|
package/dist/presets.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
logger
|
|
3
|
-
} from "./chunk-PMF2CCKK.mjs";
|
|
4
|
-
import {
|
|
2
|
+
logger,
|
|
5
3
|
resolveTailwindcssBasedir
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3XGTIDA6.mjs";
|
|
7
5
|
import {
|
|
8
6
|
defuOverrideArray
|
|
9
7
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
10
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-67CD2S5L.mjs";
|
|
11
9
|
|
|
12
10
|
// src/presets.ts
|
|
13
11
|
import process from "process";
|
package/dist/reset.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as tailwindcss_types_config from 'tailwindcss/types/config';
|
|
2
|
+
|
|
3
|
+
interface ResetOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 控制 `button` reset 的注入与选择器,传入 `false` 可跳过该规则。
|
|
6
|
+
*/
|
|
7
|
+
buttonReset?: false | ResetConfig;
|
|
8
|
+
/**
|
|
9
|
+
* 控制 `image` reset(同时覆盖 `<image>` 与 `<img>`)。
|
|
10
|
+
*/
|
|
11
|
+
imageReset?: false | ResetConfig;
|
|
12
|
+
/**
|
|
13
|
+
* 额外的 reset 规则,可根据业务自定义。
|
|
14
|
+
*/
|
|
15
|
+
extraResets?: ResetConfig[];
|
|
16
|
+
}
|
|
17
|
+
interface ResetConfig {
|
|
18
|
+
selectors?: string[];
|
|
19
|
+
declarations?: Record<string, string | number | false | null | undefined>;
|
|
20
|
+
pseudo?: Record<string, string | number | false | null | undefined>;
|
|
21
|
+
}
|
|
22
|
+
declare const reset: {
|
|
23
|
+
(options: ResetOptions): {
|
|
24
|
+
handler: tailwindcss_types_config.PluginCreator;
|
|
25
|
+
config?: Partial<tailwindcss_types_config.Config>;
|
|
26
|
+
};
|
|
27
|
+
__isOptionsFunction: true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { type ResetConfig, type ResetOptions, reset as default, reset };
|
package/dist/reset.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as tailwindcss_types_config from 'tailwindcss/types/config';
|
|
2
|
+
|
|
3
|
+
interface ResetOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 控制 `button` reset 的注入与选择器,传入 `false` 可跳过该规则。
|
|
6
|
+
*/
|
|
7
|
+
buttonReset?: false | ResetConfig;
|
|
8
|
+
/**
|
|
9
|
+
* 控制 `image` reset(同时覆盖 `<image>` 与 `<img>`)。
|
|
10
|
+
*/
|
|
11
|
+
imageReset?: false | ResetConfig;
|
|
12
|
+
/**
|
|
13
|
+
* 额外的 reset 规则,可根据业务自定义。
|
|
14
|
+
*/
|
|
15
|
+
extraResets?: ResetConfig[];
|
|
16
|
+
}
|
|
17
|
+
interface ResetConfig {
|
|
18
|
+
selectors?: string[];
|
|
19
|
+
declarations?: Record<string, string | number | false | null | undefined>;
|
|
20
|
+
pseudo?: Record<string, string | number | false | null | undefined>;
|
|
21
|
+
}
|
|
22
|
+
declare const reset: {
|
|
23
|
+
(options: ResetOptions): {
|
|
24
|
+
handler: tailwindcss_types_config.PluginCreator;
|
|
25
|
+
config?: Partial<tailwindcss_types_config.Config>;
|
|
26
|
+
};
|
|
27
|
+
__isOptionsFunction: true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
export = reset;
|
|
32
|
+
export { type ResetConfig, type ResetOptions, reset };
|
package/dist/reset.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
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; }require('./chunk-UTZLVU3M.js');
|
|
2
|
+
|
|
3
|
+
// src/reset/index.ts
|
|
4
|
+
var _plugin = require('tailwindcss/plugin'); var _plugin2 = _interopRequireDefault(_plugin);
|
|
5
|
+
var DEFAULT_BUTTON_RESET_SELECTORS = ["button"];
|
|
6
|
+
var DEFAULT_BUTTON_DECLARATIONS = {
|
|
7
|
+
padding: "0",
|
|
8
|
+
backgroundColor: "transparent",
|
|
9
|
+
fontSize: "inherit",
|
|
10
|
+
lineHeight: "inherit",
|
|
11
|
+
color: "inherit",
|
|
12
|
+
borderWidth: "0"
|
|
13
|
+
};
|
|
14
|
+
var BUTTON_RESET_PSEUDO_DECLARATIONS = {
|
|
15
|
+
border: "none"
|
|
16
|
+
};
|
|
17
|
+
var DEFAULT_IMAGE_RESET_SELECTORS = ["image", "img"];
|
|
18
|
+
var DEFAULT_IMAGE_DECLARATIONS = {
|
|
19
|
+
display: "block",
|
|
20
|
+
borderWidth: "0",
|
|
21
|
+
backgroundColor: "transparent",
|
|
22
|
+
maxWidth: "100%",
|
|
23
|
+
height: "auto"
|
|
24
|
+
};
|
|
25
|
+
function normalizeResetSelectors(option, defaults) {
|
|
26
|
+
const resolved = _optionalChain([option, 'optionalAccess', _ => _.selectors, 'optionalAccess', _2 => _2.length]) ? option.selectors : defaults;
|
|
27
|
+
const normalized = [];
|
|
28
|
+
for (const selector of resolved) {
|
|
29
|
+
const trimmed = selector.trim();
|
|
30
|
+
if (!trimmed || normalized.includes(trimmed)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
normalized.push(trimmed);
|
|
34
|
+
}
|
|
35
|
+
return normalized.length ? normalized : void 0;
|
|
36
|
+
}
|
|
37
|
+
function convertSelectorForBase(selector) {
|
|
38
|
+
if (selector.startsWith(".")) {
|
|
39
|
+
const className = selector.slice(1);
|
|
40
|
+
if (className.length > 0) {
|
|
41
|
+
return `[class~="${className}"]`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (selector.startsWith("#")) {
|
|
45
|
+
const id = selector.slice(1);
|
|
46
|
+
if (id.length > 0) {
|
|
47
|
+
return `[id="${id}"]`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return selector;
|
|
51
|
+
}
|
|
52
|
+
function normalizeDeclarations(option, defaults) {
|
|
53
|
+
const normalized = { ...defaults };
|
|
54
|
+
const overrides = _optionalChain([option, 'optionalAccess', _3 => _3.declarations]);
|
|
55
|
+
if (!overrides) {
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
const entries = Object.entries(overrides);
|
|
59
|
+
for (const [prop, value] of entries) {
|
|
60
|
+
const resolved = normalizeDeclarationValue(value);
|
|
61
|
+
if (resolved === void 0) {
|
|
62
|
+
delete normalized[prop];
|
|
63
|
+
} else {
|
|
64
|
+
normalized[prop] = resolved;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return normalized;
|
|
68
|
+
}
|
|
69
|
+
function normalizePseudo(option, defaults) {
|
|
70
|
+
const normalized = defaults ? { ...defaults } : {};
|
|
71
|
+
const overrides = _optionalChain([option, 'optionalAccess', _4 => _4.pseudo]);
|
|
72
|
+
if (!overrides) {
|
|
73
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
74
|
+
}
|
|
75
|
+
const entries = Object.entries(overrides);
|
|
76
|
+
for (const [prop, value] of entries) {
|
|
77
|
+
const resolved = normalizeDeclarationValue(value);
|
|
78
|
+
if (resolved === void 0) {
|
|
79
|
+
delete normalized[prop];
|
|
80
|
+
} else {
|
|
81
|
+
normalized[prop] = resolved;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
85
|
+
}
|
|
86
|
+
function normalizeDeclarationValue(value) {
|
|
87
|
+
if (value === false || value === null || value === void 0) {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
return typeof value === "number" ? value.toString() : value;
|
|
91
|
+
}
|
|
92
|
+
function createResetRule(option, defaults) {
|
|
93
|
+
if (option === false) {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
const selectors = normalizeResetSelectors(option, defaults.selectors);
|
|
97
|
+
if (!selectors) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
const declarations = normalizeDeclarations(_nullishCoalesce(option, () => ( {})), defaults.declarations);
|
|
101
|
+
if (Object.keys(declarations).length === 0) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
const pseudo = normalizePseudo(_nullishCoalesce(option, () => ( {})), defaults.pseudo);
|
|
105
|
+
return {
|
|
106
|
+
selectors: selectors.map(convertSelectorForBase),
|
|
107
|
+
declarations,
|
|
108
|
+
pseudo
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
var reset = _plugin2.default.withOptions(
|
|
112
|
+
(options) => {
|
|
113
|
+
const rules = [];
|
|
114
|
+
const buttonRule = createResetRule(_optionalChain([options, 'optionalAccess', _5 => _5.buttonReset]), {
|
|
115
|
+
selectors: DEFAULT_BUTTON_RESET_SELECTORS,
|
|
116
|
+
declarations: DEFAULT_BUTTON_DECLARATIONS,
|
|
117
|
+
pseudo: BUTTON_RESET_PSEUDO_DECLARATIONS
|
|
118
|
+
});
|
|
119
|
+
if (buttonRule) {
|
|
120
|
+
rules.push(buttonRule);
|
|
121
|
+
}
|
|
122
|
+
const imageRule = createResetRule(_optionalChain([options, 'optionalAccess', _6 => _6.imageReset]), {
|
|
123
|
+
selectors: DEFAULT_IMAGE_RESET_SELECTORS,
|
|
124
|
+
declarations: DEFAULT_IMAGE_DECLARATIONS
|
|
125
|
+
});
|
|
126
|
+
if (imageRule) {
|
|
127
|
+
rules.push(imageRule);
|
|
128
|
+
}
|
|
129
|
+
for (const extra of _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.extraResets]), () => ( []))) {
|
|
130
|
+
const normalized = createResetRule(extra, {
|
|
131
|
+
selectors: _nullishCoalesce(extra.selectors, () => ( [])),
|
|
132
|
+
declarations: {}
|
|
133
|
+
});
|
|
134
|
+
if (normalized) {
|
|
135
|
+
rules.push(normalized);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return ({ addBase }) => {
|
|
139
|
+
if (!rules.length) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const baseRules = {};
|
|
143
|
+
for (const rule of rules) {
|
|
144
|
+
baseRules[rule.selectors.join(",")] = rule.declarations;
|
|
145
|
+
if (rule.pseudo) {
|
|
146
|
+
const pseudoSelectors = rule.selectors.map((selector) => `${selector}::after`).join(",");
|
|
147
|
+
baseRules[pseudoSelectors] = rule.pseudo;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
addBase(baseRules);
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
() => {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
var reset_default = reset;
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
exports.default = reset_default; exports.reset = reset;
|