@adminide-stack/yantra-mobile 12.0.149-alpha.2 → 12.0.149
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/lib/features/apps/mobileAppCatalog.js +2 -2
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/devices/bodyComposition.js +116 -0
- package/lib/features/devices/bodyComposition.js.map +1 -0
- package/lib/features/devices/readings.js.map +1 -1
- package/lib/features/devices/session.js +22 -2
- package/lib/features/devices/session.js.map +1 -1
- package/lib/features/dictate/DictateExperience.js +125 -8
- package/lib/features/dictate/DictateExperience.js.map +1 -1
- package/lib/features/dictate/components/DictationList.js +4 -4
- package/lib/features/dictate/components/DictationList.js.map +1 -1
- package/lib/features/dictate/components/NoteChat.js +272 -0
- package/lib/features/dictate/components/NoteChat.js.map +1 -0
- package/lib/features/dictate/components/NoteView.js +219 -86
- package/lib/features/dictate/components/NoteView.js.map +1 -1
- package/lib/features/dictate/components/Redacted.js +19 -0
- package/lib/features/dictate/components/Redacted.js.map +1 -0
- package/lib/features/dictate/dictateClient.js +177 -90
- package/lib/features/dictate/dictateClient.js.map +1 -1
- package/lib/features/dictate/dictationStore.js +2 -2
- package/lib/features/dictate/dictationStore.js.map +1 -1
- package/lib/features/dictate/kinds.js +76 -0
- package/lib/features/dictate/kinds.js.map +1 -0
- package/lib/features/dictate/noteShape.js +132 -0
- package/lib/features/dictate/noteShape.js.map +1 -0
- package/lib/features/dictate/noteText.js +8 -17
- package/lib/features/dictate/noteText.js.map +1 -1
- package/lib/features/dictate/privacy.js +68 -8
- package/lib/features/dictate/privacy.js.map +1 -1
- package/lib/features/dictate/shownNote.js +18 -9
- package/lib/features/dictate/shownNote.js.map +1 -1
- package/lib/screens/Devices/index.js +205 -3
- package/lib/screens/Devices/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -291,8 +291,8 @@ const MOBILE_APP_CATALOG = [
|
|
|
291
291
|
label: "Dictate",
|
|
292
292
|
icon: "microphone-outline",
|
|
293
293
|
group: "Office",
|
|
294
|
-
prompt: "Turn
|
|
295
|
-
//
|
|
294
|
+
prompt: "Turn what I say into notes: a class, a meeting, an idea or a patient visit.",
|
|
295
|
+
// Anyone speaks - a class, a meeting, an idea, a story, a visit - and gets the notes that fit it.
|
|
296
296
|
nativeRoute: "dictate-native"
|
|
297
297
|
},
|
|
298
298
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobileAppCatalog.js","sources":["../../../src/features/apps/mobileAppCatalog.ts"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport type { MaterialCommunityIcons } from '@expo/vector-icons';\n\ntype IconName = ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport type AppGroupId = 'Create' | 'Office' | 'Automate' | 'Sell' | 'Money' | 'Team' | 'More';\n\nexport type MobileAppItem = {\n key: string;\n label: string;\n icon: IconName;\n group: AppGroupId;\n /** Prompt sent as the first chat turn when the app has no native screen. */\n prompt: string;\n /**\n * Which surface host opens this app, if it has one. `webbuilder` is the\n * historical name of the shared WebView surface shell (`screens/WebBuilder`),\n * which is not web-builder-specific: it takes a `url` route param, mints the\n * system token, injects the bridge + cdecli token, stamps `embed=mobile` and\n * owns the timeout/retry UI. Anything with a deployed surface SPA can use it.\n */\n nativeRoute?:\n | 'webbuilder'\n | 'canvas-native'\n | 'characters-native'\n | 'chat-native'\n | 'billing-native'\n | 'shopping-native'\n | 'travel-native'\n | 'job-search-native'\n | 'resume-native'\n | 'inbox-native'\n | 'study-native'\n | 'local-services-native'\n | 'movies-native'\n | 'expenses-native'\n | 'dictate-native'\n | 'webbuilder-native'\n | 'design-native';\n /**\n * Deployed surface SPA for this app, as the `<slug>-surface` name. Resolved\n * against SURFACE_URL_TEMPLATE so one env var covers every surface and stays\n * per-environment, instead of 20+ near-identical URLs in eas.json.\n *\n * The slug is the SURFACE's name, which is not always the tile key\n * (issue-ticket -> issues, shop -> shopping, notebook -> notebooklm).\n */\n surfaceSlug?: string;\n /**\n * Explicit env override, for the surfaces people actually run locally\n * (design 5174, canvas 5175, webbuilder). Wins over `surfaceSlug`.\n */\n surfaceUrlKey?: 'WEB_BUILDER_URL' | 'CANVAS_SURFACE_URL' | 'DESIGN_SURFACE_URL';\n /**\n * Key of the web tile this native tile replaces in every launcher list.\n * The web entry stays in the catalog (deep links, tests, the WebView\n * lane) but users see one tile per app, the native one, under the\n * shared name. Also the key of a retired tile this one took over from\n * (Posters for Paper 2 Poster). Either way a favorite pinned under the\n * old key carries over to this tile.\n */\n supersedes?: string;\n /**\n * Account chrome, not a product app. Stays in the catalog so drawer /\n * deep-link routing still knows the native host, but never appears as\n * a tile in Apps or the Apps menu.\n */\n hideInLauncher?: boolean;\n};\n\n/**\n * Mobile Apps launcher. Labels, groups, and prompts stay in lockstep with the\n * browser ChatTopBar Apps menu (`packages-modules/account/browser`).\n */\nexport const MOBILE_APP_CATALOG: readonly MobileAppItem[] = [\n {\n key: 'design',\n label: 'Design',\n icon: 'palette-outline',\n group: 'Create',\n prompt: 'Design a 10-slide pitch deck for a coffee subscription startup',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'DESIGN_SURFACE_URL',\n surfaceSlug: 'design',\n },\n {\n key: 'design-native',\n label: 'Design',\n supersedes: 'design',\n icon: 'palette-outline',\n group: 'Create',\n prompt: 'Design a 10-slide pitch deck for a coffee subscription startup',\n // The native design studio (features/design): templates, saved designs and the\n // editor, drawn natively over the same designs as the web Design Studio. No WebView.\n nativeRoute: 'design-native',\n },\n {\n key: 'canvas',\n label: 'Canvas',\n icon: 'view-grid-outline',\n group: 'Create',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'CANVAS_SURFACE_URL',\n surfaceSlug: 'canvas',\n },\n {\n key: 'canvas-native',\n label: 'Canvas',\n supersedes: 'canvas',\n icon: 'vector-square',\n group: 'Create',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n // Renders through Module Federation: the viewer downloads from the\n // canvas-surface origin on open. First native surface; the classic\n // Canvas tile keeps the full web editor in the WebView host.\n nativeRoute: 'canvas-native',\n },\n {\n key: 'webbuilder',\n label: 'Web Builder',\n icon: 'application-outline',\n group: 'Create',\n prompt: 'Build a landing page for my bakery with a menu and a contact form',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'WEB_BUILDER_URL',\n surfaceSlug: 'webbuilder',\n },\n {\n key: 'webbuilder-native',\n label: 'Web Builder',\n supersedes: 'webbuilder',\n icon: 'application-outline',\n group: 'Create',\n prompt: 'Build a landing page for my bakery with a menu and a contact form',\n // Native web builder over the same projects as the web surface: your sites,\n // build and edit with the agent, live preview, versions, publish.\n nativeRoute: 'webbuilder-native',\n },\n {\n key: 'codezen',\n label: 'Codezen',\n icon: 'code-braces',\n group: 'Create',\n prompt: 'Clone my repository and fix the failing test',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'codezen',\n },\n {\n key: 'character',\n label: 'Characters',\n icon: 'drama-masks',\n group: 'Create',\n prompt: 'Create a stoic philosophy mentor character I can chat with',\n // Native federated experience (gallery -> detail -> chat); the web\n // surface remains reachable through the surface lane if ever needed.\n nativeRoute: 'characters-native',\n surfaceSlug: 'character',\n },\n {\n key: 'characters-native',\n label: 'Characters',\n supersedes: 'character',\n icon: 'account-star',\n group: 'Create',\n prompt: 'Show me characters I can chat with.',\n nativeRoute: 'characters-native',\n surfaceSlug: 'character',\n },\n // Word, Excel, PowerPoint and PDF files, pictures, interface designs and research posters,\n // each in its own browser editor (yantra-office).\n {\n key: 'word',\n label: 'Documents',\n icon: 'file-document-outline',\n group: 'Office',\n prompt: 'Write a one-page project proposal as a Word document',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'word',\n },\n {\n key: 'excel',\n label: 'Spreadsheets',\n icon: 'file-table-outline',\n group: 'Office',\n prompt: 'Make a monthly budget spreadsheet with totals and a chart',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'excel',\n },\n {\n key: 'presentation',\n label: 'Presentations',\n icon: 'presentation',\n group: 'Office',\n prompt: 'Turn my notes into a six-slide project update deck',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'presentation',\n },\n {\n key: 'pdf',\n label: 'PDFs',\n icon: 'file-pdf-box',\n group: 'Office',\n prompt: 'Make a one-page PDF checklist for moving house',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'pdf',\n },\n {\n key: 'photo',\n label: 'Photos',\n icon: 'image-edit-outline',\n group: 'Office',\n prompt: 'Make an Instagram post from a template with our spring sale headline',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'photo',\n },\n {\n key: 'figdesign',\n label: 'FigDesign',\n // The pen tool, not Design's palette or Canvas's vector-square: Design is AI web-design\n // boards and Canvas is media, this is the interface design editor.\n icon: 'fountain-pen-tip',\n group: 'Office',\n prompt: 'Start a mobile app design for my bakery in our brand green, with Light and Dark modes',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'figdesign',\n },\n {\n key: 'poster',\n label: 'Posters',\n // A printed sheet with a headline over its text, as on the web launcher, not\n // Presentations' easel: a poster is one big page, not a deck.\n icon: 'post-outline',\n group: 'Office',\n prompt: 'Turn this research paper into a 48 x 36 inch conference poster I can edit and print.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'poster',\n // Posters replaced Paper 2 Poster: a tile pinned under the old key stays pinned.\n supersedes: 'paper2poster',\n },\n {\n key: 'chat-native',\n label: 'Chats',\n icon: 'message-text-outline',\n group: 'Team',\n prompt: 'Show me my conversations.',\n // Person-to-person messaging, federated like canvas: the whole UI\n // downloads from the chat-native surface on open. Not the AI chat -\n // that is the Home tab.\n nativeRoute: 'chat-native',\n },\n {\n key: 'workflow',\n label: 'Workflow',\n icon: 'sitemap',\n group: 'Automate',\n prompt: 'Build a workflow that runs every morning and sends me a summary of what changed.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'workflow',\n },\n {\n key: 'computer',\n label: 'Computer',\n icon: 'monitor',\n group: 'Automate',\n prompt: 'Open a browser and compare the top 5 CRM tools with screenshots',\n },\n {\n key: 'crm',\n label: 'CRM',\n icon: 'account-group-outline',\n group: 'Sell',\n prompt: 'Look at my pipeline and tell me which deals are going cold and what I should send them.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'crm',\n },\n {\n key: 'salesiq',\n label: 'SalesIQ',\n icon: 'radar',\n group: 'Sell',\n prompt: 'Show me who is on my website right now',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'salesiq',\n },\n {\n key: 'inbox',\n label: 'Inbox',\n icon: 'inbox-outline',\n group: 'Sell',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'inbox',\n },\n {\n key: 'inbox-native',\n label: 'Inbox',\n supersedes: 'inbox',\n icon: 'inbox-outline',\n group: 'Sell',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n // Native mail client over the same yantra-mailer store as the web Inbox.\n nativeRoute: 'inbox-native',\n },\n {\n key: 'mailcampaign',\n label: 'Mail Campaigns',\n icon: 'bullhorn-outline',\n group: 'Sell',\n prompt: 'Draft an email campaign announcing what we shipped this month.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'mailcampaign',\n },\n {\n key: 'smscampaign',\n label: 'SMS Campaigns',\n icon: 'message-text-outline',\n group: 'Sell',\n prompt: \"Text my customers a short reminder about this week's offer.\",\n nativeRoute: 'webbuilder',\n surfaceSlug: 'smscampaign',\n },\n {\n key: 'social-post',\n label: 'Social Posts',\n icon: 'send-outline',\n group: 'Sell',\n prompt: 'Draft a launch post for X and LinkedIn and schedule it for Tuesday morning.',\n nativeRoute: 'webbuilder',\n // The deployed surface is `posts-surface`, not `social-post-surface`.\n surfaceSlug: 'posts',\n },\n {\n key: 'invoices',\n label: 'Invoices',\n icon: 'cash-check',\n group: 'Money',\n prompt: 'Show me which invoices are still unpaid.',\n // The served Invoices surface (yantra-surface packages/invoices) in the shared WebView.\n nativeRoute: 'webbuilder',\n surfaceSlug: 'invoices',\n },\n {\n key: 'expenses',\n label: 'Expenses',\n icon: 'receipt',\n group: 'Money',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'expenses',\n },\n {\n key: 'expenses-native',\n label: 'Expenses',\n supersedes: 'expenses',\n icon: 'receipt',\n group: 'Money',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n // Native expenses over the same expenses subgraph as the web app: scan receipts,\n // approvals, budgets, recurring payments, accounts.\n nativeRoute: 'expenses-native',\n },\n {\n key: 'dictate-native',\n label: 'Dictate',\n icon: 'microphone-outline',\n group: 'Office',\n prompt: 'Turn my dictated visit into a SOAP note.',\n // A clinician speaks a visit note; it comes back as a SOAP note with what to check.\n nativeRoute: 'dictate-native',\n },\n {\n key: 'cards-wallet',\n label: 'Cards & Wallet',\n icon: 'credit-card-outline',\n group: 'Money',\n prompt: 'Issue a $200 virtual card for monthly ad spend',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'cards-wallet',\n },\n {\n key: 'billing',\n label: 'Billing',\n icon: 'currency-usd',\n group: 'Money',\n prompt: 'Create an invoice for a $2,400 consulting project',\n nativeRoute: 'billing-native',\n surfaceSlug: 'billing',\n // Plan / subscription for this account — already in the drawer.\n hideInLauncher: true,\n },\n {\n key: 'kpi-motivation',\n label: 'KPI Motivation',\n icon: 'trophy-outline',\n group: 'Team',\n prompt: 'Set up a weekly sales KPI scoreboard for my team',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'kpi-motivation',\n },\n {\n key: 'issue-ticket',\n label: 'Issue Ticket',\n icon: 'bug-outline',\n group: 'Team',\n prompt: 'Create a bug board and triage my open issues',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'issues',\n },\n {\n key: 'notebook',\n label: 'Study',\n icon: 'school-outline',\n group: 'Team',\n prompt: 'Make a study guide from my lecture notes',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'notebooklm',\n },\n {\n key: 'study-native',\n label: 'Study',\n supersedes: 'notebook',\n icon: 'school-outline',\n group: 'Team',\n prompt: 'Make a study guide from my lecture notes',\n // Native study notebooks over the same yantra-notebook store as the web Study.\n nativeRoute: 'study-native',\n },\n {\n key: 'resume',\n label: 'Resume',\n icon: 'file-account-outline',\n group: 'Team',\n prompt: 'Draft a resume for a senior product designer with 8 years of experience',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'resume',\n },\n {\n key: 'resume-native',\n label: 'Resume',\n supersedes: 'resume',\n icon: 'file-account-outline',\n group: 'Team',\n prompt: 'Draft a resume for a senior product designer with 8 years of experience',\n nativeRoute: 'resume-native',\n },\n {\n key: 'job-search',\n label: 'Job Search',\n icon: 'briefcase-outline',\n group: 'Team',\n prompt: 'Find remote senior backend engineer roles and tailor my resume for one',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'job-search',\n },\n {\n key: 'job-search-native',\n label: 'Job Search',\n supersedes: 'job-search',\n icon: 'briefcase-search-outline',\n group: 'Team',\n prompt: 'Find remote senior backend engineer roles and tailor my resume for one',\n nativeRoute: 'job-search-native',\n },\n {\n key: 'shop',\n label: 'Shop',\n icon: 'cart-outline',\n group: 'More',\n prompt: 'Compare the best options for what I need and show me the tradeoffs.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'shopping',\n },\n {\n key: 'shopping-native',\n label: 'Shop',\n supersedes: 'shop',\n icon: 'storefront-outline',\n group: 'More',\n prompt: 'Compare the best options for what I need and show me the tradeoffs.',\n // Federated storefront: search + cart download from shopping_native/Shop.\n // The classic Shop tile keeps the web surface in the WebView host.\n nativeRoute: 'shopping-native',\n },\n {\n key: 'travel-native',\n label: 'Travel',\n supersedes: 'travel',\n icon: 'airplane-takeoff',\n group: 'More',\n prompt: 'Plan a 4-day trip for me: flights, somewhere to stay, and what to do each day.',\n nativeRoute: 'travel-native',\n },\n {\n key: 'travel',\n label: 'Travel',\n icon: 'airplane',\n group: 'More',\n prompt: 'Plan a 4-day trip for me: flights, somewhere to stay, and what to do each day.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'travel',\n },\n {\n key: 'social-events',\n label: 'yantra.live',\n icon: 'ticket-outline',\n group: 'More',\n prompt: 'What concerts are happening nearby this weekend?',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'social-events',\n },\n {\n key: 'movies',\n label: 'Movies',\n icon: 'popcorn',\n group: 'More',\n prompt: 'What movies are playing near me tonight?',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'movies',\n },\n {\n key: 'movies-native',\n label: 'Movies',\n supersedes: 'movies',\n icon: 'popcorn',\n group: 'More',\n prompt: 'What movies are playing near me tonight?',\n // Native cinema app over the yantra-movies connector: discover, trailers, showtimes, watchlist.\n nativeRoute: 'movies-native',\n },\n {\n key: 'local-services',\n label: 'Local Services',\n icon: 'wrench',\n group: 'More',\n prompt: 'Find an electrician near me',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'local-services',\n },\n {\n key: 'local-services-native',\n label: 'Local Services',\n supersedes: 'local-services',\n icon: 'wrench',\n group: 'More',\n prompt: 'Find an electrician near me',\n // Native search, details and saved pros over the same yantra-local-services\n // connector as the web Local Services surface.\n nativeRoute: 'local-services-native',\n },\n {\n key: 'fitness',\n label: 'Fitness',\n icon: 'dumbbell',\n group: 'More',\n prompt: 'Build me a workout plan for this week',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'fitness',\n },\n];\n\nexport const APP_GROUP_ORDER: readonly AppGroupId[] = ['Create', 'Office', 'Automate', 'Sell', 'Money', 'Team', 'More'];\n\nexport type AppsTab = 'all' | 'favorites';\n\n/**\n * Poster colors per group - the tile artwork. Deliberately the same in light\n * and dark themes: artwork is content, the card chrome is what adapts.\n */\nexport const APP_GROUP_ART: Record<AppGroupId, { base: string; glow: string }> = {\n Create: { base: '#4f46e5', glow: '#c4b5fd' },\n Office: { base: '#334155', glow: '#cbd5e1' },\n Automate: { base: '#0f766e', glow: '#99f6e4' },\n Sell: { base: '#c2410c', glow: '#fed7aa' },\n Money: { base: '#15803d', glow: '#bbf7d0' },\n Team: { base: '#0369a1', glow: '#bae6fd' },\n More: { base: '#be185d', glow: '#fbcfe8' },\n};\n\nexport function matchesAppQuery(label: string, query: string): boolean {\n const q = query.toLowerCase().replace(/[^a-z0-9]/g, '');\n if (!q) return true;\n return label\n .toLowerCase()\n .replace(/[^a-z0-9]/g, '')\n .includes(q);\n}\n\n/**\n * Favorites keyed by a web tile that a native tile now replaces, carried over to\n * the native tile, so pinning \"Inbox\" before it went native still pins it after.\n */\nexport function carryOverSupersededFavorites(\n favorites: ReadonlySet<string>,\n items: readonly MobileAppItem[] = MOBILE_APP_CATALOG,\n): Set<string> {\n const replacement = new Map<string, string>();\n for (const item of items) if (item.supersedes) replacement.set(item.supersedes, item.key);\n const out = new Set<string>();\n for (const key of favorites) out.add(replacement.get(key) ?? key);\n return out;\n}\n\n/** One tile per app: a web tile disappears when its native replacement is in the list. */\nexport function visibleMobileApps(items: readonly MobileAppItem[]): MobileAppItem[] {\n const replaced = new Set(items.map((item) => item.supersedes).filter(Boolean));\n return items.filter((item) => !item.hideInLauncher && !replaced.has(item.key));\n}\n\nexport function groupMobileApps(items: readonly MobileAppItem[], query: string) {\n const hits = visibleMobileApps(items).filter((item) => matchesAppQuery(item.label, query));\n return APP_GROUP_ORDER.map((label) => ({\n label,\n items: hits.filter((item) => item.group === label),\n })).filter((group) => group.items.length > 0);\n}\n\n/**\n * One flat grid (Manus/game-launcher style) instead of grouped sections: rows\n * stay dense and the group reads from each card's caption. Catalog order is\n * kept inside a group; groups follow APP_GROUP_ORDER.\n */\nexport function filterMobileApps(\n items: readonly MobileAppItem[],\n query: string,\n tab: AppsTab,\n favorites: ReadonlySet<string>,\n): MobileAppItem[] {\n const rank = new Map(APP_GROUP_ORDER.map((group, index) => [group, index]));\n return visibleMobileApps(items)\n .filter((item) => matchesAppQuery(item.label, query))\n .filter((item) => tab !== 'favorites' || favorites.has(item.key))\n .sort((a, b) => (rank.get(a.group) ?? APP_GROUP_ORDER.length) - (rank.get(b.group) ?? APP_GROUP_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1E,EAAO,OAAA,iBAAA,CAAkB,KAAK,CAAA,CAAE,MAAO,CAAA,CAAA,IAAA,KAAQ,gBAAgB,IAAK,CAAA,KAAA,EAAO,KAAK,CAAC,CAAE,CAAA,MAAA,CAAO,UAAQ,GAAQ,KAAA,WAAA,IAAe,SAAU,CAAA,GAAA,CAAI,IAAK,CAAA,GAAG,CAAC,CAAE,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAG,KAAA;AAxjBhK,IAAA,IAAA,EAAA,EAAA,EAAA;AAwjBoK,IAAA,OAAA,CAAA,CAAA,EAAA,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,CAAE,KAAK,CAAA,KAAhB,IAAqB,GAAA,EAAA,GAAA,eAAA,CAAgB,MAAW,KAAA,CAAA,EAAA,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,CAAE,KAAK,CAAA,KAAhB,YAAqB,eAAgB,CAAA,MAAA,CAAA;AAAA,GAAO,CAAA;AAChQ"}
|
|
1
|
+
{"version":3,"file":"mobileAppCatalog.js","sources":["../../../src/features/apps/mobileAppCatalog.ts"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport type { MaterialCommunityIcons } from '@expo/vector-icons';\n\ntype IconName = ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport type AppGroupId = 'Create' | 'Office' | 'Automate' | 'Sell' | 'Money' | 'Team' | 'More';\n\nexport type MobileAppItem = {\n key: string;\n label: string;\n icon: IconName;\n group: AppGroupId;\n /** Prompt sent as the first chat turn when the app has no native screen. */\n prompt: string;\n /**\n * Which surface host opens this app, if it has one. `webbuilder` is the\n * historical name of the shared WebView surface shell (`screens/WebBuilder`),\n * which is not web-builder-specific: it takes a `url` route param, mints the\n * system token, injects the bridge + cdecli token, stamps `embed=mobile` and\n * owns the timeout/retry UI. Anything with a deployed surface SPA can use it.\n */\n nativeRoute?:\n | 'webbuilder'\n | 'canvas-native'\n | 'characters-native'\n | 'chat-native'\n | 'billing-native'\n | 'shopping-native'\n | 'travel-native'\n | 'job-search-native'\n | 'resume-native'\n | 'inbox-native'\n | 'study-native'\n | 'local-services-native'\n | 'movies-native'\n | 'expenses-native'\n | 'dictate-native'\n | 'webbuilder-native'\n | 'design-native';\n /**\n * Deployed surface SPA for this app, as the `<slug>-surface` name. Resolved\n * against SURFACE_URL_TEMPLATE so one env var covers every surface and stays\n * per-environment, instead of 20+ near-identical URLs in eas.json.\n *\n * The slug is the SURFACE's name, which is not always the tile key\n * (issue-ticket -> issues, shop -> shopping, notebook -> notebooklm).\n */\n surfaceSlug?: string;\n /**\n * Explicit env override, for the surfaces people actually run locally\n * (design 5174, canvas 5175, webbuilder). Wins over `surfaceSlug`.\n */\n surfaceUrlKey?: 'WEB_BUILDER_URL' | 'CANVAS_SURFACE_URL' | 'DESIGN_SURFACE_URL';\n /**\n * Key of the web tile this native tile replaces in every launcher list.\n * The web entry stays in the catalog (deep links, tests, the WebView\n * lane) but users see one tile per app, the native one, under the\n * shared name. Also the key of a retired tile this one took over from\n * (Posters for Paper 2 Poster). Either way a favorite pinned under the\n * old key carries over to this tile.\n */\n supersedes?: string;\n /**\n * Account chrome, not a product app. Stays in the catalog so drawer /\n * deep-link routing still knows the native host, but never appears as\n * a tile in Apps or the Apps menu.\n */\n hideInLauncher?: boolean;\n};\n\n/**\n * Mobile Apps launcher. Labels, groups, and prompts stay in lockstep with the\n * browser ChatTopBar Apps menu (`packages-modules/account/browser`).\n */\nexport const MOBILE_APP_CATALOG: readonly MobileAppItem[] = [\n {\n key: 'design',\n label: 'Design',\n icon: 'palette-outline',\n group: 'Create',\n prompt: 'Design a 10-slide pitch deck for a coffee subscription startup',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'DESIGN_SURFACE_URL',\n surfaceSlug: 'design',\n },\n {\n key: 'design-native',\n label: 'Design',\n supersedes: 'design',\n icon: 'palette-outline',\n group: 'Create',\n prompt: 'Design a 10-slide pitch deck for a coffee subscription startup',\n // The native design studio (features/design): templates, saved designs and the\n // editor, drawn natively over the same designs as the web Design Studio. No WebView.\n nativeRoute: 'design-native',\n },\n {\n key: 'canvas',\n label: 'Canvas',\n icon: 'view-grid-outline',\n group: 'Create',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'CANVAS_SURFACE_URL',\n surfaceSlug: 'canvas',\n },\n {\n key: 'canvas-native',\n label: 'Canvas',\n supersedes: 'canvas',\n icon: 'vector-square',\n group: 'Create',\n prompt: 'Open a canvas and help me lay out the assets for this project.',\n // Renders through Module Federation: the viewer downloads from the\n // canvas-surface origin on open. First native surface; the classic\n // Canvas tile keeps the full web editor in the WebView host.\n nativeRoute: 'canvas-native',\n },\n {\n key: 'webbuilder',\n label: 'Web Builder',\n icon: 'application-outline',\n group: 'Create',\n prompt: 'Build a landing page for my bakery with a menu and a contact form',\n nativeRoute: 'webbuilder',\n surfaceUrlKey: 'WEB_BUILDER_URL',\n surfaceSlug: 'webbuilder',\n },\n {\n key: 'webbuilder-native',\n label: 'Web Builder',\n supersedes: 'webbuilder',\n icon: 'application-outline',\n group: 'Create',\n prompt: 'Build a landing page for my bakery with a menu and a contact form',\n // Native web builder over the same projects as the web surface: your sites,\n // build and edit with the agent, live preview, versions, publish.\n nativeRoute: 'webbuilder-native',\n },\n {\n key: 'codezen',\n label: 'Codezen',\n icon: 'code-braces',\n group: 'Create',\n prompt: 'Clone my repository and fix the failing test',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'codezen',\n },\n {\n key: 'character',\n label: 'Characters',\n icon: 'drama-masks',\n group: 'Create',\n prompt: 'Create a stoic philosophy mentor character I can chat with',\n // Native federated experience (gallery -> detail -> chat); the web\n // surface remains reachable through the surface lane if ever needed.\n nativeRoute: 'characters-native',\n surfaceSlug: 'character',\n },\n {\n key: 'characters-native',\n label: 'Characters',\n supersedes: 'character',\n icon: 'account-star',\n group: 'Create',\n prompt: 'Show me characters I can chat with.',\n nativeRoute: 'characters-native',\n surfaceSlug: 'character',\n },\n // Word, Excel, PowerPoint and PDF files, pictures, interface designs and research posters,\n // each in its own browser editor (yantra-office).\n {\n key: 'word',\n label: 'Documents',\n icon: 'file-document-outline',\n group: 'Office',\n prompt: 'Write a one-page project proposal as a Word document',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'word',\n },\n {\n key: 'excel',\n label: 'Spreadsheets',\n icon: 'file-table-outline',\n group: 'Office',\n prompt: 'Make a monthly budget spreadsheet with totals and a chart',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'excel',\n },\n {\n key: 'presentation',\n label: 'Presentations',\n icon: 'presentation',\n group: 'Office',\n prompt: 'Turn my notes into a six-slide project update deck',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'presentation',\n },\n {\n key: 'pdf',\n label: 'PDFs',\n icon: 'file-pdf-box',\n group: 'Office',\n prompt: 'Make a one-page PDF checklist for moving house',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'pdf',\n },\n {\n key: 'photo',\n label: 'Photos',\n icon: 'image-edit-outline',\n group: 'Office',\n prompt: 'Make an Instagram post from a template with our spring sale headline',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'photo',\n },\n {\n key: 'figdesign',\n label: 'FigDesign',\n // The pen tool, not Design's palette or Canvas's vector-square: Design is AI web-design\n // boards and Canvas is media, this is the interface design editor.\n icon: 'fountain-pen-tip',\n group: 'Office',\n prompt: 'Start a mobile app design for my bakery in our brand green, with Light and Dark modes',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'figdesign',\n },\n {\n key: 'poster',\n label: 'Posters',\n // A printed sheet with a headline over its text, as on the web launcher, not\n // Presentations' easel: a poster is one big page, not a deck.\n icon: 'post-outline',\n group: 'Office',\n prompt: 'Turn this research paper into a 48 x 36 inch conference poster I can edit and print.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'poster',\n // Posters replaced Paper 2 Poster: a tile pinned under the old key stays pinned.\n supersedes: 'paper2poster',\n },\n {\n key: 'chat-native',\n label: 'Chats',\n icon: 'message-text-outline',\n group: 'Team',\n prompt: 'Show me my conversations.',\n // Person-to-person messaging, federated like canvas: the whole UI\n // downloads from the chat-native surface on open. Not the AI chat -\n // that is the Home tab.\n nativeRoute: 'chat-native',\n },\n {\n key: 'workflow',\n label: 'Workflow',\n icon: 'sitemap',\n group: 'Automate',\n prompt: 'Build a workflow that runs every morning and sends me a summary of what changed.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'workflow',\n },\n {\n key: 'computer',\n label: 'Computer',\n icon: 'monitor',\n group: 'Automate',\n prompt: 'Open a browser and compare the top 5 CRM tools with screenshots',\n },\n {\n key: 'crm',\n label: 'CRM',\n icon: 'account-group-outline',\n group: 'Sell',\n prompt: 'Look at my pipeline and tell me which deals are going cold and what I should send them.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'crm',\n },\n {\n key: 'salesiq',\n label: 'SalesIQ',\n icon: 'radar',\n group: 'Sell',\n prompt: 'Show me who is on my website right now',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'salesiq',\n },\n {\n key: 'inbox',\n label: 'Inbox',\n icon: 'inbox-outline',\n group: 'Sell',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'inbox',\n },\n {\n key: 'inbox-native',\n label: 'Inbox',\n supersedes: 'inbox',\n icon: 'inbox-outline',\n group: 'Sell',\n prompt: 'Go through my inbox, tell me what actually needs a reply, and draft those replies.',\n // Native mail client over the same yantra-mailer store as the web Inbox.\n nativeRoute: 'inbox-native',\n },\n {\n key: 'mailcampaign',\n label: 'Mail Campaigns',\n icon: 'bullhorn-outline',\n group: 'Sell',\n prompt: 'Draft an email campaign announcing what we shipped this month.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'mailcampaign',\n },\n {\n key: 'smscampaign',\n label: 'SMS Campaigns',\n icon: 'message-text-outline',\n group: 'Sell',\n prompt: \"Text my customers a short reminder about this week's offer.\",\n nativeRoute: 'webbuilder',\n surfaceSlug: 'smscampaign',\n },\n {\n key: 'social-post',\n label: 'Social Posts',\n icon: 'send-outline',\n group: 'Sell',\n prompt: 'Draft a launch post for X and LinkedIn and schedule it for Tuesday morning.',\n nativeRoute: 'webbuilder',\n // The deployed surface is `posts-surface`, not `social-post-surface`.\n surfaceSlug: 'posts',\n },\n {\n key: 'invoices',\n label: 'Invoices',\n icon: 'cash-check',\n group: 'Money',\n prompt: 'Show me which invoices are still unpaid.',\n // The served Invoices surface (yantra-surface packages/invoices) in the shared WebView.\n nativeRoute: 'webbuilder',\n surfaceSlug: 'invoices',\n },\n {\n key: 'expenses',\n label: 'Expenses',\n icon: 'receipt',\n group: 'Money',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'expenses',\n },\n {\n key: 'expenses-native',\n label: 'Expenses',\n supersedes: 'expenses',\n icon: 'receipt',\n group: 'Money',\n prompt: 'Summarise my spend this month and flag anything unusual.',\n // Native expenses over the same expenses subgraph as the web app: scan receipts,\n // approvals, budgets, recurring payments, accounts.\n nativeRoute: 'expenses-native',\n },\n {\n key: 'dictate-native',\n label: 'Dictate',\n icon: 'microphone-outline',\n group: 'Office',\n prompt: 'Turn what I say into notes: a class, a meeting, an idea or a patient visit.',\n // Anyone speaks - a class, a meeting, an idea, a story, a visit - and gets the notes that fit it.\n nativeRoute: 'dictate-native',\n },\n {\n key: 'cards-wallet',\n label: 'Cards & Wallet',\n icon: 'credit-card-outline',\n group: 'Money',\n prompt: 'Issue a $200 virtual card for monthly ad spend',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'cards-wallet',\n },\n {\n key: 'billing',\n label: 'Billing',\n icon: 'currency-usd',\n group: 'Money',\n prompt: 'Create an invoice for a $2,400 consulting project',\n nativeRoute: 'billing-native',\n surfaceSlug: 'billing',\n // Plan / subscription for this account — already in the drawer.\n hideInLauncher: true,\n },\n {\n key: 'kpi-motivation',\n label: 'KPI Motivation',\n icon: 'trophy-outline',\n group: 'Team',\n prompt: 'Set up a weekly sales KPI scoreboard for my team',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'kpi-motivation',\n },\n {\n key: 'issue-ticket',\n label: 'Issue Ticket',\n icon: 'bug-outline',\n group: 'Team',\n prompt: 'Create a bug board and triage my open issues',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'issues',\n },\n {\n key: 'notebook',\n label: 'Study',\n icon: 'school-outline',\n group: 'Team',\n prompt: 'Make a study guide from my lecture notes',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'notebooklm',\n },\n {\n key: 'study-native',\n label: 'Study',\n supersedes: 'notebook',\n icon: 'school-outline',\n group: 'Team',\n prompt: 'Make a study guide from my lecture notes',\n // Native study notebooks over the same yantra-notebook store as the web Study.\n nativeRoute: 'study-native',\n },\n {\n key: 'resume',\n label: 'Resume',\n icon: 'file-account-outline',\n group: 'Team',\n prompt: 'Draft a resume for a senior product designer with 8 years of experience',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'resume',\n },\n {\n key: 'resume-native',\n label: 'Resume',\n supersedes: 'resume',\n icon: 'file-account-outline',\n group: 'Team',\n prompt: 'Draft a resume for a senior product designer with 8 years of experience',\n nativeRoute: 'resume-native',\n },\n {\n key: 'job-search',\n label: 'Job Search',\n icon: 'briefcase-outline',\n group: 'Team',\n prompt: 'Find remote senior backend engineer roles and tailor my resume for one',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'job-search',\n },\n {\n key: 'job-search-native',\n label: 'Job Search',\n supersedes: 'job-search',\n icon: 'briefcase-search-outline',\n group: 'Team',\n prompt: 'Find remote senior backend engineer roles and tailor my resume for one',\n nativeRoute: 'job-search-native',\n },\n {\n key: 'shop',\n label: 'Shop',\n icon: 'cart-outline',\n group: 'More',\n prompt: 'Compare the best options for what I need and show me the tradeoffs.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'shopping',\n },\n {\n key: 'shopping-native',\n label: 'Shop',\n supersedes: 'shop',\n icon: 'storefront-outline',\n group: 'More',\n prompt: 'Compare the best options for what I need and show me the tradeoffs.',\n // Federated storefront: search + cart download from shopping_native/Shop.\n // The classic Shop tile keeps the web surface in the WebView host.\n nativeRoute: 'shopping-native',\n },\n {\n key: 'travel-native',\n label: 'Travel',\n supersedes: 'travel',\n icon: 'airplane-takeoff',\n group: 'More',\n prompt: 'Plan a 4-day trip for me: flights, somewhere to stay, and what to do each day.',\n nativeRoute: 'travel-native',\n },\n {\n key: 'travel',\n label: 'Travel',\n icon: 'airplane',\n group: 'More',\n prompt: 'Plan a 4-day trip for me: flights, somewhere to stay, and what to do each day.',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'travel',\n },\n {\n key: 'social-events',\n label: 'yantra.live',\n icon: 'ticket-outline',\n group: 'More',\n prompt: 'What concerts are happening nearby this weekend?',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'social-events',\n },\n {\n key: 'movies',\n label: 'Movies',\n icon: 'popcorn',\n group: 'More',\n prompt: 'What movies are playing near me tonight?',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'movies',\n },\n {\n key: 'movies-native',\n label: 'Movies',\n supersedes: 'movies',\n icon: 'popcorn',\n group: 'More',\n prompt: 'What movies are playing near me tonight?',\n // Native cinema app over the yantra-movies connector: discover, trailers, showtimes, watchlist.\n nativeRoute: 'movies-native',\n },\n {\n key: 'local-services',\n label: 'Local Services',\n icon: 'wrench',\n group: 'More',\n prompt: 'Find an electrician near me',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'local-services',\n },\n {\n key: 'local-services-native',\n label: 'Local Services',\n supersedes: 'local-services',\n icon: 'wrench',\n group: 'More',\n prompt: 'Find an electrician near me',\n // Native search, details and saved pros over the same yantra-local-services\n // connector as the web Local Services surface.\n nativeRoute: 'local-services-native',\n },\n {\n key: 'fitness',\n label: 'Fitness',\n icon: 'dumbbell',\n group: 'More',\n prompt: 'Build me a workout plan for this week',\n nativeRoute: 'webbuilder',\n surfaceSlug: 'fitness',\n },\n];\n\nexport const APP_GROUP_ORDER: readonly AppGroupId[] = ['Create', 'Office', 'Automate', 'Sell', 'Money', 'Team', 'More'];\n\nexport type AppsTab = 'all' | 'favorites';\n\n/**\n * Poster colors per group - the tile artwork. Deliberately the same in light\n * and dark themes: artwork is content, the card chrome is what adapts.\n */\nexport const APP_GROUP_ART: Record<AppGroupId, { base: string; glow: string }> = {\n Create: { base: '#4f46e5', glow: '#c4b5fd' },\n Office: { base: '#334155', glow: '#cbd5e1' },\n Automate: { base: '#0f766e', glow: '#99f6e4' },\n Sell: { base: '#c2410c', glow: '#fed7aa' },\n Money: { base: '#15803d', glow: '#bbf7d0' },\n Team: { base: '#0369a1', glow: '#bae6fd' },\n More: { base: '#be185d', glow: '#fbcfe8' },\n};\n\nexport function matchesAppQuery(label: string, query: string): boolean {\n const q = query.toLowerCase().replace(/[^a-z0-9]/g, '');\n if (!q) return true;\n return label\n .toLowerCase()\n .replace(/[^a-z0-9]/g, '')\n .includes(q);\n}\n\n/**\n * Favorites keyed by a web tile that a native tile now replaces, carried over to\n * the native tile, so pinning \"Inbox\" before it went native still pins it after.\n */\nexport function carryOverSupersededFavorites(\n favorites: ReadonlySet<string>,\n items: readonly MobileAppItem[] = MOBILE_APP_CATALOG,\n): Set<string> {\n const replacement = new Map<string, string>();\n for (const item of items) if (item.supersedes) replacement.set(item.supersedes, item.key);\n const out = new Set<string>();\n for (const key of favorites) out.add(replacement.get(key) ?? key);\n return out;\n}\n\n/** One tile per app: a web tile disappears when its native replacement is in the list. */\nexport function visibleMobileApps(items: readonly MobileAppItem[]): MobileAppItem[] {\n const replaced = new Set(items.map((item) => item.supersedes).filter(Boolean));\n return items.filter((item) => !item.hideInLauncher && !replaced.has(item.key));\n}\n\nexport function groupMobileApps(items: readonly MobileAppItem[], query: string) {\n const hits = visibleMobileApps(items).filter((item) => matchesAppQuery(item.label, query));\n return APP_GROUP_ORDER.map((label) => ({\n label,\n items: hits.filter((item) => item.group === label),\n })).filter((group) => group.items.length > 0);\n}\n\n/**\n * One flat grid (Manus/game-launcher style) instead of grouped sections: rows\n * stay dense and the group reads from each card's caption. Catalog order is\n * kept inside a group; groups follow APP_GROUP_ORDER.\n */\nexport function filterMobileApps(\n items: readonly MobileAppItem[],\n query: string,\n tab: AppsTab,\n favorites: ReadonlySet<string>,\n): MobileAppItem[] {\n const rank = new Map(APP_GROUP_ORDER.map((group, index) => [group, index]));\n return visibleMobileApps(items)\n .filter((item) => matchesAppQuery(item.label, query))\n .filter((item) => tab !== 'favorites' || favorites.has(item.key))\n .sort((a, b) => (rank.get(a.group) ?? APP_GROUP_ORDER.length) - (rank.get(b.group) ?? APP_GROUP_ORDER.length));\n}\n"],"names":[],"mappings":"AAsDO,MAAM,kBAA+C,GAAA;AAAA,EAAC;AAAA,IAC3D,GAAK,EAAA,QAAA;AAAA,IACL,KAAO,EAAA,QAAA;AAAA,IACP,IAAM,EAAA,iBAAA;AAAA,IACN,KAAO,EAAA,QAAA;AAAA,IACP,MAAQ,EAAA,gEAAA;AAAA,IACR,WAAa,EAAA,YAAA;AAAA,IACb,aAAe,EAAA,oBAAA;AAAA,IACf,WAAa,EAAA;AAAA,GACf;AAAA,EAAG;AAAA,IACD,GAAK,EAAA,eAAA;AAAA,IACL,KAAO,EAAA,QAAA;AAAA,IACP,UAAY,EAAA,QAAA;AAAA,IACZ,IAAM,EAAA,iBAAA;AAAA,IACN,KAAO,EAAA,QAAA;AAAA,IACP,MAAQ,EAAA,gEAAA;AAAA;AAAA;AAAA,IAGR,WAAa,EAAA;AAAA,GACf;AAAA,EAAG;AAAA,IACD,GAAK,EAAA,QAAA;AAAA,IACL,KAAO,EAAA,QAAA;AAAA,IACP,IAAM,EAAA,mBAAA;AAAA,IACN,KAAO,EAAA,QAAA;AAAA,IACP,MAAQ,EAAA,gEAAA;AAAA,IACR,WAAa,EAAA,YAAA;AAAA,IACb,aAAe,EAAA,oBAAA;AAAA,IACf,WAAa,EAAA;AAAA,GACf;AAAA,EAAG;AAAA,IACD,GAAK,EAAA,eAAA;AAAA,IACL,KAAO,EAAA,QA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,CAAM,MAAO,CAAA,CAAA,IAAA,KAAQ,CAAC,IAAA,CAAK,cAAkB,IAAA,CAAC,QAAS,CAAA,GAAA,CAAI,IAAK,CAAA,GAAG,CAAC,CAAA;AAC7E;AAcO,SAAS,gBAAiB,CAAA,KAAA,EAAiC,KAAe,EAAA,GAAA,EAAc,SAAiD,EAAA;AAC9I,EAAA,MAAM,IAAO,GAAA,IAAI,GAAI,CAAA,eAAA,CAAgB,GAAI,CAAA,CAAC,KAAO,EAAA,KAAA,KAAU,CAAC,KAAA,EAAO,KAAK,CAAC,CAAC,CAAA;AAC1E,EAAO,OAAA,iBAAA,CAAkB,KAAK,CAAA,CAAE,MAAO,CAAA,CAAA,IAAA,KAAQ,gBAAgB,IAAK,CAAA,KAAA,EAAO,KAAK,CAAC,CAAE,CAAA,MAAA,CAAO,UAAQ,GAAQ,KAAA,WAAA,IAAe,SAAU,CAAA,GAAA,CAAI,IAAK,CAAA,GAAG,CAAC,CAAE,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAG,KAAA;AAxjBhK,IAAA,IAAA,EAAA,EAAA,EAAA;AAwjBoK,IAAA,OAAA,CAAA,CAAA,EAAA,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,CAAE,KAAK,CAAA,KAAhB,IAAqB,GAAA,EAAA,GAAA,eAAA,CAAgB,MAAW,KAAA,CAAA,EAAA,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,CAAE,KAAK,CAAA,KAAhB,YAAqB,eAAgB,CAAA,MAAA,CAAA;AAAA,GAAO,CAAA;AAChQ"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const WATER_FRACTION_OF_FFM = 0.72;
|
|
2
|
+
const BONE_FRACTION_OF_FFM = 0.0497;
|
|
3
|
+
const round1 = (n) => Math.round(n * 10) / 10;
|
|
4
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
5
|
+
function computeBodyComposition(input) {
|
|
6
|
+
const {
|
|
7
|
+
weightKg,
|
|
8
|
+
bodyFatPct,
|
|
9
|
+
heightCm,
|
|
10
|
+
age
|
|
11
|
+
} = input;
|
|
12
|
+
const male = input.sex === "male";
|
|
13
|
+
const heightM = heightCm / 100;
|
|
14
|
+
const bmi = heightM > 0 ? weightKg / (heightM * heightM) : 0;
|
|
15
|
+
const fat = Math.max(0, Math.min(75, bodyFatPct)) / 100;
|
|
16
|
+
const fatMassKg = weightKg * fat;
|
|
17
|
+
const leanMassKg = weightKg - fatMassKg;
|
|
18
|
+
const boneMassKg = leanMassKg * BONE_FRACTION_OF_FFM;
|
|
19
|
+
const muscleMassKg = leanMassKg - boneMassKg;
|
|
20
|
+
const bodyWaterKg = leanMassKg * WATER_FRACTION_OF_FFM;
|
|
21
|
+
const proteinKg = Math.max(0, leanMassKg - bodyWaterKg - boneMassKg);
|
|
22
|
+
let skeletalMuscleMassKg;
|
|
23
|
+
if (input.impedanceOhm && input.impedanceOhm > 0) {
|
|
24
|
+
const sexTerm = male ? 3.825 : 0;
|
|
25
|
+
skeletalMuscleMassKg = 0.401 * (heightCm * heightCm) / input.impedanceOhm + sexTerm - 0.071 * age + 5.102;
|
|
26
|
+
skeletalMuscleMassKg = Math.max(0, Math.min(muscleMassKg, skeletalMuscleMassKg));
|
|
27
|
+
} else {
|
|
28
|
+
skeletalMuscleMassKg = muscleMassKg * (male ? 0.68 : 0.62);
|
|
29
|
+
}
|
|
30
|
+
const bmr = Math.round(370 + 21.6 * leanMassKg);
|
|
31
|
+
const metabolicAge = estimateMetabolicAge(bmr, heightCm, male, age);
|
|
32
|
+
const visceralFat = Math.max(1, Math.min(59, Math.round(fatMassKg * (male ? 1 : 0.85) / 2.2 + age / 12 - 3)));
|
|
33
|
+
const subcutaneousFatPct = Math.max(0, bodyFatPct - visceralFat * 0.33);
|
|
34
|
+
const pct = (kg) => weightKg > 0 ? kg / weightKg * 100 : 0;
|
|
35
|
+
return {
|
|
36
|
+
bmi: round1(bmi),
|
|
37
|
+
fatMassKg: round2(fatMassKg),
|
|
38
|
+
leanMassKg: round2(leanMassKg),
|
|
39
|
+
muscleMassKg: round2(muscleMassKg),
|
|
40
|
+
musclePct: round1(pct(muscleMassKg)),
|
|
41
|
+
skeletalMuscleMassKg: round2(skeletalMuscleMassKg),
|
|
42
|
+
skeletalMusclePct: round1(pct(skeletalMuscleMassKg)),
|
|
43
|
+
boneMassKg: round2(boneMassKg),
|
|
44
|
+
bonePct: round1(pct(boneMassKg)),
|
|
45
|
+
bodyWaterKg: round2(bodyWaterKg),
|
|
46
|
+
bodyWaterPct: round1(pct(bodyWaterKg)),
|
|
47
|
+
proteinKg: round2(proteinKg),
|
|
48
|
+
proteinPct: round1(pct(proteinKg)),
|
|
49
|
+
bmr,
|
|
50
|
+
metabolicAge,
|
|
51
|
+
visceralFat,
|
|
52
|
+
subcutaneousFatPct: round1(subcutaneousFatPct)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function compositionRows(c, units = "metric") {
|
|
56
|
+
const kg = (v) => units === "imperial" ? `${Math.round(v / 0.45359237 * 10) / 10} lb` : `${v} kg`;
|
|
57
|
+
const pct = (v) => `${v}%`;
|
|
58
|
+
return [{
|
|
59
|
+
label: "BMI",
|
|
60
|
+
value: String(c.bmi)
|
|
61
|
+
}, {
|
|
62
|
+
label: "Fat mass",
|
|
63
|
+
value: kg(c.fatMassKg)
|
|
64
|
+
}, {
|
|
65
|
+
label: "Fat-free mass",
|
|
66
|
+
value: kg(c.leanMassKg)
|
|
67
|
+
}, {
|
|
68
|
+
label: "Muscle mass",
|
|
69
|
+
value: kg(c.muscleMassKg)
|
|
70
|
+
}, {
|
|
71
|
+
label: "Muscle",
|
|
72
|
+
value: pct(c.musclePct)
|
|
73
|
+
}, {
|
|
74
|
+
label: "Skeletal muscle",
|
|
75
|
+
value: kg(c.skeletalMuscleMassKg)
|
|
76
|
+
}, {
|
|
77
|
+
label: "Bone mass",
|
|
78
|
+
value: kg(c.boneMassKg)
|
|
79
|
+
}, {
|
|
80
|
+
label: "Body water",
|
|
81
|
+
value: pct(c.bodyWaterPct)
|
|
82
|
+
}, {
|
|
83
|
+
label: "Protein",
|
|
84
|
+
value: pct(c.proteinPct)
|
|
85
|
+
}, {
|
|
86
|
+
label: "BMR",
|
|
87
|
+
value: `${c.bmr} kcal`
|
|
88
|
+
}, {
|
|
89
|
+
label: "Metabolic age",
|
|
90
|
+
value: `${c.metabolicAge} yrs`
|
|
91
|
+
}, {
|
|
92
|
+
label: "Visceral fat",
|
|
93
|
+
value: String(c.visceralFat)
|
|
94
|
+
}, {
|
|
95
|
+
label: "Subcutaneous fat",
|
|
96
|
+
value: pct(c.subcutaneousFatPct)
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
function estimateMetabolicAge(bmr, heightCm, male, age) {
|
|
100
|
+
const ffmAt = (a) => {
|
|
101
|
+
const base = male ? 0.407 * heightCm - 15 : 0.357 * heightCm - 13;
|
|
102
|
+
const decline = a > 25 ? (a - 25) * 0.1 : 0;
|
|
103
|
+
return Math.max(20, base - decline);
|
|
104
|
+
};
|
|
105
|
+
const bmrAt = (a) => 370 + 21.6 * ffmAt(a);
|
|
106
|
+
let best = age;
|
|
107
|
+
let bestDiff = Infinity;
|
|
108
|
+
for (let a = 18; a <= 80; a++) {
|
|
109
|
+
const diff = Math.abs(bmrAt(a) - bmr);
|
|
110
|
+
if (diff < bestDiff) {
|
|
111
|
+
bestDiff = diff;
|
|
112
|
+
best = a;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return best;
|
|
116
|
+
}export{compositionRows,computeBodyComposition};//# sourceMappingURL=bodyComposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodyComposition.js","sources":["../../../src/features/devices/bodyComposition.ts"],"sourcesContent":["/**\n * Full body composition from a scale reading, using established published\n * formulas (not any vendor's proprietary coefficients).\n *\n * A body-fat scale measures weight and bioelectrical impedance and, from the\n * person's height/age/sex, estimates body-fat percentage. Everything else a\n * scale app shows (fat-free mass, muscle, bone, body water, protein, BMR,\n * metabolic age, visceral/subcutaneous fat) is derived from weight and body\n * fat with standard equations:\n *\n * - Fat mass / fat-free mass: definitional.\n * - Total body water: FFM is ~72% water (the standard hydration constant).\n * - Bone mineral: a small, roughly fixed fraction of fat-free mass.\n * - Muscle mass = fat-free mass minus bone mineral; protein is the dry\n * non-mineral remainder.\n * - BMR: Katch-McArdle (370 + 21.6 x FFM), which depends only on lean mass.\n * - Skeletal muscle: Janssen's impedance equation when impedance is known.\n *\n * These reproduce a RENPHO/QN scale's derived numbers closely because the scale\n * uses the same public science; the only vendor-specific step is the body-fat\n * estimate, which the device sends directly, so Yantra does not recompute it.\n */\n\nexport interface BodyCompositionInput {\n weightKg: number;\n bodyFatPct: number;\n heightCm: number;\n age: number;\n sex: 'male' | 'female' | 'unspecified';\n /** Whole-body impedance in ohms, when the scale reported it (for skeletal muscle). */\n impedanceOhm?: number;\n}\n\nexport interface BodyComposition {\n bmi: number;\n fatMassKg: number;\n /** Fat-free (lean) mass. */\n leanMassKg: number;\n muscleMassKg: number;\n musclePct: number;\n skeletalMuscleMassKg: number;\n skeletalMusclePct: number;\n boneMassKg: number;\n bonePct: number;\n bodyWaterKg: number;\n bodyWaterPct: number;\n proteinKg: number;\n proteinPct: number;\n /** Basal metabolic rate, kcal/day. */\n bmr: number;\n metabolicAge: number;\n /** Visceral fat rating (unitless, like the scale's 1-59 scale). */\n visceralFat: number;\n subcutaneousFatPct: number;\n}\n\n/** Fraction of fat-free mass that is water (standard hydration constant). */\nconst WATER_FRACTION_OF_FFM = 0.72;\n/** Fraction of fat-free mass that is bone mineral. */\nconst BONE_FRACTION_OF_FFM = 0.0497;\n\nconst round1 = (n: number) => Math.round(n * 10) / 10;\nconst round2 = (n: number) => Math.round(n * 100) / 100;\n\nexport function computeBodyComposition(input: BodyCompositionInput): BodyComposition {\n const { weightKg, bodyFatPct, heightCm, age } = input;\n const male = input.sex === 'male';\n const heightM = heightCm / 100;\n\n const bmi = heightM > 0 ? weightKg / (heightM * heightM) : 0;\n const fat = Math.max(0, Math.min(75, bodyFatPct)) / 100;\n const fatMassKg = weightKg * fat;\n const leanMassKg = weightKg - fatMassKg;\n\n const boneMassKg = leanMassKg * BONE_FRACTION_OF_FFM;\n const muscleMassKg = leanMassKg - boneMassKg;\n const bodyWaterKg = leanMassKg * WATER_FRACTION_OF_FFM;\n const proteinKg = Math.max(0, leanMassKg - bodyWaterKg - boneMassKg);\n\n // Skeletal muscle: Janssen (2000) when impedance is known, else a fraction of muscle.\n let skeletalMuscleMassKg: number;\n if (input.impedanceOhm && input.impedanceOhm > 0) {\n const sexTerm = male ? 3.825 : 0;\n skeletalMuscleMassKg =\n (0.401 * (heightCm * heightCm)) / input.impedanceOhm + sexTerm - 0.071 * age + 5.102;\n skeletalMuscleMassKg = Math.max(0, Math.min(muscleMassKg, skeletalMuscleMassKg));\n } else {\n skeletalMuscleMassKg = muscleMassKg * (male ? 0.68 : 0.62);\n }\n\n // Katch-McArdle: basal metabolic rate from lean mass.\n const bmr = Math.round(370 + 21.6 * leanMassKg);\n\n // Metabolic age: how old the person's BMR looks against the BMR a lean,\n // average person of their height would have at each age. Clamped to 18-80.\n const metabolicAge = estimateMetabolicAge(bmr, heightCm, male, age);\n\n // Visceral fat rating: rises with body-fat mass and age; a standard-style\n // index (not a clinical measure), clamped to the usual 1-59 range.\n const visceralFat = Math.max(\n 1,\n Math.min(59, Math.round((fatMassKg * (male ? 1.0 : 0.85)) / 2.2 + age / 12 - 3)),\n );\n // Subcutaneous fat is the body fat that is not visceral.\n const subcutaneousFatPct = Math.max(0, bodyFatPct - visceralFat * 0.33);\n\n const pct = (kg: number) => (weightKg > 0 ? (kg / weightKg) * 100 : 0);\n return {\n bmi: round1(bmi),\n fatMassKg: round2(fatMassKg),\n leanMassKg: round2(leanMassKg),\n muscleMassKg: round2(muscleMassKg),\n musclePct: round1(pct(muscleMassKg)),\n skeletalMuscleMassKg: round2(skeletalMuscleMassKg),\n skeletalMusclePct: round1(pct(skeletalMuscleMassKg)),\n boneMassKg: round2(boneMassKg),\n bonePct: round1(pct(boneMassKg)),\n bodyWaterKg: round2(bodyWaterKg),\n bodyWaterPct: round1(pct(bodyWaterKg)),\n proteinKg: round2(proteinKg),\n proteinPct: round1(pct(proteinKg)),\n bmr,\n metabolicAge,\n visceralFat,\n subcutaneousFatPct: round1(subcutaneousFatPct),\n };\n}\n\n/** The composition as labelled rows for a details view, in the person's units. */\nexport function compositionRows(\n c: BodyComposition,\n units: 'metric' | 'imperial' = 'metric',\n): Array<{ label: string; value: string }> {\n const kg = (v: number) =>\n units === 'imperial' ? `${Math.round((v / 0.45359237) * 10) / 10} lb` : `${v} kg`;\n const pct = (v: number) => `${v}%`;\n return [\n { label: 'BMI', value: String(c.bmi) },\n { label: 'Fat mass', value: kg(c.fatMassKg) },\n { label: 'Fat-free mass', value: kg(c.leanMassKg) },\n { label: 'Muscle mass', value: kg(c.muscleMassKg) },\n { label: 'Muscle', value: pct(c.musclePct) },\n { label: 'Skeletal muscle', value: kg(c.skeletalMuscleMassKg) },\n { label: 'Bone mass', value: kg(c.boneMassKg) },\n { label: 'Body water', value: pct(c.bodyWaterPct) },\n { label: 'Protein', value: pct(c.proteinPct) },\n { label: 'BMR', value: `${c.bmr} kcal` },\n { label: 'Metabolic age', value: `${c.metabolicAge} yrs` },\n { label: 'Visceral fat', value: String(c.visceralFat) },\n { label: 'Subcutaneous fat', value: pct(c.subcutaneousFatPct) },\n ];\n}\n\n/** Compare the person's BMR to the typical BMR by age for their height and sex. */\nfunction estimateMetabolicAge(bmr: number, heightCm: number, male: boolean, age: number): number {\n // Typical fat-free mass by age (slow decline past 25), then its Katch-McArdle BMR.\n const ffmAt = (a: number) => {\n const base = male ? 0.407 * heightCm - 15 : 0.357 * heightCm - 13;\n const decline = a > 25 ? (a - 25) * 0.1 : 0;\n return Math.max(20, base - decline);\n };\n const bmrAt = (a: number) => 370 + 21.6 * ffmAt(a);\n let best = age;\n let bestDiff = Infinity;\n for (let a = 18;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;AAC/D,IAAA,MAAM,OAAU,GAAA,CAAA,GAAI,EAAM,GAAA,CAAA,CAAA,GAAI,MAAM,GAAM,GAAA,CAAA;AAC1C,IAAA,OAAO,IAAK,CAAA,GAAA,CAAI,EAAI,EAAA,IAAA,GAAO,OAAO,CAAA;AAAA,GACpC;AACA,EAAA,MAAM,QAAQ,CAAC,CAAA,KAAc,GAAM,GAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AACjD,EAAA,IAAI,IAAO,GAAA,GAAA;AACX,EAAA,IAAI,QAAW,GAAA,QAAA;AACf,EAAA,KAAA,IAAS,CAAI,GAAA,EAAA,EAAI,CAAK,IAAA,EAAA,EAAI,CAAK,EAAA,EAAA;AAC7B,IAAA,MAAM,OAAO,IAAK,CAAA,GAAA,CAAI,KAAM,CAAA,CAAC,IAAI,GAAG,CAAA;AACpC,IAAA,IAAI,OAAO,QAAU,EAAA;AACnB,MAAW,QAAA,GAAA,IAAA;AACX,MAAO,IAAA,GAAA,CAAA;AAAA;AACT;AAEF,EAAO,OAAA,IAAA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readings.js","sources":["../../../src/features/devices/readings.ts"],"sourcesContent":["/**\n * What a paired Bluetooth device measured, and how it reaches the Fitness\n * backend.\n *\n * The backend keeps ONE day per source and replaces it whole on every upload,\n * so a reading is never sent alone: the app keeps every reading it took (the\n * device store), and each upload rebuilds the full `device` day for the dates\n * that changed. A blood-pressure reading in the evening never wipes the\n * morning's weigh-in.\n *\n * Reading ids are stable (device + what + when): a monitor that sends its\n * whole memory on every connection, or the same reading arriving twice, is\n * stored once.\n */\n\nimport { sanitizeDay, hasData } from '../health/buildDays';\nimport type { TimedValue } from '../health/model';\nimport type { HealthDay, HealthReading, HealthWorkout, MealRelation } from '../health/types';\nimport type { ZoneClock } from '../health/time';\nimport { zoneMinutes } from '../health/zones';\n\ninterface ReadingBase {\n id: string;\n /** Epoch ms of the measurement. */\n at: number;\n deviceId: string;\n deviceName: string;\n}\n\nexport interface BodyReading extends ReadingBase {\n kind: 'body';\n weightKg?: number;\n bodyFatPct?: number;\n leanMassKg?: number;\n bmi?: number;\n /**\n * Whole-body impedance in ohms, when the scale sends it. A scale that only\n * reports weight and impedance (RENPHO's common protocol) leaves body fat\n * to Yantra's own estimate; one that computes body fat itself (R-A017) also\n * fills bodyFatPct and bmi.\n */\n impedanceOhm?: number;\n}\n\nexport interface BloodPressureReading extends ReadingBase {\n kind: 'blood-pressure';\n systolic: number;\n diastolic: number;\n pulse?: number;\n /** What the monitor flagged (moved, loose cuff, irregular pulse), in words. */\n problems?: string[];\n}\n\nexport interface TemperatureReading extends ReadingBase {\n kind: 'temperature';\n celsius: number;\n}\n\nexport interface OxygenReading extends ReadingBase {\n kind: 'spo2';\n spo2: number;\n pulse?: number;\n}\n\nexport interface GlucoseReading extends ReadingBase {\n kind: 'glucose';\n mgdl: number;\n meal?: MealRelation;\n}\n\n/** A heart-rate strap worn for a session: the samples, summed up when it ended. */\nexport interface HeartRateSession extends ReadingBase {\n kind: 'heart-rate';\n /** `at` is the start. */\n end: number;\n /** run | walk | cycle | strength | hiit | other, as the person picked it. */\n workoutType: string;\n avgHr: number;\n maxHr: number;\n /** At most one sample every few seconds (see thinSamples); emptied once saved, see compactSession. */\n samples: TimedValue[];\n /** Minutes per heart-rate zone, kept when the samples are let go. */\n zoneMinutes?: number[];\n}\n\n/**\n * A finished exercise a device recorded itself: a jump-rope session or a\n * treadmill walk/run. Becomes one HealthWorkout in the day (readings with no\n * heart-rate samples, unlike HeartRateSession).\n */\nexport interface WorkoutReading extends ReadingBase {\n kind: 'workout';\n /** `at` is the start. */\n end: number;\n /** jump-rope | run | walk | ... lowercased. */\n workoutType: string;\n durationMin: number;\n calories?: number;\n distanceMeters?: number;\n /** Jump rope only: the number of skips. */\n jumps?: number;\n avgHr?: number;\n maxHr?: number;\n}\n\n/** A tape-measure girth reading of one body part. Only the waist has a home in the day. */\nexport interface BodyMeasurementReading extends ReadingBase {\n kind: 'body-measurement';\n /** waist | chest | hip | left_arm | ... as the tape reported it. */\n bodyPart: string;\n cm: number;\n}\n\nexport type DeviceReading =\n | BodyReading\n | BloodPressureReading\n | TemperatureReading\n | OxygenReading\n | GlucoseReading\n | HeartRateSession\n | WorkoutReading\n | BodyMeasurementReading;\n\nconst round1 = (n: number) => Math.round(n * 10) / 10;\n\n/** A stable id: the same measurement from the same device always gets the same one. */\nexport function readingId(deviceId: string, kind: DeviceReading['kind'], at: number, extra?: string | number): string {\n return [deviceId, kind, Math.round(at / 1000), extra].filter((p) => p !== undefined && p !== '').join(':');\n}\n\n/** Keep one heart-rate sample per `everyMs`: enough for zones, few enough to store and save. */\nexport function thinSamples(samples: readonly TimedValue[], everyMs = 5_000): TimedValue[] {\n const out: TimedValue[] = [];\n let last = -Infinity;\n for (const s of [...samples].sort((a, b) => a.t - b.t)) {\n if (s.t - last >= everyMs) {\n out.push(s);\n last = s.t;\n }\n }\n return out;\n}\n\nconst latestOf = <T extends DeviceReading>(list: readonly T[], has: (r: T) => boolean): T | undefined =>\n list.filter(has).reduce<T | undefined>((a, b) => (!a || b.at >= a.at ? b : a), undefined);\n\nexport interface DeviceDaysOptions {\n clock: ZoneClock;\n syncedAt: string;\n /** 208 - 0.7 x age, for heart-rate zones; undefined when the birth date is unknown. */\n maxHr?: number;\n /** Only these dates (the ones a new reading touched); every date when omitted. */\n dates?: ReadonlySet<string>;\n}\n\n/** Every reading -> one `device` HealthDay per local date, cleaned exactly as the backend cleans. */\nexport function deviceHealthDays(\n readings: readonly DeviceReading[],\n opts: DeviceDaysOptions,\n): { days: HealthDay[]; dropped: string[] } {\n const byDate = new Map<string, DeviceReading[]>();\n for (const r of readings) {\n const date = opts.clock.dateOf(r.at);\n if (opts.dates && !opts.dates.has(date)) continue;\n byDate.set(date, [...(byDate.get(date) ?? []), r]);\n }\n const dropped: string[] = [];\n const days: HealthDay[] = [];\n for (const [date, list] of [...byDate.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n const day: HealthDay = { date, source: 'device' };\n const body = list.filter((r): r is BodyReading => r.kind === 'body');\n const weight = latestOf(body, (r) => r.weightKg !== undefined);\n if (weight) day.weightKg = weight.weightKg;\n const fat = latestOf(body, (r) => r.bodyFatPct !== undefined);\n if (fat) day.bodyFatPct = fat.bodyFatPct;\n const lean = latestOf(body, (r) => r.leanMassKg !== undefined);\n if (lean) day.leanMassKg = lean.leanMassKg;\n const bmi = latestOf(body, (r) => r.bmi !== undefined);\n if (bmi) day.bmi = bmi.bmi;\n const temp = latestOf(\n list.filter((r): r is TemperatureReading => r.kind === 'temperature'),\n () => true,\n );\n if (temp) day.bodyTempC = temp.celsius;\n const spo2 = latestOf(\n list.filter((r): r is OxygenReading => r.kind === 'spo2'),\n () => true,\n );\n if (spo2) day.spo2 = spo2.spo2;\n const waist = latestOf(\n list.filter((r): r is BodyMeasurementReading => r.kind === 'body-measurement' && r.bodyPart === 'waist'),\n () => true,\n );\n if (waist) day.waistCm = waist.cm;\n\n const readingsOut: HealthReading[] = [];\n for (const r of list) {\n if (r.kind === 'blood-pressure') {\n readingsOut.push({\n id: r.id,\n at: new Date(r.at).toISOString(),\n kind: 'blood-pressure',\n systolic: r.systolic,\n diastolic: r.diastolic,\n ...(r.pulse !== undefined ? { pulse: r.pulse } : {}),\n device: r.deviceName,\n });\n } else if (r.kind === 'glucose') {\n readingsOut.push({\n id: r.id,\n at: new Date(r.at).toISOString(),\n kind: 'glucose',\n glucoseMgDl: r.mgdl,\n ...(r.meal ? { meal: r.meal } : {}),\n device: r.deviceName,\n });\n }\n }\n if (readingsOut.length) day.readings = readingsOut.sort((a, b) => a.at.localeCompare(b.at));\n\n const workouts: HealthWorkout[] = list\n .filter((r): r is HeartRateSession => r.kind === 'heart-rate')\n .sort((a, b) => a.at - b.at)\n .map((s) => {\n const w: HealthWorkout = {\n id: s.id,\n start: new Date(s.at).toISOString(),\n end: new Date(s.end).toISOString(),\n type: s.workoutType,\n durationMin: round1((s.end - s.at) / 60_000),\n avgHr: s.avgHr,\n maxHr: s.maxHr,\n };\n if (opts.maxHr && s.samples.length) {\n w.zoneMinutes = zoneMinutes(s.samples, { start: s.at, end: s.end }, opts.maxHr);\n } else if (s.zoneMinutes) w.zoneMinutes = s.zoneMinutes;\n return w;\n });\n // Device-recorded workouts (jump rope, treadmill): same HealthWorkout shape, no HR samples.\n for (const s of list.filter((r): r is WorkoutReading => r.kind === 'workout').sort((a, b) => a.at - b.at)) {\n const w: HealthWorkout = {\n id: s.id,\n start: new Date(s.at).toISOString(),\n end: new Date(s.end).toISOString(),\n type: s.workoutType,\n durationMin: round1(s.durationMin),\n ...(s.calories !== undefined ? { calories: s.calories } : {}),\n ...(s.distanceMeters !== undefined ? { distanceMeters: s.distanceMeters } : {}),\n ...(s.avgHr !== undefined ? { avgHr: s.avgHr } : {}),\n ...(s.maxHr !== undefined ? { maxHr: s.maxHr } : {}),\n };\n workouts.push(w);\n }\n if (workouts.length) day.workouts = workouts.sort((a, b) => a.start.localeCompare(b.start));\n\n const clean = sanitizeDay(day, dropped);\n if (hasData(clean)) days.push({ ...clean, syncedAt: opts.syncedAt });\n }\n return { days, dropped };\n}\n\n/** One line for a reading, as the person reads it (\"82.4 kg, body fat 23.1%\"). */\nexport function describeReading(r: DeviceReading, units: 'metric' | 'imperial' = 'metric'): string {\n const kg = (v: number) => (units === 'imperial' ? `${round1(v / 0.45359237)} lb` : `${round1(v)} kg`);\n switch (r.kind) {\n case 'body': {\n const parts: string[] = [];\n if (r.weightKg !== undefined) parts.push(kg(r.weightKg));\n if (r.bodyFatPct !== undefined) parts.push(`body fat ${round1(r.bodyFatPct)}%`);\n if (r.bmi !== undefined) parts.push(`BMI ${round1(r.bmi)}`);\n return parts.join(', ') || 'A measurement with no weight';\n }\n case 'blood-pressure':\n return `${Math.round(r.systolic)}/${Math.round(r.diastolic)} mmHg${r.pulse ? `, pulse ${Math.round(r.pulse)}` : ''}`;\n case 'temperature':\n return units === 'imperial' ? `${round1((r.celsius * 9) / 5 + 32)} °F` : `${round1(r.celsius)} °C`;\n case 'spo2':\n return `Blood oxygen ${Math.round(r.spo2)}%${r.pulse ? `, pulse ${Math.round(r.pulse)}` : ''}`;\n case 'glucose':\n return `${Math.round(r.mgdl)} mg/dL${r.meal ? `, ${r.meal.replace('-', ' ')}` : ''}`;\n case 'heart-rate': {\n const minutes = Math.round((r.end - r.at) / 60_000);\n return `${minutes} min, average ${Math.round(r.avgHr)} bpm, max ${Math.round(r.maxHr)}`;\n }\n case 'workout': {\n const parts: string[] = [`${Math.round(r.durationMin)} min`];\n if (r.jumps !== undefined) parts.unshift(`${r.jumps} jumps`);\n if (r.distanceMeters !== undefined) parts.push(`${round1(r.distanceMeters / 1000)} km`);\n if (r.calories !== undefined) parts.push(`${Math.round(r.calories)} kcal`);\n return parts.join(', ');\n }\n case 'body-measurement': {\n const part = r.bodyPart.replace(/_/g, ' ');\n return units === 'imperial' ? `${part} ${round1(r.cm / 2.54)} in` : `${part} ${round1(r.cm)} cm`;\n }\n default:\n return '';\n }\n}\n\n/**\n * A session's samples are only needed until they are uploaded and saved to\n * the health store; after that the zones are kept and the samples let go, so\n * the phone's store stays small.\n */\nexport function compactSession(s: HeartRateSession, maxHr: number | undefined): HeartRateSession {\n if (!s.samples.length) return s;\n const zones = maxHr ? zoneMinutes(s.samples, { start: s.at, end: s.end }, maxHr) : s.zoneMinutes;\n return { ...s, samples: [], ...(zones ? { zoneMinutes: zones } : {}) };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA2GA,MAAM,SAAS,CAAC,CAAA,KAAc,KAAK,KAAM,CAAA,CAAA,GAAI,EAAE,CAAI,GAAA,EAAA;AAG5C,SAAS,SAAU,CAAA,QAAA,EAAkB,IAA6B,EAAA,EAAA,EAAY,KAAiC,EAAA;AACpH,EAAA,OAAO,CAAC,QAAU,EAAA,IAAA,EAAM,KAAK,KAAM,CAAA,EAAA,GAAK,GAAI,CAAG,EAAA,KAAK,CAAE,CAAA,MAAA,CAAO,OAAK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;AAC7F,IACF;AACE,MAAO,OAAA,EAAA;AAAA;AAEb;AAOgB,SAAA,cAAA,CAAe,GAAqB,KAA6C,EAAA;AAC/F,EAAA,IAAI,CAAC,CAAA,CAAE,OAAQ,CAAA,MAAA,EAAe,OAAA,CAAA;AAC9B,EAAA,MAAM,KAAQ,GAAA,KAAA,GAAQ,WAAY,CAAA,CAAA,CAAE,OAAS,EAAA;AAAA,IAC3C,OAAO,CAAE,CAAA,EAAA;AAAA,IACT,KAAK,CAAE,CAAA;AAAA,GACT,EAAG,KAAK,CAAA,GAAI,CAAE,CAAA,WAAA;AACd,EAAA,OAAO,gDACF,CADE,CAAA,EAAA;AAAA,IAEL,SAAS;AAAC,GAAA,CAAA,EACN,KAAQ,GAAA;AAAA,IACV,WAAa,EAAA;AAAA,MACX,EAAC,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"readings.js","sources":["../../../src/features/devices/readings.ts"],"sourcesContent":["/**\n * What a paired Bluetooth device measured, and how it reaches the Fitness\n * backend.\n *\n * The backend keeps ONE day per source and replaces it whole on every upload,\n * so a reading is never sent alone: the app keeps every reading it took (the\n * device store), and each upload rebuilds the full `device` day for the dates\n * that changed. A blood-pressure reading in the evening never wipes the\n * morning's weigh-in.\n *\n * Reading ids are stable (device + what + when): a monitor that sends its\n * whole memory on every connection, or the same reading arriving twice, is\n * stored once.\n */\n\nimport type { BodyComposition } from './bodyComposition';\nimport { sanitizeDay, hasData } from '../health/buildDays';\nimport type { TimedValue } from '../health/model';\nimport type { HealthDay, HealthReading, HealthWorkout, MealRelation } from '../health/types';\nimport type { ZoneClock } from '../health/time';\nimport { zoneMinutes } from '../health/zones';\n\ninterface ReadingBase {\n id: string;\n /** Epoch ms of the measurement. */\n at: number;\n deviceId: string;\n deviceName: string;\n}\n\nexport interface BodyReading extends ReadingBase {\n kind: 'body';\n weightKg?: number;\n bodyFatPct?: number;\n leanMassKg?: number;\n bmi?: number;\n /**\n * Whole-body impedance in ohms, when the scale sends it. A scale that only\n * reports weight and impedance (RENPHO's common protocol) leaves body fat\n * to Yantra's own estimate; one that computes body fat itself (R-A017) also\n * fills bodyFatPct and bmi.\n */\n impedanceOhm?: number;\n /**\n * The full body composition (muscle, bone, water, BMR, metabolic age ...),\n * computed from weight + body fat + the person's height/age/sex when all are\n * known (bodyComposition.ts). Shown on the reading; the backend day keeps\n * the fields it supports.\n */\n composition?: BodyComposition;\n}\n\nexport interface BloodPressureReading extends ReadingBase {\n kind: 'blood-pressure';\n systolic: number;\n diastolic: number;\n pulse?: number;\n /** What the monitor flagged (moved, loose cuff, irregular pulse), in words. */\n problems?: string[];\n}\n\nexport interface TemperatureReading extends ReadingBase {\n kind: 'temperature';\n celsius: number;\n}\n\nexport interface OxygenReading extends ReadingBase {\n kind: 'spo2';\n spo2: number;\n pulse?: number;\n}\n\nexport interface GlucoseReading extends ReadingBase {\n kind: 'glucose';\n mgdl: number;\n meal?: MealRelation;\n}\n\n/** A heart-rate strap worn for a session: the samples, summed up when it ended. */\nexport interface HeartRateSession extends ReadingBase {\n kind: 'heart-rate';\n /** `at` is the start. */\n end: number;\n /** run | walk | cycle | strength | hiit | other, as the person picked it. */\n workoutType: string;\n avgHr: number;\n maxHr: number;\n /** At most one sample every few seconds (see thinSamples); emptied once saved, see compactSession. */\n samples: TimedValue[];\n /** Minutes per heart-rate zone, kept when the samples are let go. */\n zoneMinutes?: number[];\n}\n\n/**\n * A finished exercise a device recorded itself: a jump-rope session or a\n * treadmill walk/run. Becomes one HealthWorkout in the day (readings with no\n * heart-rate samples, unlike HeartRateSession).\n */\nexport interface WorkoutReading extends ReadingBase {\n kind: 'workout';\n /** `at` is the start. */\n end: number;\n /** jump-rope | run | walk | ... lowercased. */\n workoutType: string;\n durationMin: number;\n calories?: number;\n distanceMeters?: number;\n /** Jump rope only: the number of skips. */\n jumps?: number;\n avgHr?: number;\n maxHr?: number;\n}\n\n/** A tape-measure girth reading of one body part. Only the waist has a home in the day. */\nexport interface BodyMeasurementReading extends ReadingBase {\n kind: 'body-measurement';\n /** waist | chest | hip | left_arm | ... as the tape reported it. */\n bodyPart: string;\n cm: number;\n}\n\nexport type DeviceReading =\n | BodyReading\n | BloodPressureReading\n | TemperatureReading\n | OxygenReading\n | GlucoseReading\n | HeartRateSession\n | WorkoutReading\n | BodyMeasurementReading;\n\nconst round1 = (n: number) => Math.round(n * 10) / 10;\n\n/** A stable id: the same measurement from the same device always gets the same one. */\nexport function readingId(deviceId: string, kind: DeviceReading['kind'], at: number, extra?: string | number): string {\n return [deviceId, kind, Math.round(at / 1000), extra].filter((p) => p !== undefined && p !== '').join(':');\n}\n\n/** Keep one heart-rate sample per `everyMs`: enough for zones, few enough to store and save. */\nexport function thinSamples(samples: readonly TimedValue[], everyMs = 5_000): TimedValue[] {\n const out: TimedValue[] = [];\n let last = -Infinity;\n for (const s of [...samples].sort((a, b) => a.t - b.t)) {\n if (s.t - last >= everyMs) {\n out.push(s);\n last = s.t;\n }\n }\n return out;\n}\n\nconst latestOf = <T extends DeviceReading>(list: readonly T[], has: (r: T) => boolean): T | undefined =>\n list.filter(has).reduce<T | undefined>((a, b) => (!a || b.at >= a.at ? b : a), undefined);\n\nexport interface DeviceDaysOptions {\n clock: ZoneClock;\n syncedAt: string;\n /** 208 - 0.7 x age, for heart-rate zones; undefined when the birth date is unknown. */\n maxHr?: number;\n /** Only these dates (the ones a new reading touched); every date when omitted. */\n dates?: ReadonlySet<string>;\n}\n\n/** Every reading -> one `device` HealthDay per local date, cleaned exactly as the backend cleans. */\nexport function deviceHealthDays(\n readings: readonly DeviceReading[],\n opts: DeviceDaysOptions,\n): { days: HealthDay[]; dropped: string[] } {\n const byDate = new Map<string, DeviceReading[]>();\n for (const r of readings) {\n const date = opts.clock.dateOf(r.at);\n if (opts.dates && !opts.dates.has(date)) continue;\n byDate.set(date, [...(byDate.get(date) ?? []), r]);\n }\n const dropped: string[] = [];\n const days: HealthDay[] = [];\n for (const [date, list] of [...byDate.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n const day: HealthDay = { date, source: 'device' };\n const body = list.filter((r): r is BodyReading => r.kind === 'body');\n const weight = latestOf(body, (r) => r.weightKg !== undefined);\n if (weight) day.weightKg = weight.weightKg;\n const fat = latestOf(body, (r) => r.bodyFatPct !== undefined);\n if (fat) day.bodyFatPct = fat.bodyFatPct;\n const lean = latestOf(body, (r) => r.leanMassKg !== undefined);\n if (lean) day.leanMassKg = lean.leanMassKg;\n const bmi = latestOf(body, (r) => r.bmi !== undefined);\n if (bmi) day.bmi = bmi.bmi;\n const temp = latestOf(\n list.filter((r): r is TemperatureReading => r.kind === 'temperature'),\n () => true,\n );\n if (temp) day.bodyTempC = temp.celsius;\n const spo2 = latestOf(\n list.filter((r): r is OxygenReading => r.kind === 'spo2'),\n () => true,\n );\n if (spo2) day.spo2 = spo2.spo2;\n const waist = latestOf(\n list.filter((r): r is BodyMeasurementReading => r.kind === 'body-measurement' && r.bodyPart === 'waist'),\n () => true,\n );\n if (waist) day.waistCm = waist.cm;\n\n const readingsOut: HealthReading[] = [];\n for (const r of list) {\n if (r.kind === 'blood-pressure') {\n readingsOut.push({\n id: r.id,\n at: new Date(r.at).toISOString(),\n kind: 'blood-pressure',\n systolic: r.systolic,\n diastolic: r.diastolic,\n ...(r.pulse !== undefined ? { pulse: r.pulse } : {}),\n device: r.deviceName,\n });\n } else if (r.kind === 'glucose') {\n readingsOut.push({\n id: r.id,\n at: new Date(r.at).toISOString(),\n kind: 'glucose',\n glucoseMgDl: r.mgdl,\n ...(r.meal ? { meal: r.meal } : {}),\n device: r.deviceName,\n });\n }\n }\n if (readingsOut.length) day.readings = readingsOut.sort((a, b) => a.at.localeCompare(b.at));\n\n const workouts: HealthWorkout[] = list\n .filter((r): r is HeartRateSession => r.kind === 'heart-rate')\n .sort((a, b) => a.at - b.at)\n .map((s) => {\n const w: HealthWorkout = {\n id: s.id,\n start: new Date(s.at).toISOString(),\n end: new Date(s.end).toISOString(),\n type: s.workoutType,\n durationMin: round1((s.end - s.at) / 60_000),\n avgHr: s.avgHr,\n maxHr: s.maxHr,\n };\n if (opts.maxHr && s.samples.length) {\n w.zoneMinutes = zoneMinutes(s.samples, { start: s.at, end: s.end }, opts.maxHr);\n } else if (s.zoneMinutes) w.zoneMinutes = s.zoneMinutes;\n return w;\n });\n // Device-recorded workouts (jump rope, treadmill): same HealthWorkout shape, no HR samples.\n for (const s of list.filter((r): r is WorkoutReading => r.kind === 'workout').sort((a, b) => a.at - b.at)) {\n const w: HealthWorkout = {\n id: s.id,\n start: new Date(s.at).toISOString(),\n end: new Date(s.end).toISOString(),\n type: s.workoutType,\n durationMin: round1(s.durationMin),\n ...(s.calories !== undefined ? { calories: s.calories } : {}),\n ...(s.distanceMeters !== undefined ? { distanceMeters: s.distanceMeters } : {}),\n ...(s.avgHr !== undefined ? { avgHr: s.avgHr } : {}),\n ...(s.maxHr !== undefined ? { maxHr: s.maxHr } : {}),\n };\n workouts.push(w);\n }\n if (workouts.length) day.workouts = workouts.sort((a, b) => a.start.localeCompare(b.start));\n\n const clean = sanitizeDay(day, dropped);\n if (hasData(clean)) days.push({ ...clean, syncedAt: opts.syncedAt });\n }\n return { days, dropped };\n}\n\n/** One line for a reading, as the person reads it (\"82.4 kg, body fat 23.1%\"). */\nexport function describeReading(r: DeviceReading, units: 'metric' | 'imperial' = 'metric'): string {\n const kg = (v: number) => (units === 'imperial' ? `${round1(v / 0.45359237)} lb` : `${round1(v)} kg`);\n switch (r.kind) {\n case 'body': {\n const parts: string[] = [];\n if (r.weightKg !== undefined) parts.push(kg(r.weightKg));\n if (r.bodyFatPct !== undefined) parts.push(`body fat ${round1(r.bodyFatPct)}%`);\n if (r.bmi !== undefined) parts.push(`BMI ${round1(r.bmi)}`);\n return parts.join(', ') || 'A measurement with no weight';\n }\n case 'blood-pressure':\n return `${Math.round(r.systolic)}/${Math.round(r.diastolic)} mmHg${r.pulse ? `, pulse ${Math.round(r.pulse)}` : ''}`;\n case 'temperature':\n return units === 'imperial' ? `${round1((r.celsius * 9) / 5 + 32)} °F` : `${round1(r.celsius)} °C`;\n case 'spo2':\n return `Blood oxygen ${Math.round(r.spo2)}%${r.pulse ? `, pulse ${Math.round(r.pulse)}` : ''}`;\n case 'glucose':\n return `${Math.round(r.mgdl)} mg/dL${r.meal ? `, ${r.meal.replace('-', ' ')}` : ''}`;\n case 'heart-rate': {\n const minutes = Math.round((r.end - r.at) / 60_000);\n return `${minutes} min, average ${Math.round(r.avgHr)} bpm, max ${Math.round(r.maxHr)}`;\n }\n case 'workout': {\n const parts: string[] = [`${Math.round(r.durationMin)} min`];\n if (r.jumps !== undefined) parts.unshift(`${r.jumps} jumps`);\n if (r.distanceMeters !== undefined) parts.push(`${round1(r.distanceMeters / 1000)} km`);\n if (r.calories !== undefined) parts.push(`${Math.round(r.calories)} kcal`);\n return parts.join(', ');\n }\n case 'body-measurement': {\n const part = r.bodyPart.replace(/_/g, ' ');\n return units === 'imperial' ? `${part} ${round1(r.cm / 2.54)} in` : `${part} ${round1(r.cm)} cm`;\n }\n default:\n return '';\n }\n}\n\n/**\n * A session's samples are only needed until they are uploaded and saved to\n * the health store; after that the zones are kept and the samples let go, so\n * the phone's store stays small.\n */\nexport function compactSession(s: HeartRateSession, maxHr: number | undefined): HeartRateSession {\n if (!s.samples.length) return s;\n const zones = maxHr ? zoneMinutes(s.samples, { start: s.at, end: s.end }, maxHr) : s.zoneMinutes;\n return { ...s, samples: [], ...(zones ? { zoneMinutes: zones } : {}) };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmHA,MAAM,SAAS,CAAC,CAAA,KAAc,KAAK,KAAM,CAAA,CAAA,GAAI,EAAE,CAAI,GAAA,EAAA;AAG5C,SAAS,SAAU,CAAA,QAAA,EAAkB,IAA6B,EAAA,EAAA,EAAY,KAAiC,EAAA;AACpH,EAAA,OAAO,CAAC,QAAU,EAAA,IAAA,EAAM,KAAK,KAAM,CAAA,EAAA,GAAK,GAAI,CAAG,EAAA,KAAK,CAAE,CAAA,MAAA,CAAO,OA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A;AAC7F,IACF;AACE,MAAO,OAAA,EAAA;AAAA;AAEb;AAOgB,SAAA,cAAA,CAAe,GAAqB,KAA6C,EAAA;AAC/F,EAAA,IAAI,CAAC,CAAA,CAAE,OAAQ,CAAA,MAAA,EAAe,OAAA,CAAA;AAC9B,EAAA,MAAM,KAAQ,GAAA,KAAA,GAAQ,WAAY,CAAA,CAAA,CAAE,OAAS,EAAA;AAAA,IAC3C,OAAO,CAAE,CAAA,EAAA;AAAA,IACT,KAAK,CAAE,CAAA;AAAA,GACT,EAAG,KAAK,CAAA,GAAI,CAAE,CAAA,WAAA;AACd,EAAA,OAAO,gDACF,CADE,CAAA,EAAA;AAAA,IAEL,SAAS;AAAC,GAAA,CAAA,EACN,KAAQ,GAAA;AAAA,IACV,WAAa,EAAA;AAAA,MACX,EAAC,CAAA;AAET"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {deviceKind}from'./catalog.js';import {describeBleError}from'./link.js';import {thinSamples,readingId}from'./readings.js';import'./brands/frames.js';import'./brands/uuids.js';import'./gatt/uuids.js';import {detectBrand}from'./brands/detect.js';import {startDriver}from'./drivers.js';var __defProp = Object.defineProperty;
|
|
1
|
+
import {deviceKind}from'./catalog.js';import {describeBleError}from'./link.js';import {thinSamples,readingId}from'./readings.js';import'./brands/frames.js';import'./brands/uuids.js';import'./gatt/uuids.js';import {detectBrand}from'./brands/detect.js';import {startDriver}from'./drivers.js';import {computeBodyComposition}from'./bodyComposition.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -24,6 +24,26 @@ function ageFrom(birthDate, now) {
|
|
|
24
24
|
const t = Date.parse(`${birthDate}T00:00:00Z`);
|
|
25
25
|
return Number.isFinite(t) ? Math.floor((now - t) / (365.25 * 864e5)) : void 0;
|
|
26
26
|
}
|
|
27
|
+
function enrichWithComposition(reading, facts) {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
if (reading.kind !== "body" || reading.weightKg === void 0 || reading.bodyFatPct === void 0) {
|
|
30
|
+
return reading;
|
|
31
|
+
}
|
|
32
|
+
if (!facts.heightCm || facts.age === void 0) return reading;
|
|
33
|
+
const composition = computeBodyComposition({
|
|
34
|
+
weightKg: reading.weightKg,
|
|
35
|
+
bodyFatPct: reading.bodyFatPct,
|
|
36
|
+
heightCm: facts.heightCm,
|
|
37
|
+
age: facts.age,
|
|
38
|
+
sex: (_a = facts.sex) != null ? _a : "unspecified",
|
|
39
|
+
impedanceOhm: reading.impedanceOhm
|
|
40
|
+
});
|
|
41
|
+
return __spreadProps(__spreadValues({}, reading), {
|
|
42
|
+
bmi: (_b = reading.bmi) != null ? _b : composition.bmi,
|
|
43
|
+
leanMassKg: (_c = reading.leanMassKg) != null ? _c : composition.leanMassKg,
|
|
44
|
+
composition
|
|
45
|
+
});
|
|
46
|
+
}
|
|
27
47
|
class DeviceSession {
|
|
28
48
|
constructor(deps) {
|
|
29
49
|
this.deps = deps;
|
|
@@ -187,7 +207,7 @@ class DeviceSession {
|
|
|
187
207
|
} : void 0,
|
|
188
208
|
scaleUser: paired == null ? void 0 : paired.scaleUser,
|
|
189
209
|
saveScaleUser: (user) => store.saveScaleUser(link.id, user),
|
|
190
|
-
onReading: (r) => void this.keep([r]),
|
|
210
|
+
onReading: (r) => void this.keep([enrichWithComposition(r, facts)]),
|
|
191
211
|
onLive: (v) => this.onLive(v),
|
|
192
212
|
onNotice: (m) => this.set({
|
|
193
213
|
notices: [...this.snapshot.notices, m]
|