@nativescript/vite 8.0.0-alpha.0 → 8.0.0-alpha.10
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.d.ts +1 -1
- package/configuration/angular.js +486 -140
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +159 -41
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +3 -3
- package/configuration/javascript.js.map +1 -1
- package/configuration/solid.js +7 -0
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +4 -4
- package/configuration/typescript.js.map +1 -1
- package/helpers/angular/angular-linker.js +38 -42
- 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/inline-decorator-component-templates.d.ts +3 -0
- package/helpers/angular/inline-decorator-component-templates.js +400 -0
- package/helpers/angular/inline-decorator-component-templates.js.map +1 -0
- package/helpers/angular/shared-linker.d.ts +7 -0
- package/helpers/angular/shared-linker.js +37 -1
- package/helpers/angular/shared-linker.js.map +1 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.d.ts +1 -0
- package/helpers/angular/synthesize-decorator-ctor-parameters.js +256 -0
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/helpers/angular/synthesize-injectable-factories.d.ts +3 -0
- package/helpers/angular/synthesize-injectable-factories.js +414 -0
- package/helpers/angular/synthesize-injectable-factories.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/commonjs-plugins.d.ts +5 -2
- package/helpers/commonjs-plugins.js +126 -0
- package/helpers/commonjs-plugins.js.map +1 -1
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/esbuild-platform-resolver.js +5 -5
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +9 -1
- package/helpers/external-configs.js +31 -6
- package/helpers/external-configs.js.map +1 -1
- package/helpers/global-defines.d.ts +51 -0
- package/helpers/global-defines.js +77 -0
- package/helpers/global-defines.js.map +1 -1
- package/helpers/import-meta-path.d.ts +4 -0
- package/helpers/import-meta-path.js +5 -0
- package/helpers/import-meta-path.js.map +1 -0
- package/helpers/import-specifier.d.ts +1 -0
- package/helpers/import-specifier.js +18 -0
- package/helpers/import-specifier.js.map +1 -0
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +63 -3
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +5 -2
- package/helpers/main-entry.js +365 -116
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-transform.js +8 -127
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
- package/helpers/nativeclass-transformer-plugin.js +318 -31
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/ns-core-url.d.ts +83 -0
- package/helpers/ns-core-url.js +167 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/prelink-angular.js +1 -4
- package/helpers/prelink-angular.js.map +1 -1
- package/helpers/preserve-imports.js +2 -17
- package/helpers/preserve-imports.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 +20 -19
- package/helpers/workers.js +620 -3
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.js +60 -19
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/hmr-pending-overlay.d.ts +27 -0
- package/hmr/client/hmr-pending-overlay.js +50 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/index.js +597 -24
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +5 -0
- package/hmr/client/utils.js +212 -21
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.d.ts +10 -0
- package/hmr/entry-runtime.js +330 -42
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/client/index.d.ts +3 -1
- package/hmr/frameworks/angular/client/index.js +821 -25
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/server/linker.js +37 -6
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +30 -6
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +8 -2
- package/hmr/frameworks/typescript/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/ast-normalizer.js +22 -10
- package/hmr/helpers/ast-normalizer.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.d.ts +1 -0
- package/hmr/server/constants.js +14 -3
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +49 -2
- package/hmr/server/core-sanitize.js +267 -24
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/import-map.d.ts +65 -0
- package/hmr/server/import-map.js +222 -0
- package/hmr/server/import-map.js.map +1 -0
- package/hmr/server/index.d.ts +2 -1
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
- package/hmr/server/ns-core-cjs-shape.js +271 -0
- package/hmr/server/ns-core-cjs-shape.js.map +1 -0
- package/hmr/server/perf-instrumentation.d.ts +114 -0
- package/hmr/server/perf-instrumentation.js +195 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/runtime-graph-filter.d.ts +5 -0
- package/hmr/server/runtime-graph-filter.js +21 -0
- package/hmr/server/runtime-graph-filter.js.map +1 -0
- package/hmr/server/shared-transform-request.d.ts +12 -0
- package/hmr/server/shared-transform-request.js +144 -0
- package/hmr/server/shared-transform-request.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +21 -1
- package/hmr/server/vite-plugin.js +461 -22
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-angular-entry.d.ts +2 -0
- package/hmr/server/websocket-angular-entry.js +68 -0
- package/hmr/server/websocket-angular-entry.js.map +1 -0
- package/hmr/server/websocket-angular-hot-update.d.ts +78 -0
- package/hmr/server/websocket-angular-hot-update.js +413 -0
- package/hmr/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/server/websocket-core-bridge.d.ts +21 -0
- package/hmr/server/websocket-core-bridge.js +357 -0
- package/hmr/server/websocket-core-bridge.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +21 -0
- package/hmr/server/websocket-graph-upsert.js +33 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -0
- package/hmr/server/websocket-hmr-pending.d.ts +43 -0
- package/hmr/server/websocket-hmr-pending.js +55 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-module-bindings.d.ts +6 -0
- package/hmr/server/websocket-module-bindings.js +471 -0
- package/hmr/server/websocket-module-bindings.js.map +1 -0
- package/hmr/server/websocket-module-specifiers.d.ts +101 -0
- package/hmr/server/websocket-module-specifiers.js +820 -0
- package/hmr/server/websocket-module-specifiers.js.map +1 -0
- package/hmr/server/websocket-ns-m-finalize.d.ts +22 -0
- package/hmr/server/websocket-ns-m-finalize.js +88 -0
- package/hmr/server/websocket-ns-m-finalize.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
- package/hmr/server/websocket-ns-m-paths.js +92 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +45 -0
- package/hmr/server/websocket-ns-m-request.js +196 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-runtime-compat.d.ts +19 -0
- package/hmr/server/websocket-runtime-compat.js +287 -0
- package/hmr/server/websocket-runtime-compat.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +36 -0
- package/hmr/server/websocket-served-module-helpers.js +631 -0
- package/hmr/server/websocket-served-module-helpers.js.map +1 -0
- package/hmr/server/websocket-txn.d.ts +6 -0
- package/hmr/server/websocket-txn.js +45 -0
- package/hmr/server/websocket-txn.js.map +1 -0
- package/hmr/server/websocket-vendor-unifier.d.ts +10 -0
- package/hmr/server/websocket-vendor-unifier.js +51 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket-vue-sfc.d.ts +27 -0
- package/hmr/server/websocket-vue-sfc.js +1069 -0
- package/hmr/server/websocket-vue-sfc.js.map +1 -0
- package/hmr/server/websocket.d.ts +26 -3
- package/hmr/server/websocket.js +2233 -796
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/package-classifier.d.ts +9 -0
- package/hmr/shared/package-classifier.js +58 -0
- package/hmr/shared/package-classifier.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
- package/hmr/shared/runtime/boot-timeline.js +51 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +64 -0
- package/hmr/shared/runtime/browser-runtime-contract.js +54 -0
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +85 -0
- package/hmr/shared/runtime/dev-overlay.js +1236 -0
- package/hmr/shared/runtime/dev-overlay.js.map +1 -0
- package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
- package/hmr/shared/runtime/http-only-boot.js +53 -6
- package/hmr/shared/runtime/http-only-boot.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.d.ts +1 -0
- package/hmr/shared/runtime/module-provenance.js +63 -0
- package/hmr/shared/runtime/module-provenance.js.map +1 -0
- package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
- package/hmr/shared/runtime/platform-polyfills.js +122 -0
- package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +552 -82
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/session-bootstrap.js +195 -0
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +52 -15
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +37 -0
- package/hmr/shared/vendor/manifest.js +677 -57
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/registry.js +104 -7
- package/hmr/shared/vendor/registry.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +14 -2
- package/runtime/core-aliases-early.js +94 -67
- package/runtime/core-aliases-early.js.map +1 -1
- package/shims/solid-jsx-runtime.d.ts +7 -0
- package/shims/solid-jsx-runtime.js +17 -0
- package/shims/solid-jsx-runtime.js.map +1 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJS/ESM interop shape.
|
|
3
|
+
*
|
|
4
|
+
* PROBLEM
|
|
5
|
+
* -------
|
|
6
|
+
* ESM Module Namespace Objects (ECMA §9.4.6) have [[Prototype]] = null.
|
|
7
|
+
* They do NOT inherit Object.prototype — no `hasOwnProperty`, no `toString`,
|
|
8
|
+
* no `isPrototypeOf`. CJS consumers (most notably zone.js's `patchMethod`)
|
|
9
|
+
* assume their require() result is a plain object that has those methods:
|
|
10
|
+
*
|
|
11
|
+
* let proto = target;
|
|
12
|
+
* while (proto && !proto.hasOwnProperty(name)) // ← crashes on null-proto
|
|
13
|
+
* proto = Object.getPrototypeOf(proto);
|
|
14
|
+
*
|
|
15
|
+
* `@nativescript/core/index.js` re-exports several sub-modules as namespaces:
|
|
16
|
+
*
|
|
17
|
+
* export * as Utils from './utils';
|
|
18
|
+
* export * as Http from './http';
|
|
19
|
+
* export * as Connectivity from './connectivity';
|
|
20
|
+
* export * as ApplicationSettings from './application-settings';
|
|
21
|
+
*
|
|
22
|
+
* When bundle.mjs does `import { Utils } from '@nativescript/core'`, `Utils`
|
|
23
|
+
* binds to that null-proto sub-namespace. zone.js then does
|
|
24
|
+
* `patchMethod(Utils, 'mainThreadify', …)` and crashes.
|
|
25
|
+
*
|
|
26
|
+
* WHY globalThis.require shims ALONE DON'T FIX THIS
|
|
27
|
+
* -------------------------------------------------
|
|
28
|
+
* ESM imports never pass through `globalThis.require`. They go through the
|
|
29
|
+
* host's ESM linker (V8 on iOS). Shimming `require` only intercepts the CJS
|
|
30
|
+
* path (vendor packages that use `require('@nativescript/core')`); direct
|
|
31
|
+
* ESM imports of `Utils` still see the raw null-proto namespace.
|
|
32
|
+
*
|
|
33
|
+
* THE FIX
|
|
34
|
+
* -------
|
|
35
|
+
* Rewrite `export * as X from 'Y'` at the /ns/core bridge response level:
|
|
36
|
+
*
|
|
37
|
+
* // before
|
|
38
|
+
* export * as Utils from './utils';
|
|
39
|
+
*
|
|
40
|
+
* // after
|
|
41
|
+
* import * as __ns_re_Utils__ from './utils';
|
|
42
|
+
* export const Utils = __NS_CJS_SHAPE__(__ns_re_Utils__);
|
|
43
|
+
*
|
|
44
|
+
* Now `Utils` is a plain Object (inherits Object.prototype). Zone.js's
|
|
45
|
+
* `patchMethod(Utils, ...)` succeeds. The shape function is recursive —
|
|
46
|
+
* nested namespaces get the same treatment — and identity-preserving
|
|
47
|
+
* (WeakMap-cached) so mutations stick across lookups.
|
|
48
|
+
*
|
|
49
|
+
* WHY THE SHAPE INSTALL MUST RUN IN MODULE BODY (NOT FOOTER)
|
|
50
|
+
* ---------------------------------------------------------
|
|
51
|
+
* `export const Utils = __NS_CJS_SHAPE__(__ns_re_Utils__)` is body code. It
|
|
52
|
+
* executes during module evaluation, BEFORE the registration footer. So the
|
|
53
|
+
* shape function must be installed as a body-level statement that runs
|
|
54
|
+
* before the rewritten body — we can't rely on the footer's install.
|
|
55
|
+
*
|
|
56
|
+
* Each served /ns/core module independently installs the shape function via
|
|
57
|
+
* an idempotent `|| (globalThis.__NS_CJS_SHAPE__ = ...)` assignment. The
|
|
58
|
+
* first module to evaluate wins; subsequent evaluations are no-ops. This
|
|
59
|
+
* also handles dependency-before-importer order (depth-first ESM eval):
|
|
60
|
+
* `/ns/core/utils` evaluates before `/ns/core` main, so the shape helper
|
|
61
|
+
* is in place whenever any body needs it.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Body-code statements that idempotently install `globalThis.__NS_CJS_SHAPE__`
|
|
65
|
+
* and `globalThis.__NS_CJS_SHAPE_CACHE__`. Must execute BEFORE any transformed
|
|
66
|
+
* `export const X = __NS_CJS_SHAPE__(...)` statement in the same module.
|
|
67
|
+
*
|
|
68
|
+
* Properties:
|
|
69
|
+
* - Recursive: traverses nested namespaces so `Utils.Something` is also
|
|
70
|
+
* a plain Object (if that sub-namespace is itself null-proto).
|
|
71
|
+
* - Identity-preserving: WeakMap keyed on the underlying ESM namespace.
|
|
72
|
+
* zone.js mutates its patch target; a fresh copy per call would lose
|
|
73
|
+
* mutations. Every lookup of the same namespace returns the same
|
|
74
|
+
* shaped object.
|
|
75
|
+
* - Cycle-safe: records the output in the cache BEFORE recursing into
|
|
76
|
+
* children. Handles `core ↔ platform` style cycles.
|
|
77
|
+
* - TDZ-safe: wraps each property read in try/catch. Some exports
|
|
78
|
+
* (Angular zone.js with early-access patterns) are still in their
|
|
79
|
+
* temporal dead zone when the namespace is first snapshotted. A thrown
|
|
80
|
+
* property read is skipped rather than failing the whole shape.
|
|
81
|
+
*/
|
|
82
|
+
export function buildShapeInstallHeader() {
|
|
83
|
+
return [
|
|
84
|
+
`/* Invariant D: CJS/ESM interop shape installer */`,
|
|
85
|
+
`try { if (typeof globalThis !== 'undefined') {`,
|
|
86
|
+
` const __nsShapeCache = globalThis.__NS_CJS_SHAPE_CACHE__ || (globalThis.__NS_CJS_SHAPE_CACHE__ = new WeakMap());`,
|
|
87
|
+
` if (typeof globalThis.__NS_CJS_SHAPE__ !== 'function') {`,
|
|
88
|
+
` globalThis.__NS_CJS_SHAPE__ = function __nsShape(obj) {`,
|
|
89
|
+
` if (!obj || typeof obj !== 'object') return obj;`,
|
|
90
|
+
` let isNsModule = false;`,
|
|
91
|
+
` try { isNsModule = obj[Symbol.toStringTag] === 'Module'; } catch (e) {}`,
|
|
92
|
+
` const proto = Object.getPrototypeOf(obj);`,
|
|
93
|
+
` if (proto !== null && !isNsModule) return obj;`,
|
|
94
|
+
` if (__nsShapeCache.has(obj)) return __nsShapeCache.get(obj);`,
|
|
95
|
+
` const out = {};`,
|
|
96
|
+
` __nsShapeCache.set(obj, out);`,
|
|
97
|
+
` try {`,
|
|
98
|
+
` const keys = Object.keys(obj);`,
|
|
99
|
+
` for (let i = 0; i < keys.length; i++) {`,
|
|
100
|
+
` const k = keys[i];`,
|
|
101
|
+
` try { out[k] = __nsShape(obj[k]); } catch (e) { /* TDZ / unreadable */ }`,
|
|
102
|
+
` }`,
|
|
103
|
+
` } catch (e) {}`,
|
|
104
|
+
` return out;`,
|
|
105
|
+
` };`,
|
|
106
|
+
` }`,
|
|
107
|
+
`} } catch (e) { console.warn('[ns-core] shape installer failed:', (e && e.message) || e); }`,
|
|
108
|
+
].join('\n');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Rewrite namespace re-exports from CJS-incompatible ESM namespace form into
|
|
112
|
+
* shape-aware const exports. Handles the two forms Vite/esbuild may emit:
|
|
113
|
+
*
|
|
114
|
+
* (1) Original ES2020 syntax preserved unchanged:
|
|
115
|
+
* export * as X from 'Y';
|
|
116
|
+
*
|
|
117
|
+
* (2) Transpiled form esbuild emits when targeting older ES:
|
|
118
|
+
* import * as _foo from 'Y';
|
|
119
|
+
* export { _foo as X };
|
|
120
|
+
*
|
|
121
|
+
* Both become:
|
|
122
|
+
* import * as __ns_re_X__ from 'Y';
|
|
123
|
+
* export const X = __NS_CJS_SHAPE__(__ns_re_X__);
|
|
124
|
+
*
|
|
125
|
+
* Notes on the transform:
|
|
126
|
+
* - The internal binding uses a derived name (`__ns_re_<X>__`) so
|
|
127
|
+
* collisions with user bindings are extremely unlikely. Core doesn't
|
|
128
|
+
* declare identifiers matching that shape.
|
|
129
|
+
* - `__NS_CJS_SHAPE__` is read from globalThis with a defensive fallback
|
|
130
|
+
* (identity function) in case installation failed or runs in an
|
|
131
|
+
* environment where it hasn't been initialized yet. This makes the
|
|
132
|
+
* transform safe to apply to modules that don't always go through the
|
|
133
|
+
* /ns/core handler's headers.
|
|
134
|
+
* - We do NOT shape `export *` (star re-exports without alias). Those
|
|
135
|
+
* spread individual named exports — they don't create a nested
|
|
136
|
+
* namespace and aren't affected by the null-proto issue.
|
|
137
|
+
* - We do NOT shape `export { x } from 'y'` forms. Those copy individual
|
|
138
|
+
* named exports directly; the consumer never sees the namespace.
|
|
139
|
+
*
|
|
140
|
+
* The regex is intentionally precise. It matches only the `export * as X from
|
|
141
|
+
* 'Y'` syntactic form (and its transpiled equivalent) — no accidental matches
|
|
142
|
+
* in string literals or comments because those can't start a top-level
|
|
143
|
+
* statement with `export`.
|
|
144
|
+
*/
|
|
145
|
+
export function rewriteNamespaceReExportsForShape(code) {
|
|
146
|
+
const shapeExpr = `(typeof globalThis.__NS_CJS_SHAPE__ === 'function' ? globalThis.__NS_CJS_SHAPE__ : function (x) { return x; })`;
|
|
147
|
+
// Form (1): export * as X from 'Y'; (ES2020 aggregate re-export)
|
|
148
|
+
let out = code.replace(/(^|\n)(\s*)export\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s+(['"`])([^'"`\n]+)\4\s*;?/g, (_match, prefix, indent, name, quote, spec) => {
|
|
149
|
+
const internal = `__ns_re_${name}__`;
|
|
150
|
+
return `${prefix}${indent}import * as ${internal} from ${quote}${spec}${quote};\n${indent}export const ${name} = ${shapeExpr}(${internal});`;
|
|
151
|
+
});
|
|
152
|
+
// Form (2): import * as _x from 'Y'; export { _x as X };
|
|
153
|
+
// This pattern appears when esbuild targets older ES. We detect the pair
|
|
154
|
+
// by matching the import and its paired export on the same or adjacent
|
|
155
|
+
// lines. Rather than try to join two regex passes, we transform the
|
|
156
|
+
// `export { _x as X }` branch by replacing the `_x` in the export with a
|
|
157
|
+
// shape-wrapped const. Keeping the import intact is safe because the
|
|
158
|
+
// local binding is still needed for the shape call.
|
|
159
|
+
out = out.replace(/export\s*\{\s*([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)\s*\}\s*;?/g, (match, localName, exportName) => {
|
|
160
|
+
// Only transform if the local name looks like an esbuild-generated
|
|
161
|
+
// namespace binding (leading underscore) AND the export name is a
|
|
162
|
+
// PascalCase identifier. This avoids touching user re-exports.
|
|
163
|
+
if (!/^_/.test(localName))
|
|
164
|
+
return match;
|
|
165
|
+
if (!/^[A-Z]/.test(exportName))
|
|
166
|
+
return match;
|
|
167
|
+
return `export const ${exportName} = ${shapeExpr}(${localName});`;
|
|
168
|
+
});
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Convenience: returns true if the given code appears to contain at least one
|
|
173
|
+
* namespace re-export that would benefit from the shape transform. Used to
|
|
174
|
+
* skip the regex replace for modules that don't need it (keeps the response
|
|
175
|
+
* identical for most submodules, which just have plain `export * from` or
|
|
176
|
+
* named exports).
|
|
177
|
+
*/
|
|
178
|
+
export function hasNamespaceReExport(code) {
|
|
179
|
+
return /export\s+\*\s+as\s+[A-Za-z_$][\w$]*\s+from\s+['"`]/.test(code);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Default-export bridge footer.
|
|
183
|
+
*
|
|
184
|
+
* BACKGROUND
|
|
185
|
+
* ----------
|
|
186
|
+
* Upstream consumer rewrites in the /ns/m handler convert
|
|
187
|
+
* `import { X } from '@nativescript/core'` into
|
|
188
|
+
* `import __ns_core_ns from '/ns/core'; const { X } = __ns_core_ns;`
|
|
189
|
+
* — a DEFAULT import followed by destructuring. The inline comment on that
|
|
190
|
+
* rewrite says explicitly: "This makes `import { Frame } from
|
|
191
|
+
* '@nativescript/core'` work even if the bridge provides only a default
|
|
192
|
+
* export."
|
|
193
|
+
*
|
|
194
|
+
* The original `@nativescript/core/index.js` has no `export default` — all
|
|
195
|
+
* named exports. Without this footer, consumers of the transformed import
|
|
196
|
+
* fail at ESM link time:
|
|
197
|
+
*
|
|
198
|
+
* SyntaxError: The requested module '/ns/core/<ver>' does not
|
|
199
|
+
* provide an export named 'default'
|
|
200
|
+
*
|
|
201
|
+
* THE FIX
|
|
202
|
+
* -------
|
|
203
|
+
* Emit `export default __ns_core_self_ns__;` at the end of the served
|
|
204
|
+
* module body. `__ns_core_self_ns__` is the namespace import the server
|
|
205
|
+
* already emits at the top of every /ns/core response for self-
|
|
206
|
+
* registration purposes. ESM spec guarantees a module re-entering itself
|
|
207
|
+
* during evaluation returns the in-progress namespace — so no extra
|
|
208
|
+
* evaluation occurs, and the default binding receives an object whose
|
|
209
|
+
* properties are every named export of the same module.
|
|
210
|
+
*
|
|
211
|
+
* CONSUMER MATRIX AFTER THIS FIX
|
|
212
|
+
* ------------------------------
|
|
213
|
+
* • `import X from '/ns/core'` (default) → X = self namespace
|
|
214
|
+
* • `import * as X from '/ns/core'` → X = self namespace + X.default = self
|
|
215
|
+
* • `import { X } from '/ns/core'` (named) → individual named binding (untouched)
|
|
216
|
+
* • `const { X } = <default-import>` → destructure from self namespace
|
|
217
|
+
* • `require('@nativescript/core')` (CJS) → shaped self via registry
|
|
218
|
+
*
|
|
219
|
+
* SKIP CONDITIONS
|
|
220
|
+
* ---------------
|
|
221
|
+
* Returns empty string when the source already declares a default export
|
|
222
|
+
* (some deep subpaths do — e.g. a file that does `export default MyClass`
|
|
223
|
+
* would SyntaxError on a duplicate). The consumer rewrite is also gated
|
|
224
|
+
* on `isDeepCoreSubpath`, so those paths don't normally hit the default-
|
|
225
|
+
* import pattern anyway.
|
|
226
|
+
*
|
|
227
|
+
* WHY THE DEFAULT ISN'T SHAPED
|
|
228
|
+
* ----------------------------
|
|
229
|
+
* The default is the raw null-proto MNO. This is intentional:
|
|
230
|
+
*
|
|
231
|
+
* 1. All current default-import consumers either destructure or do
|
|
232
|
+
* property access. Neither requires Object.prototype in the chain.
|
|
233
|
+
* 2. Shaping the default inside the module body would require calling
|
|
234
|
+
* __NS_CJS_SHAPE__ on a namespace whose own `default` slot is still
|
|
235
|
+
* being initialized — temporal dead zone hazard.
|
|
236
|
+
* 3. CJS consumers that need `.hasOwnProperty` go through the registry
|
|
237
|
+
* (shaped at registration), not through the default import.
|
|
238
|
+
*
|
|
239
|
+
* If a future consumer surfaces that calls `.hasOwnProperty` on the
|
|
240
|
+
* default, we can revisit. The current rule-of-least-surprise is:
|
|
241
|
+
* shape at the CJS boundary, not at the ESM boundary.
|
|
242
|
+
*/
|
|
243
|
+
export function buildDefaultExportFooter(rewrittenCode) {
|
|
244
|
+
if (hasExistingDefaultExport(rewrittenCode))
|
|
245
|
+
return '';
|
|
246
|
+
return ['/* Default-export bridge for /ns/core consumers */', 'export default __ns_core_self_ns__;'].join('\n');
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Detects whether a module body already declares a default export in any of
|
|
250
|
+
* the syntactic forms the ESM spec allows. Mirrors the logic in
|
|
251
|
+
* `websocket-core-bridge.ts:hasModuleDefaultExport` — kept here so the
|
|
252
|
+
* default-export bridge helper is self-contained and unit-testable.
|
|
253
|
+
*
|
|
254
|
+
* Handles:
|
|
255
|
+
* - `export default <expr>;`
|
|
256
|
+
* - `export default function|class ...`
|
|
257
|
+
* - `export { x as default };`
|
|
258
|
+
* - `export { default };` (implicit `default as default`)
|
|
259
|
+
* - `export { default as default };`
|
|
260
|
+
* - `export { foo, default };`
|
|
261
|
+
*/
|
|
262
|
+
export function hasExistingDefaultExport(code) {
|
|
263
|
+
if (!code || typeof code !== 'string')
|
|
264
|
+
return false;
|
|
265
|
+
if (/\bexport\s+default\b/.test(code))
|
|
266
|
+
return true;
|
|
267
|
+
if (/\bexport\s*\{[^}]*\bdefault\b[^}]*\}/.test(code))
|
|
268
|
+
return true;
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=ns-core-cjs-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ns-core-cjs-shape.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/ns-core-cjs-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,uBAAuB;IACtC,OAAO;QACN,oDAAoD;QACpD,gDAAgD;QAChD,oHAAoH;QACpH,4DAA4D;QAC5D,6DAA6D;QAC7D,wDAAwD;QACxD,+BAA+B;QAC/B,+EAA+E;QAC/E,iDAAiD;QACjD,sDAAsD;QACtD,oEAAoE;QACpE,uBAAuB;QACvB,qCAAqC;QACrC,aAAa;QACb,wCAAwC;QACxC,iDAAiD;QACjD,8BAA8B;QAC9B,oFAAoF;QACpF,WAAW;QACX,sBAAsB;QACtB,mBAAmB;QACnB,QAAQ;QACR,KAAK;QACL,6FAA6F;KAC7F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,iCAAiC,CAAC,IAAY;IAC7D,MAAM,SAAS,GAAG,gHAAgH,CAAC;IAEnI,kEAAkE;IAClE,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,sFAAsF,EAAE,CAAC,MAAM,EAAE,MAAc,EAAE,M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;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACpD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export type ServerStartupBannerInput = {
|
|
2
|
+
version: string;
|
|
3
|
+
transformConcurrency: number;
|
|
4
|
+
transformCacheMs: number;
|
|
5
|
+
lazyInitialGraph: boolean;
|
|
6
|
+
graphVersion: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function formatServerStartupBanner(input: ServerStartupBannerInput): string;
|
|
9
|
+
/**
|
|
10
|
+
* Classify a URL path into a coarse route category. Any pathname that
|
|
11
|
+
* doesn't match a known NativeScript dev route is reported as `other`;
|
|
12
|
+
* callers are expected to filter their own irrelevant routes before
|
|
13
|
+
* calling `record()`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function classifyBootRoute(pathname: string): BootRouteCategory;
|
|
16
|
+
export type BootRouteCategory = 'ns/m' | 'ns/rt' | 'ns/core' | 'ns/vendor' | 'ns/import-map' | 'ns/boot' | 'ns/hmr' | 'ns/other' | 'other';
|
|
17
|
+
export type ColdBootRequestCounter = {
|
|
18
|
+
record: (url: string) => RecordHandle;
|
|
19
|
+
finalize: () => void;
|
|
20
|
+
getState: () => ColdBootCounterState;
|
|
21
|
+
};
|
|
22
|
+
export type RecordHandle = {
|
|
23
|
+
finish: () => void;
|
|
24
|
+
};
|
|
25
|
+
export type ColdBootCounterState = {
|
|
26
|
+
active: boolean;
|
|
27
|
+
count: number;
|
|
28
|
+
inFlight: number;
|
|
29
|
+
maxConcurrent: number;
|
|
30
|
+
startedAt: number | null;
|
|
31
|
+
firstRequestUrl: string | null;
|
|
32
|
+
perRoute: Partial<Record<BootRouteCategory, number>>;
|
|
33
|
+
};
|
|
34
|
+
export type ColdBootCounterOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Emit a rolling summary every N requests (default 100). Lower the
|
|
37
|
+
* threshold in tests to keep them snappy. Set to 0 to disable rolling
|
|
38
|
+
* summaries; a final summary still fires from `finalize()`.
|
|
39
|
+
*/
|
|
40
|
+
summaryEvery?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Cold-boot window closes when no new requests arrive within this
|
|
43
|
+
* idle window (default 5000ms). The HMR edit loop reuses the same
|
|
44
|
+
* handler, but it never bursts as heavily as cold boot. Raise this
|
|
45
|
+
* via `NS_VITE_HMR_BOOT_TRACE_IDLE_MS` when profiling a slow boot
|
|
46
|
+
* so inter-wave pauses don't close the counter prematurely.
|
|
47
|
+
*/
|
|
48
|
+
idleWindowMs?: number;
|
|
49
|
+
/** Defaults to `Date.now`; tests inject a deterministic clock. */
|
|
50
|
+
now?: () => number;
|
|
51
|
+
/** Defaults to `setTimeout`; tests can inject a fake timer. */
|
|
52
|
+
setTimer?: (handler: () => void, ms: number) => unknown;
|
|
53
|
+
/** Defaults to `clearTimeout`; tests can inject a fake timer. */
|
|
54
|
+
clearTimer?: (handle: unknown) => void;
|
|
55
|
+
/** Logger called for every summary line (rolling + final). */
|
|
56
|
+
log: (line: string) => void;
|
|
57
|
+
};
|
|
58
|
+
export declare function createColdBootRequestCounter(options: ColdBootCounterOptions): ColdBootRequestCounter;
|
|
59
|
+
export type PopulateInitialGraphSummary = {
|
|
60
|
+
moduleCount: number;
|
|
61
|
+
durationMs: number;
|
|
62
|
+
graphVersion: number;
|
|
63
|
+
bumpedVersion: boolean;
|
|
64
|
+
};
|
|
65
|
+
export declare function formatPopulateInitialGraphSummary(input: PopulateInitialGraphSummary): string;
|
|
66
|
+
export type HmrUpdateKind = 'ts' | 'html' | 'css' | 'vue' | 'tsx' | 'jsx' | 'js' | 'mjs' | 'unknown';
|
|
67
|
+
/**
|
|
68
|
+
* Classify a file's HMR update kind by extension. Used by the server-side
|
|
69
|
+
* update summary so a quick log line tells us which pipeline ran. Returns
|
|
70
|
+
* `'unknown'` for anything that doesn't match a known dev-time extension —
|
|
71
|
+
* the caller decides whether to log it or skip it entirely.
|
|
72
|
+
*/
|
|
73
|
+
export declare function classifyHmrUpdateKind(file: string): HmrUpdateKind;
|
|
74
|
+
export type HmrUpdateSummary = {
|
|
75
|
+
/** Project-relative or absolute path of the file that triggered HMR. */
|
|
76
|
+
file: string;
|
|
77
|
+
/** File classification. */
|
|
78
|
+
kind: HmrUpdateKind;
|
|
79
|
+
/** Time spent waiting for `populateInitialGraph` to complete (ms). */
|
|
80
|
+
awaitMs: number;
|
|
81
|
+
/** Time spent in framework-specific work (graph updates, invalidation). */
|
|
82
|
+
frameworkMs: number;
|
|
83
|
+
/** Time spent broadcasting the WebSocket message. */
|
|
84
|
+
broadcastMs: number;
|
|
85
|
+
/** End-to-end handler time. */
|
|
86
|
+
totalMs: number;
|
|
87
|
+
/** Number of modules invalidated by the update. */
|
|
88
|
+
invalidated: number;
|
|
89
|
+
/** Number of HMR clients the message was sent to. */
|
|
90
|
+
recipients: number;
|
|
91
|
+
/**
|
|
92
|
+
* Angular-only narrowing decision: whether transitive-importer
|
|
93
|
+
* invalidation was narrowed because the changed file lacks Angular
|
|
94
|
+
* semantic decorators (`@Component`/`@Directive`/`@Pipe`/`@Injectable`/
|
|
95
|
+
* `@NgModule`). `true` means narrow (importers preserved, ESM live
|
|
96
|
+
* bindings carry the change). `false` means broad (importers also
|
|
97
|
+
* invalidated). `null`/`undefined` means the field is not applicable
|
|
98
|
+
* to this update (e.g. CSS, non-Angular flavor) and the field is
|
|
99
|
+
* omitted from the summary line entirely.
|
|
100
|
+
*/
|
|
101
|
+
narrowed?: boolean | null;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Single-line summary for the server side of an HMR update. Always-on so
|
|
105
|
+
* a 6-second `.ts` save is immediately visible without flipping verbose.
|
|
106
|
+
* Format:
|
|
107
|
+
* [hmr-ws][update] kind=ts file=/src/foo.ts await=12ms framework=180ms broadcast=2ms total=194ms invalidated=23 recipients=1
|
|
108
|
+
*
|
|
109
|
+
* For Angular `.ts` updates, `narrowed=yes|no` is appended so the
|
|
110
|
+
* narrowing decision is immediately visible without flipping verbose:
|
|
111
|
+
* [hmr-ws][update] kind=ts file=/src/app/foo.constants.ts ... invalidated=1 recipients=1 narrowed=yes
|
|
112
|
+
* [hmr-ws][update] kind=ts file=/src/app/foo.component.ts ... invalidated=132 recipients=1 narrowed=no
|
|
113
|
+
*/
|
|
114
|
+
export declare function formatHmrUpdateSummary(input: HmrUpdateSummary): string;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Server-side perf instrumentation helpers.
|
|
2
|
+
//
|
|
3
|
+
// All exports are pure so they can be unit-tested without spinning up
|
|
4
|
+
// Vite. The websocket middleware wires them in with its own logger.
|
|
5
|
+
//
|
|
6
|
+
// The three primitives are:
|
|
7
|
+
// 1. `formatServerStartupBanner` — the always-on banner that prints
|
|
8
|
+
// on dev server startup so the user can confirm which build is
|
|
9
|
+
// live and which perf knobs are active.
|
|
10
|
+
// 2. `createColdBootRequestCounter` — a richer counter that tracks
|
|
11
|
+
// the first burst of NativeScript dev routes (`/ns/m/**`, `/ns/rt/**`,
|
|
12
|
+
// `/ns/core/**`, `/__ns_boot__/**`, `/ns/import-map.json`,
|
|
13
|
+
// `/@nativescript/vendor.mjs`). Emits a rolling + final summary so
|
|
14
|
+
// cold-boot traffic is visible without flipping verbose mode.
|
|
15
|
+
// 3. `formatPopulateInitialGraphSummary` — the single line we print
|
|
16
|
+
// when `populateInitialGraph` finishes. Includes module count and
|
|
17
|
+
// duration so it's trivial to spot regressions.
|
|
18
|
+
// Single-line, human-scannable banner. We avoid pretty-printing (no
|
|
19
|
+
// boxes/colors) so it plays well with piped logs and the Vite custom
|
|
20
|
+
// logger. Format:
|
|
21
|
+
// [hmr-ws] @nativescript/vite@<version> — transformConcurrency=8 transformCacheMs=60000ms lazyInitialGraph=on graphVersion=1
|
|
22
|
+
export function formatServerStartupBanner(input) {
|
|
23
|
+
const parts = [`transformConcurrency=${Math.max(1, Math.floor(input.transformConcurrency))}`, `transformCacheMs=${Math.max(0, Math.floor(input.transformCacheMs))}ms`, `lazyInitialGraph=${input.lazyInitialGraph ? 'on' : 'off'}`, `graphVersion=${Math.max(0, Math.floor(input.graphVersion))}`];
|
|
24
|
+
return `[hmr-ws] @nativescript/vite@${input.version} — ${parts.join(' ')}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Classify a URL path into a coarse route category. Any pathname that
|
|
28
|
+
* doesn't match a known NativeScript dev route is reported as `other`;
|
|
29
|
+
* callers are expected to filter their own irrelevant routes before
|
|
30
|
+
* calling `record()`.
|
|
31
|
+
*/
|
|
32
|
+
export function classifyBootRoute(pathname) {
|
|
33
|
+
if (!pathname || typeof pathname !== 'string')
|
|
34
|
+
return 'other';
|
|
35
|
+
if (pathname === '/ns/import-map.json')
|
|
36
|
+
return 'ns/import-map';
|
|
37
|
+
if (pathname === '/@nativescript/vendor.mjs' || pathname.startsWith('/@nativescript/'))
|
|
38
|
+
return 'ns/vendor';
|
|
39
|
+
if (pathname.startsWith('/ns/m/'))
|
|
40
|
+
return 'ns/m';
|
|
41
|
+
if (pathname.startsWith('/ns/rt/'))
|
|
42
|
+
return 'ns/rt';
|
|
43
|
+
if (pathname.startsWith('/ns/core/'))
|
|
44
|
+
return 'ns/core';
|
|
45
|
+
if (pathname.startsWith('/__ns_boot__/'))
|
|
46
|
+
return 'ns/boot';
|
|
47
|
+
if (pathname.startsWith('/__ns_hmr__/'))
|
|
48
|
+
return 'ns/hmr';
|
|
49
|
+
if (pathname.startsWith('/ns/'))
|
|
50
|
+
return 'ns/other';
|
|
51
|
+
return 'other';
|
|
52
|
+
}
|
|
53
|
+
// Factory for the cold-boot counter. Encapsulates all state in a closure
|
|
54
|
+
// so the websocket module doesn't have to track timers itself, and so
|
|
55
|
+
// this is trivially testable with a fake clock.
|
|
56
|
+
export function createColdBootRequestCounter(options) {
|
|
57
|
+
const summaryEvery = Math.max(0, Math.floor(options.summaryEvery ?? 100));
|
|
58
|
+
const idleWindowMs = Math.max(100, Math.floor(options.idleWindowMs ?? 5000));
|
|
59
|
+
const now = options.now ?? (() => Date.now());
|
|
60
|
+
const setTimer = options.setTimer ?? ((handler, ms) => setTimeout(handler, ms));
|
|
61
|
+
const clearTimer = options.clearTimer ?? ((handle) => clearTimeout(handle));
|
|
62
|
+
let active = true;
|
|
63
|
+
let count = 0;
|
|
64
|
+
let inFlight = 0;
|
|
65
|
+
let maxConcurrent = 0;
|
|
66
|
+
let startedAt = null;
|
|
67
|
+
let firstRequestUrl = null;
|
|
68
|
+
let idleTimer = null;
|
|
69
|
+
const perRoute = {};
|
|
70
|
+
const formatPerRoute = () => {
|
|
71
|
+
const entries = Object.entries(perRoute);
|
|
72
|
+
if (entries.length === 0)
|
|
73
|
+
return '';
|
|
74
|
+
entries.sort((a, b) => b[1] - a[1]);
|
|
75
|
+
return entries.map(([k, v]) => `${k}=${v}`).join(',');
|
|
76
|
+
};
|
|
77
|
+
const fireFinal = () => {
|
|
78
|
+
if (!active)
|
|
79
|
+
return;
|
|
80
|
+
active = false;
|
|
81
|
+
// `startedAt` is set the first time `record()` fires. Use an explicit
|
|
82
|
+
// null check — `startedAt` can be 0 on deterministic test clocks and
|
|
83
|
+
// `startedAt ? ... : 0` would mis-treat that as "never started".
|
|
84
|
+
const ms = startedAt !== null ? now() - startedAt : 0;
|
|
85
|
+
const routes = formatPerRoute();
|
|
86
|
+
const routesPart = routes ? ` routes=${routes}` : '';
|
|
87
|
+
options.log(`[hmr-ws][cold-boot] window closed modules=${count} ms=${ms} maxConcurrent=${maxConcurrent}${routesPart}`);
|
|
88
|
+
};
|
|
89
|
+
const scheduleIdleClose = () => {
|
|
90
|
+
if (idleTimer !== null)
|
|
91
|
+
clearTimer(idleTimer);
|
|
92
|
+
idleTimer = setTimer(() => {
|
|
93
|
+
idleTimer = null;
|
|
94
|
+
fireFinal();
|
|
95
|
+
}, idleWindowMs);
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
record(url) {
|
|
99
|
+
if (!active) {
|
|
100
|
+
return { finish: () => { } };
|
|
101
|
+
}
|
|
102
|
+
count += 1;
|
|
103
|
+
inFlight += 1;
|
|
104
|
+
if (inFlight > maxConcurrent)
|
|
105
|
+
maxConcurrent = inFlight;
|
|
106
|
+
if (startedAt === null) {
|
|
107
|
+
startedAt = now();
|
|
108
|
+
firstRequestUrl = url;
|
|
109
|
+
}
|
|
110
|
+
const route = classifyBootRoute(url);
|
|
111
|
+
perRoute[route] = (perRoute[route] ?? 0) + 1;
|
|
112
|
+
if (summaryEvery > 0 && count % summaryEvery === 0) {
|
|
113
|
+
// Same `startedAt === 0` consideration as in fireFinal().
|
|
114
|
+
const ms = startedAt !== null ? now() - startedAt : 0;
|
|
115
|
+
options.log(`[hmr-ws][cold-boot] progress modules=${count} ms=${ms} inFlight=${inFlight} maxConcurrent=${maxConcurrent}`);
|
|
116
|
+
}
|
|
117
|
+
scheduleIdleClose();
|
|
118
|
+
let finished = false;
|
|
119
|
+
return {
|
|
120
|
+
finish() {
|
|
121
|
+
if (finished)
|
|
122
|
+
return;
|
|
123
|
+
finished = true;
|
|
124
|
+
if (inFlight > 0)
|
|
125
|
+
inFlight -= 1;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
finalize() {
|
|
130
|
+
if (idleTimer !== null) {
|
|
131
|
+
clearTimer(idleTimer);
|
|
132
|
+
idleTimer = null;
|
|
133
|
+
}
|
|
134
|
+
fireFinal();
|
|
135
|
+
},
|
|
136
|
+
getState() {
|
|
137
|
+
return { active, count, inFlight, maxConcurrent, startedAt, firstRequestUrl, perRoute: { ...perRoute } };
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// Summary line for `populateInitialGraph`. Stable shape so CI greps or
|
|
142
|
+
// external dashboards can pick it up without fragile regexes.
|
|
143
|
+
export function formatPopulateInitialGraphSummary(input) {
|
|
144
|
+
return `[hmr-ws][populate] modules=${Math.max(0, Math.floor(input.moduleCount))} ms=${Math.max(0, Math.floor(input.durationMs))} graphVersion=${Math.max(0, Math.floor(input.graphVersion))} bumpedVersion=${input.bumpedVersion ? 'yes' : 'no'}`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Classify a file's HMR update kind by extension. Used by the server-side
|
|
148
|
+
* update summary so a quick log line tells us which pipeline ran. Returns
|
|
149
|
+
* `'unknown'` for anything that doesn't match a known dev-time extension —
|
|
150
|
+
* the caller decides whether to log it or skip it entirely.
|
|
151
|
+
*/
|
|
152
|
+
export function classifyHmrUpdateKind(file) {
|
|
153
|
+
if (!file || typeof file !== 'string')
|
|
154
|
+
return 'unknown';
|
|
155
|
+
const lower = file.toLowerCase();
|
|
156
|
+
if (lower.endsWith('.ts'))
|
|
157
|
+
return 'ts';
|
|
158
|
+
if (lower.endsWith('.tsx'))
|
|
159
|
+
return 'tsx';
|
|
160
|
+
if (lower.endsWith('.jsx'))
|
|
161
|
+
return 'jsx';
|
|
162
|
+
if (lower.endsWith('.html') || lower.endsWith('.htm'))
|
|
163
|
+
return 'html';
|
|
164
|
+
if (lower.endsWith('.css') || lower.endsWith('.scss') || lower.endsWith('.sass') || lower.endsWith('.less'))
|
|
165
|
+
return 'css';
|
|
166
|
+
if (lower.endsWith('.vue'))
|
|
167
|
+
return 'vue';
|
|
168
|
+
if (lower.endsWith('.mjs'))
|
|
169
|
+
return 'mjs';
|
|
170
|
+
if (lower.endsWith('.js'))
|
|
171
|
+
return 'js';
|
|
172
|
+
return 'unknown';
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Single-line summary for the server side of an HMR update. Always-on so
|
|
176
|
+
* a 6-second `.ts` save is immediately visible without flipping verbose.
|
|
177
|
+
* Format:
|
|
178
|
+
* [hmr-ws][update] kind=ts file=/src/foo.ts await=12ms framework=180ms broadcast=2ms total=194ms invalidated=23 recipients=1
|
|
179
|
+
*
|
|
180
|
+
* For Angular `.ts` updates, `narrowed=yes|no` is appended so the
|
|
181
|
+
* narrowing decision is immediately visible without flipping verbose:
|
|
182
|
+
* [hmr-ws][update] kind=ts file=/src/app/foo.constants.ts ... invalidated=1 recipients=1 narrowed=yes
|
|
183
|
+
* [hmr-ws][update] kind=ts file=/src/app/foo.component.ts ... invalidated=132 recipients=1 narrowed=no
|
|
184
|
+
*/
|
|
185
|
+
export function formatHmrUpdateSummary(input) {
|
|
186
|
+
const parts = [`kind=${input.kind || 'unknown'}`, `file=${input.file || '<unknown>'}`, `await=${Math.max(0, Math.floor(input.awaitMs))}ms`, `framework=${Math.max(0, Math.floor(input.frameworkMs))}ms`, `broadcast=${Math.max(0, Math.floor(input.broadcastMs))}ms`, `total=${Math.max(0, Math.floor(input.totalMs))}ms`, `invalidated=${Math.max(0, Math.floor(input.invalidated))}`, `recipients=${Math.max(0, Math.floor(input.recipients))}`];
|
|
187
|
+
if (input.narrowed === true) {
|
|
188
|
+
parts.push('narrowed=yes');
|
|
189
|
+
}
|
|
190
|
+
else if (input.narrowed === false) {
|
|
191
|
+
parts.push('narrowed=no');
|
|
192
|
+
}
|
|
193
|
+
return `[hmr-ws][update] ${parts.join(' ')}`;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=perf-instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perf-instrumentation.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/perf-instrumentation.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,EAAE;AACF,4BAA4B;AAC5B,sEAAsE;AACtE,oEAAoE;AACpE,6CAA6C;AAC7C,qEAAqE;AACrE,4EAA4E;AAC5E,gEAAgE;AAChE,wEA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,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,cAAc,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;IACnb,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC5B,CAAC;SAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,oBAAoB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function normalizeRuntimeGraphPath(value: string): string;
|
|
2
|
+
export declare function isRuntimeGraphExcludedPath(value: string): boolean;
|
|
3
|
+
export declare function shouldSkipRuntimeGraphDirectoryName(name: string): boolean;
|
|
4
|
+
export declare function shouldIncludeRuntimeGraphFile(value: string, filePattern: RegExp): boolean;
|
|
5
|
+
export declare function matchesRuntimeGraphModuleId(value: string, appPrefix: string, filePattern: RegExp): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function normalizeRuntimeGraphPath(value) {
|
|
2
|
+
return String(value || '')
|
|
3
|
+
.replace(/\\/g, '/')
|
|
4
|
+
.replace(/[?#].*$/, '');
|
|
5
|
+
}
|
|
6
|
+
export function isRuntimeGraphExcludedPath(value) {
|
|
7
|
+
const normalized = normalizeRuntimeGraphPath(value);
|
|
8
|
+
return /(?:^|\/)(?:__tests__|__mocks__)(?:\/|$)|(?:^|\/)[^/]+\.(?:spec|test)\.[^/]+$/i.test(normalized);
|
|
9
|
+
}
|
|
10
|
+
export function shouldSkipRuntimeGraphDirectoryName(name) {
|
|
11
|
+
return name === '__tests__' || name === '__mocks__';
|
|
12
|
+
}
|
|
13
|
+
export function shouldIncludeRuntimeGraphFile(value, filePattern) {
|
|
14
|
+
const normalized = normalizeRuntimeGraphPath(value);
|
|
15
|
+
return filePattern.test(normalized) && !isRuntimeGraphExcludedPath(normalized);
|
|
16
|
+
}
|
|
17
|
+
export function matchesRuntimeGraphModuleId(value, appPrefix, filePattern) {
|
|
18
|
+
const normalized = normalizeRuntimeGraphPath(value);
|
|
19
|
+
return normalized.startsWith(appPrefix) && filePattern.test(normalized) && !isRuntimeGraphExcludedPath(normalized);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=runtime-graph-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-graph-filter.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/runtime-graph-filter.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACtD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACxB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACvD,MAAM,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,+EAA+E,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACzG,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,IAAY;IAC/D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAa,EAAE,WAAmB;IAC/E,MAAM,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAa,EAAE,SAAiB,EAAE,WAAmB;IAChG,MAAM,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;AACpH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransformResult } from 'vite';
|
|
2
|
+
export type SharedTransformRequestRunnerOptions = {
|
|
3
|
+
maxConcurrent?: number;
|
|
4
|
+
resultCacheTtlMs?: number;
|
|
5
|
+
getResultCacheKey?: (url: string) => string;
|
|
6
|
+
};
|
|
7
|
+
export type SharedTransformRequestRunner = ((url: string, timeoutMs?: number) => Promise<TransformResult | null>) & {
|
|
8
|
+
invalidate: (url: string) => void;
|
|
9
|
+
invalidateMany: (urls: Iterable<string>) => void;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function createSharedTransformRequestRunner(transformRequest: (url: string) => Promise<TransformResult | null>, onTimeout?: (url: string, timeoutMs: number) => void, options?: SharedTransformRequestRunnerOptions): SharedTransformRequestRunner;
|