@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.1
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/.claude-flow/data/pending-insights.jsonl +43 -0
- package/.claude-flow/sessions/session-1794323376548.json +14 -0
- package/CHANGELOG.md +41 -0
- package/jest.config.cjs +22 -0
- package/lib/assets/home/loop-day.jpg +0 -0
- package/lib/assets/home/loop-day.mp4 +0 -0
- package/lib/assets/home/loop-time-back.jpg +0 -0
- package/lib/assets/home/loop-time-back.mp4 +0 -0
- package/lib/assets/home/loop-where.jpg +0 -0
- package/lib/assets/home/loop-where.mp4 +0 -0
- package/lib/assets/home/reel-gym.jpg +0 -0
- package/lib/assets/home/reel-gym.mp4 +0 -0
- package/lib/assets/home/reel-internet.jpg +0 -0
- package/lib/assets/home/reel-internet.mp4 +0 -0
- package/lib/assets/icon.png +0 -0
- package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/lib/assets/lottie/lucy-mark-call.json +1470 -0
- package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
- package/lib/assets/lottie/lucy-mark-details.json +1735 -0
- package/lib/assets/lottie/lucy-mark-email.json +1363 -0
- package/lib/assets/lottie/lucy-mark-message.json +1154 -0
- package/lib/assets/lottie/lucy-mark-search.json +1067 -0
- package/lib/assets/lottie/lucy-mark-think.json +1253 -0
- package/lib/assets/lottie/lucy-mark-write.json +1532 -0
- package/lib/assets/lottie/time-back.json +16458 -0
- package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/lib/assets/sounds/hours-back.m4a +0 -0
- package/lib/assets/sounds/meet-lucy.m4a +0 -0
- package/lib/assets/sounds/power-on.m4a +0 -0
- package/lib/assets/sounds/wind-back.m4a +0 -0
- package/lib/assets/sounds/youre-in.m4a +0 -0
- package/lib/chat/agent.js +358 -0
- package/lib/chat/agent.js.map +1 -0
- package/lib/chat/appFront.js +32 -0
- package/lib/chat/appFront.js.map +1 -0
- package/lib/chat/auth.js +370 -0
- package/lib/chat/auth.js.map +1 -0
- package/lib/chat/chores.js +360 -0
- package/lib/chat/chores.js.map +1 -0
- package/lib/chat/connectors.js +45 -0
- package/lib/chat/connectors.js.map +1 -0
- package/lib/chat/jobs.js +223 -0
- package/lib/chat/jobs.js.map +1 -0
- package/lib/chat/lucyMotion.js +6 -0
- package/lib/chat/lucyMotion.js.map +1 -0
- package/lib/chat/protocol.js +111 -0
- package/lib/chat/protocol.js.map +1 -0
- package/lib/chat/results.js +133 -0
- package/lib/chat/results.js.map +1 -0
- package/lib/chat/store.js +81 -0
- package/lib/chat/store.js.map +1 -0
- package/lib/chat/useDictation.js +168 -0
- package/lib/chat/useDictation.js.map +1 -0
- package/lib/chat/useLucyChat.js +451 -0
- package/lib/chat/useLucyChat.js.map +1 -0
- package/lib/chat/useMyComputer.js +32 -0
- package/lib/chat/useMyComputer.js.map +1 -0
- package/lib/chat/whereLucyWorks.js +52 -0
- package/lib/chat/whereLucyWorks.js.map +1 -0
- package/lib/chat/workspace.js +124 -0
- package/lib/chat/workspace.js.map +1 -0
- package/lib/components/AreaShot.js +289 -0
- package/lib/components/AreaShot.js.map +1 -0
- package/lib/components/Backdrops.js +262 -0
- package/lib/components/Backdrops.js.map +1 -0
- package/lib/components/BottomSheet.js +61 -0
- package/lib/components/BottomSheet.js.map +1 -0
- package/lib/components/ChatSheets.js +429 -0
- package/lib/components/ChatSheets.js.map +1 -0
- package/lib/components/ConnectorLogo.js +91 -0
- package/lib/components/ConnectorLogo.js.map +1 -0
- package/lib/components/CustomDrawer.js +534 -0
- package/lib/components/CustomDrawer.js.map +1 -0
- package/lib/components/IdeasPane.js +394 -0
- package/lib/components/IdeasPane.js.map +1 -0
- package/lib/components/ImessageSheet.js +261 -0
- package/lib/components/ImessageSheet.js.map +1 -0
- package/lib/components/KeyboardAvoider.js +29 -0
- package/lib/components/KeyboardAvoider.js.map +1 -0
- package/lib/components/Logo.js +81 -0
- package/lib/components/Logo.js.map +1 -0
- package/lib/components/LucyWorking.js +67 -0
- package/lib/components/LucyWorking.js.map +1 -0
- package/lib/components/Markdown.js +260 -0
- package/lib/components/Markdown.js.map +1 -0
- package/lib/components/Media.js +93 -0
- package/lib/components/Media.js.map +1 -0
- package/lib/components/MessagesAppIcon.js +23 -0
- package/lib/components/MessagesAppIcon.js.map +1 -0
- package/lib/components/MicButton.js +71 -0
- package/lib/components/MicButton.js.map +1 -0
- package/lib/components/ResultCards.js +974 -0
- package/lib/components/ResultCards.js.map +1 -0
- package/lib/components/SignInPrompt.js +148 -0
- package/lib/components/SignInPrompt.js.map +1 -0
- package/lib/components/SignedOut.js +38 -0
- package/lib/components/SignedOut.js.map +1 -0
- package/lib/components/TalkToLucyHero.js +487 -0
- package/lib/components/TalkToLucyHero.js.map +1 -0
- package/lib/components/TalkToLucySheet.js +182 -0
- package/lib/components/TalkToLucySheet.js.map +1 -0
- package/lib/components/WhereLucyWorks.js +277 -0
- package/lib/components/WhereLucyWorks.js.map +1 -0
- package/lib/components/WorkspaceSection.js +271 -0
- package/lib/components/WorkspaceSection.js.map +1 -0
- package/lib/components/YantraMark.js +13 -0
- package/lib/components/YantraMark.js.map +1 -0
- package/lib/components/drawerHeader.js +38 -0
- package/lib/components/drawerHeader.js.map +1 -0
- package/lib/components/lottieInstalled.js +6 -0
- package/lib/components/lottieInstalled.js.map +1 -0
- package/lib/components/ui.js +550 -0
- package/lib/components/ui.js.map +1 -0
- package/lib/components/useSignOut.js +7 -0
- package/lib/components/useSignOut.js.map +1 -0
- package/lib/components/viewport.js +121 -0
- package/lib/components/viewport.js.map +1 -0
- package/lib/components/voiceDial.js +10 -0
- package/lib/components/voiceDial.js.map +1 -0
- package/lib/compute.js +157 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.js +27 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/routes.js +15 -0
- package/lib/config/routes.js.map +1 -0
- package/lib/content.js +25 -0
- package/lib/content.js.map +1 -0
- package/lib/hooks/keyboardCover.js +39 -0
- package/lib/hooks/keyboardCover.js.map +1 -0
- package/lib/hooks/useKeyboard.js +121 -0
- package/lib/hooks/useKeyboard.js.map +1 -0
- package/lib/hooks/useReducedMotion.js +13 -0
- package/lib/hooks/useReducedMotion.js.map +1 -0
- package/lib/imessage/openMessages.js +25 -0
- package/lib/imessage/openMessages.js.map +1 -0
- package/lib/imessage/platform.js +12 -0
- package/lib/imessage/platform.js.map +1 -0
- package/lib/imessage/textLink.js +262 -0
- package/lib/imessage/textLink.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/live/card.js +28 -0
- package/lib/live/card.js.map +1 -0
- package/lib/live/liveActivity.js +144 -0
- package/lib/live/liveActivity.js.map +1 -0
- package/lib/module.js +3 -0
- package/lib/module.js.map +1 -0
- package/lib/offer/BlackFridayOffer.js +378 -0
- package/lib/offer/BlackFridayOffer.js.map +1 -0
- package/lib/offer/blackFriday.js +78 -0
- package/lib/offer/blackFriday.js.map +1 -0
- package/lib/offer/parts.js +624 -0
- package/lib/offer/parts.js.map +1 -0
- package/lib/offer/state.js +63 -0
- package/lib/offer/state.js.map +1 -0
- package/lib/push/push.js +142 -0
- package/lib/push/push.js.map +1 -0
- package/lib/push/usePushNotifications.js +39 -0
- package/lib/push/usePushNotifications.js.map +1 -0
- package/lib/routes.json +175 -0
- package/lib/screens/Account/index.js +209 -0
- package/lib/screens/Account/index.js.map +1 -0
- package/lib/screens/Chat/index.js +710 -0
- package/lib/screens/Chat/index.js.map +1 -0
- package/lib/screens/Chores/index.js +18 -0
- package/lib/screens/Chores/index.js.map +1 -0
- package/lib/screens/Connectors/index.js +17 -0
- package/lib/screens/Connectors/index.js.map +1 -0
- package/lib/screens/History/index.js +380 -0
- package/lib/screens/History/index.js.map +1 -0
- package/lib/screens/Home/index.js +2715 -0
- package/lib/screens/Home/index.js.map +1 -0
- package/lib/screens/Home/media.js +25 -0
- package/lib/screens/Home/media.js.map +1 -0
- package/lib/screens/Welcome/index.js +1066 -0
- package/lib/screens/Welcome/index.js.map +1 -0
- package/lib/talk/talkToLucy.js +139 -0
- package/lib/talk/talkToLucy.js.map +1 -0
- package/lib/theme/colors.js +29 -0
- package/lib/theme/colors.js.map +1 -0
- package/lib/theme/fonts.js +17 -0
- package/lib/theme/fonts.js.map +1 -0
- package/lib/theme/muse.js +134 -0
- package/lib/theme/muse.js.map +1 -0
- package/lib/utils/links.js +54 -0
- package/lib/utils/links.js.map +1 -0
- package/lib/utils/yantraLinks.js +68 -0
- package/lib/utils/yantraLinks.js.map +1 -0
- package/lib/welcome/flow.js +375 -0
- package/lib/welcome/flow.js.map +1 -0
- package/lib/welcome/haptics.js +125 -0
- package/lib/welcome/haptics.js.map +1 -0
- package/lib/welcome/parts.js +1996 -0
- package/lib/welcome/parts.js.map +1 -0
- package/lib/welcome/powerOn.js +29 -0
- package/lib/welcome/powerOn.js.map +1 -0
- package/lib/welcome/seen.js +41 -0
- package/lib/welcome/seen.js.map +1 -0
- package/lib/welcome/sound.js +110 -0
- package/lib/welcome/sound.js.map +1 -0
- package/package.json +66 -5
- package/rollup.config.mjs +42 -0
- package/src/.claude-flow/data/pending-insights.jsonl +19 -0
- package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
- package/src/__tests__/auth.test.ts +94 -0
- package/src/__tests__/blackFriday.test.ts +75 -0
- package/src/__tests__/cardTokens.test.ts +77 -0
- package/src/__tests__/chores.test.ts +188 -0
- package/src/__tests__/choresList.test.ts +100 -0
- package/src/__tests__/connectLink.test.ts +21 -0
- package/src/__tests__/content.test.ts +54 -0
- package/src/__tests__/dictation.test.ts +186 -0
- package/src/__tests__/envConfig.test.ts +14 -0
- package/src/__tests__/haptics.test.ts +202 -0
- package/src/__tests__/jobs.test.ts +130 -0
- package/src/__tests__/keyboardCover.test.ts +84 -0
- package/src/__tests__/liveCard.test.ts +39 -0
- package/src/__tests__/lockedPhone.test.ts +355 -0
- package/src/__tests__/lucyMotion.test.ts +34 -0
- package/src/__tests__/platform.test.ts +32 -0
- package/src/__tests__/powerOn.test.ts +62 -0
- package/src/__tests__/protocol.test.ts +125 -0
- package/src/__tests__/push.test.ts +111 -0
- package/src/__tests__/results.test.ts +256 -0
- package/src/__tests__/sound.test.ts +248 -0
- package/src/__tests__/talkToLucy.test.ts +205 -0
- package/src/__tests__/textLink.test.ts +91 -0
- package/src/__tests__/voiceDial.test.ts +53 -0
- package/src/__tests__/welcomeFlow.test.ts +157 -0
- package/src/__tests__/whereLucyWorks.test.ts +81 -0
- package/src/__tests__/yantraLinks.test.ts +96 -0
- package/src/assets/home/loop-day.jpg +0 -0
- package/src/assets/home/loop-day.mp4 +0 -0
- package/src/assets/home/loop-time-back.jpg +0 -0
- package/src/assets/home/loop-time-back.mp4 +0 -0
- package/src/assets/home/loop-where.jpg +0 -0
- package/src/assets/home/loop-where.mp4 +0 -0
- package/src/assets/home/reel-gym.jpg +0 -0
- package/src/assets/home/reel-gym.mp4 +0 -0
- package/src/assets/home/reel-internet.jpg +0 -0
- package/src/assets/home/reel-internet.mp4 +0 -0
- package/src/assets/icon.png +0 -0
- package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/src/assets/lottie/lucy-mark-call.json +1470 -0
- package/src/assets/lottie/lucy-mark-connect.json +2552 -0
- package/src/assets/lottie/lucy-mark-details.json +1735 -0
- package/src/assets/lottie/lucy-mark-email.json +1363 -0
- package/src/assets/lottie/lucy-mark-message.json +1154 -0
- package/src/assets/lottie/lucy-mark-search.json +1067 -0
- package/src/assets/lottie/lucy-mark-think.json +1253 -0
- package/src/assets/lottie/lucy-mark-write.json +1532 -0
- package/src/assets/lottie/time-back.json +16458 -0
- package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/src/assets/sounds/hours-back.m4a +0 -0
- package/src/assets/sounds/meet-lucy.m4a +0 -0
- package/src/assets/sounds/power-on.m4a +0 -0
- package/src/assets/sounds/wind-back.m4a +0 -0
- package/src/assets/sounds/youre-in.m4a +0 -0
- package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/chat/agent.ts +376 -0
- package/src/chat/appFront.ts +39 -0
- package/src/chat/auth.ts +433 -0
- package/src/chat/chores.ts +394 -0
- package/src/chat/connectors.ts +75 -0
- package/src/chat/jobs.ts +228 -0
- package/src/chat/lucyMotion.ts +33 -0
- package/src/chat/protocol.ts +192 -0
- package/src/chat/results.ts +224 -0
- package/src/chat/store.ts +87 -0
- package/src/chat/useDictation.ts +201 -0
- package/src/chat/useLucyChat.ts +458 -0
- package/src/chat/useMyComputer.ts +41 -0
- package/src/chat/whereLucyWorks.ts +97 -0
- package/src/chat/workspace.ts +127 -0
- package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
- package/src/components/AreaShot.tsx +239 -0
- package/src/components/Backdrops.tsx +323 -0
- package/src/components/BottomSheet.tsx +96 -0
- package/src/components/ChatSheets.tsx +565 -0
- package/src/components/ConnectorLogo.tsx +116 -0
- package/src/components/CustomDrawer.tsx +526 -0
- package/src/components/IdeasPane.tsx +318 -0
- package/src/components/ImessageSheet.tsx +280 -0
- package/src/components/KeyboardAvoider.tsx +45 -0
- package/src/components/Logo.tsx +97 -0
- package/src/components/LucyWorking.tsx +122 -0
- package/src/components/Markdown.tsx +219 -0
- package/src/components/Media.tsx +173 -0
- package/src/components/MessagesAppIcon.tsx +51 -0
- package/src/components/MicButton.tsx +92 -0
- package/src/components/ResultCards.tsx +1067 -0
- package/src/components/SignInPrompt.tsx +182 -0
- package/src/components/SignedOut.tsx +47 -0
- package/src/components/TalkToLucyHero.tsx +540 -0
- package/src/components/TalkToLucySheet.tsx +208 -0
- package/src/components/VoiceOrb.tsx +364 -0
- package/src/components/WhereLucyWorks.tsx +261 -0
- package/src/components/WorkspaceSection.tsx +307 -0
- package/src/components/YantraMark.tsx +30 -0
- package/src/components/drawerHeader.tsx +46 -0
- package/src/components/kit.tsx +309 -0
- package/src/components/lottieInstalled.ts +7 -0
- package/src/components/ui.tsx +700 -0
- package/src/components/useSignOut.ts +21 -0
- package/src/components/viewport.tsx +166 -0
- package/src/components/voiceDial.ts +45 -0
- package/src/compute.ts +168 -0
- package/src/config/env-config.ts +50 -0
- package/src/config/routes.ts +28 -0
- package/src/content.ts +217 -0
- package/src/hooks/keyboardCover.ts +70 -0
- package/src/hooks/useKeyboard.ts +135 -0
- package/src/hooks/useReducedMotion.ts +19 -0
- package/src/imessage/openMessages.ts +53 -0
- package/src/imessage/platform.ts +32 -0
- package/src/imessage/textLink.ts +307 -0
- package/src/index.ts +24 -0
- package/src/live/card.ts +62 -0
- package/src/live/liveActivity.ts +192 -0
- package/src/module.ts +8 -0
- package/src/offer/BlackFridayOffer.tsx +394 -0
- package/src/offer/blackFriday.ts +109 -0
- package/src/offer/parts.tsx +650 -0
- package/src/offer/state.ts +78 -0
- package/src/push/push.ts +171 -0
- package/src/push/usePushNotifications.ts +47 -0
- package/src/screens/Account/index.tsx +310 -0
- package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
- package/src/screens/Chat/index.tsx +891 -0
- package/src/screens/Chores/index.tsx +35 -0
- package/src/screens/Connectors/index.tsx +35 -0
- package/src/screens/History/index.tsx +346 -0
- package/src/screens/Home/index.tsx +2776 -0
- package/src/screens/Home/media.ts +31 -0
- package/src/screens/Welcome/index.tsx +1182 -0
- package/src/talk/talkToLucy.ts +187 -0
- package/src/theme/colors.ts +38 -0
- package/src/theme/fonts.ts +30 -0
- package/src/theme/muse.ts +86 -0
- package/src/utils/links.ts +84 -0
- package/src/utils/yantraLinks.ts +94 -0
- package/src/welcome/flow.ts +418 -0
- package/src/welcome/haptics.ts +179 -0
- package/src/welcome/parts.tsx +2160 -0
- package/src/welcome/powerOn.ts +84 -0
- package/src/welcome/seen.ts +68 -0
- package/src/welcome/sound.ts +173 -0
- package/tools/lottie/chat.motion +0 -0
- package/tools/lottie/cloud.motion +0 -0
- package/tools/lottie/generate.mjs +1209 -0
- package/tools/lottie/inter-glyphs.json +4416 -0
- package/tools/lottie/lucy-mark-calendar.motion +0 -0
- package/tools/lottie/lucy-mark-call.motion +0 -0
- package/tools/lottie/lucy-mark-connect.motion +0 -0
- package/tools/lottie/lucy-mark-details.motion +0 -0
- package/tools/lottie/lucy-mark-email.motion +0 -0
- package/tools/lottie/lucy-mark-message.motion +0 -0
- package/tools/lottie/lucy-mark-search.motion +0 -0
- package/tools/lottie/lucy-mark-think.motion +0 -0
- package/tools/lottie/lucy-mark-write.motion +0 -0
- package/tools/lottie/mark.json +1 -0
- package/tools/lottie/mine-none.motion +0 -0
- package/tools/lottie/mine-offline.motion +0 -0
- package/tools/lottie/mine-online.motion +0 -0
- package/tools/lottie/time-back.mjs +604 -0
- package/tools/sounds/render.mjs +730 -0
- package/tsconfig.json +17 -0
- package/README.md +0 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The power-on: the welcome's first moment, a clock that powers on with the phone's vibration timed to it (the design
|
|
3
|
+
* canvas's "First open: Clockbook powers on"). On a dark screen the clock's sixty ticks light clockwise from twelve,
|
|
4
|
+
* faster and faster, as harder taps close in; the minute hand clicks to twelve; Lucy lights up with a thoom and the cream
|
|
5
|
+
* floods out from her; she beats twice and sinks into the clock's pin as the hands settle where the welcome's clock
|
|
6
|
+
* begins. These moments drive both the picture (parts.tsx, PowerOn) and the vibration (haptics.ts, powerOn).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** When each beat lands, in ms from the first frame. */
|
|
10
|
+
export const POWER_ON = {
|
|
11
|
+
/** The last tick lights. */
|
|
12
|
+
ring: 870,
|
|
13
|
+
/** The minute hand clicks to twelve and the ring flashes. */
|
|
14
|
+
click: 900,
|
|
15
|
+
/** Lucy lights up: a flash, a shockwave, and the cream floods out from her. */
|
|
16
|
+
ignite: 1000,
|
|
17
|
+
/** The ticks and the hand turn from orange to ink with the cream. */
|
|
18
|
+
paper: 1060,
|
|
19
|
+
/** Her heartbeat, twice. */
|
|
20
|
+
beats: [1250, 1450] as const,
|
|
21
|
+
/** She sinks into the clock's pin... */
|
|
22
|
+
sink: 1640,
|
|
23
|
+
/** ...as the hands turn to ten past ten, where the welcome's clock starts. */
|
|
24
|
+
settle: 1650,
|
|
25
|
+
/** It has played: the welcome's first screen takes over on this frame. */
|
|
26
|
+
done: 2300,
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/** When tick `i` (0 at twelve, clockwise) lights, in ms: each gap shorter than the last, so the ring speeds up. */
|
|
30
|
+
export function tickLitAt(i: number): number {
|
|
31
|
+
const k = Math.min(59, Math.max(0, i));
|
|
32
|
+
return Math.round(POWER_ON.ring * Math.pow(k / 59, 0.55));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** How hard each step of the vibration is, softest first. */
|
|
36
|
+
export type Buzz = 'soft' | 'light' | 'medium' | 'rigid' | 'heavy';
|
|
37
|
+
|
|
38
|
+
/** The thoom: this many heavy hits, this many ms apart, one rumble rather than a single knock. */
|
|
39
|
+
export const THOOM_HITS = 5;
|
|
40
|
+
export const THOOM_EVERY = 25;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The iPhone's vibration, as [ms, how hard]: light, medium and heavy taps closing in as the ring lights, a rigid click
|
|
44
|
+
* as the hand locks, the thoom as Lucy lights up (a burst of heavy hits, since one tap can't go past heavy), then her
|
|
45
|
+
* heartbeat, a heavy beat and a medium one.
|
|
46
|
+
*/
|
|
47
|
+
export const POWER_ON_TRACK: readonly (readonly [number, Buzz])[] = [
|
|
48
|
+
[0, 'light'],
|
|
49
|
+
[160, 'light'],
|
|
50
|
+
[300, 'light'],
|
|
51
|
+
[420, 'medium'],
|
|
52
|
+
[520, 'medium'],
|
|
53
|
+
[605, 'medium'],
|
|
54
|
+
[675, 'heavy'],
|
|
55
|
+
[735, 'heavy'],
|
|
56
|
+
[785, 'heavy'],
|
|
57
|
+
[830, 'heavy'],
|
|
58
|
+
[POWER_ON.click, 'rigid'],
|
|
59
|
+
...Array.from({ length: THOOM_HITS }, (_, i) => [POWER_ON.ignite + i * THOOM_EVERY, 'heavy'] as const),
|
|
60
|
+
[POWER_ON.beats[0], 'heavy'],
|
|
61
|
+
[POWER_ON.beats[1], 'medium'],
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Android's, as [ms, how long the motor runs]. expo-haptics runs its motor at about a quarter strength, so Android
|
|
66
|
+
* plays the click, the thoom and the heartbeat as full-strength buzzes instead (React Native's Vibration).
|
|
67
|
+
*/
|
|
68
|
+
export const POWER_ON_ANDROID: readonly (readonly [number, number])[] = [
|
|
69
|
+
[POWER_ON.click, 40],
|
|
70
|
+
[POWER_ON.ignite, 140],
|
|
71
|
+
[POWER_ON.beats[0], 60],
|
|
72
|
+
[POWER_ON.beats[1], 45],
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
/** Those as a React Native Vibration pattern, from now: a wait, a buzz, a wait, a buzz… */
|
|
76
|
+
export function vibrationPattern(steps: readonly (readonly [number, number])[]): number[] {
|
|
77
|
+
const out: number[] = [];
|
|
78
|
+
let at = 0;
|
|
79
|
+
for (const [ms, length] of steps) {
|
|
80
|
+
out.push(ms - at, length);
|
|
81
|
+
at = ms + length;
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this phone has been through the welcome (screens/Welcome). Home opens the welcome until it has, and holds
|
|
3
|
+
* back its own push prompt meanwhile, so the welcome's notification step is the one that asks.
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
7
|
+
|
|
8
|
+
const KEY = 'clockbook.welcome.v1';
|
|
9
|
+
|
|
10
|
+
let known: boolean | null = null;
|
|
11
|
+
const listeners = new Set<(seen: boolean) => void>();
|
|
12
|
+
|
|
13
|
+
function tell(seen: boolean): void {
|
|
14
|
+
known = seen;
|
|
15
|
+
listeners.forEach((listener) => listener(seen));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function readWelcomeSeen(): Promise<boolean> {
|
|
19
|
+
if (known !== null) return known;
|
|
20
|
+
try {
|
|
21
|
+
known = (await AsyncStorage.getItem(KEY)) === 'done';
|
|
22
|
+
} catch {
|
|
23
|
+
// Storage that cannot be read must not trap anyone in the welcome: treat it as seen.
|
|
24
|
+
known = true;
|
|
25
|
+
}
|
|
26
|
+
return known;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** At the welcome's end, or when it is skipped. */
|
|
30
|
+
export async function markWelcomeSeen(): Promise<void> {
|
|
31
|
+
tell(true);
|
|
32
|
+
try {
|
|
33
|
+
await AsyncStorage.setItem(KEY, 'done');
|
|
34
|
+
} catch {
|
|
35
|
+
/* shown once more next launch */
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** For trying the welcome again in a development build. */
|
|
40
|
+
export async function resetWelcome(): Promise<void> {
|
|
41
|
+
tell(false);
|
|
42
|
+
try {
|
|
43
|
+
await AsyncStorage.removeItem(KEY);
|
|
44
|
+
} catch {
|
|
45
|
+
/* nothing kept to clear */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** null while it is being read, then whether the welcome has been seen; kept current. */
|
|
50
|
+
export function useWelcomeSeen(): boolean | null {
|
|
51
|
+
const [seen, setSeen] = useState<boolean | null>(known);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
let alive = true;
|
|
54
|
+
listeners.add(setSeen);
|
|
55
|
+
if (known === null) {
|
|
56
|
+
readWelcomeSeen()
|
|
57
|
+
.then((value) => alive && setSeen(value))
|
|
58
|
+
.catch(() => undefined);
|
|
59
|
+
} else {
|
|
60
|
+
setSeen(known);
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
alive = false;
|
|
64
|
+
listeners.delete(setSeen);
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
return seen;
|
|
68
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The welcome's sound, the haptics' twin (haptics.ts): five tones, each on one of the picture's big moments, rendered
|
|
3
|
+
* to its clock by tools/sounds/render.mjs so they land with what you see and feel.
|
|
4
|
+
*
|
|
5
|
+
* - `powerOn`: the first moment (powerOn.ts): the ring's ticks, the click, Lucy's thoom and her heartbeat.
|
|
6
|
+
* - `windBack`: the intro's third beat, the ring lighting backwards ("Now, wind them back.").
|
|
7
|
+
* - `meetLucy`: its last, Lucy arriving.
|
|
8
|
+
* - `hoursBack`: the good news, as the hours handed back lock into place.
|
|
9
|
+
* - `youreIn`: you're in.
|
|
10
|
+
*
|
|
11
|
+
* They behave as a phone's own interface sounds do. They play on the ambient channel, so the ring/silent switch mutes
|
|
12
|
+
* them and someone's music or podcast plays on underneath (on Android it dips for a moment rather than stopping).
|
|
13
|
+
* They follow the haptics: where Reduce Motion stills a moment and its haptic, it stills its sound too.
|
|
14
|
+
*
|
|
15
|
+
* expo-audio is loaded only when this binary has its native module (as haptics.ts does with expo-haptics), so a build
|
|
16
|
+
* from before it stays silent instead of failing.
|
|
17
|
+
*/
|
|
18
|
+
import { Platform } from 'react-native';
|
|
19
|
+
import { requireOptionalNativeModule } from 'expo-modules-core';
|
|
20
|
+
|
|
21
|
+
type ExpoAudio = typeof import('expo-audio');
|
|
22
|
+
type Player = ReturnType<ExpoAudio['createAudioPlayer']>;
|
|
23
|
+
|
|
24
|
+
/* eslint-disable global-require, @typescript-eslint/no-require-imports */
|
|
25
|
+
const FILES = {
|
|
26
|
+
powerOn: require('../assets/sounds/power-on.m4a') as number,
|
|
27
|
+
windBack: require('../assets/sounds/wind-back.m4a') as number,
|
|
28
|
+
meetLucy: require('../assets/sounds/meet-lucy.m4a') as number,
|
|
29
|
+
hoursBack: require('../assets/sounds/hours-back.m4a') as number,
|
|
30
|
+
youreIn: require('../assets/sounds/youre-in.m4a') as number,
|
|
31
|
+
};
|
|
32
|
+
/* eslint-enable global-require, @typescript-eslint/no-require-imports */
|
|
33
|
+
|
|
34
|
+
export type Cue = keyof typeof FILES;
|
|
35
|
+
export const CUES = Object.keys(FILES) as Cue[];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The beats the files were rendered to: POWER_ON and the ring's last tick in powerOn.ts, and the intro's wind-back
|
|
39
|
+
* (flow.ts, WIND_BACK). Move those and re-render the sounds; the test holds these equal to them.
|
|
40
|
+
*/
|
|
41
|
+
export const RENDERED_FOR = {
|
|
42
|
+
powerOn: { ring: 870, click: 900, ignite: 1000, beats: [1250, 1450], sink: 1640, done: 2300 },
|
|
43
|
+
windBack: { count: 14, every: 75, start: 60, lit: 1100 },
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
/** Cues that are a timeline under a moving picture: started late, they join where the picture is. */
|
|
47
|
+
const TIMELINE: ReadonlySet<Cue> = new Set<Cue>(['powerOn', 'windBack']);
|
|
48
|
+
/** Late by more than this, a timeline cue skips ahead to keep up. */
|
|
49
|
+
export const JOIN_AFTER_MS = 40;
|
|
50
|
+
/** How long a cue waits for its file to load before it gives up. */
|
|
51
|
+
export const LOAD_MS = 1000;
|
|
52
|
+
/** A stopped cue fades out over this long, so a skip doesn't click. */
|
|
53
|
+
export const FADE_MS = 60;
|
|
54
|
+
|
|
55
|
+
const quiet = () => undefined;
|
|
56
|
+
const wait = (ms: number) => new Promise<void>((done) => setTimeout(done, ms));
|
|
57
|
+
|
|
58
|
+
let loaded: ExpoAudio | null | undefined;
|
|
59
|
+
function audio(): ExpoAudio | null {
|
|
60
|
+
if (loaded !== undefined) return loaded;
|
|
61
|
+
try {
|
|
62
|
+
loaded = requireOptionalNativeModule('ExpoAudio')
|
|
63
|
+
? // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
64
|
+
(require('expo-audio') as ExpoAudio)
|
|
65
|
+
: null;
|
|
66
|
+
} catch {
|
|
67
|
+
loaded = null;
|
|
68
|
+
}
|
|
69
|
+
return loaded;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The ambient channel. On iOS, not playing in silent mode and mixing with others is AVAudioSession's `.ambient`. On
|
|
74
|
+
* Android it is a transient focus request others may duck under. Each platform gets only its own keys: expo-audio 0.4
|
|
75
|
+
* (SDK 53) rejects 'mixWithOthers' on Android, and from SDK 54 an `interruptionMode` there overrides the Android one.
|
|
76
|
+
*/
|
|
77
|
+
export function ambientMode() {
|
|
78
|
+
return Platform.OS === 'ios'
|
|
79
|
+
? {
|
|
80
|
+
playsInSilentMode: false,
|
|
81
|
+
interruptionMode: 'mixWithOthers' as const,
|
|
82
|
+
allowsRecording: false,
|
|
83
|
+
shouldPlayInBackground: false,
|
|
84
|
+
}
|
|
85
|
+
: { interruptionModeAndroid: 'duckOthers' as const, shouldPlayInBackground: false };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const players = new Map<Cue, Player>();
|
|
89
|
+
/** Each play of a cue, counted, so a fade from an earlier one never touches a newer one. */
|
|
90
|
+
const takes = new Map<Cue, number>();
|
|
91
|
+
|
|
92
|
+
function player(a: ExpoAudio, cue: Cue): Player | null {
|
|
93
|
+
const had = players.get(cue);
|
|
94
|
+
if (had) return had;
|
|
95
|
+
try {
|
|
96
|
+
const made = a.createAudioPlayer(FILES[cue]);
|
|
97
|
+
players.set(cue, made);
|
|
98
|
+
return made;
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Loads the welcome's sounds ahead of their moments, so each starts the moment it's asked to. */
|
|
105
|
+
export function prepare(): void {
|
|
106
|
+
const a = audio();
|
|
107
|
+
if (!a) return;
|
|
108
|
+
CUES.forEach((cue) => player(a, cue));
|
|
109
|
+
// The ambient channel set and woken now, so the first cue doesn't wait on the phone's audio waking up.
|
|
110
|
+
a.setAudioModeAsync(ambientMode())
|
|
111
|
+
.then(() => a.setIsAudioActiveAsync(true))
|
|
112
|
+
.catch(quiet);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Lets them all go, as the welcome closes. */
|
|
116
|
+
export function release(): void {
|
|
117
|
+
players.forEach((p) => {
|
|
118
|
+
try {
|
|
119
|
+
p.remove();
|
|
120
|
+
} catch {
|
|
121
|
+
/* already gone */
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
players.clear();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Plays `cue` from its start, or for a timeline from wherever the picture has got to; returns what stops it. The
|
|
129
|
+
* ambient channel is set again first, every time: expo-video sets the playback one whenever its players change (a reel
|
|
130
|
+
* watched on Home), and that one ignores the silent switch. If it can't be set, the cue stays quiet.
|
|
131
|
+
*/
|
|
132
|
+
export function play(cue: Cue): () => void {
|
|
133
|
+
const a = audio();
|
|
134
|
+
const p = a && player(a, cue);
|
|
135
|
+
if (!a || !p) return quiet;
|
|
136
|
+
const take = (takes.get(cue) ?? 0) + 1;
|
|
137
|
+
takes.set(cue, take);
|
|
138
|
+
const current = () => takes.get(cue) === take && players.get(cue) === p;
|
|
139
|
+
const asked = Date.now();
|
|
140
|
+
let stopped = false;
|
|
141
|
+
|
|
142
|
+
(async () => {
|
|
143
|
+
await a.setAudioModeAsync(ambientMode());
|
|
144
|
+
while (!p.isLoaded && Date.now() - asked < LOAD_MS && !stopped) await wait(20);
|
|
145
|
+
if (stopped || !current() || !p.isLoaded) return;
|
|
146
|
+
const late = Date.now() - asked;
|
|
147
|
+
const from = TIMELINE.has(cue) && late > JOIN_AFTER_MS ? late / 1000 : 0;
|
|
148
|
+
if (from > 0 || p.currentTime > 0) await p.seekTo(from);
|
|
149
|
+
if (stopped || !current()) return;
|
|
150
|
+
p.volume = 1;
|
|
151
|
+
p.play();
|
|
152
|
+
})().catch(quiet);
|
|
153
|
+
|
|
154
|
+
return () => {
|
|
155
|
+
if (stopped) return;
|
|
156
|
+
stopped = true;
|
|
157
|
+
const steps = [0.6, 0.3, 0.1, 0];
|
|
158
|
+
steps.forEach((v, i) =>
|
|
159
|
+
setTimeout(
|
|
160
|
+
() => {
|
|
161
|
+
if (!current()) return;
|
|
162
|
+
try {
|
|
163
|
+
if (v > 0) p.volume = v;
|
|
164
|
+
else p.pause();
|
|
165
|
+
} catch {
|
|
166
|
+
/* let go meanwhile */
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
((i + 1) * FADE_MS) / steps.length,
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
Binary file
|
|
Binary file
|