weapp-tailwindcss 3.7.0 → 3.8.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.
Files changed (149) hide show
  1. package/README.md +1 -23
  2. package/dist/chunk-2STNBSVB.js +216 -0
  3. package/dist/chunk-35CYTBPM.js +26 -0
  4. package/dist/chunk-6FNC3XMI.js +45 -0
  5. package/dist/chunk-6Z776ZWK.js +43 -0
  6. package/dist/chunk-75EWCRQW.mjs +13 -0
  7. package/dist/chunk-AB467PG7.mjs +43 -0
  8. package/dist/chunk-AXBFBHS2.mjs +45 -0
  9. package/dist/chunk-EODGLB63.mjs +173 -0
  10. package/dist/chunk-FG63RW47.mjs +7106 -0
  11. package/dist/chunk-HBQASQKY.js +13 -0
  12. package/dist/chunk-IETFIAKJ.js +152 -0
  13. package/dist/chunk-KE7J6XFD.mjs +537 -0
  14. package/dist/chunk-LQN2VTMU.js +537 -0
  15. package/dist/chunk-LWRZXI5T.js +1003 -0
  16. package/dist/chunk-MUJ65IQ3.mjs +26 -0
  17. package/dist/chunk-MWTUP5KG.mjs +1003 -0
  18. package/dist/chunk-NLFQ7XRK.mjs +152 -0
  19. package/dist/chunk-QEEWOML6.mjs +216 -0
  20. package/dist/chunk-RFNUATFD.js +24 -0
  21. package/dist/chunk-U7O2XXYR.mjs +24 -0
  22. package/dist/chunk-VKSQ6BRD.mjs +27 -0
  23. package/dist/chunk-XSZXPWWL.js +27 -0
  24. package/dist/chunk-YSEHQ3FF.js +173 -0
  25. package/dist/chunk-YYT4NLHK.js +7109 -0
  26. package/dist/cli.d.mts +2 -0
  27. package/dist/cli.d.ts +2 -1
  28. package/dist/cli.js +23 -3400
  29. package/dist/cli.mjs +28 -3392
  30. package/dist/core.d.mts +27 -0
  31. package/dist/core.d.ts +23 -4
  32. package/dist/core.js +34 -56
  33. package/dist/core.mjs +36 -54
  34. package/dist/css-macro/postcss.d.mts +7 -0
  35. package/dist/css-macro/postcss.d.ts +5 -3
  36. package/dist/css-macro/postcss.js +54 -45
  37. package/dist/css-macro/postcss.mjs +54 -45
  38. package/dist/css-macro.d.mts +18 -0
  39. package/dist/css-macro.d.ts +18 -0
  40. package/dist/css-macro.js +40 -0
  41. package/dist/css-macro.mjs +38 -0
  42. package/dist/defaults.d.mts +16 -0
  43. package/dist/defaults.d.ts +16 -2
  44. package/dist/defaults.js +5 -9
  45. package/dist/defaults.mjs +8 -4
  46. package/dist/escape.d.mts +19 -0
  47. package/dist/escape.d.ts +19 -4
  48. package/dist/escape.js +11 -0
  49. package/dist/escape.mjs +11 -0
  50. package/dist/gulp.d.mts +26 -0
  51. package/dist/gulp.d.ts +26 -1
  52. package/dist/gulp.js +11 -36
  53. package/dist/gulp.mjs +14 -31
  54. package/dist/index-g4epDIUu.d.mts +534 -0
  55. package/dist/index-g4epDIUu.d.ts +534 -0
  56. package/dist/index.d.mts +17 -0
  57. package/dist/index.d.ts +17 -4
  58. package/dist/index.js +22 -44
  59. package/dist/index.mjs +22 -34
  60. package/dist/postcss.d.mts +28 -0
  61. package/dist/postcss.d.ts +28 -1
  62. package/dist/postcss.js +9 -24
  63. package/dist/postcss.mjs +16 -8
  64. package/dist/replace.d.mts +22 -0
  65. package/dist/replace.d.ts +22 -3
  66. package/dist/replace.js +33 -50
  67. package/dist/replace.mjs +32 -25
  68. package/dist/shared-5ArEo9kL.d.mts +5 -0
  69. package/dist/shared-DI2Qz1ou.d.ts +5 -0
  70. package/dist/vite.d.mts +22 -0
  71. package/dist/vite.d.ts +22 -1
  72. package/dist/vite.js +11 -34
  73. package/dist/vite.mjs +14 -29
  74. package/dist/weapp-tw-runtime-loader.d.mts +7 -0
  75. package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
  76. package/dist/weapp-tw-runtime-loader.js +12 -12
  77. package/dist/weapp-tw-runtime-loader.mjs +12 -8
  78. package/dist/webpack.d.mts +26 -0
  79. package/dist/webpack.d.ts +26 -1
  80. package/dist/webpack.js +11 -35
  81. package/dist/webpack.mjs +14 -30
  82. package/dist/webpack4.d.mts +27 -0
  83. package/dist/webpack4.d.ts +27 -1
  84. package/dist/webpack4.js +204 -192
  85. package/dist/webpack4.mjs +210 -189
  86. package/package.json +29 -19
  87. package/dist/babel/index.d.ts +0 -5
  88. package/dist/bundlers/gulp/index.d.ts +0 -7
  89. package/dist/bundlers/vite/index.d.ts +0 -3
  90. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
  91. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
  92. package/dist/bundlers/webpack/index.d.ts +0 -1
  93. package/dist/cache/index.d.ts +0 -31
  94. package/dist/constants-CFM1J-h1.js +0 -42
  95. package/dist/constants-Dy2Dd3Fz.mjs +0 -36
  96. package/dist/constants.d.ts +0 -7
  97. package/dist/css-macro/constants.d.ts +0 -14
  98. package/dist/css-macro/index.d.ts +0 -15
  99. package/dist/css-macro/index.js +0 -36
  100. package/dist/css-macro/index.mjs +0 -30
  101. package/dist/debug/index.d.ts +0 -2
  102. package/dist/defaults-5A8JI2hW.mjs +0 -139
  103. package/dist/defaults-CdqzSWsR.js +0 -145
  104. package/dist/defu-Cdz2PomB.js +0 -60
  105. package/dist/defu-n46TJT6t.mjs +0 -57
  106. package/dist/env.d.ts +0 -2
  107. package/dist/extractors/split.d.ts +0 -3
  108. package/dist/index-BEIjgKpF.mjs +0 -11
  109. package/dist/index-BF8k8rHr.mjs +0 -517
  110. package/dist/index-BTXkyxen.js +0 -136
  111. package/dist/index-C0QsyqD6.mjs +0 -134
  112. package/dist/index-ClSBbhnm.js +0 -130
  113. package/dist/index-DoMb0-xW.mjs +0 -124
  114. package/dist/index-HC-Qkn0i.js +0 -17
  115. package/dist/index-h2-ZMO3S.js +0 -530
  116. package/dist/init.d.ts +0 -34
  117. package/dist/js/ast-grep.d.ts +0 -1
  118. package/dist/js/babel.d.ts +0 -3
  119. package/dist/js/handlers.d.ts +0 -11
  120. package/dist/js/index.d.ts +0 -7
  121. package/dist/logger.d.ts +0 -1
  122. package/dist/mangle/index.d.ts +0 -8
  123. package/dist/npm.d.ts +0 -22
  124. package/dist/options-Bv-1GQJY.js +0 -891
  125. package/dist/options-yXyCFCtr.mjs +0 -858
  126. package/dist/options.d.ts +0 -2
  127. package/dist/postcss/cssVars.d.ts +0 -5
  128. package/dist/postcss/index.d.ts +0 -4
  129. package/dist/postcss/mp.d.ts +0 -8
  130. package/dist/postcss/plugins/ctx.d.ts +0 -6
  131. package/dist/postcss/plugins/index.d.ts +0 -7
  132. package/dist/postcss/plugins/post.d.ts +0 -5
  133. package/dist/postcss/plugins/pre.d.ts +0 -5
  134. package/dist/postcss/preflight.d.ts +0 -3
  135. package/dist/postcss/selectorParser.d.ts +0 -6
  136. package/dist/postcss/shared.d.ts +0 -3
  137. package/dist/postcss/symbols.d.ts +0 -1
  138. package/dist/reg.d.ts +0 -1
  139. package/dist/shared-COWjpokr.mjs +0 -25
  140. package/dist/shared-r_GpWheO.js +0 -28
  141. package/dist/tailwindcss/patcher.d.ts +0 -3
  142. package/dist/types.d.ts +0 -165
  143. package/dist/utils.d.ts +0 -18
  144. package/dist/v5-DwFXG7m_.js +0 -181
  145. package/dist/v5-N5BYJ5JY.mjs +0 -174
  146. package/dist/wxml/Tokenizer.d.ts +0 -31
  147. package/dist/wxml/index.d.ts +0 -2
  148. package/dist/wxml/shared.d.ts +0 -2
  149. package/dist/wxml/utils.d.ts +0 -10
