weapp-tailwindcss 5.5.3 → 5.5.4
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/compiler/cache-telemetry.d.ts +30 -0
- package/dist/compiler/candidate-index.d.ts +3 -0
- package/dist/compiler/capabilities.d.ts +37 -0
- package/dist/compiler/events.d.ts +38 -1
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/runtime-state.d.ts +2 -1
- package/dist/{compiler-C9X5Afn4.js → compiler-CJ5yX-on.js} +70 -22
- package/dist/{compiler-DMPaUcH6.cjs → compiler-DFROuh5Z.cjs} +69 -22
- package/dist/core/compiler/types.d.ts +2 -0
- package/dist/core.cjs +57 -8
- package/dist/core.d.ts +3 -0
- package/dist/core.js +56 -7
- package/dist/{css-imports-DXplvodk.cjs → css-imports-_5cwJnx-.cjs} +1 -1
- package/dist/{generator-C2aWns8n.js → generator-BgbYHNgD.js} +71 -55
- package/dist/{generator-BoZIiZD5.cjs → generator-RK2HtgOb.cjs} +71 -55
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-D50z06nw.cjs → gulp-BS7fTmyj.cjs} +16 -6
- package/dist/{gulp-COAAztkm.js → gulp-nl-2p5Dw.js} +14 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CTk1uZr9.js → hmr-timing-BfxWwMeT.js} +3 -3
- package/dist/{hmr-timing-DK0MJKpl.cjs → hmr-timing-D45cTIzM.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-BzjYXNTa.cjs → pipeline-helpers-BEhISt4D.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{runtime-state-BBQcA0n5.cjs → runtime-state-XYSycuGu.cjs} +6 -0
- package/dist/{scoped-generator-CTkuf9Ae.cjs → scoped-generator-DccPwmJT.cjs} +3 -3
- package/dist/{scoped-generator-C21A7fis.js → scoped-generator-Dqq2iLky.js} +3 -3
- package/dist/{source-candidate-scan-signature-BB5DfjO2.js → source-candidate-scan-signature-BJkQJtRM.js} +2 -2
- package/dist/{source-candidate-scan-signature-4mZDDaKT.cjs → source-candidate-scan-signature-CnUlGWhP.cjs} +2 -2
- package/dist/{tailwindcss-Bji4u8In.cjs → tailwindcss-B03BGeTO.cjs} +1 -1
- package/dist/{tailwindcss-c4PkOe1F.js → tailwindcss-o3Xe-o7M.js} +1 -1
- package/dist/{transform-DmLonqPE.js → transform-BVH7iLHn.js} +3 -3
- package/dist/{transform-Cy0ddBWf.cjs → transform-MIhriZRr.cjs} +3 -3
- package/dist/{v4-generation-core-DQeiq-g1.cjs → v4-generation-core-BvW2aK23.cjs} +3 -3
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-OG66oLpb.cjs → vite-4RznbXVI.cjs} +9 -9
- package/dist/{vite-CaUxtQx5.js → vite-hGECCqfq.js} +8 -8
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +6 -6
- package/dist/{web-Bd-9OHFE.js → web-0FAisq6H.js} +50 -13
- package/dist/{web-CZKIefdl.cjs → web-DQZ27KWH.cjs} +53 -16
- package/dist/{webpack-Cyvq3H7Z.js → webpack-8cQlXIo4.js} +16 -6
- package/dist/{webpack-DJGgU27Y.cjs → webpack-DOQ_3ViW.cjs} +19 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type CacheInvalidationReason = 'source-change' | 'config-change' | 'runtime-change' | 'platform-change' | 'manual-clear' | 'capacity-eviction';
|
|
2
|
+
export interface CacheTelemetry {
|
|
3
|
+
layer: 'source-scan' | 'candidate-index' | 'tailwind-generation' | 'postcss-result' | 'asset-emission';
|
|
4
|
+
keyFingerprint: string;
|
|
5
|
+
hit: boolean;
|
|
6
|
+
invalidationReason?: CacheInvalidationReason;
|
|
7
|
+
evicted?: boolean;
|
|
8
|
+
entries?: number;
|
|
9
|
+
memoryBytes?: number;
|
|
10
|
+
revision?: number;
|
|
11
|
+
operationId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CacheTelemetryCollector {
|
|
14
|
+
record: (entry: CacheTelemetry) => void;
|
|
15
|
+
snapshot: () => readonly CacheTelemetry[];
|
|
16
|
+
clear: () => void;
|
|
17
|
+
hitRate: (layer?: CacheTelemetry['layer']) => number;
|
|
18
|
+
summary: (layer?: CacheTelemetry['layer']) => readonly CacheTelemetrySummary[];
|
|
19
|
+
}
|
|
20
|
+
export interface CacheTelemetrySummary {
|
|
21
|
+
layer: CacheTelemetry['layer'];
|
|
22
|
+
samples: number;
|
|
23
|
+
hits: number;
|
|
24
|
+
misses: number;
|
|
25
|
+
invalidations: number;
|
|
26
|
+
evictions: number;
|
|
27
|
+
entries: number;
|
|
28
|
+
memoryBytes: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function createCacheTelemetryCollector(): CacheTelemetryCollector;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { CacheTelemetryCollector } from './cache-telemetry.js';
|
|
1
2
|
import type { CandidateChange } from './types.js';
|
|
2
3
|
export declare class CandidateIndex {
|
|
4
|
+
private readonly telemetry?;
|
|
3
5
|
private readonly candidatesBySource;
|
|
6
|
+
constructor(telemetry?: CacheTelemetryCollector | undefined);
|
|
4
7
|
sync(sourceId: string, candidates: Iterable<string>): CandidateChange;
|
|
5
8
|
remove(sourceId: string): CandidateChange;
|
|
6
9
|
values(): Set<string>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CompilationDiagnosticEvent, CompilationEventListener } from './events.js';
|
|
2
|
+
export type AdapterCapability = 'compilerHost' | 'sourceCandidates' | 'cssGeneration' | 'assetEmission' | 'watchUpdate' | 'diagnostics';
|
|
3
|
+
export interface AdapterCapabilities {
|
|
4
|
+
adapter: string;
|
|
5
|
+
version: string;
|
|
6
|
+
capabilities: readonly AdapterCapability[];
|
|
7
|
+
}
|
|
8
|
+
export declare function createAdapterCapabilities(adapter: string, overrides?: Partial<AdapterCapabilities>): AdapterCapabilities;
|
|
9
|
+
export declare const BUILTIN_ADAPTER_CAPABILITIES: {
|
|
10
|
+
readonly vite: AdapterCapabilities;
|
|
11
|
+
readonly webpack: AdapterCapabilities;
|
|
12
|
+
readonly rspack: AdapterCapabilities;
|
|
13
|
+
readonly gulp: AdapterCapabilities;
|
|
14
|
+
};
|
|
15
|
+
export interface CompilerHost {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly capabilities: AdapterCapabilities;
|
|
18
|
+
revision: number;
|
|
19
|
+
dispose: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface SourceCandidateProvider {
|
|
22
|
+
scan: (sourceId: string, source: string) => Promise<ReadonlySet<string>> | ReadonlySet<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface CssGenerator {
|
|
25
|
+
generate: (candidates: ReadonlySet<string>) => Promise<string> | string;
|
|
26
|
+
}
|
|
27
|
+
export interface AssetEmitter {
|
|
28
|
+
emit: (assetId: string, content: string) => Promise<void> | void;
|
|
29
|
+
}
|
|
30
|
+
export interface WatchUpdateHandler {
|
|
31
|
+
update: (sourceId: string, source: string) => Promise<void> | void;
|
|
32
|
+
}
|
|
33
|
+
export interface DiagnosticReporter {
|
|
34
|
+
report: CompilationEventListener;
|
|
35
|
+
}
|
|
36
|
+
export declare function missingCapabilities(actual: AdapterCapabilities, required: readonly AdapterCapability[]): AdapterCapability[];
|
|
37
|
+
export declare function createCapabilityDiagnostic(capabilities: AdapterCapabilities, required: readonly AdapterCapability[]): CompilationDiagnosticEvent | undefined;
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const COMPILATION_EVENT_SCHEMA_VERSION = 1;
|
|
2
|
+
export interface CompilationDiagnosticEvent {
|
|
3
|
+
schemaVersion: typeof COMPILATION_EVENT_SCHEMA_VERSION;
|
|
4
|
+
type: 'diagnostic';
|
|
5
|
+
timestamp: string;
|
|
6
|
+
projectId?: string;
|
|
7
|
+
compilerId?: string;
|
|
8
|
+
adapter?: string;
|
|
9
|
+
phase: 'scan' | 'candidate' | 'generate' | 'postcss' | 'emit' | 'hmr';
|
|
10
|
+
revision?: number;
|
|
11
|
+
operationId?: string;
|
|
12
|
+
durationMs?: number;
|
|
13
|
+
cache?: {
|
|
14
|
+
hit: boolean;
|
|
15
|
+
key?: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
};
|
|
18
|
+
moduleId?: string;
|
|
19
|
+
sourceId?: string;
|
|
20
|
+
error?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
message: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
};
|
|
25
|
+
evidence?: string[];
|
|
26
|
+
}
|
|
27
|
+
export type CompilationEvent = CompilationDiagnosticEvent | {
|
|
2
28
|
type: 'source-updated';
|
|
3
29
|
id: string;
|
|
4
30
|
source: string;
|
|
@@ -29,4 +55,15 @@ export interface CompilationEventBus {
|
|
|
29
55
|
subscribe: (listener: CompilationEventListener) => () => void;
|
|
30
56
|
clear: () => void;
|
|
31
57
|
}
|
|
58
|
+
export interface CompilationEventReporter {
|
|
59
|
+
readonly events: readonly CompilationEvent[];
|
|
60
|
+
collect: CompilationEventListener;
|
|
61
|
+
toJSONL: () => string;
|
|
62
|
+
summarize: () => string;
|
|
63
|
+
clear: () => void;
|
|
64
|
+
}
|
|
65
|
+
export declare function createCompilationEventReporter(): CompilationEventReporter;
|
|
66
|
+
export declare function redactCompilationPath(value: string, root?: string): string;
|
|
67
|
+
export declare function serializeCompilationEvent(event: CompilationEvent): string;
|
|
68
|
+
export declare function summarizeCompilationEvents(events: readonly CompilationEvent[]): string;
|
|
32
69
|
export declare function createCompilationEventBus(): CompilationEventBus;
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './artifact.js';
|
|
2
|
+
export * from './cache-telemetry.js';
|
|
2
3
|
export * from './candidate-index.js';
|
|
4
|
+
export * from './capabilities.js';
|
|
3
5
|
export * from './compilation-change-coordinator.js';
|
|
4
6
|
export * from './compilation-scope-graph.js';
|
|
5
7
|
export * from './compilation-session-pool.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompilationEventBus } from './events.js';
|
|
1
|
+
import type { CompilationEventBus, CompilationEventListener } from './events.js';
|
|
2
2
|
import type { RefreshTailwindcssRuntimeOptions, TailwindcssRuntimeLike } from '../types/index.js';
|
|
3
3
|
export interface CompilerRuntimeState {
|
|
4
4
|
tailwindRuntime: TailwindcssRuntimeLike;
|
|
@@ -13,5 +13,6 @@ export interface CreateCompilerRuntimeStateOptions {
|
|
|
13
13
|
readyPromise?: Promise<void>;
|
|
14
14
|
refreshTailwindcssRuntime: (options?: RefreshTailwindcssRuntimeOptions) => Promise<TailwindcssRuntimeLike>;
|
|
15
15
|
events?: CompilationEventBus;
|
|
16
|
+
reporter?: CompilationEventListener;
|
|
16
17
|
}
|
|
17
18
|
export declare function createCompilerRuntimeState(options: CreateCompilerRuntimeStateOptions): CompilerRuntimeState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveMpxPlatform } from "./framework.js";
|
|
2
|
-
import { A as resolveBooleanObjectOption, Bt as shouldUseUniAppWebRpxCompatibility, Ht as resolveValidTailwindV4Candidates$1, Lt as resolveCssMacroTailwindV4Source, Mt as _defineProperty, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, Vt as loadTailwindV4DesignSystem, a as resolveGeneratorRuntimeBranch, bt as createTailwindV4Engine$1, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source$1 } from "./generator-
|
|
3
|
-
import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-
|
|
2
|
+
import { A as resolveBooleanObjectOption, Bt as shouldUseUniAppWebRpxCompatibility, Ht as resolveValidTailwindV4Candidates$1, Lt as resolveCssMacroTailwindV4Source, Mt as _defineProperty, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, Vt as loadTailwindV4DesignSystem, a as resolveGeneratorRuntimeBranch, bt as createTailwindV4Engine$1, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source$1 } from "./generator-BgbYHNgD.js";
|
|
3
|
+
import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-o3Xe-o7M.js";
|
|
4
4
|
import { i as isMap, n as defuOverrideArray$1 } from "./utils-MVwpU07P.js";
|
|
5
5
|
import { a as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, i as resolveDefaultCssPreflight, o as HARD_PARSE_CACHE_MAX_ENTRIES, r as getDefaultOptions } from "./defaults-CKx-4LcW.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
@@ -1527,9 +1527,28 @@ function createGenerationArtifact(fragments, options) {
|
|
|
1527
1527
|
});
|
|
1528
1528
|
}
|
|
1529
1529
|
//#endregion
|
|
1530
|
+
//#region src/core/compiler/source-fingerprint.ts
|
|
1531
|
+
function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
|
|
1532
|
+
if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
1533
|
+
if (typeof value === "function") return `[Function:${value.name}]`;
|
|
1534
|
+
if (typeof value !== "object") return String(value);
|
|
1535
|
+
if (stack.has(value)) return "[Circular]";
|
|
1536
|
+
stack.add(value);
|
|
1537
|
+
const serialized = Array.isArray(value) ? `[${value.map((item) => stableSerialize(item, stack)).join(",")}]` : `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
|
|
1538
|
+
stack.delete(value);
|
|
1539
|
+
return serialized;
|
|
1540
|
+
}
|
|
1541
|
+
function createSourceFingerprint(source) {
|
|
1542
|
+
return createCompilerValueFingerprint(source);
|
|
1543
|
+
}
|
|
1544
|
+
function createCompilerValueFingerprint(value) {
|
|
1545
|
+
return md5Hash(stableSerialize(value));
|
|
1546
|
+
}
|
|
1547
|
+
//#endregion
|
|
1530
1548
|
//#region src/compiler/candidate-index.ts
|
|
1531
1549
|
var CandidateIndex = class {
|
|
1532
|
-
constructor() {
|
|
1550
|
+
constructor(telemetry) {
|
|
1551
|
+
this.telemetry = telemetry;
|
|
1533
1552
|
_defineProperty(this, "candidatesBySource", /* @__PURE__ */ new Map());
|
|
1534
1553
|
}
|
|
1535
1554
|
sync(sourceId, candidates) {
|
|
@@ -1538,6 +1557,14 @@ var CandidateIndex = class {
|
|
|
1538
1557
|
const addedCandidates = new Set([...next].filter((candidate) => !previous.has(candidate)));
|
|
1539
1558
|
const removedCandidates = new Set([...previous].filter((candidate) => !next.has(candidate)));
|
|
1540
1559
|
this.candidatesBySource.set(sourceId, next);
|
|
1560
|
+
this.telemetry?.record({
|
|
1561
|
+
layer: "candidate-index",
|
|
1562
|
+
keyFingerprint: createCompilerValueFingerprint(sourceId),
|
|
1563
|
+
hit: addedCandidates.size === 0 && removedCandidates.size === 0,
|
|
1564
|
+
invalidationReason: addedCandidates.size || removedCandidates.size ? "source-change" : void 0,
|
|
1565
|
+
entries: this.candidatesBySource.size,
|
|
1566
|
+
memoryBytes: [...this.candidatesBySource.values()].reduce((total, values) => total + values.size * 32, 0)
|
|
1567
|
+
});
|
|
1541
1568
|
return {
|
|
1542
1569
|
sourceId,
|
|
1543
1570
|
addedCandidates,
|
|
@@ -1547,6 +1574,14 @@ var CandidateIndex = class {
|
|
|
1547
1574
|
remove(sourceId) {
|
|
1548
1575
|
const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
1549
1576
|
this.candidatesBySource.delete(sourceId);
|
|
1577
|
+
this.telemetry?.record({
|
|
1578
|
+
layer: "candidate-index",
|
|
1579
|
+
keyFingerprint: createCompilerValueFingerprint(sourceId),
|
|
1580
|
+
hit: false,
|
|
1581
|
+
invalidationReason: "source-change",
|
|
1582
|
+
evicted: true,
|
|
1583
|
+
entries: this.candidatesBySource.size
|
|
1584
|
+
});
|
|
1550
1585
|
return {
|
|
1551
1586
|
sourceId,
|
|
1552
1587
|
addedCandidates: /* @__PURE__ */ new Set(),
|
|
@@ -1569,6 +1604,25 @@ var CandidateIndex = class {
|
|
|
1569
1604
|
}
|
|
1570
1605
|
};
|
|
1571
1606
|
//#endregion
|
|
1607
|
+
//#region src/compiler/capabilities.ts
|
|
1608
|
+
/** 为适配器声明能力,便于统一契约检查并保持旧适配器兼容。 */
|
|
1609
|
+
function createAdapterCapabilities(adapter, overrides = {}) {
|
|
1610
|
+
return {
|
|
1611
|
+
adapter,
|
|
1612
|
+
version: "1.0",
|
|
1613
|
+
capabilities: [
|
|
1614
|
+
"compilerHost",
|
|
1615
|
+
"sourceCandidates",
|
|
1616
|
+
"cssGeneration",
|
|
1617
|
+
"assetEmission",
|
|
1618
|
+
"watchUpdate",
|
|
1619
|
+
"diagnostics"
|
|
1620
|
+
],
|
|
1621
|
+
...overrides
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
createAdapterCapabilities("vite"), createAdapterCapabilities("webpack"), createAdapterCapabilities("rspack"), createAdapterCapabilities("gulp");
|
|
1625
|
+
//#endregion
|
|
1572
1626
|
//#region src/compiler/compilation-scope-graph.ts
|
|
1573
1627
|
function sourceNodeId(sourceId) {
|
|
1574
1628
|
return `source:${sourceId}`;
|
|
@@ -2307,24 +2361,6 @@ function createCompilationEventBus() {
|
|
|
2307
2361
|
};
|
|
2308
2362
|
}
|
|
2309
2363
|
//#endregion
|
|
2310
|
-
//#region src/core/compiler/source-fingerprint.ts
|
|
2311
|
-
function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
|
|
2312
|
-
if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
2313
|
-
if (typeof value === "function") return `[Function:${value.name}]`;
|
|
2314
|
-
if (typeof value !== "object") return String(value);
|
|
2315
|
-
if (stack.has(value)) return "[Circular]";
|
|
2316
|
-
stack.add(value);
|
|
2317
|
-
const serialized = Array.isArray(value) ? `[${value.map((item) => stableSerialize(item, stack)).join(",")}]` : `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
|
|
2318
|
-
stack.delete(value);
|
|
2319
|
-
return serialized;
|
|
2320
|
-
}
|
|
2321
|
-
function createSourceFingerprint(source) {
|
|
2322
|
-
return createCompilerValueFingerprint(source);
|
|
2323
|
-
}
|
|
2324
|
-
function createCompilerValueFingerprint(value) {
|
|
2325
|
-
return md5Hash(stableSerialize(value));
|
|
2326
|
-
}
|
|
2327
|
-
//#endregion
|
|
2328
2364
|
//#region src/core/compiler/generation-cache.ts
|
|
2329
2365
|
function createCompilerGenerationCacheKey(request, candidates, target) {
|
|
2330
2366
|
return {
|
|
@@ -4352,7 +4388,9 @@ function createCompilerTransforms({ ensureActive, track, userOptions }) {
|
|
|
4352
4388
|
const DEFAULT_MAX_ROOTS = 128;
|
|
4353
4389
|
function createCompiler(options = {}) {
|
|
4354
4390
|
const { compiler: compilerOptions, ...userOptions } = options;
|
|
4355
|
-
const
|
|
4391
|
+
const maxRoots = Math.max(1, Math.floor(compilerOptions?.maxRoots ?? DEFAULT_MAX_ROOTS));
|
|
4392
|
+
const cacheTelemetry = compilerOptions?.cacheTelemetry;
|
|
4393
|
+
const rootStore = new CompilerRootStore(maxRoots, compilerOptions?.onRootEvicted);
|
|
4356
4394
|
const activeTasks = /* @__PURE__ */ new Set();
|
|
4357
4395
|
let lifecycle = "active";
|
|
4358
4396
|
let disposePromise;
|
|
@@ -4391,6 +4429,15 @@ function createCompiler(options = {}) {
|
|
|
4391
4429
|
const prepared = prepareCompilerGeneration(entry, request, source, !sourceReused || entry.appliedInvalidation !== invalidation);
|
|
4392
4430
|
const generationCacheKey = createCompilerGenerationCacheKey(request, prepared.compilation.candidates, target);
|
|
4393
4431
|
const reusableGeneration = engineReused && entry.generationCache && isSameCompilerGenerationCacheKey(entry.generationCache.key, generationCacheKey) ? entry.generationCache.result : void 0;
|
|
4432
|
+
cacheTelemetry?.record({
|
|
4433
|
+
layer: "tailwind-generation",
|
|
4434
|
+
keyFingerprint: generationCacheKey.candidateSignature,
|
|
4435
|
+
hit: reusableGeneration !== void 0,
|
|
4436
|
+
invalidationReason: reusableGeneration === void 0 && !engineReused ? "source-change" : void 0,
|
|
4437
|
+
entries: entry.generationCache ? 1 : 0,
|
|
4438
|
+
revision: getLatestRevision(entry),
|
|
4439
|
+
operationId: entry.id
|
|
4440
|
+
});
|
|
4394
4441
|
try {
|
|
4395
4442
|
const generated = reusableGeneration ? reuseCompilerGenerationResult(reusableGeneration) : await generator.generate({
|
|
4396
4443
|
...generateOptions,
|
|
@@ -4860,6 +4907,7 @@ function createRuntimeAffectingSourceSignature(source, type) {
|
|
|
4860
4907
|
/** 创建构建器无关的 runtime state,并保留旧字段供现有插件继续使用。 */
|
|
4861
4908
|
function createCompilerRuntimeState(options) {
|
|
4862
4909
|
const events = options.events ?? createCompilationEventBus();
|
|
4910
|
+
if (options.reporter) events.subscribe(options.reporter);
|
|
4863
4911
|
return {
|
|
4864
4912
|
tailwindRuntime: options.tailwindRuntime,
|
|
4865
4913
|
readyPromise: options.readyPromise ?? Promise.resolve(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
3
|
+
const require_generator = require("./generator-RK2HtgOb.cjs");
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-B03BGeTO.cjs");
|
|
5
5
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
6
|
const require_defaults = require("./defaults-CiGsr8Xq.cjs");
|
|
7
7
|
let node_path = require("node:path");
|
|
@@ -38303,9 +38303,28 @@ function createGenerationArtifact(fragments, options) {
|
|
|
38303
38303
|
});
|
|
38304
38304
|
}
|
|
38305
38305
|
//#endregion
|
|
38306
|
+
//#region src/core/compiler/source-fingerprint.ts
|
|
38307
|
+
function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
|
|
38308
|
+
if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
38309
|
+
if (typeof value === "function") return `[Function:${value.name}]`;
|
|
38310
|
+
if (typeof value !== "object") return String(value);
|
|
38311
|
+
if (stack.has(value)) return "[Circular]";
|
|
38312
|
+
stack.add(value);
|
|
38313
|
+
const serialized = Array.isArray(value) ? `[${value.map((item) => stableSerialize(item, stack)).join(",")}]` : `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
|
|
38314
|
+
stack.delete(value);
|
|
38315
|
+
return serialized;
|
|
38316
|
+
}
|
|
38317
|
+
function createSourceFingerprint(source) {
|
|
38318
|
+
return createCompilerValueFingerprint(source);
|
|
38319
|
+
}
|
|
38320
|
+
function createCompilerValueFingerprint(value) {
|
|
38321
|
+
return (0, _weapp_tailwindcss_shared_node.md5)(stableSerialize(value));
|
|
38322
|
+
}
|
|
38323
|
+
//#endregion
|
|
38306
38324
|
//#region src/compiler/candidate-index.ts
|
|
38307
38325
|
var CandidateIndex = class {
|
|
38308
|
-
constructor() {
|
|
38326
|
+
constructor(telemetry) {
|
|
38327
|
+
this.telemetry = telemetry;
|
|
38309
38328
|
require_generator._defineProperty(this, "candidatesBySource", /* @__PURE__ */ new Map());
|
|
38310
38329
|
}
|
|
38311
38330
|
sync(sourceId, candidates) {
|
|
@@ -38314,6 +38333,14 @@ var CandidateIndex = class {
|
|
|
38314
38333
|
const addedCandidates = new Set([...next].filter((candidate) => !previous.has(candidate)));
|
|
38315
38334
|
const removedCandidates = new Set([...previous].filter((candidate) => !next.has(candidate)));
|
|
38316
38335
|
this.candidatesBySource.set(sourceId, next);
|
|
38336
|
+
this.telemetry?.record({
|
|
38337
|
+
layer: "candidate-index",
|
|
38338
|
+
keyFingerprint: createCompilerValueFingerprint(sourceId),
|
|
38339
|
+
hit: addedCandidates.size === 0 && removedCandidates.size === 0,
|
|
38340
|
+
invalidationReason: addedCandidates.size || removedCandidates.size ? "source-change" : void 0,
|
|
38341
|
+
entries: this.candidatesBySource.size,
|
|
38342
|
+
memoryBytes: [...this.candidatesBySource.values()].reduce((total, values) => total + values.size * 32, 0)
|
|
38343
|
+
});
|
|
38317
38344
|
return {
|
|
38318
38345
|
sourceId,
|
|
38319
38346
|
addedCandidates,
|
|
@@ -38323,6 +38350,14 @@ var CandidateIndex = class {
|
|
|
38323
38350
|
remove(sourceId) {
|
|
38324
38351
|
const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
38325
38352
|
this.candidatesBySource.delete(sourceId);
|
|
38353
|
+
this.telemetry?.record({
|
|
38354
|
+
layer: "candidate-index",
|
|
38355
|
+
keyFingerprint: createCompilerValueFingerprint(sourceId),
|
|
38356
|
+
hit: false,
|
|
38357
|
+
invalidationReason: "source-change",
|
|
38358
|
+
evicted: true,
|
|
38359
|
+
entries: this.candidatesBySource.size
|
|
38360
|
+
});
|
|
38326
38361
|
return {
|
|
38327
38362
|
sourceId,
|
|
38328
38363
|
addedCandidates: /* @__PURE__ */ new Set(),
|
|
@@ -38345,6 +38380,25 @@ var CandidateIndex = class {
|
|
|
38345
38380
|
}
|
|
38346
38381
|
};
|
|
38347
38382
|
//#endregion
|
|
38383
|
+
//#region src/compiler/capabilities.ts
|
|
38384
|
+
/** 为适配器声明能力,便于统一契约检查并保持旧适配器兼容。 */
|
|
38385
|
+
function createAdapterCapabilities(adapter, overrides = {}) {
|
|
38386
|
+
return {
|
|
38387
|
+
adapter,
|
|
38388
|
+
version: "1.0",
|
|
38389
|
+
capabilities: [
|
|
38390
|
+
"compilerHost",
|
|
38391
|
+
"sourceCandidates",
|
|
38392
|
+
"cssGeneration",
|
|
38393
|
+
"assetEmission",
|
|
38394
|
+
"watchUpdate",
|
|
38395
|
+
"diagnostics"
|
|
38396
|
+
],
|
|
38397
|
+
...overrides
|
|
38398
|
+
};
|
|
38399
|
+
}
|
|
38400
|
+
createAdapterCapabilities("vite"), createAdapterCapabilities("webpack"), createAdapterCapabilities("rspack"), createAdapterCapabilities("gulp");
|
|
38401
|
+
//#endregion
|
|
38348
38402
|
//#region src/compiler/compilation-scope-graph.ts
|
|
38349
38403
|
function sourceNodeId(sourceId) {
|
|
38350
38404
|
return `source:${sourceId}`;
|
|
@@ -39059,24 +39113,6 @@ var AssetEmissionPlan = class {
|
|
|
39059
39113
|
}
|
|
39060
39114
|
};
|
|
39061
39115
|
//#endregion
|
|
39062
|
-
//#region src/core/compiler/source-fingerprint.ts
|
|
39063
|
-
function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
|
|
39064
|
-
if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
39065
|
-
if (typeof value === "function") return `[Function:${value.name}]`;
|
|
39066
|
-
if (typeof value !== "object") return String(value);
|
|
39067
|
-
if (stack.has(value)) return "[Circular]";
|
|
39068
|
-
stack.add(value);
|
|
39069
|
-
const serialized = Array.isArray(value) ? `[${value.map((item) => stableSerialize(item, stack)).join(",")}]` : `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
|
|
39070
|
-
stack.delete(value);
|
|
39071
|
-
return serialized;
|
|
39072
|
-
}
|
|
39073
|
-
function createSourceFingerprint(source) {
|
|
39074
|
-
return createCompilerValueFingerprint(source);
|
|
39075
|
-
}
|
|
39076
|
-
function createCompilerValueFingerprint(value) {
|
|
39077
|
-
return (0, _weapp_tailwindcss_shared_node.md5)(stableSerialize(value));
|
|
39078
|
-
}
|
|
39079
|
-
//#endregion
|
|
39080
39116
|
//#region src/core/compiler/generation-cache.ts
|
|
39081
39117
|
function createCompilerGenerationCacheKey(request, candidates, target) {
|
|
39082
39118
|
return {
|
|
@@ -41271,7 +41307,9 @@ function createCompilerTransforms({ ensureActive, track, userOptions }) {
|
|
|
41271
41307
|
const DEFAULT_MAX_ROOTS = 128;
|
|
41272
41308
|
function createCompiler(options = {}) {
|
|
41273
41309
|
const { compiler: compilerOptions, ...userOptions } = options;
|
|
41274
|
-
const
|
|
41310
|
+
const maxRoots = Math.max(1, Math.floor(compilerOptions?.maxRoots ?? DEFAULT_MAX_ROOTS));
|
|
41311
|
+
const cacheTelemetry = compilerOptions?.cacheTelemetry;
|
|
41312
|
+
const rootStore = new CompilerRootStore(maxRoots, compilerOptions?.onRootEvicted);
|
|
41275
41313
|
const activeTasks = /* @__PURE__ */ new Set();
|
|
41276
41314
|
let lifecycle = "active";
|
|
41277
41315
|
let disposePromise;
|
|
@@ -41310,6 +41348,15 @@ function createCompiler(options = {}) {
|
|
|
41310
41348
|
const prepared = prepareCompilerGeneration(entry, request, source, !sourceReused || entry.appliedInvalidation !== invalidation);
|
|
41311
41349
|
const generationCacheKey = createCompilerGenerationCacheKey(request, prepared.compilation.candidates, target);
|
|
41312
41350
|
const reusableGeneration = engineReused && entry.generationCache && isSameCompilerGenerationCacheKey(entry.generationCache.key, generationCacheKey) ? entry.generationCache.result : void 0;
|
|
41351
|
+
cacheTelemetry?.record({
|
|
41352
|
+
layer: "tailwind-generation",
|
|
41353
|
+
keyFingerprint: generationCacheKey.candidateSignature,
|
|
41354
|
+
hit: reusableGeneration !== void 0,
|
|
41355
|
+
invalidationReason: reusableGeneration === void 0 && !engineReused ? "source-change" : void 0,
|
|
41356
|
+
entries: entry.generationCache ? 1 : 0,
|
|
41357
|
+
revision: getLatestRevision(entry),
|
|
41358
|
+
operationId: entry.id
|
|
41359
|
+
});
|
|
41313
41360
|
try {
|
|
41314
41361
|
const generated = reusableGeneration ? reuseCompilerGenerationResult(reusableGeneration) : await generator.generate({
|
|
41315
41362
|
...generateOptions,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Document, FinalizeMiniProgramCssOptions, IStyleHandlerOptions, Result as PostcssResult, Root } from '@weapp-tailwindcss/postcss';
|
|
2
|
+
import type { CacheTelemetryCollector } from '../../compiler/cache-telemetry.js';
|
|
2
3
|
import type { TailwindV4ResolvedSource, TailwindV4SourceOptions, WeappTailwindcssGenerateOptions, WeappTailwindcssGenerateResult } from '../../generator/index.js';
|
|
3
4
|
import type { CreateJsHandlerOptions, ITemplateHandlerOptions, JsHandlerResult, UserDefinedOptions } from '../../types/index.js';
|
|
4
5
|
export type CompilerTarget = 'tailwind' | 'weapp' | 'web';
|
|
@@ -56,6 +57,7 @@ export type CreateCompilerOptions = UserDefinedOptions & {
|
|
|
56
57
|
compiler?: {
|
|
57
58
|
maxRoots?: number | undefined;
|
|
58
59
|
onRootEvicted?: ((id: string) => void) | undefined;
|
|
60
|
+
cacheTelemetry?: CacheTelemetryCollector | undefined;
|
|
59
61
|
} | undefined;
|
|
60
62
|
};
|
|
61
63
|
export interface Compiler {
|
package/dist/core.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_compiler = require("./compiler-
|
|
3
|
-
const require_runtime_state = require("./runtime-state-
|
|
2
|
+
const require_compiler = require("./compiler-DFROuh5Z.cjs");
|
|
3
|
+
const require_runtime_state = require("./runtime-state-XYSycuGu.cjs");
|
|
4
4
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
5
5
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
6
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
6
7
|
//#region src/core.ts
|
|
7
8
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
|
8
9
|
function resolveTransformWxssOptions(options) {
|
|
@@ -28,6 +29,26 @@ function createContext(options = {}) {
|
|
|
28
29
|
refreshTailwindcssRuntime
|
|
29
30
|
});
|
|
30
31
|
const defaultJsHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
32
|
+
const diagnosticEvents = [];
|
|
33
|
+
runtimeState.events.subscribe((event) => {
|
|
34
|
+
if (event.type === "diagnostic") diagnosticEvents.push(event);
|
|
35
|
+
});
|
|
36
|
+
async function emitDiagnostic(phase, startedAt, operationId, error) {
|
|
37
|
+
await runtimeState.events.emit({
|
|
38
|
+
schemaVersion: 1,
|
|
39
|
+
type: "diagnostic",
|
|
40
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41
|
+
compilerId: "weapp-tailwindcss",
|
|
42
|
+
phase,
|
|
43
|
+
revision: runtimeState.revision,
|
|
44
|
+
operationId,
|
|
45
|
+
durationMs: node_perf_hooks.performance.now() - startedAt,
|
|
46
|
+
error: error ? {
|
|
47
|
+
name: error instanceof Error ? error.name : void 0,
|
|
48
|
+
message: error instanceof Error ? error.message : String(error)
|
|
49
|
+
} : void 0
|
|
50
|
+
});
|
|
51
|
+
}
|
|
31
52
|
function getDefaultJsHandlerOptions(majorVersion = runtimeState.tailwindRuntime.majorVersion) {
|
|
32
53
|
if (typeof majorVersion !== "number") return;
|
|
33
54
|
let cached = defaultJsHandlerOptionsCache.get(majorVersion);
|
|
@@ -110,9 +131,17 @@ function createContext(options = {}) {
|
|
|
110
131
|
}
|
|
111
132
|
async function transformWxss(rawCss, options) {
|
|
112
133
|
await runtimeState.readyPromise;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
const startedAt = node_perf_hooks.performance.now();
|
|
135
|
+
const operationId = `css-${Date.now()}-${runtimeState.revision}`;
|
|
136
|
+
try {
|
|
137
|
+
const result = await styleHandler(rawCss, resolveTransformWxssOptions(options));
|
|
138
|
+
runtimeSet = await require_compiler.ensureRuntimeClassSet(runtimeState);
|
|
139
|
+
await emitDiagnostic("postcss", startedAt, operationId);
|
|
140
|
+
return result;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
await emitDiagnostic("postcss", startedAt, operationId, error);
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
116
145
|
}
|
|
117
146
|
async function getRuntimeSet(options) {
|
|
118
147
|
await runtimeState.readyPromise;
|
|
@@ -125,18 +154,38 @@ function createContext(options = {}) {
|
|
|
125
154
|
else if (runtimeSet.size === 0) runtimeSet = await require_compiler.ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
126
155
|
const resolvedOptions = resolveTransformJsOptions(options);
|
|
127
156
|
if (require_compiler.shouldSkipJsTransform(rawJs, resolvedOptions)) return { code: rawJs };
|
|
128
|
-
|
|
157
|
+
const startedAt = node_perf_hooks.performance.now();
|
|
158
|
+
const operationId = `js-${Date.now()}-${runtimeState.revision}`;
|
|
159
|
+
try {
|
|
160
|
+
const result = await jsHandler(rawJs, runtimeSet, resolvedOptions);
|
|
161
|
+
await emitDiagnostic("candidate", startedAt, operationId);
|
|
162
|
+
return result;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
await emitDiagnostic("candidate", startedAt, operationId, error);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
129
167
|
}
|
|
130
168
|
async function transformWxml(rawWxml, options) {
|
|
131
169
|
await runtimeState.readyPromise;
|
|
132
170
|
if (!options?.runtimeSet && runtimeSet.size === 0) runtimeSet = await require_compiler.ensureRuntimeClassSet(runtimeState, { forceCollect: true });
|
|
133
|
-
|
|
171
|
+
const startedAt = node_perf_hooks.performance.now();
|
|
172
|
+
const operationId = `template-${Date.now()}-${runtimeState.revision}`;
|
|
173
|
+
try {
|
|
174
|
+
const result = templateHandler(rawWxml, resolveTransformWxmlOptions(options));
|
|
175
|
+
await emitDiagnostic("scan", startedAt, operationId);
|
|
176
|
+
return result;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
await emitDiagnostic("scan", startedAt, operationId, error);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
134
181
|
}
|
|
135
182
|
return {
|
|
136
183
|
getRuntimeSet,
|
|
137
184
|
transformWxss,
|
|
138
185
|
transformWxml,
|
|
139
|
-
transformJs
|
|
186
|
+
transformJs,
|
|
187
|
+
events: runtimeState.events,
|
|
188
|
+
getDiagnosticEvents: () => diagnosticEvents.slice()
|
|
140
189
|
};
|
|
141
190
|
}
|
|
142
191
|
//#endregion
|
package/dist/core.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CompilationDiagnosticEvent } from './compiler/events.js';
|
|
1
2
|
import type { CreateJsHandlerOptions, IStyleHandlerOptions, ITemplateHandlerOptions, UserDefinedOptions } from './types/index.js';
|
|
2
3
|
export { createCompilationEventBus, createCompilerRuntimeState } from './compiler/index.js';
|
|
3
4
|
export type { CompilationEvent, CompilerHost, CompilerRuntimeState } from './compiler/index.js';
|
|
@@ -19,4 +20,6 @@ export declare function createContext(options?: UserDefinedOptions): {
|
|
|
19
20
|
transformWxss: (rawCss: string, options?: Partial<IStyleHandlerOptions>) => Promise<import("postcss").Result<import("postcss").Document | import("postcss").Root>>;
|
|
20
21
|
transformWxml: (rawWxml: string, options?: ITemplateHandlerOptions) => Promise<string>;
|
|
21
22
|
transformJs: (rawJs: string, options?: RuntimeJsTransformOptions) => Promise<import("./types/index.js").JsHandlerResult>;
|
|
23
|
+
events: import("./compiler/index.js").CompilationEventBus;
|
|
24
|
+
getDiagnosticEvents: () => CompilationDiagnosticEvent[];
|
|
22
25
|
};
|