MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / installDeepDiagnostics

Function installDeepDiagnostics

packages/vite/hmr/client/index.ts:207–279  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

205}
206
207function installDeepDiagnostics() {
208 if (!VERBOSE) return;
209 const g: any = globalThis as any;
210 try {
211 // Patch Frame.navigate to log calls and a short stack
212 const F = getCore('Frame') || g.Frame;
213 if (F?.prototype && !(F.prototype as any).__ns_diag_nav__) {
214 const orig = F.prototype.navigate;
215 if (typeof orig === 'function') {
216 (F.prototype as any).__ns_diag_nav__ = true;
217 // Simple duplicate navigation suppression in dev: if the same target is navigated twice within a short window, ignore the 2nd.
218 F.prototype.navigate = function (...args: any[]) {
219 try {
220 const entry = args[0];
221 const summary = summarizeNavEntry(entry);
222 const stack = (new Error().stack || '').split('\n').slice(2, 8).join('\n');
223 console.log('[diag][Frame.navigate]', {
224 frameCtor: this?.constructor?.name,
225 summary,
226 stack,
227 });
228 try {
229 const gAny: any = globalThis as any;
230 const key = JSON.stringify({
231 k: 'nav',
232 m: summary.moduleName || '',
233 c: !!summary.hasCreate,
234 ch: !!summary.clearHistory,
235 a: !!summary.animated,
236 });
237 const now = Date.now();
238 const last = gAny.__NS_DIAG_LAST_NAV__;
239 if (last && last.key === key && now - last.t < 300) {
240 console.warn('[diag][Frame.navigate] duplicate nav suppressed (dev)', { withinMs: now - last.t, key });
241 return; // suppress duplicate
242 }
243 gAny.__NS_DIAG_LAST_NAV__ = { key, t: now };
244 } catch {}
245 } catch {}
246 return orig.apply(this, args as any);
247 } as any;
248 }
249 }
250 } catch {}
251 try {
252 // Wrap Application.resetRootView to log argument classification and stack
253 const App = getCore('Application') || g.Application;
254 const proto = App && Object.getPrototypeOf(App);
255 const orig = (App && App.resetRootView) || (proto && proto.resetRootView);
256 if (typeof orig === 'function' && !(g as any).__NS_DIAG_RESET_WRAPPED__) {
257 const wrapped = function __ns_diag_resetRootView(this: any, entry: any) {
258 try {
259 const classification = classifyResetArg(entry);
260 const stack = (new Error().stack || '').split('\n').slice(2, 8).join('\n');
261 console.log('[diag][Application.resetRootView]', {
262 classification,
263 stack,
264 });

Callers 1

index.tsFile · 0.85

Calls 9

summarizeNavEntryFunction · 0.85
classifyResetArgFunction · 0.85
joinMethod · 0.80
warnMethod · 0.80
getCoreFunction · 0.70
sliceMethod · 0.45
logMethod · 0.45
applyMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected