markpdfdown 0.4.6 → 0.4.7
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.
|
@@ -71135,6 +71135,8 @@ const List = () => {
|
|
|
71135
71135
|
const { t: t2 } = useTranslation("list");
|
|
71136
71136
|
const { t: tCommon } = useTranslation("common");
|
|
71137
71137
|
const cloudContext = reactExports.useContext(CloudContext);
|
|
71138
|
+
const cloudIsAuthenticated = cloudContext?.isAuthenticated ?? false;
|
|
71139
|
+
const cloudGetTasks = cloudContext?.getTasks;
|
|
71138
71140
|
const [loading, setLoading] = reactExports.useState(false);
|
|
71139
71141
|
const [data, setData] = reactExports.useState([]);
|
|
71140
71142
|
const [pagination, setPagination] = reactExports.useState({
|
|
@@ -71147,6 +71149,10 @@ const List = () => {
|
|
|
71147
71149
|
const pollTimerRef = reactExports.useRef(null);
|
|
71148
71150
|
const paginationRef = reactExports.useRef(pagination);
|
|
71149
71151
|
paginationRef.current = pagination;
|
|
71152
|
+
const pendingRefreshRef = reactExports.useRef(false);
|
|
71153
|
+
const refreshTimerRef = reactExports.useRef(null);
|
|
71154
|
+
const dataRef = reactExports.useRef(data);
|
|
71155
|
+
dataRef.current = data;
|
|
71150
71156
|
const MAX_FETCH_ITEMS = 100;
|
|
71151
71157
|
const buildLocalModelValue = (modelId, providerId) => `${modelId}@${providerId}`;
|
|
71152
71158
|
const parseLocalModelValue = (value) => {
|
|
@@ -71193,8 +71199,8 @@ const List = () => {
|
|
|
71193
71199
|
const promises = [
|
|
71194
71200
|
window.api.task.getAll({ page: 1, pageSize: MAX_FETCH_ITEMS })
|
|
71195
71201
|
];
|
|
71196
|
-
if (
|
|
71197
|
-
promises.push(
|
|
71202
|
+
if (cloudIsAuthenticated && cloudGetTasks) {
|
|
71203
|
+
promises.push(cloudGetTasks(1, MAX_FETCH_ITEMS));
|
|
71198
71204
|
}
|
|
71199
71205
|
const results = await Promise.all(promises);
|
|
71200
71206
|
const localResult = results[0];
|
|
@@ -71285,7 +71291,7 @@ const List = () => {
|
|
|
71285
71291
|
} finally {
|
|
71286
71292
|
setLoading(false);
|
|
71287
71293
|
}
|
|
71288
|
-
}, [message2, t2,
|
|
71294
|
+
}, [message2, t2, cloudIsAuthenticated, cloudGetTasks]);
|
|
71289
71295
|
const handleTaskEvent = reactExports.useCallback((event) => {
|
|
71290
71296
|
const { type: type4, taskId, task } = event;
|
|
71291
71297
|
console.log(`[List] Received task event: ${type4}`, { taskId, task });
|
|
@@ -71335,27 +71341,33 @@ const List = () => {
|
|
|
71335
71341
|
reactExports.useEffect(() => {
|
|
71336
71342
|
if (!window.api?.events?.onCloudTaskEvent) return;
|
|
71337
71343
|
console.log("[List] Registering cloud SSE event listener");
|
|
71338
|
-
let pendingRefresh = false;
|
|
71339
71344
|
const handleCloudEvent = (event) => {
|
|
71340
|
-
const { type: type4, data:
|
|
71345
|
+
const { type: type4, data: eventData } = event;
|
|
71341
71346
|
if (type4 === "heartbeat" || type4 === "connected") return;
|
|
71342
|
-
const taskId =
|
|
71347
|
+
const taskId = eventData.task_id;
|
|
71343
71348
|
if (!taskId) return;
|
|
71344
71349
|
console.log(`[List] Cloud SSE event: type=${type4}, task_id=${taskId}`);
|
|
71345
|
-
|
|
71346
|
-
|
|
71347
|
-
|
|
71348
|
-
|
|
71349
|
-
|
|
71350
|
-
|
|
71351
|
-
|
|
71352
|
-
fetchTasks(paginationRef.current.current, paginationRef.current.pageSize);
|
|
71353
|
-
}
|
|
71354
|
-
|
|
71355
|
-
|
|
71350
|
+
const currentData = dataRef.current;
|
|
71351
|
+
const index2 = currentData.findIndex((t22) => t22.id === taskId);
|
|
71352
|
+
if (index2 === -1) {
|
|
71353
|
+
if (!pendingRefreshRef.current) {
|
|
71354
|
+
pendingRefreshRef.current = true;
|
|
71355
|
+
refreshTimerRef.current = setTimeout(async () => {
|
|
71356
|
+
try {
|
|
71357
|
+
await fetchTasks(paginationRef.current.current, paginationRef.current.pageSize);
|
|
71358
|
+
} finally {
|
|
71359
|
+
pendingRefreshRef.current = false;
|
|
71360
|
+
refreshTimerRef.current = null;
|
|
71361
|
+
}
|
|
71362
|
+
}, 500);
|
|
71356
71363
|
}
|
|
71364
|
+
return;
|
|
71365
|
+
}
|
|
71366
|
+
setData((prevData) => {
|
|
71367
|
+
const idx = prevData.findIndex((t22) => t22.id === taskId);
|
|
71368
|
+
if (idx === -1) return prevData;
|
|
71357
71369
|
const newData = [...prevData];
|
|
71358
|
-
const task = { ...newData[
|
|
71370
|
+
const task = { ...newData[idx] };
|
|
71359
71371
|
switch (type4) {
|
|
71360
71372
|
case "page_started":
|
|
71361
71373
|
case "page_retry_started": {
|
|
@@ -71363,8 +71375,8 @@ const List = () => {
|
|
|
71363
71375
|
break;
|
|
71364
71376
|
}
|
|
71365
71377
|
case "page_completed": {
|
|
71366
|
-
const pageNumber =
|
|
71367
|
-
const totalPages =
|
|
71378
|
+
const pageNumber = eventData.page;
|
|
71379
|
+
const totalPages = eventData.total_pages || task.pages || 1;
|
|
71368
71380
|
if (task.status === 8) {
|
|
71369
71381
|
task.completed_count = (task.completed_count || 0) + 1;
|
|
71370
71382
|
task.failed_count = Math.max(0, (task.failed_count || 0) - 1);
|
|
@@ -71380,15 +71392,15 @@ const List = () => {
|
|
|
71380
71392
|
break;
|
|
71381
71393
|
}
|
|
71382
71394
|
case "completed": {
|
|
71383
|
-
task.status =
|
|
71395
|
+
task.status = eventData.status || 6;
|
|
71384
71396
|
task.progress = 100;
|
|
71385
|
-
task.completed_count =
|
|
71386
|
-
task.failed_count =
|
|
71397
|
+
task.completed_count = eventData.pages_completed;
|
|
71398
|
+
task.failed_count = eventData.pages_failed;
|
|
71387
71399
|
break;
|
|
71388
71400
|
}
|
|
71389
71401
|
case "error": {
|
|
71390
71402
|
task.status = 0;
|
|
71391
|
-
task.error =
|
|
71403
|
+
task.error = eventData.error;
|
|
71392
71404
|
break;
|
|
71393
71405
|
}
|
|
71394
71406
|
case "cancelled": {
|
|
@@ -71397,13 +71409,13 @@ const List = () => {
|
|
|
71397
71409
|
}
|
|
71398
71410
|
case "pdf_ready": {
|
|
71399
71411
|
task.status = 3;
|
|
71400
|
-
task.pages =
|
|
71412
|
+
task.pages = eventData.page_count;
|
|
71401
71413
|
break;
|
|
71402
71414
|
}
|
|
71403
71415
|
default:
|
|
71404
71416
|
return prevData;
|
|
71405
71417
|
}
|
|
71406
|
-
newData[
|
|
71418
|
+
newData[idx] = task;
|
|
71407
71419
|
if (task.id) {
|
|
71408
71420
|
const terminalStatuses = [0, 6, 7, 8];
|
|
71409
71421
|
if (terminalStatuses.includes(task.status ?? -1)) {
|
|
@@ -71424,6 +71436,11 @@ const List = () => {
|
|
|
71424
71436
|
return () => {
|
|
71425
71437
|
console.log("[List] Cleaning up cloud SSE event listener");
|
|
71426
71438
|
cleanup2();
|
|
71439
|
+
if (refreshTimerRef.current) {
|
|
71440
|
+
clearTimeout(refreshTimerRef.current);
|
|
71441
|
+
refreshTimerRef.current = null;
|
|
71442
|
+
pendingRefreshRef.current = false;
|
|
71443
|
+
}
|
|
71427
71444
|
};
|
|
71428
71445
|
}, [fetchTasks]);
|
|
71429
71446
|
reactExports.useEffect(() => {
|
|
@@ -130540,41 +130557,64 @@ const CloudProvider = ({ children }) => {
|
|
|
130540
130557
|
});
|
|
130541
130558
|
return cleanup2;
|
|
130542
130559
|
}, [isAuthenticated, refreshCredits]);
|
|
130543
|
-
|
|
130544
|
-
|
|
130545
|
-
|
|
130546
|
-
|
|
130547
|
-
|
|
130548
|
-
|
|
130549
|
-
|
|
130550
|
-
|
|
130551
|
-
|
|
130552
|
-
|
|
130553
|
-
|
|
130554
|
-
|
|
130555
|
-
|
|
130556
|
-
|
|
130557
|
-
|
|
130558
|
-
|
|
130559
|
-
|
|
130560
|
-
|
|
130561
|
-
|
|
130562
|
-
|
|
130563
|
-
|
|
130564
|
-
|
|
130565
|
-
|
|
130566
|
-
|
|
130567
|
-
|
|
130568
|
-
|
|
130569
|
-
|
|
130570
|
-
|
|
130571
|
-
|
|
130572
|
-
|
|
130573
|
-
|
|
130574
|
-
|
|
130575
|
-
|
|
130576
|
-
|
|
130577
|
-
|
|
130560
|
+
const contextValue = reactExports.useMemo(() => ({
|
|
130561
|
+
user,
|
|
130562
|
+
credits,
|
|
130563
|
+
isAuthenticated,
|
|
130564
|
+
isLoading,
|
|
130565
|
+
deviceFlowStatus,
|
|
130566
|
+
userCode,
|
|
130567
|
+
verificationUrl,
|
|
130568
|
+
authError,
|
|
130569
|
+
login,
|
|
130570
|
+
logout,
|
|
130571
|
+
cancelLogin,
|
|
130572
|
+
refreshCredits,
|
|
130573
|
+
convertFile,
|
|
130574
|
+
getTasks,
|
|
130575
|
+
getTaskById,
|
|
130576
|
+
getTaskPages,
|
|
130577
|
+
cancelTask,
|
|
130578
|
+
retryTask,
|
|
130579
|
+
deleteTask,
|
|
130580
|
+
retryPage,
|
|
130581
|
+
getTaskResult,
|
|
130582
|
+
downloadResult,
|
|
130583
|
+
createCheckout,
|
|
130584
|
+
getCheckoutStatus,
|
|
130585
|
+
reconcileCheckout,
|
|
130586
|
+
getCreditHistory,
|
|
130587
|
+
getPaymentHistory
|
|
130588
|
+
}), [
|
|
130589
|
+
user,
|
|
130590
|
+
credits,
|
|
130591
|
+
isAuthenticated,
|
|
130592
|
+
isLoading,
|
|
130593
|
+
deviceFlowStatus,
|
|
130594
|
+
userCode,
|
|
130595
|
+
verificationUrl,
|
|
130596
|
+
authError,
|
|
130597
|
+
login,
|
|
130598
|
+
logout,
|
|
130599
|
+
cancelLogin,
|
|
130600
|
+
refreshCredits,
|
|
130601
|
+
convertFile,
|
|
130602
|
+
getTasks,
|
|
130603
|
+
getTaskById,
|
|
130604
|
+
getTaskPages,
|
|
130605
|
+
cancelTask,
|
|
130606
|
+
retryTask,
|
|
130607
|
+
deleteTask,
|
|
130608
|
+
retryPage,
|
|
130609
|
+
getTaskResult,
|
|
130610
|
+
downloadResult,
|
|
130611
|
+
createCheckout,
|
|
130612
|
+
getCheckoutStatus,
|
|
130613
|
+
reconcileCheckout,
|
|
130614
|
+
getCreditHistory,
|
|
130615
|
+
getPaymentHistory
|
|
130616
|
+
]);
|
|
130617
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CloudContext.Provider, { value: contextValue, children });
|
|
130578
130618
|
};
|
|
130579
130619
|
clientExports.createRoot(document.getElementById("root")).render(
|
|
130580
130620
|
/* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CloudProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) }) })
|
package/dist/renderer/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>MarkPDFdown</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-CG2nvY4Z.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-DXcyx2Q8.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|