weapp-tailwindcss 3.0.3 → 3.0.5

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 (42) hide show
  1. package/README.md +6 -2
  2. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
  3. package/dist/cli.js +18 -9
  4. package/dist/cli.mjs +14 -9
  5. package/dist/constants.d.ts +1 -0
  6. package/dist/core.js +4 -4
  7. package/dist/core.mjs +4 -4
  8. package/dist/css-macro/index.js +2 -2
  9. package/dist/css-macro/index.mjs +1 -1
  10. package/dist/{defaults-QOAV8NSV.js → defaults-1lCMiqik.js} +1 -1
  11. package/dist/{defaults-TZpmwtzd.mjs → defaults-c-Db9ovX.mjs} +1 -1
  12. package/dist/defaults.js +2 -2
  13. package/dist/defaults.mjs +2 -2
  14. package/dist/{defu-KWuJnZLV.js → defu-6bFjC68s.js} +19 -9
  15. package/dist/{defu-ms_ZBCiB.mjs → defu-p1R_k1Ss.mjs} +19 -9
  16. package/dist/gulp.js +7 -68
  17. package/dist/gulp.mjs +6 -67
  18. package/dist/index-0jdXviTO.js +142 -0
  19. package/dist/index-8dmkDRIb.mjs +64 -0
  20. package/dist/{postcss-bdPbDgs7.js → index-Fkmyt0Rc.js} +3 -1
  21. package/dist/index-IMKSE35e.js +70 -0
  22. package/dist/{postcss-MxkGjr8g.mjs → index-_74RBzwy.mjs} +2 -1
  23. package/dist/{index-z25r_Htj.js → index-juOeq2Kt.js} +1 -1
  24. package/dist/index-tkvJue1P.mjs +140 -0
  25. package/dist/index.js +11 -11
  26. package/dist/index.mjs +7 -7
  27. package/dist/{options-9bBYg22L.mjs → options-ERHjMNsB.mjs} +3 -3
  28. package/dist/{options-MDCr-9Qn.js → options-dD1xK3ZL.js} +4 -4
  29. package/dist/postcss.js +7 -7
  30. package/dist/postcss.mjs +1 -1
  31. package/dist/replace.js +5 -5
  32. package/dist/v5-Lso3d1gN.js +187 -0
  33. package/dist/v5-d_Ek52tu.mjs +180 -0
  34. package/dist/vite.js +11 -142
  35. package/dist/vite.mjs +9 -144
  36. package/dist/weapp-tw-runtime-loader.js +1 -1
  37. package/dist/webpack.js +12 -186
  38. package/dist/webpack.mjs +11 -184
  39. package/dist/webpack4.d.ts +1 -0
  40. package/dist/webpack4.js +208 -0
  41. package/dist/webpack4.mjs +199 -0
  42. package/package.json +46 -37
