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
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDebug
|
|
3
|
+
} from "./chunk-75EWCRQW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getOptions
|
|
6
|
+
} from "./chunk-PC4B5JJB.mjs";
|
|
7
|
+
import {
|
|
8
|
+
getGroupedEntries
|
|
9
|
+
} from "./chunk-GUE4UCRJ.mjs";
|
|
10
|
+
import {
|
|
11
|
+
vitePluginName
|
|
12
|
+
} from "./chunk-IOYI6MSW.mjs";
|
|
13
|
+
import {
|
|
14
|
+
__async
|
|
15
|
+
} from "./chunk-E7XGHGC7.mjs";
|
|
16
|
+
|
|
17
|
+
// src/bundlers/vite/index.ts
|
|
18
|
+
var debug = createDebug();
|
|
19
|
+
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
20
|
+
const opts = getOptions(options);
|
|
21
|
+
const {
|
|
22
|
+
disabled,
|
|
23
|
+
onEnd,
|
|
24
|
+
onLoad,
|
|
25
|
+
onStart,
|
|
26
|
+
onUpdate,
|
|
27
|
+
templateHandler,
|
|
28
|
+
styleHandler,
|
|
29
|
+
patch,
|
|
30
|
+
jsHandler,
|
|
31
|
+
mainCssChunkMatcher,
|
|
32
|
+
appType,
|
|
33
|
+
setMangleRuntimeSet,
|
|
34
|
+
cache,
|
|
35
|
+
twPatcher
|
|
36
|
+
} = opts;
|
|
37
|
+
if (disabled) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
patch == null ? void 0 : patch();
|
|
41
|
+
onLoad();
|
|
42
|
+
return {
|
|
43
|
+
name: vitePluginName,
|
|
44
|
+
enforce: "post",
|
|
45
|
+
generateBundle(opt, bundle) {
|
|
46
|
+
return __async(this, null, function* () {
|
|
47
|
+
debug("start");
|
|
48
|
+
onStart();
|
|
49
|
+
const entries = Object.entries(bundle);
|
|
50
|
+
const groupedEntries = getGroupedEntries(entries, opts);
|
|
51
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
52
|
+
setMangleRuntimeSet(runtimeSet);
|
|
53
|
+
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
54
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
55
|
+
let noCachedCount = 0;
|
|
56
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
57
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
58
|
+
const oldVal = originalSource.source.toString();
|
|
59
|
+
const hash = cache.computeHash(oldVal);
|
|
60
|
+
cache.calcHashValueChanged(file, hash);
|
|
61
|
+
yield cache.process(
|
|
62
|
+
file,
|
|
63
|
+
() => {
|
|
64
|
+
const source = cache.get(file);
|
|
65
|
+
if (source) {
|
|
66
|
+
originalSource.source = source;
|
|
67
|
+
debug("html cache hit: %s", file);
|
|
68
|
+
} else {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
() => __async(this, null, function* () {
|
|
73
|
+
originalSource.source = yield templateHandler(oldVal, {
|
|
74
|
+
runtimeSet
|
|
75
|
+
});
|
|
76
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
77
|
+
debug("html handle: %s", file);
|
|
78
|
+
noCachedCount++;
|
|
79
|
+
return {
|
|
80
|
+
key: file,
|
|
81
|
+
source: originalSource.source
|
|
82
|
+
};
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
|
|
87
|
+
}
|
|
88
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
89
|
+
let noCachedCount = 0;
|
|
90
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
91
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
92
|
+
const rawSource = originalSource.code;
|
|
93
|
+
const hash = cache.computeHash(rawSource);
|
|
94
|
+
cache.calcHashValueChanged(file, hash);
|
|
95
|
+
yield cache.process(
|
|
96
|
+
file,
|
|
97
|
+
() => {
|
|
98
|
+
const source = cache.get(file);
|
|
99
|
+
if (source) {
|
|
100
|
+
originalSource.code = source;
|
|
101
|
+
debug("js cache hit: %s", file);
|
|
102
|
+
} else {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
() => __async(this, null, function* () {
|
|
107
|
+
const mapFilename = `${file}.map`;
|
|
108
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
109
|
+
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
110
|
+
generateMap: hasMap
|
|
111
|
+
});
|
|
112
|
+
originalSource.code = code;
|
|
113
|
+
onUpdate(file, rawSource, code);
|
|
114
|
+
debug("js handle: %s", file);
|
|
115
|
+
noCachedCount++;
|
|
116
|
+
if (hasMap && map) {
|
|
117
|
+
;
|
|
118
|
+
bundle[mapFilename].source = map.toString();
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
key: file,
|
|
122
|
+
source: code
|
|
123
|
+
};
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
|
|
128
|
+
}
|
|
129
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
130
|
+
let noCachedCount = 0;
|
|
131
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
132
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
133
|
+
const rawSource = originalSource.source.toString();
|
|
134
|
+
const hash = cache.computeHash(rawSource);
|
|
135
|
+
cache.calcHashValueChanged(file, hash);
|
|
136
|
+
yield cache.process(
|
|
137
|
+
file,
|
|
138
|
+
() => {
|
|
139
|
+
const source = cache.get(file);
|
|
140
|
+
if (source) {
|
|
141
|
+
originalSource.source = source;
|
|
142
|
+
debug("css cache hit: %s", file);
|
|
143
|
+
} else {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
() => __async(this, null, function* () {
|
|
148
|
+
const css = yield styleHandler(rawSource, {
|
|
149
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
150
|
+
});
|
|
151
|
+
originalSource.source = css;
|
|
152
|
+
onUpdate(file, rawSource, css);
|
|
153
|
+
debug("css handle: %s", file);
|
|
154
|
+
noCachedCount++;
|
|
155
|
+
return {
|
|
156
|
+
key: file,
|
|
157
|
+
source: css
|
|
158
|
+
};
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
|
|
163
|
+
}
|
|
164
|
+
onEnd();
|
|
165
|
+
debug("end");
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
UnifiedViteWeappTailwindcssPlugin
|
|
173
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/debug/index.ts
|
|
2
|
+
import _createDebug from "debug";
|
|
3
|
+
var _debug = _createDebug("weapp-tw");
|
|
4
|
+
function createDebug(prefix) {
|
|
5
|
+
function debug(formatter, ...args) {
|
|
6
|
+
return _debug((prefix != null ? prefix : "") + formatter, ...args);
|
|
7
|
+
}
|
|
8
|
+
return debug;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
createDebug
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/css-macro/constants.ts
|
|
2
|
+
var queryKey = "weapp-tw-platform";
|
|
3
|
+
function createMediaQuery(value) {
|
|
4
|
+
return `@media (${queryKey}:"${value}"){&}`;
|
|
5
|
+
}
|
|
6
|
+
function createNegativeMediaQuery(value) {
|
|
7
|
+
return `@media not screen and (${queryKey}:"${value}"){&}`;
|
|
8
|
+
}
|
|
9
|
+
function normalComment(text) {
|
|
10
|
+
if (typeof text === "string") {
|
|
11
|
+
return text.replaceAll(new RegExp("(?<!\\\\)_", "g"), " ");
|
|
12
|
+
}
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
function ifdef(text) {
|
|
16
|
+
return {
|
|
17
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
18
|
+
end: `#endif`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function ifndef(text) {
|
|
22
|
+
return {
|
|
23
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
24
|
+
end: `#endif`
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
28
|
+
let arr;
|
|
29
|
+
let index = 0;
|
|
30
|
+
const regex = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
31
|
+
while ((arr = regex.exec(str)) !== null) {
|
|
32
|
+
cb(arr, index);
|
|
33
|
+
index++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
createMediaQuery,
|
|
39
|
+
createNegativeMediaQuery,
|
|
40
|
+
ifdef,
|
|
41
|
+
ifndef,
|
|
42
|
+
matchCustomPropertyFromValue
|
|
43
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
35
|
+
var __async = (__this, __arguments, generator) => {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
var fulfilled = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.next(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var rejected = (value) => {
|
|
45
|
+
try {
|
|
46
|
+
step(generator.throw(value));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
52
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
__spreadValues,
|
|
58
|
+
__spreadProps,
|
|
59
|
+
__export,
|
|
60
|
+
__reExport,
|
|
61
|
+
__async
|
|
62
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
if (value === null || typeof value !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (Symbol.iterator in value) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (Symbol.toStringTag in value) {
|
|
14
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
19
|
+
if (!isPlainObject(defaults)) {
|
|
20
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
21
|
+
}
|
|
22
|
+
const object = Object.assign({}, defaults);
|
|
23
|
+
for (const key in baseObject) {
|
|
24
|
+
if (key === "__proto__" || key === "constructor") {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const value = baseObject[key];
|
|
28
|
+
if (value === null || value === void 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
35
|
+
object[key] = [...value, ...object[key]];
|
|
36
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
37
|
+
object[key] = _defu(
|
|
38
|
+
value,
|
|
39
|
+
object[key],
|
|
40
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
41
|
+
merger
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
object[key] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return object;
|
|
48
|
+
}
|
|
49
|
+
function createDefu(merger) {
|
|
50
|
+
return (...arguments_) => (
|
|
51
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
52
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
var defu = createDefu();
|
|
56
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
57
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
58
|
+
object[key] = currentValue(object[key]);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
63
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
64
|
+
object[key] = currentValue(object[key]);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/utils.ts
|
|
70
|
+
function isMap(value) {
|
|
71
|
+
return Object.prototype.toString.call(value) === "[object Map]";
|
|
72
|
+
}
|
|
73
|
+
function noop() {
|
|
74
|
+
}
|
|
75
|
+
function groupBy(arr, cb) {
|
|
76
|
+
if (!Array.isArray(arr)) {
|
|
77
|
+
throw new TypeError("expected an array for first argument");
|
|
78
|
+
}
|
|
79
|
+
if (typeof cb !== "function") {
|
|
80
|
+
throw new TypeError("expected a function for second argument");
|
|
81
|
+
}
|
|
82
|
+
const result = {};
|
|
83
|
+
for (const item of arr) {
|
|
84
|
+
const bucketCategory = cb(item);
|
|
85
|
+
const bucket = result[bucketCategory];
|
|
86
|
+
if (Array.isArray(bucket)) {
|
|
87
|
+
result[bucketCategory].push(item);
|
|
88
|
+
} else {
|
|
89
|
+
result[bucketCategory] = [item];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
function getGroupedEntries(entries, options) {
|
|
95
|
+
const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
|
|
96
|
+
const groupedEntries = groupBy(entries, ([file]) => {
|
|
97
|
+
if (cssMatcher(file)) {
|
|
98
|
+
return "css";
|
|
99
|
+
} else if (htmlMatcher(file)) {
|
|
100
|
+
return "html";
|
|
101
|
+
} else if (jsMatcher(file) || wxsMatcher(file)) {
|
|
102
|
+
return "js";
|
|
103
|
+
} else {
|
|
104
|
+
return "other";
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return groupedEntries;
|
|
108
|
+
}
|
|
109
|
+
function removeExt(file) {
|
|
110
|
+
return file.replace(/\.[^./]+$/, "");
|
|
111
|
+
}
|
|
112
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
113
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
114
|
+
obj[key] = value;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
defu,
|
|
121
|
+
isMap,
|
|
122
|
+
noop,
|
|
123
|
+
getGroupedEntries,
|
|
124
|
+
removeExt,
|
|
125
|
+
defuOverrideArray
|
|
126
|
+
};
|