@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -11
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +369 -159
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +184 -14
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +5 -72
- package/configuration/javascript.js.map +1 -1
- package/configuration/solid.js +27 -1
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +5 -75
- package/configuration/typescript.js.map +1 -1
- package/helpers/angular/angular-linker.d.ts +5 -6
- package/helpers/angular/angular-linker.js +36 -121
- 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 +291 -0
- package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
- package/helpers/angular/inject-hmr-vite-ignore.d.ts +75 -0
- package/helpers/angular/inject-hmr-vite-ignore.js +221 -0
- package/helpers/angular/inject-hmr-vite-ignore.js.map +1 -0
- package/helpers/angular/inline-decorator-component-templates.js +1 -170
- package/helpers/angular/inline-decorator-component-templates.js.map +1 -1
- package/helpers/angular/js-lexer.d.ts +4 -0
- package/helpers/angular/js-lexer.js +182 -0
- package/helpers/angular/js-lexer.js.map +1 -0
- package/helpers/angular/shared-linker.d.ts +31 -3
- package/helpers/angular/shared-linker.js +67 -14
- package/helpers/angular/shared-linker.js.map +1 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js +2 -170
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -1
- package/helpers/angular/synthesize-injectable-factories.js +1 -174
- package/helpers/angular/synthesize-injectable-factories.js.map +1 -1
- 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/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-state.d.ts +8 -0
- package/helpers/app-css-state.js +8 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/dev-host.d.ts +341 -0
- package/helpers/dev-host.js +617 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.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/hmr-scope.d.ts +26 -0
- package/helpers/hmr-scope.js +67 -0
- package/helpers/hmr-scope.js.map +1 -0
- package/helpers/init.js +0 -18
- package/helpers/init.js.map +1 -1
- 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 +2 -1
- package/helpers/main-entry.js +430 -47
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.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/nativescript-package-resolver.js +8 -3
- package/helpers/nativescript-package-resolver.js.map +1 -1
- package/helpers/normalize-id.d.ts +42 -0
- package/helpers/normalize-id.js +60 -0
- package/helpers/normalize-id.js.map +1 -0
- package/helpers/ns-core-url.d.ts +88 -0
- package/helpers/ns-core-url.js +191 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/package-platform-aliases.js +4 -3
- package/helpers/package-platform-aliases.js.map +1 -1
- package/helpers/platform-types.d.ts +2 -0
- package/helpers/platform-types.js +2 -0
- package/helpers/platform-types.js.map +1 -0
- package/helpers/prelink-angular.js +12 -33
- 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/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/solid-jsx-deps.d.ts +15 -0
- package/helpers/solid-jsx-deps.js +178 -0
- package/helpers/solid-jsx-deps.js.map +1 -0
- package/helpers/ts-config-paths.d.ts +14 -0
- package/helpers/ts-config-paths.js +89 -8
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/workers.d.ts +20 -19
- package/helpers/workers.js +624 -4
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +1 -0
- package/hmr/client/css-handler.js +33 -20
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/css-update-overlay.d.ts +18 -0
- package/hmr/client/css-update-overlay.js +27 -0
- package/hmr/client/css-update-overlay.js.map +1 -0
- 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 +419 -15
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +6 -1
- package/hmr/client/utils.js +184 -8
- package/hmr/client/utils.js.map +1 -1
- package/hmr/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +252 -65
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/client/index.d.ts +1 -0
- package/hmr/frameworks/angular/client/index.js +778 -20
- 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 +13 -15
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/solid/server/strategy.js +3 -18
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +2 -15
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.js +30 -199
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/helpers/ast-normalizer.js +52 -5
- 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/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/server/angular-root-component.d.ts +79 -0
- package/hmr/server/angular-root-component.js +149 -0
- package/hmr/server/angular-root-component.js.map +1 -0
- package/hmr/server/constants.js +13 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +90 -7
- package/hmr/server/core-sanitize.js +211 -56
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/framework-strategy.d.ts +9 -19
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +214 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.js +60 -8
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +1 -0
- 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/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/ns-rt-route.d.ts +5 -0
- package/hmr/server/ns-rt-route.js +35 -0
- package/hmr/server/ns-rt-route.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/require-guard.d.ts +1 -0
- package/hmr/server/require-guard.js +12 -0
- package/hmr/server/require-guard.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/server-origin.d.ts +12 -0
- package/hmr/server/server-origin.js +66 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +12 -5
- package/hmr/server/shared-transform-request.js.map +1 -1
- package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
- package/hmr/server/vendor-bare-module-shims.js +80 -0
- package/hmr/server/vendor-bare-module-shims.js.map +1 -0
- package/hmr/server/vite-plugin.js +60 -42
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-angular-entry.js +1 -1
- package/hmr/server/websocket-angular-entry.js.map +1 -1
- package/hmr/server/websocket-angular-hot-update.d.ts +17 -0
- package/hmr/server/websocket-angular-hot-update.js +176 -2
- package/hmr/server/websocket-angular-hot-update.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +41 -6
- package/hmr/server/websocket-core-bridge.js +72 -75
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-css-hot-update.d.ts +33 -0
- package/hmr/server/websocket-css-hot-update.js +65 -0
- package/hmr/server/websocket-css-hot-update.js.map +1 -0
- package/hmr/server/websocket-device-transform.d.ts +21 -0
- package/hmr/server/websocket-device-transform.js +1570 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +15 -0
- package/hmr/server/websocket-graph-upsert.js +20 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -1
- 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-hot-update.d.ts +51 -0
- package/hmr/server/websocket-hot-update.js +1160 -0
- package/hmr/server/websocket-hot-update.js.map +1 -0
- package/hmr/server/websocket-import-map-route.d.ts +15 -0
- package/hmr/server/websocket-import-map-route.js +44 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.js +3 -3
- 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 +202 -19
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +21 -0
- package/hmr/server/websocket-ns-core.js +305 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +22 -0
- package/hmr/server/websocket-ns-entry.js +150 -0
- package/hmr/server/websocket-ns-entry.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-ns-m.d.ts +34 -0
- package/hmr/server/websocket-ns-m.js +853 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
- package/hmr/server/websocket-served-module-helpers.js +654 -0
- package/hmr/server/websocket-served-module-helpers.js.map +1 -0
- package/hmr/server/websocket-sfc.d.ts +24 -0
- package/hmr/server/websocket-sfc.js +1223 -0
- package/hmr/server/websocket-sfc.js.map +1 -0
- package/hmr/server/websocket-txn.d.ts +6 -0
- package/hmr/server/websocket-txn.js +39 -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 +45 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +0 -30
- package/hmr/server/websocket.js +599 -6038
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +40 -0
- package/hmr/shared/runtime/boot-progress.js +128 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
- package/hmr/shared/runtime/boot-timeline.js +52 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
- package/hmr/shared/runtime/dev-overlay.js +990 -260
- 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-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +310 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +352 -194
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +164 -1
- 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-collect.d.ts +32 -0
- package/hmr/shared/vendor/manifest-collect.js +512 -0
- package/hmr/shared/vendor/manifest-collect.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
- package/hmr/shared/vendor/manifest-loader.js +3 -2
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +1 -5
- package/hmr/shared/vendor/manifest.js +102 -739
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +55 -11
- package/runtime/core-aliases-early.js +17 -41
- package/runtime/core-aliases-early.js.map +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
const BOOTSTRAP_APPLICATION_RE = /\bbootstrapApplication\s*\(\s*([A-Za-z_$][\w$]*)/;
|
|
3
|
+
const IMPORT_STATEMENT_RE = /import\s+([^;'"]+?)\s+from\s+['"]([^'"]+)['"]/g;
|
|
4
|
+
const SOURCE_EXTENSION_RE = /\.(?:tsx?|jsx?|mjs|cjs|html?|css|scss|sass|less)$/i;
|
|
5
|
+
function scanImportBindings(source) {
|
|
6
|
+
const bindings = new Map();
|
|
7
|
+
IMPORT_STATEMENT_RE.lastIndex = 0;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = IMPORT_STATEMENT_RE.exec(source)) !== null) {
|
|
10
|
+
const clause = match[1].trim();
|
|
11
|
+
const specifier = match[2];
|
|
12
|
+
recordClauseBindings(clause, specifier, bindings);
|
|
13
|
+
}
|
|
14
|
+
return bindings;
|
|
15
|
+
}
|
|
16
|
+
function recordClauseBindings(clause, specifier, out) {
|
|
17
|
+
const namedStart = clause.indexOf('{');
|
|
18
|
+
if (namedStart !== -1) {
|
|
19
|
+
const namedEnd = clause.indexOf('}', namedStart);
|
|
20
|
+
const namedSegment = namedEnd === -1 ? clause.slice(namedStart + 1) : clause.slice(namedStart + 1, namedEnd);
|
|
21
|
+
for (const raw of namedSegment.split(',')) {
|
|
22
|
+
const entry = raw.trim();
|
|
23
|
+
if (!entry)
|
|
24
|
+
continue;
|
|
25
|
+
const asMatch = /^(\S+)\s+as\s+(\S+)$/.exec(entry);
|
|
26
|
+
if (asMatch) {
|
|
27
|
+
out.set(asMatch[2], { specifier, importedName: asMatch[1] });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
out.set(entry, { specifier, importedName: entry });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Strip the `{ … }` group so a leading default import in the same
|
|
34
|
+
// statement (`import Foo, { Bar } from '…'`) is still captured below.
|
|
35
|
+
clause = (clause.slice(0, namedStart) + clause.slice(namedEnd === -1 ? clause.length : namedEnd + 1)).trim();
|
|
36
|
+
}
|
|
37
|
+
const namespaceMatch = /^\*\s+as\s+([A-Za-z_$][\w$]*)$/.exec(clause);
|
|
38
|
+
if (namespaceMatch) {
|
|
39
|
+
out.set(namespaceMatch[1], { specifier, importedName: '*' });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const defaultName = clause.replace(/,\s*$/, '').trim();
|
|
43
|
+
if (/^[A-Za-z_$][\w$]*$/.test(defaultName)) {
|
|
44
|
+
out.set(defaultName, { specifier, importedName: 'default' });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolves a (relative or `~`/`@` aliased) module specifier — as written in
|
|
49
|
+
* the entry's import — to an extensionless project-relative POSIX path.
|
|
50
|
+
* Returns `null` for bare/package specifiers (a root component is always a
|
|
51
|
+
* project-local file).
|
|
52
|
+
*/
|
|
53
|
+
function resolveSpecifierToModuleRel(specifier, entryRel, appRootRel) {
|
|
54
|
+
const entryDir = path.posix.dirname(normalizeRel(entryRel));
|
|
55
|
+
if (specifier.startsWith('./') || specifier.startsWith('../')) {
|
|
56
|
+
return toExtensionlessModuleRel(path.posix.join(entryDir, specifier));
|
|
57
|
+
}
|
|
58
|
+
if (specifier.startsWith('~/') || specifier.startsWith('@/')) {
|
|
59
|
+
const base = normalizeRel(appRootRel || entryDir);
|
|
60
|
+
return toExtensionlessModuleRel(path.posix.join(base, specifier.slice(2)));
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function normalizeRel(rel) {
|
|
65
|
+
let normalized = String(rel || '').replace(/\\/g, '/');
|
|
66
|
+
if (!normalized.startsWith('/'))
|
|
67
|
+
normalized = '/' + normalized;
|
|
68
|
+
return normalized.replace(/\/{2,}/g, '/');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Normalizes any project-relative path to a leading-slash, extensionless
|
|
72
|
+
* POSIX key suitable for equality comparison between a `.html`/`.ts` edit
|
|
73
|
+
* and the resolved root component.
|
|
74
|
+
*/
|
|
75
|
+
export function toExtensionlessModuleRel(rel) {
|
|
76
|
+
const normalized = normalizeRel(rel);
|
|
77
|
+
return normalized.replace(SOURCE_EXTENSION_RE, '');
|
|
78
|
+
}
|
|
79
|
+
/** True when two project-relative paths refer to the same module (ignoring extension). */
|
|
80
|
+
export function isSameAngularModuleRel(a, b) {
|
|
81
|
+
if (!a || !b)
|
|
82
|
+
return false;
|
|
83
|
+
return toExtensionlessModuleRel(a) === toExtensionlessModuleRel(b);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolves the bootstrap root component from a dev-server entry module's
|
|
87
|
+
* source. Returns `null` when the bootstrap shape can't be statically
|
|
88
|
+
* resolved (callers should then keep their default behavior).
|
|
89
|
+
*/
|
|
90
|
+
export function resolveBootstrapRootComponent(options) {
|
|
91
|
+
const { entrySource, entryRel } = options;
|
|
92
|
+
if (!entrySource || !entryRel)
|
|
93
|
+
return null;
|
|
94
|
+
const bootstrapMatch = BOOTSTRAP_APPLICATION_RE.exec(entrySource);
|
|
95
|
+
if (!bootstrapMatch)
|
|
96
|
+
return null;
|
|
97
|
+
const localName = bootstrapMatch[1];
|
|
98
|
+
const binding = scanImportBindings(entrySource).get(localName);
|
|
99
|
+
if (!binding)
|
|
100
|
+
return null;
|
|
101
|
+
const moduleRel = resolveSpecifierToModuleRel(binding.specifier, entryRel, options.appRootRel ?? '');
|
|
102
|
+
if (!moduleRel)
|
|
103
|
+
return null;
|
|
104
|
+
// Prefer the originally-imported name (the declared class) over a local
|
|
105
|
+
// alias so it lines up with the class name Analog encodes in its id.
|
|
106
|
+
const className = binding.importedName && binding.importedName !== 'default' && binding.importedName !== '*' ? binding.importedName : localName;
|
|
107
|
+
return { moduleRel, className };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Decodes Analog's `angular:component-update` payload `id`
|
|
111
|
+
* (`encodeURIComponent(relativePath + '@' + className)`) into a normalized,
|
|
112
|
+
* extensionless module rel plus the class name, so the bridge can compare it
|
|
113
|
+
* against the resolved root component. Returns `null` for empty/invalid ids.
|
|
114
|
+
*/
|
|
115
|
+
export function decodeAngularComponentUpdateId(id) {
|
|
116
|
+
if (typeof id !== 'string' || !id)
|
|
117
|
+
return null;
|
|
118
|
+
let decoded = id;
|
|
119
|
+
try {
|
|
120
|
+
decoded = decodeURIComponent(id);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Leave as-is — a non-encoded id still splits/normalizes correctly.
|
|
124
|
+
}
|
|
125
|
+
// Class names never contain `@`, but scoped paths can — split on the LAST
|
|
126
|
+
// `@` so `relativePath` keeps any leading `@scope/...` segments intact.
|
|
127
|
+
const at = decoded.lastIndexOf('@');
|
|
128
|
+
const pathPart = at >= 0 ? decoded.slice(0, at) : decoded;
|
|
129
|
+
const className = at >= 0 ? decoded.slice(at + 1) : '';
|
|
130
|
+
if (!pathPart)
|
|
131
|
+
return null;
|
|
132
|
+
return { moduleRel: toExtensionlessModuleRel(pathPart), className };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* True when an Analog `angular:component-update` `id` targets the resolved
|
|
136
|
+
* root component — matched by module path first (robust to class-name
|
|
137
|
+
* collisions), then by class name as a fallback.
|
|
138
|
+
*/
|
|
139
|
+
export function isAngularRootComponentUpdate(root, id) {
|
|
140
|
+
if (!root)
|
|
141
|
+
return false;
|
|
142
|
+
const decoded = decodeAngularComponentUpdateId(id);
|
|
143
|
+
if (!decoded)
|
|
144
|
+
return false;
|
|
145
|
+
if (isSameAngularModuleRel(root.moduleRel, decoded.moduleRel))
|
|
146
|
+
return true;
|
|
147
|
+
return !!decoded.className && decoded.className === root.className;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=angular-root-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-root-component.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/angular-root-component.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAiDxB,MAAM,wBAAwB,GAAG,kDAAkD,CAAC;AACpF,MAAM,mBAAmB,GAAG,gDAAgD,CAAC;AAC7E,MAAM,mBAAmB,GAAG,oDAAoD,CAAC;AAajF,SAAS,kBAAkB,CAAC,MAAc;IACzC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,mBAAmB,CAAC,SAAS,GAAG,CAAC,CAAC;IAClC,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;I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QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,EAAE,SAAS,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAA+C,EAAE,EAAW;IACxG,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,OAAO,GAAG,8BAA8B,CAAC,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;AACpE,CAAC"}
|
package/hmr/server/constants.js
CHANGED
|
@@ -5,15 +5,24 @@ export const QUERY_PATTERN = /\?.*$/;
|
|
|
5
5
|
// Detect whether Vite's variable dynamic import helper is already inlined
|
|
6
6
|
export const VARIABLE_DYNAMIC_IMPORT_HELPER_PATTERN = /__variableDynamicImportRuntimeHelper\s*=/;
|
|
7
7
|
// Import/export matchers (static and dynamic)
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
//
|
|
9
|
+
// Each pattern's first capture group includes the optional leading anchor
|
|
10
|
+
// (`^|\n`) so the replacement function preserves the line break that would
|
|
11
|
+
// otherwise be silently consumed by the regex engine. Without this, two
|
|
12
|
+
// concatenated patterns like:
|
|
13
|
+
// `})();\nexport * from "a"\nexport * from "b"`
|
|
14
|
+
// would collapse to:
|
|
15
|
+
// `})();export * from "a"export * from "b"`
|
|
16
|
+
// because each `(?:^|\n)` ate a newline that no replacement string put back.
|
|
17
|
+
export const IMPORT_PATTERN_1 = /((?:^|\n)\s*import\s+[^'";]*?\s+from\s+["'])([^"']+)(["'];?)/g;
|
|
18
|
+
export const IMPORT_PATTERN_2 = /((?:^|\n)\s*export\s+[^'";]*?\s+from\s+["'])([^"']+)(["'];?)/g;
|
|
10
19
|
export const EXPORT_PATTERN = IMPORT_PATTERN_2;
|
|
11
20
|
export const IMPORT_PATTERN_3 = /(import\(\s*["'])([^"']+)(["']\s*\))/g;
|
|
12
21
|
// Side-effect imports: import "spec" / import 'spec' (no `from`, no bindings)
|
|
13
|
-
export const IMPORT_PATTERN_SIDE_EFFECT = /(?:^|\n)
|
|
22
|
+
export const IMPORT_PATTERN_SIDE_EFFECT = /((?:^|\n)\s*import\s+["'])([^"']+)(["'];?)/g;
|
|
14
23
|
// Vue-specific patterns
|
|
15
24
|
export const VUE_FILE_PATTERN = /\.vue(?:\?[^"']*)?$/;
|
|
16
|
-
export const VUE_FILE_IMPORT = /(?:^|\n)
|
|
25
|
+
export const VUE_FILE_IMPORT = /((?:^|\n)\s*import\s+[^'";]*?\s+from\s+["'])([^"']+\.vue(?:\?[^"']*)?)(["'];?)/g;
|
|
17
26
|
// Vite/HMR noise cleanup
|
|
18
27
|
export const VITE_CLIENT_IMPORT = /(?:^|\n)\s*import\s+['"](?:\/@vite\/client|@vite\/client)['"];?/g;
|
|
19
28
|
// Strip Vite's injected `import.meta.hot = __vite__createHotContext(...)` assignment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qGAAqG;AAErG,uBAAuB;AACvB,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sCAAsC,GAAG,0CAA0C,CAAC;AAEjG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAA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,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,6CAA6C,CAAC;AAExF,wBAAwB;AACxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,iFAAiF,CAAC;AAEjH,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,kEAAkE,CAAC;AACrG,sFAAsF;AACtF,wFAAwF;AACxF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,sCAAsC,CAAC;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,+DAA+D,CAAC;AAErG,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kEAAkE,CAAC;AACpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,sEAAsE,CAAC;AAC5G,MAAM,CAAC,MAAM,qBAAqB,GAAG,+CAA+C,CAAC"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* "@nativescript/core/index.js";
|
|
9
9
|
* This trips the sanitizer's local-core-path detector and breaks HTTP ESM loading.
|
|
10
10
|
*
|
|
11
|
-
* This helper safely maps those literals to:
|
|
12
|
-
* import "/ns/core?p=
|
|
11
|
+
* This helper safely maps those literals to the canonical path form:
|
|
12
|
+
* import "/ns/core/<sub>"; // subpath form, no version, no ?p=
|
|
13
13
|
* or, without subpath:
|
|
14
14
|
* import "/ns/core";
|
|
15
15
|
*/
|
|
@@ -19,17 +19,95 @@ export declare function normalizeStrayCoreStringLiterals(code: string): string;
|
|
|
19
19
|
* following side-effect import of the core bridge.
|
|
20
20
|
*
|
|
21
21
|
* Example:
|
|
22
|
-
* import { A, B } from\nimport "/ns/core
|
|
22
|
+
* import { A, B } from\nimport "/ns/core/index";
|
|
23
23
|
* becomes
|
|
24
|
-
* import { A, B } from "/ns/core
|
|
24
|
+
* import { A, B } from "/ns/core/index";
|
|
25
25
|
*/
|
|
26
26
|
export declare function fixDanglingCoreFrom(code: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Run the full "rescue any stray @nativescript/core references" pass over the
|
|
29
|
+
* code in one call. This is the canonical entry point for NS-M served modules
|
|
30
|
+
* (and any other consumer that wants the safety net). The three sub-passes
|
|
31
|
+
* cover progressively rarer pipeline accidents:
|
|
32
|
+
*
|
|
33
|
+
* 1. `normalizeStrayCoreStringLiterals` — turns naked `"@nativescript/core/foo";`
|
|
34
|
+
* string literals (produced by some upstream transforms that bare-stringify
|
|
35
|
+
* side-effect imports) back into proper `import "/ns/core/foo";`.
|
|
36
|
+
* 2. `fixDanglingCoreFrom` — merges multi-line accidents where a `from`
|
|
37
|
+
* clause got separated from its specifier across newlines.
|
|
38
|
+
* 3. `normalizeAnyCoreSpecToBridge` — final regex sweep that catches any
|
|
39
|
+
* remaining `from "...@nativescript/core[/sub]..."` references that escaped
|
|
40
|
+
* both the AST normalizer and the import rewriter.
|
|
41
|
+
*
|
|
42
|
+
* Centralising the passes here ensures every NS-M emitter applies the same
|
|
43
|
+
* safety net in the same order; drift between call sites re-introduces the
|
|
44
|
+
* realm-split bug.
|
|
45
|
+
*
|
|
46
|
+
* Returns the (possibly) rewritten code; never throws.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeStrayCoreReferences(code: string): string;
|
|
27
49
|
/**
|
|
28
50
|
* Fallback: normalize ANY import spec that references '@nativescript/core' (including
|
|
29
51
|
* absolute/relative or resolved forms like '/node_modules/@nativescript/core/index.js?v=...')
|
|
30
52
|
* into the unified '/ns/core' bridge before fast-fail assertions.
|
|
31
53
|
*/
|
|
32
54
|
export declare function normalizeAnyCoreSpecToBridge(code: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Description of the URL the bridge is currently serving, used to resolve
|
|
57
|
+
* relative import specifiers (`./x`, `../x`) into absolute `/ns/core/<sub>`
|
|
58
|
+
* URLs.
|
|
59
|
+
*
|
|
60
|
+
* Why this exists: Vite's `vite:import-analysis` pass usually rewrites every
|
|
61
|
+
* relative specifier to an absolute (`/@fs/...` or `/node_modules/...`) ID
|
|
62
|
+
* before code reaches us, but for files under `node_modules` some transform
|
|
63
|
+
* paths leave relatives untouched. When the device fetches such a module at
|
|
64
|
+
* `http://host/ns/core/utils/layout-helper` (no trailing slash, no `/index`)
|
|
65
|
+
* V8/iOS apply RFC 3986 URL resolution and treat `layout-helper` as the
|
|
66
|
+
* *file*, so `./layout-helper-common` becomes
|
|
67
|
+
* `http://host/ns/core/utils/layout-helper-common` — a sibling that does not
|
|
68
|
+
* exist (the real file lives at `…/layout-helper/layout-helper-common`).
|
|
69
|
+
*
|
|
70
|
+
* Passing a `RelativeBase` lets `rewriteSpec` resolve these specifiers
|
|
71
|
+
* server-side and emit canonical absolute `/ns/core/<resolved>` URLs, so the
|
|
72
|
+
* device never has to guess. When omitted, `rewriteSpec` falls back to the
|
|
73
|
+
* pre-existing behaviour of leaving relatives alone.
|
|
74
|
+
*/
|
|
75
|
+
export type RelativeBase = {
|
|
76
|
+
/**
|
|
77
|
+
* Sub-path of the served module, without the leading `/ns/core/`. May be
|
|
78
|
+
* the empty string for the package main (`/ns/core` itself).
|
|
79
|
+
*/
|
|
80
|
+
sub: string;
|
|
81
|
+
/**
|
|
82
|
+
* `true` when the served file is a directory-index (e.g.
|
|
83
|
+
* `…/utils/layout-helper/index.android.ts`); in that case `sub` already
|
|
84
|
+
* names the *directory*, and `./x` resolves to `<sub>/x`.
|
|
85
|
+
*
|
|
86
|
+
* `false` for plain file modules (e.g. `…/utils/native-helper.ts`); the
|
|
87
|
+
* resolution base is the parent directory of `sub`, so `./x` resolves to
|
|
88
|
+
* `<sub-parent>/x`.
|
|
89
|
+
*/
|
|
90
|
+
isDirectoryIndex: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Detect whether a resolved module path is a directory-index file. Matches
|
|
94
|
+
* `index.<platform?>.<ext>` shapes used across @nativescript/core (e.g.
|
|
95
|
+
* `index.js`, `index.android.ts`, `index.ios.mjs`).
|
|
96
|
+
*/
|
|
97
|
+
export declare function isDirectoryIndexFilename(modulePath: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a relative specifier (`./x`, `../x`) into a canonical
|
|
100
|
+
* @nativescript/core sub-path, given the base described by `relBase`.
|
|
101
|
+
*
|
|
102
|
+
* `…/index.<platform>.<ext>` files mean `sub` IS the directory (so `./x` →
|
|
103
|
+
* `<sub>/x`); plain files mean the resolution base is `sub`'s parent.
|
|
104
|
+
*
|
|
105
|
+
* Returned sub-path is sanitised by `buildCoreUrlPath`'s convention: trailing
|
|
106
|
+
* `.(m)?(j|t)s` extensions are stripped so callers can directly emit
|
|
107
|
+
* `/ns/core/<resolved>` without producing a non-canonical URL that the
|
|
108
|
+
* bridge would 301-redirect later.
|
|
109
|
+
*/
|
|
110
|
+
export declare function resolveRelativeCoreSub(spec: string, relBase: RelativeBase): string | null;
|
|
33
111
|
/**
|
|
34
112
|
* Minimal specifier rewriter for deep subpath core modules.
|
|
35
113
|
*
|
|
@@ -43,14 +121,19 @@ export declare function normalizeAnyCoreSpecToBridge(code: string): string;
|
|
|
43
121
|
* This replaces the heavy 5-pass pipeline (processCodeForDevice →
|
|
44
122
|
* rewriteImports → deduplicateLinkerImports → CJS wrapping → etc.)
|
|
45
123
|
* for deep subpath core modules where Vite already produces correct ESM.
|
|
124
|
+
*
|
|
125
|
+
* When `relBase` is supplied, relative specifiers (`./x`, `../x`) are
|
|
126
|
+
* resolved server-side into canonical `/ns/core/<resolved>` URLs so the
|
|
127
|
+
* device never has to guess where a directory-index file's siblings live.
|
|
128
|
+
* See `RelativeBase` and `rewriteSpec` for the full rationale.
|
|
46
129
|
*/
|
|
47
|
-
export declare function rewriteSpecifiersForDevice(code: string, origin: string, ver: number): string;
|
|
130
|
+
export declare function rewriteSpecifiersForDevice(code: string, origin: string, ver: number, relBase?: RelativeBase): string;
|
|
48
131
|
/**
|
|
49
132
|
* Determine whether a `/ns/core` bridge URL points to a real subpath module.
|
|
50
133
|
*
|
|
51
|
-
* Any `/ns/core
|
|
134
|
+
* Any `/ns/core/<sub>` module now serves real ESM content with real named
|
|
52
135
|
* exports via Vite's transform pipeline, except for package-main aliases like
|
|
53
|
-
* `/ns/core
|
|
136
|
+
* `/ns/core/index`, which should be treated like the main `/ns/core`
|
|
54
137
|
* bridge and destructured from its default export.
|
|
55
138
|
* The main proxy bridge (`/ns/core`) still only exports a default Proxy and
|
|
56
139
|
* requires named imports to be destructured from it.
|