@chrryai/chrry 1.3.13 → 1.3.15
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +87 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21506,7 +21506,7 @@ function DataProvider({
|
|
|
21506
21506
|
const [instructions, setInstructions] = (0, import_react14.useState)([]);
|
|
21507
21507
|
const [affiliateStats, setAffiliateStats] = (0, import_react14.useState)(null);
|
|
21508
21508
|
const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react14.useState)(false);
|
|
21509
|
-
const VERSION3 = "1.3.
|
|
21509
|
+
const VERSION3 = "1.3.15";
|
|
21510
21510
|
const [weather, setWeather] = useLocalStorage("weather", user?.weather || guest?.weather || void 0);
|
|
21511
21511
|
const {
|
|
21512
21512
|
API_URL: API_URL2,
|
|
@@ -22603,7 +22603,7 @@ var init_utils = __esm({
|
|
|
22603
22603
|
window.history.replaceState({}, "", newUrl);
|
|
22604
22604
|
};
|
|
22605
22605
|
isFirefox = typeof navigator !== "undefined" && navigator?.userAgent.includes("Firefox");
|
|
22606
|
-
VERSION = "1.3.
|
|
22606
|
+
VERSION = "1.3.15";
|
|
22607
22607
|
getSlugFromPathname = (path) => {
|
|
22608
22608
|
const siteConfig = getSiteConfig();
|
|
22609
22609
|
return getAppAndStoreSlugs(path, {
|
|
@@ -25669,10 +25669,11 @@ function TimerContextProvider({
|
|
|
25669
25669
|
const isExtension2 = usePlatform();
|
|
25670
25670
|
const [time, setTime] = (0, import_react29.useState)(0);
|
|
25671
25671
|
const [isCountingDown, setIsCountingDown] = (0, import_react29.useState)(false);
|
|
25672
|
-
const [replay, setReplay] =
|
|
25672
|
+
const [replay, setReplay] = (0, import_react29.useState)(false);
|
|
25673
25673
|
const [timer, setTimerInternal] = (0, import_react29.useState)(null);
|
|
25674
|
+
const [timerState, setTimerState] = (0, import_react29.useState)(null);
|
|
25675
|
+
const [activePomodoro, setActivePomodoro] = (0, import_react29.useState)(null);
|
|
25674
25676
|
const setTimer = (timer2) => {
|
|
25675
|
-
if (!timer2?.id) return;
|
|
25676
25677
|
setTimerInternal((prevTimer) => {
|
|
25677
25678
|
if (prevTimer?.id === timer2?.id && prevTimer?.preset1 === timer2?.preset1 && prevTimer?.preset2 === timer2?.preset2 && prevTimer?.preset3 === timer2?.preset3) {
|
|
25678
25679
|
return prevTimer;
|
|
@@ -25684,8 +25685,7 @@ function TimerContextProvider({
|
|
|
25684
25685
|
const [isPaused, setIsPaused] = (0, import_react29.useState)(false);
|
|
25685
25686
|
const [isFinished, setIsFinished] = (0, import_react29.useState)(false);
|
|
25686
25687
|
const [isCancelled, setIsCancelled] = (0, import_react29.useState)(false);
|
|
25687
|
-
const [
|
|
25688
|
-
const [tasks, setTasks] = useLocalStorage2("tasks", {
|
|
25688
|
+
const [tasks, setTasks] = (0, import_react29.useState)({
|
|
25689
25689
|
tasks: [],
|
|
25690
25690
|
totalCount: 0,
|
|
25691
25691
|
hasNextPage: false,
|
|
@@ -25833,6 +25833,7 @@ function TimerContextProvider({
|
|
|
25833
25833
|
const isTimerEndingRef = (0, import_react29.useRef)(false);
|
|
25834
25834
|
const adjustIntervalRef = (0, import_react29.useRef)(null);
|
|
25835
25835
|
const lastVisibilityUpdateRef = (0, import_react29.useRef)(0);
|
|
25836
|
+
const hasRestoredTimerRef = (0, import_react29.useRef)(false);
|
|
25836
25837
|
const [playBirds, setPlayBirds] = (0, import_react29.useState)(void 0);
|
|
25837
25838
|
(0, import_react29.useEffect)(() => {
|
|
25838
25839
|
if (!timer?.id) return;
|
|
@@ -25862,11 +25863,56 @@ function TimerContextProvider({
|
|
|
25862
25863
|
refetchTimer();
|
|
25863
25864
|
}, [refetchTimer]);
|
|
25864
25865
|
(0, import_react29.useEffect)(() => {
|
|
25865
|
-
if (timerData) {
|
|
25866
|
+
if (timerData && !hasRestoredTimerRef.current) {
|
|
25866
25867
|
console.log(`\u{1F680} ~ file: TimerContext.tsx:514 ~ timerData:`, timerData);
|
|
25868
|
+
hasRestoredTimerRef.current = true;
|
|
25867
25869
|
setTimer(timerData);
|
|
25870
|
+
if (timerData.isCountingDown && timerData.count > 0) {
|
|
25871
|
+
setTime(timerData.count);
|
|
25872
|
+
setIsCountingDown(true);
|
|
25873
|
+
setIsPaused(false);
|
|
25874
|
+
setIsFinished(false);
|
|
25875
|
+
setStartTime(Date.now());
|
|
25876
|
+
} else if (timerData.count > 0) {
|
|
25877
|
+
setTime(timerData.count);
|
|
25878
|
+
setIsCountingDown(false);
|
|
25879
|
+
setIsPaused(true);
|
|
25880
|
+
setIsFinished(false);
|
|
25881
|
+
} else {
|
|
25882
|
+
setTime(0);
|
|
25883
|
+
setIsCountingDown(false);
|
|
25884
|
+
setIsPaused(false);
|
|
25885
|
+
setIsFinished(true);
|
|
25886
|
+
}
|
|
25868
25887
|
}
|
|
25869
25888
|
}, [timerData]);
|
|
25889
|
+
(0, import_react29.useEffect)(() => {
|
|
25890
|
+
if (isCountingDown && time > 0 && !timerRef.current) {
|
|
25891
|
+
timerRef.current = setInterval(() => {
|
|
25892
|
+
setTime((prevTime) => {
|
|
25893
|
+
const newTime = prevTime - 1;
|
|
25894
|
+
if (newTime <= 0) {
|
|
25895
|
+
if (timerRef.current) {
|
|
25896
|
+
clearInterval(timerRef.current);
|
|
25897
|
+
timerRef.current = null;
|
|
25898
|
+
}
|
|
25899
|
+
setIsCountingDown(false);
|
|
25900
|
+
setIsFinished(true);
|
|
25901
|
+
}
|
|
25902
|
+
return newTime;
|
|
25903
|
+
});
|
|
25904
|
+
}, 1e3);
|
|
25905
|
+
} else if (!isCountingDown && timerRef.current) {
|
|
25906
|
+
clearInterval(timerRef.current);
|
|
25907
|
+
timerRef.current = null;
|
|
25908
|
+
}
|
|
25909
|
+
return () => {
|
|
25910
|
+
if (timerRef.current) {
|
|
25911
|
+
clearInterval(timerRef.current);
|
|
25912
|
+
timerRef.current = null;
|
|
25913
|
+
}
|
|
25914
|
+
};
|
|
25915
|
+
}, [isCountingDown]);
|
|
25870
25916
|
(0, import_react29.useEffect)(() => {
|
|
25871
25917
|
if (!timer && token && fingerprint && user && !isLoadingTimer) {
|
|
25872
25918
|
fetchTimer();
|
|
@@ -25969,16 +26015,14 @@ function TimerContextProvider({
|
|
|
25969
26015
|
};
|
|
25970
26016
|
setTimer(updatedTimer);
|
|
25971
26017
|
updateTimer(updatedTimer);
|
|
25972
|
-
|
|
25973
|
-
|
|
25974
|
-
|
|
25975
|
-
|
|
25976
|
-
|
|
25977
|
-
|
|
25978
|
-
|
|
25979
|
-
|
|
25980
|
-
})
|
|
25981
|
-
);
|
|
26018
|
+
setTimerState({
|
|
26019
|
+
time,
|
|
26020
|
+
isCountingDown,
|
|
26021
|
+
isPaused,
|
|
26022
|
+
startTime,
|
|
26023
|
+
timestamp: now2,
|
|
26024
|
+
isFinished: false
|
|
26025
|
+
});
|
|
25982
26026
|
}, [
|
|
25983
26027
|
time,
|
|
25984
26028
|
isCountingDown,
|
|
@@ -26018,9 +26062,7 @@ function TimerContextProvider({
|
|
|
26018
26062
|
setIsCountingDown(false);
|
|
26019
26063
|
setIsPaused(false);
|
|
26020
26064
|
setTime(0);
|
|
26021
|
-
|
|
26022
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
26023
|
-
}
|
|
26065
|
+
setTimerState(null);
|
|
26024
26066
|
if (timerRef.current) {
|
|
26025
26067
|
clearInterval(timerRef.current);
|
|
26026
26068
|
timerRef.current = null;
|
|
@@ -26078,14 +26120,13 @@ function TimerContextProvider({
|
|
|
26078
26120
|
});
|
|
26079
26121
|
}
|
|
26080
26122
|
}, 100);
|
|
26081
|
-
|
|
26123
|
+
setTimerState({
|
|
26082
26124
|
time: initialTime,
|
|
26083
26125
|
isCountingDown: true,
|
|
26084
26126
|
isPaused: false,
|
|
26085
26127
|
startTime: now2,
|
|
26086
26128
|
isFinished: false
|
|
26087
|
-
};
|
|
26088
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
|
26129
|
+
});
|
|
26089
26130
|
trackEvent({ name: "timer_start", props: { duration: duration || time } });
|
|
26090
26131
|
},
|
|
26091
26132
|
[time, isExtension2, updateTimer, timer, fingerprint]
|
|
@@ -26104,14 +26145,17 @@ function TimerContextProvider({
|
|
|
26104
26145
|
count: 0,
|
|
26105
26146
|
isCountingDown: false
|
|
26106
26147
|
});
|
|
26148
|
+
setTimer({
|
|
26149
|
+
...timer,
|
|
26150
|
+
count: 0,
|
|
26151
|
+
isCountingDown: false
|
|
26152
|
+
});
|
|
26107
26153
|
}
|
|
26108
26154
|
setTime(0);
|
|
26109
26155
|
setIsCountingDown(false);
|
|
26110
26156
|
setIsPaused(false);
|
|
26111
26157
|
setIsFinished(true);
|
|
26112
|
-
|
|
26113
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
26114
|
-
}
|
|
26158
|
+
setTimerState(null);
|
|
26115
26159
|
trackEvent({ name: "timer_cancel" });
|
|
26116
26160
|
setTimeout(() => {
|
|
26117
26161
|
isTimerEndingRef.current = false;
|
|
@@ -26128,16 +26172,14 @@ function TimerContextProvider({
|
|
|
26128
26172
|
clearInterval(timerRef.current);
|
|
26129
26173
|
timerRef.current = null;
|
|
26130
26174
|
}
|
|
26131
|
-
|
|
26132
|
-
type: "TIMER_UPDATE",
|
|
26133
|
-
isCountingDown: false,
|
|
26175
|
+
setTimerState({
|
|
26134
26176
|
time,
|
|
26177
|
+
isCountingDown: false,
|
|
26135
26178
|
isPaused: true,
|
|
26136
|
-
source: "ui",
|
|
26137
26179
|
timestamp: Date.now(),
|
|
26138
|
-
startTime
|
|
26139
|
-
|
|
26140
|
-
|
|
26180
|
+
startTime,
|
|
26181
|
+
isFinished: false
|
|
26182
|
+
});
|
|
26141
26183
|
trackEvent({ name: "timer_pause", props: { timeLeft: time } });
|
|
26142
26184
|
}, [timer, updateTimer, time, startTime, trackEvent]);
|
|
26143
26185
|
const handleResume = (0, import_react29.useCallback)(() => {
|
|
@@ -26166,41 +26208,28 @@ function TimerContextProvider({
|
|
|
26166
26208
|
}
|
|
26167
26209
|
setIsCountingDown(false);
|
|
26168
26210
|
}
|
|
26169
|
-
|
|
26211
|
+
setTimerState({
|
|
26170
26212
|
time: newTime,
|
|
26171
26213
|
isCountingDown: false,
|
|
26172
26214
|
isPaused: true,
|
|
26215
|
+
timestamp: Date.now(),
|
|
26173
26216
|
startTime: Date.now(),
|
|
26174
26217
|
isFinished: false
|
|
26175
|
-
};
|
|
26176
|
-
|
|
26177
|
-
localStorage.setItem(POMODORO_KEY, minutes.toString());
|
|
26218
|
+
});
|
|
26219
|
+
setActivePomodoro(minutes);
|
|
26178
26220
|
trackEvent({ name: "timer_preset", props: { minutes, timeSet: newTime } });
|
|
26179
26221
|
},
|
|
26180
26222
|
[isCountingDown, trackEvent]
|
|
26181
26223
|
);
|
|
26182
|
-
(0, import_react29.useEffect)(() => {
|
|
26183
|
-
const loadPomodoro = async () => {
|
|
26184
|
-
const savedPomodoro = localStorage.getItem(POMODORO_KEY);
|
|
26185
|
-
if (savedPomodoro) {
|
|
26186
|
-
setActivePomodoro(parseInt(savedPomodoro));
|
|
26187
|
-
}
|
|
26188
|
-
};
|
|
26189
|
-
loadPomodoro();
|
|
26190
|
-
}, [isExtension2]);
|
|
26191
26224
|
const restoreTimerState = (0, import_react29.useCallback)(async () => {
|
|
26192
26225
|
try {
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
if (state.isCountingDown && !state.isPaused && state.startTime) {
|
|
26201
|
-
const elapsedTime = Math.floor((Date.now() - state.startTime) / 1e3);
|
|
26202
|
-
state.time = Math.max(0, state.time - elapsedTime);
|
|
26203
|
-
}
|
|
26226
|
+
if (!timerState) {
|
|
26227
|
+
return;
|
|
26228
|
+
}
|
|
26229
|
+
const state = timerState;
|
|
26230
|
+
if (state.isCountingDown && !state.isPaused && state.startTime) {
|
|
26231
|
+
const elapsedTime = Math.floor((Date.now() - state.startTime) / 1e3);
|
|
26232
|
+
state.time = Math.max(0, state.time - elapsedTime);
|
|
26204
26233
|
}
|
|
26205
26234
|
console.log("Restoring timer state:", state);
|
|
26206
26235
|
if (state) {
|
|
@@ -26328,30 +26357,6 @@ function TimerContextProvider({
|
|
|
26328
26357
|
if (document.hidden) {
|
|
26329
26358
|
return;
|
|
26330
26359
|
}
|
|
26331
|
-
const savedTimer = localStorage.getItem("focusTimer");
|
|
26332
|
-
if (savedTimer) {
|
|
26333
|
-
try {
|
|
26334
|
-
const {
|
|
26335
|
-
timeLeft,
|
|
26336
|
-
startTime: startTime2,
|
|
26337
|
-
isCountingDown: wasCountingDown,
|
|
26338
|
-
isPaused: wasPaused
|
|
26339
|
-
} = JSON.parse(savedTimer);
|
|
26340
|
-
if (wasCountingDown && !wasPaused) {
|
|
26341
|
-
console.log("App coming to foreground, restoring timer state");
|
|
26342
|
-
const elapsedSeconds = Math.floor((now2 - startTime2) / 1e3);
|
|
26343
|
-
const newTime = Math.max(0, timeLeft - elapsedSeconds);
|
|
26344
|
-
if (newTime === 0) {
|
|
26345
|
-
console.log("Timer completed while in background");
|
|
26346
|
-
} else if (newTime > 0) {
|
|
26347
|
-
startCountdown(newTime);
|
|
26348
|
-
}
|
|
26349
|
-
}
|
|
26350
|
-
} catch (error) {
|
|
26351
|
-
console.error("Error parsing saved timer:", error);
|
|
26352
|
-
}
|
|
26353
|
-
localStorage.removeItem("focusTimer");
|
|
26354
|
-
}
|
|
26355
26360
|
},
|
|
26356
26361
|
[time, isCountingDown, startCountdown]
|
|
26357
26362
|
);
|
|
@@ -26546,7 +26551,7 @@ function TimerContextProvider({
|
|
|
26546
26551
|
}
|
|
26547
26552
|
), children);
|
|
26548
26553
|
}
|
|
26549
|
-
var import_react29, import_swr4, STORAGE_SELECTED_TASKS_KEY, TimerContext,
|
|
26554
|
+
var import_react29, import_swr4, STORAGE_SELECTED_TASKS_KEY, TimerContext, useTimerContext;
|
|
26550
26555
|
var init_TimerContext = __esm({
|
|
26551
26556
|
"context/TimerContext.tsx"() {
|
|
26552
26557
|
"use strict";
|
|
@@ -26636,8 +26641,6 @@ var init_TimerContext = __esm({
|
|
|
26636
26641
|
setTasks: (tasks) => {
|
|
26637
26642
|
}
|
|
26638
26643
|
});
|
|
26639
|
-
STORAGE_KEY = "focusbutton_timer_state";
|
|
26640
|
-
POMODORO_KEY = "focusbutton_active_pomodoro";
|
|
26641
26644
|
useTimerContext = () => {
|
|
26642
26645
|
const context = (0, import_react29.useContext)(TimerContext);
|
|
26643
26646
|
if (context === void 0) {
|
|
@@ -44544,45 +44547,11 @@ function Moodify({
|
|
|
44544
44547
|
rest.mood?.type && setMood(rest.mood?.type);
|
|
44545
44548
|
}, [rest.mood]);
|
|
44546
44549
|
const isHydrated = useHasHydrated();
|
|
44547
|
-
const [isEnabled, setIsEnabled] = (0, import_react83.useState)(!searchParams.get("editTask"));
|
|
44548
|
-
(0, import_react83.useEffect)(() => {
|
|
44549
|
-
setIsEnabled(!!searchParams.get("editTask"));
|
|
44550
|
-
}, [searchParams]);
|
|
44551
|
-
const [messages, setMessages] = (0, import_react83.useState)({
|
|
44552
|
-
messages: [],
|
|
44553
|
-
totalCount: 0,
|
|
44554
|
-
hasNextPage: false,
|
|
44555
|
-
nextPage: null
|
|
44556
|
-
});
|
|
44557
44550
|
(0, import_react83.useEffect)(() => {
|
|
44558
44551
|
if (hasReports) {
|
|
44559
44552
|
onOpenReports?.();
|
|
44560
44553
|
}
|
|
44561
44554
|
}, [hasReports]);
|
|
44562
|
-
const [until, setUntil] = (0, import_react83.useState)(1);
|
|
44563
|
-
const messagesRef = (0, import_react83.useRef)(null);
|
|
44564
|
-
const scrollToLastMessage = () => {
|
|
44565
|
-
setTimeout(() => {
|
|
44566
|
-
messagesRef.current?.scrollTo({
|
|
44567
|
-
top: messagesRef.current.scrollHeight,
|
|
44568
|
-
behavior: "smooth"
|
|
44569
|
-
});
|
|
44570
|
-
}, 200);
|
|
44571
|
-
};
|
|
44572
|
-
const moodMessages = {
|
|
44573
|
-
happy: t6("mood_happy"),
|
|
44574
|
-
sad: t6("mood_sad"),
|
|
44575
|
-
angry: t6("mood_angry"),
|
|
44576
|
-
astonished: t6("mood_astonished"),
|
|
44577
|
-
inlove: t6("mood_inlove"),
|
|
44578
|
-
thinking: t6("mood_thinking")
|
|
44579
|
-
};
|
|
44580
|
-
const handleMoodClick = (selectedMood) => {
|
|
44581
|
-
setMood(selectedMood);
|
|
44582
|
-
setIsEditing(false);
|
|
44583
|
-
};
|
|
44584
|
-
const [isEditing, setIsEditing] = (0, import_react83.useState)(false);
|
|
44585
|
-
if (!isEnabled) return null;
|
|
44586
44555
|
if (!isHydrated) return null;
|
|
44587
44556
|
return /* @__PURE__ */ import_react83.default.createElement(
|
|
44588
44557
|
"div",
|