weapp-tailwindcss 4.2.2-alpha.0 → 4.2.2-alpha.2

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.
@@ -96,13 +96,46 @@ function parseVueRequest(id) {
96
96
  };
97
97
  }
98
98
 
99
- // src/bundlers/vite/index.ts
100
- var debug = createDebug();
99
+ // src/bundlers/vite/utils.ts
100
+ import path from "path";
101
+ import process from "process";
102
+ function slash(p) {
103
+ return p.replace(/\\/g, "/");
104
+ }
105
+ var isWindows = process.platform === "win32";
101
106
  var cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
102
107
  var cssLangRE = new RegExp(cssLangs);
103
108
  function isCSSRequest(request) {
104
109
  return cssLangRE.test(request);
105
110
  }
111
+ function normalizePath(id) {
112
+ return path.posix.normalize(isWindows ? slash(id) : id);
113
+ }
114
+ var postfixRE = /[?#].*$/;
115
+ function cleanUrl(url) {
116
+ return url.replace(postfixRE, "");
117
+ }
118
+ async function formatPostcssSourceMap(rawMap, file) {
119
+ const inputFileDir = path.dirname(file);
120
+ const sources = rawMap.sources.map((source) => {
121
+ const cleanSource = cleanUrl(decodeURIComponent(source));
122
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) {
123
+ return `\0${cleanSource}`;
124
+ }
125
+ return normalizePath(path.resolve(inputFileDir, cleanSource));
126
+ });
127
+ return {
128
+ file,
129
+ mappings: rawMap.mappings,
130
+ names: rawMap.names,
131
+ sources,
132
+ sourcesContent: rawMap.sourcesContent,
133
+ version: rawMap.version
134
+ };
135
+ }
136
+
137
+ // src/bundlers/vite/index.ts
138
+ var debug = createDebug();
106
139
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
107
140
  const opts = getCompilerContext(options);
108
141
  const {
@@ -323,53 +356,48 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
323
356
  }
324
357
  ];
