@analogjs/vite-plugin-angular 3.0.0-alpha.24 → 3.0.0-alpha.26
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/package.json +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/angular-jit-plugin.js +8 -2
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +69 -3
- package/src/lib/angular-vite-plugin.js +1084 -92
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +16 -0
- package/src/lib/component-resolvers.js +77 -16
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/host.d.ts +3 -3
- package/src/lib/host.js +43 -19
- package/src/lib/host.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.js +6 -1
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/style-pipeline.d.ts +15 -0
- package/src/lib/style-pipeline.js +31 -0
- package/src/lib/style-pipeline.js.map +1 -0
- package/src/lib/style-preprocessor.d.ts +35 -1
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/stylesheet-registry.d.ts +73 -0
- package/src/lib/stylesheet-registry.js +168 -0
- package/src/lib/stylesheet-registry.js.map +1 -0
- package/src/lib/utils/debug.d.ts +7 -2
- package/src/lib/utils/debug.js +13 -3
- package/src/lib/utils/debug.js.map +1 -1
- package/src/lib/utils/devkit.d.ts +4 -4
- package/src/lib/utils/devkit.js.map +1 -1
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\n\nexport default angular;\n"],"mappings":";;AAGA,IAAA,cAAe"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debugStyles } from "./utils/debug.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
+
import { preprocessCSS } from "vite";
|
|
3
4
|
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
4
5
|
function jitPlugin({ inlineStylesExtension }) {
|
|
5
6
|
let config;
|
|
@@ -20,7 +21,12 @@ function jitPlugin({ inlineStylesExtension }) {
|
|
|
20
21
|
try {
|
|
21
22
|
styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
|
|
22
23
|
} catch (e) {
|
|
23
|
-
|
|
24
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
25
|
+
debugStyles("jit css compilation error", {
|
|
26
|
+
styleIdHash,
|
|
27
|
+
error: errorMessage
|
|
28
|
+
});
|
|
29
|
+
console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
|
|
24
30
|
}
|
|
25
31
|
return `export default \`${styles}\``;
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes('virtual:angular:jit:style:inline;')) {\n const styleId = id.split('style:inline;')[1];\n // styleId may exceed 255 bytes of base64-encoded content, limit to 16\n const styleIdHash = createHash('sha256')\n .update(styleId)\n .digest('hex')\n .slice(0, 16);\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(styleId),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n
|
|
1
|
+
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport { debugStyles } from './utils/debug.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes('virtual:angular:jit:style:inline;')) {\n const styleId = id.split('style:inline;')[1];\n // styleId may exceed 255 bytes of base64-encoded content, limit to 16\n const styleIdHash = createHash('sha256')\n .update(styleId)\n .digest('hex')\n .slice(0, 16);\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(styleId),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAS,oCAAoC,EAAE;IACpD,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC;IAE1C,MAAM,cAAc,WAAW,SAAS,CACrC,OAAO,QAAQ,CACf,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;IAEf,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,QAAQ,EAC3B,SACD,CAAC,UAAU;IAEZ,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,eACA,GAAG,YAAY,GAAG,sBAAsB,UACxC,OACD,GACkB;aACZ,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AAC/D,iBAAY,6BAA6B;MACvC;MACA,OAAO;MACR,CAAC;AACF,aAAQ,KACN,6HACA,aACA,aACD;;AAGH,WAAO,oBAAoB,OAAO;;;EAKvC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NgtscProgram } from "@angular/compiler-cli";
|
|
2
2
|
import * as ts from "typescript";
|
|
3
|
-
import { Plugin } from "vite";
|
|
3
|
+
import { ModuleNode, Plugin, ViteDevServer } from "vite";
|
|
4
4
|
import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
5
5
|
import { type DebugOption } from "./utils/debug.js";
|
|
6
6
|
import { FileReplacement } from "./plugins/file-replacements.plugin.js";
|
|
7
|
+
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
8
|
+
import { type AngularStylePipelineOptions } from "./style-pipeline.js";
|
|
7
9
|
export declare enum DiagnosticModes {
|
|
8
10
|
None = 0,
|
|
9
11
|
Option = 1,
|
|
@@ -29,6 +31,16 @@ export interface PluginOptions {
|
|
|
29
31
|
*/
|
|
30
32
|
include?: string[];
|
|
31
33
|
additionalContentDirs?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Enables Angular's HMR during development/watch mode.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `true` for watch mode. Set to `false` to disable HMR while
|
|
38
|
+
* keeping other stylesheet externalization behavior available when needed.
|
|
39
|
+
*/
|
|
40
|
+
hmr?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `hmr` instead. Kept as a compatibility alias.
|
|
43
|
+
*/
|
|
32
44
|
liveReload?: boolean;
|
|
33
45
|
disableTypeChecking?: boolean;
|
|
34
46
|
fileReplacements?: FileReplacement[];
|
|
@@ -39,7 +51,7 @@ export interface PluginOptions {
|
|
|
39
51
|
* Enable debug logging for specific scopes.
|
|
40
52
|
*
|
|
41
53
|
* - `true` → enables all `analog:angular:*` scopes
|
|
42
|
-
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:
|
|
54
|
+
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:tailwind']`)
|
|
43
55
|
* - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
|
|
44
56
|
* to restrict output to a specific Vite command (omit for both)
|
|
45
57
|
*
|
|
@@ -58,6 +70,14 @@ export interface PluginOptions {
|
|
|
58
70
|
*/
|
|
59
71
|
stylePreprocessor?: StylePreprocessor;
|
|
60
72
|
/**
|
|
73
|
+
* Experimental Angular stylesheet-resource hooks for community-maintained
|
|
74
|
+
* style-pipeline plugins.
|
|
75
|
+
*
|
|
76
|
+
* These hooks run inside the Angular resource pipeline, which is the seam a
|
|
77
|
+
* standalone Vite plugin cannot own on its own.
|
|
78
|
+
*/
|
|
79
|
+
stylePipeline?: AngularStylePipelineOptions;
|
|
80
|
+
/**
|
|
61
81
|
* First-class Tailwind CSS v4 integration for Angular component styles.
|
|
62
82
|
*
|
|
63
83
|
* Angular's compiler processes component CSS through Vite's `preprocessCSS()`,
|
|
@@ -124,6 +144,15 @@ export interface PluginOptions {
|
|
|
124
144
|
prefixes?: string[];
|
|
125
145
|
};
|
|
126
146
|
}
|
|
147
|
+
export declare function normalizeIncludeGlob(workspaceRoot: string, glob: string): string;
|
|
148
|
+
export declare function evictDeletedFileMetadata(file: string, { removeActiveGraphMetadata, removeStyleOwnerMetadata, classNamesMap, fileTransformMap }: {
|
|
149
|
+
removeActiveGraphMetadata: (file: string) => void;
|
|
150
|
+
removeStyleOwnerMetadata: (file: string) => void;
|
|
151
|
+
classNamesMap: Map<string, string>;
|
|
152
|
+
fileTransformMap: Map<string, string>;
|
|
153
|
+
}): void;
|
|
154
|
+
export declare function injectViteIgnoreForHmrMetadata(code: string): string;
|
|
155
|
+
export declare function isIgnoredHmrFile(file: string): boolean;
|
|
127
156
|
export declare function angular(options?: PluginOptions): Plugin[];
|
|
128
157
|
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
129
158
|
/**
|
|
@@ -153,7 +182,43 @@ export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<s
|
|
|
153
182
|
className: string;
|
|
154
183
|
code: string;
|
|
155
184
|
}>;
|
|
156
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Returns every live Vite module that can legitimately represent a changed
|
|
187
|
+
* Angular resource file.
|
|
188
|
+
*
|
|
189
|
+
* For normal files, `getModulesByFile()` is enough. For Angular component
|
|
190
|
+
* stylesheets, it is not: the browser often holds virtual hashed requests
|
|
191
|
+
* (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
|
|
192
|
+
* longer discoverable from the original source path alone. We therefore merge:
|
|
193
|
+
* - watcher event modules
|
|
194
|
+
* - module-graph modules by source file
|
|
195
|
+
* - registry-tracked live request ids resolved back through the module graph
|
|
196
|
+
*/
|
|
197
|
+
export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
198
|
+
export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Refreshes any already-served stylesheet records that map back to a changed
|
|
201
|
+
* source file.
|
|
202
|
+
*
|
|
203
|
+
* This is the critical bridge for externalized Angular component styles during
|
|
204
|
+
* HMR. Angular's resource watcher can notice that `/src/...component.css`
|
|
205
|
+
* changed before Angular recompilation has had a chance to repopulate the
|
|
206
|
+
* stylesheet registry. If we emit a CSS update against the existing virtual
|
|
207
|
+
* stylesheet id without first refreshing the registry content, the browser gets
|
|
208
|
+
* a hot update containing stale CSS. By rewriting the existing served records
|
|
209
|
+
* from disk up front, HMR always pushes the latest source content.
|
|
210
|
+
*/
|
|
211
|
+
export declare function refreshStylesheetRegistryForFile(file: string, stylesheetRegistry?: AnalogStylesheetRegistry, stylePreprocessor?: StylePreprocessor): void;
|
|
212
|
+
export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
213
|
+
interface TemplateClassBindingIssue {
|
|
214
|
+
line: number;
|
|
215
|
+
column: number;
|
|
216
|
+
snippet: string;
|
|
217
|
+
}
|
|
218
|
+
export declare function findStaticClassAndBoundClassConflicts(template: string): TemplateClassBindingIssue[];
|
|
219
|
+
export declare function findBoundClassAndNgClassConflicts(template: string): TemplateClassBindingIssue[];
|
|
220
|
+
export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
|
|
221
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
157
222
|
errors?: string[];
|
|
158
223
|
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
159
224
|
hmrUpdateCode?: string | null;
|
|
@@ -164,3 +229,4 @@ export declare function getFileMetadata(program: ts.BuilderProgram, angularCompi
|
|
|
164
229
|
* @returns boolean
|
|
165
230
|
*/
|
|
166
231
|
export declare function isTestWatchMode(args?: string[]): boolean;
|
|
232
|
+
export {};
|