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.
- package/dist/chunk-257YPDSI.mjs +173 -0
- package/dist/chunk-75EWCRQW.mjs +13 -0
- package/dist/chunk-AB467PG7.mjs +43 -0
- package/dist/chunk-E7XGHGC7.mjs +62 -0
- package/dist/chunk-GUE4UCRJ.mjs +126 -0
- package/dist/chunk-IOYI6MSW.mjs +533 -0
- package/dist/chunk-LDWI65M5.mjs +152 -0
- package/dist/chunk-NVFWRLOI.mjs +27 -0
- package/dist/chunk-ORMKM6ZA.mjs +30 -0
- package/dist/chunk-PC4B5JJB.mjs +953 -0
- package/dist/chunk-SRLZU2YE.mjs +95 -0
- package/dist/chunk-VECXHWWG.mjs +31 -0
- package/dist/chunk-VN37QGSM.mjs +216 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +1760 -52
- package/dist/cli.mjs +34 -46
- package/dist/core.d.mts +22 -0
- package/dist/core.d.ts +16 -2
- package/dist/core.js +1775 -62
- package/dist/core.mjs +46 -62
- package/dist/css-macro/index.d.mts +18 -0
- package/dist/css-macro/index.d.ts +7 -4
- package/dist/css-macro/index.js +140 -30
- package/dist/css-macro/index.mjs +35 -28
- package/dist/css-macro/postcss.d.mts +7 -0
- package/dist/css-macro/postcss.d.ts +5 -3
- package/dist/css-macro/postcss.js +99 -46
- package/dist/css-macro/postcss.mjs +54 -45
- package/dist/defaults.d.mts +16 -0
- package/dist/defaults.d.ts +16 -2
- package/dist/defaults.js +208 -7
- package/dist/defaults.mjs +9 -4
- package/dist/gulp.d.mts +26 -0
- package/dist/gulp.d.ts +26 -1
- package/dist/gulp.js +1898 -40
- package/dist/gulp.mjs +15 -32
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +2291 -44
- package/dist/index.mjs +23 -34
- package/dist/postcss.d.mts +23 -0
- package/dist/postcss.d.ts +23 -1
- package/dist/postcss.js +598 -22
- package/dist/postcss.mjs +17 -8
- package/dist/replace.d.mts +19 -0
- package/dist/replace.d.ts +19 -3
- package/dist/replace.js +93 -42
- package/dist/replace.mjs +30 -26
- package/dist/types-DSNuiOhH.d.mts +519 -0
- package/dist/types-DSNuiOhH.d.ts +519 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -1
- package/dist/vite.js +1947 -38
- package/dist/vite.mjs +15 -30
- package/dist/weapp-tw-runtime-loader.d.mts +7 -0
- package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
- package/dist/weapp-tw-runtime-loader.js +41 -14
- package/dist/weapp-tw-runtime-loader.mjs +12 -8
- package/dist/webpack.d.mts +26 -0
- package/dist/webpack.d.ts +26 -1
- package/dist/webpack.js +1994 -38
- package/dist/webpack.mjs +15 -30
- package/dist/webpack4.d.mts +27 -0
- package/dist/webpack4.d.ts +27 -1
- package/dist/webpack4.js +1979 -191
- package/dist/webpack4.mjs +211 -189
- package/package.json +18 -19
- package/dist/babel/index.d.ts +0 -16
- package/dist/bundlers/gulp/index.d.ts +0 -8
- package/dist/bundlers/vite/index.d.ts +0 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
- package/dist/bundlers/webpack/index.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -32
- package/dist/constants-CFM1J-h1.js +0 -42
- package/dist/constants-Dy2Dd3Fz.mjs +0 -36
- package/dist/constants.d.ts +0 -7
- package/dist/css-macro/constants.d.ts +0 -14
- package/dist/debug/index.d.ts +0 -2
- package/dist/defaults-DUZZvtdg.mjs +0 -149
- package/dist/defaults-syv_N3uk.js +0 -156
- package/dist/defu-Cdz2PomB.js +0 -60
- package/dist/defu-n46TJT6t.mjs +0 -57
- package/dist/env.d.ts +0 -2
- package/dist/escape.d.ts +0 -4
- package/dist/extractors/split.d.ts +0 -3
- package/dist/index-B8TOcVAt.js +0 -130
- package/dist/index-BEIjgKpF.mjs +0 -11
- package/dist/index-BKZH-Gxq.mjs +0 -134
- package/dist/index-BPzIdybK.mjs +0 -513
- package/dist/index-Bc61v7B0.mjs +0 -124
- package/dist/index-DXeB6ex8.js +0 -136
- package/dist/index-DwZHOkK3.js +0 -526
- package/dist/index-HC-Qkn0i.js +0 -17
- package/dist/js/handlers.d.ts +0 -13
- package/dist/js/index.d.ts +0 -7
- package/dist/mangle/index.d.ts +0 -8
- package/dist/options-BHJnjA_a.mjs +0 -981
- package/dist/options-DAp5AdGz.js +0 -1014
- package/dist/options.d.ts +0 -2
- package/dist/postcss/cssVars.d.ts +0 -5
- package/dist/postcss/index.d.ts +0 -3
- package/dist/postcss/mp.d.ts +0 -8
- package/dist/postcss/plugins/ctx.d.ts +0 -6
- package/dist/postcss/plugins/index.d.ts +0 -7
- package/dist/postcss/plugins/post.d.ts +0 -5
- package/dist/postcss/plugins/pre.d.ts +0 -5
- package/dist/postcss/preflight.d.ts +0 -3
- package/dist/postcss/selectorParser.d.ts +0 -6
- package/dist/postcss/shared.d.ts +0 -3
- package/dist/postcss/symbols.d.ts +0 -1
- package/dist/reg.d.ts +0 -1
- package/dist/shared-DbJl6i6a.mjs +0 -25
- package/dist/shared-hzYeE1wX.js +0 -28
- package/dist/tailwindcss/patcher.d.ts +0 -8
- package/dist/tailwindcss/supportCustomUnit.d.ts +0 -6
- package/dist/types.d.ts +0 -179
- package/dist/utils.d.ts +0 -18
- package/dist/v5-B9S3lBOs.mjs +0 -174
- package/dist/v5-QURRYPNk.js +0 -181
- package/dist/wxml/Tokenizer.d.ts +0 -31
- package/dist/wxml/index.d.ts +0 -2
- package/dist/wxml/shared.d.ts +0 -2
- package/dist/wxml/utils.d.ts +0 -9
package/dist/options.d.ts
DELETED
package/dist/postcss/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { IStyleHandlerOptions } from "../types";
|
|
2
|
-
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<string>;
|
|
3
|
-
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<string>;
|
package/dist/postcss/mp.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Rule } from 'postcss';
|
|
2
|
-
import type { IStyleHandlerOptions } from "../types";
|
|
3
|
-
export declare function testIfVariablesScope(node: Rule, count?: number): boolean;
|
|
4
|
-
export declare function testIfTwBackdrop(node: Rule, count?: number): boolean;
|
|
5
|
-
export declare function makePseudoVarRule(): Rule;
|
|
6
|
-
export declare function remakeCssVarSelector(selectors: string[], options: IStyleHandlerOptions): string[];
|
|
7
|
-
export declare function remakeCombinatorSelector(selector: string, cssChildCombinatorReplaceValue: IStyleHandlerOptions['cssChildCombinatorReplaceValue']): string;
|
|
8
|
-
export declare function commonChunkPreflight(node: Rule, options: IStyleHandlerOptions): void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AcceptedPlugin } from 'postcss';
|
|
2
|
-
import type { IStyleHandlerOptions } from "../../types";
|
|
3
|
-
export declare function getPlugins(options: IStyleHandlerOptions): AcceptedPlugin[];
|
|
4
|
-
export { postcssWeappTailwindcssPostPlugin } from './post';
|
|
5
|
-
export { postcssWeappTailwindcssPrePlugin } from './pre';
|
|
6
|
-
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
7
|
-
export { default as postcssRem2rpx } from 'postcss-rem-to-responsive-pixel';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { PluginCreator } from 'postcss';
|
|
2
|
-
import type { IStyleHandlerOptions } from "../../types";
|
|
3
|
-
export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
|
|
4
|
-
declare const postcssWeappTailwindcssPostPlugin: PostcssWeappTailwindcssRenamePlugin;
|
|
5
|
-
export { postcssWeappTailwindcssPostPlugin };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { PluginCreator } from 'postcss';
|
|
2
|
-
import type { IStyleHandlerOptions } from "../../types";
|
|
3
|
-
export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
|
|
4
|
-
declare const postcssWeappTailwindcssPrePlugin: PostcssWeappTailwindcssRenamePlugin;
|
|
5
|
-
export { postcssWeappTailwindcssPrePlugin };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser';
|
|
2
|
-
import type { Rule } from 'postcss';
|
|
3
|
-
import type { IStyleHandlerOptions } from "../types";
|
|
4
|
-
export declare function ruleTransformSync(rule: Rule, options: IStyleHandlerOptions): void;
|
|
5
|
-
export declare function isOnlyBeforeAndAfterPseudoElement(node: Rule): boolean;
|
|
6
|
-
export declare const fallbackRemove: selectorParser.Processor<void, selectorParser.Selectors>;
|
package/dist/postcss/shared.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const VariablesScopeSymbol: unique symbol;
|
package/dist/reg.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@weapp-core/regex';
|
package/dist/shared-DbJl6i6a.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
|
|
2
|
-
import '@ast-core/escape';
|
|
3
|
-
|
|
4
|
-
function internalCssSelectorReplacer(selectors, options = {
|
|
5
|
-
escapeMap: SimpleMappingChars2String,
|
|
6
|
-
}) {
|
|
7
|
-
const { mangleContext, escapeMap } = options;
|
|
8
|
-
if (mangleContext) {
|
|
9
|
-
selectors = mangleContext.cssHandler(selectors);
|
|
10
|
-
}
|
|
11
|
-
return escape(selectors, {
|
|
12
|
-
map: escapeMap,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function composeIsPseudo(strs) {
|
|
16
|
-
if (typeof strs === 'string') {
|
|
17
|
-
return strs;
|
|
18
|
-
}
|
|
19
|
-
if (strs.length > 1) {
|
|
20
|
-
return `:is(${strs.join(',')})`;
|
|
21
|
-
}
|
|
22
|
-
return strs.join('');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { composeIsPseudo as c, internalCssSelectorReplacer as i };
|
package/dist/shared-hzYeE1wX.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var escape = require('@weapp-core/escape');
|
|
4
|
-
require('@ast-core/escape');
|
|
5
|
-
|
|
6
|
-
function internalCssSelectorReplacer(selectors, options = {
|
|
7
|
-
escapeMap: escape.SimpleMappingChars2String,
|
|
8
|
-
}) {
|
|
9
|
-
const { mangleContext, escapeMap } = options;
|
|
10
|
-
if (mangleContext) {
|
|
11
|
-
selectors = mangleContext.cssHandler(selectors);
|
|
12
|
-
}
|
|
13
|
-
return escape.escape(selectors, {
|
|
14
|
-
map: escapeMap,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function composeIsPseudo(strs) {
|
|
18
|
-
if (typeof strs === 'string') {
|
|
19
|
-
return strs;
|
|
20
|
-
}
|
|
21
|
-
if (strs.length > 1) {
|
|
22
|
-
return `:is(${strs.join(',')})`;
|
|
23
|
-
}
|
|
24
|
-
return strs.join('');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.composeIsPseudo = composeIsPseudo;
|
|
28
|
-
exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
2
|
-
import type { ILengthUnitsPatchOptions, InternalPatchResult } from "../types";
|
|
3
|
-
import { noop } from "../utils";
|
|
4
|
-
export declare function getInstalledPkgJsonPath(options: ILengthUnitsPatchOptions): string | undefined;
|
|
5
|
-
export declare function createPatch(options: false | ILengthUnitsPatchOptions): typeof noop;
|
|
6
|
-
export declare function monkeyPatchForSupportingCustomUnit(rootDir: string, options: ILengthUnitsPatchOptions): string | undefined;
|
|
7
|
-
export declare function internalPatch(pkgJsonPath: string | undefined, options: ILengthUnitsPatchOptions): InternalPatchResult | undefined;
|
|
8
|
-
export declare function createTailwindcssPatcher(basedir?: string, cacheDir?: string): TailwindcssPatcher;
|
package/dist/types.d.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type { Rule } from 'postcss';
|
|
2
|
-
import type { ClassGenerator, IClassGeneratorOptions } from '@tailwindcss-mangle/shared';
|
|
3
|
-
import type { SourceMap } from 'magic-string';
|
|
4
|
-
import type { GeneratorResult } from '@babel/generator';
|
|
5
|
-
import type { ParseError, ParserOptions } from '@babel/parser';
|
|
6
|
-
import type { UserDefinedOptions as rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
|
|
7
|
-
import type { Result } from 'postcss-load-config';
|
|
8
|
-
import type { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
9
|
-
import type { InjectPreflight } from './postcss/preflight';
|
|
10
|
-
import type { IContext as PostcssContext } from './postcss/plugins/ctx';
|
|
11
|
-
import type { ICreateCacheReturnType } from "./cache";
|
|
12
|
-
type PostcssOptions = Partial<Omit<Result, 'file'>>;
|
|
13
|
-
export type ItemOrItemArray<T> = T | T[];
|
|
14
|
-
export type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx';
|
|
15
|
-
export interface IPropValue {
|
|
16
|
-
prop: string;
|
|
17
|
-
value: string;
|
|
18
|
-
}
|
|
19
|
-
export type CssPresetProps = string;
|
|
20
|
-
export type CssPreflightOptions = {
|
|
21
|
-
[key: CssPresetProps]: string | number | boolean;
|
|
22
|
-
} | false;
|
|
23
|
-
export type RequiredStyleHandlerOptions = {
|
|
24
|
-
isMainChunk: boolean;
|
|
25
|
-
cssInjectPreflight?: InjectPreflight;
|
|
26
|
-
escapeMap?: Record<string, string>;
|
|
27
|
-
} & Pick<UserDefinedOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
|
|
28
|
-
export type CustomRuleCallback = (node: Rule, options: Readonly<RequiredStyleHandlerOptions>) => void;
|
|
29
|
-
export interface InternalCssSelectorReplacerOptions {
|
|
30
|
-
mangleContext?: IMangleScopeContext;
|
|
31
|
-
escapeMap?: Record<string, string>;
|
|
32
|
-
}
|
|
33
|
-
export type IStyleHandlerOptions = {
|
|
34
|
-
customRuleCallback?: CustomRuleCallback;
|
|
35
|
-
mangleContext?: IMangleScopeContext;
|
|
36
|
-
ctx?: PostcssContext;
|
|
37
|
-
postcssOptions?: PostcssOptions;
|
|
38
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
39
|
-
} & RequiredStyleHandlerOptions;
|
|
40
|
-
export interface JsHandlerReplaceResult {
|
|
41
|
-
code: string;
|
|
42
|
-
map?: SourceMap;
|
|
43
|
-
}
|
|
44
|
-
export type JsHandlerResult = (JsHandlerReplaceResult | GeneratorResult) & {
|
|
45
|
-
error?: ParseError;
|
|
46
|
-
};
|
|
47
|
-
export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>> | Map<string | RegExp, ItemOrItemArray<string | RegExp>>;
|
|
48
|
-
export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
|
|
49
|
-
export interface IJsHandlerOptions {
|
|
50
|
-
escapeMap?: Record<string, string>;
|
|
51
|
-
classNameSet?: Set<string>;
|
|
52
|
-
arbitraryValues?: IArbitraryValues;
|
|
53
|
-
mangleContext?: IMangleScopeContext;
|
|
54
|
-
jsPreserveClass?: (keyword: string) => boolean | undefined;
|
|
55
|
-
needEscaped?: boolean;
|
|
56
|
-
generateMap?: boolean;
|
|
57
|
-
always?: boolean;
|
|
58
|
-
jsAstTool?: 'babel' | 'ast-grep';
|
|
59
|
-
unescapeUnicode?: boolean;
|
|
60
|
-
babelParserOptions?: ParserOptions;
|
|
61
|
-
}
|
|
62
|
-
export interface RawSource {
|
|
63
|
-
start: number;
|
|
64
|
-
end: number;
|
|
65
|
-
raw: string;
|
|
66
|
-
source?: string;
|
|
67
|
-
}
|
|
68
|
-
export interface ILengthUnitsPatchDangerousOptions {
|
|
69
|
-
packageName?: string;
|
|
70
|
-
gteVersion?: string;
|
|
71
|
-
lengthUnitsFilePath?: string;
|
|
72
|
-
variableName?: string;
|
|
73
|
-
overwrite?: boolean;
|
|
74
|
-
destPath?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface ILengthUnitsPatchOptions {
|
|
77
|
-
units: string[];
|
|
78
|
-
paths?: string[];
|
|
79
|
-
dangerousOptions?: ILengthUnitsPatchDangerousOptions;
|
|
80
|
-
basedir?: string;
|
|
81
|
-
}
|
|
82
|
-
export interface IMangleOptions {
|
|
83
|
-
classGenerator?: IClassGeneratorOptions;
|
|
84
|
-
mangleClassFilter?: (className: string) => boolean;
|
|
85
|
-
}
|
|
86
|
-
export interface IArbitraryValues {
|
|
87
|
-
allowDoubleQuotes?: boolean;
|
|
88
|
-
}
|
|
89
|
-
export interface UserDefinedOptions {
|
|
90
|
-
htmlMatcher?: (name: string) => boolean;
|
|
91
|
-
cssMatcher?: (name: string) => boolean;
|
|
92
|
-
jsMatcher?: (name: string) => boolean;
|
|
93
|
-
mainCssChunkMatcher?: (name: string, appType?: AppType) => boolean;
|
|
94
|
-
cssPreflight?: CssPreflightOptions;
|
|
95
|
-
cssPreflightRange?: 'all';
|
|
96
|
-
disabled?: boolean;
|
|
97
|
-
customRuleCallback?: CustomRuleCallback;
|
|
98
|
-
onLoad?: () => void;
|
|
99
|
-
onStart?: () => void;
|
|
100
|
-
onUpdate?: (filename: string, oldVal: string, newVal: string) => void;
|
|
101
|
-
onEnd?: () => void;
|
|
102
|
-
customAttributes?: ICustomAttributes;
|
|
103
|
-
customReplaceDictionary?: Record<string, string>;
|
|
104
|
-
supportCustomLengthUnitsPatch?: ILengthUnitsPatchOptions;
|
|
105
|
-
appType?: AppType;
|
|
106
|
-
mangle?: boolean | IMangleOptions;
|
|
107
|
-
arbitraryValues?: IArbitraryValues;
|
|
108
|
-
cssChildCombinatorReplaceValue?: string | string[];
|
|
109
|
-
wxsMatcher?: (name: string) => boolean;
|
|
110
|
-
inlineWxs?: boolean;
|
|
111
|
-
injectAdditionalCssVarScope?: boolean;
|
|
112
|
-
jsPreserveClass?: (keyword: string) => boolean | undefined;
|
|
113
|
-
disabledDefaultTemplateHandler?: boolean;
|
|
114
|
-
runtimeLoaderPath?: string;
|
|
115
|
-
cssSelectorReplacement?: {
|
|
116
|
-
root?: string | string[] | false;
|
|
117
|
-
universal?: string | string[] | false;
|
|
118
|
-
};
|
|
119
|
-
tailwindcssBasedir?: string;
|
|
120
|
-
rem2rpx?: boolean | rem2rpxOptions;
|
|
121
|
-
cache?: boolean | ICreateCacheReturnType;
|
|
122
|
-
jsAstTool?: 'babel' | 'ast-grep';
|
|
123
|
-
babelParserOptions?: ParserOptions;
|
|
124
|
-
postcssOptions?: PostcssOptions;
|
|
125
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
126
|
-
}
|
|
127
|
-
export interface JsHandler {
|
|
128
|
-
(rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions): JsHandlerResult | Promise<JsHandlerResult>;
|
|
129
|
-
sync: (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
|
|
130
|
-
}
|
|
131
|
-
export interface IMangleScopeContext {
|
|
132
|
-
rawOptions: UserDefinedOptions['mangle'];
|
|
133
|
-
runtimeSet: Set<string>;
|
|
134
|
-
classGenerator: ClassGenerator;
|
|
135
|
-
filter: (className: string) => boolean;
|
|
136
|
-
cssHandler: (rawSource: string) => string;
|
|
137
|
-
jsHandler: (rawSource: string) => string;
|
|
138
|
-
wxmlHandler: (rawSource: string) => string;
|
|
139
|
-
}
|
|
140
|
-
export interface ICommonReplaceOptions {
|
|
141
|
-
keepEOL?: boolean;
|
|
142
|
-
escapeMap?: Record<string, string>;
|
|
143
|
-
}
|
|
144
|
-
export interface ITemplateHandlerOptions extends ICommonReplaceOptions {
|
|
145
|
-
customAttributesEntities?: ICustomAttributesEntities;
|
|
146
|
-
escapeMap?: Record<string, string>;
|
|
147
|
-
mangleContext?: IMangleScopeContext;
|
|
148
|
-
inlineWxs?: boolean;
|
|
149
|
-
jsHandler?: JsHandler;
|
|
150
|
-
runtimeSet?: Set<string>;
|
|
151
|
-
disabledDefaultTemplateHandler?: boolean;
|
|
152
|
-
quote?: string | null;
|
|
153
|
-
ignoreHead?: boolean;
|
|
154
|
-
}
|
|
155
|
-
export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary' | 'cache'> & {
|
|
156
|
-
supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | false;
|
|
157
|
-
templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => Promise<string>;
|
|
158
|
-
styleHandler: (rawSource: string, options: IStyleHandlerOptions) => Promise<string>;
|
|
159
|
-
jsHandler: JsHandler;
|
|
160
|
-
escapeMap: Record<string, string>;
|
|
161
|
-
patch: () => void;
|
|
162
|
-
customReplaceDictionary: Record<string, string>;
|
|
163
|
-
setMangleRuntimeSet: (runtimeSet: Set<string>) => void;
|
|
164
|
-
cache: ICreateCacheReturnType;
|
|
165
|
-
twPatcher: TailwindcssPatcher;
|
|
166
|
-
}>;
|
|
167
|
-
export type InternalPostcssOptions = Pick<UserDefinedOptions, 'cssMatcher' | 'mainCssChunkMatcher' | 'cssPreflight' | 'cssPreflightRange' | 'customRuleCallback' | 'disabled'>;
|
|
168
|
-
export interface IBaseWebpackPlugin {
|
|
169
|
-
options: InternalUserDefinedOptions;
|
|
170
|
-
appType?: AppType;
|
|
171
|
-
apply: (compiler: any) => void;
|
|
172
|
-
}
|
|
173
|
-
export interface InternalPatchResult {
|
|
174
|
-
dataTypes?: string;
|
|
175
|
-
processTailwindFeatures?: string;
|
|
176
|
-
plugin?: string;
|
|
177
|
-
}
|
|
178
|
-
export type CreateJsHandlerOptions = Omit<IJsHandlerOptions, 'classNameSet'>;
|
|
179
|
-
export {};
|
package/dist/utils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { InternalUserDefinedOptions } from "./types";
|
|
2
|
-
export declare function isRegexp(value: unknown): boolean;
|
|
3
|
-
export declare function isMap(value: unknown): boolean;
|
|
4
|
-
export declare function regExpTest(arr: (string | RegExp)[] | undefined, str: string): boolean;
|
|
5
|
-
export declare function noop(): void;
|
|
6
|
-
export declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
7
|
-
export declare function getGroupedEntries<T>(entries: [string, T][], options: InternalUserDefinedOptions): Record<"css" | "html" | "js" | "other", [string, T][]>;
|
|
8
|
-
export declare function removeExt(file: string): string;
|
|
9
|
-
export { default as defu } from 'defu';
|
|
10
|
-
export declare const defuOverrideArray: <Source extends {
|
|
11
|
-
[x: string]: any;
|
|
12
|
-
[x: number]: any;
|
|
13
|
-
[x: symbol]: any;
|
|
14
|
-
}, Defaults extends ({
|
|
15
|
-
[x: string]: any;
|
|
16
|
-
[x: number]: any;
|
|
17
|
-
[x: symbol]: any;
|
|
18
|
-
} | (number | boolean | any[] | Record<never, any> | null | undefined))[]>(source: Source, ...defaults: Defaults) => import("defu").Defu<Source, Defaults>;
|
package/dist/v5-B9S3lBOs.mjs
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { g as getOptions, _ as __awaiter } from './options-BHJnjA_a.mjs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { b as pluginName } from './index-BPzIdybK.mjs';
|
|
5
|
-
import { g as getGroupedEntries, r as removeExt } from './defaults-DUZZvtdg.mjs';
|
|
6
|
-
import { c as createDebug } from './index-BEIjgKpF.mjs';
|
|
7
|
-
|
|
8
|
-
const debug = createDebug();
|
|
9
|
-
class UnifiedWebpackPluginV5 {
|
|
10
|
-
constructor(options = {}) {
|
|
11
|
-
this.options = getOptions(options);
|
|
12
|
-
this.appType = this.options.appType;
|
|
13
|
-
}
|
|
14
|
-
apply(compiler) {
|
|
15
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, twPatcher, } = this.options;
|
|
16
|
-
if (disabled) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
20
|
-
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
21
|
-
const { ConcatSource, RawSource } = sources;
|
|
22
|
-
function getClassSet() {
|
|
23
|
-
return twPatcher.getClassSet();
|
|
24
|
-
}
|
|
25
|
-
onLoad();
|
|
26
|
-
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
27
|
-
const isExisted = fs.existsSync(loader);
|
|
28
|
-
const WeappTwRuntimeAopLoader = {
|
|
29
|
-
loader,
|
|
30
|
-
options: {
|
|
31
|
-
getClassSet,
|
|
32
|
-
},
|
|
33
|
-
ident: null,
|
|
34
|
-
type: null,
|
|
35
|
-
};
|
|
36
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
37
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
|
|
38
|
-
if (isExisted) {
|
|
39
|
-
const idx = module.loaders.findIndex(x => x.loader.includes('postcss-loader'));
|
|
40
|
-
if (idx > -1) {
|
|
41
|
-
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
compilation.hooks.processAssets.tapPromise({
|
|
46
|
-
name: pluginName,
|
|
47
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
48
|
-
}, (assets) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
onStart();
|
|
50
|
-
debug('start');
|
|
51
|
-
for (const chunk of compilation.chunks) {
|
|
52
|
-
if (chunk.id && chunk.hash) {
|
|
53
|
-
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const entries = Object.entries(assets);
|
|
57
|
-
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
58
|
-
const runtimeSet = getClassSet();
|
|
59
|
-
setMangleRuntimeSet(runtimeSet);
|
|
60
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
61
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
62
|
-
let noCachedCount = 0;
|
|
63
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
64
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
65
|
-
const rawSource = originalSource.source().toString();
|
|
66
|
-
const hash = cache.computeHash(rawSource);
|
|
67
|
-
const cacheKey = file;
|
|
68
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
69
|
-
yield cache.process(cacheKey, () => {
|
|
70
|
-
const source = cache.get(cacheKey);
|
|
71
|
-
if (source) {
|
|
72
|
-
compilation.updateAsset(file, source);
|
|
73
|
-
debug('html cache hit: %s', file);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const wxml = yield templateHandler(rawSource, {
|
|
80
|
-
runtimeSet,
|
|
81
|
-
});
|
|
82
|
-
const source = new ConcatSource(wxml);
|
|
83
|
-
compilation.updateAsset(file, source);
|
|
84
|
-
onUpdate(file, rawSource, wxml);
|
|
85
|
-
debug('html handle: %s', file);
|
|
86
|
-
noCachedCount++;
|
|
87
|
-
return {
|
|
88
|
-
key: cacheKey,
|
|
89
|
-
source,
|
|
90
|
-
};
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
94
|
-
}
|
|
95
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
96
|
-
let noCachedCount = 0;
|
|
97
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
98
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
99
|
-
const cacheKey = removeExt(file);
|
|
100
|
-
yield cache.process(cacheKey, () => {
|
|
101
|
-
const source = cache.get(cacheKey);
|
|
102
|
-
if (source) {
|
|
103
|
-
compilation.updateAsset(file, source);
|
|
104
|
-
debug('js cache hit: %s', file);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
const rawSource = originalSource.source().toString();
|
|
111
|
-
const mapFilename = `${file}.map`;
|
|
112
|
-
const hasMap = Boolean(assets[mapFilename]);
|
|
113
|
-
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
114
|
-
generateMap: hasMap,
|
|
115
|
-
});
|
|
116
|
-
const source = new ConcatSource(code);
|
|
117
|
-
compilation.updateAsset(file, source);
|
|
118
|
-
onUpdate(file, rawSource, code);
|
|
119
|
-
debug('js handle: %s', file);
|
|
120
|
-
noCachedCount++;
|
|
121
|
-
if (hasMap && map) {
|
|
122
|
-
const source = new RawSource(map.toString());
|
|
123
|
-
compilation.updateAsset(mapFilename, source);
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
key: cacheKey,
|
|
127
|
-
source,
|
|
128
|
-
};
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
132
|
-
}
|
|
133
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
134
|
-
let noCachedCount = 0;
|
|
135
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
136
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
137
|
-
const rawSource = originalSource.source().toString();
|
|
138
|
-
const hash = cache.computeHash(rawSource);
|
|
139
|
-
const cacheKey = file;
|
|
140
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
141
|
-
yield cache.process(cacheKey, () => {
|
|
142
|
-
const source = cache.get(cacheKey);
|
|
143
|
-
if (source) {
|
|
144
|
-
compilation.updateAsset(file, source);
|
|
145
|
-
debug('css cache hit: %s', file);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
const css = yield styleHandler(rawSource, {
|
|
152
|
-
isMainChunk: mainCssChunkMatcher(file, this.appType),
|
|
153
|
-
});
|
|
154
|
-
const source = new ConcatSource(css);
|
|
155
|
-
compilation.updateAsset(file, source);
|
|
156
|
-
onUpdate(file, rawSource, css);
|
|
157
|
-
debug('css handle: %s', file);
|
|
158
|
-
noCachedCount++;
|
|
159
|
-
return {
|
|
160
|
-
key: cacheKey,
|
|
161
|
-
source,
|
|
162
|
-
};
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
166
|
-
}
|
|
167
|
-
debug('end');
|
|
168
|
-
onEnd();
|
|
169
|
-
}));
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export { UnifiedWebpackPluginV5 as U };
|