@animus-ui/extract 0.1.9 → 0.1.11
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 +1 -1
- package/crates/extract-v2/animus-extract-v2.darwin-arm64.node +0 -0
- package/crates/extract-v2/animus-extract-v2.linux-arm64-gnu.node +0 -0
- package/crates/extract-v2/animus-extract-v2.linux-x64-gnu.node +0 -0
- package/dist/index.cjs +73 -2101
- package/dist/index.mjs +2 -2026
- package/dist/pipeline/analyze-project-args.d.ts.map +1 -0
- package/dist/pipeline/assemble-stylesheet.d.ts.map +1 -0
- package/dist/pipeline/asset-placeholders.d.ts.map +1 -0
- package/dist/pipeline/content-hash.d.ts.map +1 -0
- package/dist/pipeline/core-options.d.ts +162 -0
- package/dist/pipeline/core-options.d.ts.map +1 -0
- package/dist/pipeline/correlate-external-tokens.d.ts.map +1 -0
- package/dist/pipeline/discover-files.d.ts +12 -0
- package/dist/pipeline/discover-files.d.ts.map +1 -0
- package/dist/{discover-packages.d.ts → pipeline/discover-packages.d.ts} +7 -8
- package/dist/pipeline/discover-packages.d.ts.map +1 -0
- package/dist/pipeline/dynamic-prop-config.d.ts.map +1 -0
- package/dist/{engine-adapter.d.ts → pipeline/engine-adapter.d.ts} +2 -0
- package/dist/pipeline/engine-adapter.d.ts.map +1 -0
- package/dist/pipeline/engine-retirement.d.ts.map +1 -0
- package/dist/pipeline/error-diagnostics.d.ts.map +1 -0
- package/dist/pipeline/external-keyframes.d.ts.map +1 -0
- package/dist/{index.d.ts → pipeline/index.d.ts} +10 -1
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/manifest-diagnostics.d.ts.map +1 -0
- package/dist/{mdx-preprocessor.d.ts → pipeline/mdx-preprocessor.d.ts} +10 -0
- package/dist/pipeline/mdx-preprocessor.d.ts.map +1 -0
- package/dist/pipeline/path-aliases.d.ts.map +1 -0
- package/dist/pipeline/post-process-css.d.ts.map +1 -0
- package/dist/pipeline/prefix.d.ts.map +1 -0
- package/dist/pipeline/replacement-plans.d.ts.map +1 -0
- package/dist/pipeline/resolve-asset.d.ts.map +1 -0
- package/dist/pipeline/run-analysis.d.ts.map +1 -0
- package/dist/pipeline/source-identity.d.ts.map +1 -0
- package/dist/pipeline/source-ingestion.d.ts +173 -0
- package/dist/pipeline/source-ingestion.d.ts.map +1 -0
- package/dist/pipeline/static-css.d.ts.map +1 -0
- package/dist/pipeline/structural-self-check.d.ts +32 -0
- package/dist/pipeline/structural-self-check.d.ts.map +1 -0
- package/dist/pipeline/svelte-source-adapter.d.ts +88 -0
- package/dist/pipeline/svelte-source-adapter.d.ts.map +1 -0
- package/dist/pipeline/system-config.d.ts.map +1 -0
- package/dist/{system-props-module.d.ts → pipeline/system-props-module.d.ts} +4 -3
- package/dist/pipeline/system-props-module.d.ts.map +1 -0
- package/dist/pipeline/timing-waterfall.d.ts.map +1 -0
- package/dist/pipeline/tsconfig-paths.d.ts.map +1 -0
- package/dist/pipeline/unit-fallback.d.ts.map +1 -0
- package/dist/pipeline/utils.d.ts.map +1 -0
- package/dist/pipeline/watch-keys.d.ts.map +1 -0
- package/dist/pipeline-lkbOoyAr.mjs +3228 -0
- package/dist/pipeline-ojNeABi0.cjs +3685 -0
- package/dist/session/extraction-session.d.ts +446 -0
- package/dist/session/extraction-session.d.ts.map +1 -0
- package/dist/session/index.d.ts +24 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/published-set.d.ts +32 -0
- package/dist/session/published-set.d.ts.map +1 -0
- package/dist/session/resolve-packages.d.ts +8 -0
- package/dist/session/resolve-packages.d.ts.map +1 -0
- package/dist/session/session-paths.d.ts +131 -0
- package/dist/session/session-paths.d.ts.map +1 -0
- package/dist/session/singleton.d.ts +124 -0
- package/dist/session/singleton.d.ts.map +1 -0
- package/dist/session/timing.d.ts +7 -0
- package/dist/session/timing.d.ts.map +1 -0
- package/dist/session/turbopack-orchestrator.d.ts +43 -0
- package/dist/session/turbopack-orchestrator.d.ts.map +1 -0
- package/dist/session.cjs +2146 -0
- package/dist/session.mjs +2110 -0
- package/package.json +18 -6
- package/dist/analyze-project-args.d.ts.map +0 -1
- package/dist/assemble-stylesheet.d.ts.map +0 -1
- package/dist/asset-placeholders.d.ts.map +0 -1
- package/dist/content-hash.d.ts.map +0 -1
- package/dist/correlate-external-tokens.d.ts.map +0 -1
- package/dist/discover-files.d.ts +0 -10
- package/dist/discover-files.d.ts.map +0 -1
- package/dist/discover-packages.d.ts.map +0 -1
- package/dist/dynamic-prop-config.d.ts.map +0 -1
- package/dist/engine-adapter.d.ts.map +0 -1
- package/dist/engine-retirement.d.ts.map +0 -1
- package/dist/error-diagnostics.d.ts.map +0 -1
- package/dist/external-keyframes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/manifest-diagnostics.d.ts.map +0 -1
- package/dist/mdx-preprocessor.d.ts.map +0 -1
- package/dist/path-aliases.d.ts.map +0 -1
- package/dist/post-process-css.d.ts.map +0 -1
- package/dist/prefix.d.ts.map +0 -1
- package/dist/replacement-plans.d.ts.map +0 -1
- package/dist/resolve-asset.d.ts.map +0 -1
- package/dist/run-analysis.d.ts.map +0 -1
- package/dist/source-identity.d.ts.map +0 -1
- package/dist/static-css.d.ts.map +0 -1
- package/dist/system-config.d.ts.map +0 -1
- package/dist/system-props-module.d.ts.map +0 -1
- package/dist/timing-waterfall.d.ts.map +0 -1
- package/dist/tsconfig-paths.d.ts.map +0 -1
- package/dist/unit-fallback.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/watch-keys.d.ts.map +0 -1
- /package/dist/{analyze-project-args.d.ts → pipeline/analyze-project-args.d.ts} +0 -0
- /package/dist/{assemble-stylesheet.d.ts → pipeline/assemble-stylesheet.d.ts} +0 -0
- /package/dist/{asset-placeholders.d.ts → pipeline/asset-placeholders.d.ts} +0 -0
- /package/dist/{content-hash.d.ts → pipeline/content-hash.d.ts} +0 -0
- /package/dist/{correlate-external-tokens.d.ts → pipeline/correlate-external-tokens.d.ts} +0 -0
- /package/dist/{dynamic-prop-config.d.ts → pipeline/dynamic-prop-config.d.ts} +0 -0
- /package/dist/{engine-retirement.d.ts → pipeline/engine-retirement.d.ts} +0 -0
- /package/dist/{error-diagnostics.d.ts → pipeline/error-diagnostics.d.ts} +0 -0
- /package/dist/{external-keyframes.d.ts → pipeline/external-keyframes.d.ts} +0 -0
- /package/dist/{manifest-diagnostics.d.ts → pipeline/manifest-diagnostics.d.ts} +0 -0
- /package/dist/{path-aliases.d.ts → pipeline/path-aliases.d.ts} +0 -0
- /package/dist/{post-process-css.d.ts → pipeline/post-process-css.d.ts} +0 -0
- /package/dist/{prefix.d.ts → pipeline/prefix.d.ts} +0 -0
- /package/dist/{replacement-plans.d.ts → pipeline/replacement-plans.d.ts} +0 -0
- /package/dist/{resolve-asset.d.ts → pipeline/resolve-asset.d.ts} +0 -0
- /package/dist/{run-analysis.d.ts → pipeline/run-analysis.d.ts} +0 -0
- /package/dist/{source-identity.d.ts → pipeline/source-identity.d.ts} +0 -0
- /package/dist/{static-css.d.ts → pipeline/static-css.d.ts} +0 -0
- /package/dist/{system-config.d.ts → pipeline/system-config.d.ts} +0 -0
- /package/dist/{timing-waterfall.d.ts → pipeline/timing-waterfall.d.ts} +0 -0
- /package/dist/{tsconfig-paths.d.ts → pipeline/tsconfig-paths.d.ts} +0 -0
- /package/dist/{unit-fallback.d.ts → pipeline/unit-fallback.d.ts} +0 -0
- /package/dist/{utils.d.ts → pipeline/utils.d.ts} +0 -0
- /package/dist/{watch-keys.d.ts → pipeline/watch-keys.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2102 +1,74 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
throw new Error(`[animus-extract] Custom layers have wrong order. Found ${found.join(", ")} but then expected ${missing[0]}. Required order: (${expected.join(" < ")}). You may interleave custom layers but must preserve this subsequence.`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Strip a leading `@layer ...;` declaration line from CSS if present.
|
|
81
|
-
* The Rust crate embeds this in prod-mode output; we strip it so the
|
|
82
|
-
* shared assembler controls placement.
|
|
83
|
-
*/
|
|
84
|
-
function stripLeadingLayerDeclaration(css) {
|
|
85
|
-
return css.replace(/^@layer\s+[^;{]+;\s*\n?/, "");
|
|
86
|
-
}
|
|
87
|
-
function assembleStylesheet(options) {
|
|
88
|
-
const hasCustomLayers = !!options.layers;
|
|
89
|
-
const layers = options.layers ?? ANIMUS_LAYERS;
|
|
90
|
-
if (options.layers) validateLayerOrder(options.layers);
|
|
91
|
-
const declaration = buildLayerDeclaration(layers, hasCustomLayers);
|
|
92
|
-
const variables = options.variableCss || "";
|
|
93
|
-
const componentCss = options.componentCss ? stripLeadingLayerDeclaration(options.componentCss) : "";
|
|
94
|
-
const body = [options.globalCss || "", componentCss].filter(Boolean).join("\n");
|
|
95
|
-
if (options.split) return {
|
|
96
|
-
declaration,
|
|
97
|
-
variables,
|
|
98
|
-
body
|
|
99
|
-
};
|
|
100
|
-
return [
|
|
101
|
-
declaration,
|
|
102
|
-
variables,
|
|
103
|
-
body
|
|
104
|
-
].filter(Boolean).join("\n");
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region pipeline/analyze-project-args.ts
|
|
108
|
-
/** @internal */
|
|
109
|
-
function buildAnalyzeProjectArgs(inputs) {
|
|
110
|
-
return [
|
|
111
|
-
inputs.filesJson,
|
|
112
|
-
inputs.scalesJson,
|
|
113
|
-
inputs.variableMapJson,
|
|
114
|
-
inputs.contextualVarsJson,
|
|
115
|
-
inputs.propConfigJson,
|
|
116
|
-
inputs.groupRegistryJson,
|
|
117
|
-
inputs.packageResolutionJson,
|
|
118
|
-
inputs.devMode,
|
|
119
|
-
inputs.emitterConfigJson,
|
|
120
|
-
inputs.selectorAliasesJson,
|
|
121
|
-
null,
|
|
122
|
-
inputs.globalStyleBlocksJson,
|
|
123
|
-
inputs.pathAliasesJson,
|
|
124
|
-
inputs.keyframesJson,
|
|
125
|
-
inputs.staticCssJson,
|
|
126
|
-
inputs.conditionAliasesJson,
|
|
127
|
-
inputs.externalDirsJson,
|
|
128
|
-
inputs.transformSourcesJson
|
|
129
|
-
];
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region pipeline/engine-adapter.ts
|
|
133
|
-
/**
|
|
134
|
-
* Build the engine-agnostic `engineApi()` both plugins call. Returns a function
|
|
135
|
-
* (invoked per call site) so `isV2()` and `loadNativeEngine()` re-evaluate each
|
|
136
|
-
* time — next reads its engine choice and native module dynamically from
|
|
137
|
-
* globalThis.
|
|
138
|
-
*/
|
|
139
|
-
function createV2EngineApi(deps) {
|
|
140
|
-
const { label, isV2, loadNativeEngine, store } = deps;
|
|
141
|
-
return () => {
|
|
142
|
-
if (!isV2()) return loadNativeEngine();
|
|
143
|
-
const native = loadNativeEngine();
|
|
144
|
-
return {
|
|
145
|
-
loadSystemModule: (...args) => native.loadSystemModule(...args),
|
|
146
|
-
scanKeyframesExports: (entryPath, rootDir) => native.scanKeyframesExports(entryPath, rootDir) ?? null,
|
|
147
|
-
analyzeProject: (filesJsonRaw, scalesJson, variableMapJson, contextualVarsJson, propConfigJson, groupRegistryJson, packageResolutionJson, devMode, emitterConfigJson, selectorAliasesJson, _selectorOrderJson, globalStyleBlocksJson, pathAliasesJson, keyframesJson, staticCssJson, conditionAliasesJson, externalDirsJson, transformSourcesJson) => {
|
|
148
|
-
const filesJson = deps.rehydrateFilesJson ? deps.rehydrateFilesJson(filesJsonRaw) : filesJsonRaw;
|
|
149
|
-
const sent = /* @__PURE__ */ new Map();
|
|
150
|
-
for (const entry of JSON.parse(filesJson)) sent.set(entry.path, entry.source);
|
|
151
|
-
store.setSentSources(sent);
|
|
152
|
-
const emitterConfig = emitterConfigJson ? JSON.parse(emitterConfigJson) : {};
|
|
153
|
-
store.setEngine(null);
|
|
154
|
-
const config = {
|
|
155
|
-
runtimeImport: emitterConfig.runtime_import ?? void 0,
|
|
156
|
-
cssModuleId: emitterConfig.css_module_id ?? void 0,
|
|
157
|
-
systemPropsModuleId: emitterConfig.system_props_module_id ?? void 0,
|
|
158
|
-
themeJson: scalesJson,
|
|
159
|
-
variableMapJson,
|
|
160
|
-
contextualVarsJson: contextualVarsJson ?? void 0,
|
|
161
|
-
configJson: propConfigJson,
|
|
162
|
-
groupRegistryJson,
|
|
163
|
-
selectorAliasesJson: selectorAliasesJson ?? void 0,
|
|
164
|
-
conditionAliasesJson: conditionAliasesJson ?? void 0,
|
|
165
|
-
globalStyleBlocksJson: globalStyleBlocksJson ?? void 0,
|
|
166
|
-
keyframesJson: keyframesJson ?? void 0,
|
|
167
|
-
packageResolutionJson: packageResolutionJson ?? void 0,
|
|
168
|
-
pathAliasesJson: pathAliasesJson ?? void 0,
|
|
169
|
-
staticCssJson: staticCssJson ?? void 0,
|
|
170
|
-
externalDirsJson: externalDirsJson ?? void 0,
|
|
171
|
-
transformSourcesJson: transformSourcesJson ?? void 0,
|
|
172
|
-
devMode
|
|
173
|
-
};
|
|
174
|
-
const engine = new native.ExtractEngine(config);
|
|
175
|
-
store.setEngine(engine);
|
|
176
|
-
return engine.analyze(filesJson);
|
|
177
|
-
},
|
|
178
|
-
transformFile: (source, path, _manifest) => {
|
|
179
|
-
const engine = store.getEngine();
|
|
180
|
-
if (!engine) throw new Error(`[${label}] v2 transform before analyze — engine instance not initialized`);
|
|
181
|
-
const sentMap = store.getSentSources();
|
|
182
|
-
if (deps.passThroughUnknownPaths && sentMap && !sentMap.has(path)) return {
|
|
183
|
-
code: source,
|
|
184
|
-
hasComponents: false
|
|
185
|
-
};
|
|
186
|
-
const sent = sentMap?.get(path);
|
|
187
|
-
if (sent !== void 0 && sent !== source && !store.getDriftWarned()) {
|
|
188
|
-
store.setDriftWarned(true);
|
|
189
|
-
console.warn(`[${label}] v2: transform-time source for ${path} differs from analyze-time source — an upstream transform may be reverted`);
|
|
190
|
-
}
|
|
191
|
-
return JSON.parse(engine.transformFile(path));
|
|
192
|
-
},
|
|
193
|
-
clearAnalysisCache: () => {
|
|
194
|
-
const engine = store.getEngine();
|
|
195
|
-
if (engine) engine.clearCache();
|
|
196
|
-
store.setEngine(null);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region pipeline/engine-retirement.ts
|
|
203
|
-
/**
|
|
204
|
-
* Loud rejection of the retired v1 extraction engine (openspec:
|
|
205
|
-
* retire-extract-v1).
|
|
206
|
-
*
|
|
207
|
-
* v2 is the only engine. Selecting v1 — via a plugin `engine: 'v1'` option or
|
|
208
|
-
* the `ANIMUS_ENGINE=v1` fixture env override — is a build-stopping error, never
|
|
209
|
-
* a silent upgrade to v2 (design D1: a silent flip would let a pinned consumer's
|
|
210
|
-
* build change engines without notice). Both extraction plugins call this before
|
|
211
|
-
* any engine selection so the rejection is uniform and the message is defined
|
|
212
|
-
* once.
|
|
213
|
-
*/
|
|
214
|
-
/** The one canonical retirement message, shared verbatim by both plugins and
|
|
215
|
-
* the env path (tasks.md cross-cutting: define once, reuse). */
|
|
216
|
-
const RETIRED_ENGINE_MESSAGE = "animus: extraction engine 'v1' was retired (openspec: retire-extract-v1) — v2 is the only engine; remove the engine option / ANIMUS_ENGINE override";
|
|
217
|
-
/**
|
|
218
|
-
* Throw the canonical retirement error when v1 is selected through either
|
|
219
|
-
* surface. Accepts the raw engine option as a string because the option type no
|
|
220
|
-
* longer admits `'v1'` — callers cast it so a stale `'v1'` config still fails
|
|
221
|
-
* loud at runtime instead of being silently coerced.
|
|
222
|
-
*/
|
|
223
|
-
function assertNoRetiredEngineSelection(engineOption) {
|
|
224
|
-
if (engineOption === "v1" || process.env.ANIMUS_ENGINE === "v1") throw new Error(RETIRED_ENGINE_MESSAGE);
|
|
225
|
-
}
|
|
226
|
-
//#endregion
|
|
227
|
-
//#region pipeline/content-hash.ts
|
|
228
|
-
/**
|
|
229
|
-
* MD5 content hash used for file-change detection (HMR diffing) by both
|
|
230
|
-
* extraction plugins, and for content-addressing copied asset bytes. The
|
|
231
|
-
* algorithm/encoding is a cross-plugin contract: cache keys written by one
|
|
232
|
-
* build path must compare equal in the next. Accepts a Buffer directly so
|
|
233
|
-
* binary sources hash without an intermediate string copy.
|
|
234
|
-
*/
|
|
235
|
-
function contentHash(source) {
|
|
236
|
-
return (0, crypto.createHash)("md5").update(source).digest("hex");
|
|
237
|
-
}
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region pipeline/external-keyframes.ts
|
|
240
|
-
/** Stable codes for external keyframes discovery. */
|
|
241
|
-
const KEYFRAMES_EXTERNAL_ENTRY_FAILED = "animus.keyframes.external-entry-failed";
|
|
242
|
-
const KEYFRAMES_EXPORT_COLLISION = "animus.keyframes.export-collision";
|
|
243
|
-
/**
|
|
244
|
-
* Merge `Keyframes` collections discovered from external package entries into
|
|
245
|
-
* the consumer system's collections. Keyframes are the sole carve-out from
|
|
246
|
-
* the consumer-config singular-authority rule: nothing but branded
|
|
247
|
-
* collections is read from an entry, an entry that fails to evaluate
|
|
248
|
-
* degrades to a coded diagnostic naming it, and a collection whose export
|
|
249
|
-
* name collides keeps the earlier (consumer-first) collection with a coded
|
|
250
|
-
* diagnostic instead of silently reordering names.
|
|
251
|
-
*/
|
|
252
|
-
function mergeExternalKeyframes(scan, consumerKeyframesJson, externalEntries, rootDir) {
|
|
253
|
-
const merged = {};
|
|
254
|
-
if (consumerKeyframesJson) try {
|
|
255
|
-
Object.assign(merged, JSON.parse(consumerKeyframesJson));
|
|
256
|
-
} catch {
|
|
257
|
-
return {
|
|
258
|
-
keyframesJson: consumerKeyframesJson,
|
|
259
|
-
diagnostics: []
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
const diagnostics = [];
|
|
263
|
-
const seenEntries = /* @__PURE__ */ new Set();
|
|
264
|
-
for (const entryPath of externalEntries) {
|
|
265
|
-
if (seenEntries.has(entryPath)) continue;
|
|
266
|
-
seenEntries.add(entryPath);
|
|
267
|
-
let scanned;
|
|
268
|
-
try {
|
|
269
|
-
scanned = scan(entryPath, rootDir);
|
|
270
|
-
} catch (error) {
|
|
271
|
-
diagnostics.push({
|
|
272
|
-
file: entryPath,
|
|
273
|
-
component: "keyframes",
|
|
274
|
-
kind: "warn",
|
|
275
|
-
message: `external package entry failed the keyframes scan — its collections are invisible to extraction: ${String(error)}. Keyframe collections must be reachable from the package's definition entry without evaluating framework re-exports: export them (directly or as a named re-export) from the definition entry, and avoid \`export *\` of framework packages there (${KEYFRAMES_EXTERNAL_ENTRY_FAILED})`,
|
|
276
|
-
code: KEYFRAMES_EXTERNAL_ENTRY_FAILED,
|
|
277
|
-
severity: "warn"
|
|
278
|
-
});
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (!scanned) continue;
|
|
282
|
-
let collections;
|
|
283
|
-
try {
|
|
284
|
-
collections = JSON.parse(scanned);
|
|
285
|
-
} catch {
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
for (const [exportName, collection] of Object.entries(collections)) {
|
|
289
|
-
const existing = merged[exportName];
|
|
290
|
-
if (existing !== void 0) {
|
|
291
|
-
if (JSON.stringify(existing) !== JSON.stringify(collection)) diagnostics.push({
|
|
292
|
-
file: entryPath,
|
|
293
|
-
component: exportName,
|
|
294
|
-
kind: "warn",
|
|
295
|
-
message: `keyframes collection export '${exportName}' collides with an earlier collection of the same name — the earlier one wins (${KEYFRAMES_EXPORT_COLLISION})`,
|
|
296
|
-
code: KEYFRAMES_EXPORT_COLLISION,
|
|
297
|
-
severity: "warn"
|
|
298
|
-
});
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
merged[exportName] = collection;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return {
|
|
305
|
-
keyframesJson: Object.keys(merged).length > 0 ? JSON.stringify(merged) : null,
|
|
306
|
-
diagnostics
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region pipeline/discover-files.ts
|
|
311
|
-
/**
|
|
312
|
-
* Recursively discover source files under `dir`, skipping any path that
|
|
313
|
-
* contains one of `excludePatterns` (matched as substrings of both the full
|
|
314
|
-
* and root-relative path) and keeping files whose extension is in
|
|
315
|
-
* `extensionsSet`.
|
|
316
|
-
*
|
|
317
|
-
* Single authoritative copy for both extraction plugins.
|
|
318
|
-
*/
|
|
319
|
-
function discoverFiles(dir, rootDir, excludePatterns, extensionsSet) {
|
|
320
|
-
const results = [];
|
|
321
|
-
let entries;
|
|
322
|
-
try {
|
|
323
|
-
entries = (0, fs.readdirSync)(dir, { encoding: "utf8" });
|
|
324
|
-
} catch {
|
|
325
|
-
return results;
|
|
326
|
-
}
|
|
327
|
-
for (const entry of entries) {
|
|
328
|
-
const fullPath = (0, path.join)(dir, entry);
|
|
329
|
-
const relativePath = (0, path.relative)(rootDir, fullPath);
|
|
330
|
-
if (excludePatterns.some((pattern) => fullPath.includes(pattern) || relativePath.includes(pattern))) continue;
|
|
331
|
-
let stat;
|
|
332
|
-
try {
|
|
333
|
-
stat = (0, fs.statSync)(fullPath);
|
|
334
|
-
} catch {
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (stat.isDirectory()) results.push(...discoverFiles(fullPath, rootDir, excludePatterns, extensionsSet));
|
|
338
|
-
else if (extensionsSet.has((0, path.extname)(entry))) results.push(fullPath);
|
|
339
|
-
}
|
|
340
|
-
return results;
|
|
341
|
-
}
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region pipeline/source-identity.ts
|
|
344
|
-
/**
|
|
345
|
-
* SourceId derivation authority + allowlist membership (openspec:
|
|
346
|
-
* external-source-watch-ingestion, design D1/D2/D5).
|
|
347
|
-
*
|
|
348
|
-
* One shared derivation produces the canonical source identity consumed by
|
|
349
|
-
* discovery, watch ingestion, ownership, deletion pruning, and diagnostics
|
|
350
|
-
* — raw event paths are lookup INPUTS only, so event spelling (symlink
|
|
351
|
-
* alias vs canonical, lexical vs realpath) can never fork identity.
|
|
352
|
-
*
|
|
353
|
-
* The containment and volume helpers are pure and path-API-injectable so
|
|
354
|
-
* Windows semantics are unit-testable via `path.win32` on any host; runtime
|
|
355
|
-
* callers use the ambient platform implementation.
|
|
356
|
-
*/
|
|
357
|
-
/**
|
|
358
|
-
* Structural containment: `target` is the root itself or a descendant of it,
|
|
359
|
-
* decided by `relative()` shape — never by string prefixing, so `/ui` can
|
|
360
|
-
* never claim `/ui-old`, and a cross-drive win32 target (whose relative()
|
|
361
|
-
* result is absolute) is never contained.
|
|
362
|
-
*/
|
|
363
|
-
function isPathWithinRoot(root, target, pathApi = node_path.default) {
|
|
364
|
-
const rel = pathApi.relative(root, target);
|
|
365
|
-
return rel === "" || !pathApi.isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + pathApi.sep);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Cross-volume gate (design D5): two paths share a platform path root
|
|
369
|
-
* (win32 drive letter or UNC share; always true on posix). Compared
|
|
370
|
-
* case-insensitively — win32 drive letters are case-insensitive.
|
|
371
|
-
*/
|
|
372
|
-
function sharesVolumeRoot(a, b, pathApi = node_path.default) {
|
|
373
|
-
const volumeOf = (p) => pathApi.parse(pathApi.resolve(p)).root.toLowerCase();
|
|
374
|
-
return volumeOf(a) === volumeOf(b);
|
|
375
|
-
}
|
|
376
|
-
function canonicalize(p) {
|
|
377
|
-
try {
|
|
378
|
-
return (0, node_fs.realpathSync)(p);
|
|
379
|
-
} catch {
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
function createSourceIdentity(rootDir) {
|
|
384
|
-
const normalizedRootDir = node_path.default.normalize(rootDir);
|
|
385
|
-
const canonicalRootDir = canonicalize(normalizedRootDir) ?? normalizedRootDir;
|
|
386
|
-
const roots = [];
|
|
387
|
-
const aliases = /* @__PURE__ */ new Map();
|
|
388
|
-
const owningRecord = (canonicalPath) => {
|
|
389
|
-
let owner = null;
|
|
390
|
-
for (const record of roots) {
|
|
391
|
-
if (!isPathWithinRoot(record.canonical, canonicalPath)) continue;
|
|
392
|
-
if (!owner || record.canonical.length > owner.canonical.length) owner = record;
|
|
393
|
-
}
|
|
394
|
-
return owner;
|
|
395
|
-
};
|
|
396
|
-
return {
|
|
397
|
-
rootDir: normalizedRootDir,
|
|
398
|
-
canonicalRootDir,
|
|
399
|
-
registerExternalRoot(root) {
|
|
400
|
-
const asRegistered = node_path.default.normalize(root);
|
|
401
|
-
const canonical = canonicalize(asRegistered) ?? asRegistered;
|
|
402
|
-
const existing = roots.find((record) => record.canonical === canonical);
|
|
403
|
-
if (existing) return existing.canonical;
|
|
404
|
-
roots.push({
|
|
405
|
-
asRegistered,
|
|
406
|
-
canonical
|
|
407
|
-
});
|
|
408
|
-
return canonical;
|
|
409
|
-
},
|
|
410
|
-
externalRoots() {
|
|
411
|
-
return roots.map((record) => record.canonical);
|
|
412
|
-
},
|
|
413
|
-
resolveSourceId(inputPath) {
|
|
414
|
-
const lexical = node_path.default.normalize(inputPath);
|
|
415
|
-
const canonical = canonicalize(lexical);
|
|
416
|
-
if (canonical === null) return null;
|
|
417
|
-
const owner = owningRecord(canonical);
|
|
418
|
-
const ownedBy = (record) => {
|
|
419
|
-
const pathInRoot = node_path.default.relative(record.canonical, canonical);
|
|
420
|
-
return {
|
|
421
|
-
sourceKey: node_path.default.relative(normalizedRootDir, node_path.default.join(record.asRegistered, pathInRoot)),
|
|
422
|
-
owningRoot: record.canonical,
|
|
423
|
-
pathInRoot
|
|
424
|
-
};
|
|
425
|
-
};
|
|
426
|
-
const ownerIsMoreSpecific = owner !== null && owner.canonical.length > canonicalRootDir.length;
|
|
427
|
-
let resolved;
|
|
428
|
-
if (!ownerIsMoreSpecific && isPathWithinRoot(canonicalRootDir, canonical)) {
|
|
429
|
-
const key = node_path.default.relative(canonicalRootDir, canonical);
|
|
430
|
-
resolved = {
|
|
431
|
-
sourceKey: key,
|
|
432
|
-
owningRoot: null,
|
|
433
|
-
pathInRoot: key
|
|
434
|
-
};
|
|
435
|
-
} else if (owner) resolved = ownedBy(owner);
|
|
436
|
-
else return null;
|
|
437
|
-
aliases.set(lexical, resolved);
|
|
438
|
-
aliases.set(canonical, resolved);
|
|
439
|
-
return resolved;
|
|
440
|
-
},
|
|
441
|
-
resolveDeletedSourceId(inputPath) {
|
|
442
|
-
return aliases.get(node_path.default.normalize(inputPath)) ?? null;
|
|
443
|
-
},
|
|
444
|
-
containingExternalRoot(inputPath) {
|
|
445
|
-
const lexical = node_path.default.normalize(inputPath);
|
|
446
|
-
let owner = null;
|
|
447
|
-
for (const record of roots) {
|
|
448
|
-
if (!(isPathWithinRoot(record.canonical, lexical) || isPathWithinRoot(record.asRegistered, lexical))) continue;
|
|
449
|
-
if (!owner || record.canonical.length > owner.canonical.length) owner = record;
|
|
450
|
-
}
|
|
451
|
-
if (owner) return owner.canonical;
|
|
452
|
-
const canonical = canonicalize(lexical);
|
|
453
|
-
if (canonical === null) return null;
|
|
454
|
-
for (const record of roots) {
|
|
455
|
-
if (!isPathWithinRoot(record.canonical, canonical)) continue;
|
|
456
|
-
if (!owner || record.canonical.length > owner.canonical.length) owner = record;
|
|
457
|
-
}
|
|
458
|
-
return owner?.canonical ?? null;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region pipeline/discover-packages.ts
|
|
464
|
-
/**
|
|
465
|
-
* Walk up from a resolved package entry file to the nearest directory
|
|
466
|
-
* containing a package.json (the package root). Stops at the filesystem
|
|
467
|
-
* root and returns it if no package.json is found on the way up.
|
|
468
|
-
*/
|
|
469
|
-
function findPackageRoot(absEntryPath) {
|
|
470
|
-
let pkgRoot = (0, path.dirname)(absEntryPath);
|
|
471
|
-
while (pkgRoot !== (0, path.dirname)(pkgRoot) && !(0, fs.existsSync)((0, path.join)(pkgRoot, "package.json"))) pkgRoot = (0, path.dirname)(pkgRoot);
|
|
472
|
-
return pkgRoot;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Exclusion fragments for discovery inside an external package's src/,
|
|
476
|
-
* matched against paths RELATIVE TO the src dir. Per spec
|
|
477
|
-
* external-package-file-discovery, the filters apply "within the package" —
|
|
478
|
-
* an npm-installed package whose own location is under node_modules (or a
|
|
479
|
-
* repo path containing 'dist') must still have its sources discovered.
|
|
480
|
-
*/
|
|
481
|
-
const PACKAGE_SRC_EXCLUDES = [
|
|
482
|
-
"dist",
|
|
483
|
-
"node_modules",
|
|
484
|
-
".test.",
|
|
485
|
-
".spec."
|
|
486
|
-
];
|
|
487
|
-
/** True when a PACKAGE-RELATIVE path matches a package-source exclusion
|
|
488
|
-
* fragment (the "within the package" filter — see PACKAGE_SRC_EXCLUDES). */
|
|
489
|
-
function isExcludedPackageRelativePath(rel) {
|
|
490
|
-
return PACKAGE_SRC_EXCLUDES.some((pattern) => rel.includes(pattern));
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* THE package-source walk (guardrail G1 — one policy): shared discovery with
|
|
494
|
-
* no consumer patterns, then exclusion by package-relative path so fragments
|
|
495
|
-
* in the package's own location can't blank out its sources. Used by the
|
|
496
|
-
* collector, hosts' dirty-root rewalks, and watch-path classification alike.
|
|
497
|
-
*/
|
|
498
|
-
function walkPackageSources(packageDir, extensionsSet) {
|
|
499
|
-
return discoverFiles(packageDir, packageDir, [], extensionsSet).filter((absPath) => !isExcludedPackageRelativePath((0, path.relative)(packageDir, absPath)));
|
|
500
|
-
}
|
|
501
|
-
/** Exclusions for the compiled-output fallback when a package does not ship src/. */
|
|
502
|
-
const PACKAGE_OUTPUT_EXCLUDES = [
|
|
503
|
-
"node_modules",
|
|
504
|
-
".test.",
|
|
505
|
-
".spec.",
|
|
506
|
-
".d.ts",
|
|
507
|
-
".map"
|
|
508
|
-
];
|
|
509
|
-
const isFile = (path$3) => {
|
|
510
|
-
try {
|
|
511
|
-
return (0, fs.statSync)(path$3).isFile();
|
|
512
|
-
} catch {
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
/**
|
|
517
|
-
* Resolve an absolute-path specifier (a relative `includes` entry already
|
|
518
|
-
* resolved against the system file) without a bundler: the path itself when it
|
|
519
|
-
* is a file, otherwise the extension and directory-index candidates built from
|
|
520
|
-
* the caller's extension set. Used only as a fallback — a bundler resolver that
|
|
521
|
-
* answers first still wins, since it also knows aliases and `.js`→`.ts` mapping.
|
|
522
|
-
*/
|
|
523
|
-
function resolveAbsolutePathSpecifier(absSpecifier, extensionsSet) {
|
|
524
|
-
return [
|
|
525
|
-
absSpecifier,
|
|
526
|
-
...Array.from(extensionsSet, (ext) => absSpecifier + ext),
|
|
527
|
-
...Array.from(extensionsSet, (ext) => (0, path.join)(absSpecifier, `index${ext}`))
|
|
528
|
-
].find(isFile) ?? null;
|
|
529
|
-
}
|
|
530
|
-
/** The package-name half of a bare specifier (`@scope/name/sub` → `@scope/name`). */
|
|
531
|
-
function bareSpecifierPackageName(specifier) {
|
|
532
|
-
const segments = specifier.split("/");
|
|
533
|
-
return specifier.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0];
|
|
534
|
-
}
|
|
535
|
-
function sourceEntryForSpecifier(specifier, srcDir, extensionsSet) {
|
|
536
|
-
if ((0, path.isAbsolute)(specifier)) {
|
|
537
|
-
const resolved = resolveAbsolutePathSpecifier(specifier, extensionsSet);
|
|
538
|
-
if (!resolved) return null;
|
|
539
|
-
return isPathWithinRoot(srcDir, resolved) ? resolved : null;
|
|
540
|
-
}
|
|
541
|
-
const packageName = bareSpecifierPackageName(specifier);
|
|
542
|
-
return resolveAbsolutePathSpecifier((0, path.join)(srcDir, specifier.slice(packageName.length + 1) || "index"), extensionsSet);
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* The D13 dist-freshness check: applicable only when a specifier has BOTH a
|
|
546
|
-
* walked src/ tree and a resolved dist entry that exists on disk outside that
|
|
547
|
-
* tree; stale when the dist entry's mtime is older than the newest walked
|
|
548
|
-
* source file's. Not applicable (never stale) when the entry resolves inside
|
|
549
|
-
* src/ (no dist to skew), when the entry file is missing, or when no source
|
|
550
|
-
* file's mtime is readable. Detection only — reporting is the caller's policy.
|
|
551
|
-
*/
|
|
552
|
-
function distEntryIsStale(absEntry, srcDir, srcFiles) {
|
|
553
|
-
if (isPathWithinRoot(srcDir, absEntry)) return false;
|
|
554
|
-
let distMtime;
|
|
555
|
-
try {
|
|
556
|
-
distMtime = (0, fs.statSync)(absEntry).mtimeMs;
|
|
557
|
-
} catch {
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
let newestSrcMtime = -Infinity;
|
|
561
|
-
for (const srcFile of srcFiles) try {
|
|
562
|
-
newestSrcMtime = Math.max(newestSrcMtime, (0, fs.statSync)(srcFile).mtimeMs);
|
|
563
|
-
} catch {}
|
|
564
|
-
return distMtime < newestSrcMtime;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Shared external-package source collection (spec:
|
|
568
|
-
* external-package-file-discovery), consumed by both extraction plugins.
|
|
569
|
-
* For each specifier: resolve to an absolute entry (null/throw → silently
|
|
570
|
-
* skip; an absolute-path specifier falls back to a filesystem probe), walk up
|
|
571
|
-
* to the package root, then either discover sources under src/ (redirecting
|
|
572
|
-
* module resolution to src/index.ts when present) or fall back to ingesting
|
|
573
|
-
* the resolved entry file itself.
|
|
574
|
-
*
|
|
575
|
-
* The only bundler-specific seams are callbacks: specifier resolution,
|
|
576
|
-
* dedup against already-ingested files, per-file preprocessing (MDX), and
|
|
577
|
-
* the unreadable-file warning. Hashing and caching stay in the plugins —
|
|
578
|
-
* their cache policies legitimately differ.
|
|
579
|
-
*
|
|
580
|
-
* Alongside the aggregates, one `ExternalPackageOutcome` per declared
|
|
581
|
-
* specifier records what that specifier produced. Collection never reports on
|
|
582
|
-
* them — any warning or gate is the caller's policy.
|
|
583
|
-
*/
|
|
584
|
-
async function collectExternalPackageSources(opts) {
|
|
585
|
-
const { specifiers, resolveSpecifier, rootDir, extensionsSet, hasEntry, preprocessFile, onUnreadable, onPackageResolved } = opts;
|
|
586
|
-
const entries = [];
|
|
587
|
-
const pushed = /* @__PURE__ */ new Set();
|
|
588
|
-
const packageMap = {};
|
|
589
|
-
const sourceEntries = /* @__PURE__ */ new Map();
|
|
590
|
-
const keyframesScanEntries = /* @__PURE__ */ new Map();
|
|
591
|
-
const packageDirs = [];
|
|
592
|
-
const dirOwnerSets = {};
|
|
593
|
-
const dirExtensions = {};
|
|
594
|
-
const fileOwners = {};
|
|
595
|
-
const outcomes = [];
|
|
596
|
-
const claimDir = (dir, specifier) => {
|
|
597
|
-
(dirOwnerSets[dir] ??= []).push(specifier);
|
|
598
|
-
};
|
|
599
|
-
const alreadyIngested = (relPath) => hasEntry(relPath) || pushed.has(relPath);
|
|
600
|
-
for (const specifier of specifiers) {
|
|
601
|
-
let absEntry;
|
|
602
|
-
try {
|
|
603
|
-
absEntry = await resolveSpecifier(specifier);
|
|
604
|
-
} catch {
|
|
605
|
-
absEntry = null;
|
|
606
|
-
}
|
|
607
|
-
if (!absEntry && (0, path.isAbsolute)(specifier)) absEntry = resolveAbsolutePathSpecifier(specifier, extensionsSet);
|
|
608
|
-
if (!absEntry) {
|
|
609
|
-
outcomes.push({
|
|
610
|
-
specifier,
|
|
611
|
-
outcome: "unresolvable",
|
|
612
|
-
fileCount: 0
|
|
613
|
-
});
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
const srcDir = (0, path.join)(findPackageRoot(absEntry), "src");
|
|
617
|
-
let fileCount = 0;
|
|
618
|
-
let staleDist = false;
|
|
619
|
-
if ((0, fs.existsSync)(srcDir)) {
|
|
620
|
-
packageDirs.push(srcDir);
|
|
621
|
-
claimDir(srcDir, specifier);
|
|
622
|
-
dirExtensions[srcDir] = [...extensionsSet];
|
|
623
|
-
onPackageResolved?.(specifier, srcDir);
|
|
624
|
-
const srcEntry = sourceEntryForSpecifier(specifier, srcDir, extensionsSet);
|
|
625
|
-
if (srcEntry) {
|
|
626
|
-
packageMap[specifier] = (0, path.relative)(rootDir, srcEntry);
|
|
627
|
-
sourceEntries.set(specifier, srcEntry);
|
|
628
|
-
} else packageMap[specifier] = (0, path.relative)(rootDir, absEntry);
|
|
629
|
-
keyframesScanEntries.set(specifier, srcEntry ?? absEntry);
|
|
630
|
-
if (!(0, path.isAbsolute)(specifier)) {
|
|
631
|
-
const packageName = bareSpecifierPackageName(specifier);
|
|
632
|
-
if (packageName !== specifier && !(packageName in packageMap)) {
|
|
633
|
-
const rootEntry = sourceEntryForSpecifier(packageName, srcDir, extensionsSet);
|
|
634
|
-
if (rootEntry) {
|
|
635
|
-
packageMap[packageName] = (0, path.relative)(rootDir, rootEntry);
|
|
636
|
-
sourceEntries.set(packageName, rootEntry);
|
|
637
|
-
keyframesScanEntries.set(packageName, rootEntry);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
const pkgFiles = walkPackageSources(srcDir, extensionsSet);
|
|
642
|
-
staleDist = distEntryIsStale(absEntry, srcDir, pkgFiles);
|
|
643
|
-
for (const pkgFile of pkgFiles) {
|
|
644
|
-
const relPath = (0, path.relative)(rootDir, pkgFile);
|
|
645
|
-
if (alreadyIngested(relPath)) {
|
|
646
|
-
fileCount++;
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
let source;
|
|
650
|
-
try {
|
|
651
|
-
source = (0, fs.readFileSync)(pkgFile, "utf-8");
|
|
652
|
-
} catch (err) {
|
|
653
|
-
onUnreadable(relPath, err);
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
const processed = await preprocessFile(source, relPath, pkgFile);
|
|
657
|
-
if (!processed) continue;
|
|
658
|
-
entries.push({
|
|
659
|
-
path: processed.relPath,
|
|
660
|
-
source: processed.source
|
|
661
|
-
});
|
|
662
|
-
pushed.add(processed.relPath);
|
|
663
|
-
fileOwners[processed.relPath] ??= specifier;
|
|
664
|
-
fileCount++;
|
|
665
|
-
}
|
|
666
|
-
} else {
|
|
667
|
-
const outputDir = (0, path.dirname)(absEntry);
|
|
668
|
-
packageDirs.push(outputDir);
|
|
669
|
-
claimDir(outputDir, specifier);
|
|
670
|
-
onPackageResolved?.(specifier, outputDir);
|
|
671
|
-
packageMap[specifier] = (0, path.relative)(rootDir, absEntry);
|
|
672
|
-
keyframesScanEntries.set(specifier, absEntry);
|
|
673
|
-
const outputExtensions = new Set(extensionsSet);
|
|
674
|
-
outputExtensions.add((0, path.extname)(absEntry));
|
|
675
|
-
dirExtensions[outputDir] = [...outputExtensions];
|
|
676
|
-
const outputFiles = discoverFiles(outputDir, outputDir, [], outputExtensions).filter((file) => {
|
|
677
|
-
const relToOutput = (0, path.relative)(outputDir, file);
|
|
678
|
-
return !PACKAGE_OUTPUT_EXCLUDES.some((pattern) => relToOutput.includes(pattern));
|
|
679
|
-
});
|
|
680
|
-
if (!outputFiles.includes(absEntry)) outputFiles.unshift(absEntry);
|
|
681
|
-
for (const outputFile of outputFiles) {
|
|
682
|
-
const outputRelPath = (0, path.relative)(rootDir, outputFile);
|
|
683
|
-
if (alreadyIngested(outputRelPath)) {
|
|
684
|
-
fileCount++;
|
|
685
|
-
continue;
|
|
686
|
-
}
|
|
687
|
-
let source;
|
|
688
|
-
try {
|
|
689
|
-
source = (0, fs.readFileSync)(outputFile, "utf-8");
|
|
690
|
-
} catch (err) {
|
|
691
|
-
onUnreadable(outputRelPath, err);
|
|
692
|
-
continue;
|
|
693
|
-
}
|
|
694
|
-
const processed = await preprocessFile(source, outputRelPath, outputFile);
|
|
695
|
-
if (!processed) continue;
|
|
696
|
-
entries.push({
|
|
697
|
-
path: processed.relPath,
|
|
698
|
-
source: processed.source
|
|
699
|
-
});
|
|
700
|
-
pushed.add(processed.relPath);
|
|
701
|
-
fileOwners[processed.relPath] ??= specifier;
|
|
702
|
-
fileCount++;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
outcomes.push({
|
|
706
|
-
specifier,
|
|
707
|
-
outcome: staleDist ? "stale-dist" : fileCount > 0 ? "resolved" : "empty",
|
|
708
|
-
fileCount
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
return {
|
|
712
|
-
entries,
|
|
713
|
-
packageMap,
|
|
714
|
-
sourceEntries,
|
|
715
|
-
keyframesScanEntries,
|
|
716
|
-
packageDirs,
|
|
717
|
-
dirOwnerSets,
|
|
718
|
-
dirExtensions,
|
|
719
|
-
fileOwners,
|
|
720
|
-
outcomes
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
/** First-declared specifier per package dir — the single-value ownership
|
|
724
|
-
* view correlation consumers key on, derived from `dirOwnerSets`. */
|
|
725
|
-
function firstOwners(dirOwnerSets) {
|
|
726
|
-
const owners = {};
|
|
727
|
-
for (const [dir, specifiers] of Object.entries(dirOwnerSets)) if (specifiers.length > 0) owners[dir] = specifiers[0];
|
|
728
|
-
return owners;
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Excise a set of rejected specifiers from a collection result ATOMICALLY
|
|
732
|
-
* (openspec: external-source-watch-ingestion, design D5): the returned copy
|
|
733
|
-
* carries no entries, package-map targets, source entries, package dirs, or
|
|
734
|
-
* ownership for the rejected packages — a package dir is removed only when
|
|
735
|
-
* EVERY specifier that claimed it is rejected (a dir-level rejection, such
|
|
736
|
-
* as the cross-volume gate, always rejects them together). Outcome records
|
|
737
|
-
* are reporting inputs, not membership, and pass through untouched.
|
|
738
|
-
*/
|
|
739
|
-
function excludeCollectedPackages(collected, rejectedSpecifiers, rootDir) {
|
|
740
|
-
if (rejectedSpecifiers.size === 0) return collected;
|
|
741
|
-
const rejectedDirs = Object.entries(collected.dirOwnerSets).filter(([, specs]) => specs.every((s) => rejectedSpecifiers.has(s))).map(([dir]) => dir);
|
|
742
|
-
const underRejectedDir = (absPath) => rejectedDirs.some((dir) => isPathWithinRoot(dir, absPath));
|
|
743
|
-
const targetRejected = (specifier, absTarget) => rejectedSpecifiers.has(specifier) || underRejectedDir(absTarget);
|
|
744
|
-
const packageMap = {};
|
|
745
|
-
for (const [specifier, relTarget] of Object.entries(collected.packageMap)) {
|
|
746
|
-
if (targetRejected(specifier, (0, path.resolve)(rootDir, relTarget))) continue;
|
|
747
|
-
packageMap[specifier] = relTarget;
|
|
748
|
-
}
|
|
749
|
-
const sourceEntries = /* @__PURE__ */ new Map();
|
|
750
|
-
for (const [specifier, absEntry] of collected.sourceEntries) {
|
|
751
|
-
if (targetRejected(specifier, absEntry)) continue;
|
|
752
|
-
sourceEntries.set(specifier, absEntry);
|
|
753
|
-
}
|
|
754
|
-
const keyframesScanEntries = /* @__PURE__ */ new Map();
|
|
755
|
-
for (const [specifier, absEntry] of collected.keyframesScanEntries) {
|
|
756
|
-
if (targetRejected(specifier, absEntry)) continue;
|
|
757
|
-
keyframesScanEntries.set(specifier, absEntry);
|
|
758
|
-
}
|
|
759
|
-
const dirOwnerSets = {};
|
|
760
|
-
for (const [dir, specs] of Object.entries(collected.dirOwnerSets)) {
|
|
761
|
-
const kept = specs.filter((s) => !rejectedSpecifiers.has(s));
|
|
762
|
-
if (kept.length === 0) continue;
|
|
763
|
-
dirOwnerSets[dir] = kept;
|
|
764
|
-
}
|
|
765
|
-
const dirExtensions = {};
|
|
766
|
-
for (const [dir, exts] of Object.entries(collected.dirExtensions)) {
|
|
767
|
-
if (rejectedDirs.includes(dir)) continue;
|
|
768
|
-
dirExtensions[dir] = exts;
|
|
769
|
-
}
|
|
770
|
-
const fileOwners = {};
|
|
771
|
-
for (const [relPath, owner] of Object.entries(collected.fileOwners)) {
|
|
772
|
-
if (rejectedSpecifiers.has(owner)) continue;
|
|
773
|
-
fileOwners[relPath] = owner;
|
|
774
|
-
}
|
|
775
|
-
return {
|
|
776
|
-
entries: collected.entries.filter((entry) => !rejectedSpecifiers.has(collected.fileOwners[entry.path])),
|
|
777
|
-
packageMap,
|
|
778
|
-
sourceEntries,
|
|
779
|
-
keyframesScanEntries,
|
|
780
|
-
packageDirs: collected.packageDirs.filter((dir) => !rejectedDirs.includes(dir)),
|
|
781
|
-
dirOwnerSets,
|
|
782
|
-
dirExtensions,
|
|
783
|
-
fileOwners,
|
|
784
|
-
outcomes: collected.outcomes
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Extract external DS package names from inheritance declarations in the
|
|
789
|
-
* system file.
|
|
790
|
-
*
|
|
791
|
-
* Supports four forms:
|
|
792
|
-
* - Primary: `createSystem(...).extend(identifier)` chain calls
|
|
793
|
-
* (repeatable, mixable with `.from()` links; each call
|
|
794
|
-
* contributes one source; a library-bundle identifier
|
|
795
|
-
* traces its base import)
|
|
796
|
-
* - Deprecated chain: `createSystem(...).from(identifier)` chain calls
|
|
797
|
-
* - Deprecated alias: `createSystem({ includes: [identifier, ...] })`
|
|
798
|
-
* - Legacy: `.includes([identifier, ...])` chain method (RC
|
|
799
|
-
* migration fallback)
|
|
800
|
-
*
|
|
801
|
-
* For each identifier found, traces back to its import declaration and returns
|
|
802
|
-
* the import specifier: a bare specifier normalized to its package name, a
|
|
803
|
-
* relative specifier resolved against the system file's directory into an
|
|
804
|
-
* absolute path (so a sibling package referenced by path contributes discovery
|
|
805
|
-
* too). Only packages explicitly declared through one of these forms are
|
|
806
|
-
* treated as external DS dependencies.
|
|
807
|
-
*
|
|
808
|
-
* Falls back to empty array if no declaration is found.
|
|
809
|
-
*/
|
|
810
|
-
/**
|
|
811
|
-
* The message for the strict/warn gate over unresolvable includes, or null
|
|
812
|
-
* when every declared specifier resolved (external-package-file-discovery:
|
|
813
|
-
* silence is never an outcome — non-strict consumers warn with this line,
|
|
814
|
-
* strict consumers throw it).
|
|
815
|
-
*/
|
|
816
|
-
function unresolvableIncludesMessage(outcomes) {
|
|
817
|
-
const unresolvable = outcomes.filter((record) => record.outcome === "unresolvable").map((record) => record.specifier);
|
|
818
|
-
if (unresolvable.length === 0) return null;
|
|
819
|
-
return `[animus-extract] unresolvable include specifier(s): ${unresolvable.join(", ")}`;
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* The message for the strict/warn gate over stale dist entries
|
|
823
|
-
* (first-class-extension D13), or null when no declared specifier is stale.
|
|
824
|
-
* A stale dist silently skews merged registry content while discovery
|
|
825
|
-
* compiles the fresh sources, so it surfaces like an unresolvable specifier:
|
|
826
|
-
* non-strict consumers warn with this line, strict consumers throw it.
|
|
827
|
-
*/
|
|
828
|
-
function staleDistIncludesMessage(outcomes) {
|
|
829
|
-
const stale = outcomes.filter((record) => record.outcome === "stale-dist").map((record) => record.specifier);
|
|
830
|
-
if (stale.length === 0) return null;
|
|
831
|
-
return `[animus-extract] stale dist for include specifier(s): ${stale.join(", ")} — dist entry is older than the newest src/ file; rebuild the package(s) before extracting`;
|
|
832
|
-
}
|
|
833
|
-
function extractSystemFilePackages(systemFilePath) {
|
|
834
|
-
let source;
|
|
835
|
-
try {
|
|
836
|
-
source = (0, fs.readFileSync)(systemFilePath, "utf-8");
|
|
837
|
-
} catch {
|
|
838
|
-
return [];
|
|
839
|
-
}
|
|
840
|
-
const identifiers = /* @__PURE__ */ new Set();
|
|
841
|
-
const constructorRegex = /createSystem\s*\(\s*\{[^}]*?\bincludes\s*:\s*\[([^\]]*)\]/gs;
|
|
842
|
-
const chainRegex = /\.includes\s*\(\s*\[([^\]]*)\]\s*\)/gs;
|
|
843
|
-
const collectIdentifiers = (regex) => {
|
|
844
|
-
let match;
|
|
845
|
-
while ((match = regex.exec(source)) !== null) {
|
|
846
|
-
const inner = match[1];
|
|
847
|
-
for (const token of inner.split(",")) {
|
|
848
|
-
const id = token.trim();
|
|
849
|
-
if (id && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(id)) identifiers.add(id);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
collectIdentifiers(constructorRegex);
|
|
854
|
-
collectIdentifiers(chainRegex);
|
|
855
|
-
const IDENT_START_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]*/;
|
|
856
|
-
/** Position after any run of whitespace, line comments, block comments. */
|
|
857
|
-
const skipTrivia = (from) => {
|
|
858
|
-
let pos = from;
|
|
859
|
-
for (;;) {
|
|
860
|
-
while (pos < source.length && /\s/.test(source[pos])) pos++;
|
|
861
|
-
if (source.startsWith("//", pos)) {
|
|
862
|
-
const newline = source.indexOf("\n", pos);
|
|
863
|
-
pos = newline === -1 ? source.length : newline + 1;
|
|
864
|
-
continue;
|
|
865
|
-
}
|
|
866
|
-
if (source.startsWith("/*", pos)) {
|
|
867
|
-
const close = source.indexOf("*/", pos + 2);
|
|
868
|
-
pos = close === -1 ? source.length : close + 2;
|
|
869
|
-
continue;
|
|
870
|
-
}
|
|
871
|
-
return pos;
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
/**
|
|
875
|
-
* Consume consecutive extend/from links starting at `from`, collecting
|
|
876
|
-
* each link's base identifier; tolerates trivia between tokens and a
|
|
877
|
-
* trailing comma in the argument list. Returns the position after the
|
|
878
|
-
* last consumed link (`from` itself when none matched).
|
|
879
|
-
*/
|
|
880
|
-
const consumeChainLinks = (from) => {
|
|
881
|
-
let pos = from;
|
|
882
|
-
for (;;) {
|
|
883
|
-
let cursor = skipTrivia(pos);
|
|
884
|
-
if (source[cursor] !== ".") return pos;
|
|
885
|
-
cursor = skipTrivia(cursor + 1);
|
|
886
|
-
const method = IDENT_START_RE.exec(source.slice(cursor))?.[0];
|
|
887
|
-
if (method !== "extend" && method !== "from") return pos;
|
|
888
|
-
cursor = skipTrivia(cursor + method.length);
|
|
889
|
-
if (source[cursor] !== "(") return pos;
|
|
890
|
-
cursor = skipTrivia(cursor + 1);
|
|
891
|
-
const base = IDENT_START_RE.exec(source.slice(cursor))?.[0];
|
|
892
|
-
if (!base) return pos;
|
|
893
|
-
cursor = skipTrivia(cursor + base.length);
|
|
894
|
-
while (source[cursor] === ".") {
|
|
895
|
-
const afterDot = skipTrivia(cursor + 1);
|
|
896
|
-
const segment = IDENT_START_RE.exec(source.slice(afterDot))?.[0];
|
|
897
|
-
if (!segment) break;
|
|
898
|
-
cursor = skipTrivia(afterDot + segment.length);
|
|
899
|
-
}
|
|
900
|
-
if (source[cursor] === ",") cursor = skipTrivia(cursor + 1);
|
|
901
|
-
if (source[cursor] !== ")") return pos;
|
|
902
|
-
identifiers.add(base);
|
|
903
|
-
pos = cursor + 1;
|
|
904
|
-
}
|
|
905
|
-
};
|
|
906
|
-
/** Identifier assigned directly before `index` (`const x = <here>`), if any. */
|
|
907
|
-
const boundIdentifierBefore = (index) => {
|
|
908
|
-
const match = /([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*$/.exec(source.slice(0, index));
|
|
909
|
-
return match ? match[1] : null;
|
|
910
|
-
};
|
|
911
|
-
const chainRootIdentifiers = /* @__PURE__ */ new Set();
|
|
912
|
-
const createSystemAnchor = /createSystem\s*\(/g;
|
|
913
|
-
let anchorMatch;
|
|
914
|
-
while ((anchorMatch = createSystemAnchor.exec(source)) !== null) {
|
|
915
|
-
let pos = anchorMatch.index + anchorMatch[0].length;
|
|
916
|
-
let depth = 1;
|
|
917
|
-
while (pos < source.length && depth > 0) {
|
|
918
|
-
const ch = source[pos];
|
|
919
|
-
if (ch === "(") depth++;
|
|
920
|
-
else if (ch === ")") depth--;
|
|
921
|
-
pos++;
|
|
922
|
-
}
|
|
923
|
-
consumeChainLinks(pos);
|
|
924
|
-
const bound = boundIdentifierBefore(anchorMatch.index);
|
|
925
|
-
if (bound) chainRootIdentifiers.add(bound);
|
|
926
|
-
}
|
|
927
|
-
const scannedRoots = /* @__PURE__ */ new Set();
|
|
928
|
-
for (;;) {
|
|
929
|
-
const pendingRoots = [...chainRootIdentifiers].filter((root) => !scannedRoots.has(root));
|
|
930
|
-
if (pendingRoots.length === 0) break;
|
|
931
|
-
for (const root of pendingRoots) {
|
|
932
|
-
scannedRoots.add(root);
|
|
933
|
-
const rootUse = new RegExp(`(?<![a-zA-Z0-9_$])${root.replace(/\$/g, "\\$")}(?![a-zA-Z0-9_$])`, "g");
|
|
934
|
-
let useMatch;
|
|
935
|
-
while ((useMatch = rootUse.exec(source)) !== null) {
|
|
936
|
-
const afterIdentifier = useMatch.index + useMatch[0].length;
|
|
937
|
-
if (consumeChainLinks(afterIdentifier) === afterIdentifier) continue;
|
|
938
|
-
const bound = boundIdentifierBefore(useMatch.index);
|
|
939
|
-
if (bound) chainRootIdentifiers.add(bound);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
if (identifiers.size === 0) return [];
|
|
944
|
-
const importMap = /* @__PURE__ */ new Map();
|
|
945
|
-
const importRegex = /^\s*import\s+(?:([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*)?(?:\{([^}]*)\}|([a-zA-Z_$][a-zA-Z0-9_$]*))\s+from\s+['"]([^'"]+)['"]/gm;
|
|
946
|
-
let importMatch;
|
|
947
|
-
while ((importMatch = importRegex.exec(source)) !== null) {
|
|
948
|
-
const [, comboDefault, namedImports, defaultImport, specifier] = importMatch;
|
|
949
|
-
if (comboDefault) importMap.set(comboDefault, specifier);
|
|
950
|
-
if (defaultImport) importMap.set(defaultImport, specifier);
|
|
951
|
-
if (namedImports) for (const binding of namedImports.split(",")) {
|
|
952
|
-
const parts = binding.trim().split(/\s+as\s+/);
|
|
953
|
-
const localName = (parts[1] || parts[0]).trim();
|
|
954
|
-
if (localName) importMap.set(localName, specifier);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
const systemFileDir = (0, path.dirname)(systemFilePath);
|
|
958
|
-
const packages = /* @__PURE__ */ new Set();
|
|
959
|
-
for (const id of identifiers) {
|
|
960
|
-
const specifier = importMap.get(id);
|
|
961
|
-
if (!specifier) continue;
|
|
962
|
-
if (specifier.startsWith(".")) packages.add((0, path.resolve)(systemFileDir, specifier));
|
|
963
|
-
else packages.add(specifier);
|
|
964
|
-
}
|
|
965
|
-
return Array.from(packages);
|
|
966
|
-
}
|
|
967
|
-
//#endregion
|
|
968
|
-
//#region pipeline/asset-placeholders.ts
|
|
969
|
-
/**
|
|
970
|
-
* Host-side handling of `asset()` placeholders (global-styles-system):
|
|
971
|
-
* `animus-asset:<specifier>` markers ride through the sandbox and the
|
|
972
|
-
* emitter byte-exact; each HOST plugin substitutes them with its bundler's
|
|
973
|
-
* resolved asset URL after extraction. This module owns the shared scanning
|
|
974
|
-
* and replacement mechanics — resolution and strict gating stay at the
|
|
975
|
-
* plugin call sites.
|
|
976
|
-
*/
|
|
977
|
-
/** Mirrors the producer-side constant in `@animus-ui/system`'s `asset.ts`
|
|
978
|
-
* (extract must not take a runtime dependency on system); the pairing is
|
|
979
|
-
* pinned by a contract test in `tests/asset-placeholders.test.ts`. */
|
|
980
|
-
const ASSET_PLACEHOLDER_PREFIX = "animus-asset:";
|
|
981
|
-
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
982
|
-
const PREFIX_RE = escapeRegExp(ASSET_PLACEHOLDER_PREFIX);
|
|
983
|
-
/**
|
|
984
|
-
* Quoted `url('animus-asset:<specifier>')` form — the emitter always quotes
|
|
985
|
-
* `url()` values, so a quoted match carries the FULL specifier, including
|
|
986
|
-
* whitespace and parentheses (D5 pins the placeholder as specifier-verbatim,
|
|
987
|
-
* so scanning fidelity is the only place such characters can be honored).
|
|
988
|
-
*/
|
|
989
|
-
const QUOTED_PLACEHOLDER_RE = new RegExp(`(['"])${PREFIX_RE}([^'"]*?)\\1`, "g");
|
|
990
|
-
/** Bare-form fallback: a placeholder up to CSS url()/quote/whitespace. */
|
|
991
|
-
const BARE_PLACEHOLDER_RE = new RegExp(`${PREFIX_RE}([^'")\\s]+)`, "g");
|
|
992
|
-
/** Unique asset specifiers referenced by placeholders, in appearance order. */
|
|
993
|
-
function findAssetSpecifiers(css) {
|
|
994
|
-
if (!css.includes("animus-asset:")) return [];
|
|
995
|
-
const seen = /* @__PURE__ */ new Set();
|
|
996
|
-
const remainder = css.replace(QUOTED_PLACEHOLDER_RE, (_match, _quote, specifier) => {
|
|
997
|
-
seen.add(specifier);
|
|
998
|
-
return "";
|
|
999
|
-
});
|
|
1000
|
-
for (const match of remainder.matchAll(BARE_PLACEHOLDER_RE)) seen.add(match[1]);
|
|
1001
|
-
return [...seen];
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Replace each specifier's placeholder with its substitution. Specifiers
|
|
1005
|
-
* absent from the map keep their placeholder — the caller decides whether
|
|
1006
|
-
* that is a strict failure or a warn-and-emit-literally. A substitution may
|
|
1007
|
-
* itself be a bundler marker (e.g. Vite's `__VITE_ASSET__<ref>__`) that the
|
|
1008
|
-
* host's own asset pipeline resolves to a hashed file name later.
|
|
1009
|
-
*
|
|
1010
|
-
* Each replacement is anchored to a following delimiter (quote, `)`,
|
|
1011
|
-
* whitespace, or end of input) so a specifier that textually prefixes a
|
|
1012
|
-
* longer one can never clobber the longer placeholder; longest-first
|
|
1013
|
-
* ordering additionally lets the longer of two mapped specifiers claim its
|
|
1014
|
-
* occurrences before the shorter runs.
|
|
1015
|
-
*/
|
|
1016
|
-
function substituteAssetPlaceholders(css, urlBySpecifier) {
|
|
1017
|
-
if (urlBySpecifier.size === 0) return css;
|
|
1018
|
-
if (!css.includes("animus-asset:")) return css;
|
|
1019
|
-
const specifiers = [...urlBySpecifier.keys()].sort((a, b) => b.length - a.length);
|
|
1020
|
-
let out = css;
|
|
1021
|
-
for (const specifier of specifiers) {
|
|
1022
|
-
const placeholder = new RegExp(escapeRegExp(ASSET_PLACEHOLDER_PREFIX + specifier) + String.raw`(?=['")\s]|$)`, "g");
|
|
1023
|
-
out = out.replace(placeholder, () => urlBySpecifier.get(specifier));
|
|
1024
|
-
}
|
|
1025
|
-
return out;
|
|
1026
|
-
}
|
|
1027
|
-
//#endregion
|
|
1028
|
-
//#region pipeline/resolve-asset.ts
|
|
1029
|
-
/**
|
|
1030
|
-
* Node-side asset specifier resolution shared by the host plugins (the
|
|
1031
|
-
* asset() contract, global-styles-system): host path aliases apply FIRST —
|
|
1032
|
-
* an alias such as `@fonts` works in application modules, so
|
|
1033
|
-
* `asset('@fonts/inter.woff2')` must resolve identically — then direct Node
|
|
1034
|
-
* resolution, then the package-root fallback (exports maps rarely list
|
|
1035
|
-
* asset subpaths). Bundler-native resolution (Vite's `this.resolve`) is
|
|
1036
|
-
* still preferred where available; this resolver covers the paths that have
|
|
1037
|
-
* no bundler hook (Next's session, Vite's dev re-analysis).
|
|
1038
|
-
*/
|
|
1039
|
-
const requireByRoot = /* @__PURE__ */ new Map();
|
|
1040
|
-
function requireAnchoredAt(rootDir) {
|
|
1041
|
-
let req = requireByRoot.get(rootDir);
|
|
1042
|
-
if (!req) {
|
|
1043
|
-
req = (0, module$1.createRequire)((0, path.join)(rootDir, "package.json"));
|
|
1044
|
-
requireByRoot.set(rootDir, req);
|
|
1045
|
-
}
|
|
1046
|
-
return req;
|
|
1047
|
-
}
|
|
1048
|
-
function packageRootFromEntry(entry) {
|
|
1049
|
-
let current = (0, path.dirname)(entry);
|
|
1050
|
-
while (true) {
|
|
1051
|
-
if ((0, fs.existsSync)((0, path.join)(current, "package.json"))) return current;
|
|
1052
|
-
const parent = (0, path.dirname)(current);
|
|
1053
|
-
if (parent === current) return null;
|
|
1054
|
-
current = parent;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
const aliasTableCache = /* @__PURE__ */ new Map();
|
|
1058
|
-
function parseAliasTable(pathAliasesJson) {
|
|
1059
|
-
const cached = aliasTableCache.get(pathAliasesJson);
|
|
1060
|
-
if (cached) return cached;
|
|
1061
|
-
let aliases;
|
|
1062
|
-
try {
|
|
1063
|
-
aliases = JSON.parse(pathAliasesJson).aliases ?? [];
|
|
1064
|
-
} catch {
|
|
1065
|
-
aliases = [];
|
|
1066
|
-
}
|
|
1067
|
-
aliasTableCache.set(pathAliasesJson, aliases);
|
|
1068
|
-
return aliases;
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Map a specifier through the harvested host alias table (the same
|
|
1072
|
-
* `pathAliasesJson` wire the engine consumes — entries pre-sorted longest
|
|
1073
|
-
* pattern first by `buildPathAliasesJson`). Returns an absolute path to an
|
|
1074
|
-
* EXISTING file, or null when no alias claims the specifier.
|
|
1075
|
-
*/
|
|
1076
|
-
function resolveThroughPathAliases(specifier, rootDir, pathAliasesJson) {
|
|
1077
|
-
if (!pathAliasesJson) return null;
|
|
1078
|
-
const aliases = parseAliasTable(pathAliasesJson);
|
|
1079
|
-
for (const alias of aliases) {
|
|
1080
|
-
let mapped = null;
|
|
1081
|
-
if (alias.type === "exact") {
|
|
1082
|
-
if (alias.pattern === specifier) mapped = alias.replacement;
|
|
1083
|
-
} else if (specifier.startsWith(alias.pattern)) mapped = alias.replacement + specifier.slice(alias.pattern.length);
|
|
1084
|
-
if (mapped === null) continue;
|
|
1085
|
-
const absolute = (0, path.isAbsolute)(mapped) ? mapped : (0, path.join)(rootDir, mapped);
|
|
1086
|
-
if ((0, fs.existsSync)(absolute)) return absolute;
|
|
1087
|
-
}
|
|
1088
|
-
return null;
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Resolve an asset specifier to an absolute file: host aliases, then direct
|
|
1092
|
-
* Node resolution anchored at `rootDir`, then the package-root fallback.
|
|
1093
|
-
* Returns null when nothing matches — strict gating stays at the caller.
|
|
1094
|
-
*/
|
|
1095
|
-
function resolveAssetFile(specifier, rootDir, pathAliasesJson) {
|
|
1096
|
-
const aliased = resolveThroughPathAliases(specifier, rootDir, pathAliasesJson);
|
|
1097
|
-
if (aliased) return aliased;
|
|
1098
|
-
const requireFromRoot = requireAnchoredAt(rootDir);
|
|
1099
|
-
try {
|
|
1100
|
-
return requireFromRoot.resolve(specifier);
|
|
1101
|
-
} catch {}
|
|
1102
|
-
const segments = specifier.split("/");
|
|
1103
|
-
const packageName = specifier.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0];
|
|
1104
|
-
const subpath = specifier.slice(packageName.length + 1);
|
|
1105
|
-
if (!subpath) return null;
|
|
1106
|
-
for (const modulesDir of requireFromRoot.resolve.paths(packageName) ?? []) {
|
|
1107
|
-
const packageRoot = (0, path.join)(modulesDir, packageName);
|
|
1108
|
-
if (!(0, fs.existsSync)((0, path.join)(packageRoot, "package.json"))) continue;
|
|
1109
|
-
const candidate = (0, path.join)(packageRoot, subpath);
|
|
1110
|
-
if ((0, fs.existsSync)(candidate)) return candidate;
|
|
1111
|
-
}
|
|
1112
|
-
try {
|
|
1113
|
-
const packageRoot = packageRootFromEntry(requireFromRoot.resolve(packageName));
|
|
1114
|
-
if (!packageRoot) return null;
|
|
1115
|
-
const candidate = (0, path.join)(packageRoot, subpath);
|
|
1116
|
-
return (0, fs.existsSync)(candidate) ? candidate : null;
|
|
1117
|
-
} catch {
|
|
1118
|
-
return null;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
//#endregion
|
|
1122
|
-
//#region pipeline/correlate-external-tokens.ts
|
|
1123
|
-
/**
|
|
1124
|
-
* Index the loader-captured theme manifests by owning specifier. Module paths
|
|
1125
|
-
* are canonical absolute paths (symlinks resolved), so each package dir is
|
|
1126
|
-
* realpath'd before prefix-matching; a module outside every known package dir
|
|
1127
|
-
* (typically the consumer's own theme) contributes nothing.
|
|
1128
|
-
*/
|
|
1129
|
-
function buildSourceTokenIndex(opts) {
|
|
1130
|
-
const index = /* @__PURE__ */ new Map();
|
|
1131
|
-
if (!opts.sourceThemeManifestsJson) return index;
|
|
1132
|
-
let manifests;
|
|
1133
|
-
try {
|
|
1134
|
-
manifests = JSON.parse(opts.sourceThemeManifestsJson);
|
|
1135
|
-
} catch {
|
|
1136
|
-
return index;
|
|
1137
|
-
}
|
|
1138
|
-
const realDirOwners = [];
|
|
1139
|
-
const addOwnerDir = (dir, specifier) => {
|
|
1140
|
-
if (!realDirOwners.some((entry) => entry.dir === dir)) realDirOwners.push({
|
|
1141
|
-
dir,
|
|
1142
|
-
specifier
|
|
1143
|
-
});
|
|
1144
|
-
};
|
|
1145
|
-
for (const [dir, specifier] of Object.entries(opts.dirOwners)) {
|
|
1146
|
-
let real = dir;
|
|
1147
|
-
try {
|
|
1148
|
-
real = (0, fs.realpathSync)(dir);
|
|
1149
|
-
} catch {}
|
|
1150
|
-
addOwnerDir(real, specifier);
|
|
1151
|
-
let packageRoot = real;
|
|
1152
|
-
while (packageRoot !== (0, path.dirname)(packageRoot) && !(0, fs.existsSync)((0, path.join)(packageRoot, "package.json"))) packageRoot = (0, path.dirname)(packageRoot);
|
|
1153
|
-
if ((0, fs.existsSync)((0, path.join)(packageRoot, "package.json"))) addOwnerDir(packageRoot, specifier);
|
|
1154
|
-
}
|
|
1155
|
-
for (const [modulePath, exports] of Object.entries(manifests)) {
|
|
1156
|
-
const owner = realDirOwners.find(({ dir }) => isPathWithinRoot(dir, modulePath));
|
|
1157
|
-
if (!owner) continue;
|
|
1158
|
-
let tokens = index.get(owner.specifier);
|
|
1159
|
-
if (!tokens) {
|
|
1160
|
-
tokens = /* @__PURE__ */ new Set();
|
|
1161
|
-
index.set(owner.specifier, tokens);
|
|
1162
|
-
}
|
|
1163
|
-
for (const paths of Object.values(exports)) for (const token of paths) tokens.add(token);
|
|
1164
|
-
}
|
|
1165
|
-
return index;
|
|
1166
|
-
}
|
|
1167
|
-
/**
|
|
1168
|
-
* The correlation join. Returns one teaching-error message per distinct
|
|
1169
|
-
* (component, token, specifier) whose file belongs to a discovered source AND
|
|
1170
|
-
* whose token that source's manifest defines. The messages follow the
|
|
1171
|
-
* standard severity routing at the CALLER (throw under `strict`, warn
|
|
1172
|
-
* otherwise) — this join never reports on its own.
|
|
1173
|
-
*/
|
|
1174
|
-
function correlateExternalTokenDiagnostics(opts) {
|
|
1175
|
-
const messages = [];
|
|
1176
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1177
|
-
for (const diagnostic of opts.diagnostics ?? []) {
|
|
1178
|
-
if (diagnostic.kind !== "external-token-candidate" || !diagnostic.token) continue;
|
|
1179
|
-
const specifier = opts.fileOwners[diagnostic.file];
|
|
1180
|
-
if (!specifier) continue;
|
|
1181
|
-
if (!opts.sourceTokens.get(specifier)?.has(diagnostic.token)) continue;
|
|
1182
|
-
const key = `${diagnostic.component}\u0000${diagnostic.token}\u0000${specifier}`;
|
|
1183
|
-
if (seen.has(key)) continue;
|
|
1184
|
-
seen.add(key);
|
|
1185
|
-
messages.push(`${diagnostic.component} (from '${specifier}') references token '${diagnostic.token}', which the consumer theme does not define — inherit the source's tokens with createTheme().extend(...) using the tokens (or bundle) export of '${specifier}'`);
|
|
1186
|
-
}
|
|
1187
|
-
return messages;
|
|
1188
|
-
}
|
|
1189
|
-
const indexCache = /* @__PURE__ */ new WeakMap();
|
|
1190
|
-
/**
|
|
1191
|
-
* The complete cross-source token-contract gate both plugins share
|
|
1192
|
-
* (extraction-diagnostics): index the loader-captured source manifests,
|
|
1193
|
-
* join them against the engine's candidates, and route the resulting
|
|
1194
|
-
* teaching errors — throw under `strict`, warn otherwise. One entry point
|
|
1195
|
-
* so the two hosts cannot drift on wiring or severity semantics.
|
|
1196
|
-
*/
|
|
1197
|
-
function enforceExternalTokenContracts(opts) {
|
|
1198
|
-
const manifestsJson = opts.sourceThemeManifestsJson ?? "";
|
|
1199
|
-
const cached = indexCache.get(opts.dirOwners);
|
|
1200
|
-
let sourceTokens;
|
|
1201
|
-
if (cached && cached.manifestsJson === manifestsJson) sourceTokens = cached.index;
|
|
1202
|
-
else {
|
|
1203
|
-
sourceTokens = buildSourceTokenIndex({
|
|
1204
|
-
sourceThemeManifestsJson: opts.sourceThemeManifestsJson,
|
|
1205
|
-
dirOwners: opts.dirOwners
|
|
1206
|
-
});
|
|
1207
|
-
indexCache.set(opts.dirOwners, {
|
|
1208
|
-
manifestsJson,
|
|
1209
|
-
index: sourceTokens
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
const messages = correlateExternalTokenDiagnostics({
|
|
1213
|
-
diagnostics: opts.diagnostics,
|
|
1214
|
-
fileOwners: opts.fileOwners,
|
|
1215
|
-
sourceTokens
|
|
1216
|
-
});
|
|
1217
|
-
if (messages.length === 0) return;
|
|
1218
|
-
if (opts.strict) throw new Error(`${opts.prefix} ${messages.join("\n")}`);
|
|
1219
|
-
for (const message of messages) opts.warn(message);
|
|
1220
|
-
}
|
|
1221
|
-
//#endregion
|
|
1222
|
-
//#region pipeline/path-aliases.ts
|
|
1223
|
-
/**
|
|
1224
|
-
* Normalize alias pairs: strip a `rootDir` prefix from targets, classify
|
|
1225
|
-
* exact (file) vs prefix (directory) matches, force trailing slashes on
|
|
1226
|
-
* prefix entries, and sort longest pattern first for correct matching
|
|
1227
|
-
* priority. Returns null when no entries survive.
|
|
1228
|
-
*/
|
|
1229
|
-
function buildPathAliasesJson(pairs, rootDir) {
|
|
1230
|
-
const entries = [];
|
|
1231
|
-
for (const { pattern, target, kind } of pairs) {
|
|
1232
|
-
const replacement = target.startsWith(rootDir) ? target.slice(rootDir.length + 1) : target;
|
|
1233
|
-
if (kind ? kind === "exact" : /\.\w+$/.test(replacement)) entries.push({
|
|
1234
|
-
pattern,
|
|
1235
|
-
replacement,
|
|
1236
|
-
type: "exact"
|
|
1237
|
-
});
|
|
1238
|
-
else entries.push({
|
|
1239
|
-
pattern: pattern.endsWith("/") ? pattern : pattern + "/",
|
|
1240
|
-
replacement: replacement.endsWith("/") ? replacement : replacement + "/",
|
|
1241
|
-
type: "prefix"
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
entries.sort((a, b) => b.pattern.length - a.pattern.length);
|
|
1245
|
-
if (entries.length === 0) return null;
|
|
1246
|
-
return {
|
|
1247
|
-
json: JSON.stringify({ aliases: entries }),
|
|
1248
|
-
count: entries.length
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
//#endregion
|
|
1252
|
-
//#region pipeline/post-process-css.ts
|
|
1253
|
-
/**
|
|
1254
|
-
* CSS post-processing (spec: css-post-processing) — Lightning CSS
|
|
1255
|
-
* autoprefixing, syntax lowering, and optional minification against
|
|
1256
|
-
* browserslist targets. The single implementation consumed by both the
|
|
1257
|
-
* Vite plugin (virtual-module serve time) and the Next.js plugin
|
|
1258
|
-
* (ExtractionSession artifact emission).
|
|
1259
|
-
*/
|
|
1260
|
-
/**
|
|
1261
|
-
* Resolve browser targets for Lightning CSS.
|
|
1262
|
-
* Priority: explicit config → project browserslist → 'defaults' fallback.
|
|
1263
|
-
*/
|
|
1264
|
-
function resolveLightningTargets(explicitTargets, rootDir) {
|
|
1265
|
-
let queries;
|
|
1266
|
-
if (explicitTargets) queries = Array.isArray(explicitTargets) ? explicitTargets : [explicitTargets];
|
|
1267
|
-
else {
|
|
1268
|
-
const detected = (0, browserslist.default)(void 0, { path: rootDir });
|
|
1269
|
-
queries = detected.length > 0 ? detected : (0, browserslist.default)("defaults");
|
|
1270
|
-
}
|
|
1271
|
-
return (0, lightningcss.browserslistToTargets)(Array.isArray(queries) && typeof queries[0] === "string" && queries[0].includes(" ") ? (0, browserslist.default)(queries) : queries);
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Post-process CSS with Lightning CSS: autoprefixing + optional minification.
|
|
1275
|
-
* On failure, returns the original CSS and logs a warning.
|
|
1276
|
-
*/
|
|
1277
|
-
function postProcessCss(css, opts) {
|
|
1278
|
-
if (!css) return css;
|
|
1279
|
-
try {
|
|
1280
|
-
return (0, lightningcss.transform)({
|
|
1281
|
-
filename: "animus-extracted.css",
|
|
1282
|
-
code: Buffer.from(css),
|
|
1283
|
-
minify: opts.minify,
|
|
1284
|
-
targets: opts.targets
|
|
1285
|
-
}).code.toString();
|
|
1286
|
-
} catch (e) {
|
|
1287
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
1288
|
-
(opts.warnFn ?? console.warn)(`[animus] Lightning CSS post-processing failed: ${msg}`);
|
|
1289
|
-
return css;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
//#endregion
|
|
1293
|
-
//#region pipeline/manifest-diagnostics.ts
|
|
1294
|
-
/** Stable code for selector forms with no substitutable subject.
|
|
1295
|
-
* Mirrors the Rust constant in `extract-v2/src/eval.rs`. */
|
|
1296
|
-
const SELECTOR_UNSUPPORTED_SUBJECT = "animus.selector.unsupported-subject";
|
|
1297
|
-
/** Unresolved-parent chain-drop message (mirrors the Rust diagnostic in
|
|
1298
|
-
* `extract-v2` — the ONE encoding of this message shape; consumers match
|
|
1299
|
-
* through the helpers below, never their own regex copies). */
|
|
1300
|
-
const UNRESOLVED_PARENT_RE = /chain dropped: could not resolve parent component '([^']+)'/;
|
|
1301
|
-
/** True when the diagnostic reports a chain dropped for an unresolved
|
|
1302
|
-
* parent component. */
|
|
1303
|
-
function isUnresolvedParentDrop(diagnostic) {
|
|
1304
|
-
return typeof diagnostic?.message === "string" && UNRESOLVED_PARENT_RE.test(diagnostic.message);
|
|
1305
|
-
}
|
|
1306
|
-
/** The parent binding named by an unresolved-parent drop, or null when the
|
|
1307
|
-
* diagnostic is not one. */
|
|
1308
|
-
function unresolvedParentName(diagnostic) {
|
|
1309
|
-
if (typeof diagnostic?.message !== "string") return null;
|
|
1310
|
-
return UNRESOLVED_PARENT_RE.exec(diagnostic.message)?.[1] ?? null;
|
|
1311
|
-
}
|
|
1312
|
-
/** True when the selector string carries at least one substitutable `&`
|
|
1313
|
-
* subject outside quoted text (mirrors the Rust `selector_subject` walk —
|
|
1314
|
-
* ancestor, leading, and repeated subjects all count; a `&` inside a
|
|
1315
|
-
* quoted attribute value does not). */
|
|
1316
|
-
function hasSelectorSubject(value) {
|
|
1317
|
-
let quote = null;
|
|
1318
|
-
let escaped = false;
|
|
1319
|
-
for (const c of value) {
|
|
1320
|
-
if (escaped) {
|
|
1321
|
-
escaped = false;
|
|
1322
|
-
continue;
|
|
1323
|
-
}
|
|
1324
|
-
if (c === "\\") {
|
|
1325
|
-
escaped = true;
|
|
1326
|
-
continue;
|
|
1327
|
-
}
|
|
1328
|
-
if (quote !== null) {
|
|
1329
|
-
if (c === quote) quote = null;
|
|
1330
|
-
} else if (c === "\"" || c === "'") quote = c;
|
|
1331
|
-
else if (c === "&") return true;
|
|
1332
|
-
}
|
|
1333
|
-
return false;
|
|
1334
|
-
}
|
|
1335
|
-
/**
|
|
1336
|
-
* Synthesize coded diagnostics for registered selector-alias values that
|
|
1337
|
-
* look selector-shaped (`&` present) but carry no substitutable subject —
|
|
1338
|
-
* every `&` sits inside quoted text, so there is nothing to anchor the
|
|
1339
|
-
* class to. Ancestor-prefixed and repeated subjects are supported and pass
|
|
1340
|
-
* validation. The system-config boundary is where these must fail loud
|
|
1341
|
-
* (alias values never reach the evaluator's key guard).
|
|
1342
|
-
*/
|
|
1343
|
-
function collectSelectorAliasDiagnostics(selectorAliasesJson) {
|
|
1344
|
-
if (!selectorAliasesJson) return [];
|
|
1345
|
-
let aliases;
|
|
1346
|
-
try {
|
|
1347
|
-
aliases = JSON.parse(selectorAliasesJson);
|
|
1348
|
-
} catch {
|
|
1349
|
-
return [];
|
|
1350
|
-
}
|
|
1351
|
-
const diagnostics = [];
|
|
1352
|
-
for (const [name, value] of Object.entries(aliases)) {
|
|
1353
|
-
if (typeof value !== "string") continue;
|
|
1354
|
-
if (value.includes("&") && !hasSelectorSubject(value)) diagnostics.push({
|
|
1355
|
-
file: "system",
|
|
1356
|
-
component: name,
|
|
1357
|
-
kind: "warn",
|
|
1358
|
-
message: `selector alias '${name}' value '${value}' has no substitutable '&' subject outside quoted text (${SELECTOR_UNSUPPORTED_SUBJECT})`,
|
|
1359
|
-
code: SELECTOR_UNSUPPORTED_SUBJECT,
|
|
1360
|
-
severity: "error"
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
return diagnostics;
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Surface extraction-manifest diagnostics through a plugin's warn channel.
|
|
1367
|
-
*
|
|
1368
|
-
* Single authoritative copy for both extraction plugins — and the single
|
|
1369
|
-
* strict-escalation policy point: error-severity diagnostics throw one
|
|
1370
|
-
* Error naming every offender when `policy.strict`, and print as warnings
|
|
1371
|
-
* otherwise. Surfaces `bail` (component not extracted), `skip` (component
|
|
1372
|
-
* skipped), and `warn` kinds; unknown kinds stay silent. Printed lines
|
|
1373
|
-
* include the diagnostic code when the message doesn't already carry it.
|
|
1374
|
-
*/
|
|
1375
|
-
function surfaceManifestDiagnostics(manifest, warn, policy = {}) {
|
|
1376
|
-
const errors = [];
|
|
1377
|
-
const diagnostics = policy.prepend?.length ? [...policy.prepend, ...manifest.diagnostics ?? []] : manifest.diagnostics ?? [];
|
|
1378
|
-
for (const diagnostic of diagnostics) {
|
|
1379
|
-
let line = null;
|
|
1380
|
-
if (diagnostic.kind === "bail") line = `⚠ ${diagnostic.component} not extracted: ${diagnostic.message}`;
|
|
1381
|
-
else if (diagnostic.kind === "skip") line = `⚠ ${diagnostic.component}: skipped ${diagnostic.message}`;
|
|
1382
|
-
else if (diagnostic.kind === "warn") line = `⚠ ${diagnostic.file}: ${diagnostic.component}: ${diagnostic.message}`;
|
|
1383
|
-
if (line === null) continue;
|
|
1384
|
-
if (diagnostic.code && !diagnostic.message.includes(diagnostic.code)) line += ` [${diagnostic.code}]`;
|
|
1385
|
-
if (policy.strict && diagnostic.severity === "error") {
|
|
1386
|
-
errors.push(`${diagnostic.code ?? "error"} — ${diagnostic.component}: ${diagnostic.message}`);
|
|
1387
|
-
continue;
|
|
1388
|
-
}
|
|
1389
|
-
warn(line);
|
|
1390
|
-
}
|
|
1391
|
-
if (errors.length > 0) throw new Error(`[animus] strict: ${errors.length} error diagnostic(s):\n${errors.join("\n")}`);
|
|
1392
|
-
}
|
|
1393
|
-
//#endregion
|
|
1394
|
-
//#region pipeline/unit-fallback.ts
|
|
1395
|
-
/**
|
|
1396
|
-
* Append `px` to bare numeric values in CSS declarations for properties
|
|
1397
|
-
* that expect length units. Unitless properties are preserved as-is.
|
|
1398
|
-
* Numbers inside CSS function calls (cubic-bezier, rgb, calc, etc.) are skipped.
|
|
1399
|
-
*/
|
|
1400
|
-
function applyUnitFallback(css) {
|
|
1401
|
-
return css.replace(/([a-z-]+)\s*:\s*([^;{}]+);/g, (match, prop, value) => {
|
|
1402
|
-
if ((0, _animus_ui_properties.isUnitlessProperty)(prop)) return match;
|
|
1403
|
-
let depth = 0;
|
|
1404
|
-
let fixed = "";
|
|
1405
|
-
let i = 0;
|
|
1406
|
-
while (i < value.length) if (value[i] === "(") {
|
|
1407
|
-
depth++;
|
|
1408
|
-
fixed += value[i];
|
|
1409
|
-
i++;
|
|
1410
|
-
} else if (value[i] === ")") {
|
|
1411
|
-
depth--;
|
|
1412
|
-
fixed += value[i];
|
|
1413
|
-
i++;
|
|
1414
|
-
} else if (depth > 0) {
|
|
1415
|
-
fixed += value[i];
|
|
1416
|
-
i++;
|
|
1417
|
-
} else {
|
|
1418
|
-
const numMatch = value.slice(i).match(/^(-?\d+\.?\d*)/);
|
|
1419
|
-
if (numMatch) {
|
|
1420
|
-
const num = numMatch[1];
|
|
1421
|
-
const after = value[i + num.length];
|
|
1422
|
-
if (after && /[a-z%]/i.test(after)) fixed += num;
|
|
1423
|
-
else fixed += num + "px";
|
|
1424
|
-
i += num.length;
|
|
1425
|
-
} else {
|
|
1426
|
-
fixed += value[i];
|
|
1427
|
-
i++;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
return fixed !== value ? `${prop}:${fixed};` : match;
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
//#endregion
|
|
1434
|
-
//#region pipeline/run-analysis.ts
|
|
1435
|
-
/**
|
|
1436
|
-
* Build the named `analyzeProject` input set from analysis options. Also
|
|
1437
|
-
* the persistence shape for `.animus/analysis-inputs.json` — an isolated
|
|
1438
|
-
* process can replay the analysis from exactly this object
|
|
1439
|
-
* (spec: next-turbopack-integration).
|
|
1440
|
-
*/
|
|
1441
|
-
function buildAnalysisInputs(opts) {
|
|
1442
|
-
return {
|
|
1443
|
-
filesJson: JSON.stringify(opts.fileEntries),
|
|
1444
|
-
scalesJson: opts.system.scalesJson,
|
|
1445
|
-
variableMapJson: opts.system.variableMapJson,
|
|
1446
|
-
contextualVarsJson: opts.system.contextualVarsJson,
|
|
1447
|
-
propConfigJson: opts.system.propConfigJson,
|
|
1448
|
-
groupRegistryJson: opts.system.groupRegistryJson,
|
|
1449
|
-
packageResolutionJson: JSON.stringify(opts.packageMap),
|
|
1450
|
-
devMode: opts.devMode,
|
|
1451
|
-
emitterConfigJson: JSON.stringify({
|
|
1452
|
-
runtime_import: opts.emitter.runtimeImport,
|
|
1453
|
-
css_module_id: opts.emitter.cssModuleId,
|
|
1454
|
-
...opts.emitter.systemPropsModuleId ? { system_props_module_id: opts.emitter.systemPropsModuleId } : {}
|
|
1455
|
-
}),
|
|
1456
|
-
selectorAliasesJson: opts.system.selectorAliasesJson,
|
|
1457
|
-
globalStyleBlocksJson: opts.system.globalStyleBlocksJson,
|
|
1458
|
-
pathAliasesJson: opts.pathAliasesJson,
|
|
1459
|
-
keyframesJson: opts.system.keyframesJson,
|
|
1460
|
-
staticCssJson: opts.staticCssJson ?? null,
|
|
1461
|
-
conditionAliasesJson: opts.system.conditionAliasesJson ?? null,
|
|
1462
|
-
transformSourcesJson: opts.system.transformSourcesJson ?? null,
|
|
1463
|
-
externalDirsJson: opts.externalDirs?.length && hasSourceThemeManifests(opts.system) ? JSON.stringify(opts.externalDirs) : null
|
|
1464
|
-
};
|
|
1465
|
-
}
|
|
1466
|
-
/** Whether the loader captured at least one source built-theme manifest. */
|
|
1467
|
-
function hasSourceThemeManifests(system) {
|
|
1468
|
-
const json = system.sourceThemeManifestsJson;
|
|
1469
|
-
return typeof json === "string" && json.length > 0 && json !== "{}";
|
|
1470
|
-
}
|
|
1471
|
-
/**
|
|
1472
|
-
* The one analysis invocation both plugins share: build the emitter
|
|
1473
|
-
* config, serialize inputs, call the NAPI `analyzeProject`, parse the
|
|
1474
|
-
* manifest, surface its diagnostics, and resolve the CSS outputs.
|
|
1475
|
-
*
|
|
1476
|
-
* Error handling stays at the call site (strict-mode throw vs warn).
|
|
1477
|
-
*/
|
|
1478
|
-
function runProjectAnalysis(engineApi, opts) {
|
|
1479
|
-
const { analyzeProject } = engineApi();
|
|
1480
|
-
let t = performance.now();
|
|
1481
|
-
const inputs = buildAnalysisInputs(opts);
|
|
1482
|
-
const serializeMs = Math.round(performance.now() - t);
|
|
1483
|
-
t = performance.now();
|
|
1484
|
-
const manifestJson = analyzeProject(...buildAnalyzeProjectArgs(inputs));
|
|
1485
|
-
const extractMs = Math.round(performance.now() - t);
|
|
1486
|
-
t = performance.now();
|
|
1487
|
-
const manifest = JSON.parse(manifestJson);
|
|
1488
|
-
surfaceManifestDiagnostics(manifest, opts.warn, {
|
|
1489
|
-
strict: opts.strict,
|
|
1490
|
-
prepend: [...collectSelectorAliasDiagnostics(opts.system.selectorAliasesJson), ...opts.extraDiagnostics ?? []]
|
|
1491
|
-
});
|
|
1492
|
-
const parseMs = Math.round(performance.now() - t);
|
|
1493
|
-
return {
|
|
1494
|
-
manifest,
|
|
1495
|
-
manifestJson,
|
|
1496
|
-
globalCss: manifest?.sheets?.global || "",
|
|
1497
|
-
componentCss: applyUnitFallback(manifest?.css || ""),
|
|
1498
|
-
inputs,
|
|
1499
|
-
timings: {
|
|
1500
|
-
serializeMs,
|
|
1501
|
-
extractMs,
|
|
1502
|
-
parseMs
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
/**
|
|
1507
|
-
* Clear the engine's per-file analysis cache so stale results from a prior
|
|
1508
|
-
* build never bleed into a fresh run. Tolerates engines without the
|
|
1509
|
-
* capability (older builds) — the probe is benign.
|
|
1510
|
-
*/
|
|
1511
|
-
function clearEngineCache(engineApi) {
|
|
1512
|
-
try {
|
|
1513
|
-
const { clearAnalysisCache } = engineApi();
|
|
1514
|
-
clearAnalysisCache();
|
|
1515
|
-
} catch {}
|
|
1516
|
-
}
|
|
1517
|
-
//#endregion
|
|
1518
|
-
//#region pipeline/static-css.ts
|
|
1519
|
-
/** Key-sorted stringify so semantically identical configs serialize
|
|
1520
|
-
* identically (stable analysis-inputs hashing). */
|
|
1521
|
-
function stableStringify(value) {
|
|
1522
|
-
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
1523
|
-
if (value !== null && typeof value === "object") return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
1524
|
-
return JSON.stringify(value);
|
|
1525
|
-
}
|
|
1526
|
-
/** Serialize a staticCss option for the engine; null when absent/empty. */
|
|
1527
|
-
function serializeStaticCss(config) {
|
|
1528
|
-
if (!config) return null;
|
|
1529
|
-
const json = stableStringify(config);
|
|
1530
|
-
return json === "{}" ? null : json;
|
|
1531
|
-
}
|
|
1532
|
-
//#endregion
|
|
1533
|
-
//#region pipeline/prefix.ts
|
|
1534
|
-
/**
|
|
1535
|
-
* Apply namespace prefix to a variable map, CSS variable declarations, and theme JSON.
|
|
1536
|
-
*
|
|
1537
|
-
* Variable map: `{ "colors.ember": "--color-ember" }` -> `{ "colors.ember": "--prefix-color-ember" }`
|
|
1538
|
-
* Variable CSS: `--color-ember: #FF2800` -> `--prefix-color-ember: #FF2800`
|
|
1539
|
-
* `var(--color-ember)` -> `var(--prefix-color-ember)`
|
|
1540
|
-
* Theme JSON: `{ "colors.ember": "var(--color-ember)" }` -> `{ "colors.ember": "var(--prefix-color-ember)" }`
|
|
1541
|
-
*/
|
|
1542
|
-
function applyPrefix(prefix, variableMapJson, variableCss, themeJson, contextualVarsJson) {
|
|
1543
|
-
if (!prefix) return {
|
|
1544
|
-
variableMapJson,
|
|
1545
|
-
variableCss,
|
|
1546
|
-
themeJson,
|
|
1547
|
-
contextualVarsJson
|
|
1548
|
-
};
|
|
1549
|
-
const varRefRe = /var\(--([a-zA-Z][\w-]*)\)/g;
|
|
1550
|
-
const map = JSON.parse(variableMapJson);
|
|
1551
|
-
const prefixed = {};
|
|
1552
|
-
for (const [key, varName] of Object.entries(map)) prefixed[key] = varName.startsWith("--") ? `--${prefix}-${varName.slice(2)}` : varName;
|
|
1553
|
-
let css = variableCss;
|
|
1554
|
-
css = css.replace(/--([a-zA-Z][\w-]*)\s*:/g, `--${prefix}-$1:`);
|
|
1555
|
-
css = css.replace(varRefRe, `var(--${prefix}-$1)`);
|
|
1556
|
-
const result = {
|
|
1557
|
-
variableMapJson: JSON.stringify(prefixed),
|
|
1558
|
-
variableCss: css
|
|
1559
|
-
};
|
|
1560
|
-
if (themeJson) result.themeJson = themeJson.replace(varRefRe, `var(--${prefix}-$1)`);
|
|
1561
|
-
if (contextualVarsJson) {
|
|
1562
|
-
const ctxVars = JSON.parse(contextualVarsJson);
|
|
1563
|
-
const prefixedCtx = {};
|
|
1564
|
-
for (const [scale, names] of Object.entries(ctxVars)) prefixedCtx[scale] = names.map((name) => `${prefix}-${name}`);
|
|
1565
|
-
result.contextualVarsJson = JSON.stringify(prefixedCtx);
|
|
1566
|
-
}
|
|
1567
|
-
return result;
|
|
1568
|
-
}
|
|
1569
|
-
//#endregion
|
|
1570
|
-
//#region pipeline/system-config.ts
|
|
1571
|
-
/**
|
|
1572
|
-
* Load a SystemInstance via the engine's `loadSystemModule` and normalize
|
|
1573
|
-
* it into a SystemConfig. When `prefix` is set, CSS variable names in the
|
|
1574
|
-
* variable map/css (and theme + contextual vars when affected) are
|
|
1575
|
-
* namespaced via the shared `applyPrefix`.
|
|
1576
|
-
*
|
|
1577
|
-
* Error handling stays at the call site — the Vite plugin warns (or throws
|
|
1578
|
-
* in strict mode) and keeps its previous config, the Next plugin lets the
|
|
1579
|
-
* failure propagate.
|
|
1580
|
-
*/
|
|
1581
|
-
function loadSystemConfig(engineApi, opts) {
|
|
1582
|
-
const { loadSystemModule } = engineApi();
|
|
1583
|
-
const config = loadSystemModule(opts.systemPath, opts.rootDir);
|
|
1584
|
-
let scalesJson = config.scalesJson;
|
|
1585
|
-
let variableMapJson = config.variableMapJson;
|
|
1586
|
-
let variableCss = config.variableCss;
|
|
1587
|
-
let contextualVarsJson = config.contextualVarsJson || null;
|
|
1588
|
-
if (opts.prefix) {
|
|
1589
|
-
const prefixed = applyPrefix(opts.prefix, variableMapJson, variableCss, scalesJson, contextualVarsJson || void 0);
|
|
1590
|
-
variableMapJson = prefixed.variableMapJson;
|
|
1591
|
-
variableCss = prefixed.variableCss;
|
|
1592
|
-
if (prefixed.themeJson) scalesJson = prefixed.themeJson;
|
|
1593
|
-
if (prefixed.contextualVarsJson) contextualVarsJson = prefixed.contextualVarsJson;
|
|
1594
|
-
}
|
|
1595
|
-
return {
|
|
1596
|
-
propConfigJson: config.propConfig,
|
|
1597
|
-
groupRegistryJson: config.groupRegistry,
|
|
1598
|
-
scalesJson,
|
|
1599
|
-
variableMapJson,
|
|
1600
|
-
variableCss,
|
|
1601
|
-
contextualVarsJson,
|
|
1602
|
-
selectorAliasesJson: config.selectorAliases || null,
|
|
1603
|
-
conditionAliasesJson: config.conditionAliases || null,
|
|
1604
|
-
transformSourcesJson: config.transformSources || null,
|
|
1605
|
-
globalStyleBlocksJson: config.globalStyleBlocks || null,
|
|
1606
|
-
keyframesJson: config.keyframesBlocks || null,
|
|
1607
|
-
dependencies: config.dependencies ?? [],
|
|
1608
|
-
sourceThemeManifestsJson: config.sourceThemeManifests || null
|
|
1609
|
-
};
|
|
1610
|
-
}
|
|
1611
|
-
//#endregion
|
|
1612
|
-
//#region pipeline/dynamic-prop-config.ts
|
|
1613
|
-
function buildDynamicPropConfig(dynamicProps) {
|
|
1614
|
-
const configEntries = {};
|
|
1615
|
-
for (const [propName, meta] of Object.entries(dynamicProps)) {
|
|
1616
|
-
if (!meta.varName || !meta.slotClass) throw new Error(`buildDynamicPropConfig: dynamic prop '${propName}' carries no slot metadata — expected varName and slotClass, got keys [${Object.keys(meta).join(", ")}].`);
|
|
1617
|
-
const entry = {
|
|
1618
|
-
varName: meta.varName,
|
|
1619
|
-
slotClass: meta.slotClass
|
|
1620
|
-
};
|
|
1621
|
-
if (meta.property) entry.property = meta.property;
|
|
1622
|
-
if (meta.properties && meta.properties.length > 0) entry.properties = meta.properties;
|
|
1623
|
-
if (meta.transformName) entry.transformName = meta.transformName;
|
|
1624
|
-
if (meta.scaleValues && Object.keys(meta.scaleValues).length > 0) entry.scaleValues = meta.scaleValues;
|
|
1625
|
-
configEntries[propName] = entry;
|
|
1626
|
-
}
|
|
1627
|
-
return configEntries;
|
|
1628
|
-
}
|
|
1629
|
-
//#endregion
|
|
1630
|
-
//#region pipeline/system-props-module.ts
|
|
1631
|
-
/**
|
|
1632
|
-
* Build the source of the runtime system-props module — served as
|
|
1633
|
-
* `virtual:animus/system-props` by the Vite plugin and written to
|
|
1634
|
-
* `.animus/system-props.js` by the Next plugin. One generator so the two
|
|
1635
|
-
* runtimes can never drift.
|
|
1636
|
-
*
|
|
1637
|
-
* Runtime transform functions for dynamic props are not yet supported
|
|
1638
|
-
* (transforms are resolved at extraction time via boa_engine in Rust), so
|
|
1639
|
-
* `transforms` defaults to an empty object literal.
|
|
1640
|
-
*
|
|
1641
|
-
* `dynamicPropConfig` entries carry the CSS property the slot class declares
|
|
1642
|
-
* — the runtime's unit-fallback decision. Their field order and omission
|
|
1643
|
-
* rules belong to buildDynamicPropConfig.
|
|
1644
|
-
*/
|
|
1645
|
-
function buildSystemPropsModule(opts) {
|
|
1646
|
-
const dynamicPropConfig = buildDynamicPropConfig(opts.dynamicProps);
|
|
1647
|
-
return `export const systemPropMap = ${opts.systemPropMapJson};\nexport const systemPropGroups = ${opts.groupRegistryJson};\nexport const dynamicPropConfig = ${JSON.stringify(dynamicPropConfig)};\nexport const transforms = ${opts.transformsSource ?? "{}"};\n`;
|
|
1648
|
-
}
|
|
1649
|
-
//#endregion
|
|
1650
|
-
//#region pipeline/timing-waterfall.ts
|
|
1651
|
-
/**
|
|
1652
|
-
* Rust-side timing phases as reported in `manifest.timing`, in waterfall
|
|
1653
|
-
* order, with their display labels. Mirrors the timing struct in the
|
|
1654
|
-
* extract-v2 crate — a renamed or added Rust phase is updated here once,
|
|
1655
|
-
* not per plugin.
|
|
1656
|
-
*/
|
|
1657
|
-
const RUST_TIMING_PHASES = [
|
|
1658
|
-
["parseAndWalk", "parse+walk"],
|
|
1659
|
-
["importResolution", "imports"],
|
|
1660
|
-
["extensionProvenance", "provenance"],
|
|
1661
|
-
["topologicalSort", "topo-sort"],
|
|
1662
|
-
["chainEvaluation", "chains"],
|
|
1663
|
-
["jsxScanning", "jsx-scan"],
|
|
1664
|
-
["systemPropAggregation", "sys-props"],
|
|
1665
|
-
["usageLedger", "usage"],
|
|
1666
|
-
["reconciliation", "reconcile"],
|
|
1667
|
-
["cssGeneration", "css-gen"],
|
|
1668
|
-
["manifestSerialization", "serialize"]
|
|
1669
|
-
];
|
|
1670
|
-
/**
|
|
1671
|
-
* Format the Rust timing waterfall as log lines. `indent` and `labelWidth`
|
|
1672
|
-
* let each plugin keep its established column layout; the phase table and
|
|
1673
|
-
* the `(N files, M cached)` suffix are shared.
|
|
1674
|
-
*/
|
|
1675
|
-
function formatRustTimingWaterfall(timing, opts) {
|
|
1676
|
-
const lines = [];
|
|
1677
|
-
for (const [key, label] of RUST_TIMING_PHASES) {
|
|
1678
|
-
const ms = timing[key] ?? 0;
|
|
1679
|
-
const pad = " ".repeat(Math.max(0, opts.labelWidth - label.length));
|
|
1680
|
-
const extra = key === "parseAndWalk" ? ` (${timing.fileCount ?? 0} files, ${timing.cacheHits ?? 0} cached)` : "";
|
|
1681
|
-
lines.push(`${opts.indent}${label}${pad}${String(ms).padStart(5)}ms${extra}`);
|
|
1682
|
-
}
|
|
1683
|
-
return lines;
|
|
1684
|
-
}
|
|
1685
|
-
//#endregion
|
|
1686
|
-
//#region pipeline/tsconfig-paths.ts
|
|
1687
|
-
/**
|
|
1688
|
-
* tsconfig `paths` → alias pairs for the Rust `pathAliasesJson` contract
|
|
1689
|
-
* (via `buildPathAliasesJson`). Used by drivers that cannot harvest aliases
|
|
1690
|
-
* from a live bundler config — Turbopack exposes none.
|
|
1691
|
-
*
|
|
1692
|
-
* Semantics (deliberately the TypeScript subset that matters for import
|
|
1693
|
-
* provenance): JSONC tolerated (comments + trailing commas); `extends`
|
|
1694
|
-
* chains followed (string or array; missing parents and cycles skipped);
|
|
1695
|
-
* the NEAREST config declaring `paths` wins wholesale (TS replaces the
|
|
1696
|
-
* object, never merges); targets resolve against the nearest `baseUrl`
|
|
1697
|
-
* (resolved from its declaring config's directory) or, absent one, the
|
|
1698
|
-
* directory of the config declaring `paths`; first target per pattern.
|
|
1699
|
-
* `x/*` patterns become prefix pairs, non-wildcard patterns exact pairs,
|
|
1700
|
-
* bare `*` catch-alls and mid-pattern wildcards are skipped.
|
|
1701
|
-
*/
|
|
1702
|
-
/** String-aware JSONC → JSON: strips // and block comments + trailing commas. */
|
|
1703
|
-
function stripJsonc(text) {
|
|
1704
|
-
let out = "";
|
|
1705
|
-
let inString = false;
|
|
1706
|
-
let inLine = false;
|
|
1707
|
-
let inBlock = false;
|
|
1708
|
-
for (let i = 0; i < text.length; i++) {
|
|
1709
|
-
const ch = text[i];
|
|
1710
|
-
const next = text[i + 1];
|
|
1711
|
-
if (inLine) {
|
|
1712
|
-
if (ch === "\n") {
|
|
1713
|
-
inLine = false;
|
|
1714
|
-
out += ch;
|
|
1715
|
-
}
|
|
1716
|
-
continue;
|
|
1717
|
-
}
|
|
1718
|
-
if (inBlock) {
|
|
1719
|
-
if (ch === "*" && next === "/") {
|
|
1720
|
-
inBlock = false;
|
|
1721
|
-
i++;
|
|
1722
|
-
}
|
|
1723
|
-
continue;
|
|
1724
|
-
}
|
|
1725
|
-
if (inString) {
|
|
1726
|
-
out += ch;
|
|
1727
|
-
if (ch === "\\") {
|
|
1728
|
-
out += next ?? "";
|
|
1729
|
-
i++;
|
|
1730
|
-
} else if (ch === "\"") inString = false;
|
|
1731
|
-
continue;
|
|
1732
|
-
}
|
|
1733
|
-
if (ch === "\"") {
|
|
1734
|
-
inString = true;
|
|
1735
|
-
out += ch;
|
|
1736
|
-
continue;
|
|
1737
|
-
}
|
|
1738
|
-
if (ch === "/" && next === "/") {
|
|
1739
|
-
inLine = true;
|
|
1740
|
-
i++;
|
|
1741
|
-
continue;
|
|
1742
|
-
}
|
|
1743
|
-
if (ch === "/" && next === "*") {
|
|
1744
|
-
inBlock = true;
|
|
1745
|
-
i++;
|
|
1746
|
-
continue;
|
|
1747
|
-
}
|
|
1748
|
-
out += ch;
|
|
1749
|
-
}
|
|
1750
|
-
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
1751
|
-
}
|
|
1752
|
-
function readConfig(path$2) {
|
|
1753
|
-
let raw;
|
|
1754
|
-
try {
|
|
1755
|
-
raw = (0, fs.readFileSync)(path$2, "utf-8");
|
|
1756
|
-
} catch {
|
|
1757
|
-
return null;
|
|
1758
|
-
}
|
|
1759
|
-
try {
|
|
1760
|
-
const json = JSON.parse(stripJsonc(raw));
|
|
1761
|
-
return {
|
|
1762
|
-
dir: (0, path.dirname)(path$2),
|
|
1763
|
-
compilerOptions: json.compilerOptions ?? {},
|
|
1764
|
-
extends: json.extends
|
|
1765
|
-
};
|
|
1766
|
-
} catch {
|
|
1767
|
-
return null;
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
function resolveExtendsTarget(specifier, fromDir) {
|
|
1771
|
-
if (specifier.startsWith(".") || (0, path.isAbsolute)(specifier)) {
|
|
1772
|
-
const base = (0, path.resolve)(fromDir, specifier);
|
|
1773
|
-
for (const candidate of [
|
|
1774
|
-
base,
|
|
1775
|
-
`${base}.json`,
|
|
1776
|
-
(0, path.join)(base, "tsconfig.json")
|
|
1777
|
-
]) if ((0, fs.existsSync)(candidate)) return candidate;
|
|
1778
|
-
return null;
|
|
1779
|
-
}
|
|
1780
|
-
try {
|
|
1781
|
-
return require.resolve(specifier.endsWith(".json") ? specifier : `${specifier}/tsconfig.json`, { paths: [fromDir] });
|
|
1782
|
-
} catch {
|
|
1783
|
-
try {
|
|
1784
|
-
return require.resolve(specifier, { paths: [fromDir] });
|
|
1785
|
-
} catch {
|
|
1786
|
-
return null;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
/** Child-first flattened extends chain starting at `entryPath`. */
|
|
1791
|
-
function loadChain(entryPath) {
|
|
1792
|
-
const chain = [];
|
|
1793
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1794
|
-
const queue = [entryPath];
|
|
1795
|
-
while (queue.length > 0) {
|
|
1796
|
-
const key = (0, path.resolve)(queue.shift());
|
|
1797
|
-
if (visited.has(key)) continue;
|
|
1798
|
-
visited.add(key);
|
|
1799
|
-
const node = readConfig(key);
|
|
1800
|
-
if (!node) continue;
|
|
1801
|
-
chain.push(node);
|
|
1802
|
-
const parents = Array.isArray(node.extends) ? node.extends : node.extends !== void 0 ? [node.extends] : [];
|
|
1803
|
-
for (const parent of parents) {
|
|
1804
|
-
if (typeof parent !== "string") continue;
|
|
1805
|
-
const resolved = resolveExtendsTarget(parent, node.dir);
|
|
1806
|
-
if (resolved) queue.push(resolved);
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
return chain;
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* Read the project's tsconfig path aliases as pairs consumable by
|
|
1813
|
-
* `buildPathAliasesJson`. Returns an empty array when no readable tsconfig
|
|
1814
|
-
* (or no usable `paths`) exists.
|
|
1815
|
-
*/
|
|
1816
|
-
function readTsconfigAliasPairs(rootDir) {
|
|
1817
|
-
const chain = loadChain((0, path.join)(rootDir, "tsconfig.json"));
|
|
1818
|
-
if (chain.length === 0) return [];
|
|
1819
|
-
const pathsOwner = chain.find((node) => node.compilerOptions.paths && typeof node.compilerOptions.paths === "object");
|
|
1820
|
-
if (!pathsOwner) return [];
|
|
1821
|
-
const paths = pathsOwner.compilerOptions.paths;
|
|
1822
|
-
const baseOwner = chain.find((node) => typeof node.compilerOptions.baseUrl === "string");
|
|
1823
|
-
const base = baseOwner ? (0, path.resolve)(baseOwner.dir, baseOwner.compilerOptions.baseUrl) : pathsOwner.dir;
|
|
1824
|
-
const pairs = [];
|
|
1825
|
-
for (const [pattern, targets] of Object.entries(paths)) {
|
|
1826
|
-
const target = Array.isArray(targets) ? targets[0] : void 0;
|
|
1827
|
-
if (typeof target !== "string") continue;
|
|
1828
|
-
const patternStars = pattern.split("*").length - 1;
|
|
1829
|
-
const targetStars = target.split("*").length - 1;
|
|
1830
|
-
if (pattern === "*" || patternStars > 1 || targetStars > 1) continue;
|
|
1831
|
-
if (pattern.endsWith("/*")) {
|
|
1832
|
-
if (!target.endsWith("/*")) continue;
|
|
1833
|
-
pairs.push({
|
|
1834
|
-
pattern: pattern.slice(0, -2),
|
|
1835
|
-
target: (0, path.resolve)(base, target.slice(0, -2)),
|
|
1836
|
-
kind: "prefix"
|
|
1837
|
-
});
|
|
1838
|
-
continue;
|
|
1839
|
-
}
|
|
1840
|
-
if (patternStars > 0 || targetStars > 0) continue;
|
|
1841
|
-
pairs.push({
|
|
1842
|
-
pattern,
|
|
1843
|
-
target: (0, path.resolve)(base, target),
|
|
1844
|
-
kind: "exact"
|
|
1845
|
-
});
|
|
1846
|
-
}
|
|
1847
|
-
return pairs;
|
|
1848
|
-
}
|
|
1849
|
-
//#endregion
|
|
1850
|
-
//#region pipeline/error-diagnostics.ts
|
|
1851
|
-
/**
|
|
1852
|
-
* Throw when the diagnostics carry any `kind: "error"` entry — one
|
|
1853
|
-
* aggregated `Error` naming EVERY offender (component, file, message — one
|
|
1854
|
-
* line per entry, each prefixed `[animus]`). Warning-only diagnostics
|
|
1855
|
-
* (`bail`/`skip`/`warn`, any severity) never trip this gate; their routing
|
|
1856
|
-
* stays with `surfaceManifestDiagnostics`. Callers accept the manifest only
|
|
1857
|
-
* past this point, so no stylesheet from a failing analysis is published.
|
|
1858
|
-
*/
|
|
1859
|
-
function assertNoErrorDiagnostics(diagnostics) {
|
|
1860
|
-
const errors = (diagnostics ?? []).filter((diagnostic) => diagnostic.kind === "error");
|
|
1861
|
-
if (errors.length === 0) return;
|
|
1862
|
-
const lines = [...new Set(errors.map((diagnostic) => `[animus] ${diagnostic.component || "<unknown component>"} (${diagnostic.file || "<unknown file>"}): ${diagnostic.message || "<no message>"}`))];
|
|
1863
|
-
throw new Error(lines.join("\n"));
|
|
1864
|
-
}
|
|
1865
|
-
//#endregion
|
|
1866
|
-
//#region pipeline/mdx-preprocessor.ts
|
|
1867
|
-
/**
|
|
1868
|
-
* MDX source preprocessor for the extraction pipeline.
|
|
1869
|
-
*
|
|
1870
|
-
* MDX files are first-class consumers of ds-built components but are not
|
|
1871
|
-
* directly parseable by OXC (which the scanner uses for .tsx/.jsx). This
|
|
1872
|
-
* module compiles MDX sources to scanner-consumable JSX using @mdx-js/mdx.
|
|
1873
|
-
*
|
|
1874
|
-
* @mdx-js/mdx is declared as `peerDependenciesMeta.optional` on the
|
|
1875
|
-
* plugin packages that import this module. The dynamic import with
|
|
1876
|
-
* .catch() ensures non-MDX consumers (who configure `extensions` to
|
|
1877
|
-
* exclude .mdx) never trigger the resolution — zero install-footprint
|
|
1878
|
-
* cost for them.
|
|
1879
|
-
*
|
|
1880
|
-
* The `DEFAULT_EXTENSIONS` constant is the shared source of truth for
|
|
1881
|
-
* both `@animus-ui/vite-plugin` and `@animus-ui/next-plugin`. Each plugin
|
|
1882
|
-
* imports it directly; independent redeclaration of default extensions
|
|
1883
|
-
* is considered a regression.
|
|
1884
|
-
*/
|
|
1885
|
-
const DEFAULT_EXTENSIONS = [
|
|
1886
|
-
".ts",
|
|
1887
|
-
".tsx",
|
|
1888
|
-
".js",
|
|
1889
|
-
".jsx",
|
|
1890
|
-
".mdx"
|
|
1891
|
-
];
|
|
1892
|
-
/**
|
|
1893
|
-
* Preprocess an MDX source string into scanner-consumable JSX.
|
|
1894
|
-
*
|
|
1895
|
-
* - Returns `{ kind: 'ok', source }` with JSX-compiled output on success.
|
|
1896
|
-
* - Returns `{ kind: 'missing-dep' }` if @mdx-js/mdx is not resolvable
|
|
1897
|
-
* (consumer needs to install it).
|
|
1898
|
-
* - Returns `{ kind: 'error', error }` on compile failure (e.g. malformed
|
|
1899
|
-
* MDX syntax). Plugins SHALL warn + skip affected files; the build
|
|
1900
|
-
* continues with remaining files.
|
|
1901
|
-
*/
|
|
1902
|
-
async function preprocessMdx(source, filename) {
|
|
1903
|
-
const mdxMod = await import("@mdx-js/mdx").catch(() => null);
|
|
1904
|
-
if (mdxMod === null) return { kind: "missing-dep" };
|
|
1905
|
-
try {
|
|
1906
|
-
const vfile = await mdxMod.compile(source, {
|
|
1907
|
-
outputFormat: "program",
|
|
1908
|
-
development: false,
|
|
1909
|
-
jsx: true
|
|
1910
|
-
});
|
|
1911
|
-
return {
|
|
1912
|
-
kind: "ok",
|
|
1913
|
-
source: `/* @mdx-source: ${filename} */\n${String(vfile)}`
|
|
1914
|
-
};
|
|
1915
|
-
} catch (err) {
|
|
1916
|
-
return {
|
|
1917
|
-
kind: "error",
|
|
1918
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1919
|
-
};
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
//#endregion
|
|
1923
|
-
//#region pipeline/replacement-plans.ts
|
|
1924
|
-
const snapshotByManifest = /* @__PURE__ */ new WeakMap();
|
|
1925
|
-
function snapshotFilePlans(manifest) {
|
|
1926
|
-
const memoKey = manifest !== null && typeof manifest === "object" ? manifest : null;
|
|
1927
|
-
if (memoKey) {
|
|
1928
|
-
const cached = snapshotByManifest.get(memoKey);
|
|
1929
|
-
if (cached) return cached;
|
|
1930
|
-
}
|
|
1931
|
-
const entriesByFile = /* @__PURE__ */ new Map();
|
|
1932
|
-
for (const [id, desc] of Object.entries(manifest?.components ?? {})) {
|
|
1933
|
-
const file = desc.file;
|
|
1934
|
-
if (!file) continue;
|
|
1935
|
-
const list = entriesByFile.get(file) ?? [];
|
|
1936
|
-
list.push([id, desc.replacement ?? ""]);
|
|
1937
|
-
entriesByFile.set(file, list);
|
|
1938
|
-
}
|
|
1939
|
-
const snapshot = /* @__PURE__ */ new Map();
|
|
1940
|
-
for (const [file, entries] of entriesByFile) {
|
|
1941
|
-
entries.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
1942
|
-
snapshot.set(file, JSON.stringify(entries));
|
|
1943
|
-
}
|
|
1944
|
-
if (memoKey) snapshotByManifest.set(memoKey, snapshot);
|
|
1945
|
-
return snapshot;
|
|
1946
|
-
}
|
|
1947
|
-
/**
|
|
1948
|
-
* Rel paths whose plan changed between two snapshots: absent→present,
|
|
1949
|
-
* present→absent, and any change to membership or replacement content.
|
|
1950
|
-
* `exclude` drops one path (the changed file itself on the edit path — its
|
|
1951
|
-
* own modules are already in the update set).
|
|
1952
|
-
*/
|
|
1953
|
-
function diffFilePlans(prev, next, opts) {
|
|
1954
|
-
const changed = /* @__PURE__ */ new Set();
|
|
1955
|
-
for (const [file, plan] of next) if (prev.get(file) !== plan) changed.add(file);
|
|
1956
|
-
for (const file of prev.keys()) if (!next.has(file)) changed.add(file);
|
|
1957
|
-
if (opts?.exclude) changed.delete(opts.exclude);
|
|
1958
|
-
return [...changed].sort();
|
|
1959
|
-
}
|
|
1960
|
-
/** Domain prefix keeping the epoch hash disjoint from every other
|
|
1961
|
-
* contentHash use in the pipeline (design D5). */
|
|
1962
|
-
const REPLACEMENT_PLANS_DOMAIN = "animus-replacement-plans-v1\0";
|
|
1963
|
-
/** Section marker for the served-dependency witness. Leads with NUL: every
|
|
1964
|
-
* plan entry ends `…\0` and neither file paths nor plan JSON contain NUL,
|
|
1965
|
-
* so `\0\0` is unreachable from entry serialization alone — a snapshot can
|
|
1966
|
-
* never forge the witness section. */
|
|
1967
|
-
const SERVED_DEPENDENCY_DOMAIN = "\0animus-served-dependency-v1\0";
|
|
1968
|
-
/**
|
|
1969
|
-
* Canonical replacement epoch: contentHash over the domain-prefixed, sorted
|
|
1970
|
-
* canonical serialization of a file-plan snapshot — each entry contributes
|
|
1971
|
-
* `file + '\0' + plan + '\0'` (unambiguous: neither file paths nor the
|
|
1972
|
-
* JSON plan strings contain NUL). Byte-identical plans → identical epoch;
|
|
1973
|
-
* any membership/replacement/absent↔present change moves it.
|
|
1974
|
-
*
|
|
1975
|
-
* `servedDependencyWitness` extends the epoch to content the plans cannot
|
|
1976
|
-
* see but restored modules depend on: transformed modules import the
|
|
1977
|
-
* session's served system-props artifact, so a consumer passes that
|
|
1978
|
-
* artifact's content here and an offline change to it moves the epoch —
|
|
1979
|
-
* invalidating persistent-cache snapshots that reference the old epoch
|
|
1980
|
-
* artifact. Absence and empty-string are distinct values.
|
|
1981
|
-
*
|
|
1982
|
-
* This is THE epoch definition — integrations consume this hash (or the
|
|
1983
|
-
* snapshot diff) and never define their own. Epoch values compare only for
|
|
1984
|
-
* equality (a moved value invalidates), so the serialization is free to
|
|
1985
|
-
* evolve with a domain bump: sessions running different serializations
|
|
1986
|
-
* simply disagree once and rebuild.
|
|
1987
|
-
*/
|
|
1988
|
-
function hashReplacementPlans(snapshot, servedDependencyWitness) {
|
|
1989
|
-
const entries = [...snapshot.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
1990
|
-
let serialized = REPLACEMENT_PLANS_DOMAIN;
|
|
1991
|
-
for (const [file, plan] of entries) serialized += file + "\0" + plan + "\0";
|
|
1992
|
-
if (servedDependencyWitness !== void 0) serialized += SERVED_DEPENDENCY_DOMAIN + servedDependencyWitness;
|
|
1993
|
-
return contentHash(serialized);
|
|
1994
|
-
}
|
|
1995
|
-
//#endregion
|
|
1996
|
-
//#region pipeline/utils.ts
|
|
1997
|
-
/** Convert camelCase CSS property names to kebab-case. */
|
|
1998
|
-
function camelToKebab(str) {
|
|
1999
|
-
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2000
|
-
}
|
|
2001
|
-
//#endregion
|
|
2002
|
-
//#region pipeline/watch-keys.ts
|
|
2003
|
-
/**
|
|
2004
|
-
* Membership keys for a filesystem path in the system-dependency watch set.
|
|
2005
|
-
*
|
|
2006
|
-
* The loader reports symlink-resolved canonical paths; watcher events carry
|
|
2007
|
-
* lexical absolute paths that may traverse symlinks (bun workspace links) and
|
|
2008
|
-
* — for deletions — may no longer exist, so `realpathSync` on the event path
|
|
2009
|
-
* alone cannot produce the canonical form. Both insertion and lookup go
|
|
2010
|
-
* through this one normalizer: the lexical form plus a canonical form
|
|
2011
|
-
* reconstructed through the nearest existing ancestor.
|
|
2012
|
-
*/
|
|
2013
|
-
function toWatchKeys(input) {
|
|
2014
|
-
const lexical = (0, node_path.normalize)(input);
|
|
2015
|
-
const canonical = realpathThroughNearestExistingAncestor(lexical);
|
|
2016
|
-
return canonical === lexical ? [lexical] : [lexical, canonical];
|
|
2017
|
-
}
|
|
2018
|
-
/**
|
|
2019
|
-
* Canonicalize a path that may not exist: walk up to the nearest existing
|
|
2020
|
-
* ancestor, realpath it, and re-append the missing suffix. Handles deleted
|
|
2021
|
-
* files under still-existing (possibly symlinked) directories and atomic
|
|
2022
|
-
* unlink/rename saves. Falls back to the input when no ancestor resolves.
|
|
2023
|
-
*
|
|
2024
|
-
* Known limit: a symlink retargeted AFTER the system load canonicalizes to
|
|
2025
|
-
* the new target, which cannot match the recorded (old-target) dependency —
|
|
2026
|
-
* the membership test then fails open (no reset), identical to not having
|
|
2027
|
-
* this reconstruction at all. Retarget sensitivity is a resolution-input
|
|
2028
|
-
* concern, deliberately out of scope for the watch set.
|
|
2029
|
-
*/
|
|
2030
|
-
function realpathThroughNearestExistingAncestor(path) {
|
|
2031
|
-
try {
|
|
2032
|
-
return (0, node_fs.realpathSync)(path);
|
|
2033
|
-
} catch {}
|
|
2034
|
-
const suffix = [];
|
|
2035
|
-
let current = path;
|
|
2036
|
-
for (;;) {
|
|
2037
|
-
const parent = (0, node_path.dirname)(current);
|
|
2038
|
-
if (parent === current) return path;
|
|
2039
|
-
suffix.unshift((0, node_path.basename)(current));
|
|
2040
|
-
current = parent;
|
|
2041
|
-
try {
|
|
2042
|
-
return (0, node_path.join)((0, node_fs.realpathSync)(current), ...suffix);
|
|
2043
|
-
} catch {}
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
//#endregion
|
|
2047
|
-
exports.ANIMUS_LAYERS = ANIMUS_LAYERS;
|
|
2048
|
-
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
|
|
2049
|
-
exports.KEYFRAMES_EXPORT_COLLISION = KEYFRAMES_EXPORT_COLLISION;
|
|
2050
|
-
exports.KEYFRAMES_EXTERNAL_ENTRY_FAILED = KEYFRAMES_EXTERNAL_ENTRY_FAILED;
|
|
2051
|
-
exports.RETIRED_ENGINE_MESSAGE = RETIRED_ENGINE_MESSAGE;
|
|
2052
|
-
exports.applyPrefix = applyPrefix;
|
|
2053
|
-
exports.applyUnitFallback = applyUnitFallback;
|
|
2054
|
-
exports.assembleStylesheet = assembleStylesheet;
|
|
2055
|
-
exports.assertNoErrorDiagnostics = assertNoErrorDiagnostics;
|
|
2056
|
-
exports.assertNoRetiredEngineSelection = assertNoRetiredEngineSelection;
|
|
2057
|
-
exports.buildAnalysisInputs = buildAnalysisInputs;
|
|
2058
|
-
exports.buildAnalyzeProjectArgs = buildAnalyzeProjectArgs;
|
|
2059
|
-
exports.buildDynamicPropConfig = buildDynamicPropConfig;
|
|
2060
|
-
exports.buildPathAliasesJson = buildPathAliasesJson;
|
|
2061
|
-
exports.buildSystemPropsModule = buildSystemPropsModule;
|
|
2062
|
-
exports.camelToKebab = camelToKebab;
|
|
2063
|
-
exports.clearEngineCache = clearEngineCache;
|
|
2064
|
-
exports.collectExternalPackageSources = collectExternalPackageSources;
|
|
2065
|
-
exports.contentHash = contentHash;
|
|
2066
|
-
exports.createSourceIdentity = createSourceIdentity;
|
|
2067
|
-
exports.createV2EngineApi = createV2EngineApi;
|
|
2068
|
-
exports.diffFilePlans = diffFilePlans;
|
|
2069
|
-
exports.discoverFiles = discoverFiles;
|
|
2070
|
-
exports.enforceExternalTokenContracts = enforceExternalTokenContracts;
|
|
2071
|
-
exports.excludeCollectedPackages = excludeCollectedPackages;
|
|
2072
|
-
exports.extractSystemFilePackages = extractSystemFilePackages;
|
|
2073
|
-
exports.findAssetSpecifiers = findAssetSpecifiers;
|
|
2074
|
-
exports.findPackageRoot = findPackageRoot;
|
|
2075
|
-
exports.firstOwners = firstOwners;
|
|
2076
|
-
exports.formatRustTimingWaterfall = formatRustTimingWaterfall;
|
|
2077
|
-
exports.hashReplacementPlans = hashReplacementPlans;
|
|
2078
|
-
exports.isExcludedPackageRelativePath = isExcludedPackageRelativePath;
|
|
2079
|
-
exports.isPathWithinRoot = isPathWithinRoot;
|
|
2080
|
-
exports.isUnresolvedParentDrop = isUnresolvedParentDrop;
|
|
2081
|
-
exports.loadSystemConfig = loadSystemConfig;
|
|
2082
|
-
exports.mergeExternalKeyframes = mergeExternalKeyframes;
|
|
2083
|
-
exports.postProcessCss = postProcessCss;
|
|
2084
|
-
exports.preprocessMdx = preprocessMdx;
|
|
2085
|
-
exports.readTsconfigAliasPairs = readTsconfigAliasPairs;
|
|
2086
|
-
exports.resolveAbsolutePathSpecifier = resolveAbsolutePathSpecifier;
|
|
2087
|
-
exports.resolveAssetFile = resolveAssetFile;
|
|
2088
|
-
exports.resolveLightningTargets = resolveLightningTargets;
|
|
2089
|
-
exports.resolveThroughPathAliases = resolveThroughPathAliases;
|
|
2090
|
-
exports.runProjectAnalysis = runProjectAnalysis;
|
|
2091
|
-
exports.serializeStaticCss = serializeStaticCss;
|
|
2092
|
-
exports.sharesVolumeRoot = sharesVolumeRoot;
|
|
2093
|
-
exports.snapshotFilePlans = snapshotFilePlans;
|
|
2094
|
-
exports.staleDistIncludesMessage = staleDistIncludesMessage;
|
|
2095
|
-
exports.stripLeadingLayerDeclaration = stripLeadingLayerDeclaration;
|
|
2096
|
-
exports.substituteAssetPlaceholders = substituteAssetPlaceholders;
|
|
2097
|
-
exports.surfaceManifestDiagnostics = surfaceManifestDiagnostics;
|
|
2098
|
-
exports.toWatchKeys = toWatchKeys;
|
|
2099
|
-
exports.unresolvableIncludesMessage = unresolvableIncludesMessage;
|
|
2100
|
-
exports.unresolvedParentName = unresolvedParentName;
|
|
2101
|
-
exports.validateLayerOrder = validateLayerOrder;
|
|
2102
|
-
exports.walkPackageSources = walkPackageSources;
|
|
2
|
+
const require_pipeline = require("./pipeline-ojNeABi0.cjs");
|
|
3
|
+
exports.ANIMUS_LAYERS = require_pipeline.ANIMUS_LAYERS;
|
|
4
|
+
exports.AnimusConfigError = require_pipeline.AnimusConfigError;
|
|
5
|
+
exports.CORE_OPTION_KEYS = require_pipeline.CORE_OPTION_KEYS;
|
|
6
|
+
exports.DEFAULT_EXCLUDE = require_pipeline.DEFAULT_EXCLUDE;
|
|
7
|
+
exports.DEFAULT_EXTENSIONS = require_pipeline.DEFAULT_EXTENSIONS;
|
|
8
|
+
exports.DRIVER_NAMESPACES = require_pipeline.DRIVER_NAMESPACES;
|
|
9
|
+
exports.ENGINE_TRANSFORM_EXTENSIONS = require_pipeline.ENGINE_TRANSFORM_EXTENSIONS;
|
|
10
|
+
exports.KEYFRAMES_EXPORT_COLLISION = require_pipeline.KEYFRAMES_EXPORT_COLLISION;
|
|
11
|
+
exports.KEYFRAMES_EXTERNAL_ENTRY_FAILED = require_pipeline.KEYFRAMES_EXTERNAL_ENTRY_FAILED;
|
|
12
|
+
exports.REPLACEABLE_DEFAULT_EXCLUDE = require_pipeline.REPLACEABLE_DEFAULT_EXCLUDE;
|
|
13
|
+
exports.RETIRED_ENGINE_MESSAGE = require_pipeline.RETIRED_ENGINE_MESSAGE;
|
|
14
|
+
exports.STRUCTURAL_EXCLUDE = require_pipeline.STRUCTURAL_EXCLUDE;
|
|
15
|
+
exports.adaptSvelteSource = require_pipeline.adaptSvelteSource;
|
|
16
|
+
exports.applyPrefix = require_pipeline.applyPrefix;
|
|
17
|
+
exports.applyUnitFallback = require_pipeline.applyUnitFallback;
|
|
18
|
+
exports.assembleStylesheet = require_pipeline.assembleStylesheet;
|
|
19
|
+
exports.assertKnownOptionKeys = require_pipeline.assertKnownOptionKeys;
|
|
20
|
+
exports.assertNoErrorDiagnostics = require_pipeline.assertNoErrorDiagnostics;
|
|
21
|
+
exports.assertNoRetiredEngineSelection = require_pipeline.assertNoRetiredEngineSelection;
|
|
22
|
+
exports.buildAnalysisInputs = require_pipeline.buildAnalysisInputs;
|
|
23
|
+
exports.buildAnalyzeProjectArgs = require_pipeline.buildAnalyzeProjectArgs;
|
|
24
|
+
exports.buildDynamicPropConfig = require_pipeline.buildDynamicPropConfig;
|
|
25
|
+
exports.buildPathAliasesJson = require_pipeline.buildPathAliasesJson;
|
|
26
|
+
exports.buildSystemPropsModule = require_pipeline.buildSystemPropsModule;
|
|
27
|
+
exports.camelToKebab = require_pipeline.camelToKebab;
|
|
28
|
+
exports.clearEngineCache = require_pipeline.clearEngineCache;
|
|
29
|
+
exports.collectExternalPackageSources = require_pipeline.collectExternalPackageSources;
|
|
30
|
+
exports.contentHash = require_pipeline.contentHash;
|
|
31
|
+
exports.createExcludeMatcher = require_pipeline.createExcludeMatcher;
|
|
32
|
+
exports.createSourceIdentity = require_pipeline.createSourceIdentity;
|
|
33
|
+
exports.createSourceIngestor = require_pipeline.createSourceIngestor;
|
|
34
|
+
exports.createV2EngineApi = require_pipeline.createV2EngineApi;
|
|
35
|
+
exports.diffFilePlans = require_pipeline.diffFilePlans;
|
|
36
|
+
exports.discoverFiles = require_pipeline.discoverFiles;
|
|
37
|
+
exports.enforceExternalTokenContracts = require_pipeline.enforceExternalTokenContracts;
|
|
38
|
+
exports.excludeCollectedPackages = require_pipeline.excludeCollectedPackages;
|
|
39
|
+
exports.extractSystemFilePackages = require_pipeline.extractSystemFilePackages;
|
|
40
|
+
exports.findAssetSpecifiers = require_pipeline.findAssetSpecifiers;
|
|
41
|
+
exports.findPackageRoot = require_pipeline.findPackageRoot;
|
|
42
|
+
exports.firstOwners = require_pipeline.firstOwners;
|
|
43
|
+
exports.formatRustTimingWaterfall = require_pipeline.formatRustTimingWaterfall;
|
|
44
|
+
exports.hashReplacementPlans = require_pipeline.hashReplacementPlans;
|
|
45
|
+
exports.ingestSourceEntries = require_pipeline.ingestSourceEntries;
|
|
46
|
+
exports.isAdvisorySourceDiagnostic = require_pipeline.isAdvisorySourceDiagnostic;
|
|
47
|
+
exports.isExcludedPackageRelativePath = require_pipeline.isExcludedPackageRelativePath;
|
|
48
|
+
exports.isPathWithinRoot = require_pipeline.isPathWithinRoot;
|
|
49
|
+
exports.isUnresolvedParentDrop = require_pipeline.isUnresolvedParentDrop;
|
|
50
|
+
exports.loadSystemConfig = require_pipeline.loadSystemConfig;
|
|
51
|
+
exports.mergeExternalKeyframes = require_pipeline.mergeExternalKeyframes;
|
|
52
|
+
exports.postProcessCss = require_pipeline.postProcessCss;
|
|
53
|
+
exports.preprocessMdx = require_pipeline.preprocessMdx;
|
|
54
|
+
exports.readTsconfigAliasPairs = require_pipeline.readTsconfigAliasPairs;
|
|
55
|
+
exports.resolveAbsolutePathSpecifier = require_pipeline.resolveAbsolutePathSpecifier;
|
|
56
|
+
exports.resolveAssetFile = require_pipeline.resolveAssetFile;
|
|
57
|
+
exports.resolveLightningTargets = require_pipeline.resolveLightningTargets;
|
|
58
|
+
exports.resolveMode = require_pipeline.resolveMode;
|
|
59
|
+
exports.resolveThroughPathAliases = require_pipeline.resolveThroughPathAliases;
|
|
60
|
+
exports.runProjectAnalysis = require_pipeline.runProjectAnalysis;
|
|
61
|
+
exports.runStructuralSelfCheck = require_pipeline.runStructuralSelfCheck;
|
|
62
|
+
exports.serializeStaticCss = require_pipeline.serializeStaticCss;
|
|
63
|
+
exports.sharesVolumeRoot = require_pipeline.sharesVolumeRoot;
|
|
64
|
+
exports.snapshotFilePlans = require_pipeline.snapshotFilePlans;
|
|
65
|
+
exports.staleDistIncludesMessage = require_pipeline.staleDistIncludesMessage;
|
|
66
|
+
exports.stripLeadingLayerDeclaration = require_pipeline.stripLeadingLayerDeclaration;
|
|
67
|
+
exports.substituteAssetPlaceholders = require_pipeline.substituteAssetPlaceholders;
|
|
68
|
+
exports.surfaceManifestDiagnostics = require_pipeline.surfaceManifestDiagnostics;
|
|
69
|
+
exports.toWatchKeys = require_pipeline.toWatchKeys;
|
|
70
|
+
exports.unresolvableIncludesMessage = require_pipeline.unresolvableIncludesMessage;
|
|
71
|
+
exports.unresolvedParentName = require_pipeline.unresolvedParentName;
|
|
72
|
+
exports.validateLayerOrder = require_pipeline.validateLayerOrder;
|
|
73
|
+
exports.walkPackageSources = require_pipeline.walkPackageSources;
|
|
74
|
+
exports.withoutInvalidOriginals = require_pipeline.withoutInvalidOriginals;
|