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.
Files changed (125) hide show
  1. package/dist/chunk-257YPDSI.mjs +173 -0
  2. package/dist/chunk-75EWCRQW.mjs +13 -0
  3. package/dist/chunk-AB467PG7.mjs +43 -0
  4. package/dist/chunk-E7XGHGC7.mjs +62 -0
  5. package/dist/chunk-GUE4UCRJ.mjs +126 -0
  6. package/dist/chunk-IOYI6MSW.mjs +533 -0
  7. package/dist/chunk-LDWI65M5.mjs +152 -0
  8. package/dist/chunk-NVFWRLOI.mjs +27 -0
  9. package/dist/chunk-ORMKM6ZA.mjs +30 -0
  10. package/dist/chunk-PC4B5JJB.mjs +953 -0
  11. package/dist/chunk-SRLZU2YE.mjs +95 -0
  12. package/dist/chunk-VECXHWWG.mjs +31 -0
  13. package/dist/chunk-VN37QGSM.mjs +216 -0
  14. package/dist/cli.d.mts +2 -0
  15. package/dist/cli.d.ts +2 -1
  16. package/dist/cli.js +1760 -52
  17. package/dist/cli.mjs +34 -46
  18. package/dist/core.d.mts +22 -0
  19. package/dist/core.d.ts +16 -2
  20. package/dist/core.js +1775 -62
  21. package/dist/core.mjs +46 -62
  22. package/dist/css-macro/index.d.mts +18 -0
  23. package/dist/css-macro/index.d.ts +7 -4
  24. package/dist/css-macro/index.js +140 -30
  25. package/dist/css-macro/index.mjs +35 -28
  26. package/dist/css-macro/postcss.d.mts +7 -0
  27. package/dist/css-macro/postcss.d.ts +5 -3
  28. package/dist/css-macro/postcss.js +99 -46
  29. package/dist/css-macro/postcss.mjs +54 -45
  30. package/dist/defaults.d.mts +16 -0
  31. package/dist/defaults.d.ts +16 -2
  32. package/dist/defaults.js +208 -7
  33. package/dist/defaults.mjs +9 -4
  34. package/dist/gulp.d.mts +26 -0
  35. package/dist/gulp.d.ts +26 -1
  36. package/dist/gulp.js +1898 -40
  37. package/dist/gulp.mjs +15 -32
  38. package/dist/index.d.mts +17 -0
  39. package/dist/index.d.ts +17 -4
  40. package/dist/index.js +2291 -44
  41. package/dist/index.mjs +23 -34
  42. package/dist/postcss.d.mts +23 -0
  43. package/dist/postcss.d.ts +23 -1
  44. package/dist/postcss.js +598 -22
  45. package/dist/postcss.mjs +17 -8
  46. package/dist/replace.d.mts +19 -0
  47. package/dist/replace.d.ts +19 -3
  48. package/dist/replace.js +93 -42
  49. package/dist/replace.mjs +30 -26
  50. package/dist/types-DSNuiOhH.d.mts +519 -0
  51. package/dist/types-DSNuiOhH.d.ts +519 -0
  52. package/dist/vite.d.mts +22 -0
  53. package/dist/vite.d.ts +22 -1
  54. package/dist/vite.js +1947 -38
  55. package/dist/vite.mjs +15 -30
  56. package/dist/weapp-tw-runtime-loader.d.mts +7 -0
  57. package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
  58. package/dist/weapp-tw-runtime-loader.js +41 -14
  59. package/dist/weapp-tw-runtime-loader.mjs +12 -8
  60. package/dist/webpack.d.mts +26 -0
  61. package/dist/webpack.d.ts +26 -1
  62. package/dist/webpack.js +1994 -38
  63. package/dist/webpack.mjs +15 -30
  64. package/dist/webpack4.d.mts +27 -0
  65. package/dist/webpack4.d.ts +27 -1
  66. package/dist/webpack4.js +1979 -191
  67. package/dist/webpack4.mjs +211 -189
  68. package/package.json +18 -19
  69. package/dist/babel/index.d.ts +0 -16
  70. package/dist/bundlers/gulp/index.d.ts +0 -8
  71. package/dist/bundlers/vite/index.d.ts +0 -3
  72. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
  73. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
  74. package/dist/bundlers/webpack/index.d.ts +0 -1
  75. package/dist/cache/index.d.ts +0 -32
  76. package/dist/constants-CFM1J-h1.js +0 -42
  77. package/dist/constants-Dy2Dd3Fz.mjs +0 -36
  78. package/dist/constants.d.ts +0 -7
  79. package/dist/css-macro/constants.d.ts +0 -14
  80. package/dist/debug/index.d.ts +0 -2
  81. package/dist/defaults-DUZZvtdg.mjs +0 -149
  82. package/dist/defaults-syv_N3uk.js +0 -156
  83. package/dist/defu-Cdz2PomB.js +0 -60
  84. package/dist/defu-n46TJT6t.mjs +0 -57
  85. package/dist/env.d.ts +0 -2
  86. package/dist/escape.d.ts +0 -4
  87. package/dist/extractors/split.d.ts +0 -3
  88. package/dist/index-B8TOcVAt.js +0 -130
  89. package/dist/index-BEIjgKpF.mjs +0 -11
  90. package/dist/index-BKZH-Gxq.mjs +0 -134
  91. package/dist/index-BPzIdybK.mjs +0 -513
  92. package/dist/index-Bc61v7B0.mjs +0 -124
  93. package/dist/index-DXeB6ex8.js +0 -136
  94. package/dist/index-DwZHOkK3.js +0 -526
  95. package/dist/index-HC-Qkn0i.js +0 -17
  96. package/dist/js/handlers.d.ts +0 -13
  97. package/dist/js/index.d.ts +0 -7
  98. package/dist/mangle/index.d.ts +0 -8
  99. package/dist/options-BHJnjA_a.mjs +0 -981
  100. package/dist/options-DAp5AdGz.js +0 -1014
  101. package/dist/options.d.ts +0 -2
  102. package/dist/postcss/cssVars.d.ts +0 -5
  103. package/dist/postcss/index.d.ts +0 -3
  104. package/dist/postcss/mp.d.ts +0 -8
  105. package/dist/postcss/plugins/ctx.d.ts +0 -6
  106. package/dist/postcss/plugins/index.d.ts +0 -7
  107. package/dist/postcss/plugins/post.d.ts +0 -5
  108. package/dist/postcss/plugins/pre.d.ts +0 -5
  109. package/dist/postcss/preflight.d.ts +0 -3
  110. package/dist/postcss/selectorParser.d.ts +0 -6
  111. package/dist/postcss/shared.d.ts +0 -3
  112. package/dist/postcss/symbols.d.ts +0 -1
  113. package/dist/reg.d.ts +0 -1
  114. package/dist/shared-DbJl6i6a.mjs +0 -25
  115. package/dist/shared-hzYeE1wX.js +0 -28
  116. package/dist/tailwindcss/patcher.d.ts +0 -8
  117. package/dist/tailwindcss/supportCustomUnit.d.ts +0 -6
  118. package/dist/types.d.ts +0 -179
  119. package/dist/utils.d.ts +0 -18
  120. package/dist/v5-B9S3lBOs.mjs +0 -174
  121. package/dist/v5-QURRYPNk.js +0 -181
  122. package/dist/wxml/Tokenizer.d.ts +0 -31
  123. package/dist/wxml/index.d.ts +0 -2
  124. package/dist/wxml/shared.d.ts +0 -2
  125. package/dist/wxml/utils.d.ts +0 -9