@@ -0,0 +1,152 @@
1
+ import {
2
+ createDebug
3
+ } from "./chunk-75EWCRQW.mjs";
4
+ import {
5
+ getOptions
6
+ } from "./chunk-MWTUP5KG.mjs";
7
+ import {
8
+ __async,
9
+ __spreadValues
10
+ } from "./chunk-AXBFBHS2.mjs";
11
+
12
+ // src/bundlers/gulp/index.ts
13
+ import { Buffer } from "node:buffer";
14
+ import stream from "node:stream";
15
+ var debug = createDebug();
16
+ var Transform = stream.Transform;
17
+ function createPlugins(options = {}) {
18
+ const opts = getOptions(options);
19
+ const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
20
+ let runtimeSet = /* @__PURE__ */ new Set();
21
+ patch == null ? void 0 : patch();
22
+ function transformWxss(options2 = {}) {
23
+ return new Transform({
24
+ objectMode: true,
25
+ transform(file, _encoding, callback) {
26
+ return __async(this, null, function* () {
27
+ runtimeSet = twPatcher.getClassSet();
28
+ setMangleRuntimeSet(runtimeSet);
29
+ const error = null;
30
+ if (file.contents) {
31
+ const rawSource = file.contents.toString();
32
+ const hash = cache.computeHash(rawSource);
33
+ cache.calcHashValueChanged(file.path, hash);
34
+ yield cache.process(
35
+ file.path,
36
+ () => {
37
+ const source = cache.get(file.path);
38
+ if (source) {
39
+ file.contents = Buffer.from(source);
40
+ debug("css cache hit: %s", file.path);
41
+ } else {
42
+ return false;
43
+ }
44
+ },
45
+ () => __async(this, null, function* () {
46
+ const { css } = yield styleHandler(rawSource, __spreadValues({
47
+ isMainChunk: true
48
+ }, options2));
49
+ file.contents = Buffer.from(css);
50
+ debug("css handle: %s", file.path);
51
+ return {
52
+ key: file.path,
53
+ source: css
54
+ };
55
+ })
56
+ );
57
+ }
58
+ callback(error, file);
59
+ });
60
+ }
61
+ // construct(callback) {
62
+ // debug('transformWxss start')
63
+ // callback()
64
+ // }
65
+ });
66
+ }
67
+ function transformJs(options2 = {}) {
68
+ return new Transform({
69
+ objectMode: true,
70
+ transform(file, _encoding, callback) {
71
+ return __async(this, null, function* () {
72
+ const error = null;
73
+ if (file.contents) {
74
+ const rawSource = file.contents.toString();
75
+ const hash = cache.computeHash(rawSource);
76
+ cache.calcHashValueChanged(file.path, hash);
77
+ yield cache.process(
78
+ file.path,
79
+ () => {
80
+ const source = cache.get(file.path);
81
+ if (source) {
82
+ file.contents = Buffer.from(source);
83
+ debug("js cache hit: %s", file.path);
84
+ } else {
85
+ return false;
86
+ }
87
+ },
88
+ () => __async(this, null, function* () {
89
+ const { code } = yield jsHandler(rawSource, runtimeSet, options2);
90
+ file.contents = Buffer.from(code);
91
+ debug("js handle: %s", file.path);
92
+ return {
93
+ key: file.path,
94
+ source: code
95
+ };
96
+ })
97
+ );
98
+ }
99
+ callback(error, file);
100
+ });
101
+ }
102
+ });
103
+ }
104
+ function transformWxml(options2 = {}) {
105
+ return new Transform({
106
+ objectMode: true,
107
+ transform(file, _encoding, callback) {
108
+ return __async(this, null, function* () {
109
+ const error = null;
110
+ if (file.contents) {
111
+ const rawSource = file.contents.toString();
112
+ const hash = cache.computeHash(rawSource);
113
+ cache.calcHashValueChanged(file.path, hash);
114
+ yield cache.process(
115
+ file.path,
116
+ () => {
117
+ const source = cache.get(file.path);
118
+ if (source) {
119
+ file.contents = Buffer.from(source);
120
+ debug("html cache hit: %s", file.path);
121
+ } else {
122
+ return false;
123
+ }
124
+ },
125
+ () => __async(this, null, function* () {
126
+ const code = yield templateHandler(rawSource, __spreadValues({
127
+ runtimeSet
128
+ }, options2));
129
+ file.contents = Buffer.from(code);
130
+ debug("html handle: %s", file.path);
131
+ return {
132
+ key: file.path,
133
+ source: code
134
+ };
135
+ })
136
+ );
137
+ }
138
+ callback(error, file);
139
+ });
140
+ }
141
+ });
142
+ }
143
+ return {
144
+ transformWxss,
145
+ transformWxml,
146
+ transformJs
147
+ };
148
+ }
149
+
150
+ export {
151
+ createPlugins
152
+ };
@@ -0,0 +1,216 @@
1
+ import {
2
+ createDebug
3
+ } from "./chunk-75EWCRQW.mjs";
4
+ import {
5
+ getOptions
6
+ } from "./chunk-MWTUP5KG.mjs";
7
+ import {
8
+ getGroupedEntries,
9
+ removeExt
10
+ } from "./chunk-MUJ65IQ3.mjs";
11
+ import {
12
+ pluginName
13
+ } from "./chunk-KE7J6XFD.mjs";
14
+ import {
15
+ __async
16
+ } from "./chunk-AXBFBHS2.mjs";
17
+
18
+ // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
19
+ import fs from "node:fs";
20
+ import path from "node:path";
21
+ var debug = createDebug();
22
+ var UnifiedWebpackPluginV5 = class {
23
+ constructor(options = {}) {
24
+ this.options = getOptions(options);
25
+ this.appType = this.options.appType;
26
+ }
27
+ apply(compiler) {
28
+ const {
29
+ mainCssChunkMatcher,
30
+ disabled,
31
+ onLoad,
32
+ onUpdate,
33
+ onEnd,
34
+ onStart,
35
+ styleHandler,
36
+ patch,
37
+ templateHandler,
38
+ jsHandler,
39
+ setMangleRuntimeSet,
40
+ runtimeLoaderPath,
41
+ cache,
42
+ twPatcher
43
+ } = this.options;
44
+ if (disabled) {
45
+ return;
46
+ }
47
+ patch == null ? void 0 : patch();
48
+ const { Compilation, sources, NormalModule } = compiler.webpack;
49
+ const { ConcatSource, RawSource } = sources;
50
+ function getClassSet() {
51
+ return twPatcher.getClassSet();
52
+ }
53
+ onLoad();
54
+ const loader = runtimeLoaderPath != null ? runtimeLoaderPath : path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
55
+ const isExisted = fs.existsSync(loader);
56
+ const WeappTwRuntimeAopLoader = {
57
+ loader,
58
+ options: {
59
+ getClassSet
60
+ },
61
+ ident: null,
62
+ type: null
63
+ };
64
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
65
+ NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
66
+ if (isExisted) {
67
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
68
+ if (idx > -1) {
69
+ module.loaders.unshift(WeappTwRuntimeAopLoader);
70
+ }
71
+ }
72
+ });
73
+ compilation.hooks.processAssets.tapPromise(
74
+ {
75
+ name: pluginName,
76
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
77
+ },
78
+ (assets) => __async(this, null, function* () {
79
+ onStart();
80
+ debug("start");
81
+ for (const chunk of compilation.chunks) {
82
+ if (chunk.id && chunk.hash) {
83
+ cache.calcHashValueChanged(chunk.id, chunk.hash);
84
+ }
85
+ }
86
+ const entries = Object.entries(assets);
87
+ const groupedEntries = getGroupedEntries(entries, this.options);
88
+ const runtimeSet = getClassSet();
89
+ setMangleRuntimeSet(runtimeSet);
90
+ debug("get runtimeSet, class count: %d", runtimeSet.size);
91
+ if (Array.isArray(groupedEntries.html)) {
92
+ let noCachedCount = 0;
93
+ for (let i = 0; i < groupedEntries.html.length; i++) {
94
+ const [file, originalSource] = groupedEntries.html[i];
95
+ const rawSource = originalSource.source().toString();
96
+ const hash = cache.computeHash(rawSource);
97
+ const cacheKey = file;
98
+ cache.calcHashValueChanged(cacheKey, hash);
99
+ yield cache.process(
100
+ cacheKey,
101
+ () => {
102
+ const source = cache.get(cacheKey);
103
+ if (source) {
104
+ compilation.updateAsset(file, source);
105
+ debug("html cache hit: %s", file);
106
+ } else {
107
+ return false;
108
+ }
109
+ },
110
+ () => __async(this, null, function* () {
111
+ const wxml = yield templateHandler(rawSource, {
112
+ runtimeSet
113
+ });
114
+ const source = new ConcatSource(wxml);
115
+ compilation.updateAsset(file, source);
116
+ onUpdate(file, rawSource, wxml);
117
+ debug("html handle: %s", file);
118
+ noCachedCount++;
119
+ return {
120
+ key: cacheKey,
121
+ source
122
+ };
123
+ })
124
+ );
125
+ }
126
+ debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
127
+ }
128
+ if (Array.isArray(groupedEntries.js)) {
129
+ let noCachedCount = 0;
130
+ for (let i = 0; i < groupedEntries.js.length; i++) {
131
+ const [file, originalSource] = groupedEntries.js[i];
132
+ const cacheKey = removeExt(file);
133
+ yield cache.process(
134
+ cacheKey,
135
+ () => {
136
+ const source = cache.get(cacheKey);
137
+ if (source) {
138
+ compilation.updateAsset(file, source);
139
+ debug("js cache hit: %s", file);
140
+ } else {
141
+ return false;
142
+ }
143
+ },
144
+ () => __async(this, null, function* () {
145
+ const rawSource = originalSource.source().toString();
146
+ const mapFilename = `${file}.map`;
147
+ const hasMap = Boolean(assets[mapFilename]);
148
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
149
+ generateMap: hasMap
150
+ });
151
+ const source = new ConcatSource(code);
152
+ compilation.updateAsset(file, source);
153
+ onUpdate(file, rawSource, code);
154
+ debug("js handle: %s", file);
155
+ noCachedCount++;
156
+ if (hasMap && map) {
157
+ const source2 = new RawSource(map.toString());
158
+ compilation.updateAsset(mapFilename, source2);
159
+ }
160
+ return {
161
+ key: cacheKey,
162
+ source
163
+ };
164
+ })
165
+ );
166
+ }
167
+ debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
168
+ }
169
+ if (Array.isArray(groupedEntries.css)) {
170
+ let noCachedCount = 0;
171
+ for (let i = 0; i < groupedEntries.css.length; i++) {
172
+ const [file, originalSource] = groupedEntries.css[i];
173
+ const rawSource = originalSource.source().toString();
174
+ const hash = cache.computeHash(rawSource);
175
+ const cacheKey = file;
176
+ cache.calcHashValueChanged(cacheKey, hash);
177
+ yield cache.process(
178
+ cacheKey,
179
+ () => {
180
+ const source = cache.get(cacheKey);
181
+ if (source) {
182
+ compilation.updateAsset(file, source);
183
+ debug("css cache hit: %s", file);
184
+ } else {
185
+ return false;
186
+ }
187
+ },
188
+ () => __async(this, null, function* () {
189
+ const { css } = yield styleHandler(rawSource, {
190
+ isMainChunk: mainCssChunkMatcher(file, this.appType)
191
+ });
192
+ const source = new ConcatSource(css);
193
+ compilation.updateAsset(file, source);
194
+ onUpdate(file, rawSource, css);
195
+ debug("css handle: %s", file);
196
+ noCachedCount++;
197
+ return {
198
+ key: cacheKey,
199
+ source
200
+ };
201
+ })
202
+ );
203
+ }
204
+ debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
205
+ }
206
+ debug("end");
207
+ onEnd();
208
+ })
209
+ );
210
+ });
211
+ }
212
+ };
213
+
214
+ export {
215
+ UnifiedWebpackPluginV5
216
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/wxml/shared.ts
2
+ var _escape = require('@weapp-core/escape');
3
+ function replaceWxml(original, options = {
4
+ keepEOL: false,
5
+ escapeMap: _escape.SimpleMappingChars2String
6
+ }) {
7
+ const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
8
+ let res = original;
9
+ if (!keepEOL) {
10
+ res = res.replaceAll(/[\n\r]+/g, "");
11
+ }
12
+ if (mangleContext) {
13
+ res = mangleContext.wxmlHandler(res);
14
+ }
15
+ res = _escape.escape.call(void 0, res, {
16
+ map: escapeMap,
17
+ ignoreHead
18
+ });
19
+ return res;
20
+ }
21
+
22
+
23
+
24
+ exports.replaceWxml = replaceWxml;
@@ -0,0 +1,24 @@
1
+ // src/wxml/shared.ts
2
+ import { escape, SimpleMappingChars2String } from "@weapp-core/escape";
3
+ function replaceWxml(original, options = {
4
+ keepEOL: false,
5
+ escapeMap: SimpleMappingChars2String
6
+ }) {
7
+ const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
8
+ let res = original;
9
+ if (!keepEOL) {
10
+ res = res.replaceAll(/[\n\r]+/g, "");
11
+ }
12
+ if (mangleContext) {
13
+ res = mangleContext.wxmlHandler(res);
14
+ }
15
+ res = escape(res, {
16
+ map: escapeMap,
17
+ ignoreHead
18
+ });
19
+ return res;
20
+ }
21
+
22
+ export {
23
+ replaceWxml
24
+ };
@@ -0,0 +1,27 @@
1
+ // src/postcss/shared.ts
2
+ import { escape, SimpleMappingChars2String } from "@weapp-core/escape";
3
+ function internalCssSelectorReplacer(selectors, options = {
4
+ escapeMap: SimpleMappingChars2String
5
+ }) {
6
+ const { mangleContext, escapeMap } = options;
7
+ if (mangleContext) {
8
+ selectors = mangleContext.cssHandler(selectors);
9
+ }
10
+ return escape(selectors, {
11
+ map: escapeMap
12
+ });
13
+ }
14
+ function composeIsPseudo(strs) {
15
+ if (typeof strs === "string") {
16
+ return strs;
17
+ }
18
+ if (strs.length > 1) {
19
+ return `:is(${strs.join(",")})`;
20
+ }
21
+ return strs.join("");
22
+ }
23
+
24
+ export {
25
+ internalCssSelectorReplacer,
26
+ composeIsPseudo
27
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/postcss/shared.ts
2
+ var _escape = require('@weapp-core/escape');
3
+ function internalCssSelectorReplacer(selectors, options = {
4
+ escapeMap: _escape.SimpleMappingChars2String
5
+ }) {
6
+ const { mangleContext, escapeMap } = options;
7
+ if (mangleContext) {
8
+ selectors = mangleContext.cssHandler(selectors);
9
+ }
10
+ return _escape.escape.call(void 0, selectors, {
11
+ map: escapeMap
12
+ });
13
+ }
14
+ function composeIsPseudo(strs) {
15
+ if (typeof strs === "string") {
16
+ return strs;
17
+ }
18
+ if (strs.length > 1) {
19
+ return `:is(${strs.join(",")})`;
20
+ }
21
+ return strs.join("");
22
+ }
23
+
24
+
25
+
26
+
27
+ exports.internalCssSelectorReplacer = internalCssSelectorReplacer; exports.composeIsPseudo = composeIsPseudo;
@@ -0,0 +1,173 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
4
+
5
+
6
+ var _chunkLWRZXI5Tjs = require('./chunk-LWRZXI5T.js');
7
+
8
+
9
+ var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
10
+
11
+
12
+ var _chunkLQN2VTMUjs = require('./chunk-LQN2VTMU.js');
13
+
14
+
15
+ var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
16
+
17
+ // src/bundlers/vite/index.ts
18
+ var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
19
+ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
20
+ const opts = _chunkLWRZXI5Tjs.getOptions.call(void 0, 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: _chunkLQN2VTMUjs.vitePluginName,
44
+ enforce: "post",
45
+ generateBundle(_opt, bundle) {
46
+ return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
47
+ debug("start");
48
+ onStart();
49
+ const entries = Object.entries(bundle);
50
+ const groupedEntries = _chunk35CYTBPMjs.getGroupedEntries.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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
+
172
+
173
+ exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;