@nativescript/vite 0.0.1-alpha.7 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +44 -0
- package/{dist/configuration → configuration}/angular.d.ts +1 -1
- package/configuration/angular.js +480 -0
- package/configuration/angular.js.map +1 -0
- package/configuration/base.d.ts +5 -0
- package/configuration/base.js +494 -0
- package/configuration/base.js.map +1 -0
- package/configuration/javascript.d.ts +4 -0
- package/configuration/javascript.js +151 -0
- package/configuration/javascript.js.map +1 -0
- package/{dist/configuration → configuration}/react.d.ts +1 -1
- package/{dist/configuration → configuration}/react.js +18 -17
- package/configuration/react.js.map +1 -0
- package/{dist/configuration → configuration}/solid.d.ts +1 -1
- package/{dist/configuration → configuration}/solid.js +17 -16
- package/configuration/solid.js.map +1 -0
- package/configuration/typescript.d.ts +4 -0
- package/configuration/typescript.js +175 -0
- package/configuration/typescript.js.map +1 -0
- package/{dist/configuration → configuration}/vue.d.ts +1 -1
- package/configuration/vue.js +163 -0
- package/configuration/vue.js.map +1 -0
- package/helpers/angular-linker.d.ts +13 -0
- package/helpers/angular-linker.js +181 -0
- package/helpers/angular-linker.js.map +1 -0
- package/helpers/cli-flags.d.ts +1 -0
- package/helpers/cli-flags.js +15 -0
- package/helpers/cli-flags.js.map +1 -0
- package/{dist/helpers → helpers}/commonjs-plugins.js +14 -13
- package/helpers/commonjs-plugins.js.map +1 -0
- package/{dist/helpers → helpers}/config-as-json.d.ts +1 -1
- package/{dist/helpers → helpers}/config-as-json.js +7 -6
- package/helpers/config-as-json.js.map +1 -0
- package/helpers/css-platform-plugin.d.ts +10 -0
- package/helpers/css-platform-plugin.js +76 -0
- package/helpers/css-platform-plugin.js.map +1 -0
- package/helpers/css-tree.js +22 -0
- package/helpers/css-tree.js.map +1 -0
- package/{dist/helpers → helpers}/dynamic-import-plugin.js +8 -7
- package/helpers/dynamic-import-plugin.js.map +1 -0
- package/helpers/esbuild-platform-resolver.d.ts +14 -0
- package/helpers/esbuild-platform-resolver.js +93 -0
- package/helpers/esbuild-platform-resolver.js.map +1 -0
- package/{dist/helpers → helpers}/external-configs.js +2 -1
- package/helpers/external-configs.js.map +1 -0
- package/{dist/helpers → helpers}/flavor.d.ts +1 -0
- package/helpers/flavor.js +51 -0
- package/helpers/flavor.js.map +1 -0
- package/{dist/helpers → helpers}/global-defines.d.ts +11 -3
- package/helpers/global-defines.js +24 -0
- package/helpers/global-defines.js.map +1 -0
- package/helpers/logging.d.ts +13 -0
- package/helpers/logging.js +111 -0
- package/helpers/logging.js.map +1 -0
- package/helpers/main-entry.d.ts +10 -0
- package/helpers/main-entry.js +215 -0
- package/helpers/main-entry.js.map +1 -0
- package/{dist/helpers → helpers}/module-resolution.js +4 -3
- package/helpers/module-resolution.js.map +1 -0
- package/{dist/helpers → helpers}/module-runner-patch.d.ts +1 -1
- package/{dist/helpers → helpers}/module-runner-patch.js +10 -12
- package/helpers/module-runner-patch.js.map +1 -0
- package/helpers/nativeclass-transform.d.ts +7 -0
- package/helpers/nativeclass-transform.js +158 -0
- package/helpers/nativeclass-transform.js.map +1 -0
- package/helpers/nativeclass-transformer-plugin.d.ts +5 -0
- package/helpers/nativeclass-transformer-plugin.js +23 -0
- package/helpers/nativeclass-transformer-plugin.js.map +1 -0
- package/{dist/helpers → helpers}/nativescript-package-resolver.js +18 -17
- package/helpers/nativescript-package-resolver.js.map +1 -0
- package/{dist/helpers → helpers}/ns-cli-plugins.d.ts +6 -1
- package/{dist/helpers → helpers}/ns-cli-plugins.js +31 -51
- package/helpers/ns-cli-plugins.js.map +1 -0
- package/helpers/package-platform-aliases.d.ts +10 -0
- package/{dist/helpers → helpers}/package-platform-aliases.js +18 -22
- package/helpers/package-platform-aliases.js.map +1 -0
- package/helpers/postcss-platform-config.d.ts +13 -0
- package/helpers/postcss-platform-config.js +97 -0
- package/helpers/postcss-platform-config.js.map +1 -0
- package/helpers/prelink-angular.d.ts +2 -0
- package/helpers/prelink-angular.js +117 -0
- package/helpers/prelink-angular.js.map +1 -0
- package/helpers/preserve-imports.js +38 -0
- package/helpers/preserve-imports.js.map +1 -0
- package/{dist/helpers → helpers}/project.js +2 -4
- package/helpers/project.js.map +1 -0
- package/helpers/resolver.d.ts +4 -0
- package/{dist/helpers → helpers}/resolver.js +7 -6
- package/helpers/resolver.js.map +1 -0
- package/helpers/theme-core-plugins.d.ts +14 -0
- package/helpers/theme-core-plugins.js +121 -0
- package/helpers/theme-core-plugins.js.map +1 -0
- package/helpers/ts-config-paths.d.ts +10 -0
- package/{dist/helpers → helpers}/ts-config-paths.js +70 -71
- package/helpers/ts-config-paths.js.map +1 -0
- package/{dist/helpers → helpers}/utils.js +14 -27
- package/helpers/utils.js.map +1 -0
- package/{dist/helpers → helpers}/workers.js +15 -16
- package/helpers/workers.js.map +1 -0
- package/{dist/hmr → hmr/client}/css-handler.js +18 -17
- package/hmr/client/css-handler.js.map +1 -0
- package/hmr/client/index.d.ts +13 -0
- package/hmr/client/index.js +1550 -0
- package/hmr/client/index.js.map +1 -0
- package/hmr/client/utils.d.ts +38 -0
- package/hmr/client/utils.js +426 -0
- package/hmr/client/utils.js.map +1 -0
- package/hmr/entry-runtime.d.ts +8 -0
- package/hmr/entry-runtime.js +135 -0
- package/hmr/entry-runtime.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.d.ts +2 -0
- package/hmr/frameworks/angular/server/strategy.js +101 -0
- package/hmr/frameworks/angular/server/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +22 -0
- package/hmr/frameworks/vue/client/index.js +1537 -0
- package/hmr/frameworks/vue/client/index.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +11 -0
- package/hmr/frameworks/vue/server/compiler.js +26 -0
- package/hmr/frameworks/vue/server/compiler.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-transforms.d.ts +14 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js +282 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +2 -0
- package/hmr/frameworks/vue/server/strategy.js +273 -0
- package/hmr/frameworks/vue/server/strategy.js.map +1 -0
- package/hmr/helpers/ast-extract.d.ts +6 -0
- package/hmr/helpers/ast-extract.js +72 -0
- package/hmr/helpers/ast-extract.js.map +1 -0
- package/hmr/helpers/ast-normalizer.d.ts +7 -0
- package/hmr/helpers/ast-normalizer.js +772 -0
- package/hmr/helpers/ast-normalizer.js.map +1 -0
- package/hmr/helpers/babel.d.ts +3 -0
- package/hmr/helpers/babel.js +17 -0
- package/hmr/helpers/babel.js.map +1 -0
- package/hmr/helpers/sanitize.d.ts +6 -0
- package/hmr/helpers/sanitize.js +55 -0
- package/hmr/helpers/sanitize.js.map +1 -0
- package/hmr/helpers/vendor-rewrite.d.ts +1 -0
- package/hmr/helpers/vendor-rewrite.js +35 -0
- package/hmr/helpers/vendor-rewrite.js.map +1 -0
- package/hmr/server/compiler.d.ts +2 -0
- package/hmr/server/compiler.js +75 -0
- package/hmr/server/compiler.js.map +1 -0
- package/hmr/server/constants.d.ts +14 -0
- package/hmr/server/constants.js +23 -0
- package/hmr/server/constants.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +32 -0
- package/hmr/server/core-sanitize.js +134 -0
- package/hmr/server/core-sanitize.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +68 -0
- package/hmr/server/framework-strategy.js +2 -0
- package/hmr/server/framework-strategy.js.map +1 -0
- package/hmr/server/index.d.ts +5 -0
- package/hmr/server/index.js +19 -0
- package/hmr/server/index.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +5 -0
- package/{dist/hmr/plugins/plugin-vue.js → hmr/server/vite-plugin.js} +13 -15
- package/hmr/server/vite-plugin.js.map +1 -0
- package/hmr/server/websocket.d.ts +15 -0
- package/hmr/server/websocket.js +5528 -0
- package/hmr/server/websocket.js.map +1 -0
- package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
- package/hmr/shared/runtime/http-only-boot.js +107 -0
- package/hmr/shared/runtime/http-only-boot.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +142 -0
- package/hmr/shared/runtime/root-placeholder.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +134 -0
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +9 -0
- package/hmr/shared/vendor/manifest-loader.js +38 -0
- package/hmr/shared/vendor/manifest-loader.js.map +1 -0
- package/hmr/shared/vendor/manifest.d.ts +34 -0
- package/hmr/shared/vendor/manifest.js +787 -0
- package/hmr/shared/vendor/manifest.js.map +1 -0
- package/hmr/shared/vendor/registry.d.ts +9 -0
- package/hmr/shared/vendor/registry.js +62 -0
- package/hmr/shared/vendor/registry.js.map +1 -0
- package/hmr/vendor-bootstrap.d.ts +3 -0
- package/hmr/vendor-bootstrap.js +32 -0
- package/hmr/vendor-bootstrap.js.map +1 -0
- package/{dist/index.d.ts → index.d.ts} +2 -0
- package/{dist/index.js → index.js} +3 -0
- package/index.js.map +1 -0
- package/package.json +39 -31
- package/{dist/polyfills → polyfills}/mdn-data-at-rules.js +1 -0
- package/polyfills/mdn-data-at-rules.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-properties.js +1 -0
- package/polyfills/mdn-data-properties.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-syntaxes.js +1 -0
- package/polyfills/mdn-data-syntaxes.js.map +1 -0
- package/{dist/polyfills → polyfills}/module.js +1 -0
- package/polyfills/module.js.map +1 -0
- package/runtime/core-aliases-early.d.ts +1 -0
- package/runtime/core-aliases-early.js +334 -0
- package/runtime/core-aliases-early.js.map +1 -0
- package/shims/angular-animations-stub.d.ts +8 -0
- package/shims/angular-animations-stub.js +14 -0
- package/shims/angular-animations-stub.js.map +1 -0
- package/{dist/shims → shims}/node-module.js +3 -2
- package/shims/node-module.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler-constants.js +2 -1
- package/shims/react-reconciler-constants.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler.js +1 -0
- package/shims/react-reconciler.js.map +1 -0
- package/{dist/shims → shims}/set-value.js +5 -1
- package/shims/set-value.js.map +1 -0
- package/transformers/NativeClass/index.d.ts +2 -0
- package/transformers/NativeClass/index.js +222 -0
- package/transformers/NativeClass/index.js.map +1 -0
- package/dist/configuration/angular.js +0 -30
- package/dist/configuration/base.d.ts +0 -4
- package/dist/configuration/base.js +0 -386
- package/dist/configuration/vue.js +0 -45
- package/dist/helpers/css-tree.js +0 -21
- package/dist/helpers/flavor.js +0 -40
- package/dist/helpers/global-defines.js +0 -20
- package/dist/helpers/main-entry-hmr-includes.d.ts +0 -1
- package/dist/helpers/main-entry-hmr-includes.js +0 -18
- package/dist/helpers/main-entry.d.ts +0 -5
- package/dist/helpers/main-entry.js +0 -82
- package/dist/helpers/package-platform-aliases.d.ts +0 -4
- package/dist/helpers/preserve-imports.js +0 -19
- package/dist/helpers/resolver.d.ts +0 -4
- package/dist/helpers/ts-config-paths.d.ts +0 -4
- package/dist/hmr/client-vue.d.ts +0 -6
- package/dist/hmr/client-vue.js +0 -585
- package/dist/hmr/component-tracker.d.ts +0 -23
- package/dist/hmr/component-tracker.js +0 -193
- package/dist/hmr/message-handler.d.ts +0 -1
- package/dist/hmr/message-handler.js +0 -590
- package/dist/hmr/nsv-hooks.d.ts +0 -2
- package/dist/hmr/nsv-hooks.js +0 -481
- package/dist/hmr/plugins/index.d.ts +0 -1
- package/dist/hmr/plugins/index.js +0 -16
- package/dist/hmr/plugins/plugin-vue.d.ts +0 -2
- package/dist/hmr/plugins/websocket-vue.d.ts +0 -2
- package/dist/hmr/plugins/websocket-vue.js +0 -911
- package/dist/hmr/runtime-vue.d.ts +0 -13
- package/dist/hmr/runtime-vue.js +0 -2306
- package/dist/hmr/types.d.ts +0 -24
- package/dist/hmr/types.js +0 -2
- package/dist/transformers/NativeClass/index.d.ts +0 -5
- package/dist/transformers/NativeClass/index.js +0 -46
- /package/{dist/helpers → helpers}/commonjs-plugins.d.ts +0 -0
- /package/{dist/helpers → helpers}/css-tree.d.ts +0 -0
- /package/{dist/helpers → helpers}/dynamic-import-plugin.d.ts +0 -0
- /package/{dist/helpers → helpers}/external-configs.d.ts +0 -0
- /package/{dist/helpers → helpers}/module-resolution.d.ts +0 -0
- /package/{dist/helpers → helpers}/nativescript-package-resolver.d.ts +0 -0
- /package/{dist/helpers → helpers}/preserve-imports.d.ts +0 -0
- /package/{dist/helpers → helpers}/project.d.ts +0 -0
- /package/{dist/helpers → helpers}/utils.d.ts +0 -0
- /package/{dist/helpers → helpers}/workers.d.ts +0 -0
- /package/{dist/hmr → hmr/client}/css-handler.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-at-rules.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-properties.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-syntaxes.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/module.d.ts +0 -0
- /package/{dist/shims → shims}/node-module.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler-constants.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler.d.ts +0 -0
- /package/{dist/shims → shims}/set-value.d.ts +0 -0
package/dist/hmr/nsv-hooks.js
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
// NativeScript-Vue integration hooks for HMR in non-DOM/runtime-light environments
|
|
2
|
-
// - Monkey-patches nativescript-vue createApp to add a global mixin that tracks component instances
|
|
3
|
-
// - Captures the app and root instance for debugging and fallbacks
|
|
4
|
-
import componentTracker from './component-tracker';
|
|
5
|
-
const VERBOSE = true;
|
|
6
|
-
// Apply hooks immediately when this module loads
|
|
7
|
-
let hooksAttempted = false;
|
|
8
|
-
let hookRetryCount = 0;
|
|
9
|
-
const MAX_HOOK_RETRIES = 3; // Reduced from 10
|
|
10
|
-
let lastRetryTime = 0;
|
|
11
|
-
const RETRY_COOLDOWN = 1000; // 1 second cooldown between retries
|
|
12
|
-
// Function to attempt hook setup with smart retries
|
|
13
|
-
function attemptHookSetup() {
|
|
14
|
-
const now = Date.now();
|
|
15
|
-
const g = globalThis;
|
|
16
|
-
// Already applied successfully
|
|
17
|
-
if (g.__NS_VUE_HOOKS_APPLIED__)
|
|
18
|
-
return;
|
|
19
|
-
// Respect cooldown period
|
|
20
|
-
if (now - lastRetryTime < RETRY_COOLDOWN)
|
|
21
|
-
return;
|
|
22
|
-
// Max retries reached
|
|
23
|
-
if (hookRetryCount >= MAX_HOOK_RETRIES) {
|
|
24
|
-
if (VERBOSE && hookRetryCount === MAX_HOOK_RETRIES) {
|
|
25
|
-
console.info('[ns-hmr][nsv-hooks] Max retry attempts reached, switching to passive mode');
|
|
26
|
-
hookRetryCount++; // Prevent this message from repeating
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
hookRetryCount++;
|
|
31
|
-
lastRetryTime = now;
|
|
32
|
-
if (VERBOSE && hookRetryCount > 1) {
|
|
33
|
-
console.info('[ns-hmr][nsv-hooks] Retrying hook setup...', { attempt: hookRetryCount });
|
|
34
|
-
}
|
|
35
|
-
setupNativeScriptVueHooks();
|
|
36
|
-
}
|
|
37
|
-
export function setupNativeScriptVueHooks() {
|
|
38
|
-
try {
|
|
39
|
-
const g = globalThis;
|
|
40
|
-
if (g.__NS_VUE_HOOKS_APPLIED__)
|
|
41
|
-
return;
|
|
42
|
-
hooksAttempted = true;
|
|
43
|
-
// Check if app is already created (common in Vite/ES module environments)
|
|
44
|
-
const existingApp = g.__NS_VUE_APP__;
|
|
45
|
-
const existingRoot = g.__NS_VUE_ROOT_INSTANCE__;
|
|
46
|
-
if (existingApp) {
|
|
47
|
-
if (VERBOSE)
|
|
48
|
-
console.info('[ns-hmr][nsv-hooks] Found existing app, applying hooks retroactively');
|
|
49
|
-
retrofitExistingApp(existingApp);
|
|
50
|
-
g.__NS_VUE_HOOKS_APPLIED__ = true;
|
|
51
|
-
if (existingRoot) {
|
|
52
|
-
if (VERBOSE)
|
|
53
|
-
console.info('[ns-hmr][nsv-hooks] Found existing root instance, registering');
|
|
54
|
-
setTimeout(() => registerExistingInstancesWithRuntime(), 0);
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
// Debug: Let's see what's actually available
|
|
59
|
-
if (VERBOSE) {
|
|
60
|
-
console.info('[ns-hmr][nsv-hooks] Debug - Available globals:', {
|
|
61
|
-
hasRequire: !!(g.require),
|
|
62
|
-
hasGlobalRequire: !!globalThis.__require,
|
|
63
|
-
hasModuleRequire: typeof require !== 'undefined',
|
|
64
|
-
hasNSVueGlobal: !!(g.nativescriptVue || g.NativeScriptVue),
|
|
65
|
-
hasVueGlobal: !!g.Vue,
|
|
66
|
-
requireType: typeof g.require,
|
|
67
|
-
hasExistingApp: !!existingApp,
|
|
68
|
-
hasExistingRoot: !!existingRoot
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// Try multiple ways to get the module (for proactive hook setup)
|
|
72
|
-
let nsv = null;
|
|
73
|
-
// Method 1: Check global objects first (ES modules often expose via globals)
|
|
74
|
-
nsv = g.nativescriptVue || g.NativeScriptVue || g.Vue || g.__VUE__;
|
|
75
|
-
if (VERBOSE && nsv) {
|
|
76
|
-
console.info('[ns-hmr][nsv-hooks] Found Vue via global object');
|
|
77
|
-
}
|
|
78
|
-
// Method 2: Try require as fallback (may return empty object in ES modules)
|
|
79
|
-
if (!nsv) {
|
|
80
|
-
const req = g.require || globalThis.__require || (typeof require !== 'undefined' ? require : null);
|
|
81
|
-
if (req) {
|
|
82
|
-
const nsvModule = safeRequire('nativescript-vue');
|
|
83
|
-
const vueModule = safeRequire('vue');
|
|
84
|
-
// In ES modules mode, modules might be available but empty - check if they have real content
|
|
85
|
-
if (nsvModule && Object.keys(nsvModule).length > 0) {
|
|
86
|
-
nsv = nsvModule;
|
|
87
|
-
if (VERBOSE)
|
|
88
|
-
console.info('[ns-hmr][nsv-hooks] Found nativescript-vue via require with content');
|
|
89
|
-
}
|
|
90
|
-
else if (vueModule && Object.keys(vueModule).length > 0) {
|
|
91
|
-
nsv = vueModule;
|
|
92
|
-
if (VERBOSE)
|
|
93
|
-
console.info('[ns-hmr][nsv-hooks] Found vue via require with content');
|
|
94
|
-
}
|
|
95
|
-
else if (VERBOSE) {
|
|
96
|
-
console.info('[ns-hmr][nsv-hooks] require() available but modules empty (ES modules mode detected)');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!nsv) {
|
|
101
|
-
if (VERBOSE && hookRetryCount === 1) {
|
|
102
|
-
console.info('[ns-hmr][nsv-hooks] No nativescript-vue module available via any method - app likely uses ES imports');
|
|
103
|
-
console.info('[ns-hmr][nsv-hooks] Will wait for app to be created and then apply hooks retroactively');
|
|
104
|
-
}
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (VERBOSE) {
|
|
108
|
-
console.info('[ns-hmr][nsv-hooks] Found Vue module:', {
|
|
109
|
-
hasCreateApp: !!nsv.createApp,
|
|
110
|
-
hasSetRootApp: !!nsv.setRootApp,
|
|
111
|
-
moduleKeys: Object.keys(nsv).slice(0, 10)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
// In ES modules mode, Vue APIs might be distributed differently
|
|
115
|
-
let createAppFn = nsv.createApp;
|
|
116
|
-
if (!createAppFn) {
|
|
117
|
-
// Try to find createApp in various Vue-related globals
|
|
118
|
-
const vueGlobals = [g.Vue, g.__VUE__, g.nativescriptVue, g.NativeScriptVue];
|
|
119
|
-
for (const vueRef of vueGlobals) {
|
|
120
|
-
if (vueRef && vueRef.createApp) {
|
|
121
|
-
createAppFn = vueRef.createApp;
|
|
122
|
-
nsv = vueRef; // Use the Vue reference that has createApp
|
|
123
|
-
if (VERBOSE)
|
|
124
|
-
console.info('[ns-hmr][nsv-hooks] Found createApp in Vue global reference');
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (!createAppFn) {
|
|
130
|
-
if (VERBOSE)
|
|
131
|
-
console.info('[ns-hmr][nsv-hooks] No createApp function found in any Vue reference');
|
|
132
|
-
// In ES modules mode, we might need to wait for the app to be created
|
|
133
|
-
// Set up a fallback mechanism to apply hooks later
|
|
134
|
-
if (!g.__nsv_esModulesFallback) {
|
|
135
|
-
g.__nsv_esModulesFallback = true;
|
|
136
|
-
if (VERBOSE)
|
|
137
|
-
console.info('[ns-hmr][nsv-hooks] Setting up ES modules fallback for later hook application');
|
|
138
|
-
}
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
hookCreateApp(nsv);
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
if (VERBOSE)
|
|
145
|
-
console.info('[ns-hmr][nsv-hooks] Setup failed:', e?.message || String(e));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function hookCreateApp(nsv) {
|
|
149
|
-
try {
|
|
150
|
-
const g = globalThis;
|
|
151
|
-
if (g.__NS_VUE_HOOKS_APPLIED__)
|
|
152
|
-
return;
|
|
153
|
-
// Check if app already exists - if so, retrofit the hooks
|
|
154
|
-
const existingApp = g.__NS_VUE_APP__;
|
|
155
|
-
if (existingApp) {
|
|
156
|
-
if (VERBOSE)
|
|
157
|
-
console.info('[ns-hmr][nsv-hooks] Found existing app, retrofitting hooks');
|
|
158
|
-
retrofitExistingApp(existingApp);
|
|
159
|
-
}
|
|
160
|
-
// Also check for root instance and register it
|
|
161
|
-
const existingRoot = g.__NS_VUE_ROOT_INSTANCE__;
|
|
162
|
-
if (existingRoot) {
|
|
163
|
-
if (VERBOSE)
|
|
164
|
-
console.info('[ns-hmr][nsv-hooks] Found existing root instance, registering');
|
|
165
|
-
try {
|
|
166
|
-
registerExistingInstancesWithRuntime();
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
if (VERBOSE)
|
|
170
|
-
console.warn('[ns-hmr][nsv-hooks] Failed to register existing instances:', e?.message);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const originalCreateApp = nsv.createApp.bind(nsv);
|
|
174
|
-
const originalSetRootApp = typeof nsv.setRootApp === 'function' ? nsv.setRootApp.bind(nsv) : null;
|
|
175
|
-
// Capture setRootApp invocations for app access
|
|
176
|
-
if (originalSetRootApp) {
|
|
177
|
-
try {
|
|
178
|
-
nsv.setRootApp = (app) => {
|
|
179
|
-
try {
|
|
180
|
-
g.__NS_VUE_APP__ = app;
|
|
181
|
-
if (VERBOSE)
|
|
182
|
-
console.info('[ns-hmr][nsv-hooks] setRootApp called');
|
|
183
|
-
// Apply mixin to existing app if not already done
|
|
184
|
-
if (!app.__nsHmrMixinApplied) {
|
|
185
|
-
applyHmrMixin(app);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch { }
|
|
189
|
-
return originalSetRootApp(app);
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
catch { }
|
|
193
|
-
}
|
|
194
|
-
nsv.createApp = (...args) => {
|
|
195
|
-
const app = originalCreateApp(...args);
|
|
196
|
-
try {
|
|
197
|
-
g.__NS_VUE_APP__ = app;
|
|
198
|
-
if (VERBOSE)
|
|
199
|
-
console.info('[ns-hmr][nsv-hooks] Stored __NS_VUE_APP__');
|
|
200
|
-
}
|
|
201
|
-
catch { }
|
|
202
|
-
// Apply HMR mixin
|
|
203
|
-
applyHmrMixin(app);
|
|
204
|
-
// Capture the root instance on start
|
|
205
|
-
if (typeof app.start === 'function') {
|
|
206
|
-
const originalStart = app.start.bind(app);
|
|
207
|
-
app.start = (...sArgs) => {
|
|
208
|
-
const instance = originalStart(...sArgs);
|
|
209
|
-
try {
|
|
210
|
-
g.__NS_VUE_ROOT_INSTANCE__ = instance;
|
|
211
|
-
if (VERBOSE)
|
|
212
|
-
console.info('[ns-hmr][nsv-hooks] Root instance captured from start()');
|
|
213
|
-
// Register this instance and any children with HMR runtime
|
|
214
|
-
setTimeout(() => {
|
|
215
|
-
try {
|
|
216
|
-
registerExistingInstancesWithRuntime();
|
|
217
|
-
}
|
|
218
|
-
catch { }
|
|
219
|
-
}, 0);
|
|
220
|
-
}
|
|
221
|
-
catch { }
|
|
222
|
-
return instance;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
return app;
|
|
226
|
-
};
|
|
227
|
-
g.__NS_VUE_HOOKS_APPLIED__ = true;
|
|
228
|
-
if (VERBOSE)
|
|
229
|
-
console.info('[ns-hmr][nsv-hooks] Applied NativeScript-Vue hooks');
|
|
230
|
-
}
|
|
231
|
-
catch (e) {
|
|
232
|
-
if (VERBOSE)
|
|
233
|
-
console.info('[ns-hmr][nsv-hooks] Setup failed:', e?.message || String(e));
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
// Function to retrofit an existing app with HMR capabilities
|
|
237
|
-
function retrofitExistingApp(app) {
|
|
238
|
-
try {
|
|
239
|
-
if (app.__nsHmrMixinApplied)
|
|
240
|
-
return;
|
|
241
|
-
// Apply the HMR mixin to the existing app
|
|
242
|
-
applyHmrMixin(app);
|
|
243
|
-
if (VERBOSE)
|
|
244
|
-
console.info('[ns-hmr][nsv-hooks] Retrofitted existing app with HMR mixin');
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
if (VERBOSE)
|
|
248
|
-
console.warn('[ns-hmr][nsv-hooks] Failed to retrofit existing app:', e?.message);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// Function to apply the HMR tracking mixin
|
|
252
|
-
function applyHmrMixin(app) {
|
|
253
|
-
try {
|
|
254
|
-
if (app.__nsHmrMixinApplied)
|
|
255
|
-
return;
|
|
256
|
-
// Register a global mixin to track component instances
|
|
257
|
-
app.mixin({
|
|
258
|
-
mounted() {
|
|
259
|
-
try {
|
|
260
|
-
const id = this?.$?.type?.__file || this?.type?.__file || (this?.$?.uid ? String(this.$.uid) : undefined);
|
|
261
|
-
const key = id || (this?.$?.type?.name) || 'unknown';
|
|
262
|
-
componentTracker.registerComponent(key, this);
|
|
263
|
-
if (VERBOSE)
|
|
264
|
-
console.info('[ns-hmr][nsv-hooks] Component mounted:', {
|
|
265
|
-
key,
|
|
266
|
-
hasType: !!(this?.$?.type || this?.type),
|
|
267
|
-
hasFile: !!(this?.$?.type?.__file || this?.type?.__file),
|
|
268
|
-
typeName: (this?.$?.type?.name || this?.type?.name)
|
|
269
|
-
});
|
|
270
|
-
// Also attempt to register this instance with Vue's HMR runtime so rerenders reach it
|
|
271
|
-
try {
|
|
272
|
-
const rt = globalThis.__VUE_HMR_RUNTIME__;
|
|
273
|
-
if (rt && typeof rt.registerInstance === 'function') {
|
|
274
|
-
const variants = computeIdVariants(key);
|
|
275
|
-
for (const vid of variants) {
|
|
276
|
-
try {
|
|
277
|
-
if (!rt.isRecorded || !rt.isRecorded(vid)) {
|
|
278
|
-
if (typeof rt.createRecord === 'function')
|
|
279
|
-
rt.createRecord(vid, (this?.$?.type || this?.type || {}));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
catch { }
|
|
283
|
-
try {
|
|
284
|
-
rt.registerInstance(vid, this);
|
|
285
|
-
}
|
|
286
|
-
catch { }
|
|
287
|
-
}
|
|
288
|
-
if (VERBOSE)
|
|
289
|
-
console.info('[ns-hmr][nsv-hooks] registered instance with HMR runtime', { file: key, ids: Array.from(variants) });
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch { }
|
|
293
|
-
}
|
|
294
|
-
catch { }
|
|
295
|
-
},
|
|
296
|
-
unmounted() {
|
|
297
|
-
try {
|
|
298
|
-
const id = this?.$?.type?.__file || this?.type?.__file || (this?.$?.uid ? String(this.$.uid) : undefined);
|
|
299
|
-
const key = id || (this?.$?.type?.name) || 'unknown';
|
|
300
|
-
componentTracker.unregisterComponent(key, this);
|
|
301
|
-
if (VERBOSE)
|
|
302
|
-
console.info('[ns-hmr][nsv-hooks] Component unmounted:', key);
|
|
303
|
-
}
|
|
304
|
-
catch { }
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
app.__nsHmrMixinApplied = true;
|
|
308
|
-
}
|
|
309
|
-
catch (e) {
|
|
310
|
-
if (VERBOSE)
|
|
311
|
-
console.info('[ns-hmr][nsv-hooks] Failed to apply HMR mixin:', e?.message || String(e));
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function safeRequire(name) {
|
|
315
|
-
try {
|
|
316
|
-
// Try global require first
|
|
317
|
-
const globalReq = globalThis.require;
|
|
318
|
-
if (globalReq) {
|
|
319
|
-
try {
|
|
320
|
-
const result = globalReq(name);
|
|
321
|
-
if (VERBOSE)
|
|
322
|
-
console.info(`[ns-hmr][nsv-hooks] Successfully required '${name}' via global.require`);
|
|
323
|
-
return result;
|
|
324
|
-
}
|
|
325
|
-
catch (e) {
|
|
326
|
-
if (VERBOSE)
|
|
327
|
-
console.info(`[ns-hmr][nsv-hooks] Failed to require '${name}' via global.require:`, e?.message);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
// Try standard require if available
|
|
331
|
-
if (typeof require !== 'undefined') {
|
|
332
|
-
try {
|
|
333
|
-
const result = require(name);
|
|
334
|
-
if (VERBOSE)
|
|
335
|
-
console.info(`[ns-hmr][nsv-hooks] Successfully required '${name}' via standard require`);
|
|
336
|
-
return result;
|
|
337
|
-
}
|
|
338
|
-
catch (e) {
|
|
339
|
-
if (VERBOSE)
|
|
340
|
-
console.info(`[ns-hmr][nsv-hooks] Failed to require '${name}' via standard require:`, e?.message);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
// Try alternative require locations
|
|
344
|
-
const altReq = globalThis.__require || globalThis.global?.require;
|
|
345
|
-
if (altReq) {
|
|
346
|
-
try {
|
|
347
|
-
const result = altReq(name);
|
|
348
|
-
if (VERBOSE)
|
|
349
|
-
console.info(`[ns-hmr][nsv-hooks] Successfully required '${name}' via alternative require`);
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
catch (e) {
|
|
353
|
-
if (VERBOSE)
|
|
354
|
-
console.info(`[ns-hmr][nsv-hooks] Failed to require '${name}' via alternative require:`, e?.message);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
catch (e) {
|
|
359
|
-
if (VERBOSE)
|
|
360
|
-
console.info(`[ns-hmr][nsv-hooks] safeRequire('${name}') failed completely:`, e?.message);
|
|
361
|
-
}
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
// Attempt to apply hooks immediately when this module loads
|
|
365
|
-
// This ensures hooks are applied before createApp is called
|
|
366
|
-
try {
|
|
367
|
-
setupNativeScriptVueHooks();
|
|
368
|
-
}
|
|
369
|
-
catch (e) {
|
|
370
|
-
if (VERBOSE)
|
|
371
|
-
console.info('[ns-hmr][nsv-hooks] Initial hook setup failed:', e?.message);
|
|
372
|
-
}
|
|
373
|
-
export default setupNativeScriptVueHooks;
|
|
374
|
-
// Helpers
|
|
375
|
-
function computeIdVariants(raw) {
|
|
376
|
-
const out = new Set();
|
|
377
|
-
try {
|
|
378
|
-
if (!raw)
|
|
379
|
-
return out;
|
|
380
|
-
let s = String(raw);
|
|
381
|
-
// prefer source file path if available on component type
|
|
382
|
-
// normalize slashes and strip query
|
|
383
|
-
s = s.replace(/\\/g, '/');
|
|
384
|
-
const noQuery = s.split('?')[0];
|
|
385
|
-
const withVueQ = noQuery + (noQuery.endsWith('?vue') ? '' : '?vue');
|
|
386
|
-
const relFromSrc = noQuery.replace(/^.*?\/src\//, '/src/');
|
|
387
|
-
const relNoLead = relFromSrc.replace(/^\//, '');
|
|
388
|
-
out.add(s);
|
|
389
|
-
out.add(noQuery);
|
|
390
|
-
out.add(withVueQ);
|
|
391
|
-
out.add(relFromSrc);
|
|
392
|
-
out.add(relNoLead);
|
|
393
|
-
if (!relNoLead.endsWith('?vue'))
|
|
394
|
-
out.add(relNoLead + '?vue');
|
|
395
|
-
}
|
|
396
|
-
catch { }
|
|
397
|
-
return out;
|
|
398
|
-
}
|
|
399
|
-
function registerExistingInstancesWithRuntime() {
|
|
400
|
-
try {
|
|
401
|
-
const g = globalThis;
|
|
402
|
-
const rt = g.__VUE_HMR_RUNTIME__;
|
|
403
|
-
if (!rt || (typeof rt.registerInstance !== 'function'))
|
|
404
|
-
return;
|
|
405
|
-
const root = g.__NS_VUE_ROOT_INSTANCE__;
|
|
406
|
-
if (!root)
|
|
407
|
-
return;
|
|
408
|
-
let count = 0;
|
|
409
|
-
const seen = new Set();
|
|
410
|
-
const queue = [root];
|
|
411
|
-
const enqueueChildren = (node) => {
|
|
412
|
-
try {
|
|
413
|
-
if (!node || seen.has(node))
|
|
414
|
-
return;
|
|
415
|
-
seen.add(node);
|
|
416
|
-
const internal = (node.$ ? node.$ : node);
|
|
417
|
-
if (internal?.subTree)
|
|
418
|
-
queue.push(internal.subTree);
|
|
419
|
-
if (node && typeof node === 'object') {
|
|
420
|
-
if (node.component)
|
|
421
|
-
queue.push(node.component);
|
|
422
|
-
const ch = node.children || node.child || null;
|
|
423
|
-
if (Array.isArray(ch))
|
|
424
|
-
ch.forEach((c) => { if (c && typeof c === 'object')
|
|
425
|
-
queue.push(c); });
|
|
426
|
-
else if (ch && typeof ch === 'object')
|
|
427
|
-
queue.push(ch);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
catch { }
|
|
431
|
-
};
|
|
432
|
-
const handle = (ins) => {
|
|
433
|
-
try {
|
|
434
|
-
const type = (ins?.$?.type) || ins?.type || null;
|
|
435
|
-
const file = (type && type.__file) ? String(type.__file) : undefined;
|
|
436
|
-
const name = (type && (type.__name || type.name)) ? String(type.__name || type.name) : undefined;
|
|
437
|
-
const key = file || name;
|
|
438
|
-
if (!key)
|
|
439
|
-
return;
|
|
440
|
-
const variants = computeIdVariants(key);
|
|
441
|
-
variants.forEach((vid) => {
|
|
442
|
-
try {
|
|
443
|
-
if (!rt.isRecorded || !rt.isRecorded(vid)) {
|
|
444
|
-
if (typeof rt.createRecord === 'function')
|
|
445
|
-
rt.createRecord(vid, type || {});
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
catch { }
|
|
449
|
-
try {
|
|
450
|
-
rt.registerInstance(vid, ins);
|
|
451
|
-
}
|
|
452
|
-
catch { }
|
|
453
|
-
});
|
|
454
|
-
count++;
|
|
455
|
-
}
|
|
456
|
-
catch { }
|
|
457
|
-
};
|
|
458
|
-
while (queue.length) {
|
|
459
|
-
const cur = queue.shift();
|
|
460
|
-
try {
|
|
461
|
-
handle(cur);
|
|
462
|
-
}
|
|
463
|
-
catch { }
|
|
464
|
-
try {
|
|
465
|
-
enqueueChildren(cur);
|
|
466
|
-
}
|
|
467
|
-
catch { }
|
|
468
|
-
}
|
|
469
|
-
try {
|
|
470
|
-
if (VERBOSE)
|
|
471
|
-
console.info('[ns-hmr][nsv-hooks] registered existing instances with HMR runtime', { count });
|
|
472
|
-
}
|
|
473
|
-
catch { }
|
|
474
|
-
}
|
|
475
|
-
catch { }
|
|
476
|
-
}
|
|
477
|
-
// Actually execute the hooks setup as early as possible
|
|
478
|
-
console.info('[ns-hmr][nsv-hooks] Initializing hooks...');
|
|
479
|
-
attemptHookSetup();
|
|
480
|
-
// Export to global for external triggers
|
|
481
|
-
globalThis.__ns_attemptHookSetup = attemptHookSetup;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getHMRPlugins(platform: string, flavor: string, verboseLogs: boolean): import("vite").Plugin<any>[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { hmrPluginVue } from "./plugin-vue.js";
|
|
2
|
-
import { hmrWebSocketVue } from "./websocket-vue.js";
|
|
3
|
-
export function getHMRPlugins(platform, flavor, verboseLogs) {
|
|
4
|
-
switch (flavor) {
|
|
5
|
-
case "vue":
|
|
6
|
-
return [hmrPluginVue(platform, verboseLogs), hmrWebSocketVue()];
|
|
7
|
-
case "react":
|
|
8
|
-
return []; // TODO: add React HMR plugins
|
|
9
|
-
case "angular":
|
|
10
|
-
return []; // TODO: add Angular HMR plugins
|
|
11
|
-
case "solid":
|
|
12
|
-
return []; // TODO: add Solid HMR plugins
|
|
13
|
-
default:
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
}
|