weapp-tailwindcss 5.4.2 → 5.5.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 +13 -1
- package/README.zh-CN.md +13 -1
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/capability-profile.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/web-plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-handler-options.d.ts +32 -0
- package/dist/bundlers/vite/{generate-bundle/css-output.d.ts → css-output.d.ts} +1 -1
- package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +2 -32
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -5
- package/dist/bundlers/vite/shared/create-css-only-plugins-runtime.d.ts +3 -0
- package/dist/cache-CBJFB1HN.cjs +223 -0
- package/dist/compiler/events.d.ts +32 -0
- package/dist/compiler/host.d.ts +13 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/runtime-state.d.ts +17 -0
- package/dist/compiler-B0YSc0DY.js +4877 -0
- package/dist/{wxml-o-CUulAM.cjs → compiler-D2ZJc3uA.cjs} +3649 -283
- package/dist/core.cjs +6 -3
- package/dist/core.d.ts +2 -0
- package/dist/core.js +4 -4
- package/dist/defaults-B5ep0ojb.js +120 -0
- package/dist/defaults-BI9j1znS.cjs +156 -0
- package/dist/defaults.cjs +5 -121
- package/dist/defaults.js +1 -116
- package/dist/final-css-cleanup-B0HUBtiE.js +308 -0
- package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
- package/dist/{generator-WlhrtNa3.cjs → generator-DsrQ9txU.cjs} +62 -5
- package/dist/{generator-BjK5PRR-.js → generator-DyXTBPmE.js} +47 -2
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-ChecVI6A.cjs → gulp-C9ENAx3f.cjs} +30 -28
- package/dist/{gulp-D6LcfRz_.js → gulp-DXeQfvVC.js} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-afnWvy7u.cjs → hmr-timing-Cz4IesEM.cjs} +6 -229
- package/dist/{hmr-timing-CqDfjvqE.js → hmr-timing-DNxQm-bN.js} +6 -1258
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-DxPFMGxz.cjs → pipeline-helpers-CSGnR5gh.cjs} +6 -5
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +4 -4
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/runtime-state-BBQcA0n5.cjs +54 -0
- package/dist/{source-candidate-scan-signature-FywFU3Rg.cjs → scoped-generator-TVjEaOeP.cjs} +5 -123
- package/dist/{source-candidate-scan-signature-BVScymyM.js → scoped-generator-kRj_5Axx.js} +4 -92
- package/dist/source-candidate-scan-signature-B7cUxqqX.cjs +129 -0
- package/dist/source-candidate-scan-signature-CsP4BQNa.js +92 -0
- package/dist/style-injector/internal.d.ts +1 -1
- package/dist/style-injector/vite-web.d.ts +3 -0
- package/dist/{tailwindcss-9xmoCkaR.js → tailwindcss-BK9S7zuq.js} +1 -2
- package/dist/{tailwindcss-D3jltF7M.cjs → tailwindcss-C-jBBQfw.cjs} +8 -9
- package/dist/{transform-DQhgAarN.js → transform-CfOzh007.js} +3 -3
- package/dist/{transform-C6k9zTQR.cjs → transform-DUPOPZ54.cjs} +27 -27
- package/dist/uni-app-x/vite/style-source.d.ts +11 -0
- package/dist/{v4-generation-core-CPKNwzjz.cjs → v4-generation-core-CRNUU_Rr.cjs} +29 -1172
- package/dist/vite/web.cjs +27 -0
- package/dist/vite/web.d.ts +1 -0
- package/dist/vite/web.js +25 -0
- package/dist/{vite-D3aCtpmv.js → vite-BXe-axax.js} +263 -3587
- package/dist/{vite-D-gmOkPN.cjs → vite-D_mAIfTU.cjs} +514 -3798
- package/dist/vite-web.d.ts +4 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/web-B2Ea9K4B.cjs +4361 -0
- package/dist/web-Cv7ualrU.js +3796 -0
- package/dist/{webpack-B-6a8Z8F.js → webpack-7Um2GFtx.js} +13 -12
- package/dist/{webpack-yAne9ZYu.cjs → webpack-Ce04-btG.cjs} +51 -49
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +13 -4
- package/dist/cache-options-DavPxrhC.cjs +0 -16
- package/dist/cache-options-DwBtLwQe.js +0 -5
- package/dist/compiler-B-m9VGqj.cjs +0 -2316
- package/dist/compiler-BgMj2E5l.js +0 -2051
- package/dist/local-style-matcher-DRpFEu1s.cjs +0 -34
- package/dist/local-style-matcher-DsiI2wIc.js +0 -17
- package/dist/object-B-8IHefx.js +0 -47
- package/dist/object-DbHtAXRk.cjs +0 -58
- package/dist/wxml-CvKyV69S.js +0 -1822
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Bring Tailwind CSS to every platform. `weapp-tailwindcss` is the core compiler a
|
|
|
16
16
|
|
|
17
17
|
| Target | Recommended entry |
|
|
18
18
|
| --- | --- |
|
|
19
|
-
| Web / H5 | `weapp-tailwindcss/vite
|
|
19
|
+
| Web / H5 | `weapp-tailwindcss/vite/web` for plain Vite, or `weapp-tailwindcss/vite`, Webpack/Rspack integration |
|
|
20
20
|
| uni-app / uni-app x | Vite or Webpack integration selected by the framework build chain |
|
|
21
21
|
| Taro / Mpx / native mini programs | Vite, Webpack, Rspack, or Gulp integration |
|
|
22
22
|
| React Native / Expo | `@weapp-tailwindcss/react-native` |
|
|
@@ -24,6 +24,18 @@ Bring Tailwind CSS to every platform. `weapp-tailwindcss` is the core compiler a
|
|
|
24
24
|
|
|
25
25
|
Start with the [installation guide](https://tw.weapp.dev/docs/quick-start/install) or select a framework from the [documentation website](https://tw.weapp.dev/).
|
|
26
26
|
|
|
27
|
+
Plain Vite Web projects can use the dedicated entry to pin the Web target and avoid inheriting framework detection from an enclosing monorepo:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { WeappTailwindcssWeb } from 'weapp-tailwindcss/vite/web'
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
plugins: [WeappTailwindcssWeb()],
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The repository provides three canonical templates: [uni-app](../../templates/uni-app-tailwindcss-v4), [Taro Vite](../../templates/taro-vite-tailwindcss-v4), and [weapp-vite](../../templates/weapp-vite-tailwindcss-v4). Each can be installed independently and verified with the template smoke build.
|
|
38
|
+
|
|
27
39
|
## Tailwind CSS 4 entry
|
|
28
40
|
|
|
29
41
|
Your CSS entry must be imported by the application build graph. Configure `cssEntries` with absolute paths resolved from the project root when stable entry discovery is required, but do not treat it as a replacement for importing the CSS file.
|
package/README.zh-CN.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
| 目标 | 推荐入口 |
|
|
18
18
|
| --- | --- |
|
|
19
|
-
| Web / H5 | `weapp-tailwindcss/vite
|
|
19
|
+
| Web / H5 | `weapp-tailwindcss/vite/web`(普通 Vite)或 `weapp-tailwindcss/vite`、Webpack/Rspack 集成 |
|
|
20
20
|
| uni-app / uni-app x | 按框架构建链选择 Vite 或 Webpack 集成 |
|
|
21
21
|
| Taro / Mpx / 原生小程序 | Vite、Webpack、Rspack 或 Gulp 集成 |
|
|
22
22
|
| React Native / Expo | `@weapp-tailwindcss/react-native` |
|
|
@@ -24,6 +24,18 @@
|
|
|
24
24
|
|
|
25
25
|
从[安装指南](https://tw.weapp.dev/zh-cn/docs/quick-start/install)开始,或在[中文官网](https://tw.weapp.dev/zh-cn/)按框架选择接入方式。
|
|
26
26
|
|
|
27
|
+
普通 Vite Web 项目可以使用轻量入口,固定 Web target,不会因为 monorepo 上层依赖而误判为小程序框架:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { WeappTailwindcssWeb } from 'weapp-tailwindcss/vite/web'
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
plugins: [WeappTailwindcssWeb()],
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
仓库提供 [uni-app](../../templates/uni-app-tailwindcss-v4)、[Taro Vite](../../templates/taro-vite-tailwindcss-v4) 和 [weapp-vite](../../templates/weapp-vite-tailwindcss-v4) 三个 canonical 模板,可直接安装并运行 smoke 构建。
|
|
38
|
+
|
|
27
39
|
## Tailwind CSS 4 入口
|
|
28
40
|
|
|
29
41
|
CSS 入口必须被应用构建图实际引入。需要稳定识别入口时,通过 `cssEntries` 配置从项目根目录解析出的绝对路径,但不要把它当成 CSS import 的替代品。
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function hasEmptyCssBlockCandidate(css: string): boolean;
|
|
2
2
|
export declare function finalizeMiniProgramCssStructure(css: string): string;
|
|
@@ -2,6 +2,7 @@ import type { GenerateCssByGeneratorOptions, GenerateCssByGeneratorResult } from
|
|
|
2
2
|
import type { CompilationDependencyChange, CompilerShadowReport, CssStage, GenerationArtifact, SourceScope } from '../../compiler/index.js';
|
|
3
3
|
import type { InternalUserDefinedOptions } from '../../types/index.js';
|
|
4
4
|
export interface TailwindV4GenerationCoreInput extends GenerateCssByGeneratorOptions {
|
|
5
|
+
compilerMode?: 'legacy' | undefined;
|
|
5
6
|
compilationChanges?: CompilationDependencyChange[] | undefined;
|
|
6
7
|
frameworkPostcssOwner?: InternalUserDefinedOptions | undefined;
|
|
7
8
|
cssStage?: CssStage | undefined;
|
|
@@ -2,6 +2,7 @@ import type { ViteFrameworkName } from '../framework-selector.js';
|
|
|
2
2
|
import type { UserDefinedOptions } from '../../types/index.js';
|
|
3
3
|
export interface ViteCapabilityProfile {
|
|
4
4
|
name: 'framework' | 'generic-web';
|
|
5
|
+
cssOnly?: boolean;
|
|
5
6
|
frameworkName: ViteFrameworkName;
|
|
6
7
|
generatorTarget: 'web' | 'weapp' | 'app' | undefined;
|
|
7
8
|
platformFamily: 'web' | 'native-app' | 'mini-program' | 'unknown';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { InternalUserDefinedOptions, IStyleHandlerOptions } from '../../types/index.js';
|
|
2
|
+
type CssHandlerOptions = IStyleHandlerOptions & {
|
|
3
|
+
postcssOptions: {
|
|
4
|
+
options: {
|
|
5
|
+
from: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
majorVersion?: 4 | undefined;
|
|
9
|
+
sourceOptions?: {
|
|
10
|
+
outputRoot?: string | undefined;
|
|
11
|
+
requestFile?: string | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
};
|
|
14
|
+
interface CssHandlerOptionsCacheOptions {
|
|
15
|
+
getAppType: () => InternalUserDefinedOptions['appType'];
|
|
16
|
+
mainCssChunkMatcher: InternalUserDefinedOptions['mainCssChunkMatcher'];
|
|
17
|
+
getMajorVersion: () => number | undefined;
|
|
18
|
+
getOutputRoot?: (() => string | undefined) | undefined;
|
|
19
|
+
getExtraOptions?: ((file: string) => Partial<IStyleHandlerOptions>) | undefined;
|
|
20
|
+
getDynamicCssOptions?: (() => Partial<IStyleHandlerOptions>) | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface CssHandlerOptionsCache {
|
|
23
|
+
getCssHandlerOptions: (file: string) => CssHandlerOptions;
|
|
24
|
+
getCssUserHandlerOptions: (file: string) => CssHandlerOptions;
|
|
25
|
+
}
|
|
26
|
+
export declare function resolveViteCssHandlerExtraOptions(file: string): {
|
|
27
|
+
isMainChunk: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
isMainChunk?: never;
|
|
30
|
+
};
|
|
31
|
+
export declare function createCssHandlerOptionsCache(options: CssHandlerOptionsCacheOptions): CssHandlerOptionsCache;
|
|
32
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InternalUserDefinedOptions } from '
|
|
1
|
+
import type { InternalUserDefinedOptions } from '../../types/index.js';
|
|
2
2
|
export declare const SOURCE_STYLE_OUTPUT_EXT_RE: RegExp;
|
|
3
3
|
export declare const CSS_SOURCE_OUTPUT_EXT_RE: RegExp;
|
|
4
4
|
export declare function resolveMiniProgramStyleOutputExtension(options?: {
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
postcssOptions: {
|
|
4
|
-
options: {
|
|
5
|
-
from: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
majorVersion?: 4 | undefined;
|
|
9
|
-
sourceOptions?: {
|
|
10
|
-
outputRoot?: string | undefined;
|
|
11
|
-
requestFile?: string | undefined;
|
|
12
|
-
} | undefined;
|
|
13
|
-
};
|
|
14
|
-
interface CssHandlerOptionsCacheOptions {
|
|
15
|
-
getAppType: () => InternalUserDefinedOptions['appType'];
|
|
16
|
-
mainCssChunkMatcher: InternalUserDefinedOptions['mainCssChunkMatcher'];
|
|
17
|
-
getMajorVersion: () => number | undefined;
|
|
18
|
-
getOutputRoot?: (() => string | undefined) | undefined;
|
|
19
|
-
getExtraOptions?: ((file: string) => Partial<IStyleHandlerOptions>) | undefined;
|
|
20
|
-
getDynamicCssOptions?: (() => Partial<IStyleHandlerOptions>) | undefined;
|
|
21
|
-
}
|
|
22
|
-
export interface CssHandlerOptionsCache {
|
|
23
|
-
getCssHandlerOptions: (file: string) => CssHandlerOptions;
|
|
24
|
-
getCssUserHandlerOptions: (file: string) => CssHandlerOptions;
|
|
25
|
-
}
|
|
26
|
-
export declare function resolveViteCssHandlerExtraOptions(file: string): {
|
|
27
|
-
isMainChunk: boolean;
|
|
28
|
-
} | {
|
|
29
|
-
isMainChunk?: never;
|
|
30
|
-
};
|
|
31
|
-
export declare function createCssHandlerOptionsCache(options: CssHandlerOptionsCacheOptions): CssHandlerOptionsCache;
|
|
32
|
-
export {};
|
|
1
|
+
export { createCssHandlerOptionsCache, resolveViteCssHandlerExtraOptions } from '../css-handler-options.js';
|
|
2
|
+
export type { CssHandlerOptionsCache } from '../css-handler-options.js';
|
|
@@ -18,7 +18,7 @@ export interface FinalizeGenerateBundleOptions {
|
|
|
18
18
|
formatIteration: number;
|
|
19
19
|
generatorCandidateSignature: string;
|
|
20
20
|
generatorRuntime: Set<string>;
|
|
21
|
-
getCssHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('
|
|
21
|
+
getCssHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('../../css-handler-options.js').createCssHandlerOptionsCache>['getCssHandlerOptions']>;
|
|
22
22
|
getSourceCandidateSourcesForEntries: GenerateBundleContext['getSourceCandidateSourcesForEntries'];
|
|
23
23
|
getSourceCandidatesForEntries: GenerateBundleContext['getSourceCandidatesForEntries'];
|
|
24
24
|
getViteCssCacheStats: GenerateBundleContext['getViteCssCacheStats'];
|
|
@@ -25,8 +25,8 @@ interface ProcessRememberedCssReplayOptions {
|
|
|
25
25
|
emitOrReplayCssAsset: (fileName: string, source: string) => OutputAsset | undefined;
|
|
26
26
|
generatorRuntime: Set<string>;
|
|
27
27
|
generatorPlatform?: string | undefined;
|
|
28
|
-
getCssHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('
|
|
29
|
-
getCssUserHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('
|
|
28
|
+
getCssHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('../css-handler-options.js').createCssHandlerOptionsCache>['getCssHandlerOptions']>;
|
|
29
|
+
getCssUserHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('../css-handler-options.js').createCssHandlerOptionsCache>['getCssUserHandlerOptions']>;
|
|
30
30
|
getRememberedCssSignature?: ((file: string) => string | undefined) | undefined;
|
|
31
31
|
getRememberedCssSources?: (() => Iterable<[string, RememberedCssSource]>) | undefined;
|
|
32
32
|
frameworkRootImportShellTargetByFile?: ReadonlyMap<string, string> | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { resolveMiniProgramStyleOutputExtension as resolveMiniProgramStyleOutputExtension2, resolveReplayCssOutputFile as resolveReplayCssOutputFile2, resolveReplayCssOutputFileFromSourceRoot, resolveViteCssPipelineOutputFile as resolveViteCssPipelineOutputFile2, resolveViteCssPipelineOutputFileFromSourceFile } from '../css-output.js';
|
|
1
2
|
import { normalizeBundleFileNameKeysForTest } from './bundle-file-names.js';
|
|
2
|
-
import { resolveMiniProgramStyleOutputExtension as resolveMiniProgramStyleOutputExtension2, resolveReplayCssOutputFile as resolveReplayCssOutputFile2, resolveReplayCssOutputFileFromSourceRoot, resolveViteCssPipelineOutputFile as resolveViteCssPipelineOutputFile2, resolveViteCssPipelineOutputFileFromSourceFile } from './css-output.js';
|
|
3
3
|
import { resolveRememberedCssSourceForTest } from './remembered-css.js';
|
|
4
4
|
import { shouldKeepRootMiniProgramStyleAsImportShell as shouldKeepRootMiniProgramStyleAsImportShell2, shouldMoveRootMiniProgramStyleToImportShellOrigin as shouldMoveRootMiniProgramStyleToImportShellOrigin2 } from './root-style-output.js';
|
|
5
5
|
declare function createGenerateBundleHook(context: any): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
-
import type { CssHandlerOptionsCache } from '
|
|
2
|
+
import type { CssHandlerOptionsCache } from '../css-handler-options.js';
|
|
3
3
|
import type { GenerateBundleContext } from './types.js';
|
|
4
4
|
interface HandleUniAppXPostCssOptions {
|
|
5
5
|
bundle: Record<string, OutputAsset | OutputChunk>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OutputAsset, OutputChunk } from 'rollup';
|
|
2
2
|
import type { GenerateBundleContext, GenerateBundleThis } from './generate-bundle/types.js';
|
|
3
|
+
export { resolveMiniProgramStyleOutputExtension, resolveReplayCssOutputFile, resolveReplayCssOutputFileFromSourceRoot, resolveViteCssPipelineOutputFile, resolveViteCssPipelineOutputFileFromSourceFile } from './css-output.js';
|
|
3
4
|
export { normalizeBundleFileNameKeysForTest } from './generate-bundle/bundle-file-names.js';
|
|
4
|
-
export { resolveMiniProgramStyleOutputExtension, resolveReplayCssOutputFile, resolveReplayCssOutputFileFromSourceRoot, resolveViteCssPipelineOutputFile, resolveViteCssPipelineOutputFileFromSourceFile } from './generate-bundle/css-output.js';
|
|
5
5
|
export { resolveRememberedCssSourceForTest } from './generate-bundle/remembered-css.js';
|
|
6
6
|
export { shouldKeepRootMiniProgramStyleAsImportShell, shouldMoveRootMiniProgramStyleToImportShellOrigin } from './generate-bundle/root-style-output.js';
|
|
7
7
|
export type { GenerateBundleContext, GenerateBundleThis, RememberedCssSource } from './generate-bundle/types.js';
|
|
@@ -10,11 +10,7 @@ interface CreateViteRuntimeClassSetOptions {
|
|
|
10
10
|
debug: (format: string, ...args: unknown[]) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function createViteRuntimeClassSet(options: CreateViteRuntimeClassSetOptions): {
|
|
13
|
-
runtimeState:
|
|
14
|
-
tailwindRuntime: import("../../types/index.js").TailwindcssRuntimeLike;
|
|
15
|
-
readyPromise: Promise<void>;
|
|
16
|
-
refreshTailwindcssRuntime: (options?: import("../../types/index.js").RefreshTailwindcssRuntimeOptions) => Promise<import("../../types/index.js").TailwindcssRuntimeLike>;
|
|
17
|
-
};
|
|
13
|
+
runtimeState: import("../../compiler/runtime-state.js").CompilerRuntimeState;
|
|
18
14
|
refreshRuntimeState: (force: boolean) => Promise<void>;
|
|
19
15
|
ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
|
|
20
16
|
ensureBundleRuntimeClassSet: (snapshot: BundleSnapshot, forceRefresh?: boolean, options?: {
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
//#region src/compiler/runtime-build-state.ts
|
|
2
|
+
function invertLinkedByEntry(linkedByEntry) {
|
|
3
|
+
const dependentsByLinkedFile = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
|
|
5
|
+
let dependents = dependentsByLinkedFile.get(linkedFile);
|
|
6
|
+
if (!dependents) {
|
|
7
|
+
dependents = /* @__PURE__ */ new Set();
|
|
8
|
+
dependentsByLinkedFile.set(linkedFile, dependents);
|
|
9
|
+
}
|
|
10
|
+
dependents.add(entryFile);
|
|
11
|
+
}
|
|
12
|
+
return dependentsByLinkedFile;
|
|
13
|
+
}
|
|
14
|
+
function replaceMapEntries(target, source) {
|
|
15
|
+
target.clear();
|
|
16
|
+
for (const [key, value] of source) target.set(key, value);
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
19
|
+
function mergeMapEntries(target, source) {
|
|
20
|
+
for (const [key, value] of source) target.set(key, value);
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
function createRuntimeCompilationBuildState() {
|
|
24
|
+
return {
|
|
25
|
+
iteration: 0,
|
|
26
|
+
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
27
|
+
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
28
|
+
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
29
|
+
linkedByEntry: /* @__PURE__ */ new Map(),
|
|
30
|
+
dependentsByLinkedFile: /* @__PURE__ */ new Map(),
|
|
31
|
+
bundleMarkupCandidatesByFile: /* @__PURE__ */ new Map(),
|
|
32
|
+
generatorCandidateSignature: void 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function updateRuntimeCompilationBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
36
|
+
const incremental = options.incremental === true;
|
|
37
|
+
removeRuntimeCompilationBuildStateFiles(state, snapshot.removedFiles);
|
|
38
|
+
state.iteration += 1;
|
|
39
|
+
state.sourceHashByFile = incremental ? mergeMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile) : replaceMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile);
|
|
40
|
+
state.runtimeAffectingSignatureByFile.clear();
|
|
41
|
+
state.runtimeAffectingHashByFile = incremental ? mergeMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile) : replaceMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile);
|
|
42
|
+
state.linkedByEntry = incremental ? mergeMapEntries(state.linkedByEntry, linkedByEntry) : replaceMapEntries(state.linkedByEntry, linkedByEntry);
|
|
43
|
+
state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
|
|
44
|
+
}
|
|
45
|
+
function removeRuntimeCompilationBuildStateFiles(state, files) {
|
|
46
|
+
const removedFiles = new Set(files);
|
|
47
|
+
if (removedFiles.size === 0) return;
|
|
48
|
+
for (const file of removedFiles) {
|
|
49
|
+
state.sourceHashByFile.delete(file);
|
|
50
|
+
state.runtimeAffectingSignatureByFile.delete(file);
|
|
51
|
+
state.runtimeAffectingHashByFile.delete(file);
|
|
52
|
+
state.bundleMarkupCandidatesByFile.delete(file);
|
|
53
|
+
state.linkedByEntry.delete(file);
|
|
54
|
+
}
|
|
55
|
+
for (const linkedFiles of state.linkedByEntry.values()) for (const file of removedFiles) linkedFiles.delete(file);
|
|
56
|
+
state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
|
|
57
|
+
}
|
|
58
|
+
function resetRuntimeCompilationBuildState(state) {
|
|
59
|
+
state.iteration = 0;
|
|
60
|
+
state.sourceHashByFile.clear();
|
|
61
|
+
state.runtimeAffectingSignatureByFile.clear();
|
|
62
|
+
state.runtimeAffectingHashByFile.clear();
|
|
63
|
+
state.linkedByEntry.clear();
|
|
64
|
+
state.dependentsByLinkedFile.clear();
|
|
65
|
+
state.bundleMarkupCandidatesByFile.clear();
|
|
66
|
+
state.generatorCandidateSignature = void 0;
|
|
67
|
+
}
|
|
68
|
+
function createRuntimeCompilationAffectingSignature(snapshot, computeHash) {
|
|
69
|
+
const entries = [...snapshot.runtimeAffectingHashByFile].sort(([first], [second]) => first.localeCompare(second)).map(([file, hash]) => `${file}:${hash}`);
|
|
70
|
+
return entries.length === 0 ? "runtime-affecting:0" : `runtime-affecting:1:${computeHash(entries.join("\n"))}`;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/compiler/runtime-snapshot.ts
|
|
74
|
+
function createChangedByType() {
|
|
75
|
+
return {
|
|
76
|
+
html: /* @__PURE__ */ new Set(),
|
|
77
|
+
js: /* @__PURE__ */ new Set(),
|
|
78
|
+
css: /* @__PURE__ */ new Set(),
|
|
79
|
+
other: /* @__PURE__ */ new Set()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function createProcessFiles() {
|
|
83
|
+
return {
|
|
84
|
+
html: /* @__PURE__ */ new Set(),
|
|
85
|
+
js: /* @__PURE__ */ new Set(),
|
|
86
|
+
css: /* @__PURE__ */ new Set()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function markProcessFile(type, file, processFiles) {
|
|
90
|
+
if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
|
|
91
|
+
}
|
|
92
|
+
function markFilesByEntryType(files, entriesByFile, target) {
|
|
93
|
+
for (const file of files ?? []) {
|
|
94
|
+
const entry = entriesByFile.get(file);
|
|
95
|
+
if (entry) target[entry.type].add(file);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function createRuntimeCompilationSnapshot(entries, options = {}) {
|
|
99
|
+
const changedByType = createChangedByType();
|
|
100
|
+
const runtimeAffectingChangedByType = createChangedByType();
|
|
101
|
+
const processFiles = createProcessFiles();
|
|
102
|
+
const entriesByFile = new Map(entries.map((entry) => [entry.file, entry]));
|
|
103
|
+
markFilesByEntryType(options.changedFiles, entriesByFile, changedByType);
|
|
104
|
+
markFilesByEntryType(options.runtimeAffectingChangedFiles, entriesByFile, runtimeAffectingChangedByType);
|
|
105
|
+
for (const file of options.processFiles ?? []) {
|
|
106
|
+
const entry = entriesByFile.get(file);
|
|
107
|
+
if (entry) markProcessFile(entry.type, file, processFiles);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
entries,
|
|
111
|
+
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
112
|
+
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
113
|
+
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
114
|
+
hasOmittedKnownFiles: options.hasOmittedKnownFiles === true,
|
|
115
|
+
removedFiles: new Set([...options.removedFiles ?? []].filter((file) => !entriesByFile.has(file))),
|
|
116
|
+
changedByType,
|
|
117
|
+
runtimeAffectingChangedByType,
|
|
118
|
+
processFiles,
|
|
119
|
+
linkedImpactsByEntry: /* @__PURE__ */ new Map()
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function buildRuntimeCompilationSnapshot(entries, state, options) {
|
|
123
|
+
const snapshot = createRuntimeCompilationSnapshot(entries, {
|
|
124
|
+
hasOmittedKnownFiles: options.hasOmittedKnownFiles,
|
|
125
|
+
removedFiles: options.removedFiles
|
|
126
|
+
});
|
|
127
|
+
const firstRun = state.iteration === 0 && state.sourceHashByFile.size === 0;
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
const { file, source, type } = entry;
|
|
130
|
+
const hash = options.computeHash(source);
|
|
131
|
+
snapshot.sourceHashByFile.set(file, hash);
|
|
132
|
+
const previousHash = state.sourceHashByFile.get(file);
|
|
133
|
+
const changed = previousHash == null || previousHash !== hash;
|
|
134
|
+
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
135
|
+
const runtimeAffectingHash = !changed && previousRuntimeAffectingHash != null ? previousRuntimeAffectingHash : (() => {
|
|
136
|
+
const signature = options.createRuntimeAffectingSignature(source, type);
|
|
137
|
+
snapshot.runtimeAffectingSignatureByFile.set(file, signature);
|
|
138
|
+
return options.computeHash(signature);
|
|
139
|
+
})();
|
|
140
|
+
snapshot.runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
141
|
+
if (changed) snapshot.changedByType[type].add(file);
|
|
142
|
+
if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) snapshot.runtimeAffectingChangedByType[type].add(file);
|
|
143
|
+
if (options.forceAll || firstRun) markProcessFile(type, file, snapshot.processFiles);
|
|
144
|
+
else if (type === "html") snapshot.processFiles.html.add(file);
|
|
145
|
+
else if (changed && (type === "js" || type === "css")) snapshot.processFiles[type].add(file);
|
|
146
|
+
}
|
|
147
|
+
if (!options.forceAll && !firstRun) for (const changedFile of snapshot.changedByType.js) {
|
|
148
|
+
const dependents = state.dependentsByLinkedFile.get(changedFile);
|
|
149
|
+
if (!dependents) continue;
|
|
150
|
+
for (const entryFile of dependents) {
|
|
151
|
+
snapshot.processFiles.js.add(entryFile);
|
|
152
|
+
let impacts = snapshot.linkedImpactsByEntry.get(entryFile);
|
|
153
|
+
if (!impacts) {
|
|
154
|
+
impacts = /* @__PURE__ */ new Set();
|
|
155
|
+
snapshot.linkedImpactsByEntry.set(entryFile, impacts);
|
|
156
|
+
}
|
|
157
|
+
impacts.add(changedFile);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return snapshot;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/bundlers/shared/cache.ts
|
|
164
|
+
async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSource, hash, readCache, applyResult, transform, onCacheHit }) {
|
|
165
|
+
let cacheHit = false;
|
|
166
|
+
const result = await cache.process({
|
|
167
|
+
key: cacheKey,
|
|
168
|
+
hashKey,
|
|
169
|
+
rawSource,
|
|
170
|
+
hash,
|
|
171
|
+
resolveCache: readCache,
|
|
172
|
+
async onCacheHit(value) {
|
|
173
|
+
cacheHit = true;
|
|
174
|
+
await applyResult(value, { cacheHit: true });
|
|
175
|
+
onCacheHit?.();
|
|
176
|
+
},
|
|
177
|
+
transform
|
|
178
|
+
});
|
|
179
|
+
if (!cacheHit) await applyResult(result, { cacheHit: false });
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
Object.defineProperty(exports, "buildRuntimeCompilationSnapshot", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function() {
|
|
185
|
+
return buildRuntimeCompilationSnapshot;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, "createRuntimeCompilationAffectingSignature", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function() {
|
|
191
|
+
return createRuntimeCompilationAffectingSignature;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, "createRuntimeCompilationBuildState", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function() {
|
|
197
|
+
return createRuntimeCompilationBuildState;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, "processCachedTask", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function() {
|
|
203
|
+
return processCachedTask;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, "removeRuntimeCompilationBuildStateFiles", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function() {
|
|
209
|
+
return removeRuntimeCompilationBuildStateFiles;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "resetRuntimeCompilationBuildState", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function() {
|
|
215
|
+
return resetRuntimeCompilationBuildState;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, "updateRuntimeCompilationBuildState", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function() {
|
|
221
|
+
return updateRuntimeCompilationBuildState;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type CompilationEvent = {
|
|
2
|
+
type: 'source-updated';
|
|
3
|
+
id: string;
|
|
4
|
+
source: string;
|
|
5
|
+
sourceKind?: 'css' | 'template' | 'script' | 'config' | 'asset';
|
|
6
|
+
} | {
|
|
7
|
+
type: 'source-removed';
|
|
8
|
+
id: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'css-entry';
|
|
11
|
+
id: string;
|
|
12
|
+
source: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'bundle-emitted';
|
|
15
|
+
file: string;
|
|
16
|
+
artifact?: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'hot-update';
|
|
19
|
+
id: string;
|
|
20
|
+
mutation: 'template' | 'script' | 'style' | 'content' | 'subpackage' | 'root-style';
|
|
21
|
+
} | {
|
|
22
|
+
type: 'config-changed';
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
export type CompilationEventListener = (event: CompilationEvent) => void | Promise<void>;
|
|
26
|
+
export interface CompilationEventBus {
|
|
27
|
+
readonly revision: number;
|
|
28
|
+
emit: (event: CompilationEvent) => Promise<number>;
|
|
29
|
+
subscribe: (listener: CompilationEventListener) => () => void;
|
|
30
|
+
clear: () => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createCompilationEventBus(): CompilationEventBus;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GenerationArtifact } from './types.js';
|
|
2
|
+
export interface CompilerHost {
|
|
3
|
+
readSource: (id: string) => string | undefined | Promise<string | undefined>;
|
|
4
|
+
resolveModule?: (specifier: string, importer: string) => string | undefined | Promise<string | undefined>;
|
|
5
|
+
getModuleInfo?: (id: string) => unknown | undefined | Promise<unknown | undefined>;
|
|
6
|
+
watchSource?: (listener: (event: CompilerHostSourceEvent) => void) => (() => void) | void;
|
|
7
|
+
emitArtifact?: (artifact: GenerationArtifact) => void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CompilerHostSourceEvent {
|
|
10
|
+
id: string;
|
|
11
|
+
type: 'added' | 'changed' | 'removed';
|
|
12
|
+
source?: string | undefined;
|
|
13
|
+
}
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export * from './compilation-scope-graph.js';
|
|
|
5
5
|
export * from './compilation-session-pool.js';
|
|
6
6
|
export * from './composition.js';
|
|
7
7
|
export * from './emission-plan.js';
|
|
8
|
+
export * from './events.js';
|
|
8
9
|
export * from './framework-compiler-session.js';
|
|
10
|
+
export * from './host.js';
|
|
9
11
|
export * from './invalidation.js';
|
|
10
12
|
export * from './mode.js';
|
|
11
13
|
export * from './owner-lifecycle.js';
|
|
@@ -13,6 +15,7 @@ export * from './platform-adapter.js';
|
|
|
13
15
|
export * from './runtime-affecting-signature.js';
|
|
14
16
|
export * from './runtime-build-state.js';
|
|
15
17
|
export * from './runtime-snapshot.js';
|
|
18
|
+
export * from './runtime-state.js';
|
|
16
19
|
export * from './scope-planner.js';
|
|
17
20
|
export * from './semantic-css.js';
|
|
18
21
|
export * from './session.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CompilationEventBus } from './events.js';
|
|
2
|
+
import type { RefreshTailwindcssRuntimeOptions, TailwindcssRuntimeLike } from '../types/index.js';
|
|
3
|
+
export interface CompilerRuntimeState {
|
|
4
|
+
tailwindRuntime: TailwindcssRuntimeLike;
|
|
5
|
+
readyPromise: Promise<void>;
|
|
6
|
+
refreshTailwindcssRuntime: (options?: RefreshTailwindcssRuntimeOptions) => Promise<TailwindcssRuntimeLike>;
|
|
7
|
+
events: CompilationEventBus;
|
|
8
|
+
readonly revision: number;
|
|
9
|
+
dispose: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateCompilerRuntimeStateOptions {
|
|
12
|
+
tailwindRuntime: TailwindcssRuntimeLike;
|
|
13
|
+
readyPromise?: Promise<void>;
|
|
14
|
+
refreshTailwindcssRuntime: (options?: RefreshTailwindcssRuntimeOptions) => Promise<TailwindcssRuntimeLike>;
|
|
15
|
+
events?: CompilationEventBus;
|
|
16
|
+
}
|
|
17
|
+
export declare function createCompilerRuntimeState(options: CreateCompilerRuntimeStateOptions): CompilerRuntimeState;
|