Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
NoSleep is a Nuxt 3 web application that prevents computers and mobile devices from going to sleep using the browser's Screen Wake Lock API. It features a timer system, Picture-in-Picture support, and cross-window state synchronization.
npm run dev # Start dev server on http://localhost:3000 npm run build # Build for production npm run preview # Preview production build npm install # Install dependencies npm run postinstall # Run Nuxt prepare (auto-runs after install)
npm run lint # Run ESLint on all files npm run typecheck # Run TypeScript type checking npm run test # Run Vitest tests
The app uses Pinia for centralized state management in
stores/wakeLock.ts. This is the single source of truth for all wake lock state, timer state, and PiP (Picture-in-Picture) window management.
Key Principle: The
useWakeLock() composable in composables/useWakeLock.ts is a thin wrapper that returns the Pinia store. All components should use this composable, which handles lifecycle hooks (onMounted/onUnmounted) automatically.
navigator.wakeLock.request('screen') APIisActive, wakeLock sentinel, timer state, PiP window refsThe app uses the Document Picture-in-Picture API (
useDocumentPiP.ts) for always-on-top floating windows. There is no fallback — if the API is unsupported, the PiP button is hidden.
Cross-Window Communication:
postMessage APIisIframePip flag)useDocumentPiP.ts forwards messages between main window ↔ PiP window ↔ iframesyncWakeLockState() broadcasts state changes to connected windowsState Synchronization Rules:
isParentWithActivePip computed)Timer is managed entirely in the Pinia store:
startTimer(minutes): Acquires wake lock + starts countdown intervalremainingTime every second, syncs to PiPstopTimer(): Clears interval, resets stateuseAnalytics.ts composable tracks events to Google Analytics (via nuxt-gtag).
Events tracked include: wake lock acquire/release, timer actions, PiP window operations.
composables/useWakeLock.ts: Main composable, wraps Pinia store with lifecyclecomposables/useDocumentPiP.ts: Document PiP API management + message relaycomposables/useAnalytics.ts: Analytics tracking (GA via nuxt-gtag)composables/useWakeLockUI.ts: UI-specific logic (toggle/timer handlers, button state and styling)stores/wakeLock.ts: Central state management - all wake lock, timer, and PiP state lives hereWakeLockControl.vue: Main toggle button componentTimerControl.vue: Timer input and countdown displayStatusAnimation.vue: Lottie sun/moon animationsFloatingWindowCTA.vue: PiP window launch buttonDarkModeToggle.vue: Theme switcherpages/index.vue: Main application pagepages/pip.vue: PiP iframe content page (loaded inside Document PiP window with ?pip=1)The app requires the Screen Wake Lock API. Browsers without support see an error message prompting upgrade. Check for support:
'wakeLock' in navigator
Optional Document PiP API enhances UX. If unsupported, the PiP button is hidden.
Configured in
nuxt.config.ts:
en (English)en-US, zh-HK, ja-JPi18n/locales/*.jsonprefix_and_default (e.g., /en/, /zh/, default /)Tests use Vitest with
@nuxt/test-utils. Configuration in vitest.config.ts.
package.json engine)dark class), uses @nuxtjs/color-mode