Add prettier. Format.

This commit is contained in:
2026-07-22 02:12:05 +00:00
parent d28b09dc21
commit 18baa96848
45 changed files with 4520 additions and 2613 deletions
+46 -38
View File
@@ -1,66 +1,74 @@
import { ref } from 'vue'
import { ref } from "vue";
import {
createNativeNavigationProfiler,
type NativeNavigationProfiler,
type NativeProfilerReport,
type NativeRouterRuntime,
} from '@native-vue-router/core'
import { pwaBuildId } from './pwa'
} from "@native-vue-router/core";
import { pwaBuildId } from "./pwa";
let profiler: NativeNavigationProfiler | undefined
export const profilerRecording = ref(false)
export const profilerHasCapture = ref(false)
let profiler: NativeNavigationProfiler | undefined;
export const profilerRecording = ref(false);
export const profilerHasCapture = ref(false);
function instance(runtime: NativeRouterRuntime) {
profiler ??= createNativeNavigationProfiler(runtime, {
metadata: { app: 'nvr-messenger-demo', build: pwaBuildId },
})
return profiler
metadata: { app: "nvr-messenger-demo", build: pwaBuildId },
});
return profiler;
}
export function startDemoProfile(runtime: NativeRouterRuntime) {
const active = instance(runtime)
active.start()
profilerRecording.value = true
profilerHasCapture.value = true
const active = instance(runtime);
active.start();
profilerRecording.value = true;
profilerHasCapture.value = true;
}
export function stopDemoProfile(runtime: NativeRouterRuntime) {
const report = instance(runtime).stop()
profilerRecording.value = false
return report
const report = instance(runtime).stop();
profilerRecording.value = false;
return report;
}
export function snapshotDemoProfile(runtime: NativeRouterRuntime) {
return instance(runtime).snapshot()
return instance(runtime).snapshot();
}
export async function shareDemoProfile(runtime: NativeRouterRuntime, report?: NativeProfilerReport) {
const active = instance(runtime)
const current = report ?? (profilerRecording.value ? stopDemoProfile(runtime) : active.snapshot())
const json = active.toJSON(current)
const stamp = new Date().toISOString().replaceAll(':', '-').replaceAll('.', '-')
const filename = `native-vue-router-profile-${stamp}.json`
const file = new File([json], filename, { type: 'application/json' })
export async function shareDemoProfile(
runtime: NativeRouterRuntime,
report?: NativeProfilerReport,
) {
const active = instance(runtime);
const current =
report ??
(profilerRecording.value ? stopDemoProfile(runtime) : active.snapshot());
const json = active.toJSON(current);
const stamp = new Date()
.toISOString()
.replaceAll(":", "-")
.replaceAll(".", "-");
const filename = `native-vue-router-profile-${stamp}.json`;
const file = new File([json], filename, { type: "application/json" });
const shareNavigator = navigator as Navigator & {
canShare?: (data: ShareData) => boolean
share?: (data: ShareData) => Promise<void>
}
canShare?: (data: ShareData) => boolean;
share?: (data: ShareData) => Promise<void>;
};
if (shareNavigator.share && shareNavigator.canShare?.({ files: [file] })) {
await shareNavigator.share({
title: 'Native Vue Router performance profile',
text: 'Frame pacing and navigation diagnostics. Route params and query values are omitted.',
title: "Native Vue Router performance profile",
text: "Frame pacing and navigation diagnostics. Route params and query values are omitted.",
files: [file],
})
return { report: current, method: 'shared' as const }
});
return { report: current, method: "shared" as const };
}
const url = URL.createObjectURL(file)
const link = document.createElement('a')
link.href = url
link.download = filename
link.click()
window.setTimeout(() => URL.revokeObjectURL(url), 1_000)
return { report: current, method: 'downloaded' as const }
const url = URL.createObjectURL(file);
const link = document.createElement("a");
link.href = url;
link.download = filename;
link.click();
window.setTimeout(() => URL.revokeObjectURL(url), 1_000);
return { report: current, method: "downloaded" as const };
}