kernel-script 1.0.0 → 1.0.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/bun.lock +1 -8
- package/dist/core/bootstrap/broadcast.d.ts +5 -0
- package/dist/core/bootstrap/command-handler.d.ts +39 -0
- package/dist/core/bootstrap/heartbeat.d.ts +1 -0
- package/dist/core/bootstrap/index.d.ts +6 -0
- package/dist/core/bootstrap/message-handler.d.ts +6 -0
- package/dist/core/bootstrap.d.ts +5 -1
- package/dist/core/engine-hub.d.ts +1 -1
- package/dist/core/helper.d.ts +1 -1
- package/dist/core/hooks/use-queue.d.ts +4 -3
- package/dist/core/persistence-manager.d.ts +2 -2
- package/dist/core/queue/index.d.ts +5 -0
- package/dist/core/queue/persistence.d.ts +14 -0
- package/dist/core/queue/queue-manager.d.ts +59 -0
- package/dist/core/queue/queue-state.d.ts +13 -0
- package/dist/core/queue/task-executor.d.ts +16 -0
- package/dist/core/queue-manager.d.ts +8 -4
- package/dist/core/registry.d.ts +1 -1
- package/dist/core/store/base-task.store.d.ts +4 -7
- package/dist/core/task-context.d.ts +1 -1
- package/dist/core/types/index.d.ts +48 -0
- package/dist/index.cjs +312 -1892
- package/dist/index.d.ts +5 -6
- package/dist/index.js +307 -1434
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -204,990 +204,6 @@ var require_eventemitter3 = __commonJS({
|
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
// node_modules/react/cjs/react.development.js
|
|
208
|
-
var require_react_development = __commonJS({
|
|
209
|
-
"node_modules/react/cjs/react.development.js"(exports, module) {
|
|
210
|
-
"use strict";
|
|
211
|
-
(function() {
|
|
212
|
-
function defineDeprecationWarning(methodName, info) {
|
|
213
|
-
Object.defineProperty(Component.prototype, methodName, {
|
|
214
|
-
get: function() {
|
|
215
|
-
console.warn(
|
|
216
|
-
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
217
|
-
info[0],
|
|
218
|
-
info[1]
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
function getIteratorFn(maybeIterable) {
|
|
224
|
-
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
|
225
|
-
return null;
|
|
226
|
-
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
227
|
-
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
228
|
-
}
|
|
229
|
-
function warnNoop(publicInstance, callerName) {
|
|
230
|
-
publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
|
|
231
|
-
var warningKey = publicInstance + "." + callerName;
|
|
232
|
-
didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
|
|
233
|
-
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
234
|
-
callerName,
|
|
235
|
-
publicInstance
|
|
236
|
-
), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
|
|
237
|
-
}
|
|
238
|
-
function Component(props, context, updater) {
|
|
239
|
-
this.props = props;
|
|
240
|
-
this.context = context;
|
|
241
|
-
this.refs = emptyObject;
|
|
242
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
|
243
|
-
}
|
|
244
|
-
function ComponentDummy() {
|
|
245
|
-
}
|
|
246
|
-
function PureComponent(props, context, updater) {
|
|
247
|
-
this.props = props;
|
|
248
|
-
this.context = context;
|
|
249
|
-
this.refs = emptyObject;
|
|
250
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
|
251
|
-
}
|
|
252
|
-
function noop() {
|
|
253
|
-
}
|
|
254
|
-
function testStringCoercion(value) {
|
|
255
|
-
return "" + value;
|
|
256
|
-
}
|
|
257
|
-
function checkKeyStringCoercion(value) {
|
|
258
|
-
try {
|
|
259
|
-
testStringCoercion(value);
|
|
260
|
-
var JSCompiler_inline_result = false;
|
|
261
|
-
} catch (e) {
|
|
262
|
-
JSCompiler_inline_result = true;
|
|
263
|
-
}
|
|
264
|
-
if (JSCompiler_inline_result) {
|
|
265
|
-
JSCompiler_inline_result = console;
|
|
266
|
-
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
267
|
-
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
268
|
-
JSCompiler_temp_const.call(
|
|
269
|
-
JSCompiler_inline_result,
|
|
270
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
271
|
-
JSCompiler_inline_result$jscomp$0
|
|
272
|
-
);
|
|
273
|
-
return testStringCoercion(value);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function getComponentNameFromType(type) {
|
|
277
|
-
if (null == type) return null;
|
|
278
|
-
if ("function" === typeof type)
|
|
279
|
-
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
280
|
-
if ("string" === typeof type) return type;
|
|
281
|
-
switch (type) {
|
|
282
|
-
case REACT_FRAGMENT_TYPE:
|
|
283
|
-
return "Fragment";
|
|
284
|
-
case REACT_PROFILER_TYPE:
|
|
285
|
-
return "Profiler";
|
|
286
|
-
case REACT_STRICT_MODE_TYPE:
|
|
287
|
-
return "StrictMode";
|
|
288
|
-
case REACT_SUSPENSE_TYPE:
|
|
289
|
-
return "Suspense";
|
|
290
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
291
|
-
return "SuspenseList";
|
|
292
|
-
case REACT_ACTIVITY_TYPE:
|
|
293
|
-
return "Activity";
|
|
294
|
-
}
|
|
295
|
-
if ("object" === typeof type)
|
|
296
|
-
switch ("number" === typeof type.tag && console.error(
|
|
297
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
298
|
-
), type.$$typeof) {
|
|
299
|
-
case REACT_PORTAL_TYPE:
|
|
300
|
-
return "Portal";
|
|
301
|
-
case REACT_CONTEXT_TYPE:
|
|
302
|
-
return type.displayName || "Context";
|
|
303
|
-
case REACT_CONSUMER_TYPE:
|
|
304
|
-
return (type._context.displayName || "Context") + ".Consumer";
|
|
305
|
-
case REACT_FORWARD_REF_TYPE:
|
|
306
|
-
var innerType = type.render;
|
|
307
|
-
type = type.displayName;
|
|
308
|
-
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
309
|
-
return type;
|
|
310
|
-
case REACT_MEMO_TYPE:
|
|
311
|
-
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
312
|
-
case REACT_LAZY_TYPE:
|
|
313
|
-
innerType = type._payload;
|
|
314
|
-
type = type._init;
|
|
315
|
-
try {
|
|
316
|
-
return getComponentNameFromType(type(innerType));
|
|
317
|
-
} catch (x) {
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
function getTaskName(type) {
|
|
323
|
-
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
324
|
-
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
325
|
-
return "<...>";
|
|
326
|
-
try {
|
|
327
|
-
var name = getComponentNameFromType(type);
|
|
328
|
-
return name ? "<" + name + ">" : "<...>";
|
|
329
|
-
} catch (x) {
|
|
330
|
-
return "<...>";
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function getOwner() {
|
|
334
|
-
var dispatcher = ReactSharedInternals.A;
|
|
335
|
-
return null === dispatcher ? null : dispatcher.getOwner();
|
|
336
|
-
}
|
|
337
|
-
function UnknownOwner() {
|
|
338
|
-
return Error("react-stack-top-frame");
|
|
339
|
-
}
|
|
340
|
-
function hasValidKey(config) {
|
|
341
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
342
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
343
|
-
if (getter && getter.isReactWarning) return false;
|
|
344
|
-
}
|
|
345
|
-
return void 0 !== config.key;
|
|
346
|
-
}
|
|
347
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
348
|
-
function warnAboutAccessingKey() {
|
|
349
|
-
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
350
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
351
|
-
displayName
|
|
352
|
-
));
|
|
353
|
-
}
|
|
354
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
355
|
-
Object.defineProperty(props, "key", {
|
|
356
|
-
get: warnAboutAccessingKey,
|
|
357
|
-
configurable: true
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
function elementRefGetterWithDeprecationWarning() {
|
|
361
|
-
var componentName = getComponentNameFromType(this.type);
|
|
362
|
-
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
363
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
364
|
-
));
|
|
365
|
-
componentName = this.props.ref;
|
|
366
|
-
return void 0 !== componentName ? componentName : null;
|
|
367
|
-
}
|
|
368
|
-
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
369
|
-
var refProp = props.ref;
|
|
370
|
-
type = {
|
|
371
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
372
|
-
type,
|
|
373
|
-
key,
|
|
374
|
-
props,
|
|
375
|
-
_owner: owner
|
|
376
|
-
};
|
|
377
|
-
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
378
|
-
enumerable: false,
|
|
379
|
-
get: elementRefGetterWithDeprecationWarning
|
|
380
|
-
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
381
|
-
type._store = {};
|
|
382
|
-
Object.defineProperty(type._store, "validated", {
|
|
383
|
-
configurable: false,
|
|
384
|
-
enumerable: false,
|
|
385
|
-
writable: true,
|
|
386
|
-
value: 0
|
|
387
|
-
});
|
|
388
|
-
Object.defineProperty(type, "_debugInfo", {
|
|
389
|
-
configurable: false,
|
|
390
|
-
enumerable: false,
|
|
391
|
-
writable: true,
|
|
392
|
-
value: null
|
|
393
|
-
});
|
|
394
|
-
Object.defineProperty(type, "_debugStack", {
|
|
395
|
-
configurable: false,
|
|
396
|
-
enumerable: false,
|
|
397
|
-
writable: true,
|
|
398
|
-
value: debugStack
|
|
399
|
-
});
|
|
400
|
-
Object.defineProperty(type, "_debugTask", {
|
|
401
|
-
configurable: false,
|
|
402
|
-
enumerable: false,
|
|
403
|
-
writable: true,
|
|
404
|
-
value: debugTask
|
|
405
|
-
});
|
|
406
|
-
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
407
|
-
return type;
|
|
408
|
-
}
|
|
409
|
-
function cloneAndReplaceKey(oldElement, newKey) {
|
|
410
|
-
newKey = ReactElement(
|
|
411
|
-
oldElement.type,
|
|
412
|
-
newKey,
|
|
413
|
-
oldElement.props,
|
|
414
|
-
oldElement._owner,
|
|
415
|
-
oldElement._debugStack,
|
|
416
|
-
oldElement._debugTask
|
|
417
|
-
);
|
|
418
|
-
oldElement._store && (newKey._store.validated = oldElement._store.validated);
|
|
419
|
-
return newKey;
|
|
420
|
-
}
|
|
421
|
-
function validateChildKeys(node) {
|
|
422
|
-
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
423
|
-
}
|
|
424
|
-
function isValidElement(object) {
|
|
425
|
-
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
426
|
-
}
|
|
427
|
-
function escape(key) {
|
|
428
|
-
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
429
|
-
return "$" + key.replace(/[=:]/g, function(match) {
|
|
430
|
-
return escaperLookup[match];
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
function getElementKey(element, index) {
|
|
434
|
-
return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
|
|
435
|
-
}
|
|
436
|
-
function resolveThenable(thenable) {
|
|
437
|
-
switch (thenable.status) {
|
|
438
|
-
case "fulfilled":
|
|
439
|
-
return thenable.value;
|
|
440
|
-
case "rejected":
|
|
441
|
-
throw thenable.reason;
|
|
442
|
-
default:
|
|
443
|
-
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
444
|
-
function(fulfilledValue) {
|
|
445
|
-
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
446
|
-
},
|
|
447
|
-
function(error) {
|
|
448
|
-
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
449
|
-
}
|
|
450
|
-
)), thenable.status) {
|
|
451
|
-
case "fulfilled":
|
|
452
|
-
return thenable.value;
|
|
453
|
-
case "rejected":
|
|
454
|
-
throw thenable.reason;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
throw thenable;
|
|
458
|
-
}
|
|
459
|
-
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
460
|
-
var type = typeof children;
|
|
461
|
-
if ("undefined" === type || "boolean" === type) children = null;
|
|
462
|
-
var invokeCallback = false;
|
|
463
|
-
if (null === children) invokeCallback = true;
|
|
464
|
-
else
|
|
465
|
-
switch (type) {
|
|
466
|
-
case "bigint":
|
|
467
|
-
case "string":
|
|
468
|
-
case "number":
|
|
469
|
-
invokeCallback = true;
|
|
470
|
-
break;
|
|
471
|
-
case "object":
|
|
472
|
-
switch (children.$$typeof) {
|
|
473
|
-
case REACT_ELEMENT_TYPE:
|
|
474
|
-
case REACT_PORTAL_TYPE:
|
|
475
|
-
invokeCallback = true;
|
|
476
|
-
break;
|
|
477
|
-
case REACT_LAZY_TYPE:
|
|
478
|
-
return invokeCallback = children._init, mapIntoArray(
|
|
479
|
-
invokeCallback(children._payload),
|
|
480
|
-
array,
|
|
481
|
-
escapedPrefix,
|
|
482
|
-
nameSoFar,
|
|
483
|
-
callback
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (invokeCallback) {
|
|
488
|
-
invokeCallback = children;
|
|
489
|
-
callback = callback(invokeCallback);
|
|
490
|
-
var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
|
491
|
-
isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
492
|
-
return c;
|
|
493
|
-
})) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
|
|
494
|
-
callback,
|
|
495
|
-
escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
|
|
496
|
-
userProvidedKeyEscapeRegex,
|
|
497
|
-
"$&/"
|
|
498
|
-
) + "/") + childKey
|
|
499
|
-
), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
|
|
500
|
-
return 1;
|
|
501
|
-
}
|
|
502
|
-
invokeCallback = 0;
|
|
503
|
-
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
504
|
-
if (isArrayImpl(children))
|
|
505
|
-
for (var i = 0; i < children.length; i++)
|
|
506
|
-
nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
507
|
-
nameSoFar,
|
|
508
|
-
array,
|
|
509
|
-
escapedPrefix,
|
|
510
|
-
type,
|
|
511
|
-
callback
|
|
512
|
-
);
|
|
513
|
-
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
514
|
-
for (i === children.entries && (didWarnAboutMaps || console.warn(
|
|
515
|
-
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
516
|
-
), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
517
|
-
nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
518
|
-
nameSoFar,
|
|
519
|
-
array,
|
|
520
|
-
escapedPrefix,
|
|
521
|
-
type,
|
|
522
|
-
callback
|
|
523
|
-
);
|
|
524
|
-
else if ("object" === type) {
|
|
525
|
-
if ("function" === typeof children.then)
|
|
526
|
-
return mapIntoArray(
|
|
527
|
-
resolveThenable(children),
|
|
528
|
-
array,
|
|
529
|
-
escapedPrefix,
|
|
530
|
-
nameSoFar,
|
|
531
|
-
callback
|
|
532
|
-
);
|
|
533
|
-
array = String(children);
|
|
534
|
-
throw Error(
|
|
535
|
-
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
return invokeCallback;
|
|
539
|
-
}
|
|
540
|
-
function mapChildren(children, func, context) {
|
|
541
|
-
if (null == children) return children;
|
|
542
|
-
var result = [], count = 0;
|
|
543
|
-
mapIntoArray(children, result, "", "", function(child) {
|
|
544
|
-
return func.call(context, child, count++);
|
|
545
|
-
});
|
|
546
|
-
return result;
|
|
547
|
-
}
|
|
548
|
-
function lazyInitializer(payload) {
|
|
549
|
-
if (-1 === payload._status) {
|
|
550
|
-
var ioInfo = payload._ioInfo;
|
|
551
|
-
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
|
|
552
|
-
ioInfo = payload._result;
|
|
553
|
-
var thenable = ioInfo();
|
|
554
|
-
thenable.then(
|
|
555
|
-
function(moduleObject) {
|
|
556
|
-
if (0 === payload._status || -1 === payload._status) {
|
|
557
|
-
payload._status = 1;
|
|
558
|
-
payload._result = moduleObject;
|
|
559
|
-
var _ioInfo = payload._ioInfo;
|
|
560
|
-
null != _ioInfo && (_ioInfo.end = performance.now());
|
|
561
|
-
void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
function(error) {
|
|
565
|
-
if (0 === payload._status || -1 === payload._status) {
|
|
566
|
-
payload._status = 2;
|
|
567
|
-
payload._result = error;
|
|
568
|
-
var _ioInfo2 = payload._ioInfo;
|
|
569
|
-
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
570
|
-
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
);
|
|
574
|
-
ioInfo = payload._ioInfo;
|
|
575
|
-
if (null != ioInfo) {
|
|
576
|
-
ioInfo.value = thenable;
|
|
577
|
-
var displayName = thenable.displayName;
|
|
578
|
-
"string" === typeof displayName && (ioInfo.name = displayName);
|
|
579
|
-
}
|
|
580
|
-
-1 === payload._status && (payload._status = 0, payload._result = thenable);
|
|
581
|
-
}
|
|
582
|
-
if (1 === payload._status)
|
|
583
|
-
return ioInfo = payload._result, void 0 === ioInfo && console.error(
|
|
584
|
-
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
|
585
|
-
ioInfo
|
|
586
|
-
), "default" in ioInfo || console.error(
|
|
587
|
-
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
|
588
|
-
ioInfo
|
|
589
|
-
), ioInfo.default;
|
|
590
|
-
throw payload._result;
|
|
591
|
-
}
|
|
592
|
-
function resolveDispatcher() {
|
|
593
|
-
var dispatcher = ReactSharedInternals.H;
|
|
594
|
-
null === dispatcher && console.error(
|
|
595
|
-
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
596
|
-
);
|
|
597
|
-
return dispatcher;
|
|
598
|
-
}
|
|
599
|
-
function releaseAsyncTransition() {
|
|
600
|
-
ReactSharedInternals.asyncTransitions--;
|
|
601
|
-
}
|
|
602
|
-
function enqueueTask(task) {
|
|
603
|
-
if (null === enqueueTaskImpl)
|
|
604
|
-
try {
|
|
605
|
-
var requireString = ("require" + Math.random()).slice(0, 7);
|
|
606
|
-
enqueueTaskImpl = (module && module[requireString]).call(
|
|
607
|
-
module,
|
|
608
|
-
"timers"
|
|
609
|
-
).setImmediate;
|
|
610
|
-
} catch (_err) {
|
|
611
|
-
enqueueTaskImpl = function(callback) {
|
|
612
|
-
false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
|
|
613
|
-
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
614
|
-
));
|
|
615
|
-
var channel = new MessageChannel();
|
|
616
|
-
channel.port1.onmessage = callback;
|
|
617
|
-
channel.port2.postMessage(void 0);
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
return enqueueTaskImpl(task);
|
|
621
|
-
}
|
|
622
|
-
function aggregateErrors(errors) {
|
|
623
|
-
return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
|
|
624
|
-
}
|
|
625
|
-
function popActScope(prevActQueue, prevActScopeDepth) {
|
|
626
|
-
prevActScopeDepth !== actScopeDepth - 1 && console.error(
|
|
627
|
-
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
628
|
-
);
|
|
629
|
-
actScopeDepth = prevActScopeDepth;
|
|
630
|
-
}
|
|
631
|
-
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
632
|
-
var queue = ReactSharedInternals.actQueue;
|
|
633
|
-
if (null !== queue)
|
|
634
|
-
if (0 !== queue.length)
|
|
635
|
-
try {
|
|
636
|
-
flushActQueue(queue);
|
|
637
|
-
enqueueTask(function() {
|
|
638
|
-
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
639
|
-
});
|
|
640
|
-
return;
|
|
641
|
-
} catch (error) {
|
|
642
|
-
ReactSharedInternals.thrownErrors.push(error);
|
|
643
|
-
}
|
|
644
|
-
else ReactSharedInternals.actQueue = null;
|
|
645
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
|
|
646
|
-
}
|
|
647
|
-
function flushActQueue(queue) {
|
|
648
|
-
if (!isFlushing) {
|
|
649
|
-
isFlushing = true;
|
|
650
|
-
var i = 0;
|
|
651
|
-
try {
|
|
652
|
-
for (; i < queue.length; i++) {
|
|
653
|
-
var callback = queue[i];
|
|
654
|
-
do {
|
|
655
|
-
ReactSharedInternals.didUsePromise = false;
|
|
656
|
-
var continuation = callback(false);
|
|
657
|
-
if (null !== continuation) {
|
|
658
|
-
if (ReactSharedInternals.didUsePromise) {
|
|
659
|
-
queue[i] = callback;
|
|
660
|
-
queue.splice(0, i);
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
callback = continuation;
|
|
664
|
-
} else break;
|
|
665
|
-
} while (1);
|
|
666
|
-
}
|
|
667
|
-
queue.length = 0;
|
|
668
|
-
} catch (error) {
|
|
669
|
-
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
|
670
|
-
} finally {
|
|
671
|
-
isFlushing = false;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
676
|
-
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
|
|
677
|
-
isMounted: function() {
|
|
678
|
-
return false;
|
|
679
|
-
},
|
|
680
|
-
enqueueForceUpdate: function(publicInstance) {
|
|
681
|
-
warnNoop(publicInstance, "forceUpdate");
|
|
682
|
-
},
|
|
683
|
-
enqueueReplaceState: function(publicInstance) {
|
|
684
|
-
warnNoop(publicInstance, "replaceState");
|
|
685
|
-
},
|
|
686
|
-
enqueueSetState: function(publicInstance) {
|
|
687
|
-
warnNoop(publicInstance, "setState");
|
|
688
|
-
}
|
|
689
|
-
}, assign = Object.assign, emptyObject = {};
|
|
690
|
-
Object.freeze(emptyObject);
|
|
691
|
-
Component.prototype.isReactComponent = {};
|
|
692
|
-
Component.prototype.setState = function(partialState, callback) {
|
|
693
|
-
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
694
|
-
throw Error(
|
|
695
|
-
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
696
|
-
);
|
|
697
|
-
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
698
|
-
};
|
|
699
|
-
Component.prototype.forceUpdate = function(callback) {
|
|
700
|
-
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
701
|
-
};
|
|
702
|
-
var deprecatedAPIs = {
|
|
703
|
-
isMounted: [
|
|
704
|
-
"isMounted",
|
|
705
|
-
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
706
|
-
],
|
|
707
|
-
replaceState: [
|
|
708
|
-
"replaceState",
|
|
709
|
-
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
710
|
-
]
|
|
711
|
-
};
|
|
712
|
-
for (fnName in deprecatedAPIs)
|
|
713
|
-
deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
714
|
-
ComponentDummy.prototype = Component.prototype;
|
|
715
|
-
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
|
716
|
-
deprecatedAPIs.constructor = PureComponent;
|
|
717
|
-
assign(deprecatedAPIs, Component.prototype);
|
|
718
|
-
deprecatedAPIs.isPureReactComponent = true;
|
|
719
|
-
var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
|
|
720
|
-
H: null,
|
|
721
|
-
A: null,
|
|
722
|
-
T: null,
|
|
723
|
-
S: null,
|
|
724
|
-
actQueue: null,
|
|
725
|
-
asyncTransitions: 0,
|
|
726
|
-
isBatchingLegacy: false,
|
|
727
|
-
didScheduleLegacyUpdate: false,
|
|
728
|
-
didUsePromise: false,
|
|
729
|
-
thrownErrors: [],
|
|
730
|
-
getCurrentStack: null,
|
|
731
|
-
recentlyCreatedOwnerStacks: 0
|
|
732
|
-
}, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
|
|
733
|
-
return null;
|
|
734
|
-
};
|
|
735
|
-
deprecatedAPIs = {
|
|
736
|
-
react_stack_bottom_frame: function(callStackForError) {
|
|
737
|
-
return callStackForError();
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
|
741
|
-
var didWarnAboutElementRef = {};
|
|
742
|
-
var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
|
|
743
|
-
deprecatedAPIs,
|
|
744
|
-
UnknownOwner
|
|
745
|
-
)();
|
|
746
|
-
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
747
|
-
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
748
|
-
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
749
|
-
var event = new window.ErrorEvent("error", {
|
|
750
|
-
bubbles: true,
|
|
751
|
-
cancelable: true,
|
|
752
|
-
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
753
|
-
error
|
|
754
|
-
});
|
|
755
|
-
if (!window.dispatchEvent(event)) return;
|
|
756
|
-
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
757
|
-
process.emit("uncaughtException", error);
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
console.error(error);
|
|
761
|
-
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
|
762
|
-
queueMicrotask(function() {
|
|
763
|
-
return queueMicrotask(callback);
|
|
764
|
-
});
|
|
765
|
-
} : enqueueTask;
|
|
766
|
-
deprecatedAPIs = Object.freeze({
|
|
767
|
-
__proto__: null,
|
|
768
|
-
c: function(size) {
|
|
769
|
-
return resolveDispatcher().useMemoCache(size);
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
var fnName = {
|
|
773
|
-
map: mapChildren,
|
|
774
|
-
forEach: function(children, forEachFunc, forEachContext) {
|
|
775
|
-
mapChildren(
|
|
776
|
-
children,
|
|
777
|
-
function() {
|
|
778
|
-
forEachFunc.apply(this, arguments);
|
|
779
|
-
},
|
|
780
|
-
forEachContext
|
|
781
|
-
);
|
|
782
|
-
},
|
|
783
|
-
count: function(children) {
|
|
784
|
-
var n = 0;
|
|
785
|
-
mapChildren(children, function() {
|
|
786
|
-
n++;
|
|
787
|
-
});
|
|
788
|
-
return n;
|
|
789
|
-
},
|
|
790
|
-
toArray: function(children) {
|
|
791
|
-
return mapChildren(children, function(child) {
|
|
792
|
-
return child;
|
|
793
|
-
}) || [];
|
|
794
|
-
},
|
|
795
|
-
only: function(children) {
|
|
796
|
-
if (!isValidElement(children))
|
|
797
|
-
throw Error(
|
|
798
|
-
"React.Children.only expected to receive a single React element child."
|
|
799
|
-
);
|
|
800
|
-
return children;
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
804
|
-
exports.Children = fnName;
|
|
805
|
-
exports.Component = Component;
|
|
806
|
-
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
807
|
-
exports.Profiler = REACT_PROFILER_TYPE;
|
|
808
|
-
exports.PureComponent = PureComponent;
|
|
809
|
-
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
810
|
-
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
811
|
-
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
812
|
-
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
|
813
|
-
exports.act = function(callback) {
|
|
814
|
-
var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
|
|
815
|
-
actScopeDepth++;
|
|
816
|
-
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
|
817
|
-
try {
|
|
818
|
-
var result = callback();
|
|
819
|
-
} catch (error) {
|
|
820
|
-
ReactSharedInternals.thrownErrors.push(error);
|
|
821
|
-
}
|
|
822
|
-
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
823
|
-
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
824
|
-
if (null !== result && "object" === typeof result && "function" === typeof result.then) {
|
|
825
|
-
var thenable = result;
|
|
826
|
-
queueSeveralMicrotasks(function() {
|
|
827
|
-
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
828
|
-
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
829
|
-
));
|
|
830
|
-
});
|
|
831
|
-
return {
|
|
832
|
-
then: function(resolve, reject) {
|
|
833
|
-
didAwaitActCall = true;
|
|
834
|
-
thenable.then(
|
|
835
|
-
function(returnValue) {
|
|
836
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
|
837
|
-
if (0 === prevActScopeDepth) {
|
|
838
|
-
try {
|
|
839
|
-
flushActQueue(queue), enqueueTask(function() {
|
|
840
|
-
return recursivelyFlushAsyncActWork(
|
|
841
|
-
returnValue,
|
|
842
|
-
resolve,
|
|
843
|
-
reject
|
|
844
|
-
);
|
|
845
|
-
});
|
|
846
|
-
} catch (error$0) {
|
|
847
|
-
ReactSharedInternals.thrownErrors.push(error$0);
|
|
848
|
-
}
|
|
849
|
-
if (0 < ReactSharedInternals.thrownErrors.length) {
|
|
850
|
-
var _thrownError = aggregateErrors(
|
|
851
|
-
ReactSharedInternals.thrownErrors
|
|
852
|
-
);
|
|
853
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
|
854
|
-
reject(_thrownError);
|
|
855
|
-
}
|
|
856
|
-
} else resolve(returnValue);
|
|
857
|
-
},
|
|
858
|
-
function(error) {
|
|
859
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
|
860
|
-
0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
|
|
861
|
-
ReactSharedInternals.thrownErrors
|
|
862
|
-
), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
|
|
863
|
-
}
|
|
864
|
-
);
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
var returnValue$jscomp$0 = result;
|
|
869
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
|
870
|
-
0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
|
|
871
|
-
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
872
|
-
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
873
|
-
));
|
|
874
|
-
}), ReactSharedInternals.actQueue = null);
|
|
875
|
-
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
876
|
-
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
877
|
-
return {
|
|
878
|
-
then: function(resolve, reject) {
|
|
879
|
-
didAwaitActCall = true;
|
|
880
|
-
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
881
|
-
return recursivelyFlushAsyncActWork(
|
|
882
|
-
returnValue$jscomp$0,
|
|
883
|
-
resolve,
|
|
884
|
-
reject
|
|
885
|
-
);
|
|
886
|
-
})) : resolve(returnValue$jscomp$0);
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
exports.cache = function(fn) {
|
|
891
|
-
return function() {
|
|
892
|
-
return fn.apply(null, arguments);
|
|
893
|
-
};
|
|
894
|
-
};
|
|
895
|
-
exports.cacheSignal = function() {
|
|
896
|
-
return null;
|
|
897
|
-
};
|
|
898
|
-
exports.captureOwnerStack = function() {
|
|
899
|
-
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
|
900
|
-
return null === getCurrentStack ? null : getCurrentStack();
|
|
901
|
-
};
|
|
902
|
-
exports.cloneElement = function(element, config, children) {
|
|
903
|
-
if (null === element || void 0 === element)
|
|
904
|
-
throw Error(
|
|
905
|
-
"The argument must be a React element, but you passed " + element + "."
|
|
906
|
-
);
|
|
907
|
-
var props = assign({}, element.props), key = element.key, owner = element._owner;
|
|
908
|
-
if (null != config) {
|
|
909
|
-
var JSCompiler_inline_result;
|
|
910
|
-
a: {
|
|
911
|
-
if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
|
912
|
-
config,
|
|
913
|
-
"ref"
|
|
914
|
-
).get) && JSCompiler_inline_result.isReactWarning) {
|
|
915
|
-
JSCompiler_inline_result = false;
|
|
916
|
-
break a;
|
|
917
|
-
}
|
|
918
|
-
JSCompiler_inline_result = void 0 !== config.ref;
|
|
919
|
-
}
|
|
920
|
-
JSCompiler_inline_result && (owner = getOwner());
|
|
921
|
-
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
|
922
|
-
for (propName in config)
|
|
923
|
-
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
924
|
-
}
|
|
925
|
-
var propName = arguments.length - 2;
|
|
926
|
-
if (1 === propName) props.children = children;
|
|
927
|
-
else if (1 < propName) {
|
|
928
|
-
JSCompiler_inline_result = Array(propName);
|
|
929
|
-
for (var i = 0; i < propName; i++)
|
|
930
|
-
JSCompiler_inline_result[i] = arguments[i + 2];
|
|
931
|
-
props.children = JSCompiler_inline_result;
|
|
932
|
-
}
|
|
933
|
-
props = ReactElement(
|
|
934
|
-
element.type,
|
|
935
|
-
key,
|
|
936
|
-
props,
|
|
937
|
-
owner,
|
|
938
|
-
element._debugStack,
|
|
939
|
-
element._debugTask
|
|
940
|
-
);
|
|
941
|
-
for (key = 2; key < arguments.length; key++)
|
|
942
|
-
validateChildKeys(arguments[key]);
|
|
943
|
-
return props;
|
|
944
|
-
};
|
|
945
|
-
exports.createContext = function(defaultValue) {
|
|
946
|
-
defaultValue = {
|
|
947
|
-
$$typeof: REACT_CONTEXT_TYPE,
|
|
948
|
-
_currentValue: defaultValue,
|
|
949
|
-
_currentValue2: defaultValue,
|
|
950
|
-
_threadCount: 0,
|
|
951
|
-
Provider: null,
|
|
952
|
-
Consumer: null
|
|
953
|
-
};
|
|
954
|
-
defaultValue.Provider = defaultValue;
|
|
955
|
-
defaultValue.Consumer = {
|
|
956
|
-
$$typeof: REACT_CONSUMER_TYPE,
|
|
957
|
-
_context: defaultValue
|
|
958
|
-
};
|
|
959
|
-
defaultValue._currentRenderer = null;
|
|
960
|
-
defaultValue._currentRenderer2 = null;
|
|
961
|
-
return defaultValue;
|
|
962
|
-
};
|
|
963
|
-
exports.createElement = function(type, config, children) {
|
|
964
|
-
for (var i = 2; i < arguments.length; i++)
|
|
965
|
-
validateChildKeys(arguments[i]);
|
|
966
|
-
i = {};
|
|
967
|
-
var key = null;
|
|
968
|
-
if (null != config)
|
|
969
|
-
for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
|
|
970
|
-
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
971
|
-
)), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
|
|
972
|
-
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
|
|
973
|
-
var childrenLength = arguments.length - 2;
|
|
974
|
-
if (1 === childrenLength) i.children = children;
|
|
975
|
-
else if (1 < childrenLength) {
|
|
976
|
-
for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
|
|
977
|
-
childArray[_i] = arguments[_i + 2];
|
|
978
|
-
Object.freeze && Object.freeze(childArray);
|
|
979
|
-
i.children = childArray;
|
|
980
|
-
}
|
|
981
|
-
if (type && type.defaultProps)
|
|
982
|
-
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
983
|
-
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
|
984
|
-
key && defineKeyPropWarningGetter(
|
|
985
|
-
i,
|
|
986
|
-
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
987
|
-
);
|
|
988
|
-
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
989
|
-
return ReactElement(
|
|
990
|
-
type,
|
|
991
|
-
key,
|
|
992
|
-
i,
|
|
993
|
-
getOwner(),
|
|
994
|
-
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
995
|
-
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
996
|
-
);
|
|
997
|
-
};
|
|
998
|
-
exports.createRef = function() {
|
|
999
|
-
var refObject = { current: null };
|
|
1000
|
-
Object.seal(refObject);
|
|
1001
|
-
return refObject;
|
|
1002
|
-
};
|
|
1003
|
-
exports.forwardRef = function(render) {
|
|
1004
|
-
null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
|
|
1005
|
-
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
1006
|
-
) : "function" !== typeof render ? console.error(
|
|
1007
|
-
"forwardRef requires a render function but was given %s.",
|
|
1008
|
-
null === render ? "null" : typeof render
|
|
1009
|
-
) : 0 !== render.length && 2 !== render.length && console.error(
|
|
1010
|
-
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
1011
|
-
1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
1012
|
-
);
|
|
1013
|
-
null != render && null != render.defaultProps && console.error(
|
|
1014
|
-
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
1015
|
-
);
|
|
1016
|
-
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
|
|
1017
|
-
Object.defineProperty(elementType, "displayName", {
|
|
1018
|
-
enumerable: false,
|
|
1019
|
-
configurable: true,
|
|
1020
|
-
get: function() {
|
|
1021
|
-
return ownName;
|
|
1022
|
-
},
|
|
1023
|
-
set: function(name) {
|
|
1024
|
-
ownName = name;
|
|
1025
|
-
render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
return elementType;
|
|
1029
|
-
};
|
|
1030
|
-
exports.isValidElement = isValidElement;
|
|
1031
|
-
exports.lazy = function(ctor) {
|
|
1032
|
-
ctor = { _status: -1, _result: ctor };
|
|
1033
|
-
var lazyType = {
|
|
1034
|
-
$$typeof: REACT_LAZY_TYPE,
|
|
1035
|
-
_payload: ctor,
|
|
1036
|
-
_init: lazyInitializer
|
|
1037
|
-
}, ioInfo = {
|
|
1038
|
-
name: "lazy",
|
|
1039
|
-
start: -1,
|
|
1040
|
-
end: -1,
|
|
1041
|
-
value: null,
|
|
1042
|
-
owner: null,
|
|
1043
|
-
debugStack: Error("react-stack-top-frame"),
|
|
1044
|
-
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
1045
|
-
};
|
|
1046
|
-
ctor._ioInfo = ioInfo;
|
|
1047
|
-
lazyType._debugInfo = [{ awaited: ioInfo }];
|
|
1048
|
-
return lazyType;
|
|
1049
|
-
};
|
|
1050
|
-
exports.memo = function(type, compare) {
|
|
1051
|
-
null == type && console.error(
|
|
1052
|
-
"memo: The first argument must be a component. Instead received: %s",
|
|
1053
|
-
null === type ? "null" : typeof type
|
|
1054
|
-
);
|
|
1055
|
-
compare = {
|
|
1056
|
-
$$typeof: REACT_MEMO_TYPE,
|
|
1057
|
-
type,
|
|
1058
|
-
compare: void 0 === compare ? null : compare
|
|
1059
|
-
};
|
|
1060
|
-
var ownName;
|
|
1061
|
-
Object.defineProperty(compare, "displayName", {
|
|
1062
|
-
enumerable: false,
|
|
1063
|
-
configurable: true,
|
|
1064
|
-
get: function() {
|
|
1065
|
-
return ownName;
|
|
1066
|
-
},
|
|
1067
|
-
set: function(name) {
|
|
1068
|
-
ownName = name;
|
|
1069
|
-
type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
|
|
1070
|
-
}
|
|
1071
|
-
});
|
|
1072
|
-
return compare;
|
|
1073
|
-
};
|
|
1074
|
-
exports.startTransition = function(scope) {
|
|
1075
|
-
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
1076
|
-
currentTransition._updatedFibers = /* @__PURE__ */ new Set();
|
|
1077
|
-
ReactSharedInternals.T = currentTransition;
|
|
1078
|
-
try {
|
|
1079
|
-
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
1080
|
-
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
1081
|
-
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
|
|
1082
|
-
} catch (error) {
|
|
1083
|
-
reportGlobalError(error);
|
|
1084
|
-
} finally {
|
|
1085
|
-
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
|
1086
|
-
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
1087
|
-
)), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
|
|
1088
|
-
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
1089
|
-
), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
exports.unstable_useCacheRefresh = function() {
|
|
1093
|
-
return resolveDispatcher().useCacheRefresh();
|
|
1094
|
-
};
|
|
1095
|
-
exports.use = function(usable) {
|
|
1096
|
-
return resolveDispatcher().use(usable);
|
|
1097
|
-
};
|
|
1098
|
-
exports.useActionState = function(action, initialState, permalink) {
|
|
1099
|
-
return resolveDispatcher().useActionState(
|
|
1100
|
-
action,
|
|
1101
|
-
initialState,
|
|
1102
|
-
permalink
|
|
1103
|
-
);
|
|
1104
|
-
};
|
|
1105
|
-
exports.useCallback = function(callback, deps) {
|
|
1106
|
-
return resolveDispatcher().useCallback(callback, deps);
|
|
1107
|
-
};
|
|
1108
|
-
exports.useContext = function(Context) {
|
|
1109
|
-
var dispatcher = resolveDispatcher();
|
|
1110
|
-
Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
|
|
1111
|
-
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
1112
|
-
);
|
|
1113
|
-
return dispatcher.useContext(Context);
|
|
1114
|
-
};
|
|
1115
|
-
exports.useDebugValue = function(value, formatterFn) {
|
|
1116
|
-
return resolveDispatcher().useDebugValue(value, formatterFn);
|
|
1117
|
-
};
|
|
1118
|
-
exports.useDeferredValue = function(value, initialValue) {
|
|
1119
|
-
return resolveDispatcher().useDeferredValue(value, initialValue);
|
|
1120
|
-
};
|
|
1121
|
-
exports.useEffect = function(create2, deps) {
|
|
1122
|
-
null == create2 && console.warn(
|
|
1123
|
-
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1124
|
-
);
|
|
1125
|
-
return resolveDispatcher().useEffect(create2, deps);
|
|
1126
|
-
};
|
|
1127
|
-
exports.useEffectEvent = function(callback) {
|
|
1128
|
-
return resolveDispatcher().useEffectEvent(callback);
|
|
1129
|
-
};
|
|
1130
|
-
exports.useId = function() {
|
|
1131
|
-
return resolveDispatcher().useId();
|
|
1132
|
-
};
|
|
1133
|
-
exports.useImperativeHandle = function(ref, create2, deps) {
|
|
1134
|
-
return resolveDispatcher().useImperativeHandle(ref, create2, deps);
|
|
1135
|
-
};
|
|
1136
|
-
exports.useInsertionEffect = function(create2, deps) {
|
|
1137
|
-
null == create2 && console.warn(
|
|
1138
|
-
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1139
|
-
);
|
|
1140
|
-
return resolveDispatcher().useInsertionEffect(create2, deps);
|
|
1141
|
-
};
|
|
1142
|
-
exports.useLayoutEffect = function(create2, deps) {
|
|
1143
|
-
null == create2 && console.warn(
|
|
1144
|
-
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1145
|
-
);
|
|
1146
|
-
return resolveDispatcher().useLayoutEffect(create2, deps);
|
|
1147
|
-
};
|
|
1148
|
-
exports.useMemo = function(create2, deps) {
|
|
1149
|
-
return resolveDispatcher().useMemo(create2, deps);
|
|
1150
|
-
};
|
|
1151
|
-
exports.useOptimistic = function(passthrough, reducer) {
|
|
1152
|
-
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
|
1153
|
-
};
|
|
1154
|
-
exports.useReducer = function(reducer, initialArg, init) {
|
|
1155
|
-
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
|
1156
|
-
};
|
|
1157
|
-
exports.useRef = function(initialValue) {
|
|
1158
|
-
return resolveDispatcher().useRef(initialValue);
|
|
1159
|
-
};
|
|
1160
|
-
exports.useState = function(initialState) {
|
|
1161
|
-
return resolveDispatcher().useState(initialState);
|
|
1162
|
-
};
|
|
1163
|
-
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
1164
|
-
return resolveDispatcher().useSyncExternalStore(
|
|
1165
|
-
subscribe,
|
|
1166
|
-
getSnapshot,
|
|
1167
|
-
getServerSnapshot
|
|
1168
|
-
);
|
|
1169
|
-
};
|
|
1170
|
-
exports.useTransition = function() {
|
|
1171
|
-
return resolveDispatcher().useTransition();
|
|
1172
|
-
};
|
|
1173
|
-
exports.version = "19.2.5";
|
|
1174
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1175
|
-
})();
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
// node_modules/react/index.js
|
|
1180
|
-
var require_react = __commonJS({
|
|
1181
|
-
"node_modules/react/index.js"(exports, module) {
|
|
1182
|
-
"use strict";
|
|
1183
|
-
if (false) {
|
|
1184
|
-
module.exports = null;
|
|
1185
|
-
} else {
|
|
1186
|
-
module.exports = require_react_development();
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
|
|
1191
207
|
// node_modules/eventemitter3/index.mjs
|
|
1192
208
|
var import_index = __toESM(require_eventemitter3(), 1);
|
|
1193
209
|
|
|
@@ -2061,11 +1077,15 @@ updateRateLimitState_fn = function() {
|
|
|
2061
1077
|
};
|
|
2062
1078
|
|
|
2063
1079
|
// src/core/persistence-manager.ts
|
|
2064
|
-
var
|
|
1080
|
+
var PersistenceManager = class {
|
|
1081
|
+
constructor(storageKey = "queue_manager_state") {
|
|
1082
|
+
__publicField(this, "storageKey");
|
|
1083
|
+
this.storageKey = storageKey;
|
|
1084
|
+
}
|
|
2065
1085
|
async saveQueueStates(states) {
|
|
2066
1086
|
try {
|
|
2067
1087
|
if (chrome.storage) {
|
|
2068
|
-
await chrome.storage.local.set({ [
|
|
1088
|
+
await chrome.storage.local.set({ [this.storageKey]: states });
|
|
2069
1089
|
}
|
|
2070
1090
|
} catch (e) {
|
|
2071
1091
|
console.error("Failed to persist queue states:", e);
|
|
@@ -2074,8 +1094,8 @@ var _PersistenceManager = class _PersistenceManager {
|
|
|
2074
1094
|
async loadQueueStates() {
|
|
2075
1095
|
try {
|
|
2076
1096
|
if (chrome.storage) {
|
|
2077
|
-
const data = await chrome.storage.local.get(
|
|
2078
|
-
const stored = data[
|
|
1097
|
+
const data = await chrome.storage.local.get(this.storageKey);
|
|
1098
|
+
const stored = data[this.storageKey];
|
|
2079
1099
|
if (stored && typeof stored === "object") {
|
|
2080
1100
|
return stored;
|
|
2081
1101
|
}
|
|
@@ -2086,8 +1106,6 @@ var _PersistenceManager = class _PersistenceManager {
|
|
|
2086
1106
|
return {};
|
|
2087
1107
|
}
|
|
2088
1108
|
};
|
|
2089
|
-
__publicField(_PersistenceManager, "STORAGE_KEY", "queue_manager_state");
|
|
2090
|
-
var PersistenceManager = _PersistenceManager;
|
|
2091
1109
|
var persistenceManager = new PersistenceManager();
|
|
2092
1110
|
|
|
2093
1111
|
// src/core/engine-hub.ts
|
|
@@ -2108,35 +1126,18 @@ var EngineHub = class {
|
|
|
2108
1126
|
var engineHub = new EngineHub();
|
|
2109
1127
|
|
|
2110
1128
|
// src/core/helper.ts
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
signal
|
|
2114
|
-
|
|
2115
|
-
await new Promise((resolve, reject) => {
|
|
2116
|
-
const abortHandler = () => {
|
|
2117
|
-
reject(new DOMException("Sleep aborted", "AbortError"));
|
|
2118
|
-
};
|
|
2119
|
-
if (signal) {
|
|
2120
|
-
signal.addEventListener("abort", abortHandler, { once: true });
|
|
2121
|
-
}
|
|
2122
|
-
const timeoutId = setTimeout(() => {
|
|
2123
|
-
if (signal) {
|
|
2124
|
-
signal.removeEventListener("abort", abortHandler);
|
|
2125
|
-
}
|
|
2126
|
-
resolve(void 0);
|
|
2127
|
-
}, ms);
|
|
2128
|
-
if (signal) {
|
|
2129
|
-
signal.addEventListener(
|
|
2130
|
-
"abort",
|
|
2131
|
-
() => {
|
|
2132
|
-
clearTimeout(timeoutId);
|
|
2133
|
-
reject(new DOMException("Sleep aborted", "AbortError"));
|
|
2134
|
-
},
|
|
2135
|
-
{ once: true }
|
|
2136
|
-
);
|
|
1129
|
+
var sleep = (seconds, signal) => {
|
|
1130
|
+
return new Promise((resolve, reject) => {
|
|
1131
|
+
if (signal?.aborted) {
|
|
1132
|
+
return reject(new Error("CANCELLED"));
|
|
2137
1133
|
}
|
|
1134
|
+
const timeout = setTimeout(resolve, seconds);
|
|
1135
|
+
signal?.addEventListener("abort", () => {
|
|
1136
|
+
clearTimeout(timeout);
|
|
1137
|
+
reject(new Error("CANCELLED"));
|
|
1138
|
+
}, { once: true });
|
|
2138
1139
|
});
|
|
2139
|
-
}
|
|
1140
|
+
};
|
|
2140
1141
|
|
|
2141
1142
|
// src/core/task-context.ts
|
|
2142
1143
|
var TaskContext = class {
|
|
@@ -2185,18 +1186,28 @@ var QueueManager = class {
|
|
|
2185
1186
|
__publicField(this, "runningQueues", /* @__PURE__ */ new Set());
|
|
2186
1187
|
__publicField(this, "concurrencyMap", /* @__PURE__ */ new Map());
|
|
2187
1188
|
__publicField(this, "abortControllers", /* @__PURE__ */ new Map());
|
|
1189
|
+
__publicField(this, "debug", false);
|
|
1190
|
+
__publicField(this, "persistenceManager");
|
|
2188
1191
|
this.defaultOptions = options;
|
|
1192
|
+
this.debug = options.debug ?? false;
|
|
1193
|
+
this.persistenceManager = new PersistenceManager(options.storageKey);
|
|
1194
|
+
}
|
|
1195
|
+
debugLog(...args) {
|
|
1196
|
+
if (this.debug) {
|
|
1197
|
+
console.log(...args);
|
|
1198
|
+
}
|
|
2189
1199
|
}
|
|
2190
1200
|
logQueueState(keycard, identifier, action) {
|
|
1201
|
+
if (!this.debug) return;
|
|
2191
1202
|
const key = this.getQueueKey(keycard, identifier);
|
|
2192
1203
|
const entry = this.queues.get(key);
|
|
2193
1204
|
if (!entry) {
|
|
2194
|
-
|
|
1205
|
+
this.debugLog(`[Queue] ${action} - Queue not found for key: ${key}`);
|
|
2195
1206
|
return;
|
|
2196
1207
|
}
|
|
2197
1208
|
const taskSummary = entry.tasks.map((t) => `[${t.id}] ${t.status}${t.name ? ` (${t.name})` : ""}`).join(", ");
|
|
2198
|
-
|
|
2199
|
-
`[Queue] ${action} | Key: ${key} | Tasks: ${entry.tasks.length} | Queue size: ${entry.queue.size} | Pending: ${entry.queue.pending} |
|
|
1209
|
+
this.debugLog(
|
|
1210
|
+
`[Queue] ${action} | Key: ${key} | Tasks: ${entry.tasks.length} | Queue size: ${entry.queue.size} | Pending: ${entry.queue.pending} | isRunning: ${!entry.queue.isPaused} | Tasks: ${taskSummary}`
|
|
2200
1211
|
);
|
|
2201
1212
|
}
|
|
2202
1213
|
getQueueKey(keycard, identifier) {
|
|
@@ -2271,6 +1282,9 @@ var QueueManager = class {
|
|
|
2271
1282
|
engineHub.register(keycard, engine);
|
|
2272
1283
|
}
|
|
2273
1284
|
async add(keycard, identifier, task) {
|
|
1285
|
+
this.debugLog(
|
|
1286
|
+
`[DEBUG] ADD task ${task.id} (${task.name || "unnamed"}) to ${keycard}/${identifier || "default"}`
|
|
1287
|
+
);
|
|
2274
1288
|
const entry = this.getOrCreateQueue(keycard, identifier);
|
|
2275
1289
|
const { queue, tasks, queuedIds } = entry;
|
|
2276
1290
|
const exists = tasks.find((t) => t.id === task.id);
|
|
@@ -2291,6 +1305,9 @@ var QueueManager = class {
|
|
|
2291
1305
|
this.logQueueState(keycard, identifier, "ADD");
|
|
2292
1306
|
}
|
|
2293
1307
|
async addMany(keycard, identifier, newTasks) {
|
|
1308
|
+
this.debugLog(
|
|
1309
|
+
`[DEBUG] ADD_MANY ${newTasks.length} tasks to ${keycard}/${identifier || "default"}`
|
|
1310
|
+
);
|
|
2294
1311
|
const entry = this.getOrCreateQueue(keycard, identifier);
|
|
2295
1312
|
const { queue, tasks, queuedIds } = entry;
|
|
2296
1313
|
for (const task of newTasks) {
|
|
@@ -2313,6 +1330,7 @@ var QueueManager = class {
|
|
|
2313
1330
|
this.logQueueState(keycard, identifier, "ADD_MANY");
|
|
2314
1331
|
}
|
|
2315
1332
|
async start(keycard, identifier) {
|
|
1333
|
+
this.debugLog(`[DEBUG] START queue ${keycard}/${identifier || "default"}`);
|
|
2316
1334
|
const key = this.getQueueKey(keycard, identifier);
|
|
2317
1335
|
const entry = this.queues.get(key);
|
|
2318
1336
|
if (entry) {
|
|
@@ -2337,6 +1355,7 @@ var QueueManager = class {
|
|
|
2337
1355
|
}
|
|
2338
1356
|
}
|
|
2339
1357
|
async stop(keycard, identifier) {
|
|
1358
|
+
this.debugLog(`[DEBUG] STOP queue ${keycard}/${identifier || "default"}`);
|
|
2340
1359
|
const key = this.getQueueKey(keycard, identifier);
|
|
2341
1360
|
const entry = this.queues.get(key);
|
|
2342
1361
|
if (entry) {
|
|
@@ -2357,6 +1376,7 @@ var QueueManager = class {
|
|
|
2357
1376
|
}
|
|
2358
1377
|
}
|
|
2359
1378
|
async pause(keycard, identifier) {
|
|
1379
|
+
this.debugLog(`[DEBUG] PAUSE queue ${keycard}/${identifier || "default"}`);
|
|
2360
1380
|
const key = this.getQueueKey(keycard, identifier);
|
|
2361
1381
|
const entry = this.queues.get(key);
|
|
2362
1382
|
if (entry) {
|
|
@@ -2366,6 +1386,7 @@ var QueueManager = class {
|
|
|
2366
1386
|
}
|
|
2367
1387
|
}
|
|
2368
1388
|
async resume(keycard, identifier) {
|
|
1389
|
+
this.debugLog(`[DEBUG] RESUME queue ${keycard}/${identifier || "default"}`);
|
|
2369
1390
|
const key = this.getQueueKey(keycard, identifier);
|
|
2370
1391
|
const entry = this.queues.get(key);
|
|
2371
1392
|
if (entry) {
|
|
@@ -2375,6 +1396,7 @@ var QueueManager = class {
|
|
|
2375
1396
|
}
|
|
2376
1397
|
}
|
|
2377
1398
|
async clear(keycard, identifier) {
|
|
1399
|
+
this.debugLog(`[DEBUG] CLEAR queue ${keycard}/${identifier || "default"}`);
|
|
2378
1400
|
const key = this.getQueueKey(keycard, identifier);
|
|
2379
1401
|
const entry = this.queues.get(key);
|
|
2380
1402
|
if (entry) {
|
|
@@ -2416,6 +1438,7 @@ var QueueManager = class {
|
|
|
2416
1438
|
* Stops execution AND removes the task from the project entirely.
|
|
2417
1439
|
*/
|
|
2418
1440
|
async cancelTask(keycard, identifier, taskId) {
|
|
1441
|
+
this.debugLog(`[DEBUG] CANCEL_TASK ${taskId} from ${keycard}/${identifier || "default"}`);
|
|
2419
1442
|
const controller = this.abortControllers.get(taskId);
|
|
2420
1443
|
if (controller) {
|
|
2421
1444
|
controller.abort();
|
|
@@ -2431,6 +1454,7 @@ var QueueManager = class {
|
|
|
2431
1454
|
this.notifyStatusChange(keycard, identifier);
|
|
2432
1455
|
}
|
|
2433
1456
|
getStatus(keycard, identifier) {
|
|
1457
|
+
this.debugLog(`[DEBUG] GET_STATUS ${keycard}/${identifier || "default"}`);
|
|
2434
1458
|
const key = this.getQueueKey(keycard, identifier);
|
|
2435
1459
|
const entry = this.queues.get(key);
|
|
2436
1460
|
const activeTasks = entry?.tasks || [];
|
|
@@ -2439,14 +1463,17 @@ var QueueManager = class {
|
|
|
2439
1463
|
return {
|
|
2440
1464
|
size,
|
|
2441
1465
|
pending,
|
|
2442
|
-
|
|
2443
|
-
isRunning: this.runningQueues.has(key)
|
|
1466
|
+
isRunning: !entry?.queue.isPaused || this.runningQueues.has(key)
|
|
2444
1467
|
};
|
|
2445
1468
|
}
|
|
2446
1469
|
getTasks(keycard, identifier) {
|
|
2447
1470
|
const key = this.getQueueKey(keycard, identifier);
|
|
2448
1471
|
const entry = this.queues.get(key);
|
|
2449
|
-
|
|
1472
|
+
const tasks = entry?.tasks || [];
|
|
1473
|
+
this.debugLog(
|
|
1474
|
+
`[DEBUG] GET_TASKS ${keycard}/${identifier || "default"}, count: ${tasks.length}`
|
|
1475
|
+
);
|
|
1476
|
+
return tasks;
|
|
2450
1477
|
}
|
|
2451
1478
|
updateTasks(keycard, identifier, tasks) {
|
|
2452
1479
|
this.notifyTasksUpdate(keycard, identifier, tasks);
|
|
@@ -2478,7 +1505,7 @@ var QueueManager = class {
|
|
|
2478
1505
|
return;
|
|
2479
1506
|
}
|
|
2480
1507
|
if (task.isFlagged) {
|
|
2481
|
-
|
|
1508
|
+
this.debugLog(`[QueueManager] Task ${task.id} is flagged. Skipping.`);
|
|
2482
1509
|
const taskIndex2 = entry.tasks.findIndex((t) => t.id === task.id);
|
|
2483
1510
|
const taskEntry = entry.tasks[taskIndex2];
|
|
2484
1511
|
if (taskIndex2 !== -1 && taskEntry) {
|
|
@@ -2494,7 +1521,7 @@ var QueueManager = class {
|
|
|
2494
1521
|
}
|
|
2495
1522
|
const taskIndex = entry.tasks.findIndex((t) => t.id === task.id);
|
|
2496
1523
|
if (taskIndex === -1) {
|
|
2497
|
-
|
|
1524
|
+
this.debugLog(`[QueueManager] Task ${task.id} was removed. Skipping execution.`);
|
|
2498
1525
|
return;
|
|
2499
1526
|
}
|
|
2500
1527
|
const currentTask = entry.tasks[taskIndex];
|
|
@@ -2511,7 +1538,7 @@ var QueueManager = class {
|
|
|
2511
1538
|
};
|
|
2512
1539
|
if (delayMax > 0) {
|
|
2513
1540
|
const delayMs = Math.floor(Math.random() * (delayMax - delayMin + 1) + delayMin) * 1e3;
|
|
2514
|
-
|
|
1541
|
+
this.debugLog(`[QueueManager] Delaying task ${task.id} for ${delayMs}ms...`);
|
|
2515
1542
|
await sleep(delayMs, this.abortControllers.get(key)?.signal);
|
|
2516
1543
|
}
|
|
2517
1544
|
this.logQueueState(keycard, identifier, `PROCESS_START ${task.id}`);
|
|
@@ -2542,7 +1569,7 @@ var QueueManager = class {
|
|
|
2542
1569
|
const finTask = entry.tasks[idx];
|
|
2543
1570
|
if (!finTask) return;
|
|
2544
1571
|
if (finTask.status !== "Running") {
|
|
2545
|
-
|
|
1572
|
+
this.debugLog(
|
|
2546
1573
|
`Task ${task.id} finished but its status was already changed to ${finTask.status}. Bailing out.`
|
|
2547
1574
|
);
|
|
2548
1575
|
return;
|
|
@@ -2641,8 +1668,7 @@ var QueueManager = class {
|
|
|
2641
1668
|
const status = {
|
|
2642
1669
|
size: entry?.queue.size || 0,
|
|
2643
1670
|
pending: entry?.queue.pending || 0,
|
|
2644
|
-
|
|
2645
|
-
isRunning: this.runningQueues.has(key)
|
|
1671
|
+
isRunning: !entry?.queue.isPaused || this.runningQueues.has(key)
|
|
2646
1672
|
};
|
|
2647
1673
|
const opts = this.getOptions(keycard);
|
|
2648
1674
|
opts.forEach((opt) => opt.onTasksUpdate?.(keycard, identifier, tasks, status));
|
|
@@ -2652,11 +1678,10 @@ var QueueManager = class {
|
|
|
2652
1678
|
const states = {};
|
|
2653
1679
|
for (const [key, entry] of this.queues.entries()) {
|
|
2654
1680
|
states[key] = {
|
|
2655
|
-
isPaused: entry.queue.isPaused,
|
|
2656
1681
|
isRunning: this.runningQueues.has(key)
|
|
2657
1682
|
};
|
|
2658
1683
|
}
|
|
2659
|
-
await persistenceManager.saveQueueStates(states);
|
|
1684
|
+
await this.persistenceManager.saveQueueStates(states);
|
|
2660
1685
|
}
|
|
2661
1686
|
updateTaskConfig(keycard, identifier, taskConfig) {
|
|
2662
1687
|
const key = this.getQueueKey(keycard, identifier);
|
|
@@ -2664,12 +1689,12 @@ var QueueManager = class {
|
|
|
2664
1689
|
if (entry) {
|
|
2665
1690
|
entry.taskConfig = taskConfig;
|
|
2666
1691
|
entry.queue.concurrency = taskConfig.threads;
|
|
2667
|
-
|
|
1692
|
+
this.debugLog(`[QueueManager] Updated concurrency for ${key} to ${taskConfig.threads}`);
|
|
2668
1693
|
}
|
|
2669
1694
|
this.concurrencyMap.set(keycard, taskConfig.threads);
|
|
2670
1695
|
}
|
|
2671
1696
|
async hydrate() {
|
|
2672
|
-
const states = await persistenceManager.loadQueueStates();
|
|
1697
|
+
const states = await this.persistenceManager.loadQueueStates();
|
|
2673
1698
|
if (!states) return;
|
|
2674
1699
|
for (const key in states) {
|
|
2675
1700
|
const state = states[key];
|
|
@@ -2677,7 +1702,7 @@ var QueueManager = class {
|
|
|
2677
1702
|
const [keycard, identifier] = key.split("__");
|
|
2678
1703
|
if (!keycard || !identifier) continue;
|
|
2679
1704
|
const entry = this.getOrCreateQueue(keycard, identifier);
|
|
2680
|
-
if (state.
|
|
1705
|
+
if (!state.isRunning) {
|
|
2681
1706
|
entry.queue.pause();
|
|
2682
1707
|
} else {
|
|
2683
1708
|
entry.queue.start();
|
|
@@ -2713,10 +1738,11 @@ var QueueManager = class {
|
|
|
2713
1738
|
}
|
|
2714
1739
|
};
|
|
2715
1740
|
var queueManagerInstance = null;
|
|
2716
|
-
function getQueueManager() {
|
|
1741
|
+
function getQueueManager(options) {
|
|
2717
1742
|
if (!queueManagerInstance) {
|
|
2718
1743
|
queueManagerInstance = new QueueManager({
|
|
2719
|
-
defaultConcurrency: 1
|
|
1744
|
+
defaultConcurrency: 1,
|
|
1745
|
+
...options
|
|
2720
1746
|
});
|
|
2721
1747
|
}
|
|
2722
1748
|
return queueManagerInstance;
|
|
@@ -2739,257 +1765,16 @@ var QUEUE_COMMAND = {
|
|
|
2739
1765
|
SET_TASK_CONFIG: "SET_TASK_CONFIG"
|
|
2740
1766
|
};
|
|
2741
1767
|
|
|
2742
|
-
// node_modules/zustand/esm/vanilla.mjs
|
|
2743
|
-
var createStoreImpl = (createState) => {
|
|
2744
|
-
let state;
|
|
2745
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
2746
|
-
const setState = (partial, replace) => {
|
|
2747
|
-
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
2748
|
-
if (!Object.is(nextState, state)) {
|
|
2749
|
-
const previousState = state;
|
|
2750
|
-
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
2751
|
-
listeners.forEach((listener) => listener(state, previousState));
|
|
2752
|
-
}
|
|
2753
|
-
};
|
|
2754
|
-
const getState = () => state;
|
|
2755
|
-
const getInitialState = () => initialState;
|
|
2756
|
-
const subscribe = (listener) => {
|
|
2757
|
-
listeners.add(listener);
|
|
2758
|
-
return () => listeners.delete(listener);
|
|
2759
|
-
};
|
|
2760
|
-
const api = { setState, getState, getInitialState, subscribe };
|
|
2761
|
-
const initialState = state = createState(setState, getState, api);
|
|
2762
|
-
return api;
|
|
2763
|
-
};
|
|
2764
|
-
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
2765
|
-
|
|
2766
|
-
// node_modules/zustand/esm/react.mjs
|
|
2767
|
-
var import_react = __toESM(require_react(), 1);
|
|
2768
|
-
var identity = (arg) => arg;
|
|
2769
|
-
function useStore(api, selector = identity) {
|
|
2770
|
-
const slice = import_react.default.useSyncExternalStore(
|
|
2771
|
-
api.subscribe,
|
|
2772
|
-
import_react.default.useCallback(() => selector(api.getState()), [api, selector]),
|
|
2773
|
-
import_react.default.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
2774
|
-
);
|
|
2775
|
-
import_react.default.useDebugValue(slice);
|
|
2776
|
-
return slice;
|
|
2777
|
-
}
|
|
2778
|
-
var createImpl = (createState) => {
|
|
2779
|
-
const api = createStore(createState);
|
|
2780
|
-
const useBoundStore = (selector) => useStore(api, selector);
|
|
2781
|
-
Object.assign(useBoundStore, api);
|
|
2782
|
-
return useBoundStore;
|
|
2783
|
-
};
|
|
2784
|
-
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
2785
|
-
|
|
2786
|
-
// node_modules/zustand/esm/middleware.mjs
|
|
2787
|
-
function createJSONStorage(getStorage, options) {
|
|
2788
|
-
let storage;
|
|
2789
|
-
try {
|
|
2790
|
-
storage = getStorage();
|
|
2791
|
-
} catch (e) {
|
|
2792
|
-
return;
|
|
2793
|
-
}
|
|
2794
|
-
const persistStorage = {
|
|
2795
|
-
getItem: (name) => {
|
|
2796
|
-
var _a;
|
|
2797
|
-
const parse = (str2) => {
|
|
2798
|
-
if (str2 === null) {
|
|
2799
|
-
return null;
|
|
2800
|
-
}
|
|
2801
|
-
return JSON.parse(str2, options == null ? void 0 : options.reviver);
|
|
2802
|
-
};
|
|
2803
|
-
const str = (_a = storage.getItem(name)) != null ? _a : null;
|
|
2804
|
-
if (str instanceof Promise) {
|
|
2805
|
-
return str.then(parse);
|
|
2806
|
-
}
|
|
2807
|
-
return parse(str);
|
|
2808
|
-
},
|
|
2809
|
-
setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),
|
|
2810
|
-
removeItem: (name) => storage.removeItem(name)
|
|
2811
|
-
};
|
|
2812
|
-
return persistStorage;
|
|
2813
|
-
}
|
|
2814
|
-
var toThenable = (fn) => (input) => {
|
|
2815
|
-
try {
|
|
2816
|
-
const result = fn(input);
|
|
2817
|
-
if (result instanceof Promise) {
|
|
2818
|
-
return result;
|
|
2819
|
-
}
|
|
2820
|
-
return {
|
|
2821
|
-
then(onFulfilled) {
|
|
2822
|
-
return toThenable(onFulfilled)(result);
|
|
2823
|
-
},
|
|
2824
|
-
catch(_onRejected) {
|
|
2825
|
-
return this;
|
|
2826
|
-
}
|
|
2827
|
-
};
|
|
2828
|
-
} catch (e) {
|
|
2829
|
-
return {
|
|
2830
|
-
then(_onFulfilled) {
|
|
2831
|
-
return this;
|
|
2832
|
-
},
|
|
2833
|
-
catch(onRejected) {
|
|
2834
|
-
return toThenable(onRejected)(e);
|
|
2835
|
-
}
|
|
2836
|
-
};
|
|
2837
|
-
}
|
|
2838
|
-
};
|
|
2839
|
-
var persistImpl = (config, baseOptions) => (set, get, api) => {
|
|
2840
|
-
let options = {
|
|
2841
|
-
storage: createJSONStorage(() => window.localStorage),
|
|
2842
|
-
partialize: (state) => state,
|
|
2843
|
-
version: 0,
|
|
2844
|
-
merge: (persistedState, currentState) => ({
|
|
2845
|
-
...currentState,
|
|
2846
|
-
...persistedState
|
|
2847
|
-
}),
|
|
2848
|
-
...baseOptions
|
|
2849
|
-
};
|
|
2850
|
-
let hasHydrated = false;
|
|
2851
|
-
let hydrationVersion = 0;
|
|
2852
|
-
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
2853
|
-
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
2854
|
-
let storage = options.storage;
|
|
2855
|
-
if (!storage) {
|
|
2856
|
-
return config(
|
|
2857
|
-
(...args) => {
|
|
2858
|
-
console.warn(
|
|
2859
|
-
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
2860
|
-
);
|
|
2861
|
-
set(...args);
|
|
2862
|
-
},
|
|
2863
|
-
get,
|
|
2864
|
-
api
|
|
2865
|
-
);
|
|
2866
|
-
}
|
|
2867
|
-
const setItem = () => {
|
|
2868
|
-
const state = options.partialize({ ...get() });
|
|
2869
|
-
return storage.setItem(options.name, {
|
|
2870
|
-
state,
|
|
2871
|
-
version: options.version
|
|
2872
|
-
});
|
|
2873
|
-
};
|
|
2874
|
-
const savedSetState = api.setState;
|
|
2875
|
-
api.setState = (state, replace) => {
|
|
2876
|
-
savedSetState(state, replace);
|
|
2877
|
-
return setItem();
|
|
2878
|
-
};
|
|
2879
|
-
const configResult = config(
|
|
2880
|
-
(...args) => {
|
|
2881
|
-
set(...args);
|
|
2882
|
-
return setItem();
|
|
2883
|
-
},
|
|
2884
|
-
get,
|
|
2885
|
-
api
|
|
2886
|
-
);
|
|
2887
|
-
api.getInitialState = () => configResult;
|
|
2888
|
-
let stateFromStorage;
|
|
2889
|
-
const hydrate = () => {
|
|
2890
|
-
var _a, _b;
|
|
2891
|
-
if (!storage) return;
|
|
2892
|
-
const currentVersion = ++hydrationVersion;
|
|
2893
|
-
hasHydrated = false;
|
|
2894
|
-
hydrationListeners.forEach((cb) => {
|
|
2895
|
-
var _a2;
|
|
2896
|
-
return cb((_a2 = get()) != null ? _a2 : configResult);
|
|
2897
|
-
});
|
|
2898
|
-
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
|
|
2899
|
-
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
2900
|
-
if (deserializedStorageValue) {
|
|
2901
|
-
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
2902
|
-
if (options.migrate) {
|
|
2903
|
-
const migration = options.migrate(
|
|
2904
|
-
deserializedStorageValue.state,
|
|
2905
|
-
deserializedStorageValue.version
|
|
2906
|
-
);
|
|
2907
|
-
if (migration instanceof Promise) {
|
|
2908
|
-
return migration.then((result) => [true, result]);
|
|
2909
|
-
}
|
|
2910
|
-
return [true, migration];
|
|
2911
|
-
}
|
|
2912
|
-
console.error(
|
|
2913
|
-
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
2914
|
-
);
|
|
2915
|
-
} else {
|
|
2916
|
-
return [false, deserializedStorageValue.state];
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
return [false, void 0];
|
|
2920
|
-
}).then((migrationResult) => {
|
|
2921
|
-
var _a2;
|
|
2922
|
-
if (currentVersion !== hydrationVersion) {
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
const [migrated, migratedState] = migrationResult;
|
|
2926
|
-
stateFromStorage = options.merge(
|
|
2927
|
-
migratedState,
|
|
2928
|
-
(_a2 = get()) != null ? _a2 : configResult
|
|
2929
|
-
);
|
|
2930
|
-
set(stateFromStorage, true);
|
|
2931
|
-
if (migrated) {
|
|
2932
|
-
return setItem();
|
|
2933
|
-
}
|
|
2934
|
-
}).then(() => {
|
|
2935
|
-
if (currentVersion !== hydrationVersion) {
|
|
2936
|
-
return;
|
|
2937
|
-
}
|
|
2938
|
-
postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);
|
|
2939
|
-
stateFromStorage = get();
|
|
2940
|
-
hasHydrated = true;
|
|
2941
|
-
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
2942
|
-
}).catch((e) => {
|
|
2943
|
-
if (currentVersion !== hydrationVersion) {
|
|
2944
|
-
return;
|
|
2945
|
-
}
|
|
2946
|
-
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
2947
|
-
});
|
|
2948
|
-
};
|
|
2949
|
-
api.persist = {
|
|
2950
|
-
setOptions: (newOptions) => {
|
|
2951
|
-
options = {
|
|
2952
|
-
...options,
|
|
2953
|
-
...newOptions
|
|
2954
|
-
};
|
|
2955
|
-
if (newOptions.storage) {
|
|
2956
|
-
storage = newOptions.storage;
|
|
2957
|
-
}
|
|
2958
|
-
},
|
|
2959
|
-
clearStorage: () => {
|
|
2960
|
-
storage == null ? void 0 : storage.removeItem(options.name);
|
|
2961
|
-
},
|
|
2962
|
-
getOptions: () => options,
|
|
2963
|
-
rehydrate: () => hydrate(),
|
|
2964
|
-
hasHydrated: () => hasHydrated,
|
|
2965
|
-
onHydrate: (cb) => {
|
|
2966
|
-
hydrationListeners.add(cb);
|
|
2967
|
-
return () => {
|
|
2968
|
-
hydrationListeners.delete(cb);
|
|
2969
|
-
};
|
|
2970
|
-
},
|
|
2971
|
-
onFinishHydration: (cb) => {
|
|
2972
|
-
finishHydrationListeners.add(cb);
|
|
2973
|
-
return () => {
|
|
2974
|
-
finishHydrationListeners.delete(cb);
|
|
2975
|
-
};
|
|
2976
|
-
}
|
|
2977
|
-
};
|
|
2978
|
-
if (!options.skipHydration) {
|
|
2979
|
-
hydrate();
|
|
2980
|
-
}
|
|
2981
|
-
return stateFromStorage || configResult;
|
|
2982
|
-
};
|
|
2983
|
-
var persist = persistImpl;
|
|
2984
|
-
|
|
2985
1768
|
// src/core/store/base-task.store.ts
|
|
1769
|
+
import { create } from "zustand";
|
|
1770
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
2986
1771
|
var createTaskStore = (options) => {
|
|
2987
1772
|
const { name, storage, partialize, extend } = options;
|
|
2988
1773
|
const baseState = {
|
|
2989
1774
|
tasks: [],
|
|
2990
1775
|
taskHistory: [],
|
|
2991
1776
|
pendingCount: 0,
|
|
2992
|
-
|
|
1777
|
+
isRunning: false,
|
|
2993
1778
|
taskConfig: {
|
|
2994
1779
|
threads: 1,
|
|
2995
1780
|
delayMin: 1,
|
|
@@ -3003,14 +1788,13 @@ var createTaskStore = (options) => {
|
|
|
3003
1788
|
(set, get) => ({
|
|
3004
1789
|
...baseState,
|
|
3005
1790
|
selectedIds: [],
|
|
3006
|
-
generating: false,
|
|
3007
1791
|
getTasks: () => get().tasks,
|
|
3008
1792
|
setTasks: (tasks) => {
|
|
3009
1793
|
const uniqueTasks = Array.from(new Map(tasks.map((t) => [t.id, t])).values());
|
|
3010
1794
|
set({ tasks: uniqueTasks });
|
|
3011
1795
|
},
|
|
3012
1796
|
setPendingCount: (count) => set({ pendingCount: count }),
|
|
3013
|
-
|
|
1797
|
+
setIsRunning: (running) => set({ isRunning: running }),
|
|
3014
1798
|
addTask: (task) => set((state) => {
|
|
3015
1799
|
if (state.tasks.some((t) => t.id === task.id)) return state;
|
|
3016
1800
|
const now = Date.now();
|
|
@@ -3074,9 +1858,7 @@ var createTaskStore = (options) => {
|
|
|
3074
1858
|
}),
|
|
3075
1859
|
setSelectedIds: (ids) => set({ selectedIds: ids }),
|
|
3076
1860
|
clearSelected: () => set({ selectedIds: [] }),
|
|
3077
|
-
|
|
3078
|
-
getIsPaused: () => get().isPaused,
|
|
3079
|
-
getGenerating: () => get().generating,
|
|
1861
|
+
getIsRunning: () => get().isRunning,
|
|
3080
1862
|
getTaskConfig: () => get().taskConfig,
|
|
3081
1863
|
updateTaskConfig: (updates) => set((state) => ({
|
|
3082
1864
|
taskConfig: { ...state.taskConfig, ...updates }
|
|
@@ -3106,14 +1888,13 @@ var createTaskStore = (options) => {
|
|
|
3106
1888
|
return create()((set, get) => ({
|
|
3107
1889
|
...baseState,
|
|
3108
1890
|
selectedIds: [],
|
|
3109
|
-
generating: false,
|
|
3110
1891
|
getTasks: () => get().tasks,
|
|
3111
1892
|
setTasks: (tasks) => {
|
|
3112
1893
|
const uniqueTasks = Array.from(new Map(tasks.map((t) => [t.id, t])).values());
|
|
3113
1894
|
set({ tasks: uniqueTasks });
|
|
3114
1895
|
},
|
|
3115
1896
|
setPendingCount: (count) => set({ pendingCount: count }),
|
|
3116
|
-
|
|
1897
|
+
setIsRunning: (running) => set({ isRunning: running }),
|
|
3117
1898
|
addTask: (task) => set((state) => {
|
|
3118
1899
|
if (state.tasks.some((t) => t.id === task.id)) return state;
|
|
3119
1900
|
return { tasks: [...state.tasks, task] };
|
|
@@ -3162,9 +1943,7 @@ var createTaskStore = (options) => {
|
|
|
3162
1943
|
}),
|
|
3163
1944
|
setSelectedIds: (ids) => set({ selectedIds: ids }),
|
|
3164
1945
|
clearSelected: () => set({ selectedIds: [] }),
|
|
3165
|
-
|
|
3166
|
-
getIsPaused: () => get().isPaused,
|
|
3167
|
-
getGenerating: () => get().generating,
|
|
1946
|
+
getIsRunning: () => get().isRunning,
|
|
3168
1947
|
updateTaskConfig: (updates) => set((state) => ({
|
|
3169
1948
|
taskConfig: { ...state.taskConfig, ...updates }
|
|
3170
1949
|
})),
|
|
@@ -3173,11 +1952,14 @@ var createTaskStore = (options) => {
|
|
|
3173
1952
|
};
|
|
3174
1953
|
|
|
3175
1954
|
// src/core/hooks/use-queue.ts
|
|
3176
|
-
|
|
1955
|
+
import { useEffect, useCallback, useRef } from "react";
|
|
3177
1956
|
function useQueue(config) {
|
|
3178
1957
|
return function initQueue() {
|
|
3179
|
-
const { keycard, getIdentifier, funcs } = config;
|
|
3180
|
-
const
|
|
1958
|
+
const { keycard, getIdentifier, funcs, debug = false } = config;
|
|
1959
|
+
const debugLog = (...args) => {
|
|
1960
|
+
if (debug) console.log(...args);
|
|
1961
|
+
};
|
|
1962
|
+
const safeSendMessage = useCallback((msg, callback) => {
|
|
3181
1963
|
try {
|
|
3182
1964
|
if (!chrome.runtime?.id) {
|
|
3183
1965
|
console.warn("Extension context invalidated.");
|
|
@@ -3194,13 +1976,14 @@ function useQueue(config) {
|
|
|
3194
1976
|
console.error("Critical messaging error:", e);
|
|
3195
1977
|
}
|
|
3196
1978
|
}, []);
|
|
3197
|
-
const lastInitializedRef =
|
|
1979
|
+
const lastInitializedRef = useRef(void 0);
|
|
3198
1980
|
const identifier = getIdentifier();
|
|
3199
|
-
|
|
1981
|
+
useEffect(() => {
|
|
3200
1982
|
const currentId = identifier || "";
|
|
3201
1983
|
const needsSync = lastInitializedRef.current !== currentId;
|
|
3202
1984
|
if (needsSync) {
|
|
3203
1985
|
lastInitializedRef.current = currentId;
|
|
1986
|
+
debugLog(`[HOOK] SYNC: Initial sync for ${keycard}/${identifier || "default"}`);
|
|
3204
1987
|
safeSendMessage(
|
|
3205
1988
|
{
|
|
3206
1989
|
type: "QUEUE_COMMAND",
|
|
@@ -3210,11 +1993,17 @@ function useQueue(config) {
|
|
|
3210
1993
|
},
|
|
3211
1994
|
(response) => {
|
|
3212
1995
|
if (response) {
|
|
1996
|
+
debugLog(
|
|
1997
|
+
`[HOOK] SYNC: Response for ${keycard}/${identifier || "default"}: ${response.tasks?.length || 0} tasks`
|
|
1998
|
+
);
|
|
3213
1999
|
if (response.tasks && response.tasks.length > 0) {
|
|
3214
2000
|
funcs.setTasks(response.tasks);
|
|
3215
2001
|
} else {
|
|
3216
2002
|
const localTasks = funcs.getTasks();
|
|
3217
2003
|
if (localTasks.length > 0) {
|
|
2004
|
+
debugLog(
|
|
2005
|
+
`[HOOK] SYNC: No tasks in background, syncing ${localTasks.length} local tasks`
|
|
2006
|
+
);
|
|
3218
2007
|
safeSendMessage({
|
|
3219
2008
|
type: "QUEUE_COMMAND",
|
|
3220
2009
|
command: QUEUE_COMMAND.ADD_MANY,
|
|
@@ -3226,7 +2015,7 @@ function useQueue(config) {
|
|
|
3226
2015
|
}
|
|
3227
2016
|
if (response.status) {
|
|
3228
2017
|
funcs.setPendingCount(response.status.size + response.status.pending);
|
|
3229
|
-
funcs.
|
|
2018
|
+
funcs.setIsRunning(response.status.isRunning);
|
|
3230
2019
|
}
|
|
3231
2020
|
}
|
|
3232
2021
|
}
|
|
@@ -3240,20 +2029,26 @@ function useQueue(config) {
|
|
|
3240
2029
|
if (!isPlatformMatch || !isIdentifierMatch) return;
|
|
3241
2030
|
switch (event) {
|
|
3242
2031
|
case "TASKS_UPDATED": {
|
|
3243
|
-
|
|
2032
|
+
debugLog(
|
|
2033
|
+
`[HOOK] EVENT: TASKS_UPDATED for ${keycard}/${identifier || "default"}, count: ${data.tasks?.length || 0}`
|
|
2034
|
+
);
|
|
3244
2035
|
const updates = {};
|
|
3245
2036
|
data.tasks.forEach((t) => {
|
|
3246
2037
|
updates[t.id] = t;
|
|
3247
2038
|
});
|
|
3248
2039
|
funcs.updateTasks(updates);
|
|
3249
2040
|
funcs.setPendingCount(data.status.size + data.status.pending);
|
|
3250
|
-
funcs.
|
|
2041
|
+
funcs.setIsRunning(data.status.isRunning);
|
|
3251
2042
|
break;
|
|
3252
2043
|
}
|
|
3253
2044
|
case "PENDING_COUNT_CHANGED":
|
|
2045
|
+
debugLog(
|
|
2046
|
+
`[HOOK] EVENT: PENDING_COUNT_CHANGED for ${keycard}/${identifier || "default"}: ${data.count}`
|
|
2047
|
+
);
|
|
3254
2048
|
funcs.setPendingCount(data.count);
|
|
3255
2049
|
break;
|
|
3256
2050
|
case "HISTORY_ADDED":
|
|
2051
|
+
debugLog(`[HOOK] EVENT: HISTORY_ADDED for ${keycard}/${identifier || "default"}`);
|
|
3257
2052
|
if (funcs.addHistoryTask) {
|
|
3258
2053
|
funcs.addHistoryTask(data.task);
|
|
3259
2054
|
}
|
|
@@ -3266,7 +2061,7 @@ function useQueue(config) {
|
|
|
3266
2061
|
chrome.runtime.onMessage.removeListener(handleMessage);
|
|
3267
2062
|
};
|
|
3268
2063
|
}, [keycard, identifier, funcs, safeSendMessage]);
|
|
3269
|
-
const sendQueueCommand =
|
|
2064
|
+
const sendQueueCommand = useCallback(
|
|
3270
2065
|
async (command, payload) => {
|
|
3271
2066
|
const identifier2 = getIdentifier();
|
|
3272
2067
|
return new Promise((resolve) => {
|
|
@@ -3284,52 +2079,74 @@ function useQueue(config) {
|
|
|
3284
2079
|
},
|
|
3285
2080
|
[keycard, getIdentifier, safeSendMessage]
|
|
3286
2081
|
);
|
|
3287
|
-
const addTask =
|
|
2082
|
+
const addTask = useCallback(
|
|
3288
2083
|
async (task) => {
|
|
2084
|
+
debugLog(
|
|
2085
|
+
`[HOOK] ADD_TASK ${task.id} (${task.name || "unnamed"}) to ${keycard}/${getIdentifier() || "default"}`
|
|
2086
|
+
);
|
|
3289
2087
|
return sendQueueCommand(QUEUE_COMMAND.ADD, { task });
|
|
3290
2088
|
},
|
|
3291
|
-
[sendQueueCommand, funcs]
|
|
2089
|
+
[sendQueueCommand, funcs, debugLog]
|
|
3292
2090
|
);
|
|
3293
|
-
const start =
|
|
3294
|
-
|
|
2091
|
+
const start = useCallback(async () => {
|
|
2092
|
+
debugLog(`[HOOK] START queue ${keycard}/${getIdentifier() || "default"}`);
|
|
3295
2093
|
return sendQueueCommand(QUEUE_COMMAND.START);
|
|
3296
|
-
}, [sendQueueCommand, funcs]);
|
|
3297
|
-
const stop =
|
|
3298
|
-
|
|
2094
|
+
}, [sendQueueCommand, funcs, debugLog]);
|
|
2095
|
+
const stop = useCallback(async () => {
|
|
2096
|
+
debugLog(`[HOOK] STOP queue ${keycard}/${getIdentifier() || "default"}`);
|
|
3299
2097
|
return sendQueueCommand(QUEUE_COMMAND.STOP);
|
|
3300
|
-
}, [sendQueueCommand, funcs]);
|
|
3301
|
-
const pause =
|
|
2098
|
+
}, [sendQueueCommand, funcs, debugLog]);
|
|
2099
|
+
const pause = useCallback(async () => {
|
|
2100
|
+
debugLog(`[HOOK] PAUSE queue ${keycard}/${getIdentifier() || "default"}`);
|
|
3302
2101
|
return sendQueueCommand(QUEUE_COMMAND.PAUSE);
|
|
3303
|
-
}, [sendQueueCommand]);
|
|
3304
|
-
const resume =
|
|
2102
|
+
}, [sendQueueCommand, debugLog]);
|
|
2103
|
+
const resume = useCallback(async () => {
|
|
2104
|
+
debugLog(`[HOOK] RESUME queue ${keycard}/${getIdentifier() || "default"}`);
|
|
3305
2105
|
return sendQueueCommand(QUEUE_COMMAND.RESUME);
|
|
3306
|
-
}, [sendQueueCommand]);
|
|
3307
|
-
const clear =
|
|
2106
|
+
}, [sendQueueCommand, debugLog]);
|
|
2107
|
+
const clear = useCallback(async () => {
|
|
2108
|
+
debugLog(`[HOOK] CLEAR queue ${keycard}/${getIdentifier() || "default"}`);
|
|
3308
2109
|
return sendQueueCommand(QUEUE_COMMAND.CLEAR);
|
|
3309
|
-
}, [sendQueueCommand]);
|
|
3310
|
-
const getStatus =
|
|
2110
|
+
}, [sendQueueCommand, debugLog]);
|
|
2111
|
+
const getStatus = useCallback(async () => {
|
|
2112
|
+
debugLog(`[HOOK] GET_STATUS from ${keycard}/${getIdentifier() || "default"}`);
|
|
3311
2113
|
return sendQueueCommand(QUEUE_COMMAND.GET_STATUS);
|
|
3312
|
-
}, [sendQueueCommand]);
|
|
3313
|
-
const getTasks =
|
|
2114
|
+
}, [sendQueueCommand, debugLog]);
|
|
2115
|
+
const getTasks = useCallback(async () => {
|
|
2116
|
+
debugLog(`[HOOK] GET_TASKS from ${keycard}/${getIdentifier() || "default"}`);
|
|
3314
2117
|
return sendQueueCommand(QUEUE_COMMAND.GET_TASKS);
|
|
3315
|
-
}, [sendQueueCommand]);
|
|
3316
|
-
const cancelTask =
|
|
2118
|
+
}, [sendQueueCommand, debugLog]);
|
|
2119
|
+
const cancelTask = useCallback(
|
|
3317
2120
|
async (taskId) => {
|
|
2121
|
+
debugLog(`[HOOK] CANCEL_TASK ${taskId} from ${keycard}/${getIdentifier() || "default"}`);
|
|
3318
2122
|
return sendQueueCommand(QUEUE_COMMAND.CANCEL_TASK, { taskId });
|
|
3319
2123
|
},
|
|
3320
|
-
[sendQueueCommand]
|
|
2124
|
+
[sendQueueCommand, debugLog]
|
|
3321
2125
|
);
|
|
3322
|
-
const cancelTasks =
|
|
2126
|
+
const cancelTasks = useCallback(
|
|
3323
2127
|
async (taskIds) => {
|
|
2128
|
+
debugLog(
|
|
2129
|
+
`[HOOK] CANCEL_TASKS ${taskIds.length} tasks from ${keycard}/${getIdentifier() || "default"}`
|
|
2130
|
+
);
|
|
3324
2131
|
return sendQueueCommand(QUEUE_COMMAND.CANCEL_TASKS, { taskIds });
|
|
3325
2132
|
},
|
|
3326
|
-
[sendQueueCommand]
|
|
2133
|
+
[sendQueueCommand, debugLog]
|
|
3327
2134
|
);
|
|
3328
|
-
const setTaskConfig =
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
2135
|
+
const setTaskConfig = useCallback(
|
|
2136
|
+
(taskConfig) => {
|
|
2137
|
+
debugLog(
|
|
2138
|
+
`[HOOK] SET_TASK_CONFIG for ${keycard}/${getIdentifier() || "default"}:`,
|
|
2139
|
+
taskConfig
|
|
2140
|
+
);
|
|
2141
|
+
return sendQueueCommand(QUEUE_COMMAND.SET_TASK_CONFIG, { taskConfig });
|
|
2142
|
+
},
|
|
2143
|
+
[sendQueueCommand, debugLog]
|
|
2144
|
+
);
|
|
2145
|
+
const publishTasks = useCallback(
|
|
3332
2146
|
async (tasks) => {
|
|
2147
|
+
debugLog(
|
|
2148
|
+
`[HOOK] PUBLISH_TASKS ${tasks.length} tasks to ${keycard}/${getIdentifier() || "default"}`
|
|
2149
|
+
);
|
|
3333
2150
|
await sendQueueCommand(QUEUE_COMMAND.ADD_MANY, {
|
|
3334
2151
|
tasks: tasks.map((t) => ({
|
|
3335
2152
|
...t,
|
|
@@ -3338,32 +2155,41 @@ function useQueue(config) {
|
|
|
3338
2155
|
}))
|
|
3339
2156
|
});
|
|
3340
2157
|
},
|
|
3341
|
-
[funcs, sendQueueCommand]
|
|
2158
|
+
[funcs, sendQueueCommand, debugLog]
|
|
3342
2159
|
);
|
|
3343
|
-
const deleteTasks =
|
|
2160
|
+
const deleteTasks = useCallback(
|
|
3344
2161
|
async (taskIds) => {
|
|
3345
2162
|
if (taskIds.length === 0) return;
|
|
2163
|
+
debugLog(
|
|
2164
|
+
`[HOOK] DELETE_TASKS ${taskIds.length} tasks from ${keycard}/${getIdentifier() || "default"}`
|
|
2165
|
+
);
|
|
3346
2166
|
await sendQueueCommand(QUEUE_COMMAND.CANCEL_TASKS, { taskIds });
|
|
3347
2167
|
funcs.deleteTasks(taskIds);
|
|
3348
2168
|
},
|
|
3349
|
-
[funcs, sendQueueCommand]
|
|
2169
|
+
[funcs, sendQueueCommand, debugLog]
|
|
3350
2170
|
);
|
|
3351
|
-
const skipTaskIds =
|
|
2171
|
+
const skipTaskIds = useCallback(
|
|
3352
2172
|
async (taskIds) => {
|
|
3353
2173
|
if (taskIds.length === 0) return;
|
|
2174
|
+
debugLog(
|
|
2175
|
+
`[HOOK] SKIP_TASKS ${taskIds.length} tasks in ${keycard}/${getIdentifier() || "default"}`
|
|
2176
|
+
);
|
|
3354
2177
|
await sendQueueCommand("CANCEL_TASKS", { taskIds });
|
|
3355
2178
|
const updates = {};
|
|
3356
2179
|
taskIds.forEach((id) => {
|
|
3357
|
-
updates[id] = { status: "Skipped", isQueued: false
|
|
2180
|
+
updates[id] = { status: "Skipped", isQueued: false };
|
|
3358
2181
|
});
|
|
3359
2182
|
funcs.updateTasks(updates);
|
|
3360
2183
|
},
|
|
3361
|
-
[funcs, sendQueueCommand]
|
|
2184
|
+
[funcs, sendQueueCommand, debugLog]
|
|
3362
2185
|
);
|
|
3363
|
-
const retryTasks =
|
|
2186
|
+
const retryTasks = useCallback(
|
|
3364
2187
|
async (taskIds) => {
|
|
3365
2188
|
const tasks = funcs.getTasks().filter((t) => taskIds.includes(t.id));
|
|
3366
2189
|
if (tasks.length === 0) return;
|
|
2190
|
+
debugLog(
|
|
2191
|
+
`[HOOK] RETRY_TASKS ${taskIds.length} tasks in ${keycard}/${getIdentifier() || "default"}`
|
|
2192
|
+
);
|
|
3367
2193
|
tasks.forEach((task) => {
|
|
3368
2194
|
funcs.updateTask(task.id, {
|
|
3369
2195
|
status: "Waiting",
|
|
@@ -3380,7 +2206,7 @@ function useQueue(config) {
|
|
|
3380
2206
|
}))
|
|
3381
2207
|
});
|
|
3382
2208
|
},
|
|
3383
|
-
[funcs, sendQueueCommand]
|
|
2209
|
+
[funcs, sendQueueCommand, debugLog]
|
|
3384
2210
|
);
|
|
3385
2211
|
return {
|
|
3386
2212
|
addTask,
|
|
@@ -3409,24 +2235,116 @@ function registerAllEngines(platformEngines, queueManager) {
|
|
|
3409
2235
|
});
|
|
3410
2236
|
}
|
|
3411
2237
|
|
|
3412
|
-
// src/core/bootstrap.ts
|
|
3413
|
-
var
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
2238
|
+
// src/core/bootstrap/broadcast.ts
|
|
2239
|
+
var broadcast = (message) => {
|
|
2240
|
+
chrome.runtime.sendMessage(message).catch(() => {
|
|
2241
|
+
});
|
|
2242
|
+
};
|
|
2243
|
+
var createBroadcast = () => broadcast;
|
|
2244
|
+
|
|
2245
|
+
// src/core/bootstrap/heartbeat.ts
|
|
2246
|
+
var handleHeartbeat = (count) => {
|
|
2247
|
+
if (count > 0) {
|
|
2248
|
+
chrome.alarms.create("heartbeat", { periodInMinutes: 0.5 });
|
|
2249
|
+
} else {
|
|
2250
|
+
chrome.alarms.clear("heartbeat");
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
var createHeartbeatHandler = () => handleHeartbeat;
|
|
2254
|
+
|
|
2255
|
+
// src/core/bootstrap/command-handler.ts
|
|
2256
|
+
var createCommandHandler = ({ queueManager, debug, debugLog }) => {
|
|
2257
|
+
return async (message) => {
|
|
2258
|
+
const { command, keycard, identifier = "", payload } = message;
|
|
2259
|
+
const handleAsyncCommand = async (promise) => {
|
|
2260
|
+
await promise;
|
|
2261
|
+
return { success: true };
|
|
2262
|
+
};
|
|
2263
|
+
switch (command) {
|
|
2264
|
+
case QUEUE_COMMAND.SYNC:
|
|
2265
|
+
debugLog(`[BOOTSTRAP] SYNC from ${keycard}/${identifier || "default"}`);
|
|
2266
|
+
return {
|
|
2267
|
+
tasks: queueManager.getTasks(keycard, identifier),
|
|
2268
|
+
status: queueManager.getStatus(keycard, identifier)
|
|
2269
|
+
};
|
|
2270
|
+
case QUEUE_COMMAND.CANCEL_TASK:
|
|
2271
|
+
debugLog(
|
|
2272
|
+
`[BOOTSTRAP] CANCEL_TASK ${payload.taskId} from ${keycard}/${identifier || "default"}`
|
|
2273
|
+
);
|
|
2274
|
+
handleAsyncCommand(queueManager.cancelTask(keycard, identifier, payload.taskId || ""));
|
|
2275
|
+
return { async: true };
|
|
2276
|
+
case QUEUE_COMMAND.CANCEL_TASKS:
|
|
2277
|
+
debugLog(
|
|
2278
|
+
`[BOOTSTRAP] CANCEL_TASKS ${payload.taskIds?.length} tasks from ${keycard}/${identifier || "default"}`
|
|
2279
|
+
);
|
|
2280
|
+
handleAsyncCommand(
|
|
2281
|
+
Promise.all(
|
|
2282
|
+
(payload.taskIds || []).map(
|
|
2283
|
+
(id) => queueManager.cancelTask(keycard, identifier, id)
|
|
2284
|
+
)
|
|
2285
|
+
)
|
|
2286
|
+
);
|
|
2287
|
+
return { async: true };
|
|
2288
|
+
case QUEUE_COMMAND.ADD:
|
|
2289
|
+
debugLog(
|
|
2290
|
+
`[BOOTSTRAP] ADD task ${payload.task?.id} to ${keycard}/${identifier || "default"}`
|
|
2291
|
+
);
|
|
2292
|
+
handleAsyncCommand(queueManager.add(keycard, identifier, payload.task));
|
|
2293
|
+
return { async: true };
|
|
2294
|
+
case QUEUE_COMMAND.ADD_MANY:
|
|
2295
|
+
debugLog(
|
|
2296
|
+
`[BOOTSTRAP] ADD_MANY ${payload.tasks?.length} tasks to ${keycard}/${identifier || "default"}`
|
|
2297
|
+
);
|
|
2298
|
+
handleAsyncCommand(queueManager.addMany(keycard, identifier, payload.tasks || []));
|
|
2299
|
+
return { async: true };
|
|
2300
|
+
case QUEUE_COMMAND.START:
|
|
2301
|
+
debugLog(`[BOOTSTRAP] START queue ${keycard}/${identifier || "default"}`);
|
|
2302
|
+
handleAsyncCommand(queueManager.start(keycard, identifier));
|
|
2303
|
+
return { async: true };
|
|
2304
|
+
case QUEUE_COMMAND.STOP:
|
|
2305
|
+
debugLog(`[BOOTSTRAP] STOP queue ${keycard}/${identifier || "default"}`);
|
|
2306
|
+
handleAsyncCommand(queueManager.stop(keycard, identifier));
|
|
2307
|
+
return { async: true };
|
|
2308
|
+
case QUEUE_COMMAND.PAUSE:
|
|
2309
|
+
debugLog(`[BOOTSTRAP] PAUSE queue ${keycard}/${identifier || "default"}`);
|
|
2310
|
+
handleAsyncCommand(queueManager.pause(keycard, identifier));
|
|
2311
|
+
return { async: true };
|
|
2312
|
+
case QUEUE_COMMAND.RESUME:
|
|
2313
|
+
debugLog(`[BOOTSTRAP] RESUME queue ${keycard}/${identifier || "default"}`);
|
|
2314
|
+
handleAsyncCommand(queueManager.resume(keycard, identifier));
|
|
2315
|
+
return { async: true };
|
|
2316
|
+
case QUEUE_COMMAND.CLEAR:
|
|
2317
|
+
debugLog(`[BOOTSTRAP] CLEAR queue ${keycard}/${identifier || "default"}`);
|
|
2318
|
+
handleAsyncCommand(queueManager.clear(keycard, identifier));
|
|
2319
|
+
return { async: true };
|
|
2320
|
+
case QUEUE_COMMAND.GET_STATUS:
|
|
2321
|
+
debugLog(`[BOOTSTRAP] GET_STATUS from ${keycard}/${identifier || "default"}`);
|
|
2322
|
+
return queueManager.getStatus(keycard, identifier);
|
|
2323
|
+
case QUEUE_COMMAND.GET_TASKS:
|
|
2324
|
+
debugLog(`[BOOTSTRAP] GET_TASKS from ${keycard}/${identifier || "default"}`);
|
|
2325
|
+
return { tasks: queueManager.getTasks(keycard, identifier) };
|
|
2326
|
+
case QUEUE_COMMAND.SET_TASK_CONFIG:
|
|
2327
|
+
queueManager.updateTaskConfig(keycard, identifier, payload.taskConfig);
|
|
2328
|
+
return { success: true };
|
|
2329
|
+
default:
|
|
2330
|
+
debugLog(`[Queue] Unknown command: ${command}`);
|
|
2331
|
+
return null;
|
|
3425
2332
|
}
|
|
3426
2333
|
};
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
// src/core/bootstrap/message-handler.ts
|
|
2337
|
+
var createMessageHandler = ({
|
|
2338
|
+
queueManager,
|
|
2339
|
+
debug,
|
|
2340
|
+
debugLog,
|
|
2341
|
+
broadcast: broadcast2,
|
|
2342
|
+
handleHeartbeat: handleHeartbeat2
|
|
2343
|
+
}) => {
|
|
2344
|
+
const commandHandler = createCommandHandler({ queueManager, debug, debugLog });
|
|
3427
2345
|
queueManager.registerOptions("*", {
|
|
3428
2346
|
onTasksUpdate: (keycard, identifier, tasks, status) => {
|
|
3429
|
-
|
|
2347
|
+
broadcast2({
|
|
3430
2348
|
type: "QUEUE_EVENT",
|
|
3431
2349
|
event: "TASKS_UPDATED",
|
|
3432
2350
|
keycard,
|
|
@@ -3437,7 +2355,7 @@ var setupBackgroundEngine = (engines) => {
|
|
|
3437
2355
|
onTaskComplete: (keycard, identifier, _, result) => {
|
|
3438
2356
|
const isCancelled = result.error === "CANCELLED" || result.error === "AbortError";
|
|
3439
2357
|
if (!isCancelled) {
|
|
3440
|
-
|
|
2358
|
+
broadcast2({
|
|
3441
2359
|
type: "QUEUE_EVENT",
|
|
3442
2360
|
event: "HISTORY_ADDED",
|
|
3443
2361
|
keycard,
|
|
@@ -3447,98 +2365,67 @@ var setupBackgroundEngine = (engines) => {
|
|
|
3447
2365
|
}
|
|
3448
2366
|
},
|
|
3449
2367
|
onPendingCountChange: (keycard, identifier, count) => {
|
|
3450
|
-
|
|
2368
|
+
broadcast2({
|
|
3451
2369
|
type: "QUEUE_EVENT",
|
|
3452
2370
|
event: "PENDING_COUNT_CHANGED",
|
|
3453
2371
|
keycard,
|
|
3454
2372
|
identifier,
|
|
3455
2373
|
data: { count }
|
|
3456
2374
|
});
|
|
3457
|
-
|
|
2375
|
+
handleHeartbeat2(count);
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
return (message, _sender, sendResponse) => {
|
|
2379
|
+
if (message.type === "QUEUE_COMMAND") {
|
|
2380
|
+
const result = commandHandler(message);
|
|
2381
|
+
if (result && "async" in result) {
|
|
2382
|
+
return true;
|
|
2383
|
+
}
|
|
2384
|
+
if (result) {
|
|
2385
|
+
sendResponse(result);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
if (message.type === "PING") {
|
|
2389
|
+
sendResponse({ payload: "PONG from background" });
|
|
3458
2390
|
}
|
|
2391
|
+
};
|
|
2392
|
+
};
|
|
2393
|
+
|
|
2394
|
+
// src/core/bootstrap/index.ts
|
|
2395
|
+
var setupBackgroundEngine = (engines, options = {}) => {
|
|
2396
|
+
const { debug = false, storageKey } = options;
|
|
2397
|
+
const queueManager = getQueueManager({ debug, storageKey });
|
|
2398
|
+
registerAllEngines(engines, queueManager);
|
|
2399
|
+
const debugLog = (...args) => {
|
|
2400
|
+
if (debug) console.log(...args);
|
|
2401
|
+
};
|
|
2402
|
+
const broadcast2 = createBroadcast();
|
|
2403
|
+
const handleHeartbeat2 = createHeartbeatHandler();
|
|
2404
|
+
const messageHandler = createMessageHandler({
|
|
2405
|
+
queueManager,
|
|
2406
|
+
debug,
|
|
2407
|
+
debugLog,
|
|
2408
|
+
broadcast: broadcast2,
|
|
2409
|
+
handleHeartbeat: handleHeartbeat2
|
|
3459
2410
|
});
|
|
3460
2411
|
const bootstrap = async () => {
|
|
3461
2412
|
try {
|
|
3462
|
-
|
|
2413
|
+
debugLog("\u{1F680} Bootstrapping Background Queue Manager...");
|
|
3463
2414
|
await queueManager.hydrate();
|
|
3464
2415
|
await queueManager.rehydrateTasks();
|
|
3465
|
-
|
|
2416
|
+
debugLog("\u2705 Background Queue Manager Ready.");
|
|
3466
2417
|
} catch (error) {
|
|
3467
2418
|
console.error("\u274C Bootstrap failed:", error);
|
|
3468
2419
|
}
|
|
3469
2420
|
};
|
|
3470
|
-
chrome.runtime.onMessage.addListener(
|
|
3471
|
-
if (message.type === "QUEUE_COMMAND") {
|
|
3472
|
-
const { command, keycard, identifier, payload } = message;
|
|
3473
|
-
const handleAsyncCommand = async (promise) => {
|
|
3474
|
-
await promise;
|
|
3475
|
-
sendResponse({ success: true });
|
|
3476
|
-
};
|
|
3477
|
-
switch (command) {
|
|
3478
|
-
case QUEUE_COMMAND.SYNC:
|
|
3479
|
-
sendResponse({
|
|
3480
|
-
tasks: queueManager.getTasks(keycard, identifier),
|
|
3481
|
-
status: queueManager.getStatus(keycard, identifier)
|
|
3482
|
-
});
|
|
3483
|
-
break;
|
|
3484
|
-
case QUEUE_COMMAND.CANCEL_TASK:
|
|
3485
|
-
handleAsyncCommand(queueManager.cancelTask(keycard, identifier, payload.taskId));
|
|
3486
|
-
return true;
|
|
3487
|
-
// Keep connection to send response later
|
|
3488
|
-
case QUEUE_COMMAND.CANCEL_TASKS:
|
|
3489
|
-
handleAsyncCommand(
|
|
3490
|
-
Promise.all(
|
|
3491
|
-
payload.taskIds.map((id) => queueManager.cancelTask(keycard, identifier, id))
|
|
3492
|
-
)
|
|
3493
|
-
);
|
|
3494
|
-
return true;
|
|
3495
|
-
case QUEUE_COMMAND.ADD:
|
|
3496
|
-
handleAsyncCommand(queueManager.add(keycard, identifier, payload.task));
|
|
3497
|
-
return true;
|
|
3498
|
-
case QUEUE_COMMAND.ADD_MANY:
|
|
3499
|
-
handleAsyncCommand(queueManager.addMany(keycard, identifier, payload.tasks));
|
|
3500
|
-
return true;
|
|
3501
|
-
case QUEUE_COMMAND.START:
|
|
3502
|
-
handleAsyncCommand(queueManager.start(keycard, identifier));
|
|
3503
|
-
return true;
|
|
3504
|
-
case QUEUE_COMMAND.STOP:
|
|
3505
|
-
handleAsyncCommand(queueManager.stop(keycard, identifier));
|
|
3506
|
-
return true;
|
|
3507
|
-
case QUEUE_COMMAND.PAUSE:
|
|
3508
|
-
handleAsyncCommand(queueManager.pause(keycard, identifier));
|
|
3509
|
-
return true;
|
|
3510
|
-
case QUEUE_COMMAND.RESUME:
|
|
3511
|
-
handleAsyncCommand(queueManager.resume(keycard, identifier));
|
|
3512
|
-
return true;
|
|
3513
|
-
case QUEUE_COMMAND.CLEAR:
|
|
3514
|
-
handleAsyncCommand(queueManager.clear(keycard, identifier));
|
|
3515
|
-
return true;
|
|
3516
|
-
case QUEUE_COMMAND.GET_STATUS:
|
|
3517
|
-
sendResponse(queueManager.getStatus(keycard, identifier));
|
|
3518
|
-
break;
|
|
3519
|
-
case QUEUE_COMMAND.GET_TASKS:
|
|
3520
|
-
sendResponse({ tasks: queueManager.getTasks(keycard, identifier) });
|
|
3521
|
-
break;
|
|
3522
|
-
case QUEUE_COMMAND.SET_TASK_CONFIG:
|
|
3523
|
-
queueManager.updateTaskConfig(keycard, identifier, payload.taskConfig);
|
|
3524
|
-
sendResponse({ success: true });
|
|
3525
|
-
break;
|
|
3526
|
-
default:
|
|
3527
|
-
console.warn(`[Queue] Unknown command: ${command}`);
|
|
3528
|
-
break;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
if (message.type === "PING") {
|
|
3532
|
-
sendResponse({ payload: "PONG from background" });
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
2421
|
+
chrome.runtime.onMessage.addListener(messageHandler);
|
|
3535
2422
|
chrome.alarms.onAlarm.addListener((alarm) => {
|
|
3536
2423
|
if (alarm.name === "heartbeat") {
|
|
3537
|
-
|
|
2424
|
+
debugLog("Service Worker Heartbeat...");
|
|
3538
2425
|
}
|
|
3539
2426
|
});
|
|
3540
2427
|
chrome.runtime.onInstalled.addListener(() => {
|
|
3541
|
-
|
|
2428
|
+
debugLog("Auto Script Extension Installed");
|
|
3542
2429
|
});
|
|
3543
2430
|
chrome.commands.onCommand.addListener((command) => {
|
|
3544
2431
|
if (command === "open-popup") {
|
|
@@ -3548,28 +2435,14 @@ var setupBackgroundEngine = (engines) => {
|
|
|
3548
2435
|
bootstrap();
|
|
3549
2436
|
};
|
|
3550
2437
|
export {
|
|
2438
|
+
PersistenceManager,
|
|
3551
2439
|
QUEUE_COMMAND,
|
|
3552
|
-
QueueManager,
|
|
3553
2440
|
TaskContext,
|
|
3554
2441
|
createTaskStore,
|
|
3555
2442
|
engineHub,
|
|
3556
2443
|
getQueueManager,
|
|
3557
|
-
persistenceManager,
|
|
3558
2444
|
registerAllEngines,
|
|
3559
2445
|
setupBackgroundEngine,
|
|
3560
2446
|
sleep,
|
|
3561
2447
|
useQueue
|
|
3562
2448
|
};
|
|
3563
|
-
/*! Bundled license information:
|
|
3564
|
-
|
|
3565
|
-
react/cjs/react.development.js:
|
|
3566
|
-
(**
|
|
3567
|
-
* @license React
|
|
3568
|
-
* react.development.js
|
|
3569
|
-
*
|
|
3570
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3571
|
-
*
|
|
3572
|
-
* This source code is licensed under the MIT license found in the
|
|
3573
|
-
* LICENSE file in the root directory of this source tree.
|
|
3574
|
-
*)
|
|
3575
|
-
*/
|