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
package/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
  >
26
26
  > 小程序原生工具链 `weapp-vite` 已经发布,使用它改善你的原生小程序开发体验吧,更多详见 [官方文档](https://vite.icebreaker.top/)
27
27
 
28
- \[[文档地址](https://tw.icebreaker.top)\] \| \[[备用文档地址](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
28
+ \[[文档地址](https://tw.icebreaker.top)\] \| \[[加入技术交流群](https://tw.icebreaker.top/docs/community/group)\]
29
29
 
30
30
  - [特性](#特性)
31
31
  - [版本对应](#版本对应)
@@ -36,15 +36,11 @@
36
36
  - [旧版本迁移指南](#旧版本迁移指南)
37
37
  - [配置项参考](#配置项参考)
38
38
  - [变更日志](#变更日志)
39
- - [Tips](#tips)
40
39
  - [Contribute](#contribute)
41
40
  - [License](#license)
42
41
  - [Star History](#star-history)
43
42
  - [Related projects](#related-projects)
44
43
  - [weapp-vite](#weapp-vite)
45
- - [IceStack](#icestack)
46
- - [weapp-ide-cli](#weapp-ide-cli)
47
- - [weapp-pandacss](#weapp-pandacss)
48
44
 
49
45
  ## 特性
50
46
 
@@ -78,12 +74,6 @@
78
74
 
79
75
  ## [变更日志](./CHANGELOG.md)
80
76
 
81
- ## Tips
82
-
83
- 前沿阅读: [What’s Tailwind Oxide Engine? The Next Evolution of Tailwind CSS](https://medium.com/@bomber.marek/whats-tailwind-oxide-engine-the-next-evolution-of-tailwind-css-32e7ef8e19a1)
84
-
85
- 未来 `tailwindcss@4` 会切换到这个引擎来大幅加快构建和运行速度,当然等它发布正式版本的时候,我也会尽可能第一时间去进行兼容新的引擎。
86
-
87
77
  ## Contribute
88
78
 
89
79
  我们邀请你来贡献和帮助改进 `weapp-tailwindcss` 💚💚💚
@@ -108,15 +98,3 @@
108
98
  ### weapp-vite
109
99
 
110
100
  [weapp-vite](https://vite.icebreaker.top/): 把现代化的开发模式带入小程序开发!
111
-
112
- ### IceStack
113
-
114
- [IceStack](https://github.com/sonofmagic/icestack): ❤️ IceStack, Web UI for Mobile, PC, open-source Css component library generator
115
-
116
- ### weapp-ide-cli
117
-
118
- [weapp-ide-cli](https://github.com/sonofmagic/utils/tree/main/packages/weapp-ide-cli): 一个微信开发者工具命令行,快速方便的直接启动 ide 进行登录,开发,预览,上传代码等等功能。
119
-
120
- ### weapp-pandacss
121
-
122
- [weapp-pandacss](https://github.com/sonofmagic/weapp-pandacss) `CSS-in-JS` 编译时框架的小程序适配器
@@ -0,0 +1,216 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
4
+
5
+
6
+ var _chunkLWRZXI5Tjs = require('./chunk-LWRZXI5T.js');
7
+
8
+
9
+
10
+ var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
11
+
12
+
13
+ var _chunkLQN2VTMUjs = require('./chunk-LQN2VTMU.js');
14
+
15
+
16
+ var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
17
+
18
+ // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
19
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
20
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
21
+ var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
22
+ var UnifiedWebpackPluginV5 = class {
23
+ constructor(options = {}) {
24
+ this.options = _chunkLWRZXI5Tjs.getOptions.call(void 0, 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 : _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js");
55
+ const isExisted = _fs2.default.existsSync(loader);
56
+ const WeappTwRuntimeAopLoader = {
57
+ loader,
58
+ options: {
59
+ getClassSet
60
+ },
61
+ ident: null,
62
+ type: null
63
+ };
64
+ compiler.hooks.compilation.tap(_chunkLQN2VTMUjs.pluginName, (compilation) => {
65
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkLQN2VTMUjs.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: _chunkLQN2VTMUjs.pluginName,
76
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
77
+ },
78
+ (assets) => _chunk6FNC3XMIjs.__async.call(void 0, 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 = _chunk35CYTBPMjs.getGroupedEntries.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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 = _chunk35CYTBPMjs.removeExt.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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
+ () => _chunk6FNC3XMIjs.__async.call(void 0, 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
+
215
+
216
+ exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
@@ -0,0 +1,26 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/index.ts
2
+ var _shared = require('@weapp-tailwindcss/shared');
3
+ function getGroupedEntries(entries, options) {
4
+ const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
5
+ const groupedEntries = _shared.groupBy.call(void 0, entries, ([file]) => {
6
+ if (cssMatcher(file)) {
7
+ return "css";
8
+ } else if (htmlMatcher(file)) {
9
+ return "html";
10
+ } else if (jsMatcher(file) || wxsMatcher(file)) {
11
+ return "js";
12
+ } else {
13
+ return "other";
14
+ }
15
+ });
16
+ return groupedEntries;
17
+ }
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+ exports.defu = _shared.defu; exports.defuOverrideArray = _shared.defuOverrideArray; exports.isMap = _shared.isMap; exports.noop = _shared.noop; exports.removeExt = _shared.removeExt; exports.getGroupedEntries = getGroupedEntries;
@@ -0,0 +1,45 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+
42
+
43
+
44
+
45
+ exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__async = __async;
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// 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
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.createMediaQuery = createMediaQuery; exports.createNegativeMediaQuery = createNegativeMediaQuery; exports.ifdef = ifdef; exports.ifndef = ifndef; exports.matchCustomPropertyFromValue = matchCustomPropertyFromValue;
@@ -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,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ export {
42
+ __spreadValues,
43
+ __spreadProps,
44
+ __async
45
+ };
@@ -0,0 +1,173 @@
1
+ import {
2
+ createDebug
3
+ } from "./chunk-75EWCRQW.mjs";
4
+ import {
5
+ getOptions
6
+ } from "./chunk-MWTUP5KG.mjs";
7
+ import {
8
+ getGroupedEntries
9
+ } from "./chunk-MUJ65IQ3.mjs";
10
+ import {
11
+ vitePluginName
12
+ } from "./chunk-KE7J6XFD.mjs";
13
+ import {
14
+ __async
15
+ } from "./chunk-AXBFBHS2.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
+ };