@nativescript/vite 8.0.0-alpha.7 → 8.0.0-alpha.9
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/configuration/angular.js +168 -26
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +37 -9
- package/configuration/base.js.map +1 -1
- package/configuration/typescript.js +1 -1
- package/configuration/typescript.js.map +1 -1
- package/helpers/angular/angular-linker.js +3 -12
- package/helpers/angular/angular-linker.js.map +1 -1
- package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
- package/helpers/angular/inject-component-hmr-registration.js +359 -0
- package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
- package/helpers/angular/util.d.ts +1 -0
- package/helpers/angular/util.js +88 -0
- package/helpers/angular/util.js.map +1 -1
- package/helpers/global-defines.d.ts +2 -0
- package/helpers/global-defines.js +2 -0
- package/helpers/global-defines.js.map +1 -1
- package/helpers/main-entry.js +109 -30
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +157 -14
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/prelink-angular.js +1 -4
- package/helpers/prelink-angular.js.map +1 -1
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/ts-config-paths.js +50 -2
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/workers.d.ts +7 -19
- package/helpers/workers.js +75 -3
- package/helpers/workers.js.map +1 -1
- package/hmr/entry-runtime.js +11 -29
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/client/index.js +40 -50
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +10 -1
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.js +18 -42
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/helpers/cjs-named-exports.d.ts +23 -0
- package/hmr/helpers/cjs-named-exports.js +152 -0
- package/hmr/helpers/cjs-named-exports.js.map +1 -0
- package/hmr/server/constants.js +13 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.js +10 -3
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/ns-core-cjs-shape.js +1 -1
- package/hmr/server/ns-core-cjs-shape.js.map +1 -1
- package/hmr/server/vite-plugin.js +16 -0
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-angular-hot-update.d.ts +1 -0
- package/hmr/server/websocket-angular-hot-update.js +15 -1
- package/hmr/server/websocket-angular-hot-update.js.map +1 -1
- package/hmr/server/websocket-core-bridge.js +1 -1
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-module-bindings.js +2 -2
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -2
- package/hmr/server/websocket-module-specifiers.js +190 -19
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-m-finalize.js +1 -1
- package/hmr/server/websocket-ns-m-finalize.js.map +1 -1
- package/hmr/server/websocket-ns-m-request.d.ts +11 -1
- package/hmr/server/websocket-ns-m-request.js +17 -9
- package/hmr/server/websocket-ns-m-request.js.map +1 -1
- package/hmr/server/websocket-runtime-compat.js +1 -1
- package/hmr/server/websocket-runtime-compat.js.map +1 -1
- package/hmr/server/websocket-served-module-helpers.d.ts +1 -1
- package/hmr/server/websocket-served-module-helpers.js +18 -1
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-vue-sfc.js +15 -60
- package/hmr/server/websocket-vue-sfc.js.map +1 -1
- package/hmr/server/websocket.d.ts +1 -1
- package/hmr/server/websocket.js +176 -167
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/runtime/dev-overlay.js +5 -17
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.js +1 -4
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder.js +38 -68
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +1 -4
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +30 -0
- package/hmr/shared/vendor/manifest.js +200 -22
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +3 -1
- package/runtime/core-aliases-early.js +17 -41
- package/runtime/core-aliases-early.js.map +1 -1
|
@@ -85,10 +85,7 @@ export function angularLinkerVitePlugin(projectRoot) {
|
|
|
85
85
|
if (!babel || !linkerPlugin)
|
|
86
86
|
return null;
|
|
87
87
|
if (debug) {
|
|
88
|
-
|
|
89
|
-
console.log('[ns-angular-linker][vite-load] linking', cleanId);
|
|
90
|
-
}
|
|
91
|
-
catch { }
|
|
88
|
+
console.log('[ns-angular-linker][vite-load] linking', cleanId);
|
|
92
89
|
}
|
|
93
90
|
const result = await babel.transformAsync(code, {
|
|
94
91
|
filename: cleanId,
|
|
@@ -125,10 +122,7 @@ export function angularLinkerVitePlugin(projectRoot) {
|
|
|
125
122
|
try {
|
|
126
123
|
const plugin = createLinker({ sourceMapping: false, fileSystem: angularFileSystem });
|
|
127
124
|
if (debug) {
|
|
128
|
-
|
|
129
|
-
console.log('[ns-angular-linker][vite] linking', cleanId);
|
|
130
|
-
}
|
|
131
|
-
catch { }
|
|
125
|
+
console.log('[ns-angular-linker][vite] linking', cleanId);
|
|
132
126
|
}
|
|
133
127
|
const result = await babel.transformAsync(code, {
|
|
134
128
|
filename: cleanId,
|
|
@@ -169,10 +163,7 @@ export function angularLinkerVitePluginPost(projectRoot) {
|
|
|
169
163
|
return null;
|
|
170
164
|
try {
|
|
171
165
|
if (debug) {
|
|
172
|
-
|
|
173
|
-
console.log('[ns-angular-linker][vite-post] linking', id.split('?', 1)[0]);
|
|
174
|
-
}
|
|
175
|
-
catch { }
|
|
166
|
+
console.log('[ns-angular-linker][vite-post] linking', id.split('?', 1)[0]);
|
|
176
167
|
}
|
|
177
168
|
const result = await babel.transformAsync(code, {
|
|
178
169
|
filename: id.split('?', 1)[0],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-linker.js","sourceRoot":"","sources":["../../../../../packages/vite/helpers/angular/angular-linker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAoB;IAC3D,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzF,IAAI,KAAK,GAAwC,IAAI,CAAC;IACtD,IAAI,YAAY,GAAQ,IAAI,CAAC;IAC7B,IAAI,iBAAiB,GAAQ,IAAI,CAAC;IAElC,KAAK,UAAU,UAAU;QACxB,IAAI,KAAK,IAAI,YAAY;YAAE,OAAO;QAClC,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC7C,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAC;YACrE,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAQ,CAAC;Y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wCAAwC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5E,CAAC;gBACD,MAAM,MAAM,GAAG,MAAO,KAAa,CAAC,cAAc,CAAC,IAAI,EAAE;oBACxD,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7B,UAAU,EAAE,KAAK;oBACjB,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,KAAK;oBACjB,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,CAAC,YAAY,CAAC;iBACvB,CAAC,CAAC;gBACH,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;gBACzC,CAAC;YACF,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite-side helper that injects HMR self-registration calls into the
|
|
3
|
+
* compiled output of user `.ts` files that declare `@Component`-
|
|
4
|
+
* decorated classes.
|
|
5
|
+
*
|
|
6
|
+
* After an HMR reboot, the global `__NS_HMR_REGISTER_COMPONENT__` hook
|
|
7
|
+
* (installed by `@nativescript/angular`) records each fresh class
|
|
8
|
+
* keyed by source name. HMR helpers (modal restore, route replay) read
|
|
9
|
+
* the registry to re-attach to the live class. See
|
|
10
|
+
* `hmr-class-registry.ts` for the runtime side of the contract.
|
|
11
|
+
*
|
|
12
|
+
* The helper exposes two phases used by complementary Vite plugins:
|
|
13
|
+
* 1. `findComponentClassNames(rawTs)` — scans the user's raw TS
|
|
14
|
+
* source for `@Component`-decorated classes. Used by an
|
|
15
|
+
* `enforce: 'pre'` plugin to discover names BEFORE the Analog
|
|
16
|
+
* Angular plugin compiles the file. The discovery has to happen
|
|
17
|
+
* on raw TS because the Angular plugin rewrites the `@Component`
|
|
18
|
+
* decorator into static metadata calls (`ɵsetClassMetadata`,
|
|
19
|
+
* `ɵɵdefineComponent`) and removes the textual `@Component(...)`
|
|
20
|
+
* pattern.
|
|
21
|
+
* 2. `appendComponentHmrRegistration(compiledCode, names)` — appends
|
|
22
|
+
* the registration snippet to the END of compiled JS produced by
|
|
23
|
+
* the Analog Angular plugin. Used by an `enforce: 'post'` plugin.
|
|
24
|
+
* Appending here is the only reliable insertion point because:
|
|
25
|
+
* - Class declarations are evaluated and bound by then.
|
|
26
|
+
* - Angular's static metadata (`ɵcmp`/`ɵfac`) has finished
|
|
27
|
+
* attaching, so the registered class identity already
|
|
28
|
+
* carries the up-to-date component definition.
|
|
29
|
+
* - The Analog Angular plugin's `transform` discards anything
|
|
30
|
+
* appended before its compilation step (it returns code
|
|
31
|
+
* regenerated from its own `outputFiles` cache, not the
|
|
32
|
+
* input passed in). Verified directly in the plugin chain.
|
|
33
|
+
* - Source-map line offsets for the original module body are
|
|
34
|
+
* preserved (we only append).
|
|
35
|
+
*
|
|
36
|
+
* The legacy `injectComponentHmrRegistration(rawTs)` helper is kept
|
|
37
|
+
* for backward compatibility — it appends to raw TS in a single call —
|
|
38
|
+
* but is no longer the path used by the live HMR pipeline (its output
|
|
39
|
+
* is silently dropped by the Angular plugin for `@Component` files).
|
|
40
|
+
*
|
|
41
|
+
* The helpers are dev-only: production builds skip the Vite plugins
|
|
42
|
+
* (`apply: 'serve'`), and the runtime hook short-circuits when
|
|
43
|
+
* `isAngularHmrEnabled()` is false.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Marker comment placed immediately before the appended registration
|
|
47
|
+
* block. Plugins can scan for this string to make their work
|
|
48
|
+
* idempotent across re-transforms (the Vite cache may replay the
|
|
49
|
+
* transform pipeline on cached modules).
|
|
50
|
+
*/
|
|
51
|
+
export declare const INJECTION_MARKER = "/* @nativescript/vite ns-hmr-register */";
|
|
52
|
+
export interface InjectComponentHmrRegistrationOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Optional override of the global hook name. Defaults to
|
|
55
|
+
* `__NS_HMR_REGISTER_COMPONENT__`. Exposed for tests; production
|
|
56
|
+
* callers should keep the default.
|
|
57
|
+
*/
|
|
58
|
+
hookName?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface InjectComponentHmrRegistrationResult {
|
|
61
|
+
/** New code, or `null` if no transformation is needed. */
|
|
62
|
+
code: string | null;
|
|
63
|
+
/** Names of `@Component` classes detected in the file. */
|
|
64
|
+
componentNames: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build the trailing snippet that registers each component class with
|
|
68
|
+
* the global HMR hook. Pure string construction — exposed so the post-
|
|
69
|
+
* Angular plugin can append it to compiled output without re-scanning
|
|
70
|
+
* for class names (the pre plugin already scanned the raw TS source).
|
|
71
|
+
*
|
|
72
|
+
* Returns an empty string when `componentNames` is empty so callers
|
|
73
|
+
* can concatenate unconditionally.
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildComponentHmrRegistrationSuffix(componentNames: string[], options?: InjectComponentHmrRegistrationOptions): string;
|
|
76
|
+
/**
|
|
77
|
+
* Append the registration snippet to a piece of code (typically the
|
|
78
|
+
* compiled output from `@analogjs/vite-plugin-angular`) using a list
|
|
79
|
+
* of component names previously discovered in the raw TS source.
|
|
80
|
+
*
|
|
81
|
+
* Returns `{ code: null, componentNames: [] }` if `componentNames`
|
|
82
|
+
* is empty or if the code already contains the injection marker
|
|
83
|
+
* (idempotent re-transform case).
|
|
84
|
+
*/
|
|
85
|
+
export declare function appendComponentHmrRegistration(code: string, componentNames: string[], options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
|
|
86
|
+
/**
|
|
87
|
+
* Legacy helper: scan raw TypeScript source for `@Component` classes
|
|
88
|
+
* and append registration calls. Retained for tests and for any
|
|
89
|
+
* caller running outside the post-Angular plugin chain.
|
|
90
|
+
*
|
|
91
|
+
* NOTE: For files compiled by `@analogjs/vite-plugin-angular`, this
|
|
92
|
+
* helper's output is discarded — the Angular plugin replaces the
|
|
93
|
+
* input code with the regenerated compiled output from its internal
|
|
94
|
+
* `outputFiles` cache. Use `findComponentClassNames(rawTs)` +
|
|
95
|
+
* `appendComponentHmrRegistration(compiledCode, names)` from a
|
|
96
|
+
* `enforce: 'post'` plugin to survive that compilation step.
|
|
97
|
+
*/
|
|
98
|
+
export declare function injectComponentHmrRegistration(code: string, options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
|
|
99
|
+
/**
|
|
100
|
+
* Walk a TS source string and collect class names declared after a
|
|
101
|
+
* `@Component(...)` decorator. Supports:
|
|
102
|
+
* - `export class Foo` and bare `class Foo`
|
|
103
|
+
* - `abstract class Foo` (rare for @Component but allowed)
|
|
104
|
+
* - Any number of additional decorators stacked between `@Component`
|
|
105
|
+
* and the class keyword (e.g. `@Component({}) @SomethingElse() ...`)
|
|
106
|
+
*
|
|
107
|
+
* Skips matches that fall inside string literals or comments. Uses a
|
|
108
|
+
* paren-matching scanner instead of regex `[\s\S]*?` so multi-line
|
|
109
|
+
* decorator arguments (templates, styles arrays) don't trip up the
|
|
110
|
+
* scanner.
|
|
111
|
+
*/
|
|
112
|
+
export declare function findComponentClassNames(code: string): string[];
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite-side helper that injects HMR self-registration calls into the
|
|
3
|
+
* compiled output of user `.ts` files that declare `@Component`-
|
|
4
|
+
* decorated classes.
|
|
5
|
+
*
|
|
6
|
+
* After an HMR reboot, the global `__NS_HMR_REGISTER_COMPONENT__` hook
|
|
7
|
+
* (installed by `@nativescript/angular`) records each fresh class
|
|
8
|
+
* keyed by source name. HMR helpers (modal restore, route replay) read
|
|
9
|
+
* the registry to re-attach to the live class. See
|
|
10
|
+
* `hmr-class-registry.ts` for the runtime side of the contract.
|
|
11
|
+
*
|
|
12
|
+
* The helper exposes two phases used by complementary Vite plugins:
|
|
13
|
+
* 1. `findComponentClassNames(rawTs)` — scans the user's raw TS
|
|
14
|
+
* source for `@Component`-decorated classes. Used by an
|
|
15
|
+
* `enforce: 'pre'` plugin to discover names BEFORE the Analog
|
|
16
|
+
* Angular plugin compiles the file. The discovery has to happen
|
|
17
|
+
* on raw TS because the Angular plugin rewrites the `@Component`
|
|
18
|
+
* decorator into static metadata calls (`ɵsetClassMetadata`,
|
|
19
|
+
* `ɵɵdefineComponent`) and removes the textual `@Component(...)`
|
|
20
|
+
* pattern.
|
|
21
|
+
* 2. `appendComponentHmrRegistration(compiledCode, names)` — appends
|
|
22
|
+
* the registration snippet to the END of compiled JS produced by
|
|
23
|
+
* the Analog Angular plugin. Used by an `enforce: 'post'` plugin.
|
|
24
|
+
* Appending here is the only reliable insertion point because:
|
|
25
|
+
* - Class declarations are evaluated and bound by then.
|
|
26
|
+
* - Angular's static metadata (`ɵcmp`/`ɵfac`) has finished
|
|
27
|
+
* attaching, so the registered class identity already
|
|
28
|
+
* carries the up-to-date component definition.
|
|
29
|
+
* - The Analog Angular plugin's `transform` discards anything
|
|
30
|
+
* appended before its compilation step (it returns code
|
|
31
|
+
* regenerated from its own `outputFiles` cache, not the
|
|
32
|
+
* input passed in). Verified directly in the plugin chain.
|
|
33
|
+
* - Source-map line offsets for the original module body are
|
|
34
|
+
* preserved (we only append).
|
|
35
|
+
*
|
|
36
|
+
* The legacy `injectComponentHmrRegistration(rawTs)` helper is kept
|
|
37
|
+
* for backward compatibility — it appends to raw TS in a single call —
|
|
38
|
+
* but is no longer the path used by the live HMR pipeline (its output
|
|
39
|
+
* is silently dropped by the Angular plugin for `@Component` files).
|
|
40
|
+
*
|
|
41
|
+
* The helpers are dev-only: production builds skip the Vite plugins
|
|
42
|
+
* (`apply: 'serve'`), and the runtime hook short-circuits when
|
|
43
|
+
* `isAngularHmrEnabled()` is false.
|
|
44
|
+
*/
|
|
45
|
+
const COMPONENT_DECORATOR_RE = /@Component\s*\(/g;
|
|
46
|
+
/**
|
|
47
|
+
* Marker comment placed immediately before the appended registration
|
|
48
|
+
* block. Plugins can scan for this string to make their work
|
|
49
|
+
* idempotent across re-transforms (the Vite cache may replay the
|
|
50
|
+
* transform pipeline on cached modules).
|
|
51
|
+
*/
|
|
52
|
+
export const INJECTION_MARKER = '/* @nativescript/vite ns-hmr-register */';
|
|
53
|
+
/**
|
|
54
|
+
* Build the trailing snippet that registers each component class with
|
|
55
|
+
* the global HMR hook. Pure string construction — exposed so the post-
|
|
56
|
+
* Angular plugin can append it to compiled output without re-scanning
|
|
57
|
+
* for class names (the pre plugin already scanned the raw TS source).
|
|
58
|
+
*
|
|
59
|
+
* Returns an empty string when `componentNames` is empty so callers
|
|
60
|
+
* can concatenate unconditionally.
|
|
61
|
+
*/
|
|
62
|
+
export function buildComponentHmrRegistrationSuffix(componentNames, options = {}) {
|
|
63
|
+
if (!componentNames || componentNames.length === 0) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
const hookName = options.hookName ?? '__NS_HMR_REGISTER_COMPONENT__';
|
|
67
|
+
const registrationLines = componentNames.map((name) => buildRegistrationLine(hookName, name));
|
|
68
|
+
// Pad with two newlines so the appended block is visually separated
|
|
69
|
+
// from the original module body in source maps and stack traces.
|
|
70
|
+
return `\n\n${INJECTION_MARKER}\n${registrationLines.join('\n')}\n`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Append the registration snippet to a piece of code (typically the
|
|
74
|
+
* compiled output from `@analogjs/vite-plugin-angular`) using a list
|
|
75
|
+
* of component names previously discovered in the raw TS source.
|
|
76
|
+
*
|
|
77
|
+
* Returns `{ code: null, componentNames: [] }` if `componentNames`
|
|
78
|
+
* is empty or if the code already contains the injection marker
|
|
79
|
+
* (idempotent re-transform case).
|
|
80
|
+
*/
|
|
81
|
+
export function appendComponentHmrRegistration(code, componentNames, options = {}) {
|
|
82
|
+
if (!code) {
|
|
83
|
+
return { code: null, componentNames: [] };
|
|
84
|
+
}
|
|
85
|
+
if (!componentNames || componentNames.length === 0) {
|
|
86
|
+
return { code: null, componentNames: [] };
|
|
87
|
+
}
|
|
88
|
+
if (code.includes(INJECTION_MARKER)) {
|
|
89
|
+
return { code: null, componentNames: [] };
|
|
90
|
+
}
|
|
91
|
+
const suffix = buildComponentHmrRegistrationSuffix(componentNames, options);
|
|
92
|
+
if (!suffix) {
|
|
93
|
+
return { code: null, componentNames: [] };
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
code: code + suffix,
|
|
97
|
+
componentNames: [...componentNames],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Legacy helper: scan raw TypeScript source for `@Component` classes
|
|
102
|
+
* and append registration calls. Retained for tests and for any
|
|
103
|
+
* caller running outside the post-Angular plugin chain.
|
|
104
|
+
*
|
|
105
|
+
* NOTE: For files compiled by `@analogjs/vite-plugin-angular`, this
|
|
106
|
+
* helper's output is discarded — the Angular plugin replaces the
|
|
107
|
+
* input code with the regenerated compiled output from its internal
|
|
108
|
+
* `outputFiles` cache. Use `findComponentClassNames(rawTs)` +
|
|
109
|
+
* `appendComponentHmrRegistration(compiledCode, names)` from a
|
|
110
|
+
* `enforce: 'post'` plugin to survive that compilation step.
|
|
111
|
+
*/
|
|
112
|
+
export function injectComponentHmrRegistration(code, options = {}) {
|
|
113
|
+
if (!code) {
|
|
114
|
+
return { code: null, componentNames: [] };
|
|
115
|
+
}
|
|
116
|
+
if (code.includes(INJECTION_MARKER)) {
|
|
117
|
+
// Already injected (re-transform case) — return original to avoid
|
|
118
|
+
// duplicating registration calls.
|
|
119
|
+
return { code: null, componentNames: [] };
|
|
120
|
+
}
|
|
121
|
+
if (!COMPONENT_DECORATOR_RE.test(code)) {
|
|
122
|
+
return { code: null, componentNames: [] };
|
|
123
|
+
}
|
|
124
|
+
// RegExp.prototype.test with `g` flag advances lastIndex; reset for the
|
|
125
|
+
// next walk in `findComponentClassNames`.
|
|
126
|
+
COMPONENT_DECORATOR_RE.lastIndex = 0;
|
|
127
|
+
const componentNames = findComponentClassNames(code);
|
|
128
|
+
if (componentNames.length === 0) {
|
|
129
|
+
return { code: null, componentNames: [] };
|
|
130
|
+
}
|
|
131
|
+
const suffix = buildComponentHmrRegistrationSuffix(componentNames, options);
|
|
132
|
+
return {
|
|
133
|
+
code: code + suffix,
|
|
134
|
+
componentNames,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function buildRegistrationLine(hookName, className) {
|
|
138
|
+
// Wrap each call in its own try so a failure (e.g. the class binding
|
|
139
|
+
// not in scope at module end because the user re-exported it from
|
|
140
|
+
// somewhere else) doesn't break sibling registrations.
|
|
141
|
+
// The typeof guard prevents a ReferenceError if the global hook isn't
|
|
142
|
+
// installed (production builds, non-Angular contexts, isolated unit
|
|
143
|
+
// tests). The "globalThis" reference is universal across modern JS
|
|
144
|
+
// runtimes including the NativeScript iOS/Android runtimes.
|
|
145
|
+
return `try { if (typeof globalThis !== 'undefined' && typeof globalThis.${hookName} === 'function' && typeof ${className} !== 'undefined') { globalThis.${hookName}(${JSON.stringify(className)}, ${className}, typeof import.meta !== 'undefined' && import.meta && import.meta.url ? import.meta.url : ''); } } catch (e) {}`;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Walk a TS source string and collect class names declared after a
|
|
149
|
+
* `@Component(...)` decorator. Supports:
|
|
150
|
+
* - `export class Foo` and bare `class Foo`
|
|
151
|
+
* - `abstract class Foo` (rare for @Component but allowed)
|
|
152
|
+
* - Any number of additional decorators stacked between `@Component`
|
|
153
|
+
* and the class keyword (e.g. `@Component({}) @SomethingElse() ...`)
|
|
154
|
+
*
|
|
155
|
+
* Skips matches that fall inside string literals or comments. Uses a
|
|
156
|
+
* paren-matching scanner instead of regex `[\s\S]*?` so multi-line
|
|
157
|
+
* decorator arguments (templates, styles arrays) don't trip up the
|
|
158
|
+
* scanner.
|
|
159
|
+
*/
|
|
160
|
+
export function findComponentClassNames(code) {
|
|
161
|
+
const names = [];
|
|
162
|
+
const componentRe = /@Component\s*\(/g;
|
|
163
|
+
let match;
|
|
164
|
+
while ((match = componentRe.exec(code)) !== null) {
|
|
165
|
+
const matchStart = match.index;
|
|
166
|
+
if (isInsideStringOrComment(code, matchStart)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const openParenIdx = matchStart + match[0].length - 1;
|
|
170
|
+
const closeParenIdx = findMatchingDelimiter(code, openParenIdx, '(', ')');
|
|
171
|
+
if (closeParenIdx === -1) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const className = findClassNameAfter(code, closeParenIdx + 1);
|
|
175
|
+
if (className && !names.includes(className)) {
|
|
176
|
+
names.push(className);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return names;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Starting at `position`, skip whitespace and any further decorators
|
|
183
|
+
* (`@Foo(...)`) and return the next class name encountered, or
|
|
184
|
+
* `null` if no class declaration follows.
|
|
185
|
+
*/
|
|
186
|
+
function findClassNameAfter(code, position) {
|
|
187
|
+
let i = position;
|
|
188
|
+
while (i < code.length) {
|
|
189
|
+
while (i < code.length && /\s/.test(code[i])) {
|
|
190
|
+
i++;
|
|
191
|
+
}
|
|
192
|
+
if (i >= code.length) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (code[i] === '@') {
|
|
196
|
+
// Another decorator stacked between @Component and class.
|
|
197
|
+
i++;
|
|
198
|
+
// Decorator name (identifier).
|
|
199
|
+
while (i < code.length && /[\w$.]/.test(code[i])) {
|
|
200
|
+
i++;
|
|
201
|
+
}
|
|
202
|
+
while (i < code.length && /\s/.test(code[i])) {
|
|
203
|
+
i++;
|
|
204
|
+
}
|
|
205
|
+
if (code[i] === '(') {
|
|
206
|
+
const decoClose = findMatchingDelimiter(code, i, '(', ')');
|
|
207
|
+
if (decoClose === -1) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
i = decoClose + 1;
|
|
211
|
+
}
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const remainder = code.slice(i);
|
|
215
|
+
const classMatch = /^(?:export\s+(?:default\s+)?)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/.exec(remainder);
|
|
216
|
+
if (classMatch) {
|
|
217
|
+
return classMatch[1];
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* True if `index` falls inside a // line comment, /* block comment, or
|
|
225
|
+
* a string/template literal. Used to filter out false positives from
|
|
226
|
+
* `@Component(` matches inside docs or stringified examples.
|
|
227
|
+
*/
|
|
228
|
+
function isInsideStringOrComment(code, index) {
|
|
229
|
+
let i = 0;
|
|
230
|
+
let quote = null;
|
|
231
|
+
let escape = false;
|
|
232
|
+
let inLineComment = false;
|
|
233
|
+
let inBlockComment = false;
|
|
234
|
+
while (i < index) {
|
|
235
|
+
const char = code[i];
|
|
236
|
+
const next = code[i + 1];
|
|
237
|
+
if (inLineComment) {
|
|
238
|
+
if (char === '\n') {
|
|
239
|
+
inLineComment = false;
|
|
240
|
+
}
|
|
241
|
+
i++;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (inBlockComment) {
|
|
245
|
+
if (char === '*' && next === '/') {
|
|
246
|
+
inBlockComment = false;
|
|
247
|
+
i += 2;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
i++;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (quote) {
|
|
254
|
+
if (escape) {
|
|
255
|
+
escape = false;
|
|
256
|
+
i++;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (char === '\\') {
|
|
260
|
+
escape = true;
|
|
261
|
+
i++;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (char === quote) {
|
|
265
|
+
quote = null;
|
|
266
|
+
}
|
|
267
|
+
i++;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (char === '/' && next === '/') {
|
|
271
|
+
inLineComment = true;
|
|
272
|
+
i += 2;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (char === '/' && next === '*') {
|
|
276
|
+
inBlockComment = true;
|
|
277
|
+
i += 2;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
281
|
+
quote = char;
|
|
282
|
+
i++;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
i++;
|
|
286
|
+
}
|
|
287
|
+
return inLineComment || inBlockComment || quote !== null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Find the index of the matching close delimiter for the opener at
|
|
291
|
+
* `openIndex`. Comment- and string-aware so multi-line decorator
|
|
292
|
+
* arguments (template strings, styles arrays) are scanned correctly.
|
|
293
|
+
*/
|
|
294
|
+
function findMatchingDelimiter(source, openIndex, openChar, closeChar) {
|
|
295
|
+
if (openIndex < 0 || source[openIndex] !== openChar) {
|
|
296
|
+
return -1;
|
|
297
|
+
}
|
|
298
|
+
let depth = 0;
|
|
299
|
+
let quote = null;
|
|
300
|
+
let escape = false;
|
|
301
|
+
let inLineComment = false;
|
|
302
|
+
let inBlockComment = false;
|
|
303
|
+
for (let index = openIndex; index < source.length; index++) {
|
|
304
|
+
const char = source[index];
|
|
305
|
+
const next = source[index + 1];
|
|
306
|
+
if (inLineComment) {
|
|
307
|
+
if (char === '\n') {
|
|
308
|
+
inLineComment = false;
|
|
309
|
+
}
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (inBlockComment) {
|
|
313
|
+
if (char === '*' && next === '/') {
|
|
314
|
+
inBlockComment = false;
|
|
315
|
+
index++;
|
|
316
|
+
}
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (quote) {
|
|
320
|
+
if (escape) {
|
|
321
|
+
escape = false;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (char === '\\') {
|
|
325
|
+
escape = true;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (char === quote) {
|
|
329
|
+
quote = null;
|
|
330
|
+
}
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (char === '/' && next === '/') {
|
|
334
|
+
inLineComment = true;
|
|
335
|
+
index++;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (char === '/' && next === '*') {
|
|
339
|
+
inBlockComment = true;
|
|
340
|
+
index++;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
344
|
+
quote = char;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (char === openChar) {
|
|
348
|
+
depth++;
|
|
349
|
+
}
|
|
350
|
+
else if (char === closeChar) {
|
|
351
|
+
depth--;
|
|
352
|
+
if (depth === 0) {
|
|
353
|
+
return index;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return -1;
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=inject-component-hmr-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-component-hmr-registration.js","sourceRoot":"","sources":["../../../../../packages/vite/helpers/angular/inject-component-hmr-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAkB3E;;;;;;;;GAQG;AACH,MAAM,UAAU,mCAAmC,CAAC,cAAwB,EAAE,UAAiD,EAAE;IAChI,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MA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AK,EAAE,CAAC;YACT,CAAC;YACD,SAAS;QACV,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,GAAG,KAAK,CAAC;gBACf,SAAS;YACV,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBACnB,MAAM,GAAG,IAAI,CAAC;gBACd,SAAS;YACV,CAAC;YACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACpB,KAAK,GAAG,IAAI,CAAC;YACd,CAAC;YACD,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClC,aAAa,GAAG,IAAI,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,SAAS;QACV,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClC,cAAc,GAAG,IAAI,CAAC;YACtB,KAAK,EAAE,CAAC;YACR,SAAS;QACV,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClD,KAAK,GAAG,IAAI,CAAC;YACb,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvB,KAAK,EAAE,CAAC;QACT,CAAC;aAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACX,CAAC"}
|
package/helpers/angular/util.js
CHANGED
|
@@ -64,4 +64,92 @@ export function containsRealNgDeclare(src) {
|
|
|
64
64
|
}
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
+
// Returns the input source with `//` line comments and `/* */` block comments
|
|
68
|
+
// blanked out (replaced with spaces, preserving original line/column offsets).
|
|
69
|
+
// String and template literal contents are left untouched. The original
|
|
70
|
+
// character count is preserved so that downstream callers using regex `index`
|
|
71
|
+
// values still align with the original source.
|
|
72
|
+
//
|
|
73
|
+
// Why blank out instead of strip: callers like `extractComponentAssetPaths`
|
|
74
|
+
// run regexes against this output but consume captured paths as-is. Keeping
|
|
75
|
+
// the offsets stable means we don't need to remap any indexes — and any
|
|
76
|
+
// future caller that reports positions back to the user (e.g. a diagnostic
|
|
77
|
+
// pointing at a `styleUrl` value) gets the right line/column for free.
|
|
78
|
+
//
|
|
79
|
+
// Why this matters: in current Rolldown-Vite, `addWatchFile(path)` ALSO
|
|
80
|
+
// records the file as an `_addedImports` entry on the load/transform plugin
|
|
81
|
+
// context. The `vite:import-analysis` plugin then attempts to resolve every
|
|
82
|
+
// added import; a non-existent file (e.g. a path scraped from a commented-
|
|
83
|
+
// out `styleUrls` line) produces a `Failed to resolve import "..." from
|
|
84
|
+
// "...". Does the file exist?` pre-transform error. Stripping comments
|
|
85
|
+
// before scanning keeps us from registering phantom asset deps.
|
|
86
|
+
export function stripJsComments(src) {
|
|
87
|
+
if (!src)
|
|
88
|
+
return src;
|
|
89
|
+
const len = src.length;
|
|
90
|
+
let out = '';
|
|
91
|
+
let inStr = false, strCh = '', esc = false, inBlk = false, inLine = false;
|
|
92
|
+
for (let i = 0; i < len; i++) {
|
|
93
|
+
const ch = src[i];
|
|
94
|
+
const next = i + 1 < len ? src[i + 1] : '';
|
|
95
|
+
if (inLine) {
|
|
96
|
+
if (ch === '\n') {
|
|
97
|
+
inLine = false;
|
|
98
|
+
out += ch;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
out += ' ';
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (inBlk) {
|
|
106
|
+
if (ch === '*' && next === '/') {
|
|
107
|
+
inBlk = false;
|
|
108
|
+
out += ' ';
|
|
109
|
+
i++;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
out += ch === '\n' ? '\n' : ' ';
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (inStr) {
|
|
116
|
+
if (esc) {
|
|
117
|
+
esc = false;
|
|
118
|
+
out += ch;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (ch === '\\') {
|
|
122
|
+
esc = true;
|
|
123
|
+
out += ch;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (ch === strCh) {
|
|
127
|
+
inStr = false;
|
|
128
|
+
strCh = '';
|
|
129
|
+
}
|
|
130
|
+
out += ch;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (ch === '/' && next === '/') {
|
|
134
|
+
inLine = true;
|
|
135
|
+
out += ' ';
|
|
136
|
+
i++;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (ch === '/' && next === '*') {
|
|
140
|
+
inBlk = true;
|
|
141
|
+
out += ' ';
|
|
142
|
+
i++;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
146
|
+
inStr = true;
|
|
147
|
+
strCh = ch;
|
|
148
|
+
out += ch;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
out += ch;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
67
155
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../../packages/vite/helpers/angular/util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAChD,IAAI,KAAK,GAAG,KAAK,EAChB,KAAK,GAAG,EAAE,EACV,GAAG,GAAG,KAAK,EACX,KAAK,GAAG,KAAK,EACb,MAAM,GAAG,KAAK,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,G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