@animus-ui/vite-plugin 0.1.1 → 0.1.2
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 +66 -0
- package/dist/build-start.d.ts +9 -0
- package/dist/build-start.d.ts.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/context.d.ts +171 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/css.d.ts +9 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/hmr.d.ts +23 -0
- package/dist/hmr.d.ts.map +1 -0
- package/dist/hot-update-events.d.ts +54 -0
- package/dist/hot-update-events.d.ts.map +1 -0
- package/dist/index-html.d.ts +27 -0
- package/dist/index-html.d.ts.map +1 -0
- package/dist/index.cjs +878 -742
- package/dist/index.d.ts +55 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/reset-coalescer.d.ts +22 -0
- package/dist/reset-coalescer.d.ts.map +1 -0
- package/dist/transform.d.ts +11 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/virtual-modules.d.ts +7 -0
- package/dist/virtual-modules.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/analyze-project-args.d.ts +0 -2
- package/dist/analyze-project-args.d.ts.map +0 -1
- package/dist/manifest-diagnostics.d.ts +0 -10
- package/dist/manifest-diagnostics.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -30,6 +30,72 @@ The `system` option points to the file that exports your built system instance.
|
|
|
30
30
|
3. **Transforms**: Resolves `__TRANSFORM__` placeholders using your system's named transform functions
|
|
31
31
|
4. **Global styles**: Emits global styles (reset, base) from your exported `createGlobalStyles()` configuration
|
|
32
32
|
|
|
33
|
+
## Appearance bootstrap
|
|
34
|
+
|
|
35
|
+
Optional. Restores a persisted color mode before first paint, so a dark-persisted
|
|
36
|
+
page never flashes a light frame — with **zero runtime and a real CSP story**.
|
|
37
|
+
The restoration is a generated, dependency-free inline snippet (not a component,
|
|
38
|
+
not a listener), and its `script-src` hash is computed at build time from the
|
|
39
|
+
exact bytes generated. Runtime theme switchers have to choose between
|
|
40
|
+
`unsafe-inline` and a hand-maintained hash that goes stale; here the artifact IS
|
|
41
|
+
the hash source, so a theme edit can never strand a stale hash without also
|
|
42
|
+
changing the code it authorizes.
|
|
43
|
+
|
|
44
|
+
Generate the artifact **in your Vite config** — it is build tooling, and nothing
|
|
45
|
+
under `src/` may import it:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// vite.config.ts
|
|
49
|
+
import { createAppearanceBootstrap } from '@animus-ui/system/bootstrap';
|
|
50
|
+
import { animusExtract } from '@animus-ui/vite-plugin';
|
|
51
|
+
import { defineConfig } from 'vite';
|
|
52
|
+
|
|
53
|
+
import { tokens } from './src/ds';
|
|
54
|
+
|
|
55
|
+
const appearanceBootstrap = createAppearanceBootstrap(tokens);
|
|
56
|
+
|
|
57
|
+
export default defineConfig({
|
|
58
|
+
plugins: [animusExtract({ system: './src/ds.ts', appearanceBootstrap })],
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The plugin is **delivery-only**: it injects `artifact.code` verbatim as an inline
|
|
63
|
+
`<script data-animus-bootstrap>` at the start of `<head>`, ahead of every
|
|
64
|
+
stylesheet reference, and interprets no appearance semantics. Omit the option and
|
|
65
|
+
the built HTML is byte-for-byte what it was before.
|
|
66
|
+
|
|
67
|
+
### Content-Security-Policy
|
|
68
|
+
|
|
69
|
+
The artifact's second field, `cspHash`, authorizes that inline script. Two rules:
|
|
70
|
+
|
|
71
|
+
- **Derive it from the artifact at build time.** `createAppearanceBootstrap`
|
|
72
|
+
returns the hash of the exact bytes it just generated. Renaming a color mode or
|
|
73
|
+
changing `storageKey` changes those bytes and therefore the hash — a
|
|
74
|
+
hand-copied literal in a config file silently becomes stale, and a stale hash
|
|
75
|
+
means a blocked script and a flash of the wrong mode.
|
|
76
|
+
- **Single-quote it in `script-src`.** The value is returned ready to use:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Content-Security-Policy: script-src 'sha256-…'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Unquoted, `sha256-…` parses as a _host_ source, matches nothing, and silently
|
|
83
|
+
fails to authorize the script.
|
|
84
|
+
|
|
85
|
+
Never fall back to `unsafe-inline`, and never use a build-time constant nonce.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// Build the header from the artifact — never from a copied string.
|
|
89
|
+
// The hash is single-quoted in the source list, per the rule above.
|
|
90
|
+
const csp = `script-src 'self' '${appearanceBootstrap.cspHash}'`;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Next.js is deliberately not automatic: CSP nonces need request-time control the
|
|
94
|
+
bundler does not have, so the application places `artifact.code` itself and
|
|
95
|
+
supplies either `cspHash` or a per-request nonce. Worked App Router and Pages
|
|
96
|
+
Router examples live in the
|
|
97
|
+
[`@animus-ui/next-plugin` README](https://github.com/codecaaron/animus/tree/main/packages/next-plugin#appearance-bootstrap-no-fouc-color-mode).
|
|
98
|
+
|
|
33
99
|
## Important
|
|
34
100
|
|
|
35
101
|
- Do **not** add React resolve aliases to `vite.config.ts` — they break the extraction transform pipeline
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginContext } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* buildStart: load the system, discover and ingest sources (local +
|
|
4
|
+
* external packages), run whole-project analysis, and log the report.
|
|
5
|
+
* `resolveSpecifier` is the bundler seam — Vite's `this.resolve` mapped to
|
|
6
|
+
* an absolute id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runBuildStart(ctx: PluginContext, resolveSpecifier: (specifier: string) => Promise<string | null>): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=build-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAC9D,OAAO,CAAC,IAAI,CAAC,CAiNf"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginContext } from './context';
|
|
2
|
+
import type { ResolvedConfig } from 'vite';
|
|
3
|
+
/**
|
|
4
|
+
* configResolved: capture build mode, root, and logger; resolve Lightning
|
|
5
|
+
* CSS targets; harvest resolve.alias into the Rust `pathAliasesJson`
|
|
6
|
+
* contract via the shared encoder.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyResolvedConfig(ctx: PluginContext, config: ResolvedConfig): void;
|
|
9
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CAqDN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const VIRTUAL_CSS_ID = "virtual:animus/styles.css";
|
|
2
|
+
export declare const RESOLVED_CSS_ID = "\0virtual:animus/styles.css";
|
|
3
|
+
export declare const VIRTUAL_COMPONENTS_ID = "virtual:animus/components.js";
|
|
4
|
+
export declare const RESOLVED_COMPONENTS_ID = "\0virtual:animus/components.js";
|
|
5
|
+
export declare const VIRTUAL_BRIDGE_ID = "virtual:animus/hmr-bridge.js";
|
|
6
|
+
export declare const RESOLVED_BRIDGE_ID = "\0virtual:animus/hmr-bridge.js";
|
|
7
|
+
export declare const VIRTUAL_SYSTEM_PROPS_ID = "virtual:animus/system-props";
|
|
8
|
+
export declare const RESOLVED_SYSTEM_PROPS_ID = "\0virtual:animus/system-props";
|
|
9
|
+
export declare const DEFAULT_EXCLUDE: string[];
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,8BAA8B,CAAC;AAC1D,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAE7D,eAAO,MAAM,qBAAqB,iCAAiC,CAAC;AACpE,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,eAAO,MAAM,iBAAiB,iCAAiC,CAAC;AAChE,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AAEnE,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AACrE,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,eAAO,MAAM,eAAe,UAA+C,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { HotUpdateEvents } from './hot-update-events';
|
|
2
|
+
import type { LightningTargets } from './css';
|
|
3
|
+
import type { AnimusExtractOptions } from './index';
|
|
4
|
+
import type { ExternalPackageOutcome, SystemConfig } from '@animus-ui/extract/pipeline';
|
|
5
|
+
import type { Logger } from 'vite';
|
|
6
|
+
/**
|
|
7
|
+
* Structured per-layer CSS sheets from the Rust crate (dev split delivery).
|
|
8
|
+
* Mirrors the `CssSheets` struct in packages/extract/src/css_generator.rs —
|
|
9
|
+
* keep these fields in sync.
|
|
10
|
+
*/
|
|
11
|
+
export interface CssSheets {
|
|
12
|
+
declaration: string;
|
|
13
|
+
global: string;
|
|
14
|
+
base: string;
|
|
15
|
+
variants: string;
|
|
16
|
+
compounds: string;
|
|
17
|
+
states: string;
|
|
18
|
+
system: string;
|
|
19
|
+
custom: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reconstruct file entries from cache, including content hashes.
|
|
23
|
+
* For unchanged files (hash matches changedPath), sends empty source
|
|
24
|
+
* to avoid serializing full source text across the NAPI boundary.
|
|
25
|
+
* The engine adapter's `rehydrateFilesJson` refills empty sources from
|
|
26
|
+
* this same cache before analyze.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildFileEntriesFromCache(cache: Map<string, {
|
|
29
|
+
hash: string;
|
|
30
|
+
source: string;
|
|
31
|
+
}>, changedPath?: string): Array<{
|
|
32
|
+
path: string;
|
|
33
|
+
source: string;
|
|
34
|
+
hash: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Drop a deleted (or renamed-away) file from the dev file cache so its
|
|
38
|
+
* last-known source stops riding along as a ghost entry on every later
|
|
39
|
+
* re-analysis. Both key forms are tried: the plain rootDir-relative path, and
|
|
40
|
+
* the `.tsx` suffix MDX sources carry after preprocessing. External package
|
|
41
|
+
* entries are rootDir-relative too (with leading `..` segments) and prune the
|
|
42
|
+
* same way. Returns whether an entry was actually removed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pruneFileCache(cache: Map<string, {
|
|
45
|
+
hash: string;
|
|
46
|
+
source: string;
|
|
47
|
+
}>, rootDir: string, absPath: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Per-plugin-instance state and the pipeline operations over it. Hook
|
|
50
|
+
* bodies live in their own modules (build-start, virtual-modules,
|
|
51
|
+
* transform, hmr) and receive this context — the plugin factory in
|
|
52
|
+
* index.ts only wires Vite hooks to those functions.
|
|
53
|
+
*
|
|
54
|
+
* A class rather than closure variables so each hook module names exactly
|
|
55
|
+
* the state it touches, and the engine store (DEF-1: per-instance, never
|
|
56
|
+
* module-level) is explicit.
|
|
57
|
+
*/
|
|
58
|
+
export declare class PluginContext {
|
|
59
|
+
readonly options: AnimusExtractOptions;
|
|
60
|
+
readonly verbose: boolean;
|
|
61
|
+
/** Serialized staticCss forced-emission declarations (stable key order). */
|
|
62
|
+
readonly staticCssJson: string | null;
|
|
63
|
+
isProd: boolean;
|
|
64
|
+
rootDir: string;
|
|
65
|
+
logger: Logger | null;
|
|
66
|
+
/** System-derived config (shared SystemConfig shape). */
|
|
67
|
+
system: SystemConfig;
|
|
68
|
+
lcssTargets: LightningTargets;
|
|
69
|
+
pathAliasesJson: string | null;
|
|
70
|
+
extensionsSet: ReadonlySet<string>;
|
|
71
|
+
storedManifest: any;
|
|
72
|
+
storedManifestJson: string;
|
|
73
|
+
globalCss: string;
|
|
74
|
+
resolvedComponentCss: string;
|
|
75
|
+
storedSheets: CssSheets | null;
|
|
76
|
+
layerDeclaration: string;
|
|
77
|
+
fragmentCache: Map<string, {
|
|
78
|
+
base?: string;
|
|
79
|
+
variants?: string;
|
|
80
|
+
compounds?: string;
|
|
81
|
+
states?: string;
|
|
82
|
+
}>;
|
|
83
|
+
reverseProvenance: Record<string, string[]>;
|
|
84
|
+
storedSystemPropMapJson: string;
|
|
85
|
+
storedDynamicPropsJson: string;
|
|
86
|
+
storedTransformsSource: string;
|
|
87
|
+
fileCache: Map<string, {
|
|
88
|
+
hash: string;
|
|
89
|
+
source: string;
|
|
90
|
+
}>;
|
|
91
|
+
readonly hotUpdateEvents: HotUpdateEvents;
|
|
92
|
+
packageMap: Record<string, string>;
|
|
93
|
+
externalPackageDirs: string[];
|
|
94
|
+
externalSourceEntries: Map<string, string>;
|
|
95
|
+
externalPackageOutcomes: ExternalPackageOutcome[];
|
|
96
|
+
devServer: any;
|
|
97
|
+
bridgeInjected: boolean;
|
|
98
|
+
resolvedSystemPath: string | null;
|
|
99
|
+
systemDependencyKeys: Set<string>;
|
|
100
|
+
systemDependencyPaths: string[];
|
|
101
|
+
private v2Engine;
|
|
102
|
+
private v2SentSources;
|
|
103
|
+
private v2DriftWarned;
|
|
104
|
+
/** Single engine choke-point for every native extraction call. */
|
|
105
|
+
readonly engineApi: () => any;
|
|
106
|
+
constructor(options: AnimusExtractOptions);
|
|
107
|
+
log(msg: string): void;
|
|
108
|
+
warn(msg: string): void;
|
|
109
|
+
logTimingWaterfall(timing: Record<string, number>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Load a SystemInstance via Rust NAPI (rquickjs bundled eval) into
|
|
112
|
+
* `this.system`. On failure the previous config is kept (strict mode
|
|
113
|
+
* throws instead).
|
|
114
|
+
*/
|
|
115
|
+
loadSystem(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Run project analysis via the shared `runProjectAnalysis` and update
|
|
118
|
+
* all manifest-derived state.
|
|
119
|
+
*/
|
|
120
|
+
runAnalysis(fileEntries: Array<{
|
|
121
|
+
path: string;
|
|
122
|
+
source: string;
|
|
123
|
+
hash?: string;
|
|
124
|
+
}>): void;
|
|
125
|
+
private resetCoalescer;
|
|
126
|
+
/**
|
|
127
|
+
* Schedule a geological reset through the burst coalescer. N dependency
|
|
128
|
+
* events within the quiescence window produce one reset; events during a
|
|
129
|
+
* running reset produce exactly one follow-up.
|
|
130
|
+
*/
|
|
131
|
+
requestGeologicalReset(trigger: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* The geological reset: reload the system (refreshing the dependency
|
|
134
|
+
* set), clear the Rust per-file cache, re-analyze everything with full
|
|
135
|
+
* sources, then invalidate the static/component/system-prop virtual
|
|
136
|
+
* modules and reload the client.
|
|
137
|
+
*/
|
|
138
|
+
performGeologicalReset(): void;
|
|
139
|
+
/**
|
|
140
|
+
* True when the file is a member of the system's evaluated module-file
|
|
141
|
+
* set. Tested BEFORE component-scan exclude filters: a system dependency
|
|
142
|
+
* edit invalidates the compiler registry regardless of what the user
|
|
143
|
+
* excluded from component scanning.
|
|
144
|
+
*/
|
|
145
|
+
isSystemDependency(absFile: string): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Ask the dev watcher to watch every loader-reported dependency path.
|
|
148
|
+
* Covers system modules unreachable from app imports (workspace package
|
|
149
|
+
* config files). Vite's watcher hard-ignores `node_modules`, so
|
|
150
|
+
* node_modules-installed system dependencies produce no events — a
|
|
151
|
+
* documented limitation; workspace deps resolve to real paths outside
|
|
152
|
+
* node_modules and are watchable. No-ops without a dev server.
|
|
153
|
+
*/
|
|
154
|
+
registerSystemWatchPaths(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Invalidate the component CSS and system-props virtual modules, then
|
|
157
|
+
* reload the client. Shared by the two out-of-band re-analysis paths — a
|
|
158
|
+
* file created after buildStart (transform) and a file deleted during dev
|
|
159
|
+
* (the `hotUpdate` delete event) — which both mutate the cache, re-run
|
|
160
|
+
* analysis, and then need the client to pick up the regenerated CSS.
|
|
161
|
+
* No-ops outside dev.
|
|
162
|
+
*
|
|
163
|
+
* `devServer.moduleGraph` is Vite's back-compat mixed graph: its
|
|
164
|
+
* `getModuleById` searches the client AND ssr environment graphs and its
|
|
165
|
+
* `invalidateModule` invalidates both instances behind the returned node,
|
|
166
|
+
* which is exactly the reach this path wants. It stays the seam here.
|
|
167
|
+
*/
|
|
168
|
+
invalidateExtractedModules(): void;
|
|
169
|
+
runSelfVerify(): void;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAmBA,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,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,EA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AE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAClE,IAAI,CAuDN;IAGD,OAAO,CAAC,cAAc,CAA+B;IAErD;;;;OAIG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAM5C;IAED;;;;;OAKG;IACH,sBAAsB,IAAI,IAAI,CA4B7B;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI3C;IAED;;;;;;;OAOG;IACH,wBAAwB,IAAI,IAAI,CAI/B;IAED;;;;;;;;;;;;OAYG;IACH,0BAA0B,IAAI,IAAI,CAkBjC;IAED,aAAa,IAAI,IAAI,CA+DpB;CACF"}
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS post-processing — the implementation lives in
|
|
3
|
+
* `@animus-ui/extract/pipeline` (spec: css-post-processing, single
|
|
4
|
+
* implementation across plugins). This module re-exports it for the
|
|
5
|
+
* plugin's hook modules.
|
|
6
|
+
*/
|
|
7
|
+
export type { LightningTargets } from '@animus-ui/extract/pipeline';
|
|
8
|
+
export { postProcessCss, resolveLightningTargets, } from '@animus-ui/extract/pipeline';
|
|
9
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EACL,cAAc,EACd,uBAAuB,GACxB,MAAM,6BAA6B,CAAC"}
|
package/dist/hmr.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluginContext } from './context';
|
|
2
|
+
import type { DevEnvironment, EnvironmentModuleNode, HotUpdateOptions } from 'vite';
|
|
3
|
+
/**
|
|
4
|
+
* hotUpdate: the single dev file-event hook. Handles system-dependency
|
|
5
|
+
* membership (geological reset), content-hash diffing with incremental
|
|
6
|
+
* re-analysis, deleted-file cache pruning, and targeted module invalidation
|
|
7
|
+
* (component CSS, system props, and definition files whose replacement
|
|
8
|
+
* changed).
|
|
9
|
+
*
|
|
10
|
+
* Vite 8 dispatches this hook once per environment for ONE file event — the
|
|
11
|
+
* client environment first, then every non-client environment (see
|
|
12
|
+
* `handleHMRUpdate` in vite/dist/node/chunks/node.js). The analysis half is
|
|
13
|
+
* therefore claimed by exactly one dispatch (`ctx.hotUpdateEvents`), while the
|
|
14
|
+
* invalidation half runs in every environment against its own module graph —
|
|
15
|
+
* what the mixed-graph `handleHotUpdate` used to achieve implicitly by
|
|
16
|
+
* invalidating the client and SSR instance behind one module node.
|
|
17
|
+
*
|
|
18
|
+
* The hook fires for every watched file whether or not it has modules in any
|
|
19
|
+
* graph, so system dependencies registered through `watcher.add` outside the
|
|
20
|
+
* root still reach the reset branch, with an empty `modules` list.
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleHotUpdate(ctx: PluginContext, environment: DevEnvironment, { type, file, timestamp, modules }: HotUpdateOptions): Promise<EnvironmentModuleNode[] | void>;
|
|
23
|
+
//# sourceMappingURL=hmr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAWA,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,EAAE,gBAAgB,GACnD,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAgEzC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the owning dispatch decided for one file event, so the remaining
|
|
3
|
+
* environments act on the same decision instead of re-deriving it from state
|
|
4
|
+
* the owner already mutated.
|
|
5
|
+
*
|
|
6
|
+
* - `ignored` — out of extraction scope (extension gate, exclude pattern,
|
|
7
|
+
* unreadable, MDX skipped): normal Vite HMR applies.
|
|
8
|
+
* - `unchanged` — content hash identical: the update is suppressed everywhere.
|
|
9
|
+
* - `analyzed` — re-analysis ran; every environment invalidates the affected
|
|
10
|
+
* modules in its own graph. `staleDefinitionFiles` are rootDir-relative
|
|
11
|
+
* definition files whose component replacement changed (the changed file
|
|
12
|
+
* itself is never listed).
|
|
13
|
+
*/
|
|
14
|
+
export type HotUpdateResult = {
|
|
15
|
+
kind: 'ignored';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'unchanged';
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'analyzed';
|
|
20
|
+
staleDefinitionFiles: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Once-per-file-event coordination across the `hotUpdate` dispatches.
|
|
24
|
+
*
|
|
25
|
+
* Vite 8 calls `hotUpdate` once per environment for a single file event — the
|
|
26
|
+
* client environment first, then every non-client environment (see
|
|
27
|
+
* `handleHMRUpdate` in vite/dist/node/chunks/node.js). Analysis work (cache
|
|
28
|
+
* mutation, engine re-analysis, geological reset scheduling) must happen
|
|
29
|
+
* exactly once per event; module invalidation must happen per environment
|
|
30
|
+
* against that environment's own graph.
|
|
31
|
+
*
|
|
32
|
+
* The client dispatch always claims — it is dispatched first, so nothing can
|
|
33
|
+
* have claimed the event before it, and claiming unconditionally keeps a
|
|
34
|
+
* same-millisecond `(file, timestamp)` collision from ever costing a client
|
|
35
|
+
* analysis. A non-client dispatch claims only when the event carries no
|
|
36
|
+
* recorded claim at all, which happens when the plugin is filtered out of the
|
|
37
|
+
* client environment.
|
|
38
|
+
*
|
|
39
|
+
* Keys are retained for a bounded number of recent events so that interleaved
|
|
40
|
+
* file events (Vite does not serialize watcher handlers) still find their own
|
|
41
|
+
* result.
|
|
42
|
+
*/
|
|
43
|
+
export declare class HotUpdateEvents {
|
|
44
|
+
private readonly historyLimit;
|
|
45
|
+
private readonly results;
|
|
46
|
+
constructor(historyLimit?: number);
|
|
47
|
+
/** True when this environment dispatch owns the event's analysis work. */
|
|
48
|
+
claim(environmentName: string, file: string, timestamp: number): boolean;
|
|
49
|
+
/** Publish the owning dispatch's decision to the other environments. */
|
|
50
|
+
record(file: string, timestamp: number, result: HotUpdateResult): void;
|
|
51
|
+
/** The decision for this event — `ignored` when the event was evicted. */
|
|
52
|
+
resultOf(file: string, timestamp: number): HotUpdateResult;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=hot-update-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hot-update-events.d.ts","sourceRoot":"","sources":["../src/hot-update-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,oBAAoB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginContext } from './context';
|
|
2
|
+
import type { HtmlTagDescriptor } from 'vite';
|
|
3
|
+
/**
|
|
4
|
+
* transformIndexHtml: build the head-prepend tag set.
|
|
5
|
+
*
|
|
6
|
+
* Two independent tags, both delivery-only:
|
|
7
|
+
* - the appearance bootstrap script, when the host build passed a
|
|
8
|
+
* pre-generated artifact via `appearanceBootstrap` (absent otherwise);
|
|
9
|
+
* - the `@layer` declaration style, when `buildStart` computed one.
|
|
10
|
+
*
|
|
11
|
+
* Both branches are guarded on non-empty CONTENT, not on mere presence: an
|
|
12
|
+
* artifact whose `code` is empty is a caller defect, and emitting
|
|
13
|
+
* `<script data-animus-bootstrap></script>` for it would break the
|
|
14
|
+
* unconfigured-parity contract in spirit (a tag that does nothing) while
|
|
15
|
+
* hiding the defect. Symmetric with `layerDeclaration`.
|
|
16
|
+
*
|
|
17
|
+
* Ordering: every descriptor rides the same `head-prepend` bucket, which Vite
|
|
18
|
+
* serializes in array order (`serializeTags`) and splices in immediately after
|
|
19
|
+
* `<head>`. The bootstrap script is therefore FIRST in the array so it runs
|
|
20
|
+
* before the layer declaration and — since built stylesheet links are appended
|
|
21
|
+
* at `</head>` — before any stylesheet reference.
|
|
22
|
+
*
|
|
23
|
+
* When neither input is set the array is empty, so an unconfigured build emits
|
|
24
|
+
* no tag, attribute, or whitespace of its own.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildIndexHtmlTags(ctx: PluginContext): HtmlTagDescriptor[];
|
|
27
|
+
//# sourceMappingURL=index-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-html.d.ts","sourceRoot":"","sources":["../src/index-html.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,iBAAiB,EAAE,CAuB1E"}
|