package/dist/core.mjs CHANGED
@@ -1,65 +1,49 @@
1
- import { g as getOptions, _ as __awaiter } from './options-BHJnjA_a.mjs';
2
- import 'magic-string';
3
- import './replace.mjs';
4
- import '@weapp-core/escape';
5
- import '@ast-core/escape';
6
- import './shared-DbJl6i6a.mjs';
7
- import '@weapp-core/regex';
8
- import '@babel/generator';
9
- import '@babel/traverse';
10
- import '@babel/parser';
11
- import './defaults-DUZZvtdg.mjs';
12
- import './defu-n46TJT6t.mjs';
13
- import '@babel/types';
14
- import 'htmlparser2';
15
- import 'postcss';
16
- import './index-BPzIdybK.mjs';
17
- import '@csstools/postcss-is-pseudo-class';
18
- import 'postcss-rem-to-responsive-pixel';
19
- import 'postcss-selector-parser';
20
- import 'node:path';
21
- import 'node:fs';
22
- import 'node:process';
23
- import 'semver';
24
- import 'tailwindcss-patch';
25
- import '@tailwindcss-mangle/shared';
26
- import 'lru-cache';
27
- import 'md5';
1
+ import {
2
+ getOptions
3
+ } from "./chunk-PC4B5JJB.mjs";
4
+ import "./chunk-SRLZU2YE.mjs";
5
+ import "./chunk-GUE4UCRJ.mjs";
6
+ import "./chunk-IOYI6MSW.mjs";
7
+ import "./chunk-NVFWRLOI.mjs";
8
+ import "./chunk-ORMKM6ZA.mjs";
9
+ import "./chunk-VECXHWWG.mjs";
10
+ import {
11
+ __async
12
+ } from "./chunk-E7XGHGC7.mjs";
28
13
 
