@vue-skuilder/standalone-ui 0.1.38 → 0.1.39

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.
@@ -31690,7 +31690,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31690
31690
  return this.newQ.toString + "\n" + this.reviewQ.toString + "\n" + this.failedQ.toString;
31691
31691
  }
31692
31692
  constructor(t, c, u, d, m, g) {
31693
- super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "_initialReviewCap", 200), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "reviewQ", new ItemQueue()), _defineProperty$2(this, "newQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_depletionReplanAttempted", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.initialReviewCap !== void 0 && (this._initialReviewCap = g.initialReviewCap), this.log(`Session constructed:
31693
+ super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "_initialReviewCap", 200), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "reviewQ", new ItemQueue()), _defineProperty$2(this, "newQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.initialReviewCap !== void 0 && (this._initialReviewCap = g.initialReviewCap), this.log(`Session constructed:
31694
31694
  startTime: ${this.startTime}
31695
31695
  endTime: ${this.endTime}
31696
31696
  defaultBatchLimit: ${this._defaultBatchLimit}
@@ -31723,9 +31723,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31723
31723
  }, 1e3);
31724
31724
  }
31725
31725
  async requestReplan(t) {
31726
- let c = this.normalizeReplanOptions(t);
31727
- (c.hints || c.label || c.limit) && (this._depletionReplanAttempted = !1);
31728
- let u = this._replanHasIntent(c);
31726
+ let c = this.normalizeReplanOptions(t), u = this._replanHasIntent(c);
31729
31727
  if (this._replanPromise) {
31730
31728
  if (!u) return this.log("Replan already in progress, coalescing unhinted auto-replan"), this._replanPromise;
31731
31729
  let t = c.label ? ` [${c.label}]` : "";
@@ -31758,6 +31756,12 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31758
31756
  let d = t.label ? ` [${t.label}]` : "";
31759
31757
  this.log(`Mid-session replan requested${d} (limit: ${t.limit ?? "default"}, mode: ${t.mode ?? "replace"}${t.hints ? ", with hints" : ""})`), t.minFollowUpCards !== void 0 && t.minFollowUpCards > 0 && (this._minCardsGuarantee = Math.max(this._minCardsGuarantee, t.minFollowUpCards), this.log(`[Replan] Card guarantee set to ${this._minCardsGuarantee}`)), await this._executeReplan(t);
31760
31758
  }
31759
+ async _replanUncoalesced(t) {
31760
+ let c = this._runReplan(t);
31761
+ this._replanPromise = c.finally(() => {
31762
+ this._replanPromise === c && (this._replanPromise = null);
31763
+ }), await c;
31764
+ }
31761
31765
  normalizeReplanOptions(t) {
31762
31766
  if (!t) return {};
31763
31767
  let c = [
@@ -31775,7 +31779,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31775
31779
  additive: u === "merge",
31776
31780
  limit: c
31777
31781
  });
31778
- this._wellIndicatedRemaining = d, c !== void 0 && c < this._defaultBatchLimit ? (this._suppressQualityReplan = !0, this.log(`[Replan] Burst mode (limit=${c}): suppressing quality-based auto-replan`)) : this._suppressQualityReplan = !1, d >= 0 && d < _SessionController.MIN_WELL_INDICATED && this.log(`[Replan] Only ${d}/${_SessionController.MIN_WELL_INDICATED} well-indicated cards after replan`), this.newQ.length > 0 && (this._depletionReplanAttempted = !1), await this.hydrationService.ensureHydratedCards();
31782
+ this._wellIndicatedRemaining = d, c !== void 0 && c < this._defaultBatchLimit ? (this._suppressQualityReplan = !0, this.log(`[Replan] Burst mode (limit=${c}): suppressing quality-based auto-replan`)) : this._suppressQualityReplan = !1, d >= 0 && d < _SessionController.MIN_WELL_INDICATED && this.log(`[Replan] Only ${d}/${_SessionController.MIN_WELL_INDICATED} well-indicated cards after replan`), await this.hydrationService.ensureHydratedCards();
31779
31783
  let m = t.label ? ` [${t.label}]` : "";
31780
31784
  this.log(`Replan complete${m}: newQ now has ${this.newQ.length} cards (mode=${u})`), snapshotQueues(this.reviewQ.length, this.newQ.length, this.failedQ.length);
31781
31785
  }
@@ -31914,13 +31918,21 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31914
31918
  return this._secondsRemaining - (d + m) > 20 ? (c = .5, u = .9) : this._secondsRemaining - d > 20 ? (c = .05, u = .9) : (c = .01, u = .1), this.failedQ.length === 0 && (u = 1), this.reviewQ.length === 0 && (c = u), t < c && this.newQ.length ? this.newQ.peek(0) : t < u && this.reviewQ.length ? this.reviewQ.peek(0) : this.failedQ.length ? this.failedQ.peek(0) : (this.log("No more cards available for the session!"), null);
31915
31919
  }
31916
31920
  async nextCard(t = "dismiss-success") {
31917
- if (this.dismissCurrentCard(t), this._minCardsGuarantee > 0 && (this._minCardsGuarantee--, this.log(`[CardGuarantee] ${this._minCardsGuarantee} guaranteed cards remaining`)), this._replanPromise && (this.log("nextCard: awaiting in-flight replan before drawing"), await this._replanPromise), this.newQ.length <= 1 && this._secondsRemaining > 0 && !this._replanPromise && !this._depletionReplanAttempted) {
31918
- this._suppressQualityReplan = !1, this._depletionReplanAttempted = !0;
31921
+ if (this.dismissCurrentCard(t), this._minCardsGuarantee > 0 && (this._minCardsGuarantee--, this.log(`[CardGuarantee] ${this._minCardsGuarantee} guaranteed cards remaining`)), this._replanPromise && (this.log("nextCard: awaiting in-flight replan before drawing"), await this._replanPromise), this.newQ.length <= 1 && this._secondsRemaining > 0 && !this._replanPromise) {
31922
+ this._suppressQualityReplan = !1;
31919
31923
  let t = this.reviewQ.length + this.failedQ.length;
31920
- this.newQ.length === 0 && t === 0 ? (this.log(`[AutoReplan:depletion] All queues empty with ${this._secondsRemaining}s remaining. Awaiting replan.`), await this.requestReplan()) : (this.log(`[AutoReplan:depletion] newQ has ${this.newQ.length} card(s) (${t} in other queues) with ${this._secondsRemaining}s remaining. Triggering background replan.`), this.requestReplan());
31924
+ this.log(`[AutoReplan:depletion] newQ has ${this.newQ.length} card(s) (${t} in other queues) with ${this._secondsRemaining}s remaining. Triggering background replan.`), this.requestReplan();
31921
31925
  }
31922
31926
  if (!this._suppressQualityReplan && this._wellIndicatedRemaining <= 3 && this.newQ.length > 0 && !this._replanPromise && (this.log(`[AutoReplan:quality] ${this._wellIndicatedRemaining} well-indicated cards remaining (newQ: ${this.newQ.length}). Triggering background replan.`), this.requestReplan()), this._secondsRemaining <= 0 && this.failedQ.length === 0 && this._minCardsGuarantee <= 0) return this._currentCard = null, endSessionTracking(), null;
31923
- let c = 20;
31927
+ let c = 3, u = 250, d = 0;
31928
+ for (; this._secondsRemaining > 0 && this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0;) if (this.log(`[WedgeBreaker] All queues empty with ${this._secondsRemaining}s remaining. Running pipeline (attempt ${d + 1}/3).`), await this._replanUncoalesced({ label: "wedge-breaker" }), this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0) {
31929
+ if (d++, d >= 3) {
31930
+ this.log("[WedgeBreaker] Pipeline returned no content 3 consecutive times. Giving up; session will end.");
31931
+ break;
31932
+ }
31933
+ await new Promise((t) => setTimeout(t, 250));
31934
+ } else d = 0;
31935
+ let m = 20;
31924
31936
  for (let t = 0; t < 20; t++) {
31925
31937
  let t = this._selectNextItemToHydrate();
31926
31938
  if (!t) return this._currentCard = null, endSessionTracking(), null;