@animus-ui/vite-plugin 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-start.d.ts.map +1 -1
- package/dist/context.d.ts +15 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/hmr.d.ts.map +1 -1
- package/dist/hot-update-events.d.ts +10 -0
- package/dist/hot-update-events.d.ts.map +1 -1
- package/dist/index.cjs +138 -75
- package/dist/transform.d.ts +9 -0
- package/dist/transform.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAC/D,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAC/D,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CAuRf"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HotUpdateEvents } from './hot-update-events';
|
|
2
2
|
import type { LightningTargets } from './css';
|
|
3
3
|
import type { AnimusExtractOptions } from './index';
|
|
4
|
-
import type { ExternalPackageOutcome, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
4
|
+
import type { ExternalPackageOutcome, ManifestDiagnostic, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
5
5
|
import type { Logger } from 'vite';
|
|
6
6
|
/**
|
|
7
7
|
* Structured per-layer CSS sheets from the Rust crate (dev split delivery).
|
|
@@ -91,7 +91,7 @@ export declare function pruneFileCache(cache: Map<string, {
|
|
|
91
91
|
* index.ts only wires Vite hooks to those functions.
|
|
92
92
|
*
|
|
93
93
|
* A class rather than closure variables so each hook module names exactly
|
|
94
|
-
* the state it touches, and the engine store (
|
|
94
|
+
* the state it touches, and the engine store (per-instance, never
|
|
95
95
|
* module-level) is explicit.
|
|
96
96
|
*/
|
|
97
97
|
export declare class PluginContext {
|
|
@@ -113,12 +113,19 @@ export declare class PluginContext {
|
|
|
113
113
|
resolvedComponentCss: string;
|
|
114
114
|
storedSheets: CssSheets | null;
|
|
115
115
|
layerDeclaration: string;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
transformOutputHashes: Map<string, string>;
|
|
117
|
+
recordTransformOutput(relativePath: string, code: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Merge `Keyframes` collections from discovered external package entries
|
|
120
|
+
* into the system's collections (keyframes-only carve-out — the consumer
|
|
121
|
+
* system stays the singular config authority). Runs after buildStart
|
|
122
|
+
* discovery AND after every geological-reset system reload, since a reload
|
|
123
|
+
* rebuilds `this.system` from the consumer entry alone.
|
|
124
|
+
*/
|
|
125
|
+
applyExternalKeyframes(): void;
|
|
126
|
+
/** Discovery-time keyframes diagnostics awaiting the next analysis's
|
|
127
|
+
* shared surfacing pass. */
|
|
128
|
+
externalKeyframesDiagnostics: ManifestDiagnostic[];
|
|
122
129
|
reverseProvenance: Record<string, string[]>;
|
|
123
130
|
storedSystemPropMapJson: string;
|
|
124
131
|
storedDynamicPropsJson: string;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAiBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,WAAW,CAAC,EAAE,MAAM,GACnB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAUvD;AAYD;;;;;;;;;GASG;AACH,wBAAgB,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|
1
|
-
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,MAAM,CAAC;AAEd;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,WAAW,EAAE,cAAc,EAC3B,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,gBAAgB,GACzD,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAmEzC"}
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
* system-props module moved (see `runAnalysisTrackingSystemProps` in
|
|
14
14
|
* context.ts) — only the owning dispatch holds the before/after values, so
|
|
15
15
|
* it travels with the decision rather than being re-derived per environment.
|
|
16
|
+
* `presentationOnly` reports that the changed file's transform output is
|
|
17
|
+
* byte-identical before and after the edit (style values are not part of
|
|
18
|
+
* the emitted replacement — class names hash `filename::binding`): every
|
|
19
|
+
* environment then excludes the file's own modules from the update it
|
|
20
|
+
* returns, so the module never re-executes and React component identity,
|
|
21
|
+
* generated IDs, focus, and DOM-owned state survive the edit. Computed once
|
|
22
|
+
* by the owning dispatch (it needs the pre-edit source and manifest, which
|
|
23
|
+
* the owner consumed while re-analyzing) — the same travel rule as
|
|
24
|
+
* `systemPropsChanged`.
|
|
16
25
|
*/
|
|
17
26
|
export type HotUpdateResult = {
|
|
18
27
|
kind: 'ignored';
|
|
@@ -22,6 +31,7 @@ export type HotUpdateResult = {
|
|
|
22
31
|
kind: 'analyzed';
|
|
23
32
|
staleDefinitionFiles: string[];
|
|
24
33
|
systemPropsChanged: boolean;
|
|
34
|
+
presentationOnly: boolean;
|
|
25
35
|
};
|
|
26
36
|
/**
|
|
27
37
|
* Once-per-file-event coordination across the `hotUpdate` dispatches.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot-update-events.d.ts","sourceRoot":"","sources":["../src/hot-update-events.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hot-update-events.d.ts","sourceRoot":"","sources":["../src/hot-update-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAe;IAGd,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;IAE9D,YAA6B,YAAY,SAAK,EAAI;IAElD,0EAA0E;IAC1E,KAAK,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAUvE;IAED,wEAAwE;IACxE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAErE;IAED,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAEzD;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
|
|
|
152
152
|
}
|
|
153
153
|
ctx.externalPackageDirs = collected.packageDirs;
|
|
154
154
|
ctx.registerSystemWatchPaths();
|
|
155
|
+
ctx.applyExternalKeyframes();
|
|
155
156
|
const packageFileCount = fileEntries.length - localFileCount;
|
|
156
157
|
ctx.log(`Discovered ${fileEntries.length} files (${packageFileCount} from packages) (${Math.round(performance.now() - t0)}ms)`);
|
|
157
158
|
t0 = performance.now();
|
|
@@ -441,7 +442,7 @@ function pruneFileCache(cache, rootDir, absPath) {
|
|
|
441
442
|
* index.ts only wires Vite hooks to those functions.
|
|
442
443
|
*
|
|
443
444
|
* A class rather than closure variables so each hook module names exactly
|
|
444
|
-
* the state it touches, and the engine store (
|
|
445
|
+
* the state it touches, and the engine store (per-instance, never
|
|
445
446
|
* module-level) is explicit.
|
|
446
447
|
*/
|
|
447
448
|
var PluginContext = class {
|
|
@@ -463,7 +464,26 @@ var PluginContext = class {
|
|
|
463
464
|
resolvedComponentCss = "";
|
|
464
465
|
storedSheets = null;
|
|
465
466
|
layerDeclaration = "";
|
|
466
|
-
|
|
467
|
+
transformOutputHashes = /* @__PURE__ */ new Map();
|
|
468
|
+
recordTransformOutput(relativePath, code) {
|
|
469
|
+
this.transformOutputHashes.set(relativePath, (0, _animus_ui_extract_pipeline.contentHash)(code));
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Merge `Keyframes` collections from discovered external package entries
|
|
473
|
+
* into the system's collections (keyframes-only carve-out — the consumer
|
|
474
|
+
* system stays the singular config authority). Runs after buildStart
|
|
475
|
+
* discovery AND after every geological-reset system reload, since a reload
|
|
476
|
+
* rebuilds `this.system` from the consumer entry alone.
|
|
477
|
+
*/
|
|
478
|
+
applyExternalKeyframes() {
|
|
479
|
+
if (this.externalSourceEntries.size === 0) return;
|
|
480
|
+
const merge = (0, _animus_ui_extract_pipeline.mergeExternalKeyframes)((entry, root) => this.engineApi().scanKeyframesExports(entry, root), this.system.keyframesJson, this.externalSourceEntries.values(), this.rootDir);
|
|
481
|
+
this.system.keyframesJson = merge.keyframesJson;
|
|
482
|
+
this.externalKeyframesDiagnostics = merge.diagnostics;
|
|
483
|
+
}
|
|
484
|
+
/** Discovery-time keyframes diagnostics awaiting the next analysis's
|
|
485
|
+
* shared surfacing pass. */
|
|
486
|
+
externalKeyframesDiagnostics = [];
|
|
467
487
|
reverseProvenance = {};
|
|
468
488
|
storedSystemPropMapJson = "{}";
|
|
469
489
|
storedDynamicPropsJson = "{}";
|
|
@@ -569,6 +589,7 @@ var PluginContext = class {
|
|
|
569
589
|
this.systemDependencyKeys = keys;
|
|
570
590
|
this.systemDependencyPaths = deps;
|
|
571
591
|
this.registerSystemWatchPaths();
|
|
592
|
+
this.applyExternalKeyframes();
|
|
572
593
|
} catch (e) {
|
|
573
594
|
if (this.options.strict) throw new Error(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}: ${e}`, { cause: e });
|
|
574
595
|
console.warn(`[animus-extract] Failed to load system from ${this.resolvedSystemPath}:`, e);
|
|
@@ -593,17 +614,14 @@ var PluginContext = class {
|
|
|
593
614
|
staticCssJson: this.staticCssJson,
|
|
594
615
|
externalDirs: this.externalPackageDirs.map((dir) => (0, path.relative)(this.rootDir, dir)),
|
|
595
616
|
devMode: !this.isProd,
|
|
596
|
-
warn: (m) => this.warn(m)
|
|
617
|
+
warn: (m) => this.warn(m),
|
|
618
|
+
strict: this.options.strict,
|
|
619
|
+
extraDiagnostics: this.externalKeyframesDiagnostics
|
|
597
620
|
});
|
|
598
621
|
this.storedManifest = result.manifest;
|
|
599
622
|
this.storedManifestJson = result.manifestJson;
|
|
600
623
|
this.storedSystemPropMapJson = JSON.stringify(result.manifest?.system_prop_map ?? {});
|
|
601
624
|
this.storedDynamicPropsJson = JSON.stringify(result.manifest?.dynamic_props ?? {});
|
|
602
|
-
const newFragments = result.manifest?.component_fragments;
|
|
603
|
-
if (newFragments && typeof newFragments === "object") {
|
|
604
|
-
this.fragmentCache.clear();
|
|
605
|
-
for (const [id, sheets] of Object.entries(newFragments)) this.fragmentCache.set(id, sheets);
|
|
606
|
-
}
|
|
607
625
|
this.reverseProvenance = result.manifest?.reverse_provenance ?? {};
|
|
608
626
|
this.storedSheets = result.manifest?.sheets ?? null;
|
|
609
627
|
this.globalCss = result.globalCss;
|
|
@@ -831,6 +849,82 @@ var PluginContext = class {
|
|
|
831
849
|
}
|
|
832
850
|
};
|
|
833
851
|
//#endregion
|
|
852
|
+
//#region src/transform.ts
|
|
853
|
+
/**
|
|
854
|
+
* The dev-mode bridge prepend, shared with the hot-update gate so both
|
|
855
|
+
* compute byte-identical served output. The import goes AFTER the directive
|
|
856
|
+
* prologue the engine hoists to byte 0 — prepending above it would demote
|
|
857
|
+
* 'use client'/'use strict' to an ordinary expression statement, silently
|
|
858
|
+
* un-marking client modules on exactly the RSC-capable hosts this delivery
|
|
859
|
+
* path serves.
|
|
860
|
+
*/
|
|
861
|
+
function applyDevBridgeImport(code) {
|
|
862
|
+
const prologue = /^(?:(['"])use [a-z -]+\1;?\r?\n)*/.exec(code)?.[0] ?? "";
|
|
863
|
+
return prologue + `import '${VIRTUAL_BRIDGE_ID}';\n` + code.slice(prologue.length);
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* transform: replace builder chains with `createComponent()` calls using
|
|
867
|
+
* the pre-built manifest; detect files created after buildStart and fold
|
|
868
|
+
* them into the analysis.
|
|
869
|
+
*
|
|
870
|
+
* The HMR bridge is NOT injected here — `transformIndexHtml` delivers it as a
|
|
871
|
+
* `<script type="module">` per served document (openspec:
|
|
872
|
+
* dev-stylesheet-management, "HMR bridge auto-injected in dev mode"; "Transform
|
|
873
|
+
* emitter unchanged" forbids the emitter importing it).
|
|
874
|
+
*/
|
|
875
|
+
function transformSource(ctx, code, id) {
|
|
876
|
+
if (!ctx.storedManifest) return null;
|
|
877
|
+
if (id.startsWith("\0") || id.startsWith("virtual:animus/")) return null;
|
|
878
|
+
const isExternalPkg = ctx.externalPackageDirs.some((dir) => id.startsWith(dir + path.sep) || id === dir);
|
|
879
|
+
const relativePath = (0, path.relative)(ctx.rootDir, id);
|
|
880
|
+
if (!isExternalPkg) {
|
|
881
|
+
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
882
|
+
if (id.includes("node_modules")) return null;
|
|
883
|
+
if (relativePath.startsWith("..") || (0, path.isAbsolute)(relativePath)) return null;
|
|
884
|
+
}
|
|
885
|
+
if (!ctx.storedManifest.files?.[relativePath]?.length) {
|
|
886
|
+
if (!ctx.isProd && !ctx.fileCache.has(relativePath)) {
|
|
887
|
+
if (isExternalPkg) {
|
|
888
|
+
const owner = Object.entries(ctx.externalDirOwners).find(([dir]) => id === dir || id.startsWith(dir + path.sep));
|
|
889
|
+
if (owner) ctx.externalFileOwners[relativePath] = owner[1];
|
|
890
|
+
}
|
|
891
|
+
const hash = (0, _animus_ui_extract_pipeline.contentHash)(code);
|
|
892
|
+
ctx.fileCache.set(relativePath, {
|
|
893
|
+
hash,
|
|
894
|
+
source: code
|
|
895
|
+
});
|
|
896
|
+
const fileEntries = buildFileEntriesFromCache(ctx.fileCache, relativePath);
|
|
897
|
+
ctx.runAnalysis(fileEntries);
|
|
898
|
+
const compCount = ctx.storedManifest.files?.[relativePath]?.length ?? 0;
|
|
899
|
+
ctx.info(`New file detected: ${relativePath} — ${compCount ? `${compCount} components extracted` : "no components"}`);
|
|
900
|
+
ctx.invalidateExtractedModules();
|
|
901
|
+
}
|
|
902
|
+
if (!ctx.storedManifest.files?.[relativePath]?.length) return null;
|
|
903
|
+
}
|
|
904
|
+
try {
|
|
905
|
+
const { transformFile } = ctx.engineApi();
|
|
906
|
+
const result = transformFile(code, relativePath, ctx.storedManifestJson);
|
|
907
|
+
if (!result.hasComponents) return null;
|
|
908
|
+
if (ctx.verbose) {
|
|
909
|
+
const compCount = ctx.storedManifest.files?.[relativePath]?.length ?? 0;
|
|
910
|
+
ctx.log(`transform ${relativePath}: ${compCount} components`);
|
|
911
|
+
}
|
|
912
|
+
let outputCode = result.code;
|
|
913
|
+
if (!ctx.isProd) {
|
|
914
|
+
outputCode = applyDevBridgeImport(result.code);
|
|
915
|
+
ctx.recordTransformOutput(relativePath, outputCode);
|
|
916
|
+
}
|
|
917
|
+
return {
|
|
918
|
+
code: outputCode,
|
|
919
|
+
map: null
|
|
920
|
+
};
|
|
921
|
+
} catch (e) {
|
|
922
|
+
if (ctx.options.strict) throw new Error(`[animus-extract] Failed to transform ${id}: ${e}`, { cause: e });
|
|
923
|
+
console.warn(`[animus-extract] Failed to transform ${id}:`, e);
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
//#endregion
|
|
834
928
|
//#region src/hmr.ts
|
|
835
929
|
/**
|
|
836
930
|
* hotUpdate: the single dev file-event hook. Handles system-dependency
|
|
@@ -995,16 +1089,44 @@ async function analyzeChangedFile(ctx, file, absFile, read) {
|
|
|
995
1089
|
staleDefinitionFiles.push(defFile);
|
|
996
1090
|
}
|
|
997
1091
|
}
|
|
1092
|
+
const presentationOnly = isPresentationOnlyEdit(ctx, scannerRelPath, source);
|
|
998
1093
|
const hmrMs = Math.round(performance.now() - hmrStart);
|
|
999
|
-
ctx.log(`HMR update: ${relPath} — analysis ${analysisMs}ms, total ${hmrMs}ms`);
|
|
1094
|
+
ctx.log(`HMR update: ${relPath} — analysis ${analysisMs}ms, total ${hmrMs}ms${presentationOnly ? " (presentation-only)" : ""}`);
|
|
1000
1095
|
ctx.logTimingWaterfall(ctx.storedManifest?.timing ?? {});
|
|
1001
1096
|
return {
|
|
1002
1097
|
kind: "analyzed",
|
|
1003
1098
|
staleDefinitionFiles,
|
|
1004
|
-
systemPropsChanged
|
|
1099
|
+
systemPropsChanged,
|
|
1100
|
+
presentationOnly
|
|
1005
1101
|
};
|
|
1006
1102
|
}
|
|
1007
1103
|
/**
|
|
1104
|
+
* True when the changed file's transform output is byte-identical across the
|
|
1105
|
+
* edit — a presentation-only change (style values are not part of the emitted
|
|
1106
|
+
* replacement, whose class names hash `filename::binding`).
|
|
1107
|
+
*
|
|
1108
|
+
* Compares a POST-analysis re-transform of the file (the engine transforms
|
|
1109
|
+
* from its retained facts, so this runs against the just-updated analysis)
|
|
1110
|
+
* with the hash of what the module LAST SERVED (`recordTransformOutput` in
|
|
1111
|
+
* the transform hook, bridge import included). Comparing the full served
|
|
1112
|
+
* output — never replacement strings — is what keeps a mixed style+code edit
|
|
1113
|
+
* deliverable. Fails open: a transform error, a file the manifest does not
|
|
1114
|
+
* list, or a module that never served (no recorded hash) delivers normally.
|
|
1115
|
+
*/
|
|
1116
|
+
function isPresentationOnlyEdit(ctx, scannerRelPath, source) {
|
|
1117
|
+
const servedHash = ctx.transformOutputHashes.get(scannerRelPath);
|
|
1118
|
+
if (!servedHash || !ctx.storedManifestJson) return false;
|
|
1119
|
+
if (!ctx.storedManifest?.files?.[scannerRelPath]?.length) return false;
|
|
1120
|
+
try {
|
|
1121
|
+
const { transformFile } = ctx.engineApi();
|
|
1122
|
+
const fresh = transformFile(source, scannerRelPath, ctx.storedManifestJson);
|
|
1123
|
+
if (!fresh.hasComponents) return false;
|
|
1124
|
+
return (0, _animus_ui_extract_pipeline.contentHash)(applyDevBridgeImport(fresh.code)) === servedHash;
|
|
1125
|
+
} catch {
|
|
1126
|
+
return false;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1008
1130
|
* Reconcile a deleted file in dev.
|
|
1009
1131
|
*
|
|
1010
1132
|
* Without this the removed file's last-known source stays in `ctx.fileCache`,
|
|
@@ -1026,7 +1148,7 @@ function pruneDeletedFile(ctx, absFile) {
|
|
|
1026
1148
|
*/
|
|
1027
1149
|
function invalidateStaleModules(ctx, environment, modules, analyzed) {
|
|
1028
1150
|
const graph = environment.moduleGraph;
|
|
1029
|
-
const modulesToUpdate = [...modules];
|
|
1151
|
+
const modulesToUpdate = analyzed.presentationOnly ? [] : [...modules];
|
|
1030
1152
|
const moduleIds = [RESOLVED_COMPONENTS_ID];
|
|
1031
1153
|
if (analyzed.systemPropsChanged) moduleIds.push(RESOLVED_SYSTEM_PROPS_ID);
|
|
1032
1154
|
for (const moduleId of moduleIds) {
|
|
@@ -1045,6 +1167,11 @@ function invalidateStaleModules(ctx, environment, modules, analyzed) {
|
|
|
1045
1167
|
modulesToUpdate.push(defModule);
|
|
1046
1168
|
}
|
|
1047
1169
|
}
|
|
1170
|
+
if (analyzed.presentationOnly) {
|
|
1171
|
+
ctx.log(`HMR (${environment.name}): presentation-only — ${modules.length} module update(s) suppressed, CSS delivered`);
|
|
1172
|
+
for (const mod of modules) if (mod.url) environment.transformRequest?.(mod.url)?.catch(() => {});
|
|
1173
|
+
return modulesToUpdate;
|
|
1174
|
+
}
|
|
1048
1175
|
const invalidated = modulesToUpdate.length - modules.length;
|
|
1049
1176
|
if (invalidated > 0) {
|
|
1050
1177
|
ctx.log(`HMR (${environment.name}): ${invalidated} modules invalidated`);
|
|
@@ -1105,70 +1232,6 @@ function buildIndexHtmlTags(ctx) {
|
|
|
1105
1232
|
return tags;
|
|
1106
1233
|
}
|
|
1107
1234
|
//#endregion
|
|
1108
|
-
//#region src/transform.ts
|
|
1109
|
-
/**
|
|
1110
|
-
* transform: replace builder chains with `createComponent()` calls using
|
|
1111
|
-
* the pre-built manifest; detect files created after buildStart and fold
|
|
1112
|
-
* them into the analysis.
|
|
1113
|
-
*
|
|
1114
|
-
* The HMR bridge is NOT injected here — `transformIndexHtml` delivers it as a
|
|
1115
|
-
* `<script type="module">` per served document (openspec:
|
|
1116
|
-
* dev-stylesheet-management, "HMR bridge auto-injected in dev mode"; "Transform
|
|
1117
|
-
* emitter unchanged" forbids the emitter importing it).
|
|
1118
|
-
*/
|
|
1119
|
-
function transformSource(ctx, code, id) {
|
|
1120
|
-
if (!ctx.storedManifest) return null;
|
|
1121
|
-
if (id.startsWith("\0") || id.startsWith("virtual:animus/")) return null;
|
|
1122
|
-
const isExternalPkg = ctx.externalPackageDirs.some((dir) => id.startsWith(dir + path.sep) || id === dir);
|
|
1123
|
-
const relativePath = (0, path.relative)(ctx.rootDir, id);
|
|
1124
|
-
if (!isExternalPkg) {
|
|
1125
|
-
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
1126
|
-
if (id.includes("node_modules")) return null;
|
|
1127
|
-
if (relativePath.startsWith("..") || (0, path.isAbsolute)(relativePath)) return null;
|
|
1128
|
-
}
|
|
1129
|
-
if (!ctx.storedManifest.files?.[relativePath]?.length) {
|
|
1130
|
-
if (!ctx.isProd && !ctx.fileCache.has(relativePath)) {
|
|
1131
|
-
if (isExternalPkg) {
|
|
1132
|
-
const owner = Object.entries(ctx.externalDirOwners).find(([dir]) => id === dir || id.startsWith(dir + path.sep));
|
|
1133
|
-
if (owner) ctx.externalFileOwners[relativePath] = owner[1];
|
|
1134
|
-
}
|
|
1135
|
-
const hash = (0, _animus_ui_extract_pipeline.contentHash)(code);
|
|
1136
|
-
ctx.fileCache.set(relativePath, {
|
|
1137
|
-
hash,
|
|
1138
|
-
source: code
|
|
1139
|
-
});
|
|
1140
|
-
const fileEntries = buildFileEntriesFromCache(ctx.fileCache, relativePath);
|
|
1141
|
-
ctx.runAnalysis(fileEntries);
|
|
1142
|
-
const compCount = ctx.storedManifest.files?.[relativePath]?.length ?? 0;
|
|
1143
|
-
ctx.info(`New file detected: ${relativePath} — ${compCount ? `${compCount} components extracted` : "no components"}`);
|
|
1144
|
-
ctx.invalidateExtractedModules();
|
|
1145
|
-
}
|
|
1146
|
-
if (!ctx.storedManifest.files?.[relativePath]?.length) return null;
|
|
1147
|
-
}
|
|
1148
|
-
try {
|
|
1149
|
-
const { transformFile } = ctx.engineApi();
|
|
1150
|
-
const result = transformFile(code, relativePath, ctx.storedManifestJson);
|
|
1151
|
-
if (!result.hasComponents) return null;
|
|
1152
|
-
if (ctx.verbose) {
|
|
1153
|
-
const compCount = ctx.storedManifest.files?.[relativePath]?.length ?? 0;
|
|
1154
|
-
ctx.log(`transform ${relativePath}: ${compCount} components`);
|
|
1155
|
-
}
|
|
1156
|
-
let outputCode = result.code;
|
|
1157
|
-
if (!ctx.isProd) {
|
|
1158
|
-
const prologue = /^(?:(['"])use [a-z -]+\1;?\r?\n)*/.exec(result.code)?.[0] ?? "";
|
|
1159
|
-
outputCode = prologue + `import '${VIRTUAL_BRIDGE_ID}';\n` + result.code.slice(prologue.length);
|
|
1160
|
-
}
|
|
1161
|
-
return {
|
|
1162
|
-
code: outputCode,
|
|
1163
|
-
map: null
|
|
1164
|
-
};
|
|
1165
|
-
} catch (e) {
|
|
1166
|
-
if (ctx.options.strict) throw new Error(`[animus-extract] Failed to transform ${id}: ${e}`, { cause: e });
|
|
1167
|
-
console.warn(`[animus-extract] Failed to transform ${id}:`, e);
|
|
1168
|
-
return null;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
//#endregion
|
|
1172
1235
|
//#region src/virtual-modules.ts
|
|
1173
1236
|
/** resolveId: map virtual ids and redirect external DS package imports. */
|
|
1174
1237
|
function resolveVirtualId(ctx, id) {
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { PluginContext } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* The dev-mode bridge prepend, shared with the hot-update gate so both
|
|
4
|
+
* compute byte-identical served output. The import goes AFTER the directive
|
|
5
|
+
* prologue the engine hoists to byte 0 — prepending above it would demote
|
|
6
|
+
* 'use client'/'use strict' to an ordinary expression statement, silently
|
|
7
|
+
* un-marking client modules on exactly the RSC-capable hosts this delivery
|
|
8
|
+
* path serves.
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyDevBridgeImport(code: string): string;
|
|
2
11
|
/**
|
|
3
12
|
* transform: replace builder chains with `createComponent()` calls using
|
|
4
13
|
* the pre-built manifest; detect files created after buildStart and fold
|
package/dist/transform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAqHpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Animus static CSS extraction Vite plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animus",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"compile": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@animus-ui/extract": "0.1.
|
|
42
|
+
"@animus-ui/extract": "0.1.6",
|
|
43
43
|
"browserslist": "^4.24.0",
|
|
44
44
|
"lightningcss": "^1.29.0"
|
|
45
45
|
},
|