package/README.md CHANGED
@@ -21,8 +21,12 @@
21
21
  [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
22
22
  [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
23
23
 
24
- > `小程序` + `tailwindcss` 全方面解决方案
25
- > 想试试在小程序里使用 `CSS-in-JS` 思想? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
24
+ > 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
25
+ >
26
+ > 我的其他项目:
27
+ > `CSS UI` 生成器 [`@icestack/ui`](https://ui.icebreaker.top/zh-CN) 已经发布,快来用它管理你的`CSS` 组件吧!
28
+ >
29
+ > 想试试在小程序里使用**编译时**`CSS-in-JS` 工具? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
26
30
 
27
31
  \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
28
32
 
@@ -0,0 +1,8 @@
1
+ import type { Compiler } from 'webpack4';
2
+ import type { AppType, UserDefinedOptions, InternalUserDefinedOptions, IBaseWebpackPlugin } from "../../../types";
3
+ export declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
4
+ options: InternalUserDefinedOptions;
5
+ appType?: AppType;
6
+ constructor(options?: UserDefinedOptions);
7
+ apply(compiler: Compiler): void;
8
+ }
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-MDCr-9Qn.js');
3
+ var semver = require('semver');
4
+ var options = require('./options-dD1xK3ZL.js');
5
+ var index = require('./index-Fkmyt0Rc.js');
4
6
  require('magic-string');
5
7
  require('./replace.js');
6
8
  require('@weapp-core/escape');
@@ -10,25 +12,32 @@ require('@weapp-core/regex');
10
12
  require('@babel/generator');
11
13
  require('@babel/parser');
12
14
  require('@babel/traverse');
13
- require('./defaults-QOAV8NSV.js');
14
- require('./defu-KWuJnZLV.js');
15
+ require('./defaults-1lCMiqik.js');
16
+ require('./defu-6bFjC68s.js');
15
17
  require('@babel/types');
16
18
  require('htmlparser2');
17
19
  require('postcss');
18
- require('./postcss-bdPbDgs7.js');
19
- require('@csstools/postcss-is-pseudo-class');
20
- require('postcss-rem-to-responsive-pixel');
21
- require('postcss-selector-parser');
22
20
  require('node:path');
23
21
  require('node:fs');
24
- require('semver');
25
22
  require('tailwindcss-patch');
26
23
  require('@tailwindcss-mangle/shared');
27
24
  require('lru-cache');
28
25
  require('md5');
26
+ require('@csstools/postcss-is-pseudo-class');
27
+ require('postcss-rem-to-responsive-pixel');
28
+ require('postcss-selector-parser');
29
+
30
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
31
+
32
+ var semver__default = /*#__PURE__*/_interopDefaultCompat(semver);
29
33
 
30
34
  const args = process.argv.slice(2);
31
- if (args[0] === 'patch') {
35
+ if (semver__default["default"].lt(process.versions.node, index.WEAPP_TW_REQUIRED_NODE_VERSION)) {
36
+ console.error(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version >= v${index.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`);
37
+ process.exit(1);
38
+ }
39
+ const command = args[0];
40
+ if (command === 'patch') {
32
41
  const options$1 = options.getOptions();
33
42
  const patch = options.createPatch(options$1.supportCustomLengthUnitsPatch);
34
43
  patch();
package/dist/cli.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { g as getOptions, c as createPatch } from './options-9bBYg22L.mjs';
1
+ import semver from 'semver';
2
+ import { g as getOptions, a as createPatch } from './options-ERHjMNsB.mjs';
3
+ import { W as WEAPP_TW_REQUIRED_NODE_VERSION } from './index-_74RBzwy.mjs';
2
4
  import 'magic-string';
3
5
  import './replace.mjs';
4
6
  import '@weapp-core/escape';
@@ -8,25 +10,28 @@ import '@weapp-core/regex';
8
10
  import '@babel/generator';
9
11
  import '@babel/parser';
10
12
  import '@babel/traverse';
11
- import './defaults-TZpmwtzd.mjs';
12
- import './defu-ms_ZBCiB.mjs';
13
+ import './defaults-c-Db9ovX.mjs';
14
+ import './defu-p1R_k1Ss.mjs';
13
15
  import '@babel/types';
14
16
  import 'htmlparser2';
15
17
  import 'postcss';
16
- import './postcss-MxkGjr8g.mjs';
17
- import '@csstools/postcss-is-pseudo-class';
18
- import 'postcss-rem-to-responsive-pixel';
19
- import 'postcss-selector-parser';
20
18
  import 'node:path';
21
19
  import 'node:fs';
22
- import 'semver';
23
20
  import 'tailwindcss-patch';
24
21
  import '@tailwindcss-mangle/shared';
25
22
  import 'lru-cache';
26
23
  import 'md5';
24
+ import '@csstools/postcss-is-pseudo-class';
25
+ import 'postcss-rem-to-responsive-pixel';
26
+ import 'postcss-selector-parser';
27
27
 
28
28
  const args = process.argv.slice(2);
29
- if (args[0] === 'patch') {
29
+ if (semver.lt(process.versions.node, WEAPP_TW_REQUIRED_NODE_VERSION)) {
30
+ console.error(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version >= v${WEAPP_TW_REQUIRED_NODE_VERSION} is required.`);
31
+ process.exit(1);
32
+ }
33
+ const command = args[0];
34
+ if (command === 'patch') {
30
35
  const options = getOptions();
31
36
  const patch = createPatch(options.supportCustomLengthUnitsPatch);
32
37
  patch();
@@ -4,3 +4,4 @@ export declare const ManglePluginHooks = "ManglePluginHooks";
4
4
  export declare const WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks = "WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks";
5
5
  export declare const pluginName = "weapp-tailwindcss-webpack-plugin";
6
6
  export declare const vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
7
+ export declare const WEAPP_TW_REQUIRED_NODE_VERSION = "16.6.0";
package/dist/core.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-MDCr-9Qn.js');
5
+ var options = require('./options-dD1xK3ZL.js');
6
6
  require('magic-string');
7
7
  require('./replace.js');
8
8
  require('@weapp-core/escape');
@@ -12,12 +12,12 @@ require('@weapp-core/regex');
12
12
  require('@babel/generator');
13
13
  require('@babel/parser');
14
14
  require('@babel/traverse');
15
- require('./defaults-QOAV8NSV.js');
16
- require('./defu-KWuJnZLV.js');
15
+ require('./defaults-1lCMiqik.js');
16
+ require('./defu-6bFjC68s.js');
17
17
  require('@babel/types');
18
18
  require('htmlparser2');
19
19
  require('postcss');
20
- require('./postcss-bdPbDgs7.js');
20
+ require('./index-Fkmyt0Rc.js');
21
21
  require('@csstools/postcss-is-pseudo-class');
22
22
  require('postcss-rem-to-responsive-pixel');
23
23
  require('postcss-selector-parser');
package/dist/core.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-9bBYg22L.mjs';
1
+ import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-ERHjMNsB.mjs';
2
2
  import 'magic-string';
3
3
  import './replace.mjs';
4
4
  import '@weapp-core/escape';
@@ -8,12 +8,12 @@ import '@weapp-core/regex';
8
8
  import '@babel/generator';
9
9
  import '@babel/parser';
10
10
  import '@babel/traverse';
11
- import './defaults-TZpmwtzd.mjs';
12
- import './defu-ms_ZBCiB.mjs';
11
+ import './defaults-c-Db9ovX.mjs';
12
+ import './defu-p1R_k1Ss.mjs';
13
13
  import '@babel/types';
14
14
  import 'htmlparser2';
15
15
  import 'postcss';
16
- import './postcss-MxkGjr8g.mjs';
16
+ import './index-_74RBzwy.mjs';
17
17
  import '@csstools/postcss-is-pseudo-class';
18
18
  import 'postcss-rem-to-responsive-pixel';
19
19
  import 'postcss-selector-parser';
@@ -2,9 +2,9 @@
2
2
 
3
3
  var plugin = require('tailwindcss/plugin');
4
4
  var constants = require('../constants-EVxkHOXL.js');
5
- var defu = require('../defu-KWuJnZLV.js');
5
+ var defu = require('../defu-6bFjC68s.js');
6
6
 
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
8
 
9
9
  var plugin__default = /*#__PURE__*/_interopDefaultCompat(plugin);
10
10
 
@@ -1,6 +1,6 @@
1
1
  import plugin from 'tailwindcss/plugin';
2
2
  import { c as createMediaQuery, a as createNegativeMediaQuery } from '../constants-ol1NPf7z.mjs';
3
- import { d as defu } from '../defu-ms_ZBCiB.mjs';
3
+ import { d as defu } from '../defu-p1R_k1Ss.mjs';
4
4
 
5
5
  var index = plugin.withOptions((options) => {
6
6
  const { dynamic: dynamicMode, variantsMap } = defu(options, {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var defu = require('./defu-KWuJnZLV.js');
3
+ var defu = require('./defu-6bFjC68s.js');
4
4
  var escape = require('@weapp-core/escape');
5
5
  require('@ast-core/escape');
6
6
 
@@ -1,4 +1,4 @@
1
- import { c as createDefu } from './defu-ms_ZBCiB.mjs';
1
+ import { c as createDefu } from './defu-p1R_k1Ss.mjs';
2
2
  import { SimpleMappingChars2String } from '@weapp-core/escape';
3
3
  import '@ast-core/escape';
4
4
 
package/dist/defaults.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var defaults = require('./defaults-QOAV8NSV.js');
5
+ var defaults = require('./defaults-1lCMiqik.js');
6
6
  require('@weapp-core/escape');
7
7
  require('@ast-core/escape');
8
- require('./defu-KWuJnZLV.js');
8
+ require('./defu-6bFjC68s.js');
9
9
 
10
10
 
11
11
 
package/dist/defaults.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { a as defaultOptions } from './defaults-TZpmwtzd.mjs';
1
+ export { a as defaultOptions } from './defaults-c-Db9ovX.mjs';
2
2
  import '@weapp-core/escape';
3
3
  import '@ast-core/escape';
4
- import './defu-ms_ZBCiB.mjs';
4
+ import './defu-p1R_k1Ss.mjs';
@@ -1,7 +1,24 @@
1
1
  'use strict';
2
2
 
3
+ function isPlainObject(value) {
4
+ if (value === null || typeof value !== "object") {
5
+ return false;
6
+ }
7
+ const prototype = Object.getPrototypeOf(value);
8
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
9
+ return false;
10
+ }
11
+ if (Symbol.iterator in value) {
12
+ return false;
13
+ }
14
+ if (Symbol.toStringTag in value) {
15
+ return Object.prototype.toString.call(value) === "[object Module]";
16
+ }
17
+ return true;
18
+ }
19
+
3
20
  function _defu(baseObject, defaults, namespace = ".", merger) {
4
- if (!_isPlainObject(defaults)) {
21
+ if (!isPlainObject(defaults)) {
5
22
  return _defu(baseObject, {}, namespace, merger);
6
23
  }
7
24
  const object = Object.assign({}, defaults);
@@ -18,7 +35,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
18
35
  }
19
36
  if (Array.isArray(value) && Array.isArray(object[key])) {
20
37
  object[key] = [...value, ...object[key]];
21
- } else if (_isPlainObject(value) && _isPlainObject(object[key])) {
38
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
22
39
  object[key] = _defu(
23
40
  value,
24
41
  object[key],
@@ -31,13 +48,6 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
31
48
  }
32
49
  return object;
33
50
  }
34
- function _isPlainObject(value) {
35
- if (value === null || typeof value !== "object") {
36
- return false;
37
- }
38
- const prototype = Object.getPrototypeOf(value);
39
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
40
- }
41
51
  function createDefu(merger) {
42
52
  return (...arguments_) => (
43
53
  // eslint-disable-next-line unicorn/no-array-reduce
@@ -1,5 +1,22 @@
1
+ function isPlainObject(value) {
2
+ if (value === null || typeof value !== "object") {
3
+ return false;
4
+ }
5
+ const prototype = Object.getPrototypeOf(value);
6
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
7
+ return false;
8
+ }
9
+ if (Symbol.iterator in value) {
10
+ return false;
11
+ }
12
+ if (Symbol.toStringTag in value) {
13
+ return Object.prototype.toString.call(value) === "[object Module]";
14
+ }
15
+ return true;
16
+ }
17
+
1
18
  function _defu(baseObject, defaults, namespace = ".", merger) {
2
- if (!_isPlainObject(defaults)) {
19
+ if (!isPlainObject(defaults)) {
3
20
  return _defu(baseObject, {}, namespace, merger);
4
21
  }
5
22
  const object = Object.assign({}, defaults);
@@ -16,7 +33,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
16
33
  }
17
34
  if (Array.isArray(value) && Array.isArray(object[key])) {
18
35
  object[key] = [...value, ...object[key]];
19
- } else if (_isPlainObject(value) && _isPlainObject(object[key])) {
36
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
20
37
  object[key] = _defu(
21
38
  value,
22
39
  object[key],
@@ -29,13 +46,6 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
29
46
  }
30
47
  return object;
31
48
  }
32
- function _isPlainObject(value) {
33
- if (value === null || typeof value !== "object") {
34
- return false;
35
- }
36
- const prototype = Object.getPrototypeOf(value);
37
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
38
- }
39
49
  function createDefu(merger) {
40
50
  return (...arguments_) => (
41
51
  // eslint-disable-next-line unicorn/no-array-reduce
package/dist/gulp.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-MDCr-9Qn.js');
6
- var stream = require('node:stream');
5
+ var index = require('./index-IMKSE35e.js');
6
+ require('./options-dD1xK3ZL.js');
7
7
  require('magic-string');
8
8
  require('./replace.js');
9
9
  require('@weapp-core/escape');
@@ -13,12 +13,12 @@ require('@weapp-core/regex');
13
13
  require('@babel/generator');
14
14
  require('@babel/parser');
15
15
  require('@babel/traverse');
16
- require('./defaults-QOAV8NSV.js');
17
- require('./defu-KWuJnZLV.js');
16
+ require('./defaults-1lCMiqik.js');
17
+ require('./defu-6bFjC68s.js');
18
18
  require('@babel/types');
19
19
  require('htmlparser2');
20
20
  require('postcss');
21
- require('./postcss-bdPbDgs7.js');
21
+ require('./index-Fkmyt0Rc.js');
22
22
  require('@csstools/postcss-is-pseudo-class');
23
23
  require('postcss-rem-to-responsive-pixel');
24
24
  require('postcss-selector-parser');
@@ -29,69 +29,8 @@ require('tailwindcss-patch');
29
29
  require('@tailwindcss-mangle/shared');
30
30
  require('lru-cache');
31
31
  require('md5');
32
+ require('node:stream');
32
33
 
33
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
34
34
 
35
- var stream__default = /*#__PURE__*/_interopDefaultCompat(stream);
36
35
 
37
- const Transform = stream__default["default"].Transform;
38
- function createPlugins(options$1 = {}) {
39
- const opts = options.getOptions(options$1);
40
- const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
41
- let runtimeSet = new Set();
42
- patch === null || patch === void 0 ? void 0 : patch();
43
- const twPatcher = options.createTailwindcssPatcher();
44
- function transformWxss() {
45
- const transformStream = new Transform({ objectMode: true });
46
- transformStream._transform = function (file, encoding, callback) {
47
- return options.__awaiter(this, void 0, void 0, function* () {
48
- runtimeSet = twPatcher.getClassSet({
49
- basedir: tailwindcssBasedir
50
- });
51
- setMangleRuntimeSet(runtimeSet);
52
- const error = null;
53
- if (file.contents) {
54
- const code = yield styleHandler(file.contents.toString(), {
55
- isMainChunk: true
56
- });
57
- file.contents = Buffer.from(code);
58
- }
59
- callback(error, file);
60
- });
61
- };
62
- return transformStream;
63
- }
64
- function transformJs() {
65
- const transformStream = new Transform({ objectMode: true });
66
- transformStream._transform = function (file, encoding, callback) {
67
- const error = null;
68
- if (file.contents) {
69
- const { code } = jsHandler(file.contents.toString(), runtimeSet);
70
- file.contents = Buffer.from(code);
71
- }
72
- callback(error, file);
73
- };
74
- return transformStream;
75
- }
76
- function transformWxml() {
77
- const transformStream = new Transform({ objectMode: true });
78
- transformStream._transform = function (file, encoding, callback) {
79
- const error = null;
80
- if (file.contents) {
81
- const code = templateHandler(file.contents.toString(), {
82
- runtimeSet
83
- });
84
- file.contents = Buffer.from(code);
85
- }
86
- callback(error, file);
87
- };
88
- return transformStream;
89
- }
90
- return {
91
- transformWxss,
92
- transformWxml,
93
- transformJs
94
- };
95
- }
96
-
97
- exports.createPlugins = createPlugins;
36
+ exports.createPlugins = index.createPlugins;
package/dist/gulp.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-9bBYg22L.mjs';
2
- import stream from 'node:stream';
1
+ export { c as createPlugins } from './index-8dmkDRIb.mjs';
2
+ import './options-ERHjMNsB.mjs';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
5
5
  import '@weapp-core/escape';
@@ -9,12 +9,12 @@ import '@weapp-core/regex';
9
9
  import '@babel/generator';
10
10
  import '@babel/parser';
11
11
  import '@babel/traverse';
12
- import './defaults-TZpmwtzd.mjs';
13
- import './defu-ms_ZBCiB.mjs';
12
+ import './defaults-c-Db9ovX.mjs';
13
+ import './defu-p1R_k1Ss.mjs';
14
14
  import '@babel/types';
15
15
  import 'htmlparser2';
16
16
  import 'postcss';
17
- import './postcss-MxkGjr8g.mjs';
17
+ import './index-_74RBzwy.mjs';
18
18
  import '@csstools/postcss-is-pseudo-class';
19
19
  import 'postcss-rem-to-responsive-pixel';
20
20
  import 'postcss-selector-parser';
@@ -25,65 +25,4 @@ import 'tailwindcss-patch';
25
25
  import '@tailwindcss-mangle/shared';
26
26
  import 'lru-cache';
27
27
  import 'md5';
28
-
29
- const Transform = stream.Transform;
30
- function createPlugins(options = {}) {
31
- const opts = getOptions(options);
32
- const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
33
- let runtimeSet = new Set();
34
- patch === null || patch === void 0 ? void 0 : patch();
35
- const twPatcher = createTailwindcssPatcher();
36
- function transformWxss() {
37
- const transformStream = new Transform({ objectMode: true });
38
- transformStream._transform = function (file, encoding, callback) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- runtimeSet = twPatcher.getClassSet({
41
- basedir: tailwindcssBasedir
42
- });
43
- setMangleRuntimeSet(runtimeSet);
44
- const error = null;
45
- if (file.contents) {
46
- const code = yield styleHandler(file.contents.toString(), {
47
- isMainChunk: true
48
- });
49
- file.contents = Buffer.from(code);
50
- }
51
- callback(error, file);
52
- });
53
- };
54
- return transformStream;
55
- }
56
- function transformJs() {
57
- const transformStream = new Transform({ objectMode: true });
58
- transformStream._transform = function (file, encoding, callback) {
59
- const error = null;
60
- if (file.contents) {
61
- const { code } = jsHandler(file.contents.toString(), runtimeSet);
62
- file.contents = Buffer.from(code);
63
- }
64
- callback(error, file);
65
- };
66
- return transformStream;
67
- }
68
- function transformWxml() {
69
- const transformStream = new Transform({ objectMode: true });
70
- transformStream._transform = function (file, encoding, callback) {
71
- const error = null;
72
- if (file.contents) {
73
- const code = templateHandler(file.contents.toString(), {
74
- runtimeSet
75
- });
76
- file.contents = Buffer.from(code);
77
- }
78
- callback(error, file);
79
- };
80
- return transformStream;
81
- }
82
- return {
83
- transformWxss,
84
- transformWxml,
85
- transformJs
86
- };
87
- }
88
-
89
- export { createPlugins };
28
+ import 'node:stream';
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ var options = require('./options-dD1xK3ZL.js');
4
+ var index = require('./index-Fkmyt0Rc.js');
5
+ var defaults = require('./defaults-1lCMiqik.js');
6
+ var index$1 = require('./index-juOeq2Kt.js');
7
+
8
+ const debug = index$1.createDebug('generateBundle: ');
9
+ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
10
+ if (options$1.customReplaceDictionary === undefined) {
11
+ options$1.customReplaceDictionary = 'simple';
12
+ }
13
+ const opts = options.getOptions(options$1);
14
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
15
+ if (disabled) {
16
+ return;
17
+ }
18
+ patch === null || patch === void 0 ? void 0 : patch();
19
+ const twPatcher = options.createTailwindcssPatcher();
20
+ onLoad();
21
+ return {
22
+ name: index.vitePluginName,
23
+ enforce: 'post',
24
+ generateBundle(opt, bundle) {
25
+ return options.__awaiter(this, void 0, void 0, function* () {
26
+ debug('start');
27
+ onStart();
28
+ const entries = Object.entries(bundle);
29
+ const groupedEntries = defaults.getGroupedEntries(entries, opts);
30
+ const runtimeSet = twPatcher.getClassSet({
31
+ basedir: tailwindcssBasedir
32
+ });
33
+ setMangleRuntimeSet(runtimeSet);
34
+ debug('get runtimeSet, class count: %d', runtimeSet.size);
35
+ if (Array.isArray(groupedEntries.html)) {
36
+ let noCachedCount = 0;
37
+ for (let i = 0; i < groupedEntries.html.length; i++) {
38
+ const [file, originalSource] = groupedEntries.html[i];
39
+ const oldVal = originalSource.source.toString();
40
+ const hash = cache.computeHash(oldVal);
41
+ cache.calcHashValueChanged(file, hash);
42
+ yield cache.process(file, () => {
43
+ const source = cache.get(file);
44
+ if (source) {
45
+ originalSource.source = source;
46
+ debug('html cache hit: %s', file);
47
+ }
48
+ else {
49
+ return false;
50
+ }
51
+ }, () => {
52
+ originalSource.source = templateHandler(oldVal, {
53
+ runtimeSet
54
+ });
55
+ onUpdate(file, oldVal, originalSource.source);
56
+ debug('html handle: %s', file);
57
+ noCachedCount++;
58
+ return {
59
+ key: file,
60
+ source: originalSource.source
61
+ };
62
+ });
63
+ }
64
+ debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
65
+ }
66
+ if (Array.isArray(groupedEntries.js)) {
67
+ let noCachedCount = 0;
68
+ for (let i = 0; i < groupedEntries.js.length; i++) {
69
+ const [file, originalSource] = groupedEntries.js[i];
70
+ const rawSource = originalSource.code;
71
+ const hash = cache.computeHash(rawSource);
72
+ cache.calcHashValueChanged(file, hash);
73
+ yield cache.process(file, () => {
74
+ const source = cache.get(file);
75
+ if (source) {
76
+ originalSource.code = source;
77
+ debug('js cache hit: %s', file);
78
+ }
79
+ else {
80
+ return false;
81
+ }
82
+ }, () => {
83
+ const mapFilename = file + '.map';
84
+ const hasMap = Boolean(bundle[mapFilename]);
85
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
86
+ generateMap: hasMap
87
+ });
88
+ originalSource.code = code;
89
+ onUpdate(file, rawSource, code);
90
+ debug('js handle: %s', file);
91
+ noCachedCount++;
92
+ if (hasMap && map) {
93
+ bundle[mapFilename].source = map.toString();
94
+ }
95
+ return {
96
+ key: file,
97
+ source: code
98
+ };
99
+ });
100
+ }
101
+ debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
102
+ }
103
+ if (Array.isArray(groupedEntries.css)) {
104
+ let noCachedCount = 0;
105
+ for (let i = 0; i < groupedEntries.css.length; i++) {
106
+ const [file, originalSource] = groupedEntries.css[i];
107
+ const rawSource = originalSource.source.toString();
108
+ const hash = cache.computeHash(rawSource);
109
+ cache.calcHashValueChanged(file, hash);
110
+ yield cache.process(file, () => {
111
+ const source = cache.get(file);
112
+ if (source) {
113
+ originalSource.source = source;
114
+ debug('css cache hit: %s', file);
115
+ }
116
+ else {
117
+ return false;
118
+ }
119
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
120
+ const css = yield styleHandler(rawSource, {
121
+ isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
122
+ });
123
+ originalSource.source = css;
124
+ onUpdate(file, rawSource, css);
125
+ debug('css handle: %s', file);
126
+ noCachedCount++;
127
+ return {
128
+ key: file,
129
+ source: css
130
+ };
131
+ }));
132
+ }
133
+ debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
134
+ }
135
+ onEnd();
136
+ debug('end');
137
+ });
138
+ }
139
+ };
140
+ }
141
+
142
+ exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;