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

Function attachDiagnosticsToFrame

packages/vite/hmr/client/utils.ts:333–373  ·  view source on GitHub ↗
(frame: any)

Source from the content-addressed store, hash-verified

331}
332
333export function attachDiagnosticsToFrame(frame: any) {
334 if (!__NS_ENV_VERBOSE__ || !frame) return;
335 try {
336 if ((frame as any).__ns_diag_attached__) return;
337 (frame as any).__ns_diag_attached__ = true;
338 const safeOn = (v: any, evt: string, cb: Function) => {
339 try {
340 v?.on?.(evt as any, cb as any);
341 } catch {}
342 };
343 const logEvt = (name: string) => (args: any) => {
344 try {
345 const page = (args && (args.object?.currentPage || args.object?._currentEntry?.resolvedPage)) || args?.object || null;
346 const pageCtor = String(page?.constructor?.name || '').replace(/^_+/, '');
347 const tag = (page as any)?.__ns_hmr_tag || (page as any)?.__ns_diag_tag;
348 console.log('[diag][frame]', name, {
349 frameCtor: frame?.constructor?.name,
350 pageCtor,
351 tag,
352 backstackDepth: (frame as any)?._backStack?.length || 0,
353 });
354 } catch {}
355 };
356 safeOn(frame, 'navigatingTo', logEvt('navigatingTo'));
357 safeOn(frame, 'navigatedTo', logEvt('navigatedTo'));
358 safeOn(frame, 'navigatingFrom', logEvt('navigatingFrom'));
359 safeOn(frame, 'navigatedFrom', logEvt('navigatedFrom'));
360 safeOn(frame, 'loaded', () => {
361 try {
362 console.log('[diag][frame] loaded', { ctor: frame?.constructor?.name });
363 } catch {}
364 });
365 safeOn(frame, 'unloaded', () => {
366 try {
367 console.log('[diag][frame] unloaded', {
368 ctor: frame?.constructor?.name,
369 });
370 } catch {}
371 });
372 } catch {}
373}
374
375export function logUiSnapshot(reason: string) {
376 try {

Callers 3

__nsNavigateUsingAppFunction · 0.85
performResetRootFunction · 0.85
getRootForVueFunction · 0.85

Calls 3

safeOnFunction · 0.85
logEvtFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected