@fluentic/style 0.1.0-beta.17 → 0.1.0-beta.19
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/CHANGELOG.md +18 -0
- package/atomic/utils/types.ts +4 -2
- package/compiler/compiler/cache_identity.ts +115 -0
- package/compiler/compiler/compiler.ts +21 -1
- package/compiler/compiler/persistent_cache.ts +310 -0
- package/compiler/compiler/types.ts +12 -0
- package/compiler/extract/collector.ts +2 -2
- package/compiler/transform/evaluator/metadata_cache.ts +124 -0
- package/compiler/transform/evaluator/tracer.ts +71 -63
- package/compiler/transform/extract/plugin.ts +2 -0
- package/compiler/utils/check_diagnostics.ts +18 -0
- package/compiler/utils/file_resolver.ts +24 -0
- package/dist/{combine-BpOQWCtM.js → combine-B5AnX0Gb.js} +2 -2
- package/dist/{combine-BpOQWCtM.js.map → combine-B5AnX0Gb.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-Cat8TmMk.mjs → compiler-Dpd41bCS.mjs} +552 -41
- package/dist/compiler-Dpd41bCS.mjs.map +1 -0
- package/dist/{config-B70LIQhi.js → config-VS1lyh3Z.js} +2 -2
- package/dist/{config-B70LIQhi.js.map → config-VS1lyh3Z.js.map} +1 -1
- package/dist/{css-C7tcD3IO.js → css-CMuUcsWb.js} +99 -21
- package/dist/css-CMuUcsWb.js.map +1 -0
- package/dist/{css-Cdxkur4h.js → css-ivddFxoH.js} +6 -6
- package/dist/{css-Cdxkur4h.js.map → css-ivddFxoH.js.map} +1 -1
- package/dist/{css-BkNqUfLD.js → css-tUcQKLko.js} +5 -5
- package/dist/{css-BkNqUfLD.js.map → css-tUcQKLko.js.map} +1 -1
- package/dist/css.js +1 -1
- package/dist/{css_extra-BC1Z_hDy.js → css_extra-FjU7uCIO.js} +2 -2
- package/dist/{css_extra-BC1Z_hDy.js.map → css_extra-FjU7uCIO.js.map} +1 -1
- package/dist/dev/rsc.js +5 -5
- package/dist/{dev-BoEgFs_x.js → dev-CZUGQ_Ps.js} +3 -3
- package/dist/{dev-BoEgFs_x.js.map → dev-CZUGQ_Ps.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/{elementMarker-nYeJnJPQ.js → elementMarker-BCL0sycL.js} +99 -21
- package/dist/elementMarker-BCL0sycL.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +1 -1
- package/dist/entry/dev/adapter/react.js +1 -1
- package/dist/entry/dev/adapter/solid.js +1 -1
- package/dist/entry/dev/css.js +1 -1
- package/dist/entry/dev/jsx-dev-runtime.js +1 -1
- package/dist/entry/dev/jsx-runtime.js +1 -1
- package/dist/entry/dev.js +5 -5
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod.js +2 -2
- package/dist/entry/rsc-dev/adapter/preact.js +1 -1
- package/dist/entry/rsc-dev/adapter/react.js +1 -1
- package/dist/entry/rsc-dev/adapter/solid.js +1 -1
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +4 -4
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +3 -3
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +6 -6
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod.js +2 -2
- package/dist/{env-BcNl1tsJ.js → env-CljhzScj.js} +2 -2
- package/dist/{env-BcNl1tsJ.js.map → env-CljhzScj.js.map} +1 -1
- package/dist/{getClassName-B3azD1TO.js → getClassName-DKk03IJU.js} +3 -3
- package/dist/{getClassName-B3azD1TO.js.map → getClassName-DKk03IJU.js.map} +1 -1
- package/dist/{getClassName-CkTq92nR.js → getClassName-a1SH7I2q.js} +3 -3
- package/dist/{getClassName-CkTq92nR.js.map → getClassName-a1SH7I2q.js.map} +1 -1
- package/dist/{globalSheet-CdgVpvCb.js → globalSheet-CjX0Df0w.js} +3 -3
- package/dist/globalSheet-CjX0Df0w.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-DA1LD8nU.js → jsx-Gs5YwesA.js} +3 -3
- package/dist/{jsx-DA1LD8nU.js.map → jsx-Gs5YwesA.js.map} +1 -1
- package/dist/{jsx_runtime-pt7DOZOE.js → jsx_runtime-D3Dc1XfC.js} +3 -3
- package/dist/{jsx_runtime-pt7DOZOE.js.map → jsx_runtime-D3Dc1XfC.js.map} +1 -1
- package/dist/{loader-Cvz2pKYV.mjs → loader-CR_NH6ub.mjs} +3 -3
- package/dist/{loader-Cvz2pKYV.mjs.map → loader-CR_NH6ub.mjs.map} +1 -1
- package/dist/{misc-BKaSZF14.mjs → misc-D5AjOWP-.mjs} +3 -3
- package/dist/misc-D5AjOWP-.mjs.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -4
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +5 -5
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +1 -1
- package/dist/plugin/parcel/index.mjs +2 -2
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +2 -2
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +2 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/{registry-Bbxm5X90.mjs → registry-CdSHrX-o.mjs} +2 -2
- package/dist/{registry-Bbxm5X90.mjs.map → registry-CdSHrX-o.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-B6vKNL5y.js → resolveClassNameRuntime-BBI9nYtq.js} +2 -2
- package/dist/{resolveClassNameRuntime-B6vKNL5y.js.map → resolveClassNameRuntime-BBI9nYtq.js.map} +1 -1
- package/dist/server.js +7 -7
- package/dist/{shared-L-63tURh.cjs → shared-CcB1KDFI.cjs} +557 -47
- package/dist/shared-CcB1KDFI.cjs.map +1 -0
- package/dist/{shared-BVciI9ew.mjs → shared-CobOEWzt.mjs} +5 -5
- package/dist/shared-CobOEWzt.mjs.map +1 -0
- package/dist/sheet-AV0Sl7e2.js +1 -0
- package/dist/sheet-Bf09AL2O.js +7 -0
- package/dist/{sheet-D_grHnaJ.js.map → sheet-Bf09AL2O.js.map} +1 -1
- package/dist/{sheet-C6ymGhKV.js → sheet-CcwxBK3r.js} +2 -2
- package/dist/{sheet-C6ymGhKV.js.map → sheet-CcwxBK3r.js.map} +1 -1
- package/dist/{sidecar-B7Q2P71F.mjs → sidecar-CHDVQqN_.mjs} +3 -3
- package/dist/{sidecar-B7Q2P71F.mjs.map → sidecar-CHDVQqN_.mjs.map} +1 -1
- package/dist/{style-CRs-vfY1.js → style-DY3v7k9y.js} +3 -3
- package/dist/style-DY3v7k9y.js.map +1 -0
- package/dist/{styleStore-D1IEmq1v.js → styleStore-BpkbvtBI.js} +99 -21
- package/dist/styleStore-BpkbvtBI.js.map +1 -0
- package/dist/{styleStore-HI4V2puu.js → styleStore-DWEAtd8z.js} +3 -3
- package/dist/{styleStore-HI4V2puu.js.map → styleStore-DWEAtd8z.js.map} +1 -1
- package/dist/{trace-DdFJPELS.js → trace-BxvaCfGx.js} +2 -2
- package/dist/{trace-DdFJPELS.js.map → trace-BxvaCfGx.js.map} +1 -1
- package/dist/{trace-uHVvnYiw.js → trace-Db5et6nx.js} +2 -2
- package/dist/{trace-uHVvnYiw.js.map → trace-Db5et6nx.js.map} +1 -1
- package/dist/transform-BZ4jPwy3.js.map +1 -1
- package/dist/types/atomic/utils/types.d.ts +3 -2
- package/dist/types/builder/utils.d.ts +1 -1
- package/dist/types/compiler/compiler/cache_identity.d.ts +4 -0
- package/dist/types/compiler/compiler/compiler.d.ts +12 -0
- package/dist/types/compiler/compiler/persistent_cache.d.ts +14 -0
- package/dist/types/compiler/compiler/types.d.ts +11 -0
- package/dist/types/compiler/extract/collector.d.ts +1 -1
- package/dist/types/compiler/transform/evaluator/metadata_cache.d.ts +13 -0
- package/dist/types/compiler/transform/evaluator/tracer.d.ts +6 -0
- package/dist/types/compiler/utils/check_diagnostics.d.ts +7 -0
- package/dist/types/compiler/utils/file_resolver.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin/bundler/vite/state.d.ts +24 -0
- package/dist/types/plugin/utils/compiler.d.ts +12 -1
- package/dist/types/style/tokens.d.ts +1 -1
- package/dist/types/style/transform.d.ts +4 -3
- package/dist/{utils-CB70kIh6.js → utils-B3O2b3Ly.js} +3 -3
- package/dist/{utils-CB70kIh6.js.map → utils-B3O2b3Ly.js.map} +1 -1
- package/dist/{utils-sG7IWYP6.js → utils-BeJmRz7x.js} +99 -21
- package/dist/utils-BeJmRz7x.js.map +1 -0
- package/dist/{utils-D2QdzQkX.mjs → utils-CICsXGqS.mjs} +5 -5
- package/dist/utils-CICsXGqS.mjs.map +1 -0
- package/dist/{utils-D3KR1ht8.mjs → utils-XfsnoteV.mjs} +3 -3
- package/dist/{utils-D3KR1ht8.mjs.map → utils-XfsnoteV.mjs.map} +1 -1
- package/dist/{webpack-DRegoWgj.mjs → webpack-BAflvDbq.mjs} +6 -6
- package/dist/webpack-BAflvDbq.mjs.map +1 -0
- package/index.ts +1 -0
- package/package.json +2 -2
- package/plugin/bundler/farm/plugin.ts +1 -1
- package/plugin/bundler/parcel/shared.ts +1 -1
- package/plugin/bundler/vite/state.ts +5 -6
- package/plugin/bundler/webpack/plugin.ts +1 -1
- package/plugin/nextjs/plugin.ts +1 -1
- package/plugin/nextjs/utils.ts +1 -1
- package/plugin/utils/compiler.ts +1 -2
- package/sheet/dev/dev_layer.ts +55 -11
- package/sheet/dev/dev_sort.ts +16 -9
- package/sheet/ordered.ts +43 -6
- package/style/tokens.ts +2 -1
- package/style/transform.ts +4 -3
- package/dist/compiler-Cat8TmMk.mjs.map +0 -1
- package/dist/css-C7tcD3IO.js.map +0 -1
- package/dist/elementMarker-nYeJnJPQ.js.map +0 -1
- package/dist/globalSheet-CdgVpvCb.js.map +0 -1
- package/dist/misc-BKaSZF14.mjs.map +0 -1
- package/dist/shared-BVciI9ew.mjs.map +0 -1
- package/dist/shared-L-63tURh.cjs.map +0 -1
- package/dist/sheet-Biw_rI4_.js +0 -1
- package/dist/sheet-D_grHnaJ.js +0 -7
- package/dist/style-CRs-vfY1.js.map +0 -1
- package/dist/styleStore-D1IEmq1v.js.map +0 -1
- package/dist/utils-D2QdzQkX.mjs.map +0 -1
- package/dist/utils-sG7IWYP6.js.map +0 -1
- package/dist/webpack-DRegoWgj.mjs.map +0 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
2
|
import { BUILDER_TYPE_SCOPE } from '../../../builder/data';
|
|
4
3
|
import { TRACE_STYLE, TRACE_VALUE } from '../../../builder/data/debug';
|
|
5
4
|
import { createExtractedScope, createExtractedSheet, createExtractedStyle } from '../../../builder/extract';
|
|
6
5
|
import type { ExtractedSheetTuple, ExtractedStyleTuple } from '../../../builder/extract';
|
|
7
6
|
import type { CompilerInternal } from '../../compiler';
|
|
8
7
|
import type { CompilerOptions } from '../../compiler/types';
|
|
9
|
-
import { resolveFile } from '../../utils/file_resolver';
|
|
8
|
+
import { clearResolverCache, resolveFile } from '../../utils/file_resolver';
|
|
10
9
|
import { createImportSourceMatcher } from '../../utils/import_source';
|
|
11
10
|
import {
|
|
12
11
|
compileChain,
|
|
@@ -18,11 +17,11 @@ import {
|
|
|
18
17
|
} from '../extract/chain';
|
|
19
18
|
import { annotateAtRuleDeclaration, annotateTokenDeclaration } from '../syntax/static_ids';
|
|
20
19
|
import type { BabelCore, BabelTypes } from '../utils/babel';
|
|
21
|
-
import { babelTransformOptions } from '../utils/babel';
|
|
22
20
|
import { getProjectFileId } from '../utils/path';
|
|
23
21
|
import type { CompiledStyleObject, CompiledStyleObjectLocations, EvalScope } from './evaluator';
|
|
24
22
|
import { COMPILED_STYLE_OBJECT_LOCATIONS, evalFail, evalOk, evaluateEnumDeclaration, evaluateNode } from './evaluator';
|
|
25
23
|
import { LazyBindings } from './lazy_bindings';
|
|
24
|
+
import { createTraceMetadataCache } from './metadata_cache';
|
|
26
25
|
import type { EvalModuleBindings, EvalResult, EvalSlotRef, ImportMap, ResolveImportFn } from './types';
|
|
27
26
|
|
|
28
27
|
export type Tracer = ReturnType<typeof createTracer>;
|
|
@@ -32,25 +31,26 @@ type TraceCacheContent = {
|
|
|
32
31
|
dependencies?: TraceDependency[];
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
const CACHE_TYPE = 'transform-trace-
|
|
34
|
+
const CACHE_TYPE = 'transform-trace-links-v2';
|
|
36
35
|
|
|
37
36
|
type TraceDependency = {
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
source: string;
|
|
38
|
+
fromFile: string;
|
|
39
|
+
filePath: string | null;
|
|
40
|
+
contentHash: string | null;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
type TraceResult = TraceDependency & {
|
|
44
|
+
filePath: string;
|
|
45
|
+
contentHash: string;
|
|
43
46
|
bindings: EvalModuleBindings;
|
|
44
47
|
dependencies: TraceDependency[];
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
export function createTracer(internal: CompilerInternal) {
|
|
48
51
|
const active = new Set<string>();
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
if (!dependencyHashes.has(filePath)) dependencyHashes.set(filePath, hashFileContent(filePath));
|
|
52
|
-
return dependencyHashes.get(filePath) ?? null;
|
|
53
|
-
};
|
|
52
|
+
const cyclic = new Set<string>();
|
|
53
|
+
const metadata = createTraceMetadataCache(internal);
|
|
54
54
|
|
|
55
55
|
const resolveImport = (
|
|
56
56
|
babel: typeof BabelCore,
|
|
@@ -76,8 +76,10 @@ export function createTracer(internal: CompilerInternal) {
|
|
|
76
76
|
cacheType: CACHE_TYPE,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
if (cached?.bindings instanceof Map && areDependenciesFresh(cached.dependencies ?? []
|
|
79
|
+
if (cached?.bindings instanceof Map && areDependenciesFresh(cached.dependencies ?? [])) {
|
|
80
80
|
return {
|
|
81
|
+
source,
|
|
82
|
+
fromFile,
|
|
81
83
|
filePath: resolved.filePath,
|
|
82
84
|
contentHash,
|
|
83
85
|
bindings: cached.bindings,
|
|
@@ -85,43 +87,64 @@ export function createTracer(internal: CompilerInternal) {
|
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
if (active.has(resolved.filePath))
|
|
90
|
+
if (active.has(resolved.filePath)) {
|
|
91
|
+
// Partial export-star maps depend on which module entered the cycle first.
|
|
92
|
+
// Reconstruct them from syntax instead of retaining that partial evaluation.
|
|
93
|
+
for (const file of active) cyclic.add(file);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
89
96
|
active.add(resolved.filePath);
|
|
90
97
|
|
|
91
98
|
try {
|
|
92
99
|
const dependencies = new Map<string, TraceDependency>();
|
|
93
100
|
const dependencyList: TraceDependency[] = [];
|
|
101
|
+
const onTrack = () => {
|
|
102
|
+
dependencyList.splice(0, dependencyList.length, ...dependencies.values());
|
|
103
|
+
};
|
|
94
104
|
const resolveDependency: ResolveImportFn = (source, fromFile) => {
|
|
105
|
+
// Record lookup requests, including failures, so resolution changes are visible.
|
|
106
|
+
const dependency = resolveFile(source, fromFile);
|
|
107
|
+
addTraceDependency(dependencies, {
|
|
108
|
+
source,
|
|
109
|
+
fromFile,
|
|
110
|
+
filePath: dependency?.filePath ?? null,
|
|
111
|
+
contentHash: dependency ? hashContent(dependency.content) : null,
|
|
112
|
+
});
|
|
113
|
+
onTrack();
|
|
95
114
|
const traced = traceModuleResult(babel, source, fromFile);
|
|
96
115
|
if (!traced) return null;
|
|
97
116
|
|
|
98
|
-
return createTrackedBindings(traced, dependencies, () =>
|
|
99
|
-
dependencyList.splice(0, dependencyList.length, ...dependencies.values());
|
|
100
|
-
});
|
|
117
|
+
return createTrackedBindings(traced, dependencies, onTrack, () => traceModuleResult(babel, source, fromFile));
|
|
101
118
|
};
|
|
102
119
|
|
|
103
|
-
const
|
|
120
|
+
const ast = metadata.parse(babel, resolved.filePath, resolved.content);
|
|
121
|
+
if (!ast) return null;
|
|
122
|
+
const bindings = extractModuleBindings(
|
|
104
123
|
internal.projectDir,
|
|
105
124
|
resolved.filePath,
|
|
106
|
-
|
|
125
|
+
ast,
|
|
107
126
|
babel,
|
|
108
127
|
resolveDependency,
|
|
109
128
|
internal.options,
|
|
110
129
|
);
|
|
111
130
|
if (!bindings) return null;
|
|
112
131
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
if (!cyclic.has(resolved.filePath)) {
|
|
133
|
+
internal.cache.setItem<TraceCacheContent>({
|
|
134
|
+
filePath: resolved.filePath,
|
|
135
|
+
contentHash,
|
|
136
|
+
cacheType: CACHE_TYPE,
|
|
137
|
+
persistent: false,
|
|
138
|
+
cacheContent: {
|
|
139
|
+
bindings,
|
|
140
|
+
dependencies: dependencyList,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
123
144
|
|
|
124
145
|
return {
|
|
146
|
+
source,
|
|
147
|
+
fromFile,
|
|
125
148
|
filePath: resolved.filePath,
|
|
126
149
|
contentHash,
|
|
127
150
|
bindings,
|
|
@@ -143,34 +166,22 @@ export function createTracer(internal: CompilerInternal) {
|
|
|
143
166
|
return {
|
|
144
167
|
resolveImport,
|
|
145
168
|
traceModule,
|
|
169
|
+
getMetadataCacheStats: metadata.getStats,
|
|
146
170
|
beginCompilation() {
|
|
147
|
-
|
|
171
|
+
clearResolverCache();
|
|
172
|
+
cyclic.clear();
|
|
148
173
|
},
|
|
149
174
|
};
|
|
150
175
|
}
|
|
151
176
|
|
|
152
|
-
function
|
|
177
|
+
function extractModuleBindings(
|
|
153
178
|
projectDir: string,
|
|
154
179
|
filePath: string,
|
|
155
|
-
|
|
180
|
+
ast: BabelTypes.File,
|
|
156
181
|
babel: typeof BabelCore,
|
|
157
182
|
resolveImport: ResolveImportFn,
|
|
158
183
|
options: CompilerOptions,
|
|
159
184
|
): EvalModuleBindings | null {
|
|
160
|
-
let ast: BabelTypes.File | null = null;
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const parsed = babel.parseSync(content, {
|
|
164
|
-
...babelTransformOptions(),
|
|
165
|
-
filename: filePath,
|
|
166
|
-
});
|
|
167
|
-
ast = parsed as BabelTypes.File;
|
|
168
|
-
} catch {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (!ast) return null;
|
|
173
|
-
|
|
174
185
|
const imports: ImportMap = new Map();
|
|
175
186
|
const rawBindings: Map<string, BabelTypes.Node> = new Map();
|
|
176
187
|
const bindings = new LazyBindings();
|
|
@@ -599,20 +610,21 @@ function createSlotRef(
|
|
|
599
610
|
}
|
|
600
611
|
|
|
601
612
|
function hashContent(content: string): string {
|
|
602
|
-
return crypto.createHash('sha256').update(content).digest('hex')
|
|
613
|
+
return crypto.createHash('sha256').update(content).digest('hex');
|
|
603
614
|
}
|
|
604
615
|
|
|
605
616
|
function addTraceDependency(
|
|
606
617
|
dependencies: Map<string, TraceDependency>,
|
|
607
618
|
dependency: TraceDependency,
|
|
608
619
|
) {
|
|
609
|
-
dependencies.set(dependency.
|
|
620
|
+
dependencies.set(JSON.stringify([dependency.source, dependency.fromFile]), dependency);
|
|
610
621
|
}
|
|
611
622
|
|
|
612
623
|
function createTrackedBindings(
|
|
613
624
|
traced: TraceResult,
|
|
614
625
|
dependencies: Map<string, TraceDependency>,
|
|
615
626
|
onTrack: () => void,
|
|
627
|
+
refresh: () => TraceResult | null,
|
|
616
628
|
): EvalModuleBindings {
|
|
617
629
|
const track = () => {
|
|
618
630
|
addTraceDependency(dependencies, traced);
|
|
@@ -623,7 +635,12 @@ function createTrackedBindings(
|
|
|
623
635
|
const bindings = new LazyBindings();
|
|
624
636
|
for (const key of traced.bindings.keys()) {
|
|
625
637
|
bindings.setLazy(key, () => {
|
|
626
|
-
|
|
638
|
+
// A lazy export may first be requested in a later compilation. Refresh its
|
|
639
|
+
// module before using a previously captured binding map.
|
|
640
|
+
const current = refresh();
|
|
641
|
+
if (!current) return evalFail(`Cannot resolve export: ${key}`);
|
|
642
|
+
traced = current;
|
|
643
|
+
const value = traced.bindings.get(key) ?? evalFail(`Cannot resolve export: ${key}`);
|
|
627
644
|
track();
|
|
628
645
|
return value;
|
|
629
646
|
});
|
|
@@ -634,22 +651,13 @@ function createTrackedBindings(
|
|
|
634
651
|
return bindings;
|
|
635
652
|
}
|
|
636
653
|
|
|
637
|
-
function areDependenciesFresh(
|
|
638
|
-
dependencies: TraceDependency[],
|
|
639
|
-
getHash: (filePath: string) => string | null,
|
|
640
|
-
): boolean {
|
|
654
|
+
function areDependenciesFresh(dependencies: TraceDependency[]): boolean {
|
|
641
655
|
for (const dependency of dependencies) {
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
656
|
+
const current = resolveFile(dependency.source, dependency.fromFile);
|
|
657
|
+
if (
|
|
658
|
+
(current?.filePath ?? null) !== dependency.filePath ||
|
|
659
|
+
(current ? hashContent(current.content) : null) !== dependency.contentHash
|
|
660
|
+
) return false;
|
|
644
661
|
}
|
|
645
|
-
|
|
646
662
|
return true;
|
|
647
663
|
}
|
|
648
|
-
|
|
649
|
-
function hashFileContent(filePath: string): string | null {
|
|
650
|
-
try {
|
|
651
|
-
return hashContent(fs.readFileSync(filePath, 'utf8'));
|
|
652
|
-
} catch {
|
|
653
|
-
return null;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
@@ -3,6 +3,7 @@ import { hashString } from '../../../utils/hash';
|
|
|
3
3
|
import type { CompilerRuntimeMode } from '../../compiler';
|
|
4
4
|
import type { CompilerOptions } from '../../compiler/types';
|
|
5
5
|
import type { CompilerCssCollector } from '../../extract/collector';
|
|
6
|
+
import { recordCheckDiagnostic } from '../../utils/check_diagnostics';
|
|
6
7
|
import {
|
|
7
8
|
FN_CREATE_EXTRACTED_THEME,
|
|
8
9
|
FN_CREATE_EXTRACTED_TOKEN,
|
|
@@ -243,6 +244,7 @@ export function createExtractPlugin(args: PluginArgs) {
|
|
|
243
244
|
if (!result) return;
|
|
244
245
|
|
|
245
246
|
checkCompiledImportantUsage(result, options.check?.important, (level, message) => {
|
|
247
|
+
recordCheckDiagnostic({ level, message });
|
|
246
248
|
if (level === 'error') throw path.buildCodeFrameError(message);
|
|
247
249
|
console.warn('[fluentic-style] ' + message);
|
|
248
250
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type CheckDiagnostic = { level: 'warn' | 'error'; message: string; };
|
|
2
|
+
|
|
3
|
+
let observer: ((diagnostic: CheckDiagnostic) => void) | undefined;
|
|
4
|
+
|
|
5
|
+
/** Extraction is synchronous; restore the previous observer for nested compilations. */
|
|
6
|
+
export function observeCheckDiagnostics<T>(onDiagnostic: (diagnostic: CheckDiagnostic) => void, run: () => T): T {
|
|
7
|
+
const previous = observer;
|
|
8
|
+
observer = onDiagnostic;
|
|
9
|
+
try {
|
|
10
|
+
return run();
|
|
11
|
+
} finally {
|
|
12
|
+
observer = previous;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function recordCheckDiagnostic(diagnostic: CheckDiagnostic) {
|
|
17
|
+
observer?.(diagnostic);
|
|
18
|
+
}
|
|
@@ -15,6 +15,24 @@ export type ResolvedFile = {
|
|
|
15
15
|
export type ResolveFileFn = (info: ResolveFileInfo) => ResolvedFile | null;
|
|
16
16
|
|
|
17
17
|
const contentCache = new Map<string, ResolvedFile>();
|
|
18
|
+
let resolutionObserver: ((source: string, fromFile: string, result: ResolvedFile | null) => void) | null = null;
|
|
19
|
+
|
|
20
|
+
/** Synchronous extraction only; restore the previous observer even when extraction throws. */
|
|
21
|
+
export function observeFileResolutions<T>(
|
|
22
|
+
observer: NonNullable<typeof resolutionObserver>,
|
|
23
|
+
run: () => T,
|
|
24
|
+
): T {
|
|
25
|
+
const previous = resolutionObserver;
|
|
26
|
+
resolutionObserver = (source, fromFile, result) => {
|
|
27
|
+
previous?.(source, fromFile, result);
|
|
28
|
+
observer(source, fromFile, result);
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
return run();
|
|
32
|
+
} finally {
|
|
33
|
+
resolutionObserver = previous;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
18
36
|
|
|
19
37
|
const resolver = new ResolverFactory({
|
|
20
38
|
// Static evaluation needs executable values, never declaration-only exports.
|
|
@@ -33,6 +51,12 @@ export function resolveFile(
|
|
|
33
51
|
source: string,
|
|
34
52
|
fromFile: string,
|
|
35
53
|
): ResolvedFile | null {
|
|
54
|
+
const result = readResolvedFile(source, fromFile);
|
|
55
|
+
resolutionObserver?.(source, fromFile, result);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readResolvedFile(source: string, fromFile: string): ResolvedFile | null {
|
|
36
60
|
const filePath = resolveFilePath(source, fromFile);
|
|
37
61
|
if (!filePath) return null;
|
|
38
62
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as BUILDER_STATE, L as BUILDER_SELECTOR, P as BUILDER_CALLSITE, W as RUNTIME_CONFIG, X as symbol, d as getExtractedTokenBoundData, f as isExtractedTokenBoundData, l as createCacheTreeNode, u as getCacheTreeChild, z as BUILDER_SLOT_ID } from "./className-CC5PHcXI.js";
|
|
2
|
-
import { A as assertManualSelectorSyntax, At as hashString, B as mergeSlotOverrideData, C as isCombinedStyle, Ct as traceError, Dt as importantValue, Et as weightValue, F as FnPrefixStyle, I as resolveCallsite, L as transformStyle, M as FnPrefixScope, Mt as setBuildDebugClassName, N as FnPrefixSelector, Nt as setBuildConfig, O as createIdCounter, Ot as isStyleImportantValue, P as FnPrefixSlot, Pt as CSS_CONFIG, Q as mergeScopeData, R as mergeSelectorOverrideData, S as getCombinedStyleStyles, St as createThemeData, Tt as isStyleWeightValue, V as mergeStyleData, W as normalizeSelectorArg, X as isClassNameValue, Y as classNameValue, _ as createMutableTokenValues, _t as createSelectorData, at as getScopeTargetScope, b as mergeTokenValues, bt as createSlotOverrideData, ct as isScopeTargetData, dt as isStyleData, et as createStyleToken, f as createCombinedStyleFacade, ft as getDebugCallsiteId, g as addTokenValues, gt as createScopeTargetData, h as addTokenOverride, ht as createScopeData, it as getChildStyleTokenName, j as normalizeManualSelectors$1, k as getId, kt as DEV_CONFIG, lt as isSheetData, m as getStyleTokenValues, mt as isDebugData, ot as getScopeTargetSlotId, p as createCombinedStyleTokenWrapper, pt as getTraceCallsiteId, s as createKeyframes, st as isScopeData, u as createThemeClassName, v as finishTokenValues, vt as createSelectorOverrideData, wt as traceMarker, x as getCombinedStyleScopes, xt as createStyleData, y as mergeTokenOverrides, yt as createSlotData, z as mergeSlotData } from "./css-
|
|
2
|
+
import { A as assertManualSelectorSyntax, At as hashString, B as mergeSlotOverrideData, C as isCombinedStyle, Ct as traceError, Dt as importantValue, Et as weightValue, F as FnPrefixStyle, I as resolveCallsite, L as transformStyle, M as FnPrefixScope, Mt as setBuildDebugClassName, N as FnPrefixSelector, Nt as setBuildConfig, O as createIdCounter, Ot as isStyleImportantValue, P as FnPrefixSlot, Pt as CSS_CONFIG, Q as mergeScopeData, R as mergeSelectorOverrideData, S as getCombinedStyleStyles, St as createThemeData, Tt as isStyleWeightValue, V as mergeStyleData, W as normalizeSelectorArg, X as isClassNameValue, Y as classNameValue, _ as createMutableTokenValues, _t as createSelectorData, at as getScopeTargetScope, b as mergeTokenValues, bt as createSlotOverrideData, ct as isScopeTargetData, dt as isStyleData, et as createStyleToken, f as createCombinedStyleFacade, ft as getDebugCallsiteId, g as addTokenValues, gt as createScopeTargetData, h as addTokenOverride, ht as createScopeData, it as getChildStyleTokenName, j as normalizeManualSelectors$1, k as getId, kt as DEV_CONFIG, lt as isSheetData, m as getStyleTokenValues, mt as isDebugData, ot as getScopeTargetSlotId, p as createCombinedStyleTokenWrapper, pt as getTraceCallsiteId, s as createKeyframes, st as isScopeData, u as createThemeClassName, v as finishTokenValues, vt as createSelectorOverrideData, wt as traceMarker, x as getCombinedStyleScopes, xt as createStyleData, y as mergeTokenOverrides, yt as createSlotData, z as mergeSlotData } from "./css-CMuUcsWb.js";
|
|
3
3
|
import { SelectorType, parse } from "css-what";
|
|
4
4
|
//#region entry/shared/config_debug.ts
|
|
5
5
|
const buildConfig = JSON.parse(FLUENTIC_STYLE_BUILD_CONFIG);
|
|
@@ -1251,4 +1251,4 @@ function collectTokenOverrides(data, result, resolver) {
|
|
|
1251
1251
|
//#endregion
|
|
1252
1252
|
export { createValues as a, resetStyleThemeIdCounter as c, createStyleFn as d, getStyleFnMeta as f, type as g, transformKeyframes as h, createToken as i, createClassNameFn as l, createStyleKeyframes as m, bindScope as n, createTokens as o, style as p, combineScope as r, createTheme as s, createCombinedStyleGetter as t, assignStyleFnMeta as u };
|
|
1253
1253
|
|
|
1254
|
-
//# sourceMappingURL=combine-
|
|
1254
|
+
//# sourceMappingURL=combine-B5AnX0Gb.js.map
|