14
+ // src/core.ts
29
15
  function createContext(options = {}) {
30
- const opts = getOptions(options);
31
- const { templateHandler, styleHandler, patch, jsHandler, twPatcher } = opts;
32
- let runtimeSet = new Set();
33
- patch === null || patch === void 0 ? void 0 : patch();
34
- function transformWxss(rawCss, options) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const code = yield styleHandler(rawCss, Object.assign({
37
- isMainChunk: true,
38
- }, options));
39
- return code;
40
- });
41
- }
42
- function transformJs(rawJs_1) {
43
- return __awaiter(this, arguments, void 0, function* (rawJs, options = {}) {
44
- runtimeSet
45
- = options && options.runtimeSet
46
- ? options.runtimeSet
47
- : twPatcher.getClassSet();
48
- const { code } = yield jsHandler(rawJs, runtimeSet, options);
49
- return code;
50
- });
51
- }
52
- function transformWxml(rawWxml, options) {
53
- const code = templateHandler(rawWxml, Object.assign({
54
- runtimeSet,
55
- }, options));
56
- return code;
57
- }
58
- return {
59
- transformWxss,
60
- transformWxml,
61
- transformJs,
62
- };
16
+ const opts = getOptions(options);
17
+ const { templateHandler, styleHandler, patch, jsHandler, twPatcher } = opts;
18
+ let runtimeSet = /* @__PURE__ */ new Set();
19
+ patch == null ? void 0 : patch();
20
+ function transformWxss(rawCss, options2) {
21
+ return __async(this, null, function* () {
22
+ const code = yield styleHandler(rawCss, Object.assign({
23
+ isMainChunk: true
24
+ }, options2));
25
+ return code;
26
+ });
27
+ }
28
+ function transformJs(_0) {
29
+ return __async(this, arguments, function* (rawJs, options2 = {}) {
30
+ runtimeSet = options2 && options2.runtimeSet ? options2.runtimeSet : twPatcher.getClassSet();
31
+ const { code } = yield jsHandler(rawJs, runtimeSet, options2);
32
+ return code;
33
+ });
34
+ }
35
+ function transformWxml(rawWxml, options2) {
36
+ const code = templateHandler(rawWxml, Object.assign({
37
+ runtimeSet
38
+ }, options2));
39
+ return code;
40
+ }
41
+ return {
42
+ transformWxss,
43
+ transformWxml,
44
+ transformJs
45
+ };
63
46
  }
