@weapp-tailwindcss/shared 1.1.3 → 2.0.0-next.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.
package/README.md CHANGED
@@ -15,7 +15,6 @@
15
15
 
16
16
  ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss)
17
17
  ![dm0](https://badgen.net/npm/dm/weapp-tailwindcss)
18
- ![dm1](https://badgen.net/npm/dm/weapp-tailwindcss-webpack-plugin)
19
18
  ![license](https://badgen.net/npm/license/weapp-tailwindcss)
20
19
  [![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)
21
20
  [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
@@ -55,12 +54,12 @@
55
54
 
56
55
  ## 版本对应
57
56
 
58
- 目前,`weapp-tailwindcss` 的 `4.x` 版本
57
+ 目前,`weapp-tailwindcss` 的 `5.x` 版本
59
58
 
60
- - 支持最新版本的 `tailwindcss v4` 和 `v3` 还有 `v2 jit` 版本。
61
- - 支持 `webpack5`,`webpack4`, `vite` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
59
+ - 支持最新版本的 `tailwindcss v4` 和 `v3`。
60
+ - 支持 `webpack5`、`vite`、`rspack`、`rollup`、`rolldown` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
62
61
 
63
- > 如果你还在使用 `tailwindcss@2` 版本,那你应该使用从 `weapp-tailwindcss/webpack4` 导出的本插件的 `postcss7` `webpack4` 版本。另外请确保你的 `nodejs` 版本 `>=16.6.0`。目前低于 `16` 的长期维护版本(`偶数版本`) 都已经结束了生命周期,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
62
+ > `weapp-tailwindcss@5` 面向 Tailwind CSS v3/v4 和现代构建链路,不再内置 Webpack4、PostCSS7、Tailwind CSS v2 兼容入口。`weapp-tailwindcss@5` 需要 `nodejs` 版本 `^20.19.0 || >=22.12.0`,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
64
63
 
65
64
  ## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
66
65
 
@@ -0,0 +1,28 @@
1
+ //#region \0rolldown/runtime.js
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ Object.defineProperty(exports, "__toESM", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return __toESM;
27
+ }
28
+ });
@@ -1,5 +1,7 @@
1
+ //#region src/extractors/split.d.ts
1
2
  declare const validateFilterRE: RegExp;
2
3
  declare function isValidSelector(selector?: string): selector is string;
3
- declare function splitCode(code: string, allowDoubleQuotes?: boolean): string[];
4
-
5
- export { isValidSelector, splitCode, validateFilterRE };
4
+ declare function splitCandidateTokens(code: string): string[];
5
+ declare function splitCode(code: string, _allowDoubleQuotes?: boolean): string[];
6
+ //#endregion
7
+ export { isValidSelector, splitCandidateTokens, splitCode, validateFilterRE };
@@ -1,39 +1,67 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk5F5YENBWjs = require('./chunk-5F5YENBW.js');
4
-
5
- // src/extractors/index.ts
6
- _chunk5F5YENBWjs.init_cjs_shims.call(void 0, );
7
-
8
- // src/extractors/split.ts
9
- _chunk5F5YENBWjs.init_cjs_shims.call(void 0, );
10
- var validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/extractors/split.ts
3
+ const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
11
4
  function isValidSelector(selector = "") {
12
- return validateFilterRE.test(selector);
5
+ return validateFilterRE.test(selector);
13
6
  }
14
- var splitCacheDefault = /* @__PURE__ */ new Map();
15
- var splitCacheAllowQuotes = /* @__PURE__ */ new Map();
16
- var SPLIT_CACHE_LIMIT = 8192;
17
- var SPLITTER_DEFAULT = /\s+|"/;
18
- var SPLITTER_ALLOW_QUOTES = /\s+/;
19
- var ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
20
- function splitCode(code, allowDoubleQuotes = false) {
21
- const cache = allowDoubleQuotes ? splitCacheAllowQuotes : splitCacheDefault;
22
- const cached = cache.get(code);
23
- if (cached) {
24
- return cached;
25
- }
26
- const normalized = code.includes("\\") ? code.replace(ESCAPED_WHITESPACE_RE, " ") : code;
27
- const splitter = allowDoubleQuotes ? SPLITTER_ALLOW_QUOTES : SPLITTER_DEFAULT;
28
- const result = normalized.split(splitter).filter((element) => isValidSelector(element));
29
- if (cache.size >= SPLIT_CACHE_LIMIT) {
30
- cache.clear();
31
- }
32
- cache.set(code, result);
33
- return result;
7
+ /** 候选 token 分割结果缓存,避免对相同字符串重复分割和过滤。 */
8
+ const splitCache = /* @__PURE__ */ new Map();
9
+ const SPLIT_CACHE_LIMIT = 8192;
10
+ const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
11
+ function isSplitter(char, bracketDepth) {
12
+ return bracketDepth === 0 && (char === "\"" || /\s/.test(char));
34
13
  }
35
-
36
-
37
-
38
-
39
- exports.isValidSelector = isValidSelector; exports.splitCode = splitCode; exports.validateFilterRE = validateFilterRE;
14
+ function hasClosingQuotedArbitraryValue(code, start, quote) {
15
+ for (let index = start; index < code.length; index++) {
16
+ if (code[index] === "\\") {
17
+ index++;
18
+ continue;
19
+ }
20
+ if (code[index] === quote) return code.includes("]", index + 1);
21
+ }
22
+ return false;
23
+ }
24
+ function splitBracketAware(code) {
25
+ const result = [];
26
+ let bracketDepth = 0;
27
+ let bracketQuote;
28
+ let start = 0;
29
+ for (let index = 0; index < code.length; index++) {
30
+ const char = code[index];
31
+ if (bracketDepth > 0 && char === "\\") {
32
+ index++;
33
+ continue;
34
+ }
35
+ if (bracketDepth > 0 && (char === "\"" || char === "'")) {
36
+ if (bracketQuote === char) bracketQuote = void 0;
37
+ else if (bracketQuote === void 0 && hasClosingQuotedArbitraryValue(code, index + 1, char)) bracketQuote = char;
38
+ }
39
+ if (bracketQuote === void 0) {
40
+ if (char === "[" && code.includes("]", index + 1)) bracketDepth++;
41
+ else if (char === "]" && bracketDepth > 0) bracketDepth--;
42
+ }
43
+ if (!isSplitter(char, bracketDepth)) continue;
44
+ const candidate = code.slice(start, index);
45
+ if (isValidSelector(candidate)) result.push(candidate);
46
+ start = index + 1;
47
+ }
48
+ const candidate = code.slice(start);
49
+ if (isValidSelector(candidate)) result.push(candidate);
50
+ return result;
51
+ }
52
+ function splitCandidateTokens(code) {
53
+ const cached = splitCache.get(code);
54
+ if (cached) return cached;
55
+ const result = splitBracketAware(code.includes("\\") ? code.replace(ESCAPED_WHITESPACE_RE, " ") : code);
56
+ if (splitCache.size >= SPLIT_CACHE_LIMIT) splitCache.clear();
57
+ splitCache.set(code, result);
58
+ return result;
59
+ }
60
+ function splitCode(code, _allowDoubleQuotes = false) {
61
+ return splitCandidateTokens(code);
62
+ }
63
+ //#endregion
64
+ exports.isValidSelector = isValidSelector;
65
+ exports.splitCandidateTokens = splitCandidateTokens;
66
+ exports.splitCode = splitCode;
67
+ exports.validateFilterRE = validateFilterRE;
@@ -1,39 +1,63 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-7QA6IUZF.mjs";
4
-
5
- // src/extractors/index.ts
6
- init_esm_shims();
7
-
8
- // src/extractors/split.ts
9
- init_esm_shims();
10
- var validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
1
+ //#region src/extractors/split.ts
2
+ const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
11
3
  function isValidSelector(selector = "") {
12
- return validateFilterRE.test(selector);
4
+ return validateFilterRE.test(selector);
13
5
  }
14
- var splitCacheDefault = /* @__PURE__ */ new Map();
15
- var splitCacheAllowQuotes = /* @__PURE__ */ new Map();
16
- var SPLIT_CACHE_LIMIT = 8192;
17
- var SPLITTER_DEFAULT = /\s+|"/;
18
- var SPLITTER_ALLOW_QUOTES = /\s+/;
19
- var ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
20
- function splitCode(code, allowDoubleQuotes = false) {
21
- const cache = allowDoubleQuotes ? splitCacheAllowQuotes : splitCacheDefault;
22
- const cached = cache.get(code);
23
- if (cached) {
24
- return cached;
25
- }
26
- const normalized = code.includes("\\") ? code.replace(ESCAPED_WHITESPACE_RE, " ") : code;
27
- const splitter = allowDoubleQuotes ? SPLITTER_ALLOW_QUOTES : SPLITTER_DEFAULT;
28
- const result = normalized.split(splitter).filter((element) => isValidSelector(element));
29
- if (cache.size >= SPLIT_CACHE_LIMIT) {
30
- cache.clear();
31
- }
32
- cache.set(code, result);
33
- return result;
6
+ /** 候选 token 分割结果缓存,避免对相同字符串重复分割和过滤。 */
7
+ const splitCache = /* @__PURE__ */ new Map();
8
+ const SPLIT_CACHE_LIMIT = 8192;
9
+ const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
10
+ function isSplitter(char, bracketDepth) {
11
+ return bracketDepth === 0 && (char === "\"" || /\s/.test(char));
34
12
  }
35
- export {
36
- isValidSelector,
37
- splitCode,
38
- validateFilterRE
39
- };
13
+ function hasClosingQuotedArbitraryValue(code, start, quote) {
14
+ for (let index = start; index < code.length; index++) {
15
+ if (code[index] === "\\") {
16
+ index++;
17
+ continue;
18
+ }
19
+ if (code[index] === quote) return code.includes("]", index + 1);
20
+ }
21
+ return false;
22
+ }
23
+ function splitBracketAware(code) {
24
+ const result = [];
25
+ let bracketDepth = 0;
26
+ let bracketQuote;
27
+ let start = 0;
28
+ for (let index = 0; index < code.length; index++) {
29
+ const char = code[index];
30
+ if (bracketDepth > 0 && char === "\\") {
31
+ index++;
32
+ continue;
33
+ }
34
+ if (bracketDepth > 0 && (char === "\"" || char === "'")) {
35
+ if (bracketQuote === char) bracketQuote = void 0;
36
+ else if (bracketQuote === void 0 && hasClosingQuotedArbitraryValue(code, index + 1, char)) bracketQuote = char;
37
+ }
38
+ if (bracketQuote === void 0) {
39
+ if (char === "[" && code.includes("]", index + 1)) bracketDepth++;
40
+ else if (char === "]" && bracketDepth > 0) bracketDepth--;
41
+ }
42
+ if (!isSplitter(char, bracketDepth)) continue;
43
+ const candidate = code.slice(start, index);
44
+ if (isValidSelector(candidate)) result.push(candidate);
45
+ start = index + 1;
46
+ }
47
+ const candidate = code.slice(start);
48
+ if (isValidSelector(candidate)) result.push(candidate);
49
+ return result;
50
+ }
51
+ function splitCandidateTokens(code) {
52
+ const cached = splitCache.get(code);
53
+ if (cached) return cached;
54
+ const result = splitBracketAware(code.includes("\\") ? code.replace(ESCAPED_WHITESPACE_RE, " ") : code);
55
+ if (splitCache.size >= SPLIT_CACHE_LIMIT) splitCache.clear();
56
+ splitCache.set(code, result);
57
+ return result;
58
+ }
59
+ function splitCode(code, _allowDoubleQuotes = false) {
60
+ return splitCandidateTokens(code);
61
+ }
62
+ //#endregion
63
+ export { isValidSelector, splitCandidateTokens, splitCode, validateFilterRE };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import * as defu from 'defu';
2
- export { defu } from 'defu';
3
- export { default as getValue } from 'get-value';
4
- export { default as setValue } from 'set-value';
1
+ import { defu } from "defu";
2
+ import getValue from "get-value";
3
+ import setValue from "set-value";
5
4
 
5
+ //#region src/index.d.ts
6
6
  declare function isRegexp(value: unknown): value is RegExp;
7
7
  declare function isMap<T = unknown, K = unknown>(value: unknown): value is Map<T, K>;
8
8
  declare function isHttp(target: string): boolean;
@@ -12,19 +12,11 @@ declare function ensurePosix(value: string): string;
12
12
  declare function normalizeRoot(root: string): string;
13
13
  declare function normalizeRelativeImport(target: string): string;
14
14
  declare function regExpTest(arr: (string | RegExp)[], str: string, options?: {
15
- exact?: boolean;
15
+ exact?: boolean;
16
16
  }): boolean;
17
17
  declare function noop(): void;
18
18
  declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
19
19
  declare function removeExt(file: string): string;
20
- declare const defuOverrideArray: <Source extends {
21
- [x: string]: any;
22
- [x: number]: any;
23
- [x: symbol]: any;
24
- }, Defaults extends Array<{
25
- [x: string]: any;
26
- [x: number]: any;
27
- [x: symbol]: any;
28
- } | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
29
-
30
- export { cleanUrl, defuOverrideArray, ensurePosix, groupBy, isHttp, isMap, isRegexp, noop, normalizeRelativeImport, normalizeRoot, regExpTest, removeExt, toArray };
20
+ declare const defuOverrideArray: import("defu").DefuFn;
21
+ //#endregion
22
+ export { cleanUrl, defu, defuOverrideArray, ensurePosix, getValue, groupBy, isHttp, isMap, isRegexp, noop, normalizeRelativeImport, normalizeRoot, regExpTest, removeExt, setValue, toArray };