325
358
  if (uniAppX) {
326
- plugins.push(
327
- {
328
- name: "weapp-tailwindcss:uni-app-x:css:pre",
329
- enforce: "pre",
330
- async transform(code, id) {
331
- const { query } = parseVueRequest(id);
332
- if (isCSSRequest(id) || query.vue && query.type === "style") {
333
- const { css, map } = await styleHandler(code, {
334
- isMainChunk: mainCssChunkMatcher(id, appType),
335
- postcssOptions: {
336
- options: {
337
- from: id,
338
- map: true
339
- }
340
- }
341
- });
342
- return {
343
- code: css,
344
- map: map?.toString()
345
- };
346
- }
347
- }
348
- }
349
- );
350
- plugins.push(
351
- {
352
- name: "weapp-tailwindcss:uni-app-x:css",
353
- async transform(code, id) {
354
- const { query } = parseVueRequest(id);
355
- if (isCSSRequest(id) || query.vue && query.type === "style") {
356
- const { css, map } = await styleHandler(code, {
357
- isMainChunk: mainCssChunkMatcher(id, appType),
358
- postcssOptions: {
359
- options: {
360
- from: id,
361
- map: true
359
+ ;
360
+ [void 0, "pre"].forEach((enforce) => {
361
+ plugins.push(
362
+ {
363
+ name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
364
+ enforce,
365
+ async transform(code, id) {
366
+ const { query } = parseVueRequest(id);
367
+ if (isCSSRequest(id) || query.vue && query.type === "style") {
368
+ const postcssResult = await styleHandler(code, {
369
+ isMainChunk: mainCssChunkMatcher(id, appType),
370
+ postcssOptions: {
371
+ options: {
372
+ from: id,
373
+ map: {
374
+ inline: false,
375
+ annotation: false,
376
+ // postcss may return virtual files
377
+ // we cannot obtain content of them, so this needs to be enabled
378
+ sourcesContent: true
379
+ // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
380
+ // prev: preprocessorMap,
381
+ }
382
+ }
362
383
  }
363
- }
364
- });
365
- return {
366
- code: css,
367
- map: map?.toString()
368
- };
384
+ });
385
+ const rawPostcssMap = postcssResult.map.toJSON();
386
+ const postcssMap = await formatPostcssSourceMap(
387
+ // version property of rawPostcssMap is declared as string
388
+ // but actually it is a number
389
+ rawPostcssMap,
390
+ cleanUrl(id)
391
+ );
392
+ return {
393
+ code: postcssResult.css,
394
+ map: postcssMap
395
+ };
396
+ }
369
397
  }
370
398
  }
371
- }
372
- );
399
+ );
400
+ });
373
401
  plugins.push(
374
402
  {
375
403
  name: "weapp-tailwindcss:uni-app-x:nvue",
@@ -390,7 +418,5 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
390
418
  }
391
419
 
392
420
  export {
393
- cssLangRE,
394
- isCSSRequest,
395
421
  UnifiedViteWeappTailwindcssPlugin
396
422
  };
@@ -96,13 +96,46 @@ function parseVueRequest(id) {
96
96
  };
97
97
  }
98
98
 
99
- // src/bundlers/vite/index.ts
100
- var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
99
+ // src/bundlers/vite/utils.ts
100
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
101
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
102
+ function slash(p) {
103
+ return p.replace(/\\/g, "/");
104
+ }
105
+ var isWindows = _process2.default.platform === "win32";
101
106
  var cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
102
107
  var cssLangRE = new RegExp(cssLangs);
103
108
  function isCSSRequest(request) {
104
109
  return cssLangRE.test(request);
105
110
  }
111
+ function normalizePath(id) {
112
+ return _path2.default.posix.normalize(isWindows ? slash(id) : id);
113
+ }
114
+ var postfixRE = /[?#].*$/;
115
+ function cleanUrl(url) {
116
+ return url.replace(postfixRE, "");
117
+ }
118
+ async function formatPostcssSourceMap(rawMap, file) {
119
+ const inputFileDir = _path2.default.dirname(file);
120
+ const sources = rawMap.sources.map((source) => {
121
+ const cleanSource = cleanUrl(decodeURIComponent(source));
122
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) {
123
+ return `\0${cleanSource}`;
124
+ }
125
+ return normalizePath(_path2.default.resolve(inputFileDir, cleanSource));
126
+ });
127
+ return {
128
+ file,
129
+ mappings: rawMap.mappings,
130
+ names: rawMap.names,
131
+ sources,
132
+ sourcesContent: rawMap.sourcesContent,
133
+ version: rawMap.version
134
+ };
135
+ }
136
+
137
+ // src/bundlers/vite/index.ts
138
+ var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
106
139
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
107
140
  const opts = _chunkPLEG4SRNjs.getCompilerContext.call(void 0, options);
108
141
  const {
@@ -323,53 +356,48 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
323
356
  }
324
357
  ];
325
358
  if (uniAppX) {
326
- plugins.push(
327
- {
328
- name: "weapp-tailwindcss:uni-app-x:css:pre",
329
- enforce: "pre",
330
- async transform(code, id) {
331
- const { query } = parseVueRequest(id);
332
- if (isCSSRequest(id) || query.vue && query.type === "style") {
333
- const { css, map } = await styleHandler(code, {
334
- isMainChunk: mainCssChunkMatcher(id, appType),
335
- postcssOptions: {
336
- options: {
337
- from: id,
338
- map: true
339
- }
340
- }
341
- });
342
- return {
343
- code: css,
344
- map: _optionalChain([map, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])
345
- };
346
- }
347
- }
348
- }
349
- );
350
- plugins.push(
351
- {
352
- name: "weapp-tailwindcss:uni-app-x:css",
353
- async transform(code, id) {
354
- const { query } = parseVueRequest(id);
355
- if (isCSSRequest(id) || query.vue && query.type === "style") {
356
- const { css, map } = await styleHandler(code, {
357
- isMainChunk: mainCssChunkMatcher(id, appType),
358
- postcssOptions: {
359
- options: {
360
- from: id,
361
- map: true
359
+ ;
360
+ [void 0, "pre"].forEach((enforce) => {
361
+ plugins.push(
362
+ {
363
+ name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
364
+ enforce,
365
+ async transform(code, id) {
366
+ const { query } = parseVueRequest(id);
367
+ if (isCSSRequest(id) || query.vue && query.type === "style") {
368
+ const postcssResult = await styleHandler(code, {
369
+ isMainChunk: mainCssChunkMatcher(id, appType),
370
+ postcssOptions: {
371
+ options: {
372
+ from: id,
373
+ map: {
374
+ inline: false,
375
+ annotation: false,
376
+ // postcss may return virtual files
377
+ // we cannot obtain content of them, so this needs to be enabled
378
+ sourcesContent: true
379
+ // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
380
+ // prev: preprocessorMap,
381
+ }
382
+ }
362
383
  }
363
- }
364
- });
365
- return {
366
- code: css,
367
- map: _optionalChain([map, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()])
368
- };
384
+ });
385
+ const rawPostcssMap = postcssResult.map.toJSON();
386
+ const postcssMap = await formatPostcssSourceMap(
387
+ // version property of rawPostcssMap is declared as string
388
+ // but actually it is a number
389
+ rawPostcssMap,
390
+ cleanUrl(id)
391
+ );
392
+ return {
393
+ code: postcssResult.css,
394
+ map: postcssMap
395
+ };
396
+ }
369
397
  }
370
398
  }
371
- }
372
- );
399
+ );
400
+ });
373
401
  plugins.push(
374
402
  {
375
403
  name: "weapp-tailwindcss:uni-app-x:nvue",
@@ -391,6 +419,4 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
391
419
 
392
420
 
393
421
 
394
-
395
-
396
- exports.cssLangRE = cssLangRE; exports.isCSSRequest = isCSSRequest; exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
422
+ exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createPlugins } from './gulp.mjs';
2
2
  export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalCssSelectorReplacerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, UserDefinedOptions } from './types.mjs';
3
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest } from './vite.mjs';
3
+ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
4
4
  export { UnifiedWebpackPluginV5 } from './webpack.mjs';
5
5
  export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
6
6
  export { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createPlugins } from './gulp.js';
2
2
  export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalCssSelectorReplacerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, UserDefinedOptions } from './types.js';
3
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest } from './vite.js';
3
+ export { UnifiedViteWeappTailwindcssPlugin } from './vite.js';
4
4
  export { UnifiedWebpackPluginV5 } from './webpack.js';
5
5
  export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
6
6
  export { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
package/dist/index.js CHANGED
@@ -7,9 +7,7 @@ var _chunkZK5OYQKNjs = require('./chunk-ZK5OYQKN.js');
7
7
  var _chunkXPJSMUIZjs = require('./chunk-XPJSMUIZ.js');
8
8
 
9
9
 
10
-
11
-
12
- var _chunkJJBOP2VIjs = require('./chunk-JJBOP2VI.js');
10
+ var _chunkZKDPGRFZjs = require('./chunk-ZKDPGRFZ.js');
13
11
  require('./chunk-LSSLYD6B.js');
14
12
  require('./chunk-OGROHM4L.js');
15
13
  require('./chunk-PLEG4SRN.js');
@@ -21,6 +19,4 @@ require('./chunk-U5U4QBHD.js');
21
19
 
22
20
 
23
21
 
24
-
25
-
26
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkJJBOP2VIjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkZK5OYQKNjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkXPJSMUIZjs.createPlugins; exports.cssLangRE = _chunkJJBOP2VIjs.cssLangRE; exports.isCSSRequest = _chunkJJBOP2VIjs.isCSSRequest;
22
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunkZKDPGRFZjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkZK5OYQKNjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkXPJSMUIZjs.createPlugins;
package/dist/index.mjs CHANGED
@@ -6,10 +6,8 @@ import {
6
6
  createPlugins
7
7
  } from "./chunk-RF63Y6B4.mjs";
8
8
  import {
9
- UnifiedViteWeappTailwindcssPlugin,
10
- cssLangRE,
11
- isCSSRequest
12
- } from "./chunk-DHRJQIWW.mjs";
9
+ UnifiedViteWeappTailwindcssPlugin
10
+ } from "./chunk-XM5XNUIB.mjs";
13
11
  import "./chunk-3AUX4FGE.mjs";
14
12
  import "./chunk-CMUA5KCO.mjs";
15
13
  import "./chunk-FOPIY67W.mjs";
@@ -20,7 +18,5 @@ import "./chunk-QKNCXAGV.mjs";
20
18
  export {
21
19
  UnifiedViteWeappTailwindcssPlugin,
22
20
  UnifiedWebpackPluginV5,
23
- createPlugins,
24
- cssLangRE,
25
- isCSSRequest
21
+ createPlugins
26
22
  };
package/dist/presets.js CHANGED
@@ -10,7 +10,7 @@ require('./chunk-U5U4QBHD.js');
10
10
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
11
11
  function uniAppX(options) {
12
12
  _chunkOXASK55Qjs.logger.info(`UNI_PLATFORM: ${_process2.default.env.UNI_PLATFORM}`);
13
- const isApp = _process2.default.env.UNI_PLATFORM === "app" || _process2.default.env.UNI_PLATFORM === "app-plus";
13
+ const isApp = _process2.default.env.UNI_PLATFORM === "app" || _process2.default.env.UNI_PLATFORM === "app-plus" || _process2.default.env.UNI_PLATFORM === "app-harmony";
14
14
  return _chunkO335YLYHjs.defuOverrideArray.call(void 0,
15
15
  options.rawOptions,
16
16
  {
package/dist/presets.mjs CHANGED
@@ -10,7 +10,7 @@ import "./chunk-QKNCXAGV.mjs";
10
10
  import process from "process";
11
11
  function uniAppX(options) {
12
12
  logger.info(`UNI_PLATFORM: ${process.env.UNI_PLATFORM}`);
13
- const isApp = process.env.UNI_PLATFORM === "app" || process.env.UNI_PLATFORM === "app-plus";
13
+ const isApp = process.env.UNI_PLATFORM === "app" || process.env.UNI_PLATFORM === "app-plus" || process.env.UNI_PLATFORM === "app-harmony";
14
14
  return defuOverrideArray(
15
15
  options.rawOptions,
16
16
  {
package/dist/vite.d.mts CHANGED
@@ -11,8 +11,6 @@ import 'webpack';
11
11
  import 'lru-cache';
12
12
  import 'postcss-preset-env';
13
13
 
14
- declare const cssLangRE: RegExp;
15
- declare function isCSSRequest(request: string): boolean;
16
14
  /**
17
15
  * @name UnifiedViteWeappTailwindcssPlugin
18
16
  * @description uni-app vite vue3 版本插件
@@ -20,4 +18,4 @@ declare function isCSSRequest(request: string): boolean;
20
18
  */
21
19
  declare function UnifiedViteWeappTailwindcssPlugin(options?: UserDefinedOptions): Plugin[] | undefined;
22
20
 
23
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest };
21
+ export { UnifiedViteWeappTailwindcssPlugin };
package/dist/vite.d.ts CHANGED
@@ -11,8 +11,6 @@ import 'webpack';
11
11
  import 'lru-cache';
12
12
  import 'postcss-preset-env';
13
13
 
14
- declare const cssLangRE: RegExp;
15
- declare function isCSSRequest(request: string): boolean;
16
14
  /**
17
15
  * @name UnifiedViteWeappTailwindcssPlugin
18
16
  * @description uni-app vite vue3 版本插件
@@ -20,4 +18,4 @@ declare function isCSSRequest(request: string): boolean;
20
18
  */
21
19
  declare function UnifiedViteWeappTailwindcssPlugin(options?: UserDefinedOptions): Plugin[] | undefined;
22
20
 
23
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest };
21
+ export { UnifiedViteWeappTailwindcssPlugin };
package/dist/vite.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
-
4
-
5
- var _chunkJJBOP2VIjs = require('./chunk-JJBOP2VI.js');
3
+ var _chunkZKDPGRFZjs = require('./chunk-ZKDPGRFZ.js');
6
4
  require('./chunk-LSSLYD6B.js');
7
5
  require('./chunk-OGROHM4L.js');
8
6
  require('./chunk-PLEG4SRN.js');
@@ -12,6 +10,4 @@ require('./chunk-O335YLYH.js');
12
10
  require('./chunk-U5U4QBHD.js');
13
11
 
14
12
 
15
-
16
-
17
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkJJBOP2VIjs.UnifiedViteWeappTailwindcssPlugin; exports.cssLangRE = _chunkJJBOP2VIjs.cssLangRE; exports.isCSSRequest = _chunkJJBOP2VIjs.isCSSRequest;
13
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunkZKDPGRFZjs.UnifiedViteWeappTailwindcssPlugin;
package/dist/vite.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  import {
2
- UnifiedViteWeappTailwindcssPlugin,
3
- cssLangRE,
4
- isCSSRequest
5
- } from "./chunk-DHRJQIWW.mjs";
2
+ UnifiedViteWeappTailwindcssPlugin
3
+ } from "./chunk-XM5XNUIB.mjs";
6
4
  import "./chunk-3AUX4FGE.mjs";
7
5
  import "./chunk-CMUA5KCO.mjs";
8
6
  import "./chunk-FOPIY67W.mjs";
@@ -11,7 +9,5 @@ import "./chunk-ABB7LXDE.mjs";
11
9
  import "./chunk-JXBLHLFR.mjs";
12
10
  import "./chunk-QKNCXAGV.mjs";
13
11
  export {
14
- UnifiedViteWeappTailwindcssPlugin,
15
- cssLangRE,
16
- isCSSRequest
12
+ UnifiedViteWeappTailwindcssPlugin
17
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "4.2.2-alpha.0",
3
+ "version": "4.2.2-alpha.2",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -175,11 +175,11 @@
175
175
  "tailwindcss-patch": "~7.1.4",
176
176
  "vue": "^3.5.18",
177
177
  "webpack-sources": "3.3.3",
178
+ "@weapp-tailwindcss/init": "1.0.3",
178
179
  "@weapp-tailwindcss/logger": "1.0.2",
179
180
  "@weapp-tailwindcss/mangle": "1.0.5",
180
- "@weapp-tailwindcss/init": "1.0.3",
181
- "@weapp-tailwindcss/postcss": "1.0.18",
182
- "@weapp-tailwindcss/shared": "1.0.3"
181
+ "@weapp-tailwindcss/shared": "1.0.3",
182
+ "@weapp-tailwindcss/postcss": "1.0.19-alpha.0"
183
183
  },
184
184
  "scripts": {
185
185
  "dev": "tsup --watch --sourcemap",