64
-
65
- export { createContext };
47
+ export {
48
+ createContext
49
+ };
@@ -0,0 +1,18 @@
1
+ import * as tailwindcss_types_config from 'tailwindcss/types/config';
2
+
3
+ interface Options {
4
+ variantsMap?: Record<string, string | {
5
+ value: string;
6
+ negative?: boolean;
7
+ }>;
8
+ dynamic?: boolean;
9
+ }
10
+ declare const _default: {
11
+ (options: Options): {
12
+ handler: tailwindcss_types_config.PluginCreator;
13
+ config?: Partial<tailwindcss_types_config.Config>;
14
+ };
15
+ __isOptionsFunction: true;
16
+ };
17
+
18
+ export { type Options, _default as default };
@@ -1,4 +1,6 @@
1
- export interface Options {
1
+ import * as tailwindcss_types_config from 'tailwindcss/types/config';
2
+
3
+ interface Options {
2
4
  variantsMap?: Record<string, string | {
3
5
  value: string;
4
6
  negative?: boolean;
@@ -7,9 +9,10 @@ export interface Options {
7
9
  }
8
10
  declare const _default: {
9
11
  (options: Options): {
10
- handler: import("tailwindcss/types/config").PluginCreator;
11
- config?: Partial<import("tailwindcss/types/config").Config> | undefined;
12
+ handler: tailwindcss_types_config.PluginCreator;
13
+ config?: Partial<tailwindcss_types_config.Config>;
12
14
  };
13
15
  __isOptionsFunction: true;
14
16
  };
15
- export default _default;
17
+
18
+ export { type Options, _default as default };
@@ -1,36 +1,146 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
29
 
3
- var plugin = require('tailwindcss/plugin');
4
- var constants = require('../constants-CFM1J-h1.js');
5
- var defu = require('../defu-Cdz2PomB.js');
30
+ // src/css-macro/index.ts
31
+ var css_macro_exports = {};
32
+ __export(css_macro_exports, {
33
+ default: () => css_macro_default
34
+ });
35
+ module.exports = __toCommonJS(css_macro_exports);
36
+ var import_plugin = __toESM(require("tailwindcss/plugin"));
6
37
 
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
38
+ // src/css-macro/constants.ts
39
+ var queryKey = "weapp-tw-platform";
40
+ function createMediaQuery(value) {
41
+ return `@media (${queryKey}:"${value}"){&}`;
42
+ }
43
+ function createNegativeMediaQuery(value) {
44
+ return `@media not screen and (${queryKey}:"${value}"){&}`;
45
+ }
8
46
 
9
- var plugin__default = /*#__PURE__*/_interopDefaultCompat(plugin);
47
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
48
+ function isPlainObject(value) {
49
+ if (value === null || typeof value !== "object") {
50
+ return false;
51
+ }
52
+ const prototype = Object.getPrototypeOf(value);
53
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
54
+ return false;
55
+ }
56
+ if (Symbol.iterator in value) {
57
+ return false;
58
+ }
59
+ if (Symbol.toStringTag in value) {
60
+ return Object.prototype.toString.call(value) === "[object Module]";
61
+ }
62
+ return true;
63
+ }
64
+ function _defu(baseObject, defaults, namespace = ".", merger) {
65
+ if (!isPlainObject(defaults)) {
66
+ return _defu(baseObject, {}, namespace, merger);
67
+ }
68
+ const object = Object.assign({}, defaults);
69
+ for (const key in baseObject) {
70
+ if (key === "__proto__" || key === "constructor") {
71
+ continue;
72
+ }
73
+ const value = baseObject[key];
74
+ if (value === null || value === void 0) {
75
+ continue;
76
+ }
77
+ if (merger && merger(object, key, value, namespace)) {
78
+ continue;
79
+ }
80
+ if (Array.isArray(value) && Array.isArray(object[key])) {
81
+ object[key] = [...value, ...object[key]];
82
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
83
+ object[key] = _defu(
84
+ value,
85
+ object[key],
86
+ (namespace ? `${namespace}.` : "") + key.toString(),
87
+ merger
88
+ );
89
+ } else {
90
+ object[key] = value;
91
+ }
92
+ }
93
+ return object;
94
+ }
95
+ function createDefu(merger) {
96
+ return (...arguments_) => (
97
+ // eslint-disable-next-line unicorn/no-array-reduce
98
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
99
+ );
100
+ }
101
+ var defu = createDefu();
102
+ var defuFn = createDefu((object, key, currentValue) => {
103
+ if (object[key] !== void 0 && typeof currentValue === "function") {
104
+ object[key] = currentValue(object[key]);
105
+ return true;
106
+ }
107
+ });
108
+ var defuArrayFn = createDefu((object, key, currentValue) => {
109
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
110
+ object[key] = currentValue(object[key]);
111
+ return true;
112
+ }
113
+ });
10
114
 
11
- var index = plugin__default["default"].withOptions((options) => {
12
- const { dynamic: dynamicMode, variantsMap } = defu.defu(options, {
13
- dynamic: true,
14
- variantsMap: {},
15
- });
16
- return ({ matchVariant, addVariant }) => {
17
- if (dynamicMode) {
18
- matchVariant('ifdef', (value) => {
19
- return constants.createMediaQuery(value);
20
- });
21
- matchVariant('ifndef', (value) => {
22
- return constants.createNegativeMediaQuery(value);
23
- });
24
- }
25
- for (const [name, obj] of Object.entries(variantsMap)) {
26
- if (typeof obj === 'string') {
27
- addVariant(name, constants.createMediaQuery(obj));
28
- }
29
- else {
30
- addVariant(name, obj.negative ? constants.createNegativeMediaQuery(obj.value) : constants.createMediaQuery(obj.value));
31
- }
32
- }
33
- };
115
+ // src/utils.ts
116
+ var defuOverrideArray = createDefu((obj, key, value) => {
117
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
118
+ obj[key] = value;
119
+ return true;
120
+ }
34
121
  });
35
122
 
36
- module.exports = index;
123
+ // src/css-macro/index.ts
124
+ var css_macro_default = import_plugin.default.withOptions((options) => {
125
+ const { dynamic: dynamicMode, variantsMap } = defu(options, {
126
+ dynamic: true,
127
+ variantsMap: {}
128
+ });
129
+ return ({ matchVariant, addVariant }) => {
130
+ if (dynamicMode) {
131
+ matchVariant("ifdef", (value) => {
132
+ return createMediaQuery(value);
133
+ });
134
+ matchVariant("ifndef", (value) => {
135
+ return createNegativeMediaQuery(value);
136
+ });
137
+ }
138
+ for (const [name, obj] of Object.entries(variantsMap)) {
139
+ if (typeof obj === "string") {
140
+ addVariant(name, createMediaQuery(obj));
141
+ } else {
142
+ addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
143
+ }
144
+ }
145
+ };
146
+ });
@@ -1,30 +1,37 @@
1
- import plugin from 'tailwindcss/plugin';
2
- import { c as createMediaQuery, a as createNegativeMediaQuery } from '../constants-Dy2Dd3Fz.mjs';
3
- import { d as defu } from '../defu-n46TJT6t.mjs';
1
+ import {
2
+ createMediaQuery,
3
+ createNegativeMediaQuery
4
+ } from "../chunk-AB467PG7.mjs";
5
+ import {
6
+ defu
7
+ } from "../chunk-GUE4UCRJ.mjs";
8
+ import "../chunk-E7XGHGC7.mjs";
4
9
 
5
- var index = plugin.withOptions((options) => {
6
- const { dynamic: dynamicMode, variantsMap } = defu(options, {
7
- dynamic: true,
8
- variantsMap: {},
9
- });
10
- return ({ matchVariant, addVariant }) => {
11
- if (dynamicMode) {
12
- matchVariant('ifdef', (value) => {
13
- return createMediaQuery(value);
14
- });
15
- matchVariant('ifndef', (value) => {
16
- return createNegativeMediaQuery(value);
17
- });
18
- }
19
- for (const [name, obj] of Object.entries(variantsMap)) {
20
- if (typeof obj === 'string') {
21
- addVariant(name, createMediaQuery(obj));
22
- }
23
- else {
24
- addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
25
- }
26
- }
27
- };
10
+ // src/css-macro/index.ts
11
+ import plugin from "tailwindcss/plugin";
12
+ var css_macro_default = plugin.withOptions((options) => {
13
+ const { dynamic: dynamicMode, variantsMap } = defu(options, {
14
+ dynamic: true,
15
+ variantsMap: {}
16
+ });
17
+ return ({ matchVariant, addVariant }) => {
18
+ if (dynamicMode) {
19
+ matchVariant("ifdef", (value) => {
20
+ return createMediaQuery(value);
21
+ });
22
+ matchVariant("ifndef", (value) => {
23
+ return createNegativeMediaQuery(value);
24
+ });
25
+ }
26
+ for (const [name, obj] of Object.entries(variantsMap)) {
27
+ if (typeof obj === "string") {
28
+ addVariant(name, createMediaQuery(obj));
29
+ } else {
30
+ addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
31
+ }
32
+ }
33
+ };
28
34
  });
29
-
30
- export { index as default };
35
+ export {
36
+ css_macro_default as default
37
+ };
@@ -0,0 +1,7 @@
1
+ import { PluginCreator } from 'postcss';
2
+
3
+ interface Options {
4
+ }
5
+ declare const creator: PluginCreator<Options>;
6
+
7
+ export { type Options, creator as default };
@@ -1,5 +1,7 @@
1
- import type { PluginCreator } from 'postcss';
2
- export interface Options {
1
+ import { PluginCreator } from 'postcss';
2
+
3
+ interface Options {
3
4
  }
4
5
  declare const creator: PluginCreator<Options>;
5
- export default creator;
6
+
7
+ export { type Options, creator as default };
@@ -1,51 +1,104 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- var constants = require('../constants-CFM1J-h1.js');
20
+ // src/css-macro/postcss.ts
21
+ var postcss_exports = {};
22
+ __export(postcss_exports, {
23
+ default: () => postcss_default
24
+ });
25
+ module.exports = __toCommonJS(postcss_exports);
4
26
 
5
- const creator = () => {
6
- return {
7
- postcssPlugin: 'postcss-weapp-tw-css-macro-plugin',
8
- prepare() {
9
- return {
10
- AtRule(atRule, helper) {
11
- var _a;
12
- if (atRule.name === 'media') {
13
- const values = [];
14
- constants.matchCustomPropertyFromValue(atRule.params, (arr) => {
15
- values.push(arr[1]);
16
- });
17
- if (values.length > 0) {
18
- const isNegative = atRule.params.includes('not');
19
- const text = values.join(' ');
20
- const comment = isNegative ? constants.ifndef(text) : constants.ifdef(text);
21
- atRule.replaceWith([
22
- helper.comment({
23
- raws: {
24
- before: '\n',
25
- },
26
- text: comment.start,
27
- }),
28
- ...((_a = atRule.nodes) !== null && _a !== void 0 ? _a : []),
29
- helper.comment({
30
- raws: {
31
- before: '\n',
32
- },
33
- text: comment.end,
34
- }),
35
- ]);
36
- }
37
- }
38
- },
39
- CommentExit(comment) {
40
- if (/#(?:ifn?def|endif)/.test(comment.text)) {
41
- comment.raws.left = ' ';
42
- comment.raws.right = ' ';
43
- }
44
- },
45
- };
27
+ // src/css-macro/constants.ts
28
+ var queryKey = "weapp-tw-platform";
29
+ function normalComment(text) {
30
+ if (typeof text === "string") {
31
+ return text.replaceAll(new RegExp("(?<!\\\\)_", "g"), " ");
32
+ }
33
+ return text;
34
+ }
35
+ function ifdef(text) {
36
+ return {
37
+ start: `#ifdef ${normalComment(text)}`,
38
+ end: `#endif`
39
+ };
40
+ }
41
+ function ifndef(text) {
42
+ return {
43
+ start: `#ifndef ${normalComment(text)}`,
44
+ end: `#endif`
45
+ };
46
+ }
47
+ function matchCustomPropertyFromValue(str, cb) {
48
+ let arr;
49
+ let index = 0;
50
+ const regex = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
51
+ while ((arr = regex.exec(str)) !== null) {
52
+ cb(arr, index);
53
+ index++;
54
+ }
55
+ }
56
+
57
+ // src/css-macro/postcss.ts
58
+ var creator = () => {
59
+ return {
60
+ postcssPlugin: "postcss-weapp-tw-css-macro-plugin",
61
+ prepare() {
62
+ return {
63
+ AtRule(atRule, helper) {
64
+ var _a;
65
+ if (atRule.name === "media") {
66
+ const values = [];
67
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
68
+ values.push(arr[1]);
69
+ });
70
+ if (values.length > 0) {
71
+ const isNegative = atRule.params.includes("not");
72
+ const text = values.join(" ");
73
+ const comment = isNegative ? ifndef(text) : ifdef(text);
74
+ atRule.replaceWith([
75
+ helper.comment({
76
+ raws: {
77
+ before: "\n"
78
+ },
79
+ text: comment.start
80
+ }),
81
+ ...(_a = atRule.nodes) != null ? _a : [],
82
+ // .map((x) => x.clone()),
83
+ helper.comment({
84
+ raws: {
85
+ before: "\n"
86
+ },
87
+ text: comment.end
88
+ })
89
+ ]);
90
+ }
91
+ }
46
92
  },
47
- };
93
+ CommentExit(comment) {
94
+ if (/#(?:ifn?def|endif)/.test(comment.text)) {
95
+ comment.raws.left = " ";
96
+ comment.raws.right = " ";
97
+ }
98
+ }
99
+ };
100
+ }
101
+ };
48
102
  };
49
103
  creator.postcss = true;
50
-
51
- module.exports = creator;
104
+ var postcss_